/* Lemonmath: playful, one colour per school level. No external requests. */

:root {
  --bg: #FFFBEA; --surface: #FFFFFF; --surface2: #FFF6CC;
  --ink: #2B2A33; --muted: #5F5E6B; --line: #EFE6B8; --edge: #2B2A33;
  --lemon: #FFD43B; --lemon-ink: #2B2A33; --link: #B45309;
  --lvl: #4F46E5; --lvl-soft: #E0E7FF; --lvl-ink: #3730A3;
  --shadow: rgba(43, 42, 51, .9);
  --c-curve: #2563EB; --c-pt: #E11D48; --c-region: rgba(99, 102, 241, .22); --c-poly: rgba(255, 212, 59, .38);
  --r: 18px;
  --font: "Nunito Variable", "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --head: "Baloo 2", "Nunito Variable", system-ui, "Segoe UI", Arial, sans-serif;
  --topbar: 64px;
}
:root[data-theme="dark"] {
  --bg: #17161C; --surface: #221F2B; --surface2: #2B2735;
  --ink: #F4F1E8; --muted: #B3B0BF; --line: #3A3647; --edge: #0B0A0E;
  --link: #FDBA74; --shadow: rgba(0, 0, 0, .7);
  --c-curve: #7DB1FF; --c-pt: #FF6B8E; --c-region: rgba(129, 140, 248, .3); --c-poly: rgba(255, 212, 59, .22);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17161C; --surface: #221F2B; --surface2: #2B2735;
    --ink: #F4F1E8; --muted: #B3B0BF; --line: #3A3647; --edge: #0B0A0E;
    --link: #FDBA74; --shadow: rgba(0, 0, 0, .7);
    --c-curve: #7DB1FF; --c-pt: #FF6B8E; --c-region: rgba(129, 140, 248, .3); --c-poly: rgba(255, 212, 59, .22);
  }
}

/* one colour per level */
.lvl-primary { --lvl: #C2410C; --lvl-soft: #FFEDD5; --lvl-ink: #9A3412; }
.lvl-middle  { --lvl: #15803D; --lvl-soft: #DCFCE7; --lvl-ink: #166534; }
.lvl-high    { --lvl: #4F46E5; --lvl-soft: #E0E7FF; --lvl-ink: #3730A3; }
:root[data-theme="dark"] .lvl-primary, :root[data-theme="dark"].lvl-primary { --lvl: #FB923C; --lvl-soft: #3A2415; --lvl-ink: #FDBA74; }
:root[data-theme="dark"] .lvl-middle  { --lvl: #4ADE80; --lvl-soft: #12301F; --lvl-ink: #86EFAC; }
:root[data-theme="dark"] .lvl-high    { --lvl: #818CF8; --lvl-soft: #23244A; --lvl-ink: #A5B4FC; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .lvl-primary { --lvl: #FB923C; --lvl-soft: #3A2415; --lvl-ink: #FDBA74; }
  :root:not([data-theme="light"]) .lvl-middle  { --lvl: #4ADE80; --lvl-soft: #12301F; --lvl-ink: #86EFAC; }
  :root:not([data-theme="light"]) .lvl-high    { --lvl: #818CF8; --lvl-soft: #23244A; --lvl-ink: #A5B4FC; }
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--topbar) + 16px); -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; animation: none !important; } }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 18px/1.7 var(--font); }
h1, h2, h3, h4 { font-family: var(--head); font-weight: 800; line-height: 1.2; margin: 1.4em 0 .5em; letter-spacing: .005em; }
h1 { font-size: clamp(2rem, 5vw, 2.8rem); margin-top: .3em; }
h2 { font-size: 1.7rem; } h3 { font-size: 1.3rem; }
p { margin: 0 0 1em; }
a { color: var(--link); text-underline-offset: 3px; }
img { max-width: 100%; height: auto; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--lemon); color: var(--lemon-ink); padding: 8px 14px; border-radius: 10px; z-index: 100; font-weight: 800; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--lvl); outline-offset: 2px; border-radius: 6px; }
.ico { flex: none; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px; min-height: var(--topbar); padding: 8px 16px; background: var(--lemon); color: var(--lemon-ink); border-bottom: 3px solid var(--edge); }
.brand { display: flex; align-items: center; gap: 8px; font: 700 1.5rem/1 var(--head); color: inherit; text-decoration: none; }
.brand b { font-weight: 800; color: #166534; }
.brand-mark { width: 40px; height: 40px; }
.topnav { display: flex; gap: 4px; margin-left: 10px; }
.topnav a { color: inherit; text-decoration: none; font-weight: 800; padding: 6px 12px; border-radius: 999px; }
.topnav a:hover { background: rgba(255, 255, 255, .55); }
.spacer { flex: 1; }
.icon-btn, .lang-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 40px; height: 40px; padding: 0 12px; border: 2px solid var(--edge); border-radius: 999px; background: #fff; color: #2B2A33; font: 800 .95rem var(--font); cursor: pointer; text-decoration: none; box-shadow: 0 3px 0 var(--edge); }
.icon-btn:hover, .lang-btn:hover { transform: translateY(-1px); }
.icon-btn:active, .lang-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--edge); }
.icon-btn[hidden] { display: none; }
#menu-btn { display: none; }
.js #menu-btn:not([hidden]) { display: inline-flex; }
.searchbox { position: relative; display: flex; align-items: center; gap: 6px; height: 40px; padding: 0 12px; border: 2px solid var(--edge); border-radius: 999px; background: #fff; color: #2B2A33; min-width: 220px; }
.searchbox[hidden] { display: none; }
.searchbox input { border: 0; outline: 0; background: transparent; font: 600 .95rem var(--font); color: #2B2A33; width: 100%; min-width: 0; }
.searchbox:focus-within { box-shadow: 0 0 0 3px var(--lvl); }
.results { position: absolute; top: calc(100% + 8px); right: 0; width: min(420px, 92vw); margin: 0; padding: 6px; list-style: none; background: var(--surface); color: var(--ink); border: 2px solid var(--edge); border-radius: 16px; box-shadow: 0 5px 0 var(--edge); max-height: 70vh; overflow: auto; }
.results li a { display: block; padding: 8px 12px; border-radius: 10px; text-decoration: none; color: var(--ink); }
.results li a:hover, .results li a.active { background: var(--surface2); }
.results small { display: block; color: var(--muted); font-size: .85rem; }
.results .none { padding: 10px 12px; color: var(--muted); }

/* ---------- layout ---------- */
.layout { display: block; }
.has-side .layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); align-items: start; }
.sidebar { position: sticky; top: var(--topbar); height: calc(100vh - var(--topbar)); overflow: auto; padding: 18px 14px 40px 18px; border-right: 2px dashed var(--line); }
.side-title { font: 800 1.05rem var(--head); color: var(--lvl-ink); margin: 0 0 10px 6px; text-transform: uppercase; letter-spacing: .06em; }
.nav-ch { margin-bottom: 6px; border-radius: 14px; }
.nav-ch summary { cursor: pointer; display: flex; gap: 10px; align-items: flex-start; padding: 8px 8px; font-weight: 800; font-size: .95rem; line-height: 1.35; list-style: none; border-radius: 12px; }
.nav-ch summary::-webkit-details-marker { display: none; }
.nav-ch summary:hover { background: var(--lvl-soft); }
.nav-num { flex: none; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 9px; background: var(--lvl); color: #fff; font: 800 .85rem var(--head); }
:root[data-theme="dark"] .nav-num { color: #17161C; }
.nav-ch ul { list-style: none; margin: 2px 0 6px 12px; padding: 0 0 0 12px; border-left: 3px solid var(--lvl-soft); }
.nav-ch li a { display: flex; gap: 8px; align-items: flex-start; padding: 6px 8px; border-radius: 10px; text-decoration: none; color: var(--ink); font-size: .93rem; line-height: 1.35; }
.nav-ch li a:hover { background: var(--lvl-soft); }
.nav-ch li a[aria-current="page"] { background: var(--lvl); color: #fff; font-weight: 800; }
:root[data-theme="dark"] .nav-ch li a[aria-current="page"] { color: #17161C; }
.tick { flex: none; width: 16px; height: 16px; margin-top: 3px; border: 2px solid var(--muted); border-radius: 50%; }
.tick.on { background: #16A34A; border-color: #16A34A; box-shadow: inset 0 0 0 2px var(--surface); }
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 35; }
.scrim[hidden] { display: none; }

.main { min-width: 0; padding: 28px 24px 70px; }
.main:focus { outline: none; }
.page { max-width: 820px; margin: 0 auto; }
.page.wide { max-width: 1120px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 12px 22px; border: 2px solid var(--edge); border-radius: 999px; background: var(--lemon); color: var(--lemon-ink); font: 800 1.05rem var(--font); text-decoration: none; cursor: pointer; box-shadow: 0 4px 0 var(--edge); transition: transform .08s; }
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--edge); }
.btn-ghost, .btn-outline { background: var(--surface); color: var(--ink); }
.btn-outline[aria-pressed="true"] { background: #BBF7D0; color: #14532D; }
.btn .chk { width: 18px; height: 18px; border: 2px solid currentColor; border-radius: 6px; }
.btn[aria-pressed="true"] .chk { background: currentColor; box-shadow: inset 0 0 0 3px #BBF7D0; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 14px; }

/* ---------- home ---------- */
.hero { display: grid; grid-template-columns: 1.3fr .7fr; gap: 24px; align-items: center; padding: 20px 0 10px; }
.eyebrow { display: inline-block; margin: 0 0 8px; padding: 4px 14px; border: 2px solid var(--edge); border-radius: 999px; background: var(--surface); font: 800 .85rem var(--font); letter-spacing: .04em; text-transform: uppercase; color: var(--lvl-ink); }
.hero h1 { font-size: clamp(2.1rem, 5.4vw, 3.4rem); margin: .15em 0 .3em; }
.lead { font-size: 1.2rem; color: var(--muted); max-width: 40em; }
.hero-art { position: relative; display: grid; place-items: center; }
.hero-mascot { width: min(100%, 330px); height: auto; animation: bob 3.2s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-8px) rotate(-2deg); } }
.float { position: absolute; display: grid; place-items: center; width: 54px; height: 54px; border: 2px solid var(--edge); border-radius: 16px; background: var(--surface); font: 800 1.5rem var(--head); box-shadow: 0 4px 0 var(--edge); }
.f1 { top: 4%; left: 6%; color: #C2410C; transform: rotate(-8deg); } .f2 { top: 10%; right: 4%; color: #15803D; transform: rotate(10deg); }
.f3 { bottom: 8%; left: 2%; color: #4F46E5; transform: rotate(8deg); } .f4 { bottom: 4%; right: 8%; color: #BE185D; transform: rotate(-10deg); }
.grades h2, .features h2, .featured h2 { margin-top: 1.6em; }
.level { margin: 18px 0; padding: 18px; border: 2px solid var(--edge); border-radius: 24px; background: var(--lvl-soft); box-shadow: 0 5px 0 var(--edge); }
.level-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; margin-bottom: 12px; }
.level-head h3 { margin: 0; color: var(--lvl-ink); font-size: 1.5rem; }
.level-head p { margin: 0; color: var(--lvl-ink); font-weight: 700; opacity: .85; }
.gtiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.gtile { position: relative; display: flex; flex-direction: column; align-items: center; padding: 12px 8px 14px; border: 2px solid var(--edge); border-radius: 18px; background: var(--surface); color: var(--ink); text-decoration: none; box-shadow: 0 4px 0 var(--edge); transition: transform .1s; }
.gtile:hover { transform: translateY(-3px); }
.gnum { font: 800 2.6rem/1 var(--head); color: var(--lvl); }
.glabel { font-weight: 800; font-size: .9rem; text-transform: uppercase; letter-spacing: .08em; color: var(--lvl-ink); }
.gbadge { margin-top: 8px; padding: 2px 10px; border-radius: 999px; background: var(--lvl-soft); color: var(--lvl-ink); font-size: .78rem; font-weight: 800; }
.gtile.full { background: var(--lvl); color: #fff; }
.gtile.full .gnum, .gtile.full .glabel { color: #fff; }
.gtile.full .gbadge { background: var(--lemon); color: var(--lemon-ink); }
:root[data-theme="dark"] .gtile.full { color: #17161C; } :root[data-theme="dark"] .gtile.full .gnum, :root[data-theme="dark"] .gtile.full .glabel { color: #17161C; }
.feat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }
.feat { padding: 18px; border: 2px solid var(--edge); border-radius: var(--r); background: var(--surface); box-shadow: 0 4px 0 var(--edge); }
.feat h3 { margin: .5em 0 .2em; } .feat p { margin: 0; color: var(--muted); font-size: 1rem; line-height: 1.55; }
.feat-ico { display: inline-grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; background: var(--lemon); color: var(--lemon-ink); border: 2px solid var(--edge); }

/* ---------- cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin: 18px 0; }
.card { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 18px 18px 16px; border: 2px solid var(--edge); border-radius: var(--r); background: var(--surface); color: var(--ink); text-decoration: none; box-shadow: 0 4px 0 var(--edge); transition: transform .1s; }
a.card:hover { transform: translateY(-3px); }
.card h3 { margin: .1em 0 .15em; font-size: 1.15rem; line-height: 1.25; }
.card p { margin: 0 0 .4em; color: var(--muted); font-size: .95rem; line-height: 1.5; }
.card-num { font: 800 .8rem var(--font); letter-spacing: .08em; text-transform: uppercase; color: var(--lvl-ink); }
.cicon { display: inline-grid; place-items: center; width: 48px; height: 48px; margin-bottom: 4px; border-radius: 14px; background: var(--lvl-soft); color: var(--lvl-ink); border: 2px solid var(--edge); }
.cicon.big { width: 72px; height: 72px; border-radius: 20px; flex: none; }
.card-meta { margin-top: auto; font-weight: 800; font-size: .88rem; color: var(--muted); }
.card-meta.soon { color: var(--lvl-ink); }
.bar { height: 10px; margin-top: auto; border: 2px solid var(--edge); border-radius: 999px; background: var(--surface2); overflow: hidden; }
.bar[hidden] { display: none; }
.bar i { display: block; height: 100%; width: 0; background: var(--lvl); }
.featured .card:nth-child(3n+1) { --lvl-soft: #FFEDD5; --lvl-ink: #9A3412; }
.featured .card:nth-child(3n+2) { --lvl-soft: #DCFCE7; --lvl-ink: #166534; }
.featured .card:nth-child(3n) { --lvl-soft: #E0E7FF; --lvl-ink: #3730A3; }
:root[data-theme="dark"] .featured .card:nth-child(3n+1) { --lvl-soft: #3A2415; --lvl-ink: #FDBA74; }
:root[data-theme="dark"] .featured .card:nth-child(3n+2) { --lvl-soft: #12301F; --lvl-ink: #86EFAC; }
:root[data-theme="dark"] .featured .card:nth-child(3n) { --lvl-soft: #23244A; --lvl-ink: #A5B4FC; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .featured .card:nth-child(3n+1) { --lvl-soft: #3A2415; --lvl-ink: #FDBA74; }
  :root:not([data-theme="light"]) .featured .card:nth-child(3n+2) { --lvl-soft: #12301F; --lvl-ink: #86EFAC; }
  :root:not([data-theme="light"]) .featured .card:nth-child(3n) { --lvl-soft: #23244A; --lvl-ink: #A5B4FC; }
}

/* ---------- grade and chapter headers ---------- */
.gradehead { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 22px; margin: 10px 0 14px; border: 2px solid var(--edge); border-radius: 24px; background: var(--lvl-soft); box-shadow: 0 5px 0 var(--edge); }
.gradehead h1 { margin: 0; color: var(--lvl-ink); }
.gradehead .lead { margin: .2em 0 0; color: var(--lvl-ink); }
.grade-mascot { width: 110px; height: 110px; flex: none; }
.soon-note { padding: 12px 16px; border: 2px dashed var(--lvl); border-radius: 14px; background: var(--surface); font-weight: 700; }
.chaphead { display: flex; gap: 18px; align-items: center; margin: 8px 0 18px; }
.chaphead h1 { margin: 0; font-size: clamp(1.7rem, 4.5vw, 2.3rem); }
.chaphead .lead { margin: .2em 0 0; }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: .92rem; font-weight: 700; margin-bottom: 8px; color: var(--muted); }
.crumbs a { color: var(--muted); }
.lesson-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.lesson-list a { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 2px solid var(--edge); border-radius: 16px; background: var(--surface); color: var(--ink); text-decoration: none; font-weight: 700; box-shadow: 0 3px 0 var(--edge); }
.lesson-list a:hover { background: var(--lvl-soft); }
.lesson-list b { display: inline-block; min-width: 2.4em; color: var(--lvl-ink); font-family: var(--head); }
.ll-title { flex: 1; } .ll-meta { color: var(--muted); font-size: .9rem; white-space: nowrap; }

/* ---------- lessons ---------- */
.lesson h1 { margin-bottom: .1em; }
.meta { color: var(--muted); font-weight: 700; font-size: .95rem; }
.toc { margin: 16px 0 24px; padding: 14px 18px; border: 2px dashed var(--lvl); border-radius: 16px; background: var(--surface); }
.toc-title { margin: 0 0 4px; font: 800 .85rem var(--font); text-transform: uppercase; letter-spacing: .08em; color: var(--lvl-ink); }
.toc ol { margin: 0; padding-left: 1.3em; } .toc li { margin: 2px 0; }
.prose { overflow-wrap: break-word; }
.prose h2 { margin-top: 1.8em; padding-bottom: 4px; border-bottom: 4px solid var(--lvl-soft); color: var(--ink); }
.prose h2::before { content: ""; display: inline-block; width: 14px; height: 14px; margin-right: 10px; border-radius: 4px; background: var(--lvl); transform: rotate(12deg); }
.prose ul, .prose ol { padding-left: 1.4em; } .prose li { margin: .3em 0; }
.prose table { border-collapse: collapse; margin: 1em 0; display: block; overflow-x: auto; max-width: 100%; }
.prose th, .prose td { padding: 8px 14px; border: 2px solid var(--line); }
.prose th { background: var(--lvl-soft); color: var(--lvl-ink); }
.prose code { padding: 2px 6px; border-radius: 6px; background: var(--surface2); font-size: .9em; }
.prose blockquote { margin: 1em 0; padding: 4px 18px; border-left: 5px solid var(--lemon); background: var(--surface); border-radius: 0 12px 12px 0; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.katex { font-size: 1.1em; }

.box { margin: 1.3em 0; border: 2px solid var(--edge); border-radius: var(--r); background: var(--surface); box-shadow: 0 4px 0 var(--edge); overflow: hidden; --b: #2563EB; --bs: #DBEAFE; --bi: #1E3A8A; }
.box-title { padding: 8px 16px; background: var(--bs); color: var(--bi); font-weight: 800; border-bottom: 2px solid var(--edge); }
.box-kind { display: inline-block; margin-right: 6px; padding: 1px 10px; border-radius: 999px; background: var(--b); color: #fff; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; }
.box-body { padding: 4px 18px 6px; } .box-body > :last-child { margin-bottom: .6em; } .box-body > :first-child { margin-top: .8em; }
.box-definition { --b: #2563EB; --bs: #DBEAFE; --bi: #1E3A8A; }
.box-theorem { --b: #7C3AED; --bs: #EDE9FE; --bi: #4C1D95; }
.box-example { --b: #B45309; --bs: #FEF3C7; --bi: #78350F; }
.box-note { --b: #475569; --bs: #E2E8F0; --bi: #1E293B; }
.box-tip { --b: #15803D; --bs: #DCFCE7; --bi: #14532D; }
.box-warning { --b: #BE123C; --bs: #FFE4E6; --bi: #881337; }
.box-practice { --b: #C2410C; --bs: #FFEDD5; --bi: #7C2D12; }
.box-goals { --b: #0E7490; --bs: #CFFAFE; --bi: #164E63; }
.box-terms { --b: #BE185D; --bs: #FCE7F3; --bi: #831843; }
:root[data-theme="dark"] .box-title { color: #fff; }
:root[data-theme="dark"] .box-definition { --bs: #1E2B52; } :root[data-theme="dark"] .box-theorem { --bs: #2E2158; }
:root[data-theme="dark"] .box-example { --bs: #43300F; } :root[data-theme="dark"] .box-note { --bs: #2A3140; }
:root[data-theme="dark"] .box-tip { --bs: #153324; } :root[data-theme="dark"] .box-warning { --bs: #4A1626; }
:root[data-theme="dark"] .box-practice { --bs: #45220F; } :root[data-theme="dark"] .box-goals { --bs: #123943; } :root[data-theme="dark"] .box-terms { --bs: #451A33; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .box-title { color: #fff; }
  :root:not([data-theme="light"]) .box-definition { --bs: #1E2B52; } :root:not([data-theme="light"]) .box-theorem { --bs: #2E2158; }
  :root:not([data-theme="light"]) .box-example { --bs: #43300F; } :root:not([data-theme="light"]) .box-note { --bs: #2A3140; }
  :root:not([data-theme="light"]) .box-tip { --bs: #153324; } :root:not([data-theme="light"]) .box-warning { --bs: #4A1626; }
  :root:not([data-theme="light"]) .box-practice { --bs: #45220F; } :root:not([data-theme="light"]) .box-goals { --bs: #123943; } :root:not([data-theme="light"]) .box-terms { --bs: #451A33; }
}
.box-goals ul { list-style: none; padding-left: 0; } .box-goals li { position: relative; padding-left: 1.7em; }
.box-goals li::before { content: "★"; position: absolute; left: 0; color: #CA8A04; }
.box-solution { --b: #15803D; --bs: #DCFCE7; --bi: #14532D; }
:root[data-theme="dark"] .box-solution { --bs: #153324; } :root[data-theme="dark"] .box-solution summary { color: #fff; }
.box-solution summary { padding: 10px 16px; cursor: pointer; background: var(--bs); color: var(--bi); font-weight: 800; list-style: none; }
.box-solution summary::before { content: "▶"; display: inline-block; margin-right: 10px; font-size: .8em; transition: transform .15s; }
.box-solution[open] summary::before { transform: rotate(90deg); }
.box-solution[open] summary { border-bottom: 2px solid var(--edge); }
.box-solution summary::-webkit-details-marker { display: none; }
.terms { display: table; width: 100%; margin: .8em 0; } .terms th, .terms td { text-align: left; }
.terms tbody th { background: transparent; color: var(--ink); font-weight: 800; }

/* figures */
.figure { margin: 1.4em 0; text-align: center; }
.fsvg { width: 100%; height: auto; max-width: 440px; border: 2px solid var(--edge); border-radius: 16px; background: var(--surface); box-shadow: 0 4px 0 var(--edge); }
.figure figcaption { margin-top: 10px; color: var(--muted); font-size: .95rem; font-weight: 700; }
.fg { stroke: var(--line); stroke-width: 1; } .fa { stroke: var(--ink); stroke-width: 1.6; }
.fcurve { stroke: var(--c-curve); stroke-width: 2.8; fill: none; stroke-linecap: round; }
.fbound { stroke: var(--c-curve); stroke-width: 2.4; fill: none; } .dash { stroke-dasharray: 7 6; }
.freg { fill: var(--c-region); stroke: none; }
.fpt { fill: var(--c-pt); stroke: var(--surface); stroke-width: 1.5; } .fpt.open { fill: var(--surface); stroke: var(--c-pt); stroke-width: 2.4; }
.fseg { stroke: var(--ink); stroke-width: 2.2; fill: none; stroke-linejoin: round; stroke-linecap: round; } .fseg.nofill { fill: none; }
.fpoly { fill: var(--c-poly); stroke: none; }
.fvec { stroke: var(--c-curve); stroke-width: 2.8; fill: none; stroke-linecap: round; } .farrowhead { fill: var(--c-curve); }
.fang { stroke: var(--c-pt); stroke-width: 2; fill: none; }
.fl { fill: var(--ink); font: 700 15px var(--font); } .fl.i { font-style: italic; font-family: "Times New Roman", Georgia, serif; font-size: 17px; font-weight: 600; }
.ft { fill: var(--muted); font: 600 11px var(--font); }

/* ---------- pager ---------- */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 36px 0 0; }
.pager a { display: flex; flex-direction: column; gap: 2px; padding: 14px 18px; border: 2px solid var(--edge); border-radius: 16px; background: var(--surface); color: var(--ink); text-decoration: none; box-shadow: 0 4px 0 var(--edge); }
.pager a:hover { background: var(--lvl-soft); }
.pager small { color: var(--muted); font-weight: 800; } .pager span { font-weight: 800; }
.pager-next { text-align: right; }
.lesson-actions { margin: 36px 0 0; display: flex; justify-content: center; }

/* ---------- footer, banner ---------- */
.footer { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 30px 16px 36px; border-top: 3px solid var(--edge); background: var(--surface2); color: var(--muted); text-align: center; font-weight: 700; }
.footer p { margin: 0; } .foot-mark { width: 54px; height: 54px; }
.langbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center; padding: 10px 16px; background: var(--ink); color: var(--bg); font-weight: 700; }
.langbar a { color: var(--lemon); } .langbar button { border: 0; background: transparent; color: inherit; font: inherit; cursor: pointer; text-decoration: underline; }

/* ---------- small screens ---------- */
@media (min-width: 961px) { #menu-btn, .js #menu-btn:not([hidden]) { display: none; } }
@media (max-width: 960px) {
  .has-side .layout { display: block; }
  .js .sidebar { position: fixed; z-index: 40; left: 0; top: 0; bottom: 0; width: min(86vw, 330px); height: auto; background: var(--bg); padding-top: 20px; border-right: 3px solid var(--edge); transform: translateX(-102%); transition: transform .2s; }
  .js .sidebar.open { transform: none; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 2px dashed var(--line); }
  .topnav { display: none; }
}
@media (max-width: 760px) {
  body { font-size: 17px; }
  .hero { grid-template-columns: 1fr; } .hero-art { order: -1; max-width: 240px; margin: 0 auto; }
  .main { padding: 18px 16px 56px; }
  .searchbox { min-width: 0; flex: 1; } .lang-btn span { display: none; } .brand span { display: none; }
  .pager { grid-template-columns: 1fr; } .pager-next { text-align: left; }
  .gradehead { flex-direction: column-reverse; align-items: flex-start; } .grade-mascot { width: 84px; height: 84px; }
  .box-body { padding: 2px 14px 4px; }
}
@media (max-width: 520px) { .topbar { padding: 8px 10px; gap: 6px; } .float { display: none; } }
@media print { .topbar, .sidebar, .pager, .lesson-actions, .footer, .scrim { display: none !important; } body { background: #fff; color: #000; } .has-side .layout { display: block; } }
