@layer reset, base, chrome, components, work, utilities;

/* Cross-document view transitions: the name mark stays put while the rest
   crosses over, so moving through the site reads as one instrument. */
@view-transition { navigation: auto; }
@media (prefers-reduced-motion: no-preference) {
  ::view-transition-old(root), ::view-transition-new(root) {
    animation-duration: var(--d-page);
    animation-timing-function: var(--ease-out);
  }
}
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}

/* ══ reset ══════════════════════════════════════════════════════════ */
@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  * { margin: 0; }
  html { -webkit-text-size-adjust: 100%; }
  body { min-height: 100dvh; -webkit-font-smoothing: antialiased; }
  img, svg, video, canvas { display: block; max-width: 100%; }
  img, video { height: auto; }
  input, button, textarea, select { font: inherit; color: inherit; }
  button { background: none; border: 0; padding: 0; cursor: pointer; }
  p, h1, h2, h3, h4, h5, h6 { overflow-wrap: break-word; }
  ul, ol { list-style: none; padding: 0; }
  table { border-collapse: collapse; width: 100%; }
  /* `* { margin: 0 }` above would also strip the browser's `margin: auto`
     that centres a modal dialog, pinning it to the top-left corner. */
  dialog { color: inherit; margin: auto; }
  [hidden] { display: none !important; }
}

/* ══ base ═══════════════════════════════════════════════════════════ */
@layer base {
  html { scroll-behavior: smooth; }
  @media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

  body {
    background: var(--ground);
    color: var(--ink);
    font-family: var(--ui);
    font-size: var(--t-body);
    line-height: var(--lh-body);
    font-variant-numeric: tabular-nums;
  }

  h1, h2, h3, h4 { font-weight: 600; line-height: var(--lh-snug);
    letter-spacing: -0.022em; text-wrap: balance; }
  p, figcaption, .work-line, .proof-row span, .card-line, .room-line, .row .sub { text-wrap: pretty; }

  a { color: var(--accent); text-decoration-line: underline;
      text-decoration-thickness: 1px; text-underline-offset: 3px;
      text-decoration-color: color-mix(in srgb, var(--accent) 34%, transparent);
      transition: text-decoration-color var(--d-hover) ease, color var(--d-hover) ease; }
  @media (hover: hover) and (pointer: fine) {
    a:hover { text-decoration-color: currentColor; color: var(--accent-2); }
  }

  :focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: var(--r-sm); }
  :focus:not(:focus-visible) { outline: none; }

  ::selection { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--ink); }

  [id] { scroll-margin-top: calc(var(--nav-h, 64px) + var(--s6)); }

  .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: 0.005em; }
  .hand { font-family: var(--hand); font-weight: 600; }

  /* ── disclosure: one drawn chevron for every details/summary ──────
     The browser's triangle marker belongs to no design system. Page
     styles may still size and space the summary; the marker is settled
     here once. */
  summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: var(--s3);
            min-height: 44px; -webkit-tap-highlight-color: transparent; }
  summary::-webkit-details-marker { display: none; }
  summary::before {
    content: ""; flex: none; width: 7px; height: 7px; margin-inline: 3px 2px;
    border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
    transform: rotate(-45deg); transform-origin: 60% 60%;
    transition: transform var(--d-hover) var(--ease-out); opacity: 0.7;
  }
  details[open] > summary::before { transform: rotate(45deg); }
  summary:hover::before { opacity: 1; }

  /* Browser surfaces carry the design too. */
  html { scrollbar-color: var(--rule-strong) var(--ground); }
  input, textarea { caret-color: var(--accent); }
}

/* ══ chrome ═════════════════════════════════════════════════════════ */
@layer chrome {
  :root { --nav-h: 64px; }

  .skip {
    position: absolute; left: var(--s4); top: var(--s4); z-index: 100;
    padding: var(--s3) var(--s4); background: var(--paper); color: var(--ink);
    border: 1px solid var(--rule); border-radius: var(--r-md);
    box-shadow: var(--shadow-lift); transform: translateY(-200%);
  }
  .skip:focus { transform: none; }

  .wrap { width: 100%; max-width: var(--container); margin-inline: auto;
          padding-inline: max(var(--gutter), env(safe-area-inset-left)); }
  .wrap-wide { max-width: var(--wide); }

  /* ── masthead ─────────────────────────────────────────────────────
     One row, one left edge: the mark sits on the same line as every
     page's opening and section headings. At the top of a page it is part
     of the paper — no fill of its own, no hairline. Once the page moves
     under it, it becomes a material (86% ground, blurred) and only then
     draws its hairline (chrome.mjs sets .is-scrolled). On a phone it is
     mark, search, theme and a menu that owns the screen. */
  :root { --material: color-mix(in srgb, var(--ground) 86%, transparent); --hair: rgb(0 0 0 / .09); }
  [data-theme="dark"] { --hair: rgb(255 255 255 / .09); }
  @media (max-width: 759px) { :root { --nav-h: 56px; } }

  .masthead { position: sticky; top: 0; z-index: 50; height: var(--nav-h); background: var(--ground);
    transition: background-color .15s var(--ease-out), box-shadow .15s var(--ease-out), -webkit-backdrop-filter .15s var(--ease-out), backdrop-filter .15s var(--ease-out); }
  .masthead.is-scrolled { background: var(--material); box-shadow: 0 1px 0 var(--hair); }
  @supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .masthead.is-scrolled { -webkit-backdrop-filter: saturate(1.8) blur(24px); backdrop-filter: saturate(1.8) blur(24px); }
  }
  @supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) { .masthead.is-scrolled { background: var(--ground); } }
  .masthead > .wrap { height: 100%; display: flex; align-items: center; gap: 8px; }

  .namemark {
    view-transition-name: namemark;
    display: inline-flex; align-items: center; gap: 10px; margin-right: auto; height: 40px; padding-right: 6px;
    border-radius: var(--r-md); color: var(--ink); text-decoration: none;
    font-size: 15px; font-weight: 600; letter-spacing: -0.018em; white-space: nowrap; -webkit-tap-highlight-color: transparent;
  }
  .namemark:hover { text-decoration: none; color: var(--ink); }
  .namemark:focus-visible { outline-offset: 4px; }
  /* the mark: a squircle in the one indigo, E and M drawn as strokes —
     the same geometry as the favicon (tools/render-icons.mjs) */
  .glyph { width: 26px; height: 26px; flex: none; border-radius: 7.4px; transition: transform var(--d-press) var(--ease-out); }
  .namemark:active .glyph { transform: scale(.94); }
  /* home is a place too: the same edge tick the routes use, under the name */
  .namemark > span { position: relative; }
  .namemark[aria-current="page"] > span::after { content: ""; position: absolute; left: 0; bottom: calc((40px - var(--nav-h)) / 2 - 10px);
    width: 18px; height: 2px; border-radius: 2px 2px 0 0; background: var(--accent); }

  /* the routes */
  .nav ul { margin: 0; padding: 0; list-style: none; display: flex; align-items: center; gap: 2px; }
  .nav .nav-home { display: none; }
  .nav a { position: relative; display: inline-flex; align-items: center; height: 32px; padding: 0 12px; border-radius: var(--r-md);
    color: var(--nav-ink); text-decoration: none; font-size: 14px; font-weight: 500; letter-spacing: -.006em; white-space: nowrap; -webkit-tap-highlight-color: transparent;
    transition: color var(--d-hover) var(--ease-out), background-color var(--d-hover) var(--ease-out), transform var(--d-press) var(--ease-out); }
  @media (hover: hover) and (pointer: fine) { .nav a:hover { color: var(--ink); background: var(--paper-2); } }
  .nav a:active { transform: scale(.97); background: var(--paper-3); }
  /* here: ink, and a short indigo rule seated on the masthead's own edge —
     the tab you are standing in, not a second underline under the word */
  .nav a[aria-current="page"] { color: var(--ink); }
  .nav a[aria-current="page"]::after { content: ""; position: absolute; left: 50%; bottom: calc((32px - var(--nav-h)) / 2);
    width: 18px; height: 2px; margin-left: -9px; border-radius: 2px 2px 0 0; background: var(--accent); }

  /* utilities. Optical: the last glyph, not its 32px hit box, meets the
     container's right edge. */
  .mh-tools { display: flex; align-items: center; gap: 4px; margin-right: -8px; }
  .mh-tools::before { content: ""; width: 1px; height: 18px; margin: 0 10px 0 8px; background: var(--rule); }
  .mh-search, .mh-icon { display: inline-flex; align-items: center; justify-content: center; height: 32px; border: 0; border-radius: var(--r-md);
    background: none; color: var(--ink-2); cursor: pointer; -webkit-tap-highlight-color: transparent;
    transition: color var(--d-hover) var(--ease-out), background-color var(--d-hover) var(--ease-out), box-shadow var(--d-hover) var(--ease-out), transform var(--d-press) var(--ease-out); }
  .mh-search { gap: 8px; padding: 0 5px 0 10px; font-size: 13px; font-weight: 500; color: var(--graphite); box-shadow: inset 0 0 0 1px var(--rule); background: var(--paper); }
  .mh-search svg { width: 15px; height: 15px; }
  .mh-search-t { margin-right: 18px; }
  .mh-search .kbd { font: 500 11px/1 var(--mono); letter-spacing: .02em; color: var(--graphite); padding: 3px 5px; border: 0; border-radius: 5px;
    background: var(--paper-2); box-shadow: inset 0 0 0 1px var(--rule-soft); }
  .mh-icon { width: 32px; }
  .mh-icon svg { width: 16px; height: 16px; }
  @media (hover: hover) and (pointer: fine) {
    .mh-search:hover { color: var(--ink); box-shadow: inset 0 0 0 1px var(--rule-strong); }
    .mh-icon:hover { color: var(--ink); background: var(--paper-2); }
  }
  .mh-search:active, .mh-icon:active { transform: scale(.96); }
  #theme-toggle > span { display: inline-flex; }
  #theme-toggle .t-dark, [data-theme="dark"] #theme-toggle .t-light { display: none; }
  [data-theme="dark"] #theme-toggle .t-dark { display: inline-flex; }
  .mh-menu { display: none; }
  @media (pointer: coarse) {
    .nav a, .mh-icon, .mh-search { position: relative; }
    .mh-icon::before, .mh-search::before { content: ""; position: absolute; inset: -6px; }
  }
  @media (max-width: 1023px) { .mh-search-t { display: none; } .mh-search { padding: 0 5px 0 8px; } }

  /* ── the phone: mark, search, theme, and a menu that owns the screen ── */
  @media (max-width: 759px) {
    .masthead > .wrap { gap: 0; }
    .namemark { gap: 9px; }
    .glyph { width: 24px; height: 24px; }
    .mh-tools { gap: 0; }
    .mh-tools::before { display: none; }
    .mh-search { box-shadow: none; background: none; width: 40px; height: 40px; padding: 0; color: var(--ink); }
    .mh-search .kbd { display: none; }
    .mh-search svg { width: 17px; height: 17px; }
    .mh-icon { width: 40px; height: 40px; color: var(--ink); }
    .mh-icon svg { width: 17px; height: 17px; }
    .mh-menu { display: inline-flex; }
    .mh-burger { position: relative; width: 18px; height: 12px; }
    .mh-burger i { position: absolute; left: 0; right: 0; top: 5.25px; height: 1.5px; border-radius: 1px; background: currentColor; transition: transform .28s var(--ease-out); }
    .mh-burger i:first-child { transform: translateY(-3.25px); }
    .mh-burger i:last-child { transform: translateY(3.25px); }
    .is-menu .mh-burger i:first-child { transform: rotate(45deg); }
    .is-menu .mh-burger i:last-child { transform: rotate(-45deg); }

    .nav { position: fixed; left: 0; right: 0; top: var(--nav-h); height: calc(100dvh - var(--nav-h));
      padding: 12px max(var(--gutter), env(safe-area-inset-left)) 32px; background: var(--ground); overflow-y: auto; overscroll-behavior: contain;
      visibility: hidden; opacity: 0; transition: opacity .2s var(--ease-out), visibility 0s linear .2s; }
    .is-menu .nav { visibility: visible; opacity: 1; transition: opacity .24s var(--ease-out); }
    .nav ul { flex-direction: column; align-items: stretch; gap: 0; }
    .nav li { --i: 0; opacity: 0; transform: translateY(-6px); transition: opacity .2s var(--ease-out), transform .2s var(--ease-out); }
    .nav li:nth-child(2) { --i: 1; } .nav li:nth-child(3) { --i: 2; } .nav li:nth-child(4) { --i: 3; } .nav li:nth-child(5) { --i: 4; }
    .is-menu .nav li { opacity: 1; transform: none; transition: opacity .32s var(--ease-out) calc(40ms + var(--i) * 32ms), transform .4s var(--ease-out) calc(40ms + var(--i) * 32ms); }
    .nav a { display: flex; height: 60px; padding: 0 2px; border-radius: 0; font-size: 28px; font-weight: 600; letter-spacing: -.028em; color: var(--ink); box-shadow: 0 1px 0 var(--rule-soft); }
    .nav a:active { transform: none; background: none; color: var(--ink-2); }
    .nav .nav-home { display: list-item; }
    .namemark[aria-current="page"] > span::after { display: none; }
    .nav a[aria-current="page"] { color: var(--accent); }
    .nav a[aria-current="page"]::after { left: auto; right: 2px; bottom: 50%; margin: 0 0 -3px; width: 6px; height: 6px; border-radius: 50%; }
    .masthead.is-menu { background: var(--ground); box-shadow: 0 1px 0 var(--hair); -webkit-backdrop-filter: none; backdrop-filter: none; }
  }
  html.menu-open { overflow: hidden; }

  .kbd {
    font-family: var(--mono); font-size: 0.6875rem; color: var(--ink-2);
    border: 1px solid var(--rule); border-radius: var(--r-sm);
    background: var(--paper-2); padding: 1px 5px; line-height: 1.5;
  }

  /* ── footer ───────────────────────────────────────────────────── */
  .sitefoot { margin-top: var(--section-gap); border-top: 1px solid var(--rule-soft);
    padding-block: var(--s8); padding-bottom: max(var(--s8), env(safe-area-inset-bottom)); }
  .sitefoot .wrap { display: flex; align-items: center; gap: var(--s6); flex-wrap: wrap; }
  .sitefoot .who { display: flex; align-items: baseline; gap: var(--s3); margin-right: auto; }
  .sitefoot .who strong { font-weight: 600; font-size: var(--t-small); }
  .sitefoot .who span { color: var(--graphite); font-size: var(--t-caption); }
  .sitefoot .links { display: flex; flex-wrap: wrap; gap: var(--s5); font-size: var(--t-small); }
  .sitefoot .links a { color: var(--ink-2); text-decoration: none; }
  @media (hover: hover) and (pointer: fine) { .sitefoot .links a:hover { color: var(--accent); } }
  .sitefoot .stamp { flex-basis: 100%; font-family: var(--mono); font-size: var(--t-machine);
    color: var(--graphite); }
}

/* ══ components ═════════════════════════════════════════════════════ */
@layer components {

  /* ── eyebrow ──────────────────────────────────────────────────── */
  .eyebrow {
    display: block; font-size: var(--t-eyebrow); font-weight: 600;
    letter-spacing: 0.11em; text-transform: uppercase; color: var(--graphite);
    margin-bottom: var(--s4);
  }
  .eyebrow a { color: inherit; text-decoration: none; }
  @media (hover: hover) and (pointer: fine) { .eyebrow a:hover { color: var(--accent); } }

  /* ── page head ────────────────────────────────────────────────── */
  .pagehead { padding-block: var(--s11) var(--s8); }
  .pagehead h1 { font-size: var(--t-page); letter-spacing: -0.032em; max-width: 20ch; }
  .pagehead .lede { margin-top: var(--s5); color: var(--ink-2);
    font-size: var(--t-prose); line-height: var(--lh-prose); max-width: 62ch; }
  @media (max-width: 640px) { .pagehead { padding-block: var(--s8) var(--s6); } }

  /* ── section ──────────────────────────────────────────────────── */
  .section { padding-block: var(--s11); border-top: 1px solid var(--rule-soft); }
  .section:first-of-type { border-top: 0; }
  .section > h2,
  .section > .wrap > h2,
  .section > .wrap > .section-head h2 { font-size: var(--t-section); letter-spacing: -0.028em; }
  .section > .intro,
  .section > .wrap > .intro { margin-top: var(--s4); color: var(--ink-2); max-width: 62ch;
    font-size: var(--t-prose); line-height: var(--lh-prose); }
  .section-head { display: flex; align-items: baseline; justify-content: space-between;
    gap: var(--s6); flex-wrap: wrap; }

  /* ── arrow link ───────────────────────────────────────────────── */
  /* Inline, not flex: the sentence wraps like text and the glyph stays
     bound to its last word (see arrowLink in html.mjs). */
  .arrow {
    display: inline; font-size: var(--t-small); font-weight: 500; color: var(--accent);
    text-decoration: none;
  }
  .arrow-word { white-space: nowrap; }
  .arrow svg, .arrow-glyph { display: inline-block; width: 0.9em; height: 0.9em; vertical-align: -0.08em;
    margin-left: 0.4em; transition: transform var(--d-hover) var(--ease-out); }
  @media (hover: hover) and (pointer: fine) {
    .arrow:hover { color: var(--accent-2); }
    .arrow:hover svg { transform: translateX(3px); }
  }

  /* ── the label column pattern ─────────────────────────────────── */
  .split { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: var(--s10); align-items: start; }
  .split > .label { font-size: var(--t-caption); color: var(--graphite);
    position: sticky; top: calc(var(--nav-h) + var(--s6)); }
  @media (max-width: 900px) {
    .split { grid-template-columns: minmax(0, 1fr); gap: var(--s4); }
    .split > .label { position: static; }
  }

  /* ── prose ────────────────────────────────────────────────────── */
  .prose { max-width: 50ch; font-size: var(--t-prose); line-height: var(--lh-prose); color: var(--ink-2); }
  .prose > * + * { margin-top: var(--s5); }
  .prose strong { color: var(--ink); font-weight: 600; }
  .prose h3 { color: var(--ink); font-size: var(--t-heading); margin-top: var(--s8); }
  .prose-human { max-width: 62ch; font-size: var(--t-prose); line-height: var(--lh-prose); color: var(--ink); }

  /* ── handwritten margin note ──────────────────────────────────── */
  .note-hand {
    font-family: var(--hand); font-weight: 600; font-size: 1.5rem; line-height: 1.28;
    color: var(--ink-2); max-width: 22ch;
  }
  .note-hand svg { color: var(--rule-strong); overflow: visible; }

  /* ── buttons ──────────────────────────────────────────────────── */
  .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
    min-height: 42px; padding-inline: var(--s5);
    border-radius: var(--r-md); font-size: var(--t-small); font-weight: 500;
    border: 1px solid var(--rule); background: var(--paper); color: var(--ink);
    text-decoration: none; touch-action: manipulation;
    transition: transform var(--d-press) var(--ease-out),
                border-color var(--d-hover) ease, background-color var(--d-hover) ease;
  }
  .btn:active { transform: scale(0.97); }

  /* Press is the only acknowledgement a touch reader gets, so it belongs on
     every pressable surface, not only the three that had it. */
  .nav a:active, .nav button:active, .toc a:active, .pager a:active,
  .work-card a:active, .deck-filter button:active { transform: scale(0.985); }
  .row:active { background: var(--paper-3); }
  @media (hover: hover) and (pointer: fine) {
    .btn:hover { border-color: var(--rule-strong); background: var(--paper-2); }
  }
  .btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
  @media (hover: hover) and (pointer: fine) {
    .btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); color: var(--accent-ink); }
  }

  /* ── chips ────────────────────────────────────────────────────── */
  .chip {
    display: inline-flex; align-items: center; gap: var(--s2);
    min-height: 24px; padding: 2px var(--s3);
    border: 1px solid var(--rule); border-radius: var(--r-pill);
    background: var(--paper); font-size: var(--t-machine); font-family: var(--mono);
    color: var(--ink-2); white-space: nowrap;
  }
  .chip .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex: none; }
  .chip[data-status="In development"] { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-line); }
  .chip[data-status="Built foundation"] { color: var(--ink); }
  .chip[data-status="Prototype"] { color: var(--ink-2); }
  .chip[data-status="Concept"] { color: var(--graphite); }

  /* ── divided rows ─────────────────────────────────────────────── */
  .rows { border-top: 1px solid var(--rule-soft); }
  .row {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s5);
    align-items: baseline; padding-block: var(--s5);
    border-bottom: 1px solid var(--rule-soft); position: relative;
    transition: background-color var(--d-hover) ease;
  }
  .row h3, .row .row-h { font-size: var(--t-heading); font-weight: 600; letter-spacing: -0.018em; }
  .row h3 a, .row .row-h a { text-decoration: none; color: var(--ink); }
  .row h3 a::after, .row .row-h a::after { content: ""; position: absolute; inset: 0; }
  .row .sub { color: var(--ink-2); font-size: var(--t-small); margin-top: 3px; max-width: 48ch; }
  .row .meta { display: flex; align-items: center; gap: var(--s3); }
  @media (hover: hover) and (pointer: fine) {
    .row:hover { background: var(--paper-2);
      box-shadow: -14px 0 0 var(--paper-2), 14px 0 0 var(--paper-2); }
    .row:hover h3 a, .row:hover .row-h a { color: var(--accent); }
  }
  .row:has(a:focus-visible) { background: var(--paper-2);
    box-shadow: -14px 0 0 var(--paper-2), 14px 0 0 var(--paper-2); }
  .row:has(a:focus-visible) h3 a,
  .row:has(a:focus-visible) .row-h a { color: var(--accent); }
  @media (max-width: 640px) { .row { grid-template-columns: minmax(0, 1fr); gap: var(--s2); } }

  /* ── card ─────────────────────────────────────────────────────── */
  .card {
    border: 1px solid var(--rule); border-radius: var(--r-2xl);
    background: var(--paper); overflow: hidden; position: relative;
  }
  .card-tint { background: linear-gradient(158deg, var(--paper-2) 0%, var(--paper) 62%); }

  /* ── frame: where the site meets the work ─────────────────────── */
  .frame { border: 1px solid var(--rule); border-radius: var(--r-lg);
           background: var(--paper); overflow: hidden; position: relative; }
  .frame-label, .frame-note {
    display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap;
    font-size: var(--t-caption); color: var(--graphite);
  }
  .frame-label { margin-bottom: var(--s3); }
  .frame-note { margin-top: var(--s3); font-family: var(--mono); font-size: var(--t-machine); }
  .frame-note code { font-family: inherit; }

  /* ── local table of contents ──────────────────────────────────── */
  .toc { display: grid; gap: 2px; font-size: var(--t-small); }
  .toc a { display: flex; gap: var(--s3); text-decoration: none; color: var(--graphite);
           padding: var(--s1) 0;
           transition: color var(--d-hover) ease, transform var(--d-press) var(--ease-out); }
  .toc a .n { font-family: var(--mono); font-size: var(--t-machine); opacity: 0.7; }
  @media (hover: hover) and (pointer: fine) { .toc a:hover { color: var(--ink); } }
  .toc a[aria-current="true"] { color: var(--accent); font-weight: 500; }

  /* ── palette ──────────────────────────────────────────────────── */
  #palette {
    padding: 0; border: 1px solid var(--rule); border-radius: var(--r-xl);
    background: var(--paper); color: var(--ink); width: min(560px, calc(100vw - 32px));
    box-shadow: var(--shadow-dialog); margin: 12vh auto auto; overscroll-behavior: contain;
  }
  #palette::backdrop { background: rgba(17 17 17 / 0.32); }
  [data-theme="dark"] #palette::backdrop { background: rgba(0 0 0 / 0.6); }
  #palette .palette-search { display: flex; align-items: center; border-bottom: 1px solid var(--rule-soft); }
  #palette input {
    flex: 1; min-width: 0; width: 100%; padding: var(--s5); font-size: 1rem; background: none; border: 0;
    outline: none;
  }
  #palette-close { flex-shrink: 0; min-width: 44px; min-height: 44px; margin: var(--s2);
    padding: var(--s2) var(--s3); border: 1px solid var(--rule); border-radius: var(--r-md);
    background: var(--paper); color: var(--ink); font-size: var(--t-small); }
  @media (hover: hover) and (pointer: fine) { #palette-close:hover { background: var(--paper-2); border-color: var(--ink-2); } }
  @media (max-width: 640px) { #palette input { font-size: 16px; } }
  #palette input::placeholder { color: var(--graphite); }
  #palette ul { max-height: 46vh; overflow-y: auto; overscroll-behavior: contain; padding: var(--s2); }
  #palette li a {
    display: flex; align-items: baseline; gap: var(--s3); padding: var(--s3) var(--s4);
    border-radius: var(--r-md); text-decoration: none; color: var(--ink-2);
  }
  #palette li a strong { font-weight: 600; color: var(--ink); }
  #palette li a .kind { margin-left: auto; font-family: var(--mono); font-size: var(--t-machine); color: var(--graphite); }
  #palette li[aria-selected="true"] a { background: var(--accent-soft); color: var(--ink); }
  #palette .empty { padding: var(--s6); color: var(--graphite); font-size: var(--t-small); }
  #palette footer { display: flex; gap: var(--s5); padding: var(--s3) var(--s5);
    border-top: 1px solid var(--rule-soft); font-size: var(--t-machine); color: var(--graphite); }

  /* ── data table ───────────────────────────────────────────────── */
  .table-wrap { overflow-x: auto; }
  table.data { font-size: var(--t-small); }
  table.data th, table.data td { text-align: left; padding: var(--s3) var(--s4) var(--s3) 0;
    border-bottom: 1px solid var(--rule-soft); vertical-align: top; }
  table.data th { font-weight: 500; color: var(--graphite); font-size: var(--t-caption); }
  table.data td { color: var(--ink-2); }
  table.data td:first-child { color: var(--ink); }
  table.data .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

  /* ── prev / next ──────────────────────────────────────────────── */
  .pager { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s5);
    border-top: 1px solid var(--rule-soft); padding-top: var(--s7); margin-top: var(--s10); }
  .pager a { text-decoration: none; display: grid; gap: var(--s1); padding: var(--s5);
    border: 1px solid var(--rule); border-radius: var(--r-lg); background: var(--paper);
    transition: border-color var(--d-hover) ease, background-color var(--d-hover) ease,
                transform var(--d-press) var(--ease-out); }
  @media (hover: hover) and (pointer: fine) {
    .pager a:hover { border-color: var(--accent-line); background: var(--paper-2); }
  }
  .pager .dir { font-size: var(--t-caption); color: var(--graphite); }
  .pager .to { font-size: var(--t-heading); font-weight: 600; color: var(--ink); letter-spacing: -0.018em; }
  .pager .next { text-align: right; }
  @media (max-width: 560px) { .pager { grid-template-columns: 1fr; } }
}

/* ══ utilities ══════════════════════════════════════════════════════ */
@layer utilities {
  .vh { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
        overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
  .muted { color: var(--ink-2); }
  .faint { color: var(--graphite); }
  .stack > * + * { margin-top: var(--s4); }
  .stack-lg > * + * { margin-top: var(--s7); }
  .flow { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; }
  .measure { max-width: 62ch; }
  .nowrap { white-space: nowrap; }

  /* On a touch screen, text links keep their layout but grow a 44px touch
     area. Last layer, so it wins over the components' own display values. */
  @media (pointer: coarse) {
    .arrow { display: inline-block; padding-block: 10px; margin-block: -10px; }
    .sitefoot .links a { display: inline-flex; align-items: center; min-height: 44px; }
  }
}

/* Reduced motion is no MOVEMENT, not no motion — the promise the How I work page
   makes to the reader. An allowlist drops every property that travels and
   leaves colour and opacity on their own declared timing. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-property: color, background-color, border-color, outline-color,
      text-decoration-color, fill, stroke, opacity, box-shadow !important;
  }
}
