/* ============================================================================
   Reaction Lab — editorial design language (after the CT "Caution Tape"
   editorial system): black / white / yellow, square corners, hairlines,
   mono eyebrow labels, generous whitespace.
   ============================================================================ */
:root {
  --bg: #000000;
  --panel: #0a0a0a;
  --panel-2: #121212;
  --panel-3: #1c1c1c;
  --ink: #ffffff;
  --ink-2: #d9d9d9;
  --muted: #9a9a9a;
  --faint: #626262;
  --line: rgba(255,255,255,.12);
  --line-2: rgba(255,255,255,.22);
  --accent: #ffd60a;
  --accent-2: #ffe766;
  --accent-ink: #000000;
  --accent-soft: rgba(255,214,10,.10);
  --warn: #ff5c5c;
  --warn-soft: rgba(255,92,92,.10);
  --hot: #ff5a36;
  --cold: #4da3ff;
  --glass: #8f8f8f;
  --water: rgba(120, 175, 225, 0.45);
  --bond: #d8d8d8;
  --sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --focus: 0 0 0 2px #000, 0 0 0 4px var(--accent);
}

* { box-sizing: border-box; }
html { scrollbar-color: #333 #000; }
html, body { margin: 0; }
body { font-family: var(--sans); font-size: 15px; line-height: 1.55; color: var(--ink-2); background: var(--bg); font-feature-settings: "tnum" 1; -webkit-font-smoothing: antialiased; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: #000; }
::-webkit-scrollbar-thumb { background: #2e2e2e; border: 2px solid #000; }
::-webkit-scrollbar-thumb:hover { background: #444; }
::selection { background: var(--accent); color: #000; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: none; box-shadow: var(--focus); }
h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.15; letter-spacing: -.02em; color: #fff; font-weight: 500; }
h1 { font-size: 34px; } h2 { font-size: 22px; } h3 { font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
p { margin: 0 0 .9em; }
b, strong { color: #fff; font-weight: 600; }
code { background: var(--panel-3); padding: 1px 6px; font-size: 88%; color: #fff; font-family: var(--mono); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.tiny { font-size: 12.5px; }
.hidden { display: none !important; }
.count { font-family: var(--mono); color: var(--faint); font-weight: 400; font-size: 11px; margin-left: 8px; letter-spacing: .08em; }
.ic { width: 1.1em; height: 1.1em; vertical-align: -0.2em; flex: none; }
.btn .ic, .tabs .ic, .cond .ic, .tool .ic, .stab .ic { margin-right: 7px; }
.mol { display: block; }
sup { font-size: 70%; line-height: 0; }
kbd { border: 1px solid var(--line-2); background: var(--panel-2); padding: 0 5px; font-size: 11px; font-family: var(--mono); }

/* eyebrow labels: "—— LABEL" in mono caps, the signature of the editorial system */
.eyebrow, .panel-h, .sel-label, .fact .k, .sect h4, .stage-label, .hints .h-title, legend, .ion-group h3, .struct-info h4, .formulas .frow .k, .learn .anatomy .lbl, .tpanel .lead {
  font-family: var(--mono); font-size: 10.5px; font-weight: 500; text-transform: uppercase; letter-spacing: .16em; color: var(--muted); line-height: 1.4;
}
.panel-h { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; }
.panel-h::before { content: ""; width: 18px; height: 1px; background: var(--line-2); flex: none; }

/* ---------- generic controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; height: 36px; border: 1px solid var(--line-2); background: transparent; color: #fff; padding: 0 14px; font-weight: 500; font-size: 13.5px; letter-spacing: 0; transition: background .12s, color .12s, border-color .12s; white-space: nowrap; }
.btn:hover { border-color: rgba(255,255,255,.55); color: #fff; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: #000; border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); color: #000; }
.btn.danger { color: var(--warn); border-color: rgba(255,92,92,.5); }
.btn.danger:hover { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.btn.small { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
select.sel, .form-card select { -webkit-appearance: none; appearance: none; width: 100%; height: 38px; padding: 0 34px 0 12px; border: 1px solid var(--line-2); background: #000 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239a9a9a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6l6-6'/%3E%3C/svg%3E") no-repeat right 10px center / 16px; color: #fff; cursor: pointer; transition: border-color .12s; font-size: 14px; }
select.sel:hover, .form-card select:hover { border-color: rgba(255,255,255,.45); }
select.sel:focus, .form-card select:focus { border-color: var(--accent); box-shadow: var(--focus); outline: none; }
select.sel optgroup { color: #fff; font-style: normal; font-weight: 600; background: #0a0a0a; }
select.sel option { color: #fff; background: #0f0f0f; font-weight: 400; padding: 4px 0; }
.sel-label { display: block; margin-top: 14px; }
.sel-label select { margin-top: 6px; text-transform: none; letter-spacing: 0; font-weight: 400; font-family: var(--sans); }
.search-wrap { position: relative; }
.search-wrap > .ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); width: 16px; height: 16px; }
.search-wrap .search { padding-left: 34px; }
.search-wrap.wide { max-width: 560px; margin: 12px 0; }
.search { width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--line-2); background: #000; outline: none; color: #fff; transition: border-color .12s; }
.search::placeholder { color: var(--faint); }
.search:focus { border-color: var(--accent); box-shadow: var(--focus); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 10px 0; }
.chip { border: 1px solid var(--line-2); background: transparent; padding: 4px 10px; font-size: 12.5px; color: var(--muted); font-weight: 500; transition: all .12s; }
.chip:hover { border-color: rgba(255,255,255,.5); color: #fff; }
.chip.active { background: #fff; color: #000; border-color: #fff; font-weight: 500; }

/* ---------- header ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; padding: 12px 28px; background: #000; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo { display: inline-flex; width: 36px; height: 36px; align-items: center; justify-content: center; border: 1px solid var(--line-2); color: #fff; }
.logo .ic { width: 22px; height: 22px; }
.brand-name { font-weight: 600; font-size: 18px; letter-spacing: -.02em; line-height: 1.1; color: #fff; }
.brand-sub { font-family: var(--mono); font-size: 10px; color: var(--muted); margin-top: 3px; text-transform: uppercase; letter-spacing: .16em; }
.tabs { display: flex; gap: 0; }
.tabs button { display: inline-flex; align-items: center; border: 0; border-bottom: 2px solid transparent; background: transparent; height: 42px; padding: 0 14px; color: var(--muted); font-weight: 500; font-size: 14px; transition: all .12s; }
.tabs button:hover { color: #fff; }
.tabs button.active { color: #fff; border-bottom-color: var(--accent); }
.tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tool { display: inline-flex; align-items: center; height: 34px; border: 1px solid var(--line-2); background: transparent; color: var(--ink-2); padding: 0 12px; font-weight: 500; font-size: 13px; transition: all .12s; }
.tool:hover { border-color: rgba(255,255,255,.5); color: #fff; }
.tool.on { background: var(--accent); color: #000; border-color: var(--accent); font-weight: 600; }
.tool-sel { display: inline-flex; align-items: center; gap: 10px; font-family: var(--mono); font-size: 10.5px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: .16em; }
.tool-sel select.sel { width: 200px; height: 34px; text-transform: none; letter-spacing: 0; font-family: var(--sans); }

main { padding: 24px 28px 48px; max-width: 1560px; margin: 0 auto; }
.tab { display: none; }
.tab.active { display: block; }
.foot { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; color: var(--faint); font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .14em; padding: 22px 28px; border-top: 1px solid var(--line); }
.foot a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }

/* ---------- toggle panels: periodic table & ions ---------- */
.tpanel { background: var(--panel); border: 1px solid var(--line); padding: 18px 20px 20px; margin-bottom: 20px; }
.tpanel-h { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.tpanel-h h2 { margin: 0; }
.tpanel-h .btn { margin-left: auto; align-self: center; }
.ptable-wrap { overflow-x: auto; padding-bottom: 6px; }
.ptable { display: grid; grid-template-columns: repeat(18, minmax(60px, 1fr)); grid-auto-rows: 60px; gap: 3px; min-width: 1130px; }
.pt-cell { position: relative; border: 1px solid color-mix(in srgb, var(--cc) 55%, #000); background: color-mix(in srgb, var(--cc) 16%, #000); padding: 4px 5px; text-align: left; line-height: 1; color: #fff; display: flex; flex-direction: column; justify-content: space-between; transition: transform .08s, background .12s; }
.pt-cell:hover { background: color-mix(in srgb, var(--cc) 40%, #000); outline: 1px solid #fff; z-index: 2; }
.pt-cell .pt-n { font-family: var(--mono); font-size: 9px; color: #cfcfcf; }
.pt-cell .pt-s { font-size: 17px; font-weight: 600; }
.pt-cell .pt-m { font-family: var(--mono); font-size: 8.5px; color: #bdbdbd; }
.pt-cell .pt-en { position: absolute; top: 4px; right: 5px; font-family: var(--mono); font-size: 9px; color: #e8e8e8; font-weight: 500; }
.pt-gap { display: flex; align-items: center; justify-content: center; font-family: var(--mono); font-size: 10px; color: var(--faint); border: 1px dashed var(--line-2); }
.pt-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); align-items: center; }
.pt-legend span i { display: inline-block; width: 9px; height: 9px; margin-right: 7px; vertical-align: 0; }
.ions { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.ion-group h3 { margin: 0 0 6px; border-bottom: 1px solid var(--line-2); padding-bottom: 6px; }
.ion { display: flex; justify-content: space-between; align-items: center; padding: 6px 4px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.ion .fml { font-weight: 600; color: #fff; }
.ion sup { color: #fff; font-weight: 600; }

/* ---------- lab layout ---------- */
#tab-lab.active { display: grid; grid-template-columns: 300px minmax(360px, 440px) 1fr; gap: 20px; align-items: stretch; height: calc(100vh - 122px); min-height: 640px; }
#tab-lab .panel { display: flex; flex-direction: column; min-height: 0; overflow: auto; }
#tab-lab .bench .hints { flex: 1; }
@media (max-width: 1150px) { #tab-lab.active { grid-template-columns: 280px 1fr; height: auto; min-height: 0; } #tab-lab .results { grid-column: 1 / -1; } #tab-lab .panel { overflow: visible; } }
@media (max-width: 720px) { #tab-lab.active { grid-template-columns: 1fr; } }
.panel { background: var(--panel); border: 1px solid var(--line); padding: 18px; }
.pick-preview { margin-top: 12px; background: #000; border: 1px solid var(--line); padding: 12px; display: flex; gap: 12px; align-items: flex-start; min-height: 60px; }
.pick-preview .thumb { width: 88px; height: 88px; flex: none; background: #000; border: 1px solid var(--line); padding: 4px; }
.pick-preview .pv-f { font-size: 20px; font-weight: 500; line-height: 1.1; color: #fff; letter-spacing: -.01em; }
.pick-preview .pv-facts { font-size: 12px; color: var(--muted); margin: 4px 0 10px; line-height: 1.45; }
.pick-preview .row { display: flex; gap: 6px; flex-wrap: wrap; }
.fml sub { font-size: 72%; }
.coef { font-weight: 600; margin-right: 1px; }
.st { font-size: 75%; color: var(--muted); margin-left: 1px; }
.eq { font-size: 1.15em; color: #fff; }
.eq .plus { margin: 0 7px; color: var(--muted); }
.eq .arrow { margin: 0 10px; color: #fff; font-weight: 500; }
.eq.big { font-size: 1.6em; display: block; margin: 8px 0 14px; font-weight: 500; letter-spacing: -.01em; }
.mol-eq { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; margin: 6px 0 12px; }
.mol-eq .term { display: flex; flex-direction: column; align-items: center; font-size: 12px; color: var(--muted); }
.mol-eq .term b { color: #fff; }
.mol-eq .sym { font-size: 20px; color: var(--muted); padding: 0 2px; }
.mol-eq .sym.arrow { color: #fff; }
.thumb { display: inline-flex; align-items: center; justify-content: center; }

/* ---------- real look ---------- */
.look { display: inline-block; position: relative; --c: #cfcfcf; flex: none; }
.look::before, .look::after { content: ""; position: absolute; }
.look.powder::before { left: 6%; right: 6%; bottom: 8%; height: 52%; background: var(--c); border-radius: 55% 55% 12% 12% / 80% 80% 14% 14%; box-shadow: inset 0 -6px 10px rgba(0,0,0,.35), inset 0 5px 8px rgba(255,255,255,.28); }
.look.powder::after { left: 12%; right: 12%; bottom: 10%; height: 45%; border-radius: 50% 50% 10% 10%; background-image: radial-gradient(rgba(0,0,0,.28) 1px, transparent 1.6px); background-size: 6px 6px; opacity: .8; }
.look.crystals::before { left: 12%; top: 10%; width: 76%; height: 80%; background: linear-gradient(135deg, color-mix(in srgb, var(--c) 55%, #fff) 0 30%, var(--c) 30% 62%, color-mix(in srgb, var(--c) 60%, #000) 62%); clip-path: polygon(50% 0, 92% 22%, 100% 66%, 62% 100%, 22% 92%, 0 50%, 18% 14%); }
.look.crystals::after { left: 12%; top: 10%; width: 76%; height: 80%; clip-path: polygon(50% 0, 92% 22%, 50% 48%, 18% 14%); background: rgba(255,255,255,.35); }
.look.metal::before { left: 8%; right: 8%; top: 24%; height: 52%; background: linear-gradient(135deg, rgba(255,255,255,.75), var(--c) 32%, color-mix(in srgb, var(--c) 55%, #000) 78%, var(--c)); box-shadow: 0 2px 4px rgba(0,0,0,.6); }
.look.metal::after { left: 16%; top: 30%; width: 40%; height: 8%; background: rgba(255,255,255,.55); transform: rotate(-20deg); filter: blur(1px); }
.look.lumps::before { inset: 0; background: radial-gradient(circle at 30% 66%, var(--c) 26%, transparent 27.5%), radial-gradient(circle at 64% 70%, var(--c) 30%, transparent 31.5%), radial-gradient(circle at 48% 40%, var(--c) 22%, transparent 23.5%); }
.look.lumps::after { inset: 0; background: radial-gradient(circle at 24% 60%, rgba(255,255,255,.4) 6%, transparent 8%), radial-gradient(circle at 58% 64%, rgba(255,255,255,.4) 7%, transparent 9%), radial-gradient(circle at 44% 34%, rgba(255,255,255,.4) 5%, transparent 7%), radial-gradient(circle at 34% 72%, rgba(0,0,0,.35) 24%, transparent 26%), radial-gradient(circle at 68% 76%, rgba(0,0,0,.35) 28%, transparent 30%); }
.look.granules::before { inset: 10%; background-image: radial-gradient(circle, var(--c) 34%, color-mix(in srgb, var(--c) 60%, #000) 40%, transparent 44%); background-size: 22% 22%; }
.look.ribbon::before { left: 6%; right: 6%; top: 42%; height: 16%; background: linear-gradient(90deg, rgba(255,255,255,.7), var(--c) 30%, color-mix(in srgb, var(--c) 60%, #000) 70%, var(--c)); transform: rotate(-16deg); box-shadow: 0 2px 4px rgba(0,0,0,.6); }
.look.ribbon::after { left: 20%; right: 20%; top: 62%; height: 10%; background: linear-gradient(90deg, var(--c), rgba(255,255,255,.6) 60%, var(--c)); transform: rotate(-16deg); opacity: .8; }
.look.liquid::before { left: 22%; right: 22%; top: 6%; bottom: 8%; border: 2px solid #9a9a9a; border-top: 0; background: linear-gradient(transparent 34%, var(--c) 34%); }
.look.liquid::after { left: 20%; right: 20%; top: 6%; height: 2px; background: #9a9a9a; }
.look.liquid.clear { --c: rgba(150, 200, 240, .45); }
.look.gas::before { inset: 12%; border-radius: 50%; background: radial-gradient(circle, var(--c) 0%, color-mix(in srgb, var(--c) 40%, transparent) 55%, transparent 72%); filter: blur(1px); }
.look.gas.clear::before { background: none; border: 2px dashed rgba(255,255,255,.35); }
.look.gas.clear::after { inset: 32%; border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,.18), transparent 70%); }

/* ---------- beaker ---------- */
.beaker-stage { position: relative; height: 300px; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 46px; background: #000; border: 1px solid var(--line); }
.beaker { position: relative; width: 220px; height: 220px; border: 3px solid var(--glass); border-top: 0; overflow: hidden; background: linear-gradient(90deg, rgba(255,255,255,.10), rgba(255,255,255,0) 30%, rgba(255,255,255,0) 70%, rgba(255,255,255,.07)); box-shadow: inset 0 -8px 14px rgba(255,255,255,.04); transition: box-shadow .5s; }
.beaker::before { content: ""; position: absolute; top: 0; left: -10px; right: -10px; height: 3px; background: var(--glass); z-index: 6; }
.beaker::after { content: ""; position: absolute; right: 12px; top: 40px; width: 14px; height: 120px; background: repeating-linear-gradient(to bottom, var(--glass) 0 2px, transparent 2px 24px); opacity: .5; }
.beaker.shake { animation: shake .5s ease-in-out; }
.beaker.shake-small { animation: shake .4s ease-in-out; animation-iteration-count: 2; }
@keyframes shake { 0%,100% { transform: translate(0,0); } 20% { transform: translate(-5px, 2px) rotate(-1.5deg); } 40% { transform: translate(5px, -2px) rotate(1.5deg); } 60% { transform: translate(-4px, 1px) rotate(-1deg); } 80% { transform: translate(4px, -1px) rotate(1deg); } }
.beaker.glowing { box-shadow: inset 0 0 28px 6px var(--glow); }
.empty-label { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--faint); font-family: var(--mono); font-size: 11px; pointer-events: none; text-transform: uppercase; letter-spacing: .18em; }
.liquid { position: absolute; left: 0; right: 0; bottom: 0; height: 0%; background: var(--water); transition: height .9s ease, background-color 1.4s ease; z-index: 1; }
.liquid::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: rgba(255,255,255,.3); }
.liquid.foam { animation: foam 2.2s ease-out; }
.liquid.foam::after { content: ""; position: absolute; left: 0; right: 0; top: -14px; height: 22px; background: radial-gradient(circle at 10% 60%, #fff 0 5px, transparent 6px), radial-gradient(circle at 30% 40%, #fff 0 6px, transparent 7px), radial-gradient(circle at 52% 65%, #fff 0 5px, transparent 6px), radial-gradient(circle at 72% 35%, #fff 0 7px, transparent 8px), radial-gradient(circle at 90% 60%, #fff 0 5px, transparent 6px); opacity: .95; animation: fadeout 2.4s forwards; }
@keyframes foam { 0% { transform: scaleY(1); } 25% { transform: scaleY(1.3); } 100% { transform: scaleY(1); } }
@keyframes fadeout { 0%,60% { opacity: .95; } 100% { opacity: 0; } }
.frost { position: absolute; inset: 0; z-index: 2; opacity: 0; pointer-events: none; transition: opacity 1s; background: radial-gradient(circle at 20% 80%, rgba(180,220,255,.6), transparent 40%), radial-gradient(circle at 80% 70%, rgba(200,230,255,.5), transparent 35%), linear-gradient(rgba(220,240,255,.15), rgba(200,230,255,.35)); }
.frost.on { opacity: 1; }
.sprites { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.sprite { position: absolute; width: 44px; height: 44px; margin: -22px 0 0 -22px; transition: opacity .5s, transform .5s; filter: drop-shadow(0 1px 2px rgba(0,0,0,.6)); }
.sprite.env { opacity: .5; }
.sprite.big { width: 64px; height: 64px; margin: -32px 0 0 -32px; }
.sprite .look { width: 100%; height: 100%; }
.sprite.float { animation: floaty 3.6s ease-in-out infinite; }
.sprite.drift { animation: drift 5s ease-in-out infinite; }
.sprite.in { animation: pop-in .6s ease-out both; }
.sprite.in.float { animation: pop-in .6s ease-out both, floaty 3.6s ease-in-out .6s infinite; }
.sprite.in.drift { animation: pop-in .6s ease-out both, drift 5s ease-in-out .6s infinite; }
.sprite.out { opacity: 0; transform: scale(.3) rotate(90deg); }
.sprite.react { animation: jitter .12s linear infinite; }
.sprite.settle { animation: settle 2.4s cubic-bezier(.4,0,.8,1) both; }
.sprite.rise { animation: rise-sprite 2.2s ease-out both; }
@keyframes floaty { 0%,100% { translate: 0 0; } 50% { translate: 0 -7px; } }
@keyframes drift { 0%,100% { translate: 0 0; } 33% { translate: 6px -8px; } 66% { translate: -6px -4px; } }
@keyframes pop-in { 0% { opacity: 0; scale: .2; } 70% { scale: 1.15; } 100% { opacity: 1; scale: 1; } }
@keyframes jitter { 0% { translate: -2px 1px; } 25% { translate: 2px -1px; } 50% { translate: -1px -2px; } 75% { translate: 1px 2px; } 100% { translate: -2px 1px; } }
@keyframes settle { 0% { translate: 0 -120px; opacity: 0; } 15% { opacity: 1; } 100% { translate: 0 0; } }
@keyframes rise-sprite { 0% { translate: 0 110px; opacity: 0; } 20% { opacity: 1; } 100% { translate: 0 0; } }
.bubbles { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.bubbles .b { position: absolute; bottom: 4px; width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,.5); border: 1px solid rgba(255,255,255,.9); animation: rise linear infinite; }
@keyframes rise { 0% { transform: translateY(0) scale(.6); opacity: 0; } 15% { opacity: 1; } 100% { transform: translateY(-170px) scale(1.1); opacity: 0; } }
.fx { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.fx .spark { position: absolute; width: 5px; height: 5px; border-radius: 50%; background: var(--c); box-shadow: 0 0 6px 1px var(--c); animation: spark var(--t, 1s) ease-out forwards; }
@keyframes spark { 0% { transform: translate(0,0) scale(1); opacity: 1; } 70% { opacity: 1; } 100% { transform: translate(var(--dx), var(--dy)) scale(.3); opacity: 0; } }
.fx .puff { position: absolute; width: 26px; height: 26px; border-radius: 50%; background: var(--c); opacity: .75; filter: blur(3px); animation: puff var(--t, 2.6s) ease-out forwards; }
@keyframes puff { 0% { transform: translate(0,0) scale(.4); opacity: .8; } 100% { transform: translate(var(--dx), -150px) scale(2.4); opacity: 0; } }
.fx .twinkle { position: absolute; width: 6px; height: 6px; background: var(--c); transform: rotate(45deg) scale(0); box-shadow: 0 0 8px 2px var(--c); animation: twinkle 1.5s ease-in-out var(--d, 0s) 2; }
@keyframes twinkle { 0%,100% { transform: rotate(45deg) scale(0); } 50% { transform: rotate(45deg) scale(1); } }
.flame { position: absolute; left: 50%; bottom: 30px; width: 80px; height: 120px; transform: translateX(-50%); opacity: 0; pointer-events: none; transition: opacity .35s; z-index: 4; --fc: #ff9a2e; background: radial-gradient(ellipse at 50% 92%, #ffffff 0 7%, var(--fc) 28%, color-mix(in srgb, var(--fc) 55%, transparent) 55%, transparent 72%); border-radius: 50% 50% 40% 40%; filter: blur(1px) drop-shadow(0 0 12px var(--fc)); }
.beaker-stage.burning .flame { opacity: 1; animation: flicker .16s infinite alternate; }
@keyframes flicker { from { transform: translateX(-50%) scaleY(1) scaleX(1); } to { transform: translateX(-52%) scaleY(1.09) scaleX(.93); } }
.flash { position: absolute; inset: 0; background: var(--flash, #fff); opacity: 0; pointer-events: none; z-index: 7; }
.beaker-stage.flashing .flash { animation: flash 1.3s ease-out forwards; }
@keyframes flash { 0% { opacity: .7; } 100% { opacity: 0; } }
.shock { position: absolute; left: 50%; top: 55%; width: 20px; height: 20px; margin: -10px 0 0 -10px; border-radius: 50%; border: 4px solid rgba(255,230,160,.95); opacity: 0; pointer-events: none; z-index: 6; }
.beaker-stage.boom .shock { animation: shock .9s ease-out forwards; }
@keyframes shock { 0% { transform: scale(.2); opacity: 1; } 100% { transform: scale(14); opacity: 0; border-width: 1px; } }
.burner { position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); width: 90px; height: 46px; display: none; }
.beaker-stage.heat .burner { display: block; }
.burner-base { position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); width: 60px; height: 12px; background: #555; }
.burner-base::before { content: ""; position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); width: 14px; height: 40px; background: #777; z-index: -1; }
.burner-flame { position: absolute; bottom: 30px; left: 50%; transform: translateX(-50%); width: 26px; height: 40px; background: radial-gradient(ellipse at 50% 100%, #bde3ff 0 15%, #3aa0ff 40%, rgba(58,160,255,0) 72%); border-radius: 50% 50% 30% 30%; animation: flicker .2s infinite alternate; }
.electrodes { position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 130px; height: 150px; display: none; justify-content: space-between; z-index: 8; pointer-events: none; }
.beaker-stage.electricity .electrodes { display: flex; }
.electrodes span { width: 8px; height: 100%; background: linear-gradient(#555, #aaa); position: relative; }
.electrodes span::after { content: "−"; position: absolute; top: -20px; left: -2px; font-weight: 600; color: var(--muted); }
.electrodes span:last-child::after { content: "+"; }
.lamp { position: absolute; top: 4px; right: 40px; width: 34px; height: 34px; border-radius: 50%; background: radial-gradient(#fff6c2, #ffd83a 60%, rgba(255,216,58,0) 72%); display: none; box-shadow: 0 0 30px 10px rgba(255,220,80,.35); }
.beaker-stage.light .lamp { display: block; }
.thermo { position: absolute; right: 8px; bottom: 50px; width: 44px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.thermo-tube { width: 10px; height: 110px; background: var(--panel-2); border: 1px solid var(--line-2); position: relative; overflow: hidden; }
.thermo-fill { position: absolute; left: 0; right: 0; bottom: 0; height: 40%; background: #8a8a8a; transition: height 1.2s ease, background .6s; }
.thermo.exo .thermo-fill { height: 92%; background: var(--hot); }
.thermo.endo .thermo-fill { height: 12%; background: var(--cold); }
.thermo-label { font-family: var(--mono); font-size: 9.5px; color: var(--muted); text-align: center; line-height: 1.2; min-height: 24px; text-transform: uppercase; letter-spacing: .1em; }
.caption { text-align: center; font-size: 12.5px; color: var(--muted); min-height: 20px; margin-top: 8px; }
.contents { display: flex; flex-wrap: wrap; gap: 5px; margin: 10px 0; min-height: 34px; }
.contents .stage-label { width: 100%; margin-top: 8px; }
.item-chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-2); background: #000; padding: 2px 8px 2px 3px; font-size: 13px; }
.item-chip .thumb { width: 26px; height: 26px; }
.item-chip .x { display: inline-flex; border: 0; background: transparent; color: var(--muted); padding: 0 2px; }
.item-chip .x .ic { margin: 0; width: 14px; height: 14px; }
.item-chip .x:hover { color: var(--warn); }
.item-chip.product { border-color: rgba(255,255,255,.5); }
.item-chip.spectator, .item-chip.env { opacity: .7; }
.conds { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.cond { display: inline-flex; align-items: center; gap: 2px; height: 34px; border: 1px solid var(--line-2); padding: 0 10px; cursor: pointer; user-select: none; font-size: 13px; font-weight: 500; transition: all .12s; }
.cond:hover { border-color: rgba(255,255,255,.5); }
.cond:has(input:checked) { background: var(--accent); border-color: var(--accent); color: #000; font-weight: 600; }
.cond input { margin: 0 6px 0 0; accent-color: #000; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.hints { margin-top: 14px; }
.hints .h-title { margin-bottom: 6px; }
.hint { display: inline-flex; align-items: center; gap: 6px; border: 1px dashed var(--line-2); color: var(--ink-2); background: transparent; padding: 3px 10px 3px 6px; font-size: 12.5px; margin: 0 4px 4px 0; transition: background .12s; }
.hint .thumb { width: 22px; height: 22px; }
.hint:hover { border-color: rgba(255,255,255,.5); color: #fff; }

/* ---------- results ---------- */
.results { min-height: 0; }
.rcard { border: 1px solid var(--line); padding: 16px; margin-bottom: 12px; background: #000; }
.rcard.good { border-color: var(--line-2); }
.rcard.none { border-color: var(--warn); background: var(--warn-soft); }
.rcard h3 { display: flex; align-items: center; gap: 8px; font-size: 20px; font-weight: 500; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0 10px; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-family: var(--mono); font-size: 10px; padding: 3px 8px; background: transparent; color: var(--ink-2); font-weight: 500; cursor: help; border: 1px solid var(--line-2); letter-spacing: .1em; text-transform: uppercase; }
.badge .ic { width: 13px; height: 13px; }
.badge.cond { border-style: dashed; }
.badge.exo { color: #e9a08e; } .badge.endo { color: #9fbfe8; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; margin: 12px 0; background: var(--line); border: 1px solid var(--line); }
.fact { background: #000; padding: 10px 12px; }
.fact .v { font-weight: 500; margin-top: 4px; color: #fff; font-size: 15px; }
.ebar { height: 3px; background: var(--line-2); margin-top: 8px; overflow: hidden; }
.ebar i { display: block; height: 100%; background: var(--hot); }
.ebar.endo i { background: var(--cold); }
.sect { margin-top: 14px; }
.sect h4 { margin-bottom: 5px; }
details.sect { border-top: 1px solid var(--line); padding: 10px 0 4px; margin-top: 8px; }
details.sect summary { cursor: pointer; font-weight: 500; color: #fff; list-style: none; display: flex; align-items: center; gap: 10px; font-size: 14px; }
details.sect summary::before { content: ""; width: 0; height: 0; border-left: 6px solid var(--muted); border-top: 5px solid transparent; border-bottom: 5px solid transparent; transition: transform .15s; }
details.sect[open] summary::before { transform: rotate(90deg); }
details.sect summary:hover { color: #fff; }
table.bal { border-collapse: collapse; width: 100%; font-size: 13.5px; margin-top: 10px; }
table.bal th, table.bal td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: center; }
table.bal th { color: var(--muted); font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: .14em; font-weight: 500; }
table.bal th:first-child, table.bal td:first-child { text-align: left; }
table.bal tr.bad td { color: var(--warn); }
.ok { color: #9fd89f; font-weight: 600; } .bad { color: var(--warn); font-weight: 700; }
.ok .ic, .bad .ic { width: 16px; height: 16px; }
.match-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; }
.calc input { width: 84px; height: 30px; padding: 0 6px; border: 1px solid var(--line-2); background: #000; color: #fff; }
.demo-btns { display: grid; grid-template-columns: 1fr; gap: 0; margin-top: 8px; border-top: 1px solid var(--line); }
.demo-btns .btn { text-align: left; display: flex; justify-content: space-between; align-items: center; height: auto; padding: 10px 4px; border: 0; border-bottom: 1px solid var(--line); color: #fff; }
.demo-btns .btn::after { content: "›"; color: var(--faint); font-size: 18px; margin-left: 12px; }
.demo-btns .btn:hover { color: #fff; background: rgba(255,255,255,.04); }
.demo-btns .btn:hover::after { color: #fff; }
.demo-btns .btn small { display: block; color: var(--muted); font-weight: 400; font-family: var(--mono); font-size: 10.5px; margin-top: 3px; text-transform: uppercase; letter-spacing: .1em; }
.demo-btns .btn > small { display: inline; }
.chem-row { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.chem-row .thumb { width: 40px; height: 40px; flex: none; }

/* ---------- pages ---------- */
.page-head { margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.page-head h1 { display: flex; align-items: baseline; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 12px; }
.chem-cards { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.card { background: #000; border: 1px solid var(--line); padding: 16px; transition: border-color .12s; }
.card.clickable { cursor: pointer; }
.card.clickable:hover { border-color: rgba(255,255,255,.45); }
.card h3 { font-size: 16px; }
.card .row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.chem-card { display: flex; gap: 12px; align-items: center; }
.chem-card .thumb { width: 64px; height: 64px; flex: none; background: #000; border: 1px solid var(--line); padding: 4px; }
.chem-card .f { font-size: 18px; font-weight: 500; color: #fff; }
.chem-card .n { color: var(--muted); font-size: 12px; margin-top: 2px; }
.chem-card .cond-f { color: var(--muted); font-size: 12px; font-weight: 500; font-family: var(--mono); }
.dot { display: inline-block; width: 12px; height: 12px; border: 1px solid rgba(255,255,255,.3); vertical-align: -1px; margin-right: 5px; }
.custom-tag { font-family: var(--mono); font-size: 9.5px; background: var(--panel-3); color: #fff; border: 1px solid var(--line-2); padding: 1px 6px; margin-left: 8px; vertical-align: middle; text-transform: uppercase; letter-spacing: .12em; font-weight: 600; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }
.form-card label { display: block; font-size: 12.5px; color: var(--muted); margin: 10px 0; }
.form-card label.inline { display: inline-flex; align-items: center; gap: 5px; margin: 0; }
.form-card input:not([type=checkbox]):not([type=color]):not([type=file]), .form-card textarea { display: block; width: 100%; margin-top: 5px; padding: 8px 10px; border: 1px solid var(--line-2); background: #000; color: #fff; }
.form-card select { margin-top: 5px; }
.form-card input:focus, .form-card textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.form-card input[type=color] { width: 36px; height: 28px; padding: 0; border: 1px solid var(--line-2); background: none; vertical-align: middle; }
.form-card input[type=checkbox] { accent-color: var(--accent); }
.form-card .row { display: flex; gap: 10px; align-items: center; margin-top: 10px; }
.form-card .row.wrap { flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 600px) { .grid2 { grid-template-columns: 1fr; } }
fieldset { border: 1px solid var(--line); padding: 6px 12px 10px; margin: 10px 0; min-width: 0; }
legend { padding: 0 6px; }
.checks { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.checks label { display: inline-flex; align-items: center; gap: 5px; margin: 2px 0; color: #fff; }
.preview { background: #000; border: 1px solid var(--line); padding: 12px; margin: 10px 0; font-size: 14px; min-height: 40px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.preview .thumb { width: 72px; height: 72px; flex: none; background: #000; border: 1px solid var(--line); }
.preview .err { color: var(--warn); }
.fmt-help pre { background: #000; border: 1px solid var(--line); padding: 12px; overflow: auto; font-size: 12px; color: #ddd; font-family: var(--mono); }
.fmt-help summary { color: #fff; cursor: pointer; font-weight: 500; }
.custom-list { margin-top: 10px; font-size: 13.5px; }
.custom-list .ci { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.custom-list .ci .x { margin-left: auto; }

/* ---------- learn ---------- */
.learn { max-width: 920px; margin: 0 auto; }
.learn section { background: #000; border-top: 1px solid var(--line); padding: 22px 0 26px; margin-bottom: 8px; }
.learn h1 { font-size: 40px; font-weight: 500; letter-spacing: -.03em; line-height: 1.05; margin-bottom: .5em; }
.learn h2 { font-size: 26px; font-weight: 500; letter-spacing: -.02em; }
.learn p { max-width: 72ch; }
.learn .anatomy { display: flex; flex-wrap: wrap; gap: 6px 26px; justify-content: center; font-size: 34px; padding: 18px 0 8px; color: #fff; }
.learn .anatomy .part { display: flex; flex-direction: column; align-items: center; }
.learn .anatomy .lbl { margin-top: 4px; color: var(--muted); }
.learn .anatomy .hl { color: #fff; text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 6px; }
.learn .anatomy .hl2 { color: var(--warn); }
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.type-card { border: 1px solid var(--line); padding: 14px; background: #000; }
.type-card h3 { color: #fff; }
.type-card .pattern { font-family: var(--mono); color: #fff; font-weight: 500; margin: 4px 0 8px; font-size: 13px; letter-spacing: .04em; }
.series { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; margin: 10px 0; }
.series .el { padding: 6px 10px; font-weight: 600; color: #fff; min-width: 44px; text-align: center; }
.series .arr { color: var(--muted); }
.flames { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.flame-card { display: flex; align-items: center; gap: 10px; background: #000; border: 1px solid var(--line); padding: 8px 10px; }
.flame-card .fl { width: 26px; height: 40px; border-radius: 50% 50% 40% 40%; background: radial-gradient(ellipse at 50% 95%, #fff 0 10%, var(--fc) 35%, transparent 72%); filter: drop-shadow(0 0 6px var(--fc)); flex: none; }
.glossary { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 0 24px; }
.glossary dt { font-weight: 600; margin-top: 10px; color: #fff; } .glossary dd { margin: 0 0 4px; color: var(--muted); font-size: 13.5px; }
.diagram-types { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.diagram-types .dt { background: #000; border: 1px solid var(--line); padding: 12px; }
.diagram-types .dt .thumb { width: 100%; height: 120px; background: #000; margin-bottom: 8px; border: 1px solid var(--line); }
.diagram-types .dt b { display: block; color: #fff; margin-bottom: 2px; }

/* ---------- modal / structure viewer ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.82); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal-box { background: #000; border: 1px solid var(--line-2); max-width: 920px; width: 100%; max-height: 92vh; overflow: auto; padding: 0; position: relative; }
.modal-body { padding: 18px 24px 24px; }
.modal-close { position: absolute; top: 10px; right: 10px; border: 1px solid var(--line-2); background: #000; width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; color: #fff; z-index: 2; }
.modal-close:hover { border-color: #fff; }
.modal-close .ic { margin: 0; width: 18px; height: 18px; }
.mhead { display: flex; align-items: center; gap: 16px; padding: 20px 60px 16px 24px; border-bottom: 1px solid var(--line); background: var(--panel); }
.mhead .thumb { width: 56px; height: 56px; background: #000; border: 1px solid var(--line); flex: none; }
.mhead h2 { margin: 0; font-size: 26px; font-weight: 500; letter-spacing: -.02em; }
.mhead .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.struct { display: grid; grid-template-columns: 1fr 250px; border: 1px solid var(--line); margin: 0 0 16px; background: #000; }
@media (max-width: 700px) { .struct { grid-template-columns: 1fr; } }
.struct-tabs { grid-column: 1 / -1; display: flex; flex-wrap: wrap; border-bottom: 1px solid var(--line); background: #000; }
.stab { display: inline-flex; align-items: center; height: 40px; padding: 0 14px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font-weight: 500; font-size: 13px; transition: all .12s; }
.stab:hover { color: #fff; }
.stab.active { color: #fff; border-bottom-color: var(--accent); }
.struct-view { position: relative; height: 360px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.struct-view .mol { max-width: 100%; max-height: 100%; }
.struct-view .c3d { width: 100%; height: 100%; display: block; touch-action: none; }
.c3d-hint { position: absolute; left: 12px; bottom: 10px; font-family: var(--mono); font-size: 10px; color: var(--faint); pointer-events: none; text-transform: uppercase; letter-spacing: .16em; }
.c3d-shape { position: absolute; left: 12px; top: 10px; font-family: var(--mono); font-size: 10.5px; color: var(--muted); pointer-events: none; text-transform: uppercase; letter-spacing: .14em; }
.struct-info { border-left: 1px solid var(--line); padding: 14px; font-size: 13px; background: var(--panel); overflow: auto; }
@media (max-width: 700px) { .struct-info { border-left: 0; border-top: 1px solid var(--line); } }
.struct-info h4 { margin: 0 0 8px; }
.struct-info .el-name { font-size: 19px; font-weight: 500; display: flex; align-items: center; gap: 8px; color: #fff; }
.struct-info .el-swatch { width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgba(255,255,255,.4); }
.struct-info .kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: 12.5px; margin: 10px 0; }
.struct-info .kv span:nth-child(odd) { color: var(--muted); }
.struct-info .kv span:nth-child(even) { color: #fff; }
.struct-info .atoms { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.struct-info .atoms span { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); padding: 2px 8px; font-size: 12px; color: #fff; }
.formulas { display: grid; gap: 1px; width: 100%; padding: 16px; }
.formulas .frow { display: grid; grid-template-columns: 180px 1fr; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.formulas .frow .v { font-size: 24px; font-weight: 500; color: #fff; }
.formulas .frow .v small { display: block; font-size: 12px; color: var(--muted); font-weight: 400; margin-top: 3px; }
.tip3d { position: absolute; pointer-events: none; background: #000; border: 1px solid var(--line-2); color: #fff; padding: 4px 8px; font-family: var(--mono); font-size: 11px; letter-spacing: .06em; white-space: nowrap; z-index: 3; transform: translate(12px, -28px); }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px); background: #151515; color: #fff; border: 1px solid var(--line-2); padding: 9px 16px; opacity: 0; transition: all .25s; pointer-events: none; z-index: 60; font-size: 13.5px; font-weight: 600; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- canvas beaker ---------- */
.beaker-stage { height: auto; aspect-ratio: 9 / 10; max-height: 420px; padding: 0; display: block; background: #000; border: 1px solid var(--line); }
.beaker-canvas { width: 100%; height: 100%; display: block; }
.mol-toggle { margin-left: auto; }

/* ---------- explanations ---------- */
.why-list { margin: 6px 0 0; padding-left: 20px; }
.why-list li { margin: 0 0 8px; line-height: 1.55; }
.why-list li b { color: #fff; }
table.bal.ox td:first-child { font-weight: 500; }
/* ---------- enzyme card ---------- */
.enzyme-card { display: grid; grid-template-columns: 220px 1fr; gap: 14px; border: 1px solid var(--line); padding: 12px; margin-top: 12px; background: var(--panel); }
@media (max-width: 700px) { .enzyme-card { grid-template-columns: 1fr; } }
.enzyme-card canvas { width: 100%; height: 150px; display: block; background: #000; border: 1px solid var(--line); }
.enzyme-card .kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; font-size: 12.5px; margin: 6px 0; }
.enzyme-card .kv span:nth-child(odd) { color: var(--muted); }
/* ---------- periodic table key ---------- */
.pt-key { grid-column: 5 / 13; grid-row: 1 / 3; display: flex; align-items: center; gap: 18px; padding: 6px 12px; border: 1px dashed var(--line-2); }
.pt-key .big { position: relative; width: 96px; height: 96px; border: 1px solid #ffd43b; background: color-mix(in srgb, #ffd43b 16%, #000); flex: none; }
.pt-key .big .n { position: absolute; top: 6px; left: 8px; font-family: var(--mono); font-size: 11px; color: #cfcfcf; }
.pt-key .big .en { position: absolute; top: 6px; right: 8px; font-family: var(--mono); font-size: 11px; color: #e8e8e8; }
.pt-key .big .s { position: absolute; top: 28px; left: 8px; font-size: 30px; font-weight: 600; color: #fff; line-height: 1; }
.pt-key .big .m { position: absolute; bottom: 6px; left: 8px; font-family: var(--mono); font-size: 11px; color: #bdbdbd; }
.pt-key .keys { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; font-size: 12px; }
.pt-key .keys b { display: block; font-family: var(--mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
/* ---------- microscope ---------- */
.micro-wrap { position: absolute; inset: 0; display: flex; flex-direction: column; }
.micro-wrap canvas { flex: 1; width: 100%; min-height: 0; display: block; }
.micro-levels { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px; border-top: 1px solid var(--line); background: #000; }
.micro-levels button { border: 1px solid var(--line-2); background: transparent; color: var(--muted); font-family: var(--mono); font-size: 10px; letter-spacing: .06em; padding: 4px 8px; }
.micro-levels button.active { background: #fff; color: #000; border-color: #fff; }
/* ---------- nanite forge ---------- */
.forge { display: grid; grid-template-columns: 320px 1fr 300px; gap: 16px; align-items: start; }
@media (max-width: 1200px) { .forge { grid-template-columns: 1fr 1fr; } .forge-view { grid-column: 1 / -1; grid-row: 1; } }
@media (max-width: 760px) { .forge { grid-template-columns: 1fr; } }
.forge-code textarea { width: 100%; margin: 10px 0; padding: 10px; background: #000; color: #fff; border: 1px solid var(--line-2); font-family: var(--mono); font-size: 12.5px; line-height: 1.5; resize: vertical; }
.forge-code textarea:focus { outline: none; border-color: var(--accent); }
.forge-code .row { display: flex; gap: 6px; align-items: center; }
.forge-code .row.wrap { flex-wrap: wrap; }
.forge-code pre { white-space: pre-wrap; font-size: 11.5px; }
.forge-canvas { width: 100%; aspect-ratio: 640 / 420; display: block; background: #050505; border: 1px solid var(--line); }
.nan-log { max-height: 560px; overflow: auto; font-size: 12.5px; display: flex; flex-direction: column; gap: 6px; }
.nan-log .l { padding: 6px 8px; border-left: 2px solid var(--line-2); background: #000; }
.nan-log .l.step { border-left-color: var(--accent); }
.nan-log .l.error { border-left-color: var(--warn); color: var(--warn); }
.nan-log .l.say { border-left-color: #fff; color: #fff; font-weight: 500; }
.nan-log .l.info { color: var(--muted); }
.ai-win textarea { width: 100%; min-height: 90px; padding: 10px; background: #000; color: #fff; border: 1px solid var(--line-2); font-family: var(--sans); }
.ai-win .out { white-space: pre-wrap; font-family: var(--mono); font-size: 12px; background: #000; border: 1px solid var(--line); padding: 10px; margin-top: 10px; max-height: 260px; overflow: auto; }
.ai-win .settings { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; margin-top: 10px; }
.ai-win .settings label { font-size: 12px; color: var(--muted); }
.ai-win .settings input, .ai-win .settings select { width: 100%; margin-top: 4px; padding: 7px 10px; background: #000; color: #fff; border: 1px solid var(--line-2); }
.ai-win .status { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 8px; min-height: 16px; }

/* ---------- site search ---------- */
.gsearch { position: relative; flex: 1 1 260px; max-width: 460px; min-width: 200px; }
.gsearch > .ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); width: 16px; height: 16px; }
.gsearch input { width: 100%; height: 36px; padding: 0 12px 0 34px; border: 1px solid var(--line-2); background: #000; color: #fff; outline: none; font-size: 13.5px; }
.gsearch input:focus { border-color: var(--accent); box-shadow: var(--focus); }
.gsearch-dd { position: absolute; top: calc(100% + 6px); left: 0; right: 0; min-width: 380px; background: #000; border: 1px solid var(--line-2); z-index: 40; max-height: 70vh; overflow: auto; box-shadow: 0 20px 50px rgba(0,0,0,.8); }
.gs-item { display: grid; grid-template-columns: 96px 1fr; gap: 10px; width: 100%; text-align: left; padding: 8px 12px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: #fff; }
.gs-item:hover, .gs-item.sel { background: var(--panel-2); }
.gs-item b { font-weight: 500; }
.gs-type { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); padding-top: 3px; }
.gs-sub { font-size: 12px; color: var(--muted); }
.gs-fix, .gs-empty { padding: 8px 12px; font-size: 12.5px; color: var(--muted); border-bottom: 1px solid var(--line); }
/* ---------- assistant ---------- */
.chat { max-height: 46vh; overflow: auto; display: flex; flex-direction: column; gap: 8px; padding: 4px 0; }
.msg { max-width: 88%; padding: 8px 12px; font-size: 14px; line-height: 1.5; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--accent); color: #000; }
.msg.assistant { align-self: flex-start; background: var(--panel-2); border: 1px solid var(--line); color: #fff; }
.ai-fix { font-size: 12.5px; color: var(--muted); margin-top: 6px; padding: 6px 8px; border: 1px dashed var(--line-2); }
.ai-fix s { color: var(--warn); } .ai-fix b { color: #fff; }
/* ---------- atom diagrams ---------- */
.pt-cell.flipped { padding: 0; background: #000; }
.pt-cell.flipped svg { width: 100%; height: 100%; display: block; }
.bohr-wrap { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; height: 100%; }
.bohr-wrap svg { max-height: 300px; }
.bohr-cap { font-family: var(--mono); font-size: 10.5px; color: var(--muted); letter-spacing: .1em; text-transform: uppercase; margin-top: 4px; }

.pt-cell.flipped canvas.pt-atom { width: 100%; height: 100%; display: block; }

.ai-settings .settings select { width: 100%; margin-top: 4px; padding: 7px 34px 7px 10px; background: #000; color: #fff; border: 1px solid var(--line-2); -webkit-appearance: none; appearance: none; }

/* ---------- phones and tablets (touch only, added 2026-10-07; desktop unchanged) ---------- */
@media (hover: none) and (pointer: coarse) {
  /* 16px stops iOS zooming into every field */
  input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]):not([type=file]), select, textarea { font-size: 16px !important; }
  /* 44px tap targets */
  .btn, .btn.small, .tool, .cond, .search, select.sel, .form-card select, .stab, .chip, .micro-levels button { min-height: 44px; }
  .tabs button { height: 44px; }
  .gsearch input { height: 44px; }
  .modal-close { width: 44px; height: 44px; }
  .chip { min-width: 44px; }
  .form-card input:not([type=checkbox]):not([type=radio]):not([type=color]):not([type=file]) { min-height: 44px; }
  .form-card input[type=color] { width: 44px; height: 44px; }
  details.sect summary { min-height: 44px; }
  .fmt-help summary { padding: 12px 0; }
  .cond input { width: 18px; height: 18px; }
  .foot a { display: inline-block; padding: 13px 0; }
  /* small mono labels up to 12px */
  .eyebrow, .panel-h, .sel-label, .fact .k, .sect h4, .stage-label, .hints .h-title, legend, .ion-group h3, .struct-info h4, .formulas .frow .k, .learn .anatomy .lbl, .tpanel .lead,
  .brand-sub, .count, .tool-sel, .foot, .empty-label, .badge, .thermo-label, .custom-tag, .c3d-hint, .c3d-shape, .bohr-cap, .demo-btns .btn small, table.bal th, .pt-key .keys b, .micro-levels button { font-size: 12px; }
}
@media (hover: none) and (pointer: coarse) and (max-width: 900px), (hover: none) and (pointer: coarse) and (max-height: 500px) {
  /* the tall header would cover half a phone screen if it stayed stuck to the top */
  .top { position: relative; padding: 12px 56px 12px 16px; }
  /* every tab visible: the row wraps instead of running off the right edge.
     The first header row keeps the top-right corner free for the account button; the rows below use the full width. */
  .tabs { flex-wrap: wrap; margin-right: -40px; }
  .tools { margin-right: -40px; }
  main { padding: 20px 16px 40px; }
  /* long option names must not stretch the lab columns past the screen */
  #tab-lab > * { min-width: 0; }
  .gsearch-dd { min-width: 0; }
  .demo-btns { grid-template-columns: minmax(0, 1fr); }
  .demo-btns .btn { white-space: normal; }
  /* long equations, formulas and tables stay inside the screen */
  .eq .plus, .eq .arrow { display: inline-block; }
  .eq { overflow-wrap: break-word; }
  .cards > * { min-width: 0; }
  .chem-card > div { min-width: 0; overflow-wrap: anywhere; }
  table.bal { display: block; overflow-x: auto; }
  .foot { padding: 12px 16px; }
}
