:root {
  --bg: #0f1216;
  --panel: #171b21;
  --panel-2: #1e232b;
  --line: #2b313b;
  --text: #e6e9ee;
  --muted: #9aa3b0;
  --accent: #4cc2ff;
  --accent-ink: #06202e;
  --good: #3ecf8e;
  --warn: #f5c451;
  --bad: #ff6b6b;
  --radius: 8px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0 0 16px; font-weight: 600; }
h2 { font-size: 15px; margin: 24px 0 10px; font-weight: 600; }
h3 { font-size: 13px; margin: 14px 0 6px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12px; }
.hidden { display: none !important; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.right { margin-left: auto; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 4px; height: 48px; padding: 0 16px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.brand { font-weight: 700; letter-spacing: .02em; margin-right: 16px; color: var(--text); }
.brand span { color: var(--accent); }
.nav a { color: var(--muted); padding: 6px 10px; border-radius: 6px; }
.nav a.active, .nav a:hover { color: var(--text); background: var(--panel-2); text-decoration: none; }
.who { color: var(--muted); font-size: 13px; margin-left: auto; display: flex; gap: 10px; align-items: center; }

main { padding: 24px; max-width: 1280px; margin: 0 auto; }
main.full { max-width: none; padding: 0; height: calc(100vh - 48px); }

/* forms */
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=password], input[type=search], input[type=number], select, textarea {
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; min-width: 0;
}
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { width: 100%; resize: vertical; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
label.field input:not([type=checkbox]), label.field select, div.field input:not([type=checkbox]) { width: 100%; }
.field > label.check { margin-top: 6px; width: fit-content; }
label.check { display: flex; gap: 6px; align-items: center; cursor: pointer; }
button, .btn {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; color: var(--text);
}
button:hover, .btn:hover { border-color: #3d4552; text-decoration: none; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.danger { color: var(--bad); }
button:disabled { opacity: .45; cursor: default; }
button.small, .btn.small { padding: 3px 8px; font-size: 12px; }
button.on { border-color: var(--accent); color: var(--accent); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card + .card { margin-top: 16px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.error { color: var(--bad); margin: 8px 0; }
.ok { color: var(--good); }
.notice { background: rgba(245, 196, 81, .1); border: 1px solid rgba(245, 196, 81, .35); border-radius: 6px; padding: 10px 12px; margin-bottom: 14px; }

/* login */
.login { max-width: 360px; margin: 10vh auto; }
.login .brand { font-size: 22px; display: block; margin-bottom: 18px; }
.login .btn.google { width: 100%; justify-content: center; padding: 10px; margin-bottom: 6px; }
.login form { margin-top: 12px; }

/* tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 500; }
tr.group td { background: var(--panel-2); font-weight: 600; }
tr.sub td:first-child { padding-left: 22px; }
.table-wrap { overflow-x: auto; }
.badge { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); }
.badge.mirage { color: #d6a8ff; border-color: #5b3f78; }
.badge.unet { color: #7fe0c0; border-color: #2c6152; }
.badge.graph { color: #f0c27a; border-color: #6b5530; }
.badge.reviewed { color: var(--good); border-color: #1f6b4b; }
.badge.in_progress { color: var(--warn); border-color: #6a5326; }
.badge.failed { color: var(--bad); border-color: #7a3030; }
.progress { height: 6px; background: var(--panel-2); border-radius: 3px; overflow: hidden; min-width: 80px; }
.progress > div { height: 100%; background: var(--good); }
.progress > div.part { background: var(--warn); }
.progress > div.partly { background: var(--accent); }
/* tasks */
.task-banner { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; white-space: nowrap; }
.task-banner:empty { display: none; }
.pane.task { border-left-color: #f5c451; }
.pane.task .pane-head h3 { color: #f5c451; }
.pre { white-space: pre-wrap; }
.badge.task-label { color: var(--accent); border-color: #2d5577; }
.badge.task-agreement { color: #f29ad8; border-color: #6d3560; }
.badge.task-review { color: #8fe3b0; border-color: #2f6b4a; }
.sign-box { display: flex; flex-direction: column; gap: 6px; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius); margin: 6px 0; }
.signature { padding: 6px 8px; border-left: 3px solid var(--good); background: var(--panel-2); border-radius: 3px; margin-top: 4px; }
.person-progress { gap: 6px; flex-wrap: nowrap; }
.person-progress .who-name { min-width: 80px; }
.person-progress .progress { flex: 1; min-width: 60px; }

/* splits and dataset versions */
.badge.split.train, .split-select.train { color: #7cc4ff; border-color: #2d5577; }
.badge.split.val, .split-select.val { color: var(--warn); border-color: #6a5326; }
.badge.split.test, .split-select.test { color: #f29ad8; border-color: #6d3560; }
.badge.split.none, .split-select.none { color: var(--muted); }
select.split-select { padding: 1px 4px; font-weight: 400; font-size: 11px; border-radius: 10px; }
.card.inset { background: var(--panel-2); margin: 8px 0 12px; }
input.ratio, div.field input.ratio { width: 64px; }
.badge + .muted, td b + .badge { margin-left: 6px; }

/* tags */
.tag-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 10px; font-size: 11px; line-height: 18px;
  background: rgba(240, 163, 94, .12); border: 1px solid rgba(240, 163, 94, .45); color: #f6c79a; white-space: nowrap; font-weight: 400; }
button.tag { cursor: pointer; }
button.tag:hover { border-color: #f0a35e; }
.img-tag .tag { background: transparent; border-style: dashed; }
.tag-count { color: var(--muted); }
.tag .tag-x { background: none; border: 0; padding: 0 0 0 2px; color: inherit; font-size: 13px; line-height: 1; opacity: .7; }
.tag .tag-x:hover { opacity: 1; }
.tag-editor { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; }
.tag-editor:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.tag-editor .tag-chips { margin: 0; }
.tag-editor.readonly { background: none; border: 0; padding: 0; }
.tag-editor input.tag-input { flex: 1; min-width: 120px; border: 0; background: none; padding: 3px 2px; outline: none; }
div.field { margin-bottom: 12px; }
div.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.layer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 4px 10px; margin: 8px 0; }

/* upload */
.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 36px; text-align: center; color: var(--muted); }
.drop.over { border-color: var(--accent); color: var(--text); }
.bar { height: 10px; background: var(--panel-2); border-radius: 5px; overflow: hidden; margin: 8px 0; }
.bar > div { height: 100%; background: var(--accent); width: 0; transition: width .2s; }
pre.log { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 10px; max-height: 260px; overflow: auto; font: 12px/1.4 var(--mono); white-space: pre-wrap; }

/* editor */
.editor { display: grid; grid-template-columns: 1fr 330px; height: 100%; }
.stage { position: relative; display: flex; flex-direction: column; min-width: 0; }
.stage-head { display: flex; gap: 10px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--panel); white-space: nowrap; }
.crumbs { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; }
.crumbs b { color: var(--text); font-weight: 600; }
.canvas-wrap { position: relative; flex: 1; min-height: 0; background: #000; }
.canvas-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; }
.canvas-tools { position: absolute; top: 8px; right: 8px; z-index: 2; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; max-height: calc(100% - 16px); }
.canvas-tools > button { background: rgba(23, 27, 33, 0.85); backdrop-filter: blur(2px); }
.layer-tool-list { background: rgba(23, 27, 33, 0.92); backdrop-filter: blur(2px); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; overflow-y: auto; min-width: 150px; display: flex; flex-direction: column; gap: 4px; }
.contrast-tool { background: rgba(23, 27, 33, 0.92); backdrop-filter: blur(2px); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 220px; }
.contrast-tool label.field { margin-bottom: 6px; }
.contrast-tool input[type=range] { width: 100%; }
.canvas-wrap canvas.contrast { cursor: move; }
.status { padding: 5px 12px; border-top: 1px solid var(--line); background: var(--panel); font: 12px var(--mono); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side { border-left: 1px solid var(--line); background: var(--bg); overflow-y: auto; padding: 10px 10px 30px; }
/* each concern is its own card, with a coloured edge so overlays / annotation / review never blur together */
.pane { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--line); border-radius: 8px; padding: 8px 12px 10px; margin-bottom: 10px; }
.pane > * + * { margin-top: 6px; }
.pane-head { display: flex; align-items: baseline; gap: 8px; margin: 0 0 6px; }
.pane-head h3 { margin: 0; flex: 1; }
.pane-meta { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60%; }
.pane.overlays { border-left-color: #9b7bd4; }
.pane.overlays .pane-head h3 { color: #c4a8f0; }
.pane.annotation { border-left-color: var(--accent); }
.pane.annotation .pane-head h3 { color: var(--accent); }
.pane.review { border-left-color: var(--good); }
.pane.review .pane-head h3 { color: var(--good); }
.pane.fold > summary { cursor: pointer; list-style: none; margin: 0; }
.pane.fold > summary::-webkit-details-marker { display: none; }
.pane.fold > summary h3::before { content: "▸ "; color: var(--muted); }
.pane.fold[open] > summary h3::before { content: "▾ "; }
.pane.fold:not([open]) { padding-bottom: 8px; }
.pane.fold[open] > summary { margin-bottom: 6px; }
.rev-mark { color: var(--good); font-size: 12px; }
.pane.tags { border-left-color: #f0a35e; }
.pane.tags .pane-head h3 { color: #f0a35e; }
.history .entry.plain { cursor: default; }
.enface { width: 100%; display: block; cursor: pointer; background: #000; border-radius: 4px; image-rendering: pixelated; }
.frame-nav { display: flex; gap: 6px; align-items: center; margin-top: 8px; }
.frame-nav input[type=range] { flex: 1; min-width: 0; }
.legend { display: grid; grid-template-columns: 1fr; gap: 4px; }
.legend label { display: flex; gap: 6px; align-items: center; }
.swatch { width: 18px; height: 0; border-top: 2px solid; display: inline-block; }
.swatch.dash-mirage { border-top-style: dashed; }
.swatch.dash-unet { border-top-style: dotted; }
.swatch.dash-graph { border-top-style: double; border-top-width: 3px; }
.tools { display: flex; gap: 4px; flex-wrap: wrap; }
.seg-row { padding: 6px 0; }
.seg-row + .seg-row { border-top: 1px solid var(--line); }
.seg-row .mono { word-break: break-all; }
.seg-row .notice { margin: 4px 0 0; padding: 6px 8px; }
.layers { border: 1px solid var(--line); border-radius: 6px; margin: 4px 0 10px; max-height: 300px; overflow-y: auto; }
.layer { display: flex; align-items: center; gap: 8px; padding: 4px 8px; font-size: 13px; cursor: pointer; border-left: 3px solid transparent; }
.layer + .layer { border-top: 1px solid var(--line); }
.layer:hover { background: var(--panel-2); }
.layer.active { background: var(--panel-2); border-left-color: var(--accent); font-weight: 600; }
.layer.focus .grow::after { content: " · review pass"; color: var(--muted); font-weight: 400; font-size: 11px; }
.layer .muted { font-size: 11px; }
label.layer { cursor: pointer; }
.history { max-height: 300px; overflow-y: auto; }
.history .entry { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; margin-bottom: 6px; cursor: pointer; font-size: 12px; }
.history .entry.sel { border-color: var(--accent); }
.history .entry .what { color: var(--muted); }
.kbd { font: 11px var(--mono); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; color: var(--muted); }
.toast { position: fixed; right: 16px; bottom: 16px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; max-width: 420px; z-index: 100; box-shadow: 0 6px 24px rgba(0,0,0,.4); }
.toast.bad { border-color: var(--bad); }
.qr { background: #fff; padding: 10px; border-radius: 8px; width: 220px; }

@media (max-width: 900px) {
  .editor { grid-template-columns: 1fr; grid-template-rows: 60vh auto; }
  .side { border-left: 0; border-top: 1px solid var(--line); }
  main { padding: 16px; }
  .topbar { overflow-x: auto; }
}

/* grading guide */
.guide { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 32px; align-items: start; }
.gtoc { position: sticky; top: 64px; display: flex; flex-direction: column; gap: 2px; max-height: calc(100vh - 80px); overflow-y: auto; }
.gtoc a { color: var(--muted); padding: 3px 8px; border-radius: 6px; font-size: 13px; }
.gtoc a:hover { color: var(--text); background: var(--panel-2); text-decoration: none; }
.gbody { max-width: 1000px; }
.gsec { scroll-margin-top: 60px; border-top: 1px solid var(--line); padding-top: 4px; margin-top: 24px; }
.gsec h2 { font-size: 17px; }
.gsec p, .gsec li { max-width: 78ch; }
.gsec li { margin-bottom: 4px; }
.rules li { margin-bottom: 8px; }
.gfig { display: block; width: 100%; height: auto; border-radius: 6px; background: #0b0d10; margin: 8px 0; }
.gex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 16px; margin: 14px 0; }
.gex { margin: 0; background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.gex.good { border-top-color: var(--good); }
.gex.bad { border-top-color: var(--bad); }
.gex .gfig { margin: 0 0 8px; }
.gex-head { display: flex; gap: 8px; align-items: baseline; margin-bottom: 4px; }
.gex .verdict { font-weight: 700; font-size: 12px; white-space: nowrap; }
.gex.good .verdict { color: var(--good); }
.gex.bad .verdict { color: var(--bad); }
.gex p { margin: 0 0 4px; font-size: 13px; }
.gtable { margin: 10px 0 14px; font-size: 13px; }
.gtable td { vertical-align: top; }
.checklist li::marker { content: '☐  '; }
code { font: 12px var(--mono); background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }
@media (max-width: 900px) {
  .guide { grid-template-columns: 1fr; gap: 12px; }
  .gtoc { position: static; flex-direction: row; flex-wrap: wrap; max-height: none; }
}

/* audit pages and record reports */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.tab { padding: 6px 12px; border-radius: var(--radius) var(--radius) 0 0; color: var(--muted); text-decoration: none; }
.tab.active { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-bottom-color: var(--panel); margin-bottom: -1px; }
.filters { flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.filters input, .filters select { width: auto; min-width: 120px; }
.nowrap { white-space: nowrap; }
.flag { color: var(--warn); }
.entry-line { padding: 4px 0; border-bottom: 1px solid var(--line); }
.ok { color: var(--good); }
.kv th { text-align: left; color: var(--muted); font-weight: normal; padding-right: 16px; white-space: nowrap; vertical-align: top; }
.record-image { width: 100%; max-width: 900px; height: auto; display: block; margin-bottom: 10px; image-rendering: pixelated; }
@media print {
  :root { --bg: #fff; --panel: #fff; --panel-2: #f2f2f2; --line: #bbb; --text: #000; --muted: #444; --good: #0a6b3a; --warn: #8a5a00; color-scheme: light; }
  body { background: #fff; color: #000; }
  .topbar, .no-print, .toast { display: none !important; }
  .card { break-inside: avoid; border: 1px solid #bbb; box-shadow: none; }
  #app { padding: 0; max-width: none; }
  a { color: #000; text-decoration: none; }
}
