/* ─────────────────────────────────────────────────────────────
   tissue.systems — design system

   The lexicon restyle (plans/tissue/proposals/ui-spec-2026-08.md): one face
   (IBM Plex Mono), one ground, one panel, no radii, no shadows, no glass.
   Reference implementations: mockups/public/b4a-dash.html (marketing) and
   b4c-docs.html (the three-column docs ledger, both themes).
   ───────────────────────────────────────────────────────────── */

/* ── tokens ──────────────────────────────────────────────────────
   Colour lives in css/tokens.css, which must be linked BEFORE this file. The
   names below are this stylesheet's own vocabulary mapped onto it, so a page
   never reads a --tissue-* name directly and the palette has one definition.
   Each fallback repeats the light value, so a page that fails to load
   tokens.css still paints the light palette.

   Nothing here is theme-specific: switch a surface to dark by stamping
   data-theme="dark" on <html> and tokens.css re-points every name at once.
   ──────────────────────────────────────────────────────────────── */
:root {
  /* Lets the fold animations interpolate to `auto`; ignored where unsupported,
     which degrades a fold to an instant open rather than breaking it. */
  interpolate-size: allow-keywords;

  /* palette — one ground, one panel, and no third surface */
  --bg:              var(--tissue-bg,    #ffffff);
  --bg-offset:       var(--tissue-panel, #f4f4f1);
  --bg-secondary:    var(--tissue-panel, #f4f4f1);
  --bg-hover:        var(--tissue-panel, #f4f4f1);
  --paper:           var(--tissue-bg,    #ffffff);

  --text:            var(--tissue-ink,   #222222);
  --text-secondary:  var(--tissue-ink-2, #55625b);
  --text-tertiary:   var(--tissue-ink-3, #8a8a85);

  /* The soft/glow tints are gone with the gradients and shadows; the names
     survive so the rules that still ask for them resolve to nothing rather
     than to a colour the system no longer has. */
  --accent:          var(--tissue-accent,    #00875f);
  --accent-dark:     var(--tissue-accent,    #00875f);
  --accent-light:    transparent;
  --accent-glow:     transparent;

  --border:          var(--tissue-line,   #e6e6e1);
  --border-light:    var(--tissue-line,   #e6e6e1);
  --border-med:      var(--tissue-line-2, #cfcfc9);

  /* the two rails: dashed warm-brown "this folds open", solid gate-green
     "this is open now" */
  --rail:            var(--tissue-rail,      #8a7d6b);
  --rail-open:       var(--tissue-rail-open, #8fbfa5);

  --danger:          var(--tissue-danger, #c0392b);
  --danger-soft:     transparent;
  --danger-line:     var(--tissue-danger, #c0392b);

  /* Code is a light chip on the panel ground, not a dark plate. The ledger has
     one panel and code shares it; separation comes from the ground change and
     the green prompt, not from an inverted block. */
  --code-bg:         var(--tissue-panel, #f4f4f1);
  --code-header-bg:  var(--tissue-panel, #f4f4f1);
  --code-text:       var(--tissue-ink,   #222222);
  --code-bright:     var(--tissue-ink,   #222222);

  --inline-code-bg:  var(--tissue-panel, #f4f4f1);
  --inline-code-fg:  var(--tissue-ink,   #222222);
  --inline-code-br:  transparent;

  /* Syntax highlighting stays inside the palette: keywords take the italic
     sage second voice, strings the brand green, numbers amber, attributes the
     rail brown. Every one of them flips with the theme through tokens.css, so
     there is no second dark set to keep in step. */
  --hl-comment:      var(--tissue-ink-3, #8a8a85);
  --hl-keyword:      var(--tissue-ink-2, #55625b);
  --hl-string:       var(--tissue-accent, #00875f);
  --hl-number:       var(--tissue-amber, #b7791f);
  --hl-title:        var(--tissue-ink,   #222222);
  --hl-attr:         var(--tissue-rail,  #8a7d6b);

  /* layout. --header-h is what the sticky docs rails hang below, and it is the
     shared token rather than a second opinion about the same bar: the two
     disagreed by 12px, which hung both rails below the header they meet. The
     fallback is the measured height, not the arithmetic — see tokens.css. */
  --sidebar-w:       230px;
  --aside-w:         13em;
  --header-h:        var(--tissue-header-h, 50.61px);
  --max-width:       1296px;
  --content-max:     42em;

  /* The width the right rail takes once the viewport can pay for it out of the
     gutter instead of out of the measure (.wrap's min-width: 1320px block).
     13em holds about 17 characters, and 98 of the 543 headings in the docs are
     longer than that, so at the narrow width the rail wraps a heading onto
     three or four lines and reads as dense as the prose it indexes.

     --max-width is the sum of the parts, so the header's rule and the right
     rail end on the same pixel: 230 + 42em + 20em + two 3rem gaps + the wrap's
     own 1.25rem of padding each side = 1296 at the 15px body size. Anything
     that changes a track width changes this number too, and the templates'
     inline --tissue-hdr-max with it. */
  --aside-w-wide:    20em;

  /* type — one face for everything (spec §3). --font-body and --font-display
     are retired names kept pointing at it, so an unconverted rule still lands
     on Plex instead of on a face no page loads. */
  --font-body:       var(--tissue-font-mono, "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace);
  --font-mono:       var(--tissue-font-mono, "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace);
  --font-display:    var(--tissue-font-mono, "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace);

  /* radii + shadows — the system has neither. The names stay so that the rules
     still asking for them resolve; they all resolve to nothing. */
  --radius:          0;
  --radius-md:       0;
  --radius-lg:       0;
  --shadow-xs:       none;
  --shadow-sm:       none;
  --shadow-card:     none;
}

/* ── reset ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0 }
html { font-size: 16px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth }
body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-synthesis-weight: none;
}
img, svg { display: block; max-width: 100% }
a { color: inherit; text-decoration: none }
a:hover { text-decoration: underline }
button { cursor: pointer; font: inherit }

/* One focus ring for the whole system: the element's own ink, offset. Nothing
   here paints a focus colour of its own. */
a:focus-visible, button:focus-visible, summary:focus-visible,
input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid currentColor; outline-offset: 2px;
}

/* ── header ──────────────────────────────────────────────────────
   Light-DOM fallback with the same metrics as <tissue-header> in chrome.js, for
   pages this stylesheet is served to before that script runs. Keep the height,
   glass and wordmark in step with chrome.js or the bar shifts on upgrade.
   ──────────────────────────────────────────────────────────────── */
header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: .7rem 1.25rem;
}
.logo { display: flex; align-items: center; gap: .5rem; text-decoration: none; flex-shrink: 0; transition: opacity .15s }
.logo:hover { opacity: .7; text-decoration: none }
.logo-mark { display: block; width: 18px; height: 18px }
.logo-text { font-size: 1.1em; font-weight: 600; line-height: 1.2; color: var(--text) }

/* header nav */
.hdr-right { display: flex; align-items: center; gap: 1.25rem }
.hdr-link {
  font-size: .72rem; letter-spacing: .03em;
  color: var(--text-secondary); text-decoration: none; transition: color .15s;
}
.hdr-link:hover { color: var(--text); text-decoration: none }
.hdr-btn {
  font-family: var(--font-body); font-size: .72rem; font-weight: 500;
  padding: .35rem .8rem;
  border: 1px solid var(--border-med); border-radius: var(--radius);
  color: var(--text-secondary); background: var(--bg-hover);
  text-decoration: none; transition: all .15s;
}
.hdr-btn:hover {
  border-color: var(--accent); color: var(--accent);
  background: var(--accent-light); text-decoration: none;
}

/* ── footer ──────────────────────────────────────────────────── */
footer {
  padding: 1.25rem 2rem;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  max-width: var(--max-width); margin: 0 auto;
}
.foot-links { display: flex; gap: 1.5rem }
.foot-links a {
  font-size: .7rem; color: var(--text-tertiary); text-decoration: none;
  transition: color .15s; letter-spacing: .02em;
}
.foot-links a:hover { color: var(--text-secondary); text-decoration: none }
.foot-mark { font-size: .65rem; color: var(--text-tertiary); letter-spacing: .04em }

/* ── marketing main ──────────────────────────────────────────── */
main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 4rem 2rem 6rem;
}

/* hero */
.hero { margin-bottom: 4rem }
.hero h1 {
  font-size: 1.15em;
  font-weight: 600;
  line-height: 1.4;
  text-transform: lowercase;
  color: var(--text);
  margin-bottom: 1rem;
}
.hero .tagline {
  font-style: italic;
  color: var(--text-secondary);
  line-height: 1.65;
}
.hero .tagline .tech { color: var(--text); font-weight: 400 }

/* sections */
section { margin-bottom: 3rem }
h2 {
  font-size: 1em;
  font-weight: 400;
  font-style: italic;
  text-transform: lowercase;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}
p { margin-bottom: 1rem; color: var(--text) }
ul { list-style: none; margin-bottom: 1rem }
li {
  position: relative;
  padding-left: 1.25rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}
li::before { content: '—'; position: absolute; left: 0; color: var(--text-tertiary) }

/* ── inline code + pre ───────────────────────────────────────── */
code {
  font: inherit;
  background: var(--inline-code-bg);
  color: var(--inline-code-fg);
  padding: 0.05em 0.3em;
}
pre {
  font: inherit;
  font-size: 0.94em;
  line-height: 1.6;
  background: var(--code-bg);
  color: var(--code-text);
  padding: 0.9rem 1.1rem;
  overflow-x: auto;
  margin: 1rem 0;
}
pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
  border-radius: 0;
}

/* ── auth pages ──────────────────────────────────────────────── */
.auth-wrap {
  display: flex;
  justify-content: center;
  padding: 5rem 2rem;
}
.auth-card {
  width: 100%;
  max-width: 400px;
}
.auth-card h1 {
  font-size: 1.15em;
  font-weight: 600;
  text-transform: lowercase;
  color: var(--text);
  margin-bottom: 0.375rem;
}
.auth-card .auth-sub {
  font-style: italic;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}
.auth-card .auth-sub a { color: var(--accent) }
.auth-card .auth-sub a:hover { text-decoration: underline }

.auth-form { display: flex; flex-direction: column; gap: 1.25rem }
.field { display: flex; flex-direction: column; gap: 0.4rem }
.field label {
  font-style: italic;
  color: var(--text-secondary);
  text-transform: lowercase;
}
.field input {
  font: inherit;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border-med);
  border-radius: 0;
  background: var(--bg);
  color: var(--text);
  -webkit-appearance: none;
}
.field input::placeholder { color: var(--text-tertiary) }
.field input:focus { border-color: var(--accent); outline: none }
.field input:focus-visible { outline: 2px solid currentColor; outline-offset: 2px }
.auth-submit {
  font: inherit;
  font-weight: 600;
  padding: 0.5rem;
  background: var(--accent);
  color: var(--tissue-on-accent, #fff);
  border: none;
  border-radius: 0;
  transition: background .15s;
  margin-top: 0.25rem;
}
.auth-submit:hover { background: var(--tissue-accent-br, #00b57e) }
.auth-submit:disabled { opacity: 0.55; cursor: not-allowed }

/* A message is a note on a rail, like every other aside in the system. */
.auth-error {
  color: var(--danger);
  border-left: 1px solid var(--danger-line);
  padding: 0.2rem 0 0.2rem 0.75rem;
  display: none;
  line-height: 1.5;
}
.auth-success {
  color: var(--accent);
  border-left: 1px solid var(--accent);
  padding: 0.2rem 0 0.2rem 0.75rem;
  display: none;
  line-height: 1.5;
}

/* ── logout button ───────────────────────────────────────────── */
.logout-btn {
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.35rem 0.8rem;
  border: 1px solid var(--border-med);
  border-radius: var(--radius);
  color: var(--text-secondary);
  background: var(--bg-hover);
  transition: border-color .15s, color .15s;
}
.logout-btn:hover { border-color: var(--accent); color: var(--accent) }

/* ── account selector ────────────────────────────────────────── */
.acct-selector {
  position: relative; cursor: pointer; user-select: none;
  display: flex; align-items: center; gap: 0.45rem;
  font-size: 0.72rem; color: var(--text);
  border: 1px solid var(--border-med); border-radius: var(--radius);
  padding: 0.3rem 0.65rem;
  transition: border-color 0.15s;
}
.acct-selector:hover { border-color: var(--accent) }
.acct-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); flex-shrink: 0;
}
.acct-name {
  font-weight: 500; max-width: 160px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.acct-caret { font-size: 0.6rem; color: var(--text-tertiary); flex-shrink: 0 }
.acct-dropdown {
  display: none; position: absolute; top: calc(100% + 6px); left: 0;
  background: var(--bg); border: 1px solid var(--border-med);
  border-radius: var(--radius-lg); min-width: 230px; z-index: 200;
  box-shadow: var(--shadow-card); overflow: hidden;
}
.acct-dropdown.open { display: block }
.acct-item {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.6rem 0.9rem; font-size: 0.75rem;
  cursor: pointer; transition: background 0.1s;
}
.acct-item:hover { background: var(--bg-offset) }
.acct-item.active { color: var(--accent) }
.acct-item-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); flex-shrink: 0; opacity: 0;
}
.acct-item.active .acct-item-dot { opacity: 1 }
.acct-item-name { flex: 1 }
.acct-item-role {
  font-size: 0.62rem; color: var(--text-tertiary);
  text-transform: lowercase;
}
.acct-footer {
  padding: 0.5rem 0.9rem; font-size: 0.68rem; color: var(--text-tertiary);
  border-top: 1px solid var(--border);
}

/* ── user menu ───────────────────────────────────────────────── */
.user-menu {
  position: relative; cursor: pointer; user-select: none;
  display: flex; align-items: center; gap: 0.45rem;
  font-size: 0.72rem; color: var(--text-secondary);
  border: 1px solid var(--border-med); border-radius: var(--radius);
  padding: 0.3rem 0.65rem;
  transition: border-color 0.15s;
}
.user-menu:hover { border-color: var(--accent) }
.user-menu-email {
  max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-menu-caret { font-size: 0.6rem; color: var(--text-tertiary); flex-shrink: 0 }
.user-menu-dropdown {
  display: none; position: absolute; top: calc(100% + 6px); right: 0;
  background: var(--bg); border: 1px solid var(--border-med);
  border-radius: var(--radius-lg); min-width: 220px; z-index: 200;
  box-shadow: var(--shadow-card); overflow: hidden;
}
.user-menu-dropdown.open { display: block }
.user-menu-header {
  padding: 0.75rem 1rem; border-bottom: 1px solid var(--border);
  font-size: 0.68rem; color: var(--text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-menu-item {
  display: flex; align-items: center;
  padding: 0.6rem 1rem; font-size: 0.78rem; cursor: pointer;
  transition: background 0.1s; color: var(--text);
  text-decoration: none; border: none; background: none;
  width: 100%; text-align: left; font-family: var(--font-body);
}
.user-menu-item:hover { background: var(--bg-offset); text-decoration: none; color: var(--text) }
.user-menu-item-danger { color: var(--danger) }
.user-menu-item-danger:hover { background: var(--danger-soft); color: var(--danger) }
.user-menu-sep { border: none; border-top: 1px solid var(--border); margin: 0 }

/* ── docs: the three-column ledger (spec §5.4) ────────────────────
   left rail  = where am I in the docs   (sections and pages, never headings)
   content    = the 42em prose measure
   right rail = where am I on the page   (this page's headings, never pages)
   The two rails are never mixed; that is the rule the whole layout exists for.
   ──────────────────────────────────────────────────────────────── */
.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2.2rem 1.25rem 4rem;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, var(--content-max)) var(--aside-w);
  gap: 3rem;
  align-items: start;
}
/* Spend a wide viewport on the rail, never on the measure. The tracks are sized
   rather than flexible on purpose: given free space, `minmax()` on both the
   content and the rail splits it evenly and the measure ends up short. */
@media (min-width: 1320px) {
  .wrap { grid-template-columns: var(--sidebar-w) minmax(0, var(--content-max)) var(--aside-w-wide) }
}

/* ── left rail ─────────────────────────────────────────────────── */
.side, .navfold { font-size: .93em; line-height: 1.6 }
.side {
  position: sticky;
  top: var(--header-h);
  max-height: calc(100vh - 5rem);
  overflow-y: auto;
  padding: .2rem 0 1rem;
}
.side a, .navfold a {
  display: block; color: var(--text-tertiary); text-decoration: none;
  padding: .14rem 0 .14rem .95rem; text-transform: lowercase;
}
.side a:hover, .navfold a:hover { color: var(--text); text-decoration: underline }
/* the two top-level pages sit outside every fold, so they carry the mark
   themselves rather than the accent rail an in-section page gets */
.side a.on, .navfold a.on { color: var(--text); font-weight: 600 }

/* A closed section hangs on the dashed warm-brown rail; an open one carries the
   solid gate-green rail on the panel ground. No chevron — §1 bans icons, and the
   rail already says which state the section is in.

   The closed row behaves as a link and is styled like one on hover (the rail
   lifts to ink, the term underlines): page.html sends a click on it to the
   section's first page, and that page renders the section open. Only an already
   open row folds, so the two gestures never compete. */
details.s > summary {
  list-style: none; cursor: pointer;
  padding: .14rem 0 .14rem .95rem; text-transform: lowercase;
  background: repeating-linear-gradient(180deg, var(--rail) 0 5px, transparent 5px 9px)
              no-repeat left top / 1px 100%;
}
details.s > summary::-webkit-details-marker { display: none }
details.s:not([open]) > summary:hover {
  background: repeating-linear-gradient(180deg, var(--text-secondary) 0 5px, transparent 5px 9px)
              no-repeat left top / 1px 100%;
}
details.s > summary:hover .t,
details.s > summary:focus-visible .t { text-decoration: underline }
details.s > summary .g { color: var(--text-tertiary) }
details.s > summary .g::before { content: " — " }
details.s[open] {
  border-left: 1px solid var(--rail-open);
  background: var(--bg-offset);
  padding-bottom: .25rem;
}
details.s[open] > summary { background: none; padding-left: calc(.95rem - 1px) }
.side a.pg, .navfold a.pg { padding-left: 1.7rem }
details.s[open] a.pg { padding-left: calc(1.7rem - 1px) }
/* two rails deep: gate-green outside for the open section, accent inside for
   the page being read */
details.s a.pg.on {
  border-left: 2px solid var(--accent);
  padding-left: calc(1.7rem - 3px);
  color: var(--text); font-weight: 600;
}
details.s::details-content {
  block-size: 0; overflow: clip;
  transition: block-size .4s ease, content-visibility .4s allow-discrete;
}
details.s[open]::details-content { block-size: auto }

/* ── right rail ────────────────────────────────────────────────── */
.toc {
  font-size: .93em; line-height: 1.6;
  border-left: 1px solid var(--border);
  padding-left: .95rem;
  position: sticky; top: var(--header-h);
  max-height: calc(100vh - 5rem); overflow-y: auto;
}
.toc .lbl { font-style: italic; color: var(--text-secondary); margin: .1rem 0 .45rem }
.toc ul { list-style: none; margin: 0; padding: 0 }
.toc li { margin: 0; padding: 0 }
.toc li::before { display: none }
.toc a {
  display: block; color: var(--text-tertiary); text-decoration: none;
  padding: .12rem 0; text-transform: lowercase;
}
.toc a:hover { color: var(--text) }
/* `configuration.yaml` is one 17-character token and is wider than the narrow
   rail's text box; without this it puts a horizontal scrollbar under the whole
   ladder and clips itself. */
.toc a, .mfold .toc-in a { overflow-wrap: anywhere }
.toc li.h3 a { padding-left: .8rem }
.toc a.on { color: var(--accent); font-weight: 600 }

/* ── narrow: the ladder folds down into the page, then the sections do ──
   Same dashed-rail summary as every other fold, so the collapse changes the
   geometry and not the vocabulary. */
.mfold { display: none; margin: 0 0 1.2rem; font-size: .93em }
.mfold > summary {
  list-style: none; cursor: pointer;
  padding: .14rem 0 .14rem .95rem; font-style: italic; color: var(--text-secondary);
  background: repeating-linear-gradient(180deg, var(--rail) 0 5px, transparent 5px 9px)
              no-repeat left top / 1px 100%;
}
.mfold > summary::-webkit-details-marker { display: none }
.mfold > summary:hover { text-decoration: underline }
.mfold[open] {
  border-left: 1px solid var(--rail-open);
  background: var(--bg-offset); padding-bottom: .3rem;
}
.mfold[open] > summary { background: none; padding-left: calc(.95rem - 1px) }
.mfold .toc-in { padding: .3rem 0 .2rem .95rem }
.mfold .toc-in ul { list-style: none; margin: 0; padding: 0 }
.mfold .toc-in li { margin: 0; padding: 0 }
.mfold .toc-in li::before { display: none }
.mfold .toc-in a {
  display: block; color: var(--text-tertiary); text-decoration: none;
  padding: .12rem 0; text-transform: lowercase;
}
.mfold .toc-in a:hover { color: var(--text) }
.mfold .toc-in li.h3 a { padding-left: .8rem }

/* ── content ───────────────────────────────────────────────────── */
/* The marketing `main` rule above centres a 1200px column and pads it; inside
   the grid that column is the grid track's job, so the docs main resets it.
   Without this the content overruns its track and slides under the right rail. */
main.docs-main { min-width: 0; max-width: none; margin: 0; padding: 0 }
.crumb { color: var(--text-tertiary); text-transform: lowercase; margin: 0 }
.crumb b { font-weight: 400 }
.crumb b::before { content: " — " }

.doc-content { color: var(--text) }
.doc-content h1 {
  font-size: 1.15em; font-weight: 600; text-transform: lowercase;
  margin: .3rem 0 1.1rem; color: var(--text);
}
/* A section start is one unit: the hairline belongs to the heading rather than
   to a free-standing <hr>, which is why an authored `---` sitting directly
   above an h2 is hidden (see the hr rule below). Roman 600 rather than the
   italic second voice — an h2 set at the body size in italic grey sits lighter
   than the prose beneath it, which leaves a long page with no section start the
   eye can find. h3 keeps the italic voice, one step under it. */
.doc-content h2 {
  /* font-style is set back explicitly: the bare `h2` rule above italicises
     every h2 on the stylesheet, and this rule's higher specificity does not
     undo a property it never mentions. */
  font-size: 1.06em; font-weight: 600; font-style: normal; text-transform: lowercase;
  color: var(--text); margin: 2.8rem 0 1rem;
  border-top: 1px solid var(--border); padding-top: 1.2rem;
}
.doc-content h3 {
  font-size: 1em; font-weight: 400; font-style: italic; text-transform: lowercase;
  color: var(--text); margin: 1.9rem 0 .7rem;
}
.doc-content h4 {
  font-size: 1em; font-weight: 600; text-transform: lowercase;
  color: var(--text); margin: 1.4rem 0 .5rem;
}
/* clears the sticky header when a heading is jumped to */
.doc-content h2, .doc-content h3, .doc-content h4 { scroll-margin-top: 4.3rem }
.doc-content p { margin: .85rem 0; color: var(--text) }
.doc-content b, .doc-content strong { font-weight: 600 }
.doc-content ul { margin: .85rem 0; padding-left: 1.3rem; list-style: "– " }
.doc-content ol { margin: .85rem 0; padding-left: 1.5rem; list-style: decimal }
.doc-content li { margin: .3rem 0; padding-left: 0; color: var(--text) }
.doc-content li::before { display: none }
.doc-content li::marker { color: var(--text-tertiary) }
.doc-content hr { border: none; border-top: 1px solid var(--border); margin: 2.4rem 0 }
/* the h2 above draws this one itself; two rules a line apart read as a gap */
.doc-content hr:has(+ h2) { display: none }
.doc-content a { color: inherit; text-decoration: underline; text-underline-offset: 2px }
.doc-content a:hover { color: var(--accent) }
.doc-content blockquote {
  border-left: 1px solid var(--border); margin: 1rem 0; padding: 0 0 0 .95rem;
  color: var(--text-secondary);
}

/* doc code — the chip, same material as the marketing pages */
.doc-content pre {
  background: var(--code-bg); color: var(--code-text);
  padding: .9rem 1.1rem; margin: 1rem 0;
  overflow-x: auto; font: inherit; font-size: .94em; line-height: 1.6;
}
.doc-content pre code { background: none; padding: 0; color: inherit; font: inherit }
.doc-content code { font: inherit; background: var(--inline-code-bg); color: var(--inline-code-fg); padding: .05em .3em }

/* the copy control build-docs.js puts on every code chip. The wrapper does not
   scroll, so the glyph keeps its corner while a wide block scrolls under it;
   the right padding keeps a long first line from running beneath it. Visible
   at half strength rather than on hover only, because a phone has no hover. */
.doc-content .cb { position: relative }
.doc-content .cb pre { padding-right: 2.75rem }
.doc-content .cb .copy {
  position: absolute; top: .55rem; right: .55rem;
  font: inherit; font-size: .95em; line-height: 1;
  padding: .15rem .35rem; border: 0; border-radius: 0; cursor: pointer;
  background: var(--code-bg); color: var(--code-text); opacity: .55;
}
.doc-content .cb .copy:hover, .doc-content .cb .copy:focus-visible { opacity: 1 }
.doc-content .cb .copy[data-state] { opacity: 1; font-size: .72em; letter-spacing: .02em }

/* syntax highlighting — highlight.js tokens, rendered at build time by
   build-docs.js. The palette is the site's own (see --hl-* above): the chip is
   a light panel now, so nothing here may assume a dark ground. */
.hljs-comment, .hljs-quote, .hljs-meta { color: var(--hl-comment) }
.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-built_in,
.hljs-type, .hljs-title.class_ { color: var(--hl-keyword); font-style: italic }
.hljs-string, .hljs-addition, .hljs-symbol, .hljs-bullet, .hljs-regexp { color: var(--hl-string) }
.hljs-number { color: var(--hl-number) }
.hljs-title, .hljs-title.function_, .hljs-section, .hljs-name { color: var(--hl-title); font-weight: 600 }
.hljs-attr, .hljs-attribute, .hljs-property, .hljs-variable,
.hljs-template-variable, .hljs-params { color: var(--hl-attr) }
.hljs-deletion { color: var(--danger) }
.hljs-emphasis { font-style: italic }
.hljs-strong { font-weight: 600 }

/* doc tables — hairline row rules only, no zebra, header row in the grey voice */
.doc-content .tbl { overflow-x: auto; margin: 1rem 0 }
.doc-content table { border-collapse: collapse; font-size: .94em; width: 100% }
.doc-content th, .doc-content td {
  text-align: left; padding: .35rem 1.1rem .35rem 0;
  border-bottom: 1px solid var(--border); vertical-align: top; color: var(--text);
}
.doc-content th {
  color: var(--text-tertiary); font-weight: 400; text-transform: lowercase;
}

/* ── dashboard ───────────────────────────────────────────────── */
.dash {
  display: none;
  padding: 2.5rem 2rem 6rem;
  max-width: var(--max-width);
  margin: 0 auto;
  position: relative; z-index: 2;
}
.dash-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2.5rem;
}
.dash-email { font-size: 0.75rem; color: var(--text-secondary); margin-top: 0.125rem }

/* section header */
.section-hd {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 2.5rem 0 0.75rem;
}
.section-hd h2 {
  font-size: 1em;
  font-weight: 400;
  font-style: italic;
  text-transform: lowercase;
  color: var(--text-secondary);
  margin: 0;
}
.section-hd .count { font-size: 0.75rem; color: var(--text-tertiary) }

/* sparse list */
.sparse-list {
  border: 1px solid var(--border-med);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
  background: var(--paper);
}
.sparse-row {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background .1s;
}
.sparse-row:last-child { border-bottom: none }
.sparse-row:hover { background: var(--bg-offset) }
.sparse-name {
  font-size: 0.85rem; font-weight: 500; color: var(--text); min-width: 120px;
}
.sparse-url {
  flex: 1; font-size: 0.75rem; color: var(--accent);
  text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--font-mono);
}
.sparse-url:hover { text-decoration: underline }
.sparse-meta {
  font-size: 0.75rem; color: var(--text-tertiary); white-space: nowrap; margin-left: auto;
}
.sparse-arrow { font-size: 0.75rem; color: var(--text-tertiary); margin-left: 0.375rem; flex-shrink: 0 }

/* badges */
.badge {
  display: inline-block; font-size: 0.6rem; font-weight: 600;
  padding: 0.12rem 0.45rem; border-radius: 0;
  text-transform: lowercase; flex-shrink: 0;
}
.badge-js     { background: var(--tissue-amber, #b7791f); color: var(--tissue-on-accent, #fff) }
.badge-wasm   { background: var(--tissue-ink-2, #47554e); color: var(--tissue-on-accent, #fff) }
.badge-sqlite { background: var(--accent-light); color: var(--accent) }

.binding-chip {
  font-family: var(--font-mono); font-size: 0.65rem;
  padding: 0.12rem 0.4rem; border: 1px solid var(--border-med);
  border-radius: 0; color: var(--text-secondary); flex-shrink: 0;
}

/* empty state */
.empty-state {
  padding: 3rem 1rem; text-align: center; color: var(--text-secondary);
  font-size: 0.875rem; border: 1px solid var(--border-med);
  border-radius: var(--radius-md); background: var(--paper);
}
.empty-state a { color: var(--accent) }

/* detail view */
.detail-view { display: none }
.back-btn {
  font-family: var(--font-body); font-size: 0.75rem; font-weight: 500;
  background: none; border: 1px solid var(--border-med);
  border-radius: var(--radius); color: var(--text-secondary);
  padding: 0.35rem 0.75rem; transition: border-color .1s, color .1s;
  margin-bottom: 1.75rem;
}
.back-btn:hover { border-color: var(--accent); color: var(--accent) }

.detail-title {
  font-size: 1.15em; font-weight: 600; text-transform: lowercase;
  color: var(--text); margin-bottom: 0.25rem;
}
.detail-sub { font-size: 0.78rem; color: var(--text-secondary); margin-bottom: 1.75rem }

.detail-actions { display: flex; gap: 0.5rem; margin-bottom: 2rem; flex-wrap: wrap }
.btn-visit, .btn-danger, .btn-primary {
  font-family: var(--font-body); font-size: 0.75rem; font-weight: 500;
  padding: 0.42rem 1rem; border-radius: var(--radius); cursor: pointer;
  transition: all .1s; text-decoration: none; border: 1px solid;
  display: inline-flex; align-items: center;
}
.btn-visit {
  border-color: var(--border-med); color: var(--text-secondary); background: var(--bg-hover);
}
.btn-visit:hover {
  border-color: var(--accent); color: var(--accent); text-decoration: none;
  background: var(--accent-light);
}
.btn-danger { border-color: var(--danger); color: var(--danger); background: var(--danger-soft) }
.btn-danger:hover { background: var(--danger); color: var(--tissue-on-accent, #fff) }
.btn-primary { border-color: var(--accent); color: var(--accent); background: var(--accent-light) }
.btn-primary:hover { background: var(--accent); color: var(--tissue-on-accent, #fff) }

.info-grid {
  display: grid; grid-template-columns: 140px 1fr;
  gap: 0.6rem 1rem; font-size: 0.85rem; margin-bottom: 1.75rem;
}
.info-label { color: var(--text-secondary) }
.info-val { color: var(--text); word-break: break-all }
.info-val a { color: var(--accent) }
.info-val a:hover { text-decoration: underline }

.detail-section { margin-top: 2rem }
.detail-section-hd {
  font-style: italic; text-transform: lowercase;
  color: var(--text-secondary); margin-bottom: 0.75rem;
}

/* SQL runner */
.sql-wrap { display: flex; flex-direction: column; gap: 0.5rem }
.sql-input {
  width: 100%; font-family: var(--font-mono); font-size: 0.8rem;
  background: var(--paper); border: 1px solid var(--border-med);
  border-radius: var(--radius-md); color: var(--text);
  padding: 0.6rem 0.75rem; resize: vertical; min-height: 80px;
  transition: border-color .15s, box-shadow .15s; outline: none;
}
.sql-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light) }
.sql-result {
  font-family: var(--font-mono); font-size: 0.78rem;
  background: var(--bg-offset); border: 1px solid var(--border-med);
  border-radius: var(--radius-md); padding: 0.75rem; overflow-x: auto;
  white-space: pre; color: var(--text); max-height: 300px; overflow-y: auto; display: none;
}
.sql-result.show { display: block }

/* tables list in detail */
.table-list {
  border: 1px solid var(--border-med); border-radius: var(--radius-md);
  overflow: hidden; background: var(--paper);
}
.table-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.55rem 0.875rem; border-bottom: 1px solid var(--border); font-size: 0.85rem;
}
.table-row:last-child { border-bottom: none }
.table-name { color: var(--text); font-weight: 500 }
.table-rows { color: var(--text-secondary); font-size: 0.78rem }

/* schema block */
.schema-block {
  font-family: var(--font-mono); font-size: 0.78rem;
  background: var(--code-bg); border-radius: var(--radius-md);
  padding: 0.875rem 1rem; color: var(--code-text); overflow-x: auto; white-space: pre;
}

.cell-chips { display: flex; gap: 0.375rem; flex-wrap: wrap }
.cell-chip {
  font-size: 0.78rem; padding: 0.2rem 0.55rem;
  border: 1px solid var(--border-med); border-radius: var(--radius);
  color: var(--text); background: var(--paper); cursor: pointer;
  transition: border-color .1s, color .1s;
}
.cell-chip:hover { border-color: var(--accent); color: var(--accent) }

/* confirm modal */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex }
.modal {
  background: var(--bg); border: 1px solid var(--border-med);
  border-radius: var(--radius-lg); padding: 1.5rem; max-width: 380px; width: 90%;
  box-shadow: var(--shadow-card);
}
.modal h3 { font-size: 1rem; font-weight: 600; color: var(--text); margin-bottom: 0.5rem }
.modal p  { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 1.25rem }
.modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end }
.btn-cancel {
  font-family: var(--font-body); font-size: 0.78rem; font-weight: 500;
  padding: 0.4rem 0.875rem; border: 1px solid var(--border-med);
  border-radius: var(--radius); background: var(--bg-hover); color: var(--text-secondary); cursor: pointer;
  transition: border-color .1s, color .1s;
}
.btn-cancel:hover { border-color: var(--text-secondary); color: var(--text) }
.btn-delete {
  font-family: var(--font-body); font-size: 0.78rem; font-weight: 500;
  padding: 0.4rem 0.875rem; border: none;
  border-radius: var(--radius); background: var(--danger); color: var(--tissue-on-accent, #fff); cursor: pointer;
  transition: background .1s;
}
.btn-delete:hover { background: var(--tissue-danger, #c0392b); filter: brightness(.85) }

.placeholder { color: var(--text-tertiary); font-size: 0.85rem }
.danger-zone { margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid var(--danger-line) }
.danger-zone .detail-section-hd { color: var(--danger) }

/* tech highlight (homepage) */
.tech-highlight { color: var(--text); font-weight: 400 }

/* ── responsive ──────────────────────────────────────────────── */
@media (min-width: 600px) {
  .architecture-grid { grid-template-columns: repeat(3, 1fr) }
}
/* The right rail leaves first and comes back as a fold above the content; the
   left rail follows at the narrower step. Both keep the dashed-rail summary. */
@media (max-width: 1160px) {
  .wrap { grid-template-columns: var(--sidebar-w) minmax(0, var(--content-max)) }
  .toc { display: none }
  details.pagefold { display: block }
}
@media (max-width: 860px) {
  .wrap { display: block; padding: 1.5rem 1.25rem 3rem }
  .side { display: none }
  details.navfold { display: block }
}
@media (max-width: 600px) {
  .header-inner { padding: .7rem 1.25rem }
  main { padding: 2.5rem 1.25rem 4rem }
  .dash { padding: 1.5rem 1.25rem 4rem }
  .hdr-link { display: none }
  footer { flex-direction: column; gap: 0.75rem; text-align: center }
}

/* ── docs search ─────────────────────────────────────────────── */
.docs-search { position: relative; margin: 0 0 1rem; }
.docs-search input {
  width: 100%; font: inherit;
  padding: 0.28rem 0.55rem;
  border: 1px solid var(--border); border-radius: 0;
  background: var(--bg); color: var(--text);
}
.docs-search input::placeholder { color: var(--text-tertiary) }
.docs-search input:focus { border-color: var(--accent); }
.docs-search-results {
  position: absolute; z-index: 50; top: calc(100% + 4px); left: 0;
  width: min(30rem, 88vw); max-height: 24rem; overflow-y: auto;
  background: var(--bg); border: 1px solid var(--border-med);
}
.ds-item { display: block; padding: 0.5rem 0.75rem; text-decoration: none; color: inherit;
  border-bottom: 1px solid var(--border); }
.ds-item:last-child { border-bottom: none; }
.ds-item:hover, .ds-item.active { background: var(--bg-offset); }
.ds-title { display: block; font-weight: 600; }
.ds-sep { color: var(--text-tertiary); font-weight: 400; }
.ds-meta { display: block; font-size: 0.85em; text-transform: lowercase;
  color: var(--text-tertiary); margin: 0.05rem 0 0.15rem; }
.ds-snip { display: block; font-size: 0.85em; line-height: 1.5; color: var(--text-secondary); }
.ds-snip mark, .ds-title mark { background: var(--bg-offset); color: var(--accent); padding: 0 .05em; }
.ds-empty { padding: 0.7rem 0.8rem; color: var(--text-tertiary); }
@media (max-width: 900px) { .docs-search-results { width: 88vw; } }

/* ── reduced motion ──────────────────────────────────────────────
   The folds and the heading-jump are the only motion the system has; both are
   optional. Everything degrades to an instant state change. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important }
  html { scroll-behavior: auto }
}
