/* ==========================================================
   Partha Chakraborty — portfolio
   Editorial / Swiss grid. Paper, ink, one cobalt accent.
   ========================================================== */

:root {
  --bg: #f3f1ec;
  --surface: #fbfaf7;
  --ink: #15161a;
  --ink-2: #45474d;
  --muted: #7d7e83;
  --rule: #d8d5cc;
  --rule-strong: #15161a;
  --accent: #2742e8;
  --accent-ink: #ffffff;
  --accent-soft: #e2e6fc;
  --inv-bg: #15161a;
  --inv-fg: #ecebe6;
  --inv-muted: #8f9096;
  --inv-rule: #2d2e33;
  --inv-accent: #8d9cff;

  --serif: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --gutter: clamp(16px, 4vw, 48px);
  --max: 1320px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111214;
    --surface: #18191c;
    --ink: #ecebe6;
    --ink-2: #b4b3ae;
    --muted: #7f8085;
    --rule: #2a2b2f;
    --rule-strong: #ecebe6;
    --accent: #8394ff;
    --accent-ink: #0d0e12;
    --accent-soft: #1d2250;
    --inv-bg: #1a1c24;
    --inv-fg: #ecebe6;
    --inv-muted: #8c8d95;
    --inv-rule: #2f313b;
    --inv-accent: #9aa7ff;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111214;
  --surface: #18191c;
  --ink: #ecebe6;
  --ink-2: #b4b3ae;
  --muted: #7f8085;
  --rule: #2a2b2f;
  --rule-strong: #ecebe6;
  --accent: #8394ff;
  --accent-ink: #0d0e12;
  --accent-soft: #1d2250;
  --inv-bg: #1a1c24;
  --inv-fg: #ecebe6;
  --inv-muted: #8c8d95;
  --inv-rule: #2f313b;
  --inv-accent: #9aa7ff;
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
h1, h2, h3 { margin: 0; font-weight: 400; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
ul, ol { margin: 0; padding: 0; list-style: none; }
em { font-style: italic; }
code { font: 0.9em var(--mono); background: var(--accent-soft); padding: 0.1em 0.35em; }
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

.wrap { max-width: var(--max); margin: 0 auto; padding-left: var(--gutter); padding-right: var(--gutter); }
.mono { font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.04em; text-transform: uppercase; }
.accent { color: var(--accent); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: fixed; top: -60px; left: 12px; z-index: 50; background: var(--accent); color: var(--accent-ink); padding: 10px 14px; }
.skip:focus { top: 12px; }

/* Links & buttons */
.link {
  display: inline-flex; align-items: center; gap: 0.35em;
  font-weight: 500; font-size: 15px;
  background: linear-gradient(currentColor, currentColor) 0 100% / 100% 1px no-repeat;
  padding-bottom: 2px;
  transition: color .2s, background-size .3s var(--ease);
}
.link:hover { color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; gap: 0.6em;
  height: 44px; padding: 0 18px;
  border: 1px solid var(--rule-strong);
  font-weight: 500; font-size: 15px;
  transition: background .2s, color .2s, border-color .2s;
}
.btn:hover { background: var(--ink); color: var(--bg); }
.btn-solid { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-solid:hover { background: var(--ink); border-color: var(--ink); color: var(--bg); }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tags li {
  font: 500 11px/1 var(--mono); letter-spacing: 0.02em;
  padding: 6px 8px; border: 1px solid var(--rule); color: var(--ink-2);
}

/* ---------- Masthead ---------- */
.masthead {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px) saturate(1.2);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  border-bottom: 1px solid var(--rule);
}
.masthead-inner {
  max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter);
  height: 60px; display: flex; align-items: center; gap: 24px;
}
.wordmark { font: 400 24px/1 var(--serif); letter-spacing: -0.01em; display: inline-flex; align-items: baseline; gap: 3px; white-space: nowrap; }
.wordmark .dot { width: 7px; height: 7px; background: var(--accent); display: inline-block; }
.nav { margin-left: auto; display: flex; gap: 4px; }
.nav a {
  display: inline-flex; align-items: baseline; gap: 6px;
  padding: 8px 10px; font-size: 14px; font-weight: 500; color: var(--ink-2);
  transition: color .2s;
}
.nav a .mono { font-size: 10px; color: var(--muted); }
.nav a:hover, .nav a.is-current { color: var(--ink); }
.nav a.is-current .mono { color: var(--accent); }
.masthead-tools { display: flex; gap: 4px; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { color: var(--accent); }
.menu-btn { display: none; }

/* ---------- Hero ---------- */
.hero { padding-top: clamp(28px, 5vw, 56px); padding-bottom: clamp(56px, 9vw, 120px); }
.hero-meta {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px;
  color: var(--muted); padding-bottom: 14px; border-bottom: 1px solid var(--rule-strong);
}
.hero-meta span:first-child { color: var(--ink); }
.display {
  font-family: var(--serif);
  font-size: clamp(3.1rem, 10.4vw, 9.6rem);
  line-height: 0.92; letter-spacing: -0.025em;
  margin: clamp(32px, 6vw, 72px) 0 clamp(36px, 6vw, 72px);
}
.display em { color: var(--accent); }
.hero-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 24px; align-items: start; }
.hero-lede { grid-column: 1 / 7; }
.hero-lede p { font-size: clamp(18px, 1.6vw, 21px); line-height: 1.5; color: var(--ink-2); max-width: 34em; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; margin-top: 32px; }
.ledger { grid-column: 8 / 13; margin: 0; border-top: 1px solid var(--rule-strong); }
.ledger div { display: grid; grid-template-columns: 96px 1fr; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--rule); }
.ledger dt { color: var(--muted); padding-top: 3px; }
.ledger dd { margin: 0; font-size: 15px; }
.ledger dd a { border-bottom: 1px solid var(--accent); }
.ledger dd a:hover { color: var(--accent); }

/* ---------- Sections ---------- */
.section { padding-top: clamp(64px, 9vw, 128px); padding-bottom: clamp(32px, 5vw, 64px); }
.section-head {
  display: grid; grid-template-columns: repeat(12, 1fr); column-gap: 24px; row-gap: clamp(20px, 3vw, 36px); align-items: end;
  padding-top: 16px; border-top: 1px solid var(--rule-strong); margin-bottom: clamp(32px, 5vw, 56px);
}
.kicker { display: flex; gap: 10px; color: var(--ink); align-self: start; }
.kicker span { color: var(--accent); }
.section-head .kicker { grid-column: 1 / -1; }
.section-head h2 {
  grid-column: 1 / 9; font: 400 clamp(2.6rem, 6.2vw, 5.4rem)/0.95 var(--serif); letter-spacing: -0.02em;
}
.section-head h2 em { color: var(--accent); }
.section-dek {
  grid-column: 9 / 13; color: var(--ink-2); font-size: 16px; max-width: 26em;
  padding-left: 18px; border-left: 1px solid var(--accent); margin-bottom: 0.4em;
}

/* Filters */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.chip {
  height: 36px; padding: 0 14px; border: 1px solid var(--rule); border-radius: 999px;
  font-size: 14px; font-weight: 500; color: var(--ink-2); display: inline-flex; align-items: center; gap: 8px;
  transition: all .2s;
}
.chip .mono { font-size: 10px; }
.chip:hover { border-color: var(--ink); color: var(--ink); }
.chip.is-active { background: var(--ink); border-color: var(--ink); color: var(--bg); }

/* ---------- Case studies ---------- */
.case {
  display: grid; grid-template-columns: repeat(12, 1fr); gap: 24px;
  padding: clamp(36px, 5vw, 64px) 0; border-bottom: 1px solid var(--rule);
}
.case[hidden], .index-row[hidden] { display: none; }
.case-no { grid-column: 1 / 2; color: var(--muted); padding-top: 6px; }
.case-text { grid-column: 2 / 7; display: flex; flex-direction: column; gap: 20px; }
.case-fig { grid-column: 7 / 13; margin: 0; align-self: start; }
.case-kicker { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; color: var(--ink-2); }
.live { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); }
.live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: pulse 2.4s infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.case h3 { font: 400 clamp(2.3rem, 4.4vw, 3.8rem)/0.98 var(--serif); letter-spacing: -0.02em; }
.case-lede { font-size: 17px; line-height: 1.55; color: var(--ink-2); }
.case-links { display: flex; flex-wrap: wrap; gap: 12px 24px; }

.story { border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.story summary, .note summary {
  list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center;
  font: 500 12px/1 var(--mono); text-transform: uppercase; letter-spacing: 0.04em; padding: 14px 0;
}
.story summary::-webkit-details-marker, .note summary::-webkit-details-marker { display: none; }
.story summary::after, .note summary::after { content: "+"; font-size: 16px; color: var(--accent); transition: transform .25s var(--ease); }
.story[open] summary::after, .note[open] summary::after { transform: rotate(45deg); }
.story summary:hover, .note summary:hover { color: var(--accent); }
.story-body { display: grid; gap: 12px; padding-bottom: 20px; font-size: 15px; color: var(--ink-2); }
.story-body strong { color: var(--ink); font-weight: 600; }

/* Figures */
.case-fig { background: var(--surface); border: 1px solid var(--rule); }
.fig-bar { display: flex; justify-content: space-between; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--rule); color: var(--muted); font-size: 10.5px; }
.case-fig svg { display: block; width: 100%; height: auto; }
.fig-grid path { stroke: var(--rule); stroke-width: 1; stroke-dasharray: 2 4; fill: none; }
.fig-edge path { stroke: var(--ink-2); stroke-width: 1.25; fill: none; opacity: .55; }
.fig-node circle { fill: var(--surface); stroke: var(--ink); stroke-width: 1.5; }
.fig-hot { fill: var(--accent); }
.fig-hot-ring { fill: none; stroke: var(--accent); stroke-width: 1; stroke-dasharray: 3 3; transform-origin: 240px 170px; animation: spin 18s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.fig-label { font: 500 11px var(--mono); fill: var(--accent); letter-spacing: .03em; }
.fig-split path { stroke: var(--accent); stroke-width: 1; fill: none; opacity: .5; }
.fig-dot circle { fill: var(--ink-2); }
.fig-anom circle { fill: var(--accent); }
.fig-anom-ring circle { fill: none; stroke: var(--accent); stroke-width: 1.25; }

.pipeline { padding: 22px; display: grid; gap: 0; counter-reset: step; font-size: 12px; text-transform: none; letter-spacing: 0; }
.pipeline li { display: grid; grid-template-columns: 84px 1fr; gap: 12px; padding: 11px 0 11px 18px; border-left: 1px solid var(--rule); position: relative; }
.pipeline li::before { content: ""; position: absolute; left: -4px; top: 17px; width: 7px; height: 7px; background: var(--surface); border: 1px solid var(--ink); }
.pipeline li b { font-weight: 500; color: var(--ink); text-transform: uppercase; letter-spacing: .04em; font-size: 11px; }
.pipeline li span { color: var(--ink-2); }
.pipeline .q { display: block; font: italic 400 22px/1.25 var(--serif); color: var(--ink); padding-bottom: 18px; }
.pipeline .q::before { border-color: var(--accent); background: var(--accent); }
.pipeline .a::before { background: var(--accent); border-color: var(--accent); }
.pipeline .a b, .pipeline .a span { color: var(--accent); }
.runlog { padding: 22px; display: grid; gap: 2px; font-size: 13px; text-transform: none; letter-spacing: 0; }
.runlog li { display: block; padding: 8px 0 8px 22px; position: relative; color: var(--ink); border-bottom: 1px dashed var(--rule); }
.runlog li:last-child { border-bottom: 0; }
.runlog li > span { position: absolute; left: 0; color: var(--muted); }
.runlog em { font-style: normal; color: var(--muted); margin-left: 10px; }
.runlog .cmd { color: var(--ink-2); padding-bottom: 12px; }
.runlog .fail > span, .runlog .fail { color: #c2410c; }
.runlog .pass, .runlog .pass > span { color: var(--accent); font-weight: 500; }
.runlog .pass em { color: var(--accent); }
.fig-stats { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0; border-top: 1px solid var(--rule); }
.fig-stats div { padding: 14px; }
.fig-stats div + div { border-left: 1px solid var(--rule); }
.fig-stats dt { color: var(--muted); font-size: 10px; }
.fig-stats dd { margin: 4px 0 0; font: 400 32px/1 var(--serif); }

.caret { display: inline-block; width: 2px; height: 0.9em; background: var(--accent); margin-left: 4px; vertical-align: -0.1em; animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* Index (more work) */
.index { margin-top: clamp(48px, 6vw, 80px); }
.index[hidden] { display: none; }
.index-title { padding-bottom: 14px; border-bottom: 1px solid var(--rule-strong); }
.index-row {
  display: grid; grid-template-columns: repeat(12, 1fr); gap: 8px 24px; align-items: baseline;
  padding: 22px 0; border-bottom: 1px solid var(--rule);
}
.index-no { grid-column: 1 / 2; color: var(--muted); }
.index-main { grid-column: 2 / 8; }
.index-main h3 { font: 400 28px/1.1 var(--serif); letter-spacing: -0.01em; }
.index-main h3 a { transition: color .2s; }
.index-main h3 a span { font-family: var(--sans); font-size: 16px; color: var(--muted); transition: transform .25s var(--ease), color .2s; display: inline-block; }
.index-main h3 a:hover { color: var(--accent); }
.index-main h3 a:hover span { color: var(--accent); transform: translate(2px, -2px); }
.index-main > p { color: var(--ink-2); font-size: 15px; margin-top: 6px; max-width: 46em; }
.note { margin-top: 4px; }
.note summary { padding: 10px 0 4px; justify-content: flex-start; gap: 10px; color: var(--muted); }
.note p { font-size: 14px; color: var(--ink-2); padding: 6px 0 4px; max-width: 46em; }
.index-cat { grid-column: 8 / 10; color: var(--ink-2); }
.index-stack { grid-column: 10 / 13; color: var(--muted); text-transform: none; letter-spacing: 0; }

/* ---------- Workshop (inverted) ---------- */
.section-ink {
  --ink: var(--inv-fg); --ink-2: color-mix(in srgb, var(--inv-fg) 72%, var(--inv-bg)); --muted: var(--inv-muted);
  --rule: var(--inv-rule); --rule-strong: var(--inv-fg); --accent: var(--inv-accent);
  background: var(--inv-bg); color: var(--ink);
  margin-top: clamp(48px, 7vw, 96px);
  padding-bottom: clamp(64px, 8vw, 112px);
}
.bench { border-top: 1px solid var(--rule); }
.bench-item { display: grid; grid-template-columns: repeat(12, 1fr); gap: 24px; padding-top: 36px; }
.bench-main { grid-column: 1 / 7; display: flex; flex-direction: column; gap: 20px; }
.bench-side { grid-column: 8 / 13; display: flex; flex-direction: column; gap: 24px; }
.bench-top { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); }
.pill { color: var(--accent); border: 1px solid currentColor; padding: 4px 8px; border-radius: 999px; font-size: 10px; }
.bench-item h3 { font: 400 clamp(3rem, 7vw, 6rem)/0.95 var(--serif); letter-spacing: -0.025em; }
.bench-main > p { color: var(--ink-2); font-size: 17px; max-width: 34em; }
.bench-steps { border-top: 1px solid var(--rule-strong); text-transform: none; letter-spacing: 0; font-size: 13px; }
.bench-steps li { display: grid; grid-template-columns: 36px 1fr auto; gap: 8px; padding: 13px 0; border-bottom: 1px solid var(--rule); color: var(--muted); }
.bench-steps li span { color: var(--muted); }
.bench-steps em { font-style: normal; font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); border: 1px solid currentColor; border-radius: 999px; padding: 2px 8px; align-self: center; }
.bench-steps .is-now { color: var(--ink); }
.bench-steps .is-now span { color: var(--accent); }
.bench-side .link { align-self: flex-start; }
.fine { color: var(--muted); margin-top: 28px; font-size: 10.5px; }

/* ---------- Journal TOC ---------- */
.toc { border-top: 1px solid var(--rule); }
.toc a {
  display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px 24px; align-items: baseline;
  padding: 26px 0; border-bottom: 1px solid var(--rule); position: relative;
}
.toc-no { grid-column: 1 / 2; grid-row: 1 / 3; color: var(--muted); }
.toc-cat { grid-column: 2 / 5; grid-row: 1 / 3; color: var(--ink-2); padding-top: 4px; }
.toc-title { grid-column: 5 / 12; font: 400 clamp(1.6rem, 2.7vw, 2.4rem)/1.08 var(--serif); letter-spacing: -0.01em; transition: color .2s; }
.toc-dek { grid-column: 5 / 12; color: var(--ink-2); font-size: 15px; max-width: 40em; }
.toc-arrow { grid-column: 12 / 13; grid-row: 1; justify-self: end; font-size: 22px; transition: transform .3s var(--ease), color .2s; }
.toc a:hover .toc-title, .toc a:hover .toc-arrow { color: var(--accent); }
.toc a:hover .toc-arrow { transform: translateX(6px); }
.toc a::before {
  content: ""; position: absolute; left: 0; bottom: -1px; height: 1px; width: 100%; background: var(--accent);
  transform: scaleX(0); transform-origin: left; transition: transform .45s var(--ease);
}
.toc a:hover::before { transform: scaleX(1); }

/* ---------- Experience ---------- */
.job {
  display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px 24px;
  padding: 32px 0; border-bottom: 1px solid var(--rule);
}
.job:first-of-type { border-top: 0; }
.job-date { grid-column: 1 / 3; color: var(--muted); padding-top: 8px; }
.job-head { grid-column: 3 / 7; }
.job-head h3 { font: 400 clamp(2rem, 3.2vw, 2.8rem)/1 var(--serif); letter-spacing: -0.015em; }
.job-role { color: var(--accent); font-weight: 500; margin-top: 8px; }
.job-body { grid-column: 7 / 13; display: grid; gap: 14px; color: var(--ink-2); }
.job-body .tags { margin-top: 6px; }

/* ---------- About ---------- */
.about-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 24px; }
.about-copy { grid-column: 1 / 6; display: grid; gap: 18px; align-content: start; color: var(--ink-2); font-size: 17px; }
.pull { font: italic 400 clamp(1.7rem, 2.6vw, 2.2rem)/1.15 var(--serif); color: var(--ink); }
.edu { border-top: 1px solid var(--rule-strong); padding-top: 16px; margin-top: 18px; display: grid; gap: 6px; }
.edu .mono { color: var(--muted); }
.edu h3 { font: 400 28px/1.1 var(--serif); color: var(--ink); }
.edu p { font-size: 15px; }
.edu-meta { display: flex; gap: 20px; color: var(--ink) !important; margin-top: 4px; }
.toolbox { grid-column: 7 / 13; }
.toolbox .kicker { padding-bottom: 14px; border-bottom: 1px solid var(--rule-strong); }
.toolbox dl { margin: 0; }
.toolbox dl div { display: grid; grid-template-columns: 160px 1fr; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--rule); }
.toolbox dt { font-weight: 600; font-size: 14px; }
.toolbox dd { margin: 0; font-size: 14.5px; color: var(--ink-2); }

/* ---------- Contact ---------- */
.contact {
  --ink: var(--inv-fg); --ink-2: color-mix(in srgb, var(--inv-fg) 72%, var(--inv-bg)); --muted: var(--inv-muted);
  --rule: var(--inv-rule); --rule-strong: var(--inv-fg); --accent: var(--inv-accent);
  margin-top: clamp(64px, 9vw, 128px); padding: clamp(56px, 8vw, 112px) 0;
  background: var(--inv-bg); color: var(--ink);
}
.contact-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 24px; align-items: start; }
.contact-intro { grid-column: 1 / 6; display: grid; gap: 24px; }
.contact-title { font: 400 clamp(3rem, 6.6vw, 6.2rem)/0.92 var(--serif); letter-spacing: -0.025em; }
.contact-title em { color: var(--accent); }
.contact-dek { color: var(--ink-2); font-size: 17px; max-width: 28em; }
.contact-list { margin: 8px 0 0; border-top: 1px solid var(--rule-strong); }
.contact-list div { display: grid; grid-template-columns: 96px 1fr; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--rule); align-items: baseline; }
.contact-list dt { color: var(--muted); }
.contact-list dd { margin: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 18px; font-size: 15px; }
.contact-list a { border-bottom: 1px solid var(--rule); transition: color .2s, border-color .2s; overflow-wrap: anywhere; }
.contact-list a:hover { color: var(--accent); border-color: var(--accent); }
.copy-btn { font-size: 10px; color: var(--muted); border: 1px solid var(--rule); padding: 3px 8px; border-radius: 999px; transition: color .2s, border-color .2s; }
.copy-btn:hover { color: var(--accent); border-color: var(--accent); }
#copy-status { color: var(--accent); font-size: 10px; }
#copy-status:empty { display: none; }

.contact-form {
  grid-column: 7 / 13; display: grid; gap: 22px;
  padding: clamp(24px, 3vw, 40px); border: 1px solid var(--rule);
  background: color-mix(in srgb, var(--inv-fg) 3%, var(--inv-bg));
}
.form-title { display: flex; gap: 10px; padding-bottom: 14px; border-bottom: 1px solid var(--rule-strong); }
.form-title span { color: var(--accent); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.field { display: grid; gap: 6px; }
.field .mono { color: var(--muted); font-size: 10.5px; }
.field i { font-style: normal; opacity: .6; margin-left: 4px; }
.field input, .field textarea {
  width: 100%; font: 400 17px/1.4 var(--sans); color: var(--ink);
  background: transparent; border: 0; border-bottom: 1px solid var(--rule); border-radius: 0;
  padding: 8px 0 10px; transition: border-color .2s; resize: vertical;
}
.field textarea { min-height: 120px; }
.field input::placeholder, .field textarea::placeholder { color: var(--muted); opacity: .7; }
.field input:focus, .field textarea:focus { outline: none; border-bottom-color: var(--accent); }
.field:focus-within .mono { color: var(--accent); }
.field input[aria-invalid="true"], .field textarea[aria-invalid="true"] { border-bottom-color: #f2785c; }
.hp { display: none !important; }
.form-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding-top: 4px; }
.contact .btn-solid { background: var(--accent); border-color: var(--accent); color: var(--inv-bg); }
.contact .btn-solid:hover { background: var(--ink); border-color: var(--ink); color: var(--inv-bg); }
.contact .btn-solid[disabled] { opacity: .6; cursor: progress; }
.form-status { color: var(--ink-2); font-size: 11px; text-transform: none; letter-spacing: 0; }
.form-status.is-ok { color: var(--accent); }
.form-status.is-error { color: #f2785c; }
.form-status a { border-bottom: 1px solid currentColor; }

/* ---------- Footer ---------- */
.colophon { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px 24px; padding-top: 28px; padding-bottom: 36px; color: var(--muted); font-size: 10.5px; }
.colophon a:hover { color: var(--accent); }

/* ---------- Journal article ---------- */
.progress { position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 45; background: var(--accent); transform: scaleX(0); transform-origin: left; }
.post { padding-top: clamp(28px, 5vw, 56px); }
.post-meta {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px;
  color: var(--muted); padding-bottom: 14px; border-bottom: 1px solid var(--rule-strong);
}
.post-meta a { color: var(--ink); }
.post-meta a:hover { color: var(--accent); }
.post-head { display: grid; grid-template-columns: repeat(12, 1fr); gap: 24px; padding: clamp(36px, 6vw, 80px) 0 clamp(40px, 6vw, 72px); border-bottom: 1px solid var(--rule); }
.post-head .kicker { grid-column: 1 / -1; }
.post-head h1 { grid-column: 1 / 11; font: 400 clamp(2.6rem, 6.4vw, 5.8rem)/0.96 var(--serif); letter-spacing: -0.025em; }
.post-lede { grid-column: 4 / 11; font: italic 400 clamp(1.4rem, 2.2vw, 1.9rem)/1.3 var(--serif); color: var(--ink-2); }
.post-body { padding: clamp(40px, 6vw, 72px) 0; }
.post-section { display: grid; grid-template-columns: repeat(12, 1fr); gap: 12px 24px; padding: 28px 0; border-bottom: 1px solid var(--rule); }
.post-section:last-child { border-bottom: 0; }
.post-section .mono { grid-column: 1 / 2; color: var(--accent); padding-top: 6px; }
.post-section h2 { grid-column: 2 / 5; font: 400 clamp(1.6rem, 2.4vw, 2.1rem)/1.1 var(--serif); letter-spacing: -0.01em; }
.post-section p { grid-column: 6 / 12; font-size: 18px; line-height: 1.7; color: var(--ink-2); }
.post-foot { display: grid; grid-template-columns: repeat(12, 1fr); gap: 24px; padding: 28px 0 0; border-top: 1px solid var(--rule-strong); }
.post-foot .post-source { grid-column: 1 / 6; display: flex; flex-wrap: wrap; gap: 12px 24px; align-content: start; }
.post-next { grid-column: 6 / 13; display: grid; gap: 8px; padding-bottom: 8px; }
.post-next .mono { color: var(--muted); }
.post-next strong { font: 400 clamp(1.6rem, 3vw, 2.4rem)/1.08 var(--serif); transition: color .2s; }
.post-next:hover strong { color: var(--accent); }
.post-back { margin-top: clamp(48px, 6vw, 80px); }

/* ---------- Motion ---------- */
.reveal { opacity: 1; transform: none; }
.js .reveal { opacity: 0; transform: translateY(14px); transition: opacity .7s var(--ease), transform .7s var(--ease); }
.js .reveal.is-in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .js .reveal { opacity: 1; transform: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .nav a .mono { display: none; }
  .section-head h2 { grid-column: 1 / -1; }
  .section-dek { grid-column: 1 / 9; }
  .post-section h2 { grid-column: 2 / 6; }
  .post-section p { grid-column: 6 / 13; }
  .bench-main { grid-column: 1 / 8; }
  .bench-side { grid-column: 8 / 13; }
  .case-text { grid-column: 2 / 13; }
  .case-fig { grid-column: 2 / 13; max-width: 640px; }
  .index-main { grid-column: 2 / 13; }
  .index-cat { grid-column: 2 / 6; }
  .index-stack { grid-column: 6 / 13; }
  .job-head { grid-column: 3 / 13; }
  .job-body { grid-column: 3 / 13; }
  .about-copy { grid-column: 1 / 7; }
  .toolbox dl div { grid-template-columns: 1fr; gap: 4px; }
}

@media (max-width: 860px) {
  .menu-btn { display: grid; }
  .nav {
    position: absolute; top: 60px; left: 0; right: 0;
    flex-direction: column; gap: 0; padding: 8px var(--gutter) 20px;
    background: var(--bg); border-bottom: 1px solid var(--rule-strong);
    display: none;
  }
  .nav.is-open { display: flex; }
  .nav a { padding: 14px 0; font-size: 18px; border-bottom: 1px solid var(--rule); }
  .nav a .mono { display: inline; }
  .masthead-tools { margin-left: auto; }

  .hero-lede, .ledger { grid-column: 1 / -1; }
  .ledger { margin-top: 24px; }
  .section-head .kicker, .section-head h2, .section-dek { grid-column: 1 / -1; }
  .case-no { display: none; }
  .case-text, .case-fig { grid-column: 1 / -1; max-width: none; }
  .index-no { display: none; }
  .index-main, .index-cat, .index-stack { grid-column: 1 / -1; }
  .index-cat { margin-top: 6px; }
  .section-dek { grid-column: 1 / -1; }
  .bench-main, .bench-side { grid-column: 1 / -1; }
  .bench-side { margin-top: 12px; }
  .post-head h1, .post-lede { grid-column: 1 / -1; }
  .post-section .mono { grid-column: 1 / -1; padding-top: 0; }
  .post-section h2, .post-section p { grid-column: 1 / -1; }
  .post-section p { font-size: 17px; }
  .post-foot .post-source, .post-next { grid-column: 1 / -1; }
  .toc-no { display: none; }
  .toc-cat, .toc-title, .toc-dek { grid-column: 1 / 12; grid-row: auto; }
  .toc-arrow { grid-row: 2; }
  .job-date, .job-head, .job-body { grid-column: 1 / -1; padding-top: 0; }
  .about-copy, .toolbox { grid-column: 1 / -1; }
  .toolbox { margin-top: 32px; }
  .contact-intro, .contact-form { grid-column: 1 / -1; }
  .contact-form { margin-top: 24px; }
}

@media (max-width: 520px) {
  .wordmark { font-size: 21px; }
  .hero-meta { flex-direction: column; }
  .ledger div { grid-template-columns: 84px 1fr; }
  .pipeline { padding: 16px; }
  .pipeline li { grid-template-columns: 1fr; gap: 2px; }
  .runlog { padding: 16px; font-size: 12px; }
  .runlog em { display: block; margin-left: 0; }
  .fig-stats dd { font-size: 26px; }
  .fig-stats div { padding: 12px 10px; }
  .actions .btn { flex: 1 1 auto; justify-content: center; }
  .field-row { grid-template-columns: 1fr; }
  .contact-list div { grid-template-columns: 1fr; gap: 4px; }
  .form-foot .btn { width: 100%; justify-content: center; }
}

/* ---------- Certifications ---------- */
.cert-card { display: grid; grid-template-columns: repeat(12, 1fr); gap: 24px; align-items: center; }
.cert-thumb {
  grid-column: 1 / 7; display: block; padding: clamp(10px, 1.4vw, 18px);
  background: var(--surface); border: 1px solid var(--rule);
  transition: border-color .25s, transform .4s var(--ease);
}
.cert-thumb img { display: block; width: 100%; height: auto; }
.cert-thumb:hover { border-color: var(--accent); transform: translateY(-3px); }
.cert-info { grid-column: 8 / 13; display: grid; gap: 18px; align-content: center; }
.cert-issuer { color: var(--accent); }
.cert-info h3 { font: 400 clamp(2.2rem, 4vw, 3.4rem)/1 var(--serif); letter-spacing: -0.02em; }
.cert-info > p:not(.mono) { color: var(--ink-2); font-size: 16px; }
.cert-meta { margin: 0; border-top: 1px solid var(--rule-strong); }
.cert-meta div { display: grid; grid-template-columns: 110px 1fr; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.cert-meta dt { color: var(--muted); padding-top: 3px; }
.cert-meta dd { margin: 0; font-size: 15px; }
.cert-info .link { justify-self: start; }
@media (max-width: 1080px) { .nav a { padding: 8px 7px; font-size: 13.5px; } }
@media (max-width: 860px) {
  .cert-thumb, .cert-info { grid-column: 1 / -1; }
  .nav a { padding: 14px 0; font-size: 18px; }
}
