*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
/* Layered backdrop on every theme: three light pools + a faded Bauhaus quarter-arc (Truchet) tiling masked to two corners. */
html { background: var(--paper); }
body {
  margin: 0; background: transparent; color: var(--ink);
  font: 400 1.0625rem/1.65 var(--font-body);
  -webkit-font-smoothing: antialiased;
  position: relative;
}
body::before, body::after { content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none; }
body::before {
  background:
    radial-gradient(48% 42% at 6% 0%, var(--pool-a), transparent 70%),
    radial-gradient(40% 46% at 100% 34%, var(--pool-b), transparent 70%),
    radial-gradient(50% 40% at 34% 104%, var(--pool-c), transparent 70%);
}
body::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='96' viewBox='0 0 96 96'%3E%3Cpath d='M24 0A24 24 0 0 1 0 24M48 24A24 24 0 0 0 24 48M72 0A24 24 0 0 0 96 24M48 24A24 24 0 0 1 72 48M24 48A24 24 0 0 0 48 72M0 72A24 24 0 0 1 24 96M72 48A24 24 0 0 1 48 72M96 72A24 24 0 0 0 72 96M12 0A12 12 0 0 1 0 12M48 36A12 12 0 0 0 36 48M84 0A12 12 0 0 0 96 12M48 36A12 12 0 0 1 60 48M36 48A12 12 0 0 0 48 60M0 84A12 12 0 0 1 12 96M60 48A12 12 0 0 1 48 60M96 84A12 12 0 0 0 84 96' fill='none' stroke='%2326102f' stroke-width='1.5'/%3E%3C/svg%3E");
  background-size: 96px 96px;
  opacity: var(--arc-op);
  -webkit-mask-image: radial-gradient(70% 62% at 0% 0%, #000 10%, transparent 72%), radial-gradient(64% 58% at 100% 100%, #000 10%, transparent 72%);
  mask-image: radial-gradient(70% 62% at 0% 0%, #000 10%, transparent 72%), radial-gradient(64% 58% at 100% 100%, #000 10%, transparent 72%);
}
:root[data-theme='dark'] body::after { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='96' viewBox='0 0 96 96'%3E%3Cpath d='M24 0A24 24 0 0 1 0 24M48 24A24 24 0 0 0 24 48M72 0A24 24 0 0 0 96 24M48 24A24 24 0 0 1 72 48M24 48A24 24 0 0 0 48 72M0 72A24 24 0 0 1 24 96M72 48A24 24 0 0 1 48 72M96 72A24 24 0 0 0 72 96M12 0A12 12 0 0 1 0 12M48 36A12 12 0 0 0 36 48M84 0A12 12 0 0 0 96 12M48 36A12 12 0 0 1 60 48M36 48A12 12 0 0 0 48 60M0 84A12 12 0 0 1 12 96M60 48A12 12 0 0 1 48 60M96 84A12 12 0 0 0 84 96' fill='none' stroke='%23fbe9e0' stroke-width='1.5'/%3E%3C/svg%3E"); }
.skip { position: absolute; left: 12px; top: -60px; z-index: 300; padding: 10px 16px; border: 2px solid var(--line); border-radius: 999px; background: var(--ink); color: var(--paper); font-weight: 700; text-decoration: none; }
.skip:focus { top: 10px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
body { overflow-x: clip; }
body.menu-open { overflow: hidden; }
img, svg { max-width: 100%; display: block; }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.04; letter-spacing: -0.02em; margin: 0; }
h1 { font-size: clamp(2.3rem, 6vw, 4.4rem); font-weight: 800; letter-spacing: -0.035em; }
h2 { font-size: clamp(1.7rem, 4vw, 2.6rem); font-weight: 700; }
h3 { font-size: 1.3rem; font-weight: 700; }
p { margin: 0 0 1em; }
:focus-visible { outline: 3px solid var(--cobalt); outline-offset: 3px; border-radius: 6px; }
.wrap { width: min(var(--wrap), 100% - var(--gut) * 2); margin-inline: auto; }
.mono { font-family: var(--font-mono); font-size: 0.78rem; letter-spacing: 0.04em; text-transform: uppercase; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.kicker { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; color: var(--muted); }
.kicker a { text-decoration: none; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--cobalt); display: inline-block; }
.lede { font-size: clamp(1.1rem, 2vw, 1.35rem); max-width: 40em; color: var(--muted); }
.hl { background: linear-gradient(transparent 58%, var(--peach) 58% 92%, transparent 92%); padding: 0 0.08em; }

/* header */
#top { position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 2px solid var(--line); }
.top-in { width: min(var(--wrap), 100% - var(--gut) * 2); margin-inline: auto; display: flex; align-items: center; gap: 10px; height: 64px; }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; font: 800 1.45rem var(--font-display); letter-spacing: -0.03em; margin-right: auto; }
.logo-mark { width: 40px; height: 24px; }
.logo span { white-space: nowrap; }
@media (max-width: 420px) { .logo { font-size: 1.15rem; gap: 7px; } .logo-mark { width: 32px; height: 20px; } }
.pill { display: inline-flex; align-items: center; gap: 8px; height: 42px; padding: 0 14px; border: 2px solid var(--line); border-radius: 999px; background: var(--card); font-weight: 500; transition: transform 0.15s, box-shadow 0.15s; }
.pill:hover { box-shadow: inset 0 -4px 0 var(--peach); }
.pill-dark:hover { box-shadow: inset 0 -4px 0 var(--cobalt); }
.pill[aria-pressed='true'] { background: var(--ink); color: var(--paper); }
.pill svg { width: 18px; height: 18px; }
.pill-dark { background: var(--ink); color: var(--paper); }
.pill kbd { font: 500 0.72rem var(--font-mono); border: 1.5px solid var(--soft); border-radius: 5px; padding: 0 5px; color: var(--muted); }
.search-pill { min-width: 190px; justify-content: flex-start; color: var(--muted); }
.search-pill kbd { margin-left: auto; }

/* full-screen index menu (modal dialog) */
.menu { position: fixed; inset: 0; z-index: 90; background: var(--paper); overflow-y: auto; animation: fade 0.18s ease; }
.menu::before { content: ''; position: fixed; inset: 0; z-index: -1; background: linear-gradient(118deg, transparent 0 58%, var(--cobalt) 58% 64%, var(--peach) 64% 65.2%, transparent 65.2%); opacity: 0.14; pointer-events: none; }
.menu-bar { width: min(var(--wrap), 100% - var(--gut) * 2); margin: 0 auto; height: 64px; display: flex; align-items: center; justify-content: space-between; border-bottom: 2px solid var(--line); }
.menu-bar .logo { margin: 0; }
.menu-in { width: min(var(--wrap), 100% - var(--gut) * 2); margin: 0 auto; padding: 22px 0 48px; display: grid; grid-template-columns: 1fr 300px; gap: 48px; }
.menu-links a[aria-current='page'] b { color: var(--cobalt); }
.menu-links a { display: grid; grid-template-columns: 54px 1fr; grid-template-rows: auto auto; align-items: baseline; padding: 14px 0; border-bottom: 2px solid var(--soft); text-decoration: none; transition: padding 0.2s; }
.menu-links a:hover { padding-left: 14px; }
.menu-links a:hover b { color: var(--cobalt); }
.menu-links span { grid-row: 1 / 3; color: var(--muted); }
.menu-links b { font: 800 clamp(1.8rem, 5vw, 3.2rem)/1.05 var(--font-display); letter-spacing: -0.03em; }
.menu-links em { font-style: normal; color: var(--muted); }
.menu-side { padding-top: 16px; }
.menu-topic { display: flex; align-items: center; gap: 10px; padding: 11px 14px; margin-bottom: 8px; border: 2px solid var(--line); border-radius: var(--r-sm); background: var(--card); text-decoration: none; font-weight: 500; }
.menu-topic i { width: 14px; height: 14px; border-radius: 50%; background: var(--tc); border: 2px solid var(--line); }
.menu-topic span { margin-left: auto; color: var(--muted); }
.menu-topic:hover { box-shadow: inset 6px 0 0 var(--tc); }

/* buttons, fields */
.btn { display: inline-flex; align-items: center; gap: 8px; height: 48px; padding: 0 22px; border: 2px solid var(--line); border-radius: 999px; background: var(--card); font-weight: 700; text-decoration: none; transition: transform 0.15s, box-shadow 0.15s; }
/* Bauhaus key: hover fills a heavy foot bar inside the button, no lift, no offset shadow */
.btn:hover { box-shadow: inset 0 -5px 0 var(--peach); }
.btn-pop:hover, .btn-ink:hover { box-shadow: inset 0 -5px 0 var(--cobalt); }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn svg { width: 18px; height: 18px; }
.btn-ink { background: var(--ink); color: var(--paper); }
.btn-pop { background: var(--peach); color: #26102f; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-sm { height: 36px; padding: 0 14px; font-size: 0.9rem; }
.field { width: 100%; min-height: 46px; padding: 10px 14px; border: 2px solid var(--line); border-radius: var(--r-sm); background: var(--card); color: var(--ink); font: inherit; }
.field:focus-visible { outline: 3px solid var(--cobalt); outline-offset: 2px; }
.field[aria-invalid='true'] { border-color: var(--danger); }
.lbl { display: block; margin: 16px 0 6px; font: 500 0.78rem var(--font-mono); text-transform: uppercase; letter-spacing: 0.05em; }
.alert { padding: 10px 14px; border: 2px solid var(--danger); color: var(--danger); border-radius: var(--r-sm); margin-bottom: 12px; font-weight: 500; }
.tag { display: inline-block; padding: 2px 10px; border: 2px solid var(--line); border-radius: 999px; font: 500 0.72rem var(--font-mono); text-transform: uppercase; }
.tag.pop { background: var(--mint); color: #26102f; }
.tag.soft { background: var(--peach); color: #26102f; }

/* search overlay */
.sr { position: fixed; inset: 0; z-index: 100; background: color-mix(in srgb, var(--ink) 55%, transparent); display: flex; justify-content: center; padding: 8vh var(--gut) 0; animation: fade 0.15s; }
.sr-in { width: min(680px, 100%); align-self: flex-start; background: var(--paper); border: 2px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.sr-bar { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 2px solid var(--line); }
.sr-bar > svg { width: 22px; height: 22px; flex: none; }
.sr-bar input { flex: 1; border: 0; background: none; font: 500 1.2rem var(--font-body); color: var(--ink); min-width: 0; padding: 6px 4px; border-radius: 6px; }
.sr-bar input:focus-visible { outline: 3px solid var(--cobalt); outline-offset: 2px; }
.sr-bar input::-webkit-search-cancel-button { display: none; }
.sr-note { margin: 6px 4px; }
.is-err { color: var(--danger); }
.is-ok { color: var(--cobalt); }
.sr-res { padding: 12px; max-height: 60vh; overflow-y: auto; }
.sr-hit { display: flex; gap: 14px; align-items: center; padding: 10px; border-radius: var(--r-sm); text-decoration: none; }
.sr-hit.on, .sr-hit:hover { background: var(--blush); }
.sr-hit small { display: block; color: var(--muted); }

/* tokens used in lists */
.lr-code { position: relative; flex: none; display: grid; place-items: center; width: 52px; height: 52px; border: 2px solid var(--line); border-radius: 6px 22px 6px 6px; background: var(--tc, var(--cobalt)); color: var(--tf, #fff); font: 800 1.25rem var(--font-display); box-shadow: inset 0 -5px 0 rgba(38, 16, 47, 0.85); }
.lr-code small { position: absolute; top: 2px; left: 5px; font-size: 0.55rem; opacity: 0.85; }

/* footer */
#foot { margin-top: 40px; background: var(--ink); color: var(--paper); }
:root[data-theme='dark'] #foot { background: var(--blush); color: var(--ink); }
.marquee { overflow: hidden; border-bottom: 2px solid rgba(255, 255, 255, 0.15); padding: 8px 0; white-space: nowrap; }
.marquee-in { display: inline-flex; animation: slide 40s linear infinite; font: 800 1.5rem var(--font-display); letter-spacing: 0.35em; color: var(--peach); }
.marquee-in span { padding-right: 0.35em; }
.foot-in { padding: 32px 0 24px; display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px 40px; }
.foot-news h2 { margin-bottom: 14px; font-size: clamp(1.3rem, 2.4vw, 1.8rem); }
.news-form { display: flex; gap: 10px; max-width: 560px; margin-bottom: 8px; }
.news-form .field { flex: 1; min-width: 0; }
.news-form .btn { flex: none; }
.news-msg { margin: 0; min-height: 1.4em; }
.news-msg a { color: inherit; font-weight: 700; }
#foot .is-err { color: #ffb4a8; }
#foot .is-ok { color: var(--peach); }
:root[data-theme='dark'] #foot .is-ok { color: var(--cobalt); }
:root[data-theme='dark'] #foot .is-err { color: var(--danger); }
.news-form .field { border-color: var(--paper); }
.foot-links { display: flex; flex-wrap: wrap; gap: 10px 26px; align-content: flex-start; font: 700 1.1rem var(--font-display); }
.foot-links a { text-decoration: none; }
.foot-links a:hover { color: var(--peach); }
.foot-note { grid-column: 1 / -1; border-top: 2px solid rgba(255, 255, 255, 0.15); padding-top: 14px; margin: 0; opacity: 0.8; }
#foot .muted { color: inherit; opacity: 0.7; }

/* prose */
.prose { font-size: 1.1rem; }
.prose h2 { margin: 1.5em 0 0.45em; font-size: clamp(1.6rem, 3vw, 2.1rem); scroll-margin-top: 90px; }
.prose h3 { margin: 1.3em 0 0.4em; scroll-margin-top: 90px; }
.prose a { color: var(--cobalt); font-weight: 500; }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 1.2em; }
.prose li { margin-bottom: 0.4em; }
.prose li::marker { color: var(--cobalt); font-weight: 700; }
.prose code { font-family: var(--font-mono); background: var(--blush); padding: 2px 6px; border-radius: 6px; font-size: 0.9em; }
.prose pre { background: var(--ink); color: var(--paper); padding: 16px; border-radius: var(--r-sm); overflow-x: auto; }
.prose hr { border: 0; border-top: 2px dashed var(--soft); margin: 2em 0; }
.table-wrap { overflow-x: auto; margin: 0 0 1.4em; border: 2px solid var(--line); border-radius: var(--r-sm); background: var(--card); }
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1.5px solid var(--soft); vertical-align: top; }
th { background: var(--blush); font: 500 0.75rem var(--font-mono); text-transform: uppercase; letter-spacing: 0.05em; }
tr:last-child td { border-bottom: 0; }

/* toast + motion */
#toasts:empty { display: none; }
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: grid; gap: 8px; }
.toast { background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 999px; font-weight: 500; animation: pop 0.25s; }
#main { min-height: 60vh; }
#main:focus, h1[tabindex='-1']:focus { outline: none; }
#main:focus-visible, h1[tabindex='-1']:focus-visible { outline: 3px solid var(--cobalt); outline-offset: 4px; }
/* skeleton + state boxes */
.skel { padding: 40px 0; }
.sk { border-radius: 8px; background: linear-gradient(90deg, var(--soft), color-mix(in srgb, var(--soft) 40%, transparent), var(--soft)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
.sk-kick { width: 140px; height: 14px; margin-bottom: 18px; }
.sk-h1 { width: min(520px, 80%); height: 54px; margin-bottom: 16px; }
.sk-line { width: min(680px, 90%); height: 18px; margin-bottom: 28px; }
.sk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.sk-tile { aspect-ratio: 1 / 1.08; border-radius: 6px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.state-box { padding: 60px 0; max-width: 680px; }
.state-box h1, .state-box h2 { margin-bottom: 14px; }
/* backwards, not both: a filled transform would make #main the containing block of position:fixed children (to-top button) */
#main.enter { animation: rise 0.35s ease backwards; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(0.96); } }
@keyframes slide { to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

@media (max-width: 820px) {
  .menu-links b { font-size: 1.7rem; }
  .menu-links a { padding: 9px 0; }
  .search-pill { min-width: 0; } .search-pill span, .search-pill kbd { display: none; } .search-pill { padding: 0 12px; }
  .menu-in { grid-template-columns: 1fr; gap: 20px; }
  .foot-in { grid-template-columns: 1fr; }
  .marquee-in { font-size: 1.2rem; }
}
@media (max-width: 420px) { .pill-dark span { display: none; } .pill-dark { padding: 0 12px; } }
