/* Scale Explorer — one stylesheet, no framework. Colours are tokens so the
   light and dark themes (prefers-color-scheme) stay in sync. */

:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #efede7;
  --ink: #16181d;
  --ink-2: #454a55;
  --ink-3: #676d7c;
  --line: #dedad0;
  --line-strong: #c9c3b6;
  --accent: #1c5dcf;
  --accent-hover: #164ba8;
  --accent-ink: #ffffff;
  --accent-soft: #e5edfb;
  --stage: #fbfaf6;
  --grid: #ebe7de;
  --grid-label: #7b8190;
  --ground: #7b7262;
  --outline: rgba(22, 24, 29, 0.42);
  --label-halo: #fbfaf6;
  --warn: #b3261e;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(20, 20, 30, 0.05), 0 6px 20px rgba(20, 20, 30, 0.05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --cat: var(--accent);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1218;
    --surface: #161a22;
    --surface-2: #1d222c;
    --ink: #e9ebf0;
    --ink-2: #b9bfcb;
    --ink-3: #9098a8;
    --line: #2a303c;
    --line-strong: #3a4250;
    --accent: #7ea6ff;
    --accent-hover: #a6c1ff;
    --accent-ink: #0d1424;
    --accent-soft: #1c2640;
    --stage: #12161e;
    --grid: #222834;
    --grid-label: #8a92a3;
    --ground: #968e7e;
    --outline: rgba(236, 239, 246, 0.5);
    --label-halo: #12161e;
    --warn: #ff8a80;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}

.cat-animals { --cat: #b4540b; }
.cat-vehicles { --cat: #1c5dcf; }
.cat-buildings { --cat: #6b3fc4; }
.cat-structures { --cat: #0d7a70; }
.cat-nature { --cat: #2f7d32; }
.cat-space { --cat: #4b47c7; }
@media (prefers-color-scheme: dark) {
  .cat-animals { --cat: #f0a35e; }
  .cat-vehicles { --cat: #7ea6ff; }
  .cat-buildings { --cat: #b89cff; }
  .cat-structures { --cat: #5fd0c3; }
  .cat-nature { --cat: #86d18a; }
  .cat-space { --cat: #a3a0ff; }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1.0625rem/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img, svg { max-width: 100%; }
a { color: var(--accent); text-underline-offset: 0.16em; }
a:hover { color: var(--accent-hover); }
h1, h2, h3 { line-height: 1.15; letter-spacing: -0.015em; margin: 0 0 0.5em; }
h1 { font-size: clamp(2rem, 1.3rem + 3.2vw, 3.3rem); font-weight: 780; letter-spacing: -0.028em; }
h2 { font-size: clamp(1.35rem, 1.1rem + 1vw, 1.75rem); font-weight: 720; }
h3 { font-size: 1.1rem; font-weight: 680; }
p { margin: 0 0 1em; }
table { border-collapse: collapse; }
button, input, select { font: inherit; color: inherit; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 50;
  background: var(--accent); color: var(--accent-ink); padding: 8px 14px; border-radius: 8px; font-weight: 600;
}
.skip-link:focus { top: 12px; color: var(--accent-ink); }
main:focus { outline: none; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.wrap.narrow { max-width: 780px; }
@media (min-width: 768px) { .wrap { padding: 0 24px; } }

/* ---------- Header ---------- */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); position: relative; z-index: 20; }
.header-row { display: flex; align-items: center; gap: 12px 16px; min-height: 64px; padding-top: 10px; padding-bottom: 10px; }
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; font-weight: 760; font-size: 1.12rem; letter-spacing: -0.01em; white-space: nowrap; }
.brand:hover { color: var(--ink); }
.logo { width: 28px; height: 28px; fill: var(--accent); flex: none; }
.header-row .search { flex: 1 1 auto; max-width: 440px; margin-left: auto; }
.header-spacer { flex: 1; }
.units { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 999px; padding: 2px; background: var(--surface-2); flex: none; }
.units button {
  border: 0; background: transparent; padding: 4px 12px; border-radius: 999px; cursor: pointer;
  font-size: 0.9rem; font-weight: 650; color: var(--ink-2); min-width: 40px; min-height: 32px;
}
.units button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,0.15); }
@media (max-width: 700px) {
  .header-row { flex-wrap: wrap; }
  .header-row .search { order: 3; flex-basis: 100%; max-width: none; margin-left: 0; }
  .units { margin-left: auto; }
}

.site-nav { border-top: 1px solid var(--line); }
.site-nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.site-nav ul::-webkit-scrollbar { display: none; }
.site-nav a {
  display: block; padding: 10px 12px; white-space: nowrap; color: var(--ink-2); text-decoration: none; font-size: 0.95rem; font-weight: 560;
  border-bottom: 2px solid transparent;
}
.site-nav a:hover { color: var(--ink); }
.site-nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }

/* ---------- Search ---------- */
.search { position: relative; }
.search-label { display: block; font-weight: 700; margin-bottom: 8px; }
.search-field {
  display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 12px; padding: 4px 4px 4px 12px;
}
.search-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-icon { width: 18px; height: 18px; fill: none; stroke: var(--ink-3); stroke-width: 2; stroke-linecap: round; flex: none; }
.search-field input {
  flex: 1; min-width: 0; border: 0; background: transparent; padding: 8px 2px; outline: none; font-size: 1rem;
}
.search-field input::-webkit-search-cancel-button { cursor: pointer; }
.search-submit {
  border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 650; border-radius: 9px; padding: 7px 14px; cursor: pointer; font-size: 0.95rem;
}
.search-submit:hover { background: var(--accent-hover); }
.site-header .search-submit { display: none; }
.search-big .search-label { font-size: 1.15rem; }
.search-big .search-field { padding: 6px 6px 6px 16px; border-radius: 14px; box-shadow: var(--shadow); }
.search-big .search-field input { font-size: 1.15rem; padding: 12px 2px; }
.search-big .search-icon { width: 22px; height: 22px; }
.search-big .search-submit { padding: 11px 20px; font-size: 1.02rem; }
.search-results {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 30; margin: 0; padding: 6px; list-style: none;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,0.18);
  max-height: min(60vh, 440px); overflow-y: auto;
}
.search-results [role="option"] { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.search-results [role="option"][aria-selected="true"], .search-results [role="option"]:hover { background: var(--accent-soft); }
.search-results .no-results { color: var(--ink-3); cursor: default; }
.opt-icon { width: 34px; height: 34px; flex: none; }
.opt-text { display: flex; flex-direction: column; min-width: 0; }
.opt-label { font-weight: 640; }
.opt-meta { font-size: 0.85rem; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Buttons and forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 8px 16px;
  border-radius: 10px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
  font-weight: 650; text-decoration: none; cursor: pointer; line-height: 1.2;
}
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--accent); border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--accent-soft); color: var(--accent-hover); border-color: var(--accent); }
select, input[type="text"], input:not([type]), input[inputmode] {
  min-height: 44px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); padding: 8px 12px; max-width: 100%;
}
select { padding-right: 32px; }
select:focus, input:focus { border-color: var(--accent); }
input[aria-invalid="true"] { border-color: var(--warn); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.form-error { color: var(--warn); font-weight: 600; margin: 8px 0 0; }
.fine { font-size: 0.88rem; color: var(--ink-3); }

/* ---------- Hero ---------- */
.hero { padding: 36px 0 28px; }
.hero-grid { margin-bottom: 24px; }
.hero-copy { max-width: 760px; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.8rem; font-weight: 750; color: var(--cat); margin: 0 0 10px; }
.eyebrow a { color: inherit; text-decoration: none; }
.eyebrow a:hover { text-decoration: underline; }
.hero h1 { margin-bottom: 14px; }
.hero-lede { font-size: 1.15rem; color: var(--ink-2); max-width: 640px; margin-bottom: 22px; }
.hero-links { margin: 14px 0 0; color: var(--ink-3); font-size: 0.95rem; }

/* ---------- Sections ---------- */
.section { padding: 28px 0; }
.section-alt { background: var(--surface-2); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-top: 16px; padding: 36px 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.section-head h2 { margin: 0; }
.more { font-weight: 600; text-decoration: none; white-space: nowrap; }
.section-lede { color: var(--ink-2); max-width: 70ch; }
.page-head { padding: 12px 0 18px; }
.page-head .lede, .lede { font-size: 1.12rem; color: var(--ink-2); max-width: 70ch; }

.crumbs ol { list-style: none; margin: 16px 0 8px; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; font-size: 0.9rem; color: var(--ink-3); }
.crumbs li + li::before { content: "›"; margin: 0 6px 0 2px; color: var(--ink-3); }
.crumbs a { color: var(--ink-2); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }

/* ---------- Object page ---------- */
.object-head { padding: 4px 0 18px; }
.object-head h1 { margin-bottom: 8px; }
.object-sub { color: var(--ink-2); margin-bottom: 18px; font-size: 1.05rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin: 0; }
@media (max-width: 560px) {
  .stats { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat { padding: 9px 11px; }
  .stat-main { grid-column: 1 / -1; }
  .stat dt { font-size: 0.72rem; }
  .stat-value { font-size: 1.1rem; }
  .stat-main .stat-value { font-size: 1.35rem; }
  .stat-alt { display: block; font-size: 0.88rem; }
}
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; margin: 0; }
.stat dt { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); font-weight: 700; }
.stat dd { margin: 2px 0 0; }
.stat-value { font-size: 1.3rem; font-weight: 740; letter-spacing: -0.01em; }
.stat-main { border-color: var(--cat); box-shadow: inset 4px 0 0 var(--cat); }
.stat-main .stat-value { font-size: 1.55rem; }
.stat-alt { color: var(--ink-2); font-weight: 560; white-space: nowrap; }
.badge {
  display: inline-block; vertical-align: 2px; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line);
}

.viz-section { margin: 6px 0 10px; }
.viz-actions { margin: 12px 0 0; }

.content-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 32px; margin-top: 24px; }
@media (min-width: 1024px) {
  .content-grid:has(> .rail) { grid-template-columns: minmax(0, 1fr) 300px; }
}
.content-main > section { margin-bottom: 36px; }
.content-main > section h2 { padding-top: 6px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.dims, .index-table, .conv { width: 100%; font-size: 0.97rem; }
.dims th, .dims td, .index-table th, .index-table td, .conv th, .conv td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.dims thead th, .index-table thead th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); background: var(--surface-2); white-space: nowrap; }
.dims tbody tr:last-child > *, .index-table tbody tr:last-child > *, .conv tbody tr:last-child > * { border-bottom: 0; }
.dims tbody th, .index-table tbody th, .conv tbody th { font-weight: 650; }
.dims td:nth-child(2), .dims td:nth-child(3) { white-space: nowrap; font-variant-numeric: tabular-nums; }
.dims td:nth-child(4) { color: var(--ink-2); font-size: 0.92rem; min-width: 12rem; }
.conv caption { text-align: left; font-weight: 700; padding: 10px 14px; }
.conv td { font-variant-numeric: tabular-nums; }
.conv tr.is-source th, .conv tr.is-source td { background: var(--accent-soft); }
.ref { text-decoration: none; font-size: 0.85em; font-weight: 650; }

.facts, .notes { padding-left: 1.2em; }
.facts li, .notes li { margin-bottom: 6px; }
.notes { color: var(--ink-2); }
.sources { padding-left: 1.4em; font-size: 0.95rem; }
.sources li { margin-bottom: 8px; overflow-wrap: anywhere; }
.sources li:target { background: var(--accent-soft); border-radius: 6px; }
.src-pub { font-weight: 650; }
.src-date { color: var(--ink-3); }

.compare-list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 8px; }
.compare-list li { display: flex; gap: 14px; align-items: baseline; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 14px; }
.cmp-factor { flex: none; min-width: 4.8rem; font-weight: 780; font-size: 1.1rem; color: var(--accent); font-variant-numeric: tabular-nums; }
.cmp-text a { white-space: nowrap; font-size: 0.92rem; }

/* ---------- Visualisation ---------- */
.viz { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 12px; box-shadow: var(--shadow); }
.viz-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-bottom: 10px; }
.viz-tabs { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.viz-tabs [role="tab"] { border: 0; background: transparent; padding: 6px 14px; border-radius: 7px; cursor: pointer; font-weight: 620; font-size: 0.93rem; color: var(--ink-2); min-height: 34px; }
.viz-tabs [role="tab"][aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,0.14); }
.viz-chips { border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-width: 0; }
.viz-chips legend { float: left; font-size: 0.85rem; color: var(--ink-3); margin-right: 4px; font-weight: 600; padding: 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); border-radius: 999px; padding: 4px 11px 4px 8px; font-size: 0.88rem; cursor: pointer; background: var(--surface); min-height: 32px; }
.chip:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.chip input { accent-color: var(--accent); margin: 0; width: 15px; height: 15px; }
.viz-stage { background: var(--stage); border-radius: 10px; overflow: hidden; }
.stage-svg { display: block; width: 100%; height: auto; }
.viz-note { margin: 10px 2px 0; font-size: 0.93rem; color: var(--ink-2); }
.viz-caption { margin: 8px 2px 0; font-size: 0.86rem; color: var(--ink-3); }

.stage-svg .grid-line { stroke: var(--grid); stroke-width: 1; }
.stage-svg .grid-label { font: 500 11px var(--font); fill: var(--grid-label); }
.stage-svg .ground { stroke: var(--ground); stroke-width: 1.5; }
.stage-svg .sil path { stroke: var(--outline); stroke-width: 0.7px; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.stage-svg .ghost { opacity: 0.3; }
.stage-svg .ghost path { stroke-dasharray: 3 2; }
.stage-svg .label text { paint-order: stroke; stroke: var(--label-halo); stroke-width: 4px; stroke-linejoin: round; }
.stage-svg .label-name { font: 680 13px var(--font); fill: var(--ink); }
.stage-svg .label-dim { font: 500 12px var(--font); fill: var(--ink-2); }
.stage-svg .label.is-highlight .label-name { fill: var(--accent); }
.stage-svg .leader { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 2 2; }
.stage-svg .marker line { stroke: var(--accent); stroke-width: 1.5; }
.stage-svg .marker path { fill: var(--accent); }
.stage-svg .scale-bar path { fill: none; stroke: var(--ink); stroke-width: 1.6; }
.stage-svg .scale-bar text { font: 650 12px var(--font); fill: var(--ink); }

.bars { list-style: none; margin: 0; padding: 4px 2px; display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(7rem, 13rem) minmax(0, 1fr) auto; grid-template-areas: "name track value" "dim track value"; column-gap: 12px; align-items: center; }
.bar-name { grid-area: name; font-weight: 650; line-height: 1.25; }
.bar-name a { color: var(--ink); text-decoration: none; }
.bar-name a:hover { color: var(--accent); text-decoration: underline; }
.bar-dim { grid-area: dim; font-size: 0.8rem; color: var(--ink-3); line-height: 1.2; }
.bar-track { grid-area: track; display: block; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.bar-track svg { display: block; width: 100%; height: 16px; }
.bar-range { opacity: 0.35; }
.bar-value { grid-area: value; font-variant-numeric: tabular-nums; font-weight: 620; white-space: nowrap; font-size: 0.95rem; }
.bar-note { display: block; font-weight: 400; font-size: 0.78rem; color: var(--ink-3); white-space: normal; }
.bar-row.is-highlight .bar-name a { color: var(--accent); }
@media (max-width: 560px) {
  .bar-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name value" "dim dim" "track track"; row-gap: 4px; }
}

.zoom-level { margin-top: 22px; }
.zoom-title { margin-bottom: 2px; }
.zoom-sub { font-size: 0.92rem; color: var(--ink-2); margin-bottom: 10px; }

/* Step-by-step zoom */
.ladder { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 16px 16px; }
.ladder-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 22px; }
.ladder-title { margin-bottom: 4px; }
.step-num { display: block; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); font-weight: 700; margin-bottom: 2px; }
.ladder-sentence { color: var(--ink-2); margin-bottom: 10px; }
.ladder-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 6px 0 8px; }
.ladder-pos { font-weight: 650; color: var(--ink-2); }
.ladder-dots { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.ladder-dots button {
  min-width: 32px; height: 32px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; font-size: 0.85rem; font-weight: 650; color: var(--ink-2);
}
.ladder-dots button[aria-current="step"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ---------- Cards ---------- */
.card-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.card-link {
  display: flex; gap: 12px; align-items: center; height: 100%; padding: 12px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); text-decoration: none; color: var(--ink);
}
.card-link:hover { border-color: var(--accent); color: var(--ink); box-shadow: var(--shadow); }
.card-icon { flex: none; width: 58px; height: 58px; display: grid; place-items: center; background: var(--stage); border-radius: 8px; padding: 5px; }
.card-icon .icon, .card-icon .opt-icon { width: 100%; height: 100%; }
.card-body { display: flex; flex-direction: column; min-width: 0; }
.card-name { font-weight: 680; line-height: 1.25; }
.card-meta { font-size: 0.86rem; color: var(--ink-3); }

.pair-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 14px; }
.pair-card a {
  display: flex; flex-direction: column; gap: 8px; height: 100%; padding: 14px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); text-decoration: none; color: var(--ink);
}
.pair-card a:hover { border-color: var(--accent); box-shadow: var(--shadow); color: var(--ink); }
.pair-title { font-weight: 720; font-size: 1.05rem; }
.vs { color: var(--ink-3); font-weight: 500; font-size: 0.9em; margin: 0 2px; }
.pair-stage { display: block; background: var(--stage); border-radius: 9px; overflow: hidden; }
.pair-sentence { font-size: 0.92rem; color: var(--ink-2); }

.cat-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr)); gap: 10px; }
.cat-card a {
  display: grid; grid-template-columns: 52px 1fr; grid-template-areas: "icon name" "icon count" "ex ex"; column-gap: 12px; row-gap: 2px;
  padding: 14px; height: 100%; background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--cat);
  border-radius: var(--radius-sm); text-decoration: none; color: var(--ink);
}
.cat-card a:hover { box-shadow: var(--shadow); color: var(--ink); border-color: var(--cat); }
.cat-icon { grid-area: icon; width: 52px; height: 52px; }
.cat-icon .icon { width: 100%; height: 100%; }
.cat-name { grid-area: name; font-weight: 720; font-size: 1.08rem; align-self: end; }
.cat-count { grid-area: count; font-size: 0.86rem; color: var(--ink-3); }
.cat-examples { grid-area: ex; font-size: 0.86rem; color: var(--ink-2); margin-top: 8px; }

.link-list { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0 0 16px; }
.link-list a { display: inline-block; padding: 7px 13px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); text-decoration: none; font-weight: 600; font-size: 0.94rem; }
.link-list a:hover { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- Home: compare anything ---------- */
.any-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 32px; }
.mini-compare, .mini-measure { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.mini-compare label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 0.9rem; flex: 1 1 160px; }
.mini-compare select { width: 100%; }
.mini-measure input { width: 8.5rem; flex: 1 1 7rem; }

/* ---------- Compare and measure pages ---------- */
.compare-form, .measure-form { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 24px; }
.cf-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.cf-pick { display: flex; flex-direction: column; gap: 4px; flex: 1 1 220px; font-weight: 650; font-size: 0.92rem; min-width: 0; }
.cf-pick select { width: 100%; }
.swap { width: 44px; height: 44px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface-2); cursor: pointer; display: grid; place-items: center; flex: none; }
.swap svg { width: 20px; height: 20px; fill: none; stroke: var(--ink-2); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.swap:hover { border-color: var(--accent); }
.cf-extra-row { display: flex; align-items: flex-end; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.cf-options { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; margin-top: 14px; }
.cf-options .btn:last-child { margin-left: auto; }
.compare-result { margin-bottom: 24px; }
.compare-result > h2 { margin-bottom: 8px; }
.sentences { padding-left: 1.2em; margin: 0 0 16px; }
.sentences li { margin-bottom: 4px; }
.compare-result [data-result-ladder]:not(:empty), .measure-result .ladder { margin-top: 24px; }

.mf-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.mf-field { display: flex; flex-direction: column; gap: 4px; font-weight: 650; font-size: 0.92rem; }
.mf-field input { width: 11rem; font-size: 1.1rem; }
.mf-as { border: 0; padding: 0; margin: 14px 0 6px; display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; }
.mf-as legend { float: left; font-weight: 650; font-size: 0.92rem; margin-right: 8px; padding: 0; }
.examples { margin: 10px 0 0; font-size: 0.93rem; color: var(--ink-3); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.examples a { display: inline-block; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface-2); text-decoration: none; font-weight: 600; }
.measure-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 24px; margin-bottom: 20px; align-items: start; }
.measure-hint { margin: 8px 0 16px; }

/* ---------- Footer ---------- */
.site-footer { margin-top: 48px; background: var(--surface); border-top: 1px solid var(--line); padding: 32px 0 20px; font-size: 0.95rem; color: var(--ink-2); }
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 24px; }
.footer-grid h2 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); margin-bottom: 8px; }
.footer-grid ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.footer-grid a { color: var(--ink-2); text-decoration: none; }
.footer-grid a:hover { color: var(--accent); text-decoration: underline; }
.footer-brand { display: flex; align-items: center; gap: 8px; font-weight: 750; color: var(--ink); font-size: 1.05rem; }
.footer-note { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 0.86rem; color: var(--ink-3); }
.footer-note p { margin: 0; }

/* Ads (src/lib/ads.js): small, labelled, never over the drawings. The sidebar
   only shows where the object page has room for a second column. */
.ad { margin: 32px auto 0; text-align: center; }
.ad-label { margin: 0 0 4px; font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.ad-box { margin: 0 auto; max-width: 100%; overflow: hidden; }
.ad-bottom .ad-box { min-height: 50px; }
@media (min-width: 800px) { .ad-bottom .ad-box { min-height: 90px; } }
.rail { display: none; }
@media (min-width: 1024px) { .rail { display: block; } .rail .ad { margin-top: 0; } }

@media (prefers-reduced-motion: no-preference) {
  .card-link, .pair-card a, .cat-card a, .btn { transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s; }
}

@media print {
  .site-header, .site-footer, .viz-toolbar, .ladder-nav, .ladder-dots, .search, .ad, .rail { display: none !important; }
  .ladder-step[hidden] { display: block !important; }
}

/* ---------- How many fit, weight and volume views, you ---------- */
.fit-cards { list-style: none; margin: 0 0 12px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 10px; }
.fit-card { display: flex; flex-direction: column; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--radius-sm); padding: 12px 14px; }
.fit-card.fit-mass { border-left-color: #b4540b; }
.fit-card.fit-volume { border-left-color: #0d7a70; }
.fit-count { font-size: 1.6rem; font-weight: 780; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.fit-what { font-weight: 650; }
.fit-how { font-size: 0.9rem; color: var(--ink-3); }
.fit-big { font-weight: 650; color: var(--ink-2); }
.compare-result [data-result-howmany]:not(:empty) { margin-bottom: 14px; }
.viz-pane-note { font-size: 0.88rem; color: var(--ink-3); margin: 2px 2px 10px; }
.viz-missing, .viz-empty { font-size: 0.9rem; color: var(--ink-2); margin: 10px 2px 0; }
.viz-volume .viz-stage { background: var(--stage); border-radius: 10px; overflow: hidden; }
.cf-you { margin-top: 12px; max-width: 360px; }
.cf-you input { width: 100%; }
.mini-compare input { width: 100%; }
@media (min-width: 900px) {
  .site-nav ul { flex-wrap: wrap; overflow: visible; }
}
