/* ==========================================================================
   The Familiar · Spellworks · design system
   A private workshop for the people building the Familiar's brain.

   Two themes: night (default, the workshop after dark) and paper (daylight).
   Colour roles are strict:
     --signal  phosphor green, only for the TV and things that are live
     --glow    amber, only for light (the structure, the drawers)
     --alert   coral, only for the brand mark and safety warnings
   Type roles: Fraunces (display + headings), Archivo (body + wide-caps
   labels), Courier Prime (the machine voice: TV, typewriter, code, readouts).
   Default text scale is 120% (html font-size = 16px * --scale).
   ========================================================================== */

:root {
  --scale: 1.2;

  --phosphor: #8fe27a;
  --amber: #e3a14b;
  --amber-hot: #ffb35c;
  --coral: #f45f5f;

  --f-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --f-body: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --f-mono: "Courier Prime", "Courier New", Courier, monospace;

  --r-xs: 8px;
  --r-sm: 12px;
  --r: 22px;
  --r-lg: 28px;
  --r-pill: 999px;

  --max: 1440px;
  --gutter: clamp(20px, 4vw, 64px);
  --header-h: 4.1rem;

  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --ease-soft: cubic-bezier(0.4, 0, 0.2, 1);
}

html,
html[data-theme="night"] {
  --bg: #121016;
  --bg-2: #19161e;
  --bg-3: #231f29;
  --bg-inset: #0b0a0e;
  --fg: #f4efe4;
  --fg-2: #c2b9ac;
  --fg-3: #958c81;
  --hair: rgba(244, 239, 228, 0.12);
  --hair-2: rgba(244, 239, 228, 0.24);
  --signal: var(--phosphor);
  --signal-ink: #8fe27a;
  --signal-wash: rgba(143, 226, 122, 0.12);
  --glow: var(--amber);
  --glow-ink: #ebb066;
  --glow-wash: rgba(227, 161, 75, 0.14);
  --alert: var(--coral);
  --alert-ink: #ff8a80;
  --alert-wash: rgba(244, 95, 95, 0.12);
  --solid-bg: #f4efe4;
  --solid-fg: #121016;
  --shadow-lift: 0 1px 0 rgba(244, 239, 228, 0.05) inset;
  color-scheme: dark;
}

html[data-theme="paper"] {
  --bg: #f3eee4;
  --bg-2: #ebe4d7;
  --bg-3: #e0d7c6;
  --bg-inset: #fbf8f2;
  --fg: #1b1714;
  --fg-2: #4b443c;
  --fg-3: #6a6157;
  --hair: rgba(27, 23, 20, 0.14);
  --hair-2: rgba(27, 23, 20, 0.28);
  --signal: #8fe27a;
  --signal-ink: #2b6a25;
  --signal-wash: rgba(43, 106, 37, 0.1);
  --glow: #c9822f;
  --glow-ink: #8a4c0e;
  --glow-wash: rgba(201, 130, 47, 0.14);
  --alert: #d9483f;
  --alert-ink: #ad2d28;
  --alert-wash: rgba(217, 72, 63, 0.1);
  --solid-bg: #1b1714;
  --solid-fg: #f3eee4;
  --shadow-lift: 0 1px 0 rgba(255, 255, 255, 0.6) inset;
  color-scheme: light;
}

/* --------------------------------------------------------------------------
   reset + base
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html {
  font-size: calc(16px * var(--scale));
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  background: var(--bg);
}
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--f-body);
  font-size: 1rem;
  font-variation-settings: "wdth" 100;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  transition: background-color 0.35s var(--ease-soft), color 0.35s var(--ease-soft);
}
img, video, svg, canvas { display: block; max-width: 100%; }
img { height: auto; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4, h5, p, figure, blockquote, ul, ol, dl, dd { margin: 0; }
ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }
::selection { background: var(--signal); color: #0b0a0e; }
:focus-visible { outline: 2px solid var(--signal-ink); outline-offset: 3px; border-radius: 6px; }
[id] { scroll-margin-top: calc(var(--header-h) + 24px); }
[hidden] { display: none !important; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; left: 16px; top: -80px; z-index: 200;
  background: var(--solid-bg); color: var(--solid-fg); padding: 10px 18px;
  border-radius: var(--r-pill); font-weight: 700; text-decoration: none;
  transition: top 0.2s var(--ease);
}
.skip-link:focus { top: 12px; }

/* --------------------------------------------------------------------------
   type roles
   -------------------------------------------------------------------------- */
.t-display, .t-h1, .t-h2, .t-h3, .t-statement {
  font-family: var(--f-display);
  font-optical-sizing: auto;
  letter-spacing: -0.02em;
  text-wrap: balance;
  font-weight: 380;
}
.t-display {
  font-size: clamp(2.7rem, 6.2vw, 6.4rem);
  line-height: 0.96;
  font-weight: 350;
  font-variation-settings: "SOFT" 100, "WONK" 1;
}
.t-statement {
  font-size: clamp(1.9rem, 3.6vw, 3.4rem);
  line-height: 1.06;
  font-variation-settings: "SOFT" 70, "WONK" 0;
}
.t-h1 { font-size: clamp(2.3rem, 4.4vw, 4.2rem); line-height: 1.02; font-variation-settings: "SOFT" 80, "WONK" 1; }
.t-h2 { font-size: clamp(1.7rem, 2.8vw, 2.6rem); line-height: 1.08; font-variation-settings: "SOFT" 50; }
.t-h3 { font-size: clamp(1.18rem, 1.5vw, 1.4rem); line-height: 1.2; font-weight: 450; letter-spacing: -0.01em; }
.t-display em, .t-h1 em, .t-h2 em, .t-h3 em, .t-statement em {
  font-style: italic;
  font-variation-settings: "SOFT" 100, "WONK" 1;
}
.t-lede {
  font-family: var(--f-display);
  font-size: clamp(1.12rem, 1.35vw, 1.32rem);
  line-height: 1.5;
  font-weight: 360;
  color: var(--fg-2);
  max-width: 40ch;
  text-wrap: pretty;
}
.t-body { color: var(--fg-2); max-width: 64ch; text-wrap: pretty; }
.t-body p + p { margin-top: 0.9em; }
.t-small { font-size: 0.84rem; line-height: 1.55; color: var(--fg-2); }
.t-label {
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  font-family: var(--f-body);
  font-variation-settings: "wdth" 125;
  font-weight: 600;
  font-size: 0.64rem;
  line-height: 1.2;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-3);
}
.t-label--signal { color: var(--signal-ink); }
.t-label--glow { color: var(--glow-ink); }
.t-label--alert { color: var(--alert-ink); }
.t-mono { font-family: var(--f-mono); letter-spacing: 0; }
.t-num { font-variant-numeric: tabular-nums; }

/* prose inside long-form sections */
.prose { color: var(--fg-2); max-width: 66ch; }
.prose > * + * { margin-top: 0.95em; }
.prose h3 { font-family: var(--f-display); color: var(--fg); font-size: 1.28rem; font-weight: 450; letter-spacing: -0.01em; margin-top: 1.8em; }
.prose strong { color: var(--fg); font-weight: 600; }
.prose a { color: var(--fg); text-decoration-color: var(--hair-2); text-underline-offset: 0.2em; }
.prose a:hover { text-decoration-color: currentColor; }
.prose ul, .prose ol { padding-left: 1.2em; }
.prose li + li { margin-top: 0.35em; }
.prose li::marker { color: var(--fg-3); }

/* --------------------------------------------------------------------------
   layout
   -------------------------------------------------------------------------- */
.wrap { width: 100%; max-width: var(--max); margin: 0 auto; padding-left: var(--gutter); padding-right: var(--gutter); }
.page { display: block; min-height: calc(100vh - var(--header-h)); }
.section { padding-top: clamp(64px, 9vw, 140px); padding-bottom: clamp(64px, 9vw, 140px); }
.section--tight { padding-top: clamp(40px, 5vw, 72px); padding-bottom: clamp(40px, 5vw, 72px); }
.section + .section { border-top: 1px solid var(--hair); }
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: clamp(16px, 2vw, 32px); row-gap: clamp(24px, 3vw, 48px); }
.span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; } .span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; }
.span-9 { grid-column: span 9; } .span-12 { grid-column: 1 / -1; }
@media (max-width: 900px) {
  .grid > [class*="span-"] { grid-column: 1 / -1; }
}
.rule { border: 0; border-top: 1px solid var(--hair); margin: 0; }
.stack > * + * { margin-top: var(--stack, 1rem); }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--cluster, 0.6rem); }

/* section header: label + headline + optional lede, open layout */
.sec-head { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: clamp(16px, 2vw, 32px); row-gap: 1rem; margin-bottom: clamp(32px, 4vw, 64px); }
.sec-head > .t-label { grid-column: 1 / -1; }
.sec-head > .t-h1, .sec-head > .t-h2 { grid-column: 1 / span 7; }
.sec-head > .t-lede, .sec-head > .t-body { grid-column: 8 / -1; align-self: end; }
@media (max-width: 900px) {
  .sec-head > * { grid-column: 1 / -1 !important; }
}

/* --------------------------------------------------------------------------
   header (rendered by shell.js into [data-shell-header])
   -------------------------------------------------------------------------- */
.hdr {
  position: sticky;
  top: 0;
  z-index: 50;
  min-height: var(--header-h);
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  border-bottom: 1px solid var(--hair);
}
@supports not (background: color-mix(in srgb, red 50%, blue)) { .hdr { background: var(--bg); } }
.hdr__in {
  display: flex;
  align-items: center;
  gap: clamp(12px, 2vw, 28px);
  min-height: var(--header-h);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  white-space: nowrap;
  flex: 0 0 auto;
}
.brand__mark { font-family: var(--f-display); font-size: 1.05rem; color: var(--fg-3); line-height: 1; transform: translateY(-0.05em); }
.brand__name { font-family: var(--f-display); font-size: 1.06rem; font-weight: 450; letter-spacing: -0.01em; font-variation-settings: "SOFT" 100, "WONK" 1; }
.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  padding: 0.32em 0.8em 0.3em;
  border: 1px solid var(--hair-2);
  border-radius: var(--r-pill);
  font-family: var(--f-body);
  font-variation-settings: "wdth" 118;
  font-weight: 600;
  font-size: 0.58rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-2);
  white-space: nowrap;
  line-height: 1.2;
}
.tag--signal { border-color: color-mix(in srgb, var(--signal-ink) 55%, transparent); color: var(--signal-ink); }
.tag--glow { border-color: color-mix(in srgb, var(--glow-ink) 55%, transparent); color: var(--glow-ink); }
.tag--alert { border-color: color-mix(in srgb, var(--alert-ink) 55%, transparent); color: var(--alert-ink); }
.tbc {
  display: inline-flex;
  align-items: center;
  padding: 0.12em 0.6em 0.1em;
  border: 1px dashed var(--hair-2);
  border-radius: var(--r-pill);
  font-family: var(--f-body);
  font-variation-settings: "wdth" 118;
  font-weight: 600;
  font-size: 0.56rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-3);
  white-space: nowrap;
  vertical-align: 0.12em;
  line-height: 1.3;
}

.nav { display: flex; align-items: center; gap: clamp(2px, 0.6vw, 8px); margin-left: auto; }
.nav a {
  position: relative;
  padding: 0.5rem 0.7rem;
  border-radius: var(--r-pill);
  font-family: var(--f-body);
  font-variation-settings: "wdth" 112;
  font-weight: 560;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-decoration: none;
  color: var(--fg-2);
  transition: color 0.2s var(--ease-soft), background-color 0.2s var(--ease-soft);
}
.nav a:hover { color: var(--fg); background: var(--bg-3); }
.nav a[aria-current="page"] { color: var(--fg); }
.nav a[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 0.7rem; right: 0.7rem; bottom: 0.22rem;
  height: 1.5px;
  background: currentColor;
  border-radius: 2px;
}
.ctrls { display: flex; align-items: center; gap: 0.5rem; flex: 0 0 auto; }
.ctrl-group {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--hair-2);
  border-radius: var(--r-pill);
  padding: 2px;
}
.ctrl-btn {
  display: inline-grid;
  place-items: center;
  min-width: 2rem;
  height: 1.8rem;
  padding: 0 0.55rem;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  font-family: var(--f-body);
  font-weight: 600;
  font-size: 0.7rem;
  color: var(--fg-2);
  cursor: pointer;
  transition: background-color 0.2s var(--ease-soft), color 0.2s var(--ease-soft);
}
.ctrl-btn:hover { background: var(--bg-3); color: var(--fg); }
.ctrl-btn:disabled { opacity: 0.4; cursor: default; background: transparent; }
.ctrl-val { min-width: 2.7rem; text-align: center; font-variant-numeric: tabular-nums; font-size: 0.66rem; color: var(--fg-3); }
.menu-btn { display: none; }

@media (max-width: 1360px) and (min-width: 1081px) {
  .hdr__in { gap: 12px; }
  .brand .tag { display: none; }
  .nav a { padding: 0.45rem 0.54rem; }
}
@media (max-width: 1080px) {
  .nav { display: none; }
  .menu-btn { display: inline-grid; margin-left: auto; }
  .hdr.is-open .nav {
    display: flex;
    position: absolute;
    left: 0; right: 0; top: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0.5rem var(--gutter) 1rem;
    background: var(--bg);
    border-bottom: 1px solid var(--hair);
  }
  .hdr.is-open .nav a { padding: 0.9rem 0; font-size: 0.95rem; border-radius: 0; border-bottom: 1px solid var(--hair); }
  .hdr.is-open .nav a:hover { background: transparent; }
  .hdr.is-open .nav a[aria-current="page"]::after { display: none; }
}
@media (max-width: 560px) {
  :root { --header-h: 3.35rem; }
  .brand .tag, .ctrl-group--size .ctrl-val { display: none; }
  .hdr__in { gap: 8px; }
  .brand { gap: 0.45rem; }
  .brand__name { font-size: 0.98rem; }
  .ctrls { gap: 0.35rem; }
  .ctrl-btn { min-width: 1.65rem; height: 1.7rem; padding: 0 0.38rem; font-size: 0.66rem; }
  .menu-btn { padding: 0 0.5rem; }
  .hdr .switch__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
@media (max-width: 360px) {
  .brand__mark { display: none; }
}

/* --------------------------------------------------------------------------
   buttons, segmented controls, switches
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55em;
  min-height: 2.35rem;
  padding: 0.55em 1.15em 0.5em;
  border: 1px solid var(--hair-2);
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--fg);
  font-family: var(--f-body);
  font-variation-settings: "wdth" 115;
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.2s var(--ease-soft), color 0.2s var(--ease-soft), border-color 0.2s var(--ease-soft), transform 0.2s var(--ease);
}
.btn:hover { border-color: var(--fg); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn--solid { background: var(--solid-bg); color: var(--solid-fg); border-color: var(--solid-bg); }
.btn--solid:hover { background: transparent; color: var(--fg); border-color: var(--fg); }
.btn--signal { background: var(--signal); color: #0b0a0e; border-color: var(--signal); }
.btn--signal:hover { background: transparent; color: var(--signal-ink); border-color: var(--signal-ink); }
.btn--quiet { border-color: transparent; color: var(--fg-2); }
.btn--quiet:hover { color: var(--fg); border-color: var(--hair-2); }
.btn--sm { min-height: 1.9rem; padding: 0.42em 0.9em 0.38em; font-size: 0.62rem; }
.btn .arrow { font-family: var(--f-body); letter-spacing: 0; transition: transform 0.25s var(--ease); }
.btn:hover .arrow { transform: translateX(3px); }

.seg {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--hair-2);
  border-radius: var(--r-pill);
}
.seg > button {
  min-height: 1.85rem;
  padding: 0.38em 0.95em 0.34em;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--fg-2);
  font-family: var(--f-body);
  font-variation-settings: "wdth" 112;
  font-weight: 600;
  font-size: 0.64rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.2s var(--ease-soft), color 0.2s var(--ease-soft);
}
.seg > button:hover { color: var(--fg); }
.seg > button[aria-pressed="true"], .seg > button[aria-selected="true"] { background: var(--solid-bg); color: var(--solid-fg); }

.switch {
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-family: var(--f-body);
  font-variation-settings: "wdth" 112;
  font-weight: 600;
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-2);
}
.switch__track {
  position: relative;
  display: inline-block;
  width: 2.3em;
  height: 1.3em;
  border-radius: var(--r-pill);
  background: var(--bg-3);
  border: 1px solid var(--hair-2);
  transition: background-color 0.25s var(--ease-soft), border-color 0.25s var(--ease-soft);
  font-size: 1.15em;
}
.switch__thumb {
  position: absolute;
  top: 50%;
  left: 0.16em;
  width: 0.92em;
  height: 0.92em;
  border-radius: 50%;
  background: var(--fg-2);
  transform: translateY(-50%);
  transition: left 0.25s var(--ease), background-color 0.25s var(--ease-soft);
}
.switch[aria-checked="true"] .switch__track { background: var(--solid-bg); border-color: var(--solid-bg); }
.switch[aria-checked="true"] .switch__thumb { left: calc(100% - 1.08em); background: var(--solid-fg); }
.switch--signal[aria-checked="true"] .switch__track { background: var(--signal); border-color: var(--signal); }
.switch--signal[aria-checked="true"] .switch__thumb { background: #0b0a0e; }

/* live indicator */
.live-dot {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--fg-3);
  flex: 0 0 auto;
}
.live-dot.is-live { background: var(--signal); box-shadow: 0 0 0 3px var(--signal-wash); animation: sw-pulse 2.4s var(--ease-soft) infinite; }
.live-dot.is-warn { background: var(--glow); }
.live-dot.is-off { background: transparent; border: 1px solid var(--fg-3); }
@keyframes sw-pulse { 50% { box-shadow: 0 0 0 6px transparent; } }

/* typewriter keycap */
kbd {
  display: inline-grid;
  place-items: center;
  min-width: 1.75em;
  height: 1.75em;
  padding: 0 0.4em;
  border-radius: var(--r-pill);
  border: 1.5px solid var(--hair-2);
  background: var(--bg-2);
  box-shadow: 0 2px 0 var(--hair-2);
  font-family: var(--f-mono);
  font-size: 0.82em;
  line-height: 1;
  color: var(--fg);
  vertical-align: 0.08em;
}

/* --------------------------------------------------------------------------
   inputs
   -------------------------------------------------------------------------- */
.field { display: grid; gap: 0.45rem; }
.field > label, .field > .t-label { color: var(--fg-3); }
.input, .select, .textarea {
  width: 100%;
  min-height: 2.5rem;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--hair-2);
  border-radius: var(--r-sm);
  background: var(--bg-inset);
  color: var(--fg);
  font-size: 0.9rem;
  transition: border-color 0.2s var(--ease-soft);
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--fg); }
.input--mono, .textarea--mono { font-family: var(--f-mono); }
.textarea { min-height: 7rem; resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-right: 2.2rem; background-image: linear-gradient(45deg, transparent 50%, var(--fg-3) 50%), linear-gradient(135deg, var(--fg-3) 50%, transparent 50%); background-position: calc(100% - 1.15rem) 52%, calc(100% - 0.8rem) 52%; background-size: 0.36rem 0.36rem; background-repeat: no-repeat; }
input[type="range"] { accent-color: var(--fg); width: 100%; }

/* --------------------------------------------------------------------------
   stat links (clickable data points that jump to their evidence)
   -------------------------------------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--hair); }
.stat {
  display: grid;
  align-content: start;
  gap: 0.5rem;
  padding: 1.4rem 1.4rem 1.5rem 0;
  border-bottom: 1px solid var(--hair);
  text-decoration: none;
  color: inherit;
  transition: background-color 0.25s var(--ease-soft);
}
.stat + .stat { padding-left: 1.4rem; border-left: 1px solid var(--hair); }
.stat__n { font-family: var(--f-display); font-size: clamp(2.2rem, 3.6vw, 3.3rem); line-height: 1; font-weight: 340; letter-spacing: -0.02em; font-variation-settings: "SOFT" 100, "WONK" 1; font-variant-numeric: lining-nums; }
.stat__l { font-size: 0.84rem; color: var(--fg-2); line-height: 1.45; max-width: 24ch; }
.stat__go { font-family: var(--f-body); font-variation-settings: "wdth" 118; font-weight: 600; font-size: 0.58rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--fg-3); transition: color 0.2s var(--ease-soft); }
a.stat:hover .stat__go { color: var(--fg); }
a.stat:hover .stat__n { color: var(--fg); }
@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(odd) { padding-left: 0; border-left: 0; }
}

/* --------------------------------------------------------------------------
   notes, warnings, code, tables
   -------------------------------------------------------------------------- */
.note, .warn {
  display: grid;
  gap: 0.4rem;
  padding: 0.2rem 0 0.2rem 1.1rem;
  border-left: 2px solid var(--hair-2);
  max-width: 64ch;
}
.note p, .warn p { color: var(--fg-2); font-size: 0.92rem; }
.warn { border-left-color: var(--alert); }
.warn > .t-label { color: var(--alert-ink); }

code, pre { font-family: var(--f-mono); }
:not(pre) > code {
  padding: 0.08em 0.38em;
  border-radius: 6px;
  background: var(--bg-3);
  font-size: 0.9em;
  color: var(--fg);
}
pre.code {
  position: relative;
  margin: 0;
  padding: 1.1rem 1.25rem;
  border-radius: var(--r-sm);
  background: var(--bg-inset);
  border: 1px solid var(--hair);
  color: var(--fg);
  font-size: 0.8rem;
  line-height: 1.6;
  overflow: auto;
  tab-size: 2;
}
pre.code .c { color: var(--fg-3); }
pre.code .k { color: var(--signal-ink); }
pre.code .s { color: var(--glow-ink); }
.code-copy {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
}

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.table th {
  text-align: left;
  padding: 0.7rem 1rem 0.7rem 0;
  border-bottom: 1px solid var(--hair-2);
  font-family: var(--f-body);
  font-variation-settings: "wdth" 120;
  font-weight: 600;
  font-size: 0.58rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-3);
  white-space: nowrap;
}
.table td { padding: 0.85rem 1rem 0.85rem 0; border-bottom: 1px solid var(--hair); vertical-align: top; color: var(--fg-2); }
.table td:first-child { color: var(--fg); }
.table tr:last-child td { border-bottom: 0; }

/* --------------------------------------------------------------------------
   sticky in-page contents (scrollbar hidden on purpose)
   -------------------------------------------------------------------------- */
.toc {
  position: sticky;
  top: calc(var(--header-h) + 24px);
  max-height: calc(100vh - var(--header-h) - 48px);
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.toc::-webkit-scrollbar { display: none; width: 0; height: 0; }
.toc ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.1rem; }
.toc a {
  display: grid;
  grid-template-columns: 2.2em 1fr;
  gap: 0.2em;
  padding: 0.45rem 0;
  font-size: 0.84rem;
  line-height: 1.35;
  color: var(--fg-3);
  text-decoration: none;
  transition: color 0.2s var(--ease-soft);
}
.toc a .n { font-family: var(--f-mono); font-size: 0.78rem; }
.toc a:hover, .toc a[aria-current="true"] { color: var(--fg); }

/* --------------------------------------------------------------------------
   footer
   -------------------------------------------------------------------------- */
.ftr { border-top: 1px solid var(--hair); }
.ftr__in {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: clamp(16px, 2vw, 32px);
  row-gap: 1.5rem;
  padding-top: clamp(40px, 5vw, 72px);
  padding-bottom: clamp(40px, 5vw, 64px);
}
.ftr__note { grid-column: 1 / span 6; }
.ftr__note .t-h3 { margin-bottom: 0.5rem; }
.ftr__links { grid-column: 8 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem 1.5rem; align-content: start; }
.ftr__links a { font-size: 0.86rem; color: var(--fg-2); text-decoration: none; }
.ftr__links a:hover { color: var(--fg); }
.ftr__fine { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; justify-content: space-between; padding-top: 1.25rem; border-top: 1px solid var(--hair); }
@media (max-width: 900px) {
  .ftr__note, .ftr__links { grid-column: 1 / -1; }
}

/* --------------------------------------------------------------------------
   the gate: builders only
   -------------------------------------------------------------------------- */
html[data-locked] body > *:not(.gate):not(script) { visibility: hidden !important; }
html[data-locked] { overflow: hidden; }
.gate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: var(--gutter);
  background: #121016;
  color: #f4efe4;
  color-scheme: dark;
  overflow: auto;
}
.gate__card { width: min(100%, 34rem); display: grid; gap: 1.4rem; }
.gate__tag {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transform: rotate(-4deg);
  transform-origin: 0 50%;
}
.gate__tag-string { width: 2.2rem; height: 1.5px; background: #c2b9ac; }
.gate__tag-card {
  padding: 0.35em 0.9em 0.38em 1.1em;
  background: #f3e6cf;
  color: #3a2a1c;
  font-family: var(--f-display);
  font-style: italic;
  font-size: 0.86rem;
  line-height: 1;
  clip-path: polygon(0.55em 0, 100% 0, 100% 100%, 0.55em 100%, 0 50%);
}
.gate__title { font-family: var(--f-display); font-size: clamp(2.2rem, 5vw, 3.4rem); line-height: 1.02; font-weight: 360; letter-spacing: -0.02em; font-variation-settings: "SOFT" 100, "WONK" 1; }
.gate__title em { font-style: italic; }
.gate__body { color: #c2b9ac; font-size: 1rem; max-width: 36ch; }
.gate__form { display: flex; gap: 0.6rem; align-items: stretch; flex-wrap: wrap; }
.gate__input {
  flex: 1 1 14rem;
  min-height: 2.9rem;
  padding: 0.5rem 0.2rem;
  border: 0;
  border-bottom: 1.5px solid rgba(244, 239, 228, 0.32);
  background: transparent;
  color: #f4efe4;
  font-family: var(--f-mono);
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  caret-color: #8fe27a;
}
.gate__input::placeholder { color: rgba(244, 239, 228, 0.36); }
.gate__input:focus { outline: none; border-bottom-color: #8fe27a; }
.gate__btn { background: #f4efe4; color: #121016; border-color: #f4efe4; min-height: 2.9rem; padding-left: 1.5em; padding-right: 1.5em; }
.gate__btn:hover { background: transparent; color: #f4efe4; border-color: #f4efe4; }
.gate__msg { min-height: 1.4em; font-family: var(--f-mono); font-size: 0.86rem; color: #c2b9ac; }
.gate__msg.is-wrong { color: #ff8a80; }
.gate__fine { color: #958c81; font-size: 0.78rem; max-width: 40ch; }
.gate.is-shake .gate__form { animation: sw-shake 0.42s var(--ease); }
@keyframes sw-shake { 20% { transform: translateX(-6px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }

/* --------------------------------------------------------------------------
   motion preferences
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
html[data-reduce-motion] *, html[data-reduce-motion] *::before, html[data-reduce-motion] *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }

/* Return to public site link in header */
.nav-public {
  display: inline-flex !important;
  align-items: center !important;
  gap: 0.35rem !important;
  padding: 0.4rem 0.75rem !important;
  border: 1px solid var(--border-subtle) !important;
  border-radius: var(--r-pill) !important;
  background: var(--surface-1) !important;
  color: var(--amber) !important;
  font-weight: 650 !important;
  font-size: 0.72rem !important;
  letter-spacing: 0.04em !important;
  text-decoration: none !important;
  transition: all 0.2s var(--ease-soft) !important;
}
.nav-public:hover {
  background: var(--surface-2) !important;
  border-color: var(--amber) !important;
  color: var(--amber) !important;
  transform: translateX(-1px);
}
