/* ───────────────────────── Flame Studio ─────────────────────────
   zperiod.app's calm, warm glass, light or dark as zperiod.app is (html.dark-theme). */

:root {
  --bg: #fdfbf7;
  --text: #2c2420;
  --text2: #5d544f;
  --muted: #8f867f;
  --slate: #56698f;
  --glass: rgba(255, 255, 255, 0.92);
  --glass-strong: rgba(255, 255, 255, 0.95);
  --edge: rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.16);
  --chip: rgba(0, 0, 0, 0.05);
  --chip-hover: rgba(0, 0, 0, 0.09);
  --seg-track: rgba(0, 0, 0, 0.04);
  --seg-thumb: #ffffff;
  --accent: #23838b;
  --accent-soft: rgba(35, 131, 139, 0.12);
  /* zperiod.app's tokens (css/base.css), for the pages copied from it. */
  --bg-color: #fdfbf7;
  --element-bg: #f5efe6;
  --text-primary: #2c2420;
  --text-secondary: #5d544f;
  --text-highlight: #78350f;
  --border-color: rgba(0, 0, 0, 0.06);
  --ease-snappy: cubic-bezier(0.22, 1, 0.36, 1);
  --dur-fast: 180ms;
  --nav-clearance: calc(16px + 56px * var(--global-nav-scale));
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
  --global-nav-scale: 1;
  --radius: 16px;
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

html.dark-theme {
  --bg-color: #0e0e12;
  --element-bg: #1a1a22;
  --text-primary: #e8e6f0;
  --text-secondary: #9a97a8;
  --text-highlight: #f0a050;
  --border-color: rgba(255, 255, 255, 0.06);
  --bg: #0b0b0d;
  --text: #f3efe9;
  --text2: #b9b2ab;
  --muted: #837d76;
  --slate: #8fa3cc;
  --glass: rgba(28, 28, 33, 0.72);
  --glass-strong: rgba(34, 34, 40, 0.9);
  --edge: rgba(255, 255, 255, 0.09);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.45);
  --chip: rgba(255, 255, 255, 0.06);
  --chip-hover: rgba(255, 255, 255, 0.11);
  --seg-track: rgba(255, 255, 255, 0.06);
  --seg-thumb: rgba(255, 255, 255, 0.16);
  --accent: #6bbdc4;
  --accent-soft: rgba(107, 189, 196, 0.16);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden; }
body { font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; -webkit-user-select: none; user-select: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; opacity: 0.4; }
h2, p { margin: 0; }
.ic { width: 18px; height: 18px; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; cursor: grab; }
#stage:active { cursor: grabbing; }

.glass {
  background: var(--glass);
  border: 1px solid var(--edge);
  box-shadow: var(--shadow-lg);
  -webkit-backdrop-filter: saturate(140%) blur(18px);
  backdrop-filter: saturate(140%) blur(18px);
}

/* ───────── Top bar: zperiod.app's floating nav, in its dark form ───────── */
.top {
  position: fixed; left: 12px; right: 12px; top: calc(12px + var(--safe-t)); z-index: 10000; height: calc(56px * var(--global-nav-scale));
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; padding: 0 12px 0 18px;
  border-radius: calc(28px * var(--global-nav-scale)); background: rgba(18, 18, 24, 0.78); border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: background 0.35s var(--ease), border-color 0.35s, box-shadow 0.35s;
}
.lead { justify-self: start; display: flex; align-items: center; gap: 8px; min-width: 0; }
/* Back to zperiod.app: a pill at the head of the nav, in the language button's colours. */
.zp-back {
  display: inline-flex; align-items: center; gap: 2px; height: 34px; padding: 0 13px 0 8px; flex-shrink: 0;
  border-radius: 18px; background: rgba(255, 255, 255, 0.08); color: #9a97a8; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  font-weight: 600; font-size: 13.5px; text-decoration: none; white-space: nowrap;
  transition: background-color 0.16s ease, color 0.16s ease, transform 0.16s ease, opacity 0.35s var(--ease);
}
.zp-back svg { width: 17px; height: 17px; transition: transform 0.2s ease; }
.zp-back:hover { background: rgba(255, 255, 255, 0.14); color: #e8e6f0; }
.zp-back:hover svg { transform: translateX(-2px); }
.zp-back:active { transform: scale(0.96); }
html:not(.dark-theme) .zp-back { background: rgba(0, 0, 0, 0.04); color: #555; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); }
html:not(.dark-theme) .zp-back:hover { background: rgba(0, 0, 0, 0.07); color: #1d1d1f; }
body.clean .zp-back { opacity: 0; pointer-events: none; }
.brand { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 10px 0 4px; border-radius: 999px; }
.brand.home { cursor: pointer; }
.brand .ic { width: 22px; height: 22px; color: #ffb15a; }
.wordmark { display: flex; align-items: flex-start; gap: 3px; }
.wordmark b { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.wordmark sup { font-size: 9.5px; font-weight: 700; letter-spacing: 0.04em; color: #ffb15a; opacity: 0.9; margin-top: -2px; white-space: nowrap; }
/* Same size as the top navigation on zperiod.app (--segment-* in public/shared/segmented-control.css). */
.seg { position: relative; display: flex; padding: calc(4px * var(--global-nav-scale)); border-radius: calc(22px * var(--global-nav-scale)); gap: 0; background: var(--seg-track); }
.seg button { position: relative; z-index: 1; height: calc(36px * var(--global-nav-scale)); min-width: calc(74px * var(--global-nav-scale)); padding: 0 calc(20px * var(--global-nav-scale)); border-radius: calc(18px * var(--global-nav-scale)); font-size: calc(0.9rem * var(--global-nav-scale)); font-weight: 600; color: var(--text2); transition: color 0.18s; white-space: nowrap; }
.seg button[aria-selected="true"] { color: var(--text); }
/* Learn opens over the current room: only its tab is lit while it is open. */
.seg:has(#modeLearn[aria-selected="true"]) button:not(#modeLearn) { color: var(--text2); }
/* zperiod.app's sliding pill (css/base.css .nav-pill-slider), sized for this bar. */
.nav-pill-slider {
  position: absolute;
  top: calc(4px * var(--global-nav-scale));
  left: 0;
  height: calc(100% - 8px * var(--global-nav-scale));
  border-radius: calc(18px * var(--global-nav-scale));
  background: var(--seg-thumb);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  transition: transform 280ms cubic-bezier(0.34, 1.56, 0.64, 1),
    width 280ms cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 0;
  pointer-events: none;
}
html:not(.dark-theme) .nav-pill-slider { box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); }
/* Identify and Learn have no picture to save or clear. */
body.plain #photo, body.plain #clean { display: none !important; }
.tools { justify-self: end; display: flex; align-items: center; gap: 10px; }
.tools .iconbtn { width: 34px; padding: 0; justify-content: center; border-radius: 50%;
  background: rgba(255, 255, 255, 0.08); color: #9a97a8; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06); }
.tools .iconbtn:hover { background: rgba(255, 255, 255, 0.14); color: #e8e6f0; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12); }
.tools #resetLabel { display: none; }
.tools .ic { width: 15px; height: 15px; }
.tools .sep { display: none; }
.iconbtn { display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 999px; font-weight: 600; color: var(--text2); transition: background 0.16s, color 0.16s, box-shadow 0.16s; }
.iconbtn:hover { background: var(--chip); color: var(--text); }
#reset { display: none; }
#reset.show { display: flex; }

/* ───────── Information card ───────── */
.info {
  pointer-events: auto;
  position: fixed; z-index: 2; right: 16px; top: calc(82px + var(--safe-t));
  width: 320px; max-height: calc(100% - 250px); overflow: auto;
  border-radius: 20px; padding: 16px 18px 18px;
}
.kicker { font-size: 11px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--slate); margin-bottom: 6px; }
:lang(zh) .kicker, :lang(zh) .card-h { letter-spacing: 0.06em; text-transform: none; }
.info h2 { font-size: 20px; line-height: 1.2; font-weight: 750; letter-spacing: -0.01em; }
.info .lead { margin-top: 8px; color: var(--text); }
.info .why, .info .note { margin-top: 10px; color: var(--text2); font-size: 13px; }
.salt-h { display: flex; align-items: center; gap: 12px; }
/* The element as zperiod's periodic table draws it: its category's colours, the atomic number in the corner. */
.sym { flex: none; position: relative; width: 46px; height: 46px; border-radius: 10px; display: grid; place-items: center; font-size: 19px; font-weight: 700;
  background: var(--cat-bg, #3a3a44); color: var(--cat-fg, #e6e6ea); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); }
.sym .z { position: absolute; top: 4px; left: 5px; font-size: 9px; font-weight: 800; line-height: 1; opacity: 0.8; }
.sym.cat-alkali { --cat-bg: #6c303d; --cat-fg: #ff9ca8; }
.sym.cat-alkaline { --cat-bg: #6b5425; --cat-fg: #ffd37d; }
.sym.cat-transition { --cat-bg: #666122; --cat-fg: #fff27a; }
.sym.cat-metalloid { --cat-bg: #1f5d53; --cat-fg: #8ff2dc; }
.formula { color: var(--text2); font-size: 13px; margin-top: 2px; }
.hue { display: flex; align-items: center; gap: 8px; margin: 12px 0 14px; font-weight: 650; }
.hue .dot { width: 12px; height: 12px; border-radius: 50%; }
.card-h { display: flex; justify-content: space-between; font-size: 11px; font-weight: 700; letter-spacing: 0.13em; text-transform: uppercase; color: var(--slate); margin-bottom: 6px; }
.card-h .nm { color: var(--muted); letter-spacing: 0.02em; text-transform: none; }
.spectrum { display: block; width: 100%; height: 60px; border-radius: 10px; background: #050506; border: 1px solid var(--edge); }
.scale { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--muted); margin-top: 4px; padding: 0 2px; font-variant-numeric: tabular-nums; }

/* ───────── Dock ───────── */
.bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 3;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 0 16px calc(16px + var(--safe-b)); pointer-events: none;
}
.hint { font-size: 12.5px; color: var(--muted); text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8); pointer-events: none; }
.dock { pointer-events: auto; width: max-content; border-radius: 24px; padding: 8px; max-width: min(1240px, 100%); display: flex; flex-direction: column; gap: 0; }
.row { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; justify-content: center; padding: 2px; }
.dock.glass { background: rgba(18, 18, 24, 0.78); border-color: rgba(255, 255, 255, 0.06); box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.2); }
.row .sep { width: 1px; height: 16px; margin: 0 8px; background: var(--edge); }
.btn { height: 34px; padding: 0 15px; border-radius: 999px; font-weight: 560; color: var(--text2); background: transparent; transition: background 0.2s, color 0.2s; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover:not(:disabled) { background: var(--chip); color: var(--text); }
.btn.toggle .inf { font-size: 15px; line-height: 1; font-weight: 500; opacity: 0.8; }
.btn.toggle.on { background: var(--text); color: var(--bg); }
.btn.toggle.on:hover:not(:disabled) { background: var(--text); color: var(--bg); opacity: 0.9; }
.btn.toggle.on .inf { opacity: 1; }
.btn.primary { background: rgba(243, 239, 233, 0.94); color: #141210; font-weight: 620; }
.btn.primary:hover:not(:disabled) { background: #fff; color: #141210; }
.slider { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px 0 14px; font-weight: 560; color: var(--text2); white-space: nowrap; }
.slider input { width: 96px; height: 14px; margin: 0; background: transparent; -webkit-appearance: none; appearance: none; cursor: pointer; }
.slider input::-webkit-slider-runnable-track { height: 2px; border-radius: 1px; background: rgba(255, 255, 255, 0.18); }
.slider input::-moz-range-track { height: 2px; border-radius: 1px; background: rgba(255, 255, 255, 0.18); }
.slider input::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; margin-top: -5px; border-radius: 50%; background: var(--text); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5); }
.slider input::-moz-range-thumb { width: 12px; height: 12px; border: 0; border-radius: 50%; background: var(--text); }
.chips { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; padding: 6px 2px 2px; margin-top: 4px; border-top: 1px solid var(--edge); }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: flex; align-items: center; gap: 7px; height: 34px; padding: 0 13px 0 12px; border-radius: 999px; color: var(--text2); transition: background 0.2s, color 0.2s; }
.chip:hover { background: var(--chip); color: var(--text); }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--c); opacity: 0.45; transition: opacity 0.3s, box-shadow 0.3s; }
.chip b { font-weight: 620; }
.chip .nm { color: var(--muted); font-size: 12.5px; }
.chip.on { color: var(--text); }
.chip.on .dot { opacity: 1; box-shadow: 0 0 6px var(--c); }
.chip.sel { background: var(--chip); }

.nogl[hidden] { display: none !important; }
.nogl { position: fixed; inset: auto 16px 50% 16px; margin: auto; max-width: 420px; padding: 18px; border-radius: 16px; text-align: center; z-index: 9; }

/* The card shrinks to a tag of what is in the flame. */
.info { cursor: pointer; transition: max-height 0.35s var(--ease), padding 0.35s var(--ease), opacity 0.3s; }
.info.mini { max-height: 64px; overflow: hidden; padding-top: 12px; padding-bottom: 12px; }
.info.mini .lead, .info.mini .hue, .info.mini .card-h, .info.mini .spectrum, .info.mini .scale, .info.mini .note, .info.mini .why { display: none; }
.info.mini .kicker { display: none; }
.info.mini h2 { font-size: 15px; }
.info.mini .sym { width: 34px; height: 34px; font-size: 15px; border-radius: 9px; }
.info.mini .formula { display: none; }

/* Only the picture: everything but the eye fades away. */
body.clean .brand, body.clean .seg, body.clean .info, body.clean .bottom, body.clean #reset { opacity: 0; pointer-events: none; }
.brand, .seg, .info, .bottom, #reset { transition: opacity 0.35s var(--ease); }
body.clean .top { background: transparent; border-color: transparent; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
.tools #clean[aria-pressed="true"] { color: var(--text); background: rgba(255, 255, 255, 0.16); }

/* Fade in once the first frames are drawn; a soft dip to dark between the two rooms. */
#stage { transition: opacity 0.9s var(--ease); }
body.loading #stage { opacity: 0; }
body.loading .top, body.loading .bottom, body.loading .info { opacity: 0; }
.bottom { transition: opacity 0.6s var(--ease); }
.top { transition: opacity 0.6s var(--ease), background 0.35s, border-color 0.35s, box-shadow 0.35s; }
.veil { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; z-index: 2; transition: opacity 0.28s var(--ease); }
.veil.on { opacity: 1; }
.hint { transition: opacity 0.6s var(--ease); }
.hint.gone { opacity: 0; }
.toast { position: fixed; left: 50%; top: calc(84px + var(--safe-t)); transform: translate(-50%, -8px); z-index: 10001; padding: 8px 14px; border-radius: 999px;
  background: var(--glass-strong); border: 1px solid var(--edge); font-weight: 600; font-size: 13px; opacity: 0; pointer-events: none; transition: opacity 0.3s, transform 0.3s var(--ease); }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.chip { position: relative; }
.chip kbd { position: absolute; top: 4px; right: 4px; font: 500 9px/1 var(--font); color: var(--muted); opacity: 0; transition: opacity 0.2s; }
.dock:hover .chip kbd { opacity: 0.6; }
@media (hover: none) { .chip kbd { display: none; } }
body.clean #photo, body.clean #full { opacity: 0; pointer-events: none; }
#photo, #full { transition: opacity 0.35s var(--ease); }

/* ───────── Identify ───────── */
.info.quiz { cursor: default; width: 340px; }
.levels { display: flex; gap: 4px; margin: 2px 0 12px; padding: 3px; background: var(--seg-track); border-radius: 999px; width: max-content; }
.lv { height: 28px; padding: 0 12px; border-radius: 999px; font-weight: 650; font-size: 12.5px; color: var(--text2); }
.lv.on { background: var(--seg-thumb); color: var(--text); }
.qbar { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 6px; font-variant-numeric: tabular-nums; }
.info.quiz h2 { margin-bottom: 8px; }
.tip { font-size: 12.5px; color: var(--slate); margin: 0 0 10px; }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.opt { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 12px; border-radius: 12px; background: var(--chip); border: 1px solid transparent; text-align: left; transition: background 0.2s, border-color 0.2s, transform 0.15s; }
.opt:hover:not(:disabled) { background: var(--chip-hover); }
.opt:active:not(:disabled) { transform: scale(0.98); }
.opt.wait { opacity: 0.6; }
.opt b { font-size: 15px; }
.opt span { font-size: 12px; color: var(--text2); }
.opt.right { border-color: #52c08a; background: rgba(82, 192, 138, 0.16); }
.opt.wrong { border-color: #e0707a; background: rgba(224, 112, 122, 0.12); opacity: 0.7; }
.btn.wide { width: 100%; margin-top: 12px; justify-content: center; background: var(--chip); color: var(--text); }
.btn.cobalt { color: var(--text2); }
.btn.cobalt.on { background: #3a50e0; color: #fff; }

/* ───────── Learn: a plain reading page ─────────
   One centred column: a title, then each topic as a section with a heading, a paragraph and its figure,
   separated by thin rules. No cards. */
.learn {
  position: fixed; inset: 0; z-index: 2000; overflow-y: auto;
  background: var(--bg-color);
  opacity: 0; transition: opacity 0.3s var(--ease);
  -webkit-user-select: text; user-select: text;
}
.learn.on { opacity: 1; }
.learn[hidden] { display: none !important; }
.learn-inner {
  max-width: 760px; margin: 0 auto;
  padding: calc(96px + var(--safe-t)) 24px 80px;
  color: var(--text-primary);
}
.learn-title { margin: 0 0 6px; font-size: 2.4rem; font-weight: 750; letter-spacing: -0.01em; color: var(--text-primary); }
.learn-sub { margin: 0 0 8px; font-size: 1.02rem; color: var(--text-secondary); line-height: 1.5; }
.learn-sec { padding: 32px 0; border-top: 1px solid var(--border-color); }
.learn-sec:first-of-type { margin-top: 26px; }
.learn-sec h2 { margin: 0 0 10px; font-size: 1.35rem; font-weight: 700; color: var(--text-primary); }
.learn-sec > p { margin: 0 0 18px; font-size: 0.98rem; line-height: 1.6; color: var(--text-secondary); }
.learn-body { position: relative; }
@media (max-width: 640px) {
  .learn-inner { padding: calc(72px + var(--safe-t)) 18px 56px; }
  .learn-title { font-size: 1.9rem; }
}
.ladder { border-radius: 16px; background: #060608; border: 1px solid var(--edge); padding: 8px 6px 2px;
  --text: #f3efe9; --text2: #b9b2ab; --muted: #837d76; }
.ladder-svg { display: block; width: 100%; height: auto; font-family: var(--font); user-select: none; -webkit-user-select: none; }
.ladder-svg .who { fill: var(--text); font-size: 13px; font-weight: 700; }
.ladder-svg .tap { fill: var(--muted); font-size: 11px; }
.ladder-svg .axis, .ladder-svg .tick { stroke: rgba(255, 255, 255, 0.25); stroke-width: 1; }
.ladder-svg .axt { fill: var(--muted); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.ladder-svg .lvl { stroke: rgba(255, 255, 255, 0.34); stroke-width: 2; stroke-linecap: round; transition: stroke 0.3s; }
.ladder-svg .lvl.ground { stroke: rgba(255, 255, 255, 0.6); }
.ladder-svg .lvlt { fill: var(--text2); font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums; transition: fill 0.3s; }
.ladder-svg .lead-ln { stroke: rgba(255, 255, 255, 0.18); fill: none; }
.ladder-svg .hit { stroke: transparent; stroke-width: 14; fill: transparent; }
.ladder-svg .lv { cursor: pointer; outline: none; }
.ladder-svg .lv:hover .lvl, .ladder-svg .lv:focus-visible .lvl { stroke: rgba(255, 255, 255, 0.7); }
.ladder-svg .lv.on .lvl { stroke: #8fd3ff; }
.ladder-svg .lv.on .lvlt, .ladder-svg .lv:hover .lvlt { fill: var(--text); }
.ladder-svg .heat path { fill: #ff8a3d; filter: drop-shadow(0 0 5px #ff8a3d); }
.ladder-svg .e { fill: #f2fbff; }
.ladder-svg .gap-ln { stroke: rgba(255, 255, 255, 0.55); stroke-width: 1.4; stroke-dasharray: 3 3; }
.ladder-svg .gap-hd { fill: none; stroke: rgba(255, 255, 255, 0.55); stroke-width: 1.4; }
.ladder-svg .gap-t { fill: var(--text); font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums; paint-order: stroke; stroke: #060608; stroke-width: 5px; stroke-linejoin: round; }
.ladder-svg .photon { fill: none; stroke-width: 2.2; stroke-linecap: round; filter: drop-shadow(0 0 4px currentColor); }
.ladder-svg .strip { fill: none; stroke: rgba(255, 255, 255, 0.14); }
.ladder-svg .readout { transition: opacity 0.4s; }
.ladder-svg .readout .sw { filter: drop-shadow(0 0 8px currentColor); transition: fill 0.4s; }
.ladder-svg .ro-nm { fill: var(--text); font-size: 20px; font-weight: 780; font-variant-numeric: tabular-nums; }
.ladder-svg .ro-e { fill: var(--text2); font-size: 12px; font-variant-numeric: tabular-nums; }
.ladder-svg .ro-w { fill: var(--muted); font-size: 11.5px; }
.ladder-wrap { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(250px, 1fr); gap: 22px; align-items: start; }
.ladder-under { display: grid; gap: 16px; align-content: start; }
@media (max-width: 900px) { .ladder-wrap { grid-template-columns: 1fr; } }
.steps { margin: 0; padding: 0; list-style: none; counter-reset: st; display: grid; gap: 4px; }
.steps li { counter-increment: st; position: relative; padding: 5px 10px 5px 34px; border-radius: 10px; color: var(--muted); font-size: 13.5px; transition: color 0.35s, background 0.35s; }
.steps li::before { content: counter(st); position: absolute; left: 8px; top: 5px; width: 19px; height: 19px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 750; background: var(--chip); }
.steps li.on { color: var(--text); background: var(--chip); }
.steps li.on::before { background: var(--accent-soft); color: var(--accent); }
.ladder-side { display: grid; gap: 10px; justify-items: start; }
.btn.auto { height: 32px; background: var(--chip); color: var(--text); }
.ladder-note { margin-top: 12px; }
.mchips { display: flex; flex-wrap: wrap; gap: 6px; }
.mchip { height: 32px; min-width: 40px; padding: 0 10px; border-radius: 10px; background: var(--chip); font-weight: 750; }
.mchip.on { background: var(--accent-soft); color: var(--accent); }
.spec-list { display: flex; flex-direction: column; gap: 6px; }
.spec-row { display: grid; grid-template-columns: 34px 1fr 96px; gap: 10px; align-items: center; }
.spec-row canvas { width: 100%; height: 28px; border-radius: 7px; background: #050506; border: 1px solid var(--edge); }
.spec-row span { font-size: 12px; color: var(--text2); }
.spec-scale { margin-left: 44px; margin-right: 106px; }
.fw { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.fwc { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 6px 10px; border-radius: 14px; background: var(--chip); }
.fwc b { font-size: 13px; }
.fwc span:last-child { font-size: 11.5px; color: var(--text2); }
.spark { width: 34px; height: 34px; border-radius: 50%; background: radial-gradient(circle, #fff 0 8%, var(--c) 20%, transparent 70%);
  box-shadow: 0 0 22px var(--c); animation: twinkle 2.4s ease-in-out infinite; }
@keyframes twinkle { 0%, 100% { transform: scale(0.85); opacity: 0.8; } 50% { transform: scale(1.05); opacity: 1; } }
.safe { margin: 0; padding-left: 18px; color: var(--text2); font-size: 13.5px; display: flex; flex-direction: column; gap: 6px; }
.seen { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.seen-c { display: flex; flex-direction: column; align-items: center; padding: 10px 4px; border-radius: 12px; background: var(--chip); opacity: 0.45; }
.seen-c.on { opacity: 1; background: var(--accent-soft); }
.seen-c b { font-size: 15px; }
.seen-c span { font-size: 10.5px; color: var(--text2); text-align: center; }
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 12px; }
.stats div { padding: 10px; border-radius: 12px; background: var(--chip); display: flex; flex-direction: column; }
.stats b { font-size: 18px; font-variant-numeric: tabular-nums; }
.stats span { font-size: 11.5px; color: var(--text2); }

/* ───────── Narrow screens ───────── */
@media (max-width: 760px) {
  .top { left: 8px; right: 8px; height: 50px; gap: 6px; padding: 0 6px 0 10px; grid-template-columns: auto minmax(0, 1fr) auto; }
  .seg { justify-self: center; }
  .brand .wordmark { display: none; }
  .brand { padding: 0; }
  .tools { gap: 5px; }
  .row .sep { display: none; }
  .tools #photo, .tools #full { display: none; }
  .info { position: static; pointer-events: auto; width: 100%; max-width: 520px; max-height: 26vh; padding: 12px 14px; }
  .info h2 { font-size: 17px; }
  .info .why { display: none; }
  .chip .nm { display: none; }
  .slider input { width: 80px; }
  .hint { display: none; }
  .seg button { padding: 0 9px; font-size: 12.5px; height: 32px; }
  .fw { grid-template-columns: repeat(3, 1fr); }
  .seen { grid-template-columns: repeat(4, 1fr); }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .spec-row { grid-template-columns: 30px 1fr; }
  .spec-row span { display: none; }
  .spec-scale { margin-right: 0; margin-left: 40px; }
  .info.quiz { width: 100%; }
}
@media (max-width: 420px) {
  .top { padding: 0 5px 0 8px; gap: 4px; }
  .seg button { padding: 0 7px; font-size: 12px; }
}
@media (max-width: 760px) {
  .zp-back { width: 34px; padding: 0; justify-content: center; }
  .zp-back span { display: none; }
}
@media (max-width: 440px) {
  .top { grid-template-columns: auto minmax(0, 1fr) auto; }
  /* Phones: four tabs and the back pill need the room; the theme follows zperiod.app anyway
     and H still hides the controls on a keyboard. */
  .tools #clean, .tools .nav-theme-toggle { display: none; }
  .seg button { padding: 0 6px; font-size: 11.5px; }
  .brand { display: none; }
}
@media (max-width: 380px) {
  /* Room for the speaker: the eye goes on the narrowest phones. */
  .tools #clean { display: none; }
  .top { gap: 3px; padding: 0 4px 0 6px; }
  .seg button { padding: 0 5px; font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Zperiod's globe language menu (css/base.css and dark-theme.css on zperiod.app). */
.lang-dropdown { position: relative; display: flex; align-items: center; flex-shrink: 0; }
.lang-dropdown-toggle {
  display: flex; align-items: center; gap: 5px; height: 34px; padding: 0 14px 0 13px; border: none; border-radius: 18px;
  background: rgba(255, 255, 255, 0.08); color: #9a97a8; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  font: inherit; cursor: pointer; transition: background-color 0.16s ease, color 0.16s ease;
}
.lang-dropdown-toggle:hover, .lang-dropdown.open .lang-dropdown-toggle { background: rgba(255, 255, 255, 0.14); color: #e8e6f0; }
.lang-globe-icon { width: 15px; height: 15px; flex-shrink: 0; }
.lang-chevron { width: 9px; height: 9px; flex-shrink: 0; transition: transform 0.3s cubic-bezier(0.34, 1.4, 0.64, 1); }
.lang-dropdown.open .lang-chevron { transform: rotate(180deg); }
.lang-dropdown-menu {
  position: absolute; top: calc(100% + 16px); right: 0; z-index: 50; min-width: 210px; max-width: calc(100vw - 24px);
  display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 14px;
  background: linear-gradient(180deg, #1e1e28 0%, #181822 100%);
  border: 1px solid rgba(255, 255, 255, 0.08); box-shadow: 0 14px 38px rgba(0, 0, 0, 0.5), 0 4px 12px rgba(0, 0, 0, 0.3);
  opacity: 0; visibility: hidden; transform: translateY(-6px) scale(0.97);
  transition: opacity 0.22s ease, visibility 0.22s ease, transform 0.3s cubic-bezier(0.34, 1.4, 0.64, 1);
}
.lang-dropdown.open .lang-dropdown-menu { opacity: 1; visibility: visible; transform: none; }
.lang-option {
  position: relative; display: flex; align-items: center; width: 100%; min-height: 44px; padding: 12px 20px;
  border: none; border-radius: 12px; background: none; overflow: hidden; text-align: left;
  font: inherit; font-size: 15px; font-weight: 550; line-height: 1.18; color: #c8c6d0; cursor: pointer;
  transition: background-color 0.16s ease, color 0.16s ease;
}
.lang-option-label { display: block; transition: opacity 0.16s ease, transform 0.3s cubic-bezier(0.34, 1.4, 0.64, 1); }
.lang-option-english { position: absolute; left: 20px; right: 20px; top: 50%; opacity: 0; pointer-events: none; transform: translateY(-50%) scale(0.94); }
.lang-option:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.lang-option:hover .lang-option-native, .lang-option:focus-visible .lang-option-native { opacity: 0; transform: scale(0.94); }
.lang-option:hover .lang-option-english, .lang-option:focus-visible .lang-option-english { opacity: 1; transform: translateY(-50%) scale(1); }
.lang-option.active { background: rgba(255, 255, 255, 0.12); color: #fff; font-weight: 650; }
body.clean .lang-dropdown { opacity: 0; pointer-events: none; }
@media (max-width: 760px) {
  .lang-dropdown-toggle { width: 34px; padding: 0; justify-content: center; }
  .lang-chevron { display: none; }
}

/* zperiod.app's light / dark toggle (css/base.css and dark-theme.css), as it is there. */
.nav-theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: calc(34px * var(--global-nav-scale));
  height: calc(34px * var(--global-nav-scale));
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.04);
  color: #555;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: background-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
  flex-shrink: 0;
}

.nav-theme-toggle svg {
  width: calc(15px * var(--global-nav-scale));
  height: calc(15px * var(--global-nav-scale));
}

.nav-theme-toggle:hover {
  color: #1d1d1f;
  background: rgba(0, 0, 0, 0.09);
}

.nav-theme-toggle:active {
  background: rgba(0, 0, 0, 0.13);
}

.theme-icon-sun {
  display: none;
}

.nav-theme-toggle.active .theme-icon-moon {
  display: none;
}

.nav-theme-toggle.active .theme-icon-sun {
  display: block;
}

html.dark-theme .nav-theme-toggle {
  background: rgba(255, 255, 255, 0.08);
  color: #9a97a8;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

html.dark-theme .nav-theme-toggle:hover {
  color: #e8e6f0;
  background: rgba(255, 255, 255, 0.14);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

html.dark-theme .nav-theme-toggle.active {
  color: #f5f5f5;
}
body.clean .nav-theme-toggle { opacity: 0; pointer-events: none; }

/* ───────── Light: zperiod.app's light glass over the dark room ───────── */
/* Over the dark room the glass needs more white than zperiod's 0.72 to read as light. */
html:not(.dark-theme) .top, html:not(.dark-theme) .dock.glass {
  background: rgba(255, 255, 255, 0.9); border: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%);
}
html:not(.dark-theme) body.clean .top { background: transparent; border-color: transparent; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
html:not(.dark-theme) .wordmark sup, html:not(.dark-theme) .brand .ic { color: #e07a12; }
html:not(.dark-theme) .tools .iconbtn { background: rgba(0, 0, 0, 0.04); color: #555; box-shadow: var(--shadow-xs); }
html:not(.dark-theme) .tools .iconbtn:hover { background: rgba(0, 0, 0, 0.09); color: #1d1d1f; box-shadow: var(--shadow-xs); }
html:not(.dark-theme) .tools #clean[aria-pressed="true"] { background: rgba(0, 0, 0, 0.09); color: #1d1d1f; }
html:not(.dark-theme) .btn.primary { background: #2c2420; color: #fdfbf7; }
html:not(.dark-theme) .btn.primary:hover:not(:disabled) { background: #1a1411; color: #fff; }
html:not(.dark-theme) .slider input::-webkit-slider-runnable-track { background: rgba(0, 0, 0, 0.16); }
html:not(.dark-theme) .slider input::-moz-range-track { background: rgba(0, 0, 0, 0.16); }
html:not(.dark-theme) .slider input::-webkit-slider-thumb { box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); }
html:not(.dark-theme) .hint { color: #8f867f; text-shadow: none; }
html:not(.dark-theme) .sym.cat-alkali { --cat-bg: #ffcccc; --cat-fg: #5d2e2e; }
html:not(.dark-theme) .sym.cat-alkaline { --cat-bg: #ffe5cc; --cat-fg: #5d402e; }
html:not(.dark-theme) .sym.cat-transition { --cat-bg: #fff2cc; --cat-fg: #5d522e; }
html:not(.dark-theme) .sym.cat-metalloid { --cat-bg: #d1e7dd; --cat-fg: #2e5d4b; }
html:not(.dark-theme) .sym { box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06); }
html:not(.dark-theme) .opt.right { background: rgba(82, 192, 138, 0.14); }
/* The language menu in its light form (as on zperiod.app). */
html:not(.dark-theme) .lang-dropdown-toggle { background: rgba(0, 0, 0, 0.04); color: #555; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); }
html:not(.dark-theme) .lang-dropdown-toggle:hover, html:not(.dark-theme) .lang-dropdown.open .lang-dropdown-toggle { color: #1d1d1f; background: rgba(0, 0, 0, 0.07); }
html:not(.dark-theme) .lang-dropdown-menu { background: linear-gradient(180deg, #ffffff 0%, #f8f8fa 100%); border-color: rgba(0, 0, 0, 0.08);
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.12), 0 6px 16px rgba(0, 0, 0, 0.06); }
html:not(.dark-theme) .lang-option { color: #2f3136; }
html:not(.dark-theme) .lang-option:hover { background: rgba(0, 0, 0, 0.055); color: #15161a; }
html:not(.dark-theme) .lang-option.active { background: rgba(0, 0, 0, 0.09); color: #111827; }

html:not(.dark-theme) .veil { background: #fdfbf7; }

/* Sound: the speaker, struck through when muted. */
#sound .off, #sound[aria-pressed="true"] .on { display: none; }
#sound[aria-pressed="true"] .off { display: block; }
body.clean #sound { opacity: 0; pointer-events: none; }

/* English only for now: the language menu stays in the page (the script looks it up) but is hidden. */
.lang-dropdown[hidden] { display: none !important; }
