/* Science with Mr. Fawzy · Version 2.3 */
:root {
  --bg: #f3f7fa;
  --surface: #ffffff;
  --surface-2: #eef4f8;
  --ink: #10283a;
  --muted: #587084;
  --line: #d9e4ec;
  --brand: #0a5c8a;
  --brand-ink: #ffffff;
  --brand-2: #10a0a8;
  --deep: #062f4a;
  --phys: #3d5bd9;
  --phys-soft: #e9edfd;
  --life: #22894a;
  --life-soft: #e4f4ea;
  --danger: #c43a3a;
  --danger-soft: #fdecec;
  --ok: #1d7f49;
  --ok-soft: #e3f4ea;
  --shadow: 0 1px 2px rgba(16, 40, 58, .06), 0 6px 18px rgba(16, 40, 58, .06);
  --radius: 16px;
  --on-accent: #ffffff;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1822;
    --surface: #12232f;
    --surface-2: #172c3a;
    --ink: #e6eef4;
    --muted: #9bb0c0;
    --line: #23394a;
    --brand: #4fb3e6;
    --brand-ink: #062233;
    --brand-2: #3cc8c9;
    --deep: #05141e;
    --phys: #8fa4ff;
    --phys-soft: #1b2650;
    --life: #5cd18b;
    --life-soft: #123524;
    --danger: #ff7b7b;
    --danger-soft: #3a1919;
    --ok: #63d394;
    --ok-soft: #12321f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
    --on-accent: #0b1822;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1822;
  --surface: #12232f;
  --surface-2: #172c3a;
  --ink: #e6eef4;
  --muted: #9bb0c0;
  --line: #23394a;
  --brand: #4fb3e6;
  --brand-ink: #062233;
  --brand-2: #3cc8c9;
  --deep: #05141e;
  --phys: #8fa4ff;
  --phys-soft: #1b2650;
  --life: #5cd18b;
  --life-soft: #123524;
  --danger: #ff7b7b;
  --danger-soft: #3a1919;
  --ok: #63d394;
  --ok-soft: #12321f;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
  --on-accent: #0b1822;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Lexend", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
a { color: var(--brand); }
img, svg { display: block; }
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -.01em; }

.wrap { width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 16px; }

/* ---------- top bar ---------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10;
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 500; white-space: nowrap; }
.brand img { width: 32px; height: 32px; }
.brand b { color: var(--brand); font-weight: 700; }
.topnav { display: flex; gap: 4px; }
.topnav a {
  display: flex; align-items: center; gap: 6px;
  color: var(--muted); text-decoration: none; font-weight: 500; font-size: 15px;
  padding: 8px 12px; border-radius: 10px;
}
.topnav a svg { width: 18px; height: 18px; }
.topnav a:hover { background: var(--surface-2); color: var(--ink); }
.topnav a[aria-current="page"] { color: var(--brand); background: var(--surface-2); }
@media (max-width: 520px) {
  .brand span { font-size: 15px; }
  .topnav a span { display: none; }
  .topnav a { padding: 8px 10px; }
  .topnav a:first-child { display: none; }
}

/* ---------- hero ---------- */
.hero {
  position: relative;
  background: linear-gradient(140deg, var(--deep) 0%, #0a5c8a 55%, #10a0a8 100%);
  color: #fff;
  padding: 44px 0 92px;
  overflow: hidden;
}
.hero .wrap { position: relative; }
.hero h1 { font-size: clamp(30px, 6vw, 52px); font-weight: 700; }
.hero .eyebrow { color: #9fe6ea; }
.hero .teacher {
  display: inline-block; margin: 16px 0 0; padding: 6px 14px;
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.25);
  border-radius: 999px; font-size: 17px; font-weight: 500;
}
.waves { position: absolute; left: 0; right: 0; bottom: -1px; width: 100%; height: 56px; }
.waves path { fill: var(--bg); }

.eyebrow {
  margin: 0 0 8px; font-size: 13px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  color: var(--brand-2);
}

/* ---------- page head & crumbs ---------- */
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 20px 0 0; font-size: 14px; color: var(--muted); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--brand); text-decoration: underline; }
.crumbs .sep { opacity: .5; }
.crumbs [aria-current] { color: var(--ink); font-weight: 500; }

.page-head { padding: 20px 0 8px; }
.page-head h1 { font-size: clamp(28px, 5vw, 40px); font-weight: 700; }
.page-head .lead { margin: 8px 0 0; color: var(--muted); font-size: 17px; }
.page-head-subject { display: flex; align-items: center; gap: 16px; }

.section { margin: 32px 0 8px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-head h2 { font-size: 21px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.section-head h2 svg { width: 20px; height: 20px; color: var(--brand-2); }
.link-more { font-weight: 500; font-size: 15px; text-decoration: none; white-space: nowrap; }
.link-more:hover { text-decoration: underline; }

/* ---------- grade cards ---------- */
.grade-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.grade-card {
  position: relative; display: flex; align-items: center; gap: 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 40px 18px 18px; color: var(--ink); text-decoration: none; box-shadow: var(--shadow);
  transition: transform .15s ease, border-color .15s ease; gap: 14px;
}
.grade-card:hover { transform: translateY(-2px); border-color: var(--brand); }
.grade-num {
  flex: none; width: 68px; height: 72px; border-radius: 14px;
  background: linear-gradient(150deg, #0a5c8a, #10a0a8); color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.grade-num small { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; opacity: .85; }
.grade-num strong { font-size: 34px; line-height: 1; font-weight: 700; }
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.chip { display: flex; align-items: center; gap: 8px; font-size: 15px; white-space: nowrap; font-weight: 500; }
.chip svg { width: 20px; height: 20px; flex: none; }
.chip em { font-style: normal; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; }
.chip-physical-science svg { color: var(--phys); }
.chip-physical-science em { background: var(--phys-soft); color: var(--phys); }
.chip-life-science svg { color: var(--life); }
.chip-life-science em { background: var(--life-soft); color: var(--life); }
.chev { position: absolute; right: 14px; top: 50%; width: 22px; height: 22px; margin-top: -11px; color: var(--muted); }

/* ---------- subject cards ---------- */
.subject-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin-top: 16px; }
.subject-card {
  position: relative; display: flex; align-items: center; gap: 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 48px 22px 20px; color: var(--ink); text-decoration: none; box-shadow: var(--shadow);
  border-top: 5px solid var(--accent); transition: transform .15s ease;
}
.subject-card:hover { transform: translateY(-2px); }
.subject-physical-science { --accent: var(--phys); --accent-soft: var(--phys-soft); }
.subject-life-science { --accent: var(--life); --accent-soft: var(--life-soft); }
.subject-icon {
  flex: none; width: 64px; height: 64px; border-radius: 16px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.subject-icon svg { width: 38px; height: 38px; }
.subject-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.subject-text strong { font-size: 21px; font-weight: 600; }
.subject-text span { color: var(--muted); font-size: 15px; }
.subject-text small { color: var(--accent); font-weight: 500; font-size: 14px; }

/* ---------- unit + lessons ---------- */
.unit {
  margin-top: 20px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.unit-head { padding: 20px 20px 16px; background: var(--accent-soft); border-bottom: 1px solid var(--line); }
.unit-label { margin: 0 0 2px; font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.unit-head h2 { font-size: 22px; font-weight: 600; }
.unit-meta { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.lessons { list-style: none; margin: 0; padding: 8px; }
.lesson {
  position: relative; display: flex; align-items: center; gap: 14px;
  padding: 14px 44px 14px 12px; border-radius: 12px; color: var(--ink); text-decoration: none;
}
.lesson:hover { background: var(--surface-2); }
.lessons li + li .lesson { border-top: 1px solid var(--line); border-radius: 0 0 12px 12px; }
.lessons li + li .lesson:hover { border-radius: 12px; }
.lesson-num {
  flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 17px;
}
.lesson-text { display: flex; flex-direction: column; min-width: 0; }
.lesson-text small { color: var(--muted); font-size: 13px; font-weight: 500; }
.lesson-text strong { font-size: 17px; font-weight: 600; }
.back { margin: 24px 0 0; }
.back a { text-decoration: none; font-weight: 500; }

/* ---------- posts ---------- */
.posts { display: grid; gap: 14px; }
.post {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow); border-left: 5px solid var(--brand-2);
  min-width: 0;
}
.post-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.tag { font-weight: 600; font-size: 12px; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); color: var(--brand); }
.tag-new { background: var(--ok-soft); color: var(--ok); }
.post h3 { font-size: 19px; font-weight: 600; margin: 8px 0 0; overflow-wrap: anywhere; }
.post-body { margin: 8px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.post-body a { overflow-wrap: anywhere; }
.post-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.posts-empty, .posts-msg {
  background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 22px; text-align: center; color: var(--muted);
}
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 18px; }
.filter {
  font: inherit; font-size: 15px; font-weight: 500; cursor: pointer;
  padding: 8px 16px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink);
}
.filter:hover { border-color: var(--brand); }
.filter[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }

/* ---------- buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; font-size: 16px; line-height: 1.2;
  padding: 11px 18px; border-radius: 12px; border: 1px solid transparent; cursor: pointer;
  background: var(--brand); color: var(--brand-ink); text-decoration: none;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .6; cursor: default; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); filter: none; }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger.confirm { background: var(--danger); color: #fff; }
.btn-sm { padding: 7px 12px; font-size: 14px; border-radius: 10px; }
.btn svg { width: 18px; height: 18px; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 20px; box-shadow: var(--shadow);
}
.card h2 { font-size: 20px; font-weight: 600; margin-bottom: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-weight: 600; font-size: 15px; }
.field .hint { color: var(--muted); font-size: 13px; font-weight: 400; }
.field input, .field textarea, .field select {
  font: inherit; font-size: 16px; color: var(--ink);
  width: 100%; padding: 11px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg);
}
.field textarea { min-height: 140px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: transparent; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 640px) { .row-2 { grid-template-columns: 1fr; } }
.counter { align-self: flex-end; font-size: 12px; color: var(--muted); }

.notice { border-radius: 12px; padding: 12px 14px; margin: 0 0 16px; font-size: 15px; }
.notice-error { background: var(--danger-soft); color: var(--danger); }
.notice-ok { background: var(--ok-soft); color: var(--ok); }
[hidden] { display: none !important; }

.admin-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; margin-top: 16px; }
@media (max-width: 860px) { .admin-grid { grid-template-columns: minmax(0, 1fr); } }
.login-card { max-width: 420px; margin: 24px auto 0; }
.admin-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }

/* ---------- footer ---------- */
.footer { margin-top: 56px; border-top: 1px solid var(--line); background: var(--surface); }
.footer p { margin: 0; padding: 20px 0 8px; color: var(--muted); font-size: 14px; }
.footer b { color: var(--ink); font-weight: 600; }

:focus-visible { outline: 3px solid var(--brand-2); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- lesson page (site frame around a lesson deck) ---------- */
html.lesson-html, .lesson-body { height: 100%; }
.lesson-body { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.lesson-bar {
  flex: none; display: flex; align-items: center; gap: 12px;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 16px 8px;
  background: var(--surface); border-bottom: 3px solid var(--accent, var(--brand));
  box-shadow: 0 1px 6px rgba(16, 40, 58, .08); z-index: 2;
}
.lesson-home img { width: 34px; height: 34px; }
.back-btn {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px 9px 10px; border-radius: 999px;
  background: var(--brand); color: var(--brand-ink); text-decoration: none;
  font-weight: 600; font-size: 15px; line-height: 1;
}
.back-btn svg { width: 18px; height: 18px; }
.back-btn:hover { filter: brightness(1.1); }
.back-short { display: none; }
.lesson-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.lesson-title small { font-size: 12px; color: var(--accent, var(--muted)); font-weight: 600; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lesson-title strong { font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lesson-pager { flex: none; display: flex; gap: 6px; }
.pager-btn {
  height: 40px; padding: 0 12px; border-radius: 12px; display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid var(--line); color: var(--ink); background: var(--surface);
  text-decoration: none; font-size: 14px; font-weight: 500; white-space: nowrap;
}
.pager-btn svg { width: 18px; height: 18px; flex: none; }
.pager-btn:hover { background: var(--surface-2); }
.lesson-frame { flex: 1; width: 100%; min-height: 0; border: 0; display: block; background: var(--bg); }
@media (max-width: 640px) {
  .lesson-bar { gap: 8px; padding-left: 10px; padding-right: 10px; }
  .lesson-home { display: none; }
  .back-long { display: none; }
  .back-short { display: inline; }
  .back-btn { padding: 9px 12px 9px 8px; font-size: 14px; }
  .lesson-title strong { font-size: 15px; }
  .lesson-title small { font-size: 11px; }
  .pager-btn { width: 36px; height: 36px; padding: 0; justify-content: center; }
  .pager-btn span { display: none; }
}
@media (max-height: 460px) and (orientation: landscape) {
  .lesson-bar { padding-top: 4px; padding-bottom: 4px; }
  .lesson-title small { display: none; }
  .back-btn { padding-top: 7px; padding-bottom: 7px; }
  .pager-btn { height: 32px; }
}
.footer p.copyright { padding-top: 0; font-size: 13px; max-width: 70ch; }

/* ---------- home hero: animated science graphics ---------- */
.hero-inner { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: center; gap: 24px; }

.hero-art { position: relative; height: 300px; }
.hero-art svg { position: absolute; display: block; }
.hero-art .dna { position: absolute; display: flex; }

/* atom */
.atom { width: 220px; height: 220px; left: 44%; top: 56%; transform: translate(-50%, -50%); }
.atom .orbit { fill: none; stroke: rgba(255, 255, 255, .55); stroke-width: 2; }
.atom .electron { fill: #ffd166; filter: drop-shadow(0 0 6px rgba(255, 209, 102, .9)); }
.atom .proton { fill: #ff8a5c; }
.atom .neutron { fill: #9fe6ea; }
.atom-spin { transform-origin: 110px 110px; animation: spin 40s linear infinite; }
.nucleus { transform-origin: 110px 110px; animation: pulse 2.6s ease-in-out infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }

/* DNA helix */
.dna { right: 6%; bottom: -6px; width: 46px; height: 120px; display: flex; flex-direction: column; justify-content: space-between; transform: rotate(18deg); }
.dna span {
  position: relative; height: 3px; margin: 0 auto; width: 46px; border-radius: 3px;
  background: linear-gradient(90deg, #ff8a5c, #9fe6ea);
  animation: helix 2.4s ease-in-out infinite; animation-delay: calc(var(--i) * -0.2s);
}
.dna span::before, .dna span::after {
  content: ""; position: absolute; top: 50%; width: 10px; height: 10px; margin-top: -5px; border-radius: 50%;
}
.dna span::before { left: -5px; background: #ff8a5c; }
.dna span::after { right: -5px; background: #9fe6ea; }
@keyframes helix { 0%, 100% { transform: scaleX(1); opacity: 1; } 50% { transform: scaleX(-1); opacity: .55; } }

/* flask */
.flask { left: 2%; bottom: 0; width: 92px; height: 115px; animation: bob 5s ease-in-out infinite; }
.flask-glass { fill: rgba(255, 255, 255, .08); stroke: rgba(255, 255, 255, .8); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.flask-liquid { fill: #3fd6a0; opacity: .85; }
.flask .fb { fill: rgba(255, 255, 255, .85); transform-box: fill-box; animation: flask-bubble 3s ease-in infinite; animation-delay: var(--d); }
@keyframes flask-bubble { 0% { transform: translateY(0); opacity: 0; } 15% { opacity: 1; } 100% { transform: translateY(-95px); opacity: 0; } }

/* water molecule */
.molecule { left: 10%; top: 6px; width: 74px; height: 60px; animation: drift 7s ease-in-out infinite; }
.molecule line { stroke: rgba(255, 255, 255, .7); stroke-width: 4; }
.molecule .m-o { fill: #ff6b6b; }
.molecule .m-h { fill: #f1f5f9; }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-10px) rotate(4deg); } }
@keyframes drift { 0%, 100% { transform: translate(0, 0) rotate(0); } 50% { transform: translate(10px, 12px) rotate(25deg); } }

/* rising bubbles in the background */
.bubbles { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.bubbles span {
  position: absolute; bottom: -24px; left: var(--x); width: var(--s); height: var(--s); border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, .35); background: rgba(255, 255, 255, .06);
  animation: rise var(--t) linear infinite; animation-delay: calc(var(--d) * -1s);
}
@keyframes rise {
  0% { transform: translate(0, 0); opacity: 0; }
  10% { opacity: 1; }
  50% { transform: translate(12px, -180px); }
  100% { transform: translate(-6px, -380px); opacity: 0; }
}

@media (max-width: 760px) {
  .hero { padding-top: 32px; }
  .hero-inner { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .hero-art { height: 230px; max-width: 360px; width: 100%; margin: 0 auto; }
  .atom { width: 140px; height: 140px; left: 40%; top: 62%; }
  .orrery { width: 130px; height: 130px; right: 0; top: -4px; }
  .dna { height: 84px; width: 32px; right: 4%; bottom: 0; }
  .dna span { width: 32px; }
  .flask { width: 66px; height: 84px; left: 6%; }
  .molecule { width: 56px; height: 46px; left: 14%; top: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .atom-spin, .nucleus, .dna span, .flask, .flask .fb, .molecule, .bubbles span, .stars b, .orrery .sun-halo { animation: none !important; }
  .comet { display: none; }
  .stars b { opacity: .6; }
  .bubbles span { opacity: .5; bottom: auto; top: calc(20% + var(--d) * 8%); }
}

/* solar system */
.orrery { right: -4%; top: -26px; width: 220px; height: 220px; }
.orrery .orbit-ring { fill: none; stroke: rgba(255, 255, 255, .22); stroke-width: 1; stroke-dasharray: 2 4; }
.orrery .sun-halo { fill: rgba(255, 194, 75, .22); transform-origin: 110px 110px; animation: sun-glow 3s ease-in-out infinite; }
.orrery .saturn-ring { fill: none; stroke: #f4d58d; stroke-width: 2; opacity: .85; }
@keyframes sun-glow { 0%, 100% { transform: scale(1); opacity: .9; } 50% { transform: scale(1.25); opacity: .45; } }

/* stars and a comet */
.stars { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.stars b {
  position: absolute; left: var(--x); top: var(--y); width: var(--z); height: var(--z); border-radius: 50%;
  background: #fff; box-shadow: 0 0 6px rgba(255, 255, 255, .8);
  animation: twinkle 3.2s ease-in-out infinite; animation-delay: calc(var(--d) * -1s);
}
@keyframes twinkle { 0%, 100% { opacity: .15; transform: scale(.8); } 50% { opacity: .95; transform: scale(1.2); } }
.comet {
  position: absolute; top: 8%; left: -12%; width: 110px; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), #fff);
  transform: rotate(18deg); opacity: 0; animation: comet 9s ease-in 2s infinite;
}
.comet::after { content: ""; position: absolute; right: -2px; top: -2px; width: 6px; height: 6px; border-radius: 50%; background: #fff; box-shadow: 0 0 10px #fff; }
@keyframes comet {
  0% { transform: translate(0, 0) rotate(18deg); opacity: 0; }
  3% { opacity: 1; }
  14% { transform: translate(70vw, 23vw) rotate(18deg); opacity: 0; }
  100% { transform: translate(70vw, 23vw) rotate(18deg); opacity: 0; }
}
.footer p.version { padding-top: 4px; font-size: 11px; opacity: .7; letter-spacing: .04em; }

/* ---------- home: chemistry lab game card ---------- */
.lab-card {
  position: relative; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); align-items: center; gap: 12px;
  padding: 28px 28px 28px 32px; border-radius: 22px; overflow: hidden; text-decoration: none; color: #fff;
  background: radial-gradient(circle at 85% 20%, rgba(255, 209, 102, .25), transparent 40%),
              linear-gradient(130deg, #2b1b5e 0%, #4b2a8a 45%, #0e8f8f 100%);
  box-shadow: 0 10px 30px rgba(43, 27, 94, .35);
  transition: transform .2s ease, box-shadow .2s ease;
}
.lab-card::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .18;
  background-image: radial-gradient(circle, #fff 1px, transparent 1.5px); background-size: 22px 22px;
}
.lab-card:hover { transform: translateY(-3px); box-shadow: 0 16px 38px rgba(43, 27, 94, .45); }
.lab-card:hover .lab-play { transform: scale(1.05); }
.lab-text { position: relative; min-width: 0; }
.lab-badge { margin: 0 0 10px; display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: #ffe08a; }
.lab-badge span { background: #ffd166; color: #2b1b5e; padding: 2px 9px; border-radius: 999px; letter-spacing: .04em; animation: badge-pop 2.4s ease-in-out infinite; }
@keyframes badge-pop { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1); } }
.lab-card h2 { font-size: clamp(26px, 4vw, 36px); font-weight: 700; color: #fff; }
.lab-desc { margin: 10px 0 0; font-size: 16px; color: rgba(255, 255, 255, .88); max-width: 46ch; }
.lab-chips { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.lab-chips li { font-size: 13px; font-weight: 500; padding: 4px 12px; border-radius: 999px; background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .28); }
.lab-play {
  margin-top: 20px; display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 22px; border-radius: 14px; font-weight: 700; font-size: 17px;
  background: #ffd166; color: #2b1b5e; box-shadow: 0 6px 0 #c99a2e; transition: transform .15s ease;
}
.lab-play svg { width: 20px; height: 20px; }
.lab-scene { position: relative; min-width: 0; }
.lab-scene svg { width: 100%; max-width: 320px; height: auto; display: block; margin-left: auto; overflow: visible; }
.lab-glass { fill: rgba(255, 255, 255, .1); stroke: rgba(255, 255, 255, .9); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.lab-marks { stroke: rgba(255, 255, 255, .6); stroke-width: 2; stroke-linecap: round; }
.lab-liquid, .lab-wave { animation: liquid-color 6s linear infinite; }
.lab-wave { animation: liquid-color 6s linear infinite, wave 2s linear infinite; }
@keyframes liquid-color { 0%, 100% { fill: #3fd6a0; } 33% { fill: #5aa9ff; } 66% { fill: #ff6fae; } }
@keyframes wave { from { transform: translateX(0); } to { transform: translateX(-50px); } }
.lab-pour { animation: pour-bob 6s ease-in-out infinite; }
.lab-pour-liquid { fill: #ff6fae; }
.lab-stream { fill: none; stroke: #ff6fae; stroke-width: 4; stroke-linecap: round; stroke-dasharray: 70; animation: stream 3s ease-in-out infinite; }
@keyframes pour-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes stream { 0% { stroke-dashoffset: 70; opacity: .9; } 45%, 70% { stroke-dashoffset: 0; opacity: 1; } 100% { stroke-dashoffset: -70; opacity: .9; } }
.lab-b { fill: rgba(255, 255, 255, .85); transform-box: fill-box; animation: lab-bubble 2.6s ease-in infinite; animation-delay: var(--d); }
@keyframes lab-bubble { 0% { transform: translateY(0); opacity: 0; } 15% { opacity: 1; } 85% { opacity: .9; } 100% { transform: translateY(-38px); opacity: 0; } }
.lab-flask2 { animation: lab-float 4.5s ease-in-out infinite; }
@keyframes lab-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
.lab-liquid2 { fill: #ffd166; }
.lab-tube { animation: lab-float 5.5s ease-in-out infinite reverse; }
.lab-liquid3 { fill: #5aa9ff; }
.lab-star { fill: #ffd166; transform-box: fill-box; transform-origin: center; animation: star-spin 5s ease-in-out infinite; }
@keyframes star-spin { 0%, 100% { transform: rotate(0) scale(1); } 50% { transform: rotate(20deg) scale(1.2); } }
.lab-spark { fill: #fff; animation: twinkle 2.2s ease-in-out infinite; animation-delay: var(--d); }
@media (max-width: 720px) {
  .lab-card { grid-template-columns: minmax(0, 1fr); padding: 22px 20px; }
  .lab-scene { order: -1; }
  .lab-scene svg { max-width: 220px; margin: -6px auto 0; }
  .lab-play { width: 100%; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) {
  .lab-badge span, .lab-liquid, .lab-wave, .lab-pour, .lab-stream, .lab-b, .lab-flask2, .lab-tube, .lab-star, .lab-spark { animation: none !important; }
  .lab-liquid, .lab-wave { fill: #3fd6a0; }
  .lab-stream { stroke-dasharray: none; }
}

/* ---------- footer: studio credit ---------- */
.footer p.credit { padding-top: 6px; font-size: 12px; opacity: .85; }
.footer p.credit a { color: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.footer p.credit a:hover { color: var(--brand); }

/* ---------- home: explore and play (body + lab cards) ---------- */
.play-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); gap: 18px; }
.play-item { container-type: inline-size; min-width: 0; display: flex; }
.play-item > .play-card { flex: 1; }
@container (max-width: 560px) {
  .play-card { grid-template-columns: minmax(0, 1fr); padding: 22px 20px; }
  .play-card .lab-scene { order: -1; }
  .play-card .lab-scene svg { max-width: 220px; margin: -6px auto 0; }
  .play-card .lab-play { width: 100%; justify-content: center; }
}
.body-card {
  background: radial-gradient(circle at 82% 18%, rgba(127, 240, 255, .22), transparent 42%),
              linear-gradient(130deg, #3b0d2c 0%, #8c1d43 48%, #d9573a 100%);
  box-shadow: 0 10px 30px rgba(92, 16, 44, .35);
}
.body-card:hover { box-shadow: 0 16px 38px rgba(92, 16, 44, .45); }
.body-card .lab-play { background: #7ff0ff; color: #3b0d2c; box-shadow: 0 6px 0 #3aa9b8; }
.body-card .lab-badge { color: #b9f7ff; }
.body-card .lab-badge span { background: #7ff0ff; color: #3b0d2c; }
.body-fill { fill: rgba(255, 255, 255, .13); }
.body-edge { fill: none; stroke: rgba(255, 255, 255, .75); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.org-brain { fill: #ffb3c6; }
.org-lungs path { fill: #9fd8ff; }
.org-lungs { transform-box: fill-box; transform-origin: 50% 0; animation: breathe 4s ease-in-out infinite; }
.org-heart { fill: #ff3b5c; transform-box: fill-box; transform-origin: center; animation: heartbeat 1.2s ease-in-out infinite; }
.org-stomach { fill: #ffc65c; }
.org-gut { fill: none; stroke: #ffa86b; stroke-width: 4; stroke-linecap: round; }
.body-scan { animation: body-scan 4.5s linear infinite; }
.body-pin { fill: #fff; stroke: #3b0d2c; stroke-width: 1.5; }
.body-ring { fill: none; stroke: #7ff0ff; stroke-width: 2; transform-box: fill-box; transform-origin: center; animation: pin-ring 2.4s ease-out infinite; }
.body-ring.r2 { animation-delay: .8s; }
.body-ring.r3 { animation-delay: 1.6s; }
.body-turn { fill: none; stroke: rgba(255, 255, 255, .45); stroke-width: 2; stroke-dasharray: 6 8; animation: body-turn 6s linear infinite; }
.body-turn-arrow { fill: none; stroke: rgba(255, 255, 255, .75); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.body-ecg { fill: none; stroke: #7ff0ff; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 130; animation: ecg 2.4s linear infinite; }
.body-figure { animation: lab-float 6s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1.06, 1.08); } }
@keyframes heartbeat { 0%, 40%, 100% { transform: scale(1); } 15% { transform: scale(1.22); } 28% { transform: scale(1.08); } }
@keyframes body-scan { 0% { transform: translateY(-26px); } 100% { transform: translateY(230px); } }
@keyframes pin-ring { 0% { transform: scale(1); opacity: .9; } 100% { transform: scale(3.2); opacity: 0; } }
@keyframes body-turn { to { stroke-dashoffset: -56; } }
@keyframes ecg { 0% { stroke-dashoffset: 130; } 60% { stroke-dashoffset: 0; } 100% { stroke-dashoffset: -130; } }
@media (prefers-reduced-motion: reduce) {
  .org-lungs, .org-heart, .body-scan, .body-ring, .body-turn, .body-ecg, .body-figure { animation: none !important; }
  .body-scan, .body-ring { display: none; }
  .body-ecg { stroke-dasharray: none; }
}

/* ---------- human body lessons inside the site frame ---------- */
.body-lesson { --accent: #b3264f; }

/* ---------- home v2.1: hero + bento tiles ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.hero-bento {
  background: radial-gradient(circle at 82% 0%, rgba(109, 75, 255, .45), transparent 45%),
              radial-gradient(circle at 0% 100%, rgba(16, 160, 168, .5), transparent 50%), #061a2c;
  padding: 46px 0 124px;
}
.hero-bento .bubbles { opacity: .5; }
.hero-bento .hero-art { height: 250px; }
.hero-bento h1 { font-size: clamp(34px, 6vw, 60px); letter-spacing: -.02em; line-height: 1.05; }
.typed { margin: 12px 0 0; font-size: clamp(18px, 2.2vw, 23px); color: rgba(255, 255, 255, .9); font-weight: 500; min-height: 1.5em; }
.typed b { color: #7ff0ff; font-weight: 600; }
.typed .caret { display: inline-block; width: 2px; height: 1.05em; background: #7ff0ff; margin-left: 3px; vertical-align: -2px; animation: caret-blink 1s steps(1) infinite; }
@keyframes caret-blink { 50% { opacity: 0; } }
.bento-wrap { position: relative; z-index: 2; margin-top: -88px; }
.bento {
  display: grid; gap: 14px; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: 172px;
  grid-template-areas: "g5 g6 g7 body" "lab lab lab body";
}
.tile {
  position: relative; overflow: hidden; border-radius: 22px; padding: 18px 20px; color: #fff; text-decoration: none;
  display: flex; flex-direction: column; min-width: 0;
  box-shadow: 0 12px 30px rgba(6, 26, 44, .18); transition: transform .2s ease, box-shadow .2s ease;
}
a.tile:hover { transform: translateY(-4px); box-shadow: 0 20px 40px rgba(6, 26, 44, .26); }
a.tile:focus-visible { outline: 3px solid #ffd166; outline-offset: 3px; }
.tile::after { content: ""; position: absolute; inset: 0; pointer-events: none; background-image: radial-gradient(circle, rgba(255, 255, 255, .22) 1px, transparent 1.5px); background-size: 20px 20px; opacity: .35; }
.tile-g small { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; opacity: .9; font-weight: 600; position: relative; z-index: 1; }
.tile-g .big { font-size: 84px; font-weight: 700; line-height: .9; letter-spacing: -.04em; position: relative; z-index: 1; }
.tile-g .ghost { position: absolute; right: -12px; bottom: -34px; font-size: 170px; font-weight: 800; line-height: 1; color: rgba(255, 255, 255, .13); letter-spacing: -.06em; }
.tile-g .go { position: absolute; top: 16px; right: 16px; width: 34px; height: 34px; border-radius: 50%; background: rgba(255, 255, 255, .22); display: grid; place-items: center; transition: transform .2s; z-index: 1; }
.tile-g .go svg { width: 18px; height: 18px; }
a.tile:hover .go { transform: rotate(-45deg); }
.tile-g .sub { margin-top: auto; display: flex; gap: 6px; flex-wrap: wrap; font-size: 12.5px; font-weight: 600; position: relative; z-index: 1; }
.tile-g .sub span { background: rgba(255, 255, 255, .22); border-radius: 999px; padding: 3px 10px; }
.tile-g .sub-short { display: none; }
.g5 { grid-area: g5; background: linear-gradient(140deg, #f2613f, #ffad3b); }
.g6 { grid-area: g6; background: linear-gradient(140deg, #0b8282, #2fc493); }
.g7 { grid-area: g7; background: linear-gradient(140deg, #5233e8, #b25cf5); }
.tile-body { grid-area: body; background: linear-gradient(170deg, #3b0d2c, #8c1d43 55%, #d9573a); }
.tile-lab { grid-area: lab; background: linear-gradient(130deg, #2b1b5e, #4b2a8a 50%, #0e8f8f); flex-direction: row; align-items: center; gap: 12px; }
.tile-news { grid-area: news; background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.tile-news::after { display: none; }
.tile h3 { font-size: 22px; font-weight: 700; line-height: 1.15; margin: 0; color: inherit; }
.tile .ttag { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; margin: 0 0 6px; color: #b9f7ff; }
.tile .ttag svg { width: 15px; height: 15px; }
.tile-lab .ttag { color: #ffe08a; }
.tile-news .ttag { color: var(--brand); }
.tile-text { position: relative; z-index: 1; display: flex; flex-direction: column; min-width: 0; }
.tile-desc { margin: 6px 0 0; font-size: 14px; color: rgba(255, 255, 255, .86); }
.tile .cta { margin-top: 12px; align-self: flex-start; font-weight: 700; font-size: 14px; padding: 8px 16px; border-radius: 12px; background: #7ff0ff; color: #3b0d2c; box-shadow: 0 4px 0 #3aa9b8; }
.tile-lab .cta { background: #ffd166; color: #2b1b5e; box-shadow: 0 4px 0 #c99a2e; }
.tile-art { position: relative; z-index: 1; min-width: 0; }
.tile-art svg { display: block; width: 100%; height: 100%; overflow: visible; }
.tile-body .tile-art { flex: 1; min-height: 0; margin: 6px 0 2px; }
.tile-body .tile-text { flex: none; }
.tile-body .cta { order: 9; }
.tile-lab .tile-text { flex: 1; height: 100%; justify-content: center; }
.tile-lab .tile-art { flex: none; width: 44%; max-width: 250px; height: 100%; }
.tile-news .posts-tile { min-height: 0; overflow: hidden; }
.posts-tile .post { border: 0; padding: 0; margin: 0; box-shadow: none; background: none; }
.posts-tile .post-meta { margin-bottom: 4px; }
.posts-tile h3 { font-size: 16px; font-weight: 600; line-height: 1.3; }
.posts-tile .post-body { font-size: 13.5px; color: var(--muted); margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.posts-tile .post-meta { flex-wrap: nowrap; overflow: hidden; white-space: nowrap; }
.posts-tile .post-meta > * { flex: none; white-space: nowrap; }
.posts-tile .post-meta time { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.posts-tile h3 { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.posts-tile .post-actions, .posts-tile .posts-msg { display: none; }
.posts-tile .posts-empty { padding: 4px 0; border: 0; font-size: 14px; text-align: left; }
.tile-news .more { margin-top: auto; padding-top: 6px; font-size: 13.5px; font-weight: 600; color: var(--brand); text-decoration: none; }
.tile-news .more:hover { text-decoration: underline; }
@media (max-width: 1000px) {
  .bento { grid-template-columns: repeat(6, minmax(0, 1fr)); grid-auto-rows: auto;
    grid-template-areas: "g5 g5 g6 g6 g7 g7" "body body body lab lab lab"; }
  .tile-news { display: none; }
  .tile-g { min-height: 160px; }
  .tile-body, .tile-lab { min-height: 300px; }
  .tile-lab { flex-direction: column; align-items: stretch; }
  .tile-lab .tile-art { width: 100%; max-width: none; height: 150px; order: -1; }
  .tile-body .tile-art { height: 150px; flex: none; order: -1; margin: 0 0 6px; }
}
@media (max-width: 640px) {
  .hero-bento { padding: 30px 0 110px; }
  .bento-wrap { margin-top: -84px; }
  .bento { gap: 10px; grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-areas: "g5 g6 g7" "body body body" "lab lab lab"; }
  .hero-bento .hero-art { height: 190px; max-width: 300px; }
  .tile { border-radius: 18px; padding: 14px; }
  .tile-g { min-height: 128px; }
  .tile-g .big { font-size: 54px; }
  .tile-g small { font-size: 10.5px; letter-spacing: .08em; }
  .tile-g .ghost { font-size: 110px; bottom: -22px; }
  .tile-g .go { top: 10px; right: 10px; width: 26px; height: 26px; }
  .tile-g .go svg { width: 14px; height: 14px; }
  .tile-g .sub-long { display: none; }
  .tile-g .sub-short { display: flex; font-size: 11px; }
  .tile-g .sub span { padding: 2px 8px; }
  .tile-body, .tile-lab { min-height: 0; flex-direction: row; align-items: center; gap: 8px; padding: 16px; }
  .tile-body .tile-art, .tile-lab .tile-art { order: 2; width: 40%; height: 150px; margin: 0; flex: none; }
  .tile-body .tile-text, .tile-lab .tile-text { flex: 1; height: auto; }
  .tile h3 { font-size: 19px; }
  .tile-desc { font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  .typed .caret { animation: none; }
  a.tile, a.tile:hover, .tile-g .go { transition: none; transform: none; }
}

/* ---------- v2.2: review fixes ---------- */
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 50; background: var(--brand); color: #fff; padding: 10px 16px; border-radius: 10px; font-weight: 600; text-decoration: none; }
.skip-link:focus { top: 10px; }
.nowrap { white-space: nowrap; }
/* grade tiles: small labels on solid white pills so they are easy to read */
.tile-g .sub span { background: rgba(255, 255, 255, .94); color: var(--tile-ink); }
.g5 { --tile-ink: #8a2d0c; }
.g6 { --tile-ink: #064f4c; }
.g7 { --tile-ink: #3a1d9e; }
.tile-g small { text-shadow: 0 1px 2px rgba(0, 0, 0, .18); }
/* long lesson titles use two lines instead of being cut on phones and tablets */
@media (max-width: 860px) {
  .lesson-title strong { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.2; }
}
