:root {
  color-scheme: light;
  --paper: #f5f6f4;
  --white: #ffffff;
  --ink: #161b1a;
  --muted: #65706d;
  --line: #d8ddda;
  --teal: #0f766e;
  --teal-dark: #0b5852;
  --coral: #df624f;
  --charcoal: #222827;
  --danger: #b42318;
  --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 {
  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: 700;
}

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

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

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

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

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

.login-form input {
  width: 100%;
  height: 52px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
  color: var(--ink);
}

.login-form button {
  height: 52px;
  border: 0;
  border-radius: 6px;
  background: var(--charcoal);
  color: var(--white);
  font-weight: 700;
}

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

.voice-view {
  min-height: 100svh;
  padding-bottom: var(--safe-bottom);
}

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

.header-actions {
  display: flex;
  gap: 6px;
}

.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;
}

.voice-stage {
  min-height: clamp(410px, 58svh, 620px);
  display: grid;
  grid-template-rows: auto minmax(170px, 1fr) auto auto;
  align-items: center;
  justify-items: center;
  gap: 16px;
  padding: 30px 20px 28px;
  background: var(--white);
  border-bottom: 1px solid var(--line);
}

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

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  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;
}

#waveform {
  display: block;
  width: min(100%, 960px);
  height: clamp(170px, 25svh, 240px);
}

.voice-button {
  min-width: 196px;
  height: 54px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 0;
  border-radius: 6px;
  padding: 0 22px;
  background: var(--teal);
  color: var(--white);
  font-weight: 750;
  box-shadow: 0 8px 20px 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;
}

.conversation-band {
  width: min(100%, 920px);
  margin: 0 auto;
  padding: 26px 20px 54px;
}

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

.section-heading h2 {
  margin: 0;
  font-size: 16px;
}

.conversation {
  display: grid;
  gap: 0;
}

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

.turn-role {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  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 {
  border-left: 3px solid var(--coral);
  padding-left: 14px;
}

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

.empty-state {
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 14px;
}

#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); }
}

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

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

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