:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --text: #18181b;
  --muted: #6b6b76;
  --line: #e3e3ea;
  --accent: #6f62c9;
  --on-accent: #ffffff;
  --lav: #a99cf0;
  --lav-soft: #efedfc;
  --lav-rgb: 169,156,240;
  --lav-tint: rgba(var(--lav-rgb),.14);
  --ink: #1c1c22;
  --on-ink: #ffffff;
  --ok: #1f8a4c;
  --ok-bg: #e8f5ed;
  --bad: #c43d3d;
  --bad-bg: #fbeaea;
  --flag: #d9822b;
  --glass: rgba(245,245,247,.78);
  --glass-tile: rgba(255,255,255,.62);
  --glass-edge: rgba(255,255,255,.85);
  --soft: #f0eff5;
  --side: #f3f3f6;
  --grid: #b9b9c2;
  --stripe: #f5f5f8;
  --shadow: 0 1px 2px rgba(24,22,48,.04), 0 6px 20px rgba(60,48,140,.06);
  --shadow-hover: 0 2px 4px rgba(24,22,48,.05), 0 12px 28px rgba(80,64,170,.12);
  --backdrop: radial-gradient(1100px 620px at 8% -8%, rgba(var(--lav-rgb),.20), transparent 62%),
              radial-gradient(900px 560px at 105% 12%, rgba(200,196,230,.24), transparent 60%),
              linear-gradient(180deg, #f7f7f9 0%, #f2f2f5 100%);
  --radius: 12px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0f0f12;
  --surface: #17171c;
  --text: #ececf1;
  --muted: #9a9aa6;
  --line: #2a2a32;
  --accent: #b3a8f6;
  --on-accent: #17142e;
  --lav: #b3a8f6;
  --lav-soft: #24213a;
  --lav-rgb: 179,168,246;
  --lav-tint: rgba(var(--lav-rgb),.10);
  --ink: #ececf1;
  --on-ink: #141418;
  --ok: #4cc283;
  --ok-bg: rgba(76,194,131,.14);
  --bad: #ef7676;
  --bad-bg: rgba(239,118,118,.14);
  --flag: #f0a35e;
  --glass: rgba(15,15,18,.74);
  --glass-tile: rgba(30,30,38,.52);
  --glass-edge: rgba(255,255,255,.06);
  --soft: #24242b;
  --side: #141418;
  --grid: #4a4a54;
  --stripe: #1f1f25;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
  --shadow-hover: 0 2px 4px rgba(0,0,0,.35), 0 14px 32px rgba(0,0,0,.4), 0 0 0 1px rgba(var(--lav-rgb),.18);
  --backdrop: radial-gradient(1000px 600px at 6% -10%, rgba(var(--lav-rgb),.13), transparent 60%),
              radial-gradient(900px 560px at 108% 10%, rgba(120,110,190,.10), transparent 60%),
              linear-gradient(180deg, #111115 0%, #0d0d10 100%);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 16px/1.6 -apple-system, "Segoe UI", system-ui, Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
body.in-quiz { overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.link { background: none; border: 0; padding: 0; color: var(--accent); }
.link:hover { text-decoration: underline; }
.small { font-size: 14px; }
.muted { color: var(--muted); }
.btn { padding: 8px 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.btn.primary:hover { border-color: var(--lav); box-shadow: 0 0 0 3px var(--lav-tint); }
.btn.small { padding: 5px 12px; font-size: 13px; }
.btn.ghost { background: transparent; }
.btn.on { border-color: var(--accent); color: var(--accent); }

/* ================= home ================= */
.bar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px;
  padding: 12px 24px; background: var(--glass); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.title { font-weight: 600; letter-spacing: -.01em; }
.tools { margin-left: auto; display: flex; gap: 6px; }
.wrap { max-width: 780px; margin: 0 auto; padding: 28px 24px 64px; }
.sub { color: var(--muted); margin: 0; }
.section-title, .marked h3 { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 26px 0 10px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 18px; }
.stat { padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.stat .label { display: block; font-size: 13px; color: var(--muted); }
.stat b { display: block; font-size: 26px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin: 2px 0; }
.stat b small { font-size: 15px; font-weight: 500; color: var(--muted); }
.stat .sub { font-size: 12px; }
.bar-in { height: 4px; margin-top: 10px; background: var(--line); border-radius: 2px; overflow: hidden; }
.bar-in i { display: block; height: 100%; background: var(--accent); }
.resume-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.marked-list { display: grid; gap: 8px; }
.marked-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.marked-row .mb { font-weight: 600; font-size: 14px; margin-right: 6px; min-width: 64px; }
.chip { padding: 3px 10px; font-size: 13px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); }
.chip:hover { border-color: var(--accent); color: var(--accent); }


.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(116px, 1fr)); gap: 10px; }
.tile { text-align: left; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); transition: border-color .15s, transform .15s; }
.tile:hover { border-color: var(--accent); transform: translateY(-1px); }
.tile b { display: block; font-size: 15px; }
.tile span { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tile .bar-in { height: 3px; margin-top: 8px; }
.tile.done .bar-in i { background: var(--ok); }
.tile.missing { opacity: .4; pointer-events: none; }

/* ================= question screen ================= */
.quiz {
  position: fixed; inset: 0; display: grid;
  grid-template-columns: 88px 1fr; grid-template-rows: 64px 1fr 52px;
  grid-template-areas: "list top" "list main" "list bottom";
  background: var(--bg);
}
.qlist { grid-area: list; overflow-y: auto; background: var(--side); border-right: 1px solid var(--line); padding: 6px 0; }
.qn {
  position: relative; display: flex; align-items: center; gap: 8px; width: 100%; height: 30px;
  padding: 0 10px 0 12px; border: 0; background: transparent; font-size: 14px; font-variant-numeric: tabular-nums;
}
.qn:hover { background: var(--soft); }
.qn.cur { background: var(--accent); color: var(--on-accent); }
.qn .st { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); opacity: .35; flex: none; }
.qn.ok .st { background: var(--ok); opacity: 1; }
.qn.bad .st { background: var(--bad); opacity: 1; }
.qn.seen .st { background: var(--muted); opacity: .9; }
.qn.cur .st { box-shadow: 0 0 0 2px var(--on-accent); }
.qn .flag { width: 14px; height: 14px; margin-left: auto; fill: var(--flag); stroke: var(--flag); }
.qn.cur .flag { fill: var(--on-accent); stroke: var(--on-accent); }

.qtop {
  grid-area: top; display: flex; align-items: center; gap: 14px; padding: 0 16px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.item-box { padding: 4px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; line-height: 1.45; white-space: nowrap; }
.tool {
  display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 4px 8px;
  border: 0; border-radius: 8px; background: transparent; color: var(--text); font-size: 12px; white-space: nowrap;
}
.tool:hover:not(:disabled) { background: var(--soft); }
.tool:disabled { opacity: .35; cursor: default; }
.tool.on { color: var(--accent); }
.mark-btn {
  display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 8px;
  border: 1px solid var(--line); background: transparent; font-size: 13px; white-space: nowrap;
}
.mark-btn svg { width: 16px; height: 16px; }
.mark-btn:hover { border-color: var(--flag); color: var(--flag); }
.mark-btn.on { border-color: var(--flag); background: var(--flag); color: #fff; }
.mark-btn.on svg { fill: #fff; }
.nav { display: flex; align-items: center; gap: 6px; margin: 0 auto; }
.counter { min-width: 64px; text-align: center; font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tools-right { display: flex; gap: 2px; }

.panes { grid-area: main; display: grid; grid-template-columns: 1fr; min-height: 0; }
.quiz.answered .panes { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.qpane, .epane { overflow-y: auto; min-height: 0; }
.qinner { max-width: 820px; margin: 0 auto; padding: 26px 32px 40px; }
.quiz.answered .qinner { max-width: none; }
.epane { border-left: 1px solid var(--line); padding: 18px 28px 40px; background: var(--surface); }
.etab { display: inline-block; padding: 6px 16px; margin-bottom: 16px; border: 1px solid var(--line); border-bottom-color: transparent; border-radius: 8px 8px 0 0; font-weight: 500; }

.stem p { margin: 0 0 14px; font-size: 16.5px; line-height: 1.7; }
.imgs img { display: block; width: 100%; height: auto; margin: 0 0 12px; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
:root[data-theme="dark"] .imgs img { filter: brightness(.88); }

.choices { list-style: none; margin: 22px 0 0; padding: 6px 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.choice {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: left;
  padding: 9px 16px; border: 0; background: transparent; font-size: 16px;
}
.choice:hover:not(:disabled) { background: var(--soft); }
.choice:disabled { cursor: default; }
.choice .mk { width: 16px; flex: none; font-weight: 700; text-align: center; }
.choice .radio { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--muted); flex: none; }
.choice .k { font-weight: 500; color: var(--muted); }
.choice.picked .radio { border-color: var(--accent); background: radial-gradient(var(--accent) 45%, transparent 50%); }
.choice.ok .mk::before { content: "✓"; color: var(--ok); }
.choice.bad .mk::before { content: "✕"; color: var(--bad); }
.choice.ok .t { color: var(--ok); font-weight: 500; }
.choice.bad .t { color: var(--bad); }

.result { display: flex; align-items: center; gap: 28px; margin-top: 20px; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.verdict { display: grid; grid-template-columns: auto auto; column-gap: 8px; padding-left: 12px; border-left: 4px solid var(--muted); line-height: 1.35; }
.verdict b { grid-column: 1 / -1; font-size: 17px; }
.verdict span { font-size: 13px; color: var(--muted); }
.verdict em { font-style: normal; font-weight: 600; font-size: 13px; }
.verdict small { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }
.verdict.ok { border-color: var(--ok); } .verdict.ok b { color: var(--ok); }
.verdict.bad { border-color: var(--bad); } .verdict.bad b { color: var(--bad); }
.spent { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.spent div { display: flex; flex-direction: column; line-height: 1.3; }
.spent b { color: var(--text); font-weight: 500; font-size: 15px; }
.spent span { font-size: 12px; }

.qbottom {
  grid-area: bottom; display: flex; align-items: center; justify-content: space-between; padding: 0 16px;
  background: var(--surface); border-top: 1px solid var(--line);
}
.elapsed { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.elapsed b { color: var(--text); font-weight: 600; }
.elapsed b.stopped { color: var(--muted); }
.elapsed .sep { display: inline-block; width: 1px; height: 14px; margin: 0 14px; vertical-align: middle; background: var(--line); }
.tool.end { flex-direction: row; gap: 6px; font-size: 13px; color: var(--bad); }

/* ================= lab values drawer ================= */
.drawer {
  position: fixed; top: 64px; right: 0; bottom: 52px; z-index: 20; width: min(520px, 100vw);
  display: flex; flex-direction: column; background: var(--surface);
  border-left: 1px solid var(--line); box-shadow: -12px 0 32px rgba(0,0,0,.12);
}
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.drawer-head input {
  flex: 1; min-width: 0; padding: 7px 10px; font: inherit; font-size: 14px; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; outline: none;
}
.drawer-head input:focus { border-color: var(--accent); }
.lab-tabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 18px 0; }
.lab-tabs button { padding: 5px 11px; font-size: 13px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--muted); }
.lab-tabs button.cur { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.si { display: flex; align-items: center; gap: 6px; padding: 10px 18px 4px; font-size: 13px; color: var(--muted); }
.lab-body { flex: 1; overflow: auto; padding: 4px 18px 24px; }
.lab-body h4 { margin: 18px 0 6px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.lab-body table { width: 100%; border-collapse: collapse; font-size: 13.5px; border: 1px solid var(--grid); }
.lab-body th { text-align: left; font-weight: 600; color: var(--text); font-size: 12px; padding: 8px; border: 1px solid var(--grid); border-bottom-width: 2px; position: sticky; top: 0; background: var(--soft); }
.lab-body td { padding: 7px 8px; border: 1px solid var(--grid); vertical-align: top; }
.lab-body tbody tr:nth-child(even) td { background: var(--stripe); }
.lab-body td:not(:first-child) { white-space: nowrap; font-variant-numeric: tabular-nums; }
.lab-body .empty { color: var(--muted); }

/* ================= calculator ================= */
.drawer-head .grow { flex: 1; }
.calc-main { padding: 16px 18px 14px; }
.calc-screen { padding: 10px 12px; margin-bottom: 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; text-align: right; }
.calc-expr { min-height: 18px; font-size: 13px; color: var(--muted); word-break: break-all; }
.calc-out { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; }
.calc-keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.calc-keys button { padding: 12px 0; font-size: 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); }
.calc-keys button:hover { border-color: var(--accent); }
.calc-keys button.op { color: var(--accent); }
.calc-keys button.eq { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.calc-hist { flex: 1; min-height: 0; display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.calc-hist-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 18px 4px; font-size: 12px; font-weight: 600;
  color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.calc-hist ol { flex: 1; overflow: auto; margin: 0; padding: 0 10px 16px; list-style: none; }
.calc-hist ol:empty::before { content: "Your calculations appear here."; display: block; padding: 6px 8px; font-size: 13px; color: var(--muted); }
.calc-hist li button { display: flex; flex-direction: column; align-items: flex-end; width: 100%; padding: 6px 8px; border: 0; border-radius: 8px;
  background: transparent; color: var(--text); text-align: right; font-family: var(--font-read); }
.calc-hist li button:hover { background: var(--soft); }
.calc-hist .he { font-size: 12.5px; color: var(--muted); word-break: break-all; }
.calc-hist .hr { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ================= small screens ================= */
@media (max-width: 1000px) {
  .quiz.answered .panes { grid-template-columns: 1fr; grid-template-rows: auto auto; overflow-y: auto; }
  .quiz.answered .qpane, .quiz.answered .epane { overflow: visible; }
  .epane { border-left: 0; border-top: 1px solid var(--line); }
  .tool span { display: none; }
  .mark-btn span { display: none; }
  .item-box .muted { display: none; }
}
@media (max-width: 560px) {
  .wrap { padding: 20px 16px 64px; }
  .bar { padding: 10px 16px; }
  .quiz { grid-template-columns: 52px 1fr; }
  .qinner { padding: 18px 16px 32px; }
}

/* First Aid location */
.book {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; margin: -4px 0 16px;
  padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); font-size: 14px;
}
.book .src { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.book .path { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; }
.book .path b { font-weight: 600; }
.book .path i { font-style: normal; color: var(--muted); }
.book .pg { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* blockwise / chapterwise */
.view-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 26px 0 10px; }
.view-row .section-title { margin: 0; }
.seg { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.seg button { padding: 5px 12px; font-size: 13px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); }
.seg button.cur { background: var(--accent); color: var(--on-accent); }
.chapters { display: grid; gap: 8px; }
.chapter { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.ch-head { width: 100%; display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 0; background: transparent; text-align: left; }
.ch-head:hover { background: var(--soft); }
.ch-head b { flex: 1; font-size: 15px; font-weight: 600; }
.chev { display: inline-block; width: 12px; color: var(--muted); transition: transform .15s; }
.chapter.open .chev { transform: rotate(90deg); }
.cnt { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 64px; text-align: right; }
.mini { width: 80px; height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; flex: none; }
.mini i { display: block; height: 100%; background: var(--accent); }
.ch-body { border-top: 1px solid var(--line); }
.chapter:not(.open) .ch-body { display: none; }
.sec { display: flex; align-items: center; gap: 10px; padding: 8px 14px 8px 36px; border-bottom: 1px solid var(--line); font-size: 14px; }
.sec:last-child { border-bottom: 0; }
.sec .nm { flex: 1; }
.sec.all .nm { font-weight: 600; }
.sec .btn { min-width: 84px; }
.set-title { max-width: 32vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--muted); }
@media (max-width: 560px) { .mini { display: none; } .sec { padding-left: 16px; } .view-row { flex-wrap: wrap; } }


/* ================= theme: home (monochrome + lavender, frosted glass) ================= */
#home { min-height: 100vh; background: var(--backdrop); background-attachment: fixed; }
.bar { background: var(--glass); backdrop-filter: blur(14px) saturate(140%); -webkit-backdrop-filter: blur(14px) saturate(140%); }
.title { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: -.015em; }
.title { font-size: 24px; gap: 12px; letter-spacing: -.02em; }
.title b { font-weight: 700; color: var(--accent); }
.logo { width: 36px; height: 36px; stroke: none; filter: drop-shadow(0 2px 4px rgba(var(--lav-rgb),.35)); }
.logo .cover { fill: var(--accent); }
.logo .pages { fill: var(--surface); stroke: var(--accent); stroke-width: 1.5; }
.logo .rod, .logo .snake, .logo .halo { fill: none; stroke: var(--surface); stroke-linecap: round; }
.logo .halo { stroke: var(--accent); stroke-width: 3.6; }
.logo .rod { stroke-width: 1.7; }
.logo .snake { stroke-width: 1.5; }
.logo .head { fill: var(--surface); }
.bar { padding: 16px 32px; }
.bar .tools { gap: 8px; }
.bar .btn.small { padding: 6px 14px; font-size: 18px; font-weight: 600; letter-spacing: -.015em; }
@media (max-width: 560px) { .bar .btn.small { font-size: 15px; padding: 5px 9px; } .bar { padding: 12px 16px; } .title { font-size: 19px; } .logo { width: 30px; height: 30px; } }
.bar .btn.ghost { border-color: transparent; color: var(--text); opacity: .78; }
.bar .btn.ghost:hover { opacity: 1; }
.bar .btn.ghost:hover { border-color: var(--line); color: var(--text); background: var(--glass-tile); }

.stat, .tile, .marked-row, .chapter, .seg {
  background: var(--glass-tile); border: 1px solid var(--line); border-top-color: var(--glass-edge);
  backdrop-filter: blur(12px) saturate(130%); -webkit-backdrop-filter: blur(12px) saturate(130%);
  box-shadow: var(--shadow);
}
.stat { position: relative; overflow: hidden; padding: 16px 18px; border-radius: 14px; }
.stat::before { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .9; }
.stat:nth-child(1)::before { background: linear-gradient(135deg, rgba(var(--lav-rgb),.22), transparent 65%); }
.stat:nth-child(2)::before { background: linear-gradient(135deg, rgba(150,150,170,.16), transparent 65%); }
.stat:nth-child(3)::before { background: linear-gradient(135deg, rgba(var(--lav-rgb),.30), rgba(var(--lav-rgb),.06) 70%); }
.stat > * { position: relative; }
.stat .label { font-weight: 500; letter-spacing: .01em; }
.bar-in { background: var(--lav-tint); }
.bar-in i, .mini i { background: linear-gradient(90deg, var(--lav), var(--accent)); border-radius: inherit; }
.mini { background: var(--lav-tint); }
.tile.done .bar-in i { background: var(--ink); }
.section-title, .marked h3 { letter-spacing: .08em; }

.tile { position: relative; cursor: pointer; padding: 13px 14px 12px; transition: border-color .18s, transform .18s, box-shadow .18s; }
.tile:hover { border-color: var(--lav); transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.tile:focus-visible { outline: 2px solid var(--lav); outline-offset: 2px; }
.tile.done b::after { content: " ✓"; font-size: 12px; color: var(--accent); }
.tile-reset {
  position: absolute; top: 7px; right: 7px; display: grid; place-items: center; width: 24px; height: 24px; padding: 0;
  border: 1px solid transparent; border-radius: 7px; background: transparent; color: var(--muted); opacity: 0; transition: opacity .15s, background .15s, color .15s;
}
.tile-reset svg { width: 14px; height: 14px; }
.tile:hover .tile-reset, .tile:focus-within .tile-reset { opacity: .8; }
.tile-reset:hover { opacity: 1; color: var(--bad); background: var(--bad-bg); border-color: transparent; }

.chip { background: var(--surface); }
.chip:hover { border-color: var(--lav); color: var(--accent); }
.seg button.cur { background: var(--ink); color: var(--on-ink); }
.ch-head:hover { background: var(--lav-tint); }
.sec .btn { background: var(--surface); }
.sec .btn:hover { border-color: var(--lav); }

/* confirmation dialog */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(16,14,30,.32); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.modal-card {
  width: min(400px, 100%); padding: 22px 22px 18px; border-radius: 16px; background: var(--surface);
  border: 1px solid var(--line); box-shadow: 0 24px 60px rgba(20,16,50,.25);
}
.modal-card h4 { margin: 0 0 6px; font-size: 17px; letter-spacing: -.01em; }
.modal-card p { margin: 0 0 18px; color: var(--muted); font-size: 14.5px; line-height: 1.55; }
.modal-card p b { color: var(--text); font-weight: 600; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger:hover { filter: brightness(1.06); }

/* ================= theme: question screen (texture only, layout unchanged) ================= */
.qtop, .qbottom { box-shadow: 0 1px 0 rgba(0,0,0,.02); }
.qtop { box-shadow: 0 1px 8px rgba(40,32,100,.04); }
.choices, .result, .book { box-shadow: var(--shadow); }
.choice:hover:not(:disabled) { background: var(--lav-tint); }
.qn:hover { background: var(--lav-tint); }
.item-box { background: var(--bg); }


/* ================= accent palettes (lavender is the default in :root) ================= */
:root[data-accent="sky"] { --accent: #2f6fb8; --on-accent: #ffffff; --lav: #8ec3f0; --lav-rgb: 142,195,240; --lav-soft: #e8f2fc; }
:root[data-theme="dark"][data-accent="sky"] { --accent: #8cc4f5; --on-accent: #141418; --lav: #8cc4f5; --lav-rgb: 140,196,245; --lav-soft: #182636; }
:root[data-accent="sage"] { --accent: #2f7d6b; --on-accent: #ffffff; --lav: #8fcfbd; --lav-rgb: 143,207,189; --lav-soft: #e6f5f0; }
:root[data-theme="dark"][data-accent="sage"] { --accent: #8fd6c2; --on-accent: #141418; --lav: #8fd6c2; --lav-rgb: 143,214,194; --lav-soft: #16302a; }
:root[data-accent="rose"] { --accent: #b4466e; --on-accent: #ffffff; --lav: #f0a3bf; --lav-rgb: 240,163,191; --lav-soft: #fcebf1; }
:root[data-theme="dark"][data-accent="rose"] { --accent: #f2a7c3; --on-accent: #141418; --lav: #f2a7c3; --lav-rgb: 242,167,195; --lav-soft: #36202a; }
:root[data-accent="amber"] { --accent: #a0601a; --on-accent: #ffffff; --lav: #f0c27d; --lav-rgb: 240,194,125; --lav-soft: #fcf2e3; }
:root[data-theme="dark"][data-accent="amber"] { --accent: #f3c886; --on-accent: #141418; --lav: #f3c886; --lav-rgb: 243,200,134; --lav-soft: #352a18; }
:root[data-accent="graphite"] { --accent: #3f3f46; --on-accent: #ffffff; --lav: #a1a1aa; --lav-rgb: 161,161,170; --lav-soft: #f0f0f2; }
:root[data-theme="dark"][data-accent="graphite"] { --accent: #d4d4d8; --on-accent: #141418; --lav: #d4d4d8; --lav-rgb: 212,212,216; --lav-soft: #26262b; }

/* accent picker */
.accent-pick { position: relative; }
.accent-pick > .btn { display: inline-flex; align-items: center; gap: 7px; }
.accent-pick .dot { width: 13px; height: 13px; border-radius: 50%; background: linear-gradient(135deg, var(--lav), var(--accent)); box-shadow: 0 0 0 2px var(--lav-tint); }
.accent-pop {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; width: 216px; padding: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 18px 44px rgba(20,16,50,.18);
}
.accent-pop .lbl { display: block; margin: 0 2px 8px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.swatches { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.swatch { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 7px 2px 6px; border: 1px solid transparent; border-radius: 10px; background: transparent; font-size: 11.5px; color: var(--muted); }
.swatch i { width: 26px; height: 26px; border-radius: 50%; background: linear-gradient(135deg, var(--sw-l), var(--sw-a)); box-shadow: inset 0 0 0 1px rgba(0,0,0,.06); }
.swatch:hover { background: var(--soft); color: var(--text); }
.swatch.cur { border-color: var(--line); background: var(--soft); color: var(--text); }
.swatch.cur i { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--sw-a); }

/* greeting headline */
.hello { margin: 6px 0 20px; }
.hello h1 { margin: 0; font-size: 30px; font-weight: 650; letter-spacing: -.025em; line-height: 1.2; }
.hello .sub { margin-top: 4px; font-size: 14.5px; }
@media (max-width: 560px) { .hello h1 { font-size: 25px; } }

/* ================= stats page ================= */
.title { cursor: pointer; }
.bar .btn.ghost.on { opacity: 1; color: var(--accent); }
.back { display: inline-block; margin: 0 0 14px; }
.stats-4 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.stat:nth-child(4)::before { background: linear-gradient(135deg, rgba(var(--lav-rgb),.16), transparent 70%); }
.chart {
  display: grid; grid-template-columns: repeat(14, 1fr); gap: 6px; align-items: end; padding: 18px 16px 12px;
  background: var(--glass-tile); border: 1px solid var(--line); border-top-color: var(--glass-edge); border-radius: 14px;
  box-shadow: var(--shadow); backdrop-filter: blur(12px) saturate(130%); -webkit-backdrop-filter: blur(12px) saturate(130%);
}
.chart.weeks { grid-template-columns: repeat(8, 1fr); gap: 12px; }
.col { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.col .val { min-height: 16px; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.col .track { position: relative; width: 100%; max-width: 34px; height: 150px; border-radius: 8px; background: var(--lav-tint); overflow: hidden; }
.col .track i { position: absolute; left: 0; right: 0; bottom: 0; border-radius: 8px; background: linear-gradient(180deg, var(--lav), rgba(var(--lav-rgb),.55)); transition: height .3s; }
.col.cur .track i { background: linear-gradient(180deg, var(--accent), var(--lav)); }
.col.cur .val { color: var(--text); font-weight: 600; }
.col .lab { display: flex; flex-direction: column; align-items: center; font-size: 12px; color: var(--muted); line-height: 1.25; font-variant-numeric: tabular-nums; white-space: nowrap; }
.col .lab em { font-style: normal; font-size: 11px; min-height: 14px; }
.col.cur .lab { color: var(--text); font-weight: 600; }
.note { margin-top: 18px; font-size: 13px; }
@media (max-width: 560px) { .chart { gap: 3px; padding: 14px 8px 10px; } .col .val { font-size: 9.5px; } .col .lab { font-size: 10.5px; } }

/* explanation-only questions */
.stem .noq { padding: 12px 16px; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); font-size: 15px; }
.choice.reveal .t { color: var(--accent); font-weight: 500; }

/* ================= sign in ================= */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--backdrop); background-attachment: fixed; }
.login-card {
  width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px; padding: 30px 28px 24px; border-radius: 20px;
  background: var(--glass-tile); border: 1px solid var(--line); border-top-color: var(--glass-edge); box-shadow: var(--shadow-hover);
  backdrop-filter: blur(16px) saturate(140%); -webkit-backdrop-filter: blur(16px) saturate(140%);
}
.login-brand { display: flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 600; letter-spacing: -.02em; margin-bottom: 6px; }
.login-brand b { font-weight: 700; color: var(--accent); }
.login-brand .logo { width: 32px; height: 32px; }
.login h1 { margin: 0; font-size: 26px; font-weight: 650; letter-spacing: -.025em; line-height: 1.2; }
.login .sub { margin: -8px 0 4px; font-size: 14.5px; }
.login label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.login input {
  font: inherit; font-size: 16px; color: var(--text); padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); outline: none;
}
.login input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--lav-tint); }
.login .btn.primary { padding: 11px 16px; font-weight: 600; margin-top: 2px; }
.login .btn.primary:disabled { opacity: .6; cursor: default; }
.login-err { margin: -4px 0 0; min-height: 0; font-size: 14px; color: var(--bad); }
.login-err:empty { display: none; }
.login-switch { margin: 0; text-align: center; font-size: 14px; color: var(--muted); }
.login-switch:empty { display: none; }
.login-switch .link { font-weight: 600; }

/* navbar: signed-in user (click to sign out) */
.bar .btn.account { display: inline-flex; align-items: center; gap: 8px; }
.bar .btn.account::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.bar .btn.account.offline::before { background: #d99a2b; }
.bar .btn.account em { font-style: normal; font-weight: 500; font-size: .8em; color: var(--muted); }
@media (max-width: 560px) {
  .bar { flex-wrap: wrap; row-gap: 8px; }
  .bar .tools { margin-left: 0; width: 100%; flex-wrap: wrap; gap: 4px; }
  .bar .btn.small { white-space: nowrap; }
}
.login label.remember { flex-direction: row; align-items: center; gap: 9px; font-size: 14px; font-weight: 500; color: var(--text); cursor: pointer; user-select: none; margin-top: -2px; }
.login label.remember input { width: 17px; height: 17px; margin: 0; padding: 0; accent-color: var(--accent); cursor: pointer; box-shadow: none; }

/* ---- question bank picker (UWorld Step 1 / AMBOSS Step 2 CK) ---- */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.bank-pick { position: relative; display: inline-flex; align-items: center; margin-left: 18px; }
.bank-pick select {
  appearance: none; -webkit-appearance: none; font: inherit; font-size: 15px; font-weight: 600; letter-spacing: -.01em;
  color: var(--text); background: var(--glass-tile, var(--surface)); border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 34px 7px 14px; cursor: pointer; line-height: 1.2;
}
.bank-pick::after {
  content: ""; position: absolute; right: 14px; top: 50%; width: 7px; height: 7px; margin-top: -5px; pointer-events: none;
  border-right: 2px solid var(--accent); border-bottom: 2px solid var(--accent); transform: rotate(45deg);
}
.bank-pick select:hover { border-color: var(--accent); }
.bank-pick select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.bank-pick option { color: #111; background: #fff; }
@media (max-width: 560px) { .bank-pick { margin-left: 8px; } .bank-pick select { font-size: 13px; padding: 5px 28px 5px 10px; } .bank-pick::after { right: 11px; } }
.reset-row { justify-content: flex-end; }
.reset-row .link { color: var(--muted); }
.reset-row .link:hover { color: var(--bad, #c0392b); }

/* AMBOSS stems: lab tables / pictures kept as exact crops of the original screen, at their natural size */
.stem .stem-img { display: block; max-width: 100%; height: auto; margin: 4px 0 16px; border-radius: 6px; border: 1px solid var(--line); background: #fff; }
:root[data-theme="dark"] .stem .stem-img.ink { filter: invert(.9) hue-rotate(180deg); background: #000; border-color: var(--line); }
:root[data-theme="dark"] .stem .stem-img:not(.ink) { filter: brightness(.9); }

/* ---- tablets / iPads ---- */
/* never let the toolbar push the question grid wider than the screen */
.quiz { grid-template-columns: 88px minmax(0, 1fr); }
.qtop { min-width: 0; }
.qtop > * { flex-shrink: 0; }
.qtop .set-title { flex-shrink: 1; min-width: 0; }
.qtop .nav { margin: 0 auto; }
/* tablet landscape (iPad 1024-1366 wide): compact toolbar, icons only */
@media (max-width: 1400px) {
  .qtop { gap: 10px; padding: 0 12px; }
  .tool span, .mark-btn span { display: none; }
  .tool { padding: 6px 9px; }
  .tool svg { width: 22px; height: 22px; }
  .item-box .muted { display: none; }
  .set-title { max-width: 22vw; }
  .quiz.answered .panes { grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); }
  .quiz.answered .qinner { padding: 22px 24px 36px; }
  .epane { padding: 16px 20px 36px; }
}
/* portrait tablets and anything narrower: question and explanation stacked in one scroll */
@media (max-width: 1000px), (orientation: portrait) and (max-width: 1400px) {
  .quiz.answered .panes { display: block; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .quiz.answered .qpane, .quiz.answered .epane { overflow: visible; min-height: auto; }
  .epane { border-left: 0; border-top: 1px solid var(--line); }
  .quiz { grid-template-columns: 64px minmax(0, 1fr); }
  .qn { padding: 0 6px 0 10px; height: 34px; }
  .qinner { max-width: 860px; }
  .quiz.answered .qinner { max-width: 860px; }
  .epane .imgs, .epane .etab { max-width: 980px; margin-left: auto; margin-right: auto; }
}
/* touch screens: bigger targets, no sticky hover tint */
@media (hover: none) and (pointer: coarse) {
  .choice { padding: 12px 16px; }
  .qn { height: 38px; }
  .choice:hover:not(:disabled), .qn:hover, .tool:hover:not(:disabled) { background: transparent; }
  .qn.cur:hover { background: var(--accent); }
}
@media (max-width: 560px) { .quiz { grid-template-columns: 52px minmax(0, 1fr); } }
@media (max-width: 1400px) { .tool.end span { display: inline; } }

/* ================= random block ================= */
.rb-card {
  display: flex; align-items: center; gap: 16px; margin: 18px 0 4px; padding: 16px 18px;
  background: var(--glass-tile); border: 1px solid var(--line); border-top-color: var(--glass-edge);
  border-radius: 14px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.rb-card::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(120deg, rgba(var(--lav-rgb),.16), transparent 55%); }
.rb-card > * { position: relative; }
.rb-ico { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--lav-tint); color: var(--accent); }
.rb-ico svg { width: 24px; height: 24px; }
.rb-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.rb-txt > b { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
.rb-txt > span { font-size: 13.5px; color: var(--muted); }
.rb-tag { padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; letter-spacing: .01em; background: var(--soft); color: var(--muted); }
.rb-tag.test { background: var(--lav-tint); color: var(--accent); }
.rb-prog { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.rb-prog .bar-in { flex: 1; max-width: 240px; margin: 0; height: 5px; }
.rb-prog em { font-style: normal; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.rb-card.done .rb-prog .bar-in i { background: var(--ok); }
.rb-acts { flex: none; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.rb-acts .btn.small { padding: 6px 13px; }
.rb-del { display: inline-grid; place-items: center; padding: 5px 8px !important; color: var(--muted); }
.rb-del svg { width: 17px; height: 17px; }
.rb-del:hover { border-color: var(--bad); color: var(--bad); }
@media (max-width: 640px) {
  .rb-card { flex-wrap: wrap; }
  .rb-acts { width: 100%; justify-content: flex-start; }
  .rb-ico { width: 38px; height: 38px; }
}

/* create dialog */
.modal-card.wide { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 24px 24px 20px; }
.modal-card.wide-sm { width: min(460px, 100%); }
.rb-dlg h4 { margin: 0 0 2px; font-size: 19px; }
.modal-card p.rb-lead { margin: 0 0 18px; font-size: 14px; }
.rb-field { margin: 0 0 18px; }
.rb-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.rb-row label, .rb-lbl { font-size: 14px; font-weight: 600; }
.rb-lbl em { font-style: normal; font-weight: 500; color: var(--muted); margin-left: 6px; }
.rb-num {
  width: 84px; padding: 6px 10px; font: inherit; font-size: 15px; font-weight: 600; text-align: center; font-variant-numeric: tabular-nums;
  color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; outline: none;
}
.rb-num:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--lav-tint); }
.rb-range { width: 100%; height: 22px; margin: 0; background: transparent; -webkit-appearance: none; appearance: none; --fill: 0%; }
.rb-range::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--accent) var(--fill), var(--soft) var(--fill)); }
.rb-range::-moz-range-track { height: 6px; border-radius: 3px; background: var(--soft); }
.rb-range::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--accent); }
.rb-range::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -6px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); box-shadow: 0 1px 4px rgba(0,0,0,.18); }
.rb-range::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
.rb-hint { margin-top: 4px; font-size: 12.5px; color: var(--muted); }
.rb-subs { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px; max-height: 280px; overflow: auto; padding: 2px; }
.rb-sub {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--bg); font-size: 13.5px; cursor: pointer; user-select: none; transition: border-color .12s, background .12s;
}
.rb-sub:hover { border-color: var(--lav); }
.rb-sub input { width: 16px; height: 16px; margin: 0; flex: none; accent-color: var(--accent); cursor: pointer; }
.rb-sub .nm { flex: 1; min-width: 0; line-height: 1.3; }
.rb-sub .ct { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.rb-sub:has(input:checked) { border-color: rgba(var(--lav-rgb),.7); background: var(--lav-tint); }
.rb-switch { display: flex; align-items: flex-start; gap: 12px; margin: 0 0 12px; cursor: pointer; user-select: none; position: relative; }
.rb-switch input { position: absolute; opacity: 0; pointer-events: none; }
.rb-switch .sw { flex: none; position: relative; width: 38px; height: 22px; margin-top: 1px; border-radius: 999px; background: var(--line); transition: background .15s; }
.rb-switch .sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.rb-switch input:checked + .sw { background: var(--accent); }
.rb-switch input:checked + .sw::after { transform: translateX(16px); }
.rb-switch input:focus-visible + .sw { outline: 2px solid var(--accent); outline-offset: 2px; }
.rb-switch .tx { display: flex; flex-direction: column; line-height: 1.35; }
.rb-switch .tx b { font-size: 14px; font-weight: 600; }
.rb-switch .tx small { font-size: 12.5px; color: var(--muted); }
.modal-card p.rb-warn { margin: 4px 0 16px; padding: 10px 12px; border-radius: 9px; background: rgba(217,130,43,.10); color: var(--text); font-size: 13px; border: 1px solid rgba(217,130,43,.28); }
.modal-card .btn.primary:disabled { opacity: .5; cursor: default; box-shadow: none; }

/* summary page */
#rbSumMain .back { margin-bottom: 14px; }
.stat.score b { color: var(--accent); }
.rb-sum-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 6px; }
.rb-del-text { color: var(--bad); }
.rb-del-text:hover { border-color: var(--bad); }
.rb-subj, .rb-qlist {
  background: var(--glass-tile); border: 1px solid var(--line); border-top-color: var(--glass-edge); border-radius: 14px; overflow: hidden;
}
.rb-srow { display: grid; grid-template-columns: minmax(0, 1fr) 54px minmax(80px, 200px) 44px; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); font-size: 14px; }
.rb-srow:last-child { border-bottom: 0; }
.rb-srow .cnt { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.rb-srow b { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.rb-sbar { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: var(--soft); }
.rb-sbar i.ok { background: var(--ok); }
.rb-sbar i.bad { background: var(--bad); opacity: .75; }
.rb-qh, .rb-q { display: grid; grid-template-columns: 40px minmax(0, 1fr) 96px 52px 60px 56px; align-items: center; gap: 10px; padding: 9px 16px; }
.rb-qh { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border-bottom: 1px solid var(--line); }
.rb-q { width: 100%; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; font-size: 14px; }
.rb-q:last-child { border-bottom: 0; }
.rb-q:hover { background: var(--lav-tint); }
.rb-q .no { color: var(--muted); font-variant-numeric: tabular-nums; }
.rb-q .sj { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rb-q .yl, .rb-q .al { font-weight: 600; text-align: center; }
.rb-q .tm { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.rb-qh span:nth-child(4), .rb-qh span:nth-child(5) { text-align: center; }
.rb-qh span:last-child { text-align: right; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-style: normal; font-size: 12px; font-weight: 600; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.om, .pill.na { background: var(--soft); color: var(--muted); }
@media (max-width: 640px) {
  .rb-qh, .rb-q { grid-template-columns: 30px minmax(0, 1fr) 84px 34px 34px; padding: 9px 12px; gap: 8px; }
  .rb-qh span:last-child, .rb-q .tm { display: none; }
  .rb-srow { grid-template-columns: minmax(0, 1fr) 46px 60px 40px; padding: 10px 12px; }
}

/* random block: number-of-questions stepper and presets (touch friendly) */
.rb-step { display: inline-flex; align-items: stretch; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); overflow: hidden; }
.rb-step:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--lav-tint); }
.rb-step .rb-num { width: 64px; border: 0; border-radius: 0; background: transparent; box-shadow: none; padding: 7px 4px; }
.rb-step .rb-num:focus { box-shadow: none; }
.rb-pm { width: 38px; border: 0; background: transparent; color: var(--text); font-size: 19px; line-height: 1; touch-action: manipulation; }
.rb-pm:hover:not(:disabled) { background: var(--lav-tint); color: var(--accent); }
.rb-pm:disabled { opacity: .35; cursor: default; }
.rb-range { touch-action: pan-y; height: 30px; cursor: pointer; }
.rb-range::-webkit-slider-thumb { width: 22px; height: 22px; margin-top: -8px; }
.rb-presets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.rb-presets .chip { min-width: 46px; padding: 4px 12px; font-variant-numeric: tabular-nums; touch-action: manipulation; }
.rb-presets .chip.cur { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.rb-presets .chip:disabled { opacity: .35; cursor: default; pointer-events: none; }
@media (min-width: 561px) and (max-width: 1000px) { .bar { padding: 14px 18px; gap: 10px; } .bar .tools { gap: 2px; } .bar .btn.small { white-space: nowrap; font-size: 15px; padding: 5px 9px; } .bank-pick { margin-left: 6px; } }

/* ================= test history ================= */
.hist-head { align-items: flex-end; margin-top: 0; }
.hist-head .hello { margin: 0; }
.rb-hist span { display: inline-block; min-width: 18px; margin-left: 4px; padding: 0 6px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--lav-tint); color: var(--accent); }
.rb-tag.bank { background: var(--soft); color: var(--text); }
.hist-list { display: grid; gap: 8px; margin-top: 14px; }
.hist-row {
  display: grid; grid-template-columns: 64px minmax(0, 1fr) 120px auto; align-items: center; gap: 16px; padding: 12px 14px 12px 16px;
  background: var(--glass-tile); border: 1px solid var(--line); border-top-color: var(--glass-edge); border-radius: 14px;
  cursor: pointer; transition: box-shadow .15s, border-color .15s;
}
.hist-row:hover, .hist-row:focus-visible { box-shadow: var(--shadow-hover); border-color: rgba(var(--lav-rgb),.5); outline: none; }
.hist-date { display: flex; flex-direction: column; line-height: 1.25; }
.hist-date b { font-size: 15px; font-weight: 600; }
.hist-date span { font-size: 12px; color: var(--muted); }
.hist-main { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.hist-main b { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 15px; font-weight: 600; }
.hist-main > span { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.hist-score { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.hist-score b { font-size: 20px; font-weight: 600; letter-spacing: -.02em; color: var(--accent); font-variant-numeric: tabular-nums; }
.hist-score .bar-in { width: 100%; margin: 0; height: 4px; }
.hist-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 36px 20px; text-align: center;
  background: var(--glass-tile); border: 1px dashed var(--line); border-radius: 14px; }
.hist-empty b { font-size: 16px; }
.hist-empty span { color: var(--muted); font-size: 14px; margin-bottom: 8px; }
@media (max-width: 640px) {
  .hist-row { grid-template-columns: 52px minmax(0, 1fr) auto; gap: 12px; }
  .hist-score { grid-column: 2 / 3; flex-direction: row; align-items: center; }
  .hist-score b { font-size: 16px; }
  .hist-row .rb-del { grid-column: 3; grid-row: 1 / 3; }
  .hist-head { flex-direction: column; align-items: flex-start; }
}

/* random block card: text on top, buttons on their own row (fits every width; no squeezed title) */
.rb-card { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 16px; row-gap: 12px; align-items: center; }
.rb-card .rb-ico { grid-row: 1; grid-column: 1; align-self: start; }
.rb-card .rb-txt { grid-row: 1; grid-column: 2; }
.rb-card .rb-acts { grid-row: 2; grid-column: 2; width: auto; justify-content: flex-start; }
.rb-card.empty { grid-template-columns: auto minmax(0, 1fr) auto; }
.rb-card.empty .rb-acts { grid-row: 1; grid-column: 3; }
.rb-txt > b { flex-wrap: nowrap; white-space: nowrap; }
.rb-tag { white-space: nowrap; }
.rb-prog .bar-in { flex: 0 1 240px; min-width: 120px; }
@media (max-width: 640px) {
  .rb-card, .rb-card.empty { grid-template-columns: auto minmax(0, 1fr); }
  .rb-card .rb-acts, .rb-card.empty .rb-acts { grid-row: 2; grid-column: 1 / -1; }
  .rb-txt > b { flex-wrap: wrap; white-space: normal; }
}

/* ---- touch: long-press menus and tooltips ---- */
.lp-tip {
  position: fixed; z-index: 60; max-width: min(320px, calc(100vw - 16px)); padding: 7px 11px; border-radius: 9px;
  background: var(--ink); color: var(--on-ink); font-size: 13px; line-height: 1.4; box-shadow: 0 8px 24px rgba(0,0,0,.25);
  pointer-events: none; animation: lp-in .12s ease-out;
}
@keyframes lp-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.modal-card.lp-card { width: min(340px, 100%); }
.modal-card.lp-card h4 { margin-bottom: 14px; }
.lp-sheet { display: grid; gap: 8px; margin-bottom: 14px; }
.lp-sheet .btn { width: 100%; padding: 11px 14px; text-align: left; font-size: 15px; }
.btn.danger-soft { color: var(--bad); }
.btn.danger-soft:hover { border-color: var(--bad); background: var(--bad-bg); }
@media (hover: none) and (pointer: coarse) {
  .tile, .ch-head, .qn, .tool, .chip, .col, .btn, .rb-q, .hist-row { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
  .tile .tile-reset { opacity: .45; }
  .tile:hover { transform: none; box-shadow: none; }
}

/* ---- reset animation (block tile / AMBOSS subject) ---- */
@keyframes rs-pulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(var(--lav-rgb), .55); }
  35% { transform: scale(.965); box-shadow: 0 0 0 6px rgba(var(--lav-rgb), .28); }
  70% { transform: scale(1.015); box-shadow: 0 0 0 10px rgba(var(--lav-rgb), 0); }
  100% { transform: scale(1); box-shadow: var(--shadow); }
}
@keyframes rs-drain { from { width: var(--was, 0%); } to { width: 0%; } }
@keyframes rs-sweep { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.tile.just-reset, .chapter.just-reset { position: relative; overflow: hidden; animation: rs-pulse .7s cubic-bezier(.3, .7, .3, 1); border-color: var(--accent); }
.tile.just-reset::after, .chapter.just-reset::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(100deg, transparent 20%, rgba(var(--lav-rgb), .28) 50%, transparent 80%);
  animation: rs-sweep .7s ease-out forwards;
}
.just-reset .bar-in i, .just-reset .mini i { animation: rs-drain .6s cubic-bezier(.5, 0, .2, 1) forwards; }
@media (prefers-reduced-motion: reduce) {
  .tile.just-reset, .chapter.just-reset, .just-reset .bar-in i, .just-reset .mini i, .tile.just-reset::after, .chapter.just-reset::after { animation: none; }
}

/* ================= leaderboard ================= */
.bar .btn.ghost.on, #statsBtn.on { color: var(--accent); opacity: 1; }
.lb-head { align-items: flex-end; margin-top: 0; flex-wrap: wrap; }
.lb-head .hello { margin: 0; }
.lb-list { display: grid; gap: 8px; margin-top: 14px; }
.lb-row {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) 110px; grid-template-areas: "rank user main" "rank others others";
  align-items: center; column-gap: 16px; row-gap: 10px; padding: 14px 18px;
  background: var(--glass-tile); border: 1px solid var(--line); border-top-color: var(--glass-edge); border-radius: 14px;
}
.lb-row.you { border-color: rgba(var(--lav-rgb), .6); box-shadow: 0 0 0 3px var(--lav-tint); }
.lb-rank {
  grid-area: rank; align-self: start; display: grid; place-items: center; width: 34px; height: 34px; margin-top: 2px; border-radius: 50%;
  font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; background: var(--soft); color: var(--muted);
}
.lb-row.top1 .lb-rank { background: linear-gradient(135deg, #f6d36b, #e0a93a); color: #4a3405; }
.lb-row.top2 .lb-rank { background: linear-gradient(135deg, #e6e8ee, #b9bfcc); color: #333844; }
.lb-row.top3 .lb-rank { background: linear-gradient(135deg, #efc39a, #c98a55); color: #46270e; }
.lb-user { grid-area: user; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.lb-user b { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 600; }
.lb-user > span { font-size: 12.5px; color: var(--muted); }
.lb-user .bar-in { margin-top: 6px; height: 5px; max-width: 360px; }
.lb-main { grid-area: main; display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.lb-main b { font-size: 24px; font-weight: 600; letter-spacing: -.02em; color: var(--accent); font-variant-numeric: tabular-nums; }
.lb-main em, .lb-m em { font-style: normal; font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.lb-others { grid-area: others; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.lb-m { display: flex; flex-direction: column; line-height: 1.25; }
.lb-m b { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.lb-empty { padding: 30px 20px; text-align: center; color: var(--muted); background: var(--glass-tile); border: 1px dashed var(--line); border-radius: 14px; }
.lb-note { margin-top: 14px; font-size: 12.5px; }
.lb-note b { color: var(--text); font-weight: 600; }
@media (max-width: 640px) {
  .lb-row { grid-template-columns: 34px minmax(0, 1fr) auto; padding: 12px 14px; column-gap: 12px; }
  .lb-rank { width: 30px; height: 30px; font-size: 14px; }
  .lb-main b { font-size: 20px; }
  .lb-others { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #lbSort { overflow-x: auto; max-width: 100%; }
  #lbSort button { white-space: nowrap; }
}
@media (min-width: 561px) and (max-width: 1000px) { #home .bar .tools > [data-act="fs"] { display: none; } .bar .tools { flex-wrap: wrap; justify-content: flex-end; row-gap: 4px; } }

/* ---- settings menu (theme, accent, full screen) in the top bar ---- */
.bar .btn.set-btn { position: relative; display: inline-grid; place-items: center; width: 40px; height: 36px; padding: 0 !important; border-radius: 10px; }
.bar .btn.set-btn svg { width: 21px; height: 21px; transition: transform .35s ease; }
.bar .btn.set-btn[aria-expanded="true"] { opacity: 1; color: var(--accent); background: var(--glass-tile); border-color: var(--line); }
.bar .btn.set-btn[aria-expanded="true"] svg { transform: rotate(60deg); }
.set-btn .dot { position: absolute; right: 5px; bottom: 5px; width: 9px; height: 9px; box-shadow: 0 0 0 2px var(--bg); }
.settings-pop { width: 248px; padding: 14px; }
.settings-pop .lbl { margin-top: 2px; }
.theme-seg { display: grid; grid-template-columns: 1fr 1fr; width: 100%; margin-bottom: 14px; }
.theme-seg button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 10px; font-size: 13.5px; }
.theme-seg button svg { width: 16px; height: 16px; }
.set-sep { height: 1px; margin: 12px 0 8px; background: var(--line); }
.set-row { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 8px; border: 0; border-radius: 9px; background: transparent; color: var(--text); font-size: 14px; text-align: left; }
.set-row:hover { background: var(--soft); }
.set-row svg { width: 18px; height: 18px; color: var(--muted); }
@media (max-width: 560px) { .settings-pop { right: -8px; width: min(248px, calc(100vw - 24px)); } }
@media (max-width: 560px) { .settings-pop { position: fixed; left: 12px; right: 12px; width: auto; } }

/* ---- account menu (name in the top bar) ---- */
.acct-pick { position: relative; }
.bar .btn.account { gap: 7px; }
.bar .btn.account .chev { width: 15px; height: 15px; margin-left: -1px; color: var(--muted); transition: transform .2s ease; }
.bar .btn.account[aria-expanded="true"] { opacity: 1; background: var(--glass-tile); border-color: var(--line); }
.bar .btn.account[aria-expanded="true"] .chev { transform: rotate(180deg); }
.acct-pop { width: 260px; padding: 14px 12px 10px; }
.acct-head { display: flex; align-items: center; gap: 11px; padding: 0 4px; }
.acct-av { flex: none; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; font-weight: 700; font-size: 16px;
  background: linear-gradient(135deg, var(--lav), var(--accent)); color: #fff; }
.acct-head > div { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.acct-head b { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-head span { font-size: 12.5px; color: var(--muted); }
.acct-pop.offline .acct-head span { color: #d99a2b; }
.acct-pop .set-sep { margin: 12px 0 6px; }
.danger-row { color: var(--bad); }
.danger-row svg { color: var(--bad); }
.danger-row:hover { background: var(--bad-bg); }
@media (max-width: 560px) { .acct-pop { position: fixed; left: 12px; right: 12px; width: auto; } }
.acct-head .acct-av { color: #fff; font-size: 16px; text-shadow: 0 1px 2px rgba(0,0,0,.18); }

/* ================= loading screen ================= */
.splash {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center;
  background: var(--backdrop); background-color: var(--bg);
  transition: opacity .5s ease, visibility .5s ease;
}
.splash.out { opacity: 0; visibility: hidden; pointer-events: none; }
.splash.out .splash-in { transform: scale(1.04); }
.splash-in { display: flex; flex-direction: column; align-items: center; gap: 14px; transition: transform .5s ease; animation: sp-rise .6s cubic-bezier(.2, .8, .2, 1) both; }
.splash-mark { position: relative; display: grid; place-items: center; width: 112px; height: 112px; }
.splash-mark::before {
  content: ""; position: absolute; inset: -10px; border-radius: 50%;
  background: radial-gradient(circle, rgba(var(--lav-rgb), .55), rgba(var(--lav-rgb), .12) 45%, transparent 68%);
  animation: sp-breathe 2.6s ease-in-out infinite;
}
.splash .logo, .loader .logo { position: relative; width: 84px; height: 84px; filter: drop-shadow(0 8px 18px rgba(var(--lav-rgb), .45)); animation: sp-float 2.6s ease-in-out infinite; }
/* the snake winds itself up the rod, holds, and unwinds again */
.splash .logo .snake, .splash .logo .halo, .loader .logo .snake, .loader .logo .halo { stroke-dasharray: 1; stroke-dashoffset: 1; animation: sp-draw 2.6s ease-in-out infinite; }
.splash .logo .rod, .loader .logo .rod { stroke-dasharray: 1; stroke-dashoffset: 1; animation: sp-rod 2.6s ease-in-out infinite; }
.splash .logo .head, .loader .logo .head { animation: sp-head 2.6s ease-in-out infinite; }
.splash .logo .cover, .loader .logo .cover { animation: sp-glow 2.6s ease-in-out infinite; }
.splash-word { font-size: 30px; font-weight: 600; letter-spacing: -.02em; color: var(--text); }
.splash-word b { font-weight: 700; color: var(--accent); }
.splash-bar { position: relative; width: 168px; height: 4px; margin-top: 4px; border-radius: 3px; overflow: hidden; background: var(--line); }
.splash-bar i { position: absolute; top: 0; bottom: 0; left: 0; width: 42%; border-radius: inherit;
  background: linear-gradient(90deg, transparent, var(--lav), var(--accent), transparent); animation: sp-slide 1.25s cubic-bezier(.45, 0, .2, 1) infinite; }
.splash-msg { margin: 2px 0 0; font-size: 13.5px; color: var(--muted); min-height: 1.4em; }
@keyframes sp-rise { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes sp-breathe { 0%, 100% { transform: scale(.82); opacity: .55; } 50% { transform: scale(1.08); opacity: 1; } }
@keyframes sp-float { 0%, 100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-5px) rotate(1deg); } }
@keyframes sp-rod { 0% { stroke-dashoffset: 1; } 18%, 82% { stroke-dashoffset: 0; } 100% { stroke-dashoffset: -1; } }
@keyframes sp-draw { 0%, 12% { stroke-dashoffset: 1; } 52%, 80% { stroke-dashoffset: 0; } 100% { stroke-dashoffset: -1; } }
@keyframes sp-head { 0%, 46% { opacity: 0; transform: scale(.4); transform-origin: 14.6px 9.1px; } 56%, 82% { opacity: 1; transform: scale(1); transform-origin: 14.6px 9.1px; } 100% { opacity: 0; transform-origin: 14.6px 9.1px; } }
@keyframes sp-glow { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.12); } }
@keyframes sp-slide { from { transform: translateX(-100%); } to { transform: translateX(240%); } }

/* small overlay while a block / subject / review loads */
.loader { position: fixed; inset: 0; z-index: 150; display: grid; place-items: center; pointer-events: none; opacity: 0; transition: opacity .2s ease; }
.loader.on { opacity: 1; pointer-events: auto; background: rgba(var(--lav-rgb), .06); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
.loader-card { display: flex; align-items: center; gap: 14px; padding: 14px 22px 14px 16px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: 0 18px 48px rgba(20, 16, 50, .22);
  transform: translateY(6px) scale(.98); transition: transform .25s ease; }
.loader.on .loader-card { transform: none; }
.loader-mark { display: grid; place-items: center; width: 44px; height: 44px; }
.loader .logo { width: 40px; height: 40px; filter: drop-shadow(0 4px 10px rgba(var(--lav-rgb), .4)); }
.loader-txt { font-size: 14.5px; font-weight: 500; }

@media (prefers-reduced-motion: reduce) {
  .splash *, .splash *::before, .loader * { animation: none !important; }
  .splash .logo .snake, .splash .logo .halo, .splash .logo .rod, .loader .logo .snake, .loader .logo .halo, .loader .logo .rod { stroke-dashoffset: 0; }
}

/* ================= About page ================= */
#aboutBtn.on { color: var(--accent); opacity: 1; }
.about .section-title { margin-top: 30px; }
.ab-hero { display: flex; align-items: center; gap: 22px; padding: 22px 24px; margin-top: 4px; border-radius: 18px; position: relative; overflow: hidden;
  background: var(--glass-tile); border: 1px solid var(--line); border-top-color: var(--glass-edge); box-shadow: var(--shadow); }
.ab-hero::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(500px 200px at 0% 0%, rgba(var(--lav-rgb), .22), transparent 70%); }
.ab-hero > * { position: relative; }
.ab-hero h1 { margin: 0 0 6px; font-size: 28px; letter-spacing: -.02em; }
.ab-hero .sub { line-height: 1.6; }
.ab-hero .sub b { color: var(--text); font-weight: 600; }
.ab-hero-mark { flex: none; display: grid; place-items: center; width: 92px; height: 92px; }
.ab-hero-mark .logo { width: 72px; height: 72px; filter: drop-shadow(0 8px 18px rgba(var(--lav-rgb), .45)); animation: sp-float 2.6s ease-in-out infinite; }
.ab-hero-mark .logo .snake, .ab-hero-mark .logo .halo { stroke-dasharray: 1; stroke-dashoffset: 1; animation: sp-draw 5.2s ease-in-out infinite; }
.ab-hero-mark .logo .rod { stroke-dasharray: 1; stroke-dashoffset: 1; animation: sp-rod 5.2s ease-in-out infinite; }
.ab-hero-mark .logo .head { animation: sp-head 5.2s ease-in-out infinite; }
.ab-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; }
.ab-card { display: flex; gap: 14px; padding: 16px 18px; border-radius: 14px; background: var(--glass-tile); border: 1px solid var(--line); border-top-color: var(--glass-edge); }
.ab-card b { display: block; margin-bottom: 4px; font-size: 15px; }
.ab-card p { margin: 0; font-size: 13.5px; line-height: 1.6; color: var(--muted); }
.ab-card p b { display: inline; margin: 0; font-size: inherit; color: var(--text); font-weight: 600; }
.ab-ic { flex: none; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: var(--lav-tint); color: var(--accent); }
.ab-ic svg { width: 20px; height: 20px; }
.ab-faq { display: grid; gap: 8px; }
.ab-faq details { border-radius: 12px; background: var(--glass-tile); border: 1px solid var(--line); border-top-color: var(--glass-edge); overflow: hidden; }
.ab-faq summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 16px; cursor: pointer; list-style: none; font-weight: 600; font-size: 15px; }
.ab-faq summary::-webkit-details-marker { display: none; }
.ab-faq summary svg { flex: none; width: 18px; height: 18px; color: var(--muted); transition: transform .2s ease; }
.ab-faq details[open] summary svg { transform: rotate(180deg); color: var(--accent); }
.ab-faq summary:hover { background: var(--lav-tint); }
.ab-faq details p { margin: 0; padding: 0 16px 14px; font-size: 14px; line-height: 1.65; color: var(--muted); }
.ab-faq details p b { color: var(--text); font-weight: 600; }
.ab-faq details[open] p { animation: ab-open .2s ease-out; }
@keyframes ab-open { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.ab-dev { margin-top: 30px; padding: 22px 24px; border-radius: 18px; position: relative; overflow: hidden;
  background: var(--glass-tile); border: 1px solid rgba(var(--lav-rgb), .45); box-shadow: var(--shadow); }
.ab-dev::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(135deg, rgba(var(--lav-rgb), .18), transparent 55%); }
.ab-dev > * { position: relative; }
.ab-dev-head { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.ab-dev-head h2 { margin: 0; font-size: 21px; letter-spacing: -.01em; }
.ab-av { flex: none; display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; color: #fff;
  background: linear-gradient(135deg, var(--lav), var(--accent)); box-shadow: 0 6px 16px rgba(var(--lav-rgb), .4); }
.ab-av svg { width: 24px; height: 24px; }
.ab-dev > p { margin: 0 0 12px; font-size: 15px; line-height: 1.75; }
.ab-dev > p b { font-weight: 600; color: var(--accent); }
.ab-facts { list-style: none; margin: 16px 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 8px; }
.ab-facts li { display: flex; flex-direction: column; gap: 2px; padding: 10px 14px; border-radius: 11px; background: var(--bg); border: 1px solid var(--line); }
.ab-facts b { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.ab-facts span { font-size: 14px; }
.ab-sign { margin: 6px 0 0 !important; font-style: italic; color: var(--muted); }
.ab-legal { margin-top: 18px; font-size: 12.5px; }
@media (max-width: 640px) {
  .ab-hero { flex-direction: column; align-items: flex-start; gap: 10px; padding: 18px; }
  .ab-hero-mark { width: 64px; height: 64px; }
  .ab-hero-mark .logo { width: 56px; height: 56px; }
  .ab-grid { grid-template-columns: 1fr; }
  .ab-dev { padding: 18px; }
}

/* About: centred header (logo above the title) */
.ab-hero { flex-direction: column; justify-content: center; text-align: center; gap: 6px; padding: 26px 24px 22px; }
.ab-hero h1 { margin: 0; }
.ab-hero::before { background: radial-gradient(420px 180px at 50% 0%, rgba(var(--lav-rgb), .24), transparent 70%); }
@media (max-width: 640px) { .ab-hero { align-items: center; } }

/* ================= offline: banner + downloads ================= */
.offline-bar { display: none; align-items: center; gap: 10px; max-width: 780px; margin: 14px auto 0; padding: 10px 14px;
  border-radius: 12px; font-size: 13.5px; background: rgba(217, 154, 43, .12); border: 1px solid rgba(217, 154, 43, .35); color: var(--text); }
.offline-bar svg { flex: none; width: 18px; height: 18px; color: #d99a2b; }
body.is-offline .offline-bar { display: flex; }
@media (max-width: 820px) { .offline-bar { margin: 12px 16px 0; } }
.tile.dl::after { content: ""; position: absolute; right: 10px; bottom: 12px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 6v9M8 11l4 4 4-4'/%3E%3C/svg%3E") center/10px no-repeat; opacity: .85; }
.tile { position: relative; }
.modal-card.dl-card { width: min(640px, 100%); }
.dl-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.dl-head h4 { margin: 0; font-size: 19px; }
.dl-use { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.modal-card p.dl-lead { margin: 6px 0 14px; font-size: 13.5px; }
.dl-list { display: grid; gap: 14px; max-height: min(52vh, 460px); overflow: auto; padding: 2px; }
.dl-group > b { display: block; margin-bottom: 7px; font-size: 13.5px; font-weight: 600; }
.dl-chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; }
.dl-chip { position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; gap: 4px; height: 34px; padding: 0 8px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--bg); font-size: 13px; font-variant-numeric: tabular-nums; touch-action: manipulation; }
.dl-chip:hover { border-color: var(--lav); }
.dl-chip i { width: 12px; height: 12px; flex: none; opacity: .45;
  background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 4v11M7 10l5 5 5-5M5 20h14'/%3E%3C/svg%3E") center/contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 4v11M7 10l5 5 5-5M5 20h14'/%3E%3C/svg%3E") center/contain no-repeat; }
.dl-chip.done { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.dl-chip.done i { opacity: 1; -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E"); }
.dl-chip.busy { border-color: var(--accent); }
.dl-chip.busy::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: var(--p, 0%); background: var(--lav-tint); transition: width .2s; }
.dl-chip.busy i { animation: dl-bob .9s ease-in-out infinite; opacity: .9; }
.dl-chip.err { border-color: var(--bad); color: var(--bad); }
.dl-chip > * { position: relative; }
@keyframes dl-bob { 0%, 100% { transform: translateY(-2px); } 50% { transform: translateY(2px); } }
.dl-actions { align-items: center; margin-top: 16px; flex-wrap: wrap; }
.dl-actions .sp { flex: 1; }
@media (max-width: 560px) { .dl-actions .sp { display: none; } .dl-actions .btn { flex: 1 1 auto; } }
.dl-chips { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); } .dl-chip span { white-space: nowrap; }

/* change password + forgot password */
.pw-form h4 { margin: 0 0 4px; font-size: 18px; }
.pw-form > p:first-of-type { margin: 0 0 14px; }
.pw-form label { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; font-size: 13.5px; font-weight: 600; }
.pw-form input { padding: 9px 11px; font: inherit; font-size: 15px; font-weight: 400; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 9px; outline: none; }
.pw-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--lav-tint); }
.modal-card p.pw-err { min-height: 1.3em; margin: 0 0 10px; color: var(--bad); font-size: 13.5px; }
.login-forgot { margin: 2px 0 0; text-align: center; font-size: 13.5px; }
.login-forgot-msg { margin: 6px 0 0; padding: 10px 12px; border-radius: 10px; text-align: center; font-size: 13.5px; line-height: 1.5;
  background: var(--lav-tint); color: var(--text); animation: ab-open .2s ease-out; }

/* downloaded badge: right under the block's reset icon (top-right corner) */
.tile.dl::after { top: 35px; right: 12px; bottom: auto; width: 14px; height: 14px; }
.dl-bar { margin: 12px 0 2px; }
.dl-bar .seg { display: inline-flex; }
@media (max-width: 560px) { .dl-bar .seg { display: grid; grid-template-columns: 1fr 1fr; width: 100%; } .dl-bar .seg button { font-size: 12.5px; padding: 6px 6px; } }
#dlBtn { display: inline-flex; align-items: center; gap: 6px; } #dlBtn[hidden] { display: none; } #dlBtn svg { display: none; width: 20px; height: 20px; }
@media (max-width: 560px) { #dlBtn svg { display: block; } #dlBtn span { display: none; } }
.dl-actions .btn:disabled { opacity: .4; cursor: default; color: var(--muted); border-color: var(--line); background: transparent; box-shadow: none; }

/* ================= question screen: toolbar position ================= */
.quiz { --ql: 88px; --tbw: 78px; }
@media (max-width: 1000px), (orientation: portrait) and (max-width: 1400px) { .quiz { --ql: 64px; } }
@media (max-width: 560px) { .quiz { --ql: 52px; --tbw: 56px; } }
.quiz.tb-bottom { grid-template-columns: var(--ql) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) 64px 52px;
  grid-template-areas: "list main" "list top" "list bottom"; }
.quiz.tb-left { grid-template-columns: var(--tbw) minmax(0, 1fr) var(--ql); grid-template-rows: minmax(0, 1fr) 52px;
  grid-template-areas: "top main list" "top bottom list"; }
.quiz.tb-right { grid-template-columns: var(--ql) minmax(0, 1fr) var(--tbw); grid-template-rows: minmax(0, 1fr) 52px;
  grid-template-areas: "list main top" "list bottom top"; }
.quiz.tb-bottom .qtop { border-bottom: 0; border-top: 1px solid var(--line); }
.quiz.tb-left .qlist { border-right: 0; border-left: 1px solid var(--line); }
/* a vertical toolbar: one column of icons */
.quiz.tb-left .qtop, .quiz.tb-right .qtop {
  flex-direction: column; align-items: center; justify-content: flex-start; gap: 10px; padding: 12px 6px;
  border-bottom: 0; overflow-y: auto; overflow-x: hidden; min-height: 0;
}
.quiz.tb-left .qtop { border-right: 1px solid var(--line); }
.quiz.tb-right .qtop { border-left: 1px solid var(--line); }
.quiz.tb-left .item-box, .quiz.tb-right .item-box, .quiz.tb-left .set-title, .quiz.tb-right .set-title { display: none; }
.quiz.tb-left .qtop .tool span, .quiz.tb-right .qtop .tool span, .quiz.tb-left .mark-btn span, .quiz.tb-right .mark-btn span { display: none; }
.quiz.tb-left .mark-btn, .quiz.tb-right .mark-btn { padding: 8px; }
.quiz.tb-left .nav, .quiz.tb-right .nav { flex-direction: column; gap: 4px; margin: 4px 0; }
.quiz.tb-left .counter, .quiz.tb-right .counter { min-width: 0; font-size: 14px; line-height: 1.2; }
.quiz.tb-left .tools-right, .quiz.tb-right .tools-right { flex-direction: column; gap: 4px; margin-top: auto; }
.quiz.tb-left .qtop .tool, .quiz.tb-right .qtop .tool { padding: 8px; }
/* the lab-value drawer and calculator keep clear of the toolbar */
body.tb-bottom .drawer { top: 0; bottom: 116px; }
body.tb-left .drawer, body.tb-right .drawer { top: 0; bottom: 52px; }
body.tb-right .drawer { right: 78px; }
@media (max-width: 560px) { body.tb-right .drawer { right: 56px; width: min(520px, calc(100vw - 56px)); } }
/* the position picker */
.tbpos-pick { position: relative; }
.tbpos-pop { position: fixed; z-index: 40; width: 220px; padding: 12px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: 0 18px 44px rgba(20, 16, 50, .22); }
.tbpos-pop .lbl { display: block; margin: 0 2px 8px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.tbpos-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tbpos-grid button { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 9px 4px 7px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--bg); color: var(--text); font-size: 12.5px; }
.tbpos-grid button:hover { border-color: var(--lav); }
.tbpos-grid button.cur { border-color: var(--accent); background: var(--lav-tint); color: var(--accent); }
.tbp-ico { width: 30px; height: 30px; stroke-width: 1.5; }
.tbp-ico .f { fill: currentColor; stroke: none; opacity: .55; }
.tbpos-grid button.cur .tbp-ico .f { opacity: 1; }
/* phones: the horizontal toolbar has to fit 330 px */
@media (max-width: 560px) {
  .quiz:not(.tb-left):not(.tb-right) .qtop { gap: 4px; padding: 0 6px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
  .quiz:not(.tb-left):not(.tb-right) .qtop::-webkit-scrollbar { display: none; }
  .quiz:not(.tb-left):not(.tb-right) .item-box, .quiz:not(.tb-left):not(.tb-right) .set-title { display: none; }
  .quiz:not(.tb-left):not(.tb-right) .nav { margin: 0 auto 0 0; gap: 0; }
  .quiz:not(.tb-left):not(.tb-right) .counter { min-width: 44px; font-size: 14px; }
  .quiz:not(.tb-left):not(.tb-right) .tool { padding: 6px 5px; }
  .quiz:not(.tb-left):not(.tb-right) .mark-btn { padding: 6px 7px; }
  .quiz:not(.tb-left):not(.tb-right) .tools-right { gap: 0; }
}

/* left toolbar: the question list is on the right, so the lab drawer stops short of it */
body.tb-left .drawer { right: 88px; }
@media (max-width: 1000px), (orientation: portrait) and (max-width: 1400px) { body.tb-left .drawer { right: 64px; } }
@media (max-width: 560px) {
  body.tb-left .drawer { right: 52px; width: min(520px, calc(100vw - 52px)); }
  .qbottom { padding: 0 10px; }
  .elapsed { font-size: 13px; white-space: nowrap; }
  .elapsed .sep { margin: 0 8px; }
}
/* vertical toolbar: Mark at the top, question navigation in the exact middle, tools at the bottom */
.quiz.tb-left .qtop, .quiz.tb-right .qtop { display: grid; grid-template-rows: minmax(0, 1fr) auto minmax(0, 1fr); justify-items: center; gap: 0; }
.quiz.tb-left .mark-btn, .quiz.tb-right .mark-btn { grid-row: 1; align-self: start; }
.quiz.tb-left .nav, .quiz.tb-right .nav { grid-row: 2; align-self: center; margin: 0; }
.quiz.tb-left .tools-right, .quiz.tb-right .tools-right { grid-row: 3; align-self: end; margin: 0; }
/* side toolbar halves: buttons spread evenly between the edge and the navigation */
.quiz.tb-left .qtop, .quiz.tb-right .qtop { padding: 10px 6px; }
.tb-vgroup { display: flex; flex-direction: column; align-items: center; justify-content: space-evenly; width: 100%; height: 100%; min-height: 0; }
.tb-vtop { grid-row: 1; } .tb-vbot { grid-row: 3; }
.tb-vgroup > * { align-self: center !important; margin: 0 !important; }
.quiz.tb-left .nav, .quiz.tb-right .nav { padding: 6px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); width: 100%; align-items: center; }

/* ================= linked questions ================= */
.link-note { display: flex; align-items: flex-start; gap: 10px; margin: 4px 0 14px; padding: 10px 14px; font-size: 14px; line-height: 1.5;
  border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 10px; background: var(--lav-tint); color: var(--text); }
.link-note.locked { border-left-color: var(--muted); background: var(--soft); }
.link-note .ln-ico { flex: none; width: 18px; height: 18px; margin-top: 2px; color: var(--accent); }
.link-note.locked .ln-ico { color: var(--muted); }
.ln-ico { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.link-dlg { display: flex; align-items: center; gap: 10px; }
.link-dlg .ln-ico { width: 22px; height: 22px; color: var(--accent); }
.link-dlg h4 { margin: 0; }
.link-pick { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font-size: 14px; }

/* ================= lab values and calculator: drawers that slide in beside the question ================= */
:root { --drw: clamp(340px, 34vw, 480px); --drh: 46vh; --calch: 440px; --drw-ease: cubic-bezier(.22, .8, .24, 1); }
#labs.drawer, #calc.drawer {
  top: 0; right: 0; bottom: 0; left: auto; width: var(--drw); z-index: 25; box-shadow: none;
  transform: translateX(100%); transition: transform .3s var(--drw-ease), box-shadow .3s, bottom .3s var(--drw-ease);
}
#labs.drawer.open, #calc.drawer.open { transform: none; box-shadow: -10px 0 30px rgba(0, 0, 0, .1); }
/* both open: one column, lab values on top and the calculator (its keys only) below */
body.labs-open.calc-open #labs.drawer { bottom: var(--calch); }
body.labs-open #calc.drawer { top: auto; z-index: 26; border-top: 1px solid var(--line); }
body.labs-open #calc .calc-hist { display: none; }
/* compact keys when the calculator shares the column or comes up from the bottom */
body.labs-open #calc .calc-main { padding: 12px 18px; }
body.labs-open #calc .calc-keys button { padding: 8px 0; }
body.labs-open #calc .calc-screen { padding: 6px 12px; margin-bottom: 8px; }
body.labs-open #calc .calc-out { font-size: 22px; }
.quiz { transition: right .3s var(--drw-ease), bottom .3s var(--drw-ease), grid-template-columns .3s var(--drw-ease); }
.quiz.drawer-open { right: var(--drw); --ql: 0px; }
.quiz.drawer-open:not(.tb-left):not(.tb-right):not(.tb-bottom) { grid-template-columns: 0px minmax(0, 1fr); }
/* the question list slides out of the way and comes back when the drawer closes */
.qlist { transition: transform .3s var(--drw-ease), opacity .2s; }
.quiz.drawer-open .qlist { transform: translateX(-100%); opacity: 0; overflow: hidden; border-width: 0; pointer-events: none; }
.quiz.tb-left.drawer-open .qlist { transform: translateX(100%); }
/* answered: question and explanation stack in one column while a drawer is open */
@media (max-width: 1700px) {
  .quiz.drawer-open.answered .panes { display: block; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .quiz.drawer-open.answered .qpane, .quiz.drawer-open.answered .epane { overflow: visible; min-height: auto; }
  .quiz.drawer-open.answered .epane { border-left: 0; border-top: 1px solid var(--line); }
  .quiz.drawer-open.answered .qinner { max-width: 860px; }
}
/* phones and portrait tablets: a drawer comes up from the bottom (one at a time) and the question keeps the top */
@media (max-width: 760px), (orientation: portrait) and (max-width: 1400px) {
  #labs.drawer, #calc.drawer { top: auto; left: 0; width: auto; height: var(--drh); transform: translateY(100%);
    border-left: 0; border-top: 1px solid var(--line); border-radius: 16px 16px 0 0; }
  #calc.drawer { height: auto; max-height: 70vh; }
  #calc .calc-hist { display: none; }
  #calc .calc-main { width: min(420px, 100%); margin: 0 auto; padding: 12px 16px 16px; }
  #calc .calc-keys button { padding: 9px 0; }
  #calc .calc-screen { padding: 6px 12px; margin-bottom: 8px; }
  #calc .calc-out { font-size: 22px; }
  #calc .drawer-head { padding: 10px 16px; }
  #labs.drawer.open, #calc.drawer.open { transform: none; box-shadow: 0 -10px 30px rgba(0, 0, 0, .12); }
  body.labs-open.calc-open #labs.drawer { bottom: 0; }
  .quiz.drawer-open { right: 0; bottom: var(--drh); }
  body.calc-open .quiz.drawer-open { bottom: var(--calch); }
  .quiz.drawer-open .qlist { transform: translateX(-100%); }
  .quiz.tb-left.drawer-open .qlist { transform: translateX(100%); }
}
@media (prefers-reduced-motion: reduce) { #labs.drawer, #calc.drawer, .quiz, .qlist { transition: none; } }

/* ================= downloads: First Aid chapters ================= */
.dl-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
#dlBySeg button { font-size: 12.5px; padding: 5px 10px; }
.dl-chips.wide { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.dl-chips.wide .dl-chip { justify-content: flex-start; gap: 8px; height: 38px; padding: 0 12px; text-align: left; }
.dl-chips.wide .dl-chip span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.dl-chips.wide .dl-chip em { flex: none; font-style: normal; font-size: 12px; color: var(--muted); }
.dl-chips.wide .dl-chip.done em { color: var(--on-accent); opacity: .85; }
.ch-dl { flex: none; width: 14px; height: 14px; border-radius: 50%; opacity: .85;
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 6v9M8 11l4 4 4-4'/%3E%3C/svg%3E") center/10px no-repeat; }
@media (max-width: 560px) { .dl-chips.wide { grid-template-columns: 1fr; } #dlBySeg { display: grid; grid-template-columns: 1fr 1fr; width: 100%; } #dlBySeg[hidden] { display: none; } }

/* ================= random blocks: up to five, as tiles under the generator ================= */
.rb-count { margin-left: 6px; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--lav-tint); color: var(--accent); vertical-align: 1px; }
.rb-grid { margin: 12px 0 6px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.rb-tile span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rb-tile b { display: block; padding-right: 50px; }
.tile-del {
  position: absolute; top: 7px; right: 7px; display: grid; place-items: center; width: 24px; height: 24px; padding: 0;
  border: 1px solid transparent; border-radius: 7px; background: transparent; color: var(--muted); opacity: 0; transition: opacity .15s, background .15s, color .15s;
}
.tile-del svg { width: 14px; height: 14px; stroke-width: 2.2; }
.tile:hover .tile-del, .tile:focus-within .tile-del { opacity: .8; }
.tile-del:hover { opacity: 1; color: var(--bad); background: var(--bad-bg); }
.rb-tile .tile-reset { right: 33px; }
@media (hover: none) and (pointer: coarse) { .tile .tile-del { opacity: .45; } }
.rb-full { display: grid; gap: 8px; margin: 4px 0 14px; }
.rb-full-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.rb-full-row span { display: flex; flex-direction: column; min-width: 0; }
.rb-full-row em { font-style: normal; font-size: 12.5px; color: var(--muted); }
/* offline bar: a maintenance break (internet fine, server down) gets a wrench */
.offline-bar .ob-maint { display: none; }
.offline-bar.maint .ob-maint { display: block; }
.offline-bar.maint .ob-off { display: none; }

/* ================= About: what's new + update log ================= */
#aboutBtn { position: relative; }
.new-dot { position: absolute; top: 4px; right: 2px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--bg); }
.ab-new { margin: 18px 0 4px; padding: 18px 20px 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); position: relative; overflow: hidden; }
.ab-new::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: linear-gradient(var(--lav), var(--accent)); }
.ab-new-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; }
.ab-new-tag { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; letter-spacing: .03em; background: var(--lav-tint); color: var(--accent); }
.ab-new-v { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ab-new h3 { margin: 10px 0 8px; font-size: 17px; }
.ab-new ul, .upd ul { margin: 0 0 10px; padding-left: 20px; }
.ab-new li, .upd ul li { margin: 0 0 6px; font-size: 14.5px; line-height: 1.6; color: var(--muted); }
.ab-new li b, .upd li b { color: var(--text); font-weight: 600; }
.ab-upd .hello { margin-bottom: 18px; }
.upd-list { list-style: none; margin: 0; padding: 0; position: relative; }
.upd-list::before { content: ""; position: absolute; left: 7px; top: 10px; bottom: 10px; width: 2px; background: var(--line); }
.upd { position: relative; display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 16px; padding-bottom: 22px; }
.upd-dot { position: relative; z-index: 1; width: 16px; height: 16px; margin-top: 3px; border-radius: 50%; background: var(--surface); border: 2px solid var(--line); }
.upd.latest .upd-dot { border-color: var(--accent); background: var(--accent); box-shadow: 0 0 0 4px var(--lav-tint); }
.upd-body { padding: 0 0 4px; }
.upd-meta { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; font-size: 13px; color: var(--muted); }
.upd-meta b { color: var(--text); font-size: 14px; }
.upd-meta em { font-style: normal; font-size: 11.5px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--lav-tint); color: var(--accent); }
.upd h3 { margin: 4px 0 8px; font-size: 17px; }

/* ================= download button on chapters / subjects ================= */
.ch-row { display: flex; align-items: center; }
.ch-row .ch-head { flex: 1; min-width: 0; }
.ch-dlbtn { position: relative; flex: none; display: grid; place-items: center; width: 32px; height: 32px; margin: 0 10px 0 2px; padding: 0;
  border: 1px solid var(--line); border-radius: 50%; background: transparent; color: var(--muted); transition: color .15s, border-color .15s, background .15s; }
.ch-dlbtn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.ch-dlbtn .i-ok { display: none; }
.ch-dlbtn:hover { color: var(--accent); border-color: var(--lav); }
.ch-dlbtn.part { color: var(--accent); border-style: dashed; border-color: var(--lav); }
.ch-dlbtn.done { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.ch-dlbtn.done .i-dl { display: none; } .ch-dlbtn.done .i-ok { display: block; }
.ch-dlbtn.err { color: var(--bad); border-color: var(--bad); }
/* while downloading: a progress ring with the percentage inside */
.ch-dlbtn.busy { border-color: transparent; color: var(--accent);
  background: conic-gradient(var(--accent) var(--p, 0%), var(--lav-tint) 0); }
.ch-dlbtn.busy::before { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--surface); }
.ch-dlbtn.busy svg { display: none; }
.ch-dlbtn span { position: relative; font-size: 9.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ch-dlbtn span:empty { display: none; }

/* ================= landscape: use the width (iPad landscape, laptops, desktops) ================= */
/* portrait and phones keep the narrow reading column; wide screens get a roomier page with even side gutters */
@media (min-width: 960px) and (orientation: landscape) {
  :root { --gut: clamp(32px, 4vw, 64px); --page: 1200px; }
  .wrap { max-width: calc(var(--page) + 2 * var(--gut)); padding: 32px var(--gut) 72px; }
  .bar { padding-left: var(--gut); padding-right: var(--gut); }
  .offline-bar { max-width: none; width: min(var(--page), calc(100% - 2 * var(--gut))); }
  .hello h1 { font-size: 34px; }
  .stats { gap: 14px; margin-bottom: 22px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(136px, 1fr)); gap: 12px; }
  .rb-grid { grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); }
  .chapters { gap: 10px; }
  .ab-grid { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
  /* long lines are hard to read: prose keeps a comfortable measure inside the wider page */
  .ab-dev p, .ab-faq details p, .ab-new ul, .upd ul, .ab-legal { max-width: 80ch; }
}
.offline-bar .ob-tip { display: block; margin-top: 4px; font-size: 12.5px; color: var(--muted); }
.offline-bar .ob-tip b { color: var(--text); font-weight: 600; }
.offline-bar .ob-tip { display: block; margin-top: 4px; font-size: 12.5px; color: var(--muted); }
.offline-bar .ob-tip b { color: var(--text); font-weight: 600; }
.offline-bar.maint { align-items: flex-start; }
.offline-bar.maint svg { margin-top: 2px; }

/* ================= home: three sections, three textures ================= */
:root { --flag-rgb: 217, 130, 43; --ok-rgb: 31, 138, 76; }
:root[data-theme="dark"] { --flag-rgb: 240, 163, 94; --ok-rgb: 76, 194, 131; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --flag-rgb: 240, 163, 94; --ok-rgb: 76, 194, 131; } }
/* section headings carry their section's icon */
.marked h3, #practiceTitle { display: flex; align-items: center; gap: 8px; }
.marked h3::before, #practiceTitle::before { content: ""; flex: none; width: 15px; height: 15px; background: currentColor;
  -webkit-mask: var(--ico) center / contain no-repeat; mask: var(--ico) center / contain no-repeat; }
.marked h3::before { background: var(--flag);
  --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 21V4h11l-1.5 4L16 12H7v9z'/%3E%3C/svg%3E"); }
#practiceTitle::before {
  --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='3' y='3' width='8' height='8' rx='2'/%3E%3Crect x='13' y='3' width='8' height='8' rx='2'/%3E%3Crect x='3' y='13' width='8' height='8' rx='2'/%3E%3Crect x='13' y='13' width='8' height='8' rx='2'/%3E%3C/svg%3E"); }

/* 1. random blocks: yours, made to order -> accent tint, an accent edge and a dice-pip texture */
.rb-tile { isolation: isolate; overflow: hidden; border-color: rgba(var(--lav-rgb), .38); border-left: 3px solid var(--accent);
  background: linear-gradient(135deg, rgba(var(--lav-rgb), .18), rgba(var(--lav-rgb), .04) 65%), var(--glass-tile); }
.rb-tile::before { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(circle, rgba(var(--lav-rgb), .55) 1.3px, transparent 1.8px) 0 0 / 11px 11px;
  -webkit-mask-image: radial-gradient(120px 90px at 100% 100%, #000, transparent 75%); mask-image: radial-gradient(120px 90px at 100% 100%, #000, transparent 75%); opacity: .7; }
.rb-tile:hover { border-color: var(--accent); border-left-color: var(--accent); }
.rb-tile .bar-in { background: rgba(var(--lav-rgb), .2); }
.rb-mode { display: inline-block; margin-right: 7px; padding: 1px 7px; border-radius: 999px; font-style: normal; font-size: 11px; font-weight: 600;
  letter-spacing: .02em; vertical-align: 1px; background: rgba(var(--lav-rgb), .2); color: var(--accent); }
.rb-mode.test { background: var(--accent); color: var(--on-accent); }

/* 2. marked questions: flag orange, warm and easy to spot */
.marked-row { border-left: 3px solid var(--flag); border-color: rgba(var(--flag-rgb), .35); border-left-color: var(--flag);
  background: linear-gradient(90deg, rgba(var(--flag-rgb), .12), rgba(var(--flag-rgb), .02) 55%), var(--glass-tile); }
.marked-row .chip { display: inline-flex; align-items: center; gap: 5px; border-color: rgba(var(--flag-rgb), .45);
  background: rgba(var(--flag-rgb), .08); color: var(--text); font-variant-numeric: tabular-nums; transition: background .15s, color .15s, border-color .15s; }
.marked-row .chip::before { content: ""; width: 9px; height: 9px; background: var(--flag);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 21V4h11l-1.5 4L16 12H7v9z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 21V4h11l-1.5 4L16 12H7v9z'/%3E%3C/svg%3E") center / contain no-repeat; }
.marked-row .chip:hover { background: var(--flag); border-color: var(--flag); color: #fff; }
.marked-row .chip:hover::before { background: #fff; }

/* 3. practice blocks: a finish that shows progress at a glance */
#grid .tile.fresh { background: rgba(var(--lav-rgb), .025); box-shadow: none; border-top-color: var(--line); }
#grid .tile.fresh b { color: var(--muted); font-weight: 600; }
#grid .tile.fresh:hover b { color: var(--text); }
#grid .tile.started { background: linear-gradient(180deg, rgba(var(--lav-rgb), .13), transparent 70%), var(--glass-tile); border-color: rgba(var(--lav-rgb), .3); }
#grid .tile.done { background: linear-gradient(180deg, rgba(var(--ok-rgb), .12), transparent 70%), var(--glass-tile); border-color: rgba(var(--ok-rgb), .32); }
#grid .tile.done b::after { color: var(--ok); }
#grid .tile.done .bar-in i { background: var(--ok); }

/* a finished random block already says "% correct": no extra tick */
.rb-tile.done b::after { content: none; }

/* ================= type: Plus Jakarta Sans for the interface, Fraunces (soft, warm) for display headings ================= */
/* self-hosted (fonts/) so the installed app has them offline; Greek letters, arrows etc. fall back to the system font */
@font-face { font-family: "Plus Jakarta Sans"; font-style: normal; font-weight: 300 800; font-display: swap; src: url(fonts/plus-jakarta-sans.woff2) format("woff2"); }
@font-face { font-family: "Fraunces"; font-style: normal; font-weight: 300 700; font-display: swap; src: url(fonts/fraunces.woff2) format("woff2"); }
@font-face { font-family: "Fraunces"; font-style: italic; font-weight: 300 700; font-display: swap; src: url(fonts/fraunces-italic.woff2) format("woff2"); }
:root { --font-ui: "Plus Jakarta Sans", -apple-system, "Segoe UI", system-ui, Roboto, sans-serif; --font-display: "Fraunces", "Iowan Old Style", Georgia, serif; }
body { font-family: var(--font-ui); }
/* reading content stays in the system face: unambiguous I / l / 1 matter in clinical text (leads II, III, 1:10 dilutions) */
:root { --font-read: -apple-system, "Segoe UI", system-ui, Roboto, sans-serif; }
.stem, .choices, .lab-body, .calc-out, .calc-expr, .noq, .link-note { font-family: var(--font-read); }
/* Fraunces with its "soft" axis up: rounded, friendly terminals instead of sharp, high-contrast ones */
.hello h1, .ab-hero h1, .ab-dev h2 { font-family: var(--font-display); font-weight: 560; letter-spacing: -.02em;
  font-variation-settings: "SOFT" 100, "WONK" 0; font-optical-sizing: auto; }
.hello h1 { font-size: 38px; line-height: 1.12; }
.ab-hero h1 { font-size: 36px; }
.ab-dev h2 { font-size: 26px; }
@media (min-width: 960px) and (orientation: landscape) { .hello h1 { font-size: 42px; } }
@media (max-width: 560px) { .hello h1 { font-size: 31px; } }
.title, .section-title, .marked h3, .btn, .seg button { letter-spacing: -.005em; }
.section-title, .marked h3 { letter-spacing: .09em; font-weight: 700; }

/* ================= home stats: frosted glass over soft accent light ================= */
#stats { position: relative; isolation: isolate; }
#stats::before { content: ""; position: absolute; inset: -24px -12px; z-index: -1; pointer-events: none; filter: blur(34px); opacity: .9;
  background: radial-gradient(260px 150px at 12% 35%, rgba(var(--lav-rgb), .55), transparent 70%),
              radial-gradient(240px 150px at 55% 90%, rgba(var(--lav-rgb), .30), transparent 70%),
              radial-gradient(260px 160px at 92% 20%, rgba(var(--lav-rgb), .42), transparent 70%); }
#stats .stat { color: var(--text); border: 1px solid rgba(var(--lav-rgb), .22); border-top-color: var(--glass-edge);
  background: linear-gradient(150deg, rgba(255, 255, 255, .10), rgba(255, 255, 255, .02) 55%), var(--glass-hero);
  backdrop-filter: blur(18px) saturate(160%); -webkit-backdrop-filter: blur(18px) saturate(160%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .07), 0 12px 32px rgba(10, 8, 30, .18); }
#stats .stat::before { opacity: 1; background: radial-gradient(220px 120px at 100% 0%, rgba(var(--lav-rgb), .16), transparent 70%); }
#stats .stat .label { color: var(--text); font-size: 14px; font-weight: 750; letter-spacing: -.005em; }
#stats .stat b { font-size: 32px; font-weight: 700; letter-spacing: -.035em; margin: 6px 0 2px; }
#stats .stat b small { font-size: 15px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
#stats .stat .sub { color: var(--muted); font-weight: 500; }
#stats .stat .bar-in { background: rgba(var(--lav-rgb), .16); }
#stats .stat .bar-in i { background: linear-gradient(90deg, var(--lav), var(--accent)); }

/* phones: the first stat across the top, the other two side by side */
@media (max-width: 560px) {
  #stats { grid-template-columns: 1fr 1fr; }
  #stats .stat:first-child { grid-column: 1 / -1; }
  #stats .stat b { font-size: 28px; }
}

/* ================= moving shader-gradient background (backdrop.js) ================= */
.gradient-backdrop { position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: 0; transition: opacity 1.6s ease; }
.gradient-backdrop.is-ready { opacity: .8; }
:root[data-theme="dark"] .gradient-backdrop.is-ready { opacity: .85; }
/* the page background would paint over it: let it show through while it runs */
body.has-grad { background: transparent; }
body.has-grad #home, body.has-grad .login { background: transparent; }

/* ================= translucent top bar: frosted glass over the page and the gradient ================= */
.bar { background: rgba(245, 245, 250, .46); border-bottom-color: rgba(255, 255, 255, .45);
  backdrop-filter: blur(22px) saturate(180%); -webkit-backdrop-filter: blur(22px) saturate(180%);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .35) inset, 0 8px 24px rgba(20, 16, 50, .06); }
:root[data-theme="dark"] .bar { background: rgba(16, 15, 24, .42); border-bottom-color: rgba(255, 255, 255, .07);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 8px 24px rgba(0, 0, 0, .2); }
/* not-started tiles stay quieter than started ones, but keep enough frosted glass to read over the gradient */
#grid .tile.fresh { background: rgba(255, 255, 255, .8); }
:root[data-theme="dark"] #grid .tile.fresh { background: rgba(22, 21, 30, .86); }
#grid .tile.fresh b, #grid .tile.fresh span { color: color-mix(in srgb, var(--text) 62%, transparent); }

/* ================= light mode over the gradient: text that sits straight on the background ================= */
/* greys that read fine on a flat page vanish on the coloured waves: use a dark ink with a soft light halo */
:root[data-theme="light"] body.has-grad .sub,
:root[data-theme="light"] body.has-grad .section-title,
:root[data-theme="light"] body.has-grad .marked h3 { color: #2b2840; }
:root[data-theme="light"] body.has-grad .hello .sub, :root[data-theme="light"] body.has-grad #summary,
:root[data-theme="light"] body.has-grad .section-title, :root[data-theme="light"] body.has-grad .marked h3,
:root[data-theme="light"] body.has-grad .back, :root[data-theme="light"] body.has-grad .note {
  text-shadow: 0 0 14px rgba(255, 255, 255, .75), 0 1px 1px rgba(255, 255, 255, .5); font-weight: 600; }
:root[data-theme="light"] body.has-grad .hello h1 { text-shadow: 0 0 22px rgba(255, 255, 255, .6); }
:root[data-theme="light"] body.has-grad #markedCount { color: inherit; }

/* ================= glass only where it means something ================= */
/* Frosted glass is kept for things that float: the top bar, the three home stat cards, the sign-in card and
   pop-up menus. Every other card is a calm, near-solid surface, so the gradient shows in the gaps between
   sections instead of through every tile. */
:root { --glass-hero: rgba(255, 255, 255, .62); --glass-tile: rgba(255, 255, 255, .93); }
:root[data-theme="dark"] { --glass-hero: rgba(30, 30, 38, .52); --glass-tile: rgba(27, 26, 34, .93); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --glass-hero: rgba(30, 30, 38, .52); --glass-tile: rgba(27, 26, 34, .93); } }
.tile, .marked-row, .chapter, .seg, .chart, .rb-card, .ab-card, .ab-faq details, .ab-new, .lb-row, .hist-row, .lb-empty,
.stats .stat, .ab-hero, .ab-dev { backdrop-filter: none; -webkit-backdrop-filter: none; }
#stats .stat { backdrop-filter: blur(18px) saturate(160%); -webkit-backdrop-filter: blur(18px) saturate(160%); }
/* home stat cards open Your stats */
#stats .stat { cursor: pointer; transition: transform .18s, box-shadow .18s, border-color .18s; }
#stats .stat:hover { transform: translateY(-2px); border-color: rgba(var(--lav-rgb), .45); }
#stats .stat:focus-visible { outline: 2px solid var(--lav); outline-offset: 2px; }
@media (hover: none) { #stats .stat:hover { transform: none; } }

/* ================= greeting: warm, on-theme ================= */
/* "Good" in the text colour, the time of day in Fraunces italic with an accent-to-peach gradient */
.hello #greet { font-weight: 500; color: var(--text); text-shadow: none !important; }
.hello #greet em { font-style: italic; font-weight: 500; padding-right: .08em;
  background: linear-gradient(100deg, var(--accent) 10%, color-mix(in srgb, var(--accent) 55%, #f29a6b) 95%);
  -webkit-background-clip: text; background-clip: text; color: transparent; }
:root[data-theme="dark"] .hello #greet em { background-image: linear-gradient(100deg, var(--accent) 10%, color-mix(in srgb, var(--accent) 50%, #ffc29a) 95%); }

/* ================= motion ================= */
:root { --ease-out: cubic-bezier(.2, .8, .2, 1); --ease-spring: cubic-bezier(.34, 1.4, .64, 1); }
@keyframes m-drop { from { opacity: 0; transform: translateY(-8px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes m-pop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
@keyframes m-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes m-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes m-slide-l { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }
@keyframes m-bump { 0% { transform: scale(1); } 40% { transform: scale(1.12); } 100% { transform: scale(1); } }

/* pop-out menus: drop down on open; fold back up on close where the browser supports it (iOS 17.4+, Chrome 117+) */
.accent-pop, .tbpos-pop { transform-origin: top right; transition: opacity .16s ease, transform .18s var(--ease-out), display .18s allow-discrete; }
.tbpos-pop { transform-origin: center; }
.accent-pop:not([hidden]), .tbpos-pop:not([hidden]) { animation: m-drop .2s var(--ease-out); }
.accent-pop[hidden], .tbpos-pop[hidden] { opacity: 0; transform: translateY(-6px) scale(.97); }

/* dialogs: backdrop fades, card rises; reverse on close */
.modal { animation: m-fade .18s ease; }
.modal .modal-card { animation: m-rise .22s var(--ease-out); }
.modal.closing { animation: m-fade .16s ease reverse forwards; pointer-events: none; }
.modal.closing .modal-card { animation: m-pop .16s ease reverse forwards; }

/* segmented toggles: a pill slides to the chosen option (motion.js) */
.seg { position: relative; }
.seg > button { position: relative; z-index: 1; transition: color .2s ease, background-color .2s ease; }
.seg-pill { position: absolute; top: 0; left: 0; z-index: 0; border-radius: 7px; background: var(--ink); pointer-events: none;
  transition: transform .32s var(--ease-out), width .32s var(--ease-out), height .32s var(--ease-out), opacity .2s; }
.seg.has-pill > button.cur { background: transparent; }
.seg.has-pill > button.cur { color: var(--on-ink); }

/* switches and on/off buttons */
.rb-switch .sw, .rb-switch .sw::after { transition-duration: .26s; transition-timing-function: var(--ease-spring); }
.mark-btn { transition: background-color .2s ease, border-color .2s ease, color .2s ease; }
.mark-btn.on svg { animation: m-bump .32s var(--ease-spring); }
.tool { transition: color .2s ease, background-color .2s ease; }
.tool.on svg { animation: m-bump .3s var(--ease-spring); }
.swatch { transition: transform .2s var(--ease-spring), box-shadow .2s ease; }
.swatch.cur { transform: scale(1.08); }
.ch-dlbtn.done svg { animation: m-bump .34s var(--ease-spring); }
/* theme switch: every colour cross-fades instead of flipping */
html.theme-fade, html.theme-fade *, html.theme-fade *::before, html.theme-fade *::after {
  transition: background-color .4s ease, color .4s ease, border-color .4s ease, fill .4s ease, box-shadow .4s ease !important; }

/* things that used to appear abruptly */
main.wrap:not([hidden]) { animation: m-rise .32s var(--ease-out); }
.quiz:not([hidden]) { animation: m-fade .22s ease; }
#grid:not([hidden]), #chapters:not([hidden]) { animation: m-fade .25s ease; }
.chapter.opening .ch-body { animation: m-drop .24s var(--ease-out); transform-origin: top; }
.quiz.answered #result, .quiz.answered .epane { animation: m-rise .3s var(--ease-out); }
.link-note:not([hidden]), .offline-bar, #marked:not([hidden]), #rbList:not([hidden]) { animation: m-fade .3s ease; }
.ab-upd:not([hidden]) .upd { animation: m-rise .35s var(--ease-out) both; }
.ab-upd .upd:nth-child(2) { animation-delay: .04s; } .ab-upd .upd:nth-child(3) { animation-delay: .08s; }
.ab-upd .upd:nth-child(4) { animation-delay: .12s; } .ab-upd .upd:nth-child(5) { animation-delay: .16s; }
.new-dot:not([hidden]) { animation: m-pop .3s var(--ease-spring); }
.login-card { animation: m-rise .4s var(--ease-out); }
.rb-full-row, .lb-row, .hist-row { animation: m-fade .25s ease both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-delay: 0s !important; transition-duration: .001ms !important; }
}
/* settings: small on/off switch at the end of a row */
.set-row .mini-sw { flex: none; position: relative; width: 32px; height: 19px; margin-left: auto; border-radius: 999px; background: var(--line); transition: background .26s ease; }
.set-row .mini-sw::after { content: ""; position: absolute; top: 2.5px; left: 2.5px; width: 14px; height: 14px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .26s var(--ease-spring, ease); }
.set-row.on .mini-sw { background: var(--accent); }
.set-row.on .mini-sw::after { transform: translateX(13px); }
#motionBgRow span { white-space: nowrap; }
/* random block tiles: a download button in the bottom-right corner */
.rb-tile .tile-dl { position: absolute; right: 8px; bottom: 8px; width: 26px; height: 26px; margin: 0; z-index: 2; }
.rb-tile .tile-dl svg { width: 13px; height: 13px; }
.rb-tile .tile-dl span { font-size: 8px; }
.rb-tile:has(.tile-dl) .bar-in { margin-right: 32px; }
.rb-tile.dl::after { content: none; }   /* the button shows the downloaded state */

/* ---- lab tables rebuilt from the scans ---- */
.stem .stem-tbl { overflow-x: auto; margin: 4px 0 16px; }
.stem .stem-tbl table { border-collapse: collapse; font-size: 15.5px; line-height: 1.45; min-width: min(100%, 420px); }
.stem .stem-tbl td { padding: 5px 14px 5px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.stem .stem-tbl td:first-child { padding-left: 2px; color: var(--muted); }
.stem .stem-tbl td + td { font-variant-numeric: tabular-nums; }
.stem .stem-tbl tr.head td { font-weight: 600; color: var(--ink, inherit); border-bottom-width: 2px; }
.stem .stem-tbl tr.tsec td { padding-top: 12px; font-weight: 600; color: inherit; border-bottom: 0; }
.stem .stem-img { max-height: 70vh; width: auto; object-fit: contain; }
.stem .stem-tbl tr.in1 td:first-child { padding-left: 18px; }
.stem .stem-tbl tr.in2 td:first-child { padding-left: 34px; }
