:root {
  --ink: #14233a;
  --ink-soft: #3c4654;
  --muted: #76808d;
  --faint: #aab2bd;
  --line: #e7eaee;
  --line-soft: #eef1f4;
  --blue: #185fa5;
  --blue-d: #0c447c;
  --blue-l: #e9f1fa;
  --bg: #ffffff;
  --bg-alt: #f7f9fb;
  --bench: #9aa0a8;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --wrap: 1080px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

a { color: var(--blue-d); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 28px; }

h1, h2, h3 { color: var(--ink); font-weight: 500; }

/* ---- header ---- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255,255,255,0.92);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px;
}
.wordmark {
  font-family: var(--serif);
  font-size: 20px; font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--ink);
  font-variant: small-caps;
}
.nav { display: flex; gap: 26px; }
.nav a {
  color: var(--muted); font-size: 14px; letter-spacing: 0.01em;
}
.nav a:hover { color: var(--ink); text-decoration: none; }

/* ---- hero ---- */
.hero { padding: 92px 0 64px; }
.eyebrow {
  font-size: 12px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--blue); font-weight: 500; margin: 0 0 18px;
}
.hero h1 {
  font-family: var(--serif);
  font-size: 44px; line-height: 1.2; margin: 0;
  max-width: 16em; letter-spacing: -0.01em;
}
.hero .lede {
  margin: 22px 0 0; max-width: 38em; font-size: 18px; color: var(--ink-soft);
}
.hero .meta {
  margin-top: 26px; font-size: 14px; color: var(--muted);
  display: flex; gap: 18px; flex-wrap: wrap; align-items: center;
}
.hero .meta span { display: inline-flex; align-items: center; gap: 8px; }
.hero .dot { width: 4px; height: 4px; border-radius: 50%; background: var(--faint); }

/* ---- section scaffolding ---- */
section { padding: 24px 0; }
.section-alt { background: var(--bg-alt); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.section-label {
  font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--faint); font-weight: 500; margin: 0 0 8px;
}
.section-head { padding-top: 40px; }
.section-head h2 { font-family: var(--serif); font-size: 30px; margin: 0; }
.section-head p { color: var(--muted); max-width: 40em; margin: 12px 0 0; }

/* ---- project ---- */
.project { padding-top: 26px; padding-bottom: 56px; }
.project h3 { font-family: var(--serif); font-size: 24px; margin: 0 0 6px; }
.project .tagline { color: var(--ink-soft); margin: 0 0 14px; max-width: 46em; }
.project .lead { color: var(--ink-soft); margin: 0 0 18px; max-width: 46em; }
.tags { display: flex; flex-wrap: wrap; gap: 7px; margin: 0 0 26px; }
.tag {
  font-family: var(--mono); font-size: 12px; color: var(--blue-d);
  background: var(--blue-l); border-radius: 6px; padding: 4px 9px;
}

/* ---- report panel ---- */
.panel {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 12px; padding: 22px 24px; margin-bottom: 22px;
}
.panel-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; border-bottom: 1px solid var(--line-soft);
  padding-bottom: 12px; margin-bottom: 16px;
}
.panel-head h4 { color: var(--blue); font-size: 15px; font-weight: 600; margin: 0; }
.panel-head .period { font-size: 12px; color: var(--muted); }

.controls {
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px 26px;
  margin-bottom: 4px;
}
.control-group { display: flex; align-items: center; gap: 12px; }
.control-group > .glabel {
  font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
.toggle { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; color: var(--ink); cursor: pointer; }
.toggle input { width: 15px; height: 15px; accent-color: var(--blue); cursor: pointer; }
.toggle.qqq input { accent-color: #1d9e75; }
.weight { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 230px; }
.weight input[type=range] { flex: 1; accent-color: var(--blue); cursor: pointer; }
.weight .wval { font-size: 13px; color: var(--ink); font-weight: 500; white-space: nowrap; min-width: 150px; text-align: right; }
select {
  font-family: var(--sans); font-size: 14px; color: var(--ink); max-width: 100%;
  border: 1px solid var(--line); border-radius: 7px; padding: 6px 10px; background: var(--bg); cursor: pointer;
}
.presets { gap: 6px; }
.presets button {
  font-family: var(--sans); font-size: 12.5px; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 7px; padding: 5px 11px; cursor: pointer; transition: border-color .15s, background .15s;
}
.presets button:hover { border-color: var(--blue); background: var(--blue-l); }
.presets button.active { background: var(--blue); color: #fff; border-color: var(--blue); }

.legend { display: flex; gap: 18px; font-size: 12.5px; color: var(--muted); margin: 16px 0 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .swatch { width: 16px; height: 0; display: inline-block; }
.legend .solid { border-top: 2px solid var(--blue); }
.legend .dash { border-top: 2px dashed var(--bench); }

.chart-box { position: relative; width: 100%; height: 300px; }

.metric-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px; margin-top: 18px;
}
.metric { background: var(--bg-alt); border-radius: 8px; padding: 11px 13px; }
.metric .mlabel { font-size: 11px; color: var(--muted); margin: 0 0 4px; letter-spacing: 0.02em; }
.metric .mval { font-size: 20px; font-weight: 500; color: var(--ink); margin: 0; font-variant-numeric: tabular-nums; }
.metric.neg .mval { color: #a3402b; }

.foot-note { font-size: 12px; color: var(--faint); margin: 16px 0 0; line-height: 1.6; }
.panel-foot { display: flex; justify-content: space-between; font-size: 11px; color: var(--faint); margin-top: 14px; }

/* ---- correlation matrix ---- */
#corr-matrix { overflow-x: auto; }
.corr { border-collapse: collapse; width: 100%; max-width: 620px; min-width: 480px; font-size: 13px; }
.corr th { font-weight: 500; color: var(--muted); padding: 6px 8px; text-align: center; font-size: 12px; }
.corr td.rl { color: var(--ink); text-align: left; white-space: nowrap; padding-right: 14px; }
.corr td.cell { text-align: center; font-variant-numeric: tabular-nums; padding: 9px 8px; font-weight: 500; }

/* ---- engineering cards ---- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-top: 28px; }
.card { background: var(--bg); padding: 24px 24px 26px; }
.card .idx { font-family: var(--mono); font-size: 12px; color: var(--blue); letter-spacing: 0.04em; }
.card h3 { font-family: var(--serif); font-size: 19px; margin: 8px 0 8px; }
.card p { font-size: 14.5px; color: var(--ink-soft); margin: 0; line-height: 1.6; }

/* ---- about ---- */
.about-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 52px; margin-top: 26px; align-items: start; }
.about-grid p { margin: 0 0 16px; max-width: 36em; }
.facts { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--line); }
.facts li { padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 14px; color: var(--ink-soft); }
.facts li b { color: var(--ink); font-weight: 500; display: block; font-size: 13px; }
.skills { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }

/* ---- contact ---- */
.contact { padding-bottom: 80px; }
.contact h2 { font-family: var(--serif); font-size: 30px; margin: 0 0 10px; }
.contact p { color: var(--muted); max-width: 34em; margin: 0 0 24px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); border-radius: 9px; padding: 11px 18px;
  font-size: 14px; color: var(--ink); background: var(--bg); transition: border-color .15s, background .15s;
}
.btn:hover { border-color: var(--blue); background: var(--blue-l); text-decoration: none; }
.btn.primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn.primary:hover { background: var(--blue-d); border-color: var(--blue-d); }

/* ---- footer ---- */
.site-footer { border-top: 1px solid var(--line); padding: 30px 0 48px; }
.site-footer .wrap { display: flex; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.site-footer p { font-size: 12.5px; color: var(--faint); margin: 0; max-width: 40em; }

/* ---- responsive ---- */
@media (max-width: 760px) {
  .wrap { padding: 0 20px; }
  .nav { gap: 16px; }
  .nav a.hide-sm { display: none; }
  .hero { padding: 64px 0 44px; }
  .hero h1 { font-size: 32px; }
  .hero .lede { font-size: 16px; }
  .section-head h2 { font-size: 25px; }
  .about-grid { grid-template-columns: 1fr; gap: 28px; }
  .weight .wval { min-width: 0; }
  .controls { gap: 12px 18px; }
  .control-group { flex-wrap: wrap; }
  .weight { min-width: 100%; }
}
