/* Voice ID — an instrument panel, not a landing page.
   Everything is set in monospace so numbers, labels and headings share one
   voice; color appears only where it carries data. Surface, ink, gridline and
   series hues are the values fixed by the spec's chart system. */

:root {
  --paper:    #f2f1ec;
  --surface:  #fcfcfb;
  --inset:    #f7f6f2;
  --ink:      #0b0b0b;
  --ink-2:    #52514e;
  --ink-3:    #898781;
  --rule:     rgba(11, 11, 11, 0.10);
  --rule-soft:rgba(11, 11, 11, 0.06);
  --grid:     #e1e0d9;
  --ok:       #1baf7a;
  --alert:    #e34948;

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: Inter, "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;

  --r: 3px;
}

* { box-sizing: border-box; }

/* An author `display` rule outranks the UA sheet's [hidden] rule, so anything
   toggled through the hidden attribute needs this to actually disappear. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

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

:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 2px; }

/* ───────────────────────────────  gate  ─────────────────────────────── */

.gate {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  padding: 24px;
  background: var(--paper);
}

.gate-card {
  width: min(360px, 100%);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: 30px 28px 26px;
}

.gate-title {
  font-family: var(--mono);
  font-size: 27px; font-weight: 600; letter-spacing: -0.025em;
  margin: 6px 0 8px;
}

.gate-help { margin: 0 0 20px; color: var(--ink-2); font-size: 13.5px; }

.gate-input {
  width: 100%;
  font-family: var(--mono);
  font-size: 19px;
  letter-spacing: 0.28em;
  text-align: center;
  padding: 12px 14px;
  background: var(--inset);
  border: 1px solid var(--rule);
  border-radius: var(--r);
}

.gate-input::placeholder { letter-spacing: 0.28em; color: var(--ink-3); }

.gate-error {
  margin: 12px 0 0;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--alert);
}

.gate-card .btn { margin-top: 16px; }

/* ───────────────────────────────  shell  ────────────────────────────── */

.app { max-width: 1180px; margin: 0 auto; padding: 26px 22px 40px; }

.masthead {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--rule);
}

.masthead-id { display: flex; align-items: center; gap: 14px; }

.mark { color: var(--ink); display: block; }

.wordmark {
  font-family: var(--mono);
  font-size: 22px; font-weight: 600; letter-spacing: -0.03em;
  margin: 0;
}

.tagline { margin: 1px 0 0; font-size: 13px; color: var(--ink-2); }

.colophon {
  display: flex; flex-wrap: wrap; gap: 6px 22px; justify-content: space-between;
  margin-top: 26px; padding-top: 14px;
  border-top: 1px solid var(--rule);
  font-family: var(--mono); font-size: 11px; color: var(--ink-3);
}

/* ───────────────────────────────  grid  ─────────────────────────────── */

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(250px, 0.85fr);
  gap: 18px;
  margin-top: 22px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: 22px 22px 24px;
}

.card-side { grid-column: 2; grid-row: 1 / span 2; }
.card-wide { grid-column: 1; }
.card-full { grid-column: 1 / -1; }

.eyebrow {
  margin: 0;
  font-family: var(--mono);
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--ink-3);
}

.card-title {
  font-family: var(--mono);
  font-size: 25px; font-weight: 600; letter-spacing: -0.025em;
  margin: 5px 0 10px;
}

.card-help { margin: 0 0 18px; font-size: 13.5px; color: var(--ink-2); max-width: 62ch; }

.row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

/* ──────────────────────────────  controls  ──────────────────────────── */

.btn {
  font-family: var(--mono);
  font-size: 13px; letter-spacing: 0.01em;
  padding: 9px 16px;
  border-radius: var(--r);
  border: 1px solid var(--ink);
  background: transparent;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

.btn-primary { background: var(--ink); color: var(--surface); }
.btn-primary:hover { background: #262626; border-color: #262626; }

.btn-quiet { border-color: var(--rule); color: var(--ink-2); }
.btn-quiet:hover { border-color: var(--ink); color: var(--ink); }

.btn-block { display: block; width: 100%; }

.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

.btn.is-recording,
.btn.is-recording:hover { background: var(--alert); border-color: var(--alert); color: #fff; }

.field { display: block; margin-bottom: 16px; }

.field-label {
  display: block;
  font-family: var(--mono);
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--ink-3);
  margin-bottom: 6px;
}

.input {
  width: 100%;
  font-family: var(--mono);
  font-size: 14px;
  padding: 10px 12px;
  background: var(--inset);
  border: 1px solid var(--rule);
  border-radius: var(--r);
}

.input::placeholder { color: var(--ink-3); }

.status {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-2);
}

.status.is-error { color: var(--alert); }
.status.is-done  { color: var(--ok); }

/* ────────────────────────  capture strip (signature)  ───────────────── */

.capture {
  background: var(--inset);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: 8px 10px 6px;
  margin-bottom: 14px;
}

.capture-trace { display: block; width: 100%; height: 48px; }

.capture-meta {
  display: flex; justify-content: space-between; align-items: baseline;
  font-family: var(--mono); font-size: 10.5px;
  text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--ink-3);
  padding-top: 4px;
}

.capture-clock { font-variant-numeric: tabular-nums; letter-spacing: 0.06em; }

.capture.is-live .capture-state { color: var(--alert); }
.capture.is-live .capture-clock { color: var(--ink); }

/* ───────────────────────────  enrolled users  ───────────────────────── */

.user-list { list-style: none; margin: 4px 0 0; padding: 0; }

.user-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--rule-soft);
}

.user-key { width: 9px; height: 9px; border-radius: 2px; flex: none; }

.user-name {
  font-family: var(--mono); font-size: 13.5px;
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.user-count {
  font-family: var(--mono); font-size: 11px; color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.user-delete {
  border: none; background: none; cursor: pointer;
  font-family: var(--mono); font-size: 11px; color: var(--ink-3);
  padding: 2px 4px;
}

.user-delete:hover { color: var(--alert); }

.empty { font-size: 13px; color: var(--ink-3); margin: 10px 0 0; }

/* ────────────────────────────  identify results  ────────────────────── */

.results { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--rule); }

.verdict {
  font-family: var(--mono);
  font-size: 15px; letter-spacing: -0.01em;
  margin: 0 0 14px;
}

.verdict.is-unknown { color: var(--alert); }

.ranking { list-style: none; margin: 0; padding: 0; }

.rank-row {
  display: grid;
  grid-template-columns: minmax(80px, 150px) minmax(0, 1fr) 52px 62px;
  align-items: center;
  gap: 12px;
  padding: 7px 0;
}

.rank-name {
  font-family: var(--mono); font-size: 13.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.rank-track { height: 8px; background: var(--rule-soft); border-radius: 2px; overflow: hidden; }
.rank-fill  { height: 100%; border-radius: 2px; }

.rank-pct {
  font-family: var(--mono); font-size: 13px; text-align: right;
  font-variant-numeric: tabular-nums;
}

.rank-cos {
  font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ───────────────────────────  synthetic meter  ──────────────────────── */

.synthetic {
  margin-top: 18px;
  padding: 14px 16px 12px;
  border: 1px solid;
  border-radius: var(--r);
}

.synthetic.is-genuine   { border-color: rgba(27, 175, 122, 0.45); background: rgba(27, 175, 122, 0.07); }
.synthetic.is-synthetic { border-color: rgba(227, 73, 72, 0.45);  background: rgba(227, 73, 72, 0.07); }

.synthetic-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }

.synthetic-label { font-family: var(--mono); font-size: 13.5px; }
.synthetic.is-genuine   .synthetic-label { color: #147d57; }
.synthetic.is-synthetic .synthetic-label { color: #b32f2e; }

.synthetic-value {
  font-family: var(--mono); font-size: 13px; font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}

.synthetic-track {
  height: 8px; margin-top: 10px;
  background: rgba(11, 11, 11, 0.07);
  border-radius: 2px; overflow: hidden;
}

.synthetic-fill { height: 100%; border-radius: 2px; }
.synthetic.is-genuine   .synthetic-fill { background: var(--ok); }
.synthetic.is-synthetic .synthetic-fill { background: var(--alert); }

.synthetic-note { margin: 9px 0 0; font-size: 11.5px; color: var(--ink-3); }

/* ──────────────────────────────  live mode  ─────────────────────────── */

.live-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

.legend {
  display: flex; flex-wrap: wrap; gap: 6px 20px;
  padding: 10px 0 14px;
  font-family: var(--mono); font-size: 11.5px;
  color: var(--ink-2);
}

.legend-item { display: flex; align-items: center; gap: 7px; }
.legend-key  { width: 16px; height: 2px; border-radius: 1px; flex: none; }

.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.chart { margin: 0; }

.chart-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  padding-bottom: 7px;
}

.chart-title {
  font-family: var(--mono); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--ink-2);
}

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 11.5px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.badge-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.badge.is-unknown { color: var(--ink-3); }

.chart-body { position: relative; }

.chart-body svg { display: block; width: 100%; height: auto; }

.tooltip {
  position: absolute; top: 8px;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: 7px 9px;
  font-family: var(--mono); font-size: 11px;
  box-shadow: 0 1px 0 rgba(11, 11, 11, 0.04);
  min-width: 108px;
}

.tooltip-time { color: var(--ink-3); margin-bottom: 5px; letter-spacing: 0.06em; }

.tooltip-row { display: flex; align-items: center; gap: 7px; padding: 1.5px 0; }
.tooltip-key { width: 10px; height: 2px; border-radius: 1px; flex: none; }
.tooltip-val { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 34px; }
.tooltip-name { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ─────────────────────────────  values table  ───────────────────────── */

.values {
  /* Capped so a name and its numbers stay readable as one row instead of
     drifting to opposite edges of a wide card. */
  width: 100%; max-width: 460px;
  border-collapse: collapse; margin-top: 22px;
  font-family: var(--mono); font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.values th:not(:first-child), .values td:not(:first-child) { width: 74px; }

.values th {
  text-align: right;
  font-weight: 500; font-size: 10.5px;
  text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--ink-3);
  padding: 0 0 7px;
  border-bottom: 1px solid var(--rule);
}

.values th:first-child, .values td:first-child { text-align: left; }

.values td { padding: 7px 0; border-bottom: 1px solid var(--rule-soft); }

.values-name { display: flex; align-items: center; gap: 8px; }
.values-key  { width: 10px; height: 2px; border-radius: 1px; flex: none; }

.values-empty td { color: var(--ink-3); border-bottom: none; }

.values .is-leader { font-weight: 600; }

/* ─────────────────────────────  responsive  ─────────────────────────── */

@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; }
  .card-side, .card-wide, .card-full { grid-column: 1; grid-row: auto; }
  .charts { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .app { padding: 20px 14px 32px; }
  .card { padding: 18px 16px 20px; }
  .card-title { font-size: 22px; }
  .rank-row { grid-template-columns: minmax(64px, 96px) minmax(0, 1fr) 46px 52px; gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
