:root {
  --bg: #FAFAF7;
  --bg-alt: #F2F1EC;
  --bg-sim: #FFFFFF;
  --text: #1A1A18;
  --text-secondary: #6B6B66;
  --text-tertiary: #9C9C96;
  --accent: #C4420A;
  --accent-light: #FFF0EB;
  --accent-dark: #8B2F07;
  --teal: #0F6E56;
  --teal-light: #E1F5EE;
  --blue: #185FA5;
  --blue-light: #E6F1FB;
  --purple: #534AB7;
  --purple-light: #EEEDFE;
  --amber: #854F0B;
  --amber-light: #FAEEDA;
  --border: rgba(0,0,0,0.08);
  --border-strong: rgba(0,0,0,0.15);
  --font-display: 'Fraunces', serif;
  --font-body: 'DM Sans', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --max-w: 720px;
  --max-w-wide: 920px;
  --radius: 12px;
  --radius-sm: 8px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141413;
    --bg-alt: #1E1E1C;
    --bg-sim: #1A1A18;
    --text: #EDEDEB;
    --text-secondary: #A3A39D;
    --text-tertiary: #6B6B66;
    --accent: #E8593C;
    --accent-light: #2D1610;
    --accent-dark: #F09B85;
    --teal: #5DCAA5;
    --teal-light: #0A2A20;
    --blue: #85B7EB;
    --blue-light: #0C1F33;
    --purple: #AFA9EC;
    --purple-light: #1C1A3A;
    --amber: #FAC775;
    --amber-light: #2A1D05;
    --border: rgba(255,255,255,0.08);
    --border-strong: rgba(255,255,255,0.15);
  }
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
::selection { background: var(--accent); color: #fff; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
.container { max-width: var(--max-w); margin: 0 auto; padding: 0 24px; }
.container-wide { max-width: var(--max-w-wide); margin: 0 auto; padding: 0 24px; }

/* Hero */
.hero {
  padding: 80px 0 60px;
  border-bottom: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  top: -200px; right: -200px;
  width: 600px; height: 600px;
  background: radial-gradient(circle, var(--accent-light) 0%, transparent 70%);
  pointer-events: none;
  opacity: 0.6;
}
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-light);
  padding: 6px 14px;
  border-radius: 100px;
  margin-bottom: 28px;
}
.hero-badge::before {
  content: '';
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.3} }
.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 20px;
  max-width: 680px;
}
.hero h1 em {
  font-style: italic;
  color: var(--accent);
  font-weight: 600;
}
.hero-subtitle {
  font-size: 1.15rem;
  color: var(--text-secondary);
  max-width: 580px;
  line-height: 1.65;
  margin-bottom: 32px;
}
.hero-tagline {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-tertiary);
  letter-spacing: 0.02em;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  max-width: 460px;
}
.author-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}
.author-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  color: #fff;
}
.author-info { font-size: 14px; }
.author-name { font-weight: 600; }
.author-meta { color: var(--text-secondary); font-size: 13px; }
.author-meta a { color: var(--accent); }

/* Article */
article { padding: 56px 0; }
article h2 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 56px 0 20px;
  padding-top: 40px;
  border-top: 1px solid var(--border);
}
article h2:first-of-type { margin-top: 0; border-top: none; padding-top: 0; }
article h3 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  margin: 36px 0 14px;
}
article p { margin-bottom: 18px; font-size: 1.05rem; }
article strong { font-weight: 600; }
article .lead {
  font-size: 1.2rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 28px;
}
article blockquote {
  border-left: 3px solid var(--accent);
  padding: 16px 24px;
  margin: 28px 0;
  background: var(--bg-alt);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-style: italic;
  color: var(--text-secondary);
}
article blockquote strong { color: var(--text); }
.formula-block {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 24px;
  margin: 24px 0;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.8;
  overflow-x: auto;
}
.formula-block .formula-label {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 10px;
}
.formula-block .formula-main {
  font-size: 18px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 12px;
}
.formula-block .formula-vars {
  font-size: 13px;
  color: var(--text-secondary);
}
.callout {
  background: var(--accent-light);
  border: 1px solid rgba(196,66,10,0.15);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin: 28px 0;
  font-size: 0.95rem;
}
.callout-teal { background: var(--teal-light); border-color: rgba(15,110,86,0.15); }
.callout-blue { background: var(--blue-light); border-color: rgba(24,95,165,0.15); }
.callout strong { font-weight: 600; }
sup.fn {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  margin-left: 1px;
}
sup.fn:hover { text-decoration: underline; }
hr.section-break {
  border: none;
  height: 1px;
  background: var(--border);
  margin: 48px 0;
}

/* Data table */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 14px;
}
.data-table th {
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  padding: 10px 14px;
  border-bottom: 2px solid var(--border-strong);
}
.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.data-table tr:last-child td { border-bottom: none; }

/* Simulation Card */
.sim-card {
  background: var(--bg-sim);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  margin: 36px -40px;
  padding: 0;
  overflow: hidden;
  position: relative;
}
@media (max-width: 820px) { .sim-card { margin: 36px -12px; } }
.sim-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-alt);
}
.sim-header-left { display: flex; align-items: center; gap: 12px; }
.sim-number {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-light);
  padding: 4px 10px;
  border-radius: 100px;
}
.sim-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
}
.sim-actions { display: flex; gap: 8px; }
.sim-btn {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--bg-sim);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  display: flex; align-items: center; gap: 5px;
}
.sim-btn:hover { background: var(--bg-alt); color: var(--text); border-color: var(--text-tertiary); }
.sim-btn svg { width: 14px; height: 14px; }
.sim-body { padding: 28px; }
.sim-description {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  max-width: 600px;
}
.sim-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}
.preset-btn {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  padding: 5px 14px;
  border-radius: 100px;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}
.preset-btn:hover, .preset-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.sim-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 24px; margin-bottom: 24px; }
@media (max-width: 600px) { .sim-controls { grid-template-columns: 1fr; } }
.sim-control {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sim-control label {
  font-size: 13px;
  color: var(--text-secondary);
  min-width: 130px;
  flex-shrink: 0;
}
.sim-control input[type="range"] {
  flex: 1;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border-strong);
  border-radius: 2px;
  outline: none;
}
.sim-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid var(--bg-sim);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.sim-control .val {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  min-width: 48px;
  text-align: right;
  color: var(--text);
}
.sim-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 24px;
}
.metric-card {
  background: var(--bg-alt);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.metric-label { font-size: 11px; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.04em; }
.metric-value { font-family: var(--font-mono); font-size: 22px; font-weight: 500; margin-top: 4px; }
.metric-sub { font-size: 11px; color: var(--text-tertiary); margin-top: 2px; }
.metric-positive { color: var(--teal); }
.metric-negative { color: var(--accent); }
.metric-neutral { color: var(--text); }
.sim-chart { position: relative; width: 100%; margin-bottom: 16px; }
.sim-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 8px;
}
.sim-legend span { display: flex; align-items: center; gap: 5px; }
.sim-legend .dot { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.sim-formula-toggle {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.formula-toggle-btn {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0;
}
.formula-toggle-btn:hover { color: var(--text); }
.formula-toggle-btn svg { width: 14px; height: 14px; transition: transform 0.2s; }
.formula-toggle-btn.open svg { transform: rotate(90deg); }
.sim-formula-content {
  display: none;
  margin-top: 14px;
  padding: 20px;
  background: var(--bg-alt);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.sim-formula-content.open { display: block; }

/* Share bar */
.share-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 0;
  flex-wrap: wrap;
}
.share-bar-label { font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.share-btn {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--bg-sim);
  color: var(--text);
  cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  transition: all 0.15s;
}
.share-btn:hover { background: var(--bg-alt); border-color: var(--text-tertiary); }
.share-btn svg { width: 16px; height: 16px; }
.share-btn.linkedin { background: #0A66C2; color: #fff; border-color: #0A66C2; }
.share-btn.linkedin:hover { background: #004182; }
.share-btn.discuss { background: var(--accent); color: #fff; border-color: var(--accent); }
.share-btn.discuss:hover { background: var(--accent-dark); }

/* CTA Section */
.cta-section {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  margin: 48px 0;
  text-align: center;
}
.cta-section h3 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 12px;
}
.cta-section p { color: var(--text-secondary); margin-bottom: 24px; max-width: 500px; margin-left: auto; margin-right: auto; }

/* Footnotes */
.footnotes {
  padding: 40px 0;
  border-top: 2px solid var(--border-strong);
}
.footnotes h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 20px;
}
.footnote-item {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  padding-left: 28px;
  position: relative;
  line-height: 1.6;
}
.footnote-item .fn-num {
  position: absolute;
  left: 0;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 11px;
  color: var(--accent);
}
.footnote-item a { color: var(--accent); word-break: break-all; }

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 40px 0;
  text-align: center;
  font-size: 13px;
  color: var(--text-tertiary);
}
.footer-name { font-family: var(--font-display); font-weight: 600; color: var(--text); font-size: 15px; }
.footer-links { margin-top: 12px; display: flex; justify-content: center; gap: 20px; }
.footer-links a { color: var(--text-secondary); font-size: 13px; }

/* TOC */
.toc {
  position: fixed;
  top: 50%;
  left: max(16px, calc(50% - 540px));
  transform: translateY(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
@media (max-width: 1200px) { .toc { display: none; } }
.toc a {
  display: block;
  width: 3px;
  height: 20px;
  background: var(--border-strong);
  border-radius: 2px;
  transition: all 0.2s;
}
.toc a:hover, .toc a.active { background: var(--accent); width: 4px; }

/* Print */
@media print {
  body { background: #fff; color: #000; }
  .toc, .sim-actions, .sim-presets, .share-bar, .share-btn, .cta-section, .sim-btn, .preset-btn, .hero::before { display: none !important; }
  .sim-card { break-inside: avoid; border: 1px solid #ddd; margin: 20px 0; }
  .container, .container-wide { max-width: 100%; }
  .print-watermark { display: block !important; }
}
.print-watermark {
  display: none;
  position: fixed;
  bottom: 16px;
  right: 16px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: #999;
}
.print-watermark a { color: #999; }

/* Sim print overlay */
.sim-print-content {
  display: none;
}

/* Smooth scroll anchor offset */
[id] { scroll-margin-top: 24px; }

/* Sticky header */
.sticky-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transform: translateY(-100%);
  transition: transform 0.3s;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
}
.sticky-header.visible { transform: translateY(0); }
.sticky-header .logo {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
}
.sticky-header .logo span { color: var(--accent); }
