:root {
  --bg: #f6f6f4; --fg: #1d1d1f; --muted: #6b6b70; --card: #ffffff; --line: #dcdcd8;
  --accent: #2563eb; --ok: #16a34a; --fix: #2563eb; --add: #9333ea; --bad: #dc2626; --warn: #b45309;
  --unrev: #9ca3af; --draft: #f59e0b;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121214; --fg: #ececec; --muted: #9a9aa2; --card: #1c1c20; --line: #313137;
    --accent: #60a5fa; --ok: #4ade80; --fix: #60a5fa; --add: #c084fc; --bad: #f87171; --warn: #fbbf24;
    --unrev: #6b7280; --draft: #fbbf24;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121214; --fg: #ececec; --muted: #9a9aa2; --card: #1c1c20; --line: #313137;
  --accent: #60a5fa; --ok: #4ade80; --fix: #60a5fa; --add: #c084fc; --bad: #f87171; --warn: #fbbf24;
  --unrev: #6b7280; --draft: #fbbf24;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--fg); }
.muted { color: var(--muted); }
.pad { padding: 16px; }
h2 { font-size: 18px; margin: 0 0 4px; }
h3 { font-size: 15px; margin: 14px 0 6px; }

header.top { position: sticky; top: 0; z-index: 10; background: var(--card); border-bottom: 1px solid var(--line);
  padding: 8px 16px; display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; }
.brand { font-weight: 600; }
nav { display: flex; gap: 4px; overflow-x: auto; flex: 1 1 auto; scrollbar-width: none; }
nav a { padding: 8px 10px; border-radius: 8px; color: var(--fg); text-decoration: none; white-space: nowrap; }
nav a.active { background: var(--accent); color: #fff; }
#progress { font-size: 13px; }

main { padding: 12px 16px 96px; max-width: 1400px; margin: 0 auto; }

button, input, select, textarea { font: inherit; color: inherit; }
button { min-height: 44px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); cursor: pointer; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
button.danger { color: var(--bad); border-color: var(--bad); }
button:disabled { opacity: .5; cursor: default; }
input[type=text], input[type=number], select, textarea { min-height: 44px; padding: 8px 10px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); width: 100%; }
label { display: block; font-size: 13px; color: var(--muted); margin-top: 8px; }
.row { display: flex; gap: 8px; align-items: end; }
.row > * { flex: 1 1 0; min-width: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.actions button { flex: 1 1 120px; }
.chip { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 99px; border: 1px solid currentColor; }
.st-unreviewed { color: var(--unrev); } .st-correct { color: var(--ok); } .st-fixed { color: var(--fix); }
.st-added { color: var(--add); } .st-deleted { color: var(--bad); }
.warn { color: var(--warn); font-size: 13px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; overflow-x: auto; }
.hint { font-size: 12px; color: var(--muted); }

/* frames */
.frames { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 4px; }
.frame { position: relative; display: inline-block; }
.frames .frame { flex: 0 0 auto; scroll-snap-align: start; }
.frame canvas { display: block; border-radius: 10px; background: #000; }
.frame .fid { position: absolute; left: 6px; top: 6px; font-size: 11px; background: rgba(0,0,0,.6); color: #fff;
  padding: 1px 6px; border-radius: 6px; }

/* plan */
.plan { position: relative; width: 100%; background: #fff; border-radius: 12px; overflow: hidden; border: 1px solid var(--line);
  touch-action: none; }
.plan svg { display: block; width: 100%; height: auto; }
.plan .wall { stroke: #1d4ed8; stroke-width: 4; opacity: .55; cursor: pointer; }
.plan .wall.pick-a { stroke: #f59e0b; opacity: 1; stroke-width: 7; }
.plan .wall.pick-b { stroke: #db2777; opacity: 1; stroke-width: 7; }
.plan .room { fill: rgba(37,99,235,.06); stroke: #2563eb; stroke-width: 2; }
.plan .box { fill-opacity: .15; stroke-width: 2.5; cursor: pointer; }
.plan .box.sel { stroke: #ea580c !important; fill: #ea580c !important; stroke-width: 4; fill-opacity: .3; }
.plan .box.draft { fill: none; stroke: #f59e0b; stroke-dasharray: 6 4; stroke-width: 3; pointer-events: none; }
.plan .lbl { font-size: 7px; fill: #111; paint-order: stroke; stroke: #fff; stroke-width: 2px; pointer-events: none; }
.plan .box.sel + .lbl, .plan g:has(.box.sel) .lbl { font-weight: 700; font-size: 9px; }
.plan .handle { fill: #f59e0b; stroke: #fff; stroke-width: 2; cursor: grab; }
.plan .route { fill: none; stroke: #db2777; stroke-width: 3; marker-end: url(#arrow); }
.plan .corner { fill: #2563eb; stroke: #fff; stroke-width: 2; cursor: grab; }
.plan .corner.sel { fill: #ea580c; }
.plan .mid { fill: #fff; stroke: #2563eb; stroke-width: 2; cursor: copy; opacity: .85; }

/* layouts */
.view-a { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; max-width: 760px; margin: 0 auto; }
.view-a > *, .view-b > * { min-width: 0; }
.view-b { display: grid; grid-template-columns: minmax(0, 3fr) minmax(300px, 2fr); gap: 14px; }
.view-b .list { max-height: 260px; overflow: auto; font-size: 14px; }
.view-b .list div { padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.view-b .list div.sel { background: var(--bg); font-weight: 600; }
@media (max-width: 900px) { .view-b { grid-template-columns: 1fr; } .laptop-only { display: none; } }

table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
td input { min-height: 36px; padding: 4px 6px; }
tr.flag td { color: var(--bad); }

.strip { display: flex; gap: 2px; overflow-x: auto; padding: 4px 0; }
.strip img { height: 72px; border-radius: 4px; cursor: pointer; opacity: .75; }
.strip img.first { outline: 3px solid var(--draft); opacity: 1; }
.strip img.ai { border-bottom: 4px dashed var(--muted); }

#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--fg); color: var(--bg);
  padding: 10px 16px; border-radius: 10px; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 90vw; }
#toast.show { opacity: .95; }
pre.log { background: var(--bg); padding: 8px; border-radius: 8px; overflow: auto; max-height: 240px; font-size: 12px; }

/* stray scanner review additions */
button.small, header button.small { min-height: 34px; padding: 4px 10px; font-size: 13px; }
input[type=search] { min-height: 40px; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); width: 100%; margin: 8px 0; }
label.check { display: flex; gap: 8px; align-items: center; margin-top: 10px; color: var(--fg); font-size: 14px; }
.row.wrap { flex-wrap: wrap; }
.row.wrap > * { flex: 1 1 160px; }
.dims { margin-top: 12px; padding: 8px 10px; background: var(--bg); border-radius: 10px; font-size: 14px; }
details { margin-top: 12px; }
details summary { cursor: pointer; font-weight: 600; font-size: 14px; }
td.bad { color: var(--bad); font-weight: 600; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: start; }
.view-a:has(.split) { max-width: 1200px; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }
.nowrap, .nowrap button { white-space: nowrap; }
html, body { overflow-x: hidden; }
@media (max-width: 600px) {
  main { padding: 10px 10px 96px; }
  .row { flex-wrap: wrap; }
  .row > * { flex: 1 1 40%; }
  .row.nowrap > * { flex: 0 0 auto; }
  .frames canvas { max-width: 78vw; height: auto !important; }
  header.top { padding: 8px 10px; }
  #progress { flex: 1 1 100%; order: 3; }
  table { font-size: 13px; }
}
input.invalid { border-color: var(--bad) !important; outline: 2px solid var(--bad); }
body.saving button { cursor: progress; }
/* questions */
.qlist { display: grid; gap: 10px; }
.q .qhead { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.q .qtext { margin: 8px 0; font-weight: 500; }
.q .opts { margin: 4px 0 8px; padding-left: 20px; list-style: none; }
.q .opts li { padding: 2px 6px; border-radius: 6px; }
.q .opts li.right { background: color-mix(in srgb, var(--ok) 18%, transparent); font-weight: 600; }
.q .objs { font-size: 14px; margin-bottom: 4px; }
.small { font-size: 12px; }
.qs-human-verified { color: var(--ok); } .qs-partially-verified { color: var(--warn); } .qs-unreviewed { color: var(--unrev); }

/* hosted (webapp.py) */
a.btn { display: inline-flex; align-items: center; min-height: 34px; padding: 4px 10px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--fg); text-decoration: none; font-size: 13px; }
.focus { font-size: 13px; margin-bottom: 8px; padding: 6px 10px; border-radius: 10px; background: var(--bg); }
