/* ==========================================================================
   NaWi Thema 7: pH-Wert in der Haarpflege — Chemistry Lab & Source Archive
   Dual Theme: Labor-Hell (Cream Silk Lab) & Tafel-Dunkel (Slate Chalkboard)
   ========================================================================== */

:root {
  --bg: #faf6f0;
  --bg-alt: #f2ece3;
  --surface: #ffffff;
  --surface-soft: #f7f3ec;
  --surface-elevated: rgba(255, 255, 255, 0.86);
  --border: #e4dbcf;
  --border-strong: #cfc2b2;

  --text: #10243e;
  --text-muted: #4b5d73;
  --text-soft: #6c7d91;

  --navy: #0f2d5c;
  --navy-deep: #0b1f40;
  --accent: #0f766e;
  --accent-bright: #14b8a6;
  --accent-indigo: #2563eb;
  --copper: #a16236;
  --amber: #d97706;
  --acid: #dc2626;
  --optimal: #059669;
  --alkaline: #3b49df;

  --chalk-bg: #172329;
  --chalk-border: #6d4c33;
  --chalk-text: #f8fafc;

  --shadow-sm: 0 4px 16px rgba(15, 45, 92, 0.06);
  --shadow-md: 0 12px 32px rgba(15, 45, 92, 0.09);
  --shadow-lg: 0 24px 56px rgba(15, 45, 92, 0.14);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-pill: 999px;

  --font-display: "Space Grotesk", system-ui, -apple-system, sans-serif;
  --font-body: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;

  --font-scale: 1;
  --transition: 240ms cubic-bezier(0.22, 1, 0.36, 1);
}

html[data-theme="dark"] {
  --bg: #0c131c;
  --bg-alt: #101a26;
  --surface: #152130;
  --surface-soft: #1a293b;
  --surface-elevated: rgba(21, 33, 48, 0.88);
  --border: #25364a;
  --border-strong: #374f6b;

  --text: #f1f5f9;
  --text-muted: #b3c2d4;
  --text-soft: #8599b2;

  --navy: #93c5fd;
  --navy-deep: #070c12;
  --accent: #2dd4bf;
  --accent-bright: #5eead4;
  --accent-indigo: #60a5fa;
  --copper: #e2a472;
  --amber: #fbbf24;
  --acid: #fb7185;
  --optimal: #34d399;
  --alkaline: #818cf8;

  --chalk-bg: #101c22;
  --chalk-border: #8b6345;
  --chalk-text: #f8fafc;

  --shadow-sm: 0 4px 18px rgba(0, 0, 0, 0.32);
  --shadow-md: 0 14px 36px rgba(0, 0, 0, 0.42);
  --shadow-lg: 0 28px 64px rgba(0, 0, 0, 0.56);
}

html[data-font-scale="large"] { --font-scale: 1.08; }
html[data-font-scale="xlarge"] { --font-scale: 1.16; }

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

html {
  scroll-behavior: smooth;
  font-size: calc(16px * var(--font-scale));
  max-width: 100%;
  overflow-x: clip;
}

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  max-width: 100%;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
  transition: background var(--transition), color var(--transition);
}

/* Prevent CSS Grid intrinsic min-width overflow on narrow mobile devices */
.hero-grid > *,
.workbench-grid > *,
.anatomy-rules-grid > *,
.experiment-results-grid > *,
.video-lab-grid > *,
.books-grid > *,
.sources-grid > *,
.gallery-grid > *,
.attribution-cols > *,
.project-meta-grid > *,
.agenda-pills > * {
  min-width: 0;
}

img, video, svg { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button, input { font-family: inherit; }

.container {
  width: min(1200px, calc(100% - 2rem));
  margin-inline: auto;
}

.hidden { display: none !important; }

/* ==========================================================================
   TOPBAR & pH SPECTRUM BAR
   ========================================================================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  background: var(--surface-elevated);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.ph-spectrum-bar {
  height: 4px;
  width: 100%;
  background: linear-gradient(90deg,
    #c81d25 0%, #ea580c 18%, #f59e0b 33%,
    #10b981 48%, #22c55e 56%, #0ea5e9 72%,
    #2563eb 86%, #6d28d9 100%);
}

.scroll-progress {
  position: absolute;
  bottom: -1px;
  left: 0;
  height: 2.5px;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-indigo), var(--accent-bright), var(--amber));
  transition: width 80ms linear;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 64px;
}

.brand-compact {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  flex-shrink: 0;
}

.brand-flask {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #0f2d5c, #0f766e);
  box-shadow: 0 4px 14px rgba(15, 118, 110, 0.3);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-name {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.brand-sub {
  font-size: 0.72rem;
  color: var(--text-soft);
  font-weight: 600;
  letter-spacing: 0.03em;
}

.topbar-links {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.topbar-links a {
  padding: 0.45rem 0.8rem;
  border-radius: var(--radius-pill);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
}

.topbar-links a:hover,
.topbar-links a:focus-visible {
  background: var(--surface-soft);
  color: var(--text);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.72rem 1.25rem;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 0.9rem;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition), border-color var(--transition);
}

.btn-primary {
  background: linear-gradient(135deg, #0f2d5c, #0f766e);
  color: #fff;
  box-shadow: 0 8px 22px rgba(15, 118, 110, 0.28);
}

.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 12px 26px rgba(15, 118, 110, 0.38); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}

.btn-ghost:hover {
  background: var(--surface-soft);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-sm { padding: 0.44rem 0.85rem; font-size: 0.82rem; }

/* ==========================================================================
   HERO & PROJEKT-ÜBERSICHT
   ========================================================================== */
.hero {
  position: relative;
  padding: 2.2rem 0 3.2rem;
  overflow: hidden;
  background:
    radial-gradient(circle at 12% 18%, rgba(15, 118, 110, 0.09), transparent 38%),
    radial-gradient(circle at 88% 15%, rgba(37, 99, 235, 0.09), transparent 40%),
    radial-gradient(circle at 55% 88%, rgba(217, 119, 6, 0.08), transparent 42%);
}

.hero-molecules {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.mol-deco {
  position: absolute;
  width: 240px;
  color: var(--accent);
  opacity: 0.13;
  animation: floatMol 14s ease-in-out infinite;
}

.mol-left { top: 24px; left: -30px; }
.mol-right { bottom: 30px; right: -20px; animation-delay: -6s; color: var(--accent-indigo); }

@keyframes floatMol {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-14px) rotate(4deg); }
}

.lab-masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.25rem;
  padding: 0.72rem 1.15rem;
  margin-bottom: 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  font-size: 0.84rem;
  color: var(--text-muted);
}

.masthead-pill-left {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 700;
  color: var(--text);
}

.pulse-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--optimal);
  box-shadow: 0 0 0 4px rgba(5, 150, 105, 0.22);
}

.masthead-pill-center {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.22rem 0.65rem;
  border-radius: var(--radius-pill);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  color: var(--navy);
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.18fr 0.92fr;
  gap: 2.2rem;
  align-items: center;
}

.hero-kicker {
  margin: 0 0 0.55rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.hero-headline {
  margin: 0 0 1.25rem;
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 3.6vw, 2.95rem);
  line-height: 1.13;
  letter-spacing: -0.02em;
  color: var(--text);
}

.headline-tag {
  display: block;
  font-size: clamp(1.1rem, 1.8vw, 1.38rem);
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 0.25rem;
}

.headline-arrow { color: var(--amber); margin-inline: 0.15rem; }
.headline-accent {
  background: linear-gradient(120deg, var(--accent), var(--accent-indigo));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Chalkboard Card (echoes Slide 6!) */
.chalkboard-card {
  position: relative;
  padding: 1.25rem 1.35rem;
  margin-bottom: 1.35rem;
  border-radius: var(--radius-md);
  background:
    radial-gradient(circle at 80% 20%, rgba(255,255,255,0.06), transparent 45%),
    var(--chalk-bg);
  color: var(--chalk-text);
  border: 3px solid var(--chalk-border);
  box-shadow: var(--shadow-md);
}

.chalk-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
}

.chalk-badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-pill);
  background: rgba(251, 191, 36, 0.18);
  color: #fcd34d;
  font-weight: 700;
}

.chalk-formula {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: #94a3b8;
}

.chalk-question {
  margin: 0 0 0.75rem;
  font-family: var(--font-display);
  font-size: clamp(1.06rem, 1.55vw, 1.25rem);
  font-weight: 700;
  line-height: 1.38;
  color: #ffffff;
}

.chalk-answer-preview {
  font-size: 0.87rem;
  color: #cbd5e1;
  padding-top: 0.65rem;
  border-top: 1px dashed rgba(255, 255, 255, 0.22);
}

.chalk-answer-preview strong { color: #5eead4; }

/* Project Meta Strip */
.project-meta-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.4rem;
}

.meta-tile {
  padding: 0.82rem 0.9rem;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
}

.meta-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: var(--text-soft);
}

.meta-tile strong { font-size: 0.92rem; color: var(--text); }
.meta-tile small { font-size: 0.75rem; color: var(--text-muted); }

.hero-cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* Hero Visual Card */
.hero-frame {
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.hero-frame-bar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.65rem 1rem;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--border);
}

.hero-frame-bar .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.dot.red { background: #ef4444; }
.dot.amber { background: #f59e0b; }
.dot.green { background: #10b981; }
.frame-caption {
  margin-left: 0.45rem;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-soft);
}

.hero-img-btn {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: #0f172a;
  cursor: pointer;
  overflow: hidden;
}

.hero-img-btn img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  transition: transform 380ms ease;
}

.hero-img-btn:hover img { transform: scale(1.03); }

.zoom-chip {
  position: absolute;
  right: 12px;
  bottom: 12px;
  padding: 0.32rem 0.72rem;
  border-radius: var(--radius-pill);
  background: rgba(15, 23, 42, 0.82);
  color: #fff;
  font-size: 0.76rem;
  font-weight: 700;
  backdrop-filter: blur(6px);
}

.hero-mini-scale {
  padding: 0.85rem 1rem 0.95rem;
  background: var(--surface);
}

.mini-scale-track {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  margin-bottom: 0.45rem;
}

.mini-scale-track span {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  padding: 0.34rem 0.15rem;
  border-radius: 7px;
}

.mini-scale-track .highlight-zone {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px #10b981;
}

.mini-scale-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-soft);
  font-weight: 600;
}

.mini-scale-labels .optimal-txt { color: var(--optimal); font-weight: 800; }

/* Agenda Strip */
.agenda-strip {
  margin-top: 2.3rem;
  padding: 1.2rem 1.35rem;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.agenda-strip-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.95rem;
}

.agenda-motto {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--copper);
}

.agenda-pills {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.65rem;
}

.agenda-pill {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.72rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.agenda-pill:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.pill-num {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.18rem 0.42rem;
  border-radius: 6px;
  background: var(--navy);
  color: var(--surface);
  flex-shrink: 0;
}

html[data-theme="dark"] .pill-num { color: #0c131c; }

.agenda-pill strong { display: block; font-size: 0.84rem; line-height: 1.25; }
.agenda-pill small { display: block; font-size: 0.72rem; color: var(--text-muted); line-height: 1.3; margin-top: 2px; }

/* ==========================================================================
   SECTIONS SHARED
   ========================================================================== */
.section { padding: 4rem 0; }
.section-alt { background: var(--bg-alt); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }

.section-head {
  max-width: 780px;
  margin-bottom: 2.1rem;
}

.section-eyebrow {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 0.4rem;
}

.section-title {
  margin: 0 0 0.65rem;
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 2.8vw, 2.25rem);
  line-height: 1.18;
  letter-spacing: -0.02em;
  color: var(--text);
}

.section-lead {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.98rem;
}

/* ==========================================================================
   INTERACTIVE pH LAB WORKBENCH
   ========================================================================== */
.lab-workbench {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.4rem;
  box-shadow: var(--shadow-md);
}

.preset-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  padding-bottom: 1.25rem;
  margin-bottom: 1.35rem;
  border-bottom: 1px solid var(--border);
}

.preset-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.52rem 0.85rem;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
}

.preset-btn:hover { border-color: var(--accent); transform: translateY(-1px); }

.preset-btn.active {
  background: #0f2d5c;
  color: #fff;
  border-color: #0f2d5c;
  box-shadow: 0 6px 18px rgba(15, 45, 92, 0.28);
}

html[data-theme="dark"] .preset-btn.active {
  background: var(--accent);
  color: #09131c;
  border-color: var(--accent);
}

.preset-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }

.preset-btn kbd {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 0.1rem 0.42rem;
  border-radius: 6px;
  background: rgba(127, 127, 127, 0.16);
}

.workbench-grid {
  display: grid;
  grid-template-columns: 1.25fr 0.95fr;
  gap: 1.5rem;
  align-items: start;
}

.ph-readout-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.readout-kicker {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.15rem;
}

.ph-big-number {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.45rem 0.65rem;
}

.ph-prefix {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-soft);
}

.ph-big-number strong {
  font-family: var(--font-mono);
  font-size: clamp(2.1rem, 3.6vw, 2.9rem);
  line-height: 1;
  color: var(--text);
}

.ph-zone-badge {
  font-size: 0.78rem;
  font-weight: 800;
  padding: 0.28rem 0.72rem;
  border-radius: var(--radius-pill);
  background: rgba(5, 150, 105, 0.15);
  color: var(--optimal);
}

/* Indikatorpapier Live Strip */
.strip-widget {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.55rem 0.9rem;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.strip-caption { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-soft); }

.paper-strip {
  display: flex;
  width: 84px;
  height: 22px;
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.15);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.12);
}

.paper-dry { width: 42%; background: #f3d57a; }
.paper-wet { width: 58%; background: #f59e0b; transition: background 220ms ease; }
.strip-widget small { font-family: var(--font-mono); font-size: 0.72rem; font-weight: 700; color: var(--text); }

/* pH Spectrum Range Slider */
.slider-wrap { margin-bottom: 1.25rem; }

#phSlider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 16px;
  border-radius: 999px;
  outline: none;
  cursor: pointer;
  background: linear-gradient(90deg,
    #b91c1c 0%, #dc2626 10%, #ea580c 20%, #f59e0b 32%,
    #eab308 40%, #22c55e 50%, #10b981 58%,
    #0ea5e9 70%, #2563eb 80%, #4338ca 90%, #581c87 100%);
  border: 2px solid var(--surface);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.16);
}

#phSlider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #ffffff;
  border: 4px solid #0f2d5c;
  box-shadow: 0 3px 10px rgba(0,0,0,0.3);
  cursor: grab;
  transition: transform 150ms ease;
}

#phSlider::-webkit-slider-thumb:active { cursor: grabbing; transform: scale(1.12); }

#phSlider::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #ffffff;
  border: 4px solid #0f2d5c;
  box-shadow: 0 3px 10px rgba(0,0,0,0.3);
  cursor: grab;
}

.slider-ticks {
  display: flex;
  justify-content: space-between;
  padding: 0.35rem 6px 0;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-soft);
  font-weight: 600;
}

.slider-ticks .opt-tick { color: var(--optimal); font-weight: 800; }
.slider-ticks .neu-tick { color: var(--text); font-weight: 800; }

/* Live Cuticle Visualizer */
.cuticle-visualizer {
  padding: 1rem 1.1rem;
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  border: 1px solid var(--border);
}

.vis-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.vis-metaphor {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  padding: 0.18rem 0.6rem;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--copper);
}

#cuticleSvg {
  width: 100%;
  height: auto;
  border-radius: 12px;
  background: radial-gradient(circle at 50% 45%, rgba(255,255,255,0.55), transparent 72%);
}

html[data-theme="dark"] #cuticleSvg {
  background: radial-gradient(circle at 50% 45%, rgba(255,255,255,0.06), transparent 75%);
}

.vis-caption-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.4rem 1rem;
  margin-top: 0.55rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Right Analysis Panel */
.analysis-card {
  padding: 1.15rem 1.2rem;
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  margin-bottom: 0.9rem;
}

.analysis-row + .analysis-row {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px dashed var(--border-strong);
}

.analysis-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-soft);
  margin-bottom: 0.2rem;
}

.analysis-row strong { font-size: 0.98rem; color: var(--text); }
.analysis-row p { margin: 0; font-size: 0.87rem; color: var(--text-muted); }

.advice-pill {
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  background: rgba(5, 150, 105, 0.12);
  color: var(--text) !important;
  font-weight: 600;
  border-left: 3.5px solid var(--optimal);
}

.zone-ladder {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.ladder-step {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  text-align: left;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: all var(--transition);
}

.ladder-step:hover { border-color: var(--border-strong); transform: translateX(3px); }
.ladder-step.active { border-color: var(--accent); background: var(--surface-soft); box-shadow: var(--shadow-sm); }

.ladder-color { width: 12px; height: 34px; border-radius: 6px; flex-shrink: 0; }
.ladder-step strong { display: block; font-size: 0.83rem; }
.ladder-step small { display: block; font-size: 0.74rem; color: var(--text-muted); }

/* Anatomy + 3 Rules Grid */
.anatomy-rules-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.35rem;
  margin-top: 1.6rem;
}

.lab-card {
  padding: 1.4rem;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.lab-card-head { margin-bottom: 1rem; }
.lab-card-head h3 {
  margin: 0.35rem 0 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
}

.card-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-pill);
}

.tag-copper { background: rgba(161, 98, 54, 0.14); color: var(--copper); }
.tag-teal { background: rgba(15, 118, 110, 0.14); color: var(--accent); }

.layer-stack, .rules-stack {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.layer-item {
  display: flex;
  gap: 0.85rem;
  padding: 0.85rem;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  border: 1px solid var(--border);
}

.layer-num {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 0.85rem;
  background: var(--copper);
  color: #fff;
  flex-shrink: 0;
}

.layer-item strong, .rule-item strong { display: block; font-size: 0.92rem; margin-bottom: 0.18rem; }
.layer-item p, .rule-item p { margin: 0; font-size: 0.84rem; color: var(--text-muted); }

.rule-item {
  display: flex;
  gap: 0.85rem;
  padding: 0.85rem;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  border-left: 4px solid var(--accent);
}

.rule-blue { border-left-color: #2563eb; }
.rule-amber { border-left-color: #ea580c; }
.rule-green { border-left-color: #059669; }

.rule-badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
  height: fit-content;
  padding: 0.22rem 0.55rem;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}

/* ==========================================================================
   EXPERIMENT RESULTS & VIDEOS
   ========================================================================== */
.experiment-results-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.6rem;
}

.sample-card {
  padding: 1.15rem;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  cursor: pointer;
}

.sample-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--accent); }
.sample-highlight { border-color: var(--optimal); box-shadow: 0 8px 24px rgba(5, 150, 105, 0.14); }

.sample-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.65rem;
}

.sample-num { font-family: var(--font-mono); font-size: 0.72rem; font-weight: 700; color: var(--text-soft); }

.sample-class {
  font-size: 0.69rem;
  font-weight: 800;
  padding: 0.18rem 0.52rem;
  border-radius: var(--radius-pill);
}

.badge-neutral { background: rgba(101, 163, 13, 0.16); color: #4d7c0f; }
.badge-optimal { background: rgba(5, 150, 105, 0.16); color: #047857; }
.badge-alkaline { background: rgba(37, 99, 235, 0.16); color: #1d4ed8; }
.badge-acid { background: rgba(234, 88, 12, 0.16); color: #c2410c; }

html[data-theme="dark"] .badge-neutral { color: #bef264; }
html[data-theme="dark"] .badge-optimal { color: #6ee7b7; }
html[data-theme="dark"] .badge-alkaline { color: #93c5fd; }
html[data-theme="dark"] .badge-acid { color: #fdba74; }

.sample-card h3 { margin: 0 0 0.6rem; font-family: var(--font-display); font-size: 1.06rem; }

.sample-ph-display {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.7rem;
  margin-bottom: 0.7rem;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.sample-ph-num { font-family: var(--font-mono); font-size: 1.25rem; font-weight: 800; color: var(--text); }
.sample-strip-pill {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.22rem 0.58rem;
  border-radius: 6px;
}

.sample-card p { margin: 0; font-size: 0.83rem; color: var(--text-muted); }

/* Videos */
.video-lab-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.35rem;
}

.video-card {
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.video-wrap {
  background: #090f17;
  aspect-ratio: 16 / 9;
}

.video-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-body { padding: 1.1rem 1.25rem 1.25rem; }
.video-badges { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-bottom: 0.55rem; }
.video-body h3 { margin: 0 0 0.35rem; font-family: var(--font-display); font-size: 1.05rem; }
.video-body p { margin: 0; font-size: 0.85rem; color: var(--text-muted); }

/* ==========================================================================
   BOOKS SPOTLIGHT & FULL SOURCES ARCHIVE
   ========================================================================== */
.books-spotlight {
  padding: 1.35rem;
  margin-bottom: 1.6rem;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.spotlight-label {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
}

.cite-quick-switch {
  display: inline-flex;
  gap: 0.3rem;
  padding: 0.22rem;
  border-radius: var(--radius-pill);
  background: var(--surface-soft);
  border: 1px solid var(--border);
}

.cite-chip {
  padding: 0.28rem 0.72rem;
  border-radius: var(--radius-pill);
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
}

.cite-chip.active { background: #0f2d5c; color: #fff; }
html[data-theme="dark"] .cite-chip.active { background: var(--accent); color: #09131c; }

.books-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.book-feature-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.9rem;
  padding: 1.25rem 1.35rem;
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-top: 4px solid #0f2d5c;
  transition: transform var(--transition), box-shadow var(--transition);
}

.book-feature-card:hover {
  box-shadow: var(--shadow-md);
}

.book-feature-card.book-ht { border-top-color: var(--copper); }

.book-feature-top {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr);
  gap: 1.15rem;
  align-items: start;
}

.book-cover-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  perspective: 700px;
}

.book-cover-3d {
  position: relative;
  display: block;
  width: 114px;
  aspect-ratio: 109 / 150;
  border-radius: 4px 9px 9px 4px;
  overflow: hidden;
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.14);
  box-shadow:
    -4px 0 0 rgba(15, 23, 42, 0.12) inset,
    0 14px 26px -8px rgba(15, 23, 42, 0.34),
    -4px 6px 12px rgba(15, 23, 42, 0.16);
  transform: rotateY(-5deg);
  transform-origin: left center;
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.32s ease;
}

.book-cover-3d img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.book-cover-sheen {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.24) 0%,
    rgba(255, 255, 255, 0.34) 5%,
    rgba(0, 0, 0, 0.08) 9%,
    rgba(255, 255, 255, 0.04) 16%,
    transparent 45%,
    rgba(255, 255, 255, 0.12) 100%
  );
}

.book-cover-btn:hover .book-cover-3d,
.book-cover-btn:focus-visible .book-cover-3d {
  transform: translateY(-4px) rotateY(0deg) scale(1.03);
  box-shadow:
    0 20px 34px -8px rgba(15, 23, 42, 0.42),
    -2px 8px 16px rgba(15, 23, 42, 0.2);
}

.book-cover-zoom-pill {
  font-family: var(--font-mono);
  font-size: 0.67rem;
  font-weight: 700;
  color: var(--text-muted);
  padding: 0.14rem 0.5rem;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: color var(--transition), border-color var(--transition);
}

.book-cover-btn:hover .book-cover-zoom-pill {
  color: var(--accent);
  border-color: var(--accent);
}

.book-feature-info { min-width: 0; }

.book-feature-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.4rem; }
.book-feature-card h3 { margin: 0.35rem 0 0.25rem; font-family: var(--font-display); font-size: 1.08rem; line-height: 1.25; }
.book-feature-authors { margin: 0 0 0.45rem; font-size: 0.84rem; font-weight: 600; color: var(--text-muted); }
.book-feature-blurb {
  margin: 0;
  font-size: 0.81rem;
  line-height: 1.48;
  color: var(--text-soft);
}

@media (max-width: 520px) {
  .book-feature-top {
    grid-template-columns: 1fr;
    justify-items: start;
  }
  .book-cover-3d {
    width: 108px;
  }
}

.book-citation-box {
  margin: 0;
  padding: 0.65rem 0.8rem;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  line-height: 1.5;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.book-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.isbn-pill {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-soft);
}

/* Filter Panel */
.filter-panel {
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: 1rem;
}

.search-icon {
  position: absolute;
  left: 1rem;
  font-size: 0.95rem;
  pointer-events: none;
  opacity: 0.65;
}

#searchInput {
  width: 100%;
  padding: 0.78rem 2.6rem 0.78rem 2.7rem;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border-strong);
  background: var(--surface-soft);
  color: var(--text);
  font-size: 0.92rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

#searchInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.14);
}

.clear-search {
  position: absolute;
  right: 0.75rem;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 0;
  background: var(--border);
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
}

.filter-rows { display: flex; flex-direction: column; gap: 0.65rem; }

.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.filter-pill, .topic-filter {
  padding: 0.42rem 0.85rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
}

.filter-pill:hover, .topic-filter:hover { border-color: var(--accent); color: var(--text); }

.filter-pill.active {
  background: #0f2d5c;
  color: #fff;
  border-color: #0f2d5c;
}

html[data-theme="dark"] .filter-pill.active {
  background: var(--accent);
  color: #09131c;
  border-color: var(--accent);
}

.topic-filter.active {
  background: rgba(15, 118, 110, 0.16);
  color: var(--accent);
  border-color: var(--accent);
}

.filter-status-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-muted);
}

.filter-status-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* Source Cards */
.sources-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.1rem;
}

.source-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1.2rem 1.3rem;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.source-card:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: var(--shadow-md); }

.source-card-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
}

.inst-badge {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.71rem;
  font-weight: 700;
  padding: 0.22rem 0.62rem;
  border-radius: var(--radius-pill);
}

.inst-westermann { background: rgba(15, 45, 92, 0.13); color: #0f2d5c; }
.inst-ht { background: rgba(161, 98, 54, 0.16); color: #8c4f24; }
.inst-pubmed { background: rgba(5, 150, 105, 0.15); color: #047857; }
.inst-iqwig { background: rgba(14, 165, 233, 0.15); color: #0369a1; }
.inst-haut { background: rgba(217, 119, 6, 0.16); color: #b45309; }
.inst-chemie { background: rgba(124, 58, 237, 0.14); color: #6d28d9; }
.inst-duden { background: rgba(225, 29, 72, 0.14); color: #be123c; }
.inst-wiki { background: rgba(71, 85, 105, 0.14); color: #334155; }
.inst-eigen { background: rgba(15, 118, 110, 0.16); color: #0f766e; }

html[data-theme="dark"] .inst-westermann { color: #93c5fd; background: rgba(59, 130, 246, 0.2); }
html[data-theme="dark"] .inst-ht { color: #f6b98b; background: rgba(234, 88, 12, 0.2); }
html[data-theme="dark"] .inst-pubmed { color: #6ee7b7; }
html[data-theme="dark"] .inst-iqwig { color: #7dd3fc; }
html[data-theme="dark"] .inst-haut { color: #fcd34d; }
html[data-theme="dark"] .inst-chemie { color: #c4b5fd; }
html[data-theme="dark"] .inst-duden { color: #fda4af; }
html[data-theme="dark"] .inst-wiki { color: #cbd5e1; }
html[data-theme="dark"] .inst-eigen { color: #5eead4; }

.topic-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.18rem 0.56rem;
  border-radius: var(--radius-pill);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.source-title {
  margin: 0.15rem 0 0.25rem;
  font-family: var(--font-display);
  font-size: 1.03rem;
  line-height: 1.3;
  color: var(--text);
}

.source-meta-line {
  font-size: 0.78rem;
  color: var(--text-soft);
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.source-summary {
  margin: 0;
  font-size: 0.86rem;
  color: var(--text-muted);
}

.source-card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--border);
}

.compact-cards .source-meta-line,
.compact-cards .topic-pill { display: none; }

mark.search-hit {
  background: rgba(251, 191, 36, 0.42);
  color: inherit;
  padding: 0 2px;
  border-radius: 3px;
}

.empty-state {
  text-align: center;
  padding: 2.5rem 1.2rem;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  color: var(--text-muted);
}

/* ==========================================================================
   MEDIA & SLIDE GALLERY + ATTRIBUTION
   ========================================================================== */
.gallery-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 1.35rem;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.1rem;
  margin-bottom: 1.8rem;
}

.gallery-card {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  text-align: left;
  padding: 0;
  color: inherit;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.gallery-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--accent); }

.gallery-thumb {
  position: relative;
  overflow: hidden;
  background: #0f172a;
  aspect-ratio: 16 / 9;
}

.gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 350ms ease;
}

.gallery-card:hover .gallery-thumb img { transform: scale(1.04); }

.gallery-badge-float {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 0.69rem;
  font-weight: 700;
  background: rgba(15, 23, 42, 0.8);
  color: #fff;
  backdrop-filter: blur(5px);
}

.gallery-body { padding: 0.9rem 1rem 1rem; }
.gallery-body h3 { margin: 0 0 0.25rem; font-family: var(--font-display); font-size: 0.96rem; }
.gallery-body p { margin: 0; font-size: 0.8rem; color: var(--text-muted); }

.attribution-box {
  padding: 1.35rem 1.45rem;
  border-radius: var(--radius-lg);
  background: var(--surface-soft);
  border: 1px solid var(--border);
}

.attribution-box h3 {
  margin: 0 0 0.95rem;
  font-family: var(--font-display);
  font-size: 1.08rem;
}

.attribution-cols {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.15rem;
}

.attribution-cols strong { display: block; font-size: 0.87rem; margin-bottom: 0.25rem; color: var(--text); }
.attribution-cols p { margin: 0; font-size: 0.82rem; color: var(--text-muted); }

/* ==========================================================================
   FOOTER, LIGHTBOX, SETTINGS MODAL & TOAST
   ========================================================================== */
.site-footer {
  padding: 2.2rem 0 2.6rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.2rem;
}

.footer-brand { font-family: var(--font-display); font-weight: 700; font-size: 1rem; margin-bottom: 0.25rem; }
.footer-copy { margin: 0; font-size: 0.84rem; color: var(--text-muted); max-width: 640px; }

.footer-links { display: flex; flex-wrap: wrap; gap: 0.9rem; font-size: 0.85rem; font-weight: 700; color: var(--text-muted); }
.footer-links a:hover { color: var(--accent); }

/* Lightbox */
.lightbox, .settings-modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.lightbox-backdrop, .settings-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(7, 12, 20, 0.78);
  backdrop-filter: blur(8px);
}

.lightbox-dialog {
  position: relative;
  z-index: 1;
  width: min(1020px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  display: grid;
  grid-template-columns: 1.45fr 0.9fr;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
}

.lightbox-close, .settings-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 5;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.lightbox-media {
  background: #090f17;
  display: grid;
  place-items: center;
  padding: 0.75rem;
}

.lightbox-media img {
  max-height: 76vh;
  width: auto;
  border-radius: 10px;
}

.lightbox-info {
  padding: 1.5rem 1.4rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.85rem;
}

.lightbox-badges { display: flex; flex-wrap: wrap; gap: 0.4rem; padding-right: 2rem; }
.lightbox-info h3 { margin: 0; font-family: var(--font-display); font-size: 1.18rem; }
.lightbox-info p { margin: 0; font-size: 0.87rem; color: var(--text-muted); }
.lightbox-credit {
  font-family: var(--font-mono);
  font-size: 0.75rem !important;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  border: 1px solid var(--border);
}

.lightbox-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.8rem;
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-soft);
}

/* Settings Modal */
.settings-dialog {
  position: relative;
  z-index: 1;
  width: min(620px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
}

.settings-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 1.35rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border);
}

.settings-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent);
}

.settings-header h2 { margin: 0.2rem 0 0; font-family: var(--font-display); font-size: 1.3rem; }

.settings-body { padding: 1.25rem 1.5rem; display: flex; flex-direction: column; gap: 1.2rem; }
.setting-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; margin-bottom: 0.3rem; }
.setting-head label { font-weight: 700; font-size: 0.92rem; }
.setting-status { font-family: var(--font-mono); font-size: 0.74rem; color: var(--accent); font-weight: 700; }
.setting-desc { margin: 0 0 0.6rem; font-size: 0.81rem; color: var(--text-muted); }

.segmented-group {
  display: flex;
  gap: 0.3rem;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  border: 1px solid var(--border);
}

.seg-btn {
  flex: 1;
  padding: 0.45rem 0.65rem;
  border-radius: 7px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
}

.seg-btn.active { background: #0f2d5c; color: #fff; }
html[data-theme="dark"] .seg-btn.active { background: var(--accent); color: #09131c; }

.citation-preview {
  margin: 0.65rem 0 0;
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  border: 1px dashed var(--border-strong);
  font-family: var(--font-mono);
  font-size: 0.73rem;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

.setting-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; }

.setting-toggles { display: flex; flex-direction: column; gap: 0.7rem; }
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  cursor: pointer;
}
.toggle-row strong { display: block; font-size: 0.85rem; }
.toggle-row small { display: block; font-size: 0.75rem; color: var(--text-muted); }
.toggle-row input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }

.settings-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.5rem 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-soft);
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 160;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.75rem 1.2rem;
  border-radius: var(--radius-pill);
  background: #0f2d5c;
  color: #fff;
  font-size: 0.86rem;
  font-weight: 700;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 14px);
  transition: opacity 220ms ease, transform 220ms ease;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #10b981;
  color: #fff;
  font-size: 0.78rem;
}

/* Reveal Animations (progressive enhancement: never stuck invisible on direct hash links!) */
.reveal {
  opacity: 1;
  transform: none;
  transition: opacity 520ms cubic-bezier(0.22, 1, 0.36, 1), transform 520ms cubic-bezier(0.22, 1, 0.36, 1);
}
.reveal.reveal-pending {
  opacity: 0;
  transform: translateY(18px);
}
.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

html[data-motion="reduced"] *,
html[data-motion="reduced"] *::before,
html[data-motion="reduced"] *::after {
  animation: none !important;
  transition: none !important;
}
html[data-motion="reduced"] .reveal,
html[data-motion="reduced"] .reveal.reveal-pending { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  .mol-deco { animation: none; }
  .reveal, .reveal.reveal-pending { opacity: 1; transform: none; }
}

/* ==========================================================================
   RESPONSIVE BREAKPOINTS (TABLET & MOBILE-FIRST POLISH)
   ========================================================================== */
@media (max-width: 1024px) {
  .hero-grid,
  .workbench-grid,
  .anatomy-rules-grid,
  .books-grid,
  .sources-grid,
  .video-lab-grid { grid-template-columns: 1fr; }

  .agenda-pills { grid-template-columns: repeat(3, 1fr); }
  .experiment-results-grid { grid-template-columns: repeat(2, 1fr); }
  .gallery-grid { grid-template-columns: repeat(2, 1fr); }
  .attribution-cols { grid-template-columns: 1fr; }
  .lightbox-dialog { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .topbar-links { display: none; }
  .theme-label, .settings-btn-label { display: none; }
  .topbar-inner { min-height: 58px; gap: 0.5rem; }
  .container { width: min(1200px, calc(100% - 1.25rem)); }

  .hero { padding: 1.3rem 0 2.2rem; }
  .hero-headline { font-size: clamp(1.55rem, 6.8vw, 2.1rem); overflow-wrap: break-word; }
  .section { padding: 2.6rem 0; }
  .section-title { font-size: clamp(1.38rem, 6vw, 1.85rem); overflow-wrap: break-word; }
  .chalkboard-card { padding: 1rem 1.05rem; }
  .chalk-top-row { flex-wrap: wrap; }
  .project-meta-grid { grid-template-columns: 1fr; }
  .agenda-pills { grid-template-columns: 1fr; }
  .experiment-results-grid { grid-template-columns: 1fr; }
  .gallery-grid { grid-template-columns: 1fr; }
  .setting-grid-2 { grid-template-columns: 1fr; }
  .ph-readout-row { flex-direction: column; align-items: flex-start; }
  .lab-workbench { padding: 0.95rem; }
  .books-spotlight { padding: 1rem; }
  .filter-panel { padding: 1rem; }
  .mini-scale-track { grid-template-columns: repeat(3, 1fr); gap: 5px; }
  .mini-scale-labels { font-size: 0.68rem; }
  .vis-header { flex-wrap: wrap; }
}

@media (max-width: 420px) {
  .hero-cta-row .btn-primary,
  .hero-cta-row .btn-secondary { width: 100%; }
  .brand-name { font-size: 0.9rem; }
}
