/* Cachet. Notebook by day, Night desk after dark. Fonts are self-hosted (SIL OFL: see fonts/OFL-*.txt). */
@font-face { font-family: 'IBM Plex Sans'; src: url('../fonts/plex-sans.woff2') format('woff2'); font-weight: 100 700; font-display: swap; }
@font-face { font-family: 'IBM Plex Mono'; src: url('../fonts/plex-mono-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'IBM Plex Mono'; src: url('../fonts/plex-mono-600.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Newsreader'; src: url('../fonts/newsreader.woff2') format('woff2'); font-weight: 200 800; font-display: swap; }
@font-face { font-family: 'Newsreader'; src: url('../fonts/newsreader-italic.woff2') format('woff2'); font-weight: 200 800; font-style: italic; font-display: swap; }

:root, [data-theme='notebook'] {
  --bg: #f5efe3; --panel: #fffcf5; --panel-2: #eee7d8; --ink: #1f1c17; --muted: #5f584d; --line: #dcd2bf;
  --accent: #1f4e9e; --on-accent: #fff; --accent-soft: #e3eaf6;
  --ok: #1b6637; --ok-soft: #e1efe3; --bad: #a3341a; --bad-soft: #f6e2da; --warn-soft: #f4ead0;
  --suit-red: #a3341a; --card: #fffefb; --grid: rgba(31, 28, 23, 0.06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #141519; --panel: #1d1f24; --panel-2: #25272d; --ink: #ece5d8; --muted: #a59e92; --line: #34363c;
    --accent: #93b6ff; --on-accent: #0e1526; --accent-soft: #22304d;
    --ok: #66cf91; --ok-soft: #17321f; --bad: #ff9673; --bad-soft: #3a2219; --warn-soft: #34301f;
    --suit-red: #ff9673; --card: #282a31; --grid: rgba(236, 229, 216, 0.045);
    color-scheme: dark;
  }
}
[data-theme='night'] {
  --bg: #141519; --panel: #1d1f24; --panel-2: #25272d; --ink: #ece5d8; --muted: #a59e92; --line: #34363c;
  --accent: #93b6ff; --on-accent: #0e1526; --accent-soft: #22304d;
  --ok: #66cf91; --ok-soft: #17321f; --bad: #ff9673; --bad-soft: #3a2219; --warn-soft: #34301f;
  --suit-red: #ff9673; --card: #282a31; --grid: rgba(236, 229, 216, 0.045);
  color-scheme: dark;
}
:root {
  --display: 'Newsreader', Georgia, 'Times New Roman', serif;
  --body: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Consolas, monospace;
  --radius: 10px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background-color: var(--bg);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 22px 22px; background-attachment: fixed;
  color: var(--ink); font: 16px/1.55 var(--body); font-variant-numeric: tabular-nums;
}
h1, h2, h3, h4, .brand { font-family: var(--display); font-weight: 560; }
h1 { font-size: 1.9rem; line-height: 1.15; margin: 0 0 6px; letter-spacing: -0.01em; text-wrap: balance; }
h1:focus { outline: none; }
h2 { font-size: 1.15rem; margin: 0 0 10px; }
h3 { font-size: 1.02rem; margin: 0 0 6px; }
h4 { font-size: 0.95rem; margin: 18px 0 4px; }
p { margin: 0 0 12px; }
a { color: var(--accent); }
ul, ol { margin: 0 0 12px; padding-left: 22px; }
.lede { color: var(--muted); margin-bottom: 22px; max-width: 72ch; }
.small { font-size: 0.875rem; color: var(--muted); }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.ok { color: var(--ok); } .bad { color: var(--bad); }
.center { text-align: center; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
kbd { font: 600 0.72rem var(--mono); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; background: var(--panel); color: var(--muted); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--panel); padding: 8px 12px; border-radius: 8px; z-index: 20; }
.skip:focus { left: 8px; }

/* ── shell ── */
.shell { display: grid; grid-template-columns: 216px 1fr; min-height: 100vh; }
.nav { position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; padding: 20px 12px; border-right: 1px solid var(--line); background: var(--panel); }
.nav a.brand { display: block; font-size: 1.6rem; line-height: 1.2; padding: 0 10px; color: var(--ink); letter-spacing: -0.01em; }
.brand span { color: var(--accent); font-style: italic; font-weight: 600; margin-right: 1px; }
.brand-sub { font: 0.72rem var(--mono); color: var(--muted); padding: 0 10px 14px; margin: 0; }
.nav a, .nav button { display: flex; align-items: center; gap: 10px; color: var(--muted); text-decoration: none; padding: 8px 10px; border-radius: 8px; border: 0; background: none; font: inherit; cursor: pointer; text-align: left; }
.nav a:hover, .nav button:hover { background: var(--panel-2); color: var(--ink); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav a.brand:hover { background: none; }
.ni { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.nav-foot { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; font-size: 0.9rem; }
.badge { margin-left: auto; font: 600 0.72rem var(--mono); background: var(--accent); color: var(--on-accent); border-radius: 999px; padding: 1px 7px; }
main { padding: 32px 40px 80px; max-width: 1020px; width: 100%; justify-self: center; min-width: 0; }
.tabbar { display: none; }
#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; z-index: 30; font-size: 0.9rem; max-width: 90vw; }
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .nav { display: none; }
  main { padding: 20px 16px 96px; }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--panel); border-top: 1px solid var(--line); padding: 4px 2px calc(4px + env(safe-area-inset-bottom)); }
  .tabbar a { flex: 1; text-align: center; font-size: 0.72rem; padding: 10px 0; color: var(--muted); text-decoration: none; border-radius: 6px; }
  .tabbar a.active { color: var(--accent); font-weight: 600; background: var(--accent-soft); }
  #toast { bottom: 72px; }
  h1 { font-size: 1.55rem; }
}

/* ── building blocks ── */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.panel > :last-child { margin-bottom: 0; }
.panel-h { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.panel-h h2 { margin: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid2 > .panel { margin-bottom: 0; }
.grid2 { margin-bottom: 16px; }
.grid2 .wide { grid-column: 1 / -1; }
@media (max-width: 720px) { .grid2 { grid-template-columns: 1fr; } }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.row.center { justify-content: center; }
.row.tight { margin-top: 0; }
.grow { flex: 1; }
.btn { display: inline-flex; align-items: center; gap: 8px; font: 500 0.92rem var(--body); color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; cursor: pointer; text-decoration: none; min-height: 38px; }
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary kbd { background: transparent; color: var(--on-accent); border-color: currentColor; opacity: 0.75; }
.btn.quiet { background: transparent; color: var(--muted); }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: 0.5; cursor: default; }
.tag { display: inline-block; font: 600 0.7rem var(--mono); text-transform: uppercase; letter-spacing: 0.04em; padding: 1px 7px; border-radius: 999px; background: var(--panel-2); color: var(--muted); vertical-align: 1px; }
.tag.ok { background: var(--ok-soft); color: var(--ok); } .tag.bad { background: var(--bad-soft); color: var(--bad); }
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--panel); }
.seg > * { font: 500 0.85rem var(--body); padding: 6px 12px; border: 0; border-right: 1px solid var(--line); background: none; color: var(--muted); cursor: pointer; text-decoration: none; }
.seg > :last-child { border-right: 0; }
.seg > .on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.seg .red { color: var(--suit-red); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font: 500 0.88rem var(--body); border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 999px; padding: 5px 13px; cursor: pointer; }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip.add { border-style: dashed; color: var(--muted); }
.chip.off { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs a { padding: 8px 14px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--accent); border-color: var(--accent); font-weight: 600; }
input[type='text'], input[type='search'], textarea, select { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 7px; padding: 7px 10px; width: 100%; min-width: 0; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.75; font-style: italic; }
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 0.82rem; color: var(--muted); margin-bottom: 3px; }
.check { display: block; margin: 12px 0 0; }
.icon { display: inline-grid; place-items: center; width: 30px; height: 30px; flex: none; border: 1px solid transparent; background: none; color: var(--muted); border-radius: 6px; cursor: pointer; font: 1rem var(--mono); }
.icon:hover:not(:disabled) { border-color: var(--line); color: var(--ink); }
.icon:disabled { opacity: 0.3; cursor: default; }
.icon.danger:hover { color: var(--bad); }
.bar { height: 6px; background: var(--panel-2); border-radius: 999px; overflow: hidden; margin: 6px 0 10px; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.25s ease; }
.divider { text-align: center; color: var(--muted); font-size: 0.85rem; margin: 18px 0; display: flex; gap: 12px; align-items: center; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.crumbs { margin-bottom: 6px; }
.gmark, .lmark { display: inline-grid; place-items: center; width: 18px; height: 18px; flex: none; border: 1.5px solid var(--line); border-radius: 50%; font-size: 0.68rem; color: var(--on-accent); }
.done > .gmark, .done > a > .lmark { background: var(--ok); border-color: var(--ok); color: var(--panel); }

/* ── playing cards ── */
.pc { position: relative; display: inline-grid; place-items: center; width: 84px; height: 118px; flex: none; background: var(--card); border: 1px solid var(--line); border-radius: 8px; color: var(--ink); font-family: var(--display); box-shadow: 0 1px 0 var(--line); user-select: none; }
.pc.red, .ci.red, .pk.red { color: var(--suit-red); }
.pc b { font-weight: 600; } .pc i { font-style: normal; }
.pc-c { position: absolute; top: 6px; left: 8px; display: grid; justify-items: center; line-height: 1; font-size: 1.15rem; }
.pc-c i { font-size: 0.95rem; margin-top: 2px; }
.pc-c.br { top: auto; left: auto; bottom: 6px; right: 8px; transform: rotate(180deg); }
.pc-pip { font-size: 2.6rem; line-height: 1; }
.pc.lg { width: clamp(120px, 34vw, 168px); height: clamp(168px, 47.6vw, 236px); border-radius: 12px; }
.pc.lg .pc-c { font-size: 1.7rem; top: 10px; left: 12px; } .pc.lg .pc-c i { font-size: 1.3rem; }
.pc.lg .pc-c.br { top: auto; left: auto; bottom: 10px; right: 12px; }
.pc.lg .pc-pip { font-size: clamp(3.4rem, 11vw, 5rem); }
.pc.sm { width: 38px; height: 52px; border-radius: 5px; display: inline-flex; flex-direction: column; justify-content: center; align-items: center; line-height: 1.05; font-size: 0.98rem; box-shadow: none; }
.pc.sm i { font-size: 0.9rem; }
.pc.empty { background: transparent; border-style: dashed; box-shadow: none; }
.ci { font-family: var(--display); font-weight: 600; white-space: nowrap; }
.picker { display: grid; gap: 4px; margin: 12px 0 4px; }
.picker-row { display: grid; grid-template-columns: repeat(13, minmax(0, 1fr)); gap: 4px; }
.pk { display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.05; padding: 5px 0; min-height: 44px; background: var(--card); border: 1px solid var(--line); border-radius: 5px; font: 600 0.95rem var(--display); color: var(--ink); cursor: pointer; }
.pk i { font-style: normal; font-size: 0.85rem; }
.pk:hover:not(:disabled) { border-color: var(--accent); }
.pk:disabled { opacity: 0.22; cursor: default; }
.pk.right { background: var(--ok-soft); border-color: var(--ok); opacity: 1; }
.pk.wrong { background: var(--bad-soft); border-color: var(--bad); opacity: 1; }
@media (max-width: 480px) { .picker, .picker-row { gap: 2px; } .pk { font-size: 0.8rem; min-height: 40px; } .pk i { font-size: 0.72rem; } }

/* ── dashboard ── */
.journey { list-style: none; padding: 0; margin: 6px 0 0; display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); }
.journey li { position: relative; text-align: center; }
.journey li::before { content: ''; position: absolute; top: 10px; left: -50%; width: 100%; height: 2px; background: var(--line); }
.journey li:first-child::before { display: none; }
.journey li.done::before, .journey li.current::before { background: var(--ok); }
.journey a { position: relative; z-index: 1; display: grid; justify-items: center; gap: 6px; text-decoration: none; color: var(--muted); font-size: 0.78rem; line-height: 1.2; }
.journey .node { width: 22px; height: 22px; border-radius: 50%; background: var(--panel); border: 2px solid var(--line); display: grid; place-items: center; font-size: 0.7rem; color: var(--panel); }
.journey .done .node { background: var(--ok); border-color: var(--ok); }
.journey .current .node { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.journey .current a { color: var(--ink); font-weight: 600; }
.journey .done a { color: var(--ink); }
@media (max-width: 720px) { .journey { grid-template-columns: 1fr; gap: 0; } .journey li { text-align: left; } .journey li::before { top: -50%; left: 10px; width: 2px; height: 100%; } .journey a { grid-template-columns: 22px 1fr; justify-items: start; align-items: center; gap: 12px; padding: 5px 0; font-size: 0.9rem; } }
.plan { list-style: none; padding: 0; margin: 0 0 10px; counter-reset: plan; }
.plan li { border-top: 1px solid var(--line); }
.plan li:first-child { border-top: 0; }
.plan a { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 10px 0; text-decoration: none; color: var(--ink); }
.plan a:hover .plan-t { color: var(--accent); }
.plan-t { font-weight: 600; } .plan-w { grid-column: 1 / -1; }
.plan .done .plan-t { color: var(--muted); }
.next-lesson { display: grid; gap: 2px; padding: 12px 14px; border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 8px; text-decoration: none; color: var(--ink); margin: 10px 0 14px; background: var(--bg); }
.next-lesson b { font: 560 1.1rem var(--display); }
.next-lesson:hover { border-color: var(--accent); }
.stages-mini { list-style: none; display: flex; gap: 5px; padding: 0; margin: 0; }
.stages-mini li { flex: 1; text-align: center; font: 0.72rem var(--mono); padding: 3px 0; border-radius: 5px; background: var(--panel-2); color: var(--muted); }
.stages-mini .done { background: var(--ok-soft); color: var(--ok); }
.stages-mini .current { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { display: grid; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; text-decoration: none; color: var(--ink); align-content: start; }
a.tile:hover { border-color: var(--muted); }
.tile-l { font-size: 0.8rem; color: var(--muted); }
.tile-v { font-size: 1.6rem; font-weight: 600; line-height: 1.2; }
.tile-v span { font-size: 0.95rem; font-weight: 400; color: var(--muted); }
.tile-s { font-size: 0.78rem; color: var(--muted); }
.goal-marks { display: flex; justify-content: space-between; margin-top: -4px; }
.goal-track .bar { height: 10px; }
.activity { list-style: none; padding: 0; margin: 0; }
.activity li { display: grid; grid-template-columns: 62px 1fr auto; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); align-items: baseline; }
.activity li:first-child { border-top: 0; }

/* ── charts ── */
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 4; }
.chart .tick { font: 10px var(--mono); fill: var(--muted); }
.chart .goal { stroke: var(--ok); stroke-width: 1.2; stroke-dasharray: 5 4; }
.chart .goal-t { fill: var(--ok); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linejoin: round; }
.chart .dot { fill: var(--accent); stroke: var(--panel); stroke-width: 1.5; }
.chart .dot.miss { fill: var(--panel); stroke: var(--accent); }
.chart-empty { padding: 28px 0; text-align: center; border: 1px dashed var(--line); border-radius: 8px; }
.dist { display: flex; height: 12px; border-radius: 999px; overflow: hidden; gap: 2px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.8rem; color: var(--muted); margin-top: 10px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; border: 1px solid var(--line); }
.lv-new { background: var(--panel-2); color: var(--muted); }
.lv-learning { background: var(--accent-soft); color: var(--accent); }
.lv-shaky { background: var(--bad-soft); color: var(--bad); }
.lv-solid { background: var(--ok-soft); color: var(--ok); }
.lv-automatic { background: var(--ok); color: var(--panel); }
.lv { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.heat { display: grid; grid-template-rows: repeat(7, 12px); grid-auto-flow: column; grid-auto-columns: 12px; gap: 3px; overflow-x: auto; padding-bottom: 4px; }
.heat span { border-radius: 3px; background: var(--panel-2); }
.heat .hx { background: transparent; }
.heat .h1 { background: color-mix(in srgb, var(--ok) 35%, var(--panel-2)); }
.heat .h2 { background: color-mix(in srgb, var(--ok) 65%, var(--panel-2)); }
.heat .h3 { background: var(--ok); }

/* ── progress ── */
.mgrid { display: grid; gap: 4px; }
.mrow { display: grid; grid-template-columns: repeat(13, minmax(0, 1fr)); gap: 4px; }
.mcell { font: 600 0.82rem var(--display); border: 1px solid transparent; border-radius: 5px; padding: 8px 0; cursor: pointer; }
.mcell:hover { border-color: var(--ink); }
.mcell.sel { outline: 2px solid var(--accent); outline-offset: 1px; }
@media (max-width: 520px) { .mcell { font-size: 0.68rem; padding: 7px 0; } .mgrid, .mrow { gap: 2px; } }
.card-detail { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.detail-in { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.detail-in > div { flex: 1; min-width: 220px; }
.stat-dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px 18px; margin: 0; }
.stat-dl dt { font-size: 0.75rem; color: var(--muted); } .stat-dl dd { margin: 0; font-size: 0.9rem; }
.dots i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 3px; }
.dots i.ok { background: var(--ok); } .dots i.bad { background: var(--bad); }
.weak, .conflicts, .milestones, .ready { list-style: none; padding: 0; margin: 0; }
.weak li { display: grid; grid-template-columns: auto 1fr auto auto; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); align-items: baseline; }
.weak li:first-child { border-top: 0; }
.goals { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 8px 28px; margin-bottom: 10px; }
.goals h3 { font: 600 0.75rem var(--mono); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 8px 0 4px; }
.goals ul { list-style: none; padding: 0; margin: 0; }
.goals li, .milestones li, .ready li { display: flex; gap: 10px; align-items: center; padding: 5px 0; }
.goals li a { color: var(--ink); text-decoration: none; flex: 1; } .goals li a:hover { color: var(--accent); }
.goals li.done a { color: var(--muted); }
.milestones li span:nth-child(2) { flex: 1; }
.ladder { list-style: none; padding: 0; margin: 0 0 10px; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.ladder a { display: grid; gap: 1px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; text-decoration: none; color: var(--ink); height: 100%; }
.ladder b { font-size: 1.3rem; }
.ladder .done a { background: var(--ok-soft); border-color: transparent; }
.ladder .current a { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
@media (max-width: 720px) { .ladder { grid-template-columns: repeat(3, 1fr); } }

/* ── learn ── */
.stage-h { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: start; }
.stage-h h2 { margin: 0; } .stage-h p { margin: 2px 0 10px; }
.stage-n { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--panel-2); color: var(--muted); font-weight: 600; font-size: 0.85rem; }
.complete .stage-n { background: var(--ok-soft); color: var(--ok); }
.lessons, .recs, .modes { list-style: none; padding: 0; margin: 0; }
.lessons li { border-top: 1px solid var(--line); }
.lessons a { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 9px 4px; text-decoration: none; color: var(--ink); }
.lessons a:hover .ltitle { color: var(--accent); }
.lessons .done .ltitle { color: var(--muted); }
.lessons .next .ltitle { font-weight: 600; }
.lesson { max-width: 760px; }
.objective { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 8px; padding: 12px 16px; margin: 14px 0 22px; }
.objective b { font: 600 0.72rem var(--mono); text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); margin-right: 8px; }
.prose { font-size: 1.02rem; line-height: 1.65; }
.prose p, .prose li { max-width: 70ch; }
.prose li { margin-bottom: 5px; }
.prose .mono { font-size: 0.95em; background: var(--panel-2); padding: 1px 6px; border-radius: 4px; white-space: nowrap; }
.claim { font-size: 0.93rem; line-height: 1.55; border-left: 3px solid var(--line); padding: 2px 0 2px 14px; margin: 16px 0; color: var(--muted); }
.claim > b { display: block; font: 600 0.7rem var(--mono); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 2px; }
.claim.research { border-color: var(--ok); } .claim.research > b { color: var(--ok); }
.claim.technique { border-color: var(--accent); } .claim.technique > b { color: var(--accent); }
.claim.coach { border-color: var(--muted); } .claim.coach > b { color: var(--ink); }
.lsec { margin-top: 30px; padding-top: 20px; border-top: 1px solid var(--line); }
.lsec > h2 { font: 600 0.75rem var(--mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 12px; }
.recap ul { padding-left: 20px; } .recap li { margin-bottom: 4px; }
.lesson-nav { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 26px; }
.outcome { border-radius: 8px; padding: 12px 16px; margin-top: 12px; border: 1px solid var(--line); }
.outcome.pass { background: var(--ok-soft); border-color: transparent; } .outcome.pass b { color: var(--ok); }
.outcome.retry { background: var(--warn-soft); border-color: transparent; }
.outcome p { margin: 4px 0 0; color: var(--ink); }
.route-demo { display: flex; flex-wrap: wrap; gap: 6px 4px; list-style: none; padding: 0; counter-reset: r; }
.route-demo li { counter-increment: r; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 3px 12px 3px 6px; font-size: 0.9rem; }
.route-demo li::before { content: counter(r); font: 600 0.72rem var(--mono); background: var(--panel-2); border-radius: 50%; display: inline-grid; place-items: center; width: 19px; height: 19px; margin-right: 6px; }
.widget { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; font-size: 1rem; }
.code-out { display: flex; gap: 16px; align-items: center; margin-top: 12px; }
.assoc-sm { font: 560 1.5rem var(--display); }
.pao-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.pao-col { display: grid; justify-items: center; gap: 8px; padding: 12px 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); cursor: pointer; font: inherit; color: var(--ink); }
.pao-col.active { border-color: var(--accent); }
.pao-rows { display: grid; gap: 3px; width: 100%; font-size: 0.85rem; text-align: center; }
.pao-rows .used { background: var(--accent-soft); color: var(--accent); font-weight: 600; border-radius: 5px; padding: 2px 4px; }
.pao-rows .unused { color: var(--muted); opacity: 0.6; text-decoration: line-through; text-decoration-thickness: 1px; }
.scene-line { font: italic 500 1.35rem/1.3 var(--display); margin: 16px 0 8px; text-wrap: balance; }
.widget details { margin-top: 10px; }
table.major td.big { font-size: 1.2rem; font-weight: 600; }
@media (max-width: 520px) { .pao-col .pc { width: 62px; height: 88px; } .pao-col .pc-pip { font-size: 1.8rem; } .pao-rows { font-size: 0.72rem; } }

/* ── exercises ── */
.ex { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 14px; }
.ex > :last-child { margin-bottom: 0; }
.ex-bar { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 6px; min-height: 24px; }
.timer { font-weight: 600; font-size: 1.05rem; }
.timer.big { font-size: 1.5rem; }
.wordlist { columns: 2; column-gap: 32px; padding-left: 26px; font-size: 1.15rem; margin: 14px 0; }
.wordlist li { padding: 3px 0; break-inside: avoid; }
.wordlist li::marker { font: 0.8rem var(--mono); color: var(--muted); }
.wordlist.with-loci { columns: 1; }
.wordlist.with-loci li { display: list-item; }
.wordlist .locus { display: inline-block; width: 46%; max-width: 220px; color: var(--muted); font-size: 0.9rem; }
.recall-inputs { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px 14px; margin: 14px 0; }
.recall-inputs label { display: grid; grid-template-columns: 26px 1fr; align-items: center; gap: 6px; }
.recall-inputs label > span { color: var(--muted); font-size: 0.85rem; text-align: right; }
.recall-inputs.wide label { grid-template-columns: 110px 1fr; }
.recall-inputs.wide label > span { color: var(--ink); font-weight: 600; text-align: left; font-size: 1rem; }
.result-head { display: flex; align-items: baseline; gap: 20px; flex-wrap: wrap; margin-bottom: 8px; }
.big-score { font-size: 2.6rem; font-weight: 600; line-height: 1; }
.big-score span { font-size: 1.2rem; color: var(--muted); font-weight: 400; }
.result-meta { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 0.9rem; color: var(--muted); }
.feedback { padding-left: 20px; margin: 12px 0; } .feedback li { margin-bottom: 6px; max-width: 72ch; }
.cmp-wrap { overflow-x: auto; margin: 10px 0; }
table { border-collapse: collapse; width: 100%; }
.cmp th { text-align: left; font: 600 0.72rem var(--mono); text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); padding: 6px 10px; border-bottom: 1px solid var(--line); }
.cmp td { padding: 6px 10px; border-bottom: 1px solid var(--line); font-size: 0.93rem; }
.cmp tr.miss td { background: var(--bad-soft); }
.pairs { display: grid; gap: 8px; margin: 14px 0; }
.pair { display: grid; grid-template-columns: minmax(90px, 1fr) auto minmax(90px, 1fr) 2.2fr; gap: 10px; align-items: center; font-size: 1.05rem; }
.pair span { color: var(--muted); }
@media (max-width: 600px) { .pair { grid-template-columns: 1fr auto 1fr; } .pair input { grid-column: 1 / -1; } .wordlist { columns: 1; } }
.imagine { display: grid; gap: 14px; margin: 14px 0; }
.imagine label > span { font: 560 1.1rem var(--display); display: block; margin-bottom: 4px; }
.imagine p { margin: 4px 0 0; }
.imagine .img-example { border-left: 2px solid var(--accent); padding-left: 10px; margin-top: 6px; color: var(--ink); }
.idea-form input { flex: 1 1 220px; min-width: 0; font-size: 1.05rem; }
.idea-samples { margin-top: 12px; align-items: center; }
.idea-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px 22px; }
.idea-group h3 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 6px; }
.idea-group ul { margin: 0; padding-left: 18px; }
.idea-group li { margin: 2px 0; }
.idea-group p { margin: 6px 0 0; }
[data-peg-save] input { flex: 0 1 200px; }
.q { font: 500 1.2rem/1.4 var(--display); margin: 8px 0 14px; }
.q.big { font-size: 2.2rem; font-family: var(--mono); }
.options { display: grid; gap: 8px; }
.opt { justify-content: flex-start; text-align: left; }
.opt.right { background: var(--ok-soft); border-color: var(--ok); opacity: 1; }
.opt.wrong { background: var(--bad-soft); border-color: var(--bad); opacity: 1; }
.why { margin: 12px 0; }
input.answer { font-size: 1.4rem; max-width: 200px; letter-spacing: 0.06em; margin-bottom: 12px; }
input.answer.wide { max-width: 100%; }
.digits { display: flex; flex-wrap: wrap; gap: 12px 16px; margin: 16px 0; }
.digits span { display: grid; justify-items: center; }
.digits b { font-size: 1.9rem; font-weight: 600; letter-spacing: 0.04em; }
.digits b.bad { color: var(--bad); text-decoration: underline; }
.digits i { font: normal 0.8rem var(--body); color: var(--muted); }
.digits.result span { grid-auto-flow: row; } .digits.result span b { display: inline; }
.digits.result span { display: block; text-align: center; } .digits.result i { display: block; font-family: var(--mono); font-size: 1rem; }
.drill .prompt { display: grid; justify-items: center; gap: 12px; padding: 18px 0 6px; width: 100%; background: none; border: 0; color: inherit; font: inherit; }
.prompt.tap { cursor: pointer; }
.answer-line { font: 560 1.6rem/1.25 var(--display); min-height: 2rem; text-align: center; text-wrap: balance; }
.answer-line .bad, .answer-line .ok, .answer-line .muted { font: 500 1rem var(--body); }
.cue { min-height: 1.3rem; text-align: center; }
.assoc { font: 560 2.2rem/1.2 var(--display); text-align: center; padding: 20px 0 4px; text-wrap: balance; }
.assoc.scene { font-size: 1.6rem; font-style: italic; }
.peg-num, .locus-n { font-size: 4.2rem; font-weight: 600; line-height: 1.1; padding: 16px 0; }
.last { text-align: right; }
.triple { display: flex; gap: 10px; justify-content: center; }
.pao-parts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 12px 0; }
.pao-parts > div { display: grid; justify-items: center; gap: 4px; text-align: center; padding: 10px 6px; border: 1px solid var(--line); border-radius: 8px; }
.pao-parts > div.miss { background: var(--bad-soft); border-color: var(--bad); }
.pao-mark { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 10px 0; }
.slots3 { display: flex; gap: 12px; justify-content: center; }
.slot3 { display: grid; justify-items: center; gap: 4px; padding: 6px 10px; border-radius: 8px; border: 1px solid transparent; }
.slot3.active { border-color: var(--accent); background: var(--accent-soft); }
.two-bars { display: grid; gap: 6px; margin: 10px 0 14px; }
.two-bars > div { display: grid; grid-template-columns: 100px 1fr 50px; gap: 12px; align-items: center; }
.two-bars .bar { margin: 0; height: 10px; }
.task.done { border-color: var(--ok); }
.mode-opts { display: flex; flex-wrap: wrap; gap: 10px 20px; margin-bottom: 16px; }
.mode-opts > div { display: grid; gap: 3px; }
.recs li, .modes li { border-top: 1px solid var(--line); }
.recs li:first-child, .modes li:first-child { border-top: 0; }
.recs a { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 9px 0; text-decoration: none; color: var(--ink); }
.recs a > :last-child { grid-column: 1 / -1; }
.modes { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0 24px; }
.modes li { border-top: 1px solid var(--line) !important; }
.modes a { display: grid; gap: 1px; padding: 9px 0; text-decoration: none; color: var(--ink); }
.modes a:hover b, .recs a:hover b { color: var(--accent); }

/* ── arena ── */
.opts { display: flex; flex-wrap: wrap; gap: 14px 28px; margin: 14px 0 4px; }
.opts fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.opts legend { font-size: 0.82rem; color: var(--muted); padding: 0; margin-bottom: 4px; }
.opts p { margin: 4px 0 0; }
.deck-stage { display: flex; justify-content: center; align-items: flex-start; gap: clamp(8px, 2vw, 18px); padding: 22px 0 14px; cursor: pointer; min-height: 260px; touch-action: pan-y; }
.stage-card { display: grid; justify-items: center; gap: 8px; }
.hint { font: 500 0.95rem var(--display); color: var(--muted); text-align: center; max-width: 150px; }
.deck-stage:has(.stage-card:nth-child(3)) .pc.lg { width: clamp(92px, 27vw, 150px); height: clamp(129px, 37.8vw, 210px); }
.deck-stage:has(.stage-card:nth-child(3)) .pc-pip { font-size: clamp(2.4rem, 8vw, 4.2rem); }
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 6px; margin: 10px 0; }
.slot { display: grid; justify-items: center; gap: 2px; padding: 3px 0 5px; border: 1px solid transparent; border-radius: 7px; background: none; cursor: pointer; color: var(--muted); }
.slot-n { font-size: 0.68rem; }
.slot.active { border-color: var(--accent); background: var(--accent-soft); }
.slot.filled { cursor: grab; }
.picker-dock { position: sticky; bottom: 0; background: var(--panel); padding: 4px 0; border-top: 1px solid var(--line); z-index: 2; }
@media (max-width: 820px) { .picker-dock { bottom: 52px; } }
.picker-dock .picker-help { margin: 2px 0 0; }
@media (max-width: 600px) { .picker-help { display: none; } }
.milestone { background: var(--ok-soft); border-radius: 8px; padding: 10px 14px; margin: 10px 0; }
.milestone b { color: var(--ok); margin-right: 8px; }
.cmp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(50px, 1fr)); gap: 6px; margin: 8px 0 14px; }
.cmp-cell { display: grid; justify-items: center; gap: 3px; padding: 4px 2px 6px; border-radius: 7px; border: 1px solid var(--line); font-size: 0.68rem; color: var(--muted); }
.cmp-cell.miss { background: var(--bad-soft); border-color: var(--bad); }
.cmp-cell .tick { height: 52px; display: grid; place-items: center; font-size: 1rem; }
.pc.yours { border-color: var(--bad); }

/* ── systems ── */
.route { list-style: none; padding: 0; display: grid; gap: 10px; }
.route-area > span { display: block; font: 600 0.72rem var(--mono); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.route-area ol { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.route-area ol li { display: inline-flex; align-items: center; gap: 7px; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 3px 12px 3px 5px; font-size: 0.9rem; }
.route-area ol li .mono { background: var(--panel-2); border-radius: 999px; min-width: 22px; height: 22px; display: inline-grid; place-items: center; font-size: 0.72rem; font-weight: 600; padding: 0 5px; }
.route-area img { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; }
.area { border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-bottom: 12px; background: var(--bg); }
.area-h { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; }
.area-h input { font-weight: 600; background: var(--panel); }
.loci { list-style: none; padding: 0; margin: 0 0 8px; counter-reset: none; }
.loci li { display: grid; grid-template-columns: minmax(110px, 1fr) minmax(0, 1.4fr) auto auto auto auto; gap: 6px; align-items: center; margin-bottom: 5px; }
.loci input { background: var(--panel); }
.thumb { width: 30px; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; cursor: pointer; background: none; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
@media (max-width: 600px) { .loci li { grid-template-columns: 1fr auto auto auto auto; } .loci .note { display: none; } }
.add-locus { display: flex; gap: 8px; } .add-locus input { background: var(--panel); }
.add-area input { background: var(--bg); }
.img-grid { display: grid; gap: 4px; margin: 12px 0; overflow-x: auto; }
.img-row { display: grid; grid-template-columns: repeat(13, minmax(64px, 1fr)); gap: 4px; }
.img-cell { display: grid; gap: 1px; justify-items: center; padding: 6px 2px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; cursor: pointer; font: inherit; min-width: 0; }
.img-cell span:last-child { font-size: 0.72rem; line-height: 1.15; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.img-cell.own span:last-child { color: var(--ink); font-weight: 600; }
.img-cell.sugg span:last-child, .key.sugg { color: var(--muted); font-style: italic; }
.img-cell.sel { border-color: var(--accent); background: var(--accent-soft); }
.key { margin-right: 14px; } .key.own { color: var(--ink); font-weight: 600; }
.card-edit { display: grid; grid-template-columns: auto 1fr; gap: 24px; align-items: start; }
.edit-card { display: grid; justify-items: center; gap: 10px; }
@media (max-width: 640px) { .card-edit { grid-template-columns: 1fr; } .edit-card .pc.lg { width: 110px; height: 154px; } }
.suggestion { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; border: 1px dashed var(--line); border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; }
.suggestion b { font: italic 500 1.1rem var(--display); color: var(--muted); }
.suggestion .btn { margin-left: auto; }
.edit-form h3 { margin-top: 18px; font: 600 0.72rem var(--mono); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.pao-table th { text-align: left; font: 600 0.72rem var(--mono); text-transform: uppercase; color: var(--muted); padding: 4px 6px; }
.pao-table td, .pao-table tbody th { padding: 3px 4px; }
.pao-table tbody th { width: 48px; }
.pao-table { min-width: 520px; margin-top: 12px; }
.conflicts li { padding: 7px 0; border-top: 1px solid var(--line); }
.conflicts li:first-child { border-top: 0; }
.conflicts li .small { display: block; }
.major-strip { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 4px; margin-bottom: 10px; }
.major-strip div { display: grid; justify-items: center; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 2px; font-size: 0.8rem; text-align: center; }
.major-strip b { font-size: 1.2rem; }
@media (max-width: 600px) { .major-strip { grid-template-columns: repeat(5, 1fr); } }
.peg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; margin: 10px 0; }
.peg-grid label { display: grid; grid-template-columns: 28px 1fr; align-items: center; gap: 4px; }
.peg-grid span { font-weight: 600; font-size: 0.9rem; }
.peg-grid input { padding: 5px 8px; font-size: 0.9rem; }

/* ── handbook ── */
.hb-search { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; }
.hb-search input { max-width: 380px; background: var(--panel); }
.hb { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 24px; align-items: start; }
.hb-toc { position: sticky; top: 20px; display: grid; gap: 2px; font-size: 0.9rem; }
.hb-toc a { color: var(--muted); text-decoration: none; padding: 4px 8px; border-radius: 6px; }
.hb-toc a:hover { background: var(--panel-2); color: var(--ink); }
.hb-body .panel h2 { font-size: 1.3rem; }
@media (max-width: 820px) { .hb { grid-template-columns: 1fr; } .hb-toc { position: static; display: flex; flex-wrap: wrap; } }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
@media print { .nav, .tabbar { display: none; } .shell { display: block; } body { background: #fff; } }
.pair-cards { white-space: nowrap; }
