/* A cream canvas, small geometric glyphs, white cards, dashed dividers, one orange accent.
   Series colours (blue, orange, aqua) are the validated dataviz slots and appear only in the Sankey. */
:root {
  color-scheme: light;
  --page: #f5f5f0; --surface: #ffffff; --ink: #121211; --ink2: #55554f; --muted: #6b6b65;
  --line: rgba(18,18,17,.14); --yellow: #f6d33c; --orange: #f2552c;
  --data: #2a78d6; --rules: #eb6834; --life: #1baf7a; --neutral: #92928b;
  --shadow: 0 1px 2px rgba(18,18,17,.05), 0 10px 30px rgba(18,18,17,.06);
  --font: "Helvetica Neue", "Neue Haas Grotesk Text Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #121211; --surface: #1c1c1a; --ink: #f1f0ec; --ink2: #c3c2b8; --muted: #8a8a83;
    --line: rgba(241,240,236,.16); --yellow: #d9b91f; --orange: #ff6a3d;
    --data: #3987e5; --rules: #d95926; --life: #199e70;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px rgba(0,0,0,.35);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #121211; --surface: #1c1c1a; --ink: #f1f0ec; --ink2: #c3c2b8; --muted: #8a8a83;
  --line: rgba(241,240,236,.16); --yellow: #d9b91f; --orange: #ff6a3d;
  --data: #3987e5; --rules: #d95926; --life: #199e70;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--ink); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 4px; }

/* hero: graph left, cards right */
.hero { position: relative; min-height: 100vh; max-width: 1440px; margin: 0 auto; padding: 0 32px; display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 40px; align-items: start; }
.bar { position: absolute; top: 28px; left: 32px; right: 32px; display: flex; justify-content: space-between; align-items: baseline; z-index: 3; pointer-events: none; }
.bar > * { pointer-events: auto; }
.brand b { font-weight: 500; font-size: 15px; letter-spacing: .01em; }
.brand span { margin-left: 14px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.tools { display: flex; gap: 8px; }
.pill { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; padding: 6px 12px; border-radius: 999px; background: var(--surface); box-shadow: var(--shadow); }
.pill:hover { background: var(--ink); color: var(--page); }
.keycard { position: absolute; top: 44px; right: 0; width: 340px; display: grid; grid-template-columns: 1fr 1fr; gap: 20px; padding: 18px 20px; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); font-size: 12.5px; }
.key-h { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.key-col .key-h:not(:first-child) { margin-top: 14px; }
.key-row { display: flex; align-items: center; gap: 10px; padding: 3px 0; color: var(--ink2); }
.key-row svg { flex: none; overflow: visible; }

.graph-wrap { position: sticky; top: 0; height: 100vh; min-height: 640px; display: flex; align-items: center; justify-content: center; padding-top: 36px; }
#graph { width: 100%; max-width: 920px; height: auto; max-height: calc(100vh - 80px); overflow: visible; }
#graph text { font-family: var(--font); fill: var(--ink); }

/* regions */
.region-fill { fill: color-mix(in srgb, var(--ink) 3.5%, transparent); }
.region-label { font-size: 11px; letter-spacing: .14em; fill: var(--muted) !important; }

/* glyphs */
.node { cursor: pointer; }
.node .hit { fill: transparent; }
.node:focus { outline: none; }
.node:focus-visible .shape { stroke-width: 2.4; }
.shape { fill: var(--page); stroke: var(--ink); stroke-width: 1.3; stroke-linejoin: round; }
.starshape { fill: var(--orange); }
.st-candidate .shape { stroke-dasharray: 3 2.2; }
.st-unverified .shape { stroke-dasharray: 1 2.4; stroke-linecap: round; }
.dotmark { fill: var(--ink); }
.hexnum { font-size: 11px; font-weight: 500; fill: var(--ink) !important; }
.xmark { display: none; } .xmark path { stroke: var(--ink); stroke-width: 1.4; fill: none; }
.sel .shape:not(.starshape) { fill: var(--yellow); }
.sel .xmark { display: block; }
.lbl { font-size: 13px; letter-spacing: .005em; paint-order: stroke; stroke: var(--page); stroke-width: 5px; stroke-linejoin: round; }
.sub { font-size: 10.5px; letter-spacing: .13em; fill: var(--muted) !important; paint-order: stroke; stroke: var(--page); stroke-width: 4px; display: none; }
.sel .sub, .node:hover .sub { display: block; }
.sel .lbl { font-weight: 600; }
.node:hover .shape:not(.starshape) { fill: var(--yellow); }
.focus .t-flow .lbl { fill: var(--ink); }
.focus .t-group .lbl { fill: var(--ink2); }
.focus .t-rel .lbl { fill: var(--muted); }
.focus .t-rel .shape { stroke: var(--muted); }
.faded { opacity: .22 !important; }

/* lines */
.edge { fill: none; stroke: var(--ink); stroke-width: 1.1; stroke-linecap: round; }
.edge.flow { opacity: .75; }
.edge.flow.alt { stroke-dasharray: 4 4; }
.edge.group { stroke-dasharray: 4 4; opacity: .55; }
.edge.rel { stroke: var(--muted); stroke-dasharray: 0.5 5; stroke-width: 1.6; }

/* panel cards */
#panel { position: sticky; top: 88px; max-height: calc(100vh - 112px); overflow-y: auto; padding: 4px 4px 40px; margin-right: -4px; display: flex; flex-direction: column; gap: 10px; scrollbar-width: thin; }
.card { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: 12px; padding: 14px 20px; }
.card-ic { display: inline-flex; width: 14px; justify-content: center; }
.card-label { flex: 1; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; }
.tool { width: 24px; height: 24px; line-height: 22px; text-align: center; font-size: 15px; border-radius: 6px; }
.tool:hover { background: var(--page); }
.orange-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--orange); }
.gi { overflow: visible; }
.gi .shape { fill: var(--ink); stroke: var(--ink); }
.card-body { padding: 4px 24px 22px; }
.card-body p { margin: 0 0 12px; color: var(--ink); font-size: 14px; line-height: 1.55; }
.card-body p.summary, .card-body p.lede { text-indent: 1.6em; }
.card-body .lede { font-size: 14.5px; }
.linklike { font-size: 13px; text-decoration: underline; text-underline-offset: 3px; margin-bottom: 14px; }
.ntitle { margin: 6px 0 2px; font-size: 17px; font-weight: 500; letter-spacing: -.005em; line-height: 1.25; }
.nsubt { font-size: 10.5px; letter-spacing: .13em; text-transform: uppercase; color: var(--muted); }
.nstat { display: inline-block; margin: 2px 0 12px; font-size: 10.5px; letter-spacing: .13em; text-transform: uppercase; color: var(--ink2); }
.nstat::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 8px; border: 1.2px solid var(--ink); border-radius: 50%; vertical-align: -1px; background: var(--ink); }
.nstat.st-candidate::before { background: transparent; border-style: dashed; }
.nstat.st-unverified::before { background: transparent; border-style: dotted; }

/* accordions */
.accs { margin-top: 10px; }
.acc-head, .acc-link { width: 100%; display: flex; align-items: center; gap: 12px; padding: 13px 0; text-align: left; border-top: 1px dashed var(--ink); text-decoration: none; }
.acc-ic { display: inline-flex; width: 14px; justify-content: center; color: var(--ink); }
.acc-label { flex: 1; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; }
.acc-sign::before { content: "+"; font-size: 15px; line-height: 1; }
.acc.open .acc-sign::before { content: "−"; }
.acc-sign.arrow::before { content: ""; } .acc-sign.arrow { font-size: 14px; }
.acc-body { display: none; padding: 0 0 14px 26px; }
.acc.open .acc-body { display: block; }
.acc-body h4 { margin: 12px 0 4px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink); }
.acc-body h4:first-child { margin-top: 2px; }
.acc-body p, .acc-body li { font-size: 13.5px; line-height: 1.55; color: var(--ink2); margin: 0 0 8px; }
.acc-body ul { padding-left: 16px; margin: 0 0 6px; }
.acc-body ul.src { list-style: none; padding: 0; }
.acc-body ul.src li { font: 11.5px/1.5 var(--mono); color: var(--muted); }
.nlist { list-style: none; padding: 0; margin: 0; }
.nitem { display: block; width: 100%; text-align: left; padding: 7px 0; }
.nitem .nt { display: block; font-size: 14px; color: var(--ink); }
.nitem .ns { display: block; font-size: 10.5px; letter-spacing: .13em; text-transform: uppercase; color: var(--muted); margin-top: 1px; }
.nitem:hover .nt { text-decoration: underline; text-underline-offset: 3px; }
.card.idx.collapsed .card-head { padding: 12px 20px; }

/* flows */
.flows { background: var(--page); padding: 24px 32px 0; border-top: 1px dashed var(--line); }
.flows-in { max-width: 1376px; margin: 0 auto; padding-top: 64px; }
.eyebrow { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.flows h2 { margin: 6px 0 0; font-size: 30px; font-weight: 500; letter-spacing: -.015em; }
.intro { max-width: 62ch; margin: 10px 0 28px; color: var(--ink2); font-size: 14.5px; }
.sk-card { padding: 8px 28px 24px; }
.tabs { display: flex; flex-wrap: wrap; gap: 0 26px; border-bottom: 1px dashed var(--ink); }
.tabs button { font-size: 11px; letter-spacing: .13em; text-transform: uppercase; color: var(--muted); padding: 16px 0 12px; margin-bottom: -1px; border-bottom: 2px solid transparent; }
.tabs button:hover { color: var(--ink); }
.tabs button.active { color: var(--ink); border-bottom-color: var(--ink); }
.sk-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 6px 24px; margin: 22px 0 8px; }
.sk-head h3 { margin: 0; font-size: 17px; font-weight: 500; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink2); }
.legend .sw { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 7px; vertical-align: 0; }
#sankey { width: 100%; min-width: 760px; }
.sk-card { overflow-x: auto; }
#sankey svg { display: block; overflow: visible; }
#sankey text { font: 12.5px var(--font); fill: var(--ink); paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
#sankey .link { fill: none; transition: stroke-opacity .15s; }
.note { margin: 14px 0 0; max-width: 78ch; font-size: 13px; line-height: 1.6; color: var(--ink2); }
footer { max-width: 1376px; margin: 56px auto 0; padding: 22px 0 48px; border-top: 1px dashed var(--line); font-size: 12px; color: var(--muted); }

@media (max-width: 1100px) {
  .hero { grid-template-columns: 1fr; gap: 0; padding: 0 20px; }
  .bar { left: 20px; right: 20px; }
  .graph-wrap { position: relative; height: auto; min-height: 0; padding: 88px 0 12px; }
  #graph { max-height: none; min-width: 720px; }
  .graph-wrap { overflow-x: auto; justify-content: flex-start; }
  #panel { position: static; max-height: none; margin: 0 0 40px; }
  .flows { padding: 16px 20px 0; }
  .sk-card { padding: 4px 16px 20px; }
}
@media (max-width: 560px) { .brand span { display: none; } .keycard { width: 300px; grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; } }

/* architecture layer */
.pill[aria-pressed="true"] { background: var(--ink); color: var(--page); }
.archbadge { display: none; pointer-events: none; }
.arch-on .archbadge { display: block; }
.ab-N { fill: var(--orange); } .ab-S { fill: var(--ink); } .ab-B { fill: var(--yellow); }
.ab { stroke: var(--page); stroke-width: 1.5; }
.abt { font-size: 8.5px; font-weight: 700; }
.abt-N { fill: #fff !important; } .abt-S { fill: var(--page) !important; } .abt-B { fill: #121211 !important; }
.archbadge-key .ab { stroke: none; }
.narch { font-size: 12.5px; line-height: 1.5; color: var(--ink2); margin: 2px 0 12px; }
.narch b { font-size: 10.5px; letter-spacing: .13em; text-transform: uppercase; color: var(--ink); font-weight: 600; }
.acc-body pre { margin: 6px 0 8px; padding: 12px 14px; background: color-mix(in srgb, var(--ink) 5%, transparent); border-radius: 8px; overflow-x: auto; }
.acc-body pre code { font: 11.5px/1.55 var(--mono); color: var(--ink); white-space: pre; }
.acc-body .cap { font-size: 12px; color: var(--muted); }
.acc-body img.fig { display: block; max-width: 100%; border-radius: 8px; margin: 6px 0; }
.acc-body .figph { padding: 22px; border: 1px dashed var(--line); border-radius: 8px; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); text-align: center; }

.narch i { font-style: normal; font-size: 10.5px; letter-spacing: .13em; text-transform: uppercase; color: var(--muted); }

/* the intersection symbol and the formula line */
.shape.isect { stroke-width: 2.4; }
.card-body p.formula { font-size: 28px; font-weight: 500; letter-spacing: .01em; text-indent: 0; margin: 2px 0 4px; }
.card-body p.formula-cap { font-size: 12.5px; color: var(--ink2); text-indent: 0; margin-bottom: 14px; }
.isect-bg { fill: var(--yellow); opacity: 0; }
.sel .isect-bg, .node:hover .isect-bg { opacity: 1; }
.shape.isect, .sel .shape.isect, .node:hover .shape.isect { fill: none; }
.card-body p.formula .cap { font-family: "Cambria Math", "STIX Two Math", "Latin Modern Math", "Segoe UI Symbol", serif; font-size: 1.28em; line-height: 1; vertical-align: -.04em; }
a.nitem { text-decoration: none; color: inherit; }

/* intersection-versus-balance explorer */
.bal { display: flex; flex-direction: column; gap: 10px; }
.balplane { width: 100%; max-width: 250px; touch-action: none; }
.bal-frame { fill: none; stroke: var(--muted); stroke-width: 1; }
.bal-adm { fill: var(--yellow); fill-opacity: .5; stroke: var(--ink); stroke-width: 1; stroke-dasharray: 3 3; }
.bal-dot { fill: var(--ink); stroke: var(--surface); stroke-width: 2; cursor: grab; }
.bal-ax { font-size: 9.5px; fill: var(--muted) !important; }
.bal-slider { display: grid; grid-template-columns: 9.5em 1fr 3em; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink2); }
.bal-slider input { width: 100%; accent-color: var(--ink); }
.bal-slider output { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }
.bal-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.bal-row { display: grid; grid-template-columns: 1fr auto; gap: 3px 8px; font-size: 12.5px; }
.bal-l { color: var(--ink2); } .bal-v { text-align: right; font-weight: 600; color: var(--ink); }
.bal-bar { grid-column: 1 / -1; height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; }
.bal-fill { display: block; height: 100%; background: var(--ink); border-radius: 3px; transition: width .15s; }
.bal-bar.ok .bal-fill { background: var(--life); } .bal-bar.no .bal-fill { background: var(--rules); }
.bal-note { grid-column: 1 / -1; font-size: 11.5px; color: var(--muted); }
.bal-cap { font-size: 11.5px; color: var(--muted); margin: 2px 0 0; }
.bal-presets .rel { font: 12px/1.4 var(--font); border: 1px solid var(--line); border-radius: 999px; padding: 3px 11px; color: var(--ink); background: transparent; cursor: pointer; }
.bal-presets .rel:hover { border-color: var(--ink2); }
