/* LABDEMY — styles on the WARANYU brand tokens (waranyu.studio_brandkit/tokens.json).
   Swiss editorial × science journal. Square cards/panels, pill buttons/chips. Light + dark themes. */

/* ---------- Fonts (bundled brand files) ---------- */
@font-face { font-family: "Space Grotesk"; src: url("space-grotesk-latin-wght-normal.woff2") format("woff2"); font-weight: 300 700; font-display: swap; }
@font-face { font-family: "Inter"; src: url("inter-latin-wght-normal.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "DM Sans"; src: url("dm-sans-latin-wght-normal.woff2") format("woff2"); font-weight: 100 1000; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("ibm-plex-mono-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("ibm-plex-mono-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "IBM Plex Sans Thai"; src: url("ibm-plex-sans-thai-thai-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Sans Thai"; src: url("ibm-plex-sans-thai-thai-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "IBM Plex Sans Thai"; src: url("ibm-plex-sans-thai-thai-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "IBM Plex Sans Thai"; src: url("ibm-plex-sans-thai-thai-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }

/* ---------- Tokens ---------- */
:root {
  --ivory: #F4F1E9; --ivory-2: #EAE5D8; --charcoal: #20242C; --charcoal-2: #2B303A;
  --cobalt: #244DDB; --orange: #F26A38; --orange-ink: #C4461A; --teal: #4D9B95; --teal-ink: #23615C; --lime: #D9F36A; --muted: #5B606B;

  --bg: var(--ivory); --bg-alt: var(--ivory-2); --section: #FFFFFF; --raised: #FFFFFF; --card: var(--ivory);
  --text: var(--charcoal); --text-muted: var(--muted);
  --accent: var(--cobalt); --accent-on: #FFFFFF; --link: var(--cobalt);
  --primary-bg: var(--cobalt); --primary-bg-hover: #193CBD; --primary-fg: #FFFFFF;
  --line: rgba(32,36,44,.16); --line-strong: var(--charcoal);
  --ink-panel: var(--charcoal); --ink-panel-text: var(--ivory); --ink-panel-muted: #C3C5CA; --ink-panel-accent: var(--lime);
  --ok-bg: rgba(77,155,149,.16); --ok-fg: #23615C; --ok-border: var(--teal);
  --bad-bg: rgba(242,106,56,.15); --bad-fg: #A63D16; --bad-border: var(--orange);
  --owner-bg: rgba(36,77,219,.12); --owner-fg: #244DDB;
  --shadow-lift: 0 18px 40px rgba(32,36,44,.12);

  --particle-proton: #F26A38; --particle-neutron: #5B606B; --particle-electron: #244DDB;
  --particle-ring: rgba(32,36,44,0.38); --particle-proton-sign: #20242C; --particle-electron-sign: #FFFFFF;
  --stage-bg: var(--ivory-2);

  --font-display: "Space Grotesk", "IBM Plex Sans Thai", system-ui, sans-serif;
  --font-body: "Inter", "IBM Plex Sans Thai", system-ui, sans-serif;
  --font-ui: "DM Sans", "IBM Plex Sans Thai", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", "IBM Plex Sans Thai", ui-monospace, monospace;
  --ease: cubic-bezier(.2,.7,.1,1);
  --page: max(calc((100vw - 1368px) / 2), 5.5vw);
}

[data-theme="dark"] {
  --bg: var(--charcoal); --bg-alt: #262A33; --section: #252932; --raised: var(--charcoal-2); --card: var(--charcoal-2);
  --text: var(--ivory); --text-muted: #A9ADB5;
  --accent: var(--lime); --accent-on: var(--charcoal); --link: #B9C8FF;
  --primary-bg: var(--lime); --primary-bg-hover: #E6FA8F; --primary-fg: var(--charcoal);
  --line: rgba(244,241,233,.16); --line-strong: var(--ivory);
  --ink-panel: var(--charcoal-2); --ink-panel-text: var(--ivory); --ink-panel-muted: #A9ADB5; --ink-panel-accent: var(--lime);
  --ok-bg: rgba(77,155,149,.25); --ok-fg: #9ED6D1; --ok-border: #9ED6D1;
  --bad-bg: rgba(242,106,56,.22); --bad-fg: #FFB596; --bad-border: #FFB596;
  --owner-bg: rgba(120,150,255,.18); --owner-fg: #B9C8FF;
  --shadow-lift: 0 18px 40px rgba(0,0,0,.35);
  --particle-proton: #F26A38; --particle-neutron: #A9ADB5; --particle-electron: #B9C8FF;
  --particle-ring: rgba(244,241,233,0.42); --particle-proton-sign: #20242C; --particle-electron-sign: #20242C;
  --stage-bg: #1A1D24;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body { margin: 0; color: var(--text); background: var(--bg); font: 16px/1.6 var(--font-body); transition: background-color .25s var(--ease), color .25s var(--ease); }
button, input, select, textarea { font: inherit; color: inherit; }
button, a { touch-action: manipulation; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
h1, h2, h3, h4 { overflow-wrap: break-word; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 50; background: var(--primary-bg); color: var(--primary-fg); padding: 10px 16px; border-radius: 999px; font: 500 14px var(--font-ui); }
.skip-link:focus { top: 12px; }
.mono, .meta { font: 11px/1.5 var(--font-mono); letter-spacing: .06em; text-transform: uppercase; }
.muted { color: var(--text-muted); }
.small { font-size: 13px; }
main:focus { outline: none; }
h1:focus, h2:focus { outline: none; }

/* Thai typography: taller leading, looser tracking so tone marks never clip; natural wrapping. */
html[lang="th"] body { line-height: 1.75; }
html[lang="th"] :is(h1, h2, h3, h4, .brand-title) { letter-spacing: -0.015em !important; line-height: 1.2 !important; }
html[lang="th"] .mono, html[lang="th"] .meta { letter-spacing: .02em; }
html[lang="th"] .prose, html[lang="th"] p { line-break: auto; word-break: normal; overflow-wrap: break-word; }

/* ---------- Buttons & chips ---------- */
.btn { border: 1px solid transparent; border-radius: 999px; padding: 13px 21px; font: 500 15px/1 var(--font-ui); cursor: pointer; display: inline-flex; justify-content: center; align-items: center; gap: 12px; transition: .22s var(--ease); background: transparent; text-align: center; min-height: 44px; }
.btn.primary { background: var(--primary-bg); color: var(--primary-fg); }
.btn.primary:hover { background: var(--primary-bg-hover); transform: translateY(-1px); }
.btn.outline { border-color: var(--line); }
.btn.outline:hover { border-color: var(--text); }
.btn.small { padding: 9px 14px; font-size: 13px; min-height: 38px; gap: 8px; }
.btn.icon { width: 38px; padding: 0; }
.btn.danger, .icon-btn.danger { color: var(--bad-fg); }
.btn:disabled, .icon-btn:disabled, .step-btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.link-btn { background: none; border: 0; padding: 4px 0; color: var(--link); font: 500 13px var(--font-ui); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.icon-btn { width: 34px; height: 34px; border: 1px solid var(--line); background: var(--raised); border-radius: 999px; cursor: pointer; display: inline-grid; place-items: center; font: 500 15px var(--font-ui); flex: none; }
.icon-btn:hover:not(:disabled) { border-color: var(--text); }
.chip { border: 1px solid var(--line); border-radius: 999px; background: var(--raised); padding: 9px 14px; font: 500 13.5px/1 var(--font-ui); cursor: pointer; color: var(--text-muted); min-height: 38px; }
.chip:hover, .chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }

/* ---------- Header ---------- */
.top { position: relative; z-index: 5; min-height: 84px; padding: 0 var(--page); display: flex; align-items: center; gap: 28px; border-bottom: 1px solid var(--line); background: var(--bg); }
.brand { display: flex; align-items: center; gap: 11px; font: 700 20px/1 var(--font-display); letter-spacing: -.04em; }
.brand img { width: 36px; height: 36px; flex: none; }
.brand small { display: block; font: 9px/1.6 var(--font-mono); letter-spacing: .045em; color: var(--text-muted); margin-top: 5px; }
.site-nav { display: flex; align-items: center; gap: 30px; margin-left: auto; }
.navlink { font: 500 14px var(--font-ui); color: var(--text-muted); padding: 8px 0; border-bottom: 2px solid transparent; }
.navlink:hover { color: var(--text); }
.navlink.active { color: var(--text); border-bottom-color: var(--accent); }
.prefs { display: flex; align-items: center; gap: 10px; }
.lang-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.lang-switch button { border: 0; background: none; border-radius: 999px; padding: 7px 11px; font: 500 12px/1 var(--font-ui); letter-spacing: .04em; cursor: pointer; color: var(--text-muted); min-width: 40px; min-height: 32px; }
.lang-switch button[aria-pressed="true"] { background: var(--text); color: var(--bg); }
.theme-toggle { border: 1px solid var(--line); background: none; border-radius: 999px; padding: 7px 13px 7px 11px; display: inline-flex; align-items: center; gap: 7px; cursor: pointer; font: 500 12px var(--font-ui); min-height: 40px; }
.theme-toggle:hover { border-color: var(--text); }
.theme-toggle span[aria-hidden] { font-size: 15px; line-height: 1; }
.menu { display: none; border: 1px solid var(--line); background: none; border-radius: 999px; width: 40px; height: 40px; font-size: 18px; cursor: pointer; }

/* ---------- Home ---------- */
.hero { min-height: 560px; display: grid; grid-template-columns: 1.05fr .95fr; max-width: 1368px; margin: auto; padding: 80px 0 74px; gap: 4vw; }
.hero-copy { padding: 24px 0 20px; }
.meta { display: flex; align-items: center; gap: 10px; color: var(--text-muted); flex-wrap: wrap; }
.dot { display: inline-block; width: 7px; height: 7px; background: var(--teal); border-radius: 50%; }
.hero h1 { font: 600 clamp(48px, 6.2vw, 86px)/.98 var(--font-display); letter-spacing: -.055em; margin: 33px 0 22px; }
.hero h1 em, .section-title h2 em { font-style: normal; color: var(--link); }
.hero-copy > p { max-width: 485px; color: var(--text-muted); font-size: 18px; line-height: 1.65; margin: 0; }
.hero-actions { display: flex; align-items: center; gap: 22px; margin-top: 34px; flex-wrap: wrap; }
.micro { font: 11px var(--font-mono); color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.hero-figure { background: var(--bg-alt); position: relative; min-height: 406px; display: grid; place-items: center; overflow: hidden; }
.hero-figure::before { content: ""; position: absolute; inset: 0; background: url("dot-lattice.svg") center/260px; opacity: .14; }
[data-theme="dark"] .hero-figure::before { filter: invert(1); opacity: .1; }
.figure-top, .figure-caption { position: absolute; left: 22px; color: var(--text-muted); font-size: 9px; z-index: 2; }
.figure-top { top: 20px; } .figure-caption { bottom: 20px; }
.orbit { width: min(330px, 72%); aspect-ratio: 1; border-radius: 50%; position: relative; display: grid; place-items: center; }
.orbit-ring { position: absolute; border: 1px solid rgba(36,77,219,.32); border-radius: 50%; width: 100%; height: 51%; transform: rotate(-31deg); }
[data-theme="dark"] .orbit-ring { border-color: rgba(185,200,255,.4); }
.ring-b { transform: rotate(56deg); border-color: rgba(77,155,149,.5) !important; }
.nucleus { width: 72px; height: 72px; background: var(--charcoal); color: var(--lime); border-radius: 50%; display: grid; place-items: center; font: 600 36px var(--font-display); z-index: 1; }
[data-theme="dark"] .nucleus { background: var(--ivory); color: var(--charcoal); }
.electron { position: absolute; width: 13px; height: 13px; border-radius: 50%; background: var(--cobalt); top: 19%; left: 22%; }
[data-theme="dark"] .e1 { background: var(--lime); }
.e2 { background: var(--orange); top: 69%; left: 78%; } .e3 { background: var(--teal); top: 22%; left: 74%; }
.orb-label { position: absolute; font: 9px var(--font-mono); letter-spacing: .1em; color: var(--text-muted); }
.ol1 { top: 8%; left: 39%; } .ol2 { bottom: 14%; left: 17%; } .ol3 { right: 2%; top: 52%; }
.figure-number { position: absolute; bottom: -34px; right: 15px; font: 700 144px/.8 var(--font-display); letter-spacing: -.09em; color: transparent; -webkit-text-stroke: 1px var(--line); }

.subjects { padding: 76px var(--page) 112px; background: var(--section); }
.section-head { display: flex; align-items: center; gap: 13px; border-top: 2px solid var(--line-strong); padding-top: 14px; }
.section-no { font: 500 14px var(--font-mono); color: var(--link); }
.section-head .mono { font-size: 10px; }
.rule { height: 1px; background: var(--line); flex: 1; }
.subject-filters { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 30px; }
.section-title { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin: 51px 0 12px; }
.section-title h2, .manifesto h2 { font: 600 clamp(34px, 4vw, 55px)/1 var(--font-display); letter-spacing: -.05em; margin: 0; }
.section-title p { color: var(--text-muted); margin: 0; }
.module-group { margin-top: 40px; }
.module-head { display: flex; align-items: baseline; gap: 14px; border-top: 1px solid var(--line); padding: 14px 0 16px; flex-wrap: wrap; }
.module-head h3 { font: 600 24px/1.1 var(--font-display); letter-spacing: -.03em; margin: 0; }
.module-head .mono:last-child { margin-left: auto; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.lesson-card { position: relative; border: 1px solid var(--line); background: var(--card); min-height: 250px; padding: 22px 23px 20px; display: flex; flex-direction: column; transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .25s; }
.lesson-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lift); border-color: var(--text); }
.card-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.subject-tag { font: 10px var(--font-mono); text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.card-icon { width: 35px; height: 35px; display: grid; place-items: center; background: var(--charcoal); color: var(--lime); font: 20px var(--font-display); flex: none; }
[data-theme="dark"] .card-icon { background: var(--ivory); color: var(--charcoal); }
.lesson-card h3 { font: 600 24px/1.1 var(--font-display); letter-spacing: -.03em; margin: 25px 0 8px; }
.lesson-card p { font-size: 14px; color: var(--text-muted); margin: 0; max-width: 340px; }
.card-progress { height: 3px; background: var(--line); margin-top: auto; position: relative; }
.card-progress span { position: absolute; inset: 0 auto 0 0; background: var(--accent); }
.card-bottom { display: flex; justify-content: space-between; gap: 10px; padding-top: 14px; font: 10px var(--font-mono); letter-spacing: .04em; color: var(--text-muted); text-transform: uppercase; }
.lesson-card > .card-progress { margin-top: 22px; }
.lesson-card h3 + p { margin-bottom: 0; }
.card-state.done { color: var(--ok-fg); }
.card-state.started { color: var(--link); }
.card-demo { position: absolute; top: -1px; right: 70px; background: var(--bad-bg); color: var(--bad-fg); font-size: 8.5px; padding: 3px 7px; border-radius: 0 0 3px 3px; }

.manifesto { background: var(--ink-panel); color: var(--ink-panel-text); padding: 47px var(--page) 42px; min-height: 380px; }
.manifesto-top { display: flex; justify-content: space-between; gap: 16px; color: var(--ink-panel-muted); font-size: 10px; border-top: 1px solid rgba(244,241,233,.25); padding-top: 14px; flex-wrap: wrap; }
.manifesto-top span:first-child, .manifesto h2 em, .manifesto-foot { color: var(--ink-panel-accent); }
.manifesto h2 em { font-style: normal; }
.manifesto-body { display: flex; align-items: end; justify-content: space-between; margin: 67px 0 61px; gap: 20px; }
.manifesto h2 { font-size: clamp(36px, 5vw, 64px); }
.manifesto-body p { color: var(--ink-panel-muted); max-width: 335px; margin: 0 0 6px; }
.manifesto-foot { font-size: 9px; }

footer { min-height: 112px; padding: 20px var(--page); display: flex; align-items: center; justify-content: space-between; gap: 16px; border-top: 1px solid var(--line); }
footer > .mono { font-size: 9px; color: var(--text-muted); }
footer > span:last-child { font-size: 12px; color: var(--text-muted); }

.page-msg { min-height: 50vh; display: grid; place-content: center; justify-items: center; gap: 16px; text-align: center; padding: 60px 20px; }
.page-msg h1 { font: 600 36px/1.1 var(--font-display); letter-spacing: -.03em; margin: 0; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px); background: var(--text); color: var(--bg); padding: 12px 18px; font: 13px var(--font-ui); opacity: 0; pointer-events: none; transition: .2s; z-index: 40; max-width: min(92vw, 560px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; border-radius: 3px; padding: 5px 8px; font: 500 10.5px/1.2 var(--font-mono); text-transform: uppercase; letter-spacing: .06em; background: var(--ok-bg); color: var(--ok-fg); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge.pending, .badge.warn { background: var(--bad-bg); color: var(--bad-fg); }
.badge.owner { background: var(--owner-bg); color: var(--owner-fg); }
.badge.verified, .badge.ok { background: var(--ok-bg); color: var(--ok-fg); }

/* ---------- Lesson page ---------- */
.lesson-page { padding: 0 var(--page) 90px; }
.preview-bar { margin: 0 calc(-1 * var(--page)); padding: 10px var(--page); background: var(--ink-panel); color: var(--ink-panel-accent); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.preview-bar .btn { background: var(--ink-panel-accent); color: var(--charcoal); }
.lesson-hero { max-width: 980px; padding: 54px 0 40px; }
.crumbs { display: flex; gap: 8px; color: var(--text-muted); flex-wrap: wrap; }
.crumbs a { color: var(--link); }
.lesson-hero h1 { font: 600 clamp(40px, 5.4vw, 76px)/.95 var(--font-display); letter-spacing: -.045em; margin: 22px 0 16px; }
.lesson-hero .sub { color: var(--text-muted); font-size: 19px; max-width: 680px; margin: 0; }
.lesson-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin-top: 24px; color: var(--text-muted); }
.lesson-grid { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 56px; border-top: 2px solid var(--line-strong); padding-top: 28px; }
.lesson-rail { position: sticky; top: 20px; align-self: start; max-height: calc(100vh - 40px); overflow: auto; }
.rail-title { color: var(--text-muted); margin: 0 0 10px; }
.rail-steps { list-style: none; padding: 0; margin: 0; }
.rail-steps a { display: grid; grid-template-columns: 28px 1fr; gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--line); font: 500 13.5px/1.35 var(--font-ui); color: var(--text-muted); }
.rail-steps a .mono { color: var(--text-muted); font-size: 10px; padding-top: 2px; }
.rail-steps li.seen a .mono { color: var(--ok-fg); }
.rail-steps a:hover, .rail-steps a[aria-current] { color: var(--text); }
.rail-steps a[aria-current] .mono { color: var(--link); }
.rail-progress { margin-top: 18px; }
.bar { height: 4px; background: var(--line); position: relative; }
.bar span { position: absolute; inset: 0 auto 0 0; background: var(--accent); transition: width .4s var(--ease); }
.rail-progress .mono { color: var(--text-muted); margin: 8px 0 0; font-size: 10px; }
.lesson-main { min-width: 0; max-width: 980px; }
.objectives { border: 1px solid var(--line); border-left: 3px solid var(--teal); padding: 18px 22px; background: var(--ok-bg); }
.objectives h2 { margin: 0 0 8px; font-size: 11px; color: var(--ok-fg); }
.objectives ul { margin: 0; padding-left: 20px; }
.objectives li { margin: 4px 0; }
.lesson-sec { padding: 46px 0 6px; scroll-margin-top: 20px; }
.sec-head { display: flex; gap: 12px; align-items: baseline; }
.sec-no { color: var(--link); font-size: 13px; }
.lesson-sec h2 { font: 600 clamp(26px, 3vw, 36px)/1.05 var(--font-display); letter-spacing: -.03em; margin: 10px 0 14px; }
.prose { max-width: 680px; font-size: 17px; line-height: 1.75; }
.prose p { margin: 0 0 14px; }
.component-slot { margin-top: 20px; }
.lesson-note { margin-top: 40px; padding: 18px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); color: var(--text-muted); font-size: 15px; }
.lesson-note b { color: var(--text); margin-right: 6px; }
.lesson-end { margin-top: 28px; }
.complete-card { background: var(--ink-panel); color: var(--ink-panel-text); padding: 26px 28px; display: grid; gap: 12px; justify-items: start; }
.complete-card .mono { color: var(--ink-panel-accent); }
.complete-card h3 { font: 600 34px/1 var(--font-display); letter-spacing: -.04em; margin: 0; }
.complete-card .btn.primary { background: var(--lime); color: var(--charcoal); }
.review-line { color: var(--bad-fg); margin-top: 26px; font-size: 10px; }
.lesson-tools { margin-top: 6px; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 40px; }
.pager-link { border: 1px solid var(--line); padding: 16px 18px; display: grid; gap: 6px; font: 600 18px/1.2 var(--font-display); letter-spacing: -.02em; background: var(--card); }
.pager-link:hover { border-color: var(--text); }
.pager-link .mono { color: var(--link); font-weight: 400; letter-spacing: .06em; }
.pager-link.next { text-align: right; }

/* ---------- Quiz ---------- */
.quiz { display: grid; gap: 16px; max-width: 760px; }
.quiz-item { border: 1px solid var(--line); background: var(--bg-alt); padding: 18px 20px 16px; margin: 0; min-width: 0; }
.quiz-item legend { float: left; width: 100%; padding: 0; margin-bottom: 12px; font: 600 19px/1.3 var(--font-display); letter-spacing: -.01em; }
.quiz-item legend .mono { display: block; color: var(--text-muted); font-weight: 400; margin-bottom: 4px; letter-spacing: .06em; font-size: 10px; }
.choices { clear: both; display: grid; gap: 8px; }
.choice { display: flex; align-items: center; gap: 12px; background: var(--raised); border: 1px solid var(--line); text-align: left; padding: 11px 13px; cursor: pointer; font: 15px/1.4 var(--font-body); min-height: 48px; }
.choice:hover { border-color: var(--link); }
.choice-mark { width: 26px; height: 26px; border: 1px solid var(--line); border-radius: 50%; display: grid; place-items: center; font: 500 11px var(--font-mono); flex: none; }
.choice.right { border-color: var(--ok-border); background: var(--ok-bg); }
.choice.right .choice-mark { background: var(--teal); color: #fff; border-color: var(--teal); }
.choice.wrong { border-color: var(--bad-border); background: var(--bad-bg); }
.choice.wrong .choice-mark { background: var(--orange); color: var(--charcoal); border-color: var(--orange); }
.feedback { font-size: 14px; margin: 12px 0 0; color: var(--text-muted); }
.feedback:empty { margin: 0; }
.feedback.good { color: var(--ok-fg); }
.feedback.bad { color: var(--bad-fg); }
.feedback b { color: inherit; }

/* ---------- Atom components ---------- */
.atom-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.atom-stage { margin: 0; border: 1px solid var(--line); background: var(--stage-bg); position: relative; }
.stage-top { display: flex; justify-content: space-between; gap: 10px; padding: 12px 14px 0; color: var(--text-muted); font-size: 9.5px; }
.stage-canvas { position: relative; height: clamp(320px, 46vw, 470px); }
.stage-canvas canvas, .stage-canvas svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.stage-canvas canvas:active { cursor: grabbing; }
.stage-loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-muted); }
.stage-legend { display: flex; gap: 16px; flex-wrap: wrap; padding: 0 14px; font: 12px var(--font-ui); color: var(--text-muted); }
.stage-legend span { display: inline-flex; align-items: center; gap: 6px; }
.stage-legend b { font-weight: 500; color: var(--text); }
[class^="dot-"] { display: inline-block; width: 11px; height: 11px; border-radius: 50%; flex: none; }
.dot-proton { background: var(--particle-proton); } .dot-neutron { background: var(--particle-neutron); } .dot-electron { background: var(--particle-electron); }
.stage-toolbar { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 14px 0; }
.stage-toolbar .zoom { display: inline-flex; gap: 6px; margin-left: auto; }
.stage-toolbar .btn { background: var(--raised); }
.stage-toolbar .btn[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.stage-help { margin: 10px 14px 0; font-size: 13px; color: var(--text-muted); }
.stage-caption { margin: 8px 14px 12px; color: var(--bad-fg); font-size: 9.5px; }
.atom-svg-ring { fill: none; stroke: var(--particle-ring); stroke-width: .35; }
.atom-svg-proton { fill: var(--particle-proton); } .atom-svg-neutron { fill: var(--particle-neutron); } .atom-svg-electron { fill: var(--particle-electron); }
.atom-svg-proton, .atom-svg-neutron, .atom-svg-electron { stroke: var(--stage-bg); stroke-width: .3; cursor: pointer; }
.atom-svg .dim { opacity: .18; }
.atom-svg .selected { stroke: var(--accent); stroke-width: .8; }
.atom-svg-sign { font: 700 2.4px var(--font-display); text-anchor: middle; pointer-events: none; }
.atom-svg-sign.on-proton { fill: var(--particle-proton-sign); } .atom-svg-sign.on-electron { fill: var(--particle-electron-sign); font-size: 2px; }
.atom-panel { display: grid; gap: 14px; }
.panel-block h4, .missions-head h4 { margin: 0 0 8px; color: var(--text-muted); font-size: 10px; font-weight: 400; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg-btn { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: var(--raised); border-radius: 999px; padding: 8px 12px; font: 500 13px/1 var(--font-ui); cursor: pointer; min-height: 38px; }
.seg-btn:hover { border-color: var(--text); }
.seg-btn[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.seg-btn.ghost { color: var(--text-muted); }
.info-card, .readout { border: 1px solid var(--line); background: var(--raised); padding: 16px; }
.info-card p { margin: 10px 0 0; font-size: 14px; }
.info-head { display: flex; align-items: center; gap: 9px; }
.info-head h4 { margin: 0; font: 600 22px/1.1 var(--font-display); letter-spacing: -.02em; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin: 12px 0 0; background: var(--line); border: 1px solid var(--line); }
.facts > div { background: var(--raised); padding: 8px 10px; }
.facts dt { font: 9.5px/1.3 var(--font-mono); text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.facts dd { margin: 3px 0 0; font: 600 18px/1.2 var(--font-display); }
.facts.grid4 { grid-template-columns: repeat(2, 1fr); }
.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 14px; }
.checklist li.done span[aria-hidden] { color: var(--ok-fg); font-weight: 700; }
.checklist .all-done { color: var(--ok-fg); font-size: 13px; margin-top: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.steppers { display: grid; gap: 8px; }
.stepper { display: grid; grid-template-columns: 1fr 40px 46px 40px; align-items: center; gap: 6px; }
.stepper-label { display: inline-flex; align-items: center; gap: 8px; font: 500 14px var(--font-ui); }
.step-btn { width: 40px; height: 40px; border-radius: 999px; border: 1px solid var(--line); background: var(--raised); font: 500 20px/1 var(--font-ui); cursor: pointer; }
.step-btn:hover:not(:disabled) { border-color: var(--text); }
.step-val { text-align: center; font: 600 22px var(--font-display); }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.readout-hero { display: flex; align-items: center; gap: 14px; }
.notation { font: 600 40px/1 var(--font-display); letter-spacing: -.02em; min-width: 72px; color: var(--link); }
.el-name { font: 600 21px/1.15 var(--font-display); letter-spacing: -.02em; }
.readout .badge { margin: 12px 0 0; line-height: 1.35; text-transform: none; letter-spacing: .01em; font-size: 12px; }
.readout .small { margin: 10px 0 0; }
.missions { margin-top: 18px; border: 1px solid var(--line); padding: 16px 18px; background: var(--raised); }
.missions-head { display: flex; justify-content: space-between; align-items: baseline; }
.missions ol { list-style: none; padding: 0; margin: 4px 0 0; display: grid; gap: 2px; }
.mission { display: grid; grid-template-columns: 34px 1fr; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.mission p { margin: 0; }
.mission-mark { font: 500 12px var(--font-mono); color: var(--text-muted); padding-top: 2px; }
.mission.current .mission-mark { color: var(--link); }
.mission.current > div > p:first-child { font-weight: 600; }
.mission.done .mission-mark { color: var(--ok-fg); font-weight: 700; }
.mission.done > div > p:first-child { color: var(--text-muted); text-decoration: line-through; text-decoration-color: var(--line); }
.mission-success { color: var(--ok-fg); font-size: 14px; margin-top: 4px !important; }
.mission-hint { font-size: 14px; color: var(--text-muted); margin-top: 4px !important; }
.mission.all-done { display: block; color: var(--ok-fg); font-weight: 600; }

/* ---------- Calculators ---------- */
.calc { border: 1px solid var(--line); background: var(--bg-alt); padding: 18px 20px; max-width: 760px; }
.calc-form { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; }
.calc-form label { display: grid; gap: 6px; font: 12px var(--font-ui); color: var(--text-muted); }
.calc-form input { width: 150px; padding: 10px; border: 1px solid var(--line); background: var(--raised); min-height: 44px; }

/* ---------- Studio ---------- */
.studio { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: calc(100vh - 84px); }
.studio-side { background: var(--ink-panel); color: var(--ink-panel-text); padding: 31px 23px; display: flex; flex-direction: column; }
.studio-side .mono { font-size: 9px; color: var(--ink-panel-accent); margin: 0; }
.studio-side h1 { font: 600 35px/.95 var(--font-display); letter-spacing: -.05em; margin: 32px 0 9px; }
.studio-side > p { font-size: 13px; color: var(--ink-panel-muted); }
.studio-tabs { display: grid; gap: 4px; margin-top: 30px; }
.tab { background: none; border: 0; border-left: 2px solid transparent; color: var(--ink-panel-muted); text-align: left; padding: 11px 10px; font: 500 14px var(--font-ui); cursor: pointer; display: flex; justify-content: space-between; min-height: 44px; }
.tab:hover { color: var(--ink-panel-text); }
.tab[aria-selected="true"] { color: var(--ink-panel-accent); border-left-color: var(--ink-panel-accent); }
.tab span { opacity: .7; margin-left: 10px; }
.workflow-note { margin-top: auto; padding-top: 28px; font: 10px/1.9 var(--font-mono); color: var(--ink-panel-accent); text-transform: uppercase; letter-spacing: .04em; }
.workflow-note small { display: block; color: var(--ink-panel-muted); font: 12px/1.5 var(--font-body); text-transform: none; letter-spacing: 0; margin-top: 6px; }
.live-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-panel-accent); margin-right: 5px; }
.studio-main { padding: 36px clamp(18px, 3vw, 40px) 60px; min-width: 0; background: var(--section); }
.panel-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.panel-head .mono, .editor-head .mono { font-size: 9.5px; color: var(--text-muted); margin: 0; }
.panel-head h2, .editor-head h2 { font: 600 36px/1.05 var(--font-display); letter-spacing: -.04em; margin: 8px 0 0; }
.count { font: 12px var(--font-mono); letter-spacing: 0; color: var(--text-muted); vertical-align: top; }
.table-wrap { overflow-x: auto; position: relative; }
.lesson-table { border-collapse: collapse; width: 100%; min-width: 640px; }
.lesson-table th { text-align: left; font: 500 10px var(--font-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); padding: 11px 8px; border-bottom: 1px solid var(--line-strong); }
.lesson-table td { padding: 12px 8px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: top; }
.lesson-table td small { display: block; color: var(--text-muted); font-size: 12.5px; font-weight: 400; margin-top: 2px; }
.warn-count { color: var(--bad-fg) !important; }
.table-actions { white-space: nowrap; text-align: right; }
.table-actions button { background: none; border: 0; color: var(--link); font: 500 13px var(--font-ui); cursor: pointer; margin-left: 10px; padding: 6px 2px; text-decoration: underline; text-underline-offset: 3px; }
.editor { display: grid; gap: 18px; }
.editor-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; flex-wrap: wrap; }
.issues { border: 1px solid var(--line); border-left: 3px solid var(--orange); padding: 12px 16px; background: var(--bg-alt); font-size: 14px; }
.issues p { margin: 0 0 6px; }
.issues ul { margin: 0; padding-left: 18px; }
.issues li.error { color: var(--bad-fg); }
.issues li.warning { color: var(--text-muted); }
.issues .ok-line { color: var(--ok-fg); margin: 0; }
.ed-group { border: 1px solid var(--line); padding: 16px 18px 18px; margin: 0; display: grid; gap: 14px; min-width: 0; }
.ed-group legend { font: 500 11px var(--font-mono); text-transform: uppercase; letter-spacing: .06em; padding: 0 6px; color: var(--text-muted); }
.field-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.field { display: grid; gap: 6px; font: 11px var(--font-mono); text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); align-content: start; }
.field small { text-transform: none; letter-spacing: 0; font: 12px/1.4 var(--font-body); color: var(--text-muted); }
.field.wide { grid-column: 1 / -1; }
.field input, .field select, .field textarea, .pair input, .pair textarea { width: 100%; padding: 10px; border: 1px solid var(--line); background: var(--raised); color: var(--text); font: 14px/1.5 var(--font-body); text-transform: none; letter-spacing: 0; resize: vertical; min-height: 42px; border-radius: 0; }
.field input[readonly] { background: var(--bg-alt); color: var(--text-muted); }
textarea.code { font: 12.5px/1.5 var(--font-mono); }
[aria-invalid="true"] { border-color: var(--bad-border) !important; }
.field-error { color: var(--bad-fg); text-transform: none; letter-spacing: 0; font: 12px var(--font-body); }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
.pair-label { grid-column: 1 / -1; font: 11px var(--font-mono); text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.pair-label small { text-transform: none; letter-spacing: 0; font: 12px var(--font-body); }
.pair-field { display: grid; grid-template-columns: 30px 1fr; align-items: start; gap: 0; }
.lang-tag { font: 500 10px/1 var(--font-mono); padding: 14px 0 0; color: var(--text-muted); }
.pair textarea[lang="th"], .pair input[lang="th"] { line-height: 1.7; }
.row-with-tool, .media-ref, .module-edit { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; }
.media-ref { grid-template-columns: 1fr 2fr auto; }
.module-edit { grid-template-columns: 200px 1fr auto; padding-top: 10px; border-top: 1px solid var(--line); }
.sec-edit { border: 1px solid var(--line); padding: 14px; display: grid; gap: 12px; background: var(--bg); }
.sec-edit.kind-interactive { border-left: 3px solid var(--cobalt); }
.sec-edit.kind-quiz { border-left: 3px solid var(--teal); }
.sec-edit-head, .choice-edit-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.sec-edit-head .mono { color: var(--text-muted); }
.sec-tools { display: inline-flex; gap: 6px; }
.quiz-edit { border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 10px; }
.choice-edit { border: 1px dashed var(--line); padding: 10px 12px; display: grid; gap: 8px; }
.choice-edit.is-answer { border-style: solid; border-color: var(--ok-border); background: var(--ok-bg); }
.radio { display: inline-flex; align-items: center; gap: 8px; font: 500 13px var(--font-ui); cursor: pointer; }
.radio input { width: 18px; height: 18px; accent-color: var(--teal); }
.add-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.add-row .mono { color: var(--text-muted); margin-right: 4px; }
.editor-actions { position: sticky; bottom: 0; z-index: 2; display: flex; justify-content: flex-end; align-items: center; gap: 8px; flex-wrap: wrap; padding: 14px 0; background: var(--section); border-top: 1px solid var(--line); }
.editor-actions .review-flag { margin-right: auto; font-size: 9px; color: var(--bad-fg); }
.upload-box { margin: 20px 0; border: 1px dashed var(--line); padding: 28px; text-align: center; font: 13px var(--font-ui); }
.upload-box small { display: block; color: var(--text-muted); margin-top: 8px; }
.media-list { display: grid; gap: 4px; }
.media-item { display: grid; grid-template-columns: 1fr auto auto; gap: 14px; align-items: center; border-bottom: 1px solid var(--line); padding: 10px 0; font-size: 14px; }
.media-item small { color: var(--text-muted); }
.media-item code { font: 12px var(--font-mono); color: var(--text-muted); }
.media-item a { color: var(--link); }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; margin: 10px 0 30px; }
.steps > div { border-top: 1px solid var(--line-strong); padding-top: 13px; }
.steps b { font: 500 14px var(--font-mono); color: var(--link); }
.steps h3 { font: 600 20px var(--font-display); margin: 10px 0 4px; }
.steps p { font-size: 14px; color: var(--text-muted); margin: 0; }
.studio-main h3 { font: 600 22px var(--font-display); letter-spacing: -.02em; }
.facts.env { grid-template-columns: repeat(4, 1fr); max-width: 760px; }
.facts.env dd { font: 500 14px var(--font-body); }

/* ---------- Responsive ---------- */
@media (max-width: 1450px) { .hero { margin: 0 5.5vw; } }
@media (max-width: 1180px) {
  .atom-layout { grid-template-columns: minmax(0, 1fr); }
  .atom-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .atom-builder .atom-panel { grid-template-columns: 1fr 1fr; }
  .field-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 980px) {
  .top { gap: 16px; }
  .site-nav { gap: 20px; }
  .theme-label { display: none; }
  .lesson-grid { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .lesson-rail { position: static; max-height: none; border: 1px solid var(--line); padding: 14px 16px; }
  .rail-steps { display: none; }
  .rail-title { display: none; }
  .rail-progress { margin-top: 0; }
  .studio { grid-template-columns: minmax(0, 1fr); }
  .studio-side { padding: 22px 20px 14px; }
  .studio-side h1 { font-size: 28px; margin: 14px 0 6px; }
  .studio-side > p { display: none; }
  .studio-tabs { display: flex; overflow-x: auto; gap: 4px; margin-top: 14px; position: relative; }
  .tab { border-left: 0; border-bottom: 2px solid transparent; white-space: nowrap; padding: 10px; }
  .tab[aria-selected="true"] { border-bottom-color: var(--ink-panel-accent); }
  .workflow-note { padding-top: 12px; }
}
@media (max-width: 900px) {
  .hero { padding-top: 50px; grid-template-columns: 1fr .86fr; gap: 25px; }
  .grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .top { min-height: 70px; padding: 10px 20px; flex-wrap: wrap; }
  .brand { font-size: 17px; }
  .brand small { font-size: 7px; }
  .prefs { margin-left: auto; gap: 6px; }
  .menu { display: inline-grid; place-items: center; }
  .site-nav { display: none; position: absolute; top: 100%; left: 0; right: 0; background: var(--bg); padding: 12px 20px 18px; border-bottom: 1px solid var(--line); flex-direction: column; align-items: stretch; gap: 4px; margin: 0; }
  .site-nav.show { display: flex; }
  .navlink { padding: 12px 0; border-bottom: 1px solid var(--line); }
  .navlink.active { border-bottom-color: var(--accent); }
  .hero { display: flex; flex-direction: column; margin: 0; padding: 44px 20px 38px; gap: 28px; }
  .hero-copy { padding: 0; }
  .hero h1 { font-size: clamp(44px, 13vw, 64px); margin: 24px 0 15px; }
  .hero-copy > p { font-size: 16px; }
  .hero-figure { min-height: 300px; }
  .subjects { padding: 52px 20px 74px; }
  .section-head { gap: 8px; } .section-head .mono { font-size: 8.5px; }
  .section-title { display: block; margin: 39px 0 10px; }
  .section-title p { margin-top: 9px; }
  .grid { grid-template-columns: 1fr; }
  .lesson-card { min-height: 220px; }
  .module-head .mono:last-child { margin-left: 0; width: 100%; }
  .manifesto { padding: 33px 20px 30px; }
  .manifesto-body { display: block; margin: 50px 0 46px; }
  .manifesto-body p { margin-top: 19px; }
  footer { padding: 22px 20px; display: grid; grid-template-columns: 1fr; gap: 10px; }
  .lesson-page { padding: 0 20px 70px; }
  .preview-bar { margin: 0 -20px; padding: 10px 20px; }
  .lesson-hero { padding: 36px 0 28px; }
  .lesson-hero .sub { font-size: 17px; }
  .prose { font-size: 16px; }
  .quiz-item { padding: 16px 14px 14px; }
  .pager { grid-template-columns: 1fr; }
  .pager-link.next { text-align: left; }
  .atom-panel, .atom-builder .atom-panel { grid-template-columns: 1fr; }
  .stage-canvas { height: 320px; }
  .stage-toolbar .zoom { margin-left: 0; }
  .facts { grid-template-columns: repeat(3, 1fr); }
  .field-grid { grid-template-columns: 1fr 1fr; }
  .pair { grid-template-columns: 1fr; }
  .media-ref, .module-edit { grid-template-columns: 1fr auto; }
  .media-ref > .pair { grid-column: 1 / -1; grid-row: 2; }
  .steps { grid-template-columns: 1fr; }
  .facts.env { grid-template-columns: 1fr 1fr; }
  .editor-actions .review-flag { width: 100%; }
  .editor-actions .btn { flex: 1 1 auto; }
  .card-demo { right: 66px; }
}
@media (max-width: 400px) {
  .brand small { display: none; }
  .lang-switch button { min-width: 36px; padding: 7px 9px; }
  .field-grid { grid-template-columns: 1fr; }
  .stepper { grid-template-columns: 1fr 40px 40px 40px; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

/* Stacked nuclide notation (mass number over atomic number) */
.nuclide { display: inline-flex; align-items: center; color: var(--link); font-family: var(--font-display); min-width: 78px; }
.nuclide .nums { display: inline-grid; text-align: right; font: 600 15px/1.05 var(--font-display); margin-right: 3px; }
.nuclide .sym { font: 600 44px/1 var(--font-display); letter-spacing: -.02em; }
.nuclide .q { font: 600 17px/1 var(--font-display); align-self: flex-start; margin-left: 2px; }
.nuclide.empty { font: 600 40px/1 var(--font-display); color: var(--text-muted); }
.module-head h3 { margin-right: 4px; }

/* ---------- 2D simulations (force lab, Pythagoras lab, budget jars, savings race) ---------- */
.sim-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.sim-layout.even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.sim-stage { margin: 0; border: 1px solid var(--line); background: var(--stage-bg); min-width: 0; }
.sim-stage > [data-scene], .sim-stage > [data-chart] { padding: 8px 14px 0; }
.sim-stage > [data-readout], .sim-stage .saver-cards, .sim-stage > .sim-status { margin: 12px 14px 0; }
.sim-svg { display: block; width: 100%; height: auto; }
.sim-svg.tall { max-height: 460px; }
.sim-svg text { font-family: var(--font-ui); fill: var(--text); }
.sim-panel { display: grid; gap: 14px; min-width: 0; }
.sim-slider { display: grid; gap: 4px; font: 500 14px var(--font-ui); }
.sim-slider-head { display: flex; justify-content: space-between; gap: 10px; }
.sim-slider output { font: 500 13px var(--font-mono); color: var(--text-muted); }
.sim-slider input[type="range"] { width: 100%; height: 32px; margin: 0; accent-color: var(--accent); cursor: pointer; touch-action: pan-y; }
.stage-slider { margin: 12px 14px 0; }
.sim-status { font-size: 14px; margin: 10px 0 0; }
.sim-status.warn, .warn-text { color: var(--bad-fg); }
.org-dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; flex: none; }
.cell-explorer .info-card p { margin: 10px 0 0; font-size: 14.5px; }
.stage-canvas > p.stage-loading { padding: 24px; text-align: center; }

.f-ground { fill: var(--bg-alt); } .f-ground.s-ice { fill: rgba(77,155,149,.18); } .f-ground.s-carpet { fill: rgba(242,106,56,.16); }
.f-line { stroke: var(--text); stroke-width: 1.5; } .f-tick { stroke: var(--text-muted); stroke-width: 1; opacity: .6; }
.f-cart rect { fill: var(--raised); stroke: var(--text); stroke-width: 1.5; } .f-cart circle { fill: var(--text); } .f-cart text { font: 600 16px var(--font-display); }
.f-arrow line { stroke-width: 4; } .f-arrow text { font: 500 15px var(--font-ui); }
.a-right line { stroke: var(--particle-electron); } .a-right polygon { fill: var(--particle-electron); }
.a-left line { stroke: var(--teal); } .a-left polygon { fill: var(--teal); }
.a-friction line { stroke: var(--orange); stroke-width: 3; } .a-friction polygon { fill: var(--orange); }
.a-net line { stroke: var(--text); stroke-width: 6; } .a-net polygon { fill: var(--text); } .a-net text, .f-zero { font: 600 16px var(--font-display) !important; }
.f-arrow text, .f-zero { fill: var(--text); }

.p-sq { stroke: var(--text); stroke-width: .05; fill: var(--raised); }
.p-tri { fill: var(--stage-bg); stroke: var(--text); stroke-width: .09; stroke-linejoin: round; }
.p-right { fill: none; stroke: var(--text); stroke-width: .05; }
.p-water { opacity: .6; } .w-a { fill: var(--teal); } .w-b { fill: var(--orange); } .w-c { fill: var(--particle-electron); }
.pythagoras-lab svg text { font-weight: 600; } .pythagoras-lab .p-side { fill: var(--text-muted); font-style: italic; }
.sim-equation { font: 600 20px/1.3 var(--font-display); margin: 0 0 10px; }
.sim-equation b { color: var(--link); }

.jar-area { padding: 16px 14px 0; }
.jars { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; text-align: center; }
.jar { display: grid; gap: 8px; justify-items: center; }
.jar b { font: 600 16px var(--font-display); }
.jar small { font-size: 12px; line-height: 1.4; }
.jar-glass { position: relative; width: min(100%, 92px); height: 170px; border: 1.5px solid var(--text); border-top: 0; background: var(--raised); overflow: hidden; }
.jar-glass span { position: absolute; left: 0; right: 0; bottom: 0; transition: height .3s var(--ease); }
.jar-needs .jar-glass span { background: var(--teal); } .jar-wants .jar-glass span { background: var(--orange); } .jar-save .jar-glass span { background: var(--particle-electron); }
.jar-glass i { position: absolute; left: 0; right: 0; border-top: 2px dashed var(--text); }
.jar-step { display: grid; grid-template-columns: 40px 44px 40px; align-items: center; gap: 4px; }
.jar-area .row-actions { margin: 12px 0 0; }
.sim-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.sim-table th, .sim-table td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.sim-table thead th { font: 500 10px var(--font-mono); letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted); border-bottom-color: var(--line-strong); }
.sim-table tr.bad td { background: var(--bad-bg); }
.result-card { margin-top: 12px; padding: 12px 14px; border-left: 3px solid var(--bad-border); background: var(--bad-bg); }
.result-card.good { border-left-color: var(--ok-border); background: var(--ok-bg); }
.result-card p { margin: 4px 0 0; font-size: 14px; }
.budget-jars .info-card h4 { margin: 0 0 8px; color: var(--text-muted); font-weight: 400; font-size: 10px; }

.g-grid { stroke: var(--line); stroke-width: 1; } .g-axis { font: 15px var(--font-mono) !important; fill: var(--text-muted) !important; }
.g-line { fill: none; stroke-width: 3; stroke-linejoin: round; } .g-paid { fill: none; stroke-width: 1.5; stroke-dasharray: 5 5; opacity: .75; }
.g-a { stroke: var(--particle-electron); } .g-b { stroke: var(--orange); } .g-dot.g-a { fill: var(--particle-electron); } .g-dot.g-b { fill: var(--orange); }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 6px 14px 0; font: 12px var(--font-ui); color: var(--text-muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg { display: inline-block; width: 18px; height: 0; border-top: 3px solid var(--text-muted); }
.lg-a { border-top-color: var(--particle-electron); } .lg-b { border-top-color: var(--orange); } .lg-dash { border-top: 2px dashed var(--text-muted); }
.saver-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.saver-card { border: 1px solid var(--line); border-top: 3px solid var(--particle-electron); background: var(--raised); padding: 12px; min-width: 0; }
.saver-card.saver-b { border-top-color: var(--orange); }
.saver-card h4 { margin: 0; font: 600 18px var(--font-display); } .saver-card p { margin: 2px 0 0; }
.saver-card .facts dd { font-size: 15px; overflow-wrap: anywhere; }
.saver-h { display: flex; align-items: center; gap: 8px; margin: 4px 0 -6px; color: var(--text-muted); font-weight: 400; font-size: 10px; }

@media (max-width: 1180px) { .sim-layout, .sim-layout.even { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) { .saver-cards { grid-template-columns: 1fr; } .jar-glass { height: 130px; } .jar-step { grid-template-columns: 36px 36px 36px; } .jar-step .step-btn { width: 36px; height: 36px; } }
.jar { align-content: start; }
.saver-card .facts { grid-template-columns: 1fr; }
.saver-card .facts > div { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.saver-card .facts dd { margin: 0; }

/* ---------- Bond lab, cell division, ramp lab, box diagonal ---------- */
.b-shell { fill: none; stroke: var(--particle-ring); stroke-width: 1; stroke-dasharray: 3 4; }
.b-core { stroke: var(--text); stroke-width: 1.5; } .b-core.c-metal { fill: var(--bg-alt); } .b-core.c-non { fill: var(--raised); }
.b-sym { font: 600 24px var(--font-display) !important; text-anchor: middle; }
.b-e { stroke: var(--stage-bg); stroke-width: 1.5; } .b-e.e-m, .b-e.e-a { fill: var(--orange); } .b-e.e-x, .b-e.e-b { fill: var(--particle-electron); }
.b-hole { fill: none; stroke: var(--text-muted); stroke-width: 1.2; stroke-dasharray: 2 2; }
.b-charge { font: 600 20px var(--font-display) !important; text-anchor: middle; fill: var(--link) !important; }
.b-key { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--text); }
.b-key.c-metal { background: var(--bg-alt); } .b-key.c-non { background: var(--raised); } .b-key.b-dotkey { background: var(--orange); border-color: transparent; width: 10px; height: 10px; }
.bond-type { margin: 4px 0 8px; font: 600 22px/1.15 var(--font-display); letter-spacing: -.02em; } .bond-type span { color: var(--link); }
.bond-lab .info-card p { margin: 0; font-size: 14.5px; }
.bond-lab .seg-btn b { font-weight: 600; }

.m-cell { fill: var(--raised); stroke: var(--text); stroke-width: 2; } .m-fill { fill: var(--raised); }
.m-nuc { fill: var(--bg-alt); stroke: var(--text-muted); stroke-width: 1.5; } .m-nuc.dashed { fill: none; stroke-dasharray: 5 6; }
.m-chr { fill: none; stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; } .m-thread { fill: none; stroke-width: 2; stroke-linecap: round; }
.k-a { stroke: var(--particle-electron); } .k-b { stroke: var(--orange); }
.m-spindle { stroke: var(--text-muted); stroke-width: 1; opacity: .7; } .m-plate { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 3 5; } .m-pole { fill: var(--teal); }
.phase-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.phase-btn { width: 100%; display: grid; grid-template-columns: 30px 1fr; gap: 6px; align-items: center; text-align: left; min-height: 40px; padding: 8px 12px; border: 1px solid var(--line); background: var(--raised); cursor: pointer; font: 500 14px var(--font-ui); }
.phase-btn:hover { border-color: var(--text); } .phase-btn[aria-current="step"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.phase-btn .mono { font-size: 10px; } .cell-division .info-card h4 { margin: 0 0 6px; font: 600 20px var(--font-display); } .cell-division .info-card p { margin: 0; font-size: 14.5px; }

.r-ramp { fill: var(--bg-alt); stroke: var(--text); stroke-width: 1.5; stroke-linejoin: round; } .r-block { fill: var(--raised); stroke: var(--text); stroke-width: 1.5; }
.r-angle { fill: none; stroke: var(--text-muted); stroke-width: 1.2; } .r-deg { font: 600 15px var(--font-display) !important; }
.a-normal line { stroke: var(--text-muted); stroke-width: 3; } .a-normal polygon { fill: var(--text-muted); }
.ramp-lab .f-arrow text { font-size: 13px; }

.lg-teal { border-top-color: var(--teal); }
.eq-floor b { color: var(--particle-electron); } .eq-space b { color: var(--orange-ink); } [data-theme="dark"] .eq-space b { color: var(--orange); }
.box-diagonal .sim-equation { margin: 2px 0 12px; } .box-diagonal .info-card .mono { margin: 0; font-size: 10px; }
.box-diagonal .stage-canvas { height: clamp(300px, 42vw, 430px); }
.stage-toolbar .btn.primary { background: var(--primary-bg); color: var(--primary-fg); border-color: transparent; }
.stage-toolbar .btn.primary:hover { background: var(--primary-bg-hover); }
.pythagoras-lab .facts dt, .box-diagonal .facts dt { text-transform: none; letter-spacing: 0; }
.f-arrow text, .f-zero { paint-order: stroke; stroke: var(--stage-bg); stroke-width: 4px; stroke-linejoin: round; }
