/* ==========================================================================
   Minimalist UI Design System — Computer Networks Study Companion
   Conforming strictly to .agents/skills/minimalist-ui/SKILL.md
   Warm monochrome canvas, editorial typographic contrast, bento-grid layouts,
   flat component architecture, and deliberate muted pastel accents.
   ========================================================================== */

:root {
  color-scheme: light;

  /* Typography Stacks */
  --font-display: "Newsreader", "Playfair Display", "Instrument Serif", Georgia, "Times New Roman", serif;
  --font-body: "SF Pro Display", "Geist Sans", "Helvetica Neue", "Switzer", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: "Geist Mono", "SF Mono", "JetBrains Mono", Consolas, "Liberation Mono", monospace;

  /* Canvas & Surfaces */
  --paper: #FBFBFA;
  --surface: #FFFFFF;
  --surface-soft: #F7F6F3;
  --line: #EAEAEA;
  --line-strong: #D5D5D3;

  /* Warm Charcoal Inks */
  --ink: #111111;
  --ink-soft: #444444;
  --ink-muted: #787774;

  /* Editorial Spot Muted Pastels (Strictly per skill spec) */
  --pastel-blue-bg: #E1F3FE;
  --pastel-blue-text: #1F6C9F;
  --pastel-blue-border: #c8e8fc;

  --pastel-green-bg: #EDF3EC;
  --pastel-green-text: #346538;
  --pastel-green-border: #d4e7d2;

  --pastel-yellow-bg: #FBF3DB;
  --pastel-yellow-text: #956400;
  --pastel-yellow-border: #f4e5ba;

  --pastel-red-bg: #FDEBEC;
  --pastel-red-text: #9F2F2D;
  --pastel-red-border: #fad1d4;

  /* Primary Interactive Accents */
  --primary-btn-bg: #111111;
  --primary-btn-text: #FFFFFF;
  --primary-btn-hover: #2F3437;

  /* Subtle, ultra-diffuse shadows (< 0.05 opacity) */
  --shadow-subtle: 0 1px 3px rgba(0, 0, 0, 0.03), 0 6px 16px rgba(0, 0, 0, 0.02);
  --shadow-hover: 0 2px 8px rgba(0, 0, 0, 0.05), 0 10px 24px rgba(0, 0, 0, 0.03);

  /* Structure & Geometry */
  --radius: 10px;
  --radius-sm: 6px;
  --bar-height: 64px;
  --rail-width: 290px;
  --content-width: 940px;
}

html[data-theme="dark"] {
  color-scheme: dark;

  /* Dark Canvas & Surfaces (Warm deep matte charcoal) */
  --paper: #121212;
  --surface: #1A1A1A;
  --surface-soft: #222222;
  --line: #2B2B2B;
  --line-strong: #3D3D3D;

  /* Dark Inks */
  --ink: #EDEDED;
  --ink-soft: #B0B0AF;
  --ink-muted: #7E7D7A;

  /* Muted Pastels (Dark Mode Adapted) */
  --pastel-blue-bg: rgba(31, 108, 159, 0.18);
  --pastel-blue-text: #8ECBF5;
  --pastel-blue-border: rgba(31, 108, 159, 0.35);

  --pastel-green-bg: rgba(52, 101, 56, 0.22);
  --pastel-green-text: #99E0A0;
  --pastel-green-border: rgba(52, 101, 56, 0.4);

  --pastel-yellow-bg: rgba(149, 100, 0, 0.22);
  --pastel-yellow-text: #F3CF7A;
  --pastel-yellow-border: rgba(149, 100, 0, 0.38);

  --pastel-red-bg: rgba(159, 47, 45, 0.22);
  --pastel-red-text: #F5A5A4;
  --pastel-red-border: rgba(159, 47, 45, 0.4);

  /* Primary Interactive Accents */
  --primary-btn-bg: #EDEDED;
  --primary-btn-text: #111111;
  --primary-btn-hover: #D5D5D5;

  /* Ultra-diffuse dark shadows */
  --shadow-subtle: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-hover: 0 4px 14px rgba(0, 0, 0, 0.5);
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--bar-height) + 20px);
  scrollbar-color: var(--line-strong) transparent;
  scrollbar-width: thin;
}

*::-webkit-scrollbar { width: 7px; height: 7px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 9999px;
  border: 2px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover {
  background: var(--ink-muted);
  background-clip: content-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 15.5px/1.65 var(--font-body);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body.drawer-open { overflow: hidden; }
[hidden] { display: none !important; }

a {
  color: var(--ink);
  text-decoration-color: var(--line-strong);
  text-underline-offset: 0.2em;
  transition: color .15s ease, text-decoration-color .15s ease;
}
a:hover {
  color: var(--pastel-blue-text);
  text-decoration-color: currentColor;
}

button, input { font: inherit; }
button { color: inherit; }
img { max-width: 100%; height: auto; }

code, kbd { font-family: var(--font-mono); }
code {
  background: var(--surface-soft);
  color: var(--ink);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--line);
  font-size: 0.88em;
  overflow-wrap: anywhere;
}

kbd {
  display: inline-block;
  padding: 2px 6px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface-soft);
  font-size: 0.82em;
  color: var(--ink-soft);
}

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  z-index: 200;
  top: 10px;
  left: 12px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  background: var(--primary-btn-bg);
  color: var(--primary-btn-text);
  font-size: 13.5px;
  font-weight: 600;
  transform: translateY(-160%);
  transition: transform .2s ease;
  border: 1px solid var(--line);
}
.skip-link:focus { transform: translateY(0); }

/* ==========================================================================
   Utility Top Bar
   ========================================================================== */
.utility-bar {
  position: fixed;
  z-index: 100;
  inset: 0 0 auto;
  min-height: var(--bar-height);
  display: grid;
  grid-template-columns: auto minmax(240px, 580px) auto;
  gap: 20px;
  align-items: center;
  padding: 8px 24px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  color: var(--ink);
  text-decoration: none;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--primary-btn-bg);
  color: var(--primary-btn-text);
  font: 700 13px var(--font-mono);
  letter-spacing: -0.02em;
  border: 1px solid var(--line);
}
.brand strong {
  display: block;
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--ink);
}
.brand small {
  display: block;
  margin-top: 2px;
  color: var(--ink-muted);
  font-size: 12px;
  font-weight: 450;
  line-height: 1.2;
}

.search-shell { position: relative; width: 100%; justify-self: center; }
.search-shell input {
  width: 100%;
  min-height: 40px;
  padding: 8px 74px 8px 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 14px;
  transition: border-color .15s ease, background-color .15s ease;
}
.search-shell input:focus {
  border-color: var(--ink);
  background: var(--surface);
  outline: none;
}
.search-shell input::placeholder { color: var(--ink-muted); }
.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  color: var(--ink-muted);
  transform: translateY(-50%);
  pointer-events: none;
  font-size: 13px;
}
.search-clear, .clear-search {
  position: absolute;
  right: 8px;
  top: 50%;
  padding: 4px 8px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--ink-muted);
  transform: translateY(-50%);
  cursor: pointer;
  font-size: 16px;
}
.search-clear:hover, .clear-search:hover { color: var(--ink); }

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline: 0;
  max-height: min(60vh, 480px);
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-hover);
}
.search-results[hidden] { display: none; }
.search-result {
  display: block;
  padding: 9px 12px;
  border-radius: 4px;
  color: var(--ink);
  text-decoration: none;
  transition: background-color .12s ease;
}
.search-result:hover, .search-result:focus {
  background: var(--surface-soft);
}
.search-result strong { display: block; font-size: 14px; font-weight: 600; }
.search-result small { display: block; color: var(--ink-muted); margin-top: 2px; font-size: 12.5px; }
.search-empty { margin: 0; padding: 14px; color: var(--ink-muted); text-align: center; font-size: 13.5px; }

.utility-actions { display: flex; gap: 6px; }
.icon-button, .topic-action, .filter-button, .lightbox-close {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: all .15s cubic-bezier(0.16, 1, 0.3, 1);
}
.icon-button { min-width: 38px; padding: 6px 10px; }
.icon-button:hover, .filter-button:hover, .lightbox-close:hover {
  border-color: var(--ink);
  background: var(--surface-soft);
}
.icon-button:active, .filter-button:active, .topic-action:active {
  transform: scale(0.98);
}
.text-button {
  min-height: 38px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 550;
  transition: all .15s cubic-bezier(0.16, 1, 0.3, 1);
}
.text-button:hover {
  border-color: var(--ink);
  background: var(--surface-soft);
}
.text-button:active { transform: scale(0.98); }

/* ==========================================================================
   Sidebar Course Map
   ========================================================================== */
.sidebar {
  position: fixed;
  z-index: 80;
  inset: var(--bar-height) auto 0 0;
  width: var(--rail-width);
  overflow-y: auto;
  padding: 24px 16px 36px;
  border-right: 1px solid var(--line);
  background: var(--surface);
}
.sidebar-head p {
  margin: 0;
  font-weight: 700;
  color: var(--ink);
  font-size: 13.5px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.sidebar-nav { margin-top: 18px; }
.nav-chapter {
  margin: 22px 10px 8px;
  color: var(--ink-muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.sidebar-nav a {
  display: block;
  margin: 1px 0;
  padding: 7px 10px 7px 12px;
  border-left: 2px solid transparent;
  border-radius: 0 4px 4px 0;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.35;
  text-decoration: none;
  transition: all .12s ease;
}
.sidebar-nav a:hover {
  background: var(--surface-soft);
  color: var(--ink);
}
.sidebar-nav a.active {
  border-left-color: var(--ink);
  background: var(--surface-soft);
  color: var(--ink);
  font-weight: 650;
}

.progress-card {
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}
.progress-card > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
.progress-track {
  height: 6px;
  margin: 8px 0 6px;
  border-radius: 9999px;
  background: var(--line);
  overflow: hidden;
}
.progress-fill, #progress-fill {
  display: block;
  width: 0;
  height: 100%;
  background: var(--ink);
  border-radius: 9999px;
  transition: width .3s cubic-bezier(0.16, 1, 0.3, 1);
}
.progress-card small { color: var(--ink-muted); font-size: 12px; }

.sidebar-tools {
  display: grid;
  gap: 3px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.sidebar-tools a {
  padding: 6px 10px;
  font-size: 12.5px;
  color: var(--ink-soft);
  text-decoration: none;
  border-radius: 4px;
  transition: background-color .12s ease, color .12s ease;
}
.sidebar-tools a:hover {
  background: var(--surface-soft);
  color: var(--ink);
}

.bookmark-panel {
  position: fixed;
  z-index: 150;
  top: calc(var(--bar-height) + 8px);
  right: 18px;
  width: min(380px, calc(100vw - 24px));
  max-height: min(70vh, 600px);
  overflow-y: auto;
  margin: 0;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
}
.bookmark-panel .panel-head h2 {
  margin: 0;
  font: 600 20px var(--font-display);
  letter-spacing: -0.02em;
  color: var(--ink);
}
.bookmark-list { display: grid; gap: 4px; margin-top: 14px; }
.bookmark-list a {
  padding: 8px 10px;
  border-radius: 4px;
  color: var(--ink);
  text-decoration: none;
  background: var(--surface-soft);
  font-size: 13px;
}
.bookmark-list a:hover { background: var(--line); }

/* ==========================================================================
   Main Content Layout
   ========================================================================== */
main {
  margin-left: var(--rail-width);
  padding: calc(var(--bar-height) + 40px) 40px 96px;
}
main > * { width: min(100%, var(--content-width)); margin-inline: auto; }

/* ==========================================================================
   Course Hero / Editorial Intro Section
   No gradients, no neon, no 3D glassmorphism.
   Refined document-style editorial header.
   ========================================================================== */
.course-hero, .course-intro {
  position: relative;
  padding: clamp(32px, 5vw, 56px);
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  box-shadow: var(--shadow-subtle);
}

.intro-copy h1, .course-hero h1 {
  max-width: 820px;
  margin: 12px 0 16px;
  font: 600 clamp(34px, 5.2vw, 58px)/1.08 var(--font-display);
  letter-spacing: -.035em;
  color: var(--ink);
}
.intro-copy > p:last-child, .course-hero p {
  max-width: 740px;
  margin: 0;
  color: var(--ink-soft);
  font-size: clamp(16px, 1.8vw, 18px);
  line-height: 1.6;
}
.eyebrow {
  margin: 0;
  color: var(--ink-muted);
  font-size: 11.5px;
  font-weight: 750;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.chapter-route {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 28px;
}
.chapter-route a {
  display: grid;
  gap: 3px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--ink);
  text-decoration: none;
  transition: border-color .15s ease, background-color .15s ease, transform .15s ease;
}
.chapter-route a:hover {
  border-color: var(--ink);
  background: var(--surface);
  transform: translateY(-1px);
}
.chapter-route span {
  font: 700 11.5px var(--font-mono);
  color: var(--ink-muted);
}
.chapter-route strong {
  font-size: 15px;
  font-weight: 650;
  color: var(--ink);
}
.chapter-route small {
  color: var(--ink-muted);
  font-size: 12.5px;
  line-height: 1.35;
}

.scope-note {
  margin: 22px auto 0;
  padding: 14px 18px;
  border: 1px solid var(--pastel-yellow-border);
  border-left: 4px solid var(--pastel-yellow-text);
  border-radius: var(--radius-sm);
  background: var(--pastel-yellow-bg);
  color: var(--pastel-yellow-text);
  font-size: 14px;
}
.scope-note strong {
  color: var(--pastel-yellow-text);
  font-weight: 700;
}

/* ==========================================================================
   Chapter Headers
   ========================================================================== */
.chapter { padding-top: 64px; }
.chapter-header, .reference-section > header {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.chapter-number {
  flex: 0 0 auto;
  color: var(--ink-muted);
  font: 600 clamp(44px, 5.5vw, 68px)/.85 var(--font-display);
  opacity: 0.45;
}
.chapter-header h2, .reference-section h2 {
  margin: 4px 0 8px;
  font: 600 clamp(28px, 3.8vw, 44px)/1.1 var(--font-display);
  letter-spacing: -.025em;
  color: var(--ink);
}
.chapter-header p, .reference-section > header p:last-child {
  max-width: 740px;
  margin: 0;
  color: var(--ink-soft);
  font-size: 15.5px;
}

/* ==========================================================================
   Topic Cards (Bento-box Style, 1px solid #EAEAEA, no heavy dropshadows)
   ========================================================================== */
.topic {
  position: relative;
  margin: 0 0 32px;
  padding: clamp(24px, 4vw, 38px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-subtle);
  transition: border-color .15s ease;
}
.topic:hover {
  border-color: var(--line-strong);
}
.topic.is-complete {
  border-color: var(--pastel-green-border);
}
.topic.is-complete::before {
  content: "Complete";
  position: absolute;
  right: 18px;
  top: -11px;
  padding: 2px 10px;
  border-radius: 9999px;
  background: var(--pastel-green-bg);
  border: 1px solid var(--pastel-green-border);
  color: var(--pastel-green-text);
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.topic-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
}
.topic-code {
  flex: 0 0 auto;
  margin: 4px 0 0;
  color: var(--pastel-blue-text);
  font: 700 11.5px var(--font-mono);
  background: var(--pastel-blue-bg);
  border: 1px solid var(--pastel-blue-border);
  padding: 2px 8px;
  border-radius: 9999px;
  letter-spacing: 0.05em;
}
.topic-header h3 {
  flex: 1;
  margin: 0 0 14px;
  font: 600 clamp(24px, 3vw, 32px)/1.18 var(--font-display);
  letter-spacing: -.02em;
  color: var(--ink);
}
.topic h4 {
  margin: 1.6em 0 .5em;
  font-size: 16.5px;
  line-height: 1.35;
  color: var(--ink);
  font-weight: 650;
}
.topic p { margin: .75em 0; color: var(--ink); }
.topic ul, .topic ol { padding-left: 1.4em; color: var(--ink); }
.topic li { margin-bottom: 0.35em; }

.topic-actions { display: flex; flex: 0 0 auto; gap: 6px; }
.topic-action {
  padding: 6px 11px;
  font-size: 12.5px;
  font-weight: 550;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  border: 1px solid var(--line);
}
.topic-action:hover {
  border-color: var(--ink);
}
.topic-action[aria-pressed="true"].complete-button {
  border-color: var(--pastel-green-border);
  background: var(--pastel-green-bg);
  color: var(--pastel-green-text);
  font-weight: 650;
}
.topic-action[aria-pressed="true"].bookmark-button {
  border-color: var(--pastel-yellow-border);
  background: var(--pastel-yellow-bg);
  color: var(--pastel-yellow-text);
  font-weight: 700;
}

/* ==========================================================================
   Bento Box Feature Grids
   ========================================================================== */
.two-column, .three-column, .comparison-grid, .master-grid {
  display: grid;
  gap: 14px;
  margin: 22px 0;
}
.two-column, .comparison-grid, .master-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.three-column { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.two-column > section, .three-column > section, .comparison-grid > section, .master-grid > section {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}
.two-column h4, .three-column h4, .comparison-grid h4, .master-grid h3 {
  margin-top: 0;
  color: var(--ink);
  font-size: 15.5px;
}

.concept-grid { display: grid; gap: 12px; margin: 20px 0; }
.concept-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.concept-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.concept-grid > section {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}
.concept-grid h4 { margin-top: 0; color: var(--ink); font-size: 15.5px; }

/* ==========================================================================
   Callouts (Muted Pastels per Minimalist Protocol)
   ========================================================================== */
.callout {
  margin: 22px 0;
  padding: 14px 18px;
  border: 1px solid var(--pastel-blue-border);
  border-left: 3px solid var(--pastel-blue-text);
  border-radius: var(--radius-sm);
  background: var(--pastel-blue-bg);
  color: var(--pastel-blue-text);
}
.callout strong { display: block; margin-bottom: 4px; font-weight: 700; color: var(--pastel-blue-text); }
.callout p { color: var(--pastel-blue-text); }
.callout p:last-child { margin-bottom: 0; }

.callout.warning, .callout.exam, .callout.important, .exam-tip {
  border-color: var(--pastel-yellow-border);
  border-left-color: var(--pastel-yellow-text);
  background: var(--pastel-yellow-bg);
  color: var(--pastel-yellow-text);
}
.callout.warning strong, .callout.exam strong, .callout.important strong, .exam-tip strong {
  color: var(--pastel-yellow-text);
}
.callout.warning p, .callout.exam p, .callout.important p, .exam-tip p {
  color: var(--pastel-yellow-text);
}

.callout.success, .callout.method {
  border-color: var(--pastel-green-border);
  border-left-color: var(--pastel-green-text);
  background: var(--pastel-green-bg);
  color: var(--pastel-green-text);
}
.callout.success strong, .callout.method strong {
  color: var(--pastel-green-text);
}
.callout.success p, .callout.method p {
  color: var(--pastel-green-text);
}

.protocol-flow {
  margin: 20px 0;
  padding: 14px 16px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--ink);
  font-family: var(--font-mono);
  text-align: center;
  font-size: 13.5px;
}
.formula-box {
  margin: 18px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  text-align: center;
  color: var(--ink);
}
.quick-revision {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 14px;
}
.quick-revision strong { color: var(--ink); font-size: 14px; }

/* ==========================================================================
   Figures & Diagram Presentation
   Clean editorial container, white image pad, muted typography
   ========================================================================== */
.diagram, .course-figure {
  margin: 24px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  text-align: center;
  transition: border-color .15s ease;
}
.diagram:hover, .course-figure:hover {
  border-color: var(--line-strong);
}
.course-figure .image-button, .diagram .image-button {
  display: block;
  background: #FFFFFF;
  border-radius: 4px;
  padding: 12px;
  border: 1px solid var(--line);
}
.course-figure img, .diagram img {
  display: block;
  width: auto;
  max-height: 560px;
  margin: auto;
  object-fit: contain;
}
.course-figure figcaption, .diagram figcaption {
  padding: 10px 4px 2px;
  color: var(--ink-muted);
  font-size: 13px;
  line-height: 1.45;
  text-align: left;
}
.split-figures, .diagram-strip { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.split-figures .course-figure, .diagram-strip .course-figure { margin-block: 14px; }
.image-button {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}
.image-button:hover img { opacity: .95; }

/* ==========================================================================
   Tables
   ========================================================================== */
.table-scroll, .table-wrap {
  width: 100%;
  overflow-x: auto;
  margin: 20px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
table { width: 100%; border-collapse: collapse; min-width: 560px; }
th, td { padding: 11px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; font-size: 14px; }
th {
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
td { color: var(--ink); }
tr:hover td { background: var(--surface-soft); }
tr:last-child td { border-bottom: 0; }

/* ==========================================================================
   Worked Numericals & Practice Problems
   ========================================================================== */
.worked-example {
  margin: 24px 0;
  padding: 22px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--pastel-yellow-text);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}
.worked-example h4 {
  margin-top: 0;
  color: var(--ink);
  font-size: 17px;
  font-weight: 700;
}
.worked-example small {
  display: block;
  margin-top: 12px;
  color: var(--ink-muted);
  font-size: 12.5px;
}
.answer {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 4px;
  background: var(--pastel-green-bg);
  border: 1px solid var(--pastel-green-border);
  color: var(--pastel-green-text);
  font-weight: 550;
  font-size: 14px;
}
.answer strong { color: var(--pastel-green-text); }

.derivation, .practice {
  margin: 16px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}
.derivation summary, .practice summary {
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 650;
  color: var(--ink);
  font-size: 14px;
  border-radius: var(--radius-sm);
  transition: color .12s ease;
}
.derivation summary:hover, .practice summary:hover { color: var(--pastel-blue-text); }
.derivation > :not(summary), .practice > :not(summary) { margin-inline: 16px; }
.derivation > :last-child, .practice > :last-child { margin-bottom: 16px; }

/* ==========================================================================
   Reference, Index & Revision Sections
   ========================================================================== */
.unit-revision, .reference-section { padding-top: 60px; }
.revision-grid, .formula-grid, .diagram-index, .coverage-grid, .glossary-grid, .numerical-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.revision-card, .formula-card, .diagram-link, .coverage-grid > section, .glossary-grid > div, .numerical-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  box-shadow: var(--shadow-subtle);
  transition: border-color .15s ease, transform .15s cubic-bezier(0.16, 1, 0.3, 1);
}
.revision-card h3, .coverage-grid h3 { margin-top: 0; color: var(--ink); font-size: 17px; }
.formula-card, .diagram-link { display: grid; gap: 5px; }
.formula-card code {
  color: var(--pastel-blue-text);
  background: var(--pastel-blue-bg);
  border-color: var(--pastel-blue-border);
  padding: 2px 6px;
  border-radius: 4px;
  width: fit-content;
}
.formula-card span, .diagram-link span, .numerical-card small { color: var(--ink-muted); font-size: 12.5px; }
.formula-card:hover, .diagram-link:hover, .numerical-card:hover, .revision-card:hover {
  border-color: var(--ink);
  transform: translateY(-1px);
}
.diagram-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.diagram-links a {
  padding: 12px 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  font-size: 13.5px;
  transition: border-color .15s ease;
}
.diagram-links a:hover { border-color: var(--ink); }

.filter-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.filter-button {
  padding: 6px 14px;
  font-weight: 550;
  font-size: 13px;
  border-radius: var(--radius-sm);
}
.filter-button[aria-pressed="true"] {
  border-color: var(--primary-btn-bg);
  background: var(--primary-btn-bg);
  color: var(--primary-btn-text);
  font-weight: 650;
}

.numerical-card { display: block; }
.numerical-card strong { display: block; font-size: 14.5px; color: var(--ink); }
.numerical-card span { display: block; margin: 4px 0; color: var(--ink-soft); font-size: 13.5px; }
.numerical-card small { display: block; color: var(--ink-muted); font-size: 12px; }

.coverage-grid > section { box-shadow: none; }
.coverage-grid a, .coverage-grid span { display: block; padding: 3px 0; }
.coverage-grid a { color: var(--pastel-green-text); text-decoration: none; font-weight: 600; font-size: 13.5px; }
.coverage-grid a:hover { text-decoration: underline; }
.coverage-grid span { color: var(--ink-muted); font-size: 12.5px; }

.glossary-grid dt, .glossary dt { font-weight: 750; color: var(--ink); font-size: 14.5px; }
.glossary-grid dd, .glossary dd { margin: 4px 0 0; color: var(--ink-soft); font-size: 13.5px; }
.glossary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.glossary > div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.master-review { margin-top: 40px; }
.source-note {
  margin-top: 22px;
  padding: 16px 20px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}
.source-note p { margin-bottom: 0; color: var(--ink-muted); font-size: 13.5px; }

/* ==========================================================================
   Lightbox Modal
   ========================================================================== */
.lightbox {
  width: min(94vw, 1080px);
  max-height: 90vh;
  padding: 44px 16px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-hover);
}
.lightbox::backdrop {
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.lightbox img {
  display: block;
  max-height: 70vh;
  margin: auto;
  object-fit: contain;
  background: #FFFFFF;
  border-radius: 4px;
  padding: 8px;
}
.lightbox p { margin: 12px auto 0; max-width: 840px; text-align: center; color: var(--ink); font-size: 13.5px; }
.lightbox-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 34px;
  min-height: 34px;
  font-size: 20px;
  line-height: 1;
}

/* ==========================================================================
   Toast / Live Announcement
   ========================================================================== */
.live-region {
  position: fixed;
  z-index: 300;
  right: 18px;
  bottom: 18px;
  max-width: 320px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--primary-btn-bg);
  color: var(--primary-btn-text);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-hover);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: all .2s cubic-bezier(0.16, 1, 0.3, 1);
  font-size: 13px;
  font-weight: 550;
}
.live-region.visible { opacity: 1; transform: translateY(0); }
.mobile-only { display: none; }

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */
@media (max-width: 1040px) {
  .utility-bar { grid-template-columns: auto minmax(200px, 1fr) auto; padding-inline: 16px; }
  .brand small { display: none; }
}

@media (max-width: 899px) {
  :root { --bar-height: 60px; }
  .mobile-only { display: inline-grid; place-items: center; }
  .utility-bar { grid-template-columns: auto 1fr auto; gap: 8px; }
  .brand strong { font-size: 13.5px; }
  .search-shell {
    grid-column: 1 / -1;
    position: fixed;
    top: var(--bar-height);
    left: 0;
    padding: 8px 12px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
  }
  .search-results { inset-inline: 12px; top: calc(100% - 3px); }
  .sidebar {
    top: 0;
    z-index: 130;
    width: min(86vw, 320px);
    transform: translateX(-105%);
    transition: transform .22s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: var(--shadow-hover);
  }
  .drawer-open .sidebar { transform: translateX(0); }
  .sidebar-scrim {
    position: fixed;
    z-index: 120;
    inset: 0;
    display: block;
    border: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(2px);
  }
  main { margin-left: 0; padding: calc(var(--bar-height) + 80px) 16px 64px; }
}

@media (max-width: 680px) {
  .utility-actions .desktop-label { display: none; }
  .course-hero, .course-intro { padding: 24px 18px; border-radius: var(--radius-sm); }
  .chapter-route { grid-template-columns: 1fr; }
  .topic { padding: 20px 16px; }
  .topic-header { display: block; }
  .topic-actions { margin: 12px 0 8px; }
  .two-column, .three-column, .comparison-grid, .master-grid,
  .revision-grid, .formula-grid, .diagram-index, .diagram-links,
  .coverage-grid, .glossary-grid, .glossary, .numerical-grid,
  .concept-grid.two, .concept-grid.three, .split-figures, .diagram-strip {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

@media print {
  :root {
    --ink: #000000;
    --ink-soft: #333333;
    --paper: #ffffff;
    --surface: #ffffff;
    --surface-soft: #ffffff;
    --line: #cccccc;
  }
  .utility-bar, .sidebar, .sidebar-scrim, .drawer-scrim, .topic-actions, .live-region { display: none !important; }
  main { margin: 0; padding: 0; }
  main > * { width: 100%; }
  .course-hero, .course-intro {
    padding: 20px;
    border: 1px solid #cccccc;
    background: #ffffff;
    color: #000000;
    box-shadow: none;
  }
  .chapter-route a { border: 1px solid #cccccc; color: #000000; }
  .topic, .revision-card, .formula-card, .diagram-link, .numerical-card { break-inside: avoid; box-shadow: none; }
  .chapter { break-before: page; }
  details > * { display: block !important; }
}
