/* rdstudio dashboard. Engineering-paper palette; Literata for reading, Atkinson Hyperlegible Next for the interface. */

@import url("fonts.css");
/* Colours, fonts and sizes come from themes/<name>.css, linked before this file. */

:root { --safe-top: env(safe-area-inset-top, 0px); --bar-h: calc(52px + var(--safe-top)); --vh: 100vh; }
@supports (height: 100dvh) { :root { --vh: 100dvh; } } /* excludes mobile browser bars */

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background-color: var(--paper);
  background-image: var(--page-image, none);
  background-size: var(--page-size, auto);
  color: var(--ink);
  font: 16px/1.5 var(--font-ui);
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------------ bar */

.bar {
  position: sticky; top: 0; z-index: 20;
  height: var(--bar-h);
  display: flex; align-items: center; gap: 18px;
  padding: var(--safe-top) 16px 0;
  background: var(--paper-raised);
  border-bottom: 1px solid var(--rule);
}
.brand {
  font: 600 18px/1 var(--font-heading, var(--font-text));
  font-size: var(--brand-size, 18px);
  color: var(--ink); text-decoration: none; white-space: nowrap;
  font-variation-settings: "opsz" 36;
}
.menu {
  display: none; border: 1px solid var(--rule); background: none;
  width: 36px; height: 36px; border-radius: var(--radius); cursor: pointer;
}
.menu svg { display: block; margin: auto; }
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; height: 100%; min-width: 0; flex: 0 1 auto; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  display: flex; align-items: center; gap: 6px;
  padding: 0 12px; height: 100%;
  color: var(--ink-soft); text-decoration: none; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.count {
  font-size: 12px; line-height: 18px; min-width: 20px; padding: 0 6px; text-align: center;
  border-radius: 9px; background: var(--paper-sunk); color: var(--ink-soft); font-weight: 600;
}
.count.alert { background: var(--stale); color: var(--paper-raised); }
.live { margin-left: auto; font-size: 13px; color: var(--ink-faint); white-space: nowrap; }
.live::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--reviewed); margin-right: 6px; vertical-align: 1px; }
.live.offline::before { background: var(--ink-faint); }

/* ------------------------------------------------------------- layouts */

#view { min-height: calc(var(--vh) - var(--bar-h)); }
.page { max-width: 980px; margin: 0 auto; padding: 28px 24px 64px; }
.page > h1 { font: 600 30px/1.2 var(--font-heading, var(--font-text)); font-size: var(--h1-size, 30px); margin: 0 0 6px; font-variation-settings: "opsz" 48; }
.lede { color: var(--ink-soft); margin: 0 0 28px; max-width: 64ch; }

.kn {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr) 288px;
  min-height: calc(var(--vh) - var(--bar-h));
}
.kn.no-meta { grid-template-columns: 272px minmax(0, 1fr); }
.tree {
  border-right: 1px solid var(--rule);
  background: var(--paper-raised);
  position: sticky; top: var(--bar-h); height: calc(var(--vh) - var(--bar-h));
  overflow-y: auto; padding: 14px 10px 40px;
  font-size: 15px;
}
.doc { padding: 36px clamp(20px, 5vw, 64px) 96px; min-width: 0; }
.meta {
  border-left: 1px solid var(--rule);
  padding: 36px 20px 64px;
  font-size: 14px;
  position: sticky; top: var(--bar-h); height: calc(var(--vh) - var(--bar-h)); overflow-y: auto;
}

/* --------------------------------------------------------------- tree */

.filter {
  width: 100%; padding: 8px 10px; margin: 0 0 12px;
  border: 1px solid var(--rule); border-radius: var(--radius);
  background: var(--paper); color: var(--ink); font: inherit; font-size: 14px;
}
.tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul ul { padding-left: 14px; border-left: 1px solid var(--rule); margin-left: 7px; }
.tree details > summary { list-style: none; cursor: pointer; }
.tree details > summary::-webkit-details-marker { display: none; }
.tree .dir {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 6px; border-radius: 4px; font-weight: 600;
}
.tree .dir .twisty { width: 12px; color: var(--ink-faint); transition: transform .12s; flex: none; }
.tree details[open] > summary .twisty { transform: rotate(90deg); }
.tree .dir a { color: var(--ink); text-decoration: none; }
.tree .dir a:hover { text-decoration: underline; }
.tree .item a {
  display: flex; align-items: baseline; gap: 8px;
  padding: 4px 6px; border-radius: 4px;
  color: var(--ink-soft); text-decoration: none; line-height: 1.35;
}
.tree .item a:hover { background: var(--paper-sunk); color: var(--ink); }
.tree .item a[aria-current="page"], .tree .dir.current { background: var(--accent-soft); color: var(--ink); }
.tree .root-link { display: block; padding: 5px 6px; font-weight: 600; color: var(--ink); text-decoration: none; }

.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; transform: translateY(-1px); }
.dot.human-reviewed { background: var(--reviewed); }
.dot.machine-confirmed { background: var(--machine); }
.dot.unverified { background: transparent; box-shadow: inset 0 0 0 1.5px var(--unverified); }
.dot.stale { background: var(--stale); }

/* ------------------------------------------------------------ prose */

.doc-head { max-width: 72ch; margin-bottom: 28px; }
.doc-kind { color: var(--ink-faint); font-size: 14px; margin: 0 0 6px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.doc-head h1 { font: 600 34px/1.18 var(--font-heading, var(--font-text)); font-size: var(--h1-doc-size, 34px); margin: 0; font-variation-settings: "opsz" 60; letter-spacing: -0.01em; }
.doc-head .description { font: 19px/1.5 var(--font-text); color: var(--ink-soft); margin: 10px 0 0; font-style: italic; }

.prose { font: var(--text-size)/1.68 var(--font-text); max-width: 72ch; font-variation-settings: "opsz" 18; }
.prose h1, .prose h2, .prose h3, .prose h4 { font-family: var(--font-text); line-height: 1.25; margin: 1.8em 0 .5em; font-variation-settings: "opsz" 36; }
.prose h1 { font-size: 26px; font-weight: 600; }
.prose h2 { font-size: 22px; font-weight: 600; }
.prose h3 { font-size: 19px; font-weight: 600; }
.prose h4 { font-size: 17px; font-weight: 700; }
.prose > :first-child { margin-top: 0; }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose table, .prose pre { margin: 0 0 1.05em; }
.prose li { margin: .2em 0; }
.prose li > p { margin: 0; }
.prose ul.contains-task-list { list-style: none; padding-left: 4px; }
.prose blockquote { border-left: 3px solid var(--accent); padding: 2px 0 2px 16px; color: var(--ink-soft); margin-left: 0; }
.prose code { font: .86em/1 var(--font-mono); background: var(--paper-sunk); padding: .15em .35em; border-radius: 4px; }
.prose pre {
  font: 14px/1.55 var(--font-mono); background: var(--paper-raised); border: 1px solid var(--rule);
  border-radius: var(--radius); padding: 14px 16px; overflow-x: auto;
}
.prose pre code { background: none; padding: 0; font-size: inherit; }
.prose pre code.hljs { background: none; padding: 0; }
.prose .table-wrap { overflow-x: auto; margin: 0 0 1.2em; }
.prose table { border-collapse: collapse; font: 15px/1.45 var(--font-ui); min-width: 60%; margin: 0; }
.prose th, .prose td { border-bottom: 1px solid var(--rule); padding: 8px 12px 8px 0; text-align: left; vertical-align: top; }
.prose th { font-weight: 700; border-bottom: 2px solid var(--ink-faint); }
.prose img { max-width: 100%; height: auto; }
.prose hr { border: 0; border-top: 1px solid var(--rule); margin: 2em 0; }
.prose a.broken { color: var(--stale); text-decoration-style: dashed; }
.prose a.external::after { content: "↗"; font-size: .75em; margin-left: 2px; }
.prose .katex { font-size: 1.05em; }
.prose .katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.prose eqn, .prose section.eqno { display: block; }
code, pre, kbd, samp { font-variant-ligatures: none; } /* show -> and != as typed */
.mermaid-block { margin: 0 0 1.2em; overflow-x: auto; text-align: center; }
.mermaid-block svg { max-width: 100%; height: auto; }
.mermaid-block pre { text-align: left; }
.mermaid-block[data-rendered="pending"] .mermaid-source { opacity: .5; }
.mermaid-error { font: 14px var(--font-ui); color: var(--stale); text-align: left; margin: 0 0 6px; }
.prose .footnotes { font-size: 15px; color: var(--ink-soft); }
.prose .footnotes-sep { border-top: 1px solid var(--rule); margin-top: 2.5em; }

/* ----------------------------------------------------------- meta panel */

.meta h2 { font: 700 13px/1.3 var(--font-ui); color: var(--ink-faint); margin: 24px 0 8px; letter-spacing: .02em; }
.meta h2:first-child { margin-top: 0; }
.trust {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 600; padding: 3px 10px 3px 8px; border-radius: 12px;
  border: 1px solid currentColor;
}
.trust.human-reviewed { color: var(--reviewed); }
.trust.machine-confirmed { color: var(--machine); }
.trust.unverified { color: var(--unverified); }
.trust.stale { color: var(--stale); }
.fm { width: 100%; border-collapse: collapse; }
.fm th, .fm td { text-align: left; vertical-align: top; padding: 6px 0; border-bottom: 1px solid var(--rule); }
.fm th { color: var(--ink-faint); font-weight: 600; padding-right: 12px; width: 38%; word-break: break-word; }
.fm td { word-break: break-word; }
.fm ul { margin: 0; padding: 0; list-style: none; }
.fm li + li { margin-top: 4px; }
.fm .sub { display: block; color: var(--ink-faint); font-size: 12.5px; }
.chip {
  display: inline-block; font-size: 12.5px; line-height: 20px; padding: 0 8px; margin: 0 4px 4px 0;
  border-radius: 10px; background: var(--paper-sunk); color: var(--ink-soft);
}
.outline, .linklist { list-style: none; margin: 0; padding: 0; }
.outline li a, .linklist li a { display: block; padding: 3px 0; color: var(--ink-soft); text-decoration: none; }
.outline li a:hover, .linklist li a:hover { color: var(--accent); }
.outline .l2 { padding-left: 12px; } .outline .l3 { padding-left: 24px; } .outline .l4 { padding-left: 36px; }
.meta details.fm-wrap > summary { display: none; }

/* --------------------------------------------------------- lists/pages */

.rows { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.rows > li { border-bottom: 1px solid var(--rule); padding: 14px 0; }
.rows .title { font: 600 18px/1.3 var(--font-text); color: var(--ink); text-decoration: none; }
.rows a.title:hover { color: var(--accent); }
.rows .sub { color: var(--ink-faint); font-size: 14px; margin-top: 3px; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.rows .desc { color: var(--ink-soft); margin-top: 4px; font-size: 15px; }
.section-h { font: 600 21px/1.3 var(--font-heading, var(--font-text)); font-size: var(--h2-size, 21px); margin: 36px 0 4px; display: flex; align-items: baseline; gap: 10px; }
.section-h .count { font-family: var(--font-ui); }
.section-note { color: var(--ink-faint); font-size: 14px; margin: 0 0 10px; max-width: 70ch; }
.empty { color: var(--ink-faint); font-style: italic; padding: 10px 0; }

/* changes */
.commit { border-bottom: 1px solid var(--rule); padding: 16px 0; }
.commit-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.commit-subject { font: 600 17px/1.35 var(--font-text); }
.commit-sub { color: var(--ink-faint); font-size: 13.5px; }
.commit-sub code { font: 12.5px var(--font-mono); }
.commit.pending .commit-subject { font-style: italic; }
.filegroups { margin-top: 10px; display: grid; gap: 8px; }
.filegroup { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 10px; font-size: 14px; }
.cat { font-weight: 700; font-size: 13px; }
.cat::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; background: currentColor; }
.cat.knowledge { color: var(--cat-knowledge); } .cat.code { color: var(--cat-code); }
.cat.reports { color: var(--cat-reports); } .cat.agent { color: var(--cat-agent); } .cat.other { color: var(--cat-other); }
.files { list-style: none; margin: 0; padding: 0; font: 13px/1.6 var(--font-mono); color: var(--ink-soft); min-width: 0; }
.files li { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files .st { display: inline-block; width: 16px; color: var(--ink-faint); }
.files .st.added { color: var(--reviewed); } .files .st.deleted { color: var(--stale); }
.files a { color: inherit; text-decoration: none; } .files a:hover { color: var(--accent); text-decoration: underline; }
.toggles { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 18px; }
.toggle {
  border: 1px solid var(--rule); background: var(--paper-raised); border-radius: 16px;
  padding: 4px 12px; font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.toggle[aria-pressed="true"] { border-color: var(--ink-soft); background: var(--paper-sunk); }
.toggle[aria-pressed="false"] { color: var(--ink-faint); }
.toggle[aria-pressed="false"] .cat { opacity: .45; }

/* reports */
.report-frame-wrap { display: flex; flex-direction: column; height: calc(var(--vh) - var(--bar-h)); }
.report-bar { display: flex; align-items: center; gap: 14px; padding: 10px 16px; border-bottom: 1px solid var(--rule); background: var(--paper-raised); font-size: 14px; flex-wrap: wrap; }
.report-bar strong { font: 600 16px var(--font-text); }
.report-frame { flex: 1; width: 100%; border: 0; background: var(--paper); }

/* skills */
.cards2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 0 28px; }

/* --------------------------------------------------------------- graph */

.graph-wrap { position: relative; height: calc(var(--vh) - var(--bar-h)); overflow: hidden;
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
}
.graph-wrap svg { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.graph-wrap svg:active { cursor: grabbing; }
.g-link { stroke: var(--ink-soft); stroke-opacity: .55; stroke-width: 1.2; fill: none; }
.g-tree { stroke: var(--ink-faint); stroke-opacity: .5; stroke-width: 1; stroke-dasharray: 3 3; }
.g-node { cursor: pointer; }
.g-node .shape { stroke: var(--paper); stroke-width: 1.5; }
.g-node .hit { fill: transparent; stroke: none; }
.g-node.dir .shape { fill: var(--paper-raised); stroke: var(--ink); stroke-width: 1.6; }
.g-node.report .shape { fill: var(--cat-reports); }
.g-node.pinned .shape { stroke: var(--ink); stroke-width: 2; }
.g-label {
  font: 12px var(--font-ui); fill: var(--ink); cursor: pointer;
  paint-order: stroke; stroke: var(--paper); stroke-width: 3.5px; stroke-linejoin: round;
}
.g-label.dir { font-weight: 700; font-size: 13px; }
.g-node.dim, .g-label.dim { opacity: .18; }
.g-edge-dim { opacity: .08; }
.graph-panel {
  position: absolute; top: 12px; left: 12px; right: auto; max-width: min(360px, calc(100% - 24px));
  background: var(--paper-raised); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 10px 12px; font-size: 14px; display: grid; gap: 8px;
}
.graph-panel .row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.graph-panel input[type="search"] { flex: 1; min-width: 120px; padding: 6px 8px; border: 1px solid var(--rule); border-radius: 4px; background: var(--paper); color: var(--ink); font: inherit; font-size: 14px; }
.graph-options > summary { display: none; }
.graph-options { display: grid; gap: 8px; }
.graph-options[open] { display: grid; }
.sliders { display: grid; gap: 4px; }
.slider { display: grid; grid-template-columns: 104px 1fr 44px; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-soft); }
.slider input { width: 100%; accent-color: var(--accent); }
.slider output { font-variant-numeric: tabular-nums; text-align: right; color: var(--ink-faint); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12.5px; color: var(--ink-soft); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.graph-hint { position: absolute; bottom: 10px; left: 12px; font-size: 12.5px; color: var(--ink-faint); }
.graph-tip {
  position: absolute; pointer-events: none; background: var(--paper-raised); border: 1px solid var(--rule);
  border-radius: var(--radius); padding: 8px 10px; font-size: 13px; max-width: 280px; box-shadow: 0 4px 16px rgb(0 0 0 / .08);
}
.graph-tip strong { display: block; font: 600 14px/1.3 var(--font-text); }
.graph-tip span { color: var(--ink-faint); }

/* ----------------------------------------------------------------- map */

/* Themes restyle the map through these tokens (all optional): --map-canvas,
   --map-image, --map-size, --region-open-alpha, --region-closed-alpha,
   --region-dash, --place-fill, --route-from, --route-to, --route-both,
   --territory-font and friends. No filters (glows, blurs, wobble): the map is
   repainted on every zoom step, and filters made that 25 to 80 times slower
   (bench/, T31). Effects are fills, strokes, dashes and opacity. */
.map-wrap { background-color: var(--map-canvas, var(--paper)); background-image: var(--map-image, none); background-size: var(--map-size, auto); }
.map-wrap .m-back { fill: transparent; }
.m-dir { fill: var(--c); stroke: var(--c); cursor: zoom-in; transition: fill-opacity .2s, opacity .2s;
  stroke-dasharray: var(--region-dash, none); }
.m-dir.open { fill-opacity: var(--region-open-alpha, .035); stroke-opacity: .5; stroke-width: .8; }
.m-dir.open.depth-1 { stroke-width: 1.5; stroke-opacity: .6; }
.m-dir.closed { fill-opacity: var(--region-closed-alpha, .11); stroke-opacity: .55; stroke-width: 1; }
.m-dir.closed:hover { fill-opacity: calc(var(--region-closed-alpha, .11) + .09); }
.m-place { cursor: pointer; transition: opacity .2s; }
.m-place .mark { fill: var(--place-fill, var(--c)); stroke: var(--paper); stroke-width: 1.5; }
.m-place.ring .mark { fill: var(--paper); stroke: var(--place-fill, var(--c)); stroke-width: 2; }
.m-place .ring { fill: none; stroke: var(--ink); stroke-width: 1.4; }
.m-place.landmark .mark { stroke: var(--ink); stroke-width: 1.4; }
.m-place:focus-visible { outline: none; }
.m-place:focus-visible .mark { stroke: var(--accent); stroke-width: 3; }
/* Route colour means direction only (set per route: a gradient from a note to
   what it links to, or --route-both for links both ways). */
.m-link { fill: none; stroke-opacity: var(--route-opacity, .55); stroke-linecap: round; transition: opacity .2s; }
.m-link.s1 { stroke-opacity: .35; stroke-dasharray: 2 4; }
.m-link.s3 { stroke-opacity: .75; }
svg.focusing .m-routes .m-link:not(.hot) { opacity: .15; }
svg.focusing .m-routes .m-link.hot { stroke-opacity: .95; stroke-dasharray: none; }
.m-routes.context .m-link { opacity: .22; }
.m-routes.context .m-link.hot { opacity: 1; }
svg.focusing .m-place:not(.related) { opacity: .3; }
svg.focusing .m-text.place:not(.related) { opacity: .3; }
.m-implied { fill: none; stroke: var(--ink-faint); stroke-width: 1; stroke-dasharray: 3 3; opacity: .7; pointer-events: none; }
.m-labels { pointer-events: none; }
.m-text, .m-arc {
  font: 12px var(--font-ui); fill: var(--ink);
  paint-order: stroke; stroke: var(--paper); stroke-width: 3px; stroke-linejoin: round;
}
.m-text.place { fill: var(--ink); font-family: var(--place-font, var(--font-ui)); font-size: var(--place-size, 12px); }
.m-text.landmark { font-weight: 700; font-size: 12.5px; }
.m-text.territory { font-family: var(--territory-font, var(--font-ui)); font-style: var(--territory-style, normal); font-size: var(--territory-size, 14px); font-weight: var(--territory-weight, 600); letter-spacing: var(--territory-spacing, .06em); fill: var(--territory-ink, var(--ink-soft)); }
.m-text.territory .count { font-size: 11.5px; font-weight: 400; letter-spacing: 0; fill: var(--ink-faint); }
.m-arc { font-family: var(--territory-font, var(--font-ui)); font-style: var(--territory-style, normal); font-size: var(--territory-size, 14px); font-weight: var(--territory-weight, 600); letter-spacing: var(--territory-spacing, .08em); fill: var(--territory-ink, var(--ink-soft)); }
.map-crumbs {
  position: absolute; top: 12px; right: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
  max-width: calc(100% - 400px); justify-content: flex-end;
  background: var(--paper-raised); border: 1px solid var(--rule); border-radius: var(--radius); padding: 4px 8px; font-size: 13.5px;
}
.map-crumbs button { border: 0; background: none; color: var(--accent); font: inherit; padding: 2px 3px; cursor: pointer; }
.map-crumbs button[aria-current] { color: var(--ink); font-weight: 700; cursor: default; }
.map-crumbs span { color: var(--ink-faint); }
.legend .key-landmark { background: var(--paper-raised); border: 1.5px solid var(--ink); box-shadow: 0 0 0 2px var(--paper-raised), 0 0 0 3.5px var(--ink); width: 8px; height: 8px; margin: 0 3px; }
.m-key path { fill: var(--ink-soft); }
.m-key.ring path { fill: none; stroke: var(--ink-soft); stroke-width: 1.6; }
.map-panel { max-height: calc(100% - 24px); overflow: auto; }
.map-tuning > summary { display: block; cursor: pointer; color: var(--ink-soft); font-size: 13.5px; }
.map-tuning .slider { grid-template-columns: 150px 1fr 44px; }
.dual-slider { grid-template-columns: 104px 1fr; }
.dual-slider output { grid-column: 2; text-align: left; }
.dual { position: relative; height: 20px; margin: 0 14px; cursor: pointer; touch-action: none; }
.dual::before { content: ""; position: absolute; left: 0; right: 0; top: 9px; height: 3px; border-radius: 2px; background: var(--rule); }
.dual-fill { position: absolute; top: 9px; height: 3px; border-radius: 2px; background: var(--accent); }
.dual-thumb { position: absolute; top: 2px; width: 11px; height: 17px; background: var(--accent);
  border: 2px solid var(--paper-raised); box-shadow: 0 0 0 1px var(--accent); }
/* The lower thumb sits just left of its value and the upper just right, as
   the two halves of a bracket: apart even when both mark the same value. */
.dual-thumb.lo { margin-left: -13px; border-radius: 9px 2px 2px 9px; }
.dual-thumb.hi { margin-left: 2px; border-radius: 2px 9px 9px 2px; }
.dual-thumb:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.dist { display: grid; gap: 4px; }
.seg { font-size: 13px; color: var(--ink-soft); }
.seg .toggle { padding: 2px 8px; font-size: 12.5px; }
.map-hint { margin: 0; font-size: 12.5px; color: var(--ink-faint); }
.route-key i { width: 26px; height: 3px; border-radius: 2px; }
.route-key .key-dir { background: linear-gradient(90deg, var(--route-from, var(--accent)), var(--route-to, var(--stale))); }
.route-key .key-both { background: var(--route-both, var(--ink-faint)); }
.route-key .key-dotted { background: repeating-linear-gradient(90deg, var(--ink-faint) 0 2px, transparent 2px 6px); }
.map-status { position: absolute; left: 50%; bottom: 44px; transform: translateX(-50%); margin: 0;
  padding: 4px 12px; border: 1px solid var(--rule); border-radius: 999px; background: var(--paper-raised);
  color: var(--ink-soft); font-size: 13px; pointer-events: none; }
.map-status[hidden] { display: none; }
.map-readout { margin: 0; font-size: 12.5px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.map-snippet { margin: 0; font-size: 12px; padding: 8px; background: var(--paper-sunk); border-radius: 4px; user-select: all; white-space: pre; overflow: auto; }
.legend .key-across { width: 18px; height: 0; border-radius: 0; border-top: 2px dashed var(--accent); }

/* ------------------------------------------------------------ narrow */

.scrim { display: none; }

@media (max-width: 1180px) {
  .kn, .kn.no-meta { grid-template-columns: 248px minmax(0, 1fr); }
  .meta { grid-column: 2; position: static; height: auto; border-left: 0; border-top: 1px solid var(--rule); padding: 20px clamp(20px, 5vw, 64px) 64px; }
  .meta .meta-inner { max-width: 72ch; }
  .kn .doc { padding-bottom: 32px; }
}

@media (max-width: 760px) {
  :root { --bar-h: calc(92px + var(--safe-top)); }
  body { font-size: 15.5px; }
  .bar { flex-wrap: wrap; gap: 0 10px; padding: var(--safe-top) 12px 0; align-content: stretch; }
  .menu { display: block; flex: none; }
  .menu[hidden] { display: none !important; }
  .brand { font-size: 17px; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; height: 48px; display: flex; align-items: center; }
  .live { display: inline; font-size: 12.5px; }
  .tabs { order: 5; flex: 0 0 calc(100% + 24px); margin: 0 -12px; padding: 0 4px; height: 44px; border-top: 1px solid var(--rule); }
  .tabs a { padding: 0 10px; }
  .kn, .kn.no-meta { display: block; }
  .tree {
    position: fixed; z-index: 30; top: var(--bar-h); left: 0; bottom: 0; height: auto; width: min(86vw, 320px);
    transform: translateX(-102%); transition: transform .18s ease-out; box-shadow: 0 0 24px rgb(0 0 0 / .18);
  }
  body.drawer-open .tree { transform: none; }
  body.drawer-open .scrim { display: block; position: fixed; inset: var(--bar-h) 0 0 0; background: rgb(0 0 0 / .25); z-index: 25; }
  .doc { padding: 22px 16px 24px; }
  .meta { padding: 16px 16px 48px; }
  .doc-head h1 { font-size: 27px; }
  .doc-head .description { font-size: 17px; }
  .prose { font-size: calc(var(--text-size) - 1px); line-height: 1.62; }
  .page { padding: 20px 16px 48px; }
  .page > h1 { font-size: 25px; }
  .filegroup { grid-template-columns: 1fr; gap: 2px; }
  .meta details.fm-wrap > summary { display: block; cursor: pointer; font-weight: 700; color: var(--ink-soft); padding: 6px 0; }
  .graph-panel { top: 8px; left: 8px; right: 8px; max-width: none; }
  .graph-options > summary { display: block; cursor: pointer; color: var(--ink-soft); font-size: 13.5px; }
  .graph-hint { display: none; }
  .map-crumbs { top: auto; bottom: 10px; left: 8px; right: 8px; max-width: none; justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------------------------------------------------------- procedures */

.page.wide { max-width: 1320px; }
.flow-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; margin: 16px 0 8px; }
.flow-scroll {
  overflow: auto; border: 1px solid var(--rule); border-radius: var(--radius);
  background-color: var(--paper);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
  max-height: 70vh;
}
.flow { display: block; max-width: none; height: auto; }
.flow.vertical { margin: 0 auto; }
.flow-node rect { fill: var(--paper-raised); stroke: var(--ink-faint); stroke-width: 1.2; }
.flow-node.start rect { stroke: var(--ink); stroke-width: 2; }
.flow-node text { font: 13.5px var(--font-ui); fill: var(--ink); }
.flow-node, .flow-edge { cursor: pointer; outline: none; }
.flow-node:hover rect, .flow-node:focus-visible rect { stroke: var(--accent); }
.flow-node.selected rect { stroke: var(--accent); stroke-width: 2.5; fill: var(--accent-soft); }
.flow-line { fill: none; stroke-width: 1.8; }
.flow-hit { fill: none; stroke: transparent; stroke-width: 14; }
.flow-edge:hover .flow-line, .flow-edge:focus-visible .flow-line, .flow-edge.selected .flow-line { stroke-width: 3; }
.flow-note { stroke: var(--paper); stroke-width: 1.5; }
.inspector-wrap { position: sticky; top: calc(var(--bar-h) + 16px); }
.inspector { border: 1px solid var(--rule); border-radius: var(--radius); background: var(--paper-raised); padding: 14px 16px; font-size: 15px; }
.inspector.empty { color: var(--ink-faint); font-style: italic; }
.inspector h3 { font: 600 18px/1.35 var(--font-text); margin: 0 0 10px; }
.inspector .rel { font: 500 14px var(--font-ui); }
.inspector .attr { border-top: 1px solid var(--rule); padding-top: 8px; margin-top: 8px; }
.inspector .attr strong { font-size: 13px; color: var(--ink-faint); }
.inspector .attr p { margin: 2px 0 0; }
.inspector .attr.pitfalls strong { color: var(--stale); }
.inspector .doc-kind code { font: 12.5px var(--font-mono); }
.chip.state-pending { background: var(--accent-soft); color: var(--ink); }
.chip.state-rejected { text-decoration: line-through; }
.chip.state-applied { color: var(--reviewed); }
@media (max-width: 1000px) {
  .flow-layout { grid-template-columns: 1fr; }
  .inspector-wrap { position: static; }
  .flow-scroll { max-height: none; }
}

/* ------------------------------------------------------------ settings */

.settings-link {
  display: inline-flex; align-items: center; gap: 6px; height: 100%; padding: 0 4px 0 10px;
  color: var(--ink-soft); text-decoration: none; white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.settings-link:hover { color: var(--ink); }
.settings-link[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin: 8px 0 12px; }
.theme-card {
  display: grid; gap: 6px; text-align: left; cursor: pointer; padding: 14px 16px;
  background: var(--paper-raised); border: 1px solid var(--rule); border-radius: var(--radius); color: var(--ink);
}
.theme-card:hover { border-color: var(--ink-faint); }
.theme-card[aria-checked="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.theme-name { font-size: 17px; font-weight: 700; }
.theme-sample { font-size: 16px; line-height: 1.4; }
.theme-note { font-size: 13.5px; color: var(--ink-soft); }
.theme-swatches { display: flex; gap: 12px; margin-top: 4px; }
.swatches { display: inline-flex; border: 1px solid var(--rule); border-radius: 4px; overflow: hidden; }
.swatches i { width: 18px; height: 18px; display: block; }
@media (max-width: 760px) {
  .settings-link span { display: none; }
  .settings-link { height: 48px; }
}

/* A fixed page texture is cheap with a mouse but repaints on every scroll on phones. */
@media (hover: hover) and (pointer: fine) {
  body { background-attachment: fixed; }
}

/* No fades while the map is being panned or zoomed. */
.map-wrap svg.moving .m-link, .map-wrap svg.moving .m-dir, .map-wrap svg.moving .m-place { transition: none; }

/* Short screens (a phone on its side) get the compact map and graph controls too. */
@media (max-height: 560px) {
  .graph-panel { top: 8px; left: 8px; max-width: min(360px, calc(100% - 16px)); padding: 6px 10px; }
  .graph-options > summary { display: block; cursor: pointer; color: var(--ink-soft); font-size: 13.5px; }
  .map-panel { max-height: calc(100% - 16px); }
  .graph-hint { display: none; }
  .map-crumbs { top: 8px; right: 8px; padding: 2px 6px; font-size: 12.5px; }
}

.fullscreen { border: 0; background: none; color: var(--ink-soft); cursor: pointer; padding: 6px; display: inline-flex; border-radius: var(--radius); }
.fullscreen:hover, .fullscreen[aria-pressed="true"] { color: var(--ink); }

/* ------------------------------------------------------------ learn */
.depth { color: var(--ink-faint); font: 12px/1 var(--font-ui); white-space: nowrap; }
.linklist.study { counter-reset: step; }
.linklist.study li { display: flex; align-items: baseline; gap: 8px; counter-increment: step; }
.linklist.study li::before { content: counter(step); color: var(--ink-faint); font: 12px/1 var(--font-ui); min-width: 1.4em; text-align: right; }
.linklist.study li a { flex: 1; }
ol.reading { list-style: none; margin: 8px 0 0; padding: 0; border-top: 1px solid var(--rule); }
ol.reading li.folder { font: 700 13px/1.3 var(--font-ui); color: var(--ink-faint); padding: 18px 0 6px; letter-spacing: .02em; }
ol.reading li.step { display: grid; grid-template-columns: 2.6em 1fr auto 3.2em; align-items: baseline; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--rule); }
ol.reading li.step::before { content: attr(value); color: var(--ink-faint); font: 13px/1 var(--font-ui); text-align: right; }
ol.reading li.step > a:first-child { color: var(--ink); text-decoration: none; }
ol.reading li.step > a:first-child:hover { color: var(--accent); }
ol.reading .path-link { font: 12px/1 var(--font-ui); color: var(--ink-soft); }

/* Study path on the map */
svg.trail .m-place:not(.on-trail) { opacity: .28; }
svg.trail .m-text.place:not(.on-trail) { opacity: .35; }
svg.trail .m-text.on-trail { font-weight: 700; }
.m-steps { pointer-events: none; }
.m-step rect { fill: var(--paper-raised); stroke: var(--ink-soft); stroke-width: 1; }
.m-step text { font: 700 10.5px/1 var(--font-ui); fill: var(--ink); text-anchor: middle; }
.m-step.goal rect { fill: var(--accent); stroke: var(--accent); }
.m-step.goal text { fill: var(--paper); }
.trail-card {
  position: absolute; right: 12px; bottom: 12px; width: min(320px, calc(100% - 24px)); max-height: calc(100% - 80px); overflow: auto;
  background: var(--paper-raised); border: 1px solid var(--rule); border-radius: var(--radius); padding: 10px 12px; font-size: 14px;
}
.trail-card > summary { cursor: pointer; font-weight: 600; padding-right: 22px; }
.trail-card > summary .count { margin-left: 8px; color: var(--ink-faint); font-weight: 400; }
.trail-card .section-note { margin: 6px 0 4px; font-size: 13px; }
.trail-steps { margin: 0; padding: 0 0 0 1.8em; }
.trail-steps li { padding: 1px 0; }
.trail-steps li::marker { color: var(--ink-faint); font-size: 12px; }
.trail-steps li.goal { font-weight: 700; }
.trail-steps button { border: 0; background: none; padding: 2px 0; font: inherit; color: var(--ink); cursor: pointer; text-align: left; }
.trail-steps button:hover { color: var(--accent); }
.trail-steps a { margin-left: 8px; font-size: 12px; color: var(--ink-faint); }
.trail-close { position: absolute; top: 6px; right: 10px; font-size: 20px; line-height: 1; color: var(--ink-faint); text-decoration: none; }
@media (max-width: 760px), (max-height: 560px) {
  .trail-card { bottom: 56px; right: 8px; width: calc(100% - 16px); max-height: 45%; }
}
