/* The wiki page's own styles, on top of the shared tokens and components in
 * `app.css`. Same rules as there: every length is fluid or auto, nothing has
 * a fixed pixel width, and anything that could be wider than its column sets
 * `min-width: 0` or `overflow-wrap: anywhere`, so a 360 px viewport never
 * scrolls sideways. Only this page loads this sheet.
 */

/* Headings land below the sticky header when a TOC link is followed, and
 * scroll themselves smoothly (the global reduced-motion rule in app.css
 * turns this off for anyone who asks for it). */
html {
  scroll-behavior: smooth;
}
.prose :where(h1, h2, h3, h4, h5, h6) {
  scroll-margin-top: 5.5rem;
}

/* Search-result and snippet highlights. */
.wiki mark {
  background: var(--accent-soft);
  color: inherit;
  border-radius: 4px;
  padding: 0 0.1em;
}

/*   Ask the brain: the one box
   ---------------------------------------------------------------- */

/* The box is a card: the field, the project filter and Ask on one row (the
 * filter and the button wrap under the field on phones), the hint under
 * them, and the results listbox hanging under the whole form. */
.wiki-search {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: var(--space-3);
}

.wiki-search > input {
  flex: 1 1 16rem;
  min-width: 0;
  min-height: 48px;
  padding: 0 14px;
  font-size: 16px;
  background: var(--bg);
}

.wiki-project {
  flex: 0 1 11rem;
  min-width: 0;
  min-height: 48px;
  padding: 0 8px;
  font-size: 14px;
  background: var(--bg);
}

.wiki-search > button {
  min-height: 48px;
}

.wiki-search__hint {
  flex: 1 1 100%;
  margin: 0;
}

/* The results listbox hangs under the field, above the page. */
.wiki-search__panel {
  position: absolute;
  top: calc(100% - 8px);
  left: 0;
  right: 0;
  z-index: 60;
  max-height: min(24rem, 60vh);
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg2);
  box-shadow: 0 12px 30px oklch(0 0 0 / 0.35);
}

.wiki-search__opt {
  display: grid;
  gap: 2px;
  padding: 10px 14px;
  border-top: 1px solid var(--line2);
  cursor: pointer;
}

.wiki-search__opt:first-child {
  border-top: 0;
}

.wiki-search__opt:hover,
.wiki-search__opt--active {
  background: var(--accent-soft);
}

.wiki-search__title {
  font-weight: 600;
  font-size: 15px;
  overflow-wrap: anywhere;
}

.wiki-search__snippet {
  font-size: 13px;
  color: var(--ink2);
  overflow-wrap: anywhere;
}

.wiki-search__none {
  padding: 12px 14px;
  font-size: 14px;
  color: var(--ink3);
}

.ask-result {
  margin-top: var(--space-3);
}

.ask-result h2 {
  font-size: var(--step-1);
}

@media (max-width: 40rem) {
  .wiki-search > button,
  .wiki-project {
    flex: 1 1 8rem;
  }
}

/*   the page's "On this page" drawer (phones)
   ---------------------------------------------------------------- */

.wiki-drawer__btn {
  flex-shrink: 0;
}

/* Only a narrow-screen affordance: from 72rem up the side TOC is there
 * (the sidebar takes 15rem of the width, so the TOC waits for room). */
@media (min-width: 72rem) {
  .wiki-drawer__btn,
  #wiki-drawer {
    display: none;
  }
}

.wiki-drawer {
  border-bottom: 1px solid var(--line2);
  background: var(--bg2);
}

.wiki-drawer__h {
  margin: 0;
  padding: 10px var(--gutter) 0;
  font-family: var(--f-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink3);
}

.wiki-drawer .wiki-toc {
  padding: 0 var(--gutter) 14px;
}

/*   imports: each row opens in place
   ---------------------------------------------------------------- */

.import > summary {
  cursor: pointer;
  list-style: none;
}

.import > summary::-webkit-details-marker {
  display: none;
}

.import__body {
  padding: 12px 14px 16px;
  border-top: 1px solid var(--line2);
}

/*   the table of contents (both mounts)
   ---------------------------------------------------------------- */

.wiki-toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
}

.wiki-toc a {
  display: block;
  padding: 4px 0;
  font-size: 14px;
  color: var(--ink2);
  text-decoration: none;
  overflow-wrap: anywhere;
}

.wiki-toc a:hover {
  color: var(--accent);
}

.wiki-toc .wiki-toc__sub a {
  padding-inline-start: 1rem;
  font-size: 13px;
}

/* The desktop TOC is only the wide layout's side rail: below 60rem the
 * drawer already carries the same list, so the aside must not flow beneath
 * the article (its `hidden` attribute still wins through app.css). */
#toc-desktop {
  display: none;
}

/* Beside the page on wide screens; below it until there is room. */
.wiki-page {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}

@media (min-width: 72rem) {
  .wiki-page {
    grid-template-columns: minmax(0, 1fr) 14rem;
  }
  #toc-desktop {
    display: block;
  }
  .wiki-toc--side {
    position: sticky;
    top: 88px;
    border-inline-start: 1px solid var(--line2);
    padding-inline-start: var(--space-2);
  }
}

.wiki-toc--side h2 {
  font-family: var(--f-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink3);
}

/*   home: the page lists
   ---------------------------------------------------------------- */

.wiki-filter {
  flex: 1 1 12rem;
  min-width: 0;
  max-width: 20rem;
  min-height: 44px;
  padding: 0 12px;
  font-size: 15px;
}

.wiki-list {
  list-style: none;
  margin: 0 0 var(--space-3);
  padding: 0;
  display: grid;
  gap: 8px;
}

.wiki-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  padding: 10px 14px;
  border: 1px solid var(--line2);
  border-radius: var(--radius);
  background: var(--bg2);
  min-width: 0;
}

.wiki-row__link {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  flex: 1 1 auto;
  min-width: 0;
  text-decoration: none;
  color: var(--ink);
}

.wiki-row__slug {
  font-family: var(--f-mono);
  font-size: 15px;
  overflow-wrap: anywhere;
}

.wiki-row__link:hover .wiki-row__slug {
  color: var(--accent);
}

.wiki-row__meta {
  font-family: var(--f-mono);
  font-size: 12px;
  color: var(--ink3);
  white-space: nowrap;
}

.wiki-row__pin {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
}

@media (pointer: coarse) {
  .wiki-row__pin {
    min-height: 44px;
  }
}

.wiki-empty h2 {
  font-size: var(--step-1);
}

/*   the page meta line
   ---------------------------------------------------------------- */

.wiki-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  max-width: none;
  font-family: var(--f-mono);
  font-size: 12px;
  color: var(--ink3);
}

/*   the citations card
   ---------------------------------------------------------------- */

/* A citation's URL drops to its own line under the title (and quote), not
 * the title's tail; `anywhere` keeps a long URL from widening the card. */
#page-citations .tiny {
  display: block;
  overflow-wrap: anywhere;
}

/*   the editor
   ---------------------------------------------------------------- */

.wiki-editor__h {
  font-size: var(--step-2);
}

.wiki-editmode {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  margin-block: var(--space-2);
  border: 1px solid var(--line2);
  border-radius: 12px;
  background: var(--bg2);
}

.wiki-editmode button {
  min-height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  font-size: 14px;
  background: transparent;
}

.wiki-editmode button[aria-pressed="true"] {
  background: var(--bg3);
  color: var(--ink);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.wiki-editmode button:hover:not(:disabled) {
  background: var(--bg3);
}

@media (pointer: coarse) {
  .wiki-editmode button {
    min-height: 44px;
  }
}

/*   new page
   ---------------------------------------------------------------- */

.wiki-np {
  max-width: 34rem;
}

/* The slug gate holds Create disabled, but the shared primary keeps its
 * accent on `:disabled` — mute it here so an unready button reads as off in
 * both themes. */
#np-create:disabled {
  border-color: var(--line);
  background: var(--bg3);
  color: var(--ink3);
  filter: none;
  box-shadow: none;
  cursor: not-allowed;
}

/* The slug rule doubles as the field's helper, so it reads as one: muted
 * ink, like `.hint`. Only once validation has actually failed — a slug was
 * typed and refused, or the server sent back a 422 — does `wiki.js` mark the
 * input `aria-invalid`, and the adjacent slot then takes the danger color. A
 * pristine form never wears red. */
#np-slug-error {
  color: var(--ink3);
  font-weight: 400;
}

#np-slug[aria-invalid="true"] + #np-slug-error {
  color: var(--bad);
  font-weight: 600;
}

/*   ask
   ---------------------------------------------------------------- */

.wiki-ask {
  width: min(34rem, calc(100vw - 32px));
}

.wiki-ask__status {
  display: block;
  margin: 0 0 var(--space-2);
  font-size: 14px;
  color: var(--ink3);
}

.wiki-ask__status:empty {
  display: none;
}

/* ask citations: the title, then the quoted line it came from */
.wiki-ask .citations {
  margin-top: var(--space-2);
}

/* conflict actions live inside the notice they belong to */
#wiki-notice {
  flex-wrap: wrap;
  max-width: none;
}

#wiki-notice button {
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

@media (pointer: coarse) {
  #wiki-notice button {
    min-height: 44px;
  }
}

/* ---------------------------------------------------- agent transcript */

.transcript {
  display: grid;
  gap: var(--space-2);
  min-width: 0;
}

.transcript-facts {
  list-style: none;
  margin: 0;
  padding: 10px 14px;
  border: 1px solid var(--line2);
  border-radius: var(--radius);
  background: var(--bg2);
  font-size: 14px;
  display: grid;
  gap: 2px;
  overflow-wrap: anywhere;
}

.transcript-note,
.transcript-event {
  margin: 0;
  color: var(--ink3);
  font-size: 14px;
  font-style: italic;
}

.transcript-event {
  text-align: center;
}

.transcript-turn {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 10px 14px;
  border: 1px solid var(--line2);
  border-radius: var(--radius);
  background: var(--bg2);
}

.transcript-turn--user {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.transcript-turn--reasoning {
  background: transparent;
  border-style: dashed;
}

.transcript-turn__head {
  font-size: 13px;
  color: var(--ink3);
}

.transcript-turn__head strong {
  color: var(--ink);
}

.transcript-text {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.transcript-md > :first-child {
  margin-top: 0;
}

.transcript-md > :last-child {
  margin-bottom: 0;
}

.transcript-call {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding-left: 10px;
  border-left: 2px solid var(--line);
}

.transcript-call__head {
  font-size: 13px;
  overflow-wrap: anywhere;
}

.transcript-call__status {
  color: var(--ink3);
}

.transcript-call__status.is-bad {
  color: var(--bad);
}

.transcript-call pre,
.transcript pre {
  margin: 0;
  max-height: 28rem;
  overflow: auto;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--bg3);
  font-family: var(--f-mono);
  font-size: 12.5px;
  white-space: pre;
}

.transcript-call__output summary,
.transcript-reasoning summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--ink3);
}

.transcript-call__output[open] summary,
.transcript-reasoning[open] summary {
  margin-bottom: 6px;
}

/* A subagent, nested in the call that launched it: indented on a rule, its
   header, task and answer, its steps drawn on request. */
.transcript-sub {
  display: grid;
  gap: 6px;
  min-width: 0;
  margin-inline-start: 4px;
  padding: 8px 12px;
  border: 1px solid var(--line2);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--bg);
}

.transcript-sub__head {
  font-size: 13px;
  color: var(--ink3);
  overflow-wrap: anywhere;
}

.transcript-sub__head strong {
  color: var(--ink);
}

.transcript-sub__status.is-bad {
  color: var(--bad);
}

.transcript-sub__desc {
  margin: 0;
  font-size: 14px;
  color: var(--ink2);
  overflow-wrap: anywhere;
}

.transcript-sub__answer > :first-child { margin-top: 0; }
.transcript-sub__answer > :last-child { margin-bottom: 0; }

.transcript-sub__more {
  justify-self: start;
  font-size: 13px;
}

.transcript-sub__steps {
  display: grid;
  gap: var(--space-2);
  min-width: 0;
  padding-left: 10px;
  border-left: 2px solid var(--line);
}

.transcript-sub__steps[hidden] { display: none; }

.transcript-model {
  font-family: var(--f-mono);
  font-size: 11.5px;
  text-transform: none;
  letter-spacing: 0;
}

/* -- the coding-agents wiki: a folder tree on home, statuses on sessions -- */

.ca-section { margin-block: 1.5rem; }
.ca-tree { font-size: 0.95rem; }
.ca-folder > summary {
  cursor: pointer;
  font-family: var(--f-mono);
  padding-block: 0.15rem;
}
.ca-folder__list {
  list-style: none;
  margin: 0.15rem 0 0.35rem;
  padding-inline-start: 1.1rem;
  border-inline-start: 1px solid var(--line);
}
.ca-folder__list > li { padding-block: 0.1rem; }
.ca-folder__meta {
  font-family: var(--f-body);
  font-size: 0.85rem;
  color: var(--ink3);
}
.ca-folder__info {
  font-size: 0.85rem;
  color: var(--ink3);
}
.ca-card { margin-block: 1rem; }
.ca-card h2 { margin-top: 0; }
.ca-card__summary { font-weight: 600; }
.ca-status--done { color: var(--accent); }
.ca-status--failed { color: var(--bad); }
.ca-status--skipped-no-model,
.ca-status--over-budget { color: var(--warn); }
.ca-pages {
  display: block;
  font-size: 0.85rem;
  padding-inline-start: 0.75rem;
  padding-block-end: 0.35rem;
}
.ca-compile { margin-block: 0.25rem 1rem; }

/* Temporal facts (docs/temporal-facts.md): the page's Facts card and the
   Facts view — a Current table, then the History list, newest first. */
.facts {
  margin-top: 1rem;
}
.facts h4 {
  margin: 0.75rem 0 0.25rem;
}
.facts__asof {
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
}
.facts__table {
  width: 100%;
  border-collapse: collapse;
  overflow-wrap: anywhere;
}
.facts__table th,
.facts__table td {
  text-align: left;
  padding: 0.25rem 0.5rem 0.25rem 0;
  border-bottom: 1px solid var(--line, rgba(127, 127, 127, 0.25));
  vertical-align: top;
}
.facts__history {
  margin: 0;
  padding-left: 1.1rem;
}
.facts__history li {
  margin: 0.2rem 0;
  overflow-wrap: anywhere;
}
.facts__retracted {
  opacity: 0.7;
}
.facts__dreamed {
  color: var(--ink2);
}

.facts__dream {
  margin: 0.4rem 0 0;
}

.facts__stale {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
  min-height: 44px;
}

/* The Facts view: a sticky controls bar, a subject rail on desktop (a select
   on narrow screens), and one section per subject of readable rows. */
.facts-controls {
  position: sticky;
  top: var(--topbar-h);
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-2) var(--space-3);
  align-items: center;
  padding: var(--space-2) 0 var(--space-2);
  margin-bottom: var(--space-3);
  background: var(--header-bg);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line2);
}
.facts-controls__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  min-width: 0;
}
.facts-search {
  display: block;
  min-width: 0;
}
.facts-search input {
  width: 100%;
  min-height: 44px;
  font-size: 16px;
}
.facts-asof > span,
.facts-sort > span {
  white-space: nowrap;
}
.facts-view .page-head {
  margin-bottom: var(--space-3);
}
.facts-asof,
.facts-sort,
.facts-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  font-size: 14px;
  color: var(--ink2);
}
.facts-asof input,
.facts-sort select {
  min-height: 44px;
  font-size: 16px;
}
.facts-today {
  min-height: 44px;
  border-style: solid;
  border-color: var(--field-line);
  color: var(--ink2);
}
.facts-switch {
  cursor: pointer;
  user-select: none;
}
.facts-switch input[type="checkbox"] {
  appearance: none;
  position: relative;
  flex: none;
  width: 2.5rem;
  height: 1.4rem;
  margin: 0;
  border-radius: 999px;
  border: 1px solid var(--field-line);
  background: var(--bg3);
  cursor: pointer;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease);
}
.facts-switch input[type="checkbox"]::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0.2rem;
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 50%;
  background: var(--ink3);
  transform: translateY(-50%);
  transition: transform 0.2s var(--ease), background 0.2s var(--ease);
}
.facts-switch input[type="checkbox"]:checked {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.facts-switch input[type="checkbox"]:checked::before {
  background: var(--accent);
  transform: translate(1.1rem, -50%);
}
.facts-status {
  margin: 0;
  font-family: var(--f-mono);
  font-size: 12px;
  color: var(--ink3);
}

.facts-layout {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: minmax(0, 1fr);
}
.facts-main {
  min-width: 0;
}
.facts-jump {
  display: grid;
  gap: 0.35rem;
  margin-bottom: var(--space-3);
}
.facts-jump label {
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink3);
}
.facts-jump select {
  width: 100%;
  min-height: 44px;
  font-size: 16px;
}
.facts-rail {
  display: none;
  min-width: 0;
}
.facts-rail__list {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.facts-rail__item {
  display: grid;
  justify-items: start;
  justify-content: start;
  text-align: left;
  gap: 2px;
  width: 100%;
  min-height: 44px;
  padding: 0.45rem 0.6rem;
  text-align: left;
  color: var(--ink2);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
}
.facts-rail__item:hover {
  color: var(--ink);
  background: var(--bg2);
  border-color: var(--line2);
}
.facts-rail__name {
  font-weight: 600;
  overflow-wrap: anywhere;
}
.facts-rail__meta {
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--ink3);
}

.facts-subject {
  min-width: 0;
  margin-bottom: var(--space-4);
  scroll-margin-top: 17rem;
}
.facts-subject__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.6rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--line2);
}
.facts-subject__name {
  margin: 0;
  font-size: var(--step-1);
  overflow-wrap: anywhere;
}
.facts-subject__type {
  padding: 1px 8px;
  border: 1px dashed var(--line);
  border-radius: 999px;
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink3);
}
.facts-subject__count {
  margin-inline-start: auto;
  font-family: var(--f-mono);
  font-size: 12px;
  color: var(--ink3);
}
.facts-subject__dream {
  margin: 0.45rem 0 0;
}
.facts-items {
  margin-top: var(--space-2);
  background: var(--bg2);
  border: 1px solid var(--line2);
  border-radius: var(--radius-card);
  overflow: hidden;
}
.facts-more {
  justify-self: start;
  margin-top: var(--space-2);
  min-height: 44px;
}

.fact {
  display: grid;
  gap: 0.3rem;
  min-width: 0;
  padding: 12px clamp(14px, 2.2vw, 20px);
  border-top: 1px solid var(--line2);
}
.facts-items > .fact:first-child {
  border-top: 0;
}
.fact--disputed {
  box-shadow: inset 3px 0 0 var(--warn);
}
.fact__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 0.6rem;
  min-width: 0;
}
.fact__title {
  margin: 0;
  font-family: var(--f-body);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.fact__badge {
  font-size: 10.5px;
}
.fact__badge--disputed {
  color: var(--warn);
  border: 1px solid var(--warn);
}
.fact__badge--stale {
  color: var(--ink3);
}
.fact__badge--dreamed {
  color: var(--ink2);
}
.fact__value {
  margin: 0;
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  white-space: pre-line;
  overflow-wrap: anywhere;
}
.fact__value--clamp {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.fact:has(.fact__more[aria-expanded="true"]) .fact__value--clamp {
  display: block;
  -webkit-line-clamp: unset;
  overflow: visible;
}
.fact__more {
  justify-self: start;
  min-height: 32px;
  padding: 0 0 0 0;
  background: none;
  border: 0;
  font-size: 13px;
  color: var(--accent);
}
.fact__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 16px;
  row-gap: 2px;
  min-width: 0;
}
.fact__foot > details[open] {
  flex: 1 1 100%;
}
.fact__meta {
  display: block;
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink3);
  overflow-wrap: anywhere;
}
.fact__none {
  margin: 0;
  font-size: 14px;
  font-style: italic;
  color: var(--ink3);
}
.fact__lead {
  margin: 0;
  font-size: 13px;
  color: var(--warn);
}
.fact__options {
  display: grid;
  gap: 0.6rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.fact__option {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
  padding-inline-start: 0.7rem;
  border-inline-start: 2px solid var(--line);
}
.fact__option .fact__value {
  white-space: normal;
}
.fact__details,
.fact__past {
  font-size: 13px;
  color: var(--ink2);
  min-width: 0;
}
.fact__details summary,
.fact__past summary {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  cursor: pointer;
  font-family: var(--f-mono);
  font-size: 12px;
  color: var(--ink3);
}
.fact__details dl {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 4px 12px;
  margin: 0.4rem 0 0;
}
.fact__details dt {
  color: var(--ink3);
}
.fact__details dd {
  margin: 0;
  overflow-wrap: anywhere;
}
.fact__past ul {
  display: grid;
  gap: 6px;
  margin: 0.4rem 0 0;
  padding: 0;
  list-style: none;
}
.fact__past li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  min-width: 0;
}
.fact__hist-range {
  font-size: 13px;
  color: var(--ink3);
}
.fact__hist-value {
  overflow-wrap: anywhere;
}
.fact__value--retracted {
  text-decoration: line-through;
  opacity: 0.7;
}
.facts-none {
  margin: 0;
  padding: var(--space-3) var(--space-2);
  color: var(--ink2);
}

@media (min-width: 52rem) {
  .facts-layout {
    grid-template-columns: 13.5rem minmax(0, 1fr);
    align-items: start;
    gap: var(--space-4);
  }
  .facts-jump {
    display: none;
  }
  .facts-controls {
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .facts-search {
    grid-column: 1;
  }
  .facts-controls__row {
    grid-column: 2;
    flex-wrap: nowrap;
  }
  .facts-status {
    grid-column: 1 / -1;
  }
  .facts-rail {
    display: block;
    position: sticky;
    top: calc(var(--topbar-h) + 8.5rem);
    max-height: calc(100dvh - var(--topbar-h) - 9.5rem);
    overflow-y: auto;
  }
  .facts-subject {
    scroll-margin-top: 9rem;
  }
}

/*   Pages home: projects first
   ---------------------------------------------------------------- */

.home-section {
  margin-block: 0 var(--space-3);
}

.home-section > h2 {
  font-size: var(--step-1);
  margin-block: 0 0.6rem;
}

/* A row's real title reads in the body face; a bare slug stays mono. */
.wiki-row__title {
  font-family: var(--f-body);
  font-weight: 600;
}

.pill[data-type="session"] {
  color: var(--t-session);
  border-color: var(--t-session);
}

.wiki-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  font-size: 14px;
  color: var(--ink2);
  cursor: pointer;
}

.wiki-toggle input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

/* The project cards: as many columns as fit at 17rem each, one on a
 * phone, never wider than the column. */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));
  gap: 12px;
}

.project-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
  border-top: 3px solid var(--t-project);
}

.project-card__name {
  font-size: var(--step-1);
  margin: 0;
  overflow-wrap: anywhere;
}

.project-card__name a {
  color: var(--ink);
  text-decoration: none;
}

.project-card__name a:hover {
  color: var(--accent);
}

.project-card__meta,
.project-card__agents {
  margin: 0;
  font-size: 14px;
  color: var(--ink2);
}

.project-card__agents {
  color: var(--ink3);
}

.project-card__sections {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0.4rem 0 0;
  padding: 0;
}

.project-card__sections a {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 2px 10px;
  border: 1px solid var(--line2);
  border-radius: 999px;
  font-size: 13px;
  text-decoration: none;
  color: var(--ink2);
  background: var(--bg);
}

.project-card__sections a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

@media (pointer: coarse) {
  .project-card__sections a {
    min-height: 44px;
  }
}

/*   one project's page
   ---------------------------------------------------------------- */

.project-body {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.project-card-block h2 {
  font-size: var(--step-1);
  margin-top: 0;
}

.project-list {
  list-style: none;
  margin: 0 0 0.6rem;
  padding: 0;
  display: grid;
  gap: 2px;
}

.project-list__row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 2px 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line2);
  min-width: 0;
}

.project-list__row:last-child {
  border-bottom: 0;
}

.project-list__main {
  font-weight: 600;
  overflow-wrap: anywhere;
  min-width: 0;
}

.project-list__meta {
  font-size: 13px;
  color: var(--ink3);
  overflow-wrap: anywhere;
}

.project-part__h {
  font-size: var(--step-1);
  margin-top: 0;
}

/* ------------------------------------------------------------------
   Diagrams (diagrams.js, diagram-view.js). Mermaid's own colours come from
   the same tokens (diagram-view.js reads them), so a card follows the theme
   switch with the rest of the page. Stages scroll sideways on a phone; the
   page itself never does. */

.diagrams {
  display: grid;
  gap: var(--space-3);
  min-width: 0;
  margin-top: var(--space-3);
}
.diagrams[hidden] { display: none; }
.diagrams__title {
  margin: 0;
  font-family: var(--f-display);
  font-size: var(--step-1);
  color: var(--ink);
}

.diagram-card,
figure.mermaid-block {
  min-width: 0;
  max-width: 100%;
  margin: 0;
}
.diagram-card {
  border: 1px solid var(--line2);
  border-radius: var(--radius-card);
  background: var(--bg2);
  padding: var(--space-2) var(--space-3);
}
.diagram-card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 0.6rem;
  margin: 0;
  font: 500 0.8rem/1.3 var(--f-body);
  color: var(--ink3);
}
.diagram-card__kind {
  color: var(--ink);
  font-weight: 600;
}
.diagram-card__tools {
  display: flex;
  gap: 0.4rem;
  margin-left: auto;
  align-items: center;
}
.diagram-card__stage {
  margin-top: 0.6rem;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 0.25rem 0;
}
.diagram-card__stage svg {
  display: block;
  max-width: none;
  height: auto;
}
.diagram-card__stage .is-link { cursor: pointer; }
.diagram-card__stage .is-link:hover { opacity: 0.85; }
.diagram-card__stage.is-failed { overflow-x: auto; }
.diagram-card__code {
  margin: 0;
  font-size: 0.8rem;
  white-space: pre;
}
.diagram-card__list {
  margin-top: 0.5rem;
  font-size: 0.82rem;
  color: var(--ink3);
}
.diagram-card__list summary { cursor: pointer; }
.diagram-card__list ul { margin: 0.4rem 0 0; padding-left: 1.1rem; }

.diagram-btn {
  font: inherit;
  font-size: 0.8rem;
  line-height: 1.2;
  min-height: 2rem;
  padding: 0.25rem 0.75rem;
  color: var(--ink2);
  background: var(--bg3);
  border: 1px solid var(--line2);
  border-radius: 999px;
  cursor: pointer;
}
.diagram-btn:hover { color: var(--ink); border-color: var(--line); }
.diagram-btn:focus-visible,
.diagram-menu__item:focus-visible,
.diagram-card__stage:focus-visible,
.diagram-dialog__stage:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.diagram-menu-wrap { position: relative; }
.diagram-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  z-index: 5;
  min-width: 14rem;
  margin: 0;
  padding: 0.3rem;
  list-style: none;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px oklch(0 0 0 / 0.25);
}
.diagram-menu[hidden] { display: none; }
.diagram-menu li { margin: 0; }
.diagram-menu__item {
  display: block;
  width: 100%;
  padding: 0.5rem 0.65rem;
  text-align: left;
  font: inherit;
  font-size: 0.86rem;
  color: var(--ink);
  background: none;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
.diagram-menu__item:hover { background: var(--bg3); }
.diagram-toast {
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  z-index: 6;
  margin: 0;
  padding: 0.25rem 0.6rem;
  font-size: 0.78rem;
  white-space: nowrap;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: 999px;
}
.diagram-toast[hidden] { display: none; }

.diagram-dialog {
  width: min(96vw, 1400px);
  max-width: 96vw;
  max-height: 92vh;
  padding: var(--space-3);
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
}
.diagram-dialog::backdrop { background: oklch(0 0 0 / 0.6); }
.diagram-dialog__stage {
  overflow: auto;
  max-height: calc(92vh - 5rem);
  margin-top: 0.6rem;
}
.diagram-dialog__stage svg { display: block; max-width: none; height: auto; }

@media (max-width: 40rem) {
  .diagram-card { padding: var(--space-2); }
  .diagram-card__tools { margin-left: 0; }
  .diagram-menu { left: 0; right: auto; }
  .diagram-toast { left: 0; right: auto; }
}
