/* ───────────────── Design tokens ─────────────────
   Light "textbook" theme by default; dark theme via [data-theme=dark]. */
:root {
  --bg: #f6f4ef; --surface: #ffffff; --surface-2: #f2efe8; --surface-3: #e9e5db;
  --line: #e3ded2; --line-strong: #cbc4b4;
  --text: #1d2422; --muted: #5d655f; --faint: #8a918b;
  --accent: #1f6b52; --accent-strong: #165540; --accent-soft: #e5f0ea; --accent-ink: #ffffff;
  --highlight: #b9770e; --highlight-soft: #fbf1de;
  --ok: #2e7d32; --ok-bg: #e7f3e8; --bad: #b3261e; --bad-bg: #fbe9e7;
  --shadow: 0 1px 2px rgba(29, 36, 34, .05);
  --shadow-lg: 0 18px 50px rgba(29, 36, 34, .18);
  --radius: 10px; --radius-sm: 6px;
  --serif: 'Frank Ruhl Libre', Georgia, 'Times New Roman', serif;
  --sans: 'Assistant', system-ui, -apple-system, 'Segoe UI', sans-serif;
  /* element families */
  --c-alkali: #c8553d; --c-alkaline: #d98a3a; --c-transition: #c9a227; --c-post: #6a9a4b; --c-metalloid: #3a9488;
  --c-nonmetal: #3d77b0; --c-halogen: #7c62a8; --c-noble: #b55a86; --c-lanthanide: #3f9fb3; --c-actinide: #8f6440;
  --m-metal: #c98a2b; --m-metalloid: #3a9488; --m-nonmetal: #3d77b0;
  --s-solid: #6b6f69; --s-liquid: #3f8fc1; --s-gas: #c8553d; --s-unknown: #aaa69c;
  --tile-mix: 15%;
  color-scheme: light;
}
:root[data-theme=dark] {
  --bg: #111513; --surface: #181d1b; --surface-2: #1f2522; --surface-3: #283029;
  --line: #2b332f; --line-strong: #3e4842;
  --text: #e8ebe7; --muted: #a1a9a3; --faint: #737c76;
  --accent: #5db893; --accent-strong: #84cdb0; --accent-soft: #1b3128; --accent-ink: #0d1411;
  --highlight: #e2a64b; --highlight-soft: #33270f;
  --ok: #6cc070; --ok-bg: #16271a; --bad: #ef7b72; --bad-bg: #321715;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, .5);
  --tile-mix: 24%;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 17px/1.6 var(--sans); min-height: 100vh; display: flex; flex-direction: column; }
body.noscroll { overflow: hidden; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; }
h1, h2 { font-family: var(--serif); font-weight: 700; letter-spacing: -.005em; }
h1 { font-size: clamp(1.7rem, 3.4vw, 2.5rem); }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.08rem; font-weight: 700; }
p { margin: 0 0 .8em; }
.muted { color: var(--muted); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.arr { display: inline-block; }
[dir=rtl] .arr { transform: scaleX(-1); }
.eyebrow { display: block; font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-bottom: 6px; }
[dir=rtl] .eyebrow { letter-spacing: 0; }

/* ───── header ───── */
.top { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1280px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 22px; min-height: 64px; }
.brand { display: flex; align-items: center; gap: 11px; color: var(--text); }
.brand:hover { text-decoration: none; }
.logo { width: 40px; height: 40px; border: 2px solid var(--accent); border-radius: 4px; position: relative; display: grid; place-items: center; font-family: var(--serif); font-weight: 700; font-size: 18px; color: var(--accent); background: var(--accent-soft); direction: ltr; }
.logo::before { content: '1'; position: absolute; top: 1px; left: 3px; font: 600 8px/1 var(--sans); color: var(--accent); }
.brand b { display: block; font-family: var(--serif); font-size: 1.15rem; line-height: 1.1; }
.brand small { display: block; color: var(--muted); font-size: .78rem; }
.nav { display: flex; gap: 2px; margin-inline-start: auto; align-self: stretch; }
.nav a { display: flex; align-items: center; padding: 0 14px; color: var(--muted); font-weight: 600; font-size: .95rem; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.nav a:hover { color: var(--text); text-decoration: none; }
.nav a.active { color: var(--accent); border-bottom-color: var(--accent); }
.top-tools { display: flex; gap: 8px; align-items: center; }
.tool-btn { height: 36px; border: 1px solid var(--line-strong); background: var(--surface); padding: 0 12px; border-radius: var(--radius-sm); cursor: pointer; font-weight: 600; font-size: .88rem; display: inline-flex; align-items: center; gap: 6px; }
.tool-btn:hover { border-color: var(--accent); color: var(--accent); }
.tool-btn svg { width: 17px; height: 17px; }
@media (max-width: 760px) {
  .brand small { display: none; }
  .top-in { flex-wrap: wrap; gap: 0 10px; padding-top: 8px; min-height: 0; }
  .top-tools { margin-inline-start: auto; }
  .nav { order: 3; width: 100%; margin: 6px 0 0; }
  .nav a { flex: 1; justify-content: center; padding: 10px 4px; font-size: .9rem; }
}

main { flex: 1; width: 100%; max-width: 1280px; margin: 0 auto; padding: 28px 16px 64px; }
footer { border-top: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: .84rem; text-align: center; padding: 18px 16px; }

/* ───── generic components ───── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); padding: 9px 18px; border-radius: var(--radius-sm); font-weight: 700; cursor: pointer; text-align: center; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--accent-strong); border-color: var(--accent-strong); text-decoration: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:not(.ghost):not(.soft):disabled { background: var(--accent); }
.btn.ghost:disabled { background: var(--surface); color: var(--text); border-color: var(--line-strong); }
.btn.ghost { background: var(--surface); color: var(--text); border-color: var(--line-strong); }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); background: var(--surface); }
.btn.soft { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.btn.soft:hover { border-color: var(--accent); }
.btn.small { padding: 5px 12px; font-size: .86rem; }
.btn.big { padding: 12px 22px; font-size: 1.02rem; }
.btn.full { width: 100%; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; font-weight: 700; }
.link:hover { text-decoration: underline; }
.icon-btn { border: 1px solid var(--line-strong); background: var(--surface); width: 36px; height: 36px; border-radius: var(--radius-sm); cursor: pointer; display: grid; place-items: center; font-size: 1.05rem; }
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--line); font-size: .8rem; font-weight: 600; white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.pill.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.pill.streak { background: var(--highlight-soft); color: var(--highlight); border-color: transparent; }
.pill.tag { font-weight: 600; color: var(--muted); background: transparent; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--shadow); margin-bottom: 18px; }
.card > h2:first-child { font-size: 1.25rem; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; flex-wrap: wrap; background: var(--surface); }
.seg button { border: 0; background: none; padding: 6px 13px; cursor: pointer; font-size: .88rem; font-weight: 600; color: var(--muted); border-inline-end: 1px solid var(--line); }
.seg button:last-child { border-inline-end: 0; }
.seg button:hover { color: var(--text); background: var(--surface-2); }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.seg.small button { padding: 4px 10px; font-size: .82rem; }
.page { max-width: 1100px; margin: 0 auto; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.page-head h1 { margin-bottom: 4px; }
.page-head p { margin: 0; }
.empty { color: var(--muted); padding: 10px 0; }
.empty-state { text-align: center; padding: 50px 20px; }

/* ───── hero ───── */
.hero { display: grid; grid-template-columns: 1fr minmax(280px, 340px); gap: 28px; align-items: end; margin-bottom: 24px; }
.hero h1 { max-width: 760px; margin-top: 10px; }
.hero p { color: var(--muted); max-width: 680px; font-size: 1.06rem; margin: 0; }
.exam-badge { display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px; border-radius: 4px; background: var(--highlight-soft); color: var(--text); font-size: .86rem; border: 1px solid color-mix(in srgb, var(--highlight) 35%, transparent); }
.exam-badge:hover { text-decoration: none; border-color: var(--highlight); }
.exam-badge .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--highlight); }
.side-panel { display: grid; gap: 10px; }
.exam-card { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); border-inline-start: 4px solid var(--highlight); color: var(--text); box-shadow: var(--shadow); }
.exam-card:hover { text-decoration: none; border-color: var(--highlight); }
.exam-card.green { border-inline-start-color: var(--accent); }
.exam-card.green:hover { border-color: var(--accent); }
.exam-card b { display: block; font-size: 1.02rem; }
.exam-card small { color: var(--muted); font-size: .84rem; display: block; line-height: 1.35; }
.exam-ico { flex: none; width: 38px; height: 38px; border-radius: var(--radius-sm); background: var(--highlight-soft); color: var(--highlight); display: grid; place-items: center; }
.exam-card.green .exam-ico { background: var(--accent-soft); color: var(--accent); }
.exam-ico svg { width: 20px; height: 20px; }
.exam-card .arrow { margin-inline-start: auto; color: var(--muted); font-size: 1.2rem; }
@media (max-width: 860px) { .hero { grid-template-columns: 1fr; } }

/* ───── periodic table ───── */
.table-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px 16px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .lbl { font-size: .82rem; color: var(--muted); font-weight: 600; margin-inline-end: 8px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.legend .hint { color: var(--faint); font-size: .8rem; margin-inline-start: 6px; }
.lg { --c: var(--line-strong); display: inline-flex; align-items: center; gap: 7px; padding: 4px 10px 4px 8px; border: 1px solid var(--line); background: var(--surface); border-radius: 4px; cursor: pointer; font-size: .85rem; font-weight: 600; }
.lg i { width: 12px; height: 12px; border-radius: 2px; background: color-mix(in srgb, var(--c) 30%, var(--surface)); border: 1.5px solid var(--c); }
.lg small { color: var(--faint); font-size: .74rem; font-weight: 600; }
.lg:hover { border-color: var(--c); }
.lg.on { background: color-mix(in srgb, var(--c) 14%, var(--surface)); border-color: var(--c); }
.lg.on i { background: var(--c); }
.lg.part { border-color: var(--c); }
.lg.part i { background: linear-gradient(135deg, var(--c) 50%, color-mix(in srgb, var(--c) 25%, var(--surface)) 50%); }

.ptable-wrap { direction: ltr; overflow-x: auto; container-type: inline-size; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
.ptable { display: grid; grid-template-columns: 22px repeat(18, minmax(0, 1fr)); grid-template-rows: 22px repeat(7, auto) 14px auto auto; gap: 3px; min-width: 820px; direction: ltr; }
.gh, .ph { border: 0; background: none; color: var(--faint); font-size: .72rem; font-weight: 700; cursor: pointer; border-radius: 3px; padding: 0; }
.gh:hover, .ph:hover { background: var(--surface-2); color: var(--accent); }
.fblock-mark { display: grid; place-items: center; font-size: .62rem; color: var(--faint); border: 1px dashed var(--line-strong); border-radius: 3px; }
.el { --c: var(--s-unknown); position: relative; aspect-ratio: 1 / 1.08; border: 1px solid color-mix(in srgb, var(--c) 60%, var(--surface)); background: color-mix(in srgb, var(--c) var(--tile-mix), var(--surface)); border-radius: 3px; padding: 3px 4px; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; transition: opacity .15s, filter .15s, box-shadow .12s; overflow: hidden; min-width: 0; }
.el .z { position: absolute; top: 2px; left: 4px; font-size: .6rem; font-weight: 700; color: var(--muted); }
.el .sym { font-family: var(--serif); font-weight: 700; font-size: clamp(.9rem, 1.65cqi, 1.35rem); line-height: 1; color: color-mix(in srgb, var(--c) 50%, var(--text)); }
.el .nm { font-size: clamp(.46rem, .74cqi, .64rem); line-height: 1.1; margin-top: 2px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.el .ms { font-size: clamp(.42rem, .62cqi, .56rem); color: var(--muted); }
.el:hover { box-shadow: 0 0 0 2px var(--c); z-index: 3; }
.ptable:not(.explore) .el:not(.sel) { opacity: .3; filter: saturate(.2); }
.ptable:not(.explore) .el.sel { border-color: var(--c); border-width: 1.5px; }
.ptable .el.hl-dim { opacity: .12 !important; }
.ptable .el.hl-on { box-shadow: 0 0 0 2px var(--c); opacity: 1 !important; filter: none !important; }
@container (max-width: 1050px) { .el .ms { display: none; } }
@container (max-width: 900px) { .el .nm { display: none; } }

.c-alkali { --c: var(--c-alkali); } .c-alkaline { --c: var(--c-alkaline); } .c-transition { --c: var(--c-transition); } .c-post { --c: var(--c-post); }
.c-metalloid { --c: var(--c-metalloid); } .c-nonmetal { --c: var(--c-nonmetal); } .c-halogen { --c: var(--c-halogen); } .c-noble { --c: var(--c-noble); }
.c-lanthanide { --c: var(--c-lanthanide); } .c-actinide { --c: var(--c-actinide); }
.m-metal { --c: var(--m-metal); } .m-metalloid { --c: var(--m-metalloid); } .m-nonmetal { --c: var(--m-nonmetal); }
.s-solid { --c: var(--s-solid); } .s-liquid { --c: var(--s-liquid); } .s-gas { --c: var(--s-gas); } .s-unknown { --c: var(--s-unknown); }

.sel-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.sel-count { margin-inline-end: auto; color: var(--muted); }
.sel-count b { color: var(--text); font-size: 1.15rem; font-family: var(--serif); }

/* ───── builder ───── */
.builder { margin-top: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--shadow); }
.builder h2 { margin-bottom: 2px; }
.builder h3 { color: var(--muted); font-weight: 600; font-size: .95rem; margin: 0 0 14px; }
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.type-card { display: flex; align-items: center; gap: 10px; text-align: start; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; font-size: .93rem; }
.type-card:hover { border-color: var(--line-strong); background: var(--surface-2); }
.type-card.on { border-color: var(--accent); background: var(--accent-soft); }
.type-card .tick { width: 18px; height: 18px; flex: none; border-radius: 3px; border: 1.5px solid var(--line-strong); display: grid; place-items: center; background: var(--surface); }
.type-card.on .tick { background: var(--accent); border-color: var(--accent); }
.type-card.on .tick::after { content: '✓'; color: var(--accent-ink); font-size: .72rem; font-weight: 800; }
.builder-foot { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.count { display: flex; align-items: center; gap: 10px; color: var(--muted); font-weight: 600; font-size: .92rem; }
.start-wrap { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.warn { color: var(--bad); font-size: .88rem; width: 100%; text-align: end; }

/* ───── modal / element card ───── */
.modal-bg { position: fixed; inset: 0; z-index: 50; background: rgba(15, 20, 18, .5); display: grid; place-items: center; padding: 16px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { position: relative; width: min(640px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow-lg); border: 1px solid var(--line); }
.modal .close { position: absolute; top: 14px; inset-inline-end: 14px; }
.ec-top { display: flex; gap: 18px; align-items: center; margin-bottom: 18px; }
.ec-top h2 { font-size: 1.8rem; margin: 0; }
.ec-top p { margin: 0 0 8px; }
.ec-tile { flex: none; width: 104px; height: 112px; border-radius: 4px; background: color-mix(in srgb, var(--c) 18%, var(--surface)); border: 2px solid var(--c); display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; direction: ltr; }
.ec-tile .z { position: absolute; top: 6px; left: 9px; font-weight: 700; font-size: .85rem; }
.ec-tile .sym { font-family: var(--serif); font-size: 2.7rem; font-weight: 700; line-height: 1; color: color-mix(in srgb, var(--c) 50%, var(--text)); }
.ec-tile .ms { font-size: .74rem; color: var(--muted); margin-top: 4px; }
.pill.fam { background: color-mix(in srgb, var(--c) 15%, var(--surface)); border-color: var(--c); }
.ec-body { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center; }
@media (max-width: 560px) { .ec-body { grid-template-columns: 1fr; } .ec-bohr { justify-self: center; } }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 0; }
.facts div { background: var(--surface-2); border-radius: var(--radius-sm); padding: 7px 12px; }
.facts dt { font-size: .76rem; color: var(--muted); font-weight: 600; }
.facts dd { margin: 0; font-weight: 700; font-size: 1.04rem; direction: ltr; text-align: start; unicode-bidi: plaintext; }
.facts dd.p { color: var(--c-alkali); } .facts dd.n { color: var(--muted); } .facts dd.e { color: var(--c-nonmetal); }
.ec-foot { margin-top: 18px; display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

/* bohr */
.bohr { max-width: 100%; height: auto; direction: ltr; }
.bohr .orbit { fill: none; stroke: var(--line-strong); stroke-width: 1.2; }
.bohr .electron { fill: var(--c-nonmetal); }
.bohr .nucleus { fill: var(--c-alkali); }
.bohr .nuc-t { fill: #fff; font: 700 14px var(--sans); text-anchor: middle; dominant-baseline: middle; }
.bohr .nuc-t.small { font-size: 11px; font-weight: 600; opacity: .9; }
.bohr.spin .shell { transform-origin: 50% 50%; transform-box: view-box; animation: spin var(--dur) linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .bohr.spin .shell { animation: none; } }

/* ───── quiz ───── */
.quiz { max-width: 780px; margin: 0 auto; }
.quiz-top { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.quiz-top > .muted { font-size: .9rem; font-weight: 600; }
.quiz-stats { display: flex; gap: 6px; margin-inline-start: auto; }
.progress { height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; margin-bottom: 18px; }
.progress i { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.qcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow); }
.q-meta { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: .88rem; font-weight: 600; margin-bottom: 14px; gap: 8px; flex-wrap: wrap; }
.q-el { width: 64px; height: 64px; border-radius: 4px; display: grid; place-items: center; background: color-mix(in srgb, var(--c) 16%, var(--surface)); border: 2px solid var(--c); margin-bottom: 14px; }
.q-el .sym { font-family: var(--serif); font-size: 1.85rem; font-weight: 700; color: color-mix(in srgb, var(--c) 50%, var(--text)); }
.q-text { font-family: var(--serif); font-size: clamp(1.25rem, 2.6vw, 1.6rem); font-weight: 700; margin-bottom: 22px; }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 560px) { .options { grid-template-columns: 1fr; } .qcard { padding: 20px; } }
.opt { display: flex; align-items: center; gap: 12px; text-align: start; padding: 13px 15px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; font-size: 1.02rem; font-weight: 600; min-height: 56px; }
.opt:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
.opt .key { flex: none; width: 26px; height: 26px; border-radius: 4px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line); font-size: .8rem; font-weight: 700; color: var(--muted); }
.opt:disabled { cursor: default; }
.opt.right { border-color: var(--ok); background: var(--ok-bg); }
.opt.right .key { background: var(--ok); color: #fff; border-color: var(--ok); }
.opt.wrong { border-color: var(--bad); background: var(--bad-bg); }
.opt.wrong .key { background: var(--bad); color: #fff; border-color: var(--bad); }
.opt.dim { opacity: .5; }
.feedback { margin-top: 18px; padding: 13px 16px; border-radius: var(--radius-sm); border-inline-start: 4px solid; }
.feedback.ok { background: var(--ok-bg); border-color: var(--ok); }
.feedback.bad { background: var(--bad-bg); border-color: var(--bad); }
.feedback p { margin: 6px 0 4px; }
.q-next { display: flex; justify-content: space-between; align-items: center; margin-top: 18px; gap: 10px; }
.kbd-hint { font-size: .8rem; margin: 14px 0 0; color: var(--faint); }
.q-next .kbd-hint { margin: 0; }
@media (hover: none) { .kbd-hint { visibility: hidden; } }

/* ───── results / progress ───── */
.res-head { display: flex; gap: 28px; align-items: center; margin-bottom: 22px; flex-wrap: wrap; }
.ring .ring-bg { fill: none; stroke: var(--surface-3); stroke-width: 11; }
.ring .ring-fg { fill: none; stroke: var(--accent); stroke-width: 11; transition: stroke-dashoffset .8s; }
.ring .ring-t { text-anchor: middle; dominant-baseline: central; font: 700 28px var(--serif); fill: var(--text); }
.kpi .ring .ring-t { font-size: 22px; }
.res-counts { display: flex; gap: 10px; margin: 12px 0 16px; flex-wrap: wrap; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 18px; min-width: 96px; }
.stat b { display: block; font: 700 1.6rem/1.15 var(--serif); }
.stat span { color: var(--muted); font-size: .82rem; font-weight: 600; }
.stat.ok b { color: var(--ok); } .stat.bad b { color: var(--bad); }
.row-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(120px, 230px) 1fr auto; gap: 12px; align-items: center; }
.bl { font-size: .92rem; font-weight: 600; }
.bar { display: flex; height: 10px; border-radius: 2px; overflow: hidden; background: var(--surface-3); }
.bar .r { background: var(--ok); } .bar .w { background: var(--bad); opacity: .8; }
.bn { font-size: .86rem; white-space: nowrap; } .bn small { color: var(--muted); }
@media (max-width: 560px) { .bar-row { grid-template-columns: 1fr auto; } .bar { grid-column: 1 / -1; grid-row: 2; } }
.study-tip { display: inline-block; margin-top: 16px; padding: 9px 14px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--text); border-inline-start: 3px solid var(--accent); }
.study-tip span { color: var(--muted); }
.mistakes { margin: 0; padding: 0; list-style: none; counter-reset: m; }
.mistakes li { padding: 12px 0; border-bottom: 1px solid var(--line); counter-increment: m; }
.mistakes li:last-child { border: 0; }
.m-q { font-weight: 700; margin-bottom: 6px; }
.m-q::before { content: counter(m) '. '; color: var(--muted); }
.m-a { display: flex; gap: 6px 18px; flex-wrap: wrap; font-size: .92rem; align-items: center; }
.m-a .bad { color: var(--bad); } .m-a .ok { color: var(--ok); }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 4px; text-align: center; }
.kpi b { font: 700 2.3rem/1.1 var(--serif); }
.kpi span { color: var(--muted); font-size: .86rem; font-weight: 600; }
@media (max-width: 700px) { .kpis { grid-template-columns: 1fr 1fr; } }
.two-col { display: grid; grid-template-columns: 1.2fr 1fr; gap: 18px; }
.two-col .card { margin: 0; }
@media (max-width: 860px) { .two-col { grid-template-columns: 1fr; } }
.progress-page > .card, .two-col { margin-bottom: 18px; }
.missed-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 6px; margin-bottom: 14px; }
.mini-el { border: 1.5px solid var(--c); background: color-mix(in srgb, var(--c) var(--tile-mix), var(--surface)); border-radius: 3px; padding: 7px 4px; cursor: pointer; display: flex; flex-direction: column; align-items: center; }
.mini-el .sym { font: 700 1.25rem var(--serif); }
.mini-el .nm { font-size: .74rem; }
.mini-el .cnt { font-size: .7rem; color: var(--muted); }
.sessions { width: 100%; border-collapse: collapse; font-size: .92rem; }
.sessions td { padding: 8px 6px; border-bottom: 1px solid var(--line); }
.sessions tr:last-child td { border: 0; }
.mini-bar { display: block; width: 90px; height: 6px; border-radius: 2px; background: var(--bad-bg); overflow: hidden; }
.mini-bar i { display: block; height: 100%; background: var(--ok); }
@media (max-width: 560px) { .sessions td:nth-child(4) { display: none; } }

/* ───── learn ───── */
.topic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.topic { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--tc); border-radius: var(--radius); padding: 18px 20px; color: var(--text); box-shadow: var(--shadow); }
.topic:hover { text-decoration: none; border-color: var(--tc); }
.topic .num, .lesson-head .num { width: 34px; height: 34px; border-radius: 4px; display: grid; place-items: center; font: 700 1rem var(--serif); color: var(--tc); background: color-mix(in srgb, var(--tc) 12%, var(--surface)); border: 1.5px solid var(--tc); margin-bottom: 12px; flex: none; }
.topic h3 { font-family: var(--serif); font-size: 1.15rem; }
.topic p { color: var(--muted); font-size: .94rem; flex: 1; }
.topic-foot { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: .84rem; font-weight: 600; }
.feature { display: grid; grid-template-columns: auto 1fr auto; gap: 18px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-inline-start: 4px solid var(--accent); border-radius: var(--radius); padding: 18px 22px; margin-bottom: 18px; box-shadow: var(--shadow); color: var(--text); }
.feature:hover { text-decoration: none; border-color: var(--accent); }
.feature h3 { font-family: var(--serif); font-size: 1.2rem; margin: 0 0 2px; }
.feature p { margin: 0; color: var(--muted); }
.feature-tiles { display: flex; gap: 4px; direction: ltr; }
.feature-tiles span { width: 40px; height: 44px; border: 1.5px solid var(--c); background: color-mix(in srgb, var(--c) 15%, var(--surface)); border-radius: 3px; display: grid; place-items: center; font: 700 1.05rem var(--serif); color: color-mix(in srgb, var(--c) 50%, var(--text)); }
@media (max-width: 640px) { .feature { grid-template-columns: 1fr; } }
.back { display: inline-block; margin-bottom: 14px; font-weight: 600; }
.lesson-head { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 24px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.lesson-head .num { width: 52px; height: 52px; font-size: 1.5rem; }
.lesson-head p { color: var(--muted); font-size: 1.06rem; margin: 0; }
.lesson-grid { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 22px; align-items: start; }
@media (max-width: 900px) { .lesson-grid { grid-template-columns: 1fr; } .lesson-side { order: -1; } .sticky { position: static !important; } }
.lsec { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 26px; margin-bottom: 16px; box-shadow: var(--shadow); overflow-x: auto; }
.lsec h3 { font-family: var(--serif); color: var(--tc); font-size: 1.25rem; margin-top: 2px; }
.lsec h3:not(:first-child) { margin-top: 24px; }
.lsec ul, .lsec ol { padding-inline-start: 22px; margin: 0 0 .8em; }
.lsec li { margin-bottom: 5px; }
.callout { background: color-mix(in srgb, var(--tc, var(--accent)) 8%, var(--surface)); border-inline-start: 4px solid var(--tc, var(--accent)); padding: 12px 16px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin: 12px 0; }
[dir=rtl] .callout { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.formula { font-family: var(--serif); font-size: 1.3rem; font-weight: 700; text-align: center; padding: 14px; background: var(--surface-2); border-radius: var(--radius-sm); margin: 10px 0 14px; border: 1px solid var(--line); }
.formula.small { font-family: var(--sans); font-size: .98rem; padding: 8px 12px; margin: 8px 0; text-align: start; }
table.cmp { width: 100%; border-collapse: collapse; font-size: .94rem; margin: 10px 0 14px; }
.cmp th, .cmp td { padding: 9px 12px; text-align: start; border: 1px solid var(--line); vertical-align: top; }
.cmp th { background: var(--surface-2); font-weight: 700; }
.cmp td:first-child { font-weight: 700; color: var(--muted); background: color-mix(in srgb, var(--surface-2) 50%, var(--surface)); }
ol.steps { counter-reset: s; list-style: none; padding: 0 !important; display: grid; gap: 6px; }
ol.steps li { counter-increment: s; display: flex; gap: 12px; align-items: baseline; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); margin: 0; }
ol.steps li::before { content: counter(s); flex: none; width: 24px; height: 24px; border-radius: 3px; background: var(--tc); color: #fff; font-weight: 700; font-size: .8rem; display: grid; place-items: center; }
ul.timeline { list-style: none; padding: 0 !important; border-inline-start: 2px solid var(--line-strong); margin-inline-start: 6px !important; }
ul.timeline li { position: relative; padding-inline-start: 18px; margin-bottom: 10px; }
ul.timeline li::before { content: ''; position: absolute; inset-inline-start: -6px; top: 9px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--tc); }
.families { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.families > div { border: 1px solid var(--line); border-inline-start: 4px solid var(--c); background: var(--surface); border-radius: var(--radius-sm); padding: 10px 14px; }
.families b { display: block; margin-bottom: 4px; }
.families span { font-size: .9rem; color: var(--muted); }
.signs { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 12px; }
.signs span { background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; padding: 5px 12px; font-size: .92rem; }
.state-map { display: flex; justify-content: space-between; gap: 16px; margin: 10px 0 16px; }
.state-map span { flex: 1; text-align: center; padding: 9px; border-radius: var(--radius-sm); font-weight: 700; background: var(--surface); border: 1.5px solid var(--line-strong); position: relative; }
.state-map span:nth-child(1) { border-color: var(--s-solid); } .state-map span:nth-child(2) { border-color: var(--s-liquid); } .state-map span:nth-child(3) { border-color: var(--s-gas); }
.state-map span:not(:last-child)::after { content: '⇄'; position: absolute; inset-inline-end: -14px; top: 50%; transform: translateY(-50%); z-index: 2; color: var(--muted); font-size: .9rem; width: 12px; text-align: center; }
.tree { display: flex; flex-direction: column; align-items: center; gap: 12px; margin: 10px 0 18px; font-size: .92rem; }
.tbranch { display: flex; gap: 12px; justify-content: center; width: 100%; }
.tbranch > div { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.tnode { padding: 7px 14px; border-radius: var(--radius-sm); background: var(--surface); border: 1.5px solid var(--line-strong); font-weight: 700; text-align: center; }
.tnode.root { background: var(--tc); color: #fff; border-color: var(--tc); }
.tnode.leaf { font-weight: 700; border-color: color-mix(in srgb, var(--tc) 50%, var(--line)); background: color-mix(in srgb, var(--tc) 6%, var(--surface)); flex: 1; }
.tnode small { font-weight: 400; color: var(--muted); }
.pdiagrams { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 6px 0 12px; }
@media (max-width: 600px) { .pdiagrams { grid-template-columns: 1fr 1fr; } }
.pdiagrams figure { margin: 0; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px; text-align: center; }
.pdiagrams svg { width: 100%; height: auto; }
.pdiagrams figcaption { font-size: .82rem; font-weight: 700; }
.lesson-side .card h3 { margin-bottom: 10px; }
.sticky { position: sticky; top: 84px; }
.terms { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 6px; }
.terms li { font-size: .92rem; padding: 7px 10px; background: var(--surface-2); border-radius: var(--radius-sm); border-inline-start: 3px solid var(--tc); }
.lesson-side small { display: block; text-align: center; margin-top: 6px; }
.lesson-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 10px; flex-wrap: wrap; }

/* ───── widgets ───── */
.widget-slot { margin-bottom: 16px; }
.widget { background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--tc); border-radius: var(--radius); padding: 18px 22px; box-shadow: var(--shadow); }
.w-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.w-head h4 { margin: 0; color: var(--tc); font-size: .82rem; text-transform: uppercase; letter-spacing: .08em; }
[dir=rtl] .w-head h4 { letter-spacing: 0; font-size: .95rem; }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper select { font: inherit; padding: 6px 10px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); }
[dir=rtl] .stepper [data-d] { transform: scaleX(-1); }
.atom-body { display: grid; grid-template-columns: auto 1fr; gap: 20px; align-items: center; }
@media (max-width: 600px) { .atom-body { grid-template-columns: 1fr; justify-items: center; } }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 4px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: .86rem; font-weight: 600; }
.chip i { width: 12px; height: 12px; border-radius: 2px; background: var(--sw); border: 1px solid rgba(0, 0, 0, .2); }
.chip small { color: var(--faint); }
.chip:hover { border-color: var(--line-strong); }
.chip.on { border-color: var(--tc); background: color-mix(in srgb, var(--tc) 10%, var(--surface)); }
.dens-body { display: grid; grid-template-columns: 200px 1fr; gap: 22px; align-items: center; }
@media (max-width: 600px) { .dens-body { grid-template-columns: 1fr; justify-items: center; } .dens-ctrl { width: 100%; } }
.beaker { width: 200px; height: auto; }
.beaker .glass { fill: none; stroke: var(--line-strong); stroke-width: 3; }
.beaker .water { fill: color-mix(in srgb, #3f8fc1 22%, transparent); }
.beaker .surface { stroke: #3f8fc1; stroke-width: 2; }
.beaker .block { stroke: rgba(0, 0, 0, .35); stroke-width: 1.5; transition: y .5s cubic-bezier(.3, 1.4, .5, 1), width .2s, height .2s, x .2s; }
.dens-ctrl label, .sim-ctrl label { display: flex; flex-direction: column; gap: 4px; font-size: .92rem; font-weight: 600; }
input[type=range] { width: 100%; accent-color: var(--tc, var(--accent)); }
.widget input[type=range] { direction: ltr; }
.verdict { font-weight: 700; padding: 7px 12px; border-radius: var(--radius-sm); display: inline-block; }
.verdict.ok { background: var(--ok-bg); color: var(--ok); }
.verdict.down { background: var(--surface-2); color: var(--text); }
.calc { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.calc h4 { margin: 0 0 4px; }
.calc-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 560px) { .calc-row { grid-template-columns: 1fr; } }
.calc label { display: flex; flex-direction: column; gap: 4px; font-size: .84rem; color: var(--muted); font-weight: 600; }
.calc input { font: inherit; font-size: 1.05rem; padding: 8px 12px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); direction: ltr; }
.calc input:focus { border-color: var(--tc); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--tc) 18%, transparent); }
.calc input.calc-res { border-color: var(--ok); background: var(--ok-bg); font-weight: 700; }
.calc-out { margin-top: 6px; min-height: 1.6em; }
.particle-w canvas { width: 100%; height: 260px; border-radius: var(--radius-sm); border: 1px solid var(--line); display: block; direction: ltr; }
.sim-ctrl { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; margin-top: 12px; }
.sim-ctrl label { flex: 1; min-width: 200px; }
.sim-read { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; min-height: 28px; }
.pill.state-solid { background: color-mix(in srgb, var(--s-solid) 18%, var(--surface)); }
.pill.state-liquid { background: color-mix(in srgb, var(--s-liquid) 18%, var(--surface)); }
.pill.state-gas { background: color-mix(in srgb, var(--s-gas) 18%, var(--surface)); }
.meter { flex: 1; min-width: 120px; max-width: 260px; height: 6px; background: var(--surface-3); border-radius: 2px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--accent); transition: width .3s; }

/* ───── learning mode (study cards) ───── */
.study { max-width: 1100px; margin: 0 auto; }
.study-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.study-top h1 { font-size: 1.6rem; margin: 0; }
.strip { display: flex; gap: 3px; overflow-x: auto; padding: 4px 2px 10px; margin-bottom: 14px; direction: ltr; scrollbar-width: thin; }
.strip button { flex: none; width: 38px; height: 42px; border: 1px solid color-mix(in srgb, var(--c) 60%, var(--surface)); background: color-mix(in srgb, var(--c) var(--tile-mix), var(--surface)); border-radius: 3px; cursor: pointer; font: 700 .95rem var(--serif); color: color-mix(in srgb, var(--c) 50%, var(--text)); position: relative; }
.strip button.seen::after { content: ''; position: absolute; bottom: 3px; left: 50%; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--c); }
.strip button.cur { outline: 2px solid var(--text); outline-offset: 1px; }
.study-progress { height: 4px; background: var(--surface-3); border-radius: 2px; overflow: hidden; margin-bottom: 18px; }
.study-progress i { display: block; height: 100%; background: var(--accent); transition: width .25s; }
.study-card { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 22px; align-items: start; }
@media (max-width: 860px) { .study-card { grid-template-columns: 1fr; } }
.study-aside { display: flex; flex-direction: column; gap: 14px; align-items: stretch; }
.big-tile { position: relative; aspect-ratio: 1 / 1.05; border: 3px solid var(--c); background: color-mix(in srgb, var(--c) 14%, var(--surface)); border-radius: 4px; display: flex; flex-direction: column; align-items: center; justify-content: center; direction: ltr; padding: 14px; }
.big-tile .z { position: absolute; top: 12px; left: 16px; font: 700 1.5rem var(--serif); }
.big-tile .ms { position: absolute; top: 16px; right: 16px; font-size: .95rem; color: var(--muted); font-weight: 600; }
.big-tile .sym { font: 700 5.6rem/1 var(--serif); color: color-mix(in srgb, var(--c) 55%, var(--text)); }
.big-tile .nm { font: 700 1.35rem var(--serif); margin-top: 6px; text-align: center; }
.big-tile .nm2 { color: var(--muted); font-size: .95rem; }
@media (max-width: 860px) { .study-aside { display: grid; grid-template-columns: 1fr 1fr; align-items: stretch; } .big-tile { aspect-ratio: auto; min-height: 200px; } .big-tile .sym { font-size: 4rem; } }
@media (max-width: 480px) { .big-tile { min-height: 170px; } .big-tile .sym { font-size: 3rem; } .big-tile .nm { font-size: 1.1rem; } .big-tile .z { font-size: 1.1rem; } .big-tile .ms { font-size: .78rem; } }
.bohr-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; display: grid; place-items: center; }
.bohr-box .cap { font-size: .8rem; color: var(--muted); font-weight: 600; margin-top: 4px; text-align: center; }
.study-main { display: grid; gap: 12px; }
.sblock { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; box-shadow: var(--shadow); }
.sblock h3 { font-family: var(--serif); font-size: 1.12rem; margin: 0 0 8px; display: flex; align-items: center; gap: 8px; }
.sblock h3 .n { width: 24px; height: 24px; flex: none; border-radius: 3px; display: grid; place-items: center; font: 700 .8rem var(--sans); background: var(--accent-soft); color: var(--accent); }
.sblock p { margin: 0 0 6px; }
.sblock p:last-child { margin: 0; }
.sblock.fam { border-inline-start: 4px solid var(--c); }
.sblock.fact { background: var(--highlight-soft); border-color: color-mix(in srgb, var(--highlight) 30%, transparent); }
.sblock.fact h3 .n { background: var(--highlight); color: #fff; }
.calc-lines { display: grid; gap: 6px; margin: 4px 0 0; }
.calc-lines div { display: flex; justify-content: space-between; gap: 12px; padding: 7px 12px; background: var(--surface-2); border-radius: var(--radius-sm); }
.calc-lines b { font-family: var(--serif); font-size: 1.05rem; direction: ltr; unicode-bidi: isolate; }
.calc-lines span { color: var(--muted); }
.pos-wrap { display: grid; grid-template-columns: minmax(0, 240px) minmax(0, 1fr); gap: 16px; align-items: center; }
@media (max-width: 560px) { .pos-wrap { grid-template-columns: 1fr; } }
.mini-table { display: grid; grid-template-columns: repeat(18, minmax(0, 1fr)); width: 100%; max-width: 260px; gap: 1.5px; direction: ltr; }
.mini-table i { aspect-ratio: 1; background: var(--surface-3); border-radius: 1px; }
.mini-table i.empty { background: transparent; }
.mini-table i.g, .mini-table i.p { background: color-mix(in srgb, var(--accent) 22%, var(--surface-3)); }
.mini-table i.me { background: var(--c); box-shadow: 0 0 0 1.5px var(--text); }
.check-q .opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
@media (max-width: 560px) { .check-q .opts { grid-template-columns: 1fr; } }
.check-q .opt { min-height: 46px; padding: 9px 12px; font-size: .96rem; }
.study-nav { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.study-nav .muted { font-size: .85rem; }
.done-card { text-align: center; padding: 40px 20px; }
.done-card .row-btns { justify-content: center; margin-top: 14px; }
