/* Mobile textbook reader. No external fonts or libraries: everything works offline. */
:root {
  --bg: #ffffff; --fg: #1b1b1b; --muted: #6b6b6b; --line: #e3e3e3;
  --panel: #f6f6f6; --accent: #1f6feb; --accent-fg: #ffffff;
  --fs: 19px; --lh: 1.55;
  --font: Georgia, "Noto Serif", "DejaVu Serif", "Times New Roman", serif;
  --bar-h: 48px; --foot-h: 28px;
}
[data-theme="sepia"] { --bg: #f5ecd9; --fg: #4a3b2a; --muted: #8a7458; --line: #e0d2b4; --panel: #ece0c6; --accent: #9a5b13; }
[data-theme="dark"]  { --bg: #111315; --fg: #d8d8d8; --muted: #8c8c8c; --line: #2a2d31; --panel: #1b1e21; --accent: #6ea8ff; --accent-fg: #0b0b0b; }
[data-theme="contrast"] { --bg: #000000; --fg: #ffffff; --muted: #c8c8c8; --line: #444; --panel: #151515; --accent: #ffd400; --accent-fg: #000; }
[data-font="sans"] { --font: Roboto, "Noto Sans", "DejaVu Sans", Arial, sans-serif; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); }
body { font: 16px/1.4 Roboto, "Noto Sans", Arial, sans-serif; overscroll-behavior: none; touch-action: manipulation; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: var(--accent); }

/* ---------- Library ---------- */
.lib { max-width: 640px; margin: 0 auto; padding: 16px 16px 40px; }
.lib h1 { font-size: 22px; margin: 8px 0 4px; }
.lib .sub { color: var(--muted); margin: 0 0 12px; font-size: 14px; }
.lib-head { display: flex; align-items: center; gap: 10px; margin: 8px 0 4px; }
.lib-head h1 { flex: 1; margin: 0; }
.school { display: flex; margin: 0 0 16px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.school button { flex: 1; min-height: 52px; padding: 6px 4px; font-size: 15px; background: var(--panel); display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.2; }
.school button b { font-weight: 600; white-space: nowrap; }
.school button small { font-size: 12px; opacity: .75; }
.school button + button { border-left: 1px solid var(--line); }
.school button.on { background: var(--accent); color: var(--accent-fg); }
.my-link { flex: 0 0 auto; font-weight: 600; min-height: 40px; padding: 0 12px; font-size: 14px; }
.grade { margin-bottom: 10px; }
.grade-h { display: flex; width: 100%; align-items: center; justify-content: space-between; min-height: 52px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--panel); font-size: 18px; font-weight: 600; text-align: left; }
.grade-h::after { content: '›'; font-size: 24px; color: var(--muted); margin-left: 10px; transition: transform .15s; }
.grade.open .grade-h::after { transform: rotate(90deg); }
.grade-h .n { margin-left: auto; font-size: 14px; font-weight: 400; color: var(--muted); }
.grade-b { padding: 0 2px; }
.grade-t { font-size: 20px; margin: 18px 0 0; }
.subj { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 16px 0 6px; }
.bk { border-bottom: 1px solid var(--line); padding: 4px 0 12px; }
.bk:last-child { border-bottom: 0; }
.bk-t { font-size: 17px; font-weight: 600; }
.bk-s { font-size: 14px; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bk-m { color: var(--muted); font-size: 13px; margin: 3px 0 8px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 16px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--bg); font-size: 15px; text-decoration: none; color: var(--fg); }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-weight: 600; }
.btn[disabled] { opacity: .5; }
.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin-top: 10px; }
.progress > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.note { color: var(--muted); font-size: 13px; margin-top: 8px; }
.bk-h { display: flex; align-items: flex-start; gap: 4px; }
.bk-h .bk-t { flex: 1; padding-top: 10px; }
.bk .row { gap: 4px; }
.bk .row .btn { min-height: 40px; padding: 0 18px; font-size: 14px; margin-right: 8px; }
.bk .icon { color: var(--muted); flex: 0 0 auto; }
.bk .icon[disabled] { opacity: .5; }
.bk .icon.on { color: var(--accent); }
.bk .star.on svg { fill: currentColor; }
.bk .star.on { color: #e3a008; }
.share-opts { display: flex; flex-direction: column; gap: 10px; }
.share-opts .note { margin-top: 0; }
.sheet h3 .icon { flex: 0 0 auto; }

/* ---------- Reader ---------- */
.reader { position: fixed; inset: 0; overflow: hidden; touch-action: pan-y; user-select: text; }
.viewport { position: absolute; left: 0; right: 0; top: 0; bottom: var(--foot-h); overflow: hidden; }
.flow {
  height: 100%; column-fill: auto; padding: 20px 0 12px;
  font-family: var(--font); font-size: var(--fs); line-height: var(--lh);
  will-change: transform; transform: translate3d(0,0,0);
  hyphens: auto; -webkit-hyphens: auto; overflow-wrap: break-word;
}
.flow.anim { transition: transform .25s ease-out; }
.flow p { margin: 0 0 .15em; text-indent: 1.4em; text-align: left; }
.flow p.ni { text-indent: 0; }
.flow h1, .flow h2, .flow h3 { font-family: Roboto, "Noto Sans", Arial, sans-serif; line-height: 1.25; break-after: avoid; page-break-after: avoid; }
.flow h1 { font-size: 1.35em; margin: .2em 0 .8em; text-align: center; }
.flow h2 { font-size: 1.15em; margin: 1.1em 0 .5em; }
.flow h3 { font-size: 1.0em; margin: 1em 0 .4em; }
.flow .verse { margin: .6em 0 .8em 1em; break-inside: auto; }
.flow .verse div { text-indent: -1em; padding-left: 1em; text-align: left; }
.flow .verse .gap { height: .7em; }
.flow figure { margin: .8em 0; text-align: center; break-inside: avoid; page-break-inside: avoid; }
.flow figure img { max-width: 100%; height: auto; border-radius: 4px; background: var(--panel); }
.flow figcaption { font-size: .8em; color: var(--muted); margin-top: .3em; }
.flow .box { border-left: 3px solid var(--accent); padding: .1em 0 .1em .7em; margin: .7em 0; }
.flow .pg { font: 11px/1 Roboto, Arial, sans-serif; color: var(--muted); border: 1px solid var(--line);
  border-radius: 6px; padding: 1px 4px; margin: 0 3px; vertical-align: 2px; text-indent: 0; white-space: nowrap; user-select: none; }
.flow .end { height: 1px; }
.flow .endnote { text-align: center; color: var(--muted); font-size: .8em; margin-top: 2em; font-family: Roboto, Arial, sans-serif; }
[data-theme="dark"] .flow img, [data-theme="contrast"] .flow img { filter: brightness(.9); }

.foot { position: absolute; left: 0; right: 0; bottom: 0; height: var(--foot-h); display: flex; align-items: center;
  justify-content: space-between; padding: 0 14px; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; }
.foot .t { overflow: hidden; text-overflow: ellipsis; margin-right: 12px; }

.bar { position: absolute; left: 0; right: 0; background: var(--panel); border-color: var(--line); z-index: 5;
  transition: transform .2s; display: flex; align-items: center; }
.bar.top { top: 0; height: var(--bar-h); border-bottom: 1px solid var(--line); transform: translateY(-100%); padding: 0 4px; }
.bar.bottom { bottom: 0; border-top: 1px solid var(--line); transform: translateY(100%); padding: 10px 16px 14px; flex-direction: column; align-items: stretch; gap: 6px; }
.reader.ui .bar { transform: none; }
.bar .title { flex: 1; font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 4px; }
.icon { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: 22px; }
.icon svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.bar input[type=range] { width: 100%; accent-color: var(--accent); height: 28px; }
.bar .info { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }

/* ---------- Sheets (TOC, settings) ---------- */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 10; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-height: 85%; overflow: auto; background: var(--bg);
  border-radius: 16px 16px 0 0; z-index: 11; padding: 8px 16px 24px; -webkit-overflow-scrolling: touch; }
.sheet h3 { margin: 10px 0 12px; font-size: 17px; display: flex; justify-content: space-between; align-items: center; }
.toc a { display: block; padding: 11px 4px; border-bottom: 1px solid var(--line); color: var(--fg); text-decoration: none; font-size: 15px; }
.toc a.sub { padding-left: 20px; font-size: 14px; color: var(--muted); }
.toc a.cur { color: var(--accent); font-weight: 600; }
.set { margin: 14px 0; }
.set label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.seg { display: flex; gap: 6px; }
.seg button { flex: 1; min-height: 44px; border-radius: 10px; border: 1px solid var(--line); font-size: 15px; }
.seg button.on { border: 2px solid var(--accent); font-weight: 600; }
.swatch[data-v="light"] { background: #fff; color: #1b1b1b; }
.swatch[data-v="sepia"] { background: #f5ecd9; color: #4a3b2a; }
.swatch[data-v="dark"] { background: #111315; color: #d8d8d8; }
.swatch[data-v="contrast"] { background: #000; color: var(--accent-fg); }
.goto { display: flex; gap: 8px; }
.goto input { flex: 1; min-height: 44px; font-size: 16px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); }

.toast { position: fixed; left: 50%; bottom: 60px; transform: translateX(-50%); background: #333; color: #fff; padding: 10px 16px;
  border-radius: 20px; font-size: 14px; z-index: 20; max-width: 90%; text-align: center; }
.loading { padding: 40px 16px; text-align: center; color: var(--muted); }

/* ---------- Textbook elements produced by tools/convert_pdf.py ---------- */
.flow .tasks, .flow .gloss { font-family: Roboto, "Noto Sans", Arial, sans-serif; font-size: .88em; line-height: 1.45;
  background: var(--panel); border-radius: 8px; padding: .5em .7em; margin: .8em 0; }
.flow .tasks p, .flow .gloss p { margin: 0 0 .35em; text-align: left; }
.flow .gloss { border-left: 3px solid var(--accent); }
.flow p.note { font-family: Roboto, "Noto Sans", Arial, sans-serif; font-size: .9em; font-style: italic; text-indent: 0; margin: .6em 0; }
.flow p.attr { text-align: right; text-indent: 0; font-style: italic; color: var(--muted); margin: .1em 0 .8em; }
.flow p.sep { text-align: center; text-indent: 0; color: var(--muted); margin: .5em 0; letter-spacing: .3em; }
.flow h2 .pg, .flow h3 .pg { font-weight: normal; }
.toc .sec { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 16px 4px 2px; }
.toc a .p { float: right; color: var(--muted); font-size: 13px; margin-left: 8px; }

/* ---------- Elements produced by tools/convert_layout.py (typeset textbooks) ---------- */
.flow figure img { cursor: zoom-in; }
.flow h4.mk { font: 700 .78em/1.3 Roboto, "Noto Sans", Arial, sans-serif; letter-spacing: .05em; color: var(--accent);
  margin: 1em 0 .3em; break-after: avoid; page-break-after: avoid; }
.flow p.hl { color: var(--accent); text-indent: 0; }
.flow p.small { font-size: .82em; text-indent: 0; color: var(--muted); }
.flow sup, .flow sub { font-size: .7em; line-height: 0; }
.flow .kbox { font-family: Roboto, "Noto Sans", Arial, sans-serif; font-size: .88em; line-height: 1.45; background: var(--panel);
  border-radius: 8px; padding: .45em .7em; margin: .5em 0; border-left: 3px solid var(--accent); }
.flow .kbox > b { display: block; }
.flow .frame { background: var(--panel); border-radius: 8px; padding: .5em .7em; margin: .8em 0;
  font-family: Roboto, "Noto Sans", Arial, sans-serif; font-size: .9em; line-height: 1.45; }
.flow .frame p { text-indent: 0; margin: 0 0 .35em; text-align: left; }
.flow .tbl { margin: .8em 0; font-family: Roboto, "Noto Sans", Arial, sans-serif; font-size: .8em; line-height: 1.35; }
.flow .tbl .tt { font-weight: 600; text-indent: 0; text-align: center; margin-bottom: .3em; }
.flow .tbl table { border-collapse: collapse; width: 100%; table-layout: fixed; }
.flow .tbl th, .flow .tbl td { border: 1px solid var(--line); padding: .3em .35em; vertical-align: top; text-align: left; overflow-wrap: anywhere; hyphens: auto; }
.flow .tbl th { background: var(--panel); }
.flow .tbl tr { break-inside: avoid; page-break-inside: avoid; }

.zoom { position: fixed; inset: 0; touch-action: pan-x pan-y; -webkit-user-select: none; user-select: none; background: rgba(0,0,0,.92); z-index: 30; }
.zoom-in { position: absolute; inset: 0; overflow: auto; display: flex; -webkit-overflow-scrolling: touch; }
.zoom-in img { margin: auto; flex: none; touch-action: pan-x pan-y; object-fit: contain; background: #fff; cursor: zoom-in; }
.zoom-x { position: absolute; top: 8px; right: 8px; color: #fff; background: rgba(0,0,0,.5); z-index: 31; }
.flow h4.sh { font: 700 .95em/1.3 Roboto, "Noto Sans", Arial, sans-serif; text-align: center; margin: .8em 0 .4em; break-after: avoid; page-break-after: avoid; }

/* maths books */
.flow h4.ex, .flow h4.try { font-family: Roboto, Arial, sans-serif; margin: 1.1em 0 .3em; font-size: 1em; }
.flow h4.ex { display: inline-block; background: #f7e400; color: #111; padding: .1em .6em; border-radius: 3px; }
.flow h4.try { color: var(--accent); }
.flow p.goal { font-size: .85em; text-indent: 0; background: var(--panel); border-radius: 8px; padding: .4em .7em; }
.flow b.bd { display: inline-block; text-indent: 0; padding: 0 .4em; border-radius: 1em; background: var(--fg); color: var(--bg);
  font: bold .8em/1.45 Roboto, Arial, sans-serif; margin-right: .2em; }
.flow b.nb { display: inline-block; text-indent: 0; min-width: 1.4em; border-radius: 4px; background: var(--accent); color: var(--accent-fg);
  text-align: center; font-size: .8em; margin-right: .3em; }
.flow .fr { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; font-size: .85em; line-height: 1.15; margin: 0 .1em; }
.flow .fr > span:first-child { border-bottom: 1px solid currentColor; padding: 0 .15em; }
.flow p.ml { text-indent: 0; padding-left: 1em; }
.flow p.side { font-size: .85em; }
.flow details.ans { margin: .3em 0 .8em; font-size: .9em; }
.flow details.ans summary { color: var(--accent); cursor: pointer; font-family: Roboto, Arial, sans-serif; }

/* wide tables become one card per row on phones */
@media (max-width: 560px) {
  .flow .tbl.cards table, .flow .tbl.cards tbody, .flow .tbl.cards tr, .flow .tbl.cards td { display: block; width: auto; }
  .flow .tbl.cards tr:first-child { display: none; }
  .flow .tbl.cards tr { border: 1px solid var(--line); border-radius: 8px; margin: .5em 0; padding: .3em .5em; }
  .flow .tbl.cards td { border: 0; padding: .15em 0; }
  .flow .tbl.cards td::before { content: attr(data-l); display: block; font: 600 .75em/1.3 Roboto, Arial, sans-serif; color: var(--muted); }
  .flow .tbl.cards td:first-child { font-weight: 600; }
}
.flow figure.vec svg { max-width: 100%; height: auto; display: inline-block; background: #fff; border-radius: 4px; cursor: zoom-in; }
[data-theme="dark"] .flow figure.vec svg, [data-theme="contrast"] .flow figure.vec svg { filter: brightness(.9); }
.flow .rt { border-top: 1px solid currentColor; padding-top: 1px; margin-left: 1px; }
.flow .it { display: inline-block; max-width: 100%; margin-right: .9em; text-indent: 0; }

/* ---------- Text quality badge (library rows, first page of a book, reader top bar) ---------- */
.q { display: inline-flex; align-items: center; gap: 6px; min-height: 26px; padding: 2px 10px 2px 8px; margin: 0 8px 2px 0;
  border: 1px solid var(--line); border-radius: 13px; background: var(--panel); color: var(--fg);
  font: 12px/1.2 Roboto, "Noto Sans", Arial, sans-serif; vertical-align: middle; text-indent: 0; white-space: nowrap; }
.q i, .qdot i { flex: 0 0 auto; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.q-exact i { background: #2da44e; }
.q-proofread i { background: #3b82f6; }
.q-ocr i { background: #e8900c; }
.qdot { display: inline-flex; width: 24px; height: 24px; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 12px; }
.qdot i { width: 12px; height: 12px; }
.bk .row .q { margin: 0 0 0 auto; }
.flow .qline { margin: 0 0 1em; text-indent: 0; }
.flow .qline .q { font-size: 13px; cursor: pointer; }
.qsheet .q { font-size: 14px; min-height: 30px; margin: 0 0 4px; }
.qsheet p { font-size: 15px; line-height: 1.5; margin: 10px 0; }

/* ---------- Menu (☰), "What's new", missing books ---------- */
.lib-head .burger { flex: 0 0 auto; margin-left: -10px; }
.drawer { position: fixed; top: 0; bottom: 0; left: 0; width: min(300px, 85%); background: var(--bg); z-index: 11;
  padding: 8px 0 24px; overflow: auto; box-shadow: 2px 0 12px rgba(0,0,0,.2); }
.drawer-h { display: flex; align-items: center; justify-content: space-between; padding: 0 4px 8px 16px; font-weight: 600; font-size: 17px; }
.drawer a { display: block; padding: 14px 16px; color: var(--fg); text-decoration: none; font-size: 16px; border-top: 1px solid var(--line); }
.drawer a.cur { color: var(--accent); font-weight: 600; }
.drawer .note { padding: 8px 16px 0; border-top: 1px solid var(--line); margin-top: 0; }
.news-d { font-size: 15px; color: var(--muted); font-weight: 600; margin: 20px 0 6px; }
.news { border-bottom: 1px solid var(--line); padding: 2px 0 10px; }
.news p { margin: 6px 0; font-size: 15px; line-height: 1.5; }
.news summary { color: var(--accent); cursor: pointer; font-size: 14px; min-height: 32px; line-height: 32px; }
.news-b { margin: 2px 0 4px; padding-left: 20px; font-size: 14px; line-height: 1.8; }
.bk.miss { padding: 8px 0 12px; }
.bk.miss .bk-m { margin-bottom: 6px; }
.ms { display: inline-block; font-size: 12px; padding: 2px 10px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.ms-kyonly, .ms-edition, .ms-sample { border-color: #e8900c; }
.bk.miss .note { margin-top: 6px; font-size: 14px; }
.offer { margin: 24px 0 0; padding: 14px 16px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.offer h2 { font-size: 18px; margin: 0 0 6px; }
.offer p { margin: 6px 0; font-size: 15px; line-height: 1.5; }
.up label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
.up select, .up input[type=text], .up textarea { width: 100%; min-height: 44px; font-size: 16px; padding: 8px 10px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--fg); font-family: inherit; }
.up input[type=file] { font-size: 15px; max-width: 100%; }
.up .btn { margin-top: 14px; width: 100%; }
.up .done { font-weight: 600; }

/* ---------- Report a text error (select text in a book) ---------- */
.rep { position: absolute; left: 50%; bottom: calc(var(--foot-h) + 14px); transform: translateX(-50%); z-index: 6;
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 22px;
  background: var(--accent); color: var(--accent-fg); font-size: 15px; font-weight: 600; box-shadow: 0 2px 10px rgba(0,0,0,.25);
  white-space: nowrap; -webkit-user-select: none; user-select: none; }
.rep[hidden] { display: none; }
.rep svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.rq { margin: 0 0 6px; padding: 8px 12px; border-left: 3px solid var(--accent); background: var(--panel); border-radius: 6px;
  font-family: var(--font); font-size: 16px; line-height: 1.45; max-height: 30vh; overflow: auto; }
.sheet textarea { width: 100%; font-size: 16px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--fg); font-family: inherit; }
.sheet .rsend { width: 100%; }

/* library: how much of the Ministry's list is on the site (links to the statistics page) */
.lib-count { display: block; margin: -6px 0 14px; font-size: 14px; color: var(--muted); text-decoration: none; }

/* statistics page */
.st-total { font-size: 17px; margin: 4px 0 8px; }
.st-total b { font-size: 28px; }
.st-bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--line); flex: 1; }
.st-bar i, .st-legend i { display: block; }
.st-on { background: var(--accent); }
.st-work { background: #8fb8f2; }
.st-rf { background: #a48fd1; }
.st-part { background: #e8b04a; }
.st-none { background: #d9615a; }
.st-legend { list-style: none; padding: 0; margin: 14px 0 6px; }
.st-legend li { position: relative; padding: 5px 0 5px 24px; font-size: 15px; }
.st-legend li i { position: absolute; left: 0; top: 9px; width: 14px; height: 14px; border-radius: 4px; }
.st-legend .note { margin: 2px 0 0; }
.st-pc { color: var(--muted); font-size: 13px; }
.st-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; font-size: 14px; }
.st-row > span:first-child { flex: 0 0 74px; }
.st-row .st-n { flex: 0 0 58px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.st-sum { font-weight: 600; }
.st-sum .st-n { color: inherit; }

/* leaving the site (a book's source) */
.leave-b { display: flex; gap: 10px; margin: 6px 0 4px; }
.leave-b .btn { flex: 1; text-decoration: none; }

/* ---------- Card books (maths and science as cards, app.js startCards) ---------- */
.cr { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--panel);
  --idea: #1f6feb; --example: #a86f00; --try: #15874f; --think: #7a4fd8; --practice: #0e7490; --recap: #c7361f; --goal: #4a5566; }
[data-theme="sepia"] .cr { --idea: #2f5fb3; --example: #8a5a00; --try: #2c6e3f; --think: #6a4bb0; --practice: #1b6474; --recap: #a8432a; --goal: #6b5a44; }
[data-theme="dark"] .cr { --idea: #6ea8ff; --example: #f0c23b; --try: #4cc98a; --think: #b196ff; --practice: #4fc3dc; --recap: #ff8a73; --goal: #b8c3d1; }
[data-theme="contrast"] .cr { --idea: #6ea8ff; --example: #ffd400; --try: #5ee08f; --think: #c9b3ff; --practice: #5fd6ee; --recap: #ff9a85; --goal: #ffffff; }
.cr-top { display: flex; align-items: center; gap: 2px; padding: 4px 4px 2px; flex: none; }
.cr-where { flex: 1; min-width: 0; padding: 0 4px; }
.cr-where small { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cr-where b { display: block; font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cr-dots { display: flex; gap: 3px; padding: 2px 16px 8px; flex: none; }
.cr-dots i { flex: 1; height: 3px; border-radius: 2px; background: var(--line); }
.cr-dots i.on { background: var(--fg); }
.cr-strip { flex: 1; min-height: 0; display: flex; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory;
  scrollbar-width: none; overscroll-behavior-x: contain; }
.cr-strip::-webkit-scrollbar { display: none; }
.cr-slot { flex: 0 0 100%; width: 100%; min-width: 0; scroll-snap-align: center; scroll-snap-stop: always; padding: 2px 12px 6px; display: flex; min-height: 0; }
.cr-foot { display: flex; align-items: center; padding: 0 8px 8px; padding-bottom: max(8px, env(safe-area-inset-bottom)); flex: none; }
.cr-n { flex: 1; text-align: center; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cr-next svg { transform: scaleX(-1); }
.cr .card { --c: var(--idea); flex: 1; min-width: 0; max-width: 680px; margin: 0 auto; background: var(--bg); border: 1px solid var(--line);
  border-radius: 18px; display: flex; flex-direction: column; overflow: hidden; }
.cr .card[data-t="example"] { --c: var(--example); } .cr .card[data-t="try"] { --c: var(--try); }
.cr .card[data-t="think"] { --c: var(--think); } .cr .card[data-t="practice"] { --c: var(--practice); }
.cr .card[data-t="recap"] { --c: var(--recap); } .cr .card[data-t="goal"] { --c: var(--goal); } .cr .card[data-t="recall"] { --c: var(--example); }
.card-h { padding: 14px 16px 2px; font-family: Roboto, "Noto Sans", Arial, sans-serif; }
.card-h .kind { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--c); }
.card-h .kind::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--c); flex: none; }
.card-h .kind span { margin-left: auto; color: var(--fg); font-weight: 500; letter-spacing: 0; text-transform: none; background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; padding: 1px 8px; white-space: nowrap; }
.card-h h2 { margin: 6px 0 0; font-size: calc(var(--fs) * 1.2); line-height: 1.2; }
.card[data-t="cover"] .card-h h2 { font-size: calc(var(--fs) * 1.6); }
.card[data-t="cover"] .card-b { display: flex; flex-direction: column; justify-content: center; }
.card-b { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; overflow-wrap: break-word; padding: 4px 16px 18px;
  font-family: var(--font); font-size: calc(var(--fs) * .92); line-height: var(--lh); -webkit-overflow-scrolling: touch; overscroll-behavior-y: contain; }
.card-b p { margin: .45em 0; }
.card-b p.ml { margin: .15em 0; padding-left: .6em; font-variant-numeric: tabular-nums; }
.card-b b.bd { display: inline-block; font: 500 .72em/1.4 Roboto, Arial, sans-serif; padding: 0 .42em; border-radius: 1em; border: 1px solid var(--muted); color: var(--muted); vertical-align: .1em; margin-right: .1em; }
.card-b p:has(b.bd) { font-weight: 500; }
.card-b .it { display: inline-block; max-width: 100%; margin-right: .8em; }
.card-b b.nb { display: inline-block; font: 600 .8em/1.5 Roboto, Arial, sans-serif; min-width: 1.5em; text-align: center; border-radius: 6px; background: var(--c); color: var(--bg); margin-right: .2em; }
.card-b .fr { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; font-size: .82em; line-height: 1.15; margin: 0 .12em; }
.card-b .fr > span:first-child { border-bottom: 1.2px solid currentColor; padding: 0 .15em; }
.card-b .rt { border-top: 1.2px solid currentColor; padding-top: 1px; margin-left: 1px; }
.card-b .kbox { background: var(--panel); border-radius: 12px; padding: .5em .8em; margin: .7em 0; font-family: Roboto, "Noto Sans", Arial, sans-serif; font-size: .92em; }
.card-b .kbox > b { display: block; color: var(--c); margin-bottom: .1em; }
.card-b .kbox p { margin: .25em 0; }
.card-b figure { margin: .8em 0; background: #fff; color: #16202c; border-radius: 12px; padding: 8px; text-align: center; cursor: zoom-in; border: 1px solid var(--line); }
.card-b figure svg { display: block; width: 100%; height: auto; max-height: 46vh; margin: 0 auto; }
[data-theme="dark"] .card-b figure, [data-theme="contrast"] .card-b figure { filter: brightness(.9); }
.card-b :not(figure) > svg { height: 1.3em; width: auto; vertical-align: -.25em; }
.card-b figcaption { font: .78em/1.3 Roboto, Arial, sans-serif; color: #5b6778; padding-top: 4px; }
.card-b .tbl { overflow-x: auto; margin: .7em 0; }
.card-b table { display: block; overflow-x: auto; max-width: 100%; border-collapse: collapse; font: .85em/1.35 Roboto, Arial, sans-serif; }
.card-b th, .card-b td { border: 1px solid var(--line); padding: .35em .5em; text-align: left; vertical-align: top; }
.card-b th { background: var(--panel); font-weight: 600; }
@media (max-width: 480px) {
  .card-b .tbl.cards table, .card-b .tbl.cards tbody, .card-b .tbl.cards tr, .card-b .tbl.cards td { display: block; width: auto; }
  .card-b .tbl.cards tr:first-child:has(th) { display: none; }
  .card-b .tbl.cards tr { border: 1px solid var(--line); border-radius: 10px; margin: 0 0 .5em; padding: .3em .6em; background: var(--panel); }
  .card-b .tbl.cards td { border: 0; padding: .15em 0; }
  .card-b .tbl.cards td[data-l]::before { content: attr(data-l); display: block; font-size: .8em; color: var(--muted); }
}
.cr-step { display: none; }
.cr-step.on { display: block; animation: cr-rise .25s ease-out; }
@keyframes cr-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .cr-step.on { animation: none; } }
.cr-btn { display: block; font: 500 15px Roboto, Arial, sans-serif; border-radius: 12px; padding: 10px 16px; min-height: 44px; border: 1.5px solid var(--c); color: var(--c); margin-top: .6em; }
.cr-btn.solid { background: var(--c); color: var(--bg); }
.cr-ans { display: none; margin-top: .6em; padding: .5em .8em; border-radius: 12px; background: var(--panel); border-left: 4px solid var(--try); }
.cr-ans.on { display: block; }
.q-cards i { background: #8b5cf6; }

/* ---------- Placeholders for books of the Ministry's list not on the site yet (app.js stubRow) ---------- */
.subj.stub-h { margin-top: 26px; }
.bk.stub { border: 1.5px dashed var(--line); border-radius: 12px; padding: 4px 12px 12px; margin: 8px 0; background: transparent; }
.bk.stub:last-child { border-bottom: 1.5px dashed var(--line); }
.bk.stub .bk-t { color: var(--muted); font-weight: 600; }
.bk.stub .bk-h { align-items: center; }
.stub-tag { flex: 0 0 auto; margin-top: 8px; font: 600 11px/1 Roboto, Arial, sans-serif; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted); border: 1px solid var(--line); border-radius: 10px; padding: 4px 8px; }
.stub-st { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--fg); margin: 0 0 8px; }
.stub-st i { flex: 0 0 auto; width: 9px; height: 9px; border-radius: 50%; }
.stub-st.sf-full i { background: #8fb8f2; } .stub-st.sf-rf i { background: #a48fd1; } .stub-st.sf-part i { background: #e8b04a; } .stub-st.sf-none i { background: #d9615a; }
.bk.stub .row .btn { min-height: 36px; padding: 0 12px; font-size: 13px; }
.bk.stub .btn svg { width: 16px; height: 16px; margin-right: 6px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
