/* Netris Trainer — styles */
:root {
  --bg: #0b1120; --bg2: #0f172a; --panel: #131c31; --panel2: #1b2740;
  --line: #263349; --line2: #33425e;
  --text: #e6edf6; --muted: #9fb0c7; --faint: #6b7c95;
  --accent: #6366f1; --accent2: #818cf8;
  --good: #22c55e; --bad: #f43f5e; --warn: #f59e0b;
  --radius: 16px; --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --maxw: 960px;
  --fs: 16px;
}
html[data-theme="light"] {
  --bg: #f5f7fb; --bg2: #eef2f9; --panel: #ffffff; --panel2: #f3f6fc;
  --line: #e2e8f0; --line2: #cbd5e1;
  --text: #0f172a; --muted: #55627a; --faint: #8493a8;
  --shadow: 0 10px 28px rgba(15,23,42,.10);
}
html[data-size="sm"] { --fs: 15px; }
html[data-size="md"] { --fs: 16px; }
html[data-size="lg"] { --fs: 18px; }
html[data-size="xl"] { --fs: 20px; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(1200px 700px at 50% -10%, var(--bg2), var(--bg)) fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, "Inter", sans-serif;
  font-size: var(--fs);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
html.dyslexia body { letter-spacing: .03em; word-spacing: .16em; line-height: 1.85; }
html.reduce-motion * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }

button { font-family: inherit; font-size: inherit; cursor: pointer; }
a { color: var(--accent2); }

.icon { width: 20px; height: 20px; flex: none; }
.icon.flame { color: #fb923c; }
.icon.star { color: #fbbf24; }
.icon.big { width: 56px; height: 56px; }
.muted { color: var(--muted); }
.pad { padding: 24px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 18px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex; align-items: center; gap: 8px;
  background: none; border: 0; color: var(--text); font-weight: 700; font-size: 1.02rem;
}
.brand .icon { color: var(--accent2); }
.topnav { display: flex; gap: 4px; margin-left: 6px; }
.nav-btn {
  display: grid; place-items: center; width: 38px; height: 38px;
  border-radius: 10px; border: 1px solid transparent; background: none; color: var(--muted);
  transition: .15s;
}
.nav-btn:hover { color: var(--text); background: var(--panel); }
.nav-btn.active { color: var(--accent2); background: color-mix(in srgb, var(--accent) 16%, transparent); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.topstats { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.ts { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; font-size: .9rem; color: var(--muted);
  background: var(--panel); border: 1px solid var(--line); padding: 5px 9px; border-radius: 999px; }
.ts .icon { width: 16px; height: 16px; }
.ts.due { color: var(--accent2); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }

/* ---------- layout ---------- */
.main { max-width: var(--maxw); margin: 0 auto; padding: 22px 18px 80px; }
.appfoot { max-width: var(--maxw); margin: 0 auto; padding: 12px 18px 40px; text-align: center; font-size: .82rem; }
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); padding: 80px 0; }
.loading .icon { color: var(--accent2); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .4; } }
.view { animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }

/* ---------- hero ---------- */
.hero { background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 22%, var(--panel)), var(--panel));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.hero-title { margin: 0 0 4px; font-size: 1.6rem; }
.hero-sub { margin: 0 0 16px; color: var(--muted); }
.stat-row { display: flex; gap: 10px; flex-wrap: wrap; }
.stat { display: flex; align-items: center; gap: 10px; background: color-mix(in srgb, var(--bg) 40%, transparent);
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.stat .icon { width: 22px; height: 22px; }
.stat b { font-size: 1.1rem; display: block; line-height: 1.1; }
.stat span { font-size: .78rem; color: var(--muted); }
.xp-bar { margin-top: 14px; height: 10px; background: color-mix(in srgb, var(--bg) 50%, transparent); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.xp-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 999px; transition: width .4s; }

/* ---------- quick actions ---------- */
.quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px,1fr)); gap: 10px; margin: 18px 0; }
.qa-btn { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; color: var(--text); transition: .15s; }
.qa-btn:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--shadow); }
.qa-btn .icon { color: var(--accent2); width: 24px; height: 24px; }
.qa-btn span { font-size: .85rem; font-weight: 600; }

/* ---------- blocks ---------- */
.block { margin: 26px 0; }
.block-title { font-size: 1.05rem; margin: 0 0 12px; color: var(--text); letter-spacing: .01em; }

/* paths */
.path-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(220px,1fr)); gap: 12px; }
.path-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.path-card h3 { margin: 0 0 4px; font-size: 1rem; }
.path-card p { margin: 0 0 10px; font-size: .84rem; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { --c: var(--accent); min-width: 30px; height: 30px; padding: 0 8px; border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--c) 45%, var(--line)); background: color-mix(in srgb, var(--c) 14%, var(--panel));
  color: var(--text); font-weight: 700; font-size: .8rem; }
.chip:hover { background: color-mix(in srgb, var(--c) 26%, var(--panel)); }
.chip.active { background: var(--c); color: #fff; }

/* module grid */
.mod-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(230px,1fr)); gap: 14px; }
.mod-card { --c: var(--accent); text-align: left; background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 16px; color: var(--text); position: relative; overflow: hidden; transition: .18s; }
.mod-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--c); }
.mod-card:hover { transform: translateY(-3px); border-color: var(--c); box-shadow: var(--shadow); }
.mod-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.mod-ico { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px;
  background: color-mix(in srgb, var(--c) 18%, transparent); color: var(--c); }
.mod-ico .icon { width: 22px; height: 22px; }
.mod-num { font-weight: 800; color: var(--faint); font-size: .9rem; }
.mod-title { margin: 0 0 4px; font-size: 1.02rem; }
.mod-sub { margin: 0; font-size: .82rem; color: var(--muted); min-height: 2.4em; }
.mod-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; font-size: .78rem; color: var(--faint); }
.mod-pct { font-weight: 700; color: var(--c); }
.mod-pct.new { color: var(--warn); }

/* ---------- module head ---------- */
.mod-head { --c: var(--accent); display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.icon-btn { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--line); color: var(--text); }
.icon-btn:hover { border-color: var(--accent); color: var(--accent2); }
.mod-head-txt { min-width: 0; }
.mod-head-num { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--c); font-weight: 700; }
.mod-head-title { margin: 0; font-size: 1.35rem; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tab { display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px; border: 0; background: none;
  color: var(--muted); border-bottom: 2px solid transparent; font-weight: 600; }
.tab .icon { width: 17px; height: 17px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent2); border-bottom-color: var(--accent2); }
.tab.quiz-tab { margin-left: auto; color: var(--warn); }
.tab.quiz-tab:hover { color: #fbbf24; }

/* ---------- reader ---------- */
.reader-progress { height: 6px; background: var(--panel); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); margin-bottom: 14px; }
.reader-progress-fill { height: 100%; background: linear-gradient(90deg,var(--accent),var(--accent2)); transition: width .3s; }
.read-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--shadow); min-height: 240px; }
.crumb { font-size: .74rem; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); margin-bottom: 6px; }
.read-title-row { display: flex; align-items: flex-start; gap: 10px; }
.read-title { margin: 0 0 10px; font-size: 1.3rem; flex: 1; }
.reader-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; }
.reader-count { color: var(--muted); font-size: .85rem; font-weight: 600; }
.jump-wrap { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; justify-content: center; }
.jump-select { flex: 1 1 auto; max-width: 280px; min-width: 0; background: var(--panel2); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font: inherit; font-size: .84rem;
  font-weight: 600; cursor: pointer; }
.jump-select:hover { border-color: var(--accent); }
.jump-select:focus { outline: 2px solid color-mix(in srgb,var(--accent) 50%, transparent); outline-offset: 1px; }
@media (max-width: 620px) { .reader-count { display: none; } .jump-select { max-width: none; } }

/* fixed floating prev/next — always in the same spot, never hop */
.reader-nav.center { justify-content: center; }
.reader-fab { position: fixed; top: 50%; transform: translateY(-50%); z-index: 60;
  width: 50px; height: 50px; border-radius: 50%; display: grid; place-items: center;
  background: color-mix(in srgb, var(--panel) 92%, transparent); border: 1px solid var(--line2);
  color: var(--text); box-shadow: var(--shadow); backdrop-filter: blur(8px); transition: transform .15s, border-color .15s, color .15s; }
.reader-fab .icon { width: 24px; height: 24px; }
.reader-fab.prev { left: 20px; }
.reader-fab.next { right: 20px; }
.reader-fab:hover { border-color: var(--accent); color: var(--accent2); transform: translateY(-50%) scale(1.07); }
.reader-fab.next.to-quiz { background: linear-gradient(135deg, var(--warn), #fbbf24); color: #3b2a00; border-color: transparent; }
.reader-fab:disabled { opacity: .3; cursor: default; box-shadow: none; }
.reader-fab:disabled:hover { transform: translateY(-50%); border-color: var(--line2); color: var(--text); }
@media (max-width: 1040px) {
  .reader-fab { top: auto; bottom: 86px; transform: none; width: 46px; height: 46px; }
  .reader-fab:hover { transform: scale(1.07); }
  .reader-fab:disabled:hover { transform: none; }
  .reader-fab.prev { left: 14px; } .reader-fab.next { right: 14px; }
}

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font-weight: 600; transition: .15s; }
.btn .icon { width: 18px; height: 18px; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: linear-gradient(135deg,var(--accent),var(--accent2)); border-color: transparent; color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { background: color-mix(in srgb, var(--bad) 16%, var(--panel)); border-color: color-mix(in srgb,var(--bad) 40%, transparent); color: #fecdd3; }
.btn.again { background: color-mix(in srgb,var(--bad) 16%, var(--panel)); border-color: color-mix(in srgb,var(--bad) 40%, transparent); }
.btn.good { background: color-mix(in srgb,var(--accent) 16%, var(--panel)); border-color: color-mix(in srgb,var(--accent) 40%, transparent); }
.btn.easy { background: color-mix(in srgb,var(--good) 16%, var(--panel)); border-color: color-mix(in srgb,var(--good) 40%, transparent); }

.tts-btn.speaking { color: var(--accent2); border-color: var(--accent); animation: pulse 1s infinite; }

/* ---------- markdown ---------- */
.md { font-size: 1rem; }
.md h2, .md h3, .md h4 { margin: 1.1em 0 .4em; line-height: 1.25; }
.md p { margin: .6em 0; }
.md ul, .md ol { margin: .5em 0; padding-left: 1.3em; }
.md li { margin: .3em 0; }
.md strong { color: var(--text); }
.md a { text-decoration: underline; text-underline-offset: 2px; }
.md code { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; font-size: .88em; }
.md pre { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; overflow: auto; }
.md pre code { border: 0; background: none; padding: 0; }
.md blockquote { margin: .8em 0; padding: 10px 16px; border-left: 3px solid var(--accent); background: color-mix(in srgb,var(--accent) 8%, var(--panel2)); border-radius: 0 10px 10px 0; color: var(--muted); }
.md table { width: 100%; border-collapse: collapse; margin: .8em 0; font-size: .9rem; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.md thead th { background: var(--panel2); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 1.2em 0; }
.md img { max-width: 100%; border-radius: 10px; }

/* ---------- richer reading formatting ---------- */
.read-card { border-left: 3px solid var(--c, var(--accent)); }
.read-card .crumb { color: color-mix(in srgb, var(--c, var(--accent)) 65%, var(--faint)); }
.read-title-row { border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 6px; }

/* accent bullets + breathing room */
.read-body ul { list-style: none; padding-left: 2px; }
.read-body ul > li { position: relative; padding-left: 20px; margin: .6em 0; }
.read-body ul > li::before { content: ""; position: absolute; left: 3px; top: .62em; width: 7px; height: 7px; border-radius: 50%; background: var(--c, var(--accent)); opacity: .9; }
.read-body ul ul { margin: .4em 0; }
.read-body ul ul > li::before { background: var(--faint); width: 6px; height: 6px; }
.read-body ol { padding-left: 1.4em; }
.read-body ol li::marker { color: var(--c, var(--accent)); font-weight: 700; }
.read-body li { margin: .5em 0; }

/* bold lead-in "keys" */
.read-body li.keyed > strong:first-child { color: var(--accent2); }
html[data-theme="light"] .read-body li.keyed > strong:first-child { color: color-mix(in srgb, var(--accent) 82%, #000); }

/* metric / number highlighting */
.read-body .metric { color: var(--accent2); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
html[data-theme="light"] .read-body .metric { color: color-mix(in srgb, var(--accent) 80%, #000); }

/* callouts */
.read-body p.callout { display: flex; gap: 10px; align-items: flex-start; margin: 1em 0; padding: 11px 15px;
  border-radius: 12px; border: 1px solid var(--line); border-left-width: 4px; }
.callout-ico { flex: none; margin-top: 1px; }
.callout-ico .icon { width: 18px; height: 18px; }
.read-body p.callout-warn { background: color-mix(in srgb, var(--warn) 12%, var(--panel2)); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.read-body p.callout-warn .callout-ico { color: var(--warn); }
.read-body p.callout-ok { background: color-mix(in srgb, var(--good) 12%, var(--panel2)); border-color: color-mix(in srgb, var(--good) 45%, transparent); }
.read-body p.callout-ok .callout-ico { color: var(--good); }
.read-body p.callout-note { background: color-mix(in srgb, var(--accent) 10%, var(--panel2)); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.read-body p.callout-note .callout-ico { color: var(--accent2); }

/* list-item warn / ok emphasis */
.read-body li.li-warn, .read-body li.li-ok { border-radius: 8px; padding: 5px 12px 5px 20px; }
.read-body li.li-warn { background: color-mix(in srgb, var(--warn) 9%, transparent); }
.read-body li.li-ok { background: color-mix(in srgb, var(--good) 9%, transparent); }
.read-body li.li-warn::before { background: var(--warn); }
.read-body li.li-ok::before { background: var(--good); }

/* tables */
.read-body table { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.read-body tbody tr:nth-child(even) { background: color-mix(in srgb, var(--panel2) 55%, transparent); }
.read-body thead th { background: color-mix(in srgb, var(--c, var(--accent)) 14%, var(--panel2)); }

/* glossary inline */
.gloss { border-bottom: 1px dotted var(--accent2); cursor: help; position: relative; }
.gloss:hover, .gloss:focus { outline: none; background: color-mix(in srgb,var(--accent) 14%, transparent); border-radius: 3px; }
.gloss::after {
  content: attr(data-def); position: absolute; left: 0; top: calc(100% + 8px); z-index: 60;
  width: max-content; max-width: 300px; padding: 9px 12px; font-size: .82rem; line-height: 1.4;
  background: var(--panel2); color: var(--text); border: 1px solid var(--line2); border-radius: 10px;
  box-shadow: var(--shadow); opacity: 0; visibility: hidden; transform: translateY(-4px); transition: .15s; pointer-events: none;
}
.gloss:hover::after, .gloss:focus::after { opacity: 1; visibility: visible; transform: translateY(0); }

/* ---------- diagrams ---------- */
.diagram-card { margin: 0 0 18px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.diagram-title { font-weight: 700; margin-bottom: 10px; color: var(--accent2); }
.diagram-holder { overflow-x: auto; text-align: center; }
.diagram-holder svg { max-width: 100%; height: auto; }
.diagram-caption { margin: 10px 0 0; font-size: .85rem; color: var(--muted); }
.diagram-error { color: var(--muted); font-style: italic; }
.mermaid { text-align: center; margin: 1em 0; }

/* ---------- deeper / references ---------- */
.deeper-h { margin: 18px 0 8px; font-size: 1rem; }
.ref-link { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; margin-bottom: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; text-decoration: none; color: var(--text); transition: .15s; }
.ref-link:hover { border-color: var(--accent); transform: translateY(-1px); }
.ref-ico { color: var(--accent2); margin-top: 2px; }
.ref-title { font-weight: 700; }
.ref-note { font-size: .82rem; }

/* ---------- quiz ---------- */
.quiz-stage { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.quiz-progress { font-size: .82rem; color: var(--muted); font-weight: 600; margin-bottom: 10px; }
.quiz-q-row { display: flex; gap: 10px; align-items: flex-start; }
.quiz-q { margin: 0 0 16px; font-size: 1.2rem; flex: 1; }
.quiz-opts { display: grid; gap: 10px; }
.quiz-opt { display: flex; align-items: center; gap: 12px; text-align: left; padding: 14px 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--panel2); color: var(--text); transition: .12s; }
.quiz-opt:hover:not(:disabled) { border-color: var(--accent); transform: translateX(2px); }
.opt-key { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 7px; background: var(--panel); border: 1px solid var(--line); font-weight: 700; font-size: .8rem; flex: none; }
.quiz-opt.correct { border-color: var(--good); background: color-mix(in srgb,var(--good) 18%, var(--panel2)); }
.quiz-opt.correct .opt-key { background: var(--good); color: #04240f; border-color: transparent; }
.quiz-opt.wrong { border-color: var(--bad); background: color-mix(in srgb,var(--bad) 16%, var(--panel2)); }
.quiz-opt.wrong .opt-key { background: var(--bad); color: #2a0710; border-color: transparent; }
.quiz-opt:disabled { cursor: default; }
.quiz-feedback { margin-top: 16px; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line); }
.quiz-feedback.ok { background: color-mix(in srgb,var(--good) 12%, var(--panel2)); border-color: color-mix(in srgb,var(--good) 40%, transparent); }
.quiz-feedback.no { background: color-mix(in srgb,var(--bad) 10%, var(--panel2)); border-color: color-mix(in srgb,var(--bad) 40%, transparent); }
.quiz-verdict { display: flex; align-items: center; gap: 6px; font-weight: 800; margin-bottom: 6px; }
.quiz-feedback.ok .quiz-verdict { color: var(--good); }
.quiz-feedback.no .quiz-verdict { color: var(--bad); }
.quiz-explain { margin: 0 0 12px; color: var(--muted); font-size: .9rem; }
.quiz-result { text-align: center; padding: 10px; }
.result-ring { display: flex; justify-content: center; margin-bottom: 8px; }
.result-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }

/* ---------- flashcards / review ---------- */
.flash-filter { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.flash-stage { max-width: 640px; margin: 0 auto; }
.flash-count { text-align: center; color: var(--muted); font-size: .82rem; margin-bottom: 12px; }
.flash-card { --c: var(--accent); perspective: 1400px; height: 300px; cursor: pointer; }
.flash-inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .5s; }
.flash-card.flipped .flash-inner { transform: rotateY(180deg); }
.flash-face { position: absolute; inset: 0; backface-visibility: hidden; display: grid; place-items: center; text-align: center;
  padding: 28px; border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow); }
.flash-face.front { background: linear-gradient(135deg, color-mix(in srgb,var(--c) 20%, var(--panel)), var(--panel)); }
.flash-face.back { background: var(--panel2); transform: rotateY(180deg); }
.flash-face p { margin: 0; font-size: 1.12rem; line-height: 1.5; }
.flash-face.front p { font-weight: 700; }
.flash-hint { position: absolute; bottom: 14px; font-size: .74rem; color: var(--faint); }
.flash-tools { display: flex; justify-content: center; margin: 12px 0; }
.flash-grades { display: none; gap: 10px; justify-content: center; margin-top: 4px; }
.flash-grades.show { display: flex; animation: fade .2s; }
.flash-done { text-align: center; padding: 40px 20px; }
.flash-done .icon.big { color: var(--accent2); }
.flash-done h2 { margin: 10px 0 6px; }

/* ---------- search ---------- */
.search-bar { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 0 14px; margin-bottom: 10px; }
.search-bar .icon { color: var(--muted); }
.search-input { flex: 1; background: none; border: 0; outline: none; color: var(--text); padding: 14px 0; font-size: 1rem; }
.search-status { font-size: .82rem; margin-bottom: 12px; }
.search-results { display: grid; gap: 10px; }
.search-item { --c: var(--accent); text-align: left; background: var(--panel); border: 1px solid var(--line);
  border-left: 3px solid var(--c); border-radius: 12px; padding: 12px 14px; color: var(--text); transition: .12s; }
.search-item:hover { transform: translateX(2px); border-color: var(--c); border-left-color: var(--c); }
.si-top { display: flex; justify-content: space-between; gap: 8px; font-size: .74rem; color: var(--faint); margin-bottom: 3px; }
.si-mod { color: var(--c); font-weight: 700; }
.si-title { font-weight: 700; margin-bottom: 3px; }
.si-snip { font-size: .84rem; }

/* ---------- glossary page ---------- */
.gloss-list { display: grid; gap: 10px; }
.gloss-item { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.gloss-term { font-weight: 800; color: var(--accent2); margin-bottom: 3px; }
.gloss-def { color: var(--muted); font-size: .92rem; }

/* ---------- settings ---------- */
.settings-box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 18px; box-shadow: var(--shadow); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.set-row:last-child { border-bottom: 0; }
.set-row label { font-weight: 600; }
.set-info { padding: 14px 0; font-size: .85rem; }
.switch { width: 48px; height: 28px; border-radius: 999px; border: 1px solid var(--line2); background: var(--panel2); position: relative; transition: .15s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%; background: var(--faint); transition: .18s; }
.switch.on { background: color-mix(in srgb,var(--accent) 40%, var(--panel2)); border-color: var(--accent); }
.switch.on::after { left: 22px; background: var(--accent2); }
.seg { display: inline-flex; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg-btn { padding: 8px 14px; border: 0; background: none; color: var(--muted); text-transform: capitalize; font-weight: 600; }
.seg-btn.active { background: var(--accent); color: #fff; }
.select { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
input[type=range] { accent-color: var(--accent); }

/* ---------- misc ---------- */
.ring { display: block; }
.ring-bg { fill: none; stroke: var(--line); stroke-width: 4; }
.ring-fg { fill: none; stroke-width: 4; stroke-linecap: round; transform: rotate(-90deg); transform-origin: center; transition: stroke-dashoffset .5s; }
.ring-text { fill: var(--text); font-size: 13px; font-weight: 800; text-anchor: middle; dominant-baseline: middle; }
.error-box { background: color-mix(in srgb,var(--bad) 10%, var(--panel)); border: 1px solid color-mix(in srgb,var(--bad) 40%, transparent);
  border-radius: 12px; padding: 18px 20px; color: var(--text); line-height: 1.6; }

@media (max-width: 620px) {
  .brand span { display: none; }
  .mod-head-title { font-size: 1.15rem; }
  .hero-title { font-size: 1.3rem; }
  .flash-card { height: 340px; }
}

/* ---------- read-aloud: listen button, player bar, highlight, focus ---------- */
.listen-btn { --pad: 8px 12px; padding: 8px 12px; }
.listen-btn.active { background: color-mix(in srgb,var(--accent) 22%, var(--panel)); border-color: var(--accent); color: var(--accent2); }
.listen-btn .icon { width: 17px; height: 17px; }
.focus-btn { flex: none; }

/* the block currently being read aloud */
.tts-active {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  box-shadow: -6px 0 0 0 var(--accent);
  border-radius: 4px;
  transition: background .2s;
}
html.reduce-motion .tts-active { transition: none; }

/* floating audio player */
.audiobar {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  z-index: 80; display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 999px;
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  border: 1px solid var(--line2); box-shadow: var(--shadow); backdrop-filter: blur(10px);
  animation: barIn .2s ease;
}
@keyframes barIn { from { opacity: 0; transform: translate(-50%, 8px); } }
.audiobar[hidden] { display: none; }
.ab-btn { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--panel2); color: var(--text); }
.ab-btn:hover { border-color: var(--accent); color: var(--accent2); }
.ab-btn .icon { width: 16px; height: 16px; }
.ab-stop:hover { border-color: var(--bad); color: var(--bad); }
.ab-rate { min-width: 42px; text-align: center; font-weight: 800; font-size: .85rem; color: var(--accent2); }
.ab-div { width: 1px; height: 22px; background: var(--line2); margin: 0 2px; }
.ab-label { font-size: .78rem; color: var(--muted); padding: 0 6px 0 2px; white-space: nowrap; }
@media (max-width: 560px) { .ab-label { display: none; } }

/* focus mode: strip the chrome, centre the card */
.module-view.focus .mod-head,
.module-view.focus .tabs { display: none; }
.module-view.focus .read-card { max-width: 760px; margin: 0 auto; }
.module-view.focus .reader { max-width: 800px; margin: 0 auto; }
.focus-btn:hover { color: var(--accent2); border-color: var(--accent); }

/* settings range readout */
.range-wrap { display: flex; align-items: center; gap: 10px; }
.range-val { font-weight: 800; color: var(--accent2); min-width: 40px; text-align: right; }

/* ---------- inline visuals in the reading ---------- */
.inline-diagram { margin: 18px 0 6px; background: color-mix(in srgb, var(--accent) 6%, var(--panel2));
  border: 1px dashed var(--line2); }
.inline-diagram .diagram-title { font-size: .92rem; display: flex; align-items: center; gap: 6px; }
.inline-diagram .diagram-title::before { content: "◆"; color: var(--accent2); font-size: .7em; }

/* soundbite callout */
.md p.soundbite {
  display: flex; gap: 10px; align-items: flex-start;
  margin: 1em 0; padding: 12px 16px; border-radius: 12px;
  background: linear-gradient(135deg, color-mix(in srgb,var(--accent) 16%, var(--panel2)), var(--panel2));
  border: 1px solid color-mix(in srgb,var(--accent) 34%, transparent);
  border-left: 4px solid var(--accent); font-style: italic; color: var(--text);
}
.soundbite-ico { color: var(--accent2); margin-top: 2px; flex: none; }
.soundbite-ico .icon { width: 18px; height: 18px; }

/* ---------- dig deeper ---------- */
.dig-card-btn { padding: 8px 12px; color: var(--accent2); }
.dig-card-btn .icon { width: 16px; height: 16px; }
.dig-card-btn:hover { color: var(--accent2); border-color: var(--accent); background: color-mix(in srgb,var(--accent) 12%, var(--panel)); }

/* selection toolbar (Speak + Dig deeper) */
.sel-toolbar {
  position: fixed; z-index: 90; display: inline-flex; align-items: center; gap: 4px;
  padding: 4px; border-radius: 999px; border: 1px solid var(--line2);
  background: var(--panel2); box-shadow: var(--shadow); animation: barIn .12s ease;
}
.sel-btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px;
  border: 0; background: transparent; color: var(--text); font-weight: 700; font-size: .82rem; }
.sel-btn .icon { width: 15px; height: 15px; }
.sel-btn:hover { background: color-mix(in srgb,var(--accent) 20%, var(--panel)); }
.sel-btn:first-child { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; }
.sel-btn:first-child:hover { filter: brightness(1.08); }

/* speech highlighting: section tint (under) + current word (over) */
::highlight(tts-sel) { background-color: color-mix(in srgb, var(--accent) 24%, transparent); }
::highlight(tts-word) { background-color: #fde047; color: #0b1120; }

.dig-overlay { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: rgba(2, 6, 18, .55); backdrop-filter: blur(3px); padding: 18px; animation: fade .15s ease; }
.dig-modal { width: min(640px, 100%); max-height: 86vh; overflow: auto; background: var(--panel);
  border: 1px solid var(--line2); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.dig-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.dig-title { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.1rem; }
.dig-title .icon { color: var(--accent2); }
.dig-note { font-size: .86rem; margin: 0 0 12px; }
.dig-textarea { width: 100%; min-height: 240px; resize: vertical; background: var(--panel2);
  color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; line-height: 1.5; }
.dig-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }

/* toast */
.toast { position: fixed; left: 50%; bottom: 84px; transform: translate(-50%, 12px); z-index: 110;
  background: var(--panel2); color: var(--text); border: 1px solid var(--line2); border-radius: 999px;
  padding: 10px 18px; font-size: .86rem; font-weight: 600; box-shadow: var(--shadow); opacity: 0; transition: .25s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
