:root {
  --bg: #000; --card: #111; --panel: rgba(20,20,20,.9);
  --line: rgba(255,255,255,.06); --line2: rgba(255,255,255,.1);
  --t1: #fff; --t2: rgba(255,255,255,.5); --t3: rgba(255,255,255,.4);
  --ok: #4ade80; --bad: #f87171;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--t1); }
body { font: 400 16px/1.6 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
::-webkit-scrollbar { width: 8px; height: 8px; } ::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 8px; } ::-webkit-scrollbar-track { background: transparent; }
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.12) transparent; }
sub, sup { font-size: .72em; line-height: 0; }

/* layout */
.top { position: sticky; top: 0; z-index: 20; background: rgba(0,0,0,.82); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1100px; margin: 0 auto; padding: 0 16px; height: 56px; display: flex; align-items: center; gap: 24px; }
.brand { font-weight: 800; letter-spacing: -.02em; }
.nav { display: flex; gap: 20px; flex: 1; overflow-x: auto; }
.nav a, .tabs a { color: rgba(255,255,255,.45); font-weight: 600; font-size: 14px; padding: 17px 0 15px; border-bottom: 2px solid transparent; white-space: nowrap; }
.nav a.on, .tabs a.on { color: #fff; border-color: #fff; }
.sync { font-size: 12px; color: var(--t3); display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.sync i { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,.3); }
.sync.ok i { background: var(--ok); } .sync.bad i { background: var(--bad); } .sync.busy i { background: #fff; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 96px; }
.narrow { max-width: 760px; margin: 0 auto; }

/* type */
.label, .kicker { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--t3); font-weight: 600; }
h1 { font-size: clamp(32px, 6vw, 56px); line-height: 1.05; font-weight: 800; letter-spacing: -.035em; margin: 6px 0 10px; }
h2 { font-size: 24px; font-weight: 800; letter-spacing: -.02em; margin: 40px 0 12px; }
h3 { font-size: 18px; font-weight: 700; letter-spacing: -.01em; margin: 0 0 8px; }
.muted { color: var(--t2); } .small { font-size: 13px; }
p { margin: 0 0 12px; }
.prose { color: rgba(255,255,255,.85); } .prose b { color: #fff; } .prose ul, .prose ol { padding-left: 20px; margin: 0 0 12px; } .prose li { margin: 4px 0; }
.formula-big { font-size: 18px; font-weight: 700; text-align: center; padding: 14px; background: rgba(255,255,255,.04); border-radius: 12px; color: #fff; }

/* components */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 999px; padding: 10px 20px; font-weight: 600; font-size: 14px; white-space: nowrap; cursor: pointer; background: transparent; transition: background .15s, opacity .15s; }
.btn-primary { background: #fff; color: #000; } .btn-primary:hover { background: rgba(255,255,255,.85); }
.btn-secondary { background: rgba(255,255,255,.1); } .btn-secondary:hover { background: rgba(255,255,255,.16); }
.btn-ghost:hover { background: rgba(255,255,255,.06); }
.btn:disabled { opacity: .35; cursor: default; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.inp { width: 100%; background: rgba(255,255,255,.07); border: 1px solid transparent; border-radius: 8px; padding: 12px 14px; color: #fff; font: inherit; outline: none; }
.inp:focus { border-color: rgba(255,255,255,.3); }
textarea.inp { min-height: 220px; resize: vertical; line-height: 1.5; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: rgba(255,255,255,.08); color: rgba(255,255,255,.8); white-space: nowrap; }
.chip.on { background: #fff; color: #000; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }
button.chip { border: 0; cursor: pointer; }
.seg { display: inline-flex; background: rgba(255,255,255,.1); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: transparent; border-radius: 999px; padding: 5px 12px; font-size: 12px; font-weight: 600; cursor: pointer; color: rgba(255,255,255,.7); white-space: nowrap; }
.seg button.on { background: #fff; color: #000; }
.progress { height: 1px; background: rgba(255,255,255,.12); position: relative; }
.progress > i { position: absolute; inset: 0 auto 0 0; background: #fff; }
.tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--line); margin: 28px 0 24px; overflow-x: auto; }
.tabs a { padding: 12px 0; }

/* home */
.hero-home { padding: 24px 0 8px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 24px 0; }
.stat b { display: block; font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 20px 16px; }
.tile .art { aspect-ratio: 1; border-radius: 8px; background: linear-gradient(145deg, #1a1a1a, #0b0b0b); display: grid; place-items: center; overflow: hidden; position: relative; border: 1px solid var(--line); transition: transform .2s; }
.tile:hover .art { transform: translateY(-2px); background: linear-gradient(145deg, #222, #0e0e0e); }
.tile .art img { width: 88%; height: 88%; object-fit: contain; }
.tile .art .badge { position: absolute; top: 8px; left: 8px; }
.tile .t { font-weight: 600; margin-top: 10px; line-height: 1.3; }
.tile .m { font-size: 13px; color: var(--t2); }
.continue { display: flex; gap: 16px; align-items: center; }
.continue .art { width: 88px; height: 88px; flex: none; border-radius: 8px; background: linear-gradient(145deg, #1a1a1a, #0b0b0b); display: grid; place-items: center; }
.continue .art img { width: 90%; }

/* lesson hero */
.hero { position: relative; margin: -24px -16px 0; padding: 40px 16px 32px; overflow: hidden; }
.hero .bgimg { position: absolute; inset: -40px; background-size: 60%; background-position: center; background-repeat: no-repeat; filter: blur(48px) saturate(1.4); opacity: .55; }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(0,0,0,.2), #000 95%); }
.hero-in { position: relative; z-index: 1; max-width: 1068px; margin: 0 auto; display: flex; gap: 28px; align-items: flex-end; }
.hero .cover { width: 220px; aspect-ratio: 1; flex: none; border-radius: 12px; background: linear-gradient(145deg, #1c1c1c, #070707); display: grid; place-items: center; box-shadow: 0 30px 60px rgba(0,0,0,.6); border: 1px solid var(--line2); }
.hero .cover img { width: 90%; }
@media (max-width: 640px) { .brand, .sync.ok span { display: none; } .top-in { gap: 16px; } .nav { gap: 18px; } .grid { grid-template-columns: repeat(2, 1fr); gap: 16px 12px; } .hero-in { flex-direction: column; align-items: flex-start; } .hero .cover { width: 160px; } .stats { grid-template-columns: repeat(3, 1fr); gap: 8px; } .stat b { font-size: 22px; } .card { padding: 16px; } }

/* sections */
.sec { margin: 0 0 28px; }
.mol { padding: 12px; }
.mol .tools { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.svgbox { display: grid; place-items: center; min-height: 160px; }
.svgbox svg { width: 100%; max-width: 440px; height: auto; display: block; }
.cap { font-size: 14px; color: var(--t2); margin-top: 8px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 10px; }
tr.part { cursor: pointer; } tr.part:hover td { background: rgba(255,255,255,.04); } tr.part.on td { background: rgba(255,255,255,.1); font-weight: 600; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--t3); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line2); }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); }
tr.sum td { font-weight: 700; border-bottom: 0; }
.tablewrap { overflow-x: auto; }
.compare { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.compare .card { padding: 10px; text-align: center; }
.compare .name { font-weight: 600; font-size: 14px; } .compare .f { font-size: 13px; color: var(--t2); }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; }
.steps li { counter-increment: s; position: relative; padding: 0 0 12px 40px; color: rgba(255,255,255,.85); }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 26px; height: 26px; border-radius: 50%; background: rgba(255,255,255,.1); display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.callout { border-left: 2px solid rgba(255,255,255,.5); }
.callout .label { margin-bottom: 6px; }

/* exercises */
.qhead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.q { font-size: 18px; font-weight: 600; letter-spacing: -.01em; margin-bottom: 14px; }
.opts { display: grid; gap: 8px; }
.opt { text-align: left; background: rgba(255,255,255,.05); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; cursor: pointer; display: flex; gap: 12px; align-items: center; }
.opt:hover { background: rgba(255,255,255,.08); }
.opt.sel { border-color: rgba(255,255,255,.6); background: rgba(255,255,255,.1); }
.opt.right { border-color: var(--ok); } .opt.wrong { border-color: var(--bad); }
.opt .box { width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255,255,255,.35); flex: none; }
.opt.sel .box { background: #fff; border-color: #fff; }
.opts.molopts { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.opts.molopts .opt { flex-direction: column; }
.opt .svgbox { min-height: 100px; width: 100%; }
.feedback { margin-top: 16px; padding: 14px 16px; border-radius: 12px; background: rgba(255,255,255,.05); }
.feedback .res { font-weight: 700; margin-bottom: 4px; }
.feedback.good .res { color: var(--ok); } .feedback.bad .res { color: var(--bad); }
.hint { margin-top: 12px; color: rgba(255,255,255,.75); font-size: 14px; }
svg .hit { fill: transparent; cursor: pointer; }
svg .hit.sel { fill: rgba(255,255,255,.18); stroke: #fff; stroke-width: 2; }
.pick .svgbox svg { max-width: 520px; touch-action: manipulation; }

/* lists */
.row { display: flex; align-items: center; gap: 12px; padding: 12px 8px; border-radius: 8px; }
a.row:hover { background: rgba(255,255,255,.05); }
.row .grow { flex: 1; min-width: 0; }
.row .ttl { font-weight: 600; }
.sources a { text-decoration: underline; text-decoration-color: rgba(255,255,255,.3); text-underline-offset: 3px; }
.sources li { margin: 6px 0; }
.empty { color: var(--t2); padding: 24px 0; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--panel); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); border: 1px solid var(--line2); border-radius: 16px; padding: 12px 18px; box-shadow: 0 20px 60px rgba(0,0,0,.6); font-size: 14px; z-index: 50; max-width: calc(100% - 32px); }

/* atom diagram, orbital boxes, mechanisms */
.atomwrap { display: flex; flex-wrap: wrap; gap: 20px; align-items: center; }
.atomwrap > div:first-child { flex: 0 1 260px; display: grid; place-items: center; }
.atominfo { flex: 1 1 240px; min-width: 0; }
.orbs { display: flex; flex-wrap: wrap; gap: 12px; }
.orb { text-align: center; }
.obx { display: flex; }
.obx span { width: 30px; height: 30px; border: 1px solid rgba(255,255,255,.35); display: grid; place-items: center; font-size: 15px; font-weight: 700; letter-spacing: -2px; }
.obx span + span { border-left: 0; }
.marrow { text-align: center; color: var(--t3); font-size: 20px; margin: 4px 0; }
.card.row { display: flex; }

/* glossary */
.gl { border-bottom: 1px dotted rgba(255,255,255,.45); cursor: help; }
.gl:hover, .gl:focus { border-bottom-color: #fff; outline: none; }
.gltip { position: fixed; z-index: 60; max-width: min(320px, calc(100vw - 32px)); background: rgba(20,20,20,.92); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); border: 1px solid var(--line2); border-radius: 16px; padding: 10px 14px; font-size: 14px; line-height: 1.5; color: rgba(255,255,255,.85); box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.gltip b { display: block; color: #fff; margin-bottom: 2px; }
