:root {
  color-scheme: light;
  --paper: #f7f7f3;
  --surface: #ffffff;
  --surface-soft: #eef3ef;
  --ink: #18231f;
  --muted: #5b6862;
  --line: #d7ded9;
  --accent: #246b52;
  --accent-dark: #174936;
  --accent-soft: #dcece4;
  --warning: #805514;
  --warning-bg: #fff7e7;
  --danger: #913c35;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(24, 35, 31, 0.07);
  --content: 1160px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #121714;
    --surface: #19201c;
    --surface-soft: #212b26;
    --ink: #edf2ee;
    --muted: #b0bbb5;
    --line: #354039;
    --accent: #78c6a4;
    --accent-dark: #9bd8bd;
    --accent-soft: #213b30;
    --warning: #f0bd67;
    --warning-bg: #352b18;
    --danger: #f0aaa5;
    --shadow: none;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #121714;
  --surface: #19201c;
  --surface-soft: #212b26;
  --ink: #edf2ee;
  --muted: #b0bbb5;
  --line: #354039;
  --accent: #78c6a4;
  --accent-dark: #9bd8bd;
  --accent-soft: #213b30;
  --warning: #f0bd67;
  --warning-bg: #352b18;
  --danger: #f0aaa5;
  --shadow: none;
}

:root[data-theme="light"] { color-scheme: light; }

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 1rem;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
}
body.menu-open { overflow: hidden; }
a { color: var(--accent-dark); text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
img, svg { max-width: 100%; height: auto; }
button, input, select { font: inherit; }
button { color: inherit; }
:focus-visible { outline: 3px solid #d78c22; outline-offset: 3px; }
.skip-link {
  position: fixed; z-index: 1000; top: 0.75rem; left: 0.75rem;
  transform: translateY(-150%); padding: 0.65rem 1rem; background: var(--ink); color: var(--paper);
}
.skip-link:focus { transform: none; }

.container { width: min(calc(100% - 2rem), var(--content)); margin-inline: auto; }
.narrow { width: min(100%, 760px); }
.site-header {
  position: sticky; top: 0; z-index: 50; border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 94%, transparent); backdrop-filter: blur(12px);
}
.header-row { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { display: inline-flex; align-items: center; gap: 0.7rem; color: var(--ink); text-decoration: none; font-weight: 750; letter-spacing: -0.02em; }
.brand-mark { width: 29px; height: 29px; flex: 0 0 auto; }
.site-nav { display: flex; align-items: center; gap: 0.2rem; }
.site-nav a, .nav-more summary { color: var(--muted); text-decoration: none; padding: 0.55rem 0.7rem; border-radius: 8px; cursor: pointer; }
.site-nav a:hover, .site-nav a[aria-current="page"], .nav-more summary:hover { color: var(--ink); background: var(--surface-soft); }
.nav-more { position: relative; }
.nav-more summary { list-style: none; }
.nav-more summary::-webkit-details-marker { display: none; }
.nav-panel { position: absolute; right: 0; top: calc(100% + 0.55rem); width: 270px; display: grid; gap: 0.15rem; padding: 0.45rem; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.nav-panel a { padding: 0.55rem 0.7rem; }
.icon-button { border: 1px solid var(--line); border-radius: 9px; background: var(--surface); padding: 0.45rem 0.65rem; cursor: pointer; }
.menu-button { display: none; }

main { min-height: 65vh; }
.hero { padding: clamp(3.5rem, 9vw, 7.5rem) 0 4rem; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(310px, 0.65fr); gap: clamp(2rem, 5vw, 5rem); align-items: center; }
.eyebrow { margin: 0 0 0.85rem; color: var(--accent-dark); font-size: 0.83rem; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; }
h1, h2, h3 { line-height: 1.15; letter-spacing: -0.035em; text-wrap: balance; }
h1 { margin: 0 0 1.25rem; font-size: clamp(2.6rem, 7vw, 5.7rem); max-width: 13ch; }
.page-hero h1 { font-size: clamp(2.35rem, 5.5vw, 4.5rem); max-width: 17ch; }
h2 { margin: 0 0 1rem; font-size: clamp(1.75rem, 4vw, 2.7rem); }
h3 { margin: 0 0 0.6rem; font-size: 1.25rem; }
p { margin: 0 0 1rem; }
.lead { max-width: 700px; color: var(--muted); font-size: clamp(1.12rem, 2vw, 1.34rem); }
.hero-note { border-left: 3px solid var(--accent); padding-left: 1rem; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.75rem; }
.button { display: inline-flex; justify-content: center; align-items: center; min-height: 46px; padding: 0.65rem 1rem; border: 1px solid var(--accent); border-radius: 9px; background: var(--accent); color: #fff; font-weight: 700; text-decoration: none; cursor: pointer; }
.button:hover { background: var(--accent-dark); }
.button.secondary { background: transparent; color: var(--accent-dark); }
.button.secondary:hover { background: var(--accent-soft); }

.section { padding: clamp(3.2rem, 7vw, 6rem) 0; }
.section + .section { border-top: 1px solid var(--line); }
.section-head { max-width: 760px; margin-bottom: 2rem; }
.section-head p { color: var(--muted); font-size: 1.08rem; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { padding: clamp(1.15rem, 2.5vw, 1.6rem); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card p:last-child, .notice p:last-child { margin-bottom: 0; }
.metric { font-size: clamp(1.8rem, 4vw, 2.7rem); font-weight: 780; letter-spacing: -0.04em; line-height: 1; }
.metric-label { margin-top: 0.55rem; color: var(--muted); font-size: 0.92rem; }
.principle-card { min-height: 135px; }
.principle-card h3 { font-size: 1.08rem; }
.principle-card p { color: var(--muted); font-size: 0.94rem; }
.notice { padding: 1.1rem 1.25rem; border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 10px; background: var(--surface); }
.notice.warning { border-left-color: var(--warning); background: var(--warning-bg); }
.notice-title { display: block; margin-bottom: 0.25rem; font-weight: 750; }
.callout-number { padding: 1.8rem; background: var(--accent-soft); border-radius: var(--radius); }
.callout-number .metric { color: var(--accent-dark); }
.formula { overflow-x: auto; padding: 1.25rem; background: var(--ink); color: var(--paper); border-radius: 10px; font: 650 1.03rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.plain-list { padding-left: 1.2rem; }
.plain-list li { margin-bottom: 0.65rem; }
.check-list { list-style: none; padding: 0; margin: 0; }
.check-list li { position: relative; padding: 0.5rem 0 0.5rem 1.7rem; border-bottom: 1px solid var(--line); }
.check-list li::before { content: "✓"; position: absolute; left: 0; color: var(--accent); font-weight: 800; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 0.85rem 1rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--surface-soft); font-size: 0.88rem; line-height: 1.35; }
tr:last-child td { border-bottom: 0; }
td.numeric, th.numeric { text-align: right; white-space: nowrap; }
.caption { margin-top: 0.6rem; color: var(--muted); font-size: 0.88rem; }

.simulator-layout { display: grid; grid-template-columns: minmax(280px, 0.72fr) minmax(0, 1.28fr); gap: 1.5rem; align-items: start; }
.form-card { position: sticky; top: 86px; }
.field { margin-bottom: 1.15rem; }
.field label, .field legend { display: block; margin-bottom: 0.35rem; font-weight: 700; }
.field small { display: block; margin-top: 0.3rem; color: var(--muted); }
.input-row { display: flex; align-items: center; gap: 0.6rem; }
input[type="number"] { width: 100%; min-height: 46px; padding: 0.55rem 0.7rem; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.range-value { min-width: 3.8rem; text-align: right; font-weight: 800; }
.results-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
.result { padding: 1rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.result.total { grid-column: 1 / -1; background: var(--accent-soft); border-color: var(--accent); }
.result dd { margin: 0.3rem 0 0; font-size: 1.42rem; font-weight: 780; font-variant-numeric: tabular-nums; }
.result dt { color: var(--muted); font-size: 0.88rem; }
.chart-card { margin-top: 1rem; }
.chart-title-row { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; }
.chart-container { min-height: 300px; overflow: hidden; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 0.7rem 1rem; color: var(--muted); font-size: 0.86rem; }
.legend-item { display: inline-flex; align-items: center; gap: 0.35rem; }
.legend-swatch { width: 18px; height: 4px; border-radius: 3px; background: currentColor; }
.chart-axis { stroke: var(--line); stroke-width: 1; }
.chart-label { fill: var(--muted); font: 12px ui-sans-serif, system-ui, sans-serif; }

.source-list { display: grid; gap: 1rem; counter-reset: source; }
.source { position: relative; padding: 1.25rem 1.25rem 1.25rem 3.5rem; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.source::before { counter-increment: source; content: counter(source); position: absolute; left: 1.15rem; top: 1.1rem; display: grid; place-items: center; width: 1.65rem; height: 1.65rem; background: var(--accent-soft); color: var(--accent-dark); border-radius: 50%; font-weight: 800; font-size: 0.8rem; }
.source h2 { margin: 0 0 0.3rem; font-size: 1.05rem; letter-spacing: -0.01em; }
.source-meta { color: var(--muted); font-size: 0.88rem; }
.source p { margin: 0.6rem 0 0; }
.version-box { display: inline-grid; gap: 0.15rem; padding: 1rem 1.25rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }

.site-footer { margin-top: 4rem; border-top: 1px solid var(--line); padding: 2.5rem 0; color: var(--muted); }
.footer-grid { display: grid; grid-template-columns: 1.25fr 1fr 1fr; gap: 2rem; }
.footer-links { display: grid; align-content: start; gap: 0.35rem; }
.footer-links a { color: var(--muted); }
.fine-print { font-size: 0.86rem; }

@media (max-width: 900px) {
  .hero-grid, .simulator-layout { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-card { position: static; }
  .site-nav { position: fixed; inset: 68px 0 0; display: none; align-content: start; padding: 1rem; background: var(--paper); overflow-y: auto; }
  .site-nav.open { display: grid; }
  .site-nav a, .nav-more summary { padding: 0.8rem; }
  .nav-more { position: static; }
  .nav-panel { position: static; width: 100%; margin-top: 0.3rem; box-shadow: none; }
  .menu-button { display: inline-flex; }
}

@media (max-width: 640px) {
  .container { width: min(calc(100% - 1.25rem), var(--content)); }
  .hero { padding-top: 3rem; }
  h1 { font-size: clamp(2.45rem, 15vw, 4rem); }
  .grid-2, .grid-3, .grid-4, .footer-grid { grid-template-columns: 1fr; }
  .results-grid { grid-template-columns: 1fr; }
  .result.total { grid-column: auto; }
  .actions .button { width: 100%; }
  th, td { padding: 0.7rem; }
  .chart-container { min-height: 240px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

@media print {
  .site-header, .site-footer, .actions, .form-card { display: none !important; }
  body { background: #fff; color: #000; }
  .section { padding: 1.5rem 0; }
  .card, .notice { box-shadow: none; break-inside: avoid; }
}
