/*
 * theme.css — Lab of Everything. A bright, clean science-lab look: cool paper
 * white, indigo for the Pro Lab, warm orange for the Junior Lab. The --x-*
 * tokens are the lab's own colours (chemicals, flames, pH, elements, art for the
 * physics scenes); the canvas reads them so nothing in app.js is a colour value.
 */

:root {
  --canvas: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef1f7;
  --border: #dde2ec;
  --border-strong: #aab3c4;
  --ink: #121826;
  --muted: #535e70;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-ink: #ffffff;
  --accent-text: #4338ca;
  --accent-strong: #3730a3;
  --accent-soft: #e9e8fd;
  --accent-border: #c4c1f7;
  --success: #15803d;
  --success-ink: #ffffff;
  --success-soft: #dcf3e4;
  --success-strong: #166534;
  --warning: #b45309;
  --warning-ink: #ffffff;
  --warning-soft: #fdf0dd;
  --warning-strong: #92400e;
  --danger: #dc2626;
  --danger-ink: #ffffff;
  --danger-soft: #fde4e4;
  --danger-strong: #b91c1c;
  --chart-1: #4f46e5;
  --chart-2: #e8590c;
  --chart-3: #0e9f6e;
  --chart-4: #db2777;
  --chart-5: #0284c7;
  --chart-6: #a16207;

  --font-display: "Fredoka", "Inter Variable", ui-sans-serif, system-ui, sans-serif;
  --font-body: "Inter Variable", ui-sans-serif, system-ui, sans-serif;
  --font-sans: "Inter Variable", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "JetBrains Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --display-weight: 600;
  --display-tracking: -0.01em;
  --eyebrow-tracking: 0.08em;
  --radius-btn: 12px;
  --radius-card: 18px;
  --radius-input: 10px;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.05), 0 6px 20px rgba(0, 0, 0, 0.05);
  --shadow-raised: 0 10px 30px rgba(0, 0, 0, 0.12);

  --x-stage: #fbfcff;
  --x-stage-2: #eaf0f8;
  --x-grid: #e2e8f2;
  --x-glass: #7f95b3;
  --x-glass-hi: #ffffff;
  --x-table: #dcb58a;
  --x-table-2: #b98a5c;
  --x-shadow: #000000;
  --x-white: #ffffff;
  --x-black: #0b0f17;
  --x-ink-dark: #111827;
  --x-jr: #f97316;
  --x-jr-soft: #ffedd5;
  --x-jr-strong: #9a3412;
  --x-pro: #4f46e5;

  --x-c-water: #a8d8ff;
  --x-c-clear: #e3f0ff;
  --x-c-vinegar: #f4efd2;
  --x-c-lemon: #f7e27a;
  --x-c-cola: #5a3218;
  --x-c-cabbage: #7b3fa0;
  --x-c-cab-acid: #e24a86;
  --x-c-cab-base: #1fa37a;
  --x-c-cab-strong: #d6c21c;
  --x-c-soap: #9be3d0;
  --x-c-foam: #ffffff;
  --x-c-milk: #f8f4ea;
  --x-c-oil: #e8b93c;
  --x-c-salt: #f4f6f8;
  --x-c-sugar: #fdfcf7;
  --x-c-soda: #f2f2ee;
  --x-c-yeast: #c9a46a;
  --x-c-peroxide: #eef6ff;
  --x-c-mint: #f5f7f5;
  --x-c-starch: #f3efe2;
  --x-c-glue: #f5f2e8;
  --x-c-borax: #e8ecf0;
  --x-c-slime: #34d399;
  --x-c-red: #e11d48;
  --x-c-blue: #2563eb;
  --x-c-yellow: #facc15;
  --x-c-ice: #d4f1ff;
  --x-c-curd: #fffdf5;
  --x-c-cu2: #2f8fe0;
  --x-c-cuamm: #1d3b9a;
  --x-c-fe2: #a6cf8f;
  --x-c-fe3: #d98a1c;
  --x-c-mno4: #7e1fa6;
  --x-c-i2: #9a5412;
  --x-c-starchi: #1f1b4d;
  --x-c-cuoh: #7cc4f0;
  --x-c-cuco3: #4bb3a0;
  --x-c-feoh2: #6f9a5a;
  --x-c-feoh3: #a8471a;
  --x-c-white: #f4f4f2;
  --x-c-cream: #f1ead0;
  --x-c-yellowppt: #f3d548;
  --x-c-gold: #ffcf1a;
  --x-c-brownppt: #6d4a2a;
  --x-c-black: #22252b;
  --x-c-metal: #a7b0bd;
  --x-c-copper: #c8693b;
  --x-c-silver: #d7dde5;
  --x-c-zinc: #b9c2cc;
  --x-c-iron: #6b7280;
  --x-c-mg: #dfe3e8;
  --x-c-chlorine: #cde66a;
  --x-c-gas: #c7ced8;
  --x-c-phph: #ec4899;
  --x-c-litred: #dc2f4a;
  --x-c-litblue: #3466d6;
  --x-c-litpurple: #7a4fb0;
  --x-c-mored: #e0322f;
  --x-c-moorange: #f08a24;
  --x-c-moyellow: #f5c932;

  --x-fl-base: #3b82f6;
  --x-fl-core: #bfdbfe;
  --x-fl-li: #e11d48;
  --x-fl-na: #f59e0b;
  --x-fl-k: #c084fc;
  --x-fl-ca: #ea580c;
  --x-fl-cu: #10b981;
  --x-fl-ba: #a3e635;
  --x-fl-sr: #ef4444;

  --x-ph0: #b91c1c;
  --x-ph1: #dc2626;
  --x-ph2: #ef4444;
  --x-ph3: #f97316;
  --x-ph4: #fb923c;
  --x-ph5: #facc15;
  --x-ph6: #d9e021;
  --x-ph7: #22c55e;
  --x-ph8: #14b8a6;
  --x-ph9: #0ea5e9;
  --x-ph10: #3b82f6;
  --x-ph11: #4f46e5;
  --x-ph12: #6d28d9;
  --x-ph13: #7e22ce;
  --x-ph14: #581c87;

  --x-pt-alkali: #fca5a5;
  --x-pt-alkaline: #fdba74;
  --x-pt-transition: #fde68a;
  --x-pt-post: #bef264;
  --x-pt-metalloid: #6ee7b7;
  --x-pt-nonmetal: #67e8f9;
  --x-pt-halogen: #93c5fd;
  --x-pt-noble: #c4b5fd;
  --x-pt-lanth: #f9a8d4;
  --x-pt-actin: #f0abfc;
  --x-pt-unknown: #d1d5db;

  --x-rb-1: #ef4444;
  --x-rb-2: #f97316;
  --x-rb-3: #facc15;
  --x-rb-4: #22c55e;
  --x-rb-5: #3b82f6;
  --x-rb-6: #4f46e5;
  --x-rb-7: #a855f7;
  --x-light-r: #ff2a2a;
  --x-light-g: #22ff4e;
  --x-light-b: #3355ff;

  --x-sky: #cfe8ff;
  --x-sky-2: #f2f9ff;
  --x-ground: #7cb342;
  --x-ground-2: #5d8a32;
  --x-wood: #c98d55;
  --x-wood-2: #8d5a2f;
  --x-steel: #94a3b8;
  --x-ball: #f43f5e;
  --x-ball-2: #3b82f6;
  --x-ray: #fde047;
  --x-wave-lo: #0b2a6b;
  --x-wave-hi: #c4e6ff;
  --x-wire: #f59e0b;
  --x-bulb: #ffd84d;
  --x-bulb-glow: #fff4b8;
  --x-bulb-off: #9ca3af;
  --x-space: #0a0f24;
  --x-space-2: #1b1748;
  --x-star: #ffffff;
  --x-sun: #fbbf24;
  --x-sun-2: #f97316;
  --x-planet: #38bdf8;
  --x-particle: #6366f1;
  --x-particle-hot: #ef4444;
  --x-particle-cold: #38bdf8;
  --x-prod: #a855f7;
  --x-north: #ef4444;
  --x-south: #3b82f6;
  --x-filing: #475569;
  --x-spring: #64748b;
  --x-water-deep: #1d6fb8;
  --x-water-top: #7cc3f5;
  --x-honey: #e0a526;
  --x-mercury: #c0c6cf;
  --x-skin: #f2c29b;
  --x-shirt: #6366f1;
  --x-hair: #3b2416;
  --x-scope: #0b1f17;
  --x-scope-line: #34f5a0;
  --x-pl-earth: #4f9be8;
  --x-pl-moon: #b8bcc4;
  --x-pl-mars: #d0643a;
  --x-pl-venus: #e8c77a;
  --x-pl-mercury: #9a8f86;
  --x-pl-jupiter: #d9a77a;
  --x-pl-pluto: #c7b39b;
  --x-pl-sun: #fbbf24;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #0c1018;
  --surface: #141a25;
  --surface-2: #1b2331;
  --border: #283244;
  --border-strong: #46536b;
  --ink: #eef2f8;
  --muted: #a2adbf;
  --accent: #8b85ff;
  --accent-hover: #a39eff;
  --accent-ink: #0d0b2a;
  --accent-text: #aaa5ff;
  --accent-strong: #cdcaff;
  --accent-soft: #231f4d;
  --accent-border: #433d8f;
  --success: #22c55e;
  --success-ink: #052e14;
  --success-soft: #0f2a1a;
  --success-strong: #6ee7a0;
  --warning: #f59e0b;
  --warning-ink: #2a1700;
  --warning-soft: #2e2210;
  --warning-strong: #fbbf5a;
  --danger: #f87171;
  --danger-ink: #2a0707;
  --danger-soft: #331517;
  --danger-strong: #fca5a5;
  --chart-1: #8b85ff;
  --chart-2: #fb923c;
  --chart-3: #34d399;
  --chart-4: #f472b6;
  --chart-5: #38bdf8;
  --chart-6: #facc15;

  --x-stage: #0f1522;
  --x-stage-2: #162033;
  --x-grid: #1e293b;
  --x-glass: #9fb3cf;
  --x-glass-hi: #ffffff;
  --x-table: #6b4a2e;
  --x-table-2: #4e3520;
  --x-shadow: #000000;
  --x-white: #ffffff;
  --x-black: #0b0f17;
  --x-ink-dark: #111827;
  --x-jr: #fb923c;
  --x-jr-soft: #3a2414;
  --x-jr-strong: #fdba74;
  --x-pro: #8b85ff;

  --x-c-water: #a8d8ff;
  --x-c-clear: #d6e6fa;
  --x-c-vinegar: #f4efd2;
  --x-c-lemon: #f7e27a;
  --x-c-cola: #5a3218;
  --x-c-cabbage: #7b3fa0;
  --x-c-cab-acid: #e24a86;
  --x-c-cab-base: #1fa37a;
  --x-c-cab-strong: #d6c21c;
  --x-c-soap: #9be3d0;
  --x-c-foam: #ffffff;
  --x-c-milk: #f8f4ea;
  --x-c-oil: #e8b93c;
  --x-c-salt: #f4f6f8;
  --x-c-sugar: #fdfcf7;
  --x-c-soda: #f2f2ee;
  --x-c-yeast: #c9a46a;
  --x-c-peroxide: #eef6ff;
  --x-c-mint: #f5f7f5;
  --x-c-starch: #f3efe2;
  --x-c-glue: #f5f2e8;
  --x-c-borax: #e8ecf0;
  --x-c-slime: #34d399;
  --x-c-red: #e11d48;
  --x-c-blue: #2563eb;
  --x-c-yellow: #facc15;
  --x-c-ice: #d4f1ff;
  --x-c-curd: #fffdf5;
  --x-c-cu2: #2f8fe0;
  --x-c-cuamm: #2a4fc4;
  --x-c-fe2: #a6cf8f;
  --x-c-fe3: #d98a1c;
  --x-c-mno4: #9b2fd0;
  --x-c-i2: #b06a1c;
  --x-c-starchi: #2b2670;
  --x-c-cuoh: #7cc4f0;
  --x-c-cuco3: #4bb3a0;
  --x-c-feoh2: #6f9a5a;
  --x-c-feoh3: #b9541f;
  --x-c-white: #f4f4f2;
  --x-c-cream: #f1ead0;
  --x-c-yellowppt: #f3d548;
  --x-c-gold: #ffcf1a;
  --x-c-brownppt: #8a5f37;
  --x-c-black: #3a3f48;
  --x-c-metal: #a7b0bd;
  --x-c-copper: #d9784a;
  --x-c-silver: #d7dde5;
  --x-c-zinc: #b9c2cc;
  --x-c-iron: #8a93a3;
  --x-c-mg: #dfe3e8;
  --x-c-chlorine: #cde66a;
  --x-c-gas: #c7ced8;
  --x-c-phph: #ec4899;
  --x-c-litred: #e0425c;
  --x-c-litblue: #4a7ae6;
  --x-c-litpurple: #8d63c4;
  --x-c-mored: #e0322f;
  --x-c-moorange: #f08a24;
  --x-c-moyellow: #f5c932;

  --x-fl-base: #3b82f6;
  --x-fl-core: #bfdbfe;
  --x-fl-li: #e11d48;
  --x-fl-na: #f59e0b;
  --x-fl-k: #c084fc;
  --x-fl-ca: #ea580c;
  --x-fl-cu: #10b981;
  --x-fl-ba: #a3e635;
  --x-fl-sr: #ef4444;

  --x-ph0: #b91c1c;
  --x-ph1: #dc2626;
  --x-ph2: #ef4444;
  --x-ph3: #f97316;
  --x-ph4: #fb923c;
  --x-ph5: #facc15;
  --x-ph6: #d9e021;
  --x-ph7: #22c55e;
  --x-ph8: #14b8a6;
  --x-ph9: #0ea5e9;
  --x-ph10: #3b82f6;
  --x-ph11: #4f46e5;
  --x-ph12: #6d28d9;
  --x-ph13: #7e22ce;
  --x-ph14: #581c87;

  --x-pt-alkali: #fca5a5;
  --x-pt-alkaline: #fdba74;
  --x-pt-transition: #fde68a;
  --x-pt-post: #bef264;
  --x-pt-metalloid: #6ee7b7;
  --x-pt-nonmetal: #67e8f9;
  --x-pt-halogen: #93c5fd;
  --x-pt-noble: #c4b5fd;
  --x-pt-lanth: #f9a8d4;
  --x-pt-actin: #f0abfc;
  --x-pt-unknown: #d1d5db;

  --x-rb-1: #ef4444;
  --x-rb-2: #f97316;
  --x-rb-3: #facc15;
  --x-rb-4: #22c55e;
  --x-rb-5: #3b82f6;
  --x-rb-6: #6366f1;
  --x-rb-7: #a855f7;
  --x-light-r: #ff2a2a;
  --x-light-g: #22ff4e;
  --x-light-b: #3355ff;

  --x-sky: #1b3556;
  --x-sky-2: #0e1c31;
  --x-ground: #4d7a2a;
  --x-ground-2: #3a5d1f;
  --x-wood: #b07a46;
  --x-wood-2: #7a4d27;
  --x-steel: #94a3b8;
  --x-ball: #fb5a75;
  --x-ball-2: #5b9bff;
  --x-ray: #fde047;
  --x-wave-lo: #061638;
  --x-wave-hi: #9fd2ff;
  --x-wire: #f59e0b;
  --x-bulb: #ffd84d;
  --x-bulb-glow: #fff4b8;
  --x-bulb-off: #6b7280;
  --x-space: #070b1b;
  --x-space-2: #17133f;
  --x-star: #ffffff;
  --x-sun: #fbbf24;
  --x-sun-2: #f97316;
  --x-planet: #38bdf8;
  --x-particle: #818cf8;
  --x-particle-hot: #f87171;
  --x-particle-cold: #38bdf8;
  --x-prod: #c084fc;
  --x-north: #ef4444;
  --x-south: #3b82f6;
  --x-filing: #9aa8bc;
  --x-spring: #94a3b8;
  --x-water-deep: #1d5f9e;
  --x-water-top: #5aa9e0;
  --x-honey: #e0a526;
  --x-mercury: #c0c6cf;
  --x-skin: #f2c29b;
  --x-shirt: #818cf8;
  --x-hair: #3b2416;
  --x-scope: #071510;
  --x-scope-line: #34f5a0;
  --x-pl-earth: #4f9be8;
  --x-pl-moon: #b8bcc4;
  --x-pl-mars: #d0643a;
  --x-pl-venus: #e8c77a;
  --x-pl-mercury: #9a8f86;
  --x-pl-jupiter: #d9a77a;
  --x-pl-pluto: #c7b39b;
  --x-pl-sun: #fbbf24;
}

/* app.css — Lab of Everything. Layout and components for the lab views.
   Every colour is a token from theme.css. */

.lab-body { background: var(--canvas); color: var(--ink); font-family: var(--font-body); }
.lab { min-height: 100vh; display: flex; flex-direction: column; }
.lab .icon { width: 1.1em; height: 1.1em; flex: none; display: block; }
.wrap { width: 100%; max-width: 1240px; margin: 0 auto; padding: 0 20px; }
#main { flex: 1; }
.view[hidden] { display: none !important; }

/* ── Top bar ── */
.topbar { position: sticky; top: 0; z-index: 30; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-in { max-width: 1240px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); margin-right: auto; }
.brand-mark { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); }
.brand-mark .icon { width: 20px; height: 20px; }
.brand-name { font-family: var(--font-display); font-weight: 600; font-size: 1.2rem; letter-spacing: -0.01em; }
.topnav { display: flex; gap: 6px; }
.topnav a { display: flex; align-items: center; gap: 7px; padding: 8px 12px; border-radius: 10px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: 0.92rem; border: 1px solid transparent; }
.topnav a em { font-style: normal; font-size: 0.72rem; font-weight: 700; padding: 2px 6px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.topnav a:hover { color: var(--ink); background: var(--surface-2); }
.topnav a.nav-jr.on { color: var(--x-jr-strong); background: var(--x-jr-soft); border-color: var(--x-jr); }
.topnav a.nav-pro.on { color: var(--accent-strong); background: var(--accent-soft); border-color: var(--accent-border); }
.icon-btn { width: 38px; height: 38px; padding: 0; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--ink); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); }

/* ── Buttons ── */
.lab-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 14px; border-radius: var(--radius-btn); border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; font-size: 0.9rem; cursor: pointer; text-decoration: none; line-height: 1.2; transition: transform .08s ease, background .15s ease; }
.lab-btn:hover { background: var(--surface-2); }
.lab-btn:active { transform: translateY(1px); }
.lab-btn:disabled { opacity: .5; cursor: not-allowed; }
.lab-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.lab-btn.primary:hover { background: var(--accent-hover); }
.lab-btn.jr { background: var(--x-jr); border-color: var(--x-jr); color: var(--x-ink-dark); }
.lab-btn.jr:hover { filter: brightness(1.06); }
.lab-btn.danger { color: var(--danger-strong); border-color: var(--danger); background: var(--danger-soft); }
.lab-btn.ghost { border-color: transparent; background: transparent; }
.lab-btn.small { padding: 6px 10px; font-size: 0.82rem; }
.lab-btn.big { padding: 13px 20px; font-size: 1rem; border-radius: 14px; }
.sec-junior .lab-btn.primary { background: var(--x-jr); border-color: var(--x-jr); color: var(--x-ink-dark); }

/* ── Home ── */
.hero { display: grid; grid-template-columns: 1.05fr 1fr; gap: 32px; align-items: center; padding-top: 48px; padding-bottom: 32px; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: 0.8rem; font-weight: 700; letter-spacing: var(--eyebrow-tracking); text-transform: uppercase; color: var(--success-strong); background: var(--success-soft); padding: 6px 12px; border-radius: 999px; margin: 0; }
.hero-title { font-family: var(--font-display); font-weight: 600; font-size: clamp(2.1rem, 4.4vw, 3.5rem); line-height: 1.05; letter-spacing: -0.015em; margin: 18px 0 14px; }
.hero-lede { font-size: 1.08rem; line-height: 1.6; color: var(--muted); max-width: 36rem; margin: 0; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 26px; }
.hero-art { position: relative; border-radius: 26px; overflow: hidden; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-card); aspect-ratio: 5 / 4; }
.hero-art canvas { width: 100%; height: 100%; display: block; }
.sec-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 12px; }
.sec-card { display: flex; flex-direction: column; gap: 12px; padding: 26px; border-radius: 22px; text-decoration: none; color: var(--ink); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-card); transition: transform .15s ease, box-shadow .15s ease; }
.sec-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-raised); }
.sec-card h2 { font-family: var(--font-display); font-weight: 600; font-size: 1.6rem; margin: 4px 0 0; line-height: 1.15; }
.sec-card p { margin: 0; color: var(--muted); line-height: 1.55; }
.sec-card-top { display: flex; align-items: center; justify-content: space-between; }
.sec-badge { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 999px; font-weight: 700; font-size: 0.85rem; }
.sec-card-jr { border-top: 5px solid var(--x-jr); }
.sec-card-jr .sec-badge { background: var(--x-jr-soft); color: var(--x-jr-strong); }
.sec-card-pro { border-top: 5px solid var(--accent); }
.sec-card-pro .sec-badge { background: var(--accent-soft); color: var(--accent-strong); }
.age { font-weight: 700; font-size: 0.85rem; color: var(--muted); }
.sec-list { list-style: none; padding: 0; margin: 4px 0; display: grid; gap: 8px; }
.sec-list li { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.sec-card-jr .sec-list .icon { color: var(--x-jr); }
.sec-card-pro .sec-list .icon { color: var(--accent-text); }
.sec-go { margin-top: auto; display: inline-flex; align-items: center; gap: 8px; font-weight: 700; }
.sec-card-jr .sec-go { color: var(--x-jr-strong); }
.sec-card-pro .sec-go { color: var(--accent-text); }
.feature-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 28px 0 48px; }
.feature { display: flex; gap: 12px; align-items: flex-start; padding: 16px; border-radius: 16px; background: var(--surface-2); }
.feature > .icon { width: 22px; height: 22px; color: var(--accent-text); margin-top: 2px; }
.feature b { display: block; margin-bottom: 3px; }
.feature span { color: var(--muted); font-size: 0.9rem; line-height: 1.45; }

/* ── Section view ── */
.sec-head { padding: 36px 0 8px; }
.age-chip { display: inline-block; font-weight: 700; font-size: 0.8rem; padding: 5px 11px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-strong); }
.sec-junior .age-chip { background: var(--x-jr-soft); color: var(--x-jr-strong); }
.sec-title { font-family: var(--font-display); font-weight: 600; font-size: clamp(2rem, 4vw, 2.8rem); margin: 10px 0 8px; line-height: 1.1; }
.sec-lede { color: var(--muted); max-width: 44rem; line-height: 1.55; margin: 0; }
.tabs { display: flex; gap: 8px; margin: 22px 0 18px; flex-wrap: wrap; }
.tab { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 12px; text-decoration: none; font-weight: 600; color: var(--muted); background: var(--surface); border: 1px solid var(--border); }
.tab em { font-style: normal; font-size: 0.75rem; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); }
.tab.on { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.tab.on em { background: rgba(255, 255, 255, 0.22); color: inherit; }
.sec-junior .tab.on { color: var(--x-ink-dark); background: var(--x-jr); border-color: var(--x-jr); }
.exp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 16px; padding-bottom: 56px; }
.exp-card { position: relative; display: flex; flex-direction: column; gap: 12px; padding: 18px; border-radius: 18px; background: var(--surface); border: 1px solid var(--border); text-decoration: none; color: var(--ink); box-shadow: var(--shadow-card); transition: transform .15s ease, border-color .15s ease; }
.exp-card:hover { transform: translateY(-2px); border-color: var(--accent-border); }
.sec-junior .exp-card:hover { border-color: var(--x-jr); }
.exp-ic { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--surface-2); flex: none; }
.exp-ic .icon { width: 24px; height: 24px; }
.tone-1 { color: var(--chart-1); } .tone-2 { color: var(--chart-2); } .tone-3 { color: var(--chart-3); }
.tone-4 { color: var(--chart-4); } .tone-5 { color: var(--chart-5); } .tone-6 { color: var(--chart-6); }
.exp-txt b { display: block; font-family: var(--font-display); font-weight: 600; font-size: 1.15rem; margin-bottom: 4px; }
.exp-txt span { color: var(--muted); font-size: 0.9rem; line-height: 1.45; }
.exp-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.exp-tags i { font-style: normal; font-size: 0.72rem; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.exp-go { position: absolute; top: 18px; right: 18px; color: var(--muted); }

/* ── Experiment view ── */
.exp-head { padding: 20px 0 14px; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 0.88rem; }
.back:hover { color: var(--ink); }
.exp-title { display: flex; align-items: center; gap: 14px; margin-top: 12px; }
.exp-title h1 { font-family: var(--font-display); font-weight: 600; font-size: clamp(1.6rem, 3vw, 2.1rem); margin: 0; line-height: 1.1; }
.exp-title p { margin: 4px 0 0; color: var(--muted); }
.exp-top:empty { display: none; }
.exp-top { margin-bottom: 16px; }
.exp-body { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; padding-bottom: 56px; }
.exp-main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.stage { position: relative; border-radius: 18px; overflow: hidden; background: var(--x-stage); border: 1px solid var(--border); box-shadow: var(--shadow-card); }
.stage canvas { display: block; width: 100%; }
.stage canvas.interactive { touch-action: none; cursor: crosshair; }
.stage-hint { position: absolute; left: 12px; bottom: 12px; padding: 6px 10px; border-radius: 9px; font-size: 0.8rem; font-weight: 600; background: var(--surface); color: var(--muted); border: 1px solid var(--border); pointer-events: none; max-width: calc(100% - 24px); }
.stage-hint[hidden] { display: none; }
.readouts { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.readouts[hidden] { display: none; }
.ro { padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.ro span { display: block; font-size: 0.75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.ro b { display: block; font-size: 1.05rem; margin-top: 3px; font-variant-numeric: tabular-nums; }
.exp-side { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 76px; }
.panel { padding: 16px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-card); }
.panel[hidden] { display: none; }
.panel-title, .info h3 { display: flex; align-items: center; gap: 8px; font-size: 0.82rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 12px; }
.info h3 { margin-top: 16px; margin-bottom: 6px; }
.info h3:first-child { margin-top: 0; }
.info h3 .icon { color: var(--accent-text); }
.sec-junior .info h3 .icon, .sec-junior .panel-title .icon { color: var(--x-jr); }
.info p, .info li { line-height: 1.55; font-size: 0.93rem; margin: 0; }
.info ul { margin: 0; padding-left: 18px; display: grid; gap: 4px; }
.formula { font-size: 0.92rem; line-height: 1.6; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); }
.formula code, .mono { font-family: var(--font-mono); font-size: 0.88em; }

.ctl { display: block; margin-bottom: 14px; }
.ctl:last-child { margin-bottom: 0; }
.ctl-l { display: flex; justify-content: space-between; gap: 8px; font-size: 0.88rem; font-weight: 600; margin-bottom: 6px; }
.ctl-l output { font-weight: 700; color: var(--accent-text); font-variant-numeric: tabular-nums; }
.sec-junior .ctl-l output { color: var(--x-jr-strong); }
.ctl input[type="range"] { width: 100%; accent-color: var(--accent); }
.sec-junior .ctl input[type="range"] { accent-color: var(--x-jr); }
.ctl select, .lab-input { width: 100%; padding: 8px 10px; border-radius: var(--radius-input); border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink); font: inherit; font-size: 0.9rem; }
.ctl-toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.ctl-toggle .ctl-l { margin: 0; }
.ctl-toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.sw { width: 40px; height: 23px; border-radius: 999px; background: var(--border-strong); position: relative; flex: none; transition: background .15s; }
.sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: var(--surface); transition: transform .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); }
.ctl-toggle input:checked + .sw { background: var(--accent); }
.sec-junior .ctl-toggle input:checked + .sw { background: var(--x-jr); }
.ctl-toggle input:checked + .sw::after { transform: translateX(17px); }
.ctl-toggle input:focus-visible + .sw { outline: 2px solid var(--accent); outline-offset: 2px; }
.ctl-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.ctl-btns .lab-btn { flex: 1 1 auto; }

/* ── Ingredient / chemical pickers ── */
.ing-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.ing { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 6px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); color: var(--ink); font: inherit; font-size: 0.78rem; font-weight: 600; text-align: center; line-height: 1.2; cursor: pointer; transition: transform .08s, border-color .15s; }
.ing:hover { border-color: var(--x-jr); background: var(--x-jr-soft); }
.ing:active { transform: scale(0.96); }
.ing .em { font-size: 1.6rem; line-height: 1; }
.cat-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.cat-tab { padding: 5px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); font: inherit; font-size: 0.78rem; font-weight: 600; cursor: pointer; }
.cat-tab.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chem-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; max-height: 330px; overflow: auto; padding-right: 2px; }
.chem { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 8px 9px; border-radius: 10px; border: 1px solid var(--border); border-left: 4px solid var(--border-strong); background: var(--surface); color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.chem:hover { border-color: var(--accent-border); background: var(--accent-soft); }
.chem b { font-size: 0.9rem; font-weight: 700; }
.chem span { font-size: 0.7rem; color: var(--muted); line-height: 1.2; }
.chem.k-acid { border-left-color: var(--danger); }
.chem.k-base { border-left-color: var(--chart-5); }
.chem.k-salt { border-left-color: var(--chart-3); }
.chem.k-metal { border-left-color: var(--x-steel); }
.chem.k-ind { border-left-color: var(--chart-4); }
.chem.k-other { border-left-color: var(--warning); }
.lab-input { margin-bottom: 10px; }
.contents { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 28px; }
.contents .pill { font-size: 0.8rem; font-weight: 600; padding: 4px 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
.contents .none { color: var(--muted); font-size: 0.85rem; }
.idea-row { display: flex; flex-wrap: wrap; gap: 6px; }
.idea { padding: 6px 10px; border-radius: 999px; border: 1px dashed var(--border-strong); background: transparent; color: var(--ink); font: inherit; font-size: 0.8rem; font-weight: 600; cursor: pointer; }
.idea:hover { border-style: solid; background: var(--surface-2); }
.side-sec { margin-top: 14px; }
.side-sec:first-child { margin-top: 0; }
.side-sec > h4 { margin: 0 0 8px; font-size: 0.8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

/* ── Observations ── */
.obs-list { display: grid; gap: 10px; }
.obs { padding: 14px 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-card); }
.obs-h { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.obs-h .em { font-size: 1.5rem; line-height: 1; }
.obs-h b { font-size: 1rem; }
.obs-tag { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; padding: 3px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-strong); }
.obs p { margin: 8px 0 0; line-height: 1.55; font-size: 0.93rem; }
.obs .see { color: var(--muted); }
.eq { margin-top: 10px; padding: 9px 12px; border-radius: 10px; background: var(--surface-2); font-size: 0.95rem; line-height: 1.5; overflow-x: auto; }
.eq small { display: block; font-size: 0.7rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 2px; }
.obs.warn { border-color: var(--danger); background: var(--danger-soft); }
.obs.warn .obs-tag { background: var(--danger); color: var(--danger-ink); }
.obs.good .obs-tag { background: var(--success-soft); color: var(--success-strong); }
.obs.jr .obs-tag { background: var(--x-jr-soft); color: var(--x-jr-strong); }
.obs.empty { color: var(--muted); text-align: center; box-shadow: none; border-style: dashed; }

/* ── Periodic table ── */
.pt-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 10px; }
.pt-tools .lab-input { width: 220px; margin: 0; }
.pt-scroll { overflow-x: auto; padding-bottom: 6px; }
.pt-grid { display: grid; grid-template-columns: repeat(18, minmax(40px, 1fr)); gap: 3px; min-width: 760px; }
.pt-cell { position: relative; aspect-ratio: 1 / 1.08; border-radius: 6px; border: 0; padding: 3px 4px; display: flex; flex-direction: column; justify-content: space-between; text-align: left; cursor: pointer; color: var(--x-ink-dark); font: inherit; line-height: 1; transition: transform .1s, opacity .15s; }
.pt-cell:hover { transform: scale(1.12); z-index: 2; box-shadow: var(--shadow-raised); }
.pt-cell i { font-style: normal; font-size: 0.56rem; opacity: .75; }
.pt-cell b { font-size: 0.98rem; font-weight: 700; }
.pt-cell span { font-size: 0.48rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pt-cell.sel { outline: 3px solid var(--ink); outline-offset: 1px; z-index: 3; }
.pt-cell.dim { opacity: .18; }
.pt-gap { aspect-ratio: 1 / 1.08; border-radius: 6px; border: 1px dashed var(--border-strong); display: grid; place-items: center; font-size: 0.55rem; color: var(--muted); }
.pt-space { height: 10px; grid-column: 1 / -1; }
.c-alkali { background: var(--x-pt-alkali); } .c-alkaline { background: var(--x-pt-alkaline); }
.c-transition { background: var(--x-pt-transition); } .c-post { background: var(--x-pt-post); }
.c-metalloid { background: var(--x-pt-metalloid); } .c-nonmetal { background: var(--x-pt-nonmetal); }
.c-halogen { background: var(--x-pt-halogen); } .c-noble { background: var(--x-pt-noble); }
.c-lanth { background: var(--x-pt-lanth); } .c-actin { background: var(--x-pt-actin); }
.c-unknown { background: var(--x-pt-unknown); }
.pt-legend { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.pt-legend button { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--ink); font: inherit; font-size: 0.75rem; font-weight: 600; cursor: pointer; }
.pt-legend button.on { border-color: var(--ink); }
.pt-legend i { width: 12px; height: 12px; border-radius: 3px; display: block; }
.el-head { display: flex; gap: 14px; align-items: center; }
.el-big { width: 84px; height: 90px; border-radius: 12px; padding: 7px 9px; display: flex; flex-direction: column; justify-content: space-between; color: var(--x-ink-dark); flex: none; }
.el-big i { font-style: normal; font-size: 0.8rem; font-weight: 700; }
.el-big b { font-size: 2rem; line-height: 1; font-weight: 700; }
.el-big span { font-size: 0.7rem; }
.el-head h3 { margin: 0; font-family: var(--font-display); font-weight: 600; font-size: 1.5rem; }
.el-head p { margin: 2px 0 0; color: var(--muted); font-size: 0.88rem; }
.el-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.el-facts div { padding: 8px 10px; border-radius: 10px; background: var(--surface-2); }
.el-facts span { display: block; font-size: 0.7rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.el-facts b { display: block; font-size: 0.92rem; margin-top: 2px; }
.el-facts .full { grid-column: 1 / -1; }

/* ── Footer ── */
.foot { border-top: 1px solid var(--border); background: var(--surface); }
.foot-in { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding-top: 16px; padding-bottom: 16px; font-size: 0.85rem; color: var(--muted); }
.foot-in span { display: inline-flex; align-items: center; gap: 6px; }

/* ── Small screens ── */
@media (max-width: 960px) {
  .exp-body { grid-template-columns: 1fr; }
  .exp-side { position: static; }
  .hero { grid-template-columns: 1fr; padding-top: 28px; }
  .hero-art { aspect-ratio: 16 / 10; }
}
@media (max-width: 720px) {
  .sec-cards, .feature-row { grid-template-columns: 1fr; }
  .topnav a span { display: none; }
  .topnav a em { display: none; }
  .topnav a::after { content: attr(data-short); }
  .brand-name { font-size: 1.05rem; }
  .wrap { padding: 0 14px; }
}
