/* The Larch — one stylesheet for every page.
   One type scale, one 4px spacing grid, one palette, one set of components
   (buttons, badges, tables, cards). */

/* ─── Tokens ───────────────────────────────────────────────────────────── */
:root {
  color-scheme: light;
  /* palette */
  --bg: #f5f8f7;
  --paper: #ffffff;
  --ink: #0e1b22;
  --muted: #5b6b76;
  --faint: #95a2aa;
  --line: #dbe5e2;
  --line-soft: #eaf0ee;
  --accent: #0b7e78;
  --accent-ink: #096a65;
  --accent-soft: #e7f3f1;
  --link: #2a679f;
  --warn-bg: #fff6da;
  --warn-ink: #6f5300;
  --warn-line: #e3b33a;
  --danger-soft: #fdf1f3;
  --danger-ink: #8a3a52;
  /* type scale */
  --fs-xs: 11px;
  --fs-sm: 12.5px;
  --fs-md: 14px;
  --fs-lg: 16px;
  --fs-xl: 20px;
  --fs-2xl: 28px;
  --lh: 1.5;
  --font: Inter, "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  /* spacing grid */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  /* radii and shadow */
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px;
  --shadow: 0 2px 10px rgba(14, 40, 45, .08);
  --shadow-lg: 0 18px 48px rgba(14, 40, 45, .18);
  --header-h: 60px;
}

/* ─── Base ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body { font: var(--fs-md)/var(--lh) var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, p, ul, ol, figure, blockquote { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: var(--mono); font-size: .92em; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ─── Components: buttons ──────────────────────────────────────────────── */
.larch-btn, .larch-hbtn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s1);
  min-height: 34px; padding: 0 var(--s3);
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--paper);
  font-size: var(--fs-sm); font-weight: 600; line-height: 1.2; color: var(--ink);
  white-space: nowrap; text-decoration: none;
}
.larch-btn:hover, .larch-hbtn:hover { border-color: var(--accent); text-decoration: none; }
.larch-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.larch-btn.primary:hover { background: var(--accent-ink); }
.larch-btn.small { min-height: 26px; padding: 0 var(--s2); font-size: var(--fs-xs); }
.larch-btn.wide { width: 100%; }
.larch-btn:disabled { opacity: .5; cursor: not-allowed; }
.larch-hbtn { border-color: transparent; background: transparent; color: var(--muted); }
.larch-hbtn:hover, .larch-hbtn[aria-current="page"] { color: var(--ink); background: var(--accent-soft); border-color: transparent; }

/* ─── Components: badges and counters ──────────────────────────────────── */
.larch-badge, .larch-ev, .larch-lang {
  display: inline-flex; align-items: center; gap: var(--s1);
  padding: 0 var(--s2); min-height: 20px; border-radius: var(--r-sm);
  font-size: var(--fs-xs); font-weight: 600; line-height: 1.3; white-space: nowrap; vertical-align: 1px;
}
.larch-badge.ok { background: #e6f4ec; color: #17603a; }
.larch-badge.hyp { background: var(--warn-bg); color: var(--warn-ink); }
.larch-badge.neutral { background: var(--line-soft); color: var(--muted); }
.larch-lang { padding: 0 var(--s1); min-height: 18px; color: var(--muted); border: 1px solid var(--line); font-weight: 500; }
.larch-ev { background: var(--paper); border: 1.5px solid; }
.larch-ev b { font-weight: 800; }
.ev-science_confirmed { border-color: #2e9b4f; color: #1d6a39; background: #eaf6ee; }
.ev-nlp_author_claim { border-color: #4f6d8f; color: #334d69; border-style: dashed; }
.ev-nlp_internal { border-color: #8a979f; color: #4b5960; background: #f2f4f5; }
.ev-hypothesis { border-color: #d99a00; color: #6f5300; border-style: dashed; background: #fff8e1; }
.ev-disputed { border-color: #c0392b; color: #8e2419; border-style: dotted; }
.ev-no_analog { border-color: #9aa3a8; color: #5f686e; border-style: dotted; }
.ev-historical { border-color: #8a6d3b; color: #654c22; border-style: double; border-width: 3px; }
.ev-association { border-color: #a58bc4; color: #634a85; border-style: dotted; }
.ev-broader { border-color: #6d8f3b; color: #48661f; border-style: dashed; }
.larch-count { font-variant-numeric: tabular-nums; font-weight: 700; font-size: var(--fs-xs); color: var(--accent); }
.larch-meta { color: var(--muted); font-size: var(--fs-sm); }
.larch-dim { color: var(--muted); font-size: var(--fs-sm); }
.larch-missing { color: var(--faint); }
.larch-orig { color: var(--muted); font-size: .86em; font-weight: 400; }
.larch-list { padding-left: 18px; display: grid; gap: var(--s1); }
.larch-empty { border: 1px dashed #d9a3b3; background: var(--danger-soft); color: var(--danger-ink); border-radius: var(--r-md); padding: var(--s2) var(--s3); font-size: var(--fs-sm); }
.larch-empty-note { color: var(--muted); font-size: var(--fs-sm); font-style: italic; }
.larch-pre { white-space: pre-wrap; word-break: break-word; background: var(--line-soft); border-radius: var(--r-md); padding: var(--s3); font-size: var(--fs-sm); margin: var(--s2) 0; }
[data-src-text] { font-style: normal; }

/* ─── Page header (all pages) ──────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; gap: var(--s3);
  min-height: var(--header-h); padding: 0 var(--s5);
  background: rgba(255, 255, 255, .96); border-bottom: 1px solid var(--line);
  position: relative; z-index: 20;
}
.ph-brand { display: flex; align-items: center; gap: var(--s3); color: var(--ink); text-decoration: none; min-width: 0; }
.ph-brand:hover { text-decoration: none; }
.ph-mark { flex: 0 0 36px; height: 36px; border-radius: var(--r-md); display: grid; place-items: center; background: var(--accent); color: #fff; font-weight: 800; font-size: var(--fs-sm); }
.ph-titles { display: grid; min-width: 0; line-height: 1.25; }
.ph-title { font-size: var(--fs-lg); font-weight: 750; letter-spacing: -.01em; }
.ph-sub { font-size: var(--fs-sm); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ph-nav { display: flex; gap: var(--s1); margin-left: auto; }
.ph-lang { display: flex; align-items: center; gap: var(--s2); }
.larch-prereg {
  display: inline-flex; align-items: center; min-height: 26px; padding: 0 var(--s2);
  font-size: var(--fs-xs); font-weight: 600; color: var(--warn-ink);
  background: var(--warn-bg); border: 1px dashed var(--warn-line); border-radius: var(--r-sm); white-space: nowrap;
}
.larch-langsw { display: flex; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: var(--r-md); }
.larch-langsw button { border: 0; background: transparent; border-radius: var(--r-sm); padding: 3px var(--s2); font-size: var(--fs-xs); font-weight: 700; color: var(--muted); }
.larch-langsw button.active { background: var(--accent); color: #fff; }
.larch-lang-note { font-size: var(--fs-xs); color: var(--muted); line-height: 1.25; white-space: nowrap; }

/* ─── App shell (map page) ─────────────────────────────────────────────── */
body.larch-app { display: grid; grid-template-rows: auto 1fr auto; grid-template-columns: minmax(0, 1fr); height: 100vh; height: 100dvh; overflow: hidden; }
.larch-prereg-row { margin-bottom: var(--s4); }
.larch-prereg-row .larch-prereg { white-space: normal; width: 100%; padding: var(--s1) var(--s2); line-height: 1.35; }
.app { display: grid; grid-template-columns: 300px minmax(0, 1fr) 400px; min-height: 0; }
.sidebar { background: var(--paper); border-right: 1px solid var(--line); padding: var(--s4) var(--s4) var(--s6); overflow-y: auto; scrollbar-width: thin; }
.stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; }
.inspector { background: var(--paper); border-left: 1px solid var(--line); overflow-y: auto; scrollbar-width: thin; }
#graph { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }

/* sidebar */
.field { display: grid; gap: var(--s1); }
.field input { width: 100%; min-height: 36px; border: 1px solid var(--line); border-radius: var(--r-md); padding: 0 var(--s3); background: var(--paper); }
.field input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.ctrl-group { border-top: 1px solid var(--line-soft); padding: var(--s4) 0; margin-top: var(--s4); }
.ctrl-group + .ctrl-group { margin-top: 0; }
.ctrl-label { display: block; font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: var(--s2); }
summary.ctrl-label { cursor: pointer; margin: 0; }
.search-results { display: grid; gap: 2px; }
.search-results button { display: grid; text-align: left; border: 0; background: transparent; border-radius: var(--r-sm); padding: var(--s1) var(--s2); font-size: var(--fs-sm); font-weight: 600; }
.search-results button:hover { background: var(--accent-soft); }
.search-results button span { font-size: var(--fs-xs); font-weight: 400; color: var(--muted); }
.model-list { display: grid; gap: var(--s2); }
.larch-model { display: flex; gap: var(--s3); align-items: flex-start; width: 100%; text-align: left; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--paper); padding: var(--s2) var(--s3); }
.larch-model:hover { border-color: var(--accent); }
.larch-model.open { border-color: var(--accent); background: var(--accent-soft); }
.larch-model-mark { flex: 0 0 22px; height: 22px; margin-top: 1px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: var(--fs-sm); }
.larch-model-body { display: grid; gap: 2px; min-width: 0; }
.larch-model strong { font-size: var(--fs-md); line-height: 1.3; }
.larch-model small { font-size: var(--fs-xs); color: var(--muted); }
.larch-mini { display: flex; flex-wrap: wrap; gap: var(--s1); }
.larch-mini .larch-ev { font-style: normal; min-height: 18px; padding: 0 5px; }
.larch-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); margin-top: var(--s2); }
.larch-check { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-sm); padding: 3px 0; cursor: pointer; }
.larch-check > span:first-of-type { flex: 1; }
.larch-status-filter { display: grid; gap: 2px; }
.larch-ev-btn { display: flex; justify-content: space-between; align-items: center; gap: var(--s2); border: 1px solid transparent; background: transparent; border-radius: var(--r-sm); padding: 3px var(--s1); text-align: left; font-size: var(--fs-sm); }
.larch-ev-btn:hover { background: var(--line-soft); }
.larch-ev-btn.active { border-color: var(--accent); background: var(--accent-soft); }
.larch-layers { display: grid; }
.larch-pills { display: grid; gap: 2px; }
.larch-pill { display: flex; justify-content: space-between; gap: var(--s2); border: 1px solid transparent; background: transparent; border-radius: var(--r-sm); padding: 3px var(--s1); text-align: left; font-size: var(--fs-sm); }
.larch-pill:hover { background: var(--line-soft); }
.larch-pill.active { border-color: var(--accent); background: var(--accent-soft); }
.larch-more summary { cursor: pointer; font-size: var(--fs-sm); color: var(--muted); padding: var(--s1); }
.larch-prov { display: grid; gap: var(--s2); font-size: var(--fs-sm); color: var(--muted); margin-top: var(--s2); }
.larch-prov b { color: var(--ink); font-weight: 600; }

/* stage controls */
.larch-views { position: absolute; top: var(--s3); left: var(--s3); z-index: 4; display: flex; gap: 2px; padding: 3px; background: rgba(255,255,255,.95); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); max-width: calc(100% - 80px); overflow-x: auto; scrollbar-width: none; }
.larch-view { border: 0; background: transparent; border-radius: var(--r-md); padding: 6px var(--s3); font-weight: 600; font-size: var(--fs-md); color: var(--muted); white-space: nowrap; }
.larch-view:hover { color: var(--ink); background: var(--line-soft); }
.larch-view.active { background: var(--accent); color: #fff; }
.larch-sides { position: absolute; top: 62px; left: var(--s3); z-index: 4; display: flex; gap: 2px; padding: 2px; background: rgba(255,255,255,.95); border: 1px solid var(--line); border-radius: var(--r-md); }
.larch-side { border: 0; background: transparent; border-radius: var(--r-sm); padding: 3px var(--s3); font-weight: 600; font-size: var(--fs-sm); color: var(--muted); }
.larch-side.active { background: var(--accent-soft); color: var(--ink); }
.zoom-controls { position: absolute; top: var(--s3); right: var(--s3); z-index: 4; display: grid; gap: var(--s1); }
.zoom-controls button { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: var(--r-md); background: rgba(255,255,255,.95); box-shadow: var(--shadow); font-size: var(--fs-lg); font-weight: 700; display: grid; place-items: center; padding: 0; }
.zoom-controls button:hover { border-color: var(--accent); }
.zoom-controls .larch-export { font-size: 10px; font-weight: 800; letter-spacing: .03em; }
.zoom-controls #export-svg { margin-top: var(--s2); }
.tooltip { position: fixed; z-index: 30; max-width: 260px; pointer-events: none; background: var(--ink); color: #fff; border-radius: var(--r-sm); padding: var(--s1) var(--s2); font-size: var(--fs-sm); box-shadow: var(--shadow); }
.tooltip strong { font-weight: 700; }

/* table views */
.larch-table-view { position: absolute; inset: 0; overflow: auto; padding: 64px var(--s5) var(--s5); background: var(--paper); }
.larch-summary { font-size: var(--fs-md); max-width: 1000px; margin: var(--s2) 0 var(--s4); }
.larch-how { font-size: var(--fs-sm); white-space: nowrap; margin-left: var(--s1); }
.larch-h3 { font-size: var(--fs-lg); margin: var(--s5) 0 var(--s2); }
.larch-actions { margin: 0 0 var(--s4); }
.larch-scroll { overflow-x: auto; }

/* ─── Components: tables ───────────────────────────────────────────────── */
.larch-table { border-collapse: collapse; width: 100%; font-size: var(--fs-sm); }
.larch-table th, .larch-table td { padding: var(--s2) var(--s3) var(--s2) 0; border-bottom: 1px solid var(--line-soft); vertical-align: top; text-align: left; }
.larch-table thead th { position: sticky; top: -64px; z-index: 1; background: var(--paper); border-bottom: 1px solid var(--line); font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.larch-table tbody th { font-weight: 600; }
.larch-table.larch-num td { text-align: right; font-variant-numeric: tabular-nums; }
.larch-mrow th { padding-top: var(--s5); border-bottom: 1px solid var(--line); font-size: var(--fs-lg); font-weight: 700; }
.larch-graph-link { font-size: var(--fs-sm); font-weight: 500; margin-left: var(--s3); }
.larch-matrix { table-layout: fixed; }
.larch-matrix col.c1 { width: 19%; } .larch-matrix col.c2 { width: 19%; } .larch-matrix col.c3 { width: 19%; }
.larch-matrix col.c4 { width: 27%; } .larch-matrix col.c5 { width: 12%; } .larch-matrix col.c6 { width: 32px; }
.larch-matrix .larch-ev { white-space: nowrap; }
.larch-src { list-style: none; padding: 0; display: grid; gap: var(--s1); }
.larch-links { font-size: var(--fs-xs); color: var(--muted); }
.larch-c-edit { text-align: right; }
.larch-edit { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: var(--r-sm); color: var(--muted); }
.larch-edit:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.larch-authors tbody th { white-space: nowrap; }
.larch-authors td { min-width: 120px; }
.larch-evo td, .larch-evo th { width: 25%; }
.larch-chip { margin: 0 0 var(--s1); }
.larch-year { font-size: var(--fs-xs); color: var(--muted); border-bottom: 1px dotted; }
.larch-gaps { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: var(--s5); }
.larch-gaps h3 { font-size: var(--fs-md); margin: 0 0 var(--s2); }
.larch-jangle .larch-list { padding-left: 0; list-style: none; }

/* ─── Components: card (right panel) ───────────────────────────────────── */
.larch-card { padding: var(--s5) var(--s5) var(--s6); font-size: var(--fs-md); }
.larch-kind { font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); margin-bottom: var(--s1); }
.larch-title { font-size: var(--fs-xl); font-weight: 750; line-height: 1.25; letter-spacing: -.01em; margin-bottom: var(--s2); }
.larch-sub { color: var(--muted); margin-bottom: var(--s3); }
.larch-sec { border-top: 1px solid var(--line-soft); padding: var(--s4) 0 var(--s1); }
.larch-sec h3 { font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: var(--s2); }
.larch-sec h4 { font-size: var(--fs-sm); font-weight: 700; margin: var(--s3) 0 var(--s1); }
.larch-sec p + p { margin-top: var(--s1); }
.larch-note { border-left: 3px solid var(--line); padding-left: var(--s3); color: var(--muted); margin-top: var(--s2); }
.larch-ru-note summary { cursor: pointer; color: var(--muted); font-size: var(--fs-sm); }
.larch-ru-note [data-src-text] { display: block; margin-top: var(--s1); }
.larch-stats { margin: calc(-1 * var(--s1)) 0 var(--s2); }
.larch-quote { border: 1px solid var(--line-soft); border-radius: var(--r-md); padding: var(--s2) var(--s3); margin: var(--s2) 0; }
.larch-quote summary { cursor: pointer; font-size: var(--fs-sm); }
.larch-quote blockquote, .larch-bq { margin: var(--s2) 0; padding: var(--s1) 0 var(--s1) var(--s3); border-left: 3px solid var(--accent); white-space: pre-line; font-size: var(--fs-md); }
.larch-quote blockquote::before, .larch-bq::before { content: open-quote; }
.larch-quote blockquote::after, .larch-bq::after { content: close-quote; }
.larch-author h4 { margin-top: var(--s4); }
.larch-chain { display: grid; gap: var(--s2); }
.larch-chain > div { background: var(--line-soft); border-radius: var(--r-md); padding: var(--s2) var(--s3); display: flex; flex-wrap: wrap; gap: var(--s1) var(--s3); align-items: center; font-size: var(--fs-sm); }
.larch-chain > div > b { width: 100%; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.larch-review { border: 1px solid var(--line-soft); border-radius: var(--r-md); padding: var(--s2) var(--s3); margin: var(--s2) 0; }
.larch-overlap { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s3); margin-bottom: var(--s2); }
.larch-legend-list { list-style: none; padding: 0; display: grid; gap: var(--s2); margin: var(--s2) 0 var(--s3); }
.larch-legend-list li { display: grid; grid-template-columns: auto 1fr auto; gap: var(--s2); align-items: baseline; font-size: var(--fs-sm); }
.larch-legend-text { color: var(--muted); }

/* ─── Footer and modal ─────────────────────────────────────────────────── */
.larch-footer { display: flex; justify-content: space-between; gap: var(--s5); padding: var(--s2) var(--s5); font-size: var(--fs-xs); color: var(--muted); border-top: 1px solid var(--line); background: var(--paper); }
.larch-footer > span:first-child { max-width: 1100px; }
#footer-version { white-space: nowrap; }
.larch-modal { width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 64px); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s5); box-shadow: var(--shadow-lg); color: var(--ink); }
.larch-modal::backdrop { background: rgba(14, 27, 34, .35); }
.larch-modal h2 { font-size: var(--fs-xl); margin-bottom: var(--s3); }
.larch-modal h3 { display: flex; align-items: center; justify-content: space-between; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: var(--s4) 0 0; }
.larch-modal p { margin: var(--s2) 0; }
.larch-modal .larch-btn.primary { white-space: normal; text-align: center; padding: var(--s2) var(--s3); }
.larch-modal form { margin-top: var(--s4); display: flex; justify-content: flex-end; }
.larch-modal details { margin-top: var(--s3); font-size: var(--fs-sm); }

/* ─── Text pages: Methods, Agents, Sign in ─────────────────────────────── */
body.larch-page { min-height: 100vh; }
.larch-doc { max-width: 860px; margin: 0 auto; padding: var(--s6) var(--s5) 64px; }
.larch-doc h1 { font-size: var(--fs-2xl); line-height: 1.2; margin-bottom: var(--s3); }
.larch-doc h2 { font-size: var(--fs-xl); margin: var(--s6) 0 var(--s2); }
.larch-doc h3 { font-size: var(--fs-lg); margin: var(--s5) 0 var(--s2); }
.larch-doc p { margin: var(--s2) 0; }
.larch-doc .larch-list { margin: var(--s2) 0; }
.larch-doc .larch-table { margin: var(--s3) 0; background: var(--paper); }
.larch-doc-meta { margin: 0 0 var(--s2); }
.larch-doc .larch-prereg { white-space: normal; padding: var(--s1) var(--s2); }
.larch-doc td code, .larch-doc p code { overflow-wrap: anywhere; }
.larch-login-box { width: min(400px, calc(100vw - 32px)); margin: 10vh auto; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s6); display: grid; gap: var(--s4); box-shadow: var(--shadow); }
.larch-login-box h1 { font-size: var(--fs-xl); }
.larch-login-box form { display: grid; gap: var(--s3); }
.larch-login-box .larch-btn { min-height: 40px; }

/* ─── Narrow desktop ───────────────────────────────────────────────────── */
@media (max-width: 1360px) {
  .ph-sub { display: none; }
  .app { grid-template-columns: 260px minmax(0, 1fr) 340px; }
  .larch-view { padding: 6px var(--s2); }
}
@media (max-width: 1180px) {
  .page-header { flex-wrap: wrap; padding: var(--s2) var(--s4); gap: var(--s2) var(--s3); }
  .ph-nav { order: 5; flex: 1 1 100%; margin: 0; }
}

/* ─── Mobile and tablet: one column, the page scrolls ──────────────────── */
@media (max-width: 960px) {
  body.larch-app { display: block; height: auto; overflow: visible; }
  .page-header { flex-wrap: wrap; gap: var(--s2) var(--s3); padding: var(--s2) var(--s4); }
  .ph-brand { flex: 1 1 auto; }
  .ph-sub { display: none; }
  .ph-lang { order: 2; }
  .ph-login { order: 3; min-height: 30px; }
  .ph-nav { order: 5; flex: 1 1 100%; margin: 0 calc(-1 * var(--s4)); padding: 0 var(--s4); overflow-x: auto; scrollbar-width: none; }
  .ph-nav .larch-hbtn { border: 1px solid var(--line); }
  .larch-lang-note { white-space: normal; }
  .app { display: flex; flex-direction: column; }
  .stage { order: 1; overflow: visible; }
  .inspector { order: 2; border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
  /* the sidebar dissolves: search goes first, filters go last */
  .sidebar { display: contents; }
  .sidebar > * { padding-left: var(--s4); padding-right: var(--s4); background: var(--paper); }
  .larch-prereg-row { order: 0; margin: 0; padding-top: var(--s3); }
  .sidebar > .field { order: 0; padding-top: var(--s3); padding-bottom: var(--s3); border-bottom: 1px solid var(--line); }
  .sidebar > .ctrl-group { order: 3; margin: 0; }
  .larch-views { position: static; max-width: none; margin: var(--s3) var(--s3) 0; box-shadow: none; }
  .larch-sides { top: 64px; }
  .zoom-controls { top: 64px; }
  body:not(.table-mode) .stage { height: 70vh; }
  body:not(.table-mode) .stage #graph { height: calc(70vh - 56px); }
  .larch-table-view { position: static; padding: var(--s3) var(--s4) var(--s5); }
  .larch-table thead th { top: 0; }
  .larch-card { padding: var(--s4); }
  /* wide tables become stacked cards */
  .larch-cards, .larch-cards tbody, .larch-cards tr, .larch-cards td, .larch-cards tbody th { display: block; width: auto !important; }
  .larch-cards thead, .larch-cards colgroup { display: none; }
  .larch-cards tr { border-bottom: 1px solid var(--line); padding: var(--s2) 0; position: relative; }
  .larch-cards td, .larch-cards tbody th { border: 0; padding: 2px 0; }
  .larch-cards td[data-label]::before { content: attr(data-label); display: block; font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
  .larch-cards .larch-c-edit { position: absolute; top: var(--s2); right: 0; }
  .larch-cards td.is-empty { display: none; }
  .larch-cards .larch-mrow { border-bottom: 0; padding-bottom: 0; }
  .larch-cards .larch-mrow th { padding-top: var(--s4); }
  .larch-footer { flex-direction: column; gap: var(--s2); padding: var(--s3) var(--s4); }
  .larch-doc { padding: var(--s5) var(--s4) var(--s6); }
  .larch-doc h1 { font-size: 24px; }
  .larch-modal { padding: var(--s4); }
}
