/* Dense, keyboard-first layout. A reviewer grades a few hundred clips in a
   sitting, so the video is large, the controls never move between clips, and
   nothing animates. */

:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-2: #eef0f4;
  --line: #d7dbe2;
  --ink: #14171c;
  --ink-2: #5b626e;
  --ink-3: #8a919c;
  --accent: #2f6feb;
  --accent-ink: #ffffff;
  --hit: #1a7f4b;
  --miss: #b3341f;
  --warn: #9a6400;
  --warn-bg: #fff6e0;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --radius: 6px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --panel: #1b1e24;
    --panel-2: #23272f;
    --line: #2f343d;
    --ink: #e6e9ee;
    --ink-2: #a4acb9;
    --ink-3: #767e8b;
    --accent: #4c8dff;
    --accent-ink: #0b1220;
    --hit: #4bd08b;
    --miss: #ff7a63;
    --warn: #f0c04a;
    --warn-bg: #2c2410;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 var(--sans);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* -- top bar ------------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 16px;
  height: 48px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 10px; height: 10px; border-radius: 2px;
  background: var(--accent);
}
.brand-text { font-weight: 600; letter-spacing: .02em; }
.brand-instance {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 3px;
}

#nav { display: flex; gap: 2px; margin-right: auto; }
#nav a {
  padding: 6px 10px;
  border-radius: var(--radius);
  color: var(--ink-2);
  font-size: 13px;
}
#nav a:hover { background: var(--panel-2); text-decoration: none; }
#nav a.active { background: var(--accent); color: var(--accent-ink); }

.topbar-right { display: flex; align-items: center; gap: 10px; }

input, select, textarea, button {
  font: inherit;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 5px 8px;
}
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}
button { cursor: pointer; background: var(--panel-2); }
button:hover:not(:disabled) { border-color: var(--ink-3); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink);
                 border-color: transparent; font-weight: 600; }
button.ghost { background: transparent; }
textarea { resize: vertical; min-height: 52px; width: 100%; }

/* -- layout -------------------------------------------------------------- */
.view { padding: 16px; max-width: 1600px; margin: 0 auto; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}
.panel > h2 {
  margin: 0 0 4px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--ink-3);
}
.panel > h2 + .hint { margin-top: 0; }
.hint { margin: 0 0 12px; color: var(--ink-2); font-size: 13px; max-width: 74ch; }

.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.callout {
  border-left: 3px solid var(--warn);
  background: var(--warn-bg);
  color: var(--ink);
  padding: 10px 12px;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin-bottom: 14px;
  font-size: 13px;
  max-width: 90ch;
}
.callout strong { display: block; margin-bottom: 3px; }
.callout.oneline { padding: 6px 12px; font-size: 12px; margin-bottom: 10px; }
.callout.oneline strong { display: inline; margin-right: 6px; }

/* -- tables -------------------------------------------------------------- */
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
th { color: var(--ink-3); font-weight: 600; font-size: 11px;
     text-transform: uppercase; letter-spacing: .05em; }
td.num, th.num { text-align: right; font-family: var(--mono);
                 font-variant-numeric: tabular-nums; }
tbody tr:hover { background: var(--panel-2); }
.scroll-x { overflow-x: auto; }

code, .mono { font-family: var(--mono); font-size: 12px; }

.tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--ink-2);
}
.tag.hit { color: var(--hit); border-color: currentColor; }
.tag.miss { color: var(--miss); border-color: currentColor; }
.tag.warn { color: var(--warn); border-color: currentColor; }

.metric { display: flex; flex-direction: column; gap: 2px; min-width: 96px; }
.metric .value { font-family: var(--mono); font-size: 24px; line-height: 1.1;
                 font-variant-numeric: tabular-nums; }
.metric .label { font-size: 11px; color: var(--ink-3);
                 text-transform: uppercase; letter-spacing: .05em; }
.metrics { display: flex; gap: 26px; flex-wrap: wrap; margin-bottom: 12px; }

.bar { height: 8px; background: var(--panel-2); border-radius: 4px;
       overflow: hidden; display: flex; }
.bar span { display: block; height: 100%; }
.bar .s { background: var(--hit); }
.bar .a { background: color-mix(in srgb, var(--hit) 60%, var(--panel-2)); }
.bar .b { background: color-mix(in srgb, var(--miss) 45%, var(--panel-2)); }
.bar .c { background: var(--miss); }
.bar .todo { background: var(--panel-2); }

/* -- review page --------------------------------------------------------- */
.review-layout {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr) 340px;
  gap: 14px;
  align-items: start;
}
@media (max-width: 1180px) {
  .review-layout { grid-template-columns: 1fr; }
}

.queue { max-height: 76vh; overflow-y: auto; }
.queue-item {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 5px 7px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: none;
  text-align: left;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-2);
}
.queue-item:hover { background: var(--panel-2); }
.queue-item.current { border-color: var(--accent); color: var(--ink); }
.queue-item .dot { width: 7px; height: 7px; border-radius: 50%;
                   background: var(--line); flex: none; }
.queue-item.done .dot { background: var(--hit); }
.queue-item.done.miss .dot { background: var(--miss); }
.queue-item .idx { min-width: 26px; }
.queue-item .grow { flex: 1; overflow: hidden; text-overflow: ellipsis;
                    white-space: nowrap; }

.player { background: #000; border-radius: var(--radius); overflow: hidden;
          display: flex; align-items: center; justify-content: center;
          min-height: 200px; }
/* Capped so the grade and reason controls stay on screen with the video. A
   reviewer who has to scroll for every clip grades a few hundred of them
   slower and stops using the keyboard. */
.player video, .player img { width: 100%; max-height: 40vh; display: block; }
/* Task A watches whole videos rather than four-second segments, so the player
   gets the screen back; there is no grading form competing for it. */
.player.tall video { max-height: 64vh; }
.player .missing { color: #9aa; font-size: 13px; padding: 60px 20px;
                   text-align: center; }

.timeline { position: relative; height: 22px; margin-top: 8px;
            background: var(--panel-2); border-radius: 4px; }
.timeline .seg { position: absolute; top: 0; bottom: 0;
                 background: color-mix(in srgb, var(--accent) 35%, transparent);
                 border-left: 1px solid var(--accent);
                 border-right: 1px solid var(--accent); }
.timeline .pk { position: absolute; top: 0; bottom: 0; width: 2px;
                background: var(--warn); }
.timeline .cur { position: absolute; top: -2px; bottom: -2px; width: 2px;
                 background: var(--ink); }

.grade-row { display: flex; gap: 6px; flex-wrap: wrap; }
.choice {
  display: flex; align-items: baseline; gap: 6px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  font-size: 13px;
}
.choice:hover { border-color: var(--ink-3); }
.choice .key { font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
.choice .lab { color: var(--ink-2); font-size: 12px; }
.choice.on { border-color: var(--accent); background:
             color-mix(in srgb, var(--accent) 14%, var(--panel)); }
.choice.on .lab, .choice.on .key { color: var(--ink); }
.choice .ord { font-family: var(--mono); font-size: 11px; color: var(--accent); }

.reason-groups { display: grid; gap: 6px; }
.reason-group { display: flex; gap: 8px; align-items: flex-start; }
.reason-group > .gl { font-size: 11px; color: var(--ink-3); flex: none;
                      width: 68px; padding-top: 7px; text-align: right; }

.field { margin-top: 10px; }
/* Grade and category side by side: both fit above the fold next to the video,
   which is what keeps the whole grading pass keyboard-only. */
.field-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
              gap: 14px; }
@media (max-width: 900px) { .field-pair { grid-template-columns: 1fr; } }
.field > label { display: block; font-size: 12px; color: var(--ink-3);
                 margin-bottom: 4px; text-transform: uppercase;
                 letter-spacing: .05em; }

.problems { color: var(--miss); font-size: 13px; margin-top: 8px; }
.problems li { margin-bottom: 2px; }

.why-path {
  border-left: 3px solid var(--line);
  background: var(--panel-2);
  padding: 8px 10px;
  border-radius: 0 var(--radius) var(--radius) 0;
}
.why-path.hit { border-left-color: var(--hit); }
.why-path.warn { border-left-color: var(--warn); background: var(--warn-bg); }
.why-path.miss { border-left-color: var(--miss); }

.trace-box { font-family: var(--mono); font-size: 12px; white-space: pre-wrap;
             background: var(--panel-2); padding: 10px; border-radius: var(--radius);
             max-height: 300px; overflow: auto; }

.sidepanel { max-height: 76vh; overflow-y: auto; }
.rules dt { font-size: 12px; color: var(--ink); margin-top: 8px; }
.rules dd { margin: 2px 0 0; font-size: 12px; color: var(--ink-2); }

/* -- markdown ------------------------------------------------------------ */
.md { max-width: 90ch; }
.md h1 { font-size: 22px; margin: 0 0 10px; }
.md h2 { font-size: 17px; margin: 22px 0 8px; padding-bottom: 4px;
         border-bottom: 1px solid var(--line); }
.md h3 { font-size: 14px; margin: 16px 0 6px; }
.md p, .md li { color: var(--ink); }
.md code { background: var(--panel-2); padding: 1px 4px; border-radius: 3px; }
.md pre { background: var(--panel-2); padding: 10px; border-radius: var(--radius);
          overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md table { margin: 10px 0; }
.md blockquote { margin: 10px 0; padding-left: 12px;
                 border-left: 3px solid var(--line); color: var(--ink-2); }

/* -- toast and dialog ---------------------------------------------------- */
.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg);
  padding: 8px 14px; border-radius: var(--radius);
  font-size: 13px; z-index: 50; max-width: 70ch;
}
.toast.bad { background: var(--miss); color: #fff; }

dialog {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); color: var(--ink); max-width: 620px;
  padding: 18px;
}
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog h2 { margin: 0 0 10px; font-size: 15px; }
dialog kbd { font-family: var(--mono); font-size: 11px; background: var(--panel-2);
             border: 1px solid var(--line); border-radius: 3px; padding: 1px 5px; }

a.download {
  display: inline-block;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  color: var(--ink);
  font-weight: 600;
}
a.download:hover { border-color: var(--accent); text-decoration: none; }

.muted { color: var(--ink-3); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.spacer { flex: 1; }
/* Account controls use the existing panel and field styles. */
[hidden] { display: none !important; }
.auth-panel { max-width: 440px; margin: 48px auto; }
.auth-form .field { display: flex; flex-direction: column; gap: 6px; }
.topbar-right { flex-wrap: wrap; }
.topbar { height: auto; min-height: 48px; flex-wrap: wrap; padding: 8px 16px; }
#nav { flex-wrap: wrap; }
#account-scope select { max-width: 240px; }
.readonly-fields { border: 0; padding: 0; margin: 0; min-width: 0; }
.readonly-fields:disabled { opacity: .65; }
.telemetry-status { margin: 10px 0; padding: 8px 10px; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: var(--radius); }
.telemetry-status table { font-size: 12px; width: 100%; }
.telemetry-status th, .telemetry-status td { padding: 4px 8px; }
.telemetry-status .hint { margin: 6px 0 0; }
.truth-edit-categories { min-width: 210px; gap: 4px; }
.truth-edit-categories .choice { padding: 4px 6px; }
