:root {
  --ink: #14213d;
  --ink-2: #3b4a66;
  --muted: #64708a;
  --line: #d9dee8;
  --bg: #f5f3ee;
  --card: #ffffff;
  --navy: #1d2b53;
  --accent: #c8102e;      /* British red, used sparingly */
  --accent-soft: #fbe9ec;
  --ok: #157f4f;
  --ok-soft: #e4f4ec;
  --warn: #9a6200;
  --warn-soft: #fff4dc;
  --danger: #b42318;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 33, 61, 0.06), 0 4px 16px rgba(20, 33, 61, 0.06);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
a { color: var(--navy); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 8px; }
h1 { font-size: clamp(1.8rem, 4.5vw, 2.8rem); letter-spacing: -0.5px; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 0.86rem; }
.center { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.stack > * + * { margin-top: 12px; }

/* top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; color: var(--ink); text-decoration: none; letter-spacing: 0.2px; font-size: 1.05rem; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--navy); position: relative; flex: none; }
.brand-mark::after { content: ""; position: absolute; inset: 8px 8px 8px 8px; border-radius: 3px; border: 3px solid #fff; border-right-color: var(--accent); }
.topbar nav { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); font-size: 0.85rem; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); border-color: #b9e2cc; color: var(--ok); }
.pill.warn { background: var(--warn-soft); border-color: #f1d79a; color: var(--warn); }
.pill.bad { background: var(--accent-soft); border-color: #f2c2ca; color: var(--danger); }

/* layout */
.page { max-width: 1080px; margin: 0 auto; padding: 24px 20px 60px; }
.narrow { max-width: 480px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.section { margin-top: 28px; }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }

/* buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; touch-action: manipulation; }
.btn:hover { border-color: var(--navy); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn-primary:hover { background: #26386b; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-lg { min-height: 52px; font-size: 1.05rem; padding: 0 22px; }
.btn-block { width: 100%; }
.btn-sm { min-height: 34px; padding: 0 10px; font-size: 0.88rem; }
label { font-weight: 600; font-size: 0.92rem; display: block; margin-bottom: 4px; }
.field { margin: 12px 0; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], input[type="time"], select, textarea {
  width: 100%; min-height: 44px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-size: 16px;
}
textarea { min-height: 80px; }
input:focus-visible, select:focus-visible, .btn:focus-visible, button:focus-visible { outline: 3px solid #8ea6e6; outline-offset: 2px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; }
.check input { margin-top: 4px; width: 18px; height: 18px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: transparent; padding: 10px 14px; font: inherit; cursor: pointer; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--navy); color: #fff; }
.error { color: var(--danger); margin-top: 8px; }
.notice { padding: 10px 14px; border-radius: 10px; background: var(--warn-soft); border: 1px solid #f1d79a; color: #5e3d00; }
.notice.ok { background: var(--ok-soft); border-color: #b9e2cc; color: #0d5034; }
.notice.bad { background: var(--accent-soft); border-color: #f2c2ca; color: #7a1414; }

/* tables */
table { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }
.table-wrap { overflow-x: auto; }

/* home */
.hero { padding: 40px 0 10px; display: grid; grid-template-columns: 1.3fr 1fr; gap: 28px; align-items: center; }
.hero .lead { font-size: 1.15rem; color: var(--ink-2); max-width: 560px; }
.status-card .big { font-size: 2.6rem; font-weight: 800; line-height: 1; }
.dots { display: flex; gap: 6px; margin: 10px 0; }
.dots span { width: 22px; height: 22px; border-radius: 6px; background: var(--ok); }
.dots span.busy { background: #cfd6e4; }
.feature h3 { display: flex; gap: 8px; align-items: center; }
.price { font-size: 1.6rem; font-weight: 800; }
.footer { color: var(--muted); font-size: 0.85rem; border-top: 1px solid var(--line); margin-top: 40px; padding-top: 16px; }

/* slots */
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.slot { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 8px; text-align: center; cursor: pointer; font: inherit; }
.slot small { display: block; color: var(--muted); font-size: 0.75rem; }
.slot[aria-pressed="true"] { border-color: var(--navy); background: #e8edf9; box-shadow: inset 0 0 0 1px var(--navy); }
.slot:disabled { background: #eef0f4; color: #9aa3b5; cursor: not-allowed; }
.slot.full small { color: var(--danger); }

/* interview list */
.iv { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.iv:last-child { border-bottom: 0; }
.iv-title { font-weight: 700; }
.iv-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; align-items: start; }

/* interview room */
.room-page { display: flex; flex-direction: column; min-height: 100dvh; }
.room-main { flex: 1; display: flex; flex-direction: column; min-height: 0; width: 100%; max-width: 900px; margin: 0 auto; padding: 12px 16px 0; }
.people { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.person { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.person[data-present="false"] { opacity: 0.55; }
.person-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.person-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lang-chip { font-size: 0.78rem; color: var(--navy); background: #e8edf9; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.meter { height: 4px; background: #e8ebf2; border-radius: 4px; overflow: hidden; margin-top: 8px; }
.meter span { display: block; height: 100%; background: var(--ok); transform-origin: left; transform: scaleX(0); transition: transform 80ms linear; }
.state-line { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 10px 0 0; font-size: 0.9rem; color: var(--muted); min-height: 24px; }
.captions { flex: 1; overflow-y: auto; margin: 10px 0 4px; padding: 4px 2px 12px; display: flex; flex-direction: column; gap: 10px; min-height: 200px; }
.captions-empty { color: var(--muted); text-align: center; margin: auto; max-width: 380px; }
.bubble { max-width: 88%; padding: 10px 14px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); }
.bubble.them { align-self: flex-start; border-top-left-radius: 4px; }
.bubble.me { align-self: flex-end; border-top-right-radius: 4px; background: #eef2fb; }
.bubble header { display: flex; justify-content: space-between; gap: 12px; font-size: 0.75rem; color: var(--muted); }
.bubble .who { font-weight: 700; color: var(--ink); }
.bubble .main { margin: 4px 0 0; font-size: 1.12rem; line-height: 1.4; }
.bubble .sub { margin: 6px 0 0; font-size: 0.85rem; color: var(--muted); }
.bubble.pending .main { color: var(--muted); font-style: italic; }
.ai-note { color: var(--muted); font-size: 0.75rem; text-align: center; margin: 0 0 6px; }
.banner { margin: 8px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--warn-soft); border: 1px solid #f1d79a; display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.controls { display: flex; justify-content: center; gap: 10px; padding: 10px 12px calc(10px + var(--safe-b)); border-top: 1px solid var(--line); background: var(--card); position: sticky; bottom: 0; }
.ctl { display: grid; justify-items: center; gap: 2px; width: 96px; padding: 8px 4px; border-radius: 12px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; cursor: pointer; touch-action: manipulation; }
.ctl .t { font-size: 0.82rem; font-weight: 700; }
.ctl .s { font-size: 0.72rem; color: var(--muted); }
.ctl[aria-pressed="true"].on { border-color: var(--ok); }
.ctl[aria-pressed="true"].on .s { color: var(--ok); }
.ctl[aria-pressed="true"].mute { border-color: var(--danger); color: var(--danger); }
.ctl.end { background: var(--danger); border-color: var(--danger); color: #fff; }
.ctl.end .s { color: #ffe1e1; }
.toast { position: fixed; left: 50%; bottom: calc(100px + var(--safe-b)); transform: translateX(-50%); max-width: min(520px, calc(100vw - 24px)); padding: 10px 14px; border-radius: 10px; background: var(--ink); color: #fff; z-index: 50; font-size: 0.92rem; box-shadow: var(--shadow); }
dialog { border: 1px solid var(--line); border-radius: var(--radius); padding: 0; width: min(460px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(20, 33, 61, 0.45); }
.dialog-body { padding: 20px; }

/* face-to-face */
.face { flex: 1; display: grid; grid-template-rows: 1fr auto 1fr; min-height: 0; }
.face-half { display: flex; flex-direction: column; min-height: 0; padding: 12px 16px; }
.face-half.top { background: #eef2fb; }
.face-half.top.flipped { transform: rotate(180deg); }
.face-half .head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.face-half .lines { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding-top: 8px; }
.face-line { font-size: 1.3rem; line-height: 1.35; }
.face-line.own { font-size: 0.95rem; color: var(--muted); }
.face-mid { display: flex; justify-content: center; align-items: center; gap: 10px; padding: 8px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--card); font-size: 0.9rem; }
.listen-dot { width: 12px; height: 12px; border-radius: 50%; background: #cfd6e4; }
.listen-dot[data-state="listening"] { background: var(--ok); }
.listen-dot[data-state="hearing"] { background: var(--ok); box-shadow: 0 0 0 6px rgba(21, 127, 79, 0.2); }
.listen-dot[data-state="speaking"] { background: var(--navy); }
.listen-dot[data-state="thinking"] { background: var(--warn); }

@media (min-width: 900px) {
  .face.side { grid-template-rows: none; grid-template-columns: 1fr auto 1fr; }
  .face.side .face-mid { flex-direction: column; border: 0; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
  .face.side .face-half.top.flipped { transform: none; }
}
@media (max-width: 720px) {
  .hero { grid-template-columns: 1fr; padding-top: 20px; }
  .topbar { padding: 10px 14px; }
  .page { padding: 16px 14px 50px; }
  .ctl { width: 25%; max-width: 96px; }
  .iv { grid-template-columns: 1fr; }
  .iv-actions { justify-content: flex-start; }
}
@media (prefers-reduced-motion: reduce) { .meter span { transition: none; } }
