/* ============================================================
   ToolScope Notes — standalone stylesheet for the static,
   pre-rendered /notes pages (built by scripts/build-notes.mjs).
   Same design system as src/index.css ("precision instrument":
   warm paper + deep ink + flame accent; Space Grotesk display,
   Inter body, mono labels) including the v2.8 dark theme —
   variables are duplicated here because these pages ship as
   plain HTML and cannot load the app's bundled CSS.
   ============================================================ */
:root {
  --ink: #0b0f19;
  --ink-2: #161d2e;
  --ink-line: #26314a;
  --paper: #faf9f6;
  --card: #ffffff;
  --text: #141824;
  --muted: #5b6472;
  --border: #e6e3da;
  --border-strong: #d6d2c6;
  --accent: #e8490f;
  --accent-dark: #c53a08;
  --accent-soft: #fdeee6;
  --accent-ink: #9a2e05;
  /* Brand colours (Oct 27, 2026): overridden by ts-runtime.js
     when an admin brand is saved; defaults are the palette. */
  --gold: #d4a017;
  --green: #0b6e4f;
  --field-bg: #ffffff;
  --soft-bg: #f4f3ee;
  --prose: #333c4c;
  --code-bg: #0f1626;
  --code-text: #e6ebf4;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 1px 2px rgba(16, 20, 30, 0.05);
  --shadow-lift: 0 16px 36px -18px rgba(16, 20, 30, 0.28);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Space Grotesk", "Inter", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0b0f19;
  --card: #131a2a;
  --text: #e9edf5;
  --muted: #9aa5ba;
  --border: #26314a;
  --border-strong: #3a4a73;
  --accent-soft: #2e1508;
  --accent-ink: #ffb59a;
  --accent-dark: #ff8a50;
  --field-bg: #0f1626;
  --soft-bg: #0f1626;
  --prose: #c6cede;
  --code-bg: #0a0f1c;
  --code-text: #dbe4f2;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
  --shadow-lift: 0 16px 36px -18px rgba(0, 0, 0, 0.75);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { overflow-x: clip; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--paper);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent-soft); color: var(--accent-ink); }
a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
.container { max-width: 1120px; margin: 0 auto; padding: 0 20px; }

/* ---------- header (mirrors the app header) ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(250, 249, 246, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
:root[data-theme="dark"] .site-header { background: rgba(11, 15, 25, 0.88); }
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: 16px; }
.logo { display: flex; align-items: center; gap: 10px; color: var(--text); min-height: 40px; }
.logo:hover { text-decoration: none; }
.logo-mark {
  width: 34px; height: 34px; border-radius: 9px; background: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}
:root[data-theme="dark"] .logo-mark { background: #1d2740; border: 1px solid var(--ink-line); }
.logo-word { font-family: var(--font-display); font-size: 1.28rem; font-weight: 700; letter-spacing: -0.01em; }
.logo-word em { font-style: normal; color: var(--accent); }
.header-right { display: flex; align-items: center; gap: 6px; }
.main-nav { display: flex; gap: 2px; align-items: center; }
.main-nav a {
  color: var(--muted); font-weight: 600; font-size: 0.94rem;
  padding: 8px 12px; border-radius: 8px;
}
.main-nav a:hover { color: var(--text); background: rgba(20, 24, 36, 0.05); text-decoration: none; }
:root[data-theme="dark"] .main-nav a:hover { color: var(--text); background: rgba(255, 255, 255, 0.07); }
/* v2.8 underline: drawn on the inner .u-line span so it is
   exactly the text width; grows from the left on hover. */
.u-line {
  background-image: linear-gradient(currentColor, currentColor);
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 0% 1.5px;
  transition: background-size 0.32s ease;
  padding-bottom: 2px;
}
a:hover > .u-line, a:focus-visible > .u-line { background-size: 100% 1.5px; }
.main-nav a.nav-active { color: var(--accent-dark); }
:root[data-theme="dark"] .main-nav a.nav-active { color: var(--accent); }
.main-nav a.nav-active > .u-line { background-size: 100% 1.5px; }
.theme-toggle {
  width: 38px; height: 38px; border-radius: 9px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid var(--border);
  color: var(--muted); cursor: pointer;
}
.theme-toggle:hover { color: var(--text); border-color: var(--border-strong); }

/* Donate button (Nov 2, 2026): solid brand flame, not a plain link —
   it must stand out in the nav. Shown only when the admin enabled
   Donate; the static runtime hides it (inline display:none) otherwise. */
.main-nav a.donate-nav-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 40px; padding: 8px 18px; border-radius: 999px;
  background: var(--accent); border: 1px solid var(--accent);
  color: #fff !important; font-weight: 700; text-decoration: none;
}
.main-nav a.donate-nav-btn:hover { filter: brightness(1.08); color: #fff; }

@media (max-width: 480px) {
  /* Full 44px touch target for the theme toggle on small screens
     (Nov 2, 2026), matching the app header. */
  .theme-toggle { width: 44px; height: 44px; }
}

/* ---------- buttons (mirror .btn in the app) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--ink); color: #fff; border: 1px solid var(--ink); border-radius: 9px;
  padding: 11px 20px; font-size: 0.97rem; font-weight: 600; cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { background: var(--ink-2); text-decoration: none; }
:root[data-theme="dark"] .btn { background: #263354; border-color: #263354; }
:root[data-theme="dark"] .btn:hover { background: #2f4066; border-color: #2f4066; }
.btn-accent { background: var(--accent); border-color: var(--accent); }
.btn-accent:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
:root[data-theme="dark"] .btn-accent { background: var(--accent); border-color: var(--accent); }
:root[data-theme="dark"] .btn-accent:hover { background: #ff5c1f; border-color: #ff5c1f; }
.btn-ghost { background: var(--field-bg); color: var(--text); border: 1px solid var(--border-strong); }
.btn-ghost:hover { background: var(--paper); border-color: var(--border-strong); }
:root[data-theme="dark"] .btn-ghost { background: var(--field-bg); color: var(--text); }
:root[data-theme="dark"] .btn-ghost:hover { background: #182238; }
.btn svg { flex: none; }

/* ---------- notes pages ---------- */
.notes-page { padding-top: 30px; padding-bottom: 72px; }
.breadcrumb {
  font-family: var(--font-mono); font-size: 0.76rem; letter-spacing: 0.04em;
  color: var(--muted); margin-bottom: 14px;
  display: flex; align-items: center; flex-wrap: wrap; gap: 2px;
}
.breadcrumb a { color: var(--muted); display: inline-flex; align-items: center; min-height: 40px; padding: 0 5px; }
.breadcrumb strong { color: var(--text); font-weight: 600; }
.eyebrow {
  font-family: var(--font-mono); font-size: 0.74rem; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent-ink); margin: 0 0 10px;
}
.notes-hero h1, .note-head h1 {
  font-family: var(--font-display); font-size: clamp(1.9rem, 5vw, 2.7rem);
  line-height: 1.12; letter-spacing: -0.015em; margin: 0 0 12px; color: var(--text);
}
.notes-lead { color: var(--prose); font-size: 1.06rem; line-height: 1.65; max-width: 68ch; margin: 0 0 18px; }
.notes-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--border-strong); background: var(--field-bg); color: var(--text);
  border-radius: 999px; padding: 6px 13px; font-size: 0.84rem; font-weight: 600;
}
.chip .chip-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }

.set-block { margin-top: 42px; }
.set-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 6px; }
.set-head h2 { font-family: var(--font-display); font-size: 1.55rem; margin: 0; letter-spacing: -0.01em; }
.set-count { font-family: var(--font-mono); font-size: 0.74rem; color: var(--muted); letter-spacing: 0.08em; }
.track-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin: 26px 0 12px; }
.track-head h3 { font-family: var(--font-display); font-size: 1.2rem; margin: 0; letter-spacing: -0.01em; }
.set-blurb { color: var(--muted); font-size: 0.95rem; margin: 0 0 18px; max-width: 72ch; }

.note-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.note-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 18px; color: var(--text); display: flex; flex-direction: column; gap: 9px;
  box-shadow: var(--shadow);
}
.note-card:hover { text-decoration: none; border-color: var(--border-strong); box-shadow: var(--shadow-lift); }
.note-card-top { display: flex; align-items: center; justify-content: space-between; }
.lesson-chip {
  font-family: var(--font-mono); font-size: 0.68rem; font-weight: 600;
  letter-spacing: 0.13em; text-transform: uppercase; color: var(--accent-ink);
  background: var(--accent-soft); border-radius: 6px; padding: 4px 8px;
}
.note-arrow { color: var(--muted); font-size: 1rem; }
.note-card h3 { font-family: var(--font-display); font-size: 1.12rem; margin: 0; line-height: 1.3; }
.note-card h3 .u-line { transition: background-size 0.32s ease; }
.note-card:hover h3 .u-line { background-size: 100% 1.5px; }
.note-card p { margin: 0; color: var(--muted); font-size: 0.89rem; line-height: 1.5; flex: 1; }
.note-card-actions { display: flex; align-items: center; gap: 14px; font-size: 0.86rem; font-weight: 600; }
.note-card-actions .watch { color: var(--muted); display: inline-flex; align-items: center; gap: 5px; }
.note-card-actions .watch:hover { color: var(--accent-dark); }

.set-soon {
  margin-top: 18px; border: 1px dashed var(--border-strong); border-radius: var(--radius-lg);
  padding: 18px; color: var(--muted); font-size: 0.94rem;
}
.set-soon strong { color: var(--text); }

/* ---------- series grid (v30) ---------- */
.series-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.series-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 18px; color: var(--text); display: flex; flex-direction: column; gap: 9px;
  box-shadow: var(--shadow);
}
a.series-card:hover { text-decoration: none; border-color: var(--border-strong); box-shadow: var(--shadow-lift); }
.series-card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.series-name { font-family: var(--font-display); font-size: 1.18rem; font-weight: 700; letter-spacing: -0.01em; }
.ready-badge {
  font-family: var(--font-mono); font-size: 0.68rem; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase; white-space: nowrap;
  color: var(--accent-ink); background: var(--accent-soft);
  border-radius: 6px; padding: 4px 8px;
}
.soon-badge {
  font-family: var(--font-mono); font-size: 0.68rem; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase; white-space: nowrap;
  color: var(--muted); background: var(--soft-bg); border: 1px dashed var(--border-strong);
  border-radius: 6px; padding: 4px 8px;
}
.series-card p { margin: 0; color: var(--muted); font-size: 0.89rem; line-height: 1.5; flex: 1; }
.series-cta { font-size: 0.86rem; font-weight: 600; color: var(--accent-dark); }
.series-cta.muted { color: var(--muted); font-weight: 500; }
.series-card.soon { opacity: 0.78; box-shadow: none; border-style: dashed; }
.series-card.soon .series-name { color: var(--muted); }

/* ---------- one note (article) ---------- */
.note-wrap { max-width: 820px; }
/* Learn AI lesson subtitle (Nov 3, 2026 — H1 split): the
   Roman-Urdu lesson title under the English-only H1. It carries
   .lg-ur too, so it shows only in Roman-Urdu mode. */
.note-subtitle { color: var(--muted); font-size: 1.02rem; margin: 6px 0 0; }
.note-meta {
  display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center;
  font-family: var(--font-mono); font-size: 0.76rem; letter-spacing: 0.05em;
  color: var(--muted); margin: 0 0 18px;
}
.note-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 10px; }
.note-actions-note { font-size: 0.85rem; color: var(--muted); margin: 0 0 26px; }

.note-body { color: var(--prose); font-size: 1rem; line-height: 1.7; overflow-wrap: anywhere; }
/* Phone sideways overflow (Report 2 N-08, Nov 11, 2026): a wide
   table or one long unbroken line must scroll inside its own box
   (or wrap), never push the whole page wider than the phone.
   Media never exceeds the column; height auto keeps its ratio. */
.note-body pre, .note-body table { display: block; max-width: 100%; overflow-x: auto; }
.note-body img, .note-body video, .note-body iframe { max-width: 100%; height: auto; }
.note-body section { margin-bottom: 34px; }
.note-body h2 {
  font-family: var(--font-display); font-size: 1.42rem; color: var(--text);
  letter-spacing: -0.01em; margin: 0 0 14px;
  padding-bottom: 8px; border-bottom: 2px solid var(--accent-soft);
}
.note-body h3 { font-family: var(--font-display); font-size: 1.08rem; color: var(--text); margin: 22px 0 10px; }
.note-body p { margin: 0 0 13px; }
.note-body ul, .note-body ol { margin: 0 0 14px; padding-left: 24px; }
.note-body li { margin-bottom: 8px; }
.note-body li > ul, .note-body li > ol { margin-top: 8px; margin-bottom: 2px; }
.note-body strong { color: var(--text); }
.note-body code {
  font-family: var(--font-mono); font-size: 0.86em;
  background: var(--soft-bg); border: 1px solid var(--border);
  border-radius: 5px; padding: 1px 5px; color: var(--accent-ink);
  overflow-wrap: anywhere;
}
:root[data-theme="dark"] .note-body code { color: var(--accent-ink); }
.ru {
  display: block; margin-top: 4px; font-size: 0.92em; color: var(--muted);
}
.code-block {
  background: var(--code-bg); border-radius: var(--radius-lg);
  margin: 0 0 8px; overflow: hidden; border: 1px solid var(--ink-line);
}
.code-block pre { margin: 0; padding: 16px 18px; overflow-x: auto; }
.code-block code {
  font-family: var(--font-mono); font-size: 0.86rem; line-height: 1.6;
  color: var(--code-text); background: none; border: none; padding: 0;
  overflow-wrap: normal; white-space: pre;
}
.sec-mistakes li::marker { color: var(--accent); font-weight: 700; }
.sec-recap {
  background: var(--accent-soft); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px 22px 8px;
}
.sec-recap h2 { border-bottom-color: var(--border); }
.sec-recap li::marker { color: var(--accent); font-weight: 700; }
.sec-practice {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 20px 22px 8px; box-shadow: var(--shadow);
}
.sec-practice h2 { border-bottom-color: var(--accent-soft); }

.note-pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 40px; }
.pager-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 16px 18px; color: var(--text); box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 5px;
}
.pager-card:hover { text-decoration: none; border-color: var(--border-strong); }
.pager-card .dir {
  font-family: var(--font-mono); font-size: 0.68rem; font-weight: 600;
  letter-spacing: 0.13em; text-transform: uppercase; color: var(--muted);
}
.pager-card .ttl { font-family: var(--font-display); font-weight: 600; line-height: 1.3; }
.pager-card.next { text-align: right; }
.pager-card.single { grid-column: 1 / -1; }

/* ---------- footer (mirrors the app footer) ---------- */
.site-footer { background: var(--ink); color: #aeb6c6; margin-top: 56px; }
.footer-inner {
  max-width: 1120px; margin: 0 auto; padding: 44px 20px 8px;
  display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 28px;
}
.site-footer .logo { color: #fff; }
.site-footer .logo-mark { background: #1d2740; border: 1px solid var(--ink-line); }
.footer-tag { font-size: 0.92rem; line-height: 1.6; margin: 14px 0 0; max-width: 44ch; }
.site-footer h4 {
  font-family: var(--font-mono); font-size: 0.72rem; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase; color: #e8ecf3; margin: 4px 0 12px;
}
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { margin-bottom: 8px; }
.site-footer li a { color: #aeb6c6; font-size: 0.92rem; }
.site-footer li a:hover { color: #fff; text-decoration: none; }
.footer-bottom {
  border-top: 1px solid var(--ink-line); padding: 18px 20px; text-align: center;
  font-size: 0.86rem; margin-top: 26px;
}
/* Footer contact link (Oct 27, 2026): the "Developed by" credit
   becomes a link only when ts-runtime finds a footer contact. */
.footer-bottom a { color: #aeb6c6; }
.footer-bottom a:hover { color: #fff; }

/* ---------- responsive ---------- */
@media (max-width: 720px) {
  .header-inner { height: 58px; gap: 10px; }
  .logo { gap: 8px; }
  .logo-word { font-size: 1.05rem; }
  .logo-mark { width: 30px; height: 30px; }
  .main-nav { gap: 0; }
  .main-nav a { padding: 8px 6px; font-size: 0.85rem; white-space: nowrap; }
  .notes-page { padding-top: 22px; }
  .note-grid, .series-grid { grid-template-columns: 1fr; }
  .note-pager { grid-template-columns: 1fr; }
  .footer-inner { grid-template-columns: 1fr; }
  .note-actions .btn { flex: 1 1 auto; }
}

/* ---------- print (screen only; PDFs use their own print file) ---------- */
@media print {
  .site-header, .site-footer, .note-actions, .note-pager, .theme-toggle { display: none !important; }
  body { background: #fff; }
}

/* ============================================================
   v31: nav dropdown + mobile hamburger (mirrors src/index.css),
   back control (#26), and the "Notes by MS" section (#24).
   ============================================================ */
.nav-item { position: relative; display: inline-flex; }
.nav-caret { font-size: 0.7em; margin-left: 5px; opacity: 0.75; }
.nav-panel {
  position: absolute; top: 100%; left: 0; min-width: 230px;
  max-height: min(70vh, 640px); overflow-y: auto;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-lift);
  padding: 8px; z-index: 60;
  opacity: 0; visibility: hidden; transform: translateY(-4px);
  transition: opacity 0.16s ease, transform 0.16s ease, visibility 0.16s;
}
.nav-dropdown:hover .nav-panel,
.nav-dropdown:focus-within .nav-panel {
  opacity: 1; visibility: visible; transform: translateY(0);
}
.nav-panel-title {
  font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--muted); margin: 4px 10px 6px;
}
.main-nav .nav-panel a.nav-cat-link,
.main-nav .nav-cats-mobile a.nav-cat-link {
  display: block; padding: 9px 10px; border-radius: 8px; color: var(--text);
  font-size: 0.92rem; font-weight: 600;
}
.main-nav .nav-panel a.nav-cat-link:hover,
.main-nav .nav-cats-mobile a.nav-cat-link:hover { background: var(--soft-bg); color: var(--accent-dark); }

/* Mega menus (Nov 2, 2026) + responsive fix (Nov 3, 2026):
   same rules as src/index.css — full desktop: contained wide
   panel; medium range (761-1024px): OLD simple single-column
   list; phones: panels hidden, cats-mobile blocks instead.
   Future-proofing rule: any new nav menu MUST use .nav-panel,
   and .mega-panel + .mega-grid only for desktop cards. */
.nav-panel.mega-panel.mega-right { left: auto; right: 0; }
.mega-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 12px; }
.main-nav .nav-panel a.mega-card {
  display: block; padding: 13px 15px; border: 1px solid var(--border, #ece8df);
  border-radius: 12px; background: var(--paper); color: var(--text);
}
.main-nav .nav-panel a.mega-card:hover { border-color: var(--accent); background: var(--card); text-decoration: none; }
.mega-card-name { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 0.98rem; }
.mega-dot { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.mega-card-desc { display: block; font-size: 0.84rem; color: var(--muted); margin-top: 5px; line-height: 1.45; }
.mega-card-action { display: block; font-size: 0.8rem; color: var(--accent); font-weight: 700; margin-top: 7px; }
.main-nav .nav-panel a.mega-foot {
  display: block; margin-top: 16px; padding-top: 12px;
  border-top: 1px solid var(--border, #ece8df);
  font-weight: 700; font-size: 0.94rem; color: var(--text);
}
.main-nav .nav-panel a.mega-foot:hover { color: var(--accent); text-decoration: none; }
@media (min-width: 1025px) {
  /* FULL-WIDTH mega panel, anchored to the sticky header — mirror of
     the SPA rule in src/index.css (Nov 5 fix). Nov 20 bug: static
     pages never add .open, so the SPA's .nav-dropdown.open selector
     never fired here and panels stayed 720px wide, anchored to the
     trigger item. Static panels open on :hover/:focus-within, so the
     full-width rule uses those selectors instead of .open. Items go
     static, panel left:0 + right:0 spans edge to edge from any
     trigger; content stays centred at ~1100px via side padding.
     Selector (0,4,0) beats .mega-panel.mega-right (0,3,0), so Games
     goes full-width too. */
  .nav-item.nav-dropdown { position: static; }
  .nav-dropdown:hover .nav-panel.mega-panel,
  .nav-dropdown:focus-within .nav-panel.mega-panel {
    left: 0; right: 0; transform: translateY(0);
    width: auto; max-width: none;
    /* Hover bridge (mirrors SPA Nov 19): panel pulled up 14px (and
       padding-top raised the same) so the cursor never crosses a
       dead strip between the link and the panel. */
    margin-top: -14px;
    padding: 36px max(26px, calc((100% - 1100px) / 2)) 18px;
    border-top: 3px solid var(--accent); border-radius: 0 0 16px 16px;
    max-height: min(640px, calc(100dvh - 110px));
    overscroll-behavior: contain;
  }
}
@media (min-width: 761px) and (max-width: 1024px) {
  /* Medium range: mega panels read as the OLD simple dropdown
     list — single column, name only, plain rows. Higher
     specificity + 1fr template make multi-column impossible here. */
  .main-nav .nav-panel .mega-grid { display: block; grid-template-columns: 1fr; }
  .main-nav .nav-panel a.mega-card {
    border: 0; background: transparent; padding: 9px 10px; border-radius: 8px;
  }
  .mega-card-desc, .mega-card-action { display: none; }
}
.nav-cats-mobile { display: none; }
.nav-toggle {
  display: none; flex: none; width: 40px; height: 40px; border-radius: 10px;
  align-items: center; justify-content: center;
  background: transparent; border: 1px solid var(--border-strong);
  color: var(--muted); cursor: pointer;
}
.nav-toggle:hover { color: var(--accent); border-color: var(--accent); }
.nav-toggle svg { display: block; }

@media (max-width: 760px) {
  .nav-toggle { display: inline-flex; }
  .main-nav {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 2px;
    background: var(--paper); border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-lift); padding: 10px 16px 14px; z-index: 55;
  }
  .main-nav.open { display: flex; }
  .main-nav a { display: flex; align-items: center; min-height: 44px; padding: 10px 8px; }
  .main-nav .nav-item { display: block; }
  .main-nav .nav-panel { display: none; }
  .nav-cats-mobile { display: block; border-top: 1px solid var(--border); margin-top: 6px; padding-top: 8px; }
  .header-inner { position: relative; }
}

.back-row { margin: 0 0 6px; }
.back-link {
  display: inline-flex; align-items: center; gap: 7px; min-height: 40px;
  padding: 6px 14px 6px 10px; border: 1px solid var(--border-strong);
  border-radius: 999px; background: var(--card);
  color: var(--text); font-weight: 600; font-size: 0.9rem; text-decoration: none;
}
.back-link:hover { border-color: var(--accent); color: var(--accent-dark); text-decoration: none; }
.back-link span[aria-hidden] { font-size: 1.05rem; line-height: 1; }

.ms-notes-list { display: flex; flex-direction: column; gap: 10px; }
.ms-note {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; color: var(--text); text-decoration: none;
}
.ms-note:hover { border-color: var(--accent); text-decoration: none; }
.ms-note-title { font-weight: 700; flex: 1 1 220px; }
.ms-note-meta { color: var(--muted); font-size: 0.85rem; }
.ms-note-dl { color: var(--accent-dark); font-weight: 700; font-size: 0.9rem; }

@media print {
  .back-row { display: none !important; }
}

/* ============================================================
   v32: Learn AI — promo card (on /notes), prompt gallery cards,
   copy buttons and category footers. Same design tokens.
   ============================================================ */
.ai-promo-card {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--border-strong);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-lg); padding: 20px 22px;
  color: var(--text); box-shadow: var(--shadow);
}
.ai-promo-card:hover { text-decoration: none; box-shadow: var(--shadow-lift); border-color: var(--accent); }
.ai-promo-text { display: flex; flex-direction: column; gap: 5px; flex: 1 1 320px; }
.ai-promo-eyebrow {
  font-family: var(--font-mono); font-size: 0.7rem; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent-ink);
}
.ai-promo-title { font-family: var(--font-display); font-size: 1.3rem; font-weight: 700; letter-spacing: -0.01em; line-height: 1.25; }
.ai-promo-line { color: var(--muted); font-size: 0.93rem; line-height: 1.55; }
.ai-promo-cta { font-weight: 700; color: var(--accent-dark); white-space: nowrap; }

.cat-nav { margin-top: 4px; }
.chip-link { color: var(--text); }
.chip-link:hover { border-color: var(--accent); color: var(--accent-dark); text-decoration: none; }
.cat-en { color: var(--muted); font-weight: 500; }
section[id] { scroll-margin-top: 84px; }

.prompt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.prompt-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 18px; display: flex; flex-direction: column; gap: 10px;
  box-shadow: var(--shadow);
}
.prompt-card h3 { font-family: var(--font-display); font-size: 1.08rem; margin: 0; line-height: 1.3; }
.prompt-gives { margin: 0; color: var(--muted); font-size: 0.89rem; line-height: 1.5; }
.prompt-box {
  background: var(--soft-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; flex: 1;
}
.prompt-box p {
  margin: 0; font-size: 0.9rem; line-height: 1.65; color: var(--prose);
  overflow-wrap: break-word;
}
.copy-btn {
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--ink); color: #fff; border: 1px solid var(--ink);
  border-radius: 8px; padding: 8px 16px; min-height: 40px;
  font-size: 0.88rem; font-weight: 600; cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
:root[data-theme="dark"] .copy-btn { background: #263354; border-color: #263354; }
.copy-btn:hover { background: var(--ink-2); }
:root[data-theme="dark"] .copy-btn:hover { background: #2f4066; }
.copy-btn.copied { background: var(--accent); border-color: var(--accent); color: #fff; }

.cat-foot {
  display: flex; align-items: stretch; gap: 12px; flex-wrap: wrap; margin-top: 16px;
}
.cat-tool {
  flex: 1 1 300px; display: flex; flex-direction: column; gap: 3px;
  background: var(--accent-soft); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px 16px; color: var(--text);
}
.cat-tool:hover { text-decoration: none; border-color: var(--accent); }
.cat-tool strong { color: var(--accent-dark); font-size: 0.98rem; }
.cat-tool span { color: var(--muted); font-size: 0.88rem; line-height: 1.5; }
.cat-tool .cat-foot-label {
  font-family: var(--font-mono); font-size: 0.66rem; font-weight: 600;
  letter-spacing: 0.13em; text-transform: uppercase; color: var(--accent-ink);
}
.cat-channel {
  flex: 1 1 240px; display: inline-flex; align-items: center;
  border: 1px dashed var(--border-strong); border-radius: var(--radius-lg);
  padding: 14px 16px; color: var(--text); font-weight: 600; font-size: 0.93rem; line-height: 1.5;
}
.cat-channel:hover { text-decoration: none; border-color: var(--accent); color: var(--accent-dark); }

.use-steps {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 18px 22px 6px; box-shadow: var(--shadow); color: var(--prose);
}
.use-steps p { margin: 0 0 12px; line-height: 1.6; }
.use-steps strong { color: var(--text); }

@media (max-width: 720px) {
  .prompt-grid { grid-template-columns: 1fr; }
  .ai-promo-card { padding: 16px; }
}

@media print {
  .copy-btn, .cat-nav { display: none !important; }
}

/* ============================================================
   v33 — Learn AI language pairs + toggle, code-block Copy.
   Paired content: both variants ship in the HTML. English is
   the default (.lg-ur hidden); <html data-lang="ur"> — set
   pre-paint from localStorage 'ts-learn-lang' — flips them.
   Prompt texts and code are never paired, they never swap.
   ============================================================ */
.lg-ur { display: none !important; }
:root[data-lang="ur"] .lg-en { display: none !important; }
:root[data-lang="ur"] .lg-ur { display: block !important; }
:root[data-lang="ur"] span.lg-ur { display: inline !important; }

.lang-row { display: flex; justify-content: flex-end; margin: 2px 0 14px; }
.lang-toggle {
  display: inline-flex; border: 1px solid var(--border-strong); border-radius: 999px;
  overflow: hidden; background: var(--card); box-shadow: var(--shadow);
}
.lang-toggle button {
  appearance: none; border: 0; background: transparent; color: var(--muted);
  font-family: var(--font); font-size: 0.8rem; font-weight: 600;
  padding: 6px 14px; min-height: 32px; cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.lang-toggle button + button { border-left: 1px solid var(--border); }
.lang-toggle button.on { background: var(--ink); color: #fff; }
:root[data-theme="dark"] .lang-toggle button.on { background: #263354; color: #fff; }

/* Copy button on code blocks (notes lessons + Learn AI lesson) —
   the block itself is dark in BOTH themes, so one style serves both. */
.code-block { position: relative; }
.code-copy {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  font-family: var(--font-mono); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.04em;
  color: var(--code-text); background: rgba(15, 22, 38, 0.88);
  border: 1px solid rgba(230, 235, 244, 0.28); border-radius: 7px;
  padding: 5px 11px; min-height: 28px; cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.code-copy:hover { background: rgba(38, 49, 74, 0.95); border-color: rgba(230, 235, 244, 0.5); }
.code-copy.copied { background: var(--accent); border-color: var(--accent); color: #fff; }

@media print {
  .code-copy, .lang-row { display: none !important; }
}

/* ---------- Practice quiz blocks (notes lessons, Oct 2026) ----------
   Same card/border family as .sec-practice above. Green = right,
   red = wrong; no score is shown anywhere — feedback only. */
.quiz-sec .quiz-intro { color: var(--muted); font-size: 0.92rem; }
.quiz-q { margin: 0 0 22px; }
.quiz-kind {
  font-family: var(--font-mono); font-size: 0.7rem; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent-ink); margin: 0 0 6px;
}
.quiz-prompt { font-weight: 600; color: var(--text); margin: 0 0 12px; }
.quiz-num { color: var(--accent); margin-right: 4px; }
/* Dark mode (Nov 8, 2026): flame #e8490f on dark paper is 4.46:1,
   just under 4.5:1 — use the lighter dark accent #ff8a50 instead. */
:root[data-theme="dark"] .quiz-num { color: var(--accent-dark); }
.quiz-q .code-block { margin: 0 0 12px; }
.quiz-opts { display: grid; gap: 8px; margin: 0 0 10px; }
.quiz-opt {
  text-align: left; font: inherit; font-size: 0.95rem; color: var(--text);
  background: var(--card); border: 1px solid var(--border-strong);
  border-radius: var(--radius); padding: 11px 14px; cursor: pointer;
}
.quiz-opt:hover:not(:disabled) { border-color: var(--accent); }
.quiz-opt:disabled { cursor: default; opacity: 1; }
.quiz-q.answered .quiz-opt:not(.correct):not(.wrong) { opacity: 0.6; }
.quiz-opt.correct { border-color: #1a7f4b; background: rgba(26, 127, 75, 0.13); font-weight: 600; }
.quiz-opt.wrong { border-color: #c0392b; background: rgba(192, 57, 43, 0.1); }
.quiz-feedback { font-size: 0.92rem; font-weight: 600; margin: 0; }
.quiz-feedback.ok { color: #1a7f4b; }
.quiz-feedback.bad { color: #c0392b; }
/* Dark-theme sweep (Nov 9, 2026): the feedback greens/reds failed
   on dark cards — .ok was 3.46:1, .bad 3.19:1 (measured after
   answering a quiz). Lighten both to the dark-theme ok/err text
   the rest of the site uses. Borders on .quiz-opt.correct/.wrong
   already pass the 3:1 non-text rule, so they stay. */
:root[data-theme="dark"] .quiz-feedback.ok { color: #7fe0b2; }
:root[data-theme="dark"] .quiz-feedback.bad { color: #ffb4a6; }
.quiz-reset {
  font: inherit; font-size: 0.9rem; font-weight: 600; color: var(--accent-dark);
  background: none; border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: 9px 16px; cursor: pointer;
}
.quiz-reset:hover { border-color: var(--accent); }

/* ---------- Ad slot reservation (filled Nov 9, 2026, owner order:
   ads on ALL pages) ----------
   Empty slot = display:none: zero height, no gap, no blank box.
   public/ts-runtime.js fills the notes-lesson slot at runtime
   with the 320x50 Adsterra banner (for every visitor — Decline
   stops analytics, not ads). A FILLED slot reserves its 50px
   height from first paint, so the ad never pushes the quiz down
   when it loads; overflow is clipped so a 320px banner can never
   cause a horizontal scrollbar on a 320px phone. */
.ad-slot-empty { display: none !important; margin: 0; padding: 0; border: 0; }
.ad-slot { margin: 24px 0; text-align: center; }
.ad-slot[data-placement="notes-lesson"] { min-height: 50px; max-width: 100%; overflow: hidden; }
.ad-slot[data-placement="notes-lesson"] iframe { max-width: 100%; display: block; margin: 0 auto; }
/* Hub + series banner (Nov 10, 2026, two-unit standard): the
   /notes hub and /notes/<series> pages carry the same 320x50
   banner the lessons do. Native (same date): measured min-height
   bands reserve its space from first paint, like the React
   .ad-native rule in src/index.css. */
.ad-slot[data-placement="notes-hub"],
.ad-slot[data-placement="notes-series"] { min-height: 50px; max-width: 100%; overflow: hidden; }
.ad-slot[data-placement="notes-hub"] iframe,
.ad-slot[data-placement="notes-series"] iframe { max-width: 100%; display: block; margin: 0 auto; }
.ad-slot[data-placement="notes-native"] { max-width: 100%; overflow: hidden; }
/* Reserved height (Nov 10, 2026 — measured): same native widget
   as the React pages — one row of pictured ads on wide slots
   (~267–296px), a 2×2 grid on narrow slots (~449–607px). The
   min-heights cover the tallest creative seen per band; a shorter
   creative leaves plain whitespace, never a shift. The row/grid
   switch sits at a ~650px slot (~690px viewport). */
.ad-slot[data-placement="notes-native"] .ad-native { width: 100%; min-height: 320px; }
@media (max-width: 690px) {
  .ad-slot[data-placement="notes-native"] .ad-native { min-height: 620px; }
}
@media (max-width: 420px) {
  .ad-slot[data-placement="notes-native"] .ad-native { min-height: 520px; }
}
