:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #17202b;
  --muted: #5d6b7a;
  --brand: #1f3a5f;
  --brand-2: #e8eef6;
  --good: #1f7a4c;
  --ok: #b7791f;
  --bad: #c0392b;
  --line: #dde3ea;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f141a; --card: #18202a; --ink: #e8edf2; --muted: #9aa7b4; --brand: #8fb3e0; --brand-2: #22303f; --line: #2a3644; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--ink); padding-bottom: 72px; }
header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--brand); color: #fff; }
header h1 { margin: 0; font-size: 18px; }
.streak { font-size: 14px; }
main { padding: 12px 16px; max-width: 720px; margin: 0 auto; }
.tab { display: none; }
.tab.active { display: block; }
nav { position: fixed; bottom: 0; left: 0; right: 0; display: grid; grid-template-columns: repeat(4, 1fr); background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
nav button { border: 0; background: none; padding: 14px 4px; font-size: 14px; color: var(--muted); }
nav button.active { color: var(--brand); font-weight: 700; }
button, select, input[type="date"], input[type="text"], textarea { font: inherit; color: inherit; }
button { border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 10px 14px; cursor: pointer; }
button.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
button:disabled { opacity: 0.5; }
select, input[type="date"], input[type="text"], textarea { width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
textarea { min-height: 110px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0; }
.row.small button { padding: 6px 10px; font-size: 14px; }
.hint { color: var(--muted); font-size: 14px; }
.camera { position: relative; border-radius: 14px; overflow: hidden; background: #000; aspect-ratio: 3 / 4; }
.camera video { width: 100%; height: 100%; object-fit: cover; }
.pill { position: absolute; top: 10px; left: 10px; background: rgba(0, 0, 0, 0.6); color: #fff; padding: 6px 12px; border-radius: 99px; font-size: 14px; }
.pill.turning { background: var(--ok); }
.pill.captured { background: var(--good); }
.motion { position: absolute; bottom: 0; left: 0; right: 0; height: 5px; background: rgba(255, 255, 255, 0.15); }
.motion span { display: block; height: 100%; width: 0; background: #fff; transition: width 0.1s; }
.switch { font-size: 14px; display: flex; gap: 6px; align-items: center; }
.queue { display: grid; gap: 8px; }
.queue .item, .page { display: grid; grid-template-columns: 64px 1fr; gap: 10px; align-items: start; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.queue img, .page img { width: 64px; height: 86px; object-fit: cover; border-radius: 6px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 700; color: #fff; }
.badge.good { background: var(--good); }
.badge.ok { background: var(--ok); }
.badge.rescan { background: var(--bad); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { border-radius: 99px; padding: 6px 12px; font-size: 14px; }
.chips button.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.pages { display: grid; gap: 8px; margin: 10px 0; }
.page .meta { font-size: 13px; color: var(--muted); }
.page ul { margin: 4px 0 0; padding-left: 18px; font-size: 13px; color: var(--muted); }
.page .actions { display: flex; gap: 6px; margin-top: 6px; }
.page .actions button { padding: 4px 8px; font-size: 13px; }
.page.selected { outline: 2px solid var(--brand); }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.options { margin: 10px 0; display: grid; gap: 8px; }
.out { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-top: 10px; min-height: 40px; overflow-wrap: anywhere; }
.out:empty { display: none; }
.out h1, .out h2, .out h3 { font-size: 17px; margin: 14px 0 6px; }
.out a { color: var(--brand); }
.concepts { display: grid; gap: 8px; }
.concept { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.concept h3 { margin: 0 0 2px; font-size: 16px; }
.concept p { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.card-face { font-size: 20px; text-align: center; padding: 28px 12px; border: 1px dashed var(--line); border-radius: 12px; margin: 10px 0; }
.choices { display: grid; gap: 6px; }
.choices button.right { background: var(--good); color: #fff; }
.choices button.wrong { background: var(--bad); color: #fff; }
.plan li { margin: 6px 0; }
.spinner::after { content: " ⏳"; }
.file { display: inline-block; border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 6px 10px; font-size: 14px; cursor: pointer; }
.file input { display: none; }
