:root {
	--bg: #16161a;
	--panel: #202027;
	--line: #34343e;
	--fg: #e9e6df;
	--dim: #9a978f;
	--faint: #5d5b56;
	--accent: #e0b25c;
	--again: #d1604f;
	--hard: #d49a3c;
	--good: #5aa469;
	--easy: #4f8fd1;
	--hint: #c7a5e8;
	color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font: 17px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
main { max-width: 680px; margin: 0 auto; padding: 8px 16px 96px; }
a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: 12px 0; }
h2 { font-size: 1.25rem; margin: 8px 0; }
.dim { color: var(--dim); font-size: 0.85rem; }
.error { color: var(--again); }
button, .button { font: inherit; color: var(--fg); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; text-decoration: none; display: inline-block; cursor: pointer; min-height: 44px; }
button.primary, .button.primary { background: var(--accent); color: #1a1408; border-color: var(--accent); font-weight: 600; }
button:disabled { opacity: 0.5; }
.wide { display: block; width: 100%; text-align: center; margin: 12px 0; }
.link { background: none; border: none; color: var(--accent); padding: 4px 6px; min-height: 0; }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.row > * { flex: 1; text-align: center; }

.syncbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 4px 16px; font-size: 0.8rem; color: var(--dim); background: #111114; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.syncbar.offline { color: #1a1408; background: var(--hard); }
.syncbar.offline .link { color: #1a1408; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin: 8px 0 12px; color: var(--dim); }
.topbar.replay { color: var(--hint); }

table.decks { width: 100%; border-collapse: collapse; margin: 12px 0; }
.decks th, .decks td { text-align: left; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.decks th:not(:first-child), .decks td:not(:first-child) { text-align: right; width: 3.5em; }
.decks .sub { display: block; font-size: 0.8rem; }

.poem-head { display: flex; justify-content: space-between; align-items: center; color: var(--dim); font-size: 0.85rem; }
.badge { background: var(--easy); color: #fff; border-radius: 6px; padding: 0 6px; font-size: 0.75rem; }
.context { white-space: pre-line; color: var(--dim); font-family: Georgia, serif; margin: 16px 0 8px; font-size: 1.05rem; }
.heading { color: var(--faint); font-weight: bold; margin: 8px 0 4px; font-family: Georgia, serif; }
.verse { font-family: Georgia, serif; font-size: 1.25rem; line-height: 1.6; min-height: 3.2em; padding: 8px 0; }
.verse.blank { color: var(--faint); letter-spacing: 2px; }
.verse.hint { color: var(--hint); }
.indent { padding-left: 1.5em; }
.ratings { display: grid; grid-template-columns: repeat(auto-fit, minmax(70px, 1fr)); gap: 8px; margin: 16px 0; }
.rate.again { background: color-mix(in srgb, var(--again) 16%, var(--panel)); color: var(--again); }
.rate.hard { background: color-mix(in srgb, var(--hard) 16%, var(--panel)); color: var(--hard); }
.rate.good { background: color-mix(in srgb, var(--good) 16%, var(--panel)); color: var(--good); }
.rate.easy { background: color-mix(in srgb, var(--easy) 16%, var(--panel)); color: var(--easy); }

.whole-poem { font-family: Georgia, serif; font-size: 0.95rem; }
.wp-line { display: grid; grid-template-columns: 6px 2.2em 1fr; gap: 8px; padding: 2px 0; }
.wp-line .n { color: var(--faint); text-align: right; font-size: 0.75rem; padding-top: 3px; }
.wp-line .bar { border-radius: 3px; }
.wp-line.lit > :last-child { background: #2c2a22; border-radius: 4px; padding: 0 6px; margin-left: -6px; }
/* The highlight covers only the text, never the strength bar, so a coloured bar never meets a rounded corner. */
.lvl-locked .bar { background: #2a2a30; }
.lvl-new .bar { background: var(--line); }
.lvl-shaky .bar { background: var(--again); }
.lvl-growing .bar { background: var(--hard); }
.lvl-solid .bar { background: var(--good); }

.card .front, .card .back { font-size: 1.1rem; }
.card hr { border: none; border-top: 1px solid var(--line); margin: 16px 0; }
.card .cloze { color: var(--accent); }
.figure { max-width: 100%; border-radius: 8px; margin: 8px 0; }
.near-misses { color: var(--dim); padding-left: 1.2em; }

.recite .instructions, .causes .instructions { color: var(--dim); font-size: 0.85rem; margin: 4px 0; }
.recite-line { font-family: Georgia, serif; font-size: 1.1rem; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.recite-line.current { border-bottom-color: var(--accent); }
.recite-line .pending { color: var(--faint); font-size: 0.85rem; font-family: system-ui, sans-serif; }
.w.wrong { color: var(--again); text-decoration: underline wavy; }
.w.peek { color: var(--hard); }
.caret { color: var(--accent); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.line-grade { float: right; font-family: system-ui, sans-serif; font-size: 0.8rem; padding-left: 8px; }
.line-grade.g1 { color: var(--again); } .line-grade.g2 { color: var(--hard); } .line-grade.g3 { color: var(--good); }
.ghost-input { position: fixed; left: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; border: 0; padding: 0; font-size: 16px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.chip { border-radius: 18px; text-align: left; }
.chip small { display: block; color: var(--dim); font-size: 0.8rem; }
.chip.on { background: color-mix(in srgb, var(--accent) 20%, var(--panel)); color: var(--accent); }
.chip.right { background: #1e2b21; color: var(--good); }
.chip.missed { background: color-mix(in srgb, var(--again) 8%, var(--panel)); color: var(--again); }
.chip.wrong { background: #2d1d1b; color: var(--again); }

.locked { border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin: 8px 0; }
.locked-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.locked-head b { font-weight: 500; font-size: 0.95rem; }
.wait { display: flex; gap: 8px; align-items: center; font-size: 0.85rem; color: var(--dim); margin-top: 4px; }
.meter { flex: 0 0 60px; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--good); }
.done { color: var(--dim); text-align: center; margin-top: 40px; }
.result { white-space: pre-wrap; font-size: 0.8rem; background: var(--panel); padding: 8px; border-radius: 8px; }

.fab { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); width: 48px; height: 48px; border-radius: 24px; padding: 0; font-size: 1.3rem; z-index: 20; opacity: 0.85; }
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); display: flex; align-items: flex-end; justify-content: center; z-index: 30; }
.sheet { background: var(--panel); width: 100%; max-width: 680px; border-radius: 16px 16px 0 0; padding: 16px; }
.sheet h3 { margin: 0 0 4px; }
.sheet textarea { width: 100%; font: inherit; background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.check { display: flex; gap: 8px; align-items: center; color: var(--dim); font-size: 0.9rem; margin-top: 8px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 80px; background: var(--good); color: #0e1a10; padding: 8px 14px; border-radius: 8px; z-index: 40; font-size: 0.9rem; }
.line-rates { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 6px 0 4px; }
.mini { font: inherit; font-size: 0.8rem; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line, #444); background: transparent; color: inherit; cursor: pointer; }
.mini.on.again { background: #b3443c; border-color: #b3443c; color: #fff; }
.mini.on.hard { background: #b9862f; border-color: #b9862f; color: #111; }
.mini.on.good { background: #3f8a4f; border-color: #3f8a4f; color: #fff; }
.mini.on.easy { background: #3c6fb3; border-color: #3c6fb3; color: #fff; }
.hidden-line { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.hidden-line .hint { font-family: var(--serif, Georgia, serif); color: #c9a6e8; }
.verse-small { font-family: var(--serif, Georgia, serif); font-size: 1.05rem; line-height: 1.5; }
.hint-used { font-size: 0.8rem; color: #c9a6e8; }
.context-panel .wp-line.lit > :last-child { background: color-mix(in srgb, var(--accent) 22%, var(--panel)); }
.flatmap { background: #cfe0ee; border-radius: 12px; touch-action: manipulation; }
.flatmap .land { fill: #e9e3d3; }
.flatmap .dot { fill: #6b6357; stroke: #fff; stroke-width: 1.5; }
.flatmap .dot.done { fill: #3f8a4f; }
.flatmap .dot.answer { fill: #3f8a4f; r: 8; }
.flatmap .dot.tapped:not(.answer) { fill: #b3443c; }
.flatmap .hit { fill: transparent; }
.flatmap text { font-size: 13px; fill: #222; }
.tappable { cursor: pointer; }
.why { margin: 4px 0 8px; }
.lesson h1 { font-size: 1.4rem; margin: 8px 0; }
.lesson p, .lesson li { line-height: 1.55; }
.lesson figure { margin: 12px 0; }
.lesson figcaption { font-size: 0.85rem; opacity: 0.75; margin-top: 4px; }
.lesson .figure { width: 100%; border-radius: 8px; }
.lesson-card { background: color-mix(in srgb, var(--accent) 10%, var(--panel)); border-radius: 12px; padding: 16px; margin-top: 12px; }
.badge.sub { margin-left: 6px; display: inline-block; width: auto; font-size: 0.75rem; }

/* Golden "name the marked place" */
.flatmap .mark-ring { fill: none; stroke: #b3443c; stroke-width: 2.5; }
.flatmap .dot.marked { fill: #b3443c; }
.flatmap .reference text { font-size: 11px; fill: #555; }
.flatmap .answer-label { font-weight: 700; font-size: 14px; }

/* Scaffolding: never shown with the cue */
/* Design rule: no coloured border on a rounded element. Mark state with a tinted fill or text colour; borders stay neutral (--line). */
.scaffolds { margin: 12px 0; display: grid; gap: 8px; }
.scaffold { background: color-mix(in srgb, var(--hint) 12%, var(--panel)); border-radius: 8px; padding: 8px 12px; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 0.95rem; }
.scaffold.proposed { background: color-mix(in srgb, var(--accent) 12%, var(--panel)); }
.scaffold.retired { opacity: 0.5; }
.scaffold p { margin: 6px 0; }
.scaffold .decide { margin-top: 6px; gap: 8px; }
.scaffold-head .badge { text-transform: uppercase; font-size: 10px; letter-spacing: 0.04em; background: var(--hint); color: #1a1408; }
.scaffold.proposed .scaffold-head .badge { background: var(--accent); }
.bridge-slot { margin: 6px 0 6px 18px; }
.practice-banner { background: var(--panel); color: var(--good); border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; font-size: 0.8rem; margin: 4px 0 8px; }
.done-today { background: color-mix(in srgb, var(--good) 16%, var(--panel)); color: var(--good); }
.done h2 { margin-bottom: 4px; color: var(--fg); }
.done .button, .done button { margin-top: 10px; }
.before-scaffold { display: grid; gap: 10px; }
.small { font-size: 12px; margin: 2px 0 12px; }
.anki-card .anki { margin-bottom: 16px; }
.anki-card .anki img { max-width: 100%; height: auto; }
.anki-card .anki hr { border: none; border-top: 1px solid var(--line); }
.anki-card .anki-hint summary { cursor: pointer; color: var(--dim); }
.decks .twisty { min-height: 0; padding: 0 6px 0 0; border: none; background: none; color: var(--dim); }
