/* Palette: belt black, mat blue, cool paper. Scores are drawn as a belt tip with tape stripes. */
:root {
  --paper: #eceff3;
  --card: #ffffff;
  --ink: #14171c;
  --muted: #5d6573;
  --line: #d9dee5;
  --mat: #1d4f91;
  --mat-soft: #e3ebf6;
  --on-mat: #ffffff;
  --bar: #14171c;
  --bar-text: #f3f2ec;
  --good: #23704a;
  --good-bg: #e1f1e8;
  --bad: #b1302a;
  --bad-bg: #f8e4e2;
  --mid: #835608;
  --mid-bg: #f7ecd6;
  --belt: #121418;
  --tape: #f3f2ec;
  --tape-off: rgba(255, 255, 255, .13);

  --display: "Archivo", system-ui, sans-serif;
  --body: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --radius: 12px;
  --tabbar: 60px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0e1116;
    --card: #171b22;
    --ink: #e8ebf0;
    --muted: #9aa3b2;
    --line: #2a303a;
    --mat: #7ea6e6;
    --mat-soft: #1b2a42;
    --on-mat: #0b1220;
    --bar: #0a0c10;
    --good: #6fcf98;
    --good-bg: #173325;
    --bad: #f08a80;
    --bad-bg: #3a1f1d;
    --mid: #e9bd62;
    --mid-bg: #352a17;
    --belt: #050608;
  }
}

/* --- Base --------------------------------------------------------------- */

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 var(--body);
}
a { color: var(--mat); text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--mat); outline-offset: 2px; border-radius: 4px; }

h1, h2, h3, .eyebrow, .brand, label, .pill, .tabs a {
  font-family: var(--display);
}
h1 { font-size: 1.6rem; line-height: 1.15; font-weight: 800; font-stretch: 112%; margin: 0; letter-spacing: -.01em; }
h2 {
  font-size: .82rem; font-weight: 700; font-stretch: 125%; text-transform: uppercase;
  letter-spacing: .08em; margin: 0 0 1rem;
}
h3 {
  font-size: .74rem; font-weight: 700; font-stretch: 125%; text-transform: uppercase;
  letter-spacing: .08em; color: var(--muted); margin: 1.5rem 0 .6rem;
}
.eyebrow {
  margin: 0 0 .35rem; font-size: .72rem; font-weight: 600; font-stretch: 125%;
  text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
}
.subtitle { margin: .2rem 0 0; font-size: 1.05rem; color: var(--muted); }
.mono, code, time { font-family: var(--mono); font-size: .88em; }
.muted { color: var(--muted); }
.hint { margin: 0; font-size: .88rem; color: var(--muted); }

/* --- Header and tab bar -------------------------------------------------- */

.top {
  display: flex; align-items: center; gap: 1.5rem;
  padding: .7rem 20px; padding-top: max(.7rem, env(safe-area-inset-top));
  background: var(--bar); color: var(--bar-text);
}
.brand {
  display: flex; align-items: center; gap: .6rem;
  color: inherit; text-decoration: none; font-weight: 800; font-stretch: 125%;
  text-transform: uppercase; letter-spacing: .06em; font-size: .85rem; white-space: nowrap;
}
/* A belt tip: black with one white stripe. */
.brand-mark {
  width: 22px; height: 12px; border-radius: 2px; background: #000;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25);
  background-image: linear-gradient(90deg, transparent 12px, var(--tape) 12px 16px, transparent 16px);
}
.tabs { display: flex; gap: .25rem; }
.tabs a {
  color: var(--bar-text); opacity: .72; text-decoration: none;
  font-size: .82rem; font-weight: 600; font-stretch: 112%; letter-spacing: .02em;
  padding: .4rem .7rem; border-radius: 6px;
}
.tabs a:hover { opacity: 1; }
.tabs a[aria-current] { opacity: 1; background: rgba(255, 255, 255, .1); }
.who { margin-left: auto; display: flex; align-items: center; gap: 1rem; font-size: .9rem; }
.who a { color: var(--bar-text); text-decoration: none; opacity: .8; }
.who a[aria-current], .who a:hover { opacity: 1; }
.who button.link { color: var(--bar-text); opacity: .6; font-size: .9rem; }
.who button.link:hover { opacity: 1; }

@media (max-width: 720px) {
  .top { padding-left: 16px; padding-right: 16px; }
  .tabs {
    position: fixed; z-index: 10; left: 0; right: 0; bottom: 0;
    gap: 0; background: var(--bar); border-top: 1px solid rgba(255, 255, 255, .08);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabs a {
    flex: 1; text-align: center; height: var(--tabbar); border-radius: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: .74rem; font-stretch: 100%; position: relative;
  }
  .tabs a[aria-current] { background: none; }
  /* Active tab gets a tape stripe across the top. */
  .tabs a[aria-current]::before {
    content: ""; position: absolute; top: 0; left: 28%; right: 28%; height: 3px;
    background: var(--tape); border-radius: 0 0 2px 2px;
  }
  body.has-nav main { padding-bottom: calc(var(--tabbar) + 24px + env(safe-area-inset-bottom)); }
}

/* --- Layout ------------------------------------------------------------- */

main { max-width: 1040px; margin: 0 auto; padding: 20px 16px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.25rem; margin-bottom: 1rem;
}
.card.flush { padding: 1.25rem 0 0; overflow: hidden; }
.card.flush .pad { padding-left: 1.25rem; padding-right: 1.25rem; }
.card.flush .split.pad { margin-bottom: 1rem; }
.card.flush .split.pad h2 { margin: 0; }
.card.flush > p.pad { padding-bottom: 1.25rem; }
.card.narrow-form { max-width: 460px; }
details.card summary {
  cursor: pointer; font-family: var(--display); font-weight: 600; font-stretch: 112%;
  font-size: .9rem; color: var(--muted);
}
details.card[open] summary { margin-bottom: .5rem; }

.dash { display: grid; gap: 0 1rem; align-items: start; }
@media (min-width: 900px) {
  .dash { grid-template-columns: 340px 1fr; }
  .dash .start { position: sticky; top: 1rem; }
}

.split { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.split h2 { margin: 0; }
.columns { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.5rem; }
@media (max-width: 640px) { .columns { grid-template-columns: 1fr; } }

.back {
  display: inline-block; margin-bottom: .75rem; font-size: .9rem; text-decoration: none;
  font-family: var(--display); font-weight: 600; font-stretch: 112%;
}

.flash, .warn {
  padding: .75rem 1rem; border-radius: 10px; margin-bottom: 1rem; border-left: 4px solid;
}
.flash { background: var(--card); border-color: var(--mat); }
.warn { background: var(--mid-bg); color: var(--mid); border-color: currentColor; }
.warn code { font-size: .82em; word-break: break-word; }

/* --- Forms -------------------------------------------------------------- */

form.stack { display: flex; flex-direction: column; gap: 1rem; }
form.row, .row { display: flex; gap: .75rem; align-items: flex-end; flex-wrap: wrap; }
.row > label:not(.check) { flex: 1 1 160px; }
form.inline { display: inline; }
label {
  display: flex; flex-direction: column; gap: .35rem;
  font-size: .74rem; font-weight: 600; font-stretch: 112%; letter-spacing: .02em; color: var(--muted);
}
label.check {
  flex-direction: row; align-items: center; gap: .5rem; min-height: 44px;
  font-size: .9rem; color: var(--ink);
}
label.check input { width: 1.15rem; height: 1.15rem; accent-color: var(--mat); }
/* 16px text keeps iOS from zooming into fields on focus. */
input, select, textarea {
  font: 16px/1.4 var(--body); color: var(--ink); background: var(--paper);
  border: 1px solid var(--line); border-radius: 8px; padding: .6rem .75rem;
  width: 100%; min-width: 0; min-height: 44px;
}
input[type="checkbox"] { width: auto; min-height: 0; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--mat); box-shadow: 0 0 0 3px var(--mat-soft); }
select {
  appearance: none; padding-right: 2.25rem; text-overflow: ellipsis;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: right 1.1rem center, right .8rem center;
  background-size: 5px 5px; background-repeat: no-repeat;
}
textarea { resize: vertical; }

button, .button {
  font: 600 .95rem/1 var(--display); font-stretch: 112%; letter-spacing: .02em; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 8px; padding: 0 1.1rem; min-height: 44px; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
}
button:hover, .button:hover { border-color: var(--muted); }
button.primary, .button.primary { background: var(--mat); border-color: var(--mat); color: var(--on-mat); }
button.primary:hover, .button.primary:hover { filter: brightness(1.1); }
button.block { width: 100%; min-height: 52px; font-size: 1.05rem; }
button.small, .button.small { min-height: 36px; padding: 0 .85rem; font-size: .85rem; }
button:disabled { opacity: .45; cursor: not-allowed; filter: none; }
button.link { border: 0; background: none; padding: 0; min-height: 0; font-family: var(--body); font-weight: 400; color: var(--muted); }

/* --- Data tables -------------------------------------------------------- */

table.data { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.data th, table.data td { text-align: left; padding: .75rem .5rem; border-top: 1px solid var(--line); vertical-align: middle; }
table.data th {
  padding-top: .5rem; padding-bottom: .5rem; font-family: var(--display); font-size: .66rem; font-weight: 700;
  font-stretch: 112%; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); white-space: nowrap;
}
table.data :is(th, td):first-child { padding-left: 1.25rem; }
table.data :is(th, td):last-child { padding-right: 1.25rem; }
table.data .num { text-align: right; white-space: nowrap; }
table.data .end { text-align: right; }
table.data .nowrap { white-space: nowrap; }
table.data td.mono { font-size: .85rem; color: var(--muted); }
table.data td.when { font-size: .78rem; line-height: 1.3; white-space: nowrap; color: var(--muted); }
table.data td.sub { color: var(--muted); font-size: .92rem; }
table.data td.result { white-space: nowrap; }
table.data td.result .pill { margin-left: .35rem; }
table.data tr.inactive td, table.data tr.inactive td a { color: var(--muted); }

/* The whole row is the tap target; the link in it stretches over the row. */
table.data tr.link-row { position: relative; }
table.data tr.link-row:hover td { background: var(--paper); }
table.data a.stretch { color: inherit; font-weight: 700; text-decoration: none; }
table.data a.stretch::after { content: ""; position: absolute; inset: 0; }

button.quiet {
  min-height: 36px; padding: 0 .25rem; border: 0; background: none; color: var(--mat);
  font-size: .85rem;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (max-width: 640px) {
  table.data th, table.data td { padding-left: .35rem; padding-right: .35rem; }
  table.data :is(th, td):first-child { padding-left: 16px; }
  table.data :is(th, td):last-child { padding-right: 16px; }
  table.data td.when span { display: block; }
  table.data td.mono { font-size: .78rem; }
  table.data .clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  /* On phones the result column shows the outcome only; the belt carries the score. */
  table.data td.result .belt { display: flex; margin: 0 0 .3rem auto; }
  table.data td.result .pill { margin-left: 0; }
}

/* --- Pills -------------------------------------------------------------- */

.pill {
  display: inline-block; padding: .15rem .55rem; border-radius: 999px;
  font-size: .7rem; font-weight: 700; font-stretch: 112%; text-transform: uppercase; letter-spacing: .05em;
  background: var(--line); color: var(--ink); white-space: nowrap; vertical-align: middle;
}
.pill.pass, .pill.ended, .pill.easy { background: var(--good-bg); color: var(--good); }
.pill.fail, .pill.failed, .pill.hard, .pill.error { background: var(--bad-bg); color: var(--bad); }
.pill.in_progress, .pill.dialing, .pill.normal, .pill.no_answer, .pill.grading { background: var(--mid-bg); color: var(--mid); }
.pill.pending, .pill.skipped { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); }

/* --- Belt score ---------------------------------------------------------- */

.belt {
  --w: 6px; --h: 16px; --gap: 3px;
  display: inline-flex; justify-content: flex-end; gap: var(--gap); flex: none;
  width: 66px; height: var(--h); padding: 3px 6px; border-radius: 2px; vertical-align: middle;
  background-color: var(--belt);
  /* Stitching lines that run the length of a belt. */
  background-image: repeating-linear-gradient(0deg, rgba(255, 255, 255, .05) 0 1px, transparent 1px 3px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06);
}
.belt i {
  width: var(--w); border-radius: 1px;
  background: linear-gradient(to top, var(--tape) calc(var(--f) * 100%), var(--tape-off) 0);
}
.belt.large { --w: 14px; --h: 40px; --gap: 9px; width: 100%; padding: 6px 18px; border-radius: 4px; }

.verdict { margin: .25rem 0 1rem; }
.verdict-score { display: flex; align-items: baseline; gap: .75rem; margin-bottom: .6rem; }
.big-score { font-family: var(--display); font-weight: 800; font-stretch: 125%; font-size: 2.6rem; line-height: 1; }
.big-score small { font-size: .45em; color: var(--muted); font-weight: 600; }
.reason { font-size: 1.05rem; font-weight: 700; margin: .75rem 0 0; }

@media (prefers-reduced-motion: no-preference) {
  .verdict .belt.large i { animation: tape .45s cubic-bezier(.2, .8, .3, 1) both; animation-delay: calc(.15s + var(--i) * .12s); }
  @keyframes tape { from { transform: scaleY(0); transform-origin: bottom; } }
}

/* --- Call detail --------------------------------------------------------- */

.meta { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; margin: .75rem 0 0; color: var(--muted); }
.live { display: flex; align-items: center; gap: .5rem; margin: .75rem 0 0; font-size: .9rem; color: var(--mid); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
@media (prefers-reduced-motion: no-preference) {
  .dot { animation: pulse 1.6s ease-in-out infinite; }
  @keyframes pulse { 50% { opacity: .25; } }
}
audio { width: 100%; margin-top: 1rem; }

.points { list-style: none; margin: 0; padding: 0; }
.points li { position: relative; padding-left: 1.1rem; margin: .4rem 0; }
.points li::before { content: ""; position: absolute; left: 0; top: .55em; width: 6px; height: 6px; border-radius: 1px; }
.points.good li::before { background: var(--good); }
.points.next li::before { background: var(--mat); }

.facts { list-style: none; margin: 0; padding: 0; }
.facts li { background: var(--bad-bg); border-radius: 8px; padding: .6rem .8rem; margin-bottom: .5rem; display: grid; gap: .15rem; }
.facts s { color: var(--bad); text-decoration-thickness: 1px; }

.rubric { list-style: none; margin: 0; padding: 0; }
.rubric li { padding: .85rem 0; border-top: 1px solid var(--line); }
.rubric-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.rubric-score { display: flex; align-items: center; gap: .5rem; }
.rubric q { display: block; margin-top: .4rem; font-style: italic; color: var(--muted); }
.rubric p { margin: .35rem 0 0; }

.transcript { display: flex; flex-direction: column; gap: .5rem; }
.transcript p { margin: 0; padding: .6rem .85rem; border-radius: 12px; max-width: 88%; }
.transcript p.parent { background: var(--paper); border-bottom-left-radius: 3px; }
.transcript p.staff { background: var(--mat-soft); margin-left: auto; border-bottom-right-radius: 3px; }
.transcript b {
  display: block; font-family: var(--display); font-size: .68rem; font-weight: 700; font-stretch: 112%;
  text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: .1rem;
}
pre { white-space: pre-wrap; background: var(--paper); padding: .75rem; border-radius: 8px; font: .8rem/1.5 var(--mono); overflow-wrap: anywhere; }
.events { padding-left: 1.1rem; font-size: .9rem; }

/* --- Login --------------------------------------------------------------- */

body.login { background: var(--bar); min-height: 100vh; }
.card.narrow { max-width: 380px; margin: 12vh auto 0; padding: 1.75rem; }
.card.narrow .belt { margin-bottom: 1.25rem; }
.card.narrow h1 { font-stretch: 125%; text-transform: uppercase; letter-spacing: .03em; font-size: 1.35rem; }
.card.narrow > p { margin: .35rem 0 1.5rem; }

/* Phones: cards run edge to edge and stack flush, divided by a hairline,
   so content keeps a single 16px gutter and no space goes to margins. */
@media (max-width: 640px) {
  main { padding: 0; }
  .card { border-radius: 0; border: 0; border-bottom: 1px solid var(--line); padding: 1.1rem 16px; margin: 0; }
  .card.flush { padding: 1.1rem 0 0; }
  .card.flush .pad { padding-left: 16px; padding-right: 16px; }
  .flash, .warn { border-radius: 0; margin: 0; padding-left: 12px; padding-right: 16px; }
  .back { display: block; margin: 0; padding: .75rem 16px 0; background: var(--card); }
  .belt.large { padding-left: 12px; padding-right: 12px; }
  .transcript p { max-width: 92%; }
  .card.narrow { margin: 10vh 16px 0; border-radius: var(--radius); border: 1px solid var(--line); padding: 1.5rem 1.25rem; }
}

/* --- Portraits ----------------------------------------------------------- */

.avatar {
  --size: 40px;
  width: var(--size); height: var(--size); flex: none; border-radius: 50%;
  /* Faces sit in the upper part of the frame, so anchor the crop there. */
  object-fit: cover; object-position: 50% 22%;
  background: var(--paper); box-shadow: inset 0 0 0 1px var(--line);
}
.avatar.small { --size: 28px; }
.avatar.large { --size: 96px; border-radius: 12px; }
/* Head-and-shoulders silhouette until a portrait exists. */
.avatar.empty {
  display: inline-block;
  background:
    radial-gradient(circle at 50% 38%, var(--line) 0 18%, transparent 19%),
    radial-gradient(ellipse 42% 30% at 50% 100%, var(--line) 0 98%, transparent 100%),
    var(--paper);
}
.with-avatar { display: flex; align-items: center; gap: .65rem; }
.with-avatar > span { min-width: 0; }
.scenario-pick { align-items: flex-end; }
.scenario-pick .avatar { --size: 44px; }
.scenario-pick label { flex: 1; min-width: 0; }
.portrait-panel { display: flex; align-items: center; gap: 1rem; margin: 0 0 1.25rem; }
.portrait-panel p { margin: 0 0 .5rem; font-size: .9rem; }
.block { display: block; }
.error-text { color: var(--bad); }
