:root {
  --bg-page: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f1f5f9;
  --bg-surface-subtle: #e2e8f0;
  
  --text-primary: #090d16;
  --text-body: #1e293b;
  --text-muted: #475569;
  --text-dim: #64748b;
  
  --border-subtle: #cbd5e1;
  --border-strong: #94a3b8;
  
  --brand-accent: #991b1b;
  --brand-accent-bg: #fee2e2;
  --brand-gold: #854d0e;
  --brand-gold-bg: #fef9c3;
  --brand-navy: #1e3a8a;
  --brand-navy-bg: #dbeafe;
  --brand-emerald: #065f46;
  --brand-emerald-bg: #d1fae5;
  
  --font-serif: "Fraunces", "Spectral", Georgia, serif;
  --font-body: "Literata", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] {
  --bg-page: #0b0f19;
  --bg-surface: #131b2e;
  --bg-surface-elevated: #1e293b;
  --bg-surface-subtle: #273549;
  
  --text-primary: #f8fafc;
  --text-body: #e2e8f0;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --border-subtle: #2a374d;
  --border-strong: #3b4d68;
  
  --brand-accent: #f87171;
  --brand-accent-bg: #450a0a;
  --brand-gold: #fde047;
  --brand-gold-bg: #422006;
  --brand-navy: #93c5fd;
  --brand-navy-bg: #172554;
  --brand-emerald: #6ee7b7;
  --brand-emerald-bg: #064e3b;
  
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

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

body {
  font-family: var(--font-body);
  color: var(--text-body);
  background-color: var(--bg-page);
  line-height: 1.7;
  font-size: 1.125rem;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.wrap {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.wrap-wide {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* Header & Nav */
.topbar {
  border-bottom: 1px solid var(--border-subtle);
  background-color: var(--bg-surface);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.625rem 0;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  gap: 0.5rem;
}

.brand-link {
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  white-space: nowrap;
}

.brand-link:hover {
  color: var(--brand-accent);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.lang-switch {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
  color: var(--text-muted);
}

.lang-switch a {
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 600;
}

.lang-switch a:hover {
  text-decoration: underline;
}

.lang-switch span[aria-current="true"] {
  font-weight: 700;
  color: var(--brand-accent);
}

.theme-toggle {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.theme-toggle:hover {
  background: var(--bg-surface-subtle);
  border-color: var(--border-strong);
}

/* Masthead */
.masthead {
  padding: 3rem 0 2rem 0;
  border-bottom: 1px solid var(--border-subtle);
}

.kicker {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--brand-accent);
  margin-bottom: 0.75rem;
  font-weight: 600;
}

h1 {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 7vw, 2.75rem);
  line-height: 1.15;
  color: var(--text-primary);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 1.25rem;
  word-break: break-word;
}

.deck {
  font-size: clamp(1.1rem, 4vw, 1.35rem);
  line-height: 1.5;
  color: var(--text-body);
  font-weight: 400;
  margin-bottom: 1.5rem;
}

.meta-box {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  padding: 1rem 0;
  border-top: 1px dashed var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.meta-item strong {
  color: var(--text-primary);
}

/* Typography & Content */
.lede {
  font-size: 1.25rem;
  line-height: 1.6;
  color: var(--text-primary);
  margin: 2.5rem 0 1.5rem 0;
}

h2 {
  font-family: var(--font-serif);
  font-size: 2rem;
  color: var(--text-primary);
  margin: 3.5rem 0 1.25rem 0;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

h3 {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  color: var(--text-primary);
  margin: 2rem 0 0.75rem 0;
  line-height: 1.3;
}

p {
  margin-bottom: 1.5rem;
}

strong {
  color: var(--text-primary);
  font-weight: 600;
}

em {
  font-style: italic;
}

a {
  color: var(--brand-navy);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--brand-accent);
}

/* Callouts / Stat Cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin: 2rem 0;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.stat-number {
  font-family: var(--font-mono);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--brand-accent);
  line-height: 1.2;
  margin-bottom: 0.35rem;
}

.stat-label {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Executive Findings */
.findings-section {
  margin: 3rem 0;
}

.findings-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.finding-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 1.75rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease;
}

.finding-card:hover {
  border-color: var(--border-strong);
}

.finding-header {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.finding-num {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--brand-accent);
}

.finding-title {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  color: var(--text-primary);
  font-weight: 600;
}

.finding-highlight {
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--text-primary);
  font-size: 1.0625rem;
  margin-bottom: 0.75rem;
  padding-left: 1rem;
  border-left: 3px solid var(--brand-accent);
}

.finding-text {
  font-size: 1rem;
  color: var(--text-body);
  line-height: 1.6;
}

/* Interactive Calculator Container */
.interactive-container {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 2rem;
  margin: 3rem 0;
  box-shadow: var(--shadow-md);
}

.interactive-header {
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 1rem;
}

.interactive-kicker {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--brand-accent);
  letter-spacing: 0.05em;
  font-weight: 600;
}

.interactive-title {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  color: var(--text-primary);
  margin-top: 0.25rem;
}

.calc-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 768px) {
  .calc-grid {
    grid-template-columns: 1.2fr 1fr;
  }
}

.control-group {
  margin-bottom: 1.25rem;
}

.control-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.calc-select, .calc-input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  background-color: var(--bg-surface-elevated);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.95rem;
  transition: border-color 0.2s ease;
}

.calc-select:focus, .calc-input:focus {
  outline: none;
  border-color: var(--brand-navy);
}

.calc-result-panel {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.result-tag {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.result-sum {
  font-family: var(--font-mono);
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--brand-accent);
  margin: 0.5rem 0;
}

.result-breakdown {
  border-top: 1px dashed var(--border-subtle);
  padding-top: 1rem;
  margin-top: 1rem;
  font-size: 0.875rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.result-breakdown-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.35rem;
}

.result-commentary {
  margin-top: 1.25rem;
  padding: 1rem;
  background: var(--bg-surface);
  border-left: 3px solid var(--brand-navy);
  border-radius: 4px;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--text-body);
}

/* Laws Accordion / List */
.laws-list {
  margin: 2.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.law-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.law-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.5rem;
}

.law-num-badge {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  background: var(--brand-accent-bg);
  color: var(--brand-accent);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
}

.law-title {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  color: var(--text-primary);
  font-weight: 600;
}

.law-formula {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--brand-gold);
  background: var(--brand-gold-bg);
  padding: 0.35rem 0.65rem;
  border-radius: 4px;
  display: inline-block;
  margin: 0.5rem 0 1rem 0;
  font-weight: 600;
}

.law-text {
  font-size: 1.05rem;
  line-height: 1.65;
  color: var(--text-body);
  margin-bottom: 1rem;
}

.law-footer {
  border-top: 1px dashed var(--border-subtle);
  padding-top: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

/* Timeline / Ledger */
.timeline-container {
  position: relative;
  margin: 3rem 0;
  padding-left: 2rem;
}

.timeline-container::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0.5rem;
  width: 2px;
  background: var(--border-subtle);
}

.timeline-event {
  position: relative;
  margin-bottom: 2.5rem;
}

.timeline-dot {
  position: absolute;
  left: -2rem;
  top: 0.25rem;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 3px solid var(--brand-accent);
}

.timeline-dot.inflow {
  border-color: var(--brand-emerald);
}

.timeline-event-content {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.timeline-year {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--brand-accent);
}

.timeline-title {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  color: var(--text-primary);
  margin: 0.25rem 0 0.5rem 0;
}

.timeline-flow-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.timeline-flow-badge.inflow {
  background: var(--brand-emerald-bg);
  color: var(--brand-emerald);
}

.timeline-flow-badge.outflow {
  background: var(--brand-accent-bg);
  color: var(--brand-accent);
}

/* Cross Cultural Table */
.matrix-wrap {
  overflow-x: auto;
  margin: 2.5rem 0;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--bg-surface);
}

.matrix-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
  text-align: left;
}

.matrix-table th, .matrix-table td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
}

.matrix-table th {
  background: var(--bg-surface-elevated);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.matrix-table tr:last-child td {
  border-bottom: none;
}

.matrix-table tr:hover td {
  background: var(--bg-surface-elevated);
}

/* Monograph Box */
.monograph {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 2rem;
  margin: 3rem 0;
}

.monograph-num {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  text-transform: uppercase;
  color: var(--brand-accent);
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

/* Footnotes & Footer */
.method-box {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 1.5rem;
  margin: 4rem 0 2rem 0;
  font-size: 0.9375rem;
  color: var(--text-muted);
}

.site-footer {
  border-top: 1px solid var(--border-subtle);
  padding: 3rem 0;
  margin-top: 4rem;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--text-muted);
}

.footer-inner {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: flex-start;
}

@media (min-width: 640px) {
  .footer-inner {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}

/* Print */
@media print {
  body {
    background: white;
    color: black;
  }
  .topbar, .theme-toggle, .interactive-container {
    display: none;
  }
}
