/* Heureka Bench — the manual
   Editorial lab-notebook: ruled paper, hanging section numbers, a serif with
   a bit of wonk in it. Palette inherited from Bench itself so the docs read as
   the same object as the app. */

/* ── tokens ──────────────────────────────────────────────────────────────── */

:root {
  --ink: #22303c;
  --ink-2: #5a6672;
  --ink-3: #83857a;
  --paper: #f6f1e3;
  --paper-2: #efe8d6;
  --card: #fffdf7;
  --card-2: #f4eede;
  --line: #e6ddca;
  --line-2: #d6ccb4;
  --primary: #4d6d8e;
  --primary-soft: rgba(77, 109, 142, 0.1);
  --green: #6f9a57;
  --amber: #bf7d1f;
  --teal: #12897f;
  --rose: #c0466a;
  --purple: #7c5cc0;
  --blue: #3b6fb0;

  --grain-blend: multiply;
  --grain-opacity: 0.4;
  --shadow: 0 1px 2px rgba(60, 50, 20, 0.05);
  --shadow-lift: 0 10px 30px -18px rgba(60, 50, 20, 0.5);

  --sans: 'Instrument Sans', ui-sans-serif, system-ui, sans-serif;
  --serif: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;

  --measure: 66ch;
  --sidebar-w: 268px;
  --pad: clamp(1.25rem, 4vw, 4rem);
}

:root[data-theme='dark'] {
  --ink: #eceee7;
  --ink-2: #a2aab3;
  --ink-3: #838c97;
  --paper: #191e24;
  --paper-2: #222932;
  --card: #2b333d;
  --card-2: #333d48;
  --line: rgba(255, 255, 255, 0.1);
  --line-2: rgba(255, 255, 255, 0.19);
  --primary: #6d90b3;
  --primary-soft: rgba(109, 144, 179, 0.16);
  --green: #8fbb73;
  --amber: #e0a53f;
  --teal: #3cc2b6;
  --rose: #e0708f;
  --purple: #a58ae0;
  --blue: #5b93d6;
  --grain-blend: overlay;
  --grain-opacity: 0.28;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-lift: 0 14px 36px -20px rgba(0, 0, 0, 0.8);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme='auto'] {
    --ink: #eceee7;
    --ink-2: #a2aab3;
    --ink-3: #838c97;
    --paper: #191e24;
    --paper-2: #222932;
    --card: #2b333d;
    --card-2: #333d48;
    --line: rgba(255, 255, 255, 0.1);
    --line-2: rgba(255, 255, 255, 0.19);
    --primary: #6d90b3;
    --primary-soft: rgba(109, 144, 179, 0.16);
    --green: #8fbb73;
    --amber: #e0a53f;
    --teal: #3cc2b6;
    --rose: #e0708f;
    --purple: #a58ae0;
    --blue: #5b93d6;
    --grain-blend: overlay;
    --grain-opacity: 0.28;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-lift: 0 14px 36px -20px rgba(0, 0, 0, 0.8);
    color-scheme: dark;
  }
}

/* ── base ────────────────────────────────────────────────────────────────── */

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

html { scroll-behavior: smooth; scroll-padding-top: 6.5rem; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
  font-feature-settings: 'ss01', 'cv05';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 9;
  pointer-events: none;
  opacity: var(--grain-opacity);
  mix-blend-mode: var(--grain-blend);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='0.35'/%3E%3C/svg%3E");
}

a { color: inherit; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
.ext { font-size: 0.75em; vertical-align: 0.35em; margin-left: 0.1em; opacity: 0.55; }

code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.08em 0.34em;
}

kbd {
  font-family: var(--mono);
  font-size: 0.72em;
  background: var(--card);
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0.1em 0.38em;
  color: var(--ink-2);
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--card);
  padding: 0.75rem 1rem;
  z-index: 100;
}
.skip:focus { left: 0; }

/* ── topbar ──────────────────────────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem var(--pad);
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 0.7rem; text-decoration: none; }

.brand-mark { width: auto; height: 26px; display: block; }

/* The wordmark ships as black artwork; invert it rather than keeping a second
   file, the same way the app does. */
.brand-word { width: auto; height: 32px; display: block; }
:root[data-theme='dark'] .brand-word { filter: brightness(0) invert(1); }
@media (prefers-color-scheme: dark) {
  :root[data-theme='auto'] .brand-word { filter: brightness(0) invert(1); }
}

.topbar-actions { display: flex; align-items: center; gap: 0.5rem; }

.searchbtn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font: inherit;
  font-size: 0.86rem;
  color: var(--ink-2);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.4rem 0.5rem 0.4rem 0.95rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.searchbtn:hover { border-color: var(--line-2); color: var(--ink); }

.themebtn {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  cursor: pointer;
  color: var(--ink-2);
  font-size: 0.9rem;
  line-height: 1;
  transition: border-color 0.15s, color 0.15s;
}
.themebtn:hover { border-color: var(--line-2); color: var(--ink); }
.themebtn::before { content: '◐'; }
:root[data-theme='light'] .themebtn::before { content: '○'; }
:root[data-theme='dark'] .themebtn::before { content: '●'; }

.getbtn {
  font-size: 0.86rem;
  font-weight: 600;
  text-decoration: none;
  background: var(--ink);
  color: var(--paper);
  border-radius: 999px;
  padding: 0.45rem 1.05rem;
  transition: opacity 0.15s;
}
.getbtn:hover { opacity: 0.85; }

/* ── shell + sidebar ─────────────────────────────────────────────────────── */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  align-items: start;
  max-width: 1500px;
  margin: 0 auto;
}

.sidebar {
  position: sticky;
  top: 3.9rem;
  padding: 2.4rem 1.25rem 2.4rem var(--pad);
  border-right: 1px solid var(--line);
  min-height: calc(100vh - 3.9rem);
}

.sidebar-label {
  font-family: var(--mono);
  font-size: 0.63rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0 0 0.85rem;
}
.sidebar-label--gap { margin-top: 2rem; }

.secnav { list-style: none; margin: 0; padding: 0; }
.secnav li { margin: 0; }

.secnav a {
  display: grid;
  grid-template-columns: 1.9rem 1fr;
  align-items: baseline;
  gap: 0.35rem;
  padding: 0.42rem 0.6rem 0.42rem 0;
  text-decoration: none;
  color: var(--ink-2);
  border-left: 2px solid transparent;
  padding-left: 0.7rem;
  transition: color 0.15s, border-color 0.15s;
}
.secnav a:hover { color: var(--ink); }
.secnav .n {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--ink-3);
}
.secnav .t { font-size: 0.92rem; line-height: 1.35; }
.secnav .c {
  font-family: var(--mono);
  font-size: 0.66rem;
  color: var(--ink-3);
  opacity: 0.7;
}
.secnav li.is-active a {
  color: var(--ink);
  border-left-color: var(--primary);
  font-weight: 600;
}
.secnav li.is-active .n { color: var(--primary); }
.secnav--plain a { grid-template-columns: 1fr; }

.sidebar-foot {
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.66rem;
  line-height: 1.7;
  color: var(--ink-3);
}
.sidebar-foot p { margin: 0; }
.sidebar-foot b { color: var(--ink-2); font-weight: 500; }

main { padding: 0 var(--pad) 6rem; min-width: 0; }

/* ── shared type ─────────────────────────────────────────────────────────── */

.eyebrow {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0 0 1.4rem;
}
.eyebrow a { text-decoration: none; }
.eyebrow a:hover { color: var(--ink); }

h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0;
}

p { margin: 0 0 1.05em; max-width: var(--measure); }
p:last-child { margin-bottom: 0; }

.rule {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 4.5rem 0 2rem;
}
.rule span {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
  white-space: nowrap;
}
.rule::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* ── home ────────────────────────────────────────────────────────────────── */

.hero { padding: 4.5rem 0 1rem; }

.hero h1 {
  font-size: clamp(2.4rem, 5.6vw, 4.4rem);
  line-height: 1.02;
  font-variation-settings: 'SOFT' 40, 'WONK' 1, 'opsz' 144;
  max-width: 18ch;
  margin-bottom: 1.6rem;
}
.hero h1 em {
  font-style: italic;
  color: var(--primary);
  font-variation-settings: 'SOFT' 60, 'WONK' 1, 'opsz' 144;
}

.hero-lede {
  font-size: 1.2rem;
  line-height: 1.55;
  color: var(--ink-2);
  max-width: 54ch;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0 2rem;
  margin-top: 2.2rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--ink-3);
}
.hero-meta b { color: var(--ink); font-weight: 500; }

.ccards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  /* Card background on the container, dividers drawn by the cards themselves —
     so the empty cells in a short last row read as blank page rather than as a
     hole of a different colour. */
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}

.ccard {
  display: flex;
  flex-direction: column;
  padding: 1.7rem 1.5rem 1.5rem;
  background: var(--card);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin: 0 -1px -1px 0;
  text-decoration: none;
  position: relative;
  transition: background 0.18s;
  animation: rise 0.55s cubic-bezier(0.2, 0.7, 0.3, 1) backwards;
  animation-delay: calc(var(--i) * 55ms + 60ms);
}
.ccard:hover { background: var(--card-2); }

.ccard-n {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--ink-3);
  letter-spacing: 0.1em;
}
.ccard h3 {
  font-size: 1.32rem;
  font-variation-settings: 'SOFT' 30, 'WONK' 1, 'opsz' 40;
  margin: 0.55rem 0 0.5rem;
}
.ccard-lede {
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--ink-2);
  margin: 0 0 1.1rem;
}
.ccard-peek {
  list-style: none;
  margin: 0;
  padding: 0 0 0 0.9rem;
  border-left: 1px solid var(--line);
  font-size: 0.83rem;
  line-height: 1.75;
  color: var(--ink-3);
}
.ccard-more {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--ink-3);
  margin: 0.6rem 0 0 0.9rem;
  opacity: 0.75;
}
.ccard-go {
  margin-top: auto;
  padding-top: 1.4rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  color: var(--primary);
  opacity: 0;
  transform: translateY(3px);
  transition: opacity 0.18s, transform 0.18s;
}
.ccard:hover .ccard-go { opacity: 1; transform: none; }

@media (hover: none) { .ccard-go { opacity: 1; transform: none; } }

.closing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 2.2rem;
}
.closing-grid h4 {
  font-size: 1.02rem;
  margin-bottom: 0.5rem;
  font-variation-settings: 'SOFT' 20, 'WONK' 1, 'opsz' 20;
}
.closing-grid p { font-size: 0.92rem; color: var(--ink-2); max-width: 42ch; }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .ccard, .entry { animation: none !important; }
}

/* ── category page ───────────────────────────────────────────────────────── */

.cathead { padding: 3.4rem 0 0; }

.cathead-main {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1.4rem;
  align-items: start;
}
.cathead-n {
  font-family: var(--mono);
  font-size: 0.86rem;
  color: var(--primary);
  padding-top: 0.7rem;
  letter-spacing: 0.08em;
}
.cathead h1 {
  font-size: clamp(2rem, 4vw, 3.1rem);
  line-height: 1.08;
  font-variation-settings: 'SOFT' 36, 'WONK' 1, 'opsz' 100;
  margin-bottom: 0.7rem;
}
.cathead-lede {
  font-size: 1.12rem;
  line-height: 1.55;
  color: var(--ink-2);
  max-width: 56ch;
}
.cathead-intro {
  margin-top: 2rem;
  padding-top: 1.6rem;
  border-top: 1px solid var(--line);
  font-size: 1.02rem;
  color: var(--ink-2);
}

.cattoc {
  margin: 2.6rem 0 1rem;
  padding: 1.2rem 1.4rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.cattoc ol {
  list-style: none;
  margin: 0;
  padding: 0;
  columns: 2;
  column-gap: 2rem;
  font-size: 0.9rem;
}
.cattoc li { break-inside: avoid; margin-bottom: 0.28rem; }
.cattoc a { text-decoration: none; color: var(--ink-2); }
.cattoc a:hover { color: var(--primary); }

.entries { margin-top: 2.5rem; }

.entry {
  display: grid;
  grid-template-columns: 4.5rem minmax(0, 1fr);
  gap: 0 1.5rem;
  padding: 2.6rem 0;
  border-top: 1px solid var(--line);
  animation: rise 0.5s cubic-bezier(0.2, 0.7, 0.3, 1) backwards;
  animation-delay: calc(var(--i) * 28ms + 40ms);
}
.entry:target .entry-num a { color: var(--primary); }
.entry:target h3 { text-decoration: underline; text-decoration-color: var(--primary); text-underline-offset: 6px; }

.entry-num {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-3);
  padding-top: 0.55rem;
  letter-spacing: 0.06em;
}
.entry-num a { text-decoration: none; }
.entry-num a:hover { color: var(--primary); }

.entry h3 {
  font-size: 1.55rem;
  line-height: 1.2;
  font-variation-settings: 'SOFT' 28, 'WONK' 1, 'opsz' 60;
  margin-bottom: 0.6rem;
}
.entry-lede {
  font-size: 1.06rem;
  line-height: 1.55;
  color: var(--ink);
  font-family: var(--serif);
  font-variation-settings: 'SOFT' 40, 'WONK' 0, 'opsz' 14;
  margin-bottom: 1.15em;
}
.entry-body p { color: var(--ink-2); }
.entry-body .entry-lede { color: var(--ink); }

.steps {
  counter-reset: s;
  list-style: none;
  margin: 1.4rem 0;
  padding: 0;
  max-width: var(--measure);
}
.steps li {
  counter-increment: s;
  position: relative;
  padding-left: 2.1rem;
  margin-bottom: 0.55rem;
  color: var(--ink-2);
  font-size: 0.95rem;
}
.steps li::before {
  content: counter(s);
  position: absolute;
  left: 0;
  top: 0.12em;
  width: 1.35rem;
  height: 1.35rem;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 999px;
}

/* ── "people ask" + comparison tables ────────────────────────────────────── */

.asks {
  margin: 0 0 1.4rem;
  padding: 0.9rem 1.1rem;
  max-width: var(--measure);
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 2px solid var(--primary);
  border-radius: 0 10px 10px 0;
}
.asks-label {
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0 0 0.4rem;
}
.asks ul { margin: 0; padding: 0; list-style: none; }
.asks li {
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--ink-2);
  padding-left: 1.1rem;
  position: relative;
}
.asks li + li { margin-top: 0.2rem; }
.asks li::before {
  content: '“';
  position: absolute;
  left: 0;
  top: 0.1em;
  font-family: var(--serif);
  font-size: 1.15em;
  color: var(--primary);
  opacity: 0.6;
}

.cmp-wrap { margin: 1.6rem 0; overflow-x: auto; }
.cmp {
  border-collapse: collapse;
  width: 100%;
  min-width: 460px;
  font-size: 0.92rem;
}
.cmp caption {
  caption-side: bottom;
  text-align: left;
  padding-top: 0.7rem;
  font-size: 0.82rem;
  font-style: italic;
  color: var(--ink-3);
}
.cmp thead th {
  text-align: left;
  font-family: var(--mono);
  font-size: 0.63rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  font-weight: 400;
  color: var(--ink-3);
  padding: 0 1rem 0.6rem 0;
  border-bottom: 1px solid var(--line-2);
}
.cmp tbody th {
  text-align: left;
  font-weight: 500;
  color: var(--ink);
  padding: 0.7rem 1rem 0.7rem 0;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  width: 34%;
}
.cmp td {
  padding: 0.7rem 1rem 0.7rem 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink-2);
  vertical-align: top;
}
.cmp .cell-yes { color: var(--green); font-weight: 500; }
.cmp .cell-no { color: var(--amber); font-weight: 500; }

/* ── distribution strip ──────────────────────────────────────────────────── */
/* Palette slots, not ranks. Validated with the dataviz checker against the
   card surface in each mode — do not "tidy" these values without re-running it. */

:root {
  --viz-1: #3b6fb0;
  --viz-2: #bf7d1f;
  --viz-3: #c0466a;
}
:root[data-theme='dark'] { --viz-1: #5b93d6; --viz-2: #c08830; --viz-3: #d96486; }
@media (prefers-color-scheme: dark) {
  :root[data-theme='auto'] { --viz-1: #5b93d6; --viz-2: #c08830; --viz-3: #d96486; }
}

.dist {
  margin: 1.8rem 0;
  padding: 1.4rem 1.5rem 1.1rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.dist-title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.02rem;
  font-variation-settings: 'SOFT' 20, 'WONK' 1, 'opsz' 20;
  margin-bottom: 1.4rem;
  color: var(--ink);
}

.d-rows { list-style: none; margin: 0; padding: 0; }
.d-row + .d-row { margin-top: 1.5rem; }

.d-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.45rem;
}
.d-name { font-size: 0.94rem; color: var(--ink); font-weight: 500; }
.d-value {
  font-family: var(--mono);
  font-size: 1.1rem;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  text-align: right;
  line-height: 1.25;
}
.d-value i {
  display: block;
  font-style: normal;
  font-size: 0.66rem;
  color: var(--ink-3);
  letter-spacing: 0.02em;
}

.d-track {
  position: relative;
  height: 18px;
  border-radius: 3px;
  outline: none;
}
.d-track::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: var(--line);
}

/* 2px line, per the mark spec */
.d-whisker {
  position: absolute;
  top: calc(50% - 1px);
  height: 2px;
  background: var(--c);
  opacity: 0.34;
  border-radius: 2px;
}
/* thin mark, 4px rounded ends */
.d-band {
  position: absolute;
  top: calc(50% - 5px);
  height: 10px;
  background: var(--c);
  border-radius: 4px;
  /* 2px surface ring so it reads as separate from the whisker underneath */
  box-shadow: 0 0 0 2px var(--card);
}
.d-median {
  position: absolute;
  top: calc(50% - 9px);
  width: 2px;
  height: 18px;
  margin-left: -1px;
  background: var(--ink);
  border-radius: 1px;
  box-shadow: 0 0 0 2px var(--card);
}
/* >= 8px marker */
.d-dot {
  position: absolute;
  top: calc(50% - 4px);
  width: 8px;
  height: 8px;
  margin-left: -4px;
  border-radius: 999px;
  background: var(--c);
  opacity: 0.55;
}
.d-dot--solo {
  width: 12px;
  height: 12px;
  top: calc(50% - 6px);
  margin-left: -6px;
  opacity: 1;
  box-shadow: 0 0 0 2px var(--card);
}

.d-tip {
  position: absolute;
  left: 0;
  bottom: calc(100% + 6px);
  z-index: 3;
  padding: 0.35rem 0.6rem;
  border-radius: 7px;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.76rem;
  line-height: 1.35;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(3px);
  transition: opacity 0.14s, transform 0.14s;
  pointer-events: none;
}
.d-track:hover .d-tip,
.d-track:focus-visible .d-tip { opacity: 1; transform: none; }

.d-note {
  font-size: 0.82rem;
  color: var(--ink-3);
  margin: 0.5rem 0 0;
  line-height: 1.45;
  max-width: 54ch;
}

.d-axis {
  position: relative;
  height: 1.4rem;
  margin-top: 1.5rem;
  border-top: 1px solid var(--line);
}
.d-tick {
  position: absolute;
  top: 0.35rem;
  transform: translateX(-50%);
  font-family: var(--mono);
  font-size: 0.66rem;
  color: var(--ink-3);
}
.d-tick:first-child { transform: none; }
.d-axis-unit {
  position: absolute;
  right: 0;
  top: 0.35rem;
  font-family: var(--mono);
  font-size: 0.66rem;
  color: var(--ink-3);
  opacity: 0.75;
}

.d-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.1rem;
  margin-top: 1.1rem;
}
.d-key {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.76rem;
  color: var(--ink-3);
}
.d-key::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--c);
}

.dist-foot {
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--ink-3);
  margin: 1rem 0 0;
  padding-top: 0.8rem;
  border-top: 1px dashed var(--line);
  max-width: none;
}

@media (max-width: 620px) {
  .d-head { flex-direction: column; gap: 0.1rem; }
  .d-tip { white-space: normal; width: min(240px, 70vw); }
}

.costs { margin: 1.6rem 0; }
.costs-table th[scope='row'] { width: 38%; }
.costs-table td { font-variant-numeric: tabular-nums; }
.costs-table td b { font-size: 1.08em; color: var(--ink); }
.costs-note {
  display: block;
  font-weight: 400;
  font-size: 0.82rem;
  color: var(--ink-3);
  line-height: 1.4;
  margin-top: 0.15rem;
}
.costs-n { color: var(--ink-3); font-size: 0.85em; }
.costs-stamp {
  margin-top: 0.9rem;
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--ink-3);
  max-width: var(--measure);
}
.costs-stamp b { color: var(--ink-2); font-weight: 500; }

.costs--empty {
  padding: 1.1rem 1.3rem;
  background: var(--card);
  border: 1px dashed var(--line-2);
  border-radius: 10px;
  max-width: var(--measure);
}
.costs--empty p { font-size: 0.9rem; color: var(--ink-3); }
.costs-label {
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--amber);
  margin: 0 0 0.4rem;
}

.entry-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.4rem;
  margin-top: 1.5rem;
  padding-top: 0.9rem;
  border-top: 1px dashed var(--line);
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--ink-3);
  line-height: 1.5;
}
.entry-meta b {
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 0.62rem;
  color: var(--ink-3);
  opacity: 0.8;
  margin-right: 0.35rem;
}
.entry-meta code { background: none; border: none; padding: 0; color: var(--ink-2); }
.meta-where { color: var(--ink-2); }
.tags { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-left: auto; }
.tag {
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
  font-size: 0.66rem;
  color: var(--ink-3);
}

/* ── screenshot slots ────────────────────────────────────────────────────── */

.shot { margin: 1.8rem 0 0; max-width: 100%; }

.shot-frame {
  position: relative;
  aspect-ratio: var(--ratio, 16 / 10);
  border-radius: 12px;
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lift);
}
.shot-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }

.shot-empty { display: none; }
.shot-frame.is-empty {
  /* An unfilled slot should read as a note to the author, not as a giant hole
     in the page — so it ignores the target ratio until the image lands. */
  aspect-ratio: auto;
  height: clamp(190px, 24vw, 260px);
  border-style: dashed;
  border-color: var(--line-2);
  box-shadow: none;
  background-color: var(--paper-2);
  background-image: repeating-linear-gradient(
    -45deg,
    transparent 0 9px,
    color-mix(in srgb, var(--line) 55%, transparent) 9px 10px
  );
}
.shot-frame.is-empty .shot-empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 0.5rem;
  height: 100%;
  padding: clamp(1rem, 3vw, 2rem);
}
.shot-tag {
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--paper);
  background: var(--ink-3);
  border-radius: 4px;
  padding: 0.12rem 0.5rem;
}
.shot-empty code {
  font-size: 0.78rem;
  background: var(--card);
  border-color: var(--line-2);
  color: var(--ink-2);
}
.shot-empty p {
  font-size: 0.85rem;
  color: var(--ink-3);
  margin: 0;
  max-width: 46ch;
  line-height: 1.5;
}
.shot-ratio {
  font-family: var(--mono);
  font-size: 0.66rem;
  color: var(--ink-3);
  opacity: 0.7;
}

.shot figcaption {
  margin-top: 0.7rem;
  font-size: 0.82rem;
  color: var(--ink-3);
  font-style: italic;
  max-width: var(--measure);
}

/* ── pager ───────────────────────────────────────────────────────────────── */

.pager {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3.5rem;
  padding-top: 1.6rem;
  border-top: 1px solid var(--line);
}
.pager a {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  text-decoration: none;
  padding: 0.7rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  transition: border-color 0.15s, background 0.15s;
  max-width: 46%;
}
.pager a:hover { border-color: var(--line-2); background: var(--card-2); }
.pager span { font-family: var(--mono); font-size: 0.66rem; color: var(--ink-3); }
.pager b {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 0.98rem;
  font-variation-settings: 'SOFT' 20, 'WONK' 1, 'opsz' 20;
}
.pager-next { text-align: right; margin-left: auto; }

/* ── reference table ─────────────────────────────────────────────────────── */

.reffilter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.8rem;
  margin: 2.6rem 0 1.4rem;
}
.reffilter input {
  font: inherit;
  font-size: 0.92rem;
  padding: 0.55rem 0.95rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  min-width: 220px;
}
.reffilter input:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }

.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.chip {
  font-family: var(--mono);
  font-size: 0.68rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-3);
  cursor: pointer;
  transition: all 0.15s;
}
.chip:hover { border-color: var(--line-2); color: var(--ink-2); }
.chip.is-on { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip i { font-style: normal; opacity: 0.5; margin-left: 0.4em; font-size: 0.9em; }

.reftable { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.reftable th {
  text-align: left;
  font-family: var(--mono);
  font-size: 0.63rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 400;
  padding: 0 0.9rem 0.7rem 0;
  border-bottom: 1px solid var(--line-2);
}
.reftable td {
  padding: 0.85rem 0.9rem 0.85rem 0;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.ref-title a { text-decoration: none; font-weight: 600; }
.ref-title a:hover { color: var(--primary); }
.ref-lede { display: block; color: var(--ink-3); font-size: 0.83rem; line-height: 1.45; margin-top: 0.15rem; max-width: 52ch; }
.ref-where { color: var(--ink-2); font-size: 0.84rem; white-space: nowrap; }
.ref-cat a { text-decoration: none; color: var(--ink-2); font-size: 0.84rem; white-space: nowrap; }
.ref-cat .n { font-family: var(--mono); font-size: 0.7rem; color: var(--ink-3); }
.ref-since code { background: none; border: none; padding: 0; font-size: 0.75rem; color: var(--ink-3); }
.ref-since .dash { font-family: var(--mono); font-size: 0.7rem; color: var(--ink-3); opacity: 0.6; }
.refempty { margin-top: 2rem; color: var(--ink-3); font-style: italic; }

/* ── search ──────────────────────────────────────────────────────────────── */

.searchveil {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: color-mix(in srgb, var(--paper) 55%, transparent);
  backdrop-filter: blur(8px) saturate(1.2);
  display: flex;
  justify-content: center;
  padding: 12vh 1rem 1rem;
}
.searchveil[hidden] { display: none; }

.searchbox {
  width: min(620px, 100%);
  height: fit-content;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: 14px;
  box-shadow: var(--shadow-lift);
  overflow: hidden;
  animation: rise 0.2s ease-out;
}
.searchbox input {
  font: inherit;
  font-size: 1.05rem;
  padding: 1.1rem 1.3rem;
  border: none;
  border-bottom: 1px solid var(--line);
  background: none;
  color: var(--ink);
}
.searchbox input:focus { outline: none; }

.searchbox ul {
  list-style: none;
  margin: 0;
  padding: 0.4rem;
  overflow-y: auto;
  flex: 1;
}
.searchbox li a {
  display: block;
  padding: 0.6rem 0.9rem;
  border-radius: 8px;
  text-decoration: none;
}
.searchbox li.is-sel a,
.searchbox li a:hover { background: var(--primary-soft); }
.searchbox .r-t { font-weight: 600; font-size: 0.94rem; }
.searchbox .r-s {
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-left: 0.5rem;
}
.searchbox .r-l { display: block; font-size: 0.82rem; color: var(--ink-3); line-height: 1.4; margin-top: 0.1rem; }
.searchbox .r-none { padding: 1.4rem; color: var(--ink-3); font-style: italic; }

.searchhint {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  padding: 0.6rem 1rem;
  margin: 0;
  border-top: 1px solid var(--line);
  font-size: 0.7rem;
  color: var(--ink-3);
}

/* ── responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 1080px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    min-height: 0;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 1.4rem var(--pad);
  }
  /* One scrollable row rather than a wrapped block — the nav should not own
     the first screen on a phone. */
  .secnav {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.3rem;
    overflow-x: auto;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
    margin: 0 calc(var(--pad) * -1);
    padding: 0 var(--pad) 0.3rem;
  }
  .secnav::-webkit-scrollbar { display: none; }
  .secnav li { scroll-snap-align: start; }
  .secnav a {
    border-left: none;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.3rem 0.8rem;
    grid-template-columns: auto auto;
    gap: 0.45rem;
    white-space: nowrap;
  }
  .secnav .c { display: none; }
  .secnav li.is-active a { border-color: var(--primary); }
  .sidebar-label--gap { margin-top: 1rem; }
  .sidebar-foot { margin-top: 1rem; padding-top: 0.7rem; }
  .cattoc ol { columns: 1; }
}

@media (max-width: 720px) {
  body { font-size: 16px; }
  .entry { grid-template-columns: 1fr; gap: 0.4rem; }
  .entry-num { padding-top: 0; }
  .getbtn { display: none; }
  .searchbtn span { display: none; }
  .searchbtn { padding: 0.4rem 0.6rem; }
  .tags { margin-left: 0; }
  .reftable .ref-where, .reftable .ref-since,
  .reftable th:nth-child(2), .reftable th:nth-child(4) { display: none; }
}

/* ── print: the manual, on paper ─────────────────────────────────────────── */

@media print {
  .topbar, .sidebar, .searchveil, .grain, .pager, .cattoc { display: none !important; }
  .shell { display: block; }
  main { padding: 0; }
  .entry { break-inside: avoid; }
  body { font-size: 11pt; background: #fff; }
}
