:root {
  --bg: #f5f8ff;
  --surface: #ffffff;
  --surface-2: #eef3ff;
  --text: #0f1b3d;
  --muted: #5a6a8c;
  --line: #d9e2f5;
  --brand: #1d4ed8;
  --brand-2: #3b82f6;
  --brand-ink: #ffffff;
  --good: #0f7a4b;
  --good-bg: #e6f6ee;
  --warn: #9a3412;
  --warn-bg: #fff1e6;
  --danger: #c02626;
  --lead-bubble: #eef3ff;
  --bd-bubble: #1d4ed8;
  --bd-ink: #ffffff;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(15 27 61 / 6%), 0 4px 16px rgb(15 27 61 / 6%);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1226;
    --surface: #121b36;
    --surface-2: #18234a;
    --text: #e8eeff;
    --muted: #9aa8cc;
    --line: #26335e;
    --brand: #4f7dff;
    --brand-2: #7aa2ff;
    --good: #5fd39b;
    --good-bg: #0f2e22;
    --warn: #ffb37a;
    --warn-bg: #3a2210;
    --danger: #ff6b6b;
    --lead-bubble: #18234a;
    --bd-bubble: #2f5ff0;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1226; --surface: #121b36; --surface-2: #18234a; --text: #e8eeff; --muted: #9aa8cc;
  --line: #26335e; --brand: #4f7dff; --brand-2: #7aa2ff; --good: #5fd39b; --good-bg: #0f2e22;
  --warn: #ffb37a; --warn-bg: #3a2210; --danger: #ff6b6b; --lead-bubble: #18234a; --bd-bubble: #2f5ff0;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}
h1 { font-size: 1.5rem; margin: 0 0 .25rem; letter-spacing: -0.01em; }
h2 { font-size: 1rem; margin: 0 0 .4rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.error { color: var(--danger); min-height: 1.2em; margin: .4rem 0; }

/* Brand. The logo files are white on transparent, so they are used as masks and
   filled with --logo: brand blue in light mode, white in dark mode. */
:root { --logo: #1d4ed8; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --logo: #ffffff; } }
:root[data-theme="dark"] { --logo: #ffffff; }
.logo-horizontal, .logo-stacked {
  display: block; flex: none; background: var(--logo);
  -webkit-mask: no-repeat center / contain; mask: no-repeat center / contain;
}
.logo-horizontal { width: 128px; height: 30px; -webkit-mask-image: url("logo-horizontal.png"); mask-image: url("logo-horizontal.png"); }
.logo-stacked { width: 168px; height: 113px; -webkit-mask-image: url("logo-stacked.png"); mask-image: url("logo-stacked.png"); }
.brand { display: flex; align-items: center; gap: .65rem; white-space: nowrap; }
.product-tag {
  font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); border-left: 1px solid var(--line); padding-left: .65rem; line-height: 1.6;
}
.login-brand { display: grid; justify-items: center; gap: .6rem; padding: .5rem 0 .25rem; }
.login-brand .product-tag { border-left: 0; padding-left: 0; }

/* Buttons */
.btn {
  font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  padding: .6rem 1rem; border-radius: 10px; cursor: pointer; min-height: 44px;
}
.btn:hover { border-color: var(--brand-2); }
.btn:focus-visible, .mic:focus-visible, .card:focus-visible, .tabs button:focus-visible, input:focus-visible {
  outline: 3px solid var(--brand-2); outline-offset: 2px;
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.small { padding: .35rem .7rem; min-height: 36px; font-size: .875rem; }
.btn.big { padding: .9rem 1.6rem; font-size: 1.05rem; }
.btn:disabled { opacity: .5; cursor: default; }

input[type="text"], input[type="password"] {
  font: inherit; width: 100%; padding: .7rem .8rem; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); min-height: 44px;
}

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.75rem; box-shadow: var(--shadow); display: grid; gap: .6rem;
}
.login-card h1 { margin-top: .75rem; text-align: center; }
.login-card > p.muted { text-align: center; margin-top: 0; }
.login-card label { font-weight: 600; font-size: .875rem; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .6rem 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.tabs { display: flex; gap: .25rem; margin-right: auto; }
.tabs button {
  font: inherit; font-weight: 600; border: 0; background: transparent; color: var(--muted);
  padding: .45rem .8rem; border-radius: 8px; cursor: pointer;
}
.tabs button[aria-selected="true"] { background: var(--surface-2); color: var(--brand); }
.pill { font-size: .75rem; font-weight: 600; padding: .2rem .55rem; border-radius: 999px; background: var(--warn-bg); color: var(--warn); }

.page { max-width: 880px; margin: 0 auto; padding: 1.5rem 16px 3rem; }

/* Scenario grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: .9rem; margin-top: 1.2rem; }
.card {
  text-align: left; font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1rem; cursor: pointer; display: grid; align-content: start; gap: .35rem; box-shadow: var(--shadow);
  transition: border-color .15s, transform .15s;
}
.card:hover { border-color: var(--brand-2); transform: translateY(-1px); }
.card .num { font-size: .75rem; font-weight: 700; color: var(--brand); text-transform: uppercase; letter-spacing: .04em; }
.card .title { font-weight: 700; font-size: 1.05rem; }
.card .type { font-size: .8rem; color: var(--muted); }
.card .prof { font-size: .9rem; color: var(--muted); }

/* Call */
.call-head { display: flex; align-items: center; gap: .9rem; }
.avatar {
  width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; font-weight: 700; font-size: 1.4rem;
}
.avatar.speaking { box-shadow: 0 0 0 4px rgb(59 130 246 / 35%); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 9px rgb(59 130 246 / 15%); } }
.call-who { flex: 1; min-width: 0; }
.call-name { font-weight: 700; font-size: 1.15rem; }
.call-timer { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }
.profile { margin: 1rem 0; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .6rem .9rem; }
.profile summary { cursor: pointer; font-weight: 600; }
.profile p { margin: .5rem 0 0; }
.notice { background: var(--warn-bg); color: var(--warn); border-radius: 10px; padding: .7rem .9rem; margin: .8rem 0; font-size: .9rem; }
.status { text-align: center; color: var(--muted); font-weight: 600; margin: 0; min-height: 1.5em; }
#transcript { margin-top: 1rem; }

.transcript { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.transcript li { max-width: 85%; padding: .6rem .85rem; border-radius: 14px; overflow-wrap: anywhere; }
.transcript li.lead { align-self: flex-start; background: var(--lead-bubble); border-bottom-left-radius: 4px; }
.transcript li.bd { align-self: flex-end; background: var(--bd-bubble); color: var(--bd-ink); border-bottom-right-radius: 4px; }
.transcript li.interim { opacity: .65; font-style: italic; }
.transcript.small li { font-size: .9rem; }
#transcript { min-height: 120px; }

.controls { position: sticky; bottom: 0; padding: 1rem 0 .5rem; background: linear-gradient(to top, var(--bg) 75%, transparent); display: grid; gap: .6rem; justify-items: center; }
.row { display: flex; gap: .6rem; align-items: center; justify-content: center; flex-wrap: wrap; width: 100%; }
.typed input { flex: 1; min-width: 0; }
.typed { flex-wrap: nowrap; }
#in-call { width: 100%; display: grid; gap: .6rem; }
.mic {
  font: inherit; font-weight: 600; display: inline-flex; align-items: center; gap: .5rem; cursor: pointer;
  border: 0; border-radius: 999px; padding: .8rem 1.3rem; min-height: 52px; background: var(--brand); color: #fff;
}
.mic svg { width: 22px; height: 22px; fill: currentColor; }
.mic[aria-pressed="true"] { background: var(--danger); animation: pulse 1.2s ease-in-out infinite; }
.mic:disabled { opacity: .5; cursor: default; }
.toggle { display: inline-flex; gap: .4rem; align-items: center; font-weight: 600; font-size: .9rem; cursor: pointer; }
.toggle input { width: 18px; height: 18px; accent-color: var(--brand); }

/* Result */
.result-head { display: flex; gap: 1.2rem; align-items: center; margin-bottom: 1.2rem; }
.total { font-size: 3rem; font-weight: 700; line-height: 1; color: var(--brand); font-variant-numeric: tabular-nums; }
.total small { font-size: 1.2rem; color: var(--muted); }
.verdict { font-weight: 700; font-size: 1.15rem; }
.verdict.pass { color: var(--good); }
.verdict.fail { color: var(--warn); }
.lines { list-style: none; padding: 0; margin: 0 0 1.2rem; display: grid; gap: .5rem; }
.lines li {
  display: grid; grid-template-columns: 1fr auto; gap: .2rem 1rem; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: .7rem .9rem;
}
.lines .skill { font-weight: 600; }
.lines .note { grid-column: 1 / -1; color: var(--muted); font-size: .9rem; }
.pips { display: inline-flex; gap: 4px; align-items: center; }
.pips i { width: 14px; height: 14px; border-radius: 50%; background: var(--line); display: inline-block; }
.pips i.on { background: var(--brand); }
.pips b { margin-left: .4rem; font-variant-numeric: tabular-nums; }
.callout { border-radius: 12px; padding: .9rem 1rem; margin-bottom: .8rem; background: var(--surface); border: 1px solid var(--line); }
.callout.good { border-left: 4px solid var(--good); }
.callout.change { border-left: 4px solid var(--brand); }
.callout.warn { border-left: 4px solid var(--warn); background: var(--warn-bg); }
.callout p { margin: .2rem 0; }
.callout .said { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }
.callout .said:empty, .callout .better:empty { display: none; }
.callout .better::before { content: "Try: "; font-weight: 700; }
.callout ul { margin: .3rem 0 0; padding-left: 1.2rem; }

/* Study */
.chips { display: flex; gap: .4rem; flex-wrap: wrap; margin: 1rem 0; }
.chips button {
  font: inherit; font-size: .9rem; font-weight: 600; border: 1px solid var(--line); background: var(--surface);
  color: var(--text); border-radius: 999px; padding: .4rem .85rem; cursor: pointer;
}
.chips button[aria-current="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.prose { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem 1.4rem; overflow-x: auto; }
.prose h3 { margin-top: 1.4rem; }
.prose blockquote { margin: .6rem 0; padding: .4rem 1rem; border-left: 4px solid var(--brand-2); background: var(--surface-2); border-radius: 0 8px 8px 0; }
.prose table { border-collapse: collapse; width: 100%; font-size: .9rem; margin: .8rem 0; }
.prose th, .prose td { border: 1px solid var(--line); padding: .45rem .6rem; text-align: left; vertical-align: top; }
.prose th { background: var(--surface-2); }

@media (max-width: 600px) {
  .topbar { gap: .5rem; }
  .brand { margin-right: auto; }
  .brand .product-tag { display: none; }
  /* Logo and sign-out on the first row, tabs across the second. */
  .tabs { order: 3; width: 100%; margin-right: 0; }
  .tabs button { flex: 1; }
  .total { font-size: 2.4rem; }
  .prose { padding: 1rem; }
  .prose table { display: block; overflow-x: auto; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* Live mic level: the ring grows with the voice so BDs can see they're being picked up */
.mic[aria-pressed="true"] {
  animation: none;
  box-shadow: 0 0 0 calc(4px + var(--level, 0) * 16px) rgb(192 38 38 / 28%);
  transition: box-shadow 60ms linear;
}
.row.small { font-size: .875rem; }

/* Mic test */
.mt-lines { margin: 1rem 0 1.4rem; padding-left: 1.3rem; display: grid; gap: .35rem; }
.mt-results { display: grid; gap: .6rem; margin-top: 1rem; }
.mt-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .8rem 1rem; }
.mt-card.current { border-left: 4px solid var(--brand); }
.mt-card p { margin: .3rem 0 0; }
.mt-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
