:root {
  color-scheme: light;
  --paper: #f2f4f1;
  --white: #ffffff;
  --ink: #171c1b;
  --muted: #66716e;
  --line: #d7ddda;
  --teal: #0f766e;
  --teal-dark: #0a5751;
  --teal-soft: #dcefeb;
  --coral: #d85e4b;
  --charcoal: #222827;
  --danger: #b42318;
  --success: #217a57;
  --warning: #a65a24;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--teal) 35%, transparent);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.login-view {
  min-height: 100svh;
  display: grid;
  align-content: center;
  gap: 40px;
  width: min(100% - 40px, 440px);
  margin: 0 auto;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-lockup h1,
.brand-lockup p {
  margin: 0;
}

.brand-lockup h1 {
  font-size: 32px;
  line-height: 1;
  font-weight: 760;
}

.brand-lockup p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 15px;
}

.brand-lockup.compact h1 {
  font-size: 21px;
}

.brand-lockup.compact p {
  margin-top: 3px;
  font-size: 12px;
}

.login-form {
  display: grid;
  gap: 12px;
}

.login-form label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.login-form input,
.login-form button {
  width: 100%;
  height: 52px;
  border-radius: 6px;
}

.login-form input {
  padding: 0 14px;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--ink);
}

.login-form button {
  border: 0;
  background: var(--charcoal);
  color: var(--white);
  font-weight: 720;
}

.form-error {
  min-height: 20px;
  margin: 2px 0 0;
  color: var(--danger);
  font-size: 13px;
}

.voice-view {
  height: 100svh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.app-header {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(14px, env(safe-area-inset-top)) 20px 12px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  z-index: 10;
  backdrop-filter: blur(14px);
}

.header-actions,
.section-actions {
  display: flex;
  gap: 5px;
}

.icon-button {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
}

.icon-button:hover:not(:disabled) {
  border-color: var(--line);
  background: var(--white);
}

.icon-button:disabled {
  opacity: 0.35;
  cursor: default;
}

.icon-button svg {
  width: 19px;
  height: 19px;
}

.app-content {
  min-height: 0;
  overflow: hidden;
}

.app-screen {
  height: 100%;
}

.dialogue-screen {
  background: var(--white);
}

.voice-stage {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto auto minmax(110px, 1fr) auto auto;
  align-items: center;
  justify-items: center;
  gap: 13px;
  padding: 24px 20px 22px;
  overflow: hidden;
}

.live-pill {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 15px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.live-pill span,
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.live-pill span {
  background: var(--teal);
}

.voice-presence {
  width: min(100%, 520px);
  display: grid;
  grid-template-columns: minmax(40px, 1fr) auto minmax(40px, 1fr);
  align-items: center;
  gap: 20px;
}

.voice-presence img {
  width: 88px;
  height: 88px;
  filter: drop-shadow(0 12px 18px rgba(15, 118, 110, 0.14));
  animation: presence-breathe 3.2s ease-in-out infinite;
}

.presence-line {
  height: 2px;
  background: var(--teal);
  opacity: 0.42;
  transform-origin: right center;
  animation: presence-line 2.4s ease-in-out infinite;
}

.presence-line-right {
  transform-origin: left center;
  animation-delay: 260ms;
}

.status-line {
  min-height: 24px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 620;
}

.status-dot {
  background: #9aa39f;
}

.status-dot.listening {
  background: var(--teal);
}

.status-dot.thinking {
  background: var(--coral);
  animation: pulse 1.2s ease-in-out infinite;
}

.status-dot.speaking {
  background: var(--teal-dark);
  animation: pulse 0.8s ease-in-out infinite;
}

.audio-alert {
  border-color: var(--coral);
  color: var(--coral);
  animation: pulse 1.1s ease-in-out infinite;
}

#waveform {
  width: min(100%, 960px);
  height: 100%;
  min-height: 110px;
  max-height: 220px;
  display: block;
}

.voice-button {
  min-width: 196px;
  height: 54px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 22px;
  border: 0;
  border-radius: 6px;
  background: var(--teal);
  color: var(--white);
  font-weight: 750;
  box-shadow: 0 9px 22px rgba(15, 118, 110, 0.18);
  transition: transform 140ms ease, background 140ms ease;
}

.voice-button:hover {
  background: var(--teal-dark);
}

.voice-button:active {
  transform: translateY(1px);
}

.voice-button.connected {
  background: var(--charcoal);
}

.voice-button svg {
  width: 20px;
  height: 20px;
}

.session-timer {
  min-height: 18px;
  margin: 0;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}

.content-screen {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 28px 24px 48px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.section-heading h2,
.section-kicker {
  margin: 0;
}

.section-heading h2 {
  margin-top: 4px;
  font-size: 22px;
  line-height: 1.2;
}

.section-kicker {
  color: var(--teal);
  font-size: 11px;
  font-weight: 760;
  text-transform: uppercase;
}

.conversation,
.activity-list {
  display: grid;
}

.turn {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 16px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.turn-role {
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
  text-transform: uppercase;
}

.turn-text {
  margin: 0;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.turn.tool {
  padding-left: 14px;
  border-left: 3px solid var(--coral);
}

.turn.tool .turn-role {
  color: var(--coral);
}

.activity-list {
  gap: 14px;
  padding-top: 18px;
}

.activity-item {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.activity-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.activity-title {
  margin: 0;
  font-size: 15px;
  line-height: 1.4;
}

.activity-time {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.status-badge {
  flex: 0 0 auto;
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  padding: 0 9px;
  border-radius: 13px;
  background: #edf0ee;
  color: var(--muted);
  font-size: 11px;
  font-weight: 740;
}

.status-badge.completed {
  background: #e2f2e9;
  color: var(--success);
}

.status-badge.running,
.status-badge.queued {
  background: #fff0e5;
  color: var(--warning);
}

.status-badge.failed {
  background: #fde8e6;
  color: var(--danger);
}

.activity-result {
  margin: 16px 0 0;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.artifact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.artifact-item {
  min-width: 0;
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
}

.artifact-preview {
  width: 100%;
  max-height: 360px;
  display: block;
  object-fit: contain;
  border-radius: 4px;
  background: var(--white);
}

.artifact-link {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 680;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.artifact-link:hover {
  text-decoration: underline;
}

.artifact-link svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}

.empty-state {
  margin: 30px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.app-nav {
  min-height: calc(68px + var(--safe-bottom));
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 7px max(12px, calc((100% - 600px) / 2)) var(--safe-bottom);
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 96%, transparent);
  backdrop-filter: blur(16px);
  z-index: 10;
}

.nav-button {
  min-width: 0;
  min-height: 54px;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 4px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 680;
}

.nav-button.active {
  color: var(--teal-dark);
}

.nav-button svg {
  width: 21px;
  height: 21px;
}

.nav-icon-wrap {
  position: relative;
  display: inline-grid;
}

.nav-badge {
  min-width: 17px;
  height: 17px;
  display: inline-grid;
  place-items: center;
  padding: 0 4px;
  border: 2px solid var(--paper);
  border-radius: 9px;
  background: var(--coral);
  color: var(--white);
  position: absolute;
  top: -7px;
  right: -10px;
  font-size: 9px;
  font-weight: 800;
}

#remoteAudio {
  position: fixed;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

@keyframes pulse {
  0%, 100% { opacity: 0.55; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.15); }
}

@keyframes presence-breathe {
  0%, 100% { transform: translateY(0); opacity: 0.9; }
  50% { transform: translateY(-5px); opacity: 1; }
}

@keyframes presence-line {
  0%, 100% { transform: scaleX(0.45); opacity: 0.2; }
  50% { transform: scaleX(1); opacity: 0.55; }
}

@media (min-width: 760px) {
  .app-header {
    padding-left: 32px;
    padding-right: 32px;
  }

  .voice-stage {
    padding-left: 48px;
    padding-right: 48px;
  }
}

@media (max-width: 520px) {
  .app-header {
    min-height: 66px;
  }

  .voice-stage {
    gap: 10px;
    padding: 18px 18px 14px;
  }

  .voice-presence img {
    width: 70px;
    height: 70px;
  }

  .voice-presence {
    gap: 14px;
  }

  #waveform {
    min-height: 90px;
  }

  .content-screen {
    padding: 24px 18px 36px;
  }

  .turn {
    grid-template-columns: 62px minmax(0, 1fr);
    gap: 10px;
  }

  .activity-item {
    padding: 15px;
  }

  .artifact-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-height: 650px) {
  .live-pill {
    display: none;
  }

  .voice-stage {
    grid-template-rows: auto auto minmax(80px, 1fr) auto auto;
  }

  .voice-presence img {
    width: 62px;
    height: 62px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}
