:root {
  color-scheme: dark;
  --bg: #090a0d;
  --surface: #101218;
  --surface-2: #161922;
  --surface-3: #1b1f2a;
  --text: #f4f4f2;
  --muted: #9299a7;
  --muted-2: #697180;
  --line: rgba(255,255,255,.09);
  --line-strong: rgba(255,255,255,.15);
  --accent: #8f9cff;
  --accent-soft: #b6bfff;
  --primary: #f2f3f5;
  --primary-text: #0b0c0f;
  --danger: #ef777f;
  --good: #72d4a5;
  --warn: #dfb56f;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 50% 8%, rgba(74,84,132,.16) 0%, rgba(9,10,13,0) 46%),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button { border: 0; cursor: pointer; }
summary { cursor: pointer; }
.hidden { display: none !important; }

.shell {
  width: min(620px, calc(100% - 40px));
  margin: 0 auto;
  padding: 30px 0;
}
section {
  background: rgba(16,18,24,.9);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 28px;
  backdrop-filter: blur(18px);
}

/* Home: intentionally not a card/landing page. */
.home {
  min-height: calc(100svh - 60px);
  padding: 4px 2px 8px;
  background: transparent;
  border: 0;
  border-radius: 0;
  backdrop-filter: none;
  display: flex;
  flex-direction: column;
}
.home-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 42px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.brand-name {
  color: var(--text);
  font-size: 14px;
  font-weight: 780;
  letter-spacing: .18em;
}
.pilot-badge {
  color: var(--muted-2);
  border-left: 1px solid var(--line);
  padding-left: 10px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .13em;
  white-space: nowrap;
}
.home-top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.engine-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 10.5px;
  white-space: nowrap;
}
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted-2);
  box-shadow: 0 0 0 3px rgba(255,255,255,.025);
}
.engine-status.ready { color: #9bd9bd; }
.engine-status.ready .status-dot { background: var(--good); box-shadow: 0 0 0 3px rgba(114,212,165,.08); }
.engine-status.warn { color: var(--warn); }
.engine-status.warn .status-dot { background: var(--warn); }

.identity-panel { position: relative; }
.account-summary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  list-style: none;
  color: var(--muted);
  padding: 7px 8px;
  border-radius: 999px;
  user-select: none;
  transition: background .16s ease, color .16s ease;
}
.account-summary::-webkit-details-marker { display: none; }
.account-summary:hover,
.identity-panel[open] .account-summary { color: var(--text); background: rgba(255,255,255,.045); }
.account-glyph {
  width: 23px;
  height: 23px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  position: relative;
  background: rgba(255,255,255,.025);
}
.account-glyph::before {
  content: "";
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #aeb4c0;
  left: 8px;
  top: 5px;
}
.account-glyph::after {
  content: "";
  position: absolute;
  width: 11px;
  height: 5px;
  border-radius: 8px 8px 4px 4px;
  border: 1px solid #aeb4c0;
  border-bottom: 0;
  left: 5px;
  bottom: 4px;
}
.account-label { font-size: 10.5px; }
.identity-panel[data-authenticated="true"] .account-summary {
  color: var(--good);
}
.identity-panel[data-authenticated="true"] .account-glyph {
  border-color: color-mix(in srgb, var(--good) 48%, transparent);
  background: color-mix(in srgb, var(--good) 8%, transparent);
}
.identity-panel[data-authenticated="true"] .account-glyph::before {
  background: var(--good);
}
.identity-panel[data-authenticated="true"] .account-glyph::after {
  border-color: var(--good);
}
.identity-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  z-index: 40;
  width: min(390px, calc(100vw - 34px));
  max-height: min(620px, calc(100vh - 90px));
  overflow-y: auto;
  padding: 17px;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: rgba(18,21,28,.98);
  box-shadow: 0 26px 80px rgba(0,0,0,.52);
}
.identity-copy { display: grid; gap: 4px; }
.identity-copy strong { color: var(--text); font-size: 13px; }
.identity-copy span { color: var(--muted); font-size: 11.5px; line-height: 1.45; overflow-wrap: anywhere; }
.identity-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.identity-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 10px; }
.identity-email-fallback { margin-top: 12px; color: var(--muted); font-size: 11.5px; }
.identity-status { margin-top: 9px; color: var(--muted); font-size: 11px; }
.identity-status:empty { display: none; }
.identity-status[data-kind="error"] { color: var(--danger); }
.identity-status[data-kind="success"] { color: var(--good); }
.account-divider { height: 1px; background: var(--line); margin: 15px 0 10px; }
.account-meta {
  display: grid;
  gap: 3px;
  margin-top: 13px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted-2);
  font-size: 10px;
  line-height: 1.4;
}

.pilot-access {
  display: grid;
  gap: 10px;
  margin: 18px 0 0;
  padding: 13px 14px;
  border-radius: 15px;
  border: 1px solid color-mix(in srgb, var(--warn) 38%, transparent);
  background: rgba(223,181,111,.045);
}
.pilot-access strong { color: var(--text); font-size: 13px; }
.pilot-access p { margin: 3px 0 0; color: var(--muted); font-size: 11.5px; }
.pilot-access-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.pilot-access-status { min-height: 16px; color: var(--muted); font-size: 11px; }
.pilot-access-status[data-kind="error"] { color: var(--danger); }
.pilot-access-status[data-kind="success"] { color: var(--good); }

.home-hero {
  flex: 1;
  min-height: 520px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 42px 0 70px;
}
.home-orb {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  position: relative;
  display: grid;
  place-items: center;
  border: 1px solid rgba(143,156,255,.24);
  background: rgba(143,156,255,.045);
  box-shadow: 0 0 70px rgba(92,106,196,.09), inset 0 0 36px rgba(143,156,255,.025);
}
.home-orb::before {
  content: "";
  width: 47px;
  height: 47px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #d8dcff 0%, #9da8ff 20%, #6875de 54%, #29305d 100%);
  box-shadow: 0 8px 32px rgba(93,105,203,.32), inset 0 1px 0 rgba(255,255,255,.36);
  animation: breathe 4s ease-in-out infinite;
}
.home-orb::after {
  content: "";
  position: absolute;
  inset: 13px;
  border-radius: 50%;
  border: 1px solid rgba(166,177,255,.13);
}
.home-orb span {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(235,237,255,.85);
  filter: blur(5px);
  z-index: 2;
}
@keyframes breathe {
  0%, 100% { transform: scale(.96); filter: saturate(.92); }
  50% { transform: scale(1.04); filter: saturate(1.08); }
}
h1 {
  margin: 25px 0 5px;
  font-size: clamp(40px, 7vw, 50px);
  line-height: .98;
  letter-spacing: -.052em;
  font-weight: 720;
}
h2 { font-size: 30px; margin: 6px 0 0; letter-spacing: -.03em; }
h3 { margin: 0 0 8px; }
.home-ready {
  margin: 0 0 31px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.4;
  letter-spacing: -.01em;
}
.home-possibilities {
  max-width: 470px;
  margin: -17px auto 25px;
  color: var(--muted-2);
  font-size: 12.5px;
  line-height: 1.55;
}

button {
  border-radius: 999px;
  padding: 13px 20px;
  font-weight: 700;
  transition: transform .14s ease, opacity .14s ease, border-color .14s ease, background .14s ease, color .14s ease;
}
button:not(:disabled):active { transform: scale(.985); }
button:disabled { opacity: .45; cursor: wait; }
.primary {
  background: var(--primary);
  color: var(--primary-text);
  min-width: 150px;
}
.primary:hover { background: #ffffff; }
.secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
}
.secondary.small { padding: 8px 12px; font-size: 11.5px; }
.danger { background: var(--danger); color: #19090b; }
.call-primary {
  width: min(330px, 100%);
  min-height: 55px;
  margin: 0;
  padding: 14px 24px;
  font-size: 15.5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 12px 34px rgba(0,0,0,.18);
}
.call-icon { width: 17px; height: 17px; fill: currentColor; }
.prepare-call {
  margin-top: 14px;
  padding: 9px 13px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 600;
}
.prepare-call:hover { color: var(--text); background: rgba(255,255,255,.035); }
.prepare-call span { font-size: 17px; line-height: .8; color: var(--muted-2); }

/* Hidden call preparation surface. */
.call-setup-dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: min(760px, calc(100svh - 40px));
  margin: auto;
  padding: 22px;
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: 24px;
  background: rgba(18,20,27,.985);
  box-shadow: 0 32px 100px rgba(0,0,0,.58);
  overflow-y: auto;
}
.call-setup-dialog::backdrop {
  background: rgba(0,0,0,.62);
  backdrop-filter: blur(7px);
}
.sheet-handle { display: none; }
.sheet-close-row {
  display: flex;
  justify-content: flex-end;
  margin: -3px -3px 0 0;
}
.sheet-close {
  padding: 8px 12px;
  color: var(--muted);
  background: rgba(255,255,255,.035);
  border: 1px solid var(--line);
  font-size: 11px;
}
.sheet-close:hover { color: var(--text); border-color: var(--line-strong); }
.sheet-copy { margin: 4px 0 24px; }
.sheet-kicker {
  color: var(--muted-2);
  font-size: 9.5px;
  font-weight: 750;
  letter-spacing: .16em;
}
.sheet-copy h2 { margin-top: 7px; }
.sheet-copy p {
  margin: 8px 0 0;
  max-width: 470px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.sheet-section { margin-top: 21px; }
.sheet-label {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 650;
}
.quick-starts {
  display: flex;
  align-items: center;
  gap: 7px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-width: none;
  padding: 1px 1px 6px;
}
.quick-starts::-webkit-scrollbar { display: none; }
.quick-chip {
  flex: 0 0 auto;
  padding: 9px 13px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  font-size: 11.5px;
  font-weight: 650;
  white-space: nowrap;
}
.quick-chip:hover { color: var(--text); border-color: var(--line-strong); }
.quick-chip.active {
  color: #e4e7ff;
  background: rgba(143,156,255,.09);
  border-color: rgba(143,156,255,.42);
}
.practice-strip { margin-top: 10px; }
.pilot-option-row { display: flex; gap: 10px; margin: 0; }
.pilot-option-row label { min-width: 176px; }
#difficultyWrap:not(.hidden) {
  display: grid;
  grid-template-columns: auto 128px;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
.progress-card {
  display: grid;
  gap: 3px;
  background: rgba(255,255,255,.018);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 11px 12px;
  margin: 9px 0 0;
}
.progress-card strong { color: var(--text); font-size: 11.5px; }
.progress-card span { color: var(--muted); font-size: 10.8px; line-height: 1.4; }
.context-section {
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
label { display: grid; gap: 8px; font-size: 11.5px; color: var(--muted); }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 13px;
  padding: 11px 12px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: rgba(143,156,255,.52); box-shadow: 0 0 0 3px rgba(143,156,255,.06); }
textarea { resize: vertical; line-height: 1.45; }
#context { min-height: 100px; }
#contextLabel::after { content: " · optional"; color: var(--muted-2); font-weight: 400; }
.wide, .context-first { margin-top: 0; }
.sheet-action-row { margin-top: 20px; }
.sheet-done { width: 100%; min-height: 48px; }

/* Account-only utilities */
.memory-box, .memory-evidence-box, .local-data {
  margin: 0;
  padding: 10px 0;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}
.local-data { border-bottom: 0; }
.memory-box summary, .memory-evidence-box summary, .local-data summary {
  color: #c7cbd3;
  font-size: 11.5px;
  font-weight: 600;
  list-style-position: inside;
}
.memory-box textarea { margin-top: 10px; }

.memory-evidence-list { display: grid; gap: 9px; margin-top: 10px; }
.memory-evidence-empty { color: var(--muted-2); font-size: 10.8px; line-height: 1.45; margin-top: 9px; }
.memory-evidence-item { border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: rgba(255,255,255,.025); }
.memory-evidence-top { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.memory-evidence-kind { text-transform: capitalize; font-size: 10px; font-weight: 700; letter-spacing: .04em; color: #c7cbd3; }
.memory-evidence-date { font-size: 9.8px; color: var(--muted-2); }
.memory-evidence-content { margin: 7px 0 0; font-size: 11.5px; line-height: 1.45; color: #e5e7eb; }
.memory-evidence-source { margin: 7px 0 0; padding-left: 9px; border-left: 2px solid var(--line); color: var(--muted); font-size: 10.5px; line-height: 1.45; }
.memory-evidence-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.memory-evidence-actions .small { min-height: 30px; padding: 5px 10px; font-size: 10px; }
.details-help { color: var(--muted); font-size: 10.8px; line-height: 1.45; margin: 8px 0 2px; }
.data-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.privacy { color: var(--muted); font-size: 12px; line-height: 1.5; margin: 14px 0 0; }

/* Call */
.call {
  min-height: min(720px, calc(100svh - 60px));
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.eyebrow {
  color: var(--muted);
  font-size: 10.5px;
  letter-spacing: .14em;
  font-weight: 700;
}
.call-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; }
.status {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 11.5px;
  color: var(--muted);
}
.orb-wrap { text-align: center; display: grid; place-items: center; gap: 16px; }
.orb {
  width: 146px;
  height: 146px;
  border-radius: 50%;
  border: 1px solid rgba(143,156,255,.25);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: radial-gradient(circle at 40% 34%, #a8b0ff 0%, #6471d6 28%, #30365f 58%, #171a23 78%);
  transition: transform .2s ease, box-shadow .2s ease;
}
.orb.active { transform: scale(1.035); box-shadow: 0 0 72px rgba(110,123,218,.16); }
.orb span { width: 4px; height: 27px; border-radius: 99px; background: #ecedff; animation: pulse 1s ease-in-out infinite; }
.orb span:nth-child(2) { animation-delay: .16s; height: 43px; }
.orb span:nth-child(3) { animation-delay: .32s; }
@keyframes pulse { 0%,100% { transform: scaleY(.35); opacity:.45;} 50% { transform: scaleY(1); opacity:1;} }
.timer { font-size: 27px; font-variant-numeric: tabular-nums; }
.live-caption-details { color: var(--muted); font-size: 11.5px; }
.live-caption { min-height: 48px; max-width: 500px; color: var(--muted); line-height: 1.5; margin-top: 10px; }
.call-actions, .review-actions { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }

/* Review */
.review-status { margin-top: 10px; color: var(--muted); font-size: 13px; }
.cost-note { margin-top: 10px; color: var(--muted); font-size: 11px; line-height: 1.45; border-left: 2px solid var(--line-strong); padding-left: 10px; }
.outcome-panel { margin-top: 18px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface-2); }
.outcome-panel strong { display: block; margin-top: 5px; font-size: 18px; }
.outcome-panel p { margin: 7px 0 0; color: var(--muted); line-height: 1.55; }
.outcome-kicker { color: var(--muted); font-size: 11px; letter-spacing: .11em; }
.score-panel { margin-top: 22px; }
.scores { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.score { min-height: 92px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 16px; padding: 13px; display: flex; flex-direction: column; justify-content: space-between; }
.score span { color: var(--muted); font-size: 12px; }
.score strong { font-size: 30px; font-variant-numeric: tabular-nums; }
.score.overall { border-color: rgba(143,156,255,.4); }
.score.overall strong { color: var(--accent-soft); }
.trend { margin-top: 10px; border-radius: 12px; padding: 10px 12px; background: var(--surface-2); color: var(--muted); font-size: 13px; }
.trend.up { color: var(--good); }
.trend.down { color: var(--warn); }
.feedback { line-height: 1.7; background: var(--surface-2); border: 1px solid var(--line); border-radius: 16px; padding: 18px; margin: 16px 0 22px; }
.coach-row { display: grid; grid-template-columns: 100px 1fr; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.coach-row:last-child { border-bottom: 0; }
.coach-row span { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; padding-top: 3px; }
.coach-row p { margin: 0; }
.coach-row.retry p { color: var(--accent-soft); }
.transcript { display: grid; gap: 10px; margin-top: 14px; }
.turn { border-left: 3px solid var(--line-strong); padding-left: 12px; color: var(--muted); }
.turn.user { border-left-color: var(--accent); color: var(--text); }
.review details { margin-bottom: 22px; }
.memory-review { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.memory-option { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0; }
.memory-option input { width: auto; margin-top: 4px; }

@media (max-width: 620px) {
  body { background: var(--bg); }
  .shell { width: 100%; padding: 0; }
  section { border-radius: 0; border-left: 0; border-right: 0; padding: 20px; }
  .home { min-height: 100svh; padding: 16px 18px 12px; }
  .brand-name { font-size: 13px; }
  .pilot-badge { font-size: 8px; }
  .account-label { display: none; }
  .account-summary { padding: 4px; }
  .identity-popover { right: -2px; width: min(390px, calc(100vw - 30px)); }
  .home-hero { min-height: 0; padding: 64px 0 84px; }
  .home-orb { width: 91px; height: 91px; }
  .home-orb::before { width: 44px; height: 44px; }
  h1 { margin-top: 23px; font-size: 43px; }
  .home-ready { margin-bottom: 28px; font-size: 15.5px; }
  .call-primary { width: min(325px, 92vw); min-height: 56px; }
  .prepare-call { margin-top: 13px; }
  .call-setup-dialog {
    width: 100%;
    max-width: none;
    max-height: min(82svh, 720px);
    margin: auto 0 0;
    padding: 10px 18px 20px;
    border-radius: 24px 24px 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
  }
  .sheet-handle {
    display: block;
    width: 34px;
    height: 4px;
    margin: 1px auto 8px;
    border-radius: 999px;
    background: rgba(255,255,255,.18);
  }
  .sheet-close-row { margin-top: -4px; }
  .sheet-copy { margin-top: 0; }
  .quick-chip { padding: 9px 12px; }
  .pilot-option-row { display: block; }
  .pilot-option-row label { min-width: 0; }
  .call { min-height: 100svh; }
  .scores { grid-template-columns: repeat(2, 1fr); }
  .coach-row { grid-template-columns: 1fr; gap: 2px; }
  .identity-row, .pilot-access-row { grid-template-columns: 1fr; }
}

@media (max-height: 700px) and (max-width: 620px) {
  .home-hero { padding: 34px 0 52px; }
  .home-orb { width: 78px; height: 78px; }
  .home-orb::before { width: 38px; height: 38px; }
  h1 { margin-top: 18px; font-size: 38px; }
  .home-ready { margin-bottom: 22px; }
}

.outcome-pickup { margin-top: 12px; }

.first-call-hint {
  max-width: 390px;
  margin: -10px auto 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
.first-call-hint strong { color: var(--text); font-weight: 650; }
