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

:root {
  --bg-0: #171310;
  --bg-1: #221c17;
  --card-bg: rgba(255, 246, 235, 0.045);
  --card-border: rgba(255, 246, 235, 0.1);
  --card-shadow: 0 16px 36px rgba(0, 0, 0, 0.4);
  --text: #f6efe6;
  --text-dim: rgba(246, 239, 230, 0.62);
  --text-dimmer: rgba(246, 239, 230, 0.4);
  --accent: #e5e5e5;
  --accent-strong: #ffffff;
  --accent-bg: rgba(255, 255, 255, 0.08);
  --input-bg: rgba(255, 246, 235, 0.06);
  --input-border: rgba(255, 246, 235, 0.14);
  --hair: rgba(246, 239, 230, 0.12);
  --hair-strong: rgba(246, 239, 230, 0.22);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --mesh-line: rgba(255, 255, 255, 0.08);
  --mesh-glow: #ffffff;
  --ok: #a7cbb1;
  --warn: #e6c281;
  --bad: #e59484;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

html, body {
  min-height: 100%;
  font-family: var(--sans);
  background:
    radial-gradient(120% 50% at 50% -10%, rgba(255, 255, 255, 0.05), transparent 60%),
    linear-gradient(160deg, var(--bg-1) 0%, var(--bg-0) 100%);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.62;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

/* ---------- FEA mesh background ---------- */
#meshBg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
#meshSvg { width: 100%; height: 100%; display: block; }
.meshLine { fill: none; stroke: var(--mesh-line); stroke-width: 1; }

/* ---------- shell ---------- */
#page {
  position: relative;
  z-index: 1;
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 20px 72px;
}

::selection { background: rgba(255, 255, 255, 0.16); }

/* ---------- masthead ---------- */
.mast { padding: 52px 0 26px; border-bottom: 1px solid var(--hair-strong); }
.eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 14px;
}
.eyebrow a {
  color: inherit;
  text-decoration: none;
  text-transform: none;
  transition: color 0.2s var(--ease);
}
.eyebrow a:hover,
.eyebrow a:focus-visible { color: var(--text); }
.eyebrow a:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 4px;
  border-radius: 4px;
}
.mast h1 {
  font-size: clamp(30px, 4.6vw, 46px);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.05;
  text-wrap: balance;
  margin-bottom: 16px;
}
.standfirst {
  max-width: 60ch;
  font-size: 17px;
  color: var(--text-dim);
  line-height: 1.55;
  margin-bottom: 16px;
  text-wrap: pretty;
}
.mast-meta {
  font-size: 12.5px;
  color: var(--text-dimmer);
  letter-spacing: 0.02em;
  line-height: 1.6;
}

/* ---------- layout ---------- */
.wrap { display: grid; grid-template-columns: 1fr; gap: 40px; padding-top: 34px; }
@media (min-width: 1000px) {
  .wrap { grid-template-columns: 216px minmax(0, 1fr); gap: 52px; }
  .toc { position: sticky; top: 26px; align-self: start; }
}

/* ---------- table of contents ---------- */
.toc {
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  border-radius: 18px;
  padding: 18px 18px 20px;
}
.toc-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dimmer);
  margin-bottom: 12px;
}
.toc ol { list-style: none; }
.toc li { margin: 2px 0; }
.toc a {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 6px 8px;
  border-radius: 9px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}
.toc a:hover, .toc a:focus-visible {
  background: var(--accent-bg);
  color: var(--accent-strong);
  outline: none;
}
.toc .sn {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-dimmer);
  font-variant-numeric: tabular-nums;
  min-width: 20px;
}

/* ---------- main column ---------- */
main { min-width: 0; max-width: 74ch; }
section { margin-bottom: 60px; }
section > h2 {
  padding-top: 26px;
  border-top: 1px solid var(--hair);
  font-size: 25px;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.15;
  margin-bottom: 8px;
  text-wrap: balance;
}
.secno {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-dimmer);
  margin-bottom: 12px;
}
section > h3, .calc h3 {
  font-size: 16.5px;
  font-weight: 700;
  color: var(--accent-strong);
  margin: 30px 0 8px;
}
p { margin: 14px 0; color: var(--text); max-width: 68ch; }
p.tnote, .standfirst, .mast-meta { color: var(--text-dim); }
main ul { margin: 14px 0 14px 2px; max-width: 66ch; list-style: none; }
main ul li {
  position: relative;
  padding-left: 20px;
  margin: 9px 0;
  color: var(--text);
}
main ul li::before {
  content: "";
  position: absolute;
  left: 2px; top: 10px;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--text-dimmer);
}
strong { color: var(--accent-strong); font-weight: 700; }
em { color: var(--text); }
a { color: var(--accent-strong); }

/* ---------- equations ---------- */
.eq {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin: 18px 0;
  padding: 15px 18px;
  background: rgba(255, 246, 235, 0.04);
  border: 1px solid var(--card-border);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  overflow-x: auto;
}
.eq .m {
  font-size: 19px;
  color: var(--accent-strong);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.eq .tag {
  font-size: 12px;
  color: var(--text-dimmer);
  flex: none;
  text-align: right;
}
.m i, .mi { font-style: italic; }
.m .up { font-style: normal; }
.fr {
  display: inline-flex;
  flex-direction: column;
  vertical-align: -0.55em;
  text-align: center;
  line-height: 1.25;
  font-size: 0.92em;
  margin: 0 0.18em;
}
.fr .n { border-bottom: 1.5px solid currentColor; padding: 0 0.35em; display: block; }
.fr .d { padding: 0 0.35em 0.05em; display: block; }
sup, sub { line-height: 0; font-size: 0.72em; }
.mi { white-space: nowrap; }

/* ---------- tables ---------- */
.tw {
  overflow-x: auto;
  margin: 18px 0 8px;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  background: var(--card-bg);
  -webkit-overflow-scrolling: touch;
}
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
}
caption {
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--hair);
}
th {
  text-align: left;
  font-weight: 600;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dimmer);
  padding: 10px 14px;
  border-bottom: 1px solid var(--hair);
  white-space: nowrap;
}
td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--hair);
  white-space: nowrap;
  color: var(--text-dim);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(255, 255, 255, 0.02); }
td.sp { color: var(--text); font-weight: 500; }
th.num, td.num { text-align: right; }
.tnote { font-size: 13px; line-height: 1.55; margin: 10px 0 0; max-width: 70ch; }

/* ---------- callouts ---------- */
.note {
  margin: 20px 0;
  padding: 15px 18px;
  background: rgba(255, 246, 235, 0.04);
  border: 1px solid var(--card-border);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-dim);
  max-width: 72ch;
}
.note .nt {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-strong);
  margin-bottom: 6px;
}

/* ---------- calculators ---------- */
.calc {
  margin: 24px 0;
  padding: 22px 22px 24px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  box-shadow: var(--card-shadow);
}
.calc h3 { margin: 0 0 4px; }
.calc .sub { font-size: 13.5px; color: var(--text-dim); line-height: 1.45; margin-bottom: 18px; }
.cgrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px 16px;
}
.calc label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 7px;
}
.calc input, .calc select {
  width: 100%;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  border: 1px solid var(--input-border);
  border-radius: 11px;
  padding: 11px 13px;
}
.calc input {
  background: var(--input-bg);
  -moz-appearance: textfield;
  font-variant-numeric: tabular-nums;
}
.calc select {
  background-color: #2a231c;
  color-scheme: dark;
}
.calc select option { background-color: #2a231c; color: var(--text); }
.calc input:focus, .calc select:focus {
  outline: none;
  border-color: var(--accent);
  background-color: rgba(255, 255, 255, 0.05);
}

.cout {
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  align-items: stretch;
}
.cout .co {
  background: var(--accent-bg);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  padding: 13px 14px 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
}
.cout .co .cl {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}
.cout .co .cv {
  font-size: 24px;
  font-weight: 800;
  color: var(--accent-strong);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.cout .co.verdict { justify-content: center; }
.pill {
  align-self: center;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid currentColor;
}
.pill.ok   { color: var(--ok);   background: rgba(167, 203, 177, 0.1); }
.pill.warn { color: var(--warn); background: rgba(230, 194, 129, 0.1); }
.pill.bad  { color: var(--bad);  background: rgba(229, 148, 132, 0.1); }

/* ---------- diagrams ---------- */
figure { margin: 22px 0; }
figure svg { display: block; max-width: 100%; height: auto; }
figcaption { font-size: 13px; color: var(--text-dim); margin-top: 8px; line-height: 1.5; max-width: 66ch; }
.dg-line { stroke: var(--text-dim); fill: none; stroke-width: 1.6; }
.dg-accent { stroke: var(--accent-strong); fill: none; }
.dg-dim { stroke: var(--text-dimmer); fill: none; }
.dg-label { font-family: var(--sans); font-size: 11px; fill: var(--text-dimmer); }
.dg-var { font-family: var(--sans); font-style: italic; font-size: 13px; font-weight: 600; fill: var(--accent-strong); }

/* ---------- footer ---------- */
.colophon {
  margin-top: 48px;
  padding-top: 22px;
  border-top: 1px solid var(--hair-strong);
  font-size: 12.5px;
  color: var(--text-dimmer);
  line-height: 1.6;
  max-width: 74ch;
}

code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.9em; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
