/* Hypertext Wiki — AntJanus as a personal encyclopedia.
   Links are the interface: every internal link previews on hover or focus,
   sidenotes live in the margin, and each page carries its own "what links here". */

:root {
  --ground: #f3f2ee;
  --paper: #fffefb;
  --paper-2: #f7f6f1;
  --ink: #17191c;
  --text: #2a2d31;
  --muted: #595e66;
  --rule: #dcd8ce;
  --rule-strong: #a9a495;
  --link: #2f5d8f;
  --link-visited: #6b4c8a;
  --link-red: #b3261e;
  --brand: #364f6a;
  --brand-soft: #e7edf3;
  --brand-ink: #ffffff;
  --note-bg: #fbf7ea;
  --note-rule: #c9a44a;
  --talk-bg: #eef3ee;
  --talk-rule: #4d7a5c;
  --hl: #fff1b8;
  --code-bg: #1d2127;
  --code-ink: #e3e6ea;
  --code-dim: #9aa4b1;
  --code-key: #9ec3ec;
  --code-str: #b9d98f;
  --code-com: #9aa4b1;
  --shadow: 0 10px 30px rgba(20, 24, 30, .16), 0 2px 6px rgba(20, 24, 30, .08);
  --focus: #1f6fd6;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --measure: 40rem;
  --notes: 15rem;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #101215; --paper: #171a1e; --paper-2: #1d2126; --ink: #eeece6; --text: #d8d6d0; --muted: #a4a9b0;
    --rule: #2f343b; --rule-strong: #4c535c; --link: #8fb6e3; --link-visited: #c6a8e6; --link-red: #ff8f85;
    --brand: #5d8ab4; --brand-soft: #1f2a36; --brand-ink: #0c1117; --note-bg: #221f16; --note-rule: #b8923a;
    --talk-bg: #17231b; --talk-rule: #6fae84; --hl: #4a3f12; --code-bg: #0c0e11;
    --shadow: 0 12px 34px rgba(0, 0, 0, .55), 0 2px 6px rgba(0, 0, 0, .4); --focus: #8fc1ff; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ground: #101215; --paper: #171a1e; --paper-2: #1d2126; --ink: #eeece6; --text: #d8d6d0; --muted: #a4a9b0;
  --rule: #2f343b; --rule-strong: #4c535c; --link: #8fb6e3; --link-visited: #c6a8e6; --link-red: #ff8f85;
  --brand: #5d8ab4; --brand-soft: #1f2a36; --brand-ink: #0c1117; --note-bg: #221f16; --note-rule: #b8923a;
  --talk-bg: #17231b; --talk-rule: #6fae84; --hl: #4a3f12; --code-bg: #0c0e11;
  --shadow: 0 12px 34px rgba(0, 0, 0, .55), 0 2px 6px rgba(0, 0, 0, .4); --focus: #8fc1ff; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 1rem; }
body {
  margin: 0; background: var(--ground); color: var(--text);
  font: 400 1.0625rem/1.65 var(--serif); font-optical-sizing: auto;
  overflow-x: hidden;
}
img { max-width: 100%; height: auto; display: block; }
h1, h2, h3, h4 { color: var(--ink); font-family: var(--serif); line-height: 1.2; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: .18em; }
a:visited { color: var(--link-visited); }
.side a:visited, .tabs a:visited, .foot a:visited { color: var(--link); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: .5rem; top: -4rem; background: var(--paper); padding: .6rem 1rem; z-index: 50; font-family: var(--sans); }
.skip:focus { top: .5rem; }
code, kbd { font-family: var(--mono); font-size: .88em; background: var(--paper-2); border: 1px solid var(--rule); border-radius: 3px; padding: .05em .3em; }

/* External and typed links: Gwern-style link icons, set by attribute so authors never add them */
.prose a[href^="http"]::after, .ext::after {
  content: "↗"; font-family: var(--sans); font-size: .72em; margin-left: .12em; vertical-align: .35em; color: var(--muted);
}
.prose a[href*="github.com"]::after { content: "GH"; font-size: .62em; letter-spacing: .02em; font-weight: 600; }
.prose a[href*="youtube.com"]::after { content: "▶"; font-size: .62em; }
a[data-p] { text-decoration: underline dotted; text-decoration-color: color-mix(in srgb, currentColor 45%, transparent); text-underline-offset: .2em; text-decoration-thickness: 1px; }
a[data-p]:hover { text-decoration: underline solid; }
.side a[data-p], .tabs a[data-p] { text-decoration: none; }
a.red, a.red:visited { color: var(--link-red); }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 14.5rem minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; align-self: start; height: 100vh; overflow-y: auto;
  padding: 1.25rem 1rem 2rem 1.25rem; font-family: var(--sans); font-size: 1rem;
}
.side-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.brand { display: flex; flex-direction: column; align-items: center; gap: .35rem; color: var(--ink); text-align: center; width: 100%; padding: .25rem 0 1rem; }
.brand:hover { text-decoration: none; }
.brand:visited { color: var(--ink); }
.brand-mark { width: 4.25rem; height: 4.25rem; color: var(--brand); }
.brand-words { display: flex; flex-direction: column; }
.brand-name { font-family: var(--serif); font-size: 1.45rem; font-weight: 600; letter-spacing: .01em; }
.brand-sub { font-family: var(--serif); font-style: italic; color: var(--muted); font-size: .9rem; }
.menu-btn { display: none; }
.side-h { font-family: var(--sans); font-size: .8125rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 1.4rem 0 .4rem; padding-bottom: .3rem; border-bottom: 1px solid var(--rule); }
.side ul { list-style: none; margin: 0; padding: 0; }
.side li a { display: block; padding: .28rem .5rem; border-radius: 4px; color: var(--link); }
.side li a:hover { background: var(--paper); text-decoration: none; }
.side li a[aria-current="page"] { color: var(--ink); font-weight: 600; background: var(--paper); box-shadow: inset 3px 0 0 var(--brand); }
.search { display: flex; margin-top: .25rem; }
.search input { flex: 1; min-width: 0; font: inherit; font-size: 1rem; padding: .5rem .6rem; border: 1px solid var(--rule-strong); border-right: 0; border-radius: 4px 0 0 4px; background: var(--paper); color: var(--ink); }
.search button, .nl-row button, .btn {
  font: 600 .95rem var(--sans); padding: .5rem .8rem; min-height: 2.75rem; border: 1px solid var(--brand); background: var(--brand); color: var(--brand-ink); border-radius: 0 4px 4px 0; cursor: pointer;
}
.search button:hover, .nl-row button:hover, .btn:hover { filter: brightness(1.12); }
.pref-row { display: flex; flex-direction: column; gap: .35rem; margin: .5rem 0 .8rem; color: var(--text); font-size: .9375rem; }
.seg { display: flex; border: 1px solid var(--rule-strong); border-radius: 4px; overflow: hidden; }
.seg button { flex: 1; font: 500 .875rem var(--sans); padding: .45rem .2rem; min-height: 2.5rem; background: var(--paper); color: var(--text); border: 0; border-left: 1px solid var(--rule); cursor: pointer; }
.seg button:first-child { border-left: 0; }
.seg button[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); font-weight: 600; }

.main { min-width: 0; padding: 1.25rem 1.5rem 0 0; }
.page {
  background: var(--paper); border: 1px solid var(--rule); border-top: 0; border-radius: 0 0 6px 6px;
  padding: 1.5rem clamp(1.25rem, 3vw, 2.75rem) 3rem;
}

/* ---------- Page tabs (Article / Talk ... Read / Source / History) ---------- */
.tabs { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; font-family: var(--sans); font-size: .9375rem; border-bottom: 1px solid var(--rule); }
.tabs ul { display: flex; list-style: none; margin: 0; padding: 0; gap: .15rem; flex-wrap: wrap; }
.tabs a { display: block; padding: .55rem .9rem; border: 1px solid transparent; border-bottom: 0; border-radius: 5px 5px 0 0; color: var(--link); margin-bottom: -1px; }
.tabs a:hover { background: var(--paper-2); text-decoration: none; }
.tabs a[aria-current] { background: var(--paper); border-color: var(--rule); color: var(--ink); font-weight: 600; }

/* ---------- Headings and page furniture ---------- */
.first-heading { font-size: clamp(2rem, 1.4rem + 2.2vw, 2.85rem); font-weight: 600; margin: .2rem 0 0; padding-bottom: .35rem; border-bottom: 1px solid var(--rule-strong); letter-spacing: -.005em; }
.from { font-style: italic; color: var(--muted); margin: .45rem 0 1rem; font-size: 1rem; }
.hatnote { font-style: italic; color: var(--muted); padding-left: 1.6rem; margin: 0 0 1rem; }
.prose h2 { font-size: 1.65rem; font-weight: 600; margin: 2.2rem 0 .8rem; padding-bottom: .25rem; border-bottom: 1px solid var(--rule); }
.prose h3 { font-size: 1.25rem; font-weight: 700; margin: 1.6rem 0 .5rem; }
.prose p, .prose li { max-width: var(--measure); }
.prose p { margin: 0 0 1.05rem; }
.lead { font-size: 1.1875rem; }
.edit { font: 400 .875rem var(--sans); color: var(--muted); margin-left: .6rem; }
.count { color: var(--muted); font-weight: 400; font-size: .75em; }
.smallcaps { font-variant: small-caps; letter-spacing: .03em; }
.muted { color: var(--muted); }

/* Contents box (Wikipedia #toc) */
.toc { display: inline-block; background: var(--paper-2); border: 1px solid var(--rule); padding: .8rem 1.2rem .9rem; margin: .5rem 0 1.5rem; font-family: var(--sans); font-size: .9375rem; min-width: 15rem; max-width: 100%; }
.toc-title { font-weight: 600; text-align: center; margin: 0 0 .3rem; font-size: 1rem; color: var(--ink); }
.toc ol { margin: 0; padding-left: 1.4rem; counter-reset: toc; }
.toc li { margin: .15rem 0; }

/* Infobox */
.infobox {
  float: right; clear: right; width: 20rem; margin: .2rem 0 1.4rem 1.8rem; background: var(--paper-2);
  border: 1px solid var(--rule-strong); font-family: var(--sans); font-size: .9375rem; line-height: 1.45;
}
.infobox caption, .infobox .ib-title { display: block; background: var(--brand-soft); color: var(--ink); font: 600 1.15rem var(--serif); padding: .55rem .8rem; text-align: center; border-bottom: 1px solid var(--rule-strong); }
.infobox figure { margin: 0; padding: .6rem; border-bottom: 1px solid var(--rule); }
.infobox figcaption { font-size: .875rem; color: var(--muted); padding-top: .4rem; text-align: center; }
.infobox dl { margin: 0; display: grid; grid-template-columns: 7.5rem 1fr; }
.infobox dt, .infobox dd { padding: .42rem .7rem; border-top: 1px solid var(--rule); margin: 0; }
.infobox dt { font-weight: 600; color: var(--ink); }
.infobox dd { min-width: 0; overflow-wrap: anywhere; }
.infobox dl > :nth-child(-n+2) { border-top: 0; }
.infobox .ib-sec { grid-column: 1 / -1; background: var(--brand-soft); color: var(--ink); font-weight: 600; text-align: center; padding: .35rem; border-top: 1px solid var(--rule-strong); }

/* Thumbnails (framed wiki images) */
.thumb { margin: .3rem 0 1.2rem 1.6rem; float: right; clear: right; width: 17rem; background: var(--paper-2); border: 1px solid var(--rule); padding: .4rem; font-family: var(--sans); font-size: .875rem; color: var(--muted); }
.thumb img { width: 100%; background: var(--rule); }
.thumb figcaption { padding: .4rem .15rem .1rem; line-height: 1.4; }
.thumb.left { float: left; margin: .3rem 1.6rem 1.2rem 0; }
.clear { clear: both; }

/* Callouts: note / why / talk / notice */
.ambox { display: flex; gap: .9rem; align-items: flex-start; border: 1px solid var(--rule); border-left: 6px solid var(--brand); background: var(--paper-2); padding: .8rem 1rem; margin: 0 0 1.3rem; max-width: 46rem; font-family: var(--sans); font-size: 1rem; line-height: 1.55; }
.ambox .ambox-icon { flex: none; width: 2rem; height: 2rem; border-radius: 50%; display: grid; place-items: center; background: var(--brand); color: var(--brand-ink); font: 700 1.05rem var(--serif); }
.ambox p { margin: 0; }
.ambox.warm { border-left-color: var(--note-rule); background: var(--note-bg); }
.ambox.warm .ambox-icon { background: var(--note-rule); color: #1c1606; }
.ambox.talk { border-left-color: var(--talk-rule); background: var(--talk-bg); }
.ambox.talk .ambox-icon { background: var(--talk-rule); color: #07130b; }

/* ---------- Sidenotes (Tufte checkbox technique, Gwern layout) ---------- */
.with-notes { position: relative; padding-right: calc(var(--notes) + 2.5rem); }
.sn-toggle { display: none; }
.sn-ref { counter-increment: none; font: 600 .75em var(--sans); vertical-align: super; line-height: 0; color: var(--link); cursor: pointer; padding: 0 .1em; }
.sn-ref::before { content: "[" attr(data-n) "]"; }
.sidenote, .marginnote {
  float: right; clear: right; width: var(--notes); margin-right: calc(-1 * (var(--notes) + 2.5rem));
  margin-top: .2rem; margin-bottom: 1rem; font: 400 .9375rem/1.5 var(--sans); color: var(--text);
  border-left: 3px solid var(--note-rule); padding: .15rem 0 .15rem .8rem; position: relative;
}
.sidenote::before { content: attr(data-n) ". "; font-weight: 600; color: var(--ink); }
.sidenote strong, .marginnote strong { color: var(--ink); }
.marginnote.talk { border-left-color: var(--talk-rule); }
.sidenote.is-lit, .marginnote.is-lit { background: var(--hl); }
.sidenote-label { display: block; font-weight: 600; font-size: .8125rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: .15rem; }

/* ---------- Tables ---------- */
.wikitable { border-collapse: collapse; background: var(--paper-2); font-family: var(--sans); font-size: 1rem; line-height: 1.45; margin: .5rem 0 1.5rem; width: 100%; }
.wikitable th, .wikitable td { border: 1px solid var(--rule-strong); padding: .5rem .7rem; text-align: left; vertical-align: top; }
.wikitable th { background: var(--brand-soft); color: var(--ink); font-weight: 600; }
.wikitable td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.wikitable caption { font: 600 1.05rem var(--serif); color: var(--ink); padding-bottom: .4rem; text-align: left; }
.sort-btn { font: inherit; font-weight: 600; color: var(--ink); background: none; border: 0; padding: 0; cursor: pointer; display: inline-flex; gap: .35rem; align-items: center; min-height: 1.75rem; }
.sort-btn::after { content: "⇅"; color: var(--muted); font-size: .9em; }
th[aria-sort="ascending"] .sort-btn::after { content: "▲"; color: var(--ink); }
th[aria-sort="descending"] .sort-btn::after { content: "▼"; color: var(--ink); }
.table-wrap { overflow-x: auto; max-width: 100%; }
.tags-cell { color: var(--muted); }

/* ---------- Navbox (bottom-of-page link grid) ---------- */
.navbox { border: 1px solid var(--rule-strong); margin: 2rem 0 0; font-family: var(--sans); font-size: .9375rem; background: var(--paper); clear: both; }
.navbox-title { background: var(--brand-soft); color: var(--ink); text-align: center; font-weight: 600; padding: .45rem; font-size: 1rem; }
.navbox-row { display: grid; grid-template-columns: 11rem 1fr; border-top: 1px solid var(--rule); }
.navbox-row > :first-child { background: var(--paper-2); font-weight: 600; color: var(--ink); padding: .45rem .7rem; text-align: right; border-right: 1px solid var(--rule); }
.navbox-row > :last-child { padding: .45rem .7rem; }
.navbox-row a + a::before { content: " · "; color: var(--muted); text-decoration: none; display: inline-block; padding: 0 .3rem; }
.navbox a { line-height: 1.8; }

/* Categories bar */
.catlinks { clear: both; border: 1px solid var(--rule); background: var(--paper-2); padding: .55rem .8rem; margin-top: 1.8rem; font-family: var(--sans); font-size: .9375rem; }
.catlinks a + a::before { content: " | "; color: var(--muted); padding: 0 .25rem; display: inline-block; }
.catlinks strong { color: var(--ink); margin-right: .4rem; }

/* What links here (backlinks) */
.backlinks { margin-top: 2rem; border-top: 3px double var(--rule-strong); padding-top: .6rem; clear: both; }
.backlinks h2 { border: 0; font-size: 1.3rem; margin: .4rem 0 .6rem; }
.backlinks ul { list-style: none; padding: 0; margin: 0; display: grid; gap: .75rem; }
.backlinks li { max-width: 46rem; font-family: var(--sans); font-size: 1rem; line-height: 1.55; }
.backlinks .ctx { display: block; color: var(--muted); font-family: var(--serif); font-style: italic; }
.backlinks mark { background: var(--hl); color: inherit; padding: 0 .1em; }

/* ---------- Main page portal ---------- */
.welcome { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1.5rem; align-items: center; border: 1px solid var(--rule); background: var(--paper-2); padding: 1.3rem 1.5rem; margin-bottom: 1.5rem; }
.welcome h1 { font-size: clamp(1.9rem, 1.3rem + 2vw, 2.7rem); margin: 0 0 .5rem; font-weight: 600; }
.welcome p { margin: 0; max-width: 42rem; }
.welcome-stats { font: 500 1rem var(--sans); color: var(--muted); margin-top: .7rem !important; }
.welcome-stats b { color: var(--ink); font-weight: 600; }
.welcome-cta { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; align-items: center; margin-top: 1rem; font-family: var(--sans); }
.btn { border-radius: 4px; display: inline-flex; align-items: center; text-decoration: none; }
a.btn, a.btn:visited { color: var(--brand-ink); }
a.btn:hover { text-decoration: none; }
.cta-2 { font-weight: 600; text-decoration: underline; text-underline-offset: .2em; }
.cta-3 { color: var(--muted); }
.cta-3:visited { color: var(--muted); }
.portal-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 1.25rem; }
.mp-box { border: 1px solid var(--rule-strong); background: var(--paper); margin-bottom: 1.25rem; }
.mp-box > h2 { margin: 0; font-size: 1.2rem; padding: .45rem .85rem; background: var(--brand-soft); border-bottom: 1px solid var(--rule-strong); font-weight: 600; }
.mp-box.alt > h2 { background: var(--talk-bg); }
.mp-box.warm > h2 { background: var(--note-bg); }
.mp-body { padding: .9rem 1rem 1rem; }
.mp-body > :last-child { margin-bottom: 0; }
.mp-body p { margin: 0 0 .8rem; }
.mp-body ul { margin: 0 0 .6rem; padding-left: 1.2rem; }
.mp-body li { margin: .35rem 0; }
.mp-more { font-family: var(--sans); font-size: .9375rem; text-align: right; margin: .5rem 0 0 !important; }
.fa-img { float: left; width: 11rem; margin: .25rem 1rem .5rem 0; border: 1px solid var(--rule); }
.li-date { color: var(--muted); font-family: var(--sans); font-size: .9375rem; white-space: nowrap; }
.li-desc { display: block; color: var(--muted); font-size: 1rem; line-height: 1.5; }
.dyk-img { float: right; width: 8.5rem; margin: 0 0 .5rem 1rem; border: 1px solid var(--rule); }

/* Collection columns on the Writing index */
.coll-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin: 1rem 0 2rem; clear: both; }
.coll-card { border: 1px solid var(--rule-strong); background: var(--paper-2); padding: .9rem 1rem; }
.coll-card h3 { margin: 0 0 .3rem; font-size: 1.2rem; }
.coll-card p { font-size: 1rem; margin: 0 0 .5rem; }
.coll-card ul { margin: 0; padding-left: 1.1rem; }
.filter-bar { display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: center; font-family: var(--sans); margin: .8rem 0; }
.filter-bar input[type="search"] { font: inherit; font-size: 1rem; padding: .55rem .7rem; min-height: 2.75rem; border: 1px solid var(--rule-strong); border-radius: 4px; background: var(--paper); color: var(--ink); width: min(28rem, 100%); }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { font: 500 .9375rem var(--sans); padding: .4rem .8rem; min-height: 2.5rem; border: 1px solid var(--rule-strong); background: var(--paper); color: var(--text); border-radius: 999px; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
.result-line { font-family: var(--sans); color: var(--muted); margin: .3rem 0 .6rem; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: .35rem .9rem; font-family: var(--sans); }

/* ---------- Pattern category page ---------- */
.cat-group h2 { font-size: 1.4rem; }
.pat-list { list-style: none; padding: 0; margin: 0; columns: 2 22rem; column-gap: 2.5rem; }
.pat { break-inside: avoid; padding: .55rem 0 .75rem; border-bottom: 1px dotted var(--rule); }
.pat > a { font-weight: 600; font-size: 1.1rem; }
.pat-desc { display: block; font-size: 1rem; line-height: 1.5; }
.pat-meta { display: block; font: 400 .875rem var(--sans); color: var(--muted); margin-top: .15rem; }
.badge { font: 600 .8125rem var(--sans); padding: .05rem .45rem; border-radius: 3px; border: 1px solid var(--rule-strong); margin-left: .35rem; vertical-align: .12em; color: var(--ink); }
.badge-new { background: var(--talk-bg); border-color: var(--talk-rule); }
.badge-updated { background: var(--note-bg); border-color: var(--note-rule); }
.three-ways { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--rule-strong); margin: 1.2rem 0; background: var(--paper-2); }
.three-ways > div { padding: .8rem 1rem; border-left: 1px solid var(--rule); }
.three-ways > div:first-child { border-left: 0; }
.three-ways h3 { margin: 0 0 .25rem; font-size: 1.1rem; }
.three-ways p { margin: 0; font-size: 1rem; }
.empty-state { display: none; border: 1px dashed var(--rule-strong); padding: 1rem 1.2rem; font-family: var(--sans); }
.empty-state.is-shown { display: block; }

/* ---------- Pattern detail ---------- */
.pane-box { border: 1px solid var(--rule-strong); margin: 1rem 0 1.5rem; background: var(--paper); clear: both; }
.pane-bar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem; border-bottom: 1px solid var(--rule-strong); background: var(--paper-2); font-family: var(--sans); padding: 0 .4rem; }
.pane-tabs { display: flex; flex-wrap: wrap; }
.pane-tabs button { font: 500 .9375rem var(--sans); background: none; border: 0; border-bottom: 3px solid transparent; padding: .7rem .8rem .55rem; min-height: 2.75rem; color: var(--link); cursor: pointer; }
.pane-tabs button[aria-selected="true"] { color: var(--ink); font-weight: 600; border-bottom-color: var(--brand); }
.pane-actions { display: flex; gap: .4rem; align-items: center; padding: .3rem 0; }
.pane-actions button { font: 500 .875rem var(--sans); padding: .4rem .7rem; min-height: 2.5rem; border: 1px solid var(--rule-strong); background: var(--paper); color: var(--ink); border-radius: 4px; cursor: pointer; }
.pane { padding: 1.2rem; }
.pane[hidden] { display: none; }
.pane pre { margin: 0; }
.pane-note { font-family: var(--sans); font-size: .9375rem; color: var(--muted); margin: 0 0 .8rem; }
.prompt-text { max-width: 44rem; }
.prompt-text p { margin: 0 0 1rem; }
.uses { columns: 2 16rem; margin: .3rem 0 1rem; }
.uses li { break-inside: avoid; }

/* Hairline stat strip demo (fixes the 5-column overflow on the live site) */
.hss-demo { --hss-surface: var(--paper); font-family: var(--sans); }
.hss-cap { font-size: .9375rem; color: var(--muted); margin: 0 0 .6rem; }
.hss-strip { display: grid; gap: 1px; background: var(--rule-strong); border: 1px solid var(--rule-strong); border-radius: 10px; overflow: hidden; grid-template-columns: 1fr; margin-bottom: 1.4rem; }
@container (min-width: 17rem) { .hss-strip { grid-template-columns: repeat(2, 1fr); } }
@container (min-width: 42rem) { .hss-strip.four { grid-template-columns: repeat(4, 1fr); } .hss-strip.five { grid-template-columns: repeat(3, 1fr); } }
@container (min-width: 52rem) { .hss-strip.five { grid-template-columns: repeat(5, 1fr); } }
.hss-wrap { container-type: inline-size; }
.hss-tile { background: var(--hss-surface); padding: .8rem 1rem; display: flex; flex-direction: column; gap: .15rem; min-width: 0; text-align: left; border: 0; font: inherit; color: var(--text); }
button.hss-tile { cursor: pointer; }
button.hss-tile:hover { background: var(--paper-2); }
.hss-tile[aria-pressed="true"] { background: color-mix(in srgb, var(--brand) 16%, var(--paper)); box-shadow: inset 0 -3px 0 var(--brand); }
.hss-label { font: 500 .8125rem var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); overflow-wrap: anywhere; }
.hss-fig { font-size: 1.6rem; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; line-height: 1.2; }
.hss-fig.missing { color: var(--muted); }
.hss-sub { font-size: .875rem; color: var(--muted); }
.hss-list { list-style: none; padding: 0; margin: 0; border: 1px solid var(--rule); border-radius: 8px; }
.hss-list li { display: flex; justify-content: space-between; gap: 1rem; padding: .55rem .9rem; border-top: 1px solid var(--rule); font-size: 1rem; }
.hss-list li:first-child { border-top: 0; }
.hss-list li[hidden] { display: none; }
.hss-status { font-size: .9375rem; color: var(--muted); margin: .6rem 0 0; }

/* ---------- Code ---------- */
.code { background: var(--code-bg); color: var(--code-ink); border-radius: 6px; padding: 0; margin: 0 0 1.4rem; overflow: hidden; max-width: calc(var(--measure) + 6rem); position: relative; }
.code .code-bar { display: flex; justify-content: space-between; align-items: center; padding: .35rem .5rem .35rem .9rem; font: 500 .8125rem var(--mono); color: var(--code-dim); border-bottom: 1px solid rgba(255, 255, 255, .1); letter-spacing: .06em; }
.code .copy { font: 500 .8125rem var(--sans); background: transparent; color: var(--code-ink); border: 1px solid rgba(255, 255, 255, .25); border-radius: 4px; padding: .3rem .7rem; min-height: 2.25rem; cursor: pointer; }
.code pre { margin: 0; }
.code code { display: block; background: none; border: 0; border-radius: 0; padding: .9rem 1.1rem 1rem; overflow-x: auto; font-size: .9375rem; line-height: 1.6; color: inherit; tab-size: 2; }
.tok-k { color: var(--code-key); }
.tok-s { color: var(--code-str); }
.tok-c { color: var(--code-com); font-style: italic; }

/* ---------- Article specific ---------- */
.art-hero { margin: 0 0 1.2rem; max-width: calc(var(--measure) + 0rem); }
.art-hero img { width: 100%; aspect-ratio: 16 / 7; object-fit: cover; border: 1px solid var(--rule); background: var(--brand-soft); }
.art-hero figcaption { font: .875rem var(--sans); color: var(--muted); padding-top: .35rem; }
.meta-line { font-family: var(--sans); font-size: .9375rem; color: var(--muted); margin: 0 0 1rem; }
.art-layout { display: grid; grid-template-columns: 13rem minmax(0, 1fr); gap: 2rem; }
.art-toc { position: sticky; top: 1rem; align-self: start; font-family: var(--sans); font-size: .9375rem; max-height: calc(100vh - 2rem); overflow: auto; }
.art-toc ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--rule); }
.art-toc a { display: block; padding: .3rem .7rem; color: var(--link); margin-left: -1px; border-left: 2px solid transparent; }
.art-toc a[aria-current="true"] { color: var(--ink); font-weight: 600; border-left-color: var(--brand); }
.art-toc .toc-title { text-align: left; }
.progress { position: fixed; top: 0; left: 0; height: 3px; width: 0; background: var(--brand); z-index: 40; }
.share-row { display: flex; flex-wrap: wrap; gap: .5rem; font-family: var(--sans); margin: .5rem 0 1rem; }
.share-row a, .share-row button { font: 500 .9375rem var(--sans); padding: .45rem .9rem; min-height: 2.75rem; display: inline-flex; align-items: center; border: 1px solid var(--rule-strong); background: var(--paper); color: var(--link); border-radius: 4px; cursor: pointer; }
.share-row a::after { content: none !important; }
.nl-card { border: 1px solid var(--rule-strong); background: var(--paper-2); padding: 1rem 1.2rem; max-width: 46rem; margin: 1.5rem 0; }
.nl-card h2 { border: 0 !important; margin: 0 0 .3rem !important; font-size: 1.3rem !important; }
.nl-card p { margin: 0 0 .7rem; }

/* ---------- Projects list ---------- */
.proj-feature { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 1.5rem; border: 1px solid var(--rule-strong); background: var(--paper-2); padding: 1.1rem; margin: 1rem 0 1.5rem; }
.proj-feature img { border: 1px solid var(--rule); width: 100%; }
.proj-feature h3 { margin: 0 0 .4rem; font-size: 1.45rem; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--rule-strong); border: 1px solid var(--rule-strong); margin: .8rem 0; font-family: var(--sans); }
.stat-row div { background: var(--paper); padding: .5rem .7rem; }
.stat-row b { display: block; font: 600 1.45rem var(--serif); color: var(--ink); }
.stat-row span { font: 500 .8125rem var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.proj-entry { display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: 1.2rem; padding: 1rem 0; border-top: 1px solid var(--rule); }
.proj-entry img, .proj-entry .ph { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border: 1px solid var(--rule); background: var(--code-bg); }
.proj-entry h3 { margin: 0 0 .25rem; font-size: 1.25rem; }
.proj-entry p { margin: 0 0 .4rem; }
.tech { font: 500 .875rem var(--mono); color: var(--muted); }
.ph { display: grid; place-items: center; color: #9fb4c9; font: 500 .875rem var(--mono); text-align: center; padding: .5rem; }

/* ---------- About ---------- */
.career-bar { display: flex; border: 1px solid var(--rule-strong); margin: .6rem 0 1rem; font-family: var(--sans); font-size: .875rem; overflow-x: auto; }
.career-bar span { flex: var(--w) 0 auto; padding: .45rem .5rem; border-left: 1px solid var(--rule); background: var(--paper-2); min-width: 6.5rem; line-height: 1.3; }
.career-bar span:first-child { border-left: 0; background: var(--brand-soft); font-weight: 600; }
.career-bar b { display: block; color: var(--ink); }
details.collapsible { border: 1px solid var(--rule); background: var(--paper-2); margin: .8rem 0 1.4rem; max-width: 50rem; }
details.collapsible > summary { cursor: pointer; font: 600 1rem var(--sans); padding: .7rem 1rem; color: var(--link); min-height: 2.75rem; }
details.collapsible[open] > summary { border-bottom: 1px solid var(--rule); }
details.collapsible > div { padding: .6rem 1rem 1rem; }
.quote-list { list-style: none; padding: 0; margin: 0; counter-reset: proverb; }
.quote-list li { counter-increment: proverb; font-style: italic; font-size: 1.2rem; padding: .5rem 0 .5rem 2.4rem; position: relative; border-bottom: 1px dotted var(--rule); max-width: 40rem; }
.quote-list li::before { content: counter(proverb); position: absolute; left: 0; top: .5rem; font: 600 .95rem var(--sans); font-style: normal; color: var(--muted); width: 1.7rem; text-align: right; }
.engage { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin: 1rem 0; }
.engage > div { border: 1px solid var(--rule-strong); background: var(--paper-2); padding: .9rem 1rem; }
.engage h3 { margin: 0 0 .3rem; font-size: 1.15rem; }
.engage p { margin: 0 0 .4rem; font-size: 1rem; }

/* ---------- Footer ---------- */
.foot { font-family: var(--sans); font-size: .9375rem; padding: 2rem 0 2.5rem; color: var(--text); }
.foot-grid { display: grid; grid-template-columns: 1.3fr 1fr 1fr 1.4fr; gap: 1.5rem; border-top: 1px solid var(--rule-strong); padding-top: 1.4rem; }
.foot-brand { font: 600 1.25rem var(--serif); color: var(--ink); margin: 0 0 .3rem; }
.foot-h { font-size: .8125rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 .5rem; font-family: var(--sans); }
.foot ul { list-style: none; padding: 0; margin: 0; }
.foot li { margin: .2rem 0; }
.foot p { margin: 0 0 .5rem; }
.nl-row { display: flex; }
.nl-row input { flex: 1; min-width: 0; font: inherit; padding: .5rem .6rem; border: 1px solid var(--rule-strong); border-right: 0; border-radius: 4px 0 0 4px; background: var(--paper); color: var(--ink); min-height: 2.75rem; }
.nl-status { min-height: 1.4em; color: var(--ink); font-weight: 500; }
.foot-legal { color: var(--muted); margin-top: 1.4rem; }

/* ---------- Hover preview popups ---------- */
#popups { position: absolute; top: 0; left: 0; z-index: 60; }
.popup {
  position: absolute; width: min(26rem, calc(100vw - 1.5rem)); background: var(--paper); color: var(--text);
  border: 1px solid var(--rule-strong); border-radius: 6px; box-shadow: var(--shadow); overflow: hidden;
  font-family: var(--sans); font-size: 1rem; line-height: 1.5; opacity: 0; transform: translateY(4px);
  transition: opacity .15s ease, transform .15s ease;
}
.popup.is-in { opacity: 1; transform: none; }
.popup img { width: 100%; aspect-ratio: 16 / 7; object-fit: cover; border-bottom: 1px solid var(--rule); background: var(--brand-soft); }
.popup-body { padding: .75rem 1rem .85rem; }
.popup-kind { font: 500 .8125rem var(--mono); letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.popup-title { font: 600 1.2rem/1.25 var(--serif); color: var(--ink); margin: .15rem 0 .35rem; }
.popup-title a { color: inherit; }
.popup-desc { margin: 0; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.popup-see { margin: .6rem 0 0; padding-top: .5rem; border-top: 1px solid var(--rule); font-size: .9375rem; color: var(--muted); }
.popup-see a { margin-right: .2rem; }
.popup-see a + a::before { content: "· "; color: var(--muted); }
.popup.red .popup-title { color: var(--link-red); }
.popup-depth { float: right; font: 500 .8125rem var(--mono); color: var(--muted); }

/* ---------- Responsive ---------- */
@media (max-width: 1320px) {
  .with-notes { padding-right: 0; }
  .sidenote, .marginnote { display: none; float: none; width: auto; margin: .6rem 0 1rem; background: var(--note-bg); padding: .6rem .8rem; border-left-width: 4px; max-width: var(--measure); }
  .marginnote.talk { background: var(--talk-bg); }
  .sn-toggle:checked + .sidenote, .sn-toggle:checked + .marginnote { display: block; }
  .sn-ref { padding: .3em .2em; }
  .art-layout { grid-template-columns: minmax(0, 1fr); }
  .art-toc { display: none; }
}
@media (max-width: 1100px) {
  .portal-grid { grid-template-columns: minmax(0, 1fr); }
  .coll-grid, .engage { grid-template-columns: minmax(0, 1fr); }
  .foot-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: sticky; top: 0; z-index: 30; height: auto; max-height: 100vh; padding: .5rem 1rem; background: var(--ground); border-bottom: 1px solid var(--rule-strong); }
  .brand { flex-direction: row; text-align: left; padding: 0; width: auto; gap: .6rem; }
  .brand-mark { width: 2.5rem; height: 2.5rem; }
  .brand-name { font-size: 1.2rem; }
  .brand-sub { font-size: .8125rem; }
  .menu-btn { display: inline-flex; align-items: center; gap: .4rem; font: 600 .9375rem var(--sans); min-height: 2.75rem; padding: .4rem .8rem; border: 1px solid var(--rule-strong); background: var(--paper); color: var(--ink); border-radius: 4px; cursor: pointer; }
  .menu-btn svg { width: 1.25rem; height: 1.25rem; }
  .js .side-panel { display: none; }
  .js .side[data-open="true"] .side-panel { display: block; padding-bottom: 1rem; }
  .side[data-open="true"] { overflow-y: auto; }
  .main { padding: 0 1rem; }
  .page { border-radius: 0; padding: 1rem 1rem 2rem; margin: 0 -1rem; border-left: 0; border-right: 0; }
  .tabs { margin: 0 -1rem; padding: .5rem .5rem 0; overflow-x: auto; }
  .tabs ul { flex-wrap: nowrap; }
  .tabs a { white-space: nowrap; padding: .55rem .7rem; }
  .tabs .tabs-right { display: none; }
  .infobox, .thumb, .thumb.left { float: none; width: 100%; margin: 0 0 1.2rem; }
  .welcome { grid-template-columns: minmax(0, 1fr); }
  .welcome figure { order: -1; }
  .proj-feature { grid-template-columns: minmax(0, 1fr); }
  .three-ways { grid-template-columns: minmax(0, 1fr); }
  .three-ways > div { border-left: 0; border-top: 1px solid var(--rule); }
  .three-ways > div:first-child { border-top: 0; }
}
@media (max-width: 600px) {
  body { font-size: 1.0625rem; }
  .proj-entry { grid-template-columns: minmax(0, 1fr); }
  .proj-entry img, .proj-entry .ph { max-width: 20rem; }
  .fa-img { float: none; width: 100%; margin: 0 0 .7rem; }
  .dyk-img { width: 6.5rem; }
  .navbox-row { grid-template-columns: minmax(0, 1fr); }
  .navbox-row > :first-child { text-align: left; border-right: 0; border-bottom: 1px solid var(--rule); }
  .foot-grid { grid-template-columns: minmax(0, 1fr); }
  .wikitable { font-size: .9375rem; }
  .tags-col, .tags-cell { display: none; }
  .brand-sub { display: none; }
}
@media (hover: none) {
  .popup { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ---------- Article: margin column holds the infobox and notes on wide screens ---------- */
.with-notes { max-width: calc(var(--measure) + var(--notes) + 2.5rem); }
.with-notes .code { max-width: var(--measure); }
.infobox .ib-sec { margin: 0; }
.side .art-toc { position: static; max-height: none; }
.side .art-toc ol { margin-bottom: .4rem; }
.side .art-toc a { border-radius: 0; }
.side .art-toc a:hover { background: var(--paper); text-decoration: none; }
.toc-inline { display: none; }
@media (min-width: 1321px) {
  .with-notes .infobox { width: var(--notes); margin: .2rem calc(-1 * (var(--notes) + 2.5rem)) 1.4rem 0; font-size: .9375rem; }
  .with-notes .infobox dl { grid-template-columns: 5.6rem 1fr; }
}
@media (max-width: 1320px) {
  .toc-inline { display: inline-block; }
}

/* Gallery, definition lists, sort control */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: .8rem; margin: .5rem 0 1.5rem; max-width: 60rem; }
.gallery figure { margin: 0; background: var(--paper-2); border: 1px solid var(--rule); padding: .4rem; font: .875rem var(--sans); color: var(--muted); }
.gallery img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; background: var(--code-bg); }
.gallery figcaption { padding-top: .35rem; }
dl.beyond { max-width: var(--measure); margin: 0 0 1.2rem; }
dl.beyond dt { font-weight: 700; color: var(--ink); margin-top: .7rem; }
dl.beyond dd { margin: .1rem 0 0 1.4rem; }
.sort-label { font-family: var(--sans); display: inline-flex; gap: .5rem; align-items: center; color: var(--text); }
.sort-label select { font: inherit; padding: .45rem .6rem; min-height: 2.75rem; border: 1px solid var(--rule-strong); border-radius: 4px; background: var(--paper); color: var(--ink); }
.tag-cloud a { white-space: nowrap; }
.welcome h1 { font-weight: 600; }
.pat[hidden], .cat-group[hidden], tr[hidden] { display: none; }
