/* pages/knowledge.css — /knowledge/ and /knowledge/read/<name> (spec §5.13).
 *
 * PAGE-SCOPE RULE (§1.1, test_design check 9): every selector starts with a
 * class this file owns — `.kb*`, `.kbr*`, `.kbg*`, `.pdf*`, `.tikz` — or with
 * [data-page="knowledge"]. All eleven page files load on every page.
 *
 * ⚠️ THE OTHER TIER'S PAGE, REDRAWN ON THE M3 COMPONENTS. A folder tree of plain
 * titles (a standard M3 list); a note under a head the colour of the note
 * itself (no tone of its own since 2026-10-02, as no page's top has one),
 * carrying where it came from and where it is read; prose at a reading
 * measure with a real heading ladder; links in the page hue (K20, this page
 * only); typeset maths and drawings. The controls are the system's own — the
 * templates carry m3-icon-btn / m3-chip / m3-list-item / m3-badge — so this file
 * only places them and draws what is Knowledge's alone.
 *
 * ⚠️ ONE NOTE, ONE DESIGN. What is drawn here is the READING view: what shows for
 * the instant before the live editor (static/kblive/) mounts, and whenever it
 * cannot. The editor's head tone is --app-kb-headtone too (kblive.css's host
 * frame), and the head here is cut to the editor's head: the same tone (the
 * note's own ground), the title on the prose measure. Restyle both or neither.
 */

.kb {
  --app-kb-headtone: var(--md-sys-color-surface-container-low);   /* the reading region: the head is the note's own colour */
  --kb-hue: var(--h-knowledge);
  /* THE LIVE EDITOR'S MEASURE, not the spec's 720: the editor sets its column at
     an A4 page less its margins (kblive.css --kbmeasure: 794px - 2 x 20mm, about
     643px), and the reading view it mounts over must put the title and the first
     line where the editor will — one note, one design (pages-b 5e1). */
  --kb-measure: calc(794px - 40mm);
  /* The floor of every side inset (head, prose, notices): 24 on the reading
     region, 16 at <=839px where the note lies on the card like every record. */
  --kb-inset: 24px;
}

/* ════════════════════════════════════════════════════════════ THE TREE ══
   The list column of the §4.7 split (360 / 412 / 280 in a split; one column at
   <=839px). The search bar and the two tools sit on the card, above the tree
   (Q1: on the card). */
.kb__tools { display: flex; align-items: center; gap: 4px; flex: none; }
.kb__tools[hidden] { display: none; }
.kb__search { flex: 1; }
/* The bar is flush with the pane body's top and left edges, and the body
   clips (overflow: hidden): an outer ring would lose two sides. §2.14's inner
   offset for anything a clipping parent would cut. */
.kb__search:focus-within { outline-offset: var(--app-focus-offset-inner); }
/* THE OPEN VIEW'S TOOL IS SELECTED. Graph and Files open a view in the reading
   region as a row opens a note, so workspace.js lights them the same way
   (aria-current, cleared when a row or the other tool takes over) — and they
   paint what every selected thing on this page paints: the #333537 step, the
   glyph at FILL 1 (K35), the selected toggle's square shape. */
.kb__tool[aria-current="true"] {
  --_container: var(--md-sys-color-secondary-container);
  --_label: var(--md-sys-color-on-secondary-container);
  --_fill: 1;
  --_r: var(--_r-sq);
}

/* What went wrong with an upload, a move or a delete (.notice--bad, §3.26), and
   what is in flight: one muted line, as the empty lines are. */
.kb__problem { flex: none; }
.kb__busy {
  flex: none; margin: 0; padding: 0 16px;
  color: var(--app-color-on-surface-low);
  font-size: var(--md-sys-typescale-body-medium-size);
  line-height: var(--md-sys-typescale-body-medium-line-height);
}
.kb__busy[hidden] { display: none; }
.kb__fileinput { display: none; }

/* ⚠️ AN ACCORDION, AND THE GEOMETRY IS THREE DECLARATIONS — nothing measures
   anything. The column is a flex column of a definite height; a closed folder
   is its head and nothing else (0 0 auto); the open one is as tall as its files
   and is the ONLY item that gives way (0 1 auto), so when they do not fit its
   body scrolls and the closed heads below land on the foot of the column
   because there is nothing else for them to be. His two rules, 2026-08-09 and
   -11: one open at a time, and "an open category should only push the closed
   categories to the very bottom if there are too many elements … otherwise just
   have the other categories below the open category". ⚠️ NOT flex-grow: grow is
   the whole difference between FITS and FILLS. ⚠️ min-height: 0 on the FOLDER
   as well as its body, or a long list refuses to shrink under its content and
   pushes the folders below it off the column. */
.kb__list { flex: 1; min-height: 0; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.kb__folder { flex: 0 0 auto; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.kb__folder.is-open { flex: 0 1 auto; }
/* ⚠️⚠️ A CLOSED FOLDER'S BODY IS NEVER `display: none`. It is the tree's
   scroller, so it carries the app's edge fade — a mask driven by a scroll
   timeline (below) — and CHROMIUM'S RENDERER CRASHES when an element with that
   animation loses or gains its box under a real pointer click: found
   2026-10-05, a click on one folder head while another was open killed the tab
   ("Target crashed"), with no script on the stack. Reproduced, then bisected:
   the fade alone, on a body that toggles display, is enough; the same body
   kept in the layout at no height is fine. So a closed body keeps its box —
   zero tall, clipped, and out of the tab order and the accessibility tree
   (visibility), which is everything display: none was doing for it. */
.kb__folder:not(.is-open) > .kb__foldbody {
  flex: none;
  height: 0;
  margin: 0;
  border: 0;
  overflow: hidden;
  visibility: hidden;
}

/* A folder head is a one-line list item (56) with the §3.10 shape morph. It is
   TWO buttons side by side — the folder, and its + — so the HEAD carries the
   item's look and takes its states from whichever is under the pointer or the
   focus. ⚠️ THE OPEN FOLDER IS NOT FILLED (K34): open is the chevron, never a
   ground. */
.kb__foldhead {
  --_container: transparent;
  --_state-color: var(--md-sys-color-on-surface);
  --_r: var(--md-sys-shape-corner-extra-small);
  box-sizing: border-box;
  flex: none;
  display: flex;
  align-items: center;
  min-width: 0;
  min-height: var(--app-list-h-1);
  padding-inline-end: 8px;
  border-radius: var(--_r);
  background-color: color-mix(in srgb, var(--_state-color) var(--_state), var(--_container));
  color: var(--md-sys-color-on-surface);
}
.kb__foldtoggle {
  box-sizing: border-box;
  flex: 1;
  align-self: stretch;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  margin: 0;
  padding: 0 4px 0 16px;
  border: 0;
  border-radius: inherit;
  background: none;
  color: inherit;
  font: inherit;
  text-align: start;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  outline-offset: var(--app-focus-offset-inner);
}
@media (hover: hover) {
  .kb__foldhead:hover { --_state: var(--md-sys-state-hover-state-layer-opacity); --_r: var(--md-sys-shape-corner-medium); }
}
.kb__foldhead:has(> .kb__foldtoggle:focus-visible) { --_state: var(--md-sys-state-focus-state-layer-opacity); --_r: var(--md-sys-shape-corner-large); }
.kb__foldhead:has(> .kb__foldtoggle:active) { --_state: var(--md-sys-state-pressed-state-layer-opacity); --_r: var(--md-sys-shape-corner-large); }
.kb__chev, .kb__foldico { --_icon: var(--app-icon-size-medium); --_opsz: 20; color: var(--md-sys-color-on-surface-variant); }
.kb__folder.is-open > .kb__foldhead .kb__chev { rotate: 90deg; }
.kb__foldlbl {
  flex: 1; min-width: 0;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  font-size: var(--md-sys-typescale-title-small-size);
  line-height: var(--md-sys-typescale-title-small-line-height);
  font-weight: var(--md-sys-typescale-title-small-weight);
}
/* While he searches, a folder with nothing that matches steps back a tone — the
   column answers "which folder is it in" itself. Hiding it would take away the
   place he was about to drop a file. */
.kb__folder.is-nomatch > .kb__foldhead :is(.kb__foldlbl, .kb__chev, .kb__foldico) { color: var(--app-color-on-surface-low); }
/* A row is being dragged over this folder and may land in it: the drop-target
   line (the accent's one use on this page besides links and the caret). */
.kb__folder.is-dropkind > .kb__foldhead { box-shadow: inset 0 0 0 2px var(--app-color-accent); }
/* EVERY head has the same + (Sources' opens the file picker). Out on the open
   folder, which is the one he is in; on a closed one it is there when the head
   is pointed at or focused — OPACITY, not display, so it keeps its place and
   its tab stop — and simply there on a touch screen, where nothing is pointed
   at (K16). */
.kb__foldadd { opacity: 0; }
.kb__folder.is-open > .kb__foldhead .kb__foldadd,
.kb__foldhead:is(:hover, :focus-within) .kb__foldadd { opacity: 1; }
@media (hover: none), (pointer: coarse) {
  .kb__foldadd { opacity: 1; }
}

/* The open folder's files: THE scroller of the tree (hidden bar, the app's edge
   fades — the same rules app.css gives every vertical list). The guide line
   hangs under the chevron (16 + 20 / 2 = 26). */
.kb__foldbody {
  flex: 1 1 auto;
  min-height: 0;
  list-style: none;
  margin: 0 0 8px;
  margin-inline-start: 26px;
  padding: 0;
  padding-inline-start: 8px;
  border-inline-start: 1px solid var(--md-sys-color-outline-variant);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-width: none;
}
.kb__foldbody::-webkit-scrollbar { display: none; }
@supports (animation-timeline: scroll(self)) {
  .kb__foldbody {
    mask-image: linear-gradient(to bottom, transparent 0, black var(--m3-fade-start),
                                black calc(100% - var(--m3-fade-end)), transparent 100%);
    animation-name: m3-fade-start, m3-fade-end;
    animation-duration: auto, auto;
    animation-timing-function: linear, linear;
    animation-fill-mode: both, both;
    animation-timeline: scroll(self block), scroll(self block);
    animation-range: 0px var(--m3-fade, 40px), calc(100% - var(--m3-fade, 40px)) 100%;
  }
}
.kb__foldbody > li { display: block; min-width: 0; }
.kb__foldbody > li[hidden] { display: none; }

/* A note is a one-line list item (the template carries .m3-list-item): body-
   large in the supporting ink, the selected one the grey step with an
   emphasized headline in on-surface (§3.10 does that part). What is done TO the
   file rides on its row, at the end: there when the row is pointed at or
   focused, and always on a touch screen. ⚠️ THE ROW KEEPS THE ROOM FOR IT AT
   REST, so a name does not reflow under the pointer. ⚠️ A SIBLING of the row's
   button, never inside it. */
.kb__item { position: relative; }
.kb__row { --_head: var(--md-sys-color-on-surface-variant); padding-inline-end: 52px; user-select: none; }
/* Two things ride on a note's row — its download, then delete — and one on a
   source's (its file is a document already). Each keeps a whole target, side by
   side and never overlapping: a press on the edge of one must not be the other.
   The room is the row's at rest, as for one. (`kb__item--two` is the template's
   word for "this row has both" — the row is told, rather than asked with a
   `:has()` every time a row is drawn.) */
.kb__item--two > .kb__row { padding-inline-end: calc(52px + var(--app-target)); }
.kb__row.is-dragging { --_state: var(--md-sys-state-dragged-state-layer-opacity); }
.kb__rowact {
  position: absolute;
  inset-block-start: calc((var(--app-list-h-1) - var(--app-target)) / 2);
  inset-inline-end: 4px;
  margin: 0;
  opacity: 0;
}
.kb__rowact--download { inset-inline-end: calc(4px + var(--app-target)); }   /* after the rule it moves */
.kb__item:is(:hover, :focus-within) > .kb__rowact,
.kb__rowact[aria-expanded="true"] { opacity: 1; }
@media (hover: none), (pointer: coarse) {
  .kb__rowact { opacity: 1; }
}

/* Which download (static/knowledge.js `openDownload`): the M3 menu (m3.css
   §3.12) as a native popover, placed by the script under the button, right
   edges together — the calendars menu's arrangement (pages/calendar.css). */
.kb__dlmenu {
  --_origin: top right;
  position: fixed;
  inset: auto;                             /* the UA's popover inset 0 + margin auto would centre it */
  margin: 0;
  border: 0;
  width: max-content;
}
/* ⚠️ .m3-menu's `display: flex` is AUTHOR CSS, and beats the UA's
   `[popover]:not(:popover-open) { display: none }` — without this the closed
   menu would stand, unplaced, in the page. */
.kb__dlmenu:not(:popover-open) { display: none; }
@media (prefers-reduced-motion: no-preference) {
  /* Closing is instant: m3.css also transitions `display`, which would hold
     the closed menu on screen, out of the top layer. */
  .kb__dlmenu { transition-property: scale, opacity; }
}

/* The empty lines (§3.21): one muted line, no icon, no card. */
.kb__foldempty {
  padding: 16px;
  color: var(--app-color-on-surface-low);
  font-size: var(--md-sys-typescale-body-medium-size);
  line-height: var(--md-sys-typescale-body-medium-line-height);
}

/* FILES HELD OVER THE PAGE: the whole page says where they will land, for the
   second he is holding them (the scrim's one use outside a modal: nothing under
   it can be reached while a drag is in the air). It takes no pointer events —
   the drop is the document's (static/knowledge.js). */
.kb__drop {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 24px;
  border-radius: var(--md-sys-shape-corner-large);
  background: color-mix(in srgb, var(--md-sys-color-surface) 88%, transparent);
  box-shadow: inset 0 0 0 2px var(--app-color-accent);
  color: var(--md-sys-color-on-surface);
  text-align: center;
  pointer-events: none;
}
.kb--dropping > .kb__drop { display: flex; }
.kb__drop > .ico { --_icon: var(--app-icon-size-xl); --_opsz: 32; margin-block-end: 8px; color: var(--md-sys-color-on-surface-variant); }
.kb__droptext {
  margin: 0;
  font-family: var(--md-ref-typeface-brand);
  font-size: var(--md-sys-typescale-title-medium-size);
  line-height: var(--md-sys-typescale-title-medium-line-height);
  font-weight: var(--md-sys-typescale-title-medium-weight);
}
.kb__dropsub {
  margin: 0;
  color: var(--md-sys-color-on-surface-variant);
  font-size: var(--md-sys-typescale-body-medium-size);
  line-height: var(--md-sys-typescale-body-medium-line-height);
}
.kb__dropsub:empty { display: none; }

@media (prefers-reduced-motion: no-preference) {
  .kb__foldhead {
    transition-property: border-radius, background-color;
    transition-duration: var(--md-sys-motion-spring-fast-spatial-duration), var(--md-sys-motion-spring-default-effects-duration);
    transition-timing-function: var(--md-sys-motion-spring-fast-spatial), var(--md-sys-motion-spring-default-effects);
  }
  .kb__chev { transition: rotate var(--md-sys-motion-spring-fast-spatial-duration) var(--md-sys-motion-spring-fast-spatial); }
  .kb__foldadd, .kb__rowact { transition: opacity var(--md-sys-motion-spring-fast-effects-duration) var(--md-sys-motion-spring-fast-effects); }
}

/* ONE PANE (<=839px): THE TREE FLOWS. The column is the scroller there
   (app.css gives it the reserve under the FAB), and a phone's height is too
   short to pin five 56px heads to its foot and still show a list between them:
   the open folder is simply as tall as its files, and the rest follow it.
   ⚠️ THE ONE <=839px BLOCK HERE WITH NO TWIN FOR A HALF OF A SPLIT. It is about a
   phone being SHORT, not about it being one pane, and a half is the window's
   whole height: it keeps the accordion above, the closed heads on its foot
   (above the FAB's reserve, app.css) and only the open folder scrolling. Klaus,
   2026-10-20: "when viewing it in split view, the notelist doesnt work
   properly (it becomes scrollable)" — the twin had the whole tree scroll, the
   heads below an open Notes 1,600px down. test_design check 12 names it. */
@media (max-width: 839px) {
  .kb__list { display: block; overflow-x: hidden; }
  .kb__folder, .kb__folder.is-open { display: block; }
  .kb__foldbody { overflow: visible; mask-image: none; }
}

/* ════════════════════════════════════════════════════════════ THE NOTE ══
   #kb-detail is the reading region's scroller with NO padding of its own: the
   note's head is sticky at its top, and its parts set their own insets. ⚠️ It is
   kept OUT of the fade lists (app.css: .split__detail:not(#kb-detail)) because a
   mask is a group mask and would dissolve the pinned head; it only hides its
   bar. Once mounted, the live editor has its own scroller. */
.kb__detail { padding: 0; overscroll-behavior: contain; scrollbar-width: none; }
.kb__detail::-webkit-scrollbar { display: none; }
.kb__note { min-width: 0; }

/* THE HEAD IS THE NOTE'S FIXED TOP (K19, §4.7's record head, Knowledge's own),
   pinned while the prose scrolls under it. ⚠️ THE NOTE'S OWN COLOUR (2026-10-02,
   "seamless": it was the page hue at 9%, with a 28px lip of concave notches).
   What rises under it fades through the head's SKIRT, as under every record
   head (app.css): this scroller is out of the fade lists, because a mask would
   dissolve the pinned head with the prose. The title sits on the prose
   measure, as the live editor's does. */
.kbr__head {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: var(--kb-inset, 24px) max(var(--kb-inset, 24px), calc((100% - var(--kb-measure)) / 2)) 16px;
  border-radius: var(--md-sys-shape-corner-large) var(--md-sys-shape-corner-large) 0 0;
  background: var(--app-kb-headtone);
}
.kbr__head::after {                       /* the skirt: 0 at the note's top, 40px once it has scrolled 40 */
  content: ""; position: absolute; left: 0; right: 0; top: 100%; height: var(--m3-fade-start); pointer-events: none;
  background: linear-gradient(var(--app-kb-headtone), transparent);
}
@supports (animation-timeline: scroll(self)) {
  .kbr__head::after {
    animation-name: m3-fade-start; animation-duration: auto; animation-timing-function: linear; animation-fill-mode: both;
    animation-timeline: scroll(nearest block); animation-range: 0px var(--m3-fade, 40px);
  }
}
.kbr__titlerow { display: flex; align-items: center; gap: 8px; min-height: 32px; }
.kbr__title {
  flex: 1; min-width: 0; margin: 0;
  /* Whole words wrap first; a word wider than the line hyphenates where the
     browser can, and only then breaks (a long German compound at 360px). */
  overflow-wrap: break-word;
  hyphens: auto;
  color: var(--md-sys-color-on-surface);
  font-family: var(--md-ref-typeface-brand);
  font-size: var(--md-sys-typescale-headline-small-size);
  line-height: var(--md-sys-typescale-headline-small-line-height);
  font-weight: var(--md-sys-typescale-emphasized-headline-small-weight);
  font-variation-settings: "ROND" var(--md-sys-typescale-emphasized-rond);
}
.kbr__title--missing { color: var(--md-sys-color-on-surface-variant); }
.kbr__meta {
  flex: none;
  color: var(--md-sys-color-on-surface-variant);
  font-size: var(--md-sys-typescale-body-medium-size);
  line-height: var(--md-sys-typescale-body-medium-line-height);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.kbr__actions { flex: none; display: flex; align-items: center; gap: 8px; margin-block: -8px; }   /* the 48px targets overhang the 32px title line, as the editor's title stands alone */
.kbr__status {
  padding-inline: 8px;
  white-space: nowrap;
  color: var(--md-sys-color-on-surface-variant);
  font-size: var(--md-sys-typescale-label-medium-size);
  line-height: var(--md-sys-typescale-label-medium-line-height);
  font-weight: var(--md-sys-typescale-label-medium-weight);
}
.kbr__status.is-ok { color: var(--md-sys-color-on-surface-variant); }
.kbr__status.is-bad { color: var(--md-sys-color-error); }
/* The head's icon buttons are S standard icon buttons (the template carries
   .m3-icon-btn). --on (the source editor's Done) wears the toggle-selected look:
   on-surface, FILL 1. */
.kbr__iconbtn--on { --_label: var(--md-sys-color-on-surface); --_fill: 1; }

/* The rows under the title: a label column one word wide, and chips on ONE line
   that scroll sideways rather than wrap — a row that grows eats the reading area
   it is pinned over. The chips' 48px targets touch row to row, so the visible
   gap between two rows of chips is their two insets. */
.kbr__props { margin: 8px 0 0; display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 0 8px; }
.kbr__prop { display: contents; }
.kbr__prop dt {
  display: flex; align-items: center; gap: 14px; min-height: var(--app-target); min-width: 0;   /* the editor's key sits 14 past its glyph */
  color: var(--md-sys-color-on-surface-variant);
  font-size: var(--md-sys-typescale-label-large-size);
  line-height: var(--md-sys-typescale-label-large-line-height);
  font-weight: var(--md-sys-typescale-label-large-weight);
}
.kbr__prop dt .ico { --_icon: var(--app-icon-size-medium); --_opsz: 20; }
/* A sideways scroller (app.css: SIDEWAYS SHORT, 20px). Its inline ends are padded
   by the chips' inset, so the end chips' targets stay inside it, and pulled back
   by the same amount, so the first chip's visible edge sits on the column. */
.kbr__propval {
  display: flex; align-items: center; gap: 8px; min-width: 0; min-height: var(--app-target);
  margin: 0; margin-inline: -8px; padding-inline: 8px;
  overflow-x: auto; overflow-y: hidden; white-space: nowrap;
}
.kbr__proptext {
  overflow: hidden; text-overflow: ellipsis;
  color: var(--md-sys-color-on-surface);
  font-size: var(--md-sys-typescale-body-medium-size);
  line-height: var(--md-sys-typescale-body-medium-line-height);
}
.kbr__none {
  color: var(--app-color-on-surface-low);
  font-size: var(--md-sys-typescale-body-medium-size);
  line-height: var(--md-sys-typescale-body-medium-line-height);
}
/* .kbr__chip is an assist chip (the template carries .m3-chip--assist). */
.kbr__chipsfx { margin-inline-start: -4px; color: var(--md-sys-color-on-surface-variant); }
/* A title the note names but the vault lacks: not a control. A dashed outline
   at the chip's visible edge, muted ink, no states. */
.kbr__chip--missing.m3-chip,
.kbr__chip--missing.m3-chip:is(:hover, :active, [data-state]) {
  --_oc: transparent;
  --_label: var(--app-color-on-surface-low);
  --_state: 0%;
  outline: 1px dashed var(--md-sys-color-outline-variant);
  outline-offset: calc(-1px - var(--_inset));
  cursor: default;
}

/* ════════════════════════════════════════════════════════════ THE PROSE ══
   Body-large at the reading measure's line height (28px, DM's 1.75), the
   content starting where the head's lip ends. The measure is computed HERE, not
   in a token on .kb: a var() inside a custom property is resolved where it is
   declared, so a measure inherited as a token could never be widened below
   (.kbr__body--wide is the Files view's). */
.kbr__body {
  padding: 28px max(var(--kb-inset, 24px), calc((100% - var(--kb-measure)) / 2)) calc(24px + var(--fabreach, 0px));
  overflow-wrap: break-word;
  color: var(--md-sys-color-on-surface);
  font-size: var(--md-sys-typescale-body-large-size);
  line-height: 28px;
  font-weight: var(--md-sys-typescale-body-large-weight);
}
.kbr__body--wide { --kb-measure: 860px; }
.kbr__body > :first-child { margin-top: 0; }
.kbr__body p { margin: 0 0 12px; }
.kbr__body del { color: var(--app-color-on-surface-low); }
/* A mark is the grey step: a highlighter that took the page's hue would be the
   only coloured fill in the vault (answer 1). */
.kbr__body mark {
  padding: 1px 4px; border-radius: var(--md-sys-shape-corner-extra-small);
  background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-surface);
}

/* THE HEADING LADDER (K43): weight names a section, and the air ABOVE a head is
   three to four times the air below it, Google Docs' ratio — a heading belongs
   to what follows it. A note's `#` renders as .kbr__h1 in an <h2> (the page's
   <h1> is the title). After the M3 size mapping h2 and h3 share 16px, so the
   emphasized weight (600, ROND 100) is what separates them. */
.kbr__h { margin: 28px 0 6px; color: var(--md-sys-color-on-surface); }
.kbr__h1 {
  margin-top: 40px; margin-bottom: 8px;
  font-family: var(--md-ref-typeface-brand);
  font-size: var(--md-sys-typescale-title-large-size);
  line-height: var(--md-sys-typescale-title-large-line-height);
  font-weight: var(--md-sys-typescale-emphasized-title-large-weight);
  font-variation-settings: "ROND" var(--md-sys-typescale-emphasized-rond);
}
.kbr__h2 {
  margin-top: 34px; margin-bottom: 8px;
  font-size: var(--md-sys-typescale-title-medium-size);
  line-height: var(--md-sys-typescale-title-medium-line-height);
  font-weight: var(--md-ref-typeface-weight-semibold);
  font-variation-settings: "ROND" var(--md-sys-typescale-emphasized-rond);
}
.kbr__h3 {
  margin-top: 28px; margin-bottom: 6px;
  font-size: var(--md-sys-typescale-title-medium-size);
  line-height: var(--md-sys-typescale-title-medium-line-height);
  font-weight: var(--md-sys-typescale-title-medium-weight);
}
.kbr__h4, .kbr__h5, .kbr__h6 {
  font-size: var(--md-sys-typescale-title-small-size);
  line-height: var(--md-sys-typescale-title-small-line-height);
  font-weight: var(--md-sys-typescale-title-small-weight);
}
.kbr__h4 { margin-top: 24px; margin-bottom: 4px; }
.kbr__h5 { margin-top: 20px; margin-bottom: 4px; }
.kbr__h6 { margin-top: 16px; margin-bottom: 4px; color: var(--md-sys-color-on-surface-variant); }
/* Two heads in a row are one thing: the group's air is all above the first. */
.kbr__h + .kbr__h { margin-top: 12px; }

/* LINKS ARE OBSIDIAN PURPLE, ON THIS PAGE ONLY (K20): the page's hue as ink,
   underlined on hover. The focus ring is the system's accent ring (§2.14). */
.kbr__link, .kbr__link--file { color: var(--kb-hue); text-decoration: none; text-underline-offset: 3px; cursor: pointer; }
.kbr__link:hover { text-decoration: underline; }
.kbr__linkico { --_icon: var(--app-icon-size-small); --_opsz: 20; vertical-align: -3px; margin-inline-end: 2px; }
.kbr__body a:not(.kbr__link):not(.m3-btn):not(.m3-icon-btn):not(.m3-chip) { color: var(--kb-hue); text-underline-offset: 3px; }
/* A link to a note not written yet reads as a promise, not a broken link — and
   it is pressed to write it. */
.kbr__missing {
  padding: 0; border: 0; background: none; font: inherit; line-height: inherit; cursor: pointer;
  color: var(--app-color-on-surface-low);
  border-bottom: 1px dashed var(--md-sys-color-outline-variant);
}
@media (hover: hover) {
  .kbr__missing:hover { color: var(--kb-hue); border-bottom-color: currentColor; }
}

.kbr__body :is(ul, ol) { margin: 0 0 12px; padding-inline-start: 24px; }
.kbr__body li { margin: 2px 0; }
.kbr__body li > :is(ul, ol) { margin: 2px 0 4px; }
.kbr__body li::marker { color: var(--md-sys-color-on-surface-variant); }
.kbr__body li.kbr__task { list-style: none; margin-inline-start: -24px; display: flex; gap: 8px; align-items: flex-start; }
.kbr__check { --_icon: var(--app-icon-size-medium); --_opsz: 20; line-height: 28px; color: var(--md-sys-color-on-surface-variant); }
.kbr__task.is-done > .kbr__check { --_fill: 1; }
.kbr__task.is-done > span:last-child { color: var(--app-color-on-surface-low); text-decoration: line-through; }

.kbr__body blockquote {
  margin: 0 0 12px; padding-inline-start: 16px;
  border-inline-start: 3px solid var(--md-sys-color-outline-variant);
  color: var(--md-sys-color-on-surface-variant);
}
.kbr__body blockquote > :last-child { margin-bottom: 0; }
/* A callout wears the notice (§3.27): the container-high step, 12 corners. */
.kbr__callout {
  margin: 0 0 16px; padding: 12px 16px;
  border-radius: var(--md-sys-shape-corner-medium);
  background: var(--md-sys-color-surface-container-high);
}
.kbr__body .kbr__callouttitle {
  margin: 0 0 4px;
  font-size: var(--md-sys-typescale-title-small-size);
  line-height: var(--md-sys-typescale-title-small-line-height);
  font-weight: var(--md-sys-typescale-title-small-weight);
}
.kbr__callout > :last-child { margin-bottom: 0; }
.kbr__rule { height: 1px; margin: 24px 0; border: 0; background: var(--md-sys-color-outline-variant); }

/* Inline code on the grey step; a block is a darker well (#131314) whose CODE
   is the sideways scroller, so the fade dissolves the text and never the well's
   own ground and corners (§4.13: a fade scroller must not paint the ground it
   fades into). */
.kbr__body code {
  padding: 1px 4px; border-radius: var(--md-sys-shape-corner-extra-small);
  background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-surface);
}
.kbr__code {
  margin: 0 0 16px; padding: 16px 0;
  border-radius: var(--md-sys-shape-corner-medium);
  background: var(--md-sys-color-surface);
  overflow: hidden;
}
.kbr__body .kbr__code > code {
  display: block; padding: 0 16px; border-radius: 0; background: none;
  overflow-x: auto; overflow-y: hidden; white-space: pre;
  color: var(--md-sys-color-on-surface-variant);
}
.kbr__tablewrap { margin: 0 0 16px; overflow-x: auto; overflow-y: hidden; }
.kbr__table {
  border-collapse: collapse;
  font-size: var(--md-sys-typescale-body-medium-size);
  line-height: var(--md-sys-typescale-body-medium-line-height);
  font-variant-numeric: tabular-nums;
}
.kbr__table :is(th, td) {
  padding: 8px 12px; text-align: start; vertical-align: top;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}
.kbr__table th {
  color: var(--md-sys-color-on-surface-variant);
  font-size: var(--md-sys-typescale-title-small-size);
  line-height: var(--md-sys-typescale-title-small-line-height);
  font-weight: var(--md-sys-typescale-title-small-weight);
}

/* ---- maths ---- */
/* Until KaTeX has drawn it the TeX shows, set apart in mono and never as
   italics that could be read as the answer. */
.kbr__math:not([data-done]) {
  font-family: var(--app-typeface-mono);
  font-size: var(--app-typescale-mono-size);
  color: var(--app-color-on-surface-low);
}
.kbr__math[data-math="block"] { display: block; margin: 12px 0 16px; overflow-x: auto; overflow-y: hidden; }
/* KaTeX's own 1.21em, as the editor draws it (one note, one design: at 1.08
   every formula grew when the editor mounted). */
.kbr__math .katex { color: inherit; }
.kbr__math .katex-display { margin: 0; }
/* LEFT, NOT CENTRED — the editor's rule (Klaus, 2026-08-06: "math should be
   left aligned tho"), so a formula does not move when the editor mounts over
   this view (one note, one design). (0,3,0) over katex.min.css's two centrings. */
.kbr__body .kbr__math .katex-display,
.kbr__body .kbr__math .katex-display > .katex { text-align: left; }
/* An inline formula wider than the column scrolls sideways rather than running
   off the sheet: its own box capped at the column (it still wraps where KaTeX
   offers a break), on the text's baseline (`baseline-source: first` — a
   scroller's baseline is otherwise its bottom edge). Joins the sideways fades
   below. Same rule as the editor's. */
/* ⚠️ `baseline-source` AFTER `vertical-align`: Chrome made vertical-align a
   shorthand that sets it too, and declared second it reset `first` to `auto`
   (the formula then rode 7px above its sentence — see kblive.css). */
.kbr__math:not([data-math="block"]) > .katex {
  display: inline-block;
  max-width: 100%; overflow: auto hidden;
  vertical-align: baseline; baseline-source: first;
}

/* ---- drawings ---- */
.kbr__tikz { margin: 12px 0 20px; }
.kbr__tikz[data-state="drawing"] > pre,
.kbr__tikz[data-state="drawn"] > pre { display: none; }
/* While TeX draws: the empty line (§3.21), holding the drawing's room. */
.kbr__tikz[data-state="drawing"]:not([data-done])::before {
  content: "Drawing…";
  display: flex; align-items: center; justify-content: center; min-height: 120px;
  color: var(--app-color-on-surface-low);
  font-size: var(--md-sys-typescale-body-medium-size);
  line-height: var(--md-sys-typescale-body-medium-line-height);
}
.kbr__tikzerr {
  margin: -8px 0 0; white-space: pre-wrap;
  color: var(--md-sys-color-error);
  font-family: var(--app-typeface-mono);
  font-size: var(--app-typescale-mono-size);
  line-height: var(--app-typescale-mono-line-height);
}
/* tikz.js paints a drawing in currentColor on --tikz-paper: the reading region. */
.tikz { color: var(--md-sys-color-on-surface); --tikz-paper: var(--md-sys-color-surface-container-low); }
.tikz svg { display: block; max-width: 100%; height: auto; overflow: visible; }

/* ---- interactive figures: a ```scene block (static/scene.js) ----
   A plate one step up from the page, because it is a thing to be OPERATED: the
   drawing, then a slider per value he may move. Drawn in the note's ink; a
   colour is only where the block names one (two vectors have to be told apart),
   never by default, and is one of m3.css's figure colours: tone 80 of a
   Material 3 tonal palette. So every colour in a figure is the scheme's: the
   plate a surface role, the ink on-surface, gray on-surface-variant.
   ⚠️ ONE CANVAS UNIT IS ONE PIXEL (scene.js lays the figure out at its drawn
   width), so the sizes here are what is seen at any width. */
.kbr__scene { margin: 12px 0 20px; }
.scene {
  --scene-ground: var(--md-sys-color-surface-container);
  --_c: var(--md-sys-color-on-surface);
  box-sizing: border-box;
  max-width: 100%;
  margin: 12px 0 20px;
  padding: 0;
  overflow: hidden;
  border-radius: var(--md-sys-shape-corner-large);
  background: var(--scene-ground);
  color: var(--md-sys-color-on-surface);
  cursor: default;
  user-select: none;
}
.scene__canvas { display: block; width: 100%; height: auto; }
.scene__grid { fill: none; stroke: color-mix(in srgb, var(--md-sys-color-on-surface) 7%, transparent); stroke-width: 1; }
.scene__axis { fill: none; stroke: color-mix(in srgb, var(--md-sys-color-on-surface) 38%, transparent); stroke-width: 1; }
.scene__tick, .scene__label {
  paint-order: stroke;
  stroke: var(--scene-ground);
  stroke-linejoin: round;
  font-family: var(--md-ref-typeface-brand);
}
.scene__tick {
  fill: var(--md-sys-color-on-surface-variant);
  stroke-width: 3px;
  font-size: var(--md-sys-typescale-label-small-size);
  font-variant-numeric: tabular-nums;
}
.scene__label {
  fill: var(--_c);
  stroke-width: 4px;
  font-size: var(--md-sys-typescale-body-medium-size);
  font-weight: var(--md-sys-typescale-emphasized-body-medium-weight);
}
.scene__curve, .scene__stroke, .scene__arc, .scene__shape, .scene__mesh {
  fill: none; stroke: var(--_c); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.scene__arc { stroke-width: 1.5; }
.scene__mesh { stroke: color-mix(in srgb, var(--_c) 42%, transparent); stroke-width: 1; }
.scene__head { fill: var(--_c); stroke: var(--_c); stroke-width: 1; stroke-linejoin: round; }
.scene__dot { fill: var(--_c); stroke: var(--scene-ground); stroke-width: 2; }
.scene__area { fill: color-mix(in srgb, var(--_c) 16%, transparent); stroke: none; }
.scene__bar { fill: color-mix(in srgb, var(--_c) 20%, transparent); stroke: var(--_c); stroke-width: 1; }
.scene__shape.scene--filled { fill: color-mix(in srgb, var(--_c) 18%, transparent); }
/* How a thing is drawn — after the shapes, so they win on equal weight. */
.scene--dashed { stroke-dasharray: 7 6; }
.scene--dotted { stroke-dasharray: 1 6; }
.scene--thick { stroke-width: 3.5; }
.scene--thin { stroke-width: 1; }
.scene--red { --_c: var(--app-color-figure-red); }
.scene--orange { --_c: var(--app-color-figure-orange); }
.scene--yellow { --_c: var(--app-color-figure-yellow); }
.scene--green { --_c: var(--app-color-figure-green); }
.scene--cyan { --_c: var(--app-color-figure-cyan); }
.scene--blue { --_c: var(--app-color-figure-blue); }
.scene--purple { --_c: var(--app-color-figure-purple); }
.scene--pink { --_c: var(--app-color-figure-pink); }
.scene--gray { --_c: var(--md-sys-color-on-surface-variant); }

/* A SPACE (a view with three ranges): the same ink, turned by dragging. What is
   further away is fainter (scene.js sets each mark's opacity) — in one ink that,
   and turning it, is what tells depth.
   ⚠️ touch-action: pan-y, NOT none. A space is most of a phone's screen: a finger
   moved up or down it has to go on scrolling the note, and one moved sideways
   turns it (and may then go anywhere). */
.scene { position: relative; }
.scene--3d .scene__canvas { cursor: grab; touch-action: pan-y; outline-offset: var(--app-focus-offset-inner); }
.scene--3d.is-turning .scene__canvas { cursor: grabbing; }
/* A curve in a space is short chains of points laid end to end, each a little
   see-through: square ends, or every join would be a darker bead. */
.scene--chain { stroke-linecap: butt; }
.scene__axis3 { fill: none; stroke: color-mix(in srgb, var(--md-sys-color-on-surface) 46%, transparent); stroke-width: 1; }
.scene__axis3head { fill: color-mix(in srgb, var(--md-sys-color-on-surface) 46%, transparent); stroke: none; }
.scene__axisname { font-style: italic; font-size: var(--md-sys-typescale-body-medium-size); }
/* A surface is see-through facets with a faint mesh; a plane a fainter sheet;
   a polygon one face. How lit each is comes from scene.js (fill-opacity). */
.scene__facet, .scene__sheet, .scene__face {
  fill: var(--_c); stroke: var(--_c); stroke-width: 0.6; stroke-linejoin: round;
}
.scene__sheet { stroke-width: 0.3; }
.scene__face { stroke-width: 1.5; }
/* Turned away from where it started: the way back, in the corner. */
.scene__reset { position: absolute; inset-block-start: 4px; inset-inline-end: 4px; margin: 0; }
.scene__reset[hidden] { display: none; }

/* A row per value he may set, in the order the block names them. A slider: its
   name, the M3 slider (§3.18), what it stands at. */
.scene__controls { display: grid; grid-template-columns: minmax(0, 1fr); padding: 4px 20px 8px; }
.scene__control {
  display: grid;
  grid-template-columns: minmax(20px, auto) minmax(0, 1fr) minmax(44px, auto);
  align-items: center;
  column-gap: 16px;
  min-height: var(--app-target);
  cursor: pointer;
}
.scene__name {
  font-family: var(--md-ref-typeface-brand);
  font-style: italic;
  font-size: var(--md-sys-typescale-title-medium-size);
  line-height: var(--md-sys-typescale-title-medium-line-height);
}
.scene__value {
  text-align: end;
  color: var(--md-sys-color-on-surface-variant);
  font-size: var(--md-sys-typescale-body-medium-size);
  line-height: var(--md-sys-typescale-body-medium-line-height);
  font-variant-numeric: tabular-nums;
}
/* A SWITCH (m3.css §3.15) trails what it says, as in a list row: something on
   or off was a slider with `step 1` until 2026-10-05, and he asked for it to
   "actually look like a switch and not a drag bar". What it says is prose, not
   a variable — upright, and it may wrap. */
.scene__control--switch { grid-template-columns: minmax(0, 1fr) auto; }
.scene__says {
  padding-block: 12px;
  font-size: var(--md-sys-typescale-body-large-size);
  line-height: var(--md-sys-typescale-body-large-line-height);
}
/* A CHOICE is a connected group (§3.5) at XS — the switch's own 32 — and trails
   its name too. ⚠️ IT NEVER LEAVES THE PLATE: on a phone the group drops under
   its name before it gives anything up, and only then do its options shorten
   (to no less than a target each: the language stops at five). */
.scene__control--choice { display: flex; flex-wrap: wrap; cursor: default; }
.scene__choice { flex: 0 1 auto; min-width: 0; max-width: 100%; margin-inline-start: auto; }
.scene__choice > .m3-btn { flex: 0 1 auto; }
.scene__choice .m3-label { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.scene__choice .m3-label::after { display: block; }
/* What a line of the block got wrong, with its number — said where the figure
   is, in the error ink, and the figure still draws what it could. */
.scene__errors {
  margin: 0; padding: 4px 20px 14px; list-style: none;
  color: var(--md-sys-color-error);
  font-size: var(--md-sys-typescale-body-small-size);
  line-height: var(--md-sys-typescale-body-small-line-height);
  user-select: text;
}
.scene__errors[hidden] { display: none; }
/* In the editor a drawing opens its source on a click (as a TikZ one does); the
   sliders are the figure's own. */
.kb__render--scene .scene__canvas { cursor: text; }
/* …except in a note embedded in this one: there a click on the drawing opens
   that note, as the rest of its card does (a space keeps its grab, below). */
.kb__embed .kb__render--scene .scene__canvas { cursor: pointer; }
.kb__render--scene .scene--3d .scene__canvas { cursor: grab; }
.kb__render--scene .scene--3d.is-turning .scene__canvas { cursor: grabbing; }

/* ---- embeds ---- */
/* A transclusion is a card on the reading region: the container step, 12
   corners, its title in title-small (it links to the note it carries). */
.kbr__embed {
  margin: 16px 0;
  padding: 16px;
  border-radius: var(--md-sys-shape-corner-medium);
  background: var(--md-sys-color-surface-container);
}
.kbr__body > .kbr__embed:first-child { margin-top: 0; }
.kbr__body .kbr__embedtitle {
  margin: 0 0 8px;
  font-family: var(--md-ref-typeface-plain);
  font-size: var(--md-sys-typescale-title-small-size);
  line-height: var(--md-sys-typescale-title-small-line-height);
  font-weight: var(--md-sys-typescale-title-small-weight);
  font-variation-settings: "ROND" 0;
}
.kbr__embedlink { color: var(--md-sys-color-on-surface); }
@media (hover: hover) {
  .kbr__embedlink:hover { color: var(--kb-hue); }
}
.kbr__embedbody > :first-child { margin-top: 0; }
.kbr__embedbody > :last-child { margin-bottom: 0; }
.kbr__embed .kbr__embed { background: var(--md-sys-color-surface-container-high); }
.kbr__embedloop { color: var(--app-color-on-surface-low); }
.kbr__filecard { display: flex; align-items: baseline; gap: 12px; }
.kbr__filepage {
  color: var(--md-sys-color-on-surface-variant);
  font-size: var(--md-sys-typescale-body-medium-size);
  font-variant-numeric: tabular-nums;
}

.kbr__quiet { color: var(--app-color-on-surface-low); }
.kbr__body--empty { display: grid; justify-items: start; gap: 12px; }
.kbr__body--empty > .kbr__quiet { margin: 0; }
/* "Write it in" — the folders a missing note could be written into, as
   suggestion-style assist chips. */
.kbr__create { display: flex; align-items: center; flex-wrap: wrap; gap: 0 8px; margin-top: 8px; }
.kbr__createlbl {
  margin-inline-end: 8px;
  color: var(--md-sys-color-on-surface-variant);
  font-size: var(--md-sys-typescale-body-medium-size);
  line-height: var(--md-sys-typescale-body-medium-line-height);
}

/* .kbr__error is the error banner (m3.css, §3.26); it only takes its place. */
.kbr__error { margin: 16px max(var(--kb-inset, 24px), calc((100% - var(--kb-measure)) / 2)) 0; }
.kb__note > .kbr__head + .kbr__error { margin-top: 28px; }
/* Text a refused save left behind, offered back (knowledge.js): the notice
   (§3.27, the template — the script — carries .notice) with two text buttons. */
.kbr__kept { margin: 16px max(var(--kb-inset, 24px), calc((100% - var(--kb-measure)) / 2)) 0; flex-wrap: wrap; align-items: center; }
.kb__note > .kbr__head + .kbr__kept { margin-top: 28px; }
.kbr__kept > span { flex: 1 1 240px; }
/* The source editor's "writes are off" line: a notice in the same place. */
.kbr__notice { margin: 28px max(var(--kb-inset, 24px), calc((100% - var(--kb-measure)) / 2)) 0; }
.kbr__notice > span { flex: 1; min-width: 0; }

/* ---- the source ---- */
/* The FALLBACK editor (the live one is kblive): in place, in mono, as tall as
   its text so the reading region scrolls. The caret and the head's status say
   it has focus; it draws no ring of its own (a full-region editor, §5.13). */
.kbr__body--source { padding-top: 28px; }
.kbr__source {
  box-sizing: border-box;
  display: block; width: 100%; min-height: 55vh; margin: 0; padding: 0;
  border: 0; outline: none; resize: none; overflow: hidden;
  background: none;
  color: var(--md-sys-color-on-surface);
  caret-color: var(--app-color-accent);
  font-family: var(--app-typeface-mono);
  font-size: var(--app-typescale-mono-size);
  line-height: var(--app-typescale-mono-line-height);
  tab-size: 4;
}
.kbr__source::placeholder { color: var(--app-color-on-surface-low); }

/* ═══════════════════════════════════════════════════════════════ PDF ══
   A document we did not write is PAPER ON A WELL (K44): white pages, 8 corners,
   level 2, on a darker well. One column of pages, each as wide as the column —
   a slide deck is read at its own width, and a fixed zoom is a decision the page
   should not make for him. Each page waits as a grey slot until it is drawn. */
.pdf { display: flex; flex-direction: column; gap: 16px; max-width: 900px; }
.pdf__page {
  display: block; width: 100%; height: auto;
  border-radius: var(--md-sys-shape-corner-small);
  background: #fff;
  box-shadow: var(--md-sys-elevation-level2);
}
.pdf__slot {
  width: 100%; overflow: hidden;
  border-radius: var(--md-sys-shape-corner-small);
  background: var(--md-sys-color-secondary-container);
}
.pdf__slot[data-state="drawn"] { background: #fff; box-shadow: var(--md-sys-elevation-level2); }
.pdf__slot .pdf__page { border-radius: 0; box-shadow: none; }
.pdf__status, .pdf__error {
  margin: 0; padding: 16px;
  font-size: var(--md-sys-typescale-body-medium-size);
  line-height: var(--md-sys-typescale-body-medium-line-height);
}
.pdf__status { color: var(--app-color-on-surface-low); }
.pdf__error { color: var(--md-sys-color-error); }
/* In a source note: the well under the head, on the reading region. */
.kbr__pdf {
  box-sizing: border-box;
  max-width: none;
  margin: 28px max(var(--kb-inset, 24px), calc((100% - 1000px) / 2)) calc(24px + var(--fabreach, 0px));
  padding: 16px;
  border-radius: var(--md-sys-shape-corner-medium);
  background: var(--md-sys-color-surface);
}

/* ═════════════════════════════════════════════════════════════ FILES ══
   A segmented list (§3.10; the template carries .m3-list--segmented and each
   row .m3-list-item--two): the PDF glyph, the name over its size, then the note
   that owns it and the way out to the reader. */
/* (0,2,0) over the prose's list indent, `.kbr__body :is(ul, ol)`: a segmented
   list's tiles start on the column. The wide view's head takes the same
   measure, so the title stands over the tiles. */
.kbr__body .kbr__files { gap: 2px; margin: 0; padding: 0; }
.kb__note:has(> .kbr__body--wide) { --kb-measure: 860px; }
.kbr__file { --_icon: var(--app-icon-size-medium); --_opsz: 20; }
.kbr__files > li.kbr__file { display: grid; }      /* over .m3-list > li's block (0,1,1) */
.kbr__filetrail { display: flex; align-items: center; gap: 8px; min-width: 0; }
.kbr__filesize { font-variant-numeric: tabular-nums; }
/* The owner chip shortens with an ellipsis when the row is narrow: its label is
   a span (a bare text node cannot ellipsise), and the chip may shrink. */
.kbr__filetrail > .kbr__chip { min-width: 0; }
.kbr__chiplbl { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kbr__files > .kbr__quiet { padding: 16px; }
/* On a phone the owner's chip would squeeze the file's name to nothing: it
   drops under the name (the trail dissolves into the row's grid), and the
   way out stays at the end, centred on both lines. */
@media (max-width: 720px) {
  .kbr__files > li.kbr__file { grid-template-rows: auto auto; row-gap: 4px; }
  .kbr__file > .kbr__fileico { grid-row: 1 / span 2; }
  .kbr__file > .kbr__filetrail { display: contents; }
  .kbr__filetrail > .kbr__chip { grid-column: text / trail; grid-row: 2; justify-self: start; max-width: 100%; margin-block: -8px; }
  .kbr__filetrail > .kbr__iconbtn { grid-column: trail / end; grid-row: 1 / span 2; margin-inline-start: 4px; }
}

/* ═══════════════════════════════════════════════════════ NOTHING OPEN ══
   .kb__welcome is the empty pane (.pane__blank, §3.21, in the template). */
.kb kbd {
  padding: 0 6px;
  border: 0;
  border-radius: var(--md-sys-shape-corner-extra-small);
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-surface-variant);
  font-family: var(--app-typeface-mono);
  font-size: var(--md-sys-typescale-label-medium-size);
  line-height: var(--md-sys-typescale-label-medium-line-height);
  font-weight: var(--md-sys-typescale-label-medium-weight);
}

/* ═════════════════════════════════════════════════════════════ GRAPH ══
   The vault as one picture (server-drawn SVG). Colour stays ink: notes muted,
   topics and courses full ink, sources rings. Pointing at a node or lighting it
   adds a 2px ring in the page's hue (a ring is a line, not a fill); the keyboard
   ring is the accent ring, drawn on the circle. */
.kb__note--graph { display: flex; flex-direction: column; min-height: 100%; }
.kbg {
  flex: 1 1 auto; min-height: 360px; display: flex;
  padding: 28px 16px calc(16px + var(--fabreach, 0px));
}
.kbg__svg { display: block; flex: 1; width: 100%; height: auto; max-height: 100%; font-family: inherit; }
@media (min-width: 840px) { .kbg__svg { height: 100%; } }
.kbg__edge { stroke: var(--md-sys-color-outline-variant); stroke-width: 1; }
.kbg__node { cursor: pointer; }
.kbg__node circle { fill: var(--app-color-on-surface-low); stroke: transparent; stroke-width: 2; }
.kbg__node text {
  fill: var(--md-sys-color-on-surface-variant);
  font-size: var(--md-sys-typescale-label-small-size);
  font-weight: var(--md-sys-typescale-label-small-weight);
  text-anchor: middle;
  paint-order: stroke; stroke: var(--md-sys-color-surface-container-low); stroke-width: 4px; stroke-linejoin: round;
}
.kbg__node--topics circle, .kbg__node--courses circle { fill: var(--md-sys-color-on-surface); }
.kbg__node--topics text, .kbg__node--courses text { fill: var(--md-sys-color-on-surface); }
.kbg__node--sources circle { fill: none; stroke: var(--md-sys-color-on-surface-variant); stroke-width: 1.5; }
.kbg__node--drafts circle { opacity: .7; }
.kbg__node:is(:hover, .is-lit) circle { stroke: var(--kb-hue); stroke-width: 2; }
.kbg__node:is(:hover, :focus-visible, .is-lit) text { fill: var(--md-sys-color-on-surface); }
.kbg__node:focus-visible { outline: none; }
.kbg__node:focus-visible circle { stroke: var(--app-color-accent); stroke-width: 3; }
.kbg__svg.is-focus .kbg__node:not(.is-lit) { opacity: .22; }
.kbg__svg.is-focus .kbg__edge:not(.is-lit) { opacity: .08; }
.kbg__edge.is-lit { stroke: var(--kb-hue); }
.kbg[data-hide~="drafts"] [data-kinds~="drafts"],
.kbg[data-hide~="notes"] [data-kinds~="notes"],
.kbg[data-hide~="topics"] [data-kinds~="topics"],
.kbg[data-hide~="courses"] [data-kinds~="courses"],
.kbg[data-hide~="exercises"] [data-kinds~="exercises"],
.kbg[data-hide~="sources"] [data-kinds~="sources"] { display: none; }
@media (prefers-reduced-motion: no-preference) {
  .kbg__edge { transition: opacity var(--md-sys-motion-spring-fast-effects-duration) var(--md-sys-motion-spring-fast-effects), stroke var(--md-sys-motion-spring-fast-effects-duration) var(--md-sys-motion-spring-fast-effects); }
  .kbg__node { transition: opacity var(--md-sys-motion-spring-fast-effects-duration) var(--md-sys-motion-spring-fast-effects); }
  .kbg__node circle { transition: stroke var(--md-sys-motion-spring-fast-effects-duration) var(--md-sys-motion-spring-fast-effects); }
}

/* The key: filter chips (the template carries .m3-chip--filter), each with a
   10px dot in its kind's ink — the legend for the picture. */
.kbg__legend { display: flex; flex-wrap: wrap; gap: 0 8px; margin-top: 8px; }
.kbg__dot {
  flex: none; width: 10px; height: 10px; box-sizing: border-box;
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--app-color-on-surface-low);
}
.kbg__dot--topics, .kbg__dot--courses { background: var(--md-sys-color-on-surface); }
.kbg__dot--sources { background: none; box-shadow: inset 0 0 0 1.5px var(--md-sys-color-on-surface-variant); }
.kbg__dot--exercises { border-radius: var(--app-shape-corner-mark); }
.kbg__key[aria-pressed="false"] .kbg__dot { opacity: .38; }
.kbr__props--foot { margin: 0; padding: 8px max(var(--kb-inset, 24px), calc((100% - var(--kb-measure)) / 2)) 32px; }

/* ═══════════════════════════════════════════════ THE READER (/read/<name>) ══
   A full page: its head is shown (it carries the size and two ways on — text
   buttons, still real links), and the document is paper on a well. */
.kbr__readeractions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-inline-start: auto; }
.kbr__readeractions[hidden] { display: none; }
/* §4.13: a PDF is shown with NO mask — a mask over live canvases costs the
   viewer its smoothness. On the reader the pane body is the scroller, so its
   fade comes off (the bar stays hidden). */
[data-page="knowledge"] > .pane__body:has(> .pdf) { mask-image: none; }   /* its fade timeline keeps running, driving nothing */
/* ONE WELL (K44): in a note the paper sits on #131314 (.kbr__pdf); here the
   card under the head IS #131314, so the card is the well — no second ground,
   which drew the "well" a step LIGHTER than what it sat on. Centred on the
   card: a column hugging the left edge of a wide page left ~400px empty. */
[data-page="knowledge"] .pdf:not(.kbr__pdf) {
  box-sizing: border-box;
  margin: 16px auto 0;
  padding: 0;
  background: none;
}
[data-page="knowledge"] .pdf:not(.kbr__pdf) ~ .pdf__status { text-align: center; }
/* On a phone the two ways on stay ONE row: "Back to Knowledge" says "Back"
   (the link's aria-label keeps the whole name), and the pair fits. */
@media (max-width: 720px) {
  .kbr__readeractions { flex-wrap: nowrap; margin-inline-start: -12px; }   /* the first icon under the title's edge */
  .kbr__actmore { display: none; }
}

/* ═════════════════════════════════════════════ THIS PAGE'S OWN SCROLLERS ══
   §4.13: a new scroller joins a list or it gets no affordance. Sideways, 40px:
   a code block's code, a table, a display formula. No bar, ever. */
:where(.kbr__body .kbr__code > code, .kbr__tablewrap, .kbr__math[data-math="block"], .kbr__math:not([data-math="block"]) > .katex) { scrollbar-width: none; }
:where(.kbr__body .kbr__code > code, .kbr__tablewrap, .kbr__math[data-math="block"], .kbr__math:not([data-math="block"]) > .katex)::-webkit-scrollbar { display: none; }
:where(.kbr__math:not([data-math="block"]) > .katex) { --m3-fade: 20px; }
@supports (animation-timeline: scroll(self)) {
  :where(.kbr__body .kbr__code > code, .kbr__tablewrap, .kbr__math[data-math="block"], .kbr__math:not([data-math="block"]) > .katex) {
    mask-image: linear-gradient(to right, transparent 0, black var(--m3-fade-start),
                                black calc(100% - var(--m3-fade-end)), transparent 100%);
    animation-name: m3-fade-start, m3-fade-end;
    animation-duration: auto, auto; animation-timing-function: linear, linear; animation-fill-mode: both, both;
    animation-timeline: scroll(self inline), scroll(self inline);
    animation-range: 0px var(--m3-fade, 40px), calc(100% - var(--m3-fade, 40px)) 100%;
  }
}

/* ══════════════════════════════════════════════════ ONE PANE (<=839px) ══
   The §4.8 reading mode: the tree OR the note, and the note reads like every
   other record here (Mail, Contacts, News, Chat, Finance): NO sheet of its own —
   §4.8 drops the reading region, so the note lies on the card and runs to its
   foot — the shell's Back where theirs is (no margin of its own), and the head
   as theirs is at this width: the card's own colour, 16px insets, 12px top
   corners, the same skirt. */
@media (max-width: 839px) {
  .kb {
    --kb-inset: 16px;
    --app-kb-headtone: var(--md-sys-color-surface);
  }
  .kbr__head { border-radius: var(--md-sys-shape-corner-medium) var(--md-sys-shape-corner-medium) 0 0; }
  .kbr__pdf { margin-inline: 0; padding: 8px; }
  /* The mounted editor, the same way. kblive.css's host frame paints the note
     on --surface-0 (#1B1B1B) with 24px insets and 16 corners; here its ground
     IS the card, so the sheet vanishes — and every fade and sticky panel inside
     the editor that paints "the paper" (--surface-0) follows it onto the card
     rather than drawing #1B1B1B bands on it. (0,3,0) beats the frame's (0,2,0)
     whatever the load order. The print sheet is not inside the note, so the
     exported paper keeps its own tone. */
  .kb .kb__note.kb__note--live {
    --surface-0: var(--md-sys-color-surface);
    --panetop: var(--kb-inset);
    --paneinset: var(--kb-inset);
    --pane-tl: var(--md-sys-shape-corner-medium);
    --pane-tr: var(--md-sys-shape-corner-medium);
    --pane-bl: 0px;
    --pane-br: 0px;
  }
}
/* A HALF OF A SPLIT IS THAT ONE PANE (app.css, READING MODE): the tree OR the
   note, the note on the card. The same four rules, at the same weight. */
.kb:where(.content.is-split *) {
  --kb-inset: 16px;
  --app-kb-headtone: var(--md-sys-color-surface);
}
.kbr__head:where(.content.is-split *) { border-radius: var(--md-sys-shape-corner-medium) var(--md-sys-shape-corner-medium) 0 0; }
.kbr__pdf:where(.content.is-split *) { margin-inline: 0; padding: 8px; }
.kb:where(.content.is-split *) .kb__note.kb__note--live {
  --surface-0: var(--md-sys-color-surface);
  --panetop: var(--kb-inset);
  --paneinset: var(--kb-inset);
  --pane-tl: var(--md-sys-shape-corner-medium);
  --pane-tr: var(--md-sys-shape-corner-medium);
  --pane-bl: 0px;
  --pane-br: 0px;
}
@media (max-width: 720px) {
  /* A property STACKS, as the editor's does on a phone: the key on its line,
     the chips under it from the key's text, so the values keep the width. */
  .kbr__props { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .kbr__prop dt { min-height: 28px; }
  .kbr__propval { min-height: 40px; padding-inline-start: 36px; }
  .kbg__svg { min-height: 60vh; }
}
