:root {
  --bg: #f7f8fc;
  --panel: #ffffff;
  --ink: #1d2433;
  --muted: #6b7280;
  --line: #e6e8ef;
  --brand: #263a7a;
  --brand-2: #7357d5;
  --accent: #f0b429;
  --good: #1f9d6a;
  --bad: #d14a61;
  --soft: #eef1fb;
  --shadow: 0 12px 34px rgba(39, 49, 85, .08);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, sans-serif; color: var(--ink); background: var(--bg); }
button, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.topbar { height: 76px; padding: 0 24px; background: var(--panel); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 42px; height: 42px; border-radius: 14px; background: linear-gradient(135deg,var(--brand),var(--brand-2)); color: white; display: grid; place-items: center; font-weight: 800; font-size: 22px; }
.brand strong, .brand span { display: block; }
.brand span { color: var(--muted); font-size: 13px; margin-top: 1px; }
.header-actions { display:flex; gap:10px; align-items:center; }
select, .ghost { border: 1px solid var(--line); background: white; padding: 10px 12px; border-radius: 12px; }
.app-shell { min-height: calc(100vh - 120px); display: grid; grid-template-columns: 220px minmax(0, 1fr); }
.sidebar { padding: 20px 14px; border-right: 1px solid var(--line); background: #fbfbfe; display:flex; flex-direction:column; gap:8px; }
.nav-btn { border: 0; background: transparent; padding: 12px 14px; border-radius: 12px; text-align: left; color: #4b5563; font-weight: 700; }
.nav-btn:hover, .nav-btn.active { background: var(--soft); color: var(--brand); }
.content { padding: 28px; max-width: 1180px; width: 100%; margin: 0 auto; }
.view { display:none; }
.view.active { display:block; }
.hero { background: linear-gradient(135deg,#16213e,#384b9b); color:white; border-radius: 24px; padding: 28px; box-shadow: var(--shadow); display:grid; grid-template-columns: 1.35fr .65fr; gap:20px; align-items:center; }
.hero h1 { font-size: clamp(28px, 4vw, 46px); margin:0 0 8px; line-height:1.05; }
.hero p { margin:0; opacity:.87; max-width:650px; }
.hero-card { background: rgba(255,255,255,.12); padding:18px; border:1px solid rgba(255,255,255,.16); border-radius:18px; }
.kicker { font-size:12px; text-transform:uppercase; letter-spacing:.11em; font-weight:800; opacity:.75; }
.mission-hero { background:linear-gradient(135deg,var(--brand),var(--brand-2)); color:white; border-radius:24px; padding:28px; box-shadow:var(--shadow); }
.mission-hero .kicker { opacity:.85; }
.mission-hero h1 { font-size:clamp(26px,4vw,38px); margin:8px 0 8px; line-height:1.1; }
.mission-hero p { margin:0 0 16px; opacity:.9; max-width:640px; }
.mission-hero .cta { background:white; color:var(--brand); }
.mission-status { margin-top:12px; font-weight:700; opacity:.9; font-size:14px; }
.holiday-strip { font-size:22px; letter-spacing:10px; margin-top:10px; }
.streak-milestone { text-align:center; font-weight:800; color:var(--brand); background:var(--soft); margin-bottom:14px; }
.stat-strip { display:flex; gap:22px; flex-wrap:wrap; padding:16px 2px; }
.stat-strip .item { display:flex; align-items:center; gap:7px; font-weight:700; color:var(--muted); font-size:14px; }
.stat-strip .item b { font-size:18px; font-weight:850; color:var(--ink); }
.mini-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:14px; margin-bottom:8px; }
.grid { display:grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap:14px; margin-top:18px; }
.card { background:var(--panel); border:1px solid var(--line); border-radius:18px; padding:18px; box-shadow: var(--shadow); }
.stat-value { font-size:30px; font-weight:850; margin:4px 0; }
.stat-label { color:var(--muted); font-size:13px; }
.section-title { display:flex; align-items:end; justify-content:space-between; gap:12px; margin:28px 0 12px; }
.section-title h2 { margin:0; font-size:22px; }
.section-title p { margin:0; color:var(--muted); font-size:14px; }
.cta { border:0; border-radius:14px; padding:12px 16px; font-weight:800; background:var(--brand); color:white; }
.cta.secondary { background:var(--soft); color:var(--brand); }
.cta.warn { background:#fff1f2; color:#9f1239; }
.progress { height:10px; background:#edf0f5; border-radius:999px; overflow:hidden; }
.progress > span { display:block; height:100%; background:linear-gradient(90deg,var(--brand),var(--brand-2)); border-radius:999px; }
.skill-row { display:grid; grid-template-columns:160px 1fr 54px; gap:12px; align-items:center; padding:10px 0; }
.skill-row small { color:var(--muted); }
.badge { display:inline-flex; align-items:center; gap:6px; padding:6px 10px; border-radius:999px; background:var(--soft); color:var(--brand); font-size:12px; font-weight:800; }
.daily-shell { max-width: 850px; margin: 0 auto; }
.question-card { background:white; border:1px solid var(--line); border-radius:22px; padding:24px; box-shadow:var(--shadow); }
.q-meta { display:flex; justify-content:space-between; align-items:center; gap:10px; color:var(--muted); font-size:13px; margin-bottom:14px; }
.q-text { font-size:24px; line-height:1.35; font-weight:750; margin:12px 0 18px; }
.choices { display:grid; gap:10px; }
.choice { border:1px solid var(--line); background:white; border-radius:14px; padding:14px 16px; text-align:left; display:flex; gap:12px; align-items:center; }
.choice:hover { border-color:#b8bfd5; background:#fafbff; }
.choice.correct { border-color:#8dd4b7; background:#ecfdf5; }
.choice.wrong { border-color:#f3a4b1; background:#fff1f2; }
.choice.picked { border-color:var(--brand-2); background:var(--soft); }
.letter { width:30px; height:30px; border-radius:9px; display:grid; place-items:center; background:#f2f4f8; font-weight:850; flex:0 0 auto; }
.feedback { margin-top:16px; border-radius:14px; padding:14px 16px; background:#f8fafc; border:1px solid var(--line); line-height:1.55; }
.feedback.good { background:#ecfdf5; border-color:#bbf7d0; }
.feedback.bad { background:#fff1f2; border-color:#fecdd3; }
.actions { position:sticky; bottom:0; z-index:5; background:var(--panel); padding:14px 24px; margin:16px -24px -24px; border-top:1px solid var(--line); border-radius:0 0 22px 22px; display:flex; gap:10px; justify-content:flex-end; }
.timer { font-variant-numeric:tabular-nums; font-weight:850; }
.topic-chip { display:inline-block; padding:5px 8px; border-radius:8px; background:#f3f4f6; font-size:12px; color:#525b6b; }
.mock-grid { display:grid; grid-template-columns: 1fr 300px; gap:16px; }
.mock-side { position:sticky; top:98px; height:max-content; }
.answer-grid { display:grid; grid-template-columns:repeat(5,1fr); gap:6px; margin-top:12px; }
.answer-dot { border:1px solid var(--line); background:white; border-radius:9px; padding:7px; font-size:12px; }
.answer-dot.done { background:var(--soft); color:var(--brand); font-weight:800; }
.table { width:100%; border-collapse:collapse; }
.table th, .table td { border-bottom:1px solid var(--line); padding:11px 8px; text-align:left; font-size:14px; }
.table th { color:var(--muted); font-size:12px; text-transform:uppercase; letter-spacing:.05em; }
.empty { text-align:center; padding:32px; color:var(--muted); }
.footer { min-height:44px; display:flex; justify-content:center; align-items:center; gap:14px; padding:10px 18px; color:var(--muted); font-size:12px; border-top:1px solid var(--line); background:white; }
.hidden { display:none !important; }
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position:fixed; left:0; right:0; bottom:0; z-index:30; height:64px; border-right:0; border-top:1px solid var(--line); padding:7px; background:white; display:grid; grid-template-columns:repeat(6,1fr); }
  .nav-btn { padding:8px 4px; text-align:center; font-size:20px; }
  .nav-btn span { display:none; }
  .content { padding:18px 14px 84px; }
  .grid { grid-template-columns:repeat(2,1fr); }
  .hero { grid-template-columns:1fr; }
  .mock-grid { grid-template-columns:1fr; }
  .mock-side { position:static; }
  .skill-row { grid-template-columns:110px 1fr 46px; }
  .footer { padding-bottom:72px; flex-direction:column; gap:4px; }
  .actions { bottom:64px; } /* docks above the mobile bottom nav (.sidebar, fixed, 64px, z-index:30) instead of underneath it */
}
@media (max-width: 560px) {
  .topbar { padding:0 12px; }
  .brand span { display:none; }
  .grid { grid-template-columns:1fr 1fr; }
  .q-text { font-size:20px; }
  .mini-grid { grid-template-columns:1fr 1fr; }
  .stat-strip { gap:14px; }
}

/* Content-pack integration additions */
.hint-row { margin-top:14px; }
.hint-btn { font-weight:700; color:var(--brand); }
.hint-btn:disabled { opacity:.5; cursor:default; }
.hint-box { margin-top:14px; border-radius:14px; padding:12px 16px; background:#fffbeb; border:1px solid #fde68a; line-height:1.5; }
.badge-muted { background:#f2f4f8; color:var(--muted); }
.confidence-row { display:flex; gap:8px; flex-wrap:wrap; margin-top:10px; }
.confidence-row button { flex:1 1 auto; min-width:100px; }
.mock-card { display:flex; align-items:center; justify-content:space-between; gap:16px; flex-wrap:wrap; margin-bottom:12px; }
.mock-card.locked { opacity:.6; }
.review-item { padding:14px 0; border-bottom:1px solid var(--line); }
.review-item:last-child { border-bottom:0; }
.stat-mini { background:var(--soft); border-radius:12px; padding:10px 16px; text-align:center; min-width:80px; }

/* Gate + profile-picker overlays */
.overlay-screen { position:fixed; inset:0; z-index:100; background:linear-gradient(135deg,#16213e,#384b9b); display:flex; align-items:center; justify-content:center; padding:24px; }
.overlay-card { background:var(--panel); border-radius:24px; padding:36px; box-shadow:0 24px 60px rgba(10,14,30,.35); max-width:420px; width:100%; text-align:center; }
.overlay-card .brand-mark.large { width:64px; height:64px; margin:0 auto 16px; border-radius:18px; background:linear-gradient(135deg,var(--brand),var(--brand-2)); color:white; display:grid; place-items:center; font-weight:800; font-size:32px; }
.overlay-card h1 { margin:0 0 8px; font-size:24px; }
.overlay-card p { margin:0 0 20px; color:var(--muted); }
#gateForm { display:flex; gap:8px; }
#gateInput { flex:1; border:1px solid var(--line); border-radius:12px; padding:13px 14px; font-size:16px; }
.gate-error { margin-top:12px; color:var(--bad); font-weight:700; font-size:14px; }
.gate-error.shake { animation:shake .4s; }
@keyframes shake { 10%,90%{transform:translateX(-2px)} 20%,80%{transform:translateX(4px)} 30%,50%,70%{transform:translateX(-8px)} 40%,60%{transform:translateX(8px)} }
.picker-card { max-width:560px; }
.avatar-grid { display:grid; grid-template-columns:repeat(2,1fr); gap:16px; margin-top:8px; }
.avatar-card { border:2px solid var(--line); background:white; border-radius:20px; padding:22px 14px; display:flex; flex-direction:column; align-items:center; gap:8px; }
.avatar-card:hover { border-color:var(--brand-2); background:var(--soft); }
.avatar-circle { width:76px; height:76px; border-radius:50%; background:var(--soft); display:grid; place-items:center; font-size:38px; }
.avatar-card strong { font-size:16px; }
.avatar-card span { color:var(--muted); font-size:13px; }
.profile-badge { display:flex; align-items:center; gap:8px; font-weight:700; }
.profile-badge .avatar-mini { width:26px; height:26px; border-radius:50%; background:var(--soft); display:grid; place-items:center; font-size:16px; }
.avatar-picker-row { display:flex; gap:8px; flex-wrap:wrap; margin-top:10px; }
.avatar-choice { width:44px; height:44px; border-radius:50%; border:2px solid var(--line); background:white; font-size:20px; display:grid; place-items:center; }
.avatar-choice.selected { border-color:var(--brand); background:var(--soft); }
@media (max-width:560px) {
  .avatar-grid { grid-template-columns:1fr; }
  #gateForm { flex-direction:column; }
}

/* Parent Dashboard: PIN gate, tabs, dual-learner columns */
.parent-tabs { display:flex; gap:6px; flex-wrap:wrap; margin:18px 0 4px; }
.parent-tab-btn { border:1px solid var(--line); background:white; padding:9px 14px; border-radius:12px; font-weight:700; color:#4b5563; }
.parent-tab-btn:hover { border-color:var(--brand-2); }
.parent-tab-btn.active { background:var(--brand); border-color:var(--brand); color:white; }
.parent-columns { display:grid; grid-template-columns:1fr 1fr; gap:20px; margin-top:14px; align-items:start; }
.parent-column > .parent-column-header:first-child { margin-top:0; }
.parent-column-header { display:flex; align-items:baseline; justify-content:space-between; gap:8px; margin:18px 0 8px; font-size:16px; }
.column-source { font-size:12px; font-weight:600; color:var(--muted); }
#parentPinForm { max-width:380px; }
@media (max-width: 900px) {
  .parent-columns { grid-template-columns:1fr; }
}

/* Sound toggle + save-status banner */
.sound-toggle { font-size:18px; line-height:1; padding:10px 12px; }
.save-banner { position:fixed; left:50%; bottom:18px; transform:translateX(-50%); z-index:200; max-width:min(92vw,520px);
  display:flex; align-items:center; gap:14px; background:#fff1f2; border:1px solid #fecdd3; color:#9f1239;
  padding:14px 18px; border-radius:16px; box-shadow:var(--shadow); font-size:14px; font-weight:700; line-height:1.4; }
.save-banner.hidden { display:none; }

@media print {
  body * { visibility: hidden; }
  #parentPrintable, #parentPrintable * { visibility: visible; }
  #parentPrintable { position: absolute; left: 0; top: 0; width: 100%; }
}
.save-banner button { flex:0 0 auto; background:white; }

/* Science hub */
.sci-shell { max-width:980px; margin:0 auto; }
.sci-hero { background:linear-gradient(135deg,#0f766e,#2563eb); }
.sci-hero-row { display:flex; gap:12px; flex-wrap:wrap; align-items:center; margin-top:4px; }
.sci-hero .badge { background:rgba(255,255,255,.18); color:white; }
.sci-p { display:inline; }
.sci-s { display:block; color:var(--muted); font-size:.86em; font-style:italic; font-weight:500; margin-top:2px; }
.mission-hero .sci-s { color:rgba(255,255,255,.8); }
.cta .sci-s, .badge .sci-s, .sci-seg .sci-s, .ghost .sci-s, .sci-chip .sci-s, .choice .letter + span .sci-s { display:inline; margin-left:6px; font-style:normal; opacity:.85; }
.sci-seg { display:inline-flex; border:1px solid var(--line); border-radius:12px; overflow:hidden; background:white; }
.sci-seg button { border:0; background:white; padding:8px 12px; font-weight:700; font-size:13px; color:#4b5563; }
.sci-seg button.active { background:var(--brand); color:white; }
.sci-bar { display:flex; justify-content:space-between; align-items:center; gap:10px; flex-wrap:wrap; margin-bottom:6px; }
.sci-topics { display:grid; grid-template-columns:repeat(auto-fill,minmax(210px,1fr)); gap:14px; margin-top:18px; }
.sci-topic { text-align:left; display:flex; flex-direction:column; gap:6px; align-items:flex-start; font:inherit; color:inherit; }
button.sci-topic:hover { border-color:var(--brand-2); background:#fafbff; }
.sci-topic.soon { opacity:.65; }
.sci-topic h3, .sci-lesson h3, .sci-system h3 { margin:0; font-size:19px; }
.sci-topic-icon, .sci-lesson-icon { font-size:40px; line-height:1; }
.sci-tag { margin:0; color:var(--muted); font-size:14px; line-height:1.45; }
.sci-mini { display:flex; align-items:center; gap:6px; font-size:13px; color:var(--muted); }
.sci-star { color:#d5d9e3; font-size:22px; line-height:1; }
.sci-star.on { color:var(--accent); }
.sci-section { margin:22px 0 10px; font-size:18px; font-weight:800; }
.sci-lessons { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:14px; }
.sci-lesson { display:flex; gap:14px; text-align:left; font:inherit; color:inherit; align-items:flex-start; }
.sci-lesson:hover { border-color:var(--brand-2); background:#fafbff; }
.sci-lesson-body { flex:1; min-width:0; }
.sci-lesson-head { display:flex; justify-content:space-between; gap:8px; align-items:flex-start; }
.sci-chips { display:flex; flex-wrap:wrap; gap:8px; }
.sci-chip { border:2px solid var(--line); background:white; border-radius:14px; padding:9px 12px; font-weight:700; display:flex; gap:8px; align-items:center; }
.sci-chip:hover, .sci-chip.active { border-color:var(--c); background:color-mix(in srgb, var(--c) 10%, white); }
.sci-chip-icon { font-size:20px; }
.sci-system { margin-top:14px; border-left:6px solid var(--c); }
.sci-system-head { display:flex; align-items:center; gap:10px; }
.sci-system-icon { font-size:34px; }
.sci-system p { line-height:1.6; font-size:16px; }
.sci-label { font-size:12px; text-transform:uppercase; letter-spacing:.08em; font-weight:800; color:var(--muted); margin-top:8px; }
.sci-fact { margin:12px 0; border-radius:14px; padding:12px 16px; background:#fffbeb; border:1px solid #fde68a; line-height:1.5; }
.sci-lesson-card { margin-top:8px; padding:24px; border-radius:22px; }
.sci-question { margin:6px 0 4px; font-size:22px; line-height:1.3; }
.sci-diagram { width:100%; height:auto; max-height:360px; display:block; margin:8px auto 0; }
.sci-edge { stroke-width:3; opacity:.2; stroke-dasharray:6 6; }
.sci-edge.on { stroke-width:5; opacity:1; stroke-dasharray:12 8; animation:sci-flow 1s linear infinite; }
@keyframes sci-flow { to { stroke-dashoffset:-20; } }
.sci-node circle { fill:white; stroke:var(--line); stroke-width:3; }
.sci-node { opacity:.4; }
.sci-node.on { opacity:1; }
.sci-node.on circle { stroke:var(--brand-2); fill:var(--soft); }
.sci-node-icon { font-size:28px; }
.sci-node-label { font-size:14px; font-weight:700; fill:var(--ink); }
.sci-node-label.vi { font-size:11px; font-weight:500; font-style:italic; fill:var(--muted); }
.sci-legend { display:flex; gap:16px; flex-wrap:wrap; justify-content:center; font-size:13px; color:var(--muted); margin-top:4px; }
.sci-legend span { display:inline-flex; align-items:center; gap:6px; }
.sci-legend i { width:22px; height:5px; border-radius:3px; display:inline-block; }
.sci-legend .sci-s { display:inline; margin-left:4px; }
.sci-dots { display:flex; gap:8px; justify-content:center; margin:10px 0; }
.sci-dot { width:14px; height:14px; border-radius:50%; border:0; background:#d5d9e3; padding:0; }
.sci-dot.past { background:var(--brand-2); opacity:.55; }
.sci-dot.active { background:var(--brand); transform:scale(1.3); }
.sci-step { background:var(--soft); border-radius:16px; padding:14px 18px; }
.sci-step h3 { margin:0 0 6px; font-size:19px; }
.sci-step p { margin:0; font-size:17px; line-height:1.6; }
.sci-actions { margin-top:20px; } /* keeps .actions' sticky dock above the mobile nav */
.sci-credits { margin-top:26px; font-size:12px; color:var(--muted); line-height:1.6; }
.sci-credits a { display:inline-block; margin-top:8px; font-weight:700; color:var(--brand); }
.sci-result { text-align:center; padding:32px; margin-top:8px; }
.sci-result-stars .sci-star { font-size:56px; }
.sci-result-actions { display:flex; gap:10px; justify-content:center; flex-wrap:wrap; margin-top:14px; }
@media (max-width:900px) { .sci-lessons { grid-template-columns:1fr; } }
@media (prefers-reduced-motion:reduce) { .sci-edge.on { animation:none; } }

.sci-atlas-card { display:flex; gap:16px; align-items:center; text-align:left; width:100%; margin-top:12px; font:inherit; color:inherit; background:linear-gradient(135deg,#f0fdfa,#eef2ff); }
.sci-atlas-card:hover { border-color:var(--brand-2); }
.sci-atlas-gate { text-align:center; padding:28px; }
.sci-atlas-gate p { max-width:560px; margin:0 auto 16px; line-height:1.6; }
.sci-atlas-frame { width:100%; height:calc(100vh - 240px); min-height:520px; border:1px solid var(--line); border-radius:18px; background:#101c25; display:block; }
.sci-atlas-tab { display:inline-block; margin-top:8px; font-weight:700; color:var(--brand); }
@media (max-width:900px) { .sci-atlas-frame { height:calc(100vh - 210px); min-height:480px; } }

.sci-sources { margin-top:8px; line-height:1.8; }
.sci-sources a { font-weight:700; color:var(--brand); margin-right:2px; }

/* Human Atlas verbatim topic (lesson diagrams keep the original's dark palette so its colours read as designed) */
.function-diagram { position:relative; max-width:460px; margin:12px auto 6px; padding:14px 12px 32px; background:radial-gradient(ellipse at center,#355166aa,transparent 74%),#122531; border-radius:14px; }
.function-diagram svg { width:100%; height:auto; display:block; overflow:visible; }
.function-diagram text { font-family:inherit; font-size:10px; fill:#c3d6df; text-anchor:middle; }
.function-diagram text.small-label { font-size:8px; fill:#9ebbc9; }
.function-diagram text.organ-label { font-size:9px; fill:#fce6df; }
.function-diagram > span { position:absolute; bottom:9px; left:0; right:0; text-align:center; font-size:11px; color:#8da7b5; }
.ha-question { color:var(--muted); line-height:1.6; margin:4px 0 0; }
.ha-playback { display:flex; align-items:center; gap:12px; max-width:460px; margin:12px auto; }
.ha-play { width:40px; height:40px; border-radius:50%; border:0; background:#e0c69f; color:#162935; font-size:16px; flex:0 0 auto; }
.ha-playback input[type=range] { flex:1; min-width:0; }
.ha-playback select { border:1px solid var(--line); border-radius:8px; padding:8px 6px; background:white; }
.ha-tabs { display:flex; gap:8px; max-width:460px; margin:0 auto 14px; }
.ha-tabs button { flex:1; height:34px; border:1px solid var(--line); border-radius:8px; background:white; font-weight:700; color:#4b5563; }
.ha-tabs button.active { background:var(--brand); border-color:var(--brand); color:white; }
.ha-step { background:var(--soft); border-radius:16px; padding:14px 18px; }
.ha-step h3 { margin:0 0 8px; font-size:19px; }
.ha-step p { margin:0; font-size:17px; line-height:1.7; }
.ha-fact { border-left:3px solid #bba37f; padding:2px 0 2px 14px; margin:18px 0; }
.ha-fact > span { font-size:12px; font-weight:800; color:#8a6d3b; }
.ha-fact p { margin:6px 0 0; line-height:1.6; }
.ha-source { display:inline-block; font-weight:700; color:var(--brand); line-height:1.6; }
.ha-symbol { width:44px; height:44px; border-radius:50%; background:var(--soft); display:grid; place-items:center; font-size:22px; flex:0 0 auto; }
.sci-verbatim { font-size:13px; color:var(--muted); line-height:1.6; background:#fbfbfe; margin-top:8px; }
.ha-about p { line-height:1.7; margin:8px 0; }
.ha-note { color:var(--muted); }
.ha-prov { font-size:12px; }
.ha-only-vi { margin:10px 2px 0; }

/* 3D lesson scenes (lazy three.js chunk) */
.sci-viewbar { display:inline-flex; border:1px solid var(--line); border-radius:12px; overflow:hidden; margin:8px 0 6px; background:white; }
.sci-viewbar button { border:0; background:white; padding:7px 14px; font-weight:700; font-size:13px; color:#4b5563; }
.sci-viewbar button.active { background:var(--brand); color:white; }
.sci-3d, .sci-3d-slot { position:relative; width:100%; height:clamp(270px, 46vh, 420px); border-radius:16px; overflow:hidden; background:#0b1020; margin:6px 0 4px; }
.sci-3d-slot { display:grid; place-items:center; color:var(--muted); background:var(--soft); }
.s3-canvas { position:absolute; inset:0; width:100%; height:100%; display:block; }
.s3-labels { position:absolute; inset:0; pointer-events:none; overflow:hidden; }
.s3-label { position:absolute; left:0; top:0; will-change:transform; padding:2px 8px; border-radius:8px; background:rgba(8,14,32,.62); color:#fff; font-size:12px; font-weight:700; line-height:1.25; text-align:center; white-space:nowrap; transition:opacity .2s; }
.s3-label small { display:block; font-weight:500; font-style:italic; opacity:.85; font-size:10.5px; }
.s3-label--accent { background:rgba(37,99,235,.8); }
.s3-ui { position:absolute; right:8px; top:8px; display:flex; gap:6px; z-index:2; }
.s3-btn { width:36px; height:36px; border-radius:50%; border:0; background:rgba(255,255,255,.88); color:#162935; font-size:16px; }
.s3-hint { position:absolute; left:50%; bottom:6px; transform:translateX(-50%); width:max-content; max-width:calc(100% - 16px); font-size:10.5px; line-height:1.3; color:#fff; background:rgba(15,23,42,.68); border-radius:8px; padding:2px 8px; text-align:center; pointer-events:none; }
.s3-moonview { position:absolute; left:8px; top:8px; background:rgba(8,14,32,.62); border-radius:12px; padding:6px 8px; color:#fff; font-size:10.5px; text-align:center; z-index:2; }
.s3-moonview canvas { display:block; width:72px; height:72px; margin:0 auto 3px; }
.s3-moonview small { display:block; font-style:italic; opacity:.85; }
.s3-counter { position:absolute; left:50%; top:14px; transform:translateX(-50%); background:rgba(255,255,255,.92); color:#111; font-weight:900; font-size:26px; padding:2px 14px; border-radius:12px; z-index:2; font-variant-numeric:tabular-nums; }
@media (max-width:560px) { .s3-label { font-size:11px; padding:1px 6px; } .s3-hint { font-size:9.5px; } }
/* Labs subject tiles: two or three per row on a phone instead of one long column */
.sci-lab-tiles { display:grid; grid-template-columns:repeat(auto-fit, minmax(150px, 1fr)); gap:8px; margin-bottom:12px; }
.sci-lab-tiles .sci-chip { justify-content:flex-start; min-width:0; }
.sci-lab-tiles .sci-chip b { margin-left:auto; }
.sci-lab-name { display:flex; flex-direction:column; line-height:1.15; min-width:0; }
.sci-lab-name .sci-s { display:block; margin:2px 0 0; font-size:11px; font-style:normal; opacity:.75; }
/* Code Quest */
.cq-main { display:grid; grid-template-columns:minmax(280px, 400px) 1fr; gap:14px; align-items:start; margin-top:12px; }
.cq-levels { margin-top:8px; }
.cq-levels .sci-chip { flex-direction:column; gap:2px; padding:6px 12px; min-width:64px; }
.cq-chip-stars .sci-star { font-size:11px; }
.cq-side { padding:14px; display:grid; gap:10px; container-type:inline-size; min-width:0; }
.cq-goal { margin:0; line-height:1.5; }
.cq-title { margin:0; font-size:20px; }
.cq-board { --cell:min(46px, calc((100cqw - 6px) / var(--cols))); position:relative; display:grid; grid-template-columns:repeat(var(--cols), var(--cell)); grid-auto-rows:var(--cell); width:max-content; max-width:100%; margin:0 auto; border-radius:12px; overflow:hidden; box-shadow:0 0 0 3px var(--line); }
.cq-cell.wall { background:#334155; }
.cq-cell.floor { background:#e8f0ff; box-shadow:inset 0 0 0 1px rgba(15,23,42,.07); }
.cq-cell.goal { display:grid; place-items:center; font-size:calc(var(--cell) * .62); }
.cq-robot { position:absolute; left:0; top:0; width:var(--cell); height:var(--cell); display:grid; place-items:center; transform:translate(calc(var(--x) * var(--cell)), calc(var(--y) * var(--cell))); transition:transform .28s ease; }
.cq-bot { font-size:calc(var(--cell) * .62); line-height:1; }
.cq-arrow { position:absolute; inset:0; display:grid; place-items:start center; font-size:calc(var(--cell) * .3); line-height:1; color:#2563eb; text-shadow:0 0 2px #fff; transform:rotate(var(--r)); transition:transform .28s ease; }
.cq-robot.bump .cq-bot { animation:cq-bump .3s; }
@keyframes cq-bump { 25% { transform:translateX(-4px); } 75% { transform:translateX(4px); } }
@media (prefers-reduced-motion: reduce) { .cq-robot, .cq-arrow { transition:none; } .cq-robot.bump .cq-bot { animation:none; } }
.cq-actions { display:flex; flex-wrap:wrap; gap:8px; }
.cq-actions button[disabled] { opacity:.55; }
.cq-hint { padding:8px 12px; border-radius:12px; background:#fff8e1; border:1px solid #f5d67a; line-height:1.5; }
.cq-msg { padding:10px 12px; border-radius:12px; line-height:1.5; display:grid; gap:6px; }
.cq-msg.ok { background:#e8f8ee; border:1px solid #9bd8b0; }
.cq-msg.bad { background:#fdeeee; border:1px solid #f0b3b3; }
.cq-msg-head { font-weight:800; }
.cq-work { position:relative; min-width:0; }
.cq-blockly { position:relative; isolation:isolate; z-index:0; width:100%; height:460px; border:1px solid var(--line); border-radius:16px; overflow:hidden; background:#fff; } /* isolate: Blockly's own z-indexes must not climb over the sticky app header */
.cq-loading { position:absolute; inset:0; display:grid; place-items:center; color:var(--muted, #64748b); pointer-events:none; }
.cq-error { text-align:center; padding:24px; }
@media (max-width:900px) { .cq-main { grid-template-columns:1fr; } .cq-blockly { height:360px; } }
/* Labs: links to PhET simulations */
.sci-phet { display:grid; grid-template-columns:repeat(auto-fill, minmax(230px, 1fr)); gap:10px; margin-bottom:14px; }
.sci-phet-card { display:flex; align-items:center; gap:10px; padding:12px 14px; text-decoration:none; color:inherit; }
.sci-phet-card:hover { border-color:var(--brand); }
.sci-phet-icon { font-size:26px; }
.sci-phet-text { display:grid; gap:2px; flex:1; min-width:0; }
.sci-phet-text .sci-tag { margin:0; }
