/* The advanced style (Flow and Rings): a deep ink masthead that carries the counts, above a
   sheet with a drawing grid: the drawing or the list on the left, the node's sheet on the right. On
   phones an open node takes the screen. Colours are roles; light and dark values swap here,
   and the views read the group colours (--g1 ... --g8, the validated palette of plain/) from
   the same variables. */
:root {
  color-scheme: light;
  --ground: #E9EDF7; --surface: #FFFFFF; --surface-2: #F4F6FB;
  --ink: #0B0D14; --ink-2: #2C3144; --mute: #626C82; --muted: #898781;
  --rule: #C8CFDD; --rule-soft: #DFE4EE;
  --cobalt: #0040E3; --signal: #A81E17; --warn: #B98A14;
  --edge: #4C5570; --node-line: #2C3144;
  --sel-fill: #0040E3; --sel-ink: #FFFFFF; --sel-halo: rgba(0, 64, 227, 0.30); --hover-halo: rgba(0, 64, 227, 0.16);
  --grid: rgba(0, 64, 227, 0.05); --grid-major: rgba(0, 64, 227, 0.085);
  --shadow: 0 1px 2px rgba(11, 13, 20, 0.07), 0 16px 36px -18px rgba(11, 13, 20, 0.34);
  --band: #0A1230; --band-rule: #0040E3; --band-ink: #F2F5FC; --band-mute: #A9B4CF;
  --band-line: rgba(255, 255, 255, 0.20); --band-2: rgba(255, 255, 255, 0.08);
  --st-mathlib: #8EDDBB; --st-lean: #BFEBD5; --st-sorry: #FFE9A8; --st-planned: #EEF1F7; --st-informal: #FFFFFF;
  --code-bg: #F4F6FB;
  --g1: #2a78d6; --g2: #eb6834; --g3: #1baf7a; --g4: #eda100;
  --g5: #e87ba4; --g6: #008300; --g7: #6250d6; --g8: #e34948;
  --f-ui: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --f-text: "Source Serif 4", "STIX Two Text", Georgia, serif;
  --f-label: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ground: #080A10; --surface: #101420; --surface-2: #171C2B;
    --ink: #EDF0F7; --ink-2: #C7CEDD; --mute: #98A2B8;
    --rule: #2E3548; --rule-soft: #222839;
    --cobalt: #6E92FF; --signal: #FF8177; --warn: #F2A33A;
    --edge: #98A3BC; --node-line: #C7CEDD;
    --sel-fill: #2F5BFF; --sel-halo: rgba(110, 146, 255, 0.45); --hover-halo: rgba(110, 146, 255, 0.24);
    --grid: rgba(110, 146, 255, 0.05); --grid-major: rgba(110, 146, 255, 0.10);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 20px 44px -22px rgba(0, 0, 0, 0.85);
    --band: #121A38; --band-rule: #2F5BFF;
    --st-mathlib: #0C6749; --st-lean: #104B39; --st-sorry: #4B3D10; --st-planned: #1B2133; --st-informal: #101420;
    --code-bg: #171C2B;
    --g1: #3987e5; --g2: #d95926; --g3: #199e70; --g4: #c98500;
    --g5: #d55181; --g6: #008300; --g7: #9085e9; --g8: #e66767;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ground: #080A10; --surface: #101420; --surface-2: #171C2B;
  --ink: #EDF0F7; --ink-2: #C7CEDD; --mute: #98A2B8;
  --rule: #2E3548; --rule-soft: #222839;
  --cobalt: #6E92FF; --signal: #FF8177; --warn: #F2A33A;
  --edge: #98A3BC; --node-line: #C7CEDD;
  --sel-fill: #2F5BFF; --sel-halo: rgba(110, 146, 255, 0.45); --hover-halo: rgba(110, 146, 255, 0.24);
  --grid: rgba(110, 146, 255, 0.05); --grid-major: rgba(110, 146, 255, 0.10);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 20px 44px -22px rgba(0, 0, 0, 0.85);
  --band: #121A38; --band-rule: #2F5BFF;
  --st-mathlib: #0C6749; --st-lean: #104B39; --st-sorry: #4B3D10; --st-planned: #1B2133; --st-informal: #101420;
  --code-bg: #171C2B;
  --g1: #3987e5; --g2: #d95926; --g3: #199e70; --g4: #c98500;
  --g5: #d55181; --g6: #008300; --g7: #9085e9; --g8: #e66767;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--ground); color: var(--ink); font-family: var(--f-ui); overflow: hidden; }
.app { height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr); }
:focus-visible { outline: 2px solid var(--cobalt); outline-offset: 1px; }
a { color: var(--cobalt); }
code, pre, kbd { font-family: var(--f-label); font-size: 0.88em; }
code { color: var(--ink-2); overflow-wrap: anywhere; }
kbd { border: 1px solid var(--rule); padding: 0 4px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Masthead */
.band { background: var(--band); color: var(--band-ink); border-top: 6px solid var(--band-rule); color-scheme: dark; }
.band-in {
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 11px 12px; display: grid; gap: 10px;
}
.hd { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 24px; }
.hd > div { min-width: 0; }
h1 { margin: 0; font-size: 26px; line-height: 1.08; font-weight: 800; letter-spacing: -0.024em; text-wrap: balance; }
.meta { margin: 3px 0 0; color: var(--band-mute); font-size: 13px; }
.meta a { color: var(--band-ink); }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.seg { display: inline-flex; border: 1px solid var(--band-line); }
.seg button, .band select, .band input[type="search"] {
  font: 500 13px var(--f-ui); color: var(--band-ink); background: transparent; border: 0;
  padding: 6px 11px; min-height: 32px; cursor: pointer;
}
.seg button + button, .seg-l + button { border-left: 1px solid var(--band-line); }
/* the caption of a switch, so that "All" says what it counts */
.seg-l {
  display: inline-flex; align-items: center; padding: 0 9px; font: 500 10.5px var(--f-label);
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--band-mute); background: var(--band-2);
}
.seg button:hover { background: var(--band-2); }
.seg button[aria-pressed="true"] { background: var(--band-ink); color: var(--band); }
.band select, .band input[type="search"] { border: 1px solid var(--band-line); background: var(--band-2); max-width: 100%; }
.band select { max-width: 230px; }
.band select option { color: var(--ink); background: var(--surface); }
.band input[type="search"] { width: 170px; cursor: text; }
.band input[type="search"]::placeholder { color: var(--band-mute); }
.toggle { display: inline-flex; gap: 6px; align-items: center; font: 500 13px var(--f-ui); color: var(--band-ink); cursor: pointer; }
.toggle input { accent-color: var(--band-rule); }
.profile-switch label { display: inline-flex; gap: 6px; align-items: center; font: 500 13px var(--f-ui); color: var(--band-mute); }
.search { position: relative; }
#search-results {
  position: absolute; z-index: 30; right: 0; top: calc(100% + 4px); width: min(420px, 90vw);
  list-style: none; margin: 0; padding: 4px 0; max-height: 60vh; overflow: auto;
  background: var(--surface); color: var(--ink); border: 1px solid var(--rule); box-shadow: var(--shadow);
  color-scheme: light dark;
}
#search-results li { padding: 5px 10px; cursor: pointer; font: 14px/1.35 var(--f-ui); }
#search-results li .sub { display: block; color: var(--mute); font: 11.5px var(--f-label); }
#search-results li[aria-selected="true"], #search-results li[data-i]:hover { background: var(--surface-2); }
#search-results li.index-group {
  cursor: default; font: 700 11px var(--f-ui); letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--mute); padding-top: 10px;
}
#search-results li.lvl2 { color: var(--ink-2); font-style: italic; }
#search-results li.muted { color: var(--mute); cursor: default; }
.views { display: inline-flex; border: 1px solid var(--band-line); }
.views a { font: 500 13px var(--f-ui); color: var(--band-mute); text-decoration: none; padding: 6px 10px; min-height: 32px; display: inline-flex; align-items: center; }
.views a + a { border-left: 1px solid var(--band-line); }
.views a:hover { color: var(--band-ink); background: var(--band-2); }
.views a[aria-current="page"] { color: var(--band); background: var(--band-ink); }

.state { display: grid; grid-template-columns: auto minmax(180px, 1fr) auto; align-items: center; gap: 6px 16px; }
.state-h { font-size: 13px; color: var(--band-mute); white-space: nowrap; }
.state-h b { color: var(--band-ink); font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.bar { display: flex; gap: 2px; height: 14px; }
.sb { position: relative; min-width: 0; padding: 0; border: 0; cursor: pointer; }
.sb::before { content: ""; position: absolute; inset: -7px 0; }
.sb:first-child { border-radius: 3px 0 0 3px; }
.sb:last-child { border-radius: 0 3px 3px 0; }
.sb.hv, .sb.on { outline: 2px solid var(--band-ink); outline-offset: 1px; z-index: 1; }
.sb-mathlib { background: #0B7A53; }
.sb-lean { background: #1CAC78; }
.sb-sorry { background: #D9A21B; }
.sb-planned { background: rgba(255, 255, 255, 0.16); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.42); }
.sb-informal { background: transparent; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.42); }
.keys { display: flex; flex-wrap: wrap; gap: 2px 4px; }
.key {
  display: inline-flex; align-items: center; gap: 5px; background: none; border: 0; color: var(--band-mute);
  font: 500 12px var(--f-ui); padding: 3px 6px; cursor: pointer; white-space: nowrap;
}
.key b { color: var(--band-ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.key i { width: 10px; height: 10px; display: inline-block; }
.key.hv, .key.on { background: var(--band-2); color: var(--band-ink); }

/* Working area */
.main {
  min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) clamp(360px, 34vw, 540px); gap: 12px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 12px;
}
.left { min-height: 0; min-width: 0; display: grid; }
.stage {
  --gs: 16px; --gx: 0px; --gy: 0px;
  position: relative; overflow: hidden; min-height: 0; box-shadow: var(--shadow);
  border: 1px solid var(--rule); touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none;
  background-color: var(--surface);
  background-image:
    linear-gradient(var(--grid-major) 1px, transparent 1px), linear-gradient(90deg, var(--grid-major) 1px, transparent 1px),
    linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: calc(var(--gs) * 5) calc(var(--gs) * 5), calc(var(--gs) * 5) calc(var(--gs) * 5), var(--gs) var(--gs), var(--gs) var(--gs);
  background-position: var(--gx) var(--gy);
}
.stage.grabbing { cursor: grabbing; }
svg.gv { position: absolute; left: 0; top: 0; width: 100%; height: calc(100% - 40px); display: block; }
.status {
  position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); z-index: 4;
  font: 500 14px var(--f-ui); color: var(--ink-2); background: var(--surface); padding: 8px 14px;
  border: 1px solid var(--rule); max-width: calc(100% - 32px);
}
.status:empty { display: none; }
.status.error { color: var(--signal); }
.ctl { position: absolute; z-index: 2; }
.zoom { left: 8px; bottom: 3px; z-index: 3; display: flex; border: 1px solid var(--rule); background: var(--surface); }
.tool { font: 500 15px var(--f-ui); color: var(--ink); background: var(--surface); border: 0; padding: 6px 10px; min-height: 32px; min-width: 36px; cursor: pointer; }
.tool:hover { background: var(--surface-2); }
.tool + .tool { border-left: 1px solid var(--rule); }
#hint {
  left: 10px; top: 10px; margin: 0; padding: 4px 8px; background: var(--ink-2); max-width: calc(100% - 20px);
  font: 500 12px var(--f-label); color: var(--surface); pointer-events: none; box-shadow: var(--shadow);
}
.axis {
  left: 0; right: 0; bottom: 0; height: 40px; padding: 0 14px 0 152px; background: var(--surface);
  border-top: 1px solid var(--rule-soft); display: flex; align-items: center; gap: 10px;
  font: 500 10.5px var(--f-label); letter-spacing: 0.13em; text-transform: uppercase; color: var(--mute);
}
.axis i { flex: 1; height: 1px; background: var(--mute); position: relative; opacity: 0.55; }
.axis i::after {
  content: ""; position: absolute; right: 0; top: -3px; border-left: 7px solid var(--mute);
  border-top: 3.5px solid transparent; border-bottom: 3.5px solid transparent;
}
.mi { flex: none; }
.mousekey { flex: none; margin-left: 6px; display: flex; gap: 4px; font: 500 12px/1.2 var(--f-ui); letter-spacing: 0; text-transform: none; color: var(--ink-2); }
.mousekey span { display: flex; align-items: center; gap: 7px; padding: 4px 8px; background: var(--surface-2); }
.mousekey b { font-weight: 700; color: var(--ink); margin-right: -3px; }
.mousekey.armed .mk-r { background: var(--sel-fill); color: var(--sel-ink); }
.mousekey.armed .mk-r b { color: var(--sel-ink); }

/* Graph marks */
.lane .ft { fill: var(--ink-2); font: 700 15px var(--f-label); }
.ring { fill: none; stroke: var(--rule); stroke-width: 1px; vector-effect: non-scaling-stroke; }
.sector-title { font-family: var(--f-ui); font-weight: 800; letter-spacing: -0.02em; pointer-events: none; }
.wedge { pointer-events: none; }
.edge path { fill: none; stroke: var(--edge); stroke-width: 1.15px; vector-effect: non-scaling-stroke; }
.edge polygon { stroke: var(--edge); fill: var(--edge); stroke-width: 0.6px; vector-effect: non-scaling-stroke; }
.edge.manual path { stroke-dasharray: 5 4; }
.edge.example path { stroke-dasharray: 1.5 3; }
/* In Grouped, arrows inside a frame lead; arrows between frames recede until they are traced. */
.edge.xf:not(.up):not(.down) { opacity: 0.35; }
.edge.xf.dim:not(.up):not(.down) { opacity: 0.08; }
.edge.up path { stroke: var(--cobalt); stroke-width: 2.4px; stroke-dasharray: 7 5; animation: flow12 0.9s linear infinite; }
.edge.up polygon { stroke: var(--cobalt); fill: var(--cobalt); }
.edge.down path { stroke: var(--signal); stroke-width: 2.4px; stroke-dasharray: 7 5; animation: flow12 0.9s linear infinite; }
.edge.down polygon { stroke: var(--signal); fill: var(--signal); }
@keyframes flow12 { to { stroke-dashoffset: -12; } }
@keyframes flow8 { to { stroke-dashoffset: -8; } }
.node { cursor: pointer; }
.node .shape { stroke: var(--node-line); stroke-width: 1.4px; }
.node.imp1 .shape { stroke-width: 1px; }
.node.imp3 .shape { stroke-width: 2.6px; }
.st-mathlib .shape { fill: var(--st-mathlib); }
.st-lean .shape { fill: var(--st-lean); }
.st-sorry .shape { fill: var(--st-sorry); stroke: var(--warn); }
.st-planned .shape { fill: var(--st-planned); stroke-dasharray: 5 3; }
.st-informal .shape { fill: var(--st-informal); stroke-dasharray: 2 3; }
.node text { font: 500 12px var(--f-ui); fill: var(--ink); }
.node.lvl2 text { font-style: italic; }
.node:focus { outline: none; }
.node:hover { filter: drop-shadow(0 4px 6px rgba(11, 13, 20, 0.38)); }
.halo { fill: none; stroke: none; vector-effect: non-scaling-stroke; pointer-events: none; }
.node:hover .halo { stroke: var(--hover-halo); stroke-width: 12px; }
.node:focus-visible .shape { stroke: var(--cobalt); stroke-width: 3.4px; }
.node.sel .shape { fill: var(--sel-fill); stroke: var(--sel-fill); }
.node.sel text { fill: var(--sel-ink); font-weight: 700; }
.node.sel .halo { stroke: var(--sel-halo); stroke-width: 18px; }
.dim { opacity: 0.13; }
/* A right click opens a node without moving the arrows: a ring marks it. */
.node.peek .halo { stroke: var(--ink); stroke-width: 9px; }
.node.peek text { font-weight: 700; }

/* Status marks shared by the panel and the list: the fill of the nodes */
.st-mathlib { --sv: var(--st-mathlib); }
.st-lean { --sv: var(--st-lean); }
.st-sorry { --sv: var(--st-sorry); }
.st-planned { --sv: var(--st-planned); }
.st-informal { --sv: var(--st-informal); }
.pill { display: inline-block; font: 500 11.5px var(--f-ui); padding: 2px 8px; background: var(--sv); color: var(--ink); white-space: nowrap; border: 1px solid var(--rule); }
.sw { display: inline-block; width: 12px; height: 12px; border: 1.5px solid var(--node-line); border-radius: 50%; margin-right: 7px; vertical-align: -1px; flex: none; background: var(--sv); }
.sw.box { border-radius: 2px; }
.sw.st-planned { border-style: dashed; }
.sw.st-informal { border-style: dotted; }
.sw.st-sorry { border-color: var(--warn); }

/* List */
.list { min-height: 0; overflow: auto; background: var(--surface); border: 1px solid var(--rule); box-shadow: var(--shadow); }
.lh { padding: 12px 14px; border-bottom: 1px solid var(--rule-soft); }
.lh p { margin: 0; font: 15px/1.45 var(--f-text); }
.lh b { font-family: var(--f-ui); }
table.nt { width: 100%; border-collapse: collapse; font-size: 13px; }
table.nt th {
  position: sticky; top: 0; z-index: 1; background: var(--surface-2); text-align: left;
  font: 700 11px var(--f-ui); letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-2);
  padding: 7px 8px; border-bottom: 1px solid var(--rule); white-space: nowrap;
}
table.nt td { padding: 6px 8px; border-bottom: 1px solid var(--rule-soft); vertical-align: middle; transition: background-color 120ms ease; }
table.nt td.nm { font: 500 13.5px var(--f-ui); }
table.nt td.nm.lvl2 { font-style: italic; color: var(--ink-2); }
table.nt td.num { font: 500 12px var(--f-label); color: var(--mute); white-space: nowrap; font-variant-numeric: tabular-nums; }
table.nt td code { font-size: 11.5px; }
table.nt tr.gr td {
  padding: 13px 8px 7px; background: color-mix(in srgb, var(--c) 9%, var(--surface));
  border-bottom: 1px solid color-mix(in srgb, var(--c) 45%, var(--surface));
}
.gr-in { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.gr-t { display: inline-flex; align-items: center; gap: 8px; font: 700 13px var(--f-ui); color: var(--ink); }
.gtab { display: inline-block; width: 5px; height: 15px; background: var(--c); }
.gbar { display: inline-flex; gap: 1px; width: 130px; height: 7px; }
.gbar i { display: block; min-width: 0; height: 100%; }
.gbar .sb-planned, .gbar .sb-informal { background: var(--rule); box-shadow: none; }
.gn { font: 500 11.5px var(--f-label); color: var(--mute); font-variant-numeric: tabular-nums; }
table.nt tr[data-id] { cursor: pointer; }
table.nt tr[data-id]:hover td { background: var(--surface-2); }
table.nt tr.sel td { background: var(--surface-2); box-shadow: inset 0 -1px 0 var(--cobalt), inset 0 1px 0 var(--cobalt); }
table.nt td.mute { color: var(--mute); }

/* Sheet */
.panel { min-height: 0; overflow: auto; background: var(--surface); border: 1px solid var(--rule); padding: 16px; box-shadow: var(--shadow); }
.panel h2 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -0.018em; text-wrap: balance; line-height: 1.15; }
.panel h3 {
  display: flex; align-items: center; gap: 8px; margin: 20px 0 6px;
  font: 500 10.5px var(--f-label); letter-spacing: 0.13em; text-transform: uppercase; color: var(--mute);
}
.panel h3::after { content: ""; flex: 1; height: 1px; background: var(--rule-soft); }
.panel p, .panel li { font: 15px/1.5 var(--f-text); color: var(--ink); }
.panel p { margin: 0 0 8px; max-width: 68ch; }
.panel p.lede { font-size: 17px; line-height: 1.45; margin-top: 8px; }
.panel .hint { margin-top: 8px; font-size: 13px; color: var(--mute); }
.panel .muted, .muted { color: var(--mute); }
.nhead { margin: -16px -16px 14px; padding: 12px 16px 13px; background: var(--sv); border-bottom: 4px solid var(--node-line); }
.nhead.st-sorry { border-bottom-color: var(--warn); }
.nhead.st-planned { border-bottom-style: dashed; }
.nhead.st-informal { border-bottom-style: dotted; }
.nhead h2 { margin-top: 7px; }
.head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.gname { font: 500 11.5px var(--f-label); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); }
.close { font: 500 12px var(--f-ui); color: var(--ink-2); background: var(--surface); border: 1px solid var(--rule); padding: 5px 9px; cursor: pointer; flex: none; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.badge { font: 500 11.5px var(--f-ui); padding: 2px 8px; background: var(--surface); color: var(--ink); border: 1px solid var(--rule); white-space: nowrap; }
.badge.planned, .badge.informal { border-style: dashed; }
.badge.sorry { border-color: var(--warn); }
.lean-name { font: 12.5px var(--f-label); color: var(--ink-2); word-break: break-all; margin-top: 4px; }
.lean-name button, .inside-btn { font: 500 11px var(--f-ui); margin-left: 6px; border: 1px solid var(--rule); background: var(--surface); color: var(--ink-2); cursor: pointer; padding: 1px 6px; }
.panel pre {
  background: var(--code-bg); padding: 8px 10px; overflow: auto; white-space: pre; font-size: 12px;
  line-height: 1.4; margin: 6px 0; border-left: 4px solid var(--cobalt);
}
.statement { margin: 6px 0; font: 15px/1.5 var(--f-text); }
.doc p { margin: 6px 0; }
.doc ul { margin: 6px 0; padding-left: 20px; }
.links { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 8px 0; font: 500 13px var(--f-ui); }
.links .private { color: var(--mute); cursor: help; text-decoration: underline dotted; }
.deps { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.deps li button, .example-of button {
  font: 500 13.5px var(--f-ui); text-align: left; background: none; border: none; padding: 0;
  color: var(--cobalt); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px;
}
.deps .via { color: var(--mute); font-size: 12px; }
.deps .via .decl-link, .deps li button.decl-link { font-size: 12px; }
.decl-title { font-family: var(--f-label); font-size: 17px; word-break: break-all; }
.example-of { margin: 2px 0 8px; color: var(--ink-2); }
.warn { color: var(--signal); }
details > summary { cursor: pointer; font: 500 13px var(--f-ui); color: var(--ink-2); }
details.proof, details.supporting { margin: 10px 0 4px; border-top: 1px solid var(--rule-soft); padding-top: 8px; }
.supporting-list { list-style: none; padding: 0; margin: 6px 0; display: grid; gap: 6px; }
.supporting-list li { border-left: 2px solid var(--rule); padding-left: 8px; }
.supporting-list .name { font: 12px var(--f-label); word-break: break-all; }
.supporting-list .loc { color: var(--mute); font: 12px var(--f-ui); }
.supporting-list .sdoc { font-size: 13px; color: var(--ink-2); }
.peekbar {
  position: sticky; top: -16px; z-index: 3; margin: -16px -16px 16px; padding: 8px 12px; display: flex; flex-wrap: wrap;
  align-items: center; gap: 6px 8px; background: var(--ink-2); color: var(--surface); font: 500 12.5px/1.35 var(--f-ui);
}
.peekbar span { flex: 1 1 200px; }
.peekbar button { font: 500 12px var(--f-ui); color: var(--ink); background: var(--surface); border: 0; padding: 4px 9px; cursor: pointer; flex: none; }
.peekbar button:hover { background: var(--surface-2); }
.peekbar + .nhead { margin-top: -16px; }
.mhow { display: grid; gap: 9px; margin: 12px 0 14px; padding: 11px 13px; background: var(--surface-2); border-left: 4px solid var(--cobalt); }
.panel .mhow p { margin: 0; display: grid; grid-template-columns: 14px minmax(0, 1fr); gap: 9px; font-size: 14.5px; line-height: 1.45; }
.mhow .mi { margin-top: 3px; color: var(--ink-2); }

/* How a node connects */
.flow { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 96px minmax(0, 1fr); gap: 6px 0; margin-top: 6px; }
.fl-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.fh { font: 700 11.5px var(--f-ui); }
.need-t { color: var(--cobalt); }
.used-t { color: var(--signal); }
.fs { display: grid; gap: 5px; align-content: center; min-width: 0; position: relative; }
.fm { display: flex; align-items: center; justify-content: center; position: relative; }
.fc { font: 700 11.5px var(--f-label); color: var(--sel-ink); background: var(--sel-fill); padding: 6px 8px; border-radius: 50%/50%; min-width: 58px; text-align: center; box-shadow: 0 0 0 5px var(--sel-halo); }
.fb {
  display: flex; align-items: flex-start; width: 100%; text-align: left; background: var(--surface-2);
  border: 1px solid var(--rule-soft); padding: 5px 7px; cursor: pointer; color: var(--ink); min-width: 0;
  transition: border-color 120ms ease, background-color 120ms ease;
}
.fb:hover { border-color: var(--cobalt); }
.fb .sw { margin-top: 2px; }
.fbt { display: block; min-width: 0; font: 12.5px/1.25 var(--f-ui); overflow-wrap: anywhere; }
.none { color: var(--mute); font: 13px var(--f-text); }
.fl { fill: none; stroke-width: 1.5; stroke-dasharray: 4 4; animation: flow8 0.8s linear infinite; }
.fl.need { stroke: var(--cobalt); }
.fl.used { stroke: var(--signal); }
.fa.need { fill: var(--cobalt); }
.fa.used { fill: var(--signal); }

/* Legend */
.lg { display: grid; gap: 1px; }
.lr {
  display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 8px; align-items: center; width: 100%;
  padding: 3px 5px; text-align: left; background: none; border: 0; color: var(--ink);
}
button.lr { cursor: pointer; transition: background-color 120ms ease; }
button.lr:hover, .lr.hv, .lr.on { background: var(--surface-2); }
.lr.on { box-shadow: inset 3px 0 0 var(--sel-fill); }
.lr svg { display: block; }
.lr span { font: 14px/1.3 var(--f-text); color: var(--ink); }
.lr .n { font: 500 12px var(--f-label); color: var(--mute); font-variant-numeric: tabular-nums; }
.lg-mathlib, .lg-lean, .lg-sorry, .lg-planned, .lg-informal, .lg-shape { stroke: var(--node-line); stroke-width: 1.3; fill: var(--surface); }
.lg-mathlib { fill: var(--st-mathlib); }
.lg-lean { fill: var(--st-lean); }
.lg-sorry { fill: var(--st-sorry); stroke: var(--warn); }
.lg-planned { fill: var(--st-planned); stroke-dasharray: 4 2; }
.lg-informal { fill: var(--st-informal); stroke-dasharray: 1.5 2; }
.lg-shape.thick { stroke-width: 2.6; }
.lg-edge { fill: none; stroke: var(--edge); stroke-width: 1.3; }
.lg-edge.dashed { stroke-dasharray: 4 3; }
.lg-head { fill: var(--edge); }

@media (prefers-reduced-motion: reduce) {
  .edge.up path, .edge.down path, .fl { animation: none; stroke-dasharray: none; }
  table.nt td, .fb, button.lr { transition: none; }
}
@media (hover: none) { .mousekey { display: none; } }
@media (max-width: 1180px) {
  .state { grid-template-columns: auto minmax(0, 1fr); }
  .keys { grid-column: 1 / -1; }
  .axis > span, .axis > i { display: none; }
  .mousekey { margin-left: auto; }
}
@media (max-width: 820px) {
  .mousekey { display: none; }
  h1 { font-size: 20px; }
  .meta, .keys { display: none; }
  .state { grid-template-columns: minmax(0, 1fr); gap: 5px; }
  .main { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 56%) minmax(0, 44%); gap: 10px; }
  .axis span, .axis i { display: none; }
  .band input[type="search"] { width: 120px; }
  .app.sheet .panel {
    position: fixed; inset: 0; z-index: 20; border: 0;
    padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(14px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  }
  .flow { grid-template-columns: minmax(0, 1fr) 80px minmax(0, 1fr); }
  table.nt .opt { display: none; }
}
@media (forced-colors: active) {
  .sw, .sb, .key i { forced-color-adjust: none; }
}
