/*
 * Boost Dependency Graph: boost.org v3 look (dark default, light via html:not(.dark)).
 *
 * C++ standard scale (--std-*): one ordered 6-step palette chosen with the dataviz validator.
 * Old to new: 98/03 slate (legacy, almost neutral), 11 violet, 14 magenta, 17 rose, 20 lavender, 23 pale lilac.
 * It avoids the relation colors (orange #FFA000 and #FFD897, blues #0077B8/#6DCDF7/#92CBE9,
 * green #5AD599, error red #EB3856), so a node fill is never mistaken for a border or an edge.
 * Hex values: --std-03 #8F98B3, --std-11 #6F5CE8, --std-14 #C85BD0, --std-17 #F2587A,
 * --std-20 #C9A0F0, --std-23 #F2E6FF.
 * Validator: contrast >= 3:1 against the dark surface and every adjacent pair >= 14 dE in normal vision
 * and >= 6 under CVD, except 03 (low chroma by design) and 23 (near white by design) which fail the
 * categorical lightness and chroma bands. This is an ordered scale, not a categorical one, so the
 * standard is also always given as text (tooltip, details, legend chips) and nodes carry a ring.
 */
:root {
  --std-03: #8F98B3;
  --std-11: #6F5CE8;
  --std-14: #C85BD0;
  --std-17: #F2587A;
  --std-20: #C9A0F0;
  --std-23: #F2E6FF;
  --std-none: #8A8FA3;

  --orange: #FFA000;
  --green: #5AD599;
  --red: #EB3856;
  --radius: 8px;
  --font: "Mona Sans", "Mona Sans VF", -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

/* light */
:root {
  --page: #F7F7F8;
  --card: #FFFFFF;
  --card-2: #EEEEF1;
  --border: rgba(5, 8, 22, .1);
  --text: #050816;
  --text-dim: #4B5063;
  --text-faint: #7B8095;
  --dep: #FFA000;
  --tdep: #FFC15C;
  --rdep: #0077B8;
  --trdep: #62B3DD;
  --edge: rgba(5, 8, 22, .09);
  --edge-dim: rgba(5, 8, 22, .04);
  --node-ring: rgba(5, 8, 22, .35);
  --label-halo: #F7F7F8;
  --shadow: 0 6px 24px rgba(5, 8, 22, .12);
  --link-orange-text: #8A5600;
  color-scheme: light;
}

/* dark */
html.dark {
  --page: #050816;
  --card: #12141F;
  --card-2: #1A1C29;
  --border: rgba(247, 247, 248, .1);
  --text: #E6E6E6;
  --text-dim: #B5B8C6;
  --text-faint: #8387A0;
  --dep: #FFA000;
  --tdep: #FFD897;
  --rdep: #6DCDF7;
  --trdep: #6891AA; /* #92CBE9 at 70% over the page: the soft counterpart of #6DCDF7, 5.9:1 on #050816 */
  --edge: rgba(247, 247, 248, .08);
  --edge-dim: rgba(247, 247, 248, .035);
  --node-ring: rgba(247, 247, 248, .35);
  --label-halo: #050816;
  --shadow: 0 8px 28px rgba(0, 0, 0, .5);
  --link-orange-text: #FFA000;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: flex;
  flex-direction: column;
  background: var(--page);
  color: var(--text);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
code { font-family: var(--mono); }
.defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* header */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--page);
  flex: none;
}
.brand { min-width: 0; }
.brand h1 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; }
.subtitle { margin: 0; color: var(--text-dim); font-size: 12.5px; }
.search { position: relative; flex: 1 1 320px; max-width: 460px; margin-left: auto; }
.search input {
  width: 100%;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font: inherit;
  outline: none;
}
.search input:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(255, 160, 0, .2); }
.results {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 60vh;
  overflow: auto;
}
.results li { display: flex; flex-direction: column; padding: 7px 10px; border-radius: 6px; cursor: pointer; }
.results li.active, .results li:hover { background: var(--card-2); }
.results li.empty { color: var(--text-dim); cursor: default; }
.r-name { font-weight: 600; }
.r-desc { color: var(--text-dim); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.stamp { color: var(--text-faint); font-size: 12px; white-space: nowrap; }
.icon-btn {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
  font-size: 17px;
  line-height: 1;
}
.icon-btn:hover { background: var(--card-2); }
.zoom-controls.two-col { display: grid; grid-auto-flow: column; grid-template-rows: repeat(3, auto); }
.icon-btn:disabled { opacity: 0.4; cursor: default; }
.icon-btn:disabled:hover { background: var(--card); }
.icon-btn svg { display: block; }
:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }

/* layout */
.layout { flex: 1; min-height: 0; display: flex; gap: 12px; padding: 12px; }
.stage {
  position: relative;
  flex: 1;
  min-width: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.graph { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; user-select: none; }
.graph:active { cursor: grabbing; }
.zoom-controls { position: absolute; left: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 6px; }
.notice {
  position: absolute;
  z-index: 5;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--red);
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow);
}
.tooltip {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 10;
  max-width: 280px;
  padding: 8px 12px;
  background: var(--card-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  pointer-events: none;
}
.tt-title { font-weight: 700; }
.tt-std { margin-left: 4px; font-weight: 500; font-size: 12px; color: var(--text-dim); }
.tt-desc { margin-top: 2px; font-size: 12.5px; color: var(--text-dim); }

/* graph */
.edge { fill: none; stroke: var(--edge); stroke-width: 1; vector-effect: non-scaling-stroke; }
.edge.dim { stroke: var(--edge-dim); }
.edge.off { display: none; }
.no-bg .edge:not(.hi-dep):not(.hi-tdep):not(.hi-rdep):not(.hi-trdep):not(.hi-x):not(.hi-xr) { display: none; }
.edges-hi .edge { stroke-width: 1.6; }
.hi-dep { stroke: var(--dep); }
.hi-tdep { stroke: var(--tdep); }
.hi-rdep { stroke: var(--rdep); }
.hi-trdep { stroke: var(--trdep); }
.x-test { stroke-dasharray: 6 4; }
.x-example { stroke-dasharray: 1.5 4; stroke-linecap: round; }
.hi-x { stroke: var(--dep); }
.hi-xr { stroke: var(--rdep); }
.faint-x { stroke: var(--edge); }
.edges-bg, .edges-hi, .nodes { pointer-events: none; }
.node { pointer-events: all; cursor: pointer; }
.node .shape { stroke: var(--node-ring); stroke-width: 1.5; fill: var(--std-none); vector-effect: non-scaling-stroke; transition: opacity .15s; }
.node.std-03 .shape { fill: var(--std-03); }
.node.std-11 .shape { fill: var(--std-11); }
.node.std-14 .shape { fill: var(--std-14); }
.node.std-17 .shape { fill: var(--std-17); }
.node.std-20 .shape { fill: var(--std-20); }
.node.std-23 .shape { fill: var(--std-23); }
.node.dim { opacity: .3; }
.node.filtered { opacity: .14; pointer-events: none; }
.node.rel .shape { stroke-width: 3.5; }
.node.rel-self .shape { stroke: var(--orange); stroke-width: 4.5; }
.node.rel-dep .shape { stroke: var(--dep); }
.node.rel-tdep .shape { stroke: var(--tdep); }
.node.rel-rdep .shape { stroke: var(--rdep); }
.node.rel-trdep .shape { stroke: var(--trdep); }
.node.rel-category .shape { stroke: var(--green); }
.node.rel-testdep .shape { stroke: var(--dep); stroke-dasharray: 4 3; }
.node.rel-testrdep .shape { stroke: var(--rdep); stroke-dasharray: 4 3; }
.node.rel-exampledep .shape { stroke: var(--dep); stroke-dasharray: 1 3; stroke-linecap: round; }
.node.rel-examplerdep .shape { stroke: var(--rdep); stroke-dasharray: 1 3; stroke-linecap: round; }
.node:hover .shape { stroke: var(--text); }
.node.rel-self:hover .shape { stroke: var(--orange); }
.label {
  font: 600 var(--ls, 10.5px) var(--font);
  fill: var(--text);
  dominant-baseline: central;
  paint-order: stroke;
  stroke: var(--label-halo);
  stroke-width: var(--lh, 3px);
  stroke-linejoin: round;
  pointer-events: none;
}
.node.rel-self .label { font-size: calc(var(--ls, 10.5px) * 1.3); font-weight: 800; }
.no-labels .label { display: none; }
.halo { display: none; fill: none; stroke: var(--orange); stroke-width: 2; stroke-opacity: .55; vector-effect: non-scaling-stroke; filter: drop-shadow(0 0 5px var(--orange)); }
.node.rel-self .halo { display: inline; }
.sym-bg { fill: var(--card); stroke: var(--node-ring); stroke-width: .8; }
.sym-line { fill: none; stroke: var(--text); stroke-width: 1.2; stroke-linejoin: round; stroke-linecap: round; }
.sym-fill { fill: var(--text); }
.sym-red { stroke: var(--red); }
.sym-orange { fill: var(--orange); }
.badge { pointer-events: none; }

/* details */
.details {
  flex: none;
  width: min(380px, 38vw);
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.details[hidden] { display: none; }
.det-head { display: flex; align-items: flex-start; gap: 10px; padding: 16px 16px 10px; }
.det-titles { flex: 1; min-width: 0; }
.det-titles h2 { margin: 0; font-size: 22px; line-height: 1.2; letter-spacing: -.01em; }
.det-id { color: var(--text-faint); font-size: 12px; }
.det-body { flex: 1; min-height: 0; overflow: auto; padding: 0 16px 18px; }
.facts, .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.facts { margin: 4px 0 10px; }
.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card-2);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.pill.std { color: #050816; border-color: transparent; background: var(--std-none); }
.pill.std.std-03 { background: var(--std-03); }
.pill.std.std-11 { background: var(--std-11); color: #fff; }
.pill.std.std-14 { background: var(--std-14); }
.pill.std.std-17 { background: var(--std-17); }
.pill.std.std-20 { background: var(--std-20); }
.pill.std.std-23 { background: var(--std-23); }
.pill.flag-proposed { border-color: var(--orange); }
.pill.flag-deprecated { border-color: var(--red); }
.pill.alt { font-family: var(--mono); font-weight: 500; }
.desc { margin: 6px 0; }
.authors { margin: 6px 0; color: var(--text-dim); }
.cats { margin: 8px 0; }
.sec { margin-top: 16px; }
.sec h3 { margin: 0 0 8px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); }
.chip {
  padding: 3px 10px 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card-2);
  font-size: 12.5px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--chip-std, var(--std-none)); }
.chip:hover { border-color: var(--orange); }
.det-foot {
  flex: none;
  padding: 8px 16px;
  background: var(--card-2);
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--link-orange-text);
  height: 56px;
  overflow: hidden;
  pointer-events: none;
}
.det-foot.idle { color: var(--text-faint); }
.muted { color: var(--text-dim); }

/* legend and options (left panel) */
.legend {
  flex: none;
  width: 260px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.legend.collapsed { width: 44px; }
.lg-head { flex: none; display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.legend.collapsed .lg-head { flex-direction: column; border-bottom: 0; padding: 8px 4px; }
.lg-title { margin: 0; flex: 1; font-size: 14px; font-weight: 700; }
.legend.collapsed .lg-title { flex: none; writing-mode: vertical-rl; margin-top: 8px; color: var(--text-dim); }
.legend.collapsed .lg-reset { display: none; }
.lg-toggle { order: -1; width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--border); background: var(--card-2); line-height: 1; }
.lg-toggle:hover { border-color: var(--orange); }
.lg-reset { padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--card-2); font-size: 12px; font-weight: 600; }
.lg-reset:hover:not(:disabled) { border-color: var(--orange); }
.lg-reset:disabled { opacity: .45; cursor: default; }
.lg-panel { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 0 14px; }
.lg-group { border-bottom: 1px solid var(--border); }
.lg-group:last-child { border-bottom: 0; }
.lg-group > summary {
  cursor: pointer;
  list-style: none;
  padding: 10px 14px 6px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-dim);
}
.lg-group > summary::-webkit-details-marker { display: none; }
.lg-group > summary::before { content: "\25BE"; display: inline-block; width: 14px; transition: transform .15s; }
.lg-group:not([open]) > summary::before { transform: rotate(-90deg); }
.lg-body { padding: 0 8px 8px; }
.lg-intro, .lg-hint { margin: 0 6px 6px; font-size: 12.5px; color: var(--text-dim); }
.lg-hint { padding: 6px 10px; border-radius: 6px; background: var(--card-2); color: var(--text); }
.lg-hint[hidden] { display: none; }
.lg-row { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 6px; cursor: pointer; }
.lg-row:hover { background: var(--card-2); }
.lg-sample { flex: none; width: 46px; height: 28px; overflow: visible; }
.lg-sample .node { pointer-events: none; }
.lg-sample .edge { stroke-width: 1.8; }
.lg-sample .lg-bgedge { stroke: var(--text-faint); stroke-width: 1; opacity: .55; }
.lg-sample .lg-path { fill: var(--link-orange-text); font: 600 10px var(--font); }
.lg-sample .lg-name { --ls: 11px; --lh: 3px; }
.lg-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lg-top { display: block; }
.lg-top .lg-count { margin-left: 5px; white-space: nowrap; }
.lg-sub { margin-left: 12px; }
.lg-sub .lg-label { font-weight: 500; font-size: 12.5px; }
.lg-toggle { position: relative; }
.legend.collapsed.modified .lg-toggle::after { content: ""; position: absolute; top: -3px; right: -3px; width: 9px; height: 9px; border-radius: 50%; background: var(--orange); border: 2px solid var(--card); }
.lg-label { font-weight: 600; font-size: 13px; line-height: 1.25; }
.lg-count { color: var(--text-dim); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.lg-help { color: var(--text-dim); font-size: 12px; line-height: 1.3; }
.lg-noswitch { flex: none; width: 34px; }
.lg-switch {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  position: relative;
  width: 34px;
  height: 20px;
  margin: 0;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card-2);
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.lg-switch::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-faint);
  transition: transform .15s, background .15s;
}
.lg-switch:checked { background: var(--orange); border-color: var(--orange); }
.lg-switch:checked::before { transform: translateX(14px); background: #050816; }
.lg-switch:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }
.lg-layout { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 5px 6px 8px; }
.lg-seg { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; background: var(--card-2); }
.lg-seg-btn { padding: 3px 11px; font-size: 12px; font-weight: 600; color: var(--text-dim); background: transparent; border: 0; cursor: pointer; }
.lg-seg-btn + .lg-seg-btn { border-left: 1px solid var(--border); }
.lg-seg-btn:hover { color: var(--text); }
.lg-seg-btn.on { background: var(--orange); color: #050816; }
.lg-seg-btn:focus-visible { outline: 2px solid var(--orange); outline-offset: -2px; }
.lg-chips { display: flex; flex-wrap: wrap; gap: 5px; padding: 2px 6px 6px 60px; }
.lg-catchips { padding: 0 6px 4px; }
.lg-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-faint);
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}
.lg-catchips .lg-chip { padding-left: 9px; }
.lg-chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.lg-chip:has(input:checked) { background: var(--card-2); color: var(--text); border-color: color-mix(in srgb, var(--orange) 55%, var(--border)); }
.lg-chip:has(input:focus-visible) { outline: 2px solid var(--orange); outline-offset: 2px; }
.lg-chip:not(:has(input:checked)) .lg-dot { opacity: .35; }
.lg-dot { flex: none; overflow: visible; }
.lg-dot .node { pointer-events: none; }
.lg-chip-n { color: var(--text-faint); font-size: 11px; font-variant-numeric: tabular-nums; }
.lg-bar { display: flex; gap: 6px; padding: 0 6px 8px; }
.lg-mini { padding: 2px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--card-2); font-size: 12px; font-weight: 600; }
.lg-mini:hover { border-color: var(--orange); }

@media (min-width: 768px) and (max-width: 1279px) {
  .layout { position: relative; }
  .details { position: absolute; z-index: 8; top: 12px; right: 12px; bottom: 12px; width: min(340px, 70vw); box-shadow: var(--shadow); }
}

/* details: hide to a slim rail (tablet and desktop only) */
.det-rail { display: none; }
@media (min-width: 768px) {
  .details.folded { width: 44px; }
  .details.folded .det-head, .details.folded .det-body, .details.folded .det-foot { display: none; }
  .details.folded .det-rail {
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    flex: 1; padding: 12px 4px; border: 0; background: transparent; color: var(--text); cursor: pointer;
  }
  .det-rail:hover { background: var(--card-2); }
  .det-rail:focus-visible { outline-offset: -2px; }
  .det-rail-chev { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--border); background: var(--card-2); font-size: 18px; line-height: 1; }
  .det-rail:hover .det-rail-chev { border-color: var(--orange); }
  .det-rail-name { writing-mode: vertical-rl; font-size: 14px; font-weight: 700; max-height: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
@media (max-width: 767px) { .det-hide { display: none; } }

/* phone controls are hidden on wider screens */
.mbar, .focus, .foot, .scrim, .lg-close { display: none; }

@media (max-width: 767px) {
  html, body { overscroll-behavior: none; }
  body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
  .subtitle, .stamp { display: none; }
  .topbar { flex-wrap: wrap; gap: 8px 10px; padding: calc(8px + env(safe-area-inset-top)) 12px 8px; border-bottom: 0; }
  .brand { flex: 1; }
  .brand h1 { font-size: 17px; white-space: normal; }
  .topbar-right { order: 2; }
  .search { order: 3; flex: 1 1 100%; max-width: none; margin-left: 0; }
  .search input { min-height: 46px; padding: 10px 18px; font-size: 16px; }
  .icon-btn { width: 44px; height: 44px; }
  .results { z-index: 50; max-height: 50vh; }
  .results li { min-height: 48px; justify-content: center; }

  .mbar { display: flex; gap: 8px; padding: 0 12px 8px; flex: none; }
  .mbtn {
    position: relative;
    flex: 1;
    min-height: 44px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--card);
    font-weight: 600;
  }
  .mbtn:active { background: var(--card-2); }
  .mbtn.modified::after { content: ""; position: absolute; top: 6px; right: 8px; width: 9px; height: 9px; border-radius: 50%; background: var(--orange); }

  .layout { position: relative; flex-direction: column; gap: 0; padding: 0 8px 8px; }
  .foot { display: block; flex: none; padding: 4px 12px calc(6px + env(safe-area-inset-bottom)); color: var(--text-faint); font-size: 12px; text-align: center; }
  .m-graph .foot, .sheet-on .foot { display: none; }
  .graph-only { opacity: .6; }
  body:not(.m-graph) .graph-only .lg-label::after { content: " (full graph only)"; font-weight: 500; color: var(--text-faint); }
  .m-graph .layout { padding-bottom: calc(8px + env(safe-area-inset-bottom)); }

  .stage { display: none; }
  .m-graph .stage { display: block; }
  .focus { display: block; flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; padding-bottom: var(--sheet-h, 0px); }
  .m-graph .focus { display: none; }
  .zoom-controls { bottom: calc(12px + var(--sheet-h, 0px)); }
  .notice { max-width: calc(100% - 24px); text-align: center; }

  /* focus view */
  .focus.has-sel { overflow: hidden; }
  .focus-view { display: flex; flex-direction: column; gap: 8px; height: 100%; }
  .f-center {
    flex: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
    padding: 10px 14px;
    text-align: left;
    background: var(--card);
    border: 2px solid var(--orange);
    border-radius: var(--radius);
    box-shadow: 0 0 14px rgba(255, 160, 0, .25);
  }
  .f-ctop { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  .f-cname { font-size: 20px; font-weight: 800; letter-spacing: -.01em; }
  .f-cdesc { color: var(--text-dim); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .f-chint { color: var(--link-orange-text); font-size: 12px; font-weight: 600; }
  .f-cols { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .f-col { min-width: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 6px 10px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }
  .f-head {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0 -6px;
    padding: 10px 10px 8px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-dim);
  }
  .f-col-deps .f-head { color: var(--link-orange-text); }
  .f-col-dependants .f-head { color: var(--rdep); }
  .f-n { font-variant-numeric: tabular-nums; color: var(--text-dim); }
  .f-sub { margin: 12px 2px 0; font-size: 11.5px; font-weight: 700; color: var(--text-dim); }
  .f-empty { margin: 12px 4px; color: var(--text-dim); font-size: 13px; }
  .f-row {
    display: flex;
    align-items: center;
    gap: 7px;
    width: 100%;
    min-height: 44px;
    margin-top: 6px;
    padding: 6px 8px;
    text-align: left;
    background: var(--card-2);
    border: 1px solid var(--border);
    border-left: 4px solid var(--border);
    border-radius: 6px;
  }
  .f-row:active, .f-chip:active, .f-center:active { background: var(--card); }
  .f-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--chip-std, var(--std-none)); }
  .f-name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .f-std { flex: none; font-size: 11px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
  .f-dep { border-left-color: var(--dep); }
  .f-tdep { border-left-color: var(--tdep); }
  .f-rdep { border-left-color: var(--rdep); }
  .f-trdep { border-left-color: var(--trdep); }
  .f-testdep { border-left-color: var(--dep); border-left-style: dashed; }
  .f-testrdep { border-left-color: var(--rdep); border-left-style: dashed; }
  .f-exampledep { border-left-color: var(--dep); border-left-style: dotted; }
  .f-examplerdep { border-left-color: var(--rdep); border-left-style: dotted; }
  .f-more { width: 100%; min-height: 44px; margin-top: 8px; border-radius: 6px; border: 1px dashed var(--text-faint); background: transparent; color: var(--text-dim); font-size: 13px; font-weight: 600; }

  /* home */
  .f-home { padding: 12px 6px 16px; }
  .f-home h2 { margin: 0 0 6px; font-size: 22px; letter-spacing: -.01em; }
  .f-lead, .f-tip { margin: 0 0 12px; color: var(--text-dim); }
  .f-tip { margin-top: 16px; font-size: 13px; }
  .f-pop { display: flex; flex-wrap: wrap; gap: 8px; }
  .f-chip { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px 0 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--card); font-weight: 600; }
  .f-notice { margin: 4px 6px 0; padding: 10px 14px; border-radius: var(--radius); border: 1px solid var(--red); background: var(--card); }

  /* bottom sheet */
  .details {
    position: fixed;
    z-index: 30;
    left: 8px;
    right: 8px;
    bottom: calc(8px + env(safe-area-inset-bottom));
    width: auto;
    height: 72vh;
    max-height: none;
    border-radius: 14px;
    box-shadow: var(--shadow);
  }
  .details[hidden] { display: none; }
  .details::before { content: ""; flex: none; align-self: center; width: 40px; height: 4px; margin-top: 8px; border-radius: 2px; background: var(--text-faint); opacity: .6; }
  .details.peek { height: auto; }
  .details.peek .det-body, .details.peek .det-foot { display: none; }
  .details.peek .det-id::after { content: " \00B7  tap for details"; font-family: var(--font); color: var(--link-orange-text); }
  .det-head { padding: 8px 8px 8px 16px; min-height: 44px; touch-action: none; cursor: grab; }
  .det-foot { display: none; }
  .details .chip { min-height: 44px; padding: 0 14px 0 12px; font-size: 14px; }
  .details .chips { gap: 8px; }
  .det-body { padding-bottom: calc(18px + env(safe-area-inset-bottom)); }

  /* legend drawer */
  .legend {
    display: flex;
    position: fixed;
    z-index: 40;
    left: 0;
    right: 0;
    bottom: 0;
    top: 10vh;
    width: auto;
    border-radius: 14px 14px 0 0;
    border-bottom: 0;
    box-shadow: var(--shadow);
    padding-bottom: env(safe-area-inset-bottom);
    transform: translateY(105%);
    visibility: hidden;
    transition: transform .22s ease, visibility 0s .22s;
  }
  .drawer-open .legend { transform: none; visibility: visible; transition: transform .22s ease; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(5, 8, 22, .55); opacity: 0; pointer-events: none; transition: opacity .2s; }
  .drawer-open .scrim { opacity: 1; pointer-events: auto; }
  .lg-toggle { display: none; }
  .lg-close { display: inline-grid; flex: none; }
  .legend.collapsed { width: auto; }
  .legend.collapsed .lg-head { flex-direction: row; padding: 8px 8px 8px 14px; border-bottom: 1px solid var(--border); }
  .legend.collapsed .lg-title { flex: 1; writing-mode: horizontal-tb; margin: 0; color: var(--text); }
  .legend.collapsed .lg-reset { display: block; }
  .legend.collapsed .lg-panel[hidden] { display: block; }
  .lg-reset { min-height: 44px; padding: 0 16px; }
  .lg-group > summary { display: flex; align-items: center; min-height: 44px; padding-top: 0; padding-bottom: 0; }
  .lg-row { min-height: 48px; }
  .lg-seg-btn { min-height: 40px; padding: 0 16px; font-size: 13px; }
  .lg-chip { min-height: 44px; padding: 0 14px 0 12px; font-size: 13px; }
  .lg-catchips .lg-chip { padding-left: 14px; }
  .lg-mini { min-height: 44px; padding: 0 16px; }
  .lg-chips { gap: 8px; padding-left: 12px; }
  .lg-catchips, .lg-bar { gap: 8px; }
}

/* short phone screens (landscape): let the whole focus view scroll instead of squeezing the lists */
@media (max-width: 767px) and (max-height: 560px) {
  .focus.has-sel { overflow: auto; }
  .focus-view { height: auto; }
  .f-cols { flex: none; min-height: 300px; }
  .f-col { max-height: none; overflow: visible; }
}

/* theme menu */
.theme-wrap { position: relative; }
.theme-menu {
  position: absolute;
  z-index: 30;
  top: calc(100% + 6px);
  right: 0;
  min-width: 150px;
  padding: 5px;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.theme-menu[hidden] { display: none; }
.theme-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  text-align: left;
}
.theme-item:hover, .theme-item:focus-visible { background: var(--card-2); }
.theme-item:focus-visible { outline: 2px solid var(--orange); outline-offset: -2px; }
.theme-glyph { width: 18px; text-align: center; }
.theme-item[aria-checked="true"] { font-weight: 700; }
.theme-item[aria-checked="true"]::after { content: "\2713"; margin-left: auto; padding-left: 12px; color: var(--orange); }

/* node ornament parts: invisible unless a fun theme turns them on */
.orn { display: none; }
.orn:not(.star) { pointer-events: none; }
.decor, .decor * { pointer-events: none; }
.fun-bg { display: none; }
.lg-seg-btn:disabled { cursor: default; }
.lg-layout.locked .lg-seg-btn:not(.on) { opacity: .45; }

/* ---------------- Christmas ---------------- */
html.fun-christmas {
  --page: #060b24;
  --card: #0a1230;
  --card-2: #131d46;
  --border: rgba(196, 212, 255, .16);
  --text: #eef2ff;
  --text-dim: #bcc6e6;
  --edge: rgba(214, 226, 255, .3);
  --edge-dim: rgba(214, 226, 255, .06);
  --node-ring: rgba(255, 255, 255, .6);
  --label-halo: #0a1230;
  --shadow: 0 8px 28px rgba(0, 0, 8, .6);
  --std-03: #d62839;
  --std-11: #2f6fe0;
  --std-14: #1f9d55;
  --std-17: #e9b949;
  --std-20: #9b59b6;
  --std-23: #dfe6f2;
  --std-none: #f2f5fb;
}
.fun-christmas .pill.std.std-03, .fun-christmas .pill.std.std-20 { color: #fff; }
.fun-christmas body { background: radial-gradient(120% 50% at 50% 0%, rgba(60, 80, 180, .3), transparent 70%), var(--page); }
.fun-christmas .stage {
  background:
    radial-gradient(120% 60% at 50% 0%, rgba(70, 90, 190, .35), transparent 70%),
    radial-gradient(90% 40% at 50% 100%, rgba(150, 40, 60, .22), transparent 70%),
    linear-gradient(180deg, #0b1440 0%, #070d2c 55%, #0a1230 100%);
}
.fun-christmas .fun-bg { display: block; position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.fun-bg i { position: absolute; display: block; border-radius: 50%; }
.fun-bg .bokeh {
  width: min(var(--s), 26vw);
  height: min(var(--s), 26vw);
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(var(--c), calc(var(--o) * var(--bk, 1) * 1.5)) 0 52%, rgba(var(--c), calc(var(--o) * var(--bk, 1))) 62%, rgba(var(--c), 0) 71%);
  animation: bokeh-twinkle var(--t) ease-in-out var(--dl) infinite alternate;
}
.fun-bg .flake {
  top: -12px;
  background: #fff;
  box-shadow: 0 0 4px rgba(255, 255, 255, .8);
  animation: snow-fall var(--d) linear var(--dl) infinite;
}
@media (max-width: 767px) { .fun-bg { --bk: .55; } }
@keyframes bokeh-twinkle { from { opacity: .45; } to { opacity: 1; } }
@keyframes snow-fall { to { transform: translate3d(var(--dx), 110vh, 0); } }
@media (prefers-reduced-motion: reduce) {
  .fun-bg .bokeh { animation: none; }
  .fun-bg .flake { animation: none; top: var(--y); }
}

.fun-christmas .tree-sil { fill: rgba(24, 120, 80, .12); stroke: rgba(70, 200, 130, .14); stroke-width: 1; }
.fun-christmas .garland { fill: none; stroke: rgba(222, 232, 255, .55); stroke-width: 1.4; vector-effect: non-scaling-stroke; stroke-linecap: round; }
.fun-christmas .bulb { opacity: .95; }
.fun-christmas .string { stroke: rgba(222, 232, 255, .6); stroke-width: 1; vector-effect: non-scaling-stroke; }
.fun-christmas .ray { stroke: #ffd86b; stroke-width: 1.6; stroke-linecap: round; opacity: .8; vector-effect: non-scaling-stroke; }
.fun-christmas .mat { fill: #a3202f; stroke: #f2dfb5; }

.fun-christmas .edges-bg .edge { stroke: rgba(214, 226, 255, .42); stroke-width: 1; stroke-dasharray: 1 2.6; stroke-linecap: round; }
.fun-christmas .edges-bg .edge.dim { stroke: var(--edge-dim); }
.edges-glow { pointer-events: none; }
.edges-glow .edge { stroke-width: 7; stroke-opacity: .16; stroke-dasharray: none; stroke-linecap: round; }

.fun-christmas .node .shape { stroke-width: 1.2; }
.fun-christmas .node.rel .shape { stroke-width: 3.5; }
.fun-christmas .node.rel-self .shape { stroke-width: 4.5; }
.fun-christmas .orn-gloss { display: inline; fill: url(#orn-gloss); }
.fun-christmas .orn-cap { display: inline; fill: #e9b949; stroke: #7a5a14; stroke-width: .5; }
.fun-christmas .node.alt .diamond, .fun-christmas .node.alt .orn-gloss, .fun-christmas .node.alt .orn-cap { display: none !important; }
.fun-christmas .node.alt .star { display: inline; fill: url(#orn-gold); stroke-linejoin: round; }
.fun-christmas .node.alt .star-core { display: inline; fill: var(--std-none); stroke: rgba(0, 0, 0, .4); stroke-width: .6; }
.fun-christmas .node.std-03 .star-core { fill: var(--std-03); }
.fun-christmas .node.std-11 .star-core { fill: var(--std-11); }
.fun-christmas .node.std-14 .star-core { fill: var(--std-14); }
.fun-christmas .node.std-17 .star-core { fill: var(--std-17); }
.fun-christmas .node.std-20 .star-core { fill: var(--std-20); }
.fun-christmas .node.std-23 .star-core { fill: var(--std-23); }
.fun-christmas .node.rel .star { stroke-width: 3; }
.fun-christmas .node.rel-self .star { stroke-width: 4; }
.fun-christmas .node.rel-dep .star { stroke: var(--dep); }
.fun-christmas .node.rel-tdep .star { stroke: var(--tdep); }
.fun-christmas .node.rel-rdep .star { stroke: var(--rdep); }
.fun-christmas .node.rel-trdep .star { stroke: var(--trdep); }
.fun-christmas .node.rel-self .star { stroke: var(--orange); }

.lg-fun {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 10px 4px;
  padding: 7px 10px;
  border-radius: var(--radius);
  font-size: 12.5px;
}
.lg-fun[hidden] { display: none; }
.lg-fun-title { font-weight: 700; }
.lg-fun-back { margin-left: auto; padding: 0; border: 0; background: none; text-decoration: underline; font-size: 12.5px; }
.fun-christmas .lg-fun { border: 1px solid rgba(255, 216, 107, .35); background: linear-gradient(90deg, rgba(214, 40, 57, .16), rgba(31, 157, 85, .16)); }
.fun-christmas .lg-fun-star, .fun-christmas .lg-fun-back { color: #ffd86b; }
