/* ==========================================================================
   KALRISH LABS — Design System
   A single stylesheet. No frameworks, no build step.

   Contents
   01  Reset & base
   02  Design tokens
   03  Page rails (blueprint hairlines)
   04  Typography primitives
   05  Layout
   06  Header & navigation
   07  Search overlay
   08  Hero
   09  Section headers
   10  Index rows (editorial lists)
   11  Panels, cards, tags, status dots
   12  Filters
   13  Article / long-form prose
   14  Table of contents & reading progress
   15  Footer
   16  Motion & utilities
   17  Responsive
   18  Print & reduced motion
   ========================================================================== */

/* --------------------------------------------------------------------------
   01  Reset & base
   -------------------------------------------------------------------------- */

*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 6.5rem;
}

body,
h1, h2, h3, h4, h5, h6,
p, figure, blockquote, dl, dd, ol, ul {
  margin: 0;
  padding: 0;
}

ol, ul { list-style: none; }

img, svg, video {
  display: block;
  max-width: 100%;
  height: auto;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: 0;
  cursor: pointer;
}

a { color: inherit; }

:target { scroll-margin-top: 7rem; }

/* --------------------------------------------------------------------------
   02  Design tokens
   -------------------------------------------------------------------------- */

:root {
  color-scheme: light;

  /* Surfaces — warm paper */
  --paper:        #FBFAF7;
  --paper-sunk:   #F5F3EE;
  --paper-raised: #FFFFFE;

  /* Ink */
  --ink:          #16161C;
  --ink-2:        #43434E;
  --ink-3:        #7C7C88;
  --ink-4:        #A5A5AE;

  /* Rules — hairlines */
  --rule:         #E3DFD6;
  --rule-soft:    #EDEAE2;
  --rule-strong:  #CFCABE;

  /* Signal colours — used sparingly, mostly as 6px dots */
  --green:        #2C6A4E;
  --blue:         #2B4E7C;
  --oxide:        #A4432D;
  --amber:        #8A6318;

  --accent:       var(--green);
  --accent-wash:  #EDF2EE;

  /* Type */
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo,
          Consolas, "Liberation Mono", monospace;

  --t-hero: clamp(2.35rem, 5.6vw, 4.5rem);
  --t-h1:   clamp(2.05rem, 4.4vw, 3.25rem);
  --t-h2:   clamp(1.4rem, 2.3vw, 1.85rem);
  --t-h3:   clamp(1.1rem, 1.5vw, 1.3rem);
  --t-lead: clamp(1.0625rem, 1.35vw, 1.1875rem);
  --t-body: 1rem;
  --t-sm:   0.875rem;
  --t-meta: 0.6875rem;

  /* Space */
  --s-1:  0.25rem;
  --s-2:  0.5rem;
  --s-3:  0.75rem;
  --s-4:  1rem;
  --s-5:  1.5rem;
  --s-6:  2rem;
  --s-7:  3rem;
  --s-8:  4rem;
  --s-9:  6rem;
  --s-10: 8rem;

  /* Layout */
  --wrap: 1180px;
  --gutter: clamp(1.25rem, 4.5vw, 3.5rem);
  --measure: 68ch;
  --header-h: 3.75rem;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --dur: 340ms;
}

/* --------------------------------------------------------------------------
   03  Page rails — fine vertical hairlines, like a blueprint sheet
   -------------------------------------------------------------------------- */

.rails {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

/* The two hairlines are painted as backgrounds inset by exactly the gutter,
   so they land on the text column edges rather than the container edges. */
.rails__inner {
  height: 100%;
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  background-image:
    linear-gradient(var(--rule-soft), var(--rule-soft)),
    linear-gradient(var(--rule-soft), var(--rule-soft));
  background-size: 1px 100%, 1px 100%;
  background-position: left var(--gutter) top, right var(--gutter) top;
  background-repeat: no-repeat;
  background-origin: border-box;
}

@media (max-width: 860px) {
  .rails { display: none; }
}

/* --------------------------------------------------------------------------
   04  Typography primitives
   -------------------------------------------------------------------------- */

body {
  font-family: var(--sans);
  font-size: var(--t-body);
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  font-synthesis-weight: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "kern" 1, "liga" 1, "cv05" 1, "ss03" 1;
  overflow-x: hidden;
}

/* Monospaced technical metadata — the second voice of the site */
.mono {
  font-family: var(--mono);
  font-size: var(--t-meta);
  font-weight: 400;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  line-height: 1.4;
  color: var(--ink-3);
  font-feature-settings: "kern" 1;
}

.mono--ink { color: var(--ink); }
.mono--accent { color: var(--accent); }
.mono--lc { text-transform: none; letter-spacing: 0.02em; }

h1, h2, h3, h4 {
  font-weight: 500;
  letter-spacing: -0.022em;
  line-height: 1.12;
  text-wrap: balance;
}

.lead {
  font-size: var(--t-lead);
  line-height: 1.62;
  color: var(--ink-2);
  max-width: 62ch;
  text-wrap: pretty;
}

.dim { color: var(--ink-3); }

/* Inline link with a hairline underline that thickens on hover */
.link {
  text-decoration: none;
  background-image: linear-gradient(currentColor, currentColor);
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 100% 1px;
  padding-bottom: 1px;
  transition: background-size 180ms var(--ease), color 180ms var(--ease);
}
.link:hover { color: var(--accent); background-size: 100% 2px; }

/* Focus — visible, never ugly */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 1px;
}

.skip {
  position: absolute;
  left: var(--s-4);
  top: -100px;
  z-index: 200;
  background: var(--ink);
  color: var(--paper);
  padding: var(--s-3) var(--s-5);
  font-family: var(--mono);
  font-size: var(--t-meta);
  letter-spacing: 0.11em;
  text-transform: uppercase;
  text-decoration: none;
  transition: top 160ms var(--ease);
}
.skip:focus { top: var(--s-4); }

.vh {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* --------------------------------------------------------------------------
   05  Layout
   -------------------------------------------------------------------------- */

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--gutter);
  position: relative;
  z-index: 1;
}

main { display: block; }

.section { padding-block: clamp(3.5rem, 8vw, var(--s-9)); }
.section--tight { padding-block: clamp(2.5rem, 5vw, 3.5rem); }
.section--ruled { border-top: 1px solid var(--rule); }

.sunk { background: var(--paper-sunk); }

/* --------------------------------------------------------------------------
   06  Header & navigation
   -------------------------------------------------------------------------- */

.header {
  position: sticky;
  top: 0;
  z-index: 60;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--rule);
}

.header__bar {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-5);
}

.wordmark {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4em;
  text-decoration: none;
  font-family: var(--mono);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
  white-space: nowrap;
}

.wordmark__mark {
  width: 9px;
  height: 9px;
  border: 1.5px solid var(--accent);
  border-radius: 50%;
  position: relative;
  transform: translateY(-1px);
  flex: none;
}
.wordmark__mark::after {
  content: "";
  position: absolute;
  inset: 2px;
  background: var(--accent);
  border-radius: 50%;
  opacity: 0;
  transition: opacity 220ms var(--ease);
}
.wordmark:hover .wordmark__mark::after { opacity: 1; }

.nav { display: flex; align-items: center; gap: clamp(1rem, 2.2vw, 1.75rem); }

.header__actions { display: flex; align-items: center; gap: var(--s-1); flex: none; }

.nav__link {
  font-family: var(--mono);
  font-size: var(--t-meta);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink-3);
  padding-block: 0.35rem;
  position: relative;
  transition: color 180ms var(--ease);
  white-space: nowrap;
}
.nav__link::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 260ms var(--ease);
}
.nav__link:hover { color: var(--ink); }
.nav__link:hover::after { transform: scaleX(1); }
.nav__link[aria-current="page"] { color: var(--ink); }
.nav__link[aria-current="page"]::after { transform: scaleX(1); background: var(--accent); }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  color: var(--ink-3);
  border: 1px solid transparent;
  transition: color 180ms var(--ease), border-color 180ms var(--ease);
}
.icon-btn:hover { color: var(--ink); border-color: var(--rule); }
.icon-btn svg { width: 15px; height: 15px; }

.nav-toggle { display: none; }

/* Mobile drawer */
.mobile-nav {
  display: none;
  border-top: 1px solid var(--rule);
  background: var(--paper);
}
.mobile-nav[data-open="true"] { display: block; }

.mobile-nav__list { padding-block: var(--s-2) var(--s-5); }

.mobile-nav__link {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-4) 0;
  border-bottom: 1px solid var(--rule-soft);
  text-decoration: none;
  font-size: 1.375rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.mobile-nav__link span { font-family: var(--mono); font-size: var(--t-meta); letter-spacing: 0.11em; color: var(--ink-4); }
.mobile-nav__link[aria-current="page"] span { color: var(--accent); }

/* --------------------------------------------------------------------------
   07  Search overlay
   -------------------------------------------------------------------------- */

.search {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: none;
  padding: clamp(1rem, 9vh, 6rem) var(--gutter) var(--s-6);
  background: color-mix(in srgb, var(--paper) 72%, transparent);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.search[data-open="true"] { display: block; }

.search__panel {
  max-width: 640px;
  margin-inline: auto;
  background: var(--paper-raised);
  border: 1px solid var(--rule-strong);
  box-shadow: 0 24px 60px -28px rgba(22, 22, 28, 0.28);
  display: flex;
  flex-direction: column;
  max-height: min(70vh, 560px);
}

.search__field {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--rule);
  flex: none;
}
.search__field svg { width: 15px; height: 15px; color: var(--ink-4); flex: none; }

.search__input {
  flex: 1;
  border: 0;
  background: none;
  font-size: 1rem;
  letter-spacing: -0.01em;
  padding: 0;
  min-width: 0;
}
.search__input::placeholder { color: var(--ink-4); }
.search__input:focus { outline: none; }

.search__hint {
  font-family: var(--mono);
  font-size: 0.625rem;
  letter-spacing: 0.1em;
  color: var(--ink-4);
  border: 1px solid var(--rule);
  padding: 2px 6px;
  flex: none;
}

.search__results { overflow-y: auto; overscroll-behavior: contain; }

.search__item {
  display: block;
  padding: var(--s-3) var(--s-5);
  text-decoration: none;
  border-bottom: 1px solid var(--rule-soft);
}
.search__item:last-child { border-bottom: 0; }
.search__item[data-active="true"],
.search__item:hover { background: var(--paper-sunk); }
.search__item strong { display: block; font-weight: 500; font-size: 0.9375rem; letter-spacing: -0.012em; }
.search__item .mono { margin-bottom: 2px; display: block; }

.search__empty {
  padding: var(--s-6) var(--s-5);
  color: var(--ink-3);
  font-size: var(--t-sm);
}

/* --------------------------------------------------------------------------
   08  Hero
   -------------------------------------------------------------------------- */

.hero {
  position: relative;
  padding-block: clamp(3rem, 9vw, 6.5rem) clamp(2.5rem, 5vw, 4rem);
  overflow: hidden;
}

/* Fine measurement grid, fading out — the lab-notebook substrate */
.hero__grid {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, var(--rule-soft) 1px, transparent 1px),
    linear-gradient(to bottom, var(--rule-soft) 1px, transparent 1px);
  background-size: 76px 76px;
  background-position: center top;
  -webkit-mask-image: radial-gradient(120% 90% at 50% 8%, #000 0%, transparent 72%);
  mask-image: radial-gradient(120% 90% at 50% 8%, #000 0%, transparent 72%);
  opacity: 0.85;
}

.hero__kicker {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin-bottom: clamp(1.5rem, 4vw, 2.75rem);
}

.hero__title {
  font-size: var(--t-hero);
  font-weight: 500;
  letter-spacing: -0.038em;
  line-height: 1.06;
  /* The <br> controls the break, so the measure only needs to stop the
     longest line from running past the column on very wide screens. */
  max-width: 26ch;
  text-wrap: initial;
  margin-bottom: var(--s-5);
}
.hero__title em {
  font-style: normal;
  color: var(--ink-3);
}

.hero__body { max-width: 56ch; }

/* Live status pip */
.pip {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  flex: none;
  position: relative;
}
.pip::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 1px solid var(--green);
  opacity: 0.45;
  animation: pulse 2.8s var(--ease) infinite;
}
@keyframes pulse {
  0%   { transform: scale(0.7); opacity: 0.5; }
  70%  { transform: scale(1.5); opacity: 0; }
  100% { transform: scale(1.5); opacity: 0; }
}

/* Instrument readout strip beneath the hero */
.readout {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--rule);
  margin-top: clamp(2.5rem, 6vw, 4.5rem);
}
.readout__cell {
  padding: var(--s-4) var(--s-4) var(--s-4) 0;
  border-right: 1px solid var(--rule-soft);
}
.readout__cell:last-child { border-right: 0; }
.readout__cell:not(:first-child) { padding-left: var(--s-4); }
.readout__k { display: block; color: var(--ink-4); margin-bottom: var(--s-2); }
.readout__v {
  font-family: var(--mono);
  font-size: 0.8125rem;
  letter-spacing: 0.04em;
  color: var(--ink);
  text-transform: uppercase;
}

/* --------------------------------------------------------------------------
   09  Section headers
   -------------------------------------------------------------------------- */

.sec-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-5);
  padding-bottom: var(--s-4);
  border-bottom: 1px solid var(--ink);
  margin-bottom: var(--s-2);
  flex-wrap: wrap;
}
.sec-head__title {
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink);
}
.sec-head__aside { display: flex; align-items: baseline; gap: var(--s-5); flex-wrap: wrap; }

.more {
  font-family: var(--mono);
  font-size: var(--t-meta);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink-3);
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  transition: color 180ms var(--ease), gap 220ms var(--ease);
}
.more:hover { color: var(--accent); gap: 0.85em; }

/* Page title block for interior pages */
.page-head { padding-block: clamp(2.75rem, 7vw, 5rem) clamp(2rem, 4vw, 3rem); }
.page-head__title {
  font-size: var(--t-h1);
  font-weight: 500;
  letter-spacing: -0.032em;
  margin-block: var(--s-4) var(--s-5);
  max-width: 20ch;
}

/* --------------------------------------------------------------------------
   10  Index rows — the primary editorial list component
   -------------------------------------------------------------------------- */

/* The closing hairline lives on the last visible row so it bleeds with it. */
.index > .row:last-of-type { border-bottom: 1px solid var(--rule); }

.row {
  display: grid;
  grid-template-columns: 3.25rem minmax(0, 1fr) 11rem;
  gap: var(--s-5);
  align-items: start;
  /* No inline padding or bleed: the rules, the text and the hover wash all
     land exactly on the page rails. */
  padding-block: clamp(1.25rem, 2.5vw, 1.85rem);
  border-top: 1px solid var(--rule);
  text-decoration: none;
  color: inherit;
  position: relative;
  transition: background-color 240ms var(--ease);
}
.row:hover { background-color: var(--paper-sunk); }

.row__idx {
  font-family: var(--mono);
  font-size: var(--t-meta);
  letter-spacing: 0.08em;
  color: var(--ink-4);
  padding-top: 0.35rem;
  transition: color 240ms var(--ease);
  font-variant-numeric: tabular-nums;
}
.row:hover .row__idx { color: var(--accent); }

.row__kicker {
  display: block;
  margin-bottom: var(--s-3);
  color: var(--ink-3);
}

.row__title {
  font-size: var(--t-h3);
  font-weight: 500;
  letter-spacing: -0.021em;
  line-height: 1.28;
  margin-bottom: var(--s-3);
  max-width: 34ch;
  transition: color 200ms var(--ease);
  text-wrap: balance;
}
.row:hover .row__title { color: var(--accent); }

.row__desc {
  font-size: var(--t-sm);
  line-height: 1.62;
  color: var(--ink-2);
  max-width: 56ch;
  text-wrap: pretty;
}

.row__meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--s-2);
  padding-top: 0.3rem;
  text-align: right;
}

.row__tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin-top: var(--s-4);
}

/* Status chip with coloured pip */
.status {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  font-family: var(--mono);
  font-size: var(--t-meta);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-2);
  white-space: nowrap;
}
.status::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--ink-4);
  flex: none;
}
.status[data-status="live"]::before,
.status[data-status="ongoing"]::before   { background: var(--green); }
.status[data-status="building"]::before  { background: var(--oxide); }
.status[data-status="experiment"]::before,
.status[data-status="research"]::before  { background: var(--blue); }
.status[data-status="prototype"]::before { background: var(--amber); }
.status[data-status="archived"]::before  { background: var(--ink-4); }
.status[data-status="archived"]           { color: var(--ink-4); }

/* --------------------------------------------------------------------------
   11  Panels, cards, tags
   -------------------------------------------------------------------------- */

.tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.625rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-3);
  border: 1px solid var(--rule);
  padding: 0.2rem 0.45rem;
  background: var(--paper-raised);
  white-space: nowrap;
}

.panel {
  border: 1px solid var(--rule);
  background: var(--paper-raised);
}

/* "Currently investigating" — numbered register */
.register { border-top: 1px solid var(--rule); }
.register__item {
  display: grid;
  grid-template-columns: 3.25rem minmax(0, 1fr) auto;
  gap: var(--s-5);
  align-items: baseline;
  padding: var(--s-4) 0;
  border-bottom: 1px solid var(--rule-soft);
  transition: padding-left 300ms var(--ease);
}
.register__item:hover { padding-left: var(--s-3); }
.register__label {
  font-size: clamp(1.05rem, 1.9vw, 1.35rem);
  font-weight: 500;
  letter-spacing: -0.022em;
}
.register__note { font-size: var(--t-sm); color: var(--ink-3); }

/* Two-column editorial split */
.split {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: start;
}

.stack > * + * { margin-top: var(--s-4); }
.stack-lg > * + * { margin-top: var(--s-6); }

/* Definition-style metadata block */
.meta-list { border-top: 1px solid var(--rule); }
.meta-list__row {
  display: grid;
  grid-template-columns: 8.5rem minmax(0, 1fr);
  gap: var(--s-4);
  padding: var(--s-3) 0;
  border-bottom: 1px solid var(--rule-soft);
  align-items: baseline;
}
.meta-list__v { font-size: var(--t-sm); color: var(--ink); }
.meta-list__v a { color: var(--accent); }

/* --------------------------------------------------------------------------
   12  Filters
   -------------------------------------------------------------------------- */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  padding-block: var(--s-5);
  border-top: 1px solid var(--rule);
}

.chip {
  font-family: var(--mono);
  font-size: var(--t-meta);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  border: 1px solid var(--rule);
  background: transparent;
  padding: 0.4rem 0.7rem;
  transition: color 180ms var(--ease), border-color 180ms var(--ease), background-color 180ms var(--ease);
}
.chip:hover { color: var(--ink); border-color: var(--rule-strong); }
.chip[aria-pressed="true"] {
  color: var(--paper);
  background: var(--ink);
  border-color: var(--ink);
}

.filter-count {
  font-family: var(--mono);
  font-size: var(--t-meta);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-4);
  padding-block: var(--s-4);
}

[hidden] { display: none !important; }

/* --------------------------------------------------------------------------
   13  Article / long-form prose
   -------------------------------------------------------------------------- */

.article-head {
  padding-block: clamp(2.5rem, 6vw, 4.5rem) clamp(1.75rem, 3.5vw, 2.5rem);
  border-bottom: 1px solid var(--rule);
}

.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55em;
  margin-bottom: var(--s-5);
}
.crumbs a { text-decoration: none; color: var(--ink-3); }
.crumbs a:hover { color: var(--accent); }
.crumbs__sep { color: var(--ink-4); }

.article-head__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2) var(--s-4);
  margin-bottom: var(--s-5);
  align-items: center;
}

.article-head__title {
  font-size: var(--t-h1);
  font-weight: 500;
  letter-spacing: -0.032em;
  line-height: 1.08;
  max-width: 22ch;
  margin-bottom: var(--s-5);
}

.abstract {
  font-size: var(--t-lead);
  line-height: 1.62;
  color: var(--ink-2);
  max-width: var(--measure);
  text-wrap: pretty;
}

/* Article body grid: prose column + sticky sidebar */
.article-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 16rem;
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: start;
  padding-block: clamp(2.5rem, 5vw, 3.5rem) var(--s-9);
}

.prose {
  max-width: var(--measure);
  font-size: 1.0625rem;
  line-height: 1.72;
  color: var(--ink);
}
.prose > * + * { margin-top: 1.35em; }

.prose h2 {
  font-size: var(--t-h2);
  font-weight: 500;
  letter-spacing: -0.026em;
  margin-top: 2.6em;
  padding-top: 1.1em;
  border-top: 1px solid var(--rule);
  scroll-margin-top: 7rem;
}
.prose h2:first-child { margin-top: 0; border-top: 0; padding-top: 0; }

.prose h3 {
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.012em;
  margin-top: 2em;
  scroll-margin-top: 7rem;
}

.prose p { text-wrap: pretty; }

.prose a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent);
  transition: text-decoration-color 180ms var(--ease);
}
.prose a:hover { text-decoration-color: currentColor; }

.prose strong { font-weight: 600; }

.prose ul, .prose ol {
  padding-left: 1.15em;
  display: grid;
  gap: 0.55em;
}
.prose ul li { list-style: none; position: relative; }
.prose ul li::before {
  content: "";
  position: absolute;
  left: -1em;
  top: 0.72em;
  width: 5px; height: 1px;
  background: var(--ink-4);
}
.prose ol { list-style: decimal; }
.prose ol li { list-style: decimal; }
.prose ol li::marker {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--ink-4);
}

.prose blockquote {
  border-left: 2px solid var(--accent);
  padding: 0.1em 0 0.1em 1.35em;
  color: var(--ink-2);
  font-size: 1.0625rem;
  line-height: 1.65;
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin-block: 2.4em;
}

/* Inline code + blocks */
.prose code {
  font-family: var(--mono);
  font-size: 0.8125em;
  letter-spacing: 0;
  background: var(--paper-sunk);
  border: 1px solid var(--rule-soft);
  padding: 0.1em 0.34em;
  white-space: nowrap;
}

.code {
  position: relative;
  border: 1px solid var(--rule);
  background: var(--paper-raised);
  margin-top: 1.9em;
}
.code__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: 0.55rem var(--s-4);
  border-bottom: 1px solid var(--rule-soft);
  background: var(--paper-sunk);
}
.code pre {
  margin: 0;
  padding: var(--s-4);
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.8125rem;
  line-height: 1.68;
  letter-spacing: 0;
  tab-size: 2;
}
.code pre code {
  background: none;
  border: 0;
  padding: 0;
  font-size: inherit;
  white-space: pre;
}
.copy {
  font-family: var(--mono);
  font-size: 0.625rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  transition: color 160ms var(--ease);
}
.copy:hover { color: var(--accent); }

/* Figures */
.prose figure {
  margin-top: 2.2em;
  border: 1px solid var(--rule);
  background: var(--paper-raised);
}
.prose figure > svg,
.prose figure > img { width: 100%; display: block; }
.prose figcaption {
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
  line-height: 1.55;
  color: var(--ink-3);
  padding: var(--s-3) var(--s-4);
  border-top: 1px solid var(--rule-soft);
  text-transform: none;
}
.prose figcaption b {
  font-weight: 500;
  color: var(--ink-2);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  margin-right: 0.5em;
}

/* Mathematical notation — Unicode + type styling, no library */
.math {
  display: block;
  font-family: var(--mono);
  font-size: 0.9375rem;
  letter-spacing: 0;
  text-align: center;
  padding: 1.4em var(--s-4);
  margin-top: 1.9em;
  border-block: 1px solid var(--rule-soft);
  color: var(--ink);
  overflow-x: auto;
  line-height: 1.9;
}
.math i { font-style: italic; letter-spacing: 0.01em; }
.math .num { color: var(--ink-3); }
.math__tag { float: right; color: var(--ink-4); font-size: 0.75rem; }

/* Callout */
.note-box {
  border: 1px solid var(--rule);
  border-left: 2px solid var(--accent);
  background: var(--paper-raised);
  padding: var(--s-4) var(--s-5);
  margin-top: 1.9em;
  font-size: var(--t-sm);
  line-height: 1.65;
  color: var(--ink-2);
}
.note-box > .mono { display: block; margin-bottom: var(--s-2); color: var(--accent); }

/* Data tables */
.table-wrap { overflow-x: auto; margin-top: 1.9em; border: 1px solid var(--rule); }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--t-sm);
  background: var(--paper-raised);
}
th, td {
  text-align: left;
  padding: 0.7rem var(--s-4);
  border-bottom: 1px solid var(--rule-soft);
  vertical-align: top;
  white-space: nowrap;
}
th {
  font-family: var(--mono);
  font-size: var(--t-meta);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 400;
  background: var(--paper-sunk);
  border-bottom-color: var(--rule);
}
tbody tr:last-child td { border-bottom: 0; }
td.num { font-family: var(--mono); font-size: 0.8125rem; font-variant-numeric: tabular-nums; }
td.wrap-cell { white-space: normal; min-width: 16rem; }

/* References */
.refs { counter-reset: ref; }
.refs li {
  counter-increment: ref;
  position: relative;
  padding-left: 2.35rem;
  font-size: var(--t-sm);
  line-height: 1.6;
  color: var(--ink-2);
  padding-block: 0.55rem;
  border-bottom: 1px solid var(--rule-soft);
}
.refs li::before {
  content: "[" counter(ref) "]";
  position: absolute;
  left: 0;
  top: 0.62rem;
  font-family: var(--mono);
  font-size: var(--t-meta);
  color: var(--ink-4);
}
.refs li::marker { content: none; }

/* Superscript citation link */
.cite {
  font-family: var(--mono);
  font-size: 0.625rem;
  vertical-align: super;
  line-height: 0;
  text-decoration: none;
  color: var(--accent);
  padding-inline: 0.1em;
}

/* --------------------------------------------------------------------------
   14  Table of contents & reading progress
   -------------------------------------------------------------------------- */

.aside { position: sticky; top: calc(var(--header-h) + 2rem); }

/* In the narrow sidebar the label/value pair stacks instead of sitting in
   two columns, which would leave the value about ninety pixels wide. */
.aside .meta-list__row {
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-1);
  padding-block: var(--s-3);
}
.aside .meta-list__v { font-size: 0.8125rem; line-height: 1.5; }

.toc__title {
  font-family: var(--mono);
  font-size: var(--t-meta);
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-4);
  padding-bottom: var(--s-3);
  border-bottom: 1px solid var(--rule);
  margin-bottom: var(--s-3);
}
.toc__list { display: grid; gap: 0.1rem; }
.toc__link {
  display: block;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--ink-3);
  text-decoration: none;
  padding: 0.35rem 0 0.35rem 0.7rem;
  border-left: 1px solid var(--rule);
  transition: color 180ms var(--ease), border-color 180ms var(--ease);
}
.toc__link:hover { color: var(--ink); }
.toc__link[data-active="true"] {
  color: var(--ink);
  border-left-color: var(--accent);
}

.progress {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 100%;
  transform: scaleX(0);
  transform-origin: left;
  background: var(--accent);
  z-index: 80;
  will-change: transform;
}

/* --------------------------------------------------------------------------
   15  Footer
   -------------------------------------------------------------------------- */

.footer {
  border-top: 1px solid var(--ink);
  padding-block: clamp(3rem, 6vw, 4.5rem) var(--s-6);
  margin-top: var(--s-8);
}

.footer__top {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(2rem, 5vw, 4rem);
  padding-bottom: clamp(2.5rem, 5vw, 3.5rem);
}

.footer__mark {
  font-family: var(--mono);
  font-size: clamp(1.05rem, 2.6vw, 1.5rem);
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink);
  line-height: 1.2;
  margin-bottom: var(--s-3);
}

.footer__col-title {
  font-family: var(--mono);
  font-size: var(--t-meta);
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-4);
  padding-bottom: var(--s-3);
  border-bottom: 1px solid var(--rule);
  margin-bottom: var(--s-3);
}

.footer__link {
  display: block;
  padding: 0.3rem 0;
  font-size: var(--t-sm);
  color: var(--ink-2);
  text-decoration: none;
  transition: color 180ms var(--ease), transform 220ms var(--ease);
}
.footer__link:hover { color: var(--accent); transform: translateX(3px); }

.footer__bottom {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--s-4);
  padding-top: var(--s-5);
  border-top: 1px solid var(--rule);
}

/* --------------------------------------------------------------------------
   16  Motion & utilities
   -------------------------------------------------------------------------- */

/* Reveal on scroll — opt-in, tiny, and skipped entirely if JS is off */
.js .reveal {
  opacity: 0;
  transform: translateY(12px);
}
.js .reveal.is-in {
  opacity: 1;
  transform: none;
  transition: opacity 700ms var(--ease), transform 700ms var(--ease);
}

.hr { border: 0; border-top: 1px solid var(--rule); }
.mt-0 { margin-top: 0; }
.center { text-align: center; }

/* Empty archive state — an honest placeholder, not filler content */
.empty {
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--rule);
  padding-block: clamp(3rem, 9vw, 6rem);
  display: grid;
  gap: var(--s-4);
  /* Faint graph paper, so an empty section still reads as part of the lab. */
  background-image:
    linear-gradient(to right, var(--rule-soft) 1px, transparent 1px),
    linear-gradient(to bottom, var(--rule-soft) 1px, transparent 1px);
  background-size: 38px 38px;
}
.empty p {
  font-size: var(--t-lead);
  line-height: 1.6;
  color: var(--ink-2);
  max-width: 46ch;
  text-wrap: pretty;
}

/* Big call-to-read block at the foot of listing pages */
.endnote {
  border: 1px solid var(--rule);
  background: var(--paper-raised);
  padding: clamp(1.75rem, 4vw, 2.75rem);
  display: grid;
  gap: var(--s-4);
}
.endnote__title {
  font-size: var(--t-h2);
  font-weight: 500;
  letter-spacing: -0.026em;
  max-width: 26ch;
}

/* Related work grid */
.related {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
  border-top: 1px solid var(--rule);
}
.related__item {
  padding: var(--s-5) var(--s-5) var(--s-5) 0;
  border-right: 1px solid var(--rule-soft);
  text-decoration: none;
  display: grid;
  gap: var(--s-3);
  align-content: start;
  transition: background-color 240ms var(--ease);
}
.related__item:last-child { border-right: 0; }
.related__item:hover { background: var(--paper-sunk); }
.related__item h3 {
  font-size: 0.9375rem;
  font-weight: 500;
  letter-spacing: -0.014em;
  line-height: 1.35;
}
.related__item:hover h3 { color: var(--accent); }

/* Lab notes — compact dated entries */
.note {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  gap: var(--s-5);
  padding: clamp(1.25rem, 2.5vw, 1.75rem) 0;
  border-top: 1px solid var(--rule);
  align-items: start;
}
.note__date { padding-top: 0.3rem; font-variant-numeric: tabular-nums; }
.note__title {
  font-size: 1.0625rem;
  font-weight: 500;
  letter-spacing: -0.018em;
  line-height: 1.35;
  margin-bottom: var(--s-3);
  max-width: 40ch;
}
.note__body {
  font-size: var(--t-sm);
  line-height: 1.68;
  color: var(--ink-2);
  max-width: 62ch;
}
.note__body > * + * { margin-top: 0.85em; }
.note__body code {
  font-family: var(--mono);
  font-size: 0.78em;
  background: var(--paper-sunk);
  border: 1px solid var(--rule-soft);
  padding: 0.08em 0.3em;
}

/* --------------------------------------------------------------------------
   17  Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 1040px) {
  .article-body { grid-template-columns: minmax(0, 1fr); }
  .aside { position: static; order: -1; }
  .toc { border: 1px solid var(--rule); padding: var(--s-4) var(--s-5); background: var(--paper-raised); }
  .toc__title { border-bottom: 0; padding-bottom: var(--s-2); margin-bottom: var(--s-2); }
  .toc__list { grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); display: grid; }
}

@media (max-width: 860px) {
  :root { --header-h: 3.25rem; }

  .nav { display: none; }
  .nav-toggle { display: inline-grid; }

  .split { grid-template-columns: minmax(0, 1fr); gap: var(--s-6); }

  .footer__top { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .footer__brand { grid-column: 1 / -1; }

  .readout { grid-template-columns: repeat(2, 1fr); }
  .readout__cell { border-bottom: 1px solid var(--rule-soft); }
  .readout__cell:nth-child(2n) { border-right: 0; padding-left: var(--s-4); }
  .readout__cell:nth-child(2n+1) { padding-left: 0; }
  .readout__cell:nth-last-child(-n+2) { border-bottom: 0; }

  .related { grid-template-columns: minmax(0, 1fr); }
  .related__item { border-right: 0; border-bottom: 1px solid var(--rule-soft); padding-right: 0; }
  .related__item:last-child { border-bottom: 0; }
}

@media (max-width: 720px) {
  /* Rows collapse into clean vertical entries */
  .row {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }
  /* Stacked: the index number reads as a marker above the entry. */
  .row__idx { padding-top: 0; margin-bottom: var(--s-2); }
  .row__title { margin-top: var(--s-3); max-width: none; }
  .row__desc { max-width: none; }
  .row__meta {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: var(--s-4);
    padding-top: var(--s-4);
    text-align: left;
    flex-wrap: wrap;
  }

  .register__item { grid-template-columns: 2.5rem minmax(0, 1fr); gap: var(--s-4); }
  .register__note { grid-column: 2; }

  .note { grid-template-columns: minmax(0, 1fr); gap: var(--s-3); }
  .note__date { padding-top: 0; }

  .meta-list__row { grid-template-columns: minmax(0, 1fr); gap: var(--s-1); }

  .sec-head { align-items: flex-start; }

  th, td { padding: 0.6rem var(--s-3); }

  .prose { font-size: 1.03125rem; }
}

@media (max-width: 460px) {
  .footer__top { grid-template-columns: minmax(0, 1fr); }
  .hero__title { letter-spacing: -0.03em; }
}

/* --------------------------------------------------------------------------
   18  Print & reduced motion
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .js .reveal { opacity: 1; transform: none; }
}

@media print {
  .rails, .header, .footer, .aside, .progress, .search, .filters { display: none !important; }
  body { background: #fff; color: #000; }
  .article-body { grid-template-columns: 1fr; padding-block: 0; }
  .prose { max-width: none; font-size: 11pt; }
  a { text-decoration: underline; }
}
