:root {
  --bg-primary: #07090e;
  --bg-elevated: #0d111a;
  --bg-card: rgba(17, 23, 36, 0.72);
  --bg-card-hover: rgba(24, 32, 50, 0.88);
  --bg-glass: rgba(13, 18, 29, 0.76);
  --surface-subtle: rgba(255, 255, 255, 0.035);
  --surface-highlight: rgba(255, 255, 255, 0.07);

  --text-primary: #f4f7fb;
  --text-secondary: #9ba8be;
  --text-muted: #64728a;

  --accent-gold: #e2b857;
  --accent-gold-soft: rgba(226, 184, 87, 0.14);
  --accent-emerald: #10b981;
  --accent-emerald-soft: rgba(16, 185, 129, 0.14);
  --accent-blue: #3b82f6;
  --accent-blue-soft: rgba(59, 130, 246, 0.15);
  --accent-rose: #f43f5e;
  --accent-rose-soft: rgba(244, 63, 94, 0.14);
  --accent-amber: #f59e0b;

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --border-gold: rgba(226, 184, 87, 0.35);

  --shadow-lg: 0 24px 60px -15px rgba(0, 0, 0, 0.65);
  --shadow-glow: 0 0 45px -10px rgba(226, 184, 87, 0.22);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;

  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-serif: 'Instrument Serif', Georgia, serif;
  --font-mono: 'JetBrains Mono', monospace;

  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.22, 1, 0.36, 1);
}

[data-theme="light"] {
  --bg-primary: #f6f5f0;
  --bg-elevated: #eceae2;
  --bg-card: rgba(255, 255, 255, 0.86);
  --bg-card-hover: rgba(255, 255, 255, 0.98);
  --bg-glass: rgba(246, 245, 240, 0.85);
  --surface-subtle: rgba(15, 23, 42, 0.04);
  --surface-highlight: rgba(15, 23, 42, 0.08);

  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;

  --accent-gold: #b58318;
  --accent-gold-soft: rgba(181, 131, 24, 0.12);
  --accent-emerald: #059669;
  --accent-emerald-soft: rgba(5, 150, 105, 0.11);
  --accent-blue: #2563eb;
  --accent-blue-soft: rgba(37, 99, 235, 0.11);
  --accent-rose: #e11d48;
  --accent-rose-soft: rgba(225, 29, 72, 0.11);

  --border-subtle: rgba(15, 23, 42, 0.09);
  --border-strong: rgba(15, 23, 42, 0.18);
  --border-gold: rgba(181, 131, 24, 0.35);

  --shadow-lg: 0 20px 50px -15px rgba(15, 23, 42, 0.1);
  --shadow-glow: 0 0 35px -10px rgba(181, 131, 24, 0.18);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
  overflow-x: hidden;
  max-width: 100vw;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.65;
  overflow-x: hidden;
  max-width: 100vw;
  transition: background-color 0.45s var(--ease-out-expo), color 0.45s var(--ease-out-expo);
  -webkit-font-smoothing: antialiased;
}

.ambient-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.ambient-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(110px);
  opacity: 0.32;
  animation: orbFloat 18s ease-in-out infinite alternate;
}

[data-theme="light"] .ambient-orb {
  opacity: 0.16;
}

.orb-1 {
  width: 540px;
  height: 540px;
  background: radial-gradient(circle, rgba(226, 184, 87, 0.38), transparent 70%);
  top: -120px;
  right: -80px;
}

.orb-2 {
  width: 620px;
  height: 620px;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.28), transparent 70%);
  top: 38%;
  left: -180px;
  animation-delay: -6s;
}

.orb-3 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.24), transparent 70%);
  bottom: -120px;
  right: 12%;
  animation-delay: -11s;
}

.ambient-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, var(--border-subtle) 1px, transparent 1px),
    linear-gradient(to bottom, var(--border-subtle) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 25%, #000 30%, transparent 100%);
  opacity: 0.38;
}

@keyframes orbFloat {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(30px, -25px, 0) scale(1.06); }
  100% { transform: translate3d(-25px, 20px, 0) scale(0.96); }
}

.reading-progress-track {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: transparent;
  z-index: 100;
}

.reading-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-gold), var(--accent-emerald), var(--accent-blue));
  box-shadow: 0 0 14px var(--accent-gold);
  transition: width 0.1s linear;
}

.top-nav {
  position: sticky;
  top: 0;
  z-index: 90;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  background: var(--bg-glass);
  border-bottom: 1px solid var(--border-subtle);
}

.top-nav-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.85rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  text-decoration: none;
  color: var(--text-primary);
}

.brand-flag {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(180deg, #111827 0%, #111827 33%, #dc2626 33%, #dc2626 66%, #f59e0b 66%, #f59e0b 100%);
  border: 1px solid var(--border-strong);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  position: relative;
  flex-shrink: 0;
}

.brand-title {
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: -0.01em;
  display: block;
}

.brand-subtitle {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.nav-status-pills {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  background: var(--surface-subtle);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
  animation: pulseDot 2.2s infinite;
}

@keyframes pulseDot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.35); opacity: 0.6; }
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.btn-action {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.52rem 0.95rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--surface-subtle);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s var(--ease-out-expo);
}

.btn-action:hover {
  border-color: var(--border-gold);
  background: var(--accent-gold-soft);
  transform: translateY(-1px);
}

.btn-primary-gold {
  background: linear-gradient(135deg, #e2b857 0%, #c89629 100%);
  color: #090d16;
  border-color: transparent;
}

.btn-primary-gold:hover {
  background: linear-gradient(135deg, #edd078 0%, #d8a534 100%);
  color: #090d16;
  box-shadow: 0 8px 25px rgba(226, 184, 87, 0.35);
}

.workspace-shell {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 2.5rem 2rem 6rem;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 3rem;
  align-items: start;
}

.toc-sidebar {
  position: sticky;
  top: 5.5rem;
  background: var(--bg-card);
  backdrop-filter: blur(18px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.35rem;
  box-shadow: var(--shadow-lg);
}

.toc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.85rem;
  margin-bottom: 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
}

.toc-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.toc-progress-pct {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-gold);
}

.toc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.toc-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.52rem 0.7rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 500;
  transition: all 0.22s var(--ease-out-expo);
  border-left: 2px solid transparent;
}

.toc-link:hover {
  color: var(--text-primary);
  background: var(--surface-subtle);
}

.toc-link.active {
  color: var(--text-primary);
  background: var(--accent-gold-soft);
  border-left-color: var(--accent-gold);
  font-weight: 600;
}

.toc-num {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  min-width: 22px;
}

.toc-link.active .toc-num {
  color: var(--accent-gold);
}

.sidebar-resilience-widget {
  margin-top: 1.25rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--border-subtle);
}

.widget-caption {
  display: flex;
  justify-content: space-between;
  font-size: 0.76rem;
  color: var(--text-secondary);
  margin-bottom: 0.45rem;
}

.widget-meter {
  height: 7px;
  border-radius: 999px;
  background: var(--surface-highlight);
  overflow: hidden;
}

.widget-meter-fill {
  height: 100%;
  width: 50%;
  background: linear-gradient(90deg, var(--accent-gold), var(--accent-emerald));
  border-radius: 999px;
  transition: width 0.5s var(--ease-spring);
}

.paper-main {
  display: flex;
  flex-direction: column;
  gap: 3.5rem;
}

.hero-cover {
  position: relative;
  border-radius: var(--radius-xl);
  background:
    radial-gradient(120% 120% at 90% 10%, rgba(226, 184, 87, 0.16), transparent 55%),
    radial-gradient(100% 100% at 10% 90%, rgba(59, 130, 246, 0.14), transparent 55%),
    var(--bg-card);
  border: 1px solid var(--border-strong);
  padding: 3.25rem;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  overflow: hidden;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  background: var(--accent-gold-soft);
  border: 1px solid var(--border-gold);
  color: var(--accent-gold);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 1.5rem;
}

.hero-title {
  font-size: clamp(2.2rem, 4vw, 3.55rem);
  line-height: 1.08;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 1.25rem;
}

.hero-title .serif-accent {
  font-family: var(--font-serif);
  font-weight: 400;
  font-style: italic;
  color: var(--accent-gold);
  padding-right: 0.15em;
}

.hero-lead {
  font-size: 1.12rem;
  color: var(--text-secondary);
  max-width: 78ch;
  margin-bottom: 2.25rem;
}

.hero-meta-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--border-subtle);
}

.meta-stat-card {
  background: var(--surface-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.1rem 1.2rem;
  transition: transform 0.3s var(--ease-out-expo), border-color 0.3s;
}

.meta-stat-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-gold);
}

.meta-stat-value {
  font-family: var(--font-mono);
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--text-primary);
  display: block;
}

.meta-stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  display: block;
}

.chapter-section {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 2.75rem;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s var(--ease-out-expo), transform 0.7s var(--ease-out-expo), border-color 0.35s;
}

.chapter-section.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.chapter-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 2rem;
  padding-bottom: 1.35rem;
  border-bottom: 1px solid var(--border-subtle);
}

.chapter-index {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-gold);
  display: block;
  margin-bottom: 0.4rem;
}

.chapter-title {
  font-size: clamp(1.45rem, 2.4vw, 2rem);
  font-weight: 750;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.chapter-badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 0.38rem 0.75rem;
  border-radius: 999px;
  background: var(--surface-highlight);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  white-space: nowrap;
}

.chapter-intro {
  color: var(--text-secondary);
  font-size: 1.02rem;
  margin-bottom: 2rem;
  max-width: 82ch;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.25rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem;
}

.feature-card {
  position: relative;
  background: var(--surface-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  transition: transform 0.35s var(--ease-out-expo), border-color 0.35s, background-color 0.35s;
  overflow: hidden;
}

.feature-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    420px circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
    rgba(226, 184, 87, 0.11),
    transparent 45%
  );
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.feature-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-strong);
  background: var(--bg-card-hover);
}

.feature-card:hover::before {
  opacity: 1;
}

.card-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  margin-bottom: 0.9rem;
}

.tag-gold { background: var(--accent-gold-soft); color: var(--accent-gold); }
.tag-emerald { background: var(--accent-emerald-soft); color: var(--accent-emerald); }
.tag-blue { background: var(--accent-blue-soft); color: var(--accent-blue); }
.tag-rose { background: var(--accent-rose-soft); color: var(--accent-rose); }

.feature-card h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.55rem;
}

.feature-card p {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.card-list {
  list-style: none;
  margin-top: 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.card-list li {
  font-size: 0.84rem;
  color: var(--text-secondary);
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.card-list li::before {
  content: "→";
  font-family: var(--font-mono);
  color: var(--accent-gold);
}

.legal-callout {
  margin-top: 1.5rem;
  padding: 1.25rem 1.5rem;
  border-radius: var(--radius-md);
  background: linear-gradient(90deg, var(--accent-gold-soft), transparent);
  border-left: 3px solid var(--accent-gold);
  border-top: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.legal-callout-icon {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.8rem;
  padding: 0.3rem 0.55rem;
  border-radius: 6px;
  background: var(--accent-gold);
  color: #090d16;
  flex-shrink: 0;
}

.legal-callout-body {
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.legal-callout-body strong {
  color: var(--text-primary);
}

.simulator-box {
  margin-top: 1.75rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 1.85rem;
}

.simulator-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.simulator-title {
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.live-badge {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  background: var(--accent-emerald-soft);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.control-group {
  margin-bottom: 1.15rem;
}

.control-label-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.45rem;
  font-size: 0.86rem;
}

.control-label {
  color: var(--text-secondary);
  font-weight: 500;
}

.control-value {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-primary);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: var(--surface-highlight);
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-gold);
  border: 2px solid var(--bg-primary);
  box-shadow: 0 0 10px rgba(226, 184, 87, 0.6);
  transition: transform 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.18);
}

.select-input {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.86rem;
}

.schufa-gauge-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: var(--surface-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
}

.gauge-svg {
  width: 240px;
  height: 145px;
  overflow: visible;
}

.gauge-track {
  fill: none;
  stroke: var(--surface-highlight);
  stroke-width: 14;
  stroke-linecap: round;
}

.gauge-value-arc {
  fill: none;
  stroke: var(--accent-emerald);
  stroke-width: 14;
  stroke-linecap: round;
  stroke-dasharray: 251.2;
  stroke-dashoffset: 20;
  transition: stroke-dashoffset 0.6s var(--ease-spring), stroke 0.4s;
}

.gauge-score-number {
  font-family: var(--font-mono);
  font-size: 2.1rem;
  font-weight: 800;
  margin-top: -1.2rem;
}

.gauge-rating-pill {
  margin-top: 0.45rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.32rem 0.8rem;
  border-radius: 999px;
  font-weight: 600;
  text-align: center;
}

.schufa-toggles {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.toggle-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s;
  user-select: none;
  font-size: 0.85rem;
}

.toggle-item:hover {
  border-color: var(--border-strong);
}

.toggle-item input {
  accent-color: var(--accent-gold);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.toggle-delta {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  white-space: nowrap;
}

.data-table-wrap {
  overflow-x: auto;
  margin-top: 1.5rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.87rem;
}

.data-table th,
.data-table td {
  padding: 0.9rem 1.1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.data-table th {
  font-family: var(--font-mono);
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--surface-subtle);
}

.data-table tr:last-child td {
  border-bottom: none;
}

.budget-stacked-bar {
  height: 20px;
  border-radius: 999px;
  background: var(--surface-highlight);
  display: flex;
  overflow: hidden;
  margin: 1.1rem 0;
  gap: 3px;
}

.bar-segment {
  height: 100%;
  transition: width 0.45s var(--ease-spring);
}

.seg-needs { background: var(--accent-blue); }
.seg-wants { background: var(--accent-gold); }
.seg-savings { background: var(--accent-emerald); }

.kpi-mini-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
  margin-top: 1rem;
}

.kpi-mini-box {
  padding: 0.9rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  border: 1px solid var(--border-subtle);
}

.kpi-mini-box .label {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: block;
}

.kpi-mini-box .val {
  font-family: var(--font-mono);
  font-size: 1.12rem;
  font-weight: 700;
  margin-top: 0.2rem;
  display: block;
}

.checklist-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.check-card {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  padding: 1.1rem 1.25rem;
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: all 0.25s var(--ease-out-expo);
}

.check-card:hover {
  border-color: var(--border-strong);
}

.check-card.checked {
  border-color: rgba(16, 185, 129, 0.45);
  background: var(--accent-emerald-soft);
}

.check-card input[type="checkbox"] {
  margin-top: 0.2rem;
  width: 18px;
  height: 18px;
  accent-color: var(--accent-emerald);
  cursor: pointer;
  flex-shrink: 0;
}

.check-card-title {
  font-weight: 600;
  font-size: 0.92rem;
  display: block;
  margin-bottom: 0.2rem;
}

.check-card-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.paper-footer {
  margin-top: 1rem;
  padding: 2rem 2.5rem;
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

@media (max-width: 1100px) {
  .workspace-shell { grid-template-columns: 1fr; padding: 1.5rem 1.25rem 4rem; gap: 2rem; }
  .toc-sidebar { display: none; }
  .mobile-chapter-nav { display: flex !important; }
  .hero-meta-grid, .kpi-mini-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  html { font-size: 15px; }
  .top-nav-inner { padding: 0.7rem 1rem; gap: 0.75rem; }
  .brand-flag { width: 28px; height: 28px; border-radius: 7px; }
  .brand-title { font-size: 0.8rem; }
  .brand-subtitle { font-size: 0.62rem; }
  .nav-status-pills { display: none; }
  .btn-action { padding: 0.45rem 0.7rem; font-size: 0.76rem; }
  .btn-action span:last-child { display: none; }
  .btn-primary-gold span:last-child { display: inline; }

  .workspace-shell { padding: 1rem 0.9rem 4rem; gap: 1.5rem; }
  .grid-2, .checklist-grid, .kpi-mini-grid, .hero-meta-grid { grid-template-columns: 1fr !important; }
  .hero-cover { padding: 1.5rem 1.25rem; border-radius: var(--radius-lg); }
  .hero-eyebrow { font-size: 0.65rem; padding: 0.32rem 0.65rem; margin-bottom: 1rem; }
  .hero-title { font-size: 1.78rem; line-height: 1.14; }
  .hero-lead { font-size: 0.96rem; margin-bottom: 1.5rem; }

  .chapter-section { padding: 1.4rem 1.15rem; border-radius: var(--radius-lg); }
  .chapter-header { flex-direction: column; align-items: flex-start; gap: 0.65rem; margin-bottom: 1.35rem; padding-bottom: 1rem; }
  .chapter-title { font-size: 1.32rem; }
  .simulator-box { padding: 1.2rem 1rem; border-radius: var(--radius-md); }
  .feature-card { padding: 1.2rem; }

  input[type="range"] { height: 8px; }
  input[type="range"]::-webkit-slider-thumb { width: 24px; height: 24px; }
  .toggle-item { padding: 0.75rem 0.85rem; font-size: 0.8rem; flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .toggle-item > span:last-child { align-self: flex-end; display: flex; align-items: center; gap: 0.5rem; }
  .legal-callout { flex-direction: column; gap: 0.6rem; padding: 1rem 1.1rem; }
  .paper-footer { padding: 1.35rem 1.15rem; font-size: 0.76rem; }
}

.mobile-chapter-nav {
  display: none;
  position: sticky;
  top: 53px;
  z-index: 85;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.55rem 1rem;
  gap: 0.5rem;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.mobile-chapter-nav::-webkit-scrollbar {
  display: none;
}

.mobile-chap-pill {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.38rem 0.75rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--surface-subtle);
  border: 1px solid var(--border-subtle);
  text-decoration: none;
  transition: all 0.2s var(--ease-out-expo);
}

.mobile-chap-pill.active {
  color: #090d16;
  background: var(--accent-gold);
  border-color: var(--accent-gold);
}

body.loader-lock {
  overflow: hidden;
}

.brand-loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: radial-gradient(circle at 50% 35%, #131b2e 0%, #07090e 75%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  transition: opacity 0.65s var(--ease-out-expo), visibility 0.65s var(--ease-out-expo), transform 0.65s var(--ease-out-expo);
}

.brand-loader.is-complete {
  opacity: 0;
  visibility: hidden;
  transform: scale(1.03);
  pointer-events: none;
}

.loader-card {
  width: 100%;
  max-width: 440px;
  background: rgba(17, 23, 36, 0.82);
  border: 1px solid rgba(226, 184, 87, 0.32);
  border-radius: 28px;
  padding: 2.4rem 2rem;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.75), 0 0 60px rgba(226, 184, 87, 0.16);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.loader-emblem-wrap {
  position: relative;
  width: 88px;
  height: 88px;
  margin: 0 auto 1.35rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loader-ring-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.loader-ring-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 4;
}

.loader-ring-prog {
  fill: none;
  stroke: var(--accent-gold);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 251.2;
  stroke-dashoffset: 251.2;
  filter: drop-shadow(0 0 8px rgba(226, 184, 87, 0.65));
}

.loader-crest {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: linear-gradient(135deg, #e2b857 0%, #b58318 100%);
  color: #07090e;
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 22px rgba(226, 184, 87, 0.35);
}

.loader-brand-name {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-gold);
  margin-bottom: 0.35rem;
}

.loader-headline {
  font-size: 1.25rem;
  font-weight: 700;
  color: #f4f7fb;
  margin-bottom: 1.25rem;
}

.loader-bar-outer {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  margin-bottom: 0.85rem;
}

.loader-bar-inner {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #e2b857, #10b981);
  border-radius: 999px;
}

.loader-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: #9ba8be;
}

.loader-pct {
  color: var(--accent-gold);
  font-weight: 700;
}

@media print {
  body { background: #ffffff !important; color: #0f172a !important; }
  .ambient-canvas, .top-nav, .toc-sidebar, .reading-progress-track, .brand-loader, .mobile-chapter-nav { display: none !important; }
  .workspace-shell { display: block; max-width: 100%; padding: 0; }
  .chapter-section, .hero-cover {
    opacity: 1 !important;
    transform: none !important;
    box-shadow: none !important;
    border: 1px solid #cbd5e1 !important;
    page-break-inside: avoid;
    margin-bottom: 1.5rem;
    background: #ffffff !important;
  }
}

