:root {
  --bg: #000;
  --card: #0b0b0d;
  --card-2: #111114;
  --line: #1f1f24;
  --line-2: #2b2b33;
  --text: #f4f4f6;
  --muted: #8b8b96;
  --cyan: #67e8f9;
  --violet: #a78bfa;
  --green: #4ade80;
  --amber: #fbbf24;
  --red: #f87171;
  --radius: 16px;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.glow {
  position: fixed;
  inset: 0 0 auto 0;
  height: 520px;
  pointer-events: none;
  background:
    radial-gradient(600px 260px at 25% 0%, rgba(103, 232, 249, .13), transparent 70%),
    radial-gradient(600px 260px at 75% 0%, rgba(167, 139, 250, .13), transparent 70%);
}

/* Header / footer */
.top, main, footer { position: relative; max-width: 1040px; margin: 0 auto; padding-left: 20px; padding-right: 20px; }
.top { display: flex; align-items: center; justify-content: space-between; padding-top: 22px; padding-bottom: 22px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: -.01em; }
.logo { width: 28px; height: 28px; }
.pill {
  font-size: 12px; color: var(--muted);
  border: 1px solid var(--line-2); border-radius: 999px; padding: 4px 12px;
}
footer { padding-top: 40px; padding-bottom: 40px; color: var(--muted); font-size: 13px; text-align: center; }

/* Tabs */
.tabs { display: flex; gap: 2px; border: 1px solid var(--line-2); border-radius: 999px; padding: 3px; }
.tab-btn {
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--muted);
  background: transparent; border: none; border-radius: 999px; padding: 6px 16px;
  transition: background .15s, color .15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: #04121a; background: linear-gradient(90deg, var(--cyan), var(--violet)); }

/* Hero */
.hero { padding: 56px 0 24px; text-align: center; }
h1 { font-size: clamp(2.2rem, 6vw, 3.6rem); line-height: 1.08; letter-spacing: -.035em; margin: 0 0 18px; font-weight: 700; }
.grad { background: linear-gradient(90deg, var(--cyan), var(--violet)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lead { max-width: 620px; margin: 0 auto 36px; color: var(--muted); font-size: 1.05rem; }

/* Dropzone */
.dropzone {
  display: block; max-width: 680px; margin: 0 auto; cursor: pointer;
  padding: 44px 24px; border-radius: 20px;
  border: 1.5px dashed var(--line-2); background: var(--card);
  transition: border-color .2s, background .2s, transform .2s;
}
.dropzone:hover, .dropzone:focus-visible, .dropzone.drag { border-color: var(--cyan); background: #08111a; outline: none; }
.dropzone.drag { transform: scale(1.01); }
.dz-icon {
  width: 56px; height: 56px; margin: 0 auto 16px; border-radius: 16px;
  display: grid; place-items: center; color: var(--cyan);
  background: linear-gradient(135deg, rgba(103,232,249,.14), rgba(167,139,250,.14));
  border: 1px solid var(--line-2);
}
.dz-icon svg { width: 26px; height: 26px; }
.dz-title { font-weight: 600; font-size: 1.05rem; }
.dz-title u { text-decoration-color: var(--cyan); text-underline-offset: 3px; }
.dz-sub { color: var(--muted); font-size: 13px; margin-top: 6px; }

.picked {
  max-width: 680px; margin: 0 auto; padding: 20px; text-align: left;
  border: 1px solid var(--line-2); border-radius: 20px; background: var(--card);
}
.picked-name { font-weight: 600; word-break: break-all; }
.picked-meta { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.picked audio, .picked video { width: 100%; margin-bottom: 16px; border-radius: 12px; background: #000; }
.picked-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* Buttons */
.btn {
  font: inherit; font-weight: 600; font-size: 15px; cursor: pointer;
  padding: 11px 22px; border-radius: 12px; border: 1px solid transparent;
  transition: transform .15s, box-shadow .2s, background .2s, border-color .2s;
}
.btn:active { transform: scale(.97); }
.btn.primary { color: #04121a; background: linear-gradient(90deg, var(--cyan), var(--violet)); }
.btn.primary:hover { box-shadow: 0 0 28px rgba(103, 232, 249, .3); }
.btn.ghost { color: var(--text); background: transparent; border-color: var(--line-2); }
.btn.ghost:hover { background: var(--card-2); border-color: #3a3a44; }

/* Alerts */
.alert { max-width: 680px; margin: 18px auto 0; padding: 12px 16px; border-radius: 12px; font-size: 14px; text-align: left; border: 1px solid; }
.alert.error { color: #fecaca; background: rgba(248,113,113,.08); border-color: rgba(248,113,113,.35); }
.alert.note { color: #bae6fd; background: rgba(103,232,249,.07); border-color: rgba(103,232,249,.3); max-width: none; margin: 0 0 16px; }

/* Progress */
.progress { text-align: center; padding: 100px 0; }
.spinner {
  width: 44px; height: 44px; margin: 0 auto 24px; border-radius: 50%;
  border: 3px solid var(--line-2); border-top-color: var(--cyan);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.steps { list-style: none; padding: 0; margin: 24px auto 0; display: inline-block; text-align: left; }
.steps li { color: var(--muted); padding: 5px 0 5px 30px; position: relative; transition: color .3s; }
.steps li::before {
  content: ''; position: absolute; left: 4px; top: 12px; width: 12px; height: 12px;
  border-radius: 50%; border: 2px solid var(--line-2);
}
.steps li.active { color: var(--text); }
.steps li.active::before { border-color: var(--cyan); box-shadow: 0 0 10px var(--cyan); }
.steps li.done { color: var(--muted); }
.steps li.done::before { background: var(--green); border-color: var(--green); }

/* Results */
.results { padding: 24px 0 8px; }
.results-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
h2 { margin: 0; font-size: 1.7rem; letter-spacing: -.02em; }
h3 { margin: 0 0 14px; font-size: 1rem; letter-spacing: -.01em; }
.muted { color: var(--muted); font-size: 14px; word-break: break-all; }
.hint { color: var(--muted); font-size: 13px; margin: -6px 0 14px; }

.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 16px; }
.metrics.two { grid-template-columns: repeat(2, 1fr); }
.metric {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; animation: rise .5s both;
}
.metric .label { color: var(--muted); font-size: 13px; }
.metric .value { font-size: 2rem; font-weight: 700; letter-spacing: -.03em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.metric .value small { font-size: .95rem; font-weight: 500; color: var(--muted); margin-left: 4px; }
.metric .typical { font-size: 12px; color: var(--muted); margin-top: 4px; display: flex; align-items: center; gap: 6px; }
.metric .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line-2); }
.metric.ok .dot { background: var(--green); box-shadow: 0 0 8px var(--green); }
.metric.warn .dot { background: var(--amber); box-shadow: 0 0 8px var(--amber); }
.metric.warn .value { color: var(--amber); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.card-head h3 { margin-bottom: 14px; }

.flags { display: grid; gap: 10px; }
.flag { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; border: 1px solid; font-size: 14px; }
.flag .ic { flex: none; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #000; }
.flag.warn { background: rgba(251,191,36,.07); border-color: rgba(251,191,36,.3); }
.flag.warn .ic { background: var(--amber); }
.flag.note { background: rgba(103,232,249,.06); border-color: rgba(103,232,249,.28); }
.flag.note .ic { background: var(--cyan); }
.flag.ok { background: rgba(74,222,128,.07); border-color: rgba(74,222,128,.3); }
.flag.ok .ic { background: var(--green); }
/* Speech result: one big verdict, then a row per sign */
.verdict {
  --tone: var(--green);
  border-radius: var(--radius); padding: 28px 26px; margin-bottom: 16px; animation: rise .5s both;
  background: color-mix(in srgb, var(--tone) 12%, var(--card)); border: 1px solid color-mix(in srgb, var(--tone) 45%, transparent);
}
.verdict.note { --tone: var(--amber); }
.verdict.warn { --tone: var(--red); }
.verdict .v-label { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.verdict .v-head { font-size: clamp(2.2rem, 7vw, 3.4rem); font-weight: 700; letter-spacing: -.03em; line-height: 1.05; color: var(--tone); margin: 6px 0 10px; }
.verdict p { margin: 0; font-size: 1.05rem; }

.signs { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.sign {
  --tone: var(--muted);
  display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card-2);
}
.sign.found { --tone: var(--red); border-color: color-mix(in srgb, var(--red) 45%, transparent); }
.sign.clear { --tone: var(--green); }
.sign.pending { --tone: var(--cyan); }
.sign .s-ic { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #000; background: var(--tone); }
.sign.na .s-ic { background: var(--line-2); color: var(--muted); }
.sign .s-text { display: grid; gap: 2px; min-width: 0; }
.sign .s-name { font-weight: 600; }
.sign .s-detail { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.sign .s-tag { font-size: 12px; font-weight: 600; color: var(--tone); white-space: nowrap; }
.sign.na { opacity: .7; }
.disclaimer { font-size: 12px; color: var(--muted); margin: 14px 0 0; }

/* Transcript / Pitch graph switch */
.seg-tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--card-2); border: 1px solid var(--line); margin-bottom: 16px; }
.seg-btn { font: inherit; font-size: 14px; font-weight: 600; color: var(--muted); background: none; border: 0; border-radius: 9px; padding: 7px 14px; cursor: pointer; }
.seg-btn.active { color: #04121a; background: linear-gradient(90deg, var(--cyan), var(--violet)); }
.seg-btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

.pitch-graph { overflow-x: auto; margin-bottom: 14px; border-radius: 10px; background: var(--card-2); border: 1px solid var(--line); }
.pitch-graph svg { display: block; }
.g-grid { stroke: var(--line); stroke-width: 1; }
.g-axis { fill: var(--muted); font: 11px var(--mono); }
.g-word { fill: rgba(255,255,255,.025); cursor: pointer; }
.g-word.alt { fill: rgba(255,255,255,.06); }
.g-word.spike { fill: rgba(103,232,249,.18); }
.g-word.unusual { fill: rgba(248,113,113,.25); }
.g-word:hover { fill: rgba(255,255,255,.12); }
.g-label { fill: var(--text); font-size: 12px; }
.g-label.hot { fill: var(--red); font-weight: 700; }
.g-line { fill: none; stroke: var(--cyan); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }

/* Timeline */
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.legend span { display: flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sw.word { background: var(--cyan); }
.sw.long { background: var(--violet); }
.sw.gap { background: repeating-linear-gradient(45deg, rgba(251,191,36,.7) 0 2px, transparent 2px 4px); border: 1px solid rgba(251,191,36,.6); }
.sw.gaze { background: var(--amber); }
.sw.headpose { background: var(--cyan); }
.sw.stim { background: var(--violet); }
.sw.squeeze { background: var(--red); }
.tl-seg { position: absolute; border-radius: 3px; }
.tl-seg.gaze { background: var(--amber); opacity: .8; top: 1px; bottom: 43px; }
.tl-seg.headpose { background: var(--cyan); opacity: .8; top: 15px; bottom: 29px; }
.tl-seg.stim { background: var(--violet); opacity: .8; top: 29px; bottom: 15px; }
.tl-seg.squeeze { background: var(--red); opacity: .8; top: 43px; bottom: 1px; }
.timeline { position: relative; height: 84px; margin-bottom: 14px; }
.tl-track {
  position: absolute; left: 0; right: 0; top: 0; height: 56px;
  background: var(--card-2); border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
}
.tl-word { position: absolute; top: 10px; bottom: 10px; min-width: 2px; border-radius: 3px; background: var(--cyan); opacity: .85; transition: opacity .1s, background .1s; }
.tl-word.long { background: var(--violet); }
.tl-word.active { opacity: 1; box-shadow: 0 0 12px var(--cyan); background: #fff; }
.tl-gap { position: absolute; top: 0; bottom: 0; background: repeating-linear-gradient(45deg, rgba(251,191,36,.28) 0 3px, transparent 3px 7px); }
.tl-head { position: absolute; top: -4px; height: 64px; width: 2px; background: #fff; box-shadow: 0 0 8px #fff; left: 0; pointer-events: none; }
.tl-axis { position: absolute; left: 0; right: 0; top: 62px; height: 20px; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.tl-axis span { position: absolute; transform: translateX(-50%); }
.tl-axis span:first-child { transform: none; }
#player { width: 100%; }

/* Transcript */
.transcript { line-height: 2.1; font-size: 1.02rem; margin-bottom: 14px; }
.w { cursor: pointer; padding: 2px 3px; margin: 0 1px; border-radius: 6px; transition: background .1s, color .1s; }
.w:hover { background: var(--card-2); }
.w.rep { background: rgba(251,191,36,.16); color: var(--amber); }
.w.spike { text-decoration: underline wavy var(--cyan); text-underline-offset: 5px; }
.w.spike.unusual { text-decoration-color: var(--red); color: var(--red); }
.w.active { background: var(--cyan); color: #000; }

/* AI */
.ai { color: #d4d4dc; font-size: 15px; }
.ai h4 { margin: 20px 0 6px; font-size: 1rem; color: var(--text); }
.ai h4:first-child { margin-top: 0; }
.ai p { margin: 8px 0; }
.ai ul, .ai ol { margin: 8px 0; padding-left: 22px; }
.ai li { margin: 4px 0; }
.ai strong { color: var(--text); }
.ai.loading { color: var(--muted); display: flex; align-items: center; gap: 10px; }
.ai .mini { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--violet); animation: spin .8s linear infinite; }
.ai.failed { color: var(--muted); }

/* Word table */
.table-card summary { cursor: pointer; font-weight: 600; }
.word-table { margin-top: 14px; max-height: 360px; overflow: auto; font-family: var(--mono); font-size: 13px; }
.word-table table { width: 100%; border-collapse: collapse; }
.word-table th, .word-table td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); }
.word-table th { color: var(--muted); font-weight: 500; position: sticky; top: 0; background: var(--card); }

/* Audio player: keep it on-theme */
audio { color-scheme: dark; height: 40px; }

@media (max-width: 720px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .hero { padding-top: 32px; }
  .pill { display: none; }
}
@media (max-width: 420px) {
  .metrics { grid-template-columns: 1fr; }
  .picked-actions { flex-direction: column-reverse; }
  .btn { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition: none !important; }
}

/* Recording */
.or { display: flex; align-items: center; gap: 14px; max-width: 680px; margin: 20px auto; color: var(--muted); font-size: 13px; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.record-btn {
  display: inline-flex; align-items: center; gap: 10px; color: var(--text);
  background: var(--card); border-color: var(--line-2);
}
.record-btn:hover { border-color: var(--red); background: #150808; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--red); box-shadow: 0 0 10px var(--red); }
.recorder {
  max-width: 680px; margin: 0 auto; padding: 20px; text-align: left;
  border: 1px solid rgba(248,113,113,.4); border-radius: 20px; background: #0d0606;
}
.rec-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.rec-live { display: flex; align-items: center; gap: 8px; color: var(--red); font-weight: 600; font-size: 14px; }
.rec-live i { width: 10px; height: 10px; border-radius: 50%; background: var(--red); animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; transform: scale(.8); } }
.rec-time { font-family: var(--mono); font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.gaze-badge {
  font-family: var(--mono); font-size: 12px; font-weight: 600; padding: 4px 10px;
  border-radius: 999px; border: 1px solid var(--line-2); color: var(--muted); background: var(--card-2);
  transition: color .15s, border-color .15s, background .15s;
}
.gaze-badge.on { color: var(--green); border-color: rgba(74,222,128,.4); background: rgba(74,222,128,.08); }
.gaze-badge.away { color: var(--amber); border-color: rgba(251,191,36,.4); background: rgba(251,191,36,.08); }
.btn:disabled { opacity: .45; cursor: default; pointer-events: none; }
.v-startup {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-radius: 999px;
  background: rgba(0,0,0,.7); color: #fff; font-size: 13px; white-space: nowrap; pointer-events: none;
}
.v-startup .mini { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255,255,255,.3); border-top-color: var(--cyan); animation: spin .8s linear infinite; }
.live-counts { font-family: var(--mono); font-size: 12px; color: var(--muted); text-align: center; margin-top: 12px; }
.rec-meter { width: 100%; height: 64px; display: block; margin-bottom: 16px; }
.rec-actions { display: flex; justify-content: flex-end; gap: 10px; }
@media (max-width: 420px) { .rec-actions { flex-direction: column-reverse; } .record-btn { width: 100%; justify-content: center; } }

/* AI tables and emphasis */
.ai .tbl { overflow-x: auto; margin: 12px 0; border: 1px solid var(--line); border-radius: 12px; }
.ai table { width: 100%; border-collapse: collapse; font-size: 14px; }
.ai th, .ai td { text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.ai th { color: var(--text); background: var(--card-2); font-weight: 600; }
.ai tr:last-child td { border-bottom: 0; }
.ai code { font-family: var(--mono); font-size: .9em; background: var(--card-2); padding: 1px 6px; border-radius: 6px; }
