/* Layout idea: a calm study room. Navy/teal/gold from the kits' own print design; a reading column
   set in Naskh, UI in Plex Sans Arabic; sidebar of units on the right (RTL), outline on the left. */
:root {
  --ink: #16304d;          /* navy: headings, part 1 */
  --teal: #0f6e6a;         /* accent, part 2 */
  --blue: #2f6a99;         /* part 3 */
  --gold: #b9832a;         /* highlights, part 4 */
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-2: #eef2f5;
  --text: #1c2733;
  --muted: #5b6a79;
  --line: #d9e0e7;
  --ok: #1f7a4d;
  --bad: #b23b2e;
  --on-dark: #f4f1ea;
  --font-ui: "PlexAr", "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  --font-read: "NaskhAr", "Noto Naskh Arabic", "Traditional Arabic", "Times New Roman", serif;
  --read-size: 1.14rem;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(22, 48, 77, .06), 0 8px 24px rgba(22, 48, 77, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #cfe0f2; --teal: #4cb8a9; --blue: #7fb2dc; --gold: #e0b25c;
    --bg: #0d1722; --surface: #13212f; --surface-2: #1a2b3c; --text: #e3eaf1; --muted: #9aaabb;
    --line: #26394c; --ok: #4fbf86; --bad: #f08070; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ink: #cfe0f2; --teal: #4cb8a9; --blue: #7fb2dc; --gold: #e0b25c;
  --bg: #0d1722; --surface: #13212f; --surface-2: #1a2b3c; --text: #e3eaf1; --muted: #9aaabb;
  --line: #26394c; --ok: #4fbf86; --bad: #f08070; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
  color-scheme: dark;
}

/* fonts (self-hosted) */
@font-face { font-family: "PlexAr"; font-weight: 400; font-display: swap; src: url(fonts/ibm-plex-sans-arabic-arabic-400-normal.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+200C-200E, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: "PlexAr"; font-weight: 500; font-display: swap; src: url(fonts/ibm-plex-sans-arabic-arabic-500-normal.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+200C-200E, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: "PlexAr"; font-weight: 600; font-display: swap; src: url(fonts/ibm-plex-sans-arabic-arabic-600-normal.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+200C-200E, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: "PlexAr"; font-weight: 700; font-display: swap; src: url(fonts/ibm-plex-sans-arabic-arabic-700-normal.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+200C-200E, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: "PlexAr"; font-weight: 400; font-display: swap; src: url(fonts/ibm-plex-sans-arabic-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: "PlexAr"; font-weight: 500; font-display: swap; src: url(fonts/ibm-plex-sans-arabic-latin-500-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: "PlexAr"; font-weight: 600; font-display: swap; src: url(fonts/ibm-plex-sans-arabic-latin-600-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: "PlexAr"; font-weight: 700; font-display: swap; src: url(fonts/ibm-plex-sans-arabic-latin-700-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: "NaskhAr"; font-weight: 400; font-display: swap; src: url(fonts/noto-naskh-arabic-arabic-400-normal.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+200C-200E, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: "NaskhAr"; font-weight: 600; font-display: swap; src: url(fonts/noto-naskh-arabic-arabic-600-normal.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+200C-200E, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: "NaskhAr"; font-weight: 700; font-display: swap; src: url(fonts/noto-naskh-arabic-arabic-700-normal.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+200C-200E, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: "NaskhAr"; font-weight: 400; font-display: swap; src: url(fonts/noto-naskh-arabic-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: "NaskhAr"; font-weight: 700; font-display: swap; src: url(fonts/noto-naskh-arabic-latin-700-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F; }

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font-family: var(--font-ui); line-height: 1.7; -webkit-font-smoothing: antialiased; }
a { color: var(--teal); }
img { max-width: 100%; height: auto; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3 { text-wrap: balance; color: var(--ink); line-height: 1.35; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* pattern used on dark bands */
.pattern { background-color: #16304d; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.07' stroke-width='1.2'%3E%3Cpath d='M40 4 L52 28 L76 40 L52 52 L40 76 L28 52 L4 40 L28 28 Z'/%3E%3Cpath d='M16 16 L64 16 L64 64 L16 64 Z' transform='rotate(45 40 40)'/%3E%3Ccircle cx='40' cy='40' r='9'/%3E%3C/g%3E%3C/svg%3E"); color: var(--on-dark); }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; padding: 10px clamp(16px, 3vw, 32px); background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); min-height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 700; font-size: 1.05rem; white-space: nowrap; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--teal); color: #fff; }
.brand-mark svg { width: 20px; height: 20px; }
.topbar .spacer { flex: 1; }
.topnav { display: flex; gap: 4px; }
.topnav a, .icon-btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 10px; text-decoration: none; color: var(--text); background: none; border: 0; cursor: pointer; font-size: .95rem; }
.topnav a:hover, .icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 20px; height: 20px; }
.kit-crumb { display: none; color: var(--muted); font-size: .92rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.in-reader .kit-crumb { display: block; }
.in-reader .topnav { display: none; }
.menu-btn { display: none; }
.reader-tools { display: none; gap: 2px; }
.in-reader .reader-tools { display: flex; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 20px; border-radius: 11px; border: 1px solid transparent; font-weight: 600; cursor: pointer; text-decoration: none; transition: transform .15s ease, background .15s ease; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: color-mix(in srgb, var(--teal) 85%, #000); }
.btn-gold { background: var(--gold); color: #1d1a12; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-light { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.28); }
.btn[disabled] { opacity: .6; cursor: progress; }

/* ---------- home ---------- */
.hero { padding: clamp(48px, 8vw, 96px) clamp(16px, 5vw, 64px) clamp(40px, 6vw, 72px); }
.hero-inner { max-width: 1120px; margin: 0 auto; display: grid; gap: 18px; }
.eyebrow { font-size: .9rem; letter-spacing: 0; color: var(--gold); font-weight: 600; }
.pattern .eyebrow { color: #e9c27a; }
.hero h1 { color: #fff; font-size: clamp(2rem, 4.6vw, 3.3rem); margin: 0; max-width: 18ch; }
.hero p { margin: 0; max-width: 60ch; font-size: 1.12rem; color: rgba(244, 241, 234, .86); }
.hero .actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.section { max-width: 1120px; margin: 0 auto; padding: clamp(40px, 6vw, 72px) clamp(16px, 4vw, 32px); }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.section-head h2 { margin: 0; font-size: clamp(1.4rem, 2.6vw, 1.9rem); }
.section-head p { margin: 0; color: var(--muted); }
.kits { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 20px; }
.kit-card { display: grid; grid-template-rows: auto 1fr; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.kit-card .cover { aspect-ratio: 16 / 10; overflow: hidden; background: var(--ink); position: relative; }
.kit-card .cover img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.kit-card .cover .num { position: absolute; top: 12px; right: 12px; background: rgba(13,23,34,.7); color: #fff; padding: 2px 10px; border-radius: 99px; font-size: .85rem; }
.kit-card .body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 10px; }
.kit-card h3 { margin: 0; font-size: 1.25rem; }
.kit-card p { margin: 0; color: var(--muted); font-size: .97rem; }
.kit-card .stats { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; background: var(--surface-2); color: var(--text); font-size: .85rem; border: 1px solid var(--line); }
.kit-card .foot { margin-top: auto; display: flex; gap: 8px; align-items: center; justify-content: space-between; padding-top: 6px; }
.kit-card.soon .cover { display: grid; place-items: center; }
.kit-card.soon .cover span { font-size: 1.05rem; color: rgba(255,255,255,.75); }
.status { font-size: .85rem; font-weight: 600; padding: 3px 10px; border-radius: 99px; }
.status.live { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.status.soon { color: var(--muted); background: var(--surface-2); }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; counter-reset: step; }
.step { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: grid; gap: 6px; }
.step b { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: color-mix(in srgb, var(--teal) 14%, transparent); color: var(--teal); }
.step h3 { margin: 4px 0 0; font-size: 1.08rem; }
.step p { margin: 0; color: var(--muted); }
.site-foot { border-top: 1px solid var(--line); padding: 28px clamp(16px, 4vw, 32px); color: var(--muted); font-size: .92rem; }
.site-foot .inner { max-width: 1120px; margin: 0 auto; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; }

/* ---------- kit landing ---------- */
.kit-hero { padding: clamp(32px, 6vw, 64px) clamp(16px, 5vw, 64px); }
.kit-hero .inner { max-width: 1120px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: clamp(24px, 4vw, 56px); align-items: center; }
.kit-hero h1 { color: #fff; margin: 6px 0 10px; font-size: clamp(1.8rem, 4vw, 2.8rem); }
.kit-hero p { margin: 0 0 14px; color: rgba(244,241,234,.86); max-width: 58ch; font-size: 1.08rem; }
.kit-hero .cover { border-radius: 12px; overflow: hidden; box-shadow: 0 18px 50px rgba(0,0,0,.35); transform: rotate(-2deg); }
.kit-hero .cover img { display: block; }
.kit-hero .stats { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.kit-hero .chip { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.18); color: #fff; }
.unlock { background: var(--surface); color: var(--text); border-radius: var(--radius); padding: 18px; display: grid; gap: 10px; max-width: 480px; box-shadow: var(--shadow); }
.unlock label { font-weight: 600; color: var(--ink); }
.unlock .row { display: flex; gap: 8px; }
.unlock input { flex: 1; min-width: 0; padding: 11px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); letter-spacing: .04em; direction: ltr; text-align: center; }
.unlock small { color: var(--muted); }
.unlock .err { color: var(--bad); font-weight: 600; min-height: 1.4em; margin: 0; }
.unlocked-box { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.toc-public { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 16px; }
.part-card { background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--pc); border-radius: var(--radius); padding: 18px 20px; }
.part-card .lbl { color: var(--pc); font-weight: 700; font-size: .9rem; }
.part-card h3 { margin: 2px 0 6px; font-size: 1.15rem; }
.part-card p { margin: 0 0 10px; color: var(--muted); font-size: .93rem; }
.part-card ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.part-card li { display: flex; gap: 10px; align-items: baseline; }
.part-card li a { color: var(--text); text-decoration: none; }
.part-card li a:hover { color: var(--teal); text-decoration: underline; }
.unum { flex: none; display: inline-grid; place-items: center; min-width: 26px; height: 26px; border-radius: 8px; background: color-mix(in srgb, var(--pc) 14%, transparent); color: var(--pc); font-weight: 700; font-size: .85rem; }
.p1 { --pc: #16304d; } .p2 { --pc: #0f6e6a; } .p3 { --pc: #2f6a99; } .p4 { --pc: #b9832a; }
:root[data-theme="dark"] .p1 { --pc: #8fb4dc; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .p1 { --pc: #8fb4dc; } }

/* ---------- reader ---------- */
.reader { display: grid; grid-template-columns: 300px minmax(0, 1fr); min-height: calc(100vh - 60px); }
.sidebar { position: sticky; top: 60px; height: calc(100vh - 60px); overflow-y: auto; border-left: 1px solid var(--line); background: var(--surface); padding: 18px 14px 28px; display: flex; flex-direction: column; gap: 14px; }
.side-kit { display: grid; gap: 4px; padding: 0 6px; }
.side-kit a { text-decoration: none; color: var(--ink); font-weight: 700; line-height: 1.4; }
.progress { display: grid; gap: 6px; padding: 12px; border-radius: 12px; background: var(--surface-2); }
.progress .bar { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--teal), var(--gold)); border-radius: 99px; transition: width .4s ease; }
.progress span { font-size: .88rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.nav-group { display: grid; gap: 2px; }
.nav-group > .gl { font-size: .8rem; color: var(--muted); font-weight: 600; padding: 8px 8px 4px; }
.nav-group .gl b { color: var(--pc); }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 10px; text-decoration: none; color: var(--text); font-size: .94rem; line-height: 1.45; }
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: color-mix(in srgb, var(--teal) 12%, transparent); color: var(--ink); font-weight: 600; }
.nav-item .unum { min-width: 24px; height: 24px; font-size: .8rem; }
.nav-item .done-mark { margin-inline-start: auto; color: var(--ok); flex: none; }
.nav-item .done-mark svg { width: 16px; height: 16px; display: block; }
.nav-item .ico { width: 24px; display: grid; place-items: center; color: var(--muted); flex: none; }
.nav-item .ico svg { width: 18px; height: 18px; }
.side-foot { margin-top: auto; padding: 0 6px; }
.scrim { display: none; position: fixed; inset: 60px 0 0 0; background: rgba(0,0,0,.35); z-index: 35; }
.content-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 230px; gap: 32px; padding: 0 clamp(16px, 3vw, 40px) 64px; }
.content { max-width: 780px; width: 100%; margin: 0 auto; min-width: 0; }
.outline { position: sticky; top: 84px; align-self: start; max-height: calc(100vh - 110px); overflow-y: auto; padding-top: 32px; font-size: .88rem; }
.outline h4 { margin: 0 0 8px; color: var(--muted); font-size: .82rem; font-weight: 600; }
.outline a { display: block; padding: 5px 10px; border-inline-start: 2px solid var(--line); color: var(--muted); text-decoration: none; line-height: 1.5; }
.outline a:hover { color: var(--teal); }
.outline a.on { color: var(--ink); border-color: var(--teal); font-weight: 600; }
.outline .n { font-variant-numeric: tabular-nums; color: var(--gold); margin-inline-end: 4px; }

/* unit hero */
.unit-hero { margin: 0 calc(-1 * clamp(16px, 3vw, 40px)); padding: clamp(28px, 5vw, 48px) clamp(16px, 4vw, 48px); border-radius: 0 0 22px 22px; }
.unit-hero .meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; color: rgba(244,241,234,.8); font-size: .92rem; }
.unit-hero .badge { background: var(--pc-solid); color: #fff; padding: 2px 12px; border-radius: 99px; font-weight: 600; }
.unit-hero .bignum small { font-size: .32em; color: rgba(244,241,234,.8); font-weight: 500; margin-inline-end: .3em; vertical-align: middle; }
.unit-hero .bignum { font-size: clamp(3rem, 8vw, 4.4rem); line-height: 1.1; color: #e9c27a; font-weight: 700; margin: 10px 0 4px; font-family: var(--font-ui); }
.unit-hero h1 { color: #fff; margin: 0 0 10px; font-size: clamp(1.6rem, 3.6vw, 2.35rem); max-width: 26ch; }
.unit-hero p { margin: 0; color: rgba(244,241,234,.86); max-width: 62ch; font-size: 1.06rem; }
.p1 .unit-hero, .unit-hero.p1 { --pc-solid: #2a4a70; } .unit-hero.p2 { --pc-solid: #0f6e6a; } .unit-hero.p3 { --pc-solid: #2f6a99; } .unit-hero.p4 { --pc-solid: #b9832a; }
.unit-intro { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; margin: 24px 0 8px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.card h3 { margin: 0 0 8px; font-size: 1rem; }
.card ul { margin: 0; padding-inline-start: 1.1em; display: grid; gap: 4px; }
.concepts { display: flex; flex-wrap: wrap; gap: 6px; }
.quote-card { background: var(--surface-2); border: 0; font-family: var(--font-read); }
.quote-card blockquote { margin: 0; font-size: 1.05rem; line-height: 1.9; color: var(--text); }
.quote-card cite { display: block; margin-top: 8px; font-style: normal; color: var(--muted); font-family: var(--font-ui); font-size: .85rem; }
.page-head { padding: 36px 0 8px; }
.page-head h1 { margin: 0; font-size: clamp(1.7rem, 3.4vw, 2.3rem); }
.page-head p { color: var(--muted); margin: 8px 0 0; }

/* document typography */
.doc { font-family: var(--font-read); font-size: var(--read-size); line-height: 2.05; }
.doc p { margin: 0 0 1em; }
.doc h2 { font-family: var(--font-ui); font-size: 1.45em; margin: 2em 0 .6em; scroll-margin-top: 80px; display: flex; gap: 12px; align-items: baseline; }
.doc h2 .sec-num { flex: none; font-size: .78em; color: #fff; background: var(--teal); padding: 0 10px; border-radius: 8px; font-variant-numeric: tabular-nums; }
.doc h3 { font-family: var(--font-ui); font-size: 1.12em; margin: 1.6em 0 .4em; color: var(--teal); }
.doc ul, .doc ol { padding-inline-start: 1.4em; margin: 0 0 1em; }
.doc ol { list-style-type: arabic-indic; }
.doc li { margin: .2em 0; }
.doc li > p { margin: 0; }
.doc strong { color: var(--ink); }
.doc .ltr { unicode-bidi: isolate; font-family: var(--font-ui); font-size: .92em; }
.doc figure { margin: 1.6em 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.doc figure img { display: block; margin: 0 auto; border-radius: 8px; }
:root[data-theme="dark"] .doc figure img { background: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .doc figure img { background: #fff; } }
.doc figcaption { font-family: var(--font-ui); font-size: .85rem; color: var(--muted); text-align: center; margin-top: 8px; line-height: 1.6; }
.doc blockquote.pull { margin: 1.4em 0; padding: 14px 20px; border-inline-start: 4px solid var(--gold); background: color-mix(in srgb, var(--gold) 9%, var(--surface)); border-radius: 0 12px 12px 0; }
.table-wrap { overflow-x: auto; margin: 1.2em 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.doc table { border-collapse: collapse; width: 100%; font-family: var(--font-ui); font-size: .84em; line-height: 1.7; }
.doc th, .doc td { padding: 9px 12px; text-align: right; vertical-align: top; border-bottom: 1px solid var(--line); }
.doc thead tr:first-child th { background: var(--ink); color: #fff; font-weight: 600; }
:root[data-theme="dark"] .doc thead tr:first-child th { background: #22405f; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .doc thead tr:first-child th { background: #22405f; } }
.doc thead th { font-weight: 400; }
.doc thead tr:nth-child(n+2) th:first-child, .doc tbody td:first-child { font-weight: 600; color: var(--ink); }
.doc tbody tr:nth-child(even) td, .doc thead tr:nth-child(odd):not(:first-child) th { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.doc td p, .doc th p { margin: 0; }

/* learning boxes */
.box { --bc: var(--teal); margin: 1.4em 0; border-radius: 12px; background: color-mix(in srgb, var(--bc) 7%, var(--surface)); border: 1px solid color-mix(in srgb, var(--bc) 22%, transparent); border-inline-start: 5px solid var(--bc); padding: 14px 18px; }
.box-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-family: var(--font-ui); margin-bottom: 6px; }
.box-label { display: inline-flex; align-items: center; gap: 6px; color: var(--bc); font-weight: 700; font-size: .82em; }
.box-label::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--bc); transform: rotate(45deg); }
.box-title { font-weight: 700; color: var(--ink); font-size: .92em; }
.box-body > :last-child { margin-bottom: 0; }
.box-body .table-wrap { font-size: .95em; }
.box-def { --bc: #16304d; } .box-example { --bc: #2f6a99; } .box-arab { --bc: #0f6e6a; } .box-tool { --bc: #b9832a; }
.box-activity { --bc: #1f7a4d; } .box-warn { --bc: #b23b2e; } .box-ref { --bc: #6a5a9b; } .box-reflect { --bc: #b9832a; }
.box-case { --bc: #2f6a99; } .box-summary { --bc: #16304d; } .box-text { --bc: #8a96a3; }
:root[data-theme="dark"] .box-def, :root[data-theme="dark"] .box-summary { --bc: #8fb4dc; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .box-def, :root:not([data-theme="light"]) .box-summary { --bc: #8fb4dc; } }
.box-text { background: var(--surface); border-style: solid; border-inline-start-style: double; border-inline-start-width: 6px; }
.box-text .box-label { color: var(--muted); }
.box-summary { background: color-mix(in srgb, var(--bc) 9%, var(--surface)); }
.note { margin-top: 12px; display: grid; gap: 6px; font-family: var(--font-ui); }
.note label { font-weight: 600; font-size: .85rem; color: var(--ink); display: flex; gap: 6px; align-items: center; }
.note label svg { width: 16px; height: 16px; color: var(--bc); }
.note textarea { width: 100%; min-height: 96px; resize: vertical; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); padding: 10px 12px; font-size: .95rem; line-height: 1.8; }
.note small { color: var(--muted); font-size: .78rem; }
.note small.saved { color: var(--ok); }

/* quiz */
.quiz { margin: 40px 0 0; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); overflow: hidden; }
.quiz-head { padding: 18px 20px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.quiz-head h2, .quiz-head h3 { margin: 0; font-size: 1.2rem; }
.quiz-head p { margin: 2px 0 0; color: var(--muted); font-size: .9rem; }
.score { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); background: var(--surface); border: 1px solid var(--line); padding: 4px 12px; border-radius: 99px; }
.score.full { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.q { padding: 18px 20px; border-bottom: 1px solid var(--line); }
.q:last-of-type { border-bottom: 0; }
.q-stem { font-weight: 600; margin: 0 0 10px; display: flex; gap: 10px; }
.q-stem .qn { flex: none; color: var(--gold); font-variant-numeric: tabular-nums; }
.opts { display: grid; gap: 8px; }
.opt { display: flex; gap: 10px; align-items: center; text-align: right; width: 100%; padding: 10px 14px; border-radius: 11px; border: 1px solid var(--line); background: var(--bg); cursor: pointer; transition: border-color .15s, background .15s; }
.opt:hover:not([disabled]) { border-color: var(--teal); }
.opt .l { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--surface); border: 1px solid var(--line); font-weight: 700; font-size: .9rem; }
.opt[disabled] { cursor: default; }
.opt.right { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 11%, var(--surface)); }
.opt.right .l { background: var(--ok); color: #fff; border-color: var(--ok); }
.opt.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, var(--surface)); }
.opt.wrong .l { background: var(--bad); color: #fff; border-color: var(--bad); }
.q-fb { margin: 8px 0 0; font-weight: 600; font-size: .92rem; }
.q-fb.ok { color: var(--ok); } .q-fb.no { color: var(--bad); }
.quiz-foot { padding: 14px 20px; display: flex; gap: 10px; justify-content: flex-end; border-top: 1px solid var(--line); }
.unit-end { margin-top: 28px; display: grid; gap: 16px; }
.done-toggle { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 16px 20px; border-radius: 14px; background: color-mix(in srgb, var(--teal) 9%, var(--surface)); border: 1px solid color-mix(in srgb, var(--teal) 25%, transparent); }
.done-toggle p { margin: 0; font-weight: 600; color: var(--ink); }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pager a { display: grid; gap: 2px; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); text-decoration: none; color: var(--text); }
.pager a:hover { border-color: var(--teal); }
.pager small { color: var(--muted); }
.pager .next { text-align: left; grid-column: 2; }

/* glossary */
.gl-tools { position: sticky; top: 60px; z-index: 5; background: var(--bg); padding: 12px 0; display: grid; gap: 10px; }
.search { width: 100%; padding: 12px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); }
.letters { display: flex; flex-wrap: wrap; gap: 4px; }
.letters button { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; min-width: 34px; padding: 2px 8px; cursor: pointer; }
.letters button.on { background: var(--teal); color: #fff; border-color: var(--teal); }
.terms { display: grid; gap: 10px; }
.term { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px; }
.term h3 { margin: 0; font-size: 1.08rem; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.term h3 bdi { font-weight: 400; color: var(--muted); font-size: .88rem; }
.term p { margin: 6px 0 8px; font-family: var(--font-read); line-height: 1.95; }
.term .refs { display: flex; gap: 6px; flex-wrap: wrap; }
.term .refs a { font-size: .8rem; text-decoration: none; }
.empty { color: var(--muted); padding: 24px 0; text-align: center; }

/* notes page */
.note-entry { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px; display: grid; gap: 6px; }
.note-entry a { font-size: .88rem; }
.note-entry div { white-space: pre-wrap; font-family: var(--font-read); line-height: 1.9; }

/* toast */
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 10px; font-weight: 600; z-index: 60; }

/* responsive */
@media (max-width: 1280px) {
  .content-wrap { grid-template-columns: minmax(0, 1fr); }
  .outline { display: none; }
}
@media (max-width: 960px) {
  .reader { grid-template-columns: minmax(0, 1fr); }
  .menu-btn { display: inline-flex; }
  .sidebar { position: fixed; top: 60px; right: 0; bottom: 0; width: min(320px, 88vw); height: auto; z-index: 40; transform: translateX(105%); transition: transform .25s ease; box-shadow: var(--shadow); }
  .reader.nav-open .sidebar { transform: none; }
  .reader.nav-open .scrim { display: block; }
  .kit-hero .inner { grid-template-columns: minmax(0, 1fr); }
  .kit-hero .cover { display: none; }
  .unit-intro { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .topnav a span { display: none; }
  .brand-name { display: none; }
  .pager { grid-template-columns: minmax(0, 1fr); }
  .pager .next { grid-column: 1; }
  .unlock .row { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
@media print { .topbar, .sidebar, .outline, .note, .quiz, .unit-end { display: none !important; } .reader, .content-wrap { display: block; } }
