/* ==========================================================================
   Visual Papers — Liquid Glass Ambient, Frosted Polish, Top Corner Chrome
   (Back Pill + 3-Mode Theme Switcher: Dark | Light | Minimal) & Motion Layer
   ========================================================================== */

:root {
  --lg-scale: 1.5;
  --lg-ease-spring: cubic-bezier(0.16, 1, 0.3, 1);
  --lg-ease-float: cubic-bezier(0.37, 0, 0.63, 1);
  --lg-z-backdrop: -1;
  --lg-z-dock: 10035;
  --lg-z-chrome: 10040;

  /* Light theme defaults (warm ivory liquid glass) */
  --lg-glass-bg: rgba(255, 255, 255, 0.8);
  --lg-glass-bg-strong: rgba(255, 255, 255, 0.9);
  --lg-glass-border: rgba(255, 255, 255, 0.9);
  --lg-glass-hairline: rgba(15, 23, 42, 0.09);
  --lg-glass-shadow:
    0 18px 44px -18px rgba(15, 23, 42, 0.11),
    0 4px 14px -4px rgba(15, 23, 42, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.94);
  --lg-glass-shadow-hover:
    0 26px 56px -18px rgba(15, 23, 42, 0.16),
    0 8px 20px -6px rgba(15, 23, 42, 0.07),
    inset 0 1px 0 rgba(255, 255, 255, 0.98);
  --lg-dock-bg: rgba(255, 253, 250, 0.84);
  --lg-dock-border: rgba(255, 255, 255, 0.94);
  --lg-dock-ring: rgba(15, 23, 42, 0.11);
  --lg-dock-ink: #18202c;
  --lg-dock-muted: #526075;
  --lg-dock-pill-bg: rgba(15, 23, 42, 0.055);
  --lg-dock-active-bg: #18202c;
  --lg-dock-active-ink: #ffffff;
  --lg-dock-accent: #0369a1;
  --lg-bubble-rim: rgba(255, 255, 255, 0.84);
  --lg-bubble-tint-a: rgba(186, 230, 253, 0.34);
  --lg-bubble-tint-b: rgba(254, 215, 170, 0.25);
  --lg-bubble-tint-c: rgba(221, 214, 254, 0.25);
  --lg-bubble-shadow:
    inset 0 -6px 14px rgba(14, 116, 144, 0.12),
    inset 0 2px 6px rgba(255, 255, 255, 0.95),
    0 10px 24px -10px rgba(15, 23, 42, 0.14);
}

/* Create a clean stacking context on body so z-index: -1 sits above body's
   own background and safely behind all flow content & sticky headers. */
body {
  isolation: isolate;
}

/* ==========================================================================
   1. Fixed Ambient Liquid-Glass Backdrop (Aurora Blobs + Floating Bubbles)
   ========================================================================== */
.lg-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--lg-z-backdrop);
  overflow: hidden;
  pointer-events: none;
  contain: layout style paint;
}

.lg-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(78px);
  opacity: 0.28;
  will-change: transform;
  transform: translate3d(0, 0, 0);
}

.lg-blob-1 {
  width: min(56vw, 560px);
  height: min(56vw, 560px);
  top: -140px;
  left: -120px;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.54), rgba(14, 165, 233, 0) 70%);
  animation: lg-blob-drift-a calc(20s * var(--lg-scale, 1.5)) var(--lg-ease-float) infinite alternate;
}

.lg-blob-2 {
  width: min(60vw, 600px);
  height: min(60vw, 600px);
  top: 18%;
  right: -180px;
  background: radial-gradient(circle, rgba(251, 146, 60, 0.44), rgba(234, 88, 12, 0) 70%);
  animation: lg-blob-drift-b calc(24s * var(--lg-scale, 1.5)) var(--lg-ease-float) infinite alternate;
}

.lg-blob-3 {
  width: min(52vw, 520px);
  height: min(52vw, 520px);
  bottom: -160px;
  left: 24%;
  background: radial-gradient(circle, rgba(167, 139, 250, 0.42), rgba(52, 211, 153, 0.24) 48%, rgba(16, 185, 129, 0) 72%);
  animation: lg-blob-drift-c calc(27s * var(--lg-scale, 1.5)) var(--lg-ease-float) infinite alternate;
}

html[data-lg-has-aurora="true"] .lg-blob {
  opacity: 0.14;
}

@keyframes lg-blob-drift-a {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(76px, 56px, 0) scale(1.12); }
}
@keyframes lg-blob-drift-b {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(-84px, 64px, 0) scale(1.09); }
}
@keyframes lg-blob-drift-c {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(58px, -70px, 0) scale(1.14); }
}

/* Translucent Floating Glass Soap-Bubbles */
.lg-bubble {
  position: absolute;
  bottom: -140px;
  left: var(--lg-left, 50%);
  width: var(--lg-size, 48px);
  height: var(--lg-size, 48px);
  border-radius: 50%;
  border: 1px solid var(--lg-bubble-rim);
  background:
    radial-gradient(circle at 28% 24%, rgba(255, 255, 255, 0.88) 0%, rgba(255, 255, 255, 0.24) 22%, rgba(255, 255, 255, 0) 48%),
    radial-gradient(circle at 74% 78%, var(--lg-bubble-tint-b) 0%, rgba(255, 255, 255, 0) 54%),
    radial-gradient(circle at 32% 72%, var(--lg-bubble-tint-c) 0%, rgba(255, 255, 255, 0) 58%),
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.04) 45%, var(--lg-bubble-tint-a) 100%);
  box-shadow: var(--lg-bubble-shadow);
  opacity: var(--lg-opacity, 0.56);
  will-change: transform;
  animation: lg-bubble-rise calc(var(--lg-dur, 24s) * var(--lg-scale, 1.5)) linear var(--lg-delay, 0s) infinite;
}

.lg-bubble::before {
  content: "";
  position: absolute;
  top: 15%;
  left: 19%;
  width: 30%;
  height: 18%;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.92) 0%, rgba(255, 255, 255, 0) 75%);
  transform: rotate(-28deg);
}

.lg-bubble::after {
  content: "";
  position: absolute;
  bottom: 16%;
  right: 20%;
  width: 14%;
  height: 14%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.65) 0%, rgba(255, 255, 255, 0) 75%);
}

@keyframes lg-bubble-rise {
  0%   { transform: translate3d(0, 0, 0) scale(0.92); }
  25%  { transform: translate3d(var(--lg-sway, 24px), -32vh, 0) scale(1.03); }
  50%  { transform: translate3d(calc(var(--lg-sway, 24px) * -0.7), -64vh, 0) scale(0.97); }
  75%  { transform: translate3d(calc(var(--lg-sway, 24px) * 0.85), -96vh, 0) scale(1.04); }
  100% { transform: translate3d(0, -132vh, 0) scale(0.94); }
}

/* ==========================================================================
   2. Top-Left Back Pill (.lg-back-btn) & Top-Right Theme Switcher (.lg-theme-pill)
   ========================================================================== */
.lg-mobile-bar {
  display: none;
}

.lg-back-btn,
.lg-theme-pill {
  position: fixed;
  top: 14px;
  z-index: var(--lg-z-chrome);
  background: var(--lg-dock-bg);
  backdrop-filter: blur(20px) saturate(165%);
  -webkit-backdrop-filter: blur(20px) saturate(165%);
  border: 1px solid var(--lg-dock-border);
  box-shadow:
    0 12px 32px -10px rgba(15, 23, 42, 0.22),
    0 0 0 1px var(--lg-dock-ring),
    inset 0 1px 0 rgba(255, 255, 255, 0.32);
  color: var(--lg-dock-ink);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  line-height: 1;
  letter-spacing: 0;
  user-select: none;
  box-sizing: border-box;
  transition:
    transform calc(0.28s * var(--lg-scale, 1.5)) var(--lg-ease-spring),
    box-shadow calc(0.28s * var(--lg-scale, 1.5)) var(--lg-ease-spring),
    border-color 0.2s ease,
    background-color 0.25s ease,
    color 0.2s ease;
}

.lg-back-btn {
  left: 16px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 7px 13px;
  border-radius: 999px;
  color: var(--lg-dock-ink) !important;
  text-decoration: none !important;
  font-size: 12.5px;
  font-weight: 650;
  white-space: nowrap;
}

.lg-back-arrow {
  display: inline-block;
  font-size: 13.5px;
  transition: transform calc(0.24s * var(--lg-scale, 1.5)) var(--lg-ease-spring);
}

.lg-back-btn:hover {
  border-color: var(--lg-dock-accent);
  color: var(--lg-dock-accent) !important;
  text-decoration: none !important;
  transform: translate3d(0, -1px, 0);
}

.lg-back-btn:hover .lg-back-arrow {
  transform: translate3d(-2px, 0, 0);
}

.lg-theme-pill {
  right: 16px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  min-height: 34px;
  padding: 3px;
  border-radius: 999px;
}

.lg-theme-pill *,
.lg-back-btn * {
  box-sizing: border-box;
}

.lg-theme-btn {
  appearance: none;
  -webkit-appearance: none;
  border: 0 !important;
  margin: 0;
  min-height: 28px !important;
  padding: 5px 10px !important;
  border-radius: 999px !important;
  background: transparent !important;
  color: var(--lg-dock-muted) !important;
  font: 650 11.5px/1 "Inter", "Segoe UI", system-ui, -apple-system, sans-serif !important;
  cursor: pointer;
  white-space: nowrap;
  transition:
    background-color 0.22s var(--lg-ease-spring),
    color 0.2s ease,
    box-shadow 0.22s ease,
    transform 0.22s var(--lg-ease-spring) !important;
}

.lg-theme-btn:hover {
  color: var(--lg-dock-ink) !important;
  background: rgba(127, 127, 127, 0.13) !important;
}

.lg-theme-btn[aria-pressed="true"] {
  background: var(--lg-dock-active-bg) !important;
  color: var(--lg-dock-active-ink) !important;
  box-shadow: 0 3px 10px -2px rgba(15, 23, 42, 0.3);
}

.lg-back-btn:focus-visible,
.lg-theme-btn:focus-visible,
.lg-seg-btn:focus-visible {
  outline: 2px solid var(--lg-dock-accent) !important;
  outline-offset: 2px !important;
}

/* ==========================================================================
   3. Safe Header & Sticky Navbar Clearance (Desktop 1280px & Mobile 390px)
      Guarantees .lg-back-btn and .lg-theme-pill never block brands or links,
      and hides duplicate page-local Back & Motion buttons once active.
   ========================================================================== */
/* Hide duplicate page-local Back links & Motion toggles when Liquid Glass is active
   (elements stay in DOM so liquid-glass.js still syncs external motion handlers) */
html[data-lg-mode] #motion-toggle,
html[data-lg-mode] #global-pause-btn,
html[data-lg-mode] #pause-motion,
html[data-lg-mode] #motion,
html[data-lg-mode] #map-motion,
html[data-lg-mode] .motion-btn,
html[data-lg-mode] .topline,
html[data-lg-mode] .topline > a[href="../"],
html[data-lg-mode] .nav-actions a.nav-link[href="../"],
html[data-lg-mode] .lock-back-link,
html[data-lg-root="true"][data-lg-mode] .nav-actions a.nav-link[href="https://git-siddhesh.github.io/"] {
  display: none !important;
}

/* Non-sticky top headers on hnet, visual-design-atlas, skill-study, ldm-flow & serving-systems */
html[data-lg-root="false"] .journey > .masthead,
html[data-lg-root="false"] body > header:not(.topbar):not(.masthead):not(.mast):not(.nav) {
  padding-top: 64px;
}

/* Desktop wide clearance: keep sticky navbars at top while clearing corner pills */
@media (min-width: 1080px) {
  /* Floating pill navs (index.html, inbox/index.html, papers/index.html) */
  html[data-lg-root="true"] .nav {
    max-width: 1480px;
    padding-left: max(20px, 142px);
    padding-right: max(20px, 212px);
  }
  html[data-lg-root="false"] .nav {
    max-width: 1520px;
    padding-left: max(20px, 168px);
    padding-right: max(20px, 212px);
  }

  /* Full-width sticky headers (routing, decision-models, diffusion-models, serving-systems) */
  html[data-lg-root="false"] .topbar,
  html[data-lg-root="false"] body > .masthead,
  html[data-lg-root="false"] .mast,
  html[data-lg-root="false"] .example-ribbon {
    padding-left: 168px;
    padding-right: 212px;
  }

  html[data-lg-root="false"] .topbar .topbar-inner,
  html[data-lg-root="false"] body > .masthead .mast-wrap,
  html[data-lg-root="false"] .mast .mast-row {
    padding-left: 12px;
    padding-right: 12px;
  }
}

/* Tablet & mobile clearance (including 390px): place nav content cleanly below pills */
@media (max-width: 1079px) {
  html[data-lg-root] .nav {
    top: 54px;
    margin-top: 54px;
    padding-left: 14px;
    padding-right: 14px;
  }

  html[data-lg-root="false"] .topbar,
  html[data-lg-root="false"] body > .masthead,
  html[data-lg-root="false"] .mast,
  html[data-lg-root="false"] .example-ribbon {
    padding-top: 54px;
  }

  /* Keep hnet top chrome sticky on tablet/mobile so scrolled content glides behind header */
  html[data-lg-root="false"] .journey > .masthead {
    position: sticky;
    top: 0;
    z-index: 10025;
    max-width: none;
    background: var(--lg-dock-bg);
    backdrop-filter: blur(16px) saturate(150%);
    -webkit-backdrop-filter: blur(16px) saturate(150%);
    padding-top: 52px;
  }
}

@media (max-width: 640px) {
  .lg-mobile-bar {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 48px;
    z-index: 10035;
    background: var(--lg-dock-bg);
    backdrop-filter: blur(18px) saturate(160%);
    -webkit-backdrop-filter: blur(18px) saturate(160%);
    border-bottom: 1px solid var(--lg-glass-hairline);
    pointer-events: auto;
  }
  .lg-back-btn {
    top: 10px;
    left: 10px;
    min-height: 30px;
    padding: 6px 10px;
    font-size: 11.5px;
    gap: 5px;
  }
  .lg-theme-pill {
    top: 10px;
    right: 10px;
    min-height: 30px;
    padding: 2px;
    gap: 2px;
  }
  .lg-theme-btn {
    min-height: 26px !important;
    padding: 5px 8px !important;
    font-size: 11px !important;
  }

  html[data-lg-root] .nav {
    top: 48px;
    margin-top: 48px;
    padding-left: 10px;
    padding-right: 10px;
  }

  html[data-lg-root="false"] .topbar,
  html[data-lg-root="false"] body > .masthead,
  html[data-lg-root="false"] .mast,
  html[data-lg-root="false"] .example-ribbon {
    padding-top: 48px;
  }

  html[data-lg-root="false"] .journey > .masthead {
    position: sticky;
    top: 0;
    z-index: 10025;
    max-width: none;
    background: var(--lg-dock-bg);
    backdrop-filter: blur(16px) saturate(150%);
    -webkit-backdrop-filter: blur(16px) saturate(150%);
    padding-top: 48px;
    padding-bottom: 10px;
  }

  html[data-lg-root="false"] body > header:not(.topbar):not(.masthead):not(.mast):not(.nav) {
    padding-top: 56px;
  }
}

/* ==========================================================================
   4. THEME MODE A — DARK MODE (Cosmic-Obsidian / Indigo-Violet)
      Uses html[data-lg-mode="dark"] (0,1,1) to cleanly beat :root (0,1,0)
      regardless of stylesheet load order across all 9 pages.
   ========================================================================== */
html[data-lg-mode="dark"] {
  color-scheme: dark;

  /* Core semantic tokens across all 9 pages */
  --bg: #070914;
  --bg-alt: #0c1020;
  --bg-warm: #0e1326;
  --paper: #070914;
  --surface: #101526;
  --surface-2: #151c33;
  --panel: #101526;
  --card: #101526;
  --well: #0b1020;
  --canvas-bg: #0b1020;
  --canvas-well: #080c19;

  /* Crisp WCAG AA/AAA dark-mode typography */
  --text: #eef2ff;
  --text-body: #cbd5e1;
  --text-dim: #94a3b8;
  --text-muted: #94a3b8;
  --ink: #eef2ff;
  --ink-body: #cbd5e1;
  --ink-muted: #94a3b8;
  --fg: #eef2ff;
  --muted: #94a3b8;
  --sub: #94a3b8;
  --dim: #94a3b8;
  --soft: #94a3b8;

  /* Glass & hairline borders */
  --glass: rgba(16, 21, 38, 0.78);
  --glass-strong: rgba(20, 27, 48, 0.9);
  --glass-soft: rgba(16, 21, 38, 0.56);
  --glass-border: rgba(167, 139, 250, 0.24);
  --border: rgba(148, 163, 184, 0.22);
  --border-bright: rgba(148, 163, 184, 0.36);
  --border-cool: rgba(148, 163, 184, 0.22);
  --hairline: rgba(148, 163, 184, 0.18);
  --hairline-strong: rgba(148, 163, 184, 0.3);
  --line: rgba(148, 163, 184, 0.24);
  --edge: rgba(148, 163, 184, 0.24);

  /* Luminous cosmic accents */
  --accent-violet: #a78bfa;
  --violet: #a78bfa;
  --purple: #a78bfa;
  --accent-blue: #38bdf8;
  --cyan: #38bdf8;
  --blue: #60a5fa;
  --deep: #60a5fa;
  --sky: #60a5fa;
  --accent-orange: #fb923c;
  --accent-orange-bright: #fb923c;
  --gar: #fb923c;
  --gar-fill: #f97316;
  --new: #fb923c;
  --accent-emerald: #34d399;
  --emerald: #34d399;
  --fine: #34d399;
  --green: #34d399;
  --accent-teal: #2dd4bf;
  --teal: #2dd4bf;
  --lime: #86efac;
  --accent-amber: #fbbf24;
  --accent-gold: #fbbf24;
  --gold: #fbbf24;
  --gold-fill: #f59e0b;
  --amber: #fbbf24;
  --yellow: #fbbf24;
  --accent-rose: #fb7185;
  --coral: #fb7185;
  --rose: #fb7185;
  --red: #fb7185;
  --pink: #e879f9;
  --magenta: #e879f9;
  --old: #a5b4fc;
  --slate: #94a3b8;
  --resultant: #f8fafc;

  /* Dark translucent badge & callout tints */
  --tint-cyan: rgba(56, 189, 248, 0.14);
  --tint-gar: rgba(251, 146, 60, 0.15);
  --tint-gold: rgba(251, 191, 36, 0.14);
  --tint-coral: rgba(251, 113, 133, 0.15);
  --tint-emerald: rgba(52, 211, 153, 0.14);
  --tint-slate: rgba(148, 163, 184, 0.14);

  --shadow-glass:
    0 22px 52px -18px rgba(2, 4, 14, 0.72),
    0 4px 16px -4px rgba(2, 4, 14, 0.45),
    inset 0 1px 0 rgba(167, 139, 250, 0.16);
  --shadow-hover:
    0 30px 68px -18px rgba(2, 4, 14, 0.84),
    0 8px 24px -6px rgba(167, 139, 250, 0.2),
    inset 0 1px 0 rgba(196, 181, 253, 0.24);

  /* Liquid-glass chrome tokens (Dark) */
  --lg-glass-bg: rgba(16, 21, 38, 0.78);
  --lg-glass-bg-strong: rgba(21, 28, 50, 0.88);
  --lg-glass-border: rgba(167, 139, 250, 0.22);
  --lg-glass-hairline: rgba(148, 163, 184, 0.18);
  --lg-glass-shadow:
    0 20px 48px -18px rgba(2, 4, 14, 0.65),
    0 4px 16px -4px rgba(2, 4, 14, 0.38),
    inset 0 1px 0 rgba(196, 181, 253, 0.14);
  --lg-glass-shadow-hover:
    0 28px 60px -18px rgba(2, 4, 14, 0.76),
    0 8px 24px -6px rgba(167, 139, 250, 0.2),
    inset 0 1px 0 rgba(196, 181, 253, 0.22);
  --lg-dock-bg: rgba(13, 18, 34, 0.86);
  --lg-dock-border: rgba(167, 139, 250, 0.28);
  --lg-dock-ring: rgba(2, 4, 14, 0.62);
  --lg-dock-ink: #eef2ff;
  --lg-dock-muted: #94a3b8;
  --lg-dock-pill-bg: rgba(167, 139, 250, 0.11);
  --lg-dock-active-bg: #a78bfa;
  --lg-dock-active-ink: #090b18;
  --lg-dock-accent: #38bdf8;
  --lg-bubble-rim: rgba(196, 181, 253, 0.34);
  --lg-bubble-tint-a: rgba(167, 139, 250, 0.2);
  --lg-bubble-tint-b: rgba(56, 189, 248, 0.16);
  --lg-bubble-tint-c: rgba(251, 146, 60, 0.12);
  --lg-bubble-shadow:
    inset 0 -6px 16px rgba(167, 139, 250, 0.18),
    inset 0 2px 7px rgba(224, 242, 254, 0.32),
    0 12px 28px -10px rgba(2, 4, 14, 0.6);
}

html[data-lg-mode="dark"],
html[data-lg-mode="dark"] body {
  background: #070914;
  background-image: radial-gradient(1200px 680px at 50% -8%, #151b38 0%, #070914 64%);
  color: #cbd5e1;
}

html[data-lg-mode="dark"] .lg-blob {
  opacity: 0.26;
}
html[data-lg-mode="dark"] .lg-blob-1 {
  background: radial-gradient(circle, rgba(167, 139, 250, 0.46), rgba(109, 40, 217, 0) 70%);
}
html[data-lg-mode="dark"] .lg-blob-2 {
  background: radial-gradient(circle, rgba(56, 189, 248, 0.42), rgba(2, 132, 199, 0) 70%);
}
html[data-lg-mode="dark"] .lg-blob-3 {
  background: radial-gradient(circle, rgba(251, 146, 60, 0.3), rgba(167, 139, 250, 0.24) 48%, rgba(15, 23, 42, 0) 72%);
}
html[data-lg-mode="dark"] .lg-bubble::before {
  background: radial-gradient(ellipse at center, rgba(224, 231, 255, 0.72) 0%, rgba(224, 231, 255, 0) 75%);
}

/* Dark-mode overrides for hardcoded light surfaces across pages */
html[data-lg-mode="dark"] .aurora-stage {
  background: radial-gradient(1200px 760px at 50% -10%, #161b3a 0%, #070914 66%);
}
html[data-lg-mode="dark"] .nav-glass,
html[data-lg-mode="dark"] .topbar,
html[data-lg-mode="dark"] body > .masthead,
html[data-lg-mode="dark"] .mast,
html[data-lg-mode="dark"] .example-ribbon {
  background: rgba(12, 16, 32, 0.84);
  border-color: rgba(167, 139, 250, 0.22);
  color: #eef2ff;
}
html[data-lg-mode="dark"] .nav-link:hover,
html[data-lg-mode="dark"] .nav-link.active {
  background: rgba(167, 139, 250, 0.14);
  color: #eef2ff;
}
html[data-lg-mode="dark"] .motion-btn,
html[data-lg-mode="dark"] .pill-btn,
html[data-lg-mode="dark"] .f-pill,
html[data-lg-mode="dark"] .search-input,
html[data-lg-mode="dark"] .pw-input,
html[data-lg-mode="dark"] .schema-jump-btn,
html[data-lg-mode="dark"] .pause-btn,
html[data-lg-mode="dark"] .chapter-nav a {
  background: rgba(16, 21, 38, 0.88);
  color: #eef2ff;
  border-color: rgba(148, 163, 184, 0.3);
}
html[data-lg-mode="dark"] .f-pill.active,
html[data-lg-mode="dark"] .mode-tab.active {
  background: #a78bfa;
  color: #090b18;
  border-color: #a78bfa;
}
html[data-lg-mode="dark"] .mode-switch,
html[data-lg-mode="dark"] .chip,
html[data-lg-mode="dark"] .feature-list code {
  background: rgba(148, 163, 184, 0.12);
  border-color: rgba(148, 163, 184, 0.22);
  color: #cbd5e1;
}
html[data-lg-mode="dark"] .card::before {
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 0%), rgba(167, 139, 250, 0.18), rgba(167, 139, 250, 0) 62%);
}
html[data-lg-mode="dark"] .card:hover {
  border-color: rgba(167, 139, 250, 0.44);
}
html[data-lg-mode="dark"] h1 .hl {
  background: linear-gradient(115deg, #c4b5fd 0%, #38bdf8 52%, #fb923c 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
html[data-lg-mode="dark"] .featured-preview,
html[data-lg-mode="dark"] .preview-bar,
html[data-lg-mode="dark"] .planned-banner,
html[data-lg-mode="dark"] .flow-strip,
html[data-lg-mode="dark"] .flow-node,
html[data-lg-mode="dark"] .lock-card,
html[data-lg-mode="dark"] .chapter-rail {
  background: rgba(16, 21, 38, 0.88);
  border-color: rgba(167, 139, 250, 0.24);
  color: #cbd5e1;
}
html[data-lg-mode="dark"] .lock-orb {
  background: linear-gradient(145deg, #1b2442, #101526);
  border-color: rgba(167, 139, 250, 0.34);
  color: #eef2ff;
}
html[data-lg-mode="dark"] .lock-eyebrow,
html[data-lg-mode="dark"] .lock-back-link,
html[data-lg-mode="dark"] .brand-sub,
html[data-lg-mode="dark"] .planned-pill,
html[data-lg-mode="dark"] .planned-banner-ico {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.32);
}
html[data-lg-mode="dark"] .lock-eyebrow,
html[data-lg-mode="dark"] .lock-back-link {
  background: rgba(16, 21, 38, 0.85);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.3);
}
html[data-lg-mode="dark"] .unlock-btn {
  background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 55%, #0284c7 100%);
}
html[data-lg-mode="dark"] .kicker,
html[data-lg-mode="dark"] .badge-derived {
  background: rgba(56, 189, 248, 0.14);
  border-color: rgba(56, 189, 248, 0.34);
  color: #38bdf8;
}
html[data-lg-mode="dark"] .badge-real {
  background: rgba(52, 211, 153, 0.14);
  border-color: rgba(52, 211, 153, 0.34);
  color: #34d399;
}

/* Dark mode for hnet, serving-systems & visual-design-atlas hardcoded light surfaces */
html[data-lg-mode="dark"] :where(
  .lab,
  .promise,
  .overview,
  .official-figure,
  .official-panel,
  .reference-chapter,
  .source-scope,
  .process-route span,
  .fixture-warning,
  .hierarchy-trace,
  .everyday,
  .equation-scroll,
  .process-table,
  .story-figure,
  .story-lab,
  .official,
  .reference-tier,
  .mechanism-article,
  .analogy,
  .notice,
  .example,
  .controls,
  details
) {
  background: rgba(16, 21, 38, 0.84);
  border-color: rgba(148, 163, 184, 0.24);
  color: #cbd5e1;
}
html[data-lg-mode="dark"] :where(
  .journey button,
  .journey select,
  .story-lab button,
  .story-lab select,
  .example button,
  .example select,
  body > header button,
  .world-actions button
) {
  background: #172038;
  border-color: rgba(148, 163, 184, 0.34);
  color: #eef2ff;
}
html[data-lg-mode="dark"] .journey button.primary {
  background: #7c3aed;
  border-color: #a78bfa;
  color: #ffffff;
}
html[data-lg-mode="dark"] :where(
  .journey code,
  .byte-ledger > div,
  .reading-cell,
  .selection-cell,
  .new-part,
  .old-part,
  .head-track,
  .process-table caption,
  .process-table thead th,
  .process-table tbody th,
  .restore-table tbody tr:last-child,
  .flow-box,
  .piece,
  .takeaway,
  .address-stop,
  .cell-row span,
  .timeline-cells span,
  .state-stamp,
  .equation,
  .token,
  .diagram,
  .screen,
  .semantic-screen,
  .story-copy,
  .world-caption .contract,
  .recap-list .recap-number
) {
  background: #131b30;
  border-color: rgba(148, 163, 184, 0.28);
  color: #e2e8f0;
}
html[data-lg-mode="dark"] .takeaway,
html[data-lg-mode="dark"] .prediction,
html[data-lg-mode="dark"] .step-label,
html[data-lg-mode="dark"] .readout,
html[data-lg-mode="dark"] .article-header .eyebrow,
html[data-lg-mode="dark"] .reference-tier > summary,
html[data-lg-mode="dark"] .story-lab label,
html[data-lg-mode="dark"] .story-lab output,
html[data-lg-mode="dark"] .reader-note,
html[data-lg-mode="dark"] .tiny-label,
html[data-lg-mode="dark"] .source-link {
  color: #cbd5e1 !important;
}
html[data-lg-mode="dark"] .step-label,
html[data-lg-mode="dark"] .article-header .eyebrow,
html[data-lg-mode="dark"] .reference-tier > summary,
html[data-lg-mode="dark"] .example-ribbon strong {
  color: #38bdf8 !important;
}
html[data-lg-mode="dark"] .paper-box,
html[data-lg-mode="dark"] .fine-box,
html[data-lg-mode="dark"] .deep-box,
html[data-lg-mode="dark"] .radix-drawing rect,
html[data-lg-mode="dark"] .state-node,
html[data-lg-mode="dark"] .tensor-cell rect {
  fill: #151e36;
  stroke: rgba(167, 139, 250, 0.45);
}
html[data-lg-mode="dark"] .state-active {
  fill: #1e3a6e;
  stroke: #60a5fa;
}
html[data-lg-mode="dark"] .tensor-cell.active rect {
  fill: #3d1b35;
  stroke: #e879f9;
}
html[data-lg-mode="dark"] .tensor-cell.selected rect {
  fill: #1b3664;
  stroke: #60a5fa;
}
html[data-lg-mode="dark"] .radix-drawing {
  background: #0c1224;
}
html[data-lg-mode="dark"] .radix-drawing text,
html[data-lg-mode="dark"] .mechanism-svg text,
html[data-lg-mode="dark"] .radix-svg text,
html[data-lg-mode="dark"] .diagram text,
html[data-lg-mode="dark"] .overview text,
html[data-lg-mode="dark"] .world-full .plot text,
html[data-lg-mode="dark"] .world-full .diagram-background text,
html[data-lg-mode="dark"] .world-full .diagram-overlay text {
  fill: #e2e8f0;
}
html[data-lg-mode="dark"] .diagram rect,
html[data-lg-mode="dark"] .mechanism-svg rect,
html[data-lg-mode="dark"] .radix-svg rect {
  fill: #141c33 !important;
  stroke: rgba(148, 163, 184, 0.45) !important;
}
html[data-lg-mode="dark"] .diagram text {
  fill: #eef2ff !important;
}
html[data-lg-mode="dark"] .diagram .minor {
  fill: #94a3b8 !important;
}

/* Dark Mode: visual-design-atlas SVGs & story steps */
html[data-lg-mode="dark"] .screen:not(.equation-screen):not(.phase-screen),
html[data-lg-mode="dark"] .semantic-screen,
html[data-lg-mode="dark"] .story-figure {
  background: #0f172a;
  border-color: rgba(148, 163, 184, 0.26);
}
html[data-lg-mode="dark"] .screen:not(.equation-screen):not(.phase-screen) svg text,
html[data-lg-mode="dark"] .story-figure svg text {
  fill: #eef2ff;
}
html[data-lg-mode="dark"] .screen:not(.equation-screen):not(.phase-screen) svg .fine,
html[data-lg-mode="dark"] .story-figure svg .fine {
  fill: #cbd5e1;
}
html[data-lg-mode="dark"] .screen svg rect[fill="#f5d77f"] { fill: #5c4308; stroke: #fbbf24; }
html[data-lg-mode="dark"] .screen svg rect[fill="#dce8ff"] { fill: #1a335c; stroke: #60a5fa; }
html[data-lg-mode="dark"] .screen svg rect[fill="#edf0f4"] { fill: #182236; stroke: #475569; }
html[data-lg-mode="dark"] .screen svg rect[fill="#d9e3f5"] { fill: #1e2d48; stroke: #60a5fa; }
html[data-lg-mode="dark"] .screen svg rect[fill="#ccddfb"] { fill: #1b345c; stroke: #60a5fa; }
html[data-lg-mode="dark"] .screen svg rect[fill="#fff"] { fill: #141d32; stroke: #60a5fa; }
html[data-lg-mode="dark"] .screen svg rect[fill="#e1e4eb"] { fill: #1e293b; stroke: #64748b; }
html[data-lg-mode="dark"] .story-step { border-bottom-color: rgba(148, 163, 184, 0.24); }
html[data-lg-mode="dark"] .story-step.active { color: #fbbf24; }

/* Dark Mode: routing-in-gradient-space hardcoded light surfaces & #arch-svg */
html[data-lg-mode="dark"] tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.03);
}
html[data-lg-mode="dark"] tr.hl-gar {
  background: #2d1a10 !important;
  border-left-color: #fb923c;
}
html[data-lg-mode="dark"] tr.hl-gar td {
  color: #f8fafc;
}
html[data-lg-mode="dark"] .callout.intuition {
  background: rgba(56, 189, 248, 0.12);
  border-left-color: #38bdf8;
}
html[data-lg-mode="dark"] .callout.caveat {
  background: rgba(251, 113, 133, 0.12);
  border-left-color: #fb7185;
}
html[data-lg-mode="dark"] .callout.theorem {
  background: rgba(52, 211, 153, 0.12);
  border-left-color: #34d399;
}
html[data-lg-mode="dark"] .cmp-card.bad {
  background: rgba(251, 113, 133, 0.11);
}
html[data-lg-mode="dark"] .cmp-card.good {
  background: rgba(52, 211, 153, 0.11);
}
html[data-lg-mode="dark"] .challenge,
html[data-lg-mode="dark"] .challenge-box {
  background: #141c32;
  border-color: rgba(251, 191, 36, 0.34);
  color: #eef2ff;
}
html[data-lg-mode="dark"] .challenge-q {
  color: #f8fafc;
}
html[data-lg-mode="dark"] .c-opt {
  background: #101628;
  border-color: rgba(148, 163, 184, 0.32);
  color: #e2e8f0;
}
html[data-lg-mode="dark"] .c-opt:hover {
  background: #1a2642;
  border-color: #38bdf8;
  color: #f8fafc;
}
html[data-lg-mode="dark"] .c-opt.correct {
  background: rgba(16, 185, 129, 0.18);
  color: #6ee7b7;
}
html[data-lg-mode="dark"] .c-opt.wrong {
  background: rgba(244, 63, 94, 0.18);
  color: #fda4af;
}
html[data-lg-mode="dark"] .c-feedback {
  background: #0f172a;
  color: #cbd5e1;
}
html[data-lg-mode="dark"] .chart-tip {
  background: rgba(15, 23, 42, 0.96);
  color: #eef2ff;
  border-color: rgba(148, 163, 184, 0.34);
}
html[data-lg-mode="dark"] .tab-btn,
html[data-lg-mode="dark"] .reset-btn,
html[data-lg-mode="dark"] .exp-pick {
  background: #162038;
  color: #cbd5e1;
  border-color: rgba(148, 163, 184, 0.32);
}
html[data-lg-mode="dark"] .exp-pick.on {
  background: #38bdf8;
  color: #082127;
  border-color: #38bdf8;
}
html[data-lg-mode="dark"] #arch-svg rect[fill="#ffffff"] { fill: #131c33; }
html[data-lg-mode="dark"] #arch-svg rect[fill="#ecfdf5"] { fill: #0f2a22; stroke: #34d399; }
html[data-lg-mode="dark"] #arch-svg rect[fill="#fff7ed"] { fill: #291910; stroke: #fb923c; }
html[data-lg-mode="dark"] #arch-svg rect[fill="#fefce8"] { fill: #271f0e; stroke: #fbbf24; }
html[data-lg-mode="dark"] #arch-svg rect[fill="#fff1e6"] { fill: #2c1a10; stroke: #fb923c; }
html[data-lg-mode="dark"] #arch-svg rect[fill="#ffe4e6"] { fill: #30131c; stroke: #fb7185; }
html[data-lg-mode="dark"] #arch-svg text[fill="#18202c"] { fill: #f1f5f9; }
html[data-lg-mode="dark"] #arch-svg text[fill="#475569"] { fill: #cbd5e1; }
html[data-lg-mode="dark"] #arch-svg text[fill="#0369a1"] { fill: #38bdf8; }
html[data-lg-mode="dark"] #arch-svg text[fill="#c2410c"] { fill: #fb923c; }
html[data-lg-mode="dark"] #arch-svg text[fill="#047857"] { fill: #34d399; }
html[data-lg-mode="dark"] #arch-svg text[fill="#be123c"] { fill: #fb7185; }
html[data-lg-mode="dark"] #arch-svg text[fill="#a14a08"] { fill: #fbbf24; }

/* Dark Mode: inbox hardcoded light surfaces & architecture SVG */
html[data-lg-mode="dark"] .arch-diagram-box,
html[data-lg-mode="dark"] .arch-pillar,
html[data-lg-mode="dark"] .arch-table-wrap,
html[data-lg-mode="dark"] .stage-card,
html[data-lg-mode="dark"] .schema-panel,
html[data-lg-mode="dark"] .schema-grid,
html[data-lg-mode="dark"] .code-pane,
html[data-lg-mode="dark"] .meta-pane,
html[data-lg-mode="dark"] .meta-kv-row {
  background: #101729;
  border-color: rgba(148, 163, 184, 0.26);
  color: #e2e8f0;
  box-shadow: none;
}
html[data-lg-mode="dark"] .arch-table th,
html[data-lg-mode="dark"] .schema-toolbar {
  background: #162038;
  color: #cbd5e1;
  border-color: rgba(148, 163, 184, 0.24);
}
html[data-lg-mode="dark"] .arch-table td,
html[data-lg-mode="dark"] .arch-table td strong {
  color: #e2e8f0;
}
html[data-lg-mode="dark"] .arch-table code {
  background: #1b2742;
  color: #bae6fd;
  border-color: rgba(56, 189, 248, 0.3);
}
html[data-lg-mode="dark"] .schema-tab,
html[data-lg-mode="dark"] .fmt-btn,
html[data-lg-mode="dark"] .copy-btn,
html[data-lg-mode="dark"] .stage-btn {
  background: #162038;
  color: #cbd5e1;
  border-color: rgba(148, 163, 184, 0.32);
}
html[data-lg-mode="dark"] .schema-tab.active,
html[data-lg-mode="dark"] .fmt-btn.active,
html[data-lg-mode="dark"] .stage-btn.active {
  background: #a78bfa;
  color: #090b18;
  border-color: #a78bfa;
}
html[data-lg-mode="dark"] .cost-badge,
html[data-lg-mode="dark"] .isolation-callout {
  background: rgba(16, 185, 129, 0.16);
  color: #6ee7b7;
  border-color: rgba(52, 211, 153, 0.34);
}
html[data-lg-mode="dark"] .stage-explorer {
  background: rgba(251, 191, 36, 0.12);
  border-color: rgba(251, 191, 36, 0.3);
}
html[data-lg-mode="dark"] .st-spark { background: rgba(251, 191, 36, 0.16); color: #fde68a; border-color: rgba(251, 191, 36, 0.34); }
html[data-lg-mode="dark"] .st-lit   { background: rgba(56, 189, 248, 0.16); color: #bae6fd; border-color: rgba(56, 189, 248, 0.34); }
html[data-lg-mode="dark"] .st-proto { background: rgba(167, 139, 250, 0.18); color: #ddd6fe; border-color: rgba(167, 139, 250, 0.36); }
html[data-lg-mode="dark"] .st-exp   { background: rgba(52, 211, 153, 0.16); color: #a7f3d0; border-color: rgba(52, 211, 153, 0.34); }
html[data-lg-mode="dark"] .st-arch  { background: rgba(148, 163, 184, 0.16); color: #cbd5e1; border-color: rgba(148, 163, 184, 0.32); }
html[data-lg-mode="dark"] .tok-key  { color: #38bdf8; }
html[data-lg-mode="dark"] .tok-str  { color: #34d399; }
html[data-lg-mode="dark"] .tok-num  { color: #fb923c; }
html[data-lg-mode="dark"] .tok-bool { color: #a78bfa; }
html[data-lg-mode="dark"] .tok-cmt  { color: #94a3b8; }
html[data-lg-mode="dark"] .arch-diagram-box svg rect[fill="url(#boxWarm)"] { fill: #131c33; }
html[data-lg-mode="dark"] .arch-diagram-box svg rect[fill="#e0f2fe"] { fill: #0e2a3d; }
html[data-lg-mode="dark"] .arch-diagram-box svg rect[fill="#fff1e6"] { fill: #2d1a10; }
html[data-lg-mode="dark"] .arch-diagram-box svg rect[fill="#d1fae5"] { fill: #0e2a22; }
html[data-lg-mode="dark"] .arch-diagram-box svg text[fill="#141b26"] { fill: #f1f5f9; }
html[data-lg-mode="dark"] .arch-diagram-box svg text[fill="#475569"] { fill: #cbd5e1; }
html[data-lg-mode="dark"] .arch-diagram-box svg text[fill="#0369a1"] { fill: #38bdf8; }
html[data-lg-mode="dark"] .arch-diagram-box svg text[fill="#c2410c"] { fill: #fb923c; }
html[data-lg-mode="dark"] .arch-diagram-box svg text[fill="#047857"] { fill: #34d399; }
html[data-lg-mode="dark"] .arch-diagram-box svg text[fill="#64748b"] { fill: #94a3b8; }
html[data-lg-mode="dark"] .cat-tag {
  background: rgba(167, 139, 250, 0.16) !important;
  color: #e2e8f0 !important;
  border-color: rgba(167, 139, 250, 0.34) !important;
}

/* Dark Mode: serving-systems hardcoded light surfaces */
html[data-lg-mode="dark"] .flow-box.answer {
  background: #2b1d12;
  border-color: #fb923c;
  color: #fef3c7;
}
html[data-lg-mode="dark"] .piece.new-piece {
  background: #2b1d12;
  border-color: #fb923c;
  color: #fed7aa;
}
html[data-lg-mode="dark"] .piece.mismatch {
  background: #30151d;
  border-color: #fb7185;
  color: #fecdd3;
}
html[data-lg-mode="dark"] .world-actions button,
html[data-lg-mode="dark"] .story-lab button,
html[data-lg-mode="dark"] .chapter-nav a,
html[data-lg-mode="dark"] .controls button:not(.flow-btn),
html[data-lg-mode="dark"] .controls select,
html[data-lg-mode="dark"] .controls input[type="text"],
html[data-lg-mode="dark"] .article-main button {
  background: #172038;
  border-color: rgba(148, 163, 184, 0.36);
  color: #eef2ff;
}
html[data-lg-mode="dark"] .world-actions button:hover,
html[data-lg-mode="dark"] .article-main button.selected {
  background: #263456;
  border-color: #38bdf8;
  color: #f8fafc;
}
html[data-lg-mode="dark"] .world-caption .contract {
  background: #131b30;
  border-color: rgba(148, 163, 184, 0.3);
  color: #e2e8f0;
}
html[data-lg-mode="dark"] .story-figure figcaption,
html[data-lg-mode="dark"] .official figcaption,
html[data-lg-mode="dark"] .scroll-hint,
html[data-lg-mode="dark"] .piece small {
  color: #cbd5e1;
}
html[data-lg-mode="dark"] .benchmark-protocol > .active,
html[data-lg-mode="dark"] .responsibility-matrix .active,
html[data-lg-mode="dark"] .mechanism-steps .active {
  background: #2b1d12;
  border-color: #fb923c;
  color: #fed7aa;
}
html[data-lg-mode="dark"] .timeline-cells .redo {
  background: #33161e;
  border-color: #fb7185;
  color: #fecdd3;
}
html[data-lg-mode="dark"] .timeline-cells .fresh {
  background: #2e2310;
  border-color: #fbbf24;
  color: #fde68a;
}
html[data-lg-mode="dark"] .block-ledger .selected-block {
  background: rgba(56, 189, 248, 0.16);
  outline-color: #38bdf8;
}
html[data-lg-mode="dark"] .cell-row .empty-cell {
  background: #1a2438;
  color: #94a3b8;
}
html[data-lg-mode="dark"] .address-stop b {
  color: #38bdf8;
}
html[data-lg-mode="dark"] .radix-mobile .shared-edge,
html[data-lg-mode="dark"] .tree-fork span,
html[data-lg-mode="dark"] .state-stamp.incomplete {
  background: #17223a;
  color: #e2e8f0;
  border-color: rgba(148, 163, 184, 0.36);
}
html[data-lg-mode="dark"] .count-bar {
  background: #2b1d12;
  border-color: rgba(148, 163, 184, 0.3);
}
html[data-lg-mode="dark"] .count-bar span {
  background: #166534;
}
html[data-lg-mode="dark"] .token.hit {
  background: #122922;
  color: #6ee7b7;
}
html[data-lg-mode="dark"] .token.miss {
  background: #2d1a10;
  color: #fed7aa;
}
html[data-lg-mode="dark"] .mechanism-svg .active rect {
  fill: #2d1c12 !important;
  stroke: #fb923c !important;
}
html[data-lg-mode="dark"] .mechanism-svg .masked-slot {
  fill: #1f293d !important;
}

/* Dark Mode: papers vault (locked + unlocked workspace + inspector drawer) */
html[data-lg-mode="dark"] .drawer-close,
html[data-lg-mode="dark"] .shelf-arrow,
html[data-lg-mode="dark"] .tool-btn,
html[data-lg-mode="dark"] .search-clear-btn,
html[data-lg-mode="dark"] .facet-select,
html[data-lg-mode="dark"] .t-chip,
html[data-lg-mode="dark"] .cluster-pill,
html[data-lg-mode="dark"] .inter-chip,
html[data-lg-mode="dark"] .ins-kw-btn,
html[data-lg-mode="dark"] .action-btn,
html[data-lg-mode="dark"] .pw-toggle {
  background: #162038;
  color: #eef2ff;
  border-color: rgba(148, 163, 184, 0.34);
}
html[data-lg-mode="dark"] .action-btn.primary {
  background: #a78bfa;
  color: #090b18;
  border-color: #a78bfa;
}
html[data-lg-mode="dark"] .action-btn.accent {
  background: linear-gradient(135deg, #9a3412, #c2410c);
  color: #ffffff;
  border-color: transparent;
}
html[data-lg-mode="dark"] .drawer-close:hover,
html[data-lg-mode="dark"] .tool-btn:hover,
html[data-lg-mode="dark"] .ins-kw-btn:hover,
html[data-lg-mode="dark"] .inter-chip.active,
html[data-lg-mode="dark"] .t-chip.active {
  background: #a78bfa;
  color: #090b18;
  border-color: #a78bfa;
}
html[data-lg-mode="dark"] .t-chip.active-gold {
  background: rgba(251, 191, 36, 0.24);
  color: #fef3c7;
  border-color: rgba(251, 191, 36, 0.55);
}
html[data-lg-mode="dark"] .fuzzy-input {
  background: #11182c;
  color: #eef2ff;
  border-color: rgba(148, 163, 184, 0.36);
}
html[data-lg-mode="dark"] .fuzzy-input::placeholder {
  color: #94a3b8;
}
html[data-lg-mode="dark"] .seg-tabs {
  background: #11182c;
  border: 1px solid rgba(148, 163, 184, 0.26);
}
html[data-lg-mode="dark"] .seg-tab {
  color: #cbd5e1;
}
html[data-lg-mode="dark"] .seg-tab.active {
  background: #1f2b49;
  color: #ffffff;
  box-shadow: 0 2px 10px -2px rgba(0, 0, 0, 0.5);
}
html[data-lg-mode="dark"] .tab-count {
  background: rgba(148, 163, 184, 0.22);
  color: #e2e8f0;
}
html[data-lg-mode="dark"] .inter-chip.active .tab-count {
  background: rgba(9, 11, 24, 0.22);
  color: #090b18;
}
html[data-lg-mode="dark"] .inspector-drawer,
html[data-lg-mode="dark"] .glass-panel,
html[data-lg-mode="dark"] .shelf-panel,
html[data-lg-mode="dark"] .explorer-panel,
html[data-lg-mode="dark"] .filter-panel,
html[data-lg-mode="dark"] .tree-panel,
html[data-lg-mode="dark"] .shelf-card,
html[data-lg-mode="dark"] .intersection-ribbon,
html[data-lg-mode="dark"] .canvas-toolbar,
html[data-lg-mode="dark"] .canvas-legend,
html[data-lg-mode="dark"] .venn-tooltip,
html[data-lg-mode="dark"] .tree-cat,
html[data-lg-mode="dark"] .tree-sub,
html[data-lg-mode="dark"] .paper-row,
html[data-lg-mode="dark"] .ins-chip,
html[data-lg-mode="dark"] .ins-quote,
html[data-lg-mode="dark"] .ins-summary,
html[data-lg-mode="dark"] .ins-stat-pill,
html[data-lg-mode="dark"] .ins-path-box,
html[data-lg-mode="dark"] .drawer-foot,
html[data-lg-mode="dark"] .brand-pill {
  background: rgba(16, 22, 40, 0.96);
  border-color: rgba(148, 163, 184, 0.26);
  color: #e2e8f0;
}
html[data-lg-mode="dark"] .venn-tooltip .vt-title,
html[data-lg-mode="dark"] .inter-title,
html[data-lg-mode="dark"] .wc-header-note {
  color: #eef2ff;
}
html[data-lg-mode="dark"] .venn-tooltip .vt-meta,
html[data-lg-mode="dark"] .venn-tooltip .vt-kw {
  color: #cbd5e1;
}
html[data-lg-mode="dark"] .tree-sub-head {
  background: rgba(24, 34, 60, 0.92);
  color: #e2e8f0;
  border-color: rgba(148, 163, 184, 0.22);
}
html[data-lg-mode="dark"] .tree-sub-name {
  color: #eef2ff;
}
html[data-lg-mode="dark"] .pr-title mark {
  background: rgba(251, 191, 36, 0.32);
  color: #fef3c7;
}
html[data-lg-mode="dark"] .ins-callout {
  background: rgba(99, 102, 241, 0.16);
  border-color: rgba(165, 180, 252, 0.32);
  color: #e0e7ff;
}
html[data-lg-mode="dark"] .canvas-stage,
html[data-lg-mode="dark"] #wordcloud-stage {
  background: radial-gradient(circle at 50% 42%, #11192e 0%, #090e1c 100%);
  border-color: rgba(148, 163, 184, 0.26);
}
html[data-lg-mode="dark"] .wc-bubble {
  background: #17223b;
  color: #e2e8f0;
  border-color: rgba(148, 163, 184, 0.34);
}
html[data-lg-mode="dark"] .wc-bubble .wc-count {
  background: rgba(9, 14, 28, 0.62);
  color: #e2e8f0;
  opacity: 1;
}
html[data-lg-mode="dark"] .wc-bubble.active {
  background: #a78bfa !important;
  color: #090b18 !important;
  border-color: #a78bfa !important;
}
html[data-lg-mode="dark"] .wc-bubble.active .wc-count {
  background: rgba(9, 11, 24, 0.22);
  color: #090b18;
  opacity: 1;
}
html[data-lg-mode="dark"] .gold-badge {
  background: rgba(251, 191, 36, 0.18);
  color: #fde68a;
  border-color: rgba(251, 191, 36, 0.45);
}
html[data-lg-mode="dark"] .card-cta {
  color: #fb923c !important;
}

/* Dark Mode: hnet @scope labs & lesson.css sub-elements */
html[data-lg-mode="dark"] .world-basics,
html[data-lg-mode="dark"] .world-full {
  --bg: #0c1020;
  --card: #11182c;
  --panel: #11182c;
  --fg: #eef2ff;
  --muted: #94a3b8;
  --line: rgba(148, 163, 184, 0.28);
  --cyan: #38bdf8;
  --green: #34d399;
  --purple: #a78bfa;
  --amber: #fbbf24;
  background: #0c1020;
  color: #eef2ff;
}
html[data-lg-mode="dark"] .world-basics :where(.card, .notice, .plain, .math, .byte, .status, .process article, .track, .path .row, .question, .chip, nav),
html[data-lg-mode="dark"] .world-full :where(.card, .badge, .nav, .callout, .equation, .metric, .selected, .chip, .plot, .diagram-container, .component, .diagram-detail, details) {
  background: #131c33;
  border-color: rgba(148, 163, 184, 0.28);
  color: #e2e8f0;
}
html[data-lg-mode="dark"] .world-basics :where(button, select, input[type="text"]),
html[data-lg-mode="dark"] .world-full :where(button, select, input[type="text"]) {
  background: #182340;
  border-color: rgba(148, 163, 184, 0.36);
  color: #eef2ff;
}
html[data-lg-mode="dark"] .reading-cell.seen,
html[data-lg-mode="dark"] .selection-cell.kept,
html[data-lg-mode="dark"] .reference-chapter[open],
html[data-lg-mode="dark"] .reference-body .contract-alternate {
  background: #14223a;
  color: #e2e8f0;
}
html[data-lg-mode="dark"] .process-steps button[aria-pressed="true"] {
  background: #0369a1;
  border-color: #38bdf8;
  color: #ffffff;
}
html[data-lg-mode="dark"] .process-scroll::after {
  background: #131c33;
  color: #94a3b8;
}

html[data-lg-mode="dark"] .tour-box {
  background: rgba(56, 189, 248, 0.10);
  border-color: rgba(56, 189, 248, 0.30);
  border-left-color: #38bdf8;
  color: #cbd5e1;
}
html[data-lg-mode="dark"] .skip {
  background: #101526;
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.4);
}
html[data-lg-mode="dark"] .world-note,
html[data-lg-mode="dark"] .mechanism-view .diagram-note {
  color: #94a3b8;
}
html[data-lg-mode="dark"] .process-table {
  background: #101729;
  color: #e2e8f0;
}
html[data-lg-mode="dark"] .process-table caption,
html[data-lg-mode="dark"] .process-table thead th,
html[data-lg-mode="dark"] .process-table tbody th {
  background: #162038;
  color: #e2e8f0;
  border-color: rgba(148, 163, 184, 0.26);
}
html[data-lg-mode="dark"] .process-table td {
  color: #cbd5e1;
  border-color: rgba(148, 163, 184, 0.2);
}
html[data-lg-mode="dark"] .restore-table tbody tr:last-child {
  background: #162440;
  color: #93c5fd;
}
html[data-lg-mode="dark"] .byte-ledger > div,
html[data-lg-mode="dark"] .mixture {
  background: #131c33;
  color: #e2e8f0;
}

/* Dark Mode links: never wash out primary cyan .cta / .jump or .action-btn buttons (AA-R3-01, AA-R5-01) */
html[data-lg-mode="dark"] a:not(.cta):not(.jump):not(.btn):not(.lg-back-btn):not(.action-btn) {
  color: #38bdf8;
}
html[data-lg-mode="dark"] :where(.cta, .jump),
html[data-lg-mode="dark"] :where(.cta, .jump):hover {
  color: #082127;
}

/* ==========================================================================
   5. THEME MODE B — LIGHT MODE (Warm Ivory Liquid Glass)
      Also transforms naturally-dark pages (decision-models, diffusion-models)
      cleanly into warm ivory daylight glass!
   ========================================================================== */
html[data-lg-mode="light"] {
  color-scheme: light;

  --bg: #faf9f6;
  --bg-alt: #f3f1ec;
  --bg-warm: #f3efe6;
  --paper: #faf9f6;
  --surface: rgba(255, 255, 255, 0.8);
  --surface-2: #f7f5f0;
  --panel: rgba(255, 255, 255, 0.8);
  --well: #f4f1ea;
  --canvas-bg: #fcfbf8;
  --canvas-well: #f4f1ea;

  --text: #18202c;
  --text-body: #2b3545;
  --text-dim: #475569;
  --text-muted: #556377;
  --ink: #18202c;
  --ink-body: #2b3545;
  --ink-muted: #475569;
  --muted: #475569;
  --dim: #475569;
  --soft: #556377;

  --glass: rgba(255, 255, 255, 0.8);
  --glass-strong: rgba(255, 255, 255, 0.9);
  --glass-border: rgba(255, 255, 255, 0.92);
  --border: #e2dfd7;
  --hairline: rgba(15, 23, 42, 0.085);
  --line: #d6d2c8;
  --edge: #d6d2c8;

  --lg-glass-bg: rgba(255, 255, 255, 0.8);
  --lg-glass-bg-strong: rgba(255, 255, 255, 0.9);
  --lg-glass-border: rgba(255, 255, 255, 0.92);
  --lg-dock-bg: rgba(255, 253, 250, 0.84);
  --lg-dock-border: rgba(255, 255, 255, 0.94);
  --lg-dock-ring: rgba(15, 23, 42, 0.11);
  --lg-dock-ink: #18202c;
  --lg-dock-muted: #526075;
  --lg-dock-pill-bg: rgba(15, 23, 42, 0.055);
  --lg-dock-active-bg: #18202c;
  --lg-dock-active-ink: #ffffff;
  --lg-dock-accent: #0369a1;
}

/* Light + Minimal conversion for naturally-dark pages (decision-models, diffusion-models) */
html[data-lg-natural-theme="dark"][data-lg-mode="light"],
html[data-lg-natural-theme="dark"][data-lg-mode="minimal"] {
  --cyan: #0369a1;
  --violet: #5b21b6;
  --gold: #9a5b08;
  --amber: #9a5b08;
  --lime: #166534;
  --rose: #be123c;
}

html[data-lg-natural-theme="dark"][data-lg-mode="light"] body,
html[data-lg-natural-theme="dark"][data-lg-mode="minimal"] body {
  background: var(--bg);
  color: var(--text);
}

html[data-lg-natural-theme="dark"][data-lg-mode="light"] :where(.masthead, .mast),
html[data-lg-natural-theme="dark"][data-lg-mode="minimal"] :where(.masthead, .mast) {
  background: rgba(250, 249, 246, 0.9);
  border-color: var(--line);
}

html[data-lg-natural-theme="dark"][data-lg-mode="light"] .hero,
html[data-lg-natural-theme="dark"][data-lg-mode="minimal"] .hero {
  background: none;
  --hero-border: var(--line);
}

html[data-lg-natural-theme="dark"][data-lg-mode="light"] :where(.hero-diagram, .hero-plate),
html[data-lg-natural-theme="dark"][data-lg-mode="minimal"] :where(.hero-diagram, .hero-plate) {
  background: var(--panel);
  border-color: var(--line);
  box-shadow: var(--lg-glass-shadow);
}

html[data-lg-natural-theme="dark"][data-lg-mode="light"] :where(button, select, input[type="search"]),
html[data-lg-natural-theme="dark"][data-lg-mode="minimal"] :where(button, select, input[type="search"]) {
  background: #ffffff;
  color: #18202c;
  border-color: #cbd5e1;
}
html[data-lg-natural-theme="dark"][data-lg-mode="light"] :where(button:hover:not(:disabled), select:hover:not(:disabled)),
html[data-lg-natural-theme="dark"][data-lg-mode="minimal"] :where(button:hover:not(:disabled), select:hover:not(:disabled)) {
  background: #f1f5f9;
  border-color: var(--cyan);
}
html[data-lg-natural-theme="dark"][data-lg-mode="light"] :where(.cta, .jump, .mark, .brand span),
html[data-lg-natural-theme="dark"][data-lg-mode="minimal"] :where(.cta, .jump, .mark, .brand span) {
  color: #ffffff;
}
html[data-lg-natural-theme="dark"][data-lg-mode="light"] :where(.cta:hover, .jump:hover),
html[data-lg-natural-theme="dark"][data-lg-mode="minimal"] :where(.cta:hover, .jump:hover) {
  background: #0c4a6e;
  color: #ffffff;
}
html[data-lg-natural-theme="dark"][data-lg-mode="light"] :where(.callout, .deep, .depth, .equation, .formula, .well, .tag, .badge, .token, .lock-token),
html[data-lg-natural-theme="dark"][data-lg-mode="minimal"] :where(.callout, .deep, .depth, .equation, .formula, .well, .tag, .badge, .token, .lock-token) {
  background: #f4f2ec;
  border-color: #d6d3cb;
  color: #18202c;
}
html[data-lg-natural-theme="dark"][data-lg-mode="light"] .callout.warning,
html[data-lg-natural-theme="dark"][data-lg-mode="minimal"] .callout.warning {
  background: #fff1f2;
}
html[data-lg-natural-theme="dark"][data-lg-mode="light"] .token.mask,
html[data-lg-natural-theme="dark"][data-lg-mode="minimal"] .token.mask {
  background: #f3e8ff;
  color: #5b21b6;
}
html[data-lg-natural-theme="dark"][data-lg-mode="light"] :where(.stage-rail button[aria-current="step"], .packet-track button[aria-current="step"], td.scheduled, .data-table tr.is-current),
html[data-lg-natural-theme="dark"][data-lg-mode="minimal"] :where(.stage-rail button[aria-current="step"], .packet-track button[aria-current="step"], td.scheduled, .data-table tr.is-current) {
  background: #e0f2fe;
  color: #0369a1;
}
html[data-lg-natural-theme="dark"][data-lg-mode="light"] :where(.bar-track, .signed, .track, .work-track),
html[data-lg-natural-theme="dark"][data-lg-mode="minimal"] :where(.bar-track, .signed, .track, .work-track) {
  background: #e2e8f0;
}
html[data-lg-natural-theme="dark"][data-lg-mode="light"] .hero-start rect,
html[data-lg-natural-theme="dark"][data-lg-mode="minimal"] .hero-start rect,
html[data-lg-natural-theme="dark"][data-lg-mode="light"] .state-node rect,
html[data-lg-natural-theme="dark"][data-lg-mode="minimal"] .state-node rect,
html[data-lg-natural-theme="dark"][data-lg-mode="light"] .hero-branch rect,
html[data-lg-natural-theme="dark"][data-lg-mode="minimal"] .hero-branch rect,
html[data-lg-natural-theme="dark"][data-lg-mode="light"] .action-node rect,
html[data-lg-natural-theme="dark"][data-lg-mode="minimal"] .action-node rect,
html[data-lg-natural-theme="dark"][data-lg-mode="light"] .hero-out rect,
html[data-lg-natural-theme="dark"][data-lg-mode="minimal"] .hero-out rect,
html[data-lg-natural-theme="dark"][data-lg-mode="light"] .end-node rect,
html[data-lg-natural-theme="dark"][data-lg-mode="minimal"] .end-node rect,
html[data-lg-natural-theme="dark"][data-lg-mode="light"] .hero-slots rect,
html[data-lg-natural-theme="dark"][data-lg-mode="minimal"] .hero-slots rect,
html[data-lg-natural-theme="dark"][data-lg-mode="light"] .trace-map .map-node rect,
html[data-lg-natural-theme="dark"][data-lg-mode="minimal"] .trace-map .map-node rect {
  fill: #ffffff;
  stroke: #94a3b8;
}
html[data-lg-natural-theme="dark"][data-lg-mode="light"] .hero-slots rect.filled,
html[data-lg-natural-theme="dark"][data-lg-mode="minimal"] .hero-slots rect.filled,
html[data-lg-natural-theme="dark"][data-lg-mode="light"] .trace-map .map-node.active rect,
html[data-lg-natural-theme="dark"][data-lg-mode="minimal"] .trace-map .map-node.active rect {
  fill: #cffafe;
  stroke: #0369a1;
}
html[data-lg-natural-theme="dark"][data-lg-mode="light"] .trace-map .map-node.active text,
html[data-lg-natural-theme="dark"][data-lg-mode="minimal"] .trace-map .map-node.active text {
  fill: #083344;
}
html[data-lg-natural-theme="dark"][data-lg-mode="light"] .mask-table td.allowed,
html[data-lg-natural-theme="dark"][data-lg-mode="minimal"] .mask-table td.allowed {
  background: #e0f2fe;
  color: #0369a1;
}
html[data-lg-natural-theme="dark"][data-lg-mode="light"] .token-group,
html[data-lg-natural-theme="dark"][data-lg-mode="minimal"] .token-group {
  background: #f1f5f9;
  border-color: #cbd5e1;
}
html[data-lg-natural-theme="dark"][data-lg-mode="light"] .token.future-token,
html[data-lg-natural-theme="dark"][data-lg-mode="minimal"] .token.future-token {
  background: #f3e8ff;
  color: #5b21b6;
}
html[data-lg-natural-theme="dark"][data-lg-mode="light"] .dataset-row.selected,
html[data-lg-natural-theme="dark"][data-lg-mode="minimal"] .dataset-row.selected {
  background: #e0f2fe;
}
html[data-lg-natural-theme="dark"][data-lg-mode="light"] .hero-out .rose-node,
html[data-lg-natural-theme="dark"][data-lg-mode="minimal"] .hero-out .rose-node {
  fill: #ffe4e6;
  stroke: #be123c;
}
html[data-lg-natural-theme="dark"][data-lg-mode="light"] a:hover,
html[data-lg-natural-theme="dark"][data-lg-mode="minimal"] a:hover {
  color: #075985;
}

/* ==========================================================================
   6. THEME MODE C — MINIMAL MODE (Swiss Editorial Single-Column Layout
      WITH Smooth Spring Scroll-Reveals & Hover Slide Micro-Animations!)
   ========================================================================== */
html[data-lg-mode="minimal"] {
  color-scheme: light;

  /* Crisp Swiss monochrome + single refined indigo accent (#3730a3) */
  --bg: #ffffff;
  --bg-alt: #f9fafb;
  --bg-warm: #f9fafb;
  --paper: #ffffff;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --panel: #ffffff;
  --card: #ffffff;
  --well: #f9fafb;
  --canvas-bg: #ffffff;
  --canvas-well: #f9fafb;

  --text: #111827;
  --text-body: #1f2937;
  --text-dim: #4b5563;
  --text-muted: #4b5563;
  --ink: #111827;
  --ink-body: #1f2937;
  --ink-muted: #4b5563;
  --fg: #111827;
  --muted: #4b5563;
  --sub: #4b5563;
  --dim: #4b5563;
  --soft: #4b5563;

  --glass: #ffffff;
  --glass-strong: #ffffff;
  --glass-soft: #f9fafb;
  --glass-border: #e5e7eb;
  --border: #e5e7eb;
  --border-bright: #d1d5db;
  --border-cool: #e5e7eb;
  --hairline: #e5e7eb;
  --hairline-strong: #d1d5db;
  --line: #e5e7eb;
  --edge: #e5e7eb;

  --accent-blue: #3730a3;
  --accent-violet: #3730a3;
  --accent-orange: #3730a3;
  --accent-orange-bright: #3730a3;
  --accent-emerald: #3730a3;
  --accent-amber: #3730a3;
  --accent-rose: #3730a3;
  --cyan: #3730a3;
  --gar: #3730a3;
  --gar-fill: #3730a3;
  --deep: #3730a3;
  --blue: #3730a3;
  --violet: #3730a3;
  --purple: #3730a3;
  --fine: #3730a3;
  --green: #3730a3;
  --gold: #3730a3;
  --amber: #3730a3;
  --new: #3730a3;

  --tint-cyan: #eef2ff;
  --tint-gar: #eef2ff;
  --tint-gold: #f3f4f6;
  --tint-coral: #f3f4f6;
  --tint-emerald: #eef2ff;
  --tint-slate: #f3f4f6;

  --shadow-glass: none;
  --shadow-hover: none;
  --shadow: none;
  --shadow-sm: none;
  --radius-lg: 6px;
  --radius-md: 6px;
  --radius: 6px;

  --lg-glass-bg: #ffffff;
  --lg-glass-bg-strong: #ffffff;
  --lg-glass-border: #e5e7eb;
  --lg-glass-hairline: #e5e7eb;
  --lg-glass-shadow: none;
  --lg-glass-shadow-hover: none;
  --lg-dock-bg: rgba(255, 255, 255, 0.96);
  --lg-dock-border: #e5e7eb;
  --lg-dock-ring: rgba(17, 24, 39, 0.08);
  --lg-dock-ink: #111827;
  --lg-dock-muted: #4b5563;
  --lg-dock-pill-bg: #f3f4f6;
  --lg-dock-active-bg: #3730a3;
  --lg-dock-active-ink: #ffffff;
  --lg-dock-accent: #3730a3;
}

html[data-lg-mode="minimal"],
html[data-lg-mode="minimal"] body {
  background: #ffffff;
  background-image: none;
  color: #1f2937;
}

/* Hide heavy decorative backdrops, glows, stripes & preview widgets */
html[data-lg-mode="minimal"] .lg-backdrop,
html[data-lg-mode="minimal"] .aurora-stage,
html[data-lg-mode="minimal"] #bg-field,
html[data-lg-mode="minimal"] .orb,
html[data-lg-mode="minimal"] .card-stripe,
html[data-lg-mode="minimal"] .featured-preview,
html[data-lg-mode="minimal"] .card::before,
html[data-lg-mode="minimal"] .brand-orb,
html[data-lg-mode="minimal"] .lock-orb-ring,
html[data-lg-mode="minimal"] .chapter-rail {
  display: none !important;
}

html[data-lg-mode="minimal"] .lg-back-btn,
html[data-lg-mode="minimal"] .lg-theme-pill,
html[data-lg-mode="minimal"] .lg-dock {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-radius: 8px;
  box-shadow: 0 2px 10px -4px rgba(17, 24, 39, 0.08);
}

html[data-lg-mode="minimal"] .lg-theme-btn,
html[data-lg-mode="minimal"] .lg-seg,
html[data-lg-mode="minimal"] .lg-seg-btn {
  border-radius: 6px !important;
}

/* Swiss single-column editorial reading layout (max-width: 740px) */
html[data-lg-mode="minimal"] :where(
  .wrap,
  .container,
  .frame,
  .article-main,
  .article-header,
  .journey > .masthead,
  .journey .hero,
  .journey .chapter,
  .journey .references,
  .journey .article-footer,
  body > header:not(.topbar):not(.masthead):not(.mast):not(.nav),
  body > main:not(#lock-screen),
  body > footer,
  .decision,
  main#gallery,
  .body-grid
) {
  max-width: 740px;
  margin-inline: auto;
}

/* Keep floating .nav full 740px width in Minimal mode without horizontal squeezing */
html[data-lg-mode="minimal"] .nav {
  max-width: 740px;
  margin-inline: auto;
  padding-left: 16px;
  padding-right: 16px;
}

@media (min-width: 1080px) and (max-width: 1199px) {
  html[data-lg-mode="minimal"] .nav {
    top: 54px;
    margin-top: 54px;
  }
}

/* Align negative-margin callouts & tables cleanly to the 740px Swiss column */
html[data-lg-mode="minimal"] :where(
  .overview,
  .lab,
  .official-figure,
  .mix-worked,
  .restore-table-wrap
) {
  margin-inline: 0;
}

/* Collapse multi-column grids into a calm single-column editorial stack */
html[data-lg-mode="minimal"] :where(
  .grid,
  .principles,
  .kpi-strip,
  .glossary-grid,
  .compare-2col,
  .two-col,
  .two-col-eq,
  .body-grid,
  .hero,
  .lab-grid,
  .visual-two,
  .shape-strip,
  .official-grid,
  .research-cards,
  .media-grid,
  .intro-grid,
  .official-pair,
  .benchmark-protocol,
  .world-caption,
  .decision > div,
  main#gallery,
  .facets-row,
  .process-route,
  .assign-list,
  .paired-readout,
  .three-metrics,
  .split
) {
  grid-template-columns: minmax(0, 1fr) !important;
  max-width: 740px;
  margin-inline: auto;
  gap: 14px;
}

html[data-lg-mode="minimal"] .card,
html[data-lg-mode="minimal"] .card.featured,
html[data-lg-mode="minimal"] .card.full-span {
  grid-column: 1 / -1 !important;
  display: flex !important;
  flex-direction: column !important;
  padding: 20px 22px;
}

/* Minimalist hairline-bordered flat rows (no heavy blur or shadow) */
html[data-lg-mode="minimal"] :where(
  .card,
  .p-card,
  .panel,
  .lab,
  .story-lab,
  .story-figure,
  .example,
  .stat-card,
  .glossary-card,
  .summary-card,
  .callout,
  .controls-bar,
  .stats-row,
  .planned-banner,
  .reference-tier,
  .reference-chapter,
  .deep,
  .depth,
  .hero-plate,
  .hero-diagram,
  .well,
  .official,
  .official-figure,
  .official-panel,
  .nav-glass,
  .promise,
  .source-scope,
  .overview,
  .mechanism-article,
  .analogy,
  .notice,
  .lock-card
) {
  border-radius: 6px;
  box-shadow: none;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

html[data-lg-mode="minimal"] :where(.topbar, body > .masthead, .mast, .example-ribbon) {
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-bottom: 1px solid #e5e7eb;
  box-shadow: none;
}

html[data-lg-mode="minimal"] h1,
html[data-lg-mode="minimal"] h2,
html[data-lg-mode="minimal"] h3,
html[data-lg-mode="minimal"] strong:not(.banner strong) {
  color: #111827;
}
html[data-lg-mode="minimal"] .banner[data-style="blueprint"] strong,
html[data-lg-mode="light"] .banner[data-style="blueprint"] strong {
  color: #f1f3eb;
}

html[data-lg-mode="minimal"] h1 .hl {
  background: none;
  -webkit-text-fill-color: #3730a3;
  color: #3730a3;
}

html[data-lg-mode="minimal"] .f-pill.active,
html[data-lg-mode="minimal"] .mode-tab.active {
  background: #3730a3;
  border-color: #3730a3;
  color: #ffffff;
  box-shadow: none;
}

html[data-lg-mode="minimal"] .cat-tag,
html[data-lg-mode="minimal"] .eyebrow,
html[data-lg-mode="minimal"] .kicker,
html[data-lg-mode="minimal"] .chip,
html[data-lg-mode="minimal"] .planned-pill {
  background: #f9fafb !important;
  color: #3730a3 !important;
  border: 1px solid #e5e7eb !important;
  box-shadow: none;
}

/* Preserve silky hover slide micro-animations in Minimal Mode (suppress 3D card tilt) */
html[data-lg-mode="minimal"] .card.in-view,
html[data-lg-mode="minimal"] .card:not(.reveal) {
  transform: translate3d(0, 0, 0) !important;
}

html[data-lg-mode="minimal"] :where(
  .card,
  .p-card,
  .stat-card,
  .glossary-card,
  .summary-card,
  .example,
  .panel,
  .lab,
  .story-lab
) {
  transition:
    transform calc(0.28s * var(--lg-scale, 1.5)) var(--lg-ease-spring),
    border-color calc(0.22s * var(--lg-scale, 1.5)) ease,
    opacity calc(0.55s * var(--lg-scale, 1.5)) var(--lg-ease-spring);
}

@media (hover: hover) {
  html[data-lg-mode="minimal"]:not([data-lg-motion="off"]) :where(
    .card,
    .p-card,
    .stat-card,
    .glossary-card,
    .summary-card,
    .example,
    .panel,
    .lab,
    .story-lab
  ):hover {
    transform: translate3d(4px, 0, 0) !important;
    border-color: #3730a3;
    box-shadow: none;
  }
}

/* ==========================================================================
   7. Subpage Frosted Glass Polish (Light Warm Ivory vs Dark Deep Glass)
      Uses :where() for (0,0,0) specificity so semantic callouts & minimal
      mode rules always take precedence cleanly.
   ========================================================================== */
:where(html[data-lg-root="false"][data-lg-mode="light"]) :where(
  .lab,
  .callout,
  .story-lab,
  .story-figure,
  .official,
  .official-figure,
  .official-panel,
  .overview,
  .reference-chapter,
  .reference-tier,
  .source-scope,
  .promise,
  .example,
  .decision,
  .stat-card,
  .glossary-card,
  .summary-card,
  .eq-box,
  .panel
) {
  background-color: var(--lg-glass-bg);
  backdrop-filter: blur(14px) saturate(135%);
  -webkit-backdrop-filter: blur(14px) saturate(135%);
  box-shadow: var(--lg-glass-shadow);
}

:where(html[data-lg-root="false"][data-lg-mode="dark"]) :where(
  .panel,
  .hero-plate,
  .hero-diagram,
  .callout,
  .depth,
  .lab,
  .card,
  .story-lab,
  .story-figure,
  .example,
  .stat-card,
  .glossary-card,
  .summary-card
) {
  background-color: var(--lg-glass-bg);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-color: var(--lg-glass-border);
  box-shadow: var(--lg-glass-shadow);
}

:where(html[data-lg-root="false"][data-lg-mode="light"]) :where(.topbar, .example-ribbon, .masthead, .mast) {
  backdrop-filter: blur(16px) saturate(145%);
  -webkit-backdrop-filter: blur(16px) saturate(145%);
}
:where(html[data-lg-root="false"][data-lg-mode="dark"]) :where(.topbar, .example-ribbon, .mast, .masthead) {
  backdrop-filter: blur(16px) saturate(145%);
  -webkit-backdrop-filter: blur(16px) saturate(145%);
}

/* ==========================================================================
   8. Smooth Spring Scroll-Reveal (.lg-reveal / .lg-reveal-in)
      Preserved across Dark, Light AND Minimal modes!
   ========================================================================== */
.lg-reveal {
  opacity: 0;
  transform: translate3d(0, 26px, 0) scale(0.988);
  transition:
    opacity calc(0.55s * var(--lg-scale, 1.5)) var(--lg-ease-spring),
    transform calc(0.65s * var(--lg-scale, 1.5)) var(--lg-ease-spring);
  will-change: opacity, transform;
}

.lg-reveal.lg-reveal-in {
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1);
  will-change: auto;
}

/* ==========================================================================
   9. Floating Buoyancy (.lg-float) & Soft Liquid Hover Lift
   ========================================================================== */
.lg-float {
  animation: lg-float-bob calc(5.2s * var(--lg-scale, 1.5)) var(--lg-ease-float) infinite alternate;
  will-change: transform;
}

@keyframes lg-float-bob {
  from { transform: translate3d(0, 0px, 0); }
  to   { transform: translate3d(0, -4.5px, 0); }
}

html[data-lg-root="false"]:not([data-lg-mode="minimal"]) :where(
  .lab,
  .panel,
  .story-lab,
  .example,
  .stat-card,
  .glossary-card,
  .summary-card
) {
  transition:
    transform calc(0.34s * var(--lg-scale, 1.5)) var(--lg-ease-spring),
    box-shadow calc(0.36s * var(--lg-scale, 1.5)) var(--lg-ease-spring),
    border-color calc(0.26s * var(--lg-scale, 1.5)) ease;
}

@media (hover: hover) {
  html[data-lg-root="false"]:not([data-lg-motion="off"]):not([data-lg-mode="minimal"]) :where(
    .stat-card,
    .glossary-card,
    .summary-card,
    .example
  ):hover {
    transform: translate3d(0, -3px, 0);
    box-shadow: var(--lg-glass-shadow-hover);
  }

  html:not([data-lg-motion="off"]) :where(
    button:not(:disabled),
    .cta,
    .jump,
    .f-pill,
    .nav-link
  ) {
    transition:
      transform calc(0.24s * var(--lg-scale, 1.5)) var(--lg-ease-spring),
      box-shadow calc(0.26s * var(--lg-scale, 1.5)) var(--lg-ease-spring),
      background-color calc(0.2s * var(--lg-scale, 1.5)) ease,
      border-color calc(0.2s * var(--lg-scale, 1.5)) ease,
      color calc(0.2s * var(--lg-scale, 1.5)) ease;
  }
}

/* ==========================================================================
   10. Bottom-Right Floating Liquid-Glass Motion Dock (.lg-dock)
       Compact Motion Scale only (Back lives cleanly at top-left .lg-back-btn)
   ========================================================================== */
.lg-dock {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: var(--lg-z-dock);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px;
  border-radius: 999px;
  background: var(--lg-dock-bg);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid var(--lg-dock-border);
  box-shadow:
    0 14px 36px -10px rgba(15, 23, 42, 0.24),
    0 0 0 1px var(--lg-dock-ring),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
  color: var(--lg-dock-ink);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 12.5px;
  line-height: 1;
  letter-spacing: 0;
  user-select: none;
  transition:
    transform calc(0.32s * var(--lg-scale, 1.5)) var(--lg-ease-spring),
    box-shadow calc(0.32s * var(--lg-scale, 1.5)) var(--lg-ease-spring),
    opacity 0.25s ease;
}

.lg-dock:hover {
  transform: translate3d(0, -2px, 0);
}

.lg-dock *,
.lg-dock *::before,
.lg-dock *::after {
  box-sizing: border-box;
}

.lg-seg {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 3px 2px 8px;
  border-radius: 999px;
  background: var(--lg-dock-pill-bg);
}

.lg-seg-label {
  font-size: 11.5px;
  font-weight: 650;
  color: var(--lg-dock-muted);
  margin-right: 4px;
  white-space: nowrap;
}

.lg-seg-btn {
  appearance: none;
  -webkit-appearance: none;
  border: 0 !important;
  margin: 0;
  min-height: 26px !important;
  padding: 5px 8.5px !important;
  border-radius: 999px !important;
  background: transparent !important;
  color: var(--lg-dock-muted) !important;
  font: 650 11.5px/1 "Inter", "Segoe UI", system-ui, -apple-system, sans-serif !important;
  cursor: pointer;
  white-space: nowrap;
  transition:
    background-color 0.22s var(--lg-ease-spring),
    color 0.22s ease,
    transform 0.22s var(--lg-ease-spring),
    box-shadow 0.22s ease !important;
}

.lg-seg-btn:hover {
  color: var(--lg-dock-ink) !important;
  background: rgba(127, 127, 127, 0.12) !important;
}

.lg-seg-btn[aria-pressed="true"] {
  background: var(--lg-dock-active-bg) !important;
  color: var(--lg-dock-active-ink) !important;
  box-shadow: 0 3px 10px -2px rgba(15, 23, 42, 0.28);
}

/* ==========================================================================
   11. Motion Off / Paused / Reduced-Motion Safety Overrides
   ========================================================================== */
html[data-lg-motion="off"] .lg-blob,
html[data-lg-motion="off"] .lg-bubble,
html[data-lg-motion="off"] .lg-float,
body.motion-paused .lg-blob,
body.motion-paused .lg-bubble,
body.motion-paused .lg-float,
body.paused .lg-blob,
body.paused .lg-bubble,
body.paused .lg-float,
body[data-motion="off"] .lg-blob,
body[data-motion="off"] .lg-bubble,
body[data-motion="off"] .lg-float,
html[data-static] .lg-blob,
html[data-static] .lg-bubble,
html[data-static] .lg-float,
html[data-paused="true"] .lg-blob,
html[data-paused="true"] .lg-bubble,
html[data-paused="true"] .lg-float {
  animation-play-state: paused !important;
}

html[data-lg-motion="off"] .lg-bubble {
  opacity: 0.28;
}

html[data-lg-motion="off"] .lg-reveal,
body.motion-paused .lg-reveal,
body[data-motion="off"] .lg-reveal,
html[data-static] .lg-reveal,
html[data-paused="true"] .lg-reveal {
  opacity: 1 !important;
  transform: none !important;
  transition: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .lg-blob,
  .lg-bubble,
  .lg-float {
    animation: none !important;
  }
  .lg-reveal {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
}

/* Compact mobile dock layout */
@media (max-width: 640px) {
  .lg-dock {
    right: 10px;
    bottom: 10px;
    gap: 4px;
    padding: 4px 5px;
    max-width: calc(100vw - 20px);
  }
  .lg-seg {
    padding: 2px 2px 2px 5px;
  }
  .lg-seg-label {
    display: none;
  }
  .lg-seg-btn {
    padding: 5px 7.5px !important;
    font-size: 11px !important;
  }
}

@media print {
  .lg-backdrop,
  .lg-dock,
  .lg-mobile-bar,
  .lg-back-btn,
  .lg-theme-pill {
    display: none !important;
  }
  .lg-reveal {
    opacity: 1 !important;
    transform: none !important;
  }
}
