:root {
  --bg: #0d0f0e;
  --panel: #151917;
  --panel-2: #1d2320;
  --line: #2b332f;
  --ink: #eef2ef;
  --muted: #8d9a93;
  --accent: #3ddc84;     /* accepted read */
  --amber: #ffc24a;      /* reading */
  --hot: #ff5a4f;        /* hotlist / chalk hit */
  --box: #ffffff;
  --radius: 14px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow: hidden;
  -webkit-tap-highlight-color: transparent; }
button, select, input, textarea { font: inherit; color: inherit; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }

#stage { position: fixed; inset: 0; background: #000; }
#video, #still, #overlay { position: absolute; inset: 0; width: 100%; height: 100%; }
#video, #still { object-fit: cover; }
#stage.contain #video, #stage.contain #still { object-fit: contain; }
#overlay { pointer-events: none; }

#strip { position: fixed; top: 0; left: 0; right: 0; display: flex; flex-wrap: wrap; gap: 6px;
  padding: calc(env(safe-area-inset-top) + 8px) 12px 8px; pointer-events: none;
  background: linear-gradient(#000a, #0000); }
.pill { background: #000b; border: 1px solid #ffffff22; border-radius: 99px; padding: 3px 10px; font-size: 12.5px;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); white-space: nowrap; }
.pill.ok { border-color: #3ddc8466; color: var(--accent); }
.pill.warn { border-color: #ffc24a66; color: var(--amber); }
.pill.bad { border-color: #ff5a4f66; color: var(--hot); }

#hud { position: fixed; top: calc(env(safe-area-inset-top) + 44px); left: 12px; right: 12px; max-width: 460px; margin: 0;
  padding: 10px 12px; background: #000c; border: 1px solid #ffffff1f; border-radius: 10px; font-size: 11.5px; line-height: 1.45;
  white-space: pre-wrap; word-break: break-word; max-height: 60vh; overflow: auto; }

#bar { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(6, 1fr);
  padding: 8px 6px calc(env(safe-area-inset-bottom) + 8px); background: linear-gradient(#0000, #000d 35%); }
.tool { background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; color: #dfe6e2; padding: 6px 0; border-radius: 10px; cursor: pointer; }
.tool .ico { font-size: 19px; line-height: 1; }
.tool:active, .tool.on { background: #ffffff1a; }
.tool.on { color: var(--accent); }

#toasts { position: fixed; left: 12px; right: 12px; bottom: calc(env(safe-area-inset-bottom) + 80px);
  display: flex; flex-direction: column-reverse; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 10px;
  padding: 10px 14px; min-width: 220px; max-width: 420px; box-shadow: 0 8px 30px #0008; animation: pop .18s ease-out; }
.toast b { font-family: var(--mono); font-size: 20px; letter-spacing: .06em; }
.toast.hot { border-left-color: var(--hot); }
.toast.cand { border-left-color: var(--amber); }
.toast.info { border-left-color: var(--muted); }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

.splash { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(120% 80% at 50% 0%, #1a2420 0%, var(--bg) 60%); z-index: 20; }
.splash-inner { max-width: 420px; text-align: center; }
.brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 18px; }
.plate-mark { font-family: var(--mono); font-weight: 700; font-size: 34px; letter-spacing: .18em; padding: 8px 18px 8px 24px;
  border: 3px solid var(--accent); border-radius: 8px; color: var(--ink); background: #0b120e; }
.brand-sub { color: var(--muted); font-size: 13px; letter-spacing: .08em; text-transform: uppercase; }
.lede { color: #c9d3cd; margin: 0 0 22px; }
.primary { background: var(--accent); color: #07140c; border: 0; border-radius: 12px; padding: 13px 26px; font-weight: 650; cursor: pointer; }
.primary:disabled { opacity: .5; }
.file-link { display: block; margin-top: 14px; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: 14px; }
#start-status { min-height: 1.4em; font-size: 12px; margin-top: 18px; }

.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-height: 86vh; display: flex; flex-direction: column;
  background: var(--panel); border-top: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; z-index: 10;
  box-shadow: 0 -12px 40px #000a; max-width: 640px; margin: 0 auto; }
.sheet[hidden] { display: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { margin: 0; font-size: 17px; }
.close { background: none; border: 0; color: var(--accent); font-weight: 600; cursor: pointer; }
.sheet-body { overflow: auto; padding: 4px 16px calc(env(safe-area-inset-bottom) + 20px); }
.sheet h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 20px 0 6px; font-weight: 600; }
.sheet h3 small { text-transform: none; letter-spacing: 0; font-weight: 400; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid #ffffff0d; }
.row select, .row input[type=text], .row input[type=number] { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 8px; max-width: 58%; min-width: 0; }
.row input[type=number] { width: 90px; }
.row.slider input { flex: 1; max-width: 55%; accent-color: var(--accent); }
.row output { width: 64px; text-align: right; font-size: 13px; }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); }
textarea { width: 100%; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px; font-size: 13px; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.actions button, .actions a button { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; cursor: pointer; }
.actions .primary { background: var(--accent); border-color: var(--accent); }
.danger { color: var(--hot) !important; }
progress { width: 100%; accent-color: var(--accent); }
#bench-out { white-space: pre-wrap; font-size: 12px; background: #0008; padding: 10px; border-radius: 8px; min-height: 2em; }

#read-list { list-style: none; margin: 0; padding: 0; }
.read { display: grid; grid-template-columns: 112px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid #ffffff10; cursor: pointer; }
.read img { width: 112px; height: 52px; object-fit: cover; border-radius: 6px; background: #000; }
.read .plate { font-family: var(--mono); font-size: 19px; font-weight: 700; letter-spacing: .06em; }
.read .meta { color: var(--muted); font-size: 12.5px; }
.tag { display: inline-block; font-size: 10.5px; padding: 1px 6px; border-radius: 4px; margin-left: 6px; vertical-align: middle;
  border: 1px solid currentColor; font-family: system-ui, sans-serif; letter-spacing: 0; font-weight: 600; }
.tag.loose { color: var(--amber); } .tag.hot { color: var(--hot); } .tag.chalk { color: var(--hot); }
.cand { background: #ff5a4f14; border: 1px solid #ff5a4f55; border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.cand b { font-family: var(--mono); font-size: 17px; }
.empty { color: var(--muted); text-align: center; padding: 30px 0; }

dialog#viewer { background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px;
  max-width: min(96vw, 900px); }
dialog::backdrop { background: #000c; }
#viewer-img { max-width: 100%; max-height: 60vh; display: block; margin: 0 auto; border-radius: 8px; }
#viewer-meta { font-size: 12px; white-space: pre-wrap; margin-top: 10px; color: #c9d3cd; }
