/* magic-crop-localmaxxing dashboard — premium dark (Linear/Raycast-style).
   Near-black surfaces, ONE indigo accent for chrome, hairline borders, crisp
   type, calm motion. Semantic data-viz colours (verdicts, motion tiers, ok/
   warn/err) are kept meaningful. No external CSS/fonts/CDNs (offline-capable). */

:root {
  /* base surfaces — near-black, cool, subtle elevation steps */
  --bg:      #0a0b0f;
  --bg2:     #0c0d12;
  --panel:   #14161d;   /* cards */
  --panel2:  #0f1117;   /* insets / inputs / wells */
  --panel3:  #191c24;   /* hover surfaces */
  /* text */
  --ink:     #f3f4f7;
  --ink-dim: #cdd1db;
  --muted:   #969cab;
  --faint:   #646b7c;
  /* hairlines (alpha so they read as edges, not fills) */
  --line:    rgba(255,255,255,.07);
  --line2:   rgba(255,255,255,.12);
  --line3:   rgba(255,255,255,.18);
  /* accent — one confident indigo for all chrome */
  --accent:      #6e79f0;
  --accent2:     #98a1ff;
  --accent-soft: rgba(110,121,240,.13);
  --accent-line: rgba(110,121,240,.34);
  --focus:       rgba(110,121,240,.30);
  /* semantic / status */
  --ok: #34d399; --warn: #f0b24a; --err: #f87171;
  /* verdicts */
  --hard: #f87171; --soft: #f0b24a; --fp: #6b7280; --backstop: #b794f6;
  /* motion tiers */
  --slow: #6e79f0; --medium: #34d399; --fast: #f0b24a; --very_fast: #f87171;
  /* headline keyframe-recovery marker + dense-seed colour */
  --recovered: #2dd4bf; --dense: #b794f6;
  /* shape + depth */
  --radius: 14px; --radius-sm: 10px; --radius-xs: 7px;
  --shadow:       0 1px 2px rgba(0,0,0,.35), 0 8px 24px -12px rgba(0,0,0,.6);
  --shadow-hover: 0 1px 2px rgba(0,0,0,.4), 0 16px 42px -16px rgba(0,0,0,.72);
  --glow: 0 0 0 1px var(--accent-line), 0 10px 36px -12px rgba(110,121,240,.45);
  --ease: cubic-bezier(.2,.7,.1,1);
  --ease-out: cubic-bezier(.22,.68,0,1.06);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1100px 520px at 82% -10%, rgba(110,121,240,.10), transparent 60%),
    radial-gradient(900px 500px at 0% 0%, rgba(110,121,240,.045), transparent 55%),
    var(--bg);
  color: var(--ink);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent2); text-decoration: none; }
a:hover { color: #b9c0ff; text-decoration: none; }

code, .mono { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace; }

::selection { background: rgba(110,121,240,.32); color: #fff; }

/* thin, unobtrusive scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--line2) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 6px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--line3); background-clip: padding-box; }

/* ---------- top progress bar ---------- */
#topProgressBar {
  position: fixed; top: 0; left: 0; height: 2px; width: 0; z-index: 9000;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  box-shadow: 0 0 14px rgba(110,121,240,.7);
  transition: width .3s ease, opacity .4s ease;
  pointer-events: none; opacity: 0;
}
#topProgressBar.active { opacity: 1; }

/* ---------- header ---------- */
header {
  padding: 16px 28px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(20,22,29,.72), rgba(10,11,15,.55));
  backdrop-filter: saturate(150%) blur(12px);
  -webkit-backdrop-filter: saturate(150%) blur(12px);
  position: sticky; top: 0; z-index: 100;
}
.header-inner { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.brand { display: flex; align-items: center; gap: 11px; flex-wrap: wrap; }
/* CSS-only logo mark — a rounded gradient diamond */
.brand::before {
  content: ""; width: 22px; height: 22px; flex: 0 0 auto; border-radius: 7px;
  background: linear-gradient(145deg, var(--accent2), var(--accent));
  box-shadow: 0 2px 10px rgba(110,121,240,.5), inset 0 1px 0 rgba(255,255,255,.35);
  transform: rotate(45deg) scale(.86); transform-origin: center;
}
h1 { font-size: 18px; margin: 0; font-weight: 750; letter-spacing: -.03em; }
h1 .lm { color: var(--muted); font-weight: 600; }
.tagpill {
  font-size: 10px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--accent2); background: var(--accent-soft);
  border: 1px solid var(--accent-line); padding: 3px 10px; border-radius: 999px;
}
.flow { color: var(--faint); font-size: 11.5px; margin-top: 4px; letter-spacing: .01em; }
.flow b { color: var(--muted); font-weight: 500; }
.flow .arr { color: rgba(255,255,255,.16); margin: 0 3px; }

/* header actions: logout + advanced toggle */
.header-actions { display: flex; align-items: center; gap: 14px; }
.logout-link {
  font-size: 12.5px; font-weight: 600; color: var(--muted);
  border: 1px solid var(--line2); border-radius: var(--radius-xs); padding: 5px 12px;
  transition: color .14s, border-color .14s, background .14s;
}
.logout-link:hover { color: var(--ink); border-color: var(--line3); background: var(--panel3); }

.adv-toggle-wrap {
  display: flex; align-items: center; gap: 9px;
  font-size: 12.5px; color: var(--muted); font-weight: 600; user-select: none;
}
.adv-toggle-wrap label { cursor: pointer; }
.switch { position: relative; display: inline-block; width: 34px; height: 19px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; background: var(--panel2); border-radius: 999px;
  cursor: pointer; transition: background .2s, border-color .2s; border: 1px solid var(--line2);
}
.switch .slider::before {
  content: ""; position: absolute; height: 13px; width: 13px; left: 2px; top: 2px;
  background: var(--muted); border-radius: 50%; transition: transform .2s var(--ease), background .2s;
}
.switch input:checked + .slider { background: var(--accent); border-color: transparent; }
.switch input:checked + .slider::before { transform: translateX(15px); background: #fff; }

/* ---------- two-column layout ---------- */
.layout { display: flex; align-items: flex-start; max-width: 1560px; margin: 0 auto; }
.wrap { flex: 1; min-width: 0; max-width: 1180px; margin: 0 auto; padding: 28px 28px 80px; }

.sidebar {
  flex: 0 0 290px; width: 290px;
  position: sticky; top: 78px; max-height: calc(100vh - 94px);
  display: flex; flex-direction: column;
  margin: 28px 0 0 22px; padding: 14px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.side-head {
  display: flex; align-items: baseline; gap: 8px; margin: 2px 4px 11px;
  font-size: 11px; color: var(--muted); font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
}
.side-head .icon { color: var(--accent2); }
.side-head .count { color: var(--faint); font-weight: 600; text-transform: none; letter-spacing: 0; }
.run-filter {
  width: 100%; margin-bottom: 7px;
  background: var(--panel2); color: var(--ink);
  border: 1px solid var(--line2); border-radius: var(--radius-xs);
  padding: 8px 11px; font-size: 12.5px; font-family: inherit; outline: none;
  transition: border-color .14s, box-shadow .14s;
}
.run-filter::placeholder { color: var(--faint); }
.run-filter:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.recent-toggle {
  display: flex; align-items: center; gap: 6px; margin: 0 4px 10px;
  font-size: 11.5px; color: var(--faint); cursor: pointer; user-select: none;
}
.recent-toggle input { accent-color: var(--accent); cursor: pointer; margin: 0; }
.runs-foot { margin: 8px 4px 2px; font-size: 11px; color: var(--faint); text-align: center; font-style: italic; }
.sidebar .runs { overflow-y: auto; flex: 1; padding-right: 2px; }

@media (max-width: 1080px) {
  .layout { flex-direction: column; }
  .sidebar { position: static; width: auto; align-self: stretch; margin: 20px 22px 0; max-height: 320px; }
}

/* ---------- cards ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
  transition: box-shadow .25s var(--ease), border-color .2s;
  animation: cardIn .34s var(--ease-out) both;
}
.card:hover { border-color: var(--line2); box-shadow: var(--shadow-hover); }
#uploadCard:hover { box-shadow: var(--shadow); }

@keyframes cardIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
/* NOTE: no stagger delays — animation-delay + fill-mode:both freezes delayed
   cards at opacity 0 when the animation clock stalls (headless screenshots;
   display:none -> block re-triggers). All cards fade in together. */

.card-title {
  font-size: 11px; color: var(--muted); font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em; margin: 0 0 16px;
  display: flex; align-items: center; gap: 9px;
}
.card-title .count { color: var(--faint); font-weight: 600; letter-spacing: 0; text-transform: none; }
.card-title .icon { color: var(--accent2); font-size: 13px; }

/* ---------- upload card — hero drop zone ---------- */
.upload-row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }

/* the file zone spans the full first row (hero); tracker + Analyze wrap below */
.filewrap {
  flex: 1 1 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; text-align: center;
  border: 1.5px dashed var(--line2); border-radius: var(--radius); padding: 30px 22px;
  background:
    radial-gradient(420px 160px at 50% 0%, rgba(110,121,240,.06), transparent 70%),
    var(--panel2);
  cursor: pointer; position: relative;
  transition: border-color .16s var(--ease), background .16s, box-shadow .16s;
}
.filewrap:hover { border-color: var(--accent-line); }
.filewrap.drag-over { border-color: var(--accent); border-style: solid; box-shadow: var(--glow); }
.filewrap input { display: none; }
.filewrap .drop-icon {
  width: 48px; height: 48px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; line-height: 1; color: var(--accent2);
  background: var(--accent-soft); border: 1px solid var(--accent-line); border-radius: 50%;
  transition: transform .18s var(--ease-out);
}
.filewrap:hover .drop-icon { transform: translateY(-2px); }
.filewrap.drag-over .drop-icon { transform: scale(1.18); }
.filewrap .fhint { color: var(--muted); font-size: 14px; }
.filewrap .fname { color: var(--ink); font-size: 14px; font-weight: 600; max-width: 88%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.field { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
#go { margin-left: auto; }   /* push Analyze to the end of the second row */

select, input[type=number], input[type=text], input[type=password] {
  background: var(--panel2); color: var(--ink);
  border: 1px solid var(--line2); border-radius: var(--radius-xs);
  padding: 8px 11px; font-size: 13px; font-family: inherit; outline: none;
  transition: border-color .14s, box-shadow .14s;
}
input::placeholder { color: var(--faint); }
select:focus, input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
input[type=number] { width: 92px; font-family: ui-monospace, monospace; }

.btn {
  background: var(--accent); color: #fff; border: 1px solid transparent;
  border-radius: var(--radius-sm); padding: 9px 20px; font-size: 13.5px; font-weight: 600;
  cursor: pointer; letter-spacing: -.005em;
  box-shadow: 0 1px 2px rgba(0,0,0,.3), inset 0 1px 0 rgba(255,255,255,.14);
  transition: background .14s, box-shadow .14s, transform .1s, filter .14s;
  display: inline-flex; align-items: center; gap: 8px; position: relative; overflow: hidden;
}
.btn:hover { filter: brightness(1.08); box-shadow: 0 3px 14px rgba(110,121,240,.4), inset 0 1px 0 rgba(255,255,255,.16); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .42; cursor: default; filter: none; box-shadow: none; transform: none; }
.btn.ghost {
  background: var(--panel2); color: var(--ink-dim);
  border: 1px solid var(--line2); box-shadow: none; font-weight: 600;
  padding: 7px 14px; font-size: 13px;
}
.btn.ghost:hover { background: var(--panel3); border-color: var(--line3); color: var(--ink); filter: none; box-shadow: none; }

.btn-spinner {
  display: none; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.32); border-top-color: #fff;
  animation: spin .65s linear infinite; flex: 0 0 auto;
}
.btn.uploading .btn-spinner { display: block; }

.hint { color: var(--muted); font-size: 12px; margin-top: 14px; line-height: 1.6; }
.hint code { color: var(--accent2); }

/* ---------- knob panel ---------- */
.knobs-toggle {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  color: var(--muted); font-size: 13px; font-weight: 600; user-select: none;
  margin-top: 6px; padding: 4px 0; transition: color .14s;
}
.knobs-toggle .chev { transition: transform .18s var(--ease); display: inline-block; color: var(--faint); }
.knobs-toggle.open .chev { transform: rotate(90deg); }
.knobs-toggle:hover { color: var(--ink); }
.knobs { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 14px; }
.knobs.collapsed { display: none; }
.knob-actions { display: flex; gap: 10px; margin-top: 12px; align-items: center; }
.knob-note { color: var(--faint); font-size: 11.5px; }
.knob-group {
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0; margin-bottom: 12px;
  overflow: hidden; background: var(--panel2);
}
.knob-group > summary {
  cursor: pointer; padding: 10px 14px; font-weight: 650; font-size: 12.5px;
  color: var(--ink-dim); list-style: none; display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.015); transition: background .12s;
}
.knob-group > summary:hover { background: rgba(255,255,255,.03); }
.knob-group > summary::-webkit-details-marker { display: none; }
.knob-group > summary::before { content: "▸"; color: var(--faint); transition: transform .15s var(--ease); }
.knob-group[open] > summary::before { transform: rotate(90deg); }
.knob-group .knob-body {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr));
  gap: 10px 16px; padding: 14px;
}
.knob { display: flex; flex-direction: column; gap: 4px; }
.knob label { color: var(--muted); font-size: 11.5px; font-family: ui-monospace, monospace; }
.knob .desc { color: var(--faint); font-size: 10.5px; }
.knob.bool { flex-direction: row; align-items: center; gap: 9px; }
.knob.bool label { font-size: 12px; }
.knob input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }
.knob.full { grid-column: 1 / -1; }
.knob.full input[type=text] { width: 100%; }

/* ---------- overall progress header (N / total stages · active · elapsed) ---------- */
.progress-head { margin: -2px 0 16px; }
.progress-head .ph-row {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 9px;
}
.progress-head .ph-count { font-size: 14px; color: var(--ink-dim); font-weight: 600; }
.progress-head .ph-count b {
  color: var(--ink); font-size: 19px; font-weight: 750; margin-right: 1px;
  font-variant-numeric: tabular-nums;
}
.progress-head .ph-active {
  font-size: 12px; color: var(--accent2); font-weight: 600;
  background: var(--accent-soft); border: 1px solid var(--accent-line);
  border-radius: 999px; padding: 2px 11px; text-transform: capitalize;
  display: inline-flex; align-items: center; gap: 7px;
}
.progress-head .ph-active::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent2);
  box-shadow: 0 0 8px rgba(152,161,255,.8); animation: qpulse 1.3s ease-in-out infinite;
}
.progress-head .ph-elapsed {
  margin-left: auto; font-size: 12.5px; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.progress-head .ph-bar {
  height: 6px; background: var(--panel2); border: 1px solid var(--line);
  border-radius: 999px; overflow: hidden;
}
.progress-head .ph-bar > i {
  display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  box-shadow: 0 0 12px rgba(110,121,240,.5);
  transition: width .5s var(--ease);
}
.progress-head.done .ph-bar > i { background: linear-gradient(90deg, var(--ok), #5fe0a3); box-shadow: 0 0 12px rgba(52,211,153,.45); }
.progress-head.error .ph-bar > i { background: var(--err); box-shadow: none; }

/* ---------- stage timeline ---------- */
.stages { display: flex; flex-direction: column; gap: 1px; }
.stage {
  display: flex; align-items: center; gap: 13px; font-size: 13.5px;
  padding: 8px 10px; border-radius: var(--radius-sm); position: relative;
  transition: background .2s;
}
.stage + .stage::before {
  content: ""; position: absolute; left: 19px; top: -2px; width: 2px; height: 9px;
  background: var(--line2);
}
.stage.done + .stage::before { background: var(--ok); }
.dot {
  width: 22px; height: 22px; border-radius: 50%; flex: 0 0 auto;
  border: 2px solid var(--line2); display: flex; align-items: center;
  justify-content: center; font-size: 11px; background: var(--panel2);
  z-index: 1; transition: background .25s, border-color .25s, transform .25s var(--ease-out);
}
.stage.done .dot { background: var(--ok); border-color: var(--ok); color: #04140c; animation: dotPop .3s var(--ease-out); }
@keyframes dotPop { 0% { transform: scale(.6); opacity: .5; } 60% { transform: scale(1.18); } 100% { transform: scale(1); opacity: 1; } }
.stage.running .dot {
  border-color: var(--accent); border-top-color: transparent;
  animation: spin .7s linear infinite; background: transparent;
  box-shadow: 0 0 12px rgba(110,121,240,.55);
}
/* the active stage clearly highlighted: accent-tinted row + a left accent bar */
.stage.running {
  background: var(--accent-soft);
  box-shadow: inset 2px 0 0 var(--accent);
}
.stage.running .nm { color: var(--ink); }
.stage.error .dot { background: var(--err); border-color: var(--err); color: #fff; }
.stage.skipped .dot { border-style: dashed; color: var(--muted); }
.stage.pending { opacity: .42; }
@keyframes spin { to { transform: rotate(360deg); } }
.stage .nm { font-weight: 600; min-width: 130px; text-transform: capitalize; color: var(--ink-dim); }
.stage .dt { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage .el {
  margin-left: auto; color: var(--muted); font-size: 12px;
  font-variant-numeric: tabular-nums; background: var(--panel2);
  border: 1px solid var(--line); border-radius: var(--radius-xs); padding: 1px 8px;
}

/* ---------- summary chips ---------- */
.summary { display: flex; gap: 10px; flex-wrap: wrap; margin: 4px 0 0; }
.chip-stat {
  background: var(--panel2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 9px 14px; font-size: 12.5px; color: var(--muted);
  transition: border-color .15s, background .15s;
}
.chip-stat:hover { border-color: var(--line2); background: var(--panel3); }
.chip-stat b { color: var(--ink); font-size: 15px; font-weight: 750; margin-right: 5px; font-variant-numeric: tabular-nums; }

/* ---------- video ---------- */
video { width: 100%; max-height: 56vh; background: #000; border-radius: var(--radius-sm); display: block; border: 1px solid var(--line); }
.crop-video { max-width: 320px; margin: 0 auto; }

.video-shimmer { width: 100%; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--panel2); overflow: hidden; position: relative; }
.video-shimmer.wide { aspect-ratio: 16 / 9; max-height: 56vh; }
.video-shimmer.portrait { aspect-ratio: 9 / 16; max-width: 320px; margin: 0 auto; }
.video-shimmer::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,.05) 50%, transparent 100%);
  animation: shimmer 1.6s linear infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* ---------- timeline tracks ---------- */
.lane { margin: 16px 0; }
.lane-h { font-size: 11px; color: var(--muted); margin-bottom: 7px; text-transform: uppercase; letter-spacing: .06em; font-weight: 650; }
.track { position: relative; height: 46px; background: var(--panel2); border: 1px solid var(--line); border-radius: var(--radius-xs); cursor: pointer; overflow: hidden; transition: border-color .15s; }
.track:hover { border-color: var(--line2); }
.track.tall { height: 56px; }
.seg { position: absolute; top: 0; bottom: 0; border-right: 1px solid var(--line); display: flex; flex-direction: column; justify-content: center; padding: 0 9px; overflow: hidden; white-space: nowrap; font-size: 12px; transition: background .12s; }
.seg:last-child { border-right: none; }
.seg.alt { background: rgba(255,255,255,.022); }
.seg:hover { background: var(--accent-soft); }
.seg .ci { font-weight: 700; }
.seg .cs { color: var(--muted); font-size: 11px; }

/* ---- crop inspector ---- */
.inspect-stage { position: relative; width: 100%; aspect-ratio: 16/9; background: #000; border-radius: var(--radius-sm); overflow: hidden; }
.inspect-stage video { position: absolute; inset: 0; width: 100%; height: 100%; display: block; object-fit: contain; visibility: hidden; }
.inspect-stage canvas { position: absolute; inset: 0; pointer-events: none; }
.inspect-readout { margin: 10px 0 6px; font-size: 13px; color: var(--ink); min-height: 18px; }
.inspect-controls { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.btn.sm { padding: 5px 11px; font-size: 12px; font-weight: 600; border-radius: var(--radius-xs); }
.btn.sm.off { opacity: .42; }
.tick { position: absolute; top: 0; bottom: 0; z-index: 2; }

.mark { position: absolute; top: 0; bottom: 0; width: 3px; margin-left: -1.5px; z-index: 3; }
.mark .tag { position: absolute; top: 2px; left: 6px; font-size: 10px; color: var(--ink); background: rgba(0,0,0,.7); padding: 1px 6px; border-radius: 4px; white-space: nowrap; }
.cutline { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #fff; z-index: 4; }
.cutline.backstop { background: var(--backstop); }
.kf { position: absolute; bottom: 0; width: 1px; height: 10px; background: var(--muted); opacity: .7; z-index: 2; }
.playhead { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #fff; z-index: 6; pointer-events: none; opacity: .85; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; color: var(--muted); font-size: 11.5px; margin: 9px 0 0; align-items: center; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }

/* ---------- clip cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px,1fr)); gap: 14px; }
.clip { background: var(--panel2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; transition: border-color .15s, box-shadow .18s, transform .18s var(--ease-out); }
.clip:hover { border-color: var(--line2); box-shadow: 0 6px 22px -10px rgba(0,0,0,.6); transform: translateY(-1px); }
.clip-h { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; flex-wrap: wrap; }
.badge { font-size: 11px; font-weight: 750; padding: 3px 10px; border-radius: 999px; color: #06120a; letter-spacing: .02em; }
.manno { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
.clip .ci { font-weight: 750; color: var(--ink); }
.clip .rng { color: var(--muted); font-size: 12px; margin-left: auto; font-variant-numeric: tabular-nums; cursor: pointer; }
.clip .rng:hover { color: var(--accent2); }
.clip .subj { font-size: 13.5px; margin-bottom: 7px; font-weight: 600; }
.clip .subj .none { color: var(--muted); font-style: italic; font-weight: 400; }
.clip .meta { color: var(--muted); font-size: 11.5px; }
.clip .err { color: var(--err); font-size: 12.5px; background: rgba(248,113,113,.08); border: 1px solid rgba(248,113,113,.24); border-radius: var(--radius-xs); padding: 7px 10px; }

.grounded-pill { font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: rgba(52,211,153,.13); color: #5fe0a3; border: 1px solid rgba(52,211,153,.32); }
.grounded-pill.partial { background: rgba(240,178,74,.13); color: var(--soft); border-color: rgba(240,178,74,.34); }
.grounded-pill.zero { background: rgba(107,114,128,.14); color: var(--muted); border-color: var(--line2); }
.recovered-pill { font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: rgba(45,212,191,.15); color: var(--recovered); border: 1px solid rgba(45,212,191,.42); }

.kfrow { position: relative; height: 8px; background: var(--line); border-radius: 4px; margin: 9px 0 4px; }
.kfrow i { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--accent); }

.kfseed { font-size: 11.5px; color: var(--muted); margin: 11px 0 6px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.kfseed b { color: var(--ink); }
.kfseed .hint { color: var(--faint); font-style: italic; }
.kfstrip { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 4px; }
.kfthumb { position: relative; flex: 0 0 auto; width: 128px; cursor: pointer; }
.kfthumb img { width: 100%; border-radius: 6px; display: block; border: 1px solid var(--line); transition: transform .15s; }
.kfthumb:hover img { transform: scale(1.03); }
.kfthumb.recovered img { border-color: var(--recovered); box-shadow: 0 0 0 1px var(--recovered), 0 0 12px rgba(45,212,191,.35); }
.kfthumb .bbox { position: absolute; border: 2px solid var(--accent2); box-shadow: 0 0 0 1px rgba(0,0,0,.6); border-radius: 2px; pointer-events: none; }
.kfthumb.recovered .bbox { border-color: var(--recovered); }
.kfthumb .miss { position: absolute; left: 2px; right: 2px; top: 2px; font-size: 9.5px; color: var(--soft); text-align: center; background: rgba(0,0,0,.55); border-radius: 4px; padding: 1px 0; }
.kfthumb .rec-flag { position: absolute; left: 2px; bottom: 22px; font-size: 9.5px; font-weight: 800; color: #04231f; background: var(--recovered); border-radius: 4px; padding: 1px 5px; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.kfthumb .kt { font-size: 10px; color: var(--muted); text-align: center; margin-top: 3px; font-variant-numeric: tabular-nums; }

/* ---------- judge cards ---------- */
.jcard { background: var(--panel2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 13px 15px; margin-top: 11px; border-left: 3px solid var(--line2); cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.jcard:hover { border-color: var(--line2); box-shadow: 0 4px 16px -8px rgba(0,0,0,.5); }
.jhead { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.rtag { font-size: 11px; color: var(--muted); border: 1px solid var(--line); padding: 2px 8px; border-radius: 999px; }
.rtag.src { color: var(--backstop); border-color: rgba(183,148,246,.4); }
.jreason { font-size: 13px; margin-bottom: 10px; color: var(--ink-dim); }
.strip { display: flex; gap: 7px; overflow-x: auto; }
.frame { flex: 0 0 auto; width: 142px; }
.frame img { width: 100%; border-radius: 6px; display: block; border: 1px solid var(--line); }
.frame.before img { border-color: var(--accent); }
.frame.after img { border-color: var(--err); }
.frame .flab { font-size: 10px; color: var(--muted); margin-top: 3px; display: flex; justify-content: space-between; }
.frame .flab b { text-transform: uppercase; letter-spacing: .03em; }
.frame.before .flab b { color: var(--accent2); }
.frame.after .flab b { color: var(--err); }

details.collapser { margin-top: 4px; }
details.collapser > summary { cursor: pointer; color: var(--muted); font-size: 13px; padding: 4px 0; user-select: none; font-weight: 600; }
details.collapser > summary:hover { color: var(--ink); }

/* ---------- latency breakdown ---------- */
.timings { display: flex; flex-direction: column; gap: 6px; }
.trow { display: flex; align-items: center; gap: 12px; font-size: 12.5px; }
.trow .tn { min-width: 120px; color: var(--muted); text-transform: capitalize; }
.trow .tbar { flex: 1; height: 10px; background: var(--panel2); border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
.trow .tbar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width .4s ease; }
.trow .tv { min-width: 56px; text-align: right; font-variant-numeric: tabular-nums; }
.trow.total { margin-top: 4px; padding-top: 7px; border-top: 1px solid var(--line); }
.trow.total .tn, .trow.total .tv { color: var(--ink); font-weight: 700; }
.trow.total .tbar { border: none; background: none; }

/* ---------- crop result ---------- */
.crop-clips { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.crop-clip { display: flex; align-items: center; gap: 10px; font-size: 12.5px; }
.crop-clip .cc-name { min-width: 42px; font-weight: 700; }
.crop-clip .cc-bar { flex: 1; height: 14px; border-radius: 5px; background: var(--panel2); border: 1px solid var(--line); overflow: hidden; position: relative; }
.crop-clip .cc-bar > i { display: block; height: 100%; }
.crop-clip .cc-bar > i.tracked { background: linear-gradient(90deg, rgba(52,211,153,.55), rgba(52,211,153,.9)); }
.crop-clip .cc-bar > i.fallback { background: repeating-linear-gradient(45deg, rgba(107,114,128,.45), rgba(107,114,128,.45) 6px, rgba(107,114,128,.25) 6px, rgba(107,114,128,.25) 12px); width: 100%; }
.crop-clip .cc-meta { min-width: 130px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.crop-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

/* ---------- plays band ---------- */
.plays-band { display: flex; flex-wrap: wrap; gap: 10px; margin: 4px 0 0; }
.play-pill { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; background: var(--panel2); border: 1px solid var(--line2); border-radius: 999px; padding: 6px 14px; cursor: pointer; transition: border-color .15s, background .15s, box-shadow .15s; font-size: 13px; }
.play-pill:hover { border-color: var(--accent-line); background: var(--accent-soft); }
.play-pill.multi-shot { border-color: rgba(183,148,246,.35); }
.play-pill.multi-shot:hover { border-color: var(--dense); }
.play-pill .pp-subj { font-weight: 600; color: var(--ink); }
.play-pill .pp-shots { color: var(--muted); font-size: 11.5px; }
.play-pill .pp-tracker { font-size: 10px; font-weight: 800; padding: 2px 7px; border-radius: 999px; background: rgba(183,148,246,.14); color: #c9a8ff; border: 1px solid rgba(183,148,246,.3); }
.play-drift { font-size: 10px; font-weight: 800; padding: 2px 7px; border-radius: 999px; background: rgba(240,178,74,.16); color: var(--warn); border: 1px solid rgba(240,178,74,.4); }

.play-detail { background: var(--panel2); border: 1px solid var(--line2); border-radius: var(--radius-sm); padding: 14px 16px; margin-top: 12px; display: none; }
.play-detail.open { display: block; }
.play-detail-h { font-size: 11.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.play-seed-strip { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 4px; }
.play-seed-thumb { position: relative; flex: 0 0 auto; text-align: center; }
.play-seed-thumb canvas { display: block; border-radius: 6px; border: 1px solid var(--dense); box-shadow: 0 0 0 1px rgba(183,148,246,.25), 0 0 10px rgba(183,148,246,.2); }
.play-seed-thumb .pst-t { font-size: 9.5px; color: var(--dense); margin-top: 3px; font-variant-numeric: tabular-nums; font-weight: 700; }
.drift-sparkline-wrap { margin-top: 10px; display: flex; align-items: center; gap: 10px; }
.drift-sparkline-wrap .ds-label { font-size: 11px; color: var(--warn); font-weight: 700; white-space: nowrap; }
.drift-sparkline { display: block; border-radius: 5px; background: rgba(0,0,0,.3); }

/* ---------- past runs (sidebar rows) ---------- */
.runs { display: flex; flex-direction: column; gap: 6px; }
.run {
  display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto;
  column-gap: 8px; row-gap: 2px; padding: 9px 11px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  cursor: pointer; font-size: 12.5px;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.run:hover { border-color: var(--line2); background: var(--panel3); }
.run.active { border-color: var(--accent-line); background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.run .rn { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; grid-column: 1; grid-row: 1; display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--ink-dim); }
.run .rn .nm { overflow: hidden; text-overflow: ellipsis; }
.run .rid { grid-column: 1; grid-row: 2; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; color: var(--accent2); opacity: .85; }
.run .rmeta { grid-column: 1 / -1; grid-row: 3; color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.run .tbadge { font-size: 10px; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: rgba(183,148,246,.16); color: #c9a8ff; border: 1px solid rgba(183,148,246,.35); }
.run .ebadge { font-size: 10px; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: rgba(248,113,113,.16); color: var(--err); border: 1px solid rgba(248,113,113,.35); }
.run .rbadge { font-size: 10px; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent2); border: 1px solid var(--accent-line); }
.run .del { flex: 0 0 auto; width: 28px; height: 28px; line-height: 1; background: none; border: 1px solid var(--line2); border-radius: var(--radius-xs); color: var(--muted); font-size: 16px; cursor: pointer; transition: background .14s, border-color .14s, color .14s; display: flex; align-items: center; justify-content: center; }
.run .del:hover { background: var(--err); border-color: var(--err); color: #fff; }

/* skeleton shimmer for past runs loading */
.skel { background: linear-gradient(90deg, var(--panel2) 25%, var(--line) 50%, var(--panel2) 75%); background-size: 200% 100%; animation: skelMove 1.4s ease-in-out infinite; border-radius: var(--radius-xs); }
.skel-row { display: flex; align-items: center; gap: 12px; padding: 13px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 7px; }
.skel-text { height: 14px; border-radius: 5px; }
.skel-badge { height: 18px; width: 50px; border-radius: 999px; }
@keyframes skelMove { from { background-position: 200% center; } to { background-position: -200% center; } }

/* ---------- queue + cancel (live progress) ---------- */
.queue-banner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background:
    linear-gradient(180deg, var(--accent-soft), transparent),
    var(--panel2);
  border: 1px solid var(--accent-line); border-radius: var(--radius-sm);
  padding: 13px 16px; margin-bottom: 16px; font-size: 13.5px; color: var(--ink);
}
.queue-banner .qdot { width: 11px; height: 11px; border-radius: 50%; flex: 0 0 auto; background: var(--accent2); box-shadow: 0 0 12px rgba(152,161,255,.7); animation: qpulse 1.3s ease-in-out infinite; }
.queue-banner.canceled { background: var(--panel2); border-color: var(--line2); color: var(--muted); }
.queue-banner.canceled .qdot { background: var(--faint); box-shadow: none; animation: none; }
.queue-banner .qpos { font-weight: 800; color: var(--accent2); font-variant-numeric: tabular-nums; }
.queue-banner .qmeta { color: var(--muted); font-size: 12px; }
@keyframes qpulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .4; transform: scale(.78); } }
.cancel-btn { margin-left: auto; background: var(--panel); color: var(--muted); border: 1px solid var(--line2); border-radius: var(--radius-xs); padding: 6px 14px; font-size: 12.5px; font-weight: 600; cursor: pointer; transition: color .14s, border-color .14s, background .14s; }
.cancel-btn:hover { color: var(--err); border-color: rgba(248,113,113,.5); background: rgba(248,113,113,.08); }
.cancel-btn:disabled { opacity: .42; cursor: default; }

/* job-list state badges */
.run .qbadge { font-size: 10px; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent2); border: 1px solid var(--accent-line); }
.run .cbadge { font-size: 10px; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: rgba(107,114,128,.16); color: var(--muted); border: 1px solid var(--line2); }
.run .rerr { grid-column: 1 / -1; grid-row: 4; color: var(--err); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- login overlay ---------- */
.login-overlay {
  position: fixed; inset: 0; z-index: 2000;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background:
    radial-gradient(1000px 600px at 70% -10%, rgba(110,121,240,.18), transparent 55%),
    radial-gradient(800px 500px at 12% 8%, rgba(110,121,240,.08), transparent 50%),
    rgba(7,8,12,.9);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.login-box {
  width: 100%; max-width: 366px;
  background: var(--panel); border: 1px solid var(--line2);
  border-radius: var(--radius); box-shadow: var(--shadow-hover);
  padding: 28px 26px 24px; display: flex; flex-direction: column; gap: 12px;
  animation: cardIn .3s var(--ease-out) both;
}
.login-brand { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 2px; }
.login-brand::before {
  content: ""; width: 22px; height: 22px; flex: 0 0 auto; border-radius: 7px;
  background: linear-gradient(145deg, var(--accent2), var(--accent));
  box-shadow: 0 2px 10px rgba(110,121,240,.5), inset 0 1px 0 rgba(255,255,255,.35);
  transform: rotate(45deg) scale(.86);
}
.login-brand h2 { font-size: 17px; margin: 0; font-weight: 750; letter-spacing: -.03em; }
.login-brand h2 .lm { color: var(--muted); font-weight: 600; }
.login-hint { color: var(--muted); font-size: 12.5px; margin: 0 0 4px; line-height: 1.5; }
.login-field { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.login-box input[type=password], .login-box input[type=text] { width: 100%; font-size: 14px; padding: 10px 12px; }
.login-userrow, .login-invrow { display: contents; }
.login-toggle { display: block; margin-top: 6px; font-size: 12.5px; text-align: center; cursor: pointer; }
.user-badge { color: var(--muted); font-size: 13px; font-weight: 600; margin-right: 10px; }
.login-err { color: var(--err); font-size: 12.5px; font-weight: 600; background: rgba(248,113,113,.08); border: 1px solid rgba(248,113,113,.25); border-radius: var(--radius-xs); padding: 7px 10px; }
.login-box .btn { justify-content: center; margin-top: 4px; padding: 11px; font-size: 14px; }
.login-box.shake { animation: loginShake .35s; }
@keyframes loginShake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }

/* ---------- misc ---------- */
.note { color: var(--soft); font-size: 12.5px; margin-top: 4px; }
.err-box { color: var(--err); font-size: 13px; }
.empty { color: var(--faint); font-size: 12.5px; font-style: italic; }
.hide { display: none !important; }

/* ---------- lightbox ---------- */
.lb { position: fixed; inset: 0; z-index: 1000; background: rgba(5,6,10,.95); display: flex; align-items: center; justify-content: center; gap: 8px; backdrop-filter: blur(4px); }
.lb-stage { display: flex; flex-direction: column; align-items: center; gap: 12px; max-width: 92vw; max-height: 90vh; }
.lb-wrap { position: relative; display: inline-block; line-height: 0; }
.lb-wrap img { max-width: 88vw; max-height: 78vh; width: auto; height: auto; border-radius: var(--radius-sm); border: 1px solid var(--line2); display: block; }
.lb-box { position: absolute; border: 2px solid var(--accent2); box-shadow: 0 0 0 1px rgba(0,0,0,.6); border-radius: 2px; pointer-events: none; }
.lb-box.recovered { border-color: var(--recovered); }
.lb-cap { color: var(--ink); font-size: 14px; text-align: center; }
.lb-cap .none { color: var(--muted); font-style: italic; }
.lb-cap .rec { color: var(--recovered); font-weight: 700; }
.lb-nav, .lb-close { background: rgba(20,22,30,.9); border: 1px solid var(--line2); color: var(--ink); cursor: pointer; border-radius: var(--radius-sm); transition: background .13s, border-color .13s; }
.lb-nav { width: 48px; height: 66px; font-size: 30px; line-height: 1; flex: 0 0 auto; }
.lb-nav:hover, .lb-close:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.lb-close { position: absolute; top: 18px; right: 20px; width: 40px; height: 40px; font-size: 22px; line-height: 1; }

/* ---------- advanced-hidden sections ---------- */
.adv-section { transition: opacity .2s; }
body:not(.advanced-on) .adv-section { display: none !important; }
body:not(.advanced-on) .adv-insp { display: none !important; }

/* ---------- reduced-motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .card { animation: none; }
}

@media (max-width: 640px) {
  .wrap { padding: 18px 14px 50px; }
  .crop-video { max-width: 100%; }
  .video-shimmer.portrait { max-width: 100%; }
  header { padding: 14px 16px; }
}

/* ── whole-video subject context panel ───────────────────────────────────── */
.sc-summary { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.sc-section-h {
  font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase;
  letter-spacing: .04em; margin: 14px 0 7px;
}
.sc-section-h:first-child { margin-top: 4px; }
.sc-row {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  background: var(--panel2); border: 1px solid var(--line); border-radius: var(--radius-xs);
  padding: 7px 11px; margin-bottom: 6px; font-size: 13px; transition: border-color .15s, background .15s;
}
.sc-row[data-seek]:hover { border-color: var(--accent-line); background: var(--accent-soft); }
.sc-clip { color: var(--faint); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sc-rewrite { border-left: 2px solid var(--ok); }
.sc-old { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--err); }
.sc-arrow { color: var(--ok); font-weight: 800; }
.sc-new { color: var(--ink); font-weight: 650; }
.sc-subj { color: var(--ink-dim); }
.sc-reason { color: var(--faint); font-size: 12px; flex: 1 1 220px; min-width: 0; }
.sc-route {
  font-size: 10.5px; font-weight: 750; text-transform: uppercase; letter-spacing: .03em;
  padding: 2px 8px; border-radius: 999px; white-space: nowrap;
  background: var(--panel3); border: 1px solid var(--line2); color: var(--muted);
}
.sc-route-arbitrate { color: var(--warn); border-color: rgba(240,178,74,.4); background: rgba(240,178,74,.1); }
.sc-route-graphic_hold { color: var(--dense); border-color: rgba(183,148,246,.4); background: rgba(183,148,246,.1); }
.sc-clusters { display: flex; flex-wrap: wrap; gap: 7px; }
