/* ============================================================
   Ultrasound & NDT Toolkit — Global Stylesheet
   ============================================================ */

/* --- Tokens --- */
:root {
  color-scheme: light;
  --brand-navy:   #0f2d5e;
  --brand-blue:   #1e40af;
  --brand-cyan:   #0891b2;
  --brand-teal:   #0d9488;
  --accent-light: #e0f2fe;
  --bg:           #f8fafc;
  --bg-card:      #ffffff;
  --text:         #0f172a;
  --text-muted:   #64748b;
  --text-soft:    #475569;
  --border:       #e2e8f0;
  --radius:       10px;
  --radius-lg:    16px;
  --shadow:       0 2px 12px rgba(0,0,0,.08);
  --shadow-hover: 0 8px 28px rgba(14,65,163,.15);
  --nav-h:        64px;
  --font:         -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Inter', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', 'Fira Code', 'Courier New', monospace;

  /* Apple-style motion: a symmetric ease-in/ease-out, not the browser
     default `ease`. Used for hover/theme transitions site-wide. */
  --ease: cubic-bezier(.4, 0, .6, 1);

  /* RGB triplets (no #) so translucent/frosted-glass surfaces can use
     rgba(var(--x-rgb), alpha) — a plain hex custom property can't be
     split into components for that. */
  --bg-card-rgb:    255, 255, 255;
  --brand-navy-rgb: 15, 45, 94;

  /* Surfaces that intentionally stay light in both themes — canvases, SVG
     diagrams, and KaTeX equations draw fixed-color content that assumes a
     paper-white backing, so their containers don't invert. */
  --surface-canvas: #ffffff;
  --surface-screen:  #edf6ff;
  --surface-canvas-text: #0f172a;

  /* Pastel semantic callouts (insight boxes, concept chips, highlight cards) */
  --pastel-blue-bg:     #eff6ff;
  --pastel-blue-border: #bfdbfe;
  --pastel-blue-text:   #1e3a8a;
  --pastel-green-bg:     #f0fdf4;
  --pastel-green-border: #bbf7d0;
  --pastel-green-text:   #166534;
  --pastel-purple-bg:     #faf5ff;
  --pastel-purple-border: #ddd6fe;
  --pastel-purple-text:   #5b21b6;
  --pastel-orange-bg:     #fff7ed;
  --pastel-orange-border: #fed7aa;
  --pastel-orange-text:   #c2410c;

  /* Navy used as heading/result-value text on a light card — needs to lift
     to a lighter blue on dark cards so it doesn't go dark-on-dark. */
  --heading-accent: var(--brand-navy);

  --transition-theme: background-color .25s var(--ease), border-color .25s var(--ease), color .25s var(--ease), box-shadow .25s var(--ease);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg:           #0a1120;
  --bg-card:      #131d31;
  --bg-card-rgb:  19, 29, 49;
  --text:         #e7edf6;
  --text-muted:   #94a3b8;
  --text-soft:    #b6c2d4;
  --border:       #223049;
  --accent-light: rgba(34,211,238,.14);
  --shadow:       0 2px 16px rgba(0,0,0,.45);
  --shadow-hover: 0 10px 34px rgba(34,211,238,.16);

  /* Diagrams/canvases/KaTeX stay legible paper surfaces even in dark mode */
  --surface-canvas: #eef2f7;
  --surface-screen:  #dbe8f7;
  --surface-canvas-text: #0f172a;

  --pastel-blue-bg:     rgba(59,130,246,.16);
  --pastel-blue-border: rgba(96,165,250,.35);
  --pastel-blue-text:   #93c5fd;
  --pastel-green-bg:     rgba(34,197,94,.16);
  --pastel-green-border: rgba(74,222,128,.35);
  --pastel-green-text:   #86efac;
  --pastel-purple-bg:     rgba(167,139,250,.18);
  --pastel-purple-border: rgba(196,181,253,.35);
  --pastel-purple-text:   #c4b5fd;
  --pastel-orange-bg:     rgba(251,146,60,.18);
  --pastel-orange-border: rgba(253,186,116,.35);
  --pastel-orange-text:   #fdba74;

  --heading-accent: #7dd3fc;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  transition: var(--transition-theme);
}

::selection { background: var(--brand-cyan); color: #fff; }

:focus-visible {
  outline: 2.5px solid var(--brand-cyan);
  outline-offset: 2px;
  border-radius: 4px;
}
a { color: var(--brand-blue); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
ul { list-style: none; }

/* --- Typography --- */
h1 { font-size: clamp(1.9rem, 4vw, 2.8rem); font-weight: 800; line-height: 1.15; letter-spacing: -.02em; }
h2 { font-size: clamp(1.3rem, 2.5vw, 1.75rem); font-weight: 700; letter-spacing: -.015em; }
h3 { font-size: 1.1rem; font-weight: 600; }
p  { color: var(--text); }

/* ============================================================
   NAVBAR
   ============================================================ */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  padding: 0 2rem;
  gap: 2rem;
  box-shadow: 0 2px 10px rgba(0,0,0,.25);
  transition: box-shadow .2s var(--ease);
}
/* Tinted frosted glass on a pseudo-element layer, not on `.nav` itself —
   keeps the navy brand color but lets scrolled content show through,
   softened and saturated, instead of a flat fill. `backdrop-filter`
   directly on `.nav` would create a new containing block for its
   `position: fixed` mega-menu dropdown (.theory-dropdown), breaking its
   viewport-relative positioning; the pseudo-element avoids that. */
.nav::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: rgba(var(--brand-navy-rgb), .95);
  backdrop-filter: saturate(1.8) blur(20px);
  -webkit-backdrop-filter: saturate(1.8) blur(20px);
}
.nav.scrolled { box-shadow: 0 4px 20px rgba(0,0,0,.35); }

.nav-brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  color: #fff;
  font-weight: 800;
  font-size: 1.1rem;
  white-space: nowrap;
}
.nav-brand svg { width: 28px; height: 28px; flex-shrink: 0; }

.nav-links {
  display: flex;
  align-items: center;
  gap: .25rem;
  margin-left: auto;
}
/* Every item is its own flex row so the link text centers consistently
   whether the <li> holds a plain <a> or (Theory) an <a> plus a chevron
   button — without this, the chevron's fixed height inflates only the
   Theory <li>'s line box, leaving its link text sitting visibly lower
   than its siblings. */
.nav-links li { display: flex; align-items: center; }
.nav-links a {
  color: #cbd5e1;
  padding: .45rem .85rem;
  border-radius: 6px;
  font-size: .9rem;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-links a:hover,
.nav-links a.active {
  background: rgba(255,255,255,.12);
  color: #fff;
  text-decoration: none;
}
.nav-links a.active { background: var(--brand-cyan); color: #fff; }

/* Theory mega-menu — built once in main.js and shared by every page */
.theory-menu { position: relative; display: flex; align-items: center; }
.theory-menu > a { padding-right: .35rem; }
.theory-menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 25px;
  height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  transition: color .15s, transform .15s;
}
.theory-menu:hover .theory-menu-toggle,
.theory-menu:focus-within .theory-menu-toggle { color: #fff; }
.theory-menu-toggle svg { width: 12px; height: 12px; transition: transform .18s; }
.theory-menu.open .theory-menu-toggle svg { transform: rotate(180deg); }
.theory-dropdown {
  position: fixed;
  top: var(--nav-h);
  /* left is computed in JS (positionTheoryDropdown) and clamped to the
     viewport, centered on the actual trigger — NOT viewport-centered —
     so the open/close hover-tracking below lines up with where the
     dropdown really renders. Falls back to 50% before JS runs, while
     it's still invisible/inert. */
  left: var(--dd-left, 50%);
  width: min(1080px, calc(100vw - 2rem));
  padding: 1rem;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: .7rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: 3px solid var(--brand-cyan);
  border-radius: 0 0 12px 12px;
  box-shadow: 0 18px 40px rgba(15,45,94,.2);
  transform: translateY(-6px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .16s, transform .16s, visibility .16s, background-color .25s ease;
}
.theory-menu:focus-within .theory-dropdown,
.theory-menu.open .theory-dropdown {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}
.theory-dropdown-group {
  min-width: 0;
  padding: .65rem;
  border-radius: 9px;
  background: var(--bg);
}
.theory-dropdown-title {
  display: block;
  margin: 0 0 .4rem;
  padding: 0 .35rem .45rem;
  border-bottom: 1px solid var(--border);
  color: var(--brand-cyan);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.nav-links .theory-dropdown a {
  display: block;
  padding: .34rem .4rem;
  border-radius: 5px;
  color: var(--text-muted);
  font-size: .78rem;
  line-height: 1.3;
}
.nav-links .theory-dropdown a:hover,
.nav-links .theory-dropdown a:focus {
  background: var(--accent-light);
  color: var(--pastel-blue-text);
}

/* ============================================================
   THEME TOGGLE
   ============================================================ */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  margin-left: .25rem;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  color: #e0f2fe;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s var(--ease), border-color .15s var(--ease), transform .15s var(--ease);
}
.theme-toggle:hover { background: rgba(255,255,255,.16); border-color: rgba(255,255,255,.3); }
.theme-toggle:active { transform: scale(.92); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

.nav-hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  margin-left: auto;
  color: #fff;
  padding: .4rem;
}

/* ============================================================
   HERO
   ============================================================ */
.hero {
  position: relative;
  background: linear-gradient(135deg, var(--brand-navy) 0%, #0c4a6e 60%, #0e7490 100%);
  color: #fff;
  padding: 5rem 2rem 4rem;
  overflow: hidden;
  text-align: center;
}
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 200'%3E%3Cpath fill='rgba(255,255,255,.04)' d='M0,100 C360,160 720,40 1080,100 C1260,130 1380,90 1440,80 L1440,200 L0,200Z'/%3E%3Cpath fill='rgba(255,255,255,.03)' d='M0,130 C300,70 720,170 1080,120 C1260,95 1380,140 1440,130 L1440,200 L0,200Z'/%3E%3C/svg%3E") bottom/cover no-repeat;
}
.hero-inner { position: relative; max-width: 800px; margin: 0 auto; }
.hero-tag {
  display: inline-block;
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.25);
  color: #7dd3fc;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: .3rem .9rem;
  border-radius: 999px;
  margin-bottom: 1.25rem;
}
.hero h1 { color: #fff; margin-bottom: 1rem; }
.hero p.lead {
  font-size: 1.1rem;
  color: #bae6fd;
  max-width: 600px;
  margin: 0 auto 2rem;
}
.hero-cta {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .65rem 1.4rem;
  border-radius: 999px;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .18s var(--ease);
  border: 2px solid transparent;
  text-decoration: none !important;
}
.btn-primary {
  background: var(--brand-cyan);
  color: #fff;
  border-color: var(--brand-cyan);
}
.btn-primary:hover { background: #0e7490; border-color: #0e7490; }
.btn-outline {
  background: transparent;
  color: #fff;
  border-color: rgba(255,255,255,.4);
}
.btn-outline:hover { background: rgba(255,255,255,.1); border-color: #fff; }
.btn-sm { padding: .45rem 1rem; font-size: .85rem; }

/* ============================================================
   LAYOUT CONTAINERS
   ============================================================ */
.container { max-width: 1200px; margin: 0 auto; padding: 0 2rem; }
.section { padding: 4rem 0; }
.section-title {
  text-align: center;
  margin-bottom: 2.5rem;
}
.section-title h2 { margin-bottom: .4rem; }
.section-title p { max-width: 560px; margin: 0 auto; }

/* ============================================================
   CARDS
   ============================================================ */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 1.25rem;
}
.card-grid-2 { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  transition: transform .18s, box-shadow .18s, var(--transition-theme);
  display: flex;
  flex-direction: column;
  gap: .6rem;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
}
.card-icon {
  font-size: 1.8rem;
  line-height: 1;
  margin-bottom: .2rem;
}
.card h3 { color: var(--text); }
.card p { font-size: .9rem; flex: 1; }
.card-tags { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .4rem; }
.tag {
  background: var(--pastel-blue-bg);
  color: var(--pastel-blue-text);
  font-size: .72rem;
  font-weight: 600;
  padding: .2rem .6rem;
  border-radius: 999px;
}
.tag-green { background: var(--pastel-green-bg); color: var(--pastel-green-text); }
.tag-orange { background: var(--pastel-orange-bg); color: var(--pastel-orange-text); }
.tag-purple { background: var(--pastel-purple-bg); color: var(--pastel-purple-text); }

.card-link {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  color: var(--brand-cyan);
  font-size: .88rem;
  font-weight: 600;
  margin-top: .5rem;
  text-decoration: none !important;
}
.card-link:hover { color: var(--brand-blue); }
.card-link::after { content: '→'; }

/* ============================================================
   PATHWAY STRIP (homepage quick-access)
   ============================================================ */
.pathways {
  background: var(--brand-navy);
  color: #fff;
  padding: 2.5rem 2rem;
}
.pathways h2 { color: #fff; text-align: center; margin-bottom: 1.5rem; }
.pathway-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  max-width: 1200px;
  margin: 0 auto;
}
.pathway-card {
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  cursor: pointer;
  transition: background .15s var(--ease);
  text-decoration: none !important;
  display: block;
}
.pathway-card:hover { background: rgba(255,255,255,.14); }
.pathway-card .pw-icon { font-size: 1.6rem; margin-bottom: .5rem; }
.pathway-card h3 { color: #fff; font-size: .95rem; margin-bottom: .25rem; }
.pathway-card p  { color: #94a3b8; font-size: .82rem; }

/* ============================================================
   CALCULATOR COMPONENTS
   ============================================================ */
.calc-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
}
.calc-box h3 { margin-bottom: 1.25rem; color: var(--heading-accent); }
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: .35rem;
}
.form-group input,
.form-group select {
  width: 100%;
  padding: .55rem .85rem;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: .95rem;
  color: var(--text);
  background: var(--bg-card);
  transition: border-color .15s, var(--transition-theme);
}
.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--brand-cyan);
  box-shadow: 0 0 0 3px rgba(8,145,178,.18);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.calc-result {
  margin-top: 1.25rem;
  padding: 1rem 1.25rem;
  background: var(--accent-light);
  border-radius: 8px;
  border-left: 4px solid var(--brand-cyan);
}
.calc-result .result-label { font-size: .78rem; font-weight: 600; color: var(--brand-cyan); text-transform: uppercase; letter-spacing: .06em; }
.calc-result .result-value { font-size: 1.5rem; font-weight: 800; color: var(--heading-accent); }
.calc-result .result-unit  { font-size: .9rem; font-weight: 500; color: var(--text-muted); margin-left: .3rem; }
.calc-formula {
  margin-top: 1rem;
  padding: .75rem 1rem;
  background: var(--bg);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: .88rem;
  color: var(--text-muted);
}
.calc-desc {
  font-size: .82rem;
  color: var(--text-muted);
  margin-top: .5rem;
}

/* ============================================================
   THEORY PAGE
   ============================================================ */
.topic-sidebar {
  position: sticky;
  top: calc(var(--nav-h) + 1rem);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  max-height: calc(100vh - var(--nav-h) - 2rem);
  overflow-y: auto;
}
.topic-sidebar h4 { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin-bottom: .75rem; }
.topic-sidebar a {
  display: block;
  padding: .4rem .6rem;
  color: var(--text-muted);
  font-size: .88rem;
  border-radius: 5px;
  transition: background .12s, color .12s;
}
.topic-sidebar a:hover, .topic-sidebar a.active {
  background: var(--accent-light);
  color: var(--brand-blue);
  text-decoration: none;
}
.two-col-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 2rem;
  align-items: start;
}
.theory-section { margin-bottom: 3rem; }
.theory-section h2 { border-bottom: 2px solid var(--border); padding-bottom: .5rem; margin-bottom: 1rem; }
.theory-section h3 { margin: 1.25rem 0 .5rem; color: var(--heading-accent); }
.theory-section p, .theory-section li { color: var(--text); font-size: .95rem; }
.theory-section ul { margin-left: 1.25rem; list-style: disc; }
.theory-section ul li { margin-bottom: .3rem; }
.eq-box {
  background: var(--surface-canvas);
  color: var(--surface-canvas-text);
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand-cyan);
  border-radius: 8px;
  padding: .9rem 1.5rem;
  margin: .75rem 0;
  overflow-x: auto;
  text-align: center;
  transition: var(--transition-theme);
}
.eq-box .katex-display { margin: 0; }
.eq-box .katex { font-size: 1.05rem; }
.callout {
  background: var(--pastel-blue-bg);
  border-left: 4px solid var(--brand-blue);
  border-radius: 0 8px 8px 0;
  padding: .9rem 1.25rem;
  margin: 1rem 0;
  font-size: .9rem;
  color: var(--text);
  transition: var(--transition-theme);
}
.callout strong { color: var(--pastel-blue-text); }

/* ============================================================
   RESOURCES PAGE
   ============================================================ */
.resource-item {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  padding: 1rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s;
}
.resource-item:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.resource-icon {
  font-size: 1.6rem;
  flex-shrink: 0;
  margin-top: .1rem;
}
.resource-body h4 { font-size: 1rem; color: var(--text); margin-bottom: .2rem; }
.resource-body p  { font-size: .85rem; margin: 0; }
.resource-list { display: flex; flex-direction: column; gap: .85rem; }

/* ============================================================
   FOOTER
   ============================================================ */
.footer {
  background: var(--brand-navy);
  color: #94a3b8;
  padding: 2.5rem 2rem;
  margin-top: 4rem;
  text-align: center;
  font-size: .85rem;
}
.footer p { color: #94a3b8; }
.footer a { color: #7dd3fc; }
.footer .footer-links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

/* ============================================================
   PAGE HEADER (inner pages)
   ============================================================ */
.page-header {
  background: linear-gradient(135deg, var(--brand-navy) 0%, #0c4a6e 100%);
  color: #fff;
  padding: 3rem 2rem 2.5rem;
  text-align: center;
}
.page-header h1 { color: #fff; font-size: clamp(1.6rem, 3vw, 2.2rem); }
.page-header p  { color: #bae6fd; font-size: 1rem; margin-top: .5rem; }

/* ============================================================
   SEARCH BAR
   ============================================================ */
.search-bar {
  position: relative;
  max-width: 440px;
  margin: 1.5rem auto 0;
}
.search-bar input {
  width: 100%;
  padding: .65rem 1rem .65rem 2.7rem;
  border-radius: 8px;
  border: none;
  font-size: .95rem;
  background: rgba(255,255,255,.95);
  color: #0f172a;
}
.search-bar input:focus { outline: 2px solid var(--brand-cyan); }
.search-bar svg {
  position: absolute;
  left: .85rem;
  top: 50%;
  transform: translateY(-50%);
  color: #64748b;
  width: 16px;
  height: 16px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .nav { padding: 0 1rem; gap: .5rem; }
  .theme-toggle { width: 34px; height: 34px; margin-left: 0; }
  .theme-toggle svg { width: 16px; height: 16px; }
  .nav-links { display: none; }
  .nav-links.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: var(--nav-h);
    left: 0;
    right: 0;
    background: var(--brand-navy);
    padding: 1rem;
    gap: .25rem;
    border-top: 1px solid rgba(255,255,255,.1);
  }
  .nav-hamburger { display: flex; }
  .theory-menu { display: grid; grid-template-columns: 1fr auto; }
  .theory-menu > a { padding-right: .85rem; }
  .theory-menu-toggle { width: 38px; height: 36px; }
  .theory-dropdown {
    position: static;
    grid-column: 1 / -1;
    width: auto;
    max-height: 0;
    padding: 0 .45rem;
    grid-template-columns: 1fr;
    gap: .4rem;
    overflow: hidden;
    border: 0;
    border-radius: 8px;
    box-shadow: none;
    transform: none;
    opacity: 1;
    visibility: visible;
    pointer-events: none;
    transition: max-height .22s, padding .22s;
  }
  .theory-menu:hover .theory-dropdown,
  .theory-menu:focus-within .theory-dropdown { max-height: 0; padding: 0 .45rem; pointer-events: none; }
  .theory-menu.open .theory-dropdown {
    max-height: 900px;
    padding: .55rem;
    pointer-events: auto;
    transform: none;
  }
  .theory-dropdown-group { padding: .45rem; }
  .two-col-layout { grid-template-columns: 1fr; }
  .topic-sidebar { position: static; max-height: none; }
  .form-row { grid-template-columns: 1fr; }
}
