:root {
  color-scheme: light dark;
  --page: #e9e9e5;
  --surface: #f7f7f5;
  --raised: #ffffff;
  --ink: #171715;
  --muted: #777772;
  --line: rgba(23, 23, 21, 0.12);
  --soft: #eeeeea;
  --accent: #ff643e;
  --green: #49bd73;
  --danger: #ea4d45;
  --app-height: 100dvh;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

:root[data-theme="dark"] {
  --page: #080807;
  --surface: #11110f;
  --raised: #1b1b18;
  --ink: #f7f7f3;
  --muted: #989891;
  --line: rgba(247, 247, 243, 0.13);
  --soft: #1d1d1a;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page: #080807;
    --surface: #11110f;
    --raised: #1b1b18;
    --ink: #f7f7f3;
    --muted: #989891;
    --line: rgba(247, 247, 243, 0.13);
    --soft: #1d1d1a;
  }
}

* { box-sizing: border-box; }

html {
  background: var(--page);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow: hidden;
  background: var(--page);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

button,
input,
textarea,
select { color: inherit; font: inherit; }

button { border: 0; cursor: pointer; }

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 62%, transparent);
  outline-offset: 2px;
}

.app-shell {
  position: relative;
  width: min(100%, 500px);
  height: var(--app-height);
  min-height: 460px;
  margin: 0 auto;
  overflow: hidden;
  background: var(--surface);
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  visibility: hidden;
  overflow: hidden;
  opacity: 0;
  transition: opacity 150ms ease, visibility 150ms;
}

.screen.is-active { visibility: visible; opacity: 1; }

.app-header,
.call-header {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  min-height: 70px;
  padding: max(16px, env(safe-area-inset-top)) 20px 12px;
}

.app-header { justify-content: space-between; }

.wordmark {
  color: var(--ink);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.06em;
  text-decoration: none;
}

.header-actions { display: flex; align-items: center; gap: 8px; }

.account-button,
.text-button {
  min-height: 38px;
  padding: 0 13px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--ink);
  font-size: 12px;
  font-weight: 750;
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 50%;
  background: var(--soft);
  place-items: center;
}

.icon-button svg {
  width: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.start-content {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  min-height: 0;
  padding: 28px 24px calc(28px + env(safe-area-inset-bottom));
}

.presence-mark {
  display: grid;
  width: 50px;
  height: 50px;
  margin-bottom: 30px;
  border-radius: 16px;
  background: var(--ink);
  place-items: center;
}

.presence-mark span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--green) 18%, transparent);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.start-content h1,
.end-content h1 {
  margin: 0;
  font-size: clamp(48px, 14vw, 68px);
  font-weight: 760;
  letter-spacing: -0.075em;
  line-height: 0.96;
}

.lede {
  margin: 18px 0 34px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
}

.primary-button,
.secondary-button,
.google-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 54px;
  padding: 13px 18px;
  border-radius: 15px;
  font-size: 14px;
  font-weight: 780;
  transition: transform 110ms ease, opacity 110ms ease;
}

.primary-button { background: var(--ink); color: var(--surface); }
.secondary-button { border: 1px solid var(--line); background: transparent; }

.primary-button:active,
.secondary-button:active,
.google-button:active,
.hangup-button:active { transform: scale(0.98); }

button:disabled { cursor: default; opacity: 0.45; }

.privacy-note {
  align-self: center;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.call-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.call-identity h2,
.call-identity p { margin: 0; }

.call-identity h2 { font-size: 14px; letter-spacing: -0.02em; }

.call-identity p {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.presence-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
}

#call-timer {
  align-self: center;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.hangup-button {
  display: grid;
  justify-self: end;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  place-items: center;
}

.hangup-button svg {
  width: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.conversation-stage {
  display: grid;
  flex: 1;
  grid-template-rows: minmax(0, 1fr) minmax(0, 0.86fr);
  min-height: 0;
}

.speaker-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 24px;
}

.speaker-label {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.live-copy {
  overflow-y: auto;
  color: var(--ink);
  font-size: clamp(27px, 7.8vw, 39px);
  font-weight: 650;
  letter-spacing: -0.05em;
  line-height: 1.14;
  overflow-wrap: anywhere;
  scrollbar-width: none;
}

.live-copy::-webkit-scrollbar { display: none; }

.ai-copy.is-streaming::after {
  display: inline-block;
  width: 0.1em;
  height: 0.88em;
  margin-left: 0.08em;
  border-radius: 999px;
  background: var(--accent);
  content: "";
  vertical-align: -0.04em;
  animation: cursor-blink 700ms step-end infinite;
}

@keyframes cursor-blink { 50% { opacity: 0; } }

.sr-status {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.user-panel {
  position: relative;
  border-top: 1px solid var(--line);
  background: var(--raised);
  padding-bottom: calc(18px + env(safe-area-inset-bottom));
}

.user-label-row { display: flex; justify-content: space-between; }
.user-label-row span { color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }

#message-input {
  width: 100%;
  min-height: 76px;
  flex: 1;
  resize: none;
  overflow-y: auto;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  caret-color: var(--accent);
  font-size: clamp(26px, 7.4vw, 37px);
  font-weight: 630;
  letter-spacing: -0.05em;
  line-height: 1.15;
}

#message-input::placeholder { color: color-mix(in srgb, var(--muted) 42%, transparent); }

.send-hint {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.send-hint span { width: 6px; height: 6px; border-radius: 50%; background: var(--line); }
.send-hint.is-counting span { background: var(--accent); animation: pulse 900ms ease-out; }

@keyframes pulse {
  from { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); }
  to { box-shadow: 0 0 0 7px transparent; }
}

.end-content {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: flex-start;
  min-height: 0;
  padding: clamp(30px, 7vh, 64px) 24px calc(24px + env(safe-area-inset-bottom));
  overflow-y: auto;
}

.call-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
  margin: 34px 0 18px;
}

.call-stats div { display: flex; flex-direction: column; gap: 4px; padding: 16px 0; border-top: 1px solid var(--line); }
.call-stats strong { font-size: 22px; font-variant-numeric: tabular-nums; letter-spacing: -0.04em; }
.call-stats span { color: var(--muted); font-size: 10px; text-transform: uppercase; }

.transcript-details { width: 100%; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.transcript-details summary { padding: 16px 0; cursor: pointer; font-size: 13px; font-weight: 750; }
.transcript { display: flex; flex-direction: column; gap: 13px; max-height: 220px; padding: 2px 0 18px; overflow-y: auto; }
.transcript-item { display: grid; grid-template-columns: 56px 1fr; gap: 10px; font-size: 13px; line-height: 1.45; }
.transcript-item strong { color: var(--muted); font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase; }
.transcript-item p { margin: 0; overflow-wrap: anywhere; }
.end-actions { display: grid; gap: 9px; width: 100%; margin-top: auto; padding-top: 24px; }

.settings-dialog {
  width: min(100% - 20px, 480px);
  max-height: min(90dvh, 780px);
  margin: auto auto max(10px, env(safe-area-inset-bottom));
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.28);
}

.settings-dialog:focus { outline: none; }

.settings-dialog::backdrop { background: rgba(0, 0, 0, 0.46); backdrop-filter: blur(3px); }

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-height: inherit;
  padding: 24px 20px calc(20px + env(safe-area-inset-bottom));
  overflow-y: auto;
}

.settings-header { display: flex; align-items: flex-start; justify-content: space-between; }
.settings-header .eyebrow { margin-bottom: 4px; }
.settings-header h2 { margin: 0; font-size: 28px; letter-spacing: -0.05em; }

.account-card {
  display: grid;
  gap: 10px;
  padding: 15px;
  border-radius: 16px;
  background: var(--soft);
}

.account-card > div { display: flex; flex-direction: column; gap: 3px; }
.account-card strong { font-size: 13px; }
.account-card span { color: var(--muted); font-size: 10px; }

.google-button { gap: 10px; min-height: 46px; background: var(--raised); color: var(--ink); }
.google-button b { display: grid; width: 22px; height: 22px; border: 1px solid var(--line); border-radius: 50%; color: #4285f4; font-size: 12px; place-items: center; }
.text-button { justify-self: start; min-height: 34px; padding: 0; background: transparent; color: var(--muted); }
.is-hidden { display: none !important; }

.field { display: flex; flex-direction: column; gap: 7px; }
.field > span,
.choice-fieldset legend,
.theme-row > span { color: var(--muted); font-size: 11px; font-weight: 700; }

.field input,
.field textarea,
.theme-row select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 13px;
  outline: 0;
  background: var(--raised);
}

.field input { min-height: 46px; padding: 0 13px; }
.field textarea { resize: vertical; min-height: 92px; padding: 12px 13px; line-height: 1.45; }
.field small { color: var(--muted); font-size: 9px; line-height: 1.4; }

.choice-fieldset { margin: 0; padding: 0; border: 0; }
.choice-fieldset legend { margin-bottom: 7px; }
.choice-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.choice-row button { min-height: 42px; border-radius: 12px; background: var(--soft); color: var(--muted); font-size: 11px; font-weight: 700; }
.choice-row button[aria-pressed="true"] { background: var(--ink); color: var(--surface); }

.theme-row { display: flex; align-items: center; justify-content: space-between; }
.theme-row select { width: auto; min-height: 42px; padding: 0 34px 0 12px; }

.toast {
  position: fixed;
  z-index: 20;
  right: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  left: 18px;
  max-width: 420px;
  margin: 0 auto;
  padding: 12px 16px;
  border-radius: 13px;
  background: var(--ink);
  color: var(--surface);
  font-size: 12px;
  line-height: 1.4;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 150ms ease, transform 150ms ease;
}

.toast.is-visible { opacity: 1; transform: translateY(0); }

@media (min-width: 600px) {
  body { padding: 20px; }
  .app-shell { height: min(calc(100dvh - 40px), 850px); border: 1px solid var(--line); border-radius: 28px; box-shadow: 0 20px 70px rgba(0, 0, 0, 0.12); }
  .settings-dialog { margin: auto; }
}

@media (max-height: 620px) {
  .start-content { justify-content: flex-start; padding-top: 26px; overflow-y: auto; }
  .presence-mark { width: 42px; height: 42px; margin-bottom: 22px; border-radius: 13px; }
  .lede { margin: 12px 0 22px; }
}

@media (hover: none) and (pointer: coarse) {
  button:focus,
  summary:focus { outline: none; }
}

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