:root {
  --bg: #05060d;
  --panel: rgba(12, 16, 32, 0.72);
  --panel-solid: #0c1020;
  --line: rgba(140, 170, 255, 0.16);
  --line-strong: rgba(140, 170, 255, 0.32);
  --text: #e3e9ff;
  --muted: #8a94b6;
  --accent: #7fd6ff;
  --accent-2: #b58cff;
  --good: #5ef2a8;
  --warn: #ffc15e;
  --bad: #ff6b76;
  --radius: 14px;
  --font: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  font: 15px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  touch-action: none; user-select: none; -webkit-user-select: none;
  overscroll-behavior: none; overflow-x: hidden; -webkit-text-size-adjust: 100%;
}
button, .btn, .chip, .kw { touch-action: manipulation; }
canvas#space { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; }
canvas#space.dragging { cursor: grabbing; }
canvas#space.pointing { cursor: pointer; }

.hidden { display: none !important; }
button { font: inherit; color: inherit; }

/* ── HUD shell ──────────────────────────────────────────────────────────── */
.hud { position: fixed; inset: 0; pointer-events: none; }
.hud > * { pointer-events: auto; }
.topbar {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) 16px 12px;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { margin: 0; font-size: 22px; letter-spacing: 0.04em; font-weight: 650; }
.brand h1 span { color: var(--accent); text-shadow: 0 0 12px var(--accent); }
.brand .sub { margin: 0; color: var(--muted); font-size: 12.5px; }
.logo {
  width: 34px; height: 34px; border-radius: 50%; position: relative;
  background: radial-gradient(circle at 50% 50%, #ff5a67 0 5px, transparent 6px);
  border: 1.5px solid rgba(127, 214, 255, 0.6);
  box-shadow: 0 0 18px rgba(127, 214, 255, 0.35), inset 0 0 10px rgba(127, 214, 255, 0.25);
}
.logo::after {
  content: ""; position: absolute; width: 6px; height: 6px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 8px #fff; top: -3px; left: 14px;
  animation: orbit 3.2s linear infinite; transform-origin: 3px 20px;
}
@keyframes orbit { to { transform: rotate(360deg); } }

.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.btn {
  border: 1px solid var(--line-strong); background: var(--panel);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  padding: 8px 14px; border-radius: 999px; cursor: pointer;
  transition: border-color .15s, background .15s, transform .1s, box-shadow .2s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent); box-shadow: 0 0 16px rgba(127, 214, 255, 0.18); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; }
.btn.icon { width: 38px; height: 38px; padding: 0; display: grid; place-items: center; font-size: 17px; }
.btn.primary { background: linear-gradient(135deg, rgba(127, 214, 255, .28), rgba(181, 140, 255, .28)); border-color: rgba(127, 214, 255, .6); }
.btn.good { background: rgba(94, 242, 168, .16); border-color: rgba(94, 242, 168, .6); }
.btn.small { padding: 5px 11px; font-size: 13px; }

.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 999px; overflow: hidden; background: var(--panel); backdrop-filter: blur(8px); }
.seg button { background: none; border: 0; padding: 8px 12px; cursor: pointer; color: var(--muted); }
.seg button.on { color: var(--text); background: rgba(127, 214, 255, .16); }

.card {
  background: var(--panel); border: 1px solid var(--line);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-radius: var(--radius); box-shadow: 0 10px 40px rgba(0, 0, 0, .45);
}

/* ── Map ────────────────────────────────────────────────────────────────── */
.motd {
  position: absolute; top: 76px; left: 50%; transform: translateX(-50%);
  padding: 6px 14px; border-radius: 999px; font-size: 13px;
  background: rgba(181, 140, 255, .14); border: 1px solid rgba(181, 140, 255, .4);
}
.node-card {
  position: absolute; right: 16px; top: 78px; width: min(340px, calc(100vw - 32px));
  padding: 16px 18px; animation: rise .22s ease-out;
}
.node-card h2 { margin: 0 0 2px; font-size: 20px; }
.node-card .chem { color: var(--muted); margin: 0 0 10px; font-size: 13.5px; }
.node-card p { margin: 8px 0; font-size: 14px; color: #c7d0ee; }
.node-card .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.node-card .close { position: absolute; top: 10px; right: 10px; }
.formula { font-family: var(--mono); font-size: 17px; letter-spacing: .02em; color: var(--accent); }
.stars { color: var(--warn); letter-spacing: 2px; font-size: 15px; }
.stars .off { color: rgba(255, 255, 255, .15); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--line-strong); font-size: 12.5px; color: var(--muted);
}
.chip b { color: var(--text); font-weight: 600; }
button.chip { background: none; cursor: pointer; font: inherit; font-size: 12.5px; }
button.chip:hover { border-color: var(--accent); color: var(--text); }
.el-swatch { width: 10px; height: 10px; border-radius: 50%; display: inline-block; box-shadow: 0 0 8px currentColor; }
.safety { border-left: 3px solid var(--warn); padding: 6px 10px; background: rgba(255, 193, 94, .08); border-radius: 0 8px 8px 0; font-size: 13.5px; }
.shell-diagram { display: block; margin: 8px auto 2px; }

.legend {
  position: absolute; left: 16px; bottom: max(14px, env(safe-area-inset-bottom));
  display: flex; gap: 14px; font-size: 12px; color: var(--muted); align-items: center; flex-wrap: wrap;
  padding: 6px 12px; border-radius: 999px; background: rgba(5, 6, 13, .5);
}
.legend .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 5px; vertical-align: middle; }
.dot.solved { background: #fff; box-shadow: 0 0 8px #fff; }
.dot.open { border: 1.5px solid var(--accent); }
.dot.locked { background: #3a4058; }
.dot.rx { background: #ff9f43; border-radius: 2px; transform: rotate(45deg); box-shadow: 0 0 8px #ff9f43; }
.spark-status .dot { background: #3a4058; }
.spark-status.up .dot { background: var(--good); box-shadow: 0 0 8px var(--good); }
.spark-status.off .dot { background: var(--warn); }

/* ── Lab ────────────────────────────────────────────────────────────────── */
.lab-top { align-items: flex-start; }
.target {
  flex: 1; min-width: 0; padding: 8px 14px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(10px);
  max-width: 460px; margin-right: auto;
}
.target .name { font-size: 18px; font-weight: 650; }
.target .meta { color: var(--muted); font-size: 13px; }
.target .formula { font-size: 15px; margin-left: 6px; }
.target .hidden-formula { font-family: var(--mono); color: var(--muted); margin-left: 6px; letter-spacing: .1em; }
.target .hintline { margin-top: 4px; font-size: 13px; color: var(--warn); }

.counts {
  position: absolute; left: 16px; top: 124px; display: flex; flex-direction: column; gap: 4px;
  font-family: var(--mono); font-size: 13px; pointer-events: none;
}
.counts div { padding: 2px 8px; border-radius: 8px; background: rgba(5, 6, 13, .55); color: var(--muted); width: max-content; }
.counts div.ok { color: var(--good); }
.counts div.over { color: var(--bad); }
.counts div.energy { color: var(--warn); margin-top: 4px; }

.tip {
  position: absolute; left: 50%; bottom: 128px; transform: translateX(-50%);
  max-width: min(520px, calc(100vw - 32px)); padding: 8px 14px; border-radius: 12px;
  background: rgba(8, 10, 22, .85); border: 1px solid var(--line-strong); font-size: 13.5px; text-align: center;
  pointer-events: none;
}
.tip.bad { border-color: rgba(255, 107, 118, .6); color: #ffd1d5; }
.tip.good { border-color: rgba(94, 242, 168, .6); color: #d6ffe9; }

.tray {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: max(12px, env(safe-area-inset-bottom));
  display: flex; gap: 10px; padding: 10px 14px; max-width: calc(100vw - 24px); overflow-x: auto;
  border-radius: 22px; background: rgba(10, 13, 28, .78); border: 1px solid var(--line);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  scrollbar-width: none;
}
.tray::-webkit-scrollbar { display: none; }
.tray.drop { border-color: var(--bad); box-shadow: 0 0 24px rgba(255, 107, 118, .25); }
.tray-label { align-self: center; color: var(--muted); font-size: 11.5px; writing-mode: vertical-rl; transform: rotate(180deg); letter-spacing: .12em; text-transform: uppercase; }
.atom-chip {
  position: relative; flex: 0 0 auto; width: 58px; height: 58px; border-radius: 50%;
  display: grid; place-items: center; cursor: grab; touch-action: none;
  background: radial-gradient(circle at 38% 32%, color-mix(in srgb, var(--c) 85%, white 15%), color-mix(in srgb, var(--c) 45%, #05060d) 70%);
  border: 1.5px solid color-mix(in srgb, var(--c) 70%, white 30%);
  box-shadow: 0 0 14px color-mix(in srgb, var(--c) 40%, transparent);
  transition: transform .12s, opacity .2s;
}
.atom-chip:hover { transform: translateY(-2px) scale(1.05); }
.atom-chip b { font-size: 19px; font-weight: 700; color: #0b0d18; text-shadow: 0 1px 0 rgba(255,255,255,.35); }
.atom-chip .n {
  position: absolute; right: -4px; top: -4px; min-width: 20px; height: 20px; border-radius: 10px; padding: 0 5px;
  display: grid; place-items: center; font-size: 11.5px; font-weight: 700;
  background: #0b0d18; border: 1px solid var(--line-strong);
}
.atom-chip .v { position: absolute; bottom: -6px; font-size: 10px; color: var(--muted); background: #0b0d18; padding: 0 5px; border-radius: 6px; border: 1px solid var(--line); }
.atom-chip.empty { opacity: .22; cursor: default; }
.atom-chip.hinted { animation: hintpulse 1.2s ease-in-out infinite; }
@keyframes hintpulse { 50% { box-shadow: 0 0 26px var(--warn); } }

/* ── Result panel: docked beside the molecule, never over it ────────────── */
.result {
  position: absolute; right: 24px; top: 50%; transform: translateY(-50%);
  width: min(400px, 38vw); max-height: calc(100vh - 150px); overflow: auto;
  padding: 20px 22px 16px; user-select: text; -webkit-user-select: text;
  background: rgba(10, 13, 28, .66);
  animation: slidein .45s cubic-bezier(.2, 1.2, .4, 1);
}
@keyframes slidein { from { opacity: 0; transform: translate(40px, -50%); } }
.result h2 { margin: 2px 0 0; font-size: 24px; text-align: center; }
.result .chem { color: var(--muted); margin: 2px 0 10px; text-align: center; }
.result p { color: #c7d0ee; margin: 10px 0; font-size: 14.5px; }
.result .row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.result .big-stars { display: block; text-align: center; font-size: 28px; letter-spacing: 6px; color: var(--warn); text-shadow: 0 0 16px rgba(255, 193, 94, .5); }
.result .big-stars .off { color: rgba(255,255,255,.12); text-shadow: none; }
.result .fold { position: absolute; top: 10px; right: 10px; width: 30px; height: 30px; font-size: 14px; }
.result.collapsed .more { display: none; }
.result .actions { justify-content: flex-end; }
body.showcase .tray, body.showcase .counts, body.showcase .tip,
body.showcase #btn-hint, body.showcase #btn-clear, body.showcase #btn-check { display: none; }

.kw {
  display: inline; font: inherit; color: #bfe9ff; background: rgba(127, 214, 255, .10);
  border: 0; border-bottom: 1.5px dotted rgba(127, 214, 255, .8); border-radius: 4px 4px 0 0;
  padding: 0 3px; margin: 0 1px; cursor: help; text-shadow: 0 0 10px rgba(127, 214, 255, .45);
  pointer-events: auto; transition: background .15s, color .15s;
}
.kw:hover, .kw:focus-visible { background: rgba(127, 214, 255, .24); color: #fff; outline: none; }
.key-ideas { margin: 10px 0 4px; padding: 10px 12px; border-radius: 12px; background: rgba(127, 214, 255, .05); border: 1px solid rgba(127, 214, 255, .18); }
.key-ideas .kw { margin: 2px 2px; padding: 3px 9px; border: 1px solid rgba(127, 214, 255, .45); border-radius: 999px; font-size: 13px; }
.kw-pop {
  position: fixed; z-index: 40; width: min(380px, calc(100vw - 32px)); max-height: 70vh; overflow: auto;
  padding: 16px 18px 12px; background: rgba(9, 13, 30, .94); border-color: rgba(127, 214, 255, .35);
  animation: rise .18s ease-out; user-select: text; -webkit-user-select: text;
}
.kw-pop h3 { margin: 0 34px 4px 0; font-size: 18px; color: #bfe9ff; }
.kw-pop p { margin: 8px 0; font-size: 14px; color: #c7d0ee; line-height: 1.5; }
.kw-pop p b { color: #fff; }
.kw-pop .kw-short { color: var(--text); font-weight: 550; }
.kw-pop .kw-where { font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 8px; }
.kw-pop .kw-where.good { color: var(--accent); }
.kw-pop .close { position: absolute; top: 10px; right: 10px; width: 30px; height: 30px; font-size: 13px; }

/* ── Hub link, search ───────────────────────────────────────────────────── */
.hub-btn { text-decoration: none; font-size: 13.5px; padding: 7px 12px; flex: 0 0 auto; }
.search { position: relative; flex: 1 1 260px; max-width: 420px; margin: 0 8px; }
.search input {
  width: 100%; padding: 9px 14px 9px 36px; border-radius: 999px; font: inherit; font-size: 14px; color: var(--text);
  background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238a94b6' stroke-width='2'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='m11 11 4 4'/%3E%3C/svg%3E") no-repeat 13px 50%;
  border: 1px solid var(--line-strong); outline: none; backdrop-filter: blur(8px);
}
.search input:focus { border-color: var(--accent); box-shadow: 0 0 16px rgba(127, 214, 255, .18); }
.search-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; max-height: 70vh; overflow: auto; padding: 6px; z-index: 25; background: rgba(9, 13, 30, .95); }
.sr { display: flex; flex-direction: column; align-items: flex-start; width: 100%; text-align: left; background: none; border: 0; border-radius: 10px; padding: 8px 10px; cursor: pointer; color: var(--text); }
.sr:hover, .sr.on { background: rgba(127, 214, 255, .12); }
.sr-main { font-weight: 600; font-size: 14px; }
.sr-sub { font-size: 12px; color: var(--muted); }
.sr-web { border-top: 1px solid var(--line); border-radius: 0 0 10px 10px; margin-top: 4px; }
.sr-status { padding: 12px; font-size: 14px; color: var(--muted); display: flex; gap: 10px; align-items: center; }
.sr-status.bad { color: #ffc2c7; }
.sr-card { padding: 10px 12px; font-size: 14px; user-select: text; -webkit-user-select: text; }
.sr-card a { color: var(--accent); }
.sr-card p { margin: 8px 0; color: #c7d0ee; font-size: 13.5px; }
.sr-why { color: #ffc2c7 !important; }
.sr-ok { color: var(--good) !important; font-size: 12.5px !important; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(127,214,255,.25); border-top-color: var(--accent); animation: spin2 .8s linear infinite; display: inline-block; }
@keyframes spin2 { to { transform: rotate(360deg); } }

/* ── Read more (research) ───────────────────────────────────────────────── */
.modal-card.wide { width: min(720px, 100%); }
.modal-card.wide h2 { padding-right: 44px; }
.rm-x { position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; font-size: 14px; }
.modal-card { position: relative; }
.rm-steps { list-style: none; padding: 0; margin: 14px 0; }
.rm-steps li { padding: 6px 0 6px 28px; position: relative; color: var(--muted); font-size: 14px; }
.rm-steps li::before { content: "○"; position: absolute; left: 4px; }
.rm-steps li.done { color: #c7d0ee; } .rm-steps li.done::before { content: "✓"; color: var(--good); }
.rm-steps li.now { color: var(--text); } .rm-steps li.now::before { content: ""; width: 12px; height: 12px; top: 9px; border-radius: 50%; border: 2px solid rgba(127,214,255,.25); border-top-color: var(--accent); animation: spin2 .8s linear infinite; }
.rm-summary p { font-size: 15px; line-height: 1.6; color: #d6ddf5; }
.cite { display: inline-block; min-width: 18px; padding: 0 4px; margin: 0 1px; border-radius: 6px; font-size: 11px; line-height: 16px; text-align: center; vertical-align: super; text-decoration: none; color: #0b0d18; background: var(--accent); }
.cite:hover { background: #fff; }
.rm-h { margin: 18px 0 6px; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.rm-sources { padding-left: 22px; margin: 0; font-size: 13.5px; }
.rm-sources li { margin: 4px 0; } .rm-sources a { color: var(--accent); }
.rm-kind { display: inline-block; width: 20px; text-align: center; opacity: .8; }
.paper { padding: 10px 12px; margin: 8px 0; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.02); }
.paper-title { color: var(--text); font-weight: 600; text-decoration: none; }
.paper-title:hover { color: var(--accent); }
.paper details { font-size: 13.5px; color: #c7d0ee; }
.paper summary { cursor: pointer; color: var(--accent); padding: 5px 0; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; }
.rm-note { margin-top: 14px; font-size: 12.5px; }

/* ── Specimen view bar (pause / 3D / angles) ────────────────────────────── */
.viewbar { position: absolute; left: 16px; bottom: max(16px, env(safe-area-inset-bottom)); width: min(330px, 34vw); padding: 10px 12px; background: rgba(9, 13, 30, .74); }
.vb-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.viewbar .btn.small { padding: 6px 10px; font-size: 13px; }
.viewbar .btn.icon.small { width: 32px; height: 32px; }
.viewbar .btn.on { background: rgba(127, 214, 255, .2); border-color: var(--accent); }
.vb-info { margin-top: 10px; font-size: 13px; user-select: text; -webkit-user-select: text; }
.vb-row { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; padding: 3px 0; border-bottom: 1px solid var(--line); }
.vb-row b { min-width: 18px; }
.vb-ang { color: var(--accent); font-weight: 700; font-family: var(--mono); }
.vb-dom { color: var(--muted); font-size: 12px; }
.vb-why { margin: 8px 0 4px; color: #c7d0ee; font-size: 12.5px; line-height: 1.45; }
.vb-hint { margin: 0; color: var(--muted); font-size: 11.5px; }

/* ── Learning window: tabs, simple terms, word breakdown ─────────────────── */
.lt-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: 6px 0 12px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.lt-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.lt-tab { background: none; border: 1px solid transparent; border-radius: 999px; padding: 7px 12px; cursor: pointer; color: var(--muted); font-size: 14px; }
.lt-tab:hover { color: var(--text); }
.lt-tab.on { color: var(--text); background: rgba(127, 214, 255, .14); border-color: rgba(127, 214, 255, .45); }
.lt-notes { font-size: 15px; line-height: 1.6; color: #d6ddf5; }
.simple-card { padding: 16px 18px; border-radius: 16px; background: linear-gradient(135deg, rgba(94, 242, 168, .08), rgba(127, 214, 255, .06)); border: 1px solid rgba(94, 242, 168, .3); }
.simple-card p { font-size: 17px; line-height: 1.65; color: #e8f3ff; margin: 8px 0; }
.speak-btn.speaking, .speak-card.speaking { background: rgba(255, 193, 94, .18); border-color: var(--warn); }
.learn-row { margin-top: 6px !important; }
.good-chip { color: var(--good) !important; border-color: rgba(94, 242, 168, .5) !important; }

.wb { margin: 8px 0 4px; }
.wb-blocks { display: flex; flex-wrap: wrap; align-items: stretch; gap: 3px; }
.wb-part { display: flex; flex-direction: column; align-items: center; min-width: 44px; padding: 5px 9px 6px; border-radius: 10px;
  background: color-mix(in srgb, var(--c) 14%, transparent); border: 1px solid color-mix(in srgb, var(--c) 55%, transparent); }
.wb-part b { font-size: 17px; color: var(--c); letter-spacing: .02em; }
.wb-part i { font-style: normal; font-size: 11.5px; color: #c7d0ee; text-align: center; max-width: 130px; line-height: 1.25; margin-top: 2px; }
.wb-glue { align-self: flex-start; padding: 6px 1px; font-size: 17px; color: var(--muted); }
.wb-sum { margin-top: 5px; font-size: 12.5px; color: var(--muted); }
.wb-row { display: grid; grid-template-columns: 130px 1fr; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.wb-word { font-weight: 650; font-size: 16px; }
.wb-legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.wb-legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; background: var(--c); }
.wcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.wcard { padding: 12px; border-radius: 14px; border: 1px solid var(--line-strong); background: rgba(255, 255, 255, .025); }
.wc-top { display: flex; gap: 10px; align-items: flex-start; }
.wc-icon { flex: 0 0 auto; width: 80px; height: 44px; display: grid; place-items: center; border-radius: 10px; background: rgba(127, 214, 255, .06); }
.wc-emoji { font-size: 26px; }
.wc-title { font-weight: 650; font-size: 15px; color: #bfe9ff; }
.wc-short { font-size: 13px; color: #c7d0ee; line-height: 1.4; margin-top: 2px; }
.wcard .kw { border-bottom: 0; text-shadow: none; }
.kw-head { display: flex; align-items: center; gap: 10px; margin-right: 34px; }
.kw-head h3 { margin: 0; }

.rx-found { margin: 14px 0 4px; }
.rxf { padding: 12px 14px; margin: 8px 0; border-radius: 14px; border: 1px solid var(--line-strong); background: rgba(255, 159, 67, .04); }
.rxf-new { border-color: rgba(94, 242, 168, .55); box-shadow: 0 0 22px rgba(94, 242, 168, .12); animation: rise .4s ease-out; }
.rxf-no { opacity: .7; background: none; }
.rxf-head { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.rxf-name { font-weight: 650; font-size: 16px; }
.rxf p { font-size: 14px; color: #c7d0ee; margin: 6px 0; }
.rxf .chem a { color: var(--accent); }

/* angle picker */
.vb-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 6px; }
.vb-chip { cursor: pointer; background: none; font: inherit; font-size: 12.5px; }
.vb-chip.on { color: var(--text); border-color: var(--accent); background: rgba(127, 214, 255, .14); }
.vb-rows { max-height: 32vh; overflow: auto; }
.vb-mol { font-size: 12px; color: var(--muted); margin: 6px 0 2px; font-family: var(--mono); }
.vb-check { color: var(--accent); width: 16px; }
#vb-angles.dim { opacity: .75; border-style: dashed; }

/* ── Focus mode: the molecule gets the whole screen ─────────────────────── */
.vb-title { display: none; }
body.focus-mode .lab-top, body.focus-mode #result, body.focus-mode #counts, body.focus-mode #tip, body.focus-mode .vb-info { display: none !important; }
body.focus-mode .viewbar {
  top: auto !important; left: 50% !important; right: auto !important; transform: translateX(-50%);
  bottom: max(14px, env(safe-area-inset-bottom)); width: max-content; max-width: calc(100vw - 24px);
  padding: 8px 10px; border-radius: 22px; background: rgba(9, 13, 30, .6);
}
body.focus-mode .vb-title { display: block; text-align: center; font-size: 13px; color: var(--muted); margin: -2px 0 6px; }
body.focus-mode .vb-title .formula { font-size: 13px; margin-left: 4px; }
body.focus-mode .vb-buttons { justify-content: center; flex-wrap: nowrap; }
body.focus-mode .viewbar .lbl { display: none; }
@media (min-width: 721px) { body.focus-mode #vb-focus .lbl { display: inline; } }
.vb-row { cursor: pointer; border-radius: 6px; }
.vb-row.on { background: rgba(127, 214, 255, .12); }

/* ── Toasts / modal ─────────────────────────────────────────────────────── */
.toasts { position: fixed; top: 84px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; z-index: 20; width: min(560px, calc(100vw - 32px)); }
.toast {
  padding: 9px 16px; border-radius: 12px; font-size: 14px; text-align: center;
  background: rgba(10, 13, 28, .9); border: 1px solid var(--line-strong);
  animation: rise .2s ease-out, fade .4s ease-in forwards; animation-delay: 0s, var(--life, 3.2s);
}
.toast.good { border-color: rgba(94, 242, 168, .6); }
.toast.bad { border-color: rgba(255, 107, 118, .6); }
.toast.warn { border-color: rgba(255, 193, 94, .6); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes fade { to { opacity: 0; transform: translateY(-6px); } }

.modal { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(2, 3, 8, .45); z-index: 30; padding: 16px; }
.modal-card { width: min(460px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 22px 22px 18px; animation: pop .3s cubic-bezier(.2, 1.4, .4, 1); user-select: text; -webkit-user-select: text; }
@keyframes pop { from { opacity: 0; transform: scale(.92); } }
.modal-card h2 { margin: 0; font-size: 24px; }
.modal-card .chem { color: var(--muted); margin: 2px 0 10px; }
.modal-card p { color: #c7d0ee; margin: 10px 0; }
.modal-card .row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.modal-card .big-stars { font-size: 30px; letter-spacing: 6px; color: var(--warn); text-shadow: 0 0 16px rgba(255, 193, 94, .5); }
.modal-card .big-stars .off { color: rgba(255,255,255,.12); text-shadow: none; }
.modal-card label { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); gap: 12px; }
.modal-card ol { padding-left: 20px; color: #c7d0ee; }
.modal-card ol li { margin: 6px 0; }

.spark-box { margin-top: 12px; padding: 10px 12px; border-radius: 12px; border: 1px solid rgba(127, 214, 255, .3); background: rgba(127, 214, 255, .06); font-size: 14px; min-height: 20px; }
.spark-box .src { display: block; margin-top: 6px; font-size: 11.5px; color: var(--muted); }
.spark-box.loading::after { content: "▍"; animation: blink .8s steps(2) infinite; color: var(--accent); }
@keyframes blink { 50% { opacity: 0; } }

.boot { position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; gap: 16px; background: var(--bg); z-index: 50; transition: opacity .5s; color: var(--muted); }
.boot.gone { opacity: 0; pointer-events: none; }
.boot-atom { width: 64px; height: 64px; position: relative; }
.boot-atom::before { content: ""; position: absolute; inset: 26px; border-radius: 50%; background: #ff5a67; box-shadow: 0 0 16px #ff5a67; }
.boot-atom i { position: absolute; inset: 0; border: 1.5px solid rgba(127, 214, 255, .5); border-radius: 50%; transform: rotateX(70deg) rotateZ(var(--r)); animation: spin 2s linear infinite; }
.boot-atom i:nth-child(1) { --r: 0deg; } .boot-atom i:nth-child(2) { --r: 60deg; } .boot-atom i:nth-child(3) { --r: 120deg; }
@keyframes spin { to { transform: rotateX(70deg) rotateZ(calc(var(--r) + 360deg)); } }

input[type=range] { accent-color: var(--accent); }
input[type=checkbox] { accent-color: var(--accent); width: 18px; height: 18px; }

/* ── Small screens ─────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .viewbar.v3on .lbl { display: none; }
  .viewbar.v3on .btn.small { padding: 6px 9px; min-width: 36px; justify-content: center; }
  .vb-buttons { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .vb-buttons::-webkit-scrollbar { display: none; }
  .wb-row { grid-template-columns: 1fr; gap: 4px; }
  .simple-card p { font-size: 16px; }
  .viewbar { top: 150px; bottom: auto; left: 12px; right: 12px; width: auto; padding: 8px 10px; }
  .vb-info { max-height: 30vh; overflow: auto; }
  .vb-rows { max-height: none; }
  .vb-why { display: none; }
  .search { order: 5; flex-basis: 100%; max-width: none; margin: 4px 0 0; }
  .hub-btn { padding: 0; width: 34px; height: 34px; justify-content: center; }
  .hub-label { display: none; }
  .brand .sub { font-size: 11.5px; }
  .kw-pop { left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); top: auto; width: auto; max-height: 55vh; }
  .brand h1 { font-size: 19px; }
  .topbar { flex-wrap: wrap; padding-left: 12px; padding-right: 12px; }
  .lab-top .top-actions { width: 100%; justify-content: space-between; }
  .lab-top .top-actions .btn { padding: 7px 11px; font-size: 13.5px; }
  .target { max-width: calc(100vw - 80px); }
  .counts { top: 168px; left: 12px; font-size: 12px; }
  .node-card { top: auto; bottom: 56px; right: 12px; left: 12px; width: auto; }
  .atom-chip { width: 50px; height: 50px; }
  .atom-chip b { font-size: 17px; }
  .tip { bottom: 120px; font-size: 13px; }
  .result {
    top: auto; bottom: max(12px, env(safe-area-inset-bottom)); left: 12px; right: 12px;
    width: auto; max-height: 50vh; transform: none; padding: 16px 16px 12px;
    animation: sheetin .45s cubic-bezier(.2, 1.2, .4, 1);
  }
  @keyframes sheetin { from { opacity: 0; transform: translateY(40px); } }
  .result h2 { font-size: 21px; }
  .legend { gap: 10px; }
}

/* Settings → read-aloud voice */
.voice-set { margin: 12px 0 4px; padding: 10px 12px 12px; border: 1px solid var(--line); border-radius: 14px; background: rgba(127, 214, 255, .04); }
.voice-set h3 { margin: 0 0 8px; font-size: 15px; }
.voice-set .seg { display: flex; width: 100%; margin-bottom: 4px; }
.voice-set .seg button { flex: 1; padding: 8px 6px; font: inherit; font-size: 13px; }
.voice-set label:last-of-type { border-bottom: 0; }
.voice-set select { max-width: 62%; min-width: 0; background: var(--panel); color: var(--text); border: 1px solid var(--line-strong); border-radius: 10px; padding: 6px 8px; font: inherit; font-size: 13px; }
.voice-set select:disabled { opacity: .5; }
.voice-set .speed { display: inline-flex; align-items: center; gap: 8px; }
.voice-set .speed input { width: 130px; accent-color: var(--accent); }
.voice-set .speed b { min-width: 42px; text-align: right; font-size: 13px; color: var(--accent); }
.voice-set .voice-note { font-size: 12.5px; margin: 8px 0 0; }
.voice-set .voice-note:empty { display: none; }
.voice-set select option, .voice-set select optgroup { background: #0c1020; color: var(--text); }

/* ── Read-along: word highlight in place, caption strip, docked window ───── */
::highlight(speak-line) { background-color: rgba(127, 214, 255, .10); }
::highlight(speak-word) { background-color: rgba(255, 214, 107, .55); color: #fff; }
.speak-cap {
  position: fixed; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 45; display: flex; align-items: center; gap: 10px; width: min(760px, calc(100vw - 24px));
  padding: 10px 14px; border-radius: 16px; border: 1px solid rgba(255, 214, 107, .35);
  background: rgba(8, 10, 22, .9); backdrop-filter: blur(10px); box-shadow: 0 10px 40px rgba(0, 0, 0, .45);
  animation: pop .25s ease-out;
}
.speak-cap.hidden { display: none; }
.speak-cap .sc-stop { flex: none; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--panel); color: var(--text); cursor: pointer; }
.speak-cap .sc-line { position: relative; font-size: 17px; line-height: 1.45; color: #aeb8da; max-height: 2.9em; overflow: hidden; scroll-behavior: smooth; }
.speak-cap .sc-line span { transition: color .12s, background-color .12s; border-radius: 5px; padding: 0 1px; }
.speak-cap .sc-line span.done { color: #e3e9ff; }
.speak-cap .sc-line span.on { color: #1b1203; background: #ffd66b; box-shadow: 0 0 0 2px #ffd66b; }
@media (max-width: 720px) { .speak-cap .sc-line { font-size: 15px; } }

/* while a window is being read over a molecule, slide it aside so the molecule shows */
body.read-dock .modal { background: transparent; pointer-events: none; place-items: center end; }
body.read-dock .modal-card { pointer-events: auto; width: min(430px, 42vw); max-height: calc(100vh - 110px); margin-right: 4px; transition: width .3s; }
@media (max-width: 720px) {
  body.read-dock .modal { place-items: end center; padding-bottom: 128px; }
  body.read-dock .modal-card { width: 100%; max-height: 38vh; margin: 0; }
}

/* Spark answers: citations + sources + listen */
.sp-text p { margin: 0 0 8px; }
.sp-text .cite { margin-left: 2px; }
.sp-foot { margin-top: 6px; }
.sp-foot .sp-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 4px 0 0; }
.sp-foot .src { display: inline; margin: 0; font-size: 11.5px; color: var(--muted); }
.sp-sources { margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.sp-sources summary { cursor: pointer; color: var(--accent); }
.sp-sources ol { margin: 6px 0 0; padding-left: 22px; }
.sp-sources li { margin: 3px 0; }
.sp-sources a { color: #c7d0ee; }
.sp-kind { font-size: 10.5px; padding: 1px 6px; border-radius: 999px; border: 1px solid var(--line-strong); margin-right: 4px; }

/* Map: the Build dock — one tap back into building */
.build-dock {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: max(14px, env(safe-area-inset-bottom));
  display: flex; align-items: stretch; gap: 6px; z-index: 6;
}
.build-dock .bd-main {
  display: flex; align-items: center; gap: 10px; padding: 9px 18px 9px 14px; border-radius: 999px; text-align: left;
  box-shadow: 0 0 0 1px rgba(127, 214, 255, .35), 0 8px 30px rgba(60, 140, 255, .25); max-width: min(360px, 70vw);
}
.build-dock .bd-icon { font-size: 20px; line-height: 1; flex: none; width: 24px; text-align: center; }
.build-dock .bd-text { display: flex; flex-direction: column; min-width: 0; }
.build-dock .bd-text small, .bd-item small { font-size: 11px; color: var(--muted); letter-spacing: .02em; }
.build-dock .bd-text b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.build-dock .bd-more { align-self: center; }
.bd-menu { position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); width: min(320px, calc(100vw - 24px)); padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.bd-menu.hidden { display: none; }
.bd-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 0; border-radius: 10px; background: none; color: var(--text); font: inherit; font-size: 14px; text-align: left; cursor: pointer; }
.bd-item:hover, .bd-item:focus-visible { background: rgba(127, 214, 255, .1); }
.bd-item > span:nth-child(2) { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.bd-tag { font-size: 11px; color: var(--warn); flex: none; }
@media (max-width: 1000px) {
  .build-dock { bottom: calc(max(14px, env(safe-area-inset-bottom)) + 40px); }
  .build-dock .bd-main { max-width: calc(100vw - 90px); }
}

/* "What you built" card (isomers and other molecules) */
.ident { position: absolute; top: 96px; left: 50%; transform: translateX(-50%); width: min(520px, calc(100vw - 24px)); padding: 14px 16px 12px; z-index: 7; animation: pop .3s ease-out; }
.ident.hidden { display: none; }
.ident h3 { margin: 0 34px 6px 0; font-size: 16px; }
.ident p { margin: 6px 0; font-size: 14px; color: #c7d0ee; }
.ident .close { position: absolute; top: 8px; right: 8px; }
.ident .id-link { font-size: 12px; font-weight: 500; color: var(--accent); margin-left: 6px; }
.ident .id-g { display: inline-block; font-size: 12px; padding: 1px 8px; margin: 2px 2px 0 0; border-radius: 999px; border: 1px solid var(--line-strong); background: rgba(127, 214, 255, .06); }
.ident .id-diff { border-left: 3px solid var(--warn); padding-left: 8px; }
@media (max-width: 720px) { .ident { top: 212px; } }

/* Map: browse / filter by grouping */
.sr-browse { padding: 8px 10px 10px; }
.sr-browse .sr-h { margin: 8px 2px 4px; font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.sr-browse .sr-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sr-browse .sr-chip { cursor: pointer; font: inherit; font-size: 12.5px; color: var(--text); }
.sr-browse .sr-chip:hover { background: rgba(127, 214, 255, .14); border-color: var(--accent); }
.sr-browse .sr-tip { margin: 10px 2px 0; font-size: 12px; color: var(--muted); }
.map-filter {
  position: absolute; top: 76px; left: 50%; transform: translateX(-50%); z-index: 5;
  display: flex; align-items: center; gap: 8px; padding: 5px 6px 5px 14px; border-radius: 999px;
  background: rgba(10, 16, 34, .85); border: 1px solid rgba(127, 214, 255, .45); font-size: 13.5px;
}
.map-filter.hidden { display: none; }
.map-filter .btn.icon { width: 28px; height: 28px; font-size: 12px; }
@media (max-width: 720px) { .map-filter { top: 170px; } }
.ident .id-more summary { cursor: pointer; color: var(--accent); font-size: 13px; margin-top: 4px; }
@media (max-width: 720px) { .ident { padding: 10px 12px; } .ident h3 { font-size: 15px; } .ident p { font-size: 13px; } }

/* ⓘ chip beside the selected atom (details on tap, nothing covering the build) */
.atom-info {
  position: absolute; left: 0; top: 0; z-index: 8; display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 8px 4px 10px; border-radius: 999px; border: 1px solid rgba(127, 214, 255, .55);
  background: rgba(8, 14, 30, .9); color: var(--text); font: inherit; font-size: 12.5px; cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .4); will-change: transform; touch-action: manipulation;
}
.atom-info.hidden { display: none; }
.atom-info.ok { border-color: rgba(94, 242, 168, .6); }
.atom-info .ai-i { color: var(--accent); font-size: 14px; }
.chip.good { border-color: rgba(94, 242, 168, .6); color: #d6ffe9; }
.tip.slim { padding: 6px 12px; font-size: 12.5px; pointer-events: none; opacity: .92; }

/* bond check legend */
.bc-ok { color: #5ef2a8; font-weight: 600; }
.bc-order { color: #ffc15e; font-weight: 600; }
.bc-wrong { color: #ff6b76; font-weight: 600; }
.parts-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin-top: 4px; font-size: 12px; color: var(--muted); }
.parts-row .kw { font-size: 12px; }
.ident.mini { cursor: pointer; padding: 8px 12px; }
.ident.mini > :not(h3):not(.close) { display: none; }
.ident.mini h3 { margin: 0 30px 0 0; font-size: 14px; }
.ident.mini .close { top: 3px; right: 4px; width: 28px; height: 28px; }
@media (min-width: 721px) { .ident { left: auto; right: 16px; transform: none; top: 64px; width: min(420px, 36vw); } }
#kw-pop .kw-head .wc-icon svg { width: 120px; height: 66px; }
#kw-pop .kw-head .wc-icon { width: auto; height: auto; }
@media (max-width: 720px) {
  .parts-row { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .parts-row::-webkit-scrollbar { display: none; }
  .parts-row .kw { flex: none; }
  .target .meta { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .target .hintline { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
}
.text-in { background: var(--panel-solid); color: var(--text); border: 1px solid var(--line-strong); border-radius: 10px; padding: 7px 10px; font: inherit; font-size: 14px; min-width: 0; max-width: 60%; }
.modal-card > .text-in { display: block; width: 100%; max-width: none; margin: 8px 0; }

/* The Build dock steps aside while a map card or the search results are open (they have their own buttons) */
body.map-card-open .build-dock, #map-hud:has(#node-card:not(.hidden)) .build-dock,
#map-hud:has(#search-results:not(.hidden)) .build-dock { opacity: 0; pointer-events: none; transform: translate(-50%, 12px); }
.build-dock { transition: opacity .2s, transform .2s; }

/* ── touch guard ──────────────────────────────────────────────────────────────
   On phones a long-press (holding a button) or a quick double-tap selects the nearest text and the browser
   pops its edit menu ("Search with… / Find in Page"). Mobile Safari/WebKit doesn't reliably pass
   user-select: none down to children, so every element inherits it explicitly; anything with its own
   user-select: text rule (and inputs, code) stays selectable. Enforced at runtime by js/touch-guard.js. */
html { touch-action: manipulation; -webkit-text-size-adjust: 100%; }
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
:where(body *) { -webkit-user-select: inherit; user-select: inherit; -webkit-touch-callout: inherit; }
:where(input, textarea, select, [contenteditable], .selectable, code, pre) { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }

/* phones: the counts are one compact strip under the header, not a column over the atoms */
@media (max-width: 720px) {
  .counts { left: 12px; right: 12px; flex-direction: row; flex-wrap: wrap; gap: 4px 5px; font-size: 11.5px; }
  .counts div { padding: 2px 7px; background: rgba(5, 6, 13, .78); }
  .counts div.energy { margin-top: 0; }
}

/* ⚡ Energy lab */
.energy-lab { --src: #7fd6ff; }
.el-chip { cursor: pointer; font: inherit; color: inherit; background: none; }
.el-steps { display: flex; gap: 6px; margin: 6px 0 8px; font-size: 12.5px; color: var(--muted); }
.el-steps span { padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); }
.el-steps span.on { color: var(--text); border-color: var(--accent); background: rgba(127, 214, 255, .1); }
.el-meters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 8px; }
.el-meter { font-size: 12px; color: var(--muted); }
.el-meter > div { height: 10px; border-radius: 6px; background: rgba(255, 255, 255, .06); overflow: hidden; margin: 3px 0; }
.el-meter i { display: block; height: 100%; width: 0; transition: width .12s linear; }
.el-meter.in i { background: linear-gradient(90deg, #4aa3ff, #7fd6ff); }
.el-meter.out i { background: linear-gradient(90deg, #ff7a3d, #ffc15e); }
.el-meter b { color: var(--text); font-size: 13px; }
.el-say { margin: 6px 0; }
.el-src { display: flex; width: 100%; margin: 4px 0; }
.el-src button { flex: 1; padding: 8px 4px; font: inherit; font-size: 13.5px; }
.el-src-note { font-size: 12.5px; margin: 4px 0 8px; }
.el-list { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.el-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 10px; background: rgba(255, 255, 255, .03); }
.el-lab { min-width: 92px; font-size: 13px; }
.el-lab small { display: block; color: var(--muted); font-size: 11px; }
.el-bonds { display: flex; flex-wrap: wrap; gap: 6px; }
.el-bonds i { position: relative; width: 34px; height: 14px; border-radius: 7px; background: rgba(160, 190, 255, .18); overflow: hidden; }
.el-row.brk .el-bonds i { background: rgba(200, 215, 255, .55); }
.el-row.brk .el-bonds i em { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--src); opacity: .85; }
.el-row.brk .el-bonds i.snap { background: transparent; border: 1px dashed rgba(200, 215, 255, .35); animation: elsnap .3s ease-out; }
.el-row.brk .el-bonds i.snap em { display: none; }
@keyframes elsnap { 0% { transform: scale(1.3); } 100% { transform: scale(1); } }
.el-row.frm .el-bonds i { cursor: pointer; border: 1px dashed rgba(255, 193, 94, .7); animation: elglow 1.2s ease-in-out infinite; width: 40px; height: 22px; border-radius: 11px; }
.el-row.frm .el-bonds i.made { animation: none; border: 0; background: linear-gradient(90deg, #ff9f43, #ffd27a); box-shadow: 0 0 10px rgba(255, 170, 80, .6); cursor: default; }
@keyframes elglow { 50% { box-shadow: 0 0 10px rgba(255, 193, 94, .7); } }
.el-hold { width: 100%; padding: 14px; font-size: 16px; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; margin-top: 6px; }
.el-hold.on { background: var(--src); color: #0b0d18; box-shadow: 0 0 24px var(--src); transform: scale(.98); }
.el-hold.done { background: rgba(94, 242, 168, .2); border-color: var(--good); }
.el-verdict { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 14px; background: rgba(255, 255, 255, .04); border: 1px solid var(--line); }
.el-verdict.endo { border-color: rgba(110, 200, 255, .5); }
.el-verdict.exo { border-color: rgba(255, 159, 67, .55); }
.el-verdict p { margin: 4px 0 0; font-size: 13.5px; }
.el-big { font-size: 34px; }
.el-amt { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 10px 0 4px; font-size: 13px; color: var(--muted); }
.el-amt .seg button { font: inherit; font-size: 12.5px; padding: 6px 9px; }
.el-things { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.el-thing { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 10px 8px; border-radius: 12px; background: rgba(127, 214, 255, .05); border: 1px solid var(--line); }
.el-ico { font-size: 26px; }
.el-thing b { font-size: 20px; margin-top: 2px; }
.el-thing span { font-size: 13px; }
.el-thing small { color: var(--muted); font-size: 11px; margin-top: 2px; }
.el-ledger { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; font-size: 12.5px; color: var(--muted); margin: -2px 0 6px; }
.el-ledger b.neg { color: #7fd6ff; } .el-ledger b.pos { color: #ffc15e; }
.el-now { font-size: 13px; margin: 4px 0; color: var(--text); min-height: 1.2em; }
.el-prog { color: var(--accent) !important; font-variant-numeric: tabular-nums; }
.energy-lab { position: relative; }
.el-pop { position: absolute; transform: translate(-50%, 0); font-size: 13px; font-weight: 700; pointer-events: none; animation: elpop 1.1s ease-out forwards; z-index: 3; }
.el-pop.in { color: #7fd6ff; } .el-pop.out { color: #ffc15e; }
@keyframes elpop { from { opacity: 1; transform: translate(-50%, 0); } to { opacity: 0; transform: translate(-50%, -34px); } }
.el-fuelcard { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.el-fuelcard > div { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 12px; background: rgba(255, 255, 255, .04); border: 1px solid var(--line); }
.el-fuelcard small { display: block; color: var(--muted); font-size: 11.5px; }

/* ── 📘 Learn hub (study.js) ─────────────────────────────────────────────── */
.modal-card.study { width: min(760px, 100%); }
.study-tabs { margin: 8px 0 10px; }
.study-body h3 { margin: 10px 0 4px; font-size: 16px; }
.study-mode { margin-bottom: 8px; }
.study-mode button.on { color: var(--text); background: rgba(127, 214, 255, .14); }
.study-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; margin-top: 10px; }
.study-link { text-align: left; font: inherit; color: var(--text); background: rgba(127, 214, 255, .06); border: 1px solid var(--line-strong); border-radius: 12px; padding: 10px 12px; cursor: pointer; display: flex; flex-direction: column; gap: 3px; }
.study-link span { color: var(--muted); font-size: 13px; }
.study-link:hover { border-color: var(--accent); }
.study .good { color: var(--good); } .study .bad { color: var(--bad); } .study .warn { color: var(--warn); }
.study .pos { color: #ff9f8a; } .study .neg { color: #7fd6ff; }
.formula.big { font-size: 24px; }

/* periodic table */
.pt-wrap { overflow-x: auto; padding: 9px 7px 4px 0; -webkit-overflow-scrolling: touch; }
.pt { display: grid; grid-template-columns: repeat(18, minmax(26px, 1fr)); grid-template-rows: auto repeat(7, auto) 8px auto auto; gap: 2px; min-width: 500px; }
.pt-h { font-size: 9.5px; color: var(--muted); text-align: center; align-self: end; }
.pt-h.ng { color: #b58cff; font-weight: 700; }
.pt-c { --c: #7fd6ff; position: relative; aspect-ratio: 1 / 1.05; padding: 0; border-radius: 5px; cursor: pointer; font: inherit; color: var(--text);
  background: color-mix(in srgb, var(--c) 16%, #0b0e1c); border: 1px solid color-mix(in srgb, var(--c) 45%, transparent);
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; transition: transform .15s, box-shadow .2s; }
.pt-c small { font-size: 7.5px; color: var(--muted); }
.pt-c b { font-size: 12.5px; }
.pt-c:hover { transform: scale(1.12); z-index: 2; box-shadow: 0 0 12px var(--c); }
.pt-c.sel { box-shadow: 0 0 0 2px #fff, 0 0 16px var(--c); z-index: 2; }
.pt-c.step { box-shadow: 0 0 0 2px var(--warn); }
.pt-c.goal { box-shadow: 0 0 0 2px var(--good), 0 0 18px var(--good); }
.pt-c.off { opacity: .25; }
.pt-b { position: absolute; top: -8px; right: -6px; background: var(--warn); color: #111; font-size: 10px; font-weight: 700; border-radius: 8px; padding: 1px 4px; animation: pop .3s; }
.pt-c.goal .pt-b { background: var(--good); }
.t-alk { --c: #ff8a65; } .t-ae { --c: #ffb74d; } .t-tm { --c: #8fa3c8; } .t-ptm { --c: #80cbc4; } .t-md { --c: #aed581; }
.t-nm { --c: #7fd6ff; } .t-hal { --c: #e08fe8; } .t-ng { --c: #b58cff; } .t-lan { --c: #f48fb1; } .t-act { --c: #ef9a9a; }
.pt-legend { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 11px; color: var(--muted); margin: 6px 0; }
.pt-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; background: var(--c); margin-right: 4px; vertical-align: -1px; }

/* the ion story */
.ion-detail { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 8px; }
.ion-head h3 { margin: 0; }
.ion-visual { display: flex; align-items: center; gap: 12px; margin: 6px 0; }
.ion-shells { width: 190px; height: 190px; flex: none; overflow: visible; }
.sh-nuc { fill: rgba(255, 159, 138, .25); stroke: #ff9f8a; }
.sh-sym { fill: var(--text); font-size: 13px; font-weight: 700; text-anchor: middle; }
.sh-orbit { fill: none; stroke: rgba(255, 255, 255, .22); stroke-dasharray: 3 4; }
.sh-core { fill: rgba(127, 214, 255, .08); stroke: rgba(127, 214, 255, .3); }
.sh-core-t { fill: var(--muted); font-size: 9px; text-anchor: middle; }
.sh-e { fill: #7fd6ff; filter: drop-shadow(0 0 3px #7fd6ff); transition: transform .55s cubic-bezier(.2, .8, .3, 1), opacity .55s; }
.sh-e.in { fill: rgba(127, 214, 255, .6); filter: none; }
.sh-e.new { fill: var(--good); filter: drop-shadow(0 0 4px var(--good)); }
.sh-hole { fill: none; stroke: rgba(255, 255, 255, .18); stroke-dasharray: 2 2; }
.sh-ring { transition: opacity .6s; }
.sh-ring.outer.empty { opacity: .15; }
.sh-ring.now-outer .sh-orbit { stroke: var(--good); stroke-dasharray: none; filter: drop-shadow(0 0 4px var(--good)); }
.ion-visual.done .ion-shells { animation: pop .4s; }
.ion-count { font-size: 14px; line-height: 1.5; flex: 1; min-width: 140px; }
.ion-q { margin-top: 6px; font-size: 16px; }
.ion-name { margin: 8px 0; font-size: 22px; }
.ion-name .nm-drop { color: var(--bad); text-decoration: none; transition: opacity .4s; }
.ion-name .nm-add { color: var(--good); opacity: 0; transition: opacity .5s .5s; }
.ion-name.play .nm-drop { text-decoration: line-through; opacity: .45; }
.ion-name.play .nm-add, .ion-name.multi .nm-add { opacity: 1; }
.ion-name.multi { font-size: 14px; }
.ion-name p { font-size: 14px; }
.ion-tools { margin-top: 4px !important; }
.ion-pair { margin-top: 10px; }
.ion-pair:empty { display: none; }
.pair-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.pair-res { margin-top: 6px; }

/* practice */
.quiz-score { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; }
.quiz-q { font-size: 18px; margin: 10px 0; }
.quiz-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.quiz-o.right { border-color: var(--good); box-shadow: 0 0 14px rgba(94, 242, 168, .35); }
.quiz-o.wrong { border-color: var(--bad); }
.quiz-why p { margin: 8px 0; }

/* molar mass + balance */
.mm-form { display: flex; gap: 8px; margin: 8px 0; }
.mm-form .text-in { flex: 1; min-width: 0; font-family: var(--mono); }
.mm-ex { margin-top: 4px !important; }
.mm-table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 14px; font-variant-numeric: tabular-nums; }
.mm-table th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; border-bottom: 1px solid var(--line); padding: 4px 6px; }
.mm-table td { padding: 5px 6px; border-bottom: 1px solid var(--line); }
.mm-table td:nth-child(3), .mm-table td:nth-child(4) { white-space: nowrap; }
.mm-table tfoot td { border: 0; font-size: 15px; }
.mm-in { width: 56px; text-align: center; }
.mm-in.ok { border-color: var(--good); } .mm-in.bad { border-color: var(--bad); }
.mm-note { border-left: 3px solid var(--accent); padding-left: 8px; }
.bal-pick select { width: 100%; }
.bal-own { margin: 6px 0; color: var(--muted); font-size: 13px; }
.bal-eq { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 6px 10px; padding: 12px; border-radius: 12px; border: 1px solid var(--line); margin: 8px 0; transition: border-color .3s, box-shadow .3s; }
.bal-eq.ok { border-color: var(--good); box-shadow: 0 0 18px rgba(94, 242, 168, .25); }
.bal-term { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.bal-step { display: flex; align-items: center; gap: 2px; }
.bal-b { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--panel); color: var(--text); font-size: 17px; cursor: pointer; line-height: 1; }
.bal-c { min-width: 22px; text-align: center; font-size: 18px; color: var(--warn); }
.bal-plus, .bal-arrow { align-self: flex-end; padding-bottom: 2px; color: var(--muted); }
.bal-tally tr.ok td { color: var(--good); } .bal-tally tr.off td { color: var(--bad); }
.card-extras { margin-top: 6px !important; }
a.chip { text-decoration: none; }
@media (max-width: 720px) {
  .modal-card.study { padding: 16px 14px; }
  .ion-shells { width: 140px; height: 140px; }
  .pt { min-width: 0; gap: 1px; grid-template-columns: repeat(18, minmax(0, 1fr)); }
  .pt-c { border-radius: 3px; aspect-ratio: 1 / 1.15; }
  .pt-c small { display: none; }
  .pt-c b { font-size: 10px; }
  .pt-h { font-size: 8px; }
  .pt-b { font-size: 9px; top: -9px; right: -4px; padding: 0 3px; }
  .ion-name { font-size: 19px; }
  #btn-learn { padding: 0; width: 36px; height: 36px; justify-content: center; }
  #btn-learn .learn-lbl { display: none; }
  .topbar:not(.lab-top) .top-actions { gap: 6px; }
  .topbar:not(.lab-top) .seg button { padding: 7px 9px; font-size: 13.5px; }
  .topbar:not(.lab-top) #btn-sandbox { padding: 7px 10px; font-size: 13.5px; }
}
.study button, .study .bal-c { -webkit-user-select: none; user-select: none; }

/* ── 🎓 My class (classroom.js) ──────────────────────────────────────────── */
.class-join label { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.class-join .text-in { max-width: 60%; flex: 1; }
.cl-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; }
.cl-head h3 { margin: 0; }
.cl-total { color: var(--good); font-weight: 600; white-space: nowrap; }
.cl-units { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.cl-unit { display: flex; gap: 12px; align-items: center; text-align: left; font: inherit; color: var(--text); background: rgba(127, 214, 255, .05);
  border: 1px solid var(--line-strong); border-radius: 12px; padding: 10px 12px; cursor: pointer; }
.cl-unit:hover { border-color: var(--accent); }
.cl-unit.done { border-color: rgba(94, 242, 168, .45); }
.cl-ico { font-size: 20px; width: 28px; text-align: center; }
.cl-unit.done .cl-ico { color: var(--good); }
.cl-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cl-main small { color: var(--muted); font-size: 12.5px; }
.cl-bar { height: 4px; border-radius: 3px; background: rgba(255, 255, 255, .08); overflow: hidden; margin-top: 4px; }
.cl-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--good)); }
.cl-side { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.cl-due { color: var(--muted); } .cl-due.soon { color: var(--warn); } .cl-due.late { color: var(--bad); }
.cl-foot { justify-content: space-between; }
.cl-uhead { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.cl-note { border-left: 3px solid var(--accent-2); padding-left: 10px; color: #c7d0ee; }
.cl-result { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 18px; border: 1px solid var(--line); border-radius: 12px; margin: 10px 0; }
.cl-result b { font-size: 34px; } .cl-result.good { border-color: rgba(94, 242, 168, .55); }
.cl-steps { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 6px; }
.cl-step { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--panel); color: var(--text); cursor: pointer; font: inherit; }
.cl-step.on { border-color: var(--accent); box-shadow: 0 0 10px rgba(127, 214, 255, .4); }
.cl-step.ok { background: rgba(94, 242, 168, .18); border-color: rgba(94, 242, 168, .6); }
.cl-items { display: flex; flex-direction: column; gap: 6px; }
.cl-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; }
.cl-item.ok { border-color: rgba(94, 242, 168, .45); }
.cl-item > span:first-child { width: 18px; color: var(--good); }
.cl-item .row { margin: 0 !important; flex-wrap: nowrap; }
.cl-reading p { font-size: 16px; line-height: 1.6; }
@media (max-width: 720px) {
  .class-join label { flex-direction: column; align-items: stretch; }
  .class-join .text-in { max-width: none; }
  .cl-item { flex-wrap: wrap; }
}
