:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-ink: #ffffff;
  --primary-soft: #dbeafe;
  --ok: #16a34a;
  --ok-soft: #dcfce7;
  --bad: #dc2626;
  --bad-soft: #fee2e2;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --info: #2563eb;
  --landmark: #22d3ee;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .05);
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1120; --surface: #111827; --surface-2: #0f172a; --border: #1f2a3c;
    --text: #e5e7eb; --muted: #94a3b8; --primary: #3b82f6; --primary-soft: #1e3a8a55;
    --ok: #22c55e; --ok-soft: #14532d66; --bad: #ef4444; --bad-soft: #7f1d1d66;
    --warn: #f59e0b; --warn-soft: #78350f66; --info: #60a5fa;
    --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1 { font-size: 20px; margin: 0 0 2px; }
h2 { font-size: 15px; margin: 0; }
h3 { font-size: 13px; margin: 0; }
.muted { color: var(--muted); margin: 0; }
.small { font-size: 12px; }
.error { color: var(--bad); margin: 0; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 24px;
  padding: 0 24px; height: 56px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--primary); font-size: 15px; }
.brand span { color: var(--text); }
.tabs { display: flex; gap: 4px; height: 100%; }
.tab {
  border: 0; background: none; color: var(--muted); font: inherit; font-weight: 500;
  padding: 0 14px; cursor: pointer; border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.link { color: var(--primary); text-decoration: none; }
.link:hover { text-decoration: underline; }
.pill { font-size: 12px; padding: 2px 10px; border-radius: 99px; white-space: nowrap; }
.pill-muted { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-bad { background: var(--bad-soft); color: var(--bad); }

/* ---------- layout ---------- */
main { max-width: 1240px; margin: 0 auto; padding: 24px; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.narrow { max-width: 900px; }
.verify-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.stage-title { color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-size: 11px; margin-bottom: -8px; }
.head-actions { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.verify-grid + .verdict, .verify-grid + .io { margin-top: 16px; }
#ver-verdict { margin-top: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-head { display: flex; justify-content: space-between; align-items: baseline; padding: 16px 16px 0; }

/* ---------- controls ---------- */
.btn {
  font: inherit; font-weight: 500; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 7px 14px; border-radius: 8px;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { color: var(--primary-ink); filter: brightness(1.08); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.icon-btn {
  border: 0; background: none; color: var(--muted); cursor: pointer; padding: 4px; border-radius: 6px; line-height: 0;
}
.icon-btn:hover { color: var(--bad); background: var(--bad-soft); }
.threshold { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.threshold input { width: 160px; accent-color: var(--primary); }
.threshold output { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600; min-width: 34px; }
.toggle { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; font-size: 13px; }
.toggle input { accent-color: var(--primary); }
.toggle:has(input:disabled) { opacity: .5; cursor: default; }
input[type="text"] {
  font: inherit; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%;
}
input[type="text"]:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }

/* ---------- stage ---------- */
.stage { overflow: hidden; }
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 340px; margin: 12px; padding: 24px; text-align: center;
  border: 2px dashed var(--border); border-radius: 10px; color: var(--muted); cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone:focus-visible, .dropzone.over { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); outline: none; }
.dz-title { font-size: 16px; font-weight: 600; color: var(--text); }
.dz-sample { margin-top: 10px; }
.toolbar { display: flex; align-items: center; gap: 16px; padding: 10px 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.spacer { flex: 1; }
.timing { font-variant-numeric: tabular-nums; }
.figure-wrap { display: flex; justify-content: center; background: var(--surface-2); padding: 12px; }
.figure { position: relative; margin: 0; display: inline-block; line-height: 0; max-width: 100%; }
.figure img { display: block; max-width: 100%; max-height: 62vh; border-radius: 4px; }
.layer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.boxes { position: absolute; inset: 0; }
.busy { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(255,255,255,.45); }
.spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid var(--primary-soft); border-top-color: var(--primary); animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.stage-msg { margin: 0; padding: 10px 14px; border-top: 1px solid var(--border); color: var(--muted); line-height: 1.4; }
.stage-msg.error { color: var(--bad); }

.face-box {
  --c: var(--info);
  position: absolute; border: 2px solid var(--c); border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(0,0,0,.25); cursor: default; line-height: 1.3;
}
.face-box.ok { --c: var(--ok); }
.face-box.bad { --c: var(--bad); }
.face-box.warn { --c: var(--warn); }
.face-box.dim { opacity: .55; }
.face-box .tag {
  position: absolute; left: -2px; bottom: 100%; margin-bottom: 2px;
  background: var(--c); color: #fff; font-size: 11px; font-weight: 600;
  padding: 1px 6px; border-radius: 3px; white-space: nowrap;
}
.face-box .tag.below { bottom: auto; top: 100%; margin: 2px 0 0; }
.face-box .tip {
  display: none; position: absolute; left: 50%; top: 100%; transform: translateX(-50%); margin-top: 6px; z-index: 3;
  background: rgba(15,23,42,.92); color: #e5e7eb; font-size: 11px; padding: 6px 8px; border-radius: 6px; white-space: nowrap;
}
.face-box:hover .tip { display: block; }
.face-box:hover { z-index: 2; }

/* ---------- results ---------- */
.results { padding: 4px 0; overflow-x: auto; }
.results td, .results th { white-space: nowrap; }
.results table { width: 100%; border-collapse: collapse; font-size: 13px; }
.results th, .results td { text-align: left; padding: 8px 14px; border-bottom: 1px solid var(--border); }
.results th { color: var(--muted); font-weight: 500; font-size: 12px; }
.results tr:last-child td { border-bottom: 0; }
.results td.num { font-variant-numeric: tabular-nums; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 99px; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.alts { color: var(--muted); font-size: 12px; }
.bar { position: relative; height: 6px; width: 90px; background: var(--border); border-radius: 3px; display: inline-block; vertical-align: middle; margin-right: 8px; }
.bar > i { position: absolute; inset: 0 auto 0 0; background: var(--c, var(--primary)); border-radius: 3px; }
.bar > b { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text); opacity: .5; }

.verdict { display: flex; align-items: center; gap: 16px; padding: 16px 20px; margin-bottom: 16px; }
.verdict .big { font-size: 22px; font-weight: 700; }
.verdict.ok { border-color: var(--ok); background: var(--ok-soft); }
.verdict.bad { border-color: var(--bad); background: var(--bad-soft); }
.verdict.ok .big { color: var(--ok); }
.verdict.bad .big { color: var(--bad); }

/* ---------- request / response ---------- */
.io { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
.io details { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.io summary { cursor: pointer; padding: 10px 14px; font-weight: 600; font-size: 13px; display: flex; justify-content: space-between; align-items: center; }
.io pre {
  margin: 0; padding: 12px 14px; max-height: 380px; overflow: auto; border-top: 1px solid var(--border);
  background: var(--surface-2); font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre;
}

/* ---------- gallery ---------- */
.gallery { position: sticky; top: 76px; max-height: calc(100vh - 100px); display: flex; flex-direction: column; }
.enroll { display: flex; flex-direction: column; gap: 8px; padding: 12px 16px 16px; border-bottom: 1px solid var(--border); }
.file-btn {
  display: block; border: 1px dashed var(--border); border-radius: 8px; padding: 8px 10px;
  color: var(--muted); cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.file-btn:hover, .file-btn.over { border-color: var(--primary); color: var(--primary); }
.file-btn input { display: none; }
.subjects { list-style: none; margin: 0; padding: 8px; overflow: auto; }
.subjects .empty { padding: 24px 12px; text-align: center; color: var(--muted); font-size: 13px; }
.subject { padding: 8px; border-radius: 8px; }
.subject:hover { background: var(--surface-2); }
.subject-head { display: flex; align-items: center; gap: 8px; }
.subject-name { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subject-count { color: var(--muted); font-size: 12px; }
.thumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.thumb { position: relative; width: 44px; height: 44px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }
.thumb button {
  position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; padding: 0; border-radius: 50%;
  border: 0; background: var(--bad); color: #fff; font-size: 12px; line-height: 18px; cursor: pointer; display: none;
}
.thumb:hover button { display: block; }

/* ---------- camera ---------- */
.dz-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; justify-content: center; }
.dz-actions .btn { display: inline-flex; align-items: center; gap: 6px; }
.dz-url[hidden] { display: none; }
.dz-url { display: flex; gap: 8px; margin-top: 10px; width: min(460px, 100%); cursor: default; }
.dz-url input { flex: 1; min-width: 0; }
.cam-controls, .photo-controls { display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cam-select {
  font: inherit; font-size: 13px; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px; padding: 4px 8px; max-width: 200px;
}
.cam-video { display: block; max-width: 100%; max-height: 62vh; border-radius: 4px; background: #000; }
.figure.camera img { display: none; }
/* Mirror the preview like a selfie view; frames sent to the API stay un-mirrored,
   so overlays are mirrored with the video and their text is flipped back. */
.figure.mirrored .cam-video, .figure.mirrored .layer, .figure.mirrored .boxes { transform: scaleX(-1); }
.figure.mirrored .tag { transform: scaleX(-1); }
.figure.mirrored .tip { transform: translateX(-50%) scaleX(-1); }
.cam-live { display: inline-flex; align-items: center; gap: 6px; }
.cam-live .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.cam-live.on { border-color: var(--bad); color: var(--bad); }
.cam-live.on .dot { background: var(--bad); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.live-badge {
  position: absolute; top: 8px; left: 8px; z-index: 4; line-height: 1.4;
  background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; letter-spacing: .05em;
  padding: 2px 8px; border-radius: 4px;
}

.enroll-photo { display: flex; gap: 8px; align-items: stretch; }
.enroll-photo .file-btn { flex: 1; min-width: 0; }
.enroll-photo .btn { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.enroll-preview { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }

.cam-dialog {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 0; width: min(640px, calc(100vw - 32px));
  background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.cam-dialog::backdrop { background: rgba(15, 23, 42, .55); }
.cam-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.cam-dialog-body { background: #000; line-height: 0; }
.cam-dialog-body video { width: 100%; max-height: 60vh; display: block; }
.cam-dialog-body video.mirrored { transform: scaleX(-1); }
.cam-dialog-body .error { line-height: 1.5; padding: 12px 16px; background: var(--surface); }
.cam-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }

/* ---------- personal information ---------- */
input[type="email"], input[type="tel"], input[type="date"], textarea {
  font: inherit; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; width: 100%;
}
input[type="email"]:focus, input[type="tel"]:focus, input[type="date"]:focus, textarea:focus {
  outline: 2px solid var(--primary-soft); border-color: var(--primary);
}
textarea { resize: vertical; min-height: 64px; }
.more-info { border: 1px solid var(--border); border-radius: 8px; }
.more-info summary { cursor: pointer; padding: 8px 10px; font-size: 13px; font-weight: 500; }
.more-info[open] summary { border-bottom: 1px solid var(--border); }
.more-info .fields { padding: 10px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.gallery .fields { grid-template-columns: 1fr; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span:first-child { font-size: 12px; font-weight: 500; color: var(--muted); }
.field.wide { grid-column: 1 / -1; }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); color: var(--bad); background: var(--bad-soft); }

/* gallery rows */
.subject-row { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; font: inherit; color: inherit;
  background: none; border: 0; padding: 0; cursor: pointer; }
.subject-info { flex: 1; min-width: 0; }
.subject-sub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); flex: none; background: var(--surface-2); }
.avatar.lg { width: 56px; height: 56px; }
.avatar.placeholder { display: grid; place-items: center; color: var(--muted); font-weight: 700; }

/* recognition person cards */
.person-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.person-card { padding: 14px; display: flex; flex-direction: column; gap: 10px; border-left: 4px solid var(--warn); }
.person-card.ok { border-left-color: var(--ok); }
.pc-head { display: flex; align-items: center; gap: 12px; }
.pc-title { flex: 1; min-width: 0; }
.pc-name { font-size: 16px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-sub { color: var(--muted); font-size: 12px; }
.pc-score { display: flex; align-items: center; font-size: 13px; font-variant-numeric: tabular-nums; }
.pc-actions { display: flex; gap: 8px; flex-wrap: wrap; }
dl.info { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 13px; }
dl.info dt { color: var(--muted); }
dl.info dd { margin: 0; min-width: 0; overflow-wrap: anywhere; white-space: pre-line; }
dl.info a { color: var(--primary); }

/* profile dialog */
.profile-dialog { width: min(620px, calc(100vw - 32px)); }
.profile-body { padding: 16px; display: grid; gap: 14px; max-height: 70vh; overflow: auto; }
.profile-photos { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.profile-photos .thumbs { margin: 0; }
.profile-photos .thumb { width: 56px; height: 56px; }
.profile-photos .thumb button:disabled { display: none; }
.close-x { font-size: 20px; }
.profile-body .meta:empty { display: none; }

/* ---------- model picker ---------- */
.model-pick { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.model-pick select {
  font: inherit; font-size: 13px; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px; padding: 4px 8px; max-width: 230px;
}
.model-banner {
  display: flex; align-items: center; gap: 10px; margin: 0 0 16px; padding: 10px 14px; border-radius: 10px;
  background: var(--warn-soft); color: var(--text); border: 1px solid var(--warn); font-size: 13px;
}
.model-banner.ok { background: var(--ok-soft); border-color: var(--ok); }
.model-banner button { margin-left: auto; }
.subject-sub.warn { color: var(--warn); }
.thumb.stale img { opacity: .45; filter: grayscale(1); }
.thumb.stale::after {
  content: '!'; position: absolute; left: -5px; bottom: -5px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--warn); color: #fff; font-size: 11px; font-weight: 700; line-height: 16px; text-align: center;
}

/* ---------- benchmark tab ---------- */
.bench {
  /* categorical slots for pipeline stages (validated light + dark), ordinal blues for percentiles */
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #6250d6;
  --o1: #86b6ef; --o2: #3987e5; --o3: #1c5cab;
  --grid: #e7e8ec; --axis: #94a3b8;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .bench {
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #0ca30c; --s7: #9085e9;
    --o1: #1c5cab; --o2: #3987e5; --o3: #9ec5f4;
    --grid: #1f2a3c; --axis: #64748b;
  }
}
.bench code { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; border: 1px solid var(--border); }
.bench-empty { padding: 28px; line-height: 1.6; }
.bench-empty pre { margin: 10px 0 0; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; font: 12px/1.6 ui-monospace, Menlo, monospace; overflow: auto; }
#bench-body { display: flex; flex-direction: column; gap: 16px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.tiles.compact .tile { box-shadow: none; background: var(--surface-2); }
.tile .t-label { color: var(--muted); font-size: 12px; }
.tile .t-value { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; margin-top: 2px; }
.tile .t-value small { font-size: 14px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.tile .t-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.bench-card { padding: 16px; }
.bench-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.bench-card-head p { margin: 2px 0 0; }
.bench-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--muted); margin: 4px 0 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text { font: 11px system-ui, -apple-system, "Segoe UI", sans-serif; fill: var(--muted); }
.chart text.lbl { fill: var(--text); font-size: 12px; }
.chart text.val { fill: var(--text); font-variant-numeric: tabular-nums; }
.chart .grid line { stroke: var(--grid); }
.chart .hit { fill: transparent; cursor: default; }
.chart .mark { transition: opacity .1s; }
.chart.hovering .mark:not(.on) { opacity: .45; }
.chart table { margin-top: 12px; }
.viz-tip {
  position: fixed; z-index: 50; pointer-events: none; background: rgba(15,23,42,.94); color: #e5e7eb;
  font-size: 12px; line-height: 1.5; padding: 8px 10px; border-radius: 8px; max-width: 280px; box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
.viz-tip b { color: #fff; }
.viz-tip .row { display: flex; align-items: center; gap: 6px; }
.viz-tip .row i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.viz-tip .row span:last-child { margin-left: auto; padding-left: 12px; font-variant-numeric: tabular-nums; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { font: inherit; font-size: 13px; border: 0; background: var(--surface); color: var(--muted); padding: 5px 12px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button[aria-pressed="true"] { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td { text-align: right; padding: 7px 10px; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; white-space: nowrap; }
.data-table th:first-child, .data-table td:first-child { text-align: left; }
.data-table th { color: var(--muted); font-weight: 500; font-size: 12px; }
.table-wrap { overflow-x: auto; }
.bench-foot { margin: 4px 0 0; line-height: 1.6; }

/* ---------- architecture tab ---------- */
.arch { display: flex; flex-direction: column; gap: 16px; }
.arch .panel-head { margin-bottom: 0; }
.arch-card { padding: 18px; }
.arch-card h2, .arch-h2 { font-size: 16px; margin: 0 0 4px; }
.arch-h2 { margin: 8px 0 -4px; }
.arch code { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; border: 1px solid var(--border); }
.flow {
  list-style: none; margin: 14px 0 16px; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 22px 22px;
}
.step {
  position: relative; display: flex; flex-direction: column; gap: 4px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 12px 10px;
  font-size: 12px; color: var(--muted); line-height: 1.4;
}
.step b { color: var(--text); font-size: 14px; }
.step em { font-style: normal; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; margin-top: auto; padding-top: 4px; }
.step .n {
  align-self: flex-start; font-size: 11px; font-weight: 700; letter-spacing: .04em;
  background: var(--border); color: var(--text); border-radius: 99px; padding: 1px 8px;
}
.step.nn { border-color: var(--primary); }
.step.nn .n { background: var(--primary); color: #fff; }
.step.hot { background: var(--primary-soft); }
.step.io { border-style: dashed; }
.step[data-model] { cursor: pointer; }
.step[data-model]:hover, .step[data-model]:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
/* arrow to the next step */
.step:not(:last-child)::after {
  content: '→'; position: absolute; right: -18px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 14px; font-weight: 700;
}
.arch-uses td:nth-child(2), .arch-uses td:nth-child(3) { text-align: left; white-space: normal; }
.arch-uses th { text-align: left !important; }
.arch-models { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.model-card { padding: 18px; transition: box-shadow .3s, border-color .3s; }
.model-card.wide { grid-column: 1 / -1; }
.model-card.flash { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.model-card p { margin: 6px 0 10px; line-height: 1.55; }
.mc-head h3 { font-size: 16px; margin: 2px 0 0; }
.mc-layer { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--primary); }
dl.spec { display: grid; grid-template-columns: 110px 1fr; gap: 6px 14px; margin: 8px 0 10px; font-size: 13px; }
dl.spec dt { color: var(--muted); }
dl.spec dd { margin: 0; line-height: 1.5; }
#arch-models-table td { white-space: nowrap; }
#arch-models-table tr.active-row td { background: var(--ok-soft); }
.deploy { display: flex; align-items: stretch; gap: 10px; margin: 12px 0; flex-wrap: wrap; }
.dbox { flex: 1 1 220px; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; background: var(--surface-2); }
.dbox.main { border-color: var(--primary); }
.dbox h4 { margin: 0 0 6px; font-size: 14px; }
.dbox ul { margin: 0; padding-left: 18px; font-size: 13px; color: var(--muted); line-height: 1.6; }
.darrow { align-self: center; color: var(--muted); font-size: 12px; white-space: nowrap; }
.arch-limits { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.limit { padding: 14px 16px; border-top: 3px solid var(--warn); }
.limit h3 { font-size: 14px; margin: 0 0 4px; }
.limit p { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.55; }

/* ---------- mermaid diagrams ---------- */
.mermaid-box {
  min-height: 160px; overflow-x: auto; padding: 12px; margin-top: 4px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  display: flex; justify-content: center; align-items: flex-start;
}
.mermaid-box svg { max-width: 100%; height: auto; }
/* drawn diagrams (scripts/arch_diagrams.py): their colours follow the page theme */
.mermaid-box { --dd-paper: var(--surface-2); --dd-ink: var(--text); --dd-muted: var(--muted); --dd-accent: var(--primary); --dd-tint: var(--primary-soft); }
.mermaid-box svg.drawn { width: 100%; min-width: 960px; max-width: 1180px; margin: 0 auto; }
.mermaid-box:has(svg.drawn) { justify-content: flex-start; }
.mermaid-box.loading::before { content: 'Rendering diagram…'; color: var(--muted); font-size: 13px; align-self: center; }
.mermaid-box pre { margin: 0; font: 12px/1.5 ui-monospace, Menlo, monospace; white-space: pre; }
.mermaid-src { margin-top: 10px; }
.mermaid-src summary { cursor: pointer; font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.mermaid-src summary .btn { margin-left: auto; }
.mermaid-src pre {
  margin: 8px 0 0; padding: 12px 14px; max-height: 320px; overflow: auto; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px; font: 12px/1.5 ui-monospace, Menlo, monospace;
}
#arch-diagram-pick { flex-wrap: wrap; }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .grid-main { grid-template-columns: 1fr; }
  .gallery { position: static; max-height: none; }
}
@media (max-width: 720px) {
  main { padding: 16px; }
  .topbar { padding: 0 16px; gap: 12px; flex-wrap: wrap; height: auto; padding-top: 8px; }
  .tabs { order: 3; width: 100%; height: 40px; overflow-x: auto; }
  .verify-grid, .io, .fields, .bench-grid, .arch-models { grid-template-columns: 1fr; }
  .flow { grid-template-columns: 1fr; gap: 18px; }
  .step:not(:last-child)::after { content: '↓'; right: auto; left: 50%; top: auto; bottom: -17px; transform: translateX(-50%); }
  .darrow { display: none; }
  dl.spec { grid-template-columns: 1fr; gap: 2px; }
  dl.spec dd { margin-bottom: 6px; }
  .topbar .link { display: none; }
  .model-pick select { max-width: 170px; }
  .dropzone { min-height: 240px; }
}
#arch-models-table td:nth-child(2), #arch-models-table td:nth-child(3), #arch-models-table th:nth-child(2), #arch-models-table th:nth-child(3) { text-align: left; }
.arch-models > *, .bench-grid > *, .flow > *, .arch-limits > *, .grid-main > * { min-width: 0; }
#arch-live { white-space: normal; }
#arch-root { display: flex; flex-direction: column; gap: 16px; }
#arch-root .panel-head { margin-bottom: 0; }
#arch-lang button { white-space: nowrap; }

/* ---------- liveness tab ---------- */
.lv-panel { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.lv-instruction { display: flex; gap: 14px; align-items: center; padding: 14px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.lv-instruction b { display: block; font-size: 17px; }
.lv-instruction .lv-icon { width: 52px; height: 52px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 26px; font-weight: 700; background: var(--border); color: var(--text); }
.lv-instruction.active { border-color: var(--primary); background: var(--primary-soft); }
.lv-instruction.active .lv-icon { background: var(--primary); color: #fff; animation: pulse 1.4s ease-in-out infinite; }
.lv-instruction.ok { border-color: var(--ok); background: var(--ok-soft); }
.lv-instruction.ok .lv-icon { background: var(--ok); color: #fff; }
.lv-instruction.bad { border-color: var(--bad); background: var(--bad-soft); }
.lv-instruction.bad .lv-icon { background: var(--bad); color: #fff; }
.lv-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.lv-steps:empty { display: none; }
.lv-steps li { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.lv-steps .tick { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--border); font-size: 13px; }
.lv-steps li.now { color: var(--text); font-weight: 600; }
.lv-steps li.now .tick { border-color: var(--primary); color: var(--primary); }
.lv-steps li.done { color: var(--ok); }
.lv-steps li.done .tick { background: var(--ok); border-color: var(--ok); color: #fff; }
.lv-timer { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.lv-timer i { display: block; height: 100%; background: var(--primary); transition: width .3s linear; }
.lv-verdict { padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.lv-verdict p { margin: 0; font-size: 13px; color: var(--muted); }
.lv-verdict.ok { border-color: var(--ok); background: var(--ok-soft); }
.lv-verdict.bad { border-color: var(--bad); background: var(--bad-soft); }
.lv-h3 { font-size: 13px; margin: 4px 0 0; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.lv-metrics { display: grid; grid-template-columns: 110px 1fr; gap: 8px 10px; margin: 0; font-size: 13px; }
.lv-metrics dt { color: var(--muted); }
.lv-metrics dd { margin: 0; font-variant-numeric: tabular-nums; }
.lv-bar { width: 110px; }
.lv-note { margin: 0; line-height: 1.5; }
.badge.spoof { background: var(--bad-soft); color: var(--bad); }
.lv-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 99px; }
.lv-chip.ok { background: var(--ok-soft); color: var(--ok); }
.lv-chip.bad { background: var(--bad-soft); color: var(--bad); }

/* ---------- two-level menu: Face SDK functions on top, project information below ---------- */
.masthead { position: sticky; top: 0; z-index: 10; }
.masthead .topbar { position: static; }
/* project information lives in a fixed bottom menu */
body { padding-bottom: 56px; }
.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center; gap: 14px; height: 48px; padding: 0 24px;
  background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -2px 10px rgba(15, 23, 42, .05);
}
.subbar-label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.tabs.sub { height: 100%; gap: 4px; }
.tabs.sub .tab {
  font-size: 13px; padding: 0 14px; display: inline-flex; align-items: center; gap: 6px;
  border-bottom: 0; border-top: 2px solid transparent;
}
.tabs.sub .tab[aria-selected="true"] { border-top-color: var(--primary); }
.tabs.sub .tab svg { opacity: .8; }

/* ---------- API tab ---------- */
#tab-api { display: flex; flex-direction: column; gap: 16px; }
#tab-api .panel-head { margin-bottom: 0; }
.api-card { padding: 16px; }
.api-group + .api-group { margin-top: 14px; }
.api-group h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 4px; }
.api-table td { text-align: left !important; white-space: normal; vertical-align: top; }
.api-table tr { cursor: pointer; }
.api-table tr:hover td, .api-table tr:focus-visible td { background: var(--surface-2); }
.api-method { width: 76px; }
.api-path { width: 300px; }
.api-path code { font: 12.5px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--text); }
.api-desc { color: var(--muted); font-size: 13px; }
.method { display: inline-block; min-width: 56px; text-align: center; font: 700 11px ui-monospace, Menlo, monospace; padding: 2px 6px; border-radius: 4px; color: #fff; }
.m-get { background: #2563eb; } .m-post { background: #16a34a; } .m-put { background: #d97706; } .m-delete { background: #dc2626; }
.api-fields { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.api-field { font: 11.5px ui-monospace, Menlo, monospace; background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; color: var(--text); }
.api-field.req { border-color: var(--primary); }
.api-field i { font-style: normal; color: var(--muted); margin-left: 4px; }
.api-frame { width: 100%; height: 760px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }

@media (max-width: 720px) {
  .bottombar { padding: 0 8px; gap: 0; }
  .subbar-label { display: none; }
  .tabs.sub { width: 100%; justify-content: space-around; overflow: visible; height: 100%; order: 0; }
  .tabs.sub .tab { flex-direction: column; justify-content: center; gap: 2px; font-size: 11px; padding: 0 8px; }
  .api-path { width: auto; }
  .api-table tr { display: grid; grid-template-columns: auto 1fr; }
  .api-table td.api-desc { grid-column: 1 / -1; padding-top: 0; }
  .api-frame { height: 560px; }
}
.api-table { table-layout: fixed; }
.api-table td.api-method { width: 84px; }
.api-table td.api-path { width: 360px; }
@media (max-width: 720px) { .api-table { table-layout: auto; } .api-table td.api-path { width: auto; } }
.gallery { max-height: calc(100vh - 150px); }
.sim-notes { margin: 8px 0 0; padding-left: 18px; font-size: 13px; color: var(--muted); line-height: 1.6; }
.sim-notes li + li { margin-top: 4px; }
.limit.wide { grid-column: 1 / -1; }
.limit-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 4px 20px; margin-top: 8px; }
.limit-cols > * { min-width: 0; }
.limit h4 { font-size: 13px; margin: 6px 0 4px; }
.limit ul { margin: 0; padding-left: 18px; font-size: 13px; color: var(--muted); line-height: 1.55; }
.limit li + li { margin-top: 3px; }
.limit p.limit-rec { margin-top: 10px; color: var(--text); }
.arch-limits { display: flex; flex-wrap: wrap; }
.arch-limits > .limit { flex: 1 1 220px; }
.arch-limits > .limit.wide { flex-basis: 100%; }

/* ---------- Face | OCR switch and OCR pages ---------- */
.group-switch button { padding: 4px 12px; font-size: 13px; }
.ocr-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: start; margin-bottom: 16px; }
.ocr-grid.has-file { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
.ocr-head { margin-bottom: 16px; }
.paper-thumb { position: relative; }
.thumb-badge { position: absolute; right: 6px; bottom: 6px; font-size: 10px; background: var(--bad); color: #fff; border-radius: 4px; padding: 1px 5px; }
.ocr-grid > * { min-width: 0; }
.ocr-layer .ocr-poly { fill: rgba(37, 99, 235, .08); stroke: var(--primary); stroke-width: 2; vector-effect: non-scaling-stroke; pointer-events: all; cursor: default; }
.ocr-layer .ocr-poly.mid { stroke: var(--warn); fill: rgba(217, 119, 6, .10); }
.ocr-layer .ocr-poly.low { stroke: var(--bad); fill: rgba(220, 38, 38, .12); }
.ocr-layer .ocr-poly.src-qr { stroke: var(--ok); fill: rgba(22, 163, 74, .10); }
.ocr-layer .ocr-poly.portrait { stroke: var(--landmark); fill: none; stroke-dasharray: 6 4; }
.ocr-layer .ocr-poly.hot { stroke-width: 3; fill: rgba(37, 99, 235, .28); }
.ocr-layer.off { display: none; }
.ocr-pages button { padding: 3px 10px; font-size: 12px; }
.ocr-text { display: flex; flex-direction: column; max-height: calc(62vh + 64px); }
.ocr-text-head { align-items: center; gap: 8px; flex-wrap: wrap; }
.ocr-text-head h3 { margin: 0; }
.ocr-actions { display: inline-flex; gap: 4px; }
.ocr-meta { margin: 6px 16px 0; display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.ocr-legend { display: inline-flex; align-items: center; gap: 6px; }
.ocr-legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; margin-left: 6px; }
.ocr-legend i.mid { background: var(--warn-soft); border: 1px solid var(--warn); }
.ocr-legend i.low { background: var(--bad-soft); border: 1px solid var(--bad); }
.ocr-lines { padding: 10px 16px 16px; overflow: auto; font-size: 15px; line-height: 1.7; }
.ocr-lines p { margin: 0 0 6px; }
.ocr-line { border-radius: 3px; padding: 1px 1px; }
.ocr-line.mid { background: var(--warn-soft); }
.ocr-line.low { background: var(--bad-soft); }
.ocr-line.hot { background: var(--primary-soft); }
.src-chip { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px; }
.src-chip.qr { background: var(--ok-soft); color: var(--ok); }
.src-chip.ocr { background: var(--primary-soft); color: var(--primary); }
.ocr-pad { padding: 8px 16px 16px; }
.ocr-portrait { display: flex; gap: 16px; padding: 12px 16px; align-items: flex-start; }
.ocr-portrait img { width: 96px; border-radius: 6px; border: 1px solid var(--border); }
.ocr-portrait > div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ocr-match { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.ok-text { color: var(--ok); }
.bad-text { color: var(--bad); }
.ocr-face-actions { display: flex; gap: 8px; padding: 0 16px 16px; flex-wrap: wrap; }
@media (max-width: 960px) { .ocr-grid, .ocr-grid.has-file { grid-template-columns: minmax(0, 1fr); } .ocr-text { max-height: none; } }
@media (max-width: 720px) { .group-switch { order: 2; } }

/* ---------- OCR Papers: sidebar of document types + header card + workspace ---------- */
.papers { display: grid; grid-template-columns: 268px minmax(0, 1fr); gap: 20px; align-items: start; }
.papers-nav { position: sticky; top: 72px; max-height: calc(100vh - 150px); overflow-y: auto; display: flex; flex-direction: column;
  gap: 10px; padding: 4px 4px 12px 0; }
.paper-group { display: flex; flex-direction: column; gap: 2px; }
.paper-group h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 4px 10px; }
.paper-item { font: inherit; text-align: left; display: flex; flex-direction: column; gap: 0; padding: 5px 10px; border: 0;
  border-left: 3px solid transparent; border-radius: 0 8px 8px 0; background: none; color: var(--text); cursor: pointer; }
.paper-item:hover { background: var(--surface); }
.paper-item[aria-pressed="true"] { background: var(--primary-soft); border-left-color: var(--primary); }
.paper-item[aria-pressed="true"] .pi-title { color: var(--primary); }
.pi-title { font-size: 13.5px; font-weight: 600; line-height: 1.3; }
.pi-sub { font-size: 12px; color: var(--muted); }
.papers-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.papers-head { padding: 18px 20px; }
.ph-text { min-width: 0; flex: 1; }
.ph-kicker { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--primary); font-weight: 600; }
.papers-head h1 { font-size: 22px; margin: 4px 0 0; }
.ph-en { margin: 2px 0 8px; color: var(--muted); font-size: 13px; }
.ph-desc { margin: 0; font-size: 14px; line-height: 1.55; color: var(--text); max-width: 72ch; }
.ph-fields { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.ph-fields span { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }
.ph-samples { display: flex; gap: 8px; margin-top: 14px; overflow-x: auto; padding-bottom: 2px; align-items: center; }
.ph-samples-label { font-size: 12px; color: var(--muted); margin-right: 4px; }
.paper-thumb { font: inherit; flex-shrink: 0; padding: 3px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2);
  cursor: pointer; }
.paper-thumb:hover { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.paper-thumb img { width: 104px; height: 66px; object-fit: cover; border-radius: 5px; display: block; }
.papers-work { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
.papers-work.has-file { grid-template-columns: minmax(0, 1.15fr) minmax(320px, 1fr); }
.papers-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.paper-head { align-items: flex-start; gap: 8px; }
.paper-head h3 { margin: 0; }
.pf-list { display: flex; flex-direction: column; margin-top: 8px; }
.pf-row { display: flex; gap: 12px; justify-content: space-between; align-items: flex-start; padding: 9px 16px; border-top: 1px solid var(--border); }
.pf-row.hot { background: var(--primary-soft); }
.pf-main { min-width: 0; }
.pf-label { font-size: 12px; color: var(--muted); }
.pf-value { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.pf-note { font-size: 12px; color: var(--muted); margin-top: 2px; }
.pf-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.pf-conf { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pf-conf.low { color: var(--warn); font-weight: 600; }
.paper-mrz { padding: 10px 16px 0; border-top: 1px solid var(--border); }
.paper-mrz pre { font-size: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; overflow-x: auto; margin: 6px 0; }
.paper-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.paper-checklist { list-style: none; margin: 6px 0 10px; padding: 0 16px; display: flex; flex-direction: column; gap: 6px; }
.paper-checklist li { display: grid; grid-template-columns: 20px 1fr auto; gap: 8px; align-items: start; font-size: 13px; }
.paper-checklist li.ok .ck { color: var(--ok); }
.paper-checklist li.warn .ck { color: var(--warn); }
.src-chip.mrz { background: var(--warn-soft); color: var(--warn); }
.src-chip.rule { background: var(--surface-2); color: var(--muted); }
.ocr-layer .ocr-poly.src-mrz { stroke: var(--warn); fill: rgba(217, 119, 6, .08); }
.ocr-layer .ocr-poly.quad { stroke: var(--ok); stroke-width: 3; fill: rgba(22, 163, 74, .06); }
@media (max-width: 1180px) {
  .papers-work.has-file { grid-template-columns: minmax(0, 1fr); }
}
#ocr-paper-stage .toolbar { gap: 10px; }
#ocr-paper-stage .toolbar .seg button { padding: 4px 10px; }
@media (max-width: 960px) {
  .papers { grid-template-columns: minmax(0, 1fr); }
  .papers-nav { position: static; max-height: none; flex-direction: row; overflow-x: auto; gap: 6px; padding: 0 0 6px;
    scrollbar-width: thin; }
  .paper-group { flex-direction: row; gap: 6px; }
  .paper-group h3 { display: none; }
  .paper-item { flex-shrink: 0; border: 1px solid var(--border); border-radius: 99px; padding: 6px 12px; background: var(--surface); }
  .paper-item .pi-sub { display: none; }
  .paper-item[aria-pressed="true"] { border-color: var(--primary); }
  .pi-title { font-size: 13px; white-space: nowrap; }

}
@media (max-width: 720px) {
  .paper-thumb img { width: 88px; height: 56px; }
  .papers-head { padding: 14px; }
  .papers-head h1 { font-size: 19px; }
}

/* ---------- OCR Table ---------- */
.ocr-table-wrap { padding: 8px 16px 16px; max-height: calc(62vh + 40px); overflow: auto; }
.ocr-table { border-collapse: collapse; font-size: 13px; min-width: 100%; }
.ocr-table th, .ocr-table td { border: 1px solid var(--border); padding: 6px 8px; text-align: left; vertical-align: top; }
.ocr-table th { background: var(--surface-2); font-weight: 600; }
.ocr-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.ocr-table .hot { background: var(--primary-soft); }
.ocr-layer .ocr-poly.cell { stroke: var(--primary); stroke-width: 1.5; fill: rgba(37, 99, 235, .04); }
.ocr-eval .bench-card-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.ocr-eval-cell { display: inline-flex; align-items: center; gap: 2px; white-space: nowrap; }
@media (max-width: 960px) { .ocr-grid.has-file { grid-template-columns: minmax(0, 1fr); } }
.src-chip.ner { background: #ede9fe; color: #6d28d9; }
@media (prefers-color-scheme: dark) { .src-chip.ner { background: #4c1d9566; color: #c4b5fd; } }
.real-eval .real-sec { padding: 12px 0 4px; border-top: 1px solid var(--border); }
.real-eval .real-sec:first-child { border-top: 0; }
.real-eval .real-sec h3 { margin: 0 0 2px; font-size: 15px; }
.real-eval .real-sec > p { margin: 4px 0 8px; }
.real-eval .tiles { margin: 8px 0; }
.real-pending code { font-size: 12px; }
/* ---------- Backtest page ---------- */
.bt-tiles { margin: 12px 0 6px; }
.bt-private { margin: 8px 0 0; font-size: 13px; color: var(--warn); }
.bt-filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 14px; }
.bt-filters select, .bt-filters input[type=search] { font: inherit; font-size: 13px; padding: 5px 8px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); max-width: 220px; }
.bt-filters input[type=search] { min-width: 180px; }
.bt-grid td { vertical-align: top; cursor: pointer; }
.bt-grid tbody tr:hover { background: var(--surface-2); }
.bt-grid tr.bt-fail td.bt-id { color: var(--bad); }
.bt-grid td.bt-text { max-width: 420px; white-space: normal; overflow-wrap: anywhere; }
.bt-grid td.bt-pct, .bt-grid td.bt-num, .bt-grid td.bt-ms { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bt-thumb img { height: 34px; max-width: 160px; object-fit: contain; border-radius: 4px; background: var(--surface-2); display: block; }
.bt-tags { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.bt-tags span { font-size: 11px; padding: 1px 7px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); }
.bt-pager { display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--border); }
.bt-dialog { width: min(760px, 94vw); border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); padding: 16px 18px; }
.bt-dialog::backdrop { background: rgba(15, 23, 42, .45); }
.bt-dlg-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.bt-dlg-head h3 { margin: 0; }
.bt-dlg-img { max-width: 100%; max-height: 50vh; display: block; margin: 0 auto 12px; border-radius: 6px; }
.bt-dialog tr.bt-fail td { color: var(--bad); }
.bt-clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bt-grid td.bt-text { min-width: 140px; }
#bt-dialog dl.spec dd { overflow-wrap: anywhere; }
#bt-dialog .data-table { width: 100%; table-layout: fixed; }
#bt-dialog .data-table td, #bt-dialog .data-table th { white-space: normal; overflow-wrap: anywhere; text-align: left; }
#bt-dialog .data-table th:first-child, #bt-dialog .data-table td:first-child { width: 26%; }
.kn { margin-left: 6px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sum-wrap table { table-layout: auto; }
.sum-wrap td, .sum-wrap th { white-space: normal; text-align: left; vertical-align: top; }
.sum-wrap td:nth-child(2) { max-width: 220px; color: var(--muted); }
.sum-wrap td:nth-child(3), .sum-wrap td:nth-child(4) { max-width: 200px; }
.sum-wrap td:nth-child(5), .sum-wrap td:nth-child(6) { white-space: nowrap; }
.sum-wrap td:nth-child(5) .kn { display: block; margin-left: 0; }

/* ---------------------------------------------------------------- Camera AI */
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.cam-root { display: flex; flex-direction: column; gap: 16px; margin-top: 16px; }
.cam-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.cam-stage { padding: 12px; min-width: 0; }
.cam-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.cam-figure { position: relative; line-height: 0; background: #000; border-radius: 10px; overflow: hidden; }
.cam-media img, .cam-media video { width: auto; height: auto; max-width: 100%; max-height: 70vh; display: block; }
.cam-figure { width: fit-content; max-width: 100%; margin: 0 auto; }
.cam-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.cam-foot { margin-top: 8px; min-height: 18px; }
.cam-side { padding: 14px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.cam-settings { display: flex; flex-direction: column; gap: 10px; }
.cam-settings label { display: flex; flex-direction: column; gap: 4px; }
.cam-settings select { width: 100%; font: inherit; font-size: 13px; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; }
.cam-toolbar { align-items: center; }
.cam-dropzone { margin: 0; min-height: 300px; }
.cam-dropzone p { margin: 6px 0 0; }
.cam-badge { background: var(--primary); }
.cam-credit { margin: 6px 0 0; font-size: 11px; }
.cam-kind { flex-shrink: 0; margin-right: 4px; }
.cam-kind button { padding: 4px 10px; font-size: 12px; }
.cam-range { display: flex; align-items: center; gap: 8px; }
.cam-range input { flex: 1; }
.cam-h { font-size: 14px; margin: 4px 0 0; }
.cam-counts { display: flex; flex-wrap: wrap; gap: 6px; }
.cam-count { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 99px; padding: 2px 10px; font-size: 13px; }
.cam-count i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.cam-count b { font-variant-numeric: tabular-nums; }
.cam-list { margin: 0; padding-left: 20px; font-size: 13px; max-height: 260px; overflow: auto; }
@media (max-width: 960px) { .cam-grid { grid-template-columns: minmax(0, 1fr); } }

.cam-result { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.cam-check { display: flex !important; flex-direction: row !important; align-items: flex-start; gap: 8px; font-size: 14px; }
.cam-check input { margin-top: 3px; }
.cam-overlay.drawing { pointer-events: auto; cursor: crosshair; }
.cam-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.cam-table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.cam-table th, .cam-table td { text-align: right; padding: 4px 6px; border-bottom: 1px solid var(--border); }
.cam-table th:first-child, .cam-table td:first-child { text-align: left; }
.cam-events { max-height: 220px; }

/* ---------- Camera AI · Safety (PPE) ---------- */
.cam-req { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.cam-legend { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.cam-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 6px; }
.cam-tile { display: flex; flex-direction: column; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.cam-tile b { font-size: 18px; font-variant-numeric: tabular-nums; }
.cam-tile span { font-size: 11px; color: var(--muted); }
.cam-tile.ok b { color: var(--ok); } .cam-tile.bad b { color: var(--bad); } .cam-tile.muted b { color: var(--muted); }
.cam-workers li { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; padding: 3px 0; }
.cam-state { font-size: 12px; padding: 1px 6px; border-radius: 99px; border: 1px solid var(--border); }
.cam-state.ok { color: var(--ok); border-color: var(--ok); } .cam-state.bad { color: var(--bad); border-color: var(--bad); }
.cam-state.muted { color: var(--muted); }
.cam-beta { margin-left: 6px; font-size: 10px; padding: 0 6px; vertical-align: middle; }
.cam-beta-note { margin: 8px 0 0; color: var(--warn); }
.cam-soon { margin: 6px 10px 0; }
@media (max-width: 960px) { .cam-soon { display: none; } }

/* Detection menu: groups fold, the heading opens one */
#cam-detect-nav .paper-group > h3 { cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 6px; margin: 0; border-radius: 8px; user-select: none; }
#cam-detect-nav .paper-group > h3:hover { background: var(--primary-soft); }
#cam-detect-nav .paper-group > h3:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
#cam-detect-nav .paper-group > h3::after { content: ''; width: 7px; height: 7px; border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor; transform: rotate(45deg); transition: transform .15s; flex: none; margin-right: 4px; }
#cam-detect-nav .paper-group.folded > h3::after { transform: rotate(-45deg); }
/* on narrow screens the menu is a row of chips without headings: nothing folds there */
@media (min-width: 961px) { #cam-detect-nav .paper-group.folded > .paper-item { display: none; } }
@media (prefers-reduced-motion: reduce) { #cam-detect-nav .paper-group > h3::after { transition: none; } }
