/* Tokens follow pflow.xyz/compose: same fonts, same ink and paper, same link and schema
   colors. Dark values are this page's, because compose has no dark theme. */
:root {
  color-scheme: light;
  --font-sans: ui-sans-serif, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ink: #2b2f36; --muted: #5f6670; --paper: #fafafa; --panel: #ffffff; --bg: #eef0f3; --line: #dde1e6;
  --accent: #2f6fb3; --bad: #c0392b; --focus: #2f6fb3;
  --edge: #8a93a0; --edge-sub: #4a5563; --edge-dr: #7b4cc2; --edge-port: #2f6fb3; --edge-idiom: #178f7f; --edge-links: #227744; --edge-concept: #a8457f; --edge-comp: #c47a12; --edge-know: #6b7f99;
  --k-class: #e8f0fa; --k-prop: #f1ebfa; --k-pattern: #fbf0e0; --k-concept: #e6f4ef; --k-other: #f1f2f4; --k-idiom: #e9f3ec; --k-layer: #eceff3;
  --tr-port: #3c4656; --on-color: #ffffff; --halo: #fafafa;
  --lk-token: #aa3333; --lk-data: #3355aa; --lk-event: #227744; --lk-guard: #886600;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ink: #e6e8eb; --muted: #a4abb5; --paper: #15181c; --panel: #1d2126; --bg: #101215; --line: #333a42;
    --accent: #7fb2e8; --bad: #ef8074; --focus: #9cc6f2;
    --edge: #76808c; --edge-sub: #b4bcc6; --edge-dr: #b596ec; --edge-port: #7fb2e8; --edge-idiom: #5cc8b6; --edge-links: #5fc98a; --edge-concept: #d98cbb; --edge-comp: #e0a44f; --edge-know: #9fb2c9;
    --k-class: #1f3247; --k-prop: #2e2542; --k-pattern: #41311a; --k-concept: #1b3a30; --k-other: #2a2f35; --k-idiom: #1e3a28; --k-layer: #2a2f35;
    --tr-port: #aab4c2; --on-color: #101215; --halo: #15181c;
    --lk-token: #e8807f; --lk-data: #8ea8ea; --lk-event: #5fc98a; --lk-guard: #d4a93a;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e6e8eb; --muted: #a4abb5; --paper: #15181c; --panel: #1d2126; --bg: #101215; --line: #333a42;
  --accent: #7fb2e8; --bad: #ef8074; --focus: #9cc6f2;
  --edge: #76808c; --edge-sub: #b4bcc6; --edge-dr: #b596ec; --edge-port: #7fb2e8; --edge-idiom: #5cc8b6; --edge-links: #5fc98a; --edge-concept: #d98cbb; --edge-comp: #e0a44f; --edge-know: #9fb2c9;
  --k-class: #1f3247; --k-prop: #2e2542; --k-pattern: #41311a; --k-concept: #1b3a30; --k-other: #2a2f35; --k-idiom: #1e3a28; --k-layer: #2a2f35;
  --tr-port: #aab4c2; --on-color: #101215; --halo: #15181c;
  --lk-token: #e8807f; --lk-data: #8ea8ea; --lk-event: #5fc98a; --lk-guard: #d4a93a;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 13px/1.45 var(--font-sans); color: var(--ink); background: var(--bg); display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
code { font-family: var(--font-mono); font-size: 11.5px; overflow-wrap: anywhere; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--panel); padding: 6px 10px; z-index: 20; }
.skip:focus { left: 6px; top: 6px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

.top { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; padding: 8px 14px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; flex-direction: column; min-width: 200px; }
.brand b { font-size: 15px; }
.brand .home { font-size: 11.5px; }
.brand .muted { font-size: 11px; }
.examples { display: flex; flex-wrap: wrap; }
.seg { border: 1px solid var(--line); background: var(--panel); color: inherit; padding: 6px 10px; min-height: 32px; cursor: pointer; font: inherit; margin-left: -1px; }
.seg:first-child { border-radius: 6px 0 0 6px; margin-left: 0; }
.seg:last-child { border-radius: 0 6px 6px 0; }
.seg[aria-pressed="true"] { background: var(--ink); color: var(--panel); border-color: var(--ink); }
.search { position: relative; flex: 1 1 220px; min-width: 180px; max-width: 460px; }
input, select { font: inherit; color: inherit; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; min-height: 32px; width: 100%; }
.results { position: absolute; z-index: 10; left: 0; right: 0; margin: 2px 0 0; padding: 4px; list-style: none; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; max-height: 320px; overflow: auto; box-shadow: 0 4px 16px rgb(0 0 0 / .18); }
.results li { padding: 5px 7px; border-radius: 4px; cursor: pointer; display: grid; gap: 1px; }
.results li[aria-selected="true"], .results li:hover { background: var(--bg); }
.results .why { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn { font: inherit; color: inherit; border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 4px 9px; min-height: 30px; min-width: 30px; cursor: pointer; }
.btn:hover, .seg:hover { border-color: var(--muted); }

.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 380px; grid-template-rows: minmax(0, 1fr); gap: 10px; padding: 10px; }
.stage-wrap { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; justify-content: space-between; padding: 6px 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px 8px 0 0; }
.filters { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; border: 0; margin: 0; padding: 0; min-width: 0; }
.tb-label { color: var(--muted); float: left; padding: 0 4px 0 0; }
.tb-tools { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.chk { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; padding: 2px 8px 2px 4px; min-height: 28px; border: 1px solid var(--line); border-radius: 999px; white-space: nowrap; }
.chk input { width: auto; min-height: 0; margin: 0 1px; accent-color: var(--swatch, var(--accent)); }
.chk .n { color: var(--muted); font-size: 11px; }
.stage { position: relative; flex: 1; min-height: 260px; background: var(--paper); border: 1px solid var(--line); border-top: 0; }
#canvas { display: block; width: 100%; height: 100%; touch-action: none; user-select: none; cursor: grab; }
#canvas.panning { cursor: grabbing; }
.stage-empty { position: absolute; inset: 40% 16px auto; text-align: center; color: var(--muted); margin: 0; }
.legend { display: flex; flex-wrap: wrap; gap: 3px 12px; padding: 6px 8px; background: var(--panel); border: 1px solid var(--line); border-top: 0; font-size: 11.5px; color: var(--muted); }
.legend .item { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.legend svg { display: block; }
.status { margin: 4px 2px 0; min-height: 1.2em; font-size: 11.5px; color: var(--muted); }

.side { display: flex; flex-direction: column; gap: 10px; min-width: 0; min-height: 0; overflow: auto; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; min-width: 0; flex: 0 0 auto; }
.card:focus { outline: none; }
.card h2 { font-size: 11.5px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; font-weight: 600; }
.ins-title { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.chip { display: inline-block; border: 1px solid var(--line); border-radius: 999px; padding: 0 7px; font-size: 11px; color: var(--muted); margin-right: 4px; }
.chip.judge { border-color: var(--lk-guard); color: var(--lk-guard); }
.ins-actions { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0; }
.ins-def { margin: 6px 0; overflow-wrap: anywhere; }
.facts { display: grid; grid-template-columns: minmax(84px, max-content) minmax(0, 1fr); gap: 2px 8px; margin: 6px 0; font-size: 12px; }
.facts dt { color: var(--muted); overflow-wrap: anywhere; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.caveats { margin: 6px 0; padding-left: 16px; font-size: 12px; }
.caveats li { margin-bottom: 4px; }
.ins-h { font-size: 11.5px; color: var(--muted); margin: 10px 0 3px; font-weight: 600; }
.nb-list { list-style: none; margin: 0; padding: 0; max-height: 280px; overflow: auto; }
.nb-list li { display: flex; gap: 6px; align-items: baseline; }
.nb { font: inherit; color: var(--accent); background: none; border: 0; padding: 3px 2px; cursor: pointer; text-align: left; min-height: 26px; overflow-wrap: anywhere; }
.nb:hover { text-decoration: underline; }
.nb-p { color: var(--muted); font: 11px var(--font-mono); flex: 0 0 auto; }
.nb-glyph { font-size: 14px; flex: 0 0 auto; }
.path-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 6px; align-items: end; }
.pick label { display: block; color: var(--muted); font-size: 11px; }
.path-steps { list-style: none; margin: 8px 0 0; padding: 0; }
.path-steps li { padding: 2px 0; overflow-wrap: anywhere; }
.warn { color: var(--bad); }
#tree-mode { margin-bottom: 6px; }
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree { max-height: 360px; overflow: auto; }
.tree ul { padding-left: 14px; border-left: 1px solid var(--line); margin-left: 6px; }
.tree [role="treeitem"] > .row { display: flex; align-items: center; gap: 3px; padding: 2px 3px; border-radius: 4px; cursor: pointer; min-height: 26px; }
.tree [role="treeitem"] > .row:hover { background: var(--bg); }
.tree [role="treeitem"]:focus { outline: none; }
.tree [role="treeitem"]:focus-visible > .row { outline: 2px solid var(--focus); outline-offset: -1px; }
.tw { width: 14px; flex: 0 0 14px; text-align: center; color: var(--muted); }
.tree .on-canvas > .row .tl { font-weight: 600; }

/* graph */
.edge { fill: none; stroke: var(--edge); stroke-width: 1.2; }
.edge.g-subclass { stroke: var(--edge-sub); stroke-width: 1.5; }
.edge.g-domainrange { stroke: var(--edge-dr); stroke-dasharray: 4 3; }
.edge.g-ports { stroke: var(--edge-port); }
.edge.g-idioms { stroke: var(--edge-idiom); }
.edge.g-concepts { stroke: var(--edge-concept); }
.edge.g-components { stroke: var(--edge-comp); }
.edge.g-knowledge { stroke: var(--edge-know); }
.edge.lk-token { stroke: var(--lk-token); stroke-dasharray: 6 4; stroke-width: 2; }
.edge.lk-data { stroke: var(--lk-data); stroke-dasharray: 2 3; stroke-width: 2; }
.edge.lk-event { stroke: var(--lk-event); stroke-width: 2.4; }
.edge.lk-guard { stroke: var(--lk-guard); stroke-dasharray: 6 4; stroke-width: 2; }
.edge.inferred { opacity: .55; stroke-dasharray: 1 3; }
.edge.dim, .node.dim, .elabel.dim { opacity: .18; }
.edge.on-path { stroke: var(--accent); stroke-width: 3; opacity: 1; }
.edge.touching { stroke-width: 2.2; }
.arrow { fill: var(--edge-sub); }
.far .elabel { display: none; }
.elabel { font: 9.5px var(--font-mono); fill: var(--muted); paint-order: stroke; stroke: var(--halo); stroke-width: 3px; pointer-events: none; }
.eglyph { font: 15px var(--font-sans); text-anchor: middle; paint-order: stroke; stroke: var(--halo); stroke-width: 4px; pointer-events: none; }
.eglyph.lk-token { fill: var(--lk-token); } .eglyph.lk-data { fill: var(--lk-data); } .eglyph.lk-event { fill: var(--lk-event); } .eglyph.lk-guard { fill: var(--lk-guard); }
.node { cursor: pointer; }
.node:focus { outline: none; }
.node .shape { stroke: var(--edge-sub); stroke-width: 1; }
.node text { font: 11px var(--font-sans); fill: var(--ink); text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.node .under { paint-order: stroke; stroke: var(--halo); stroke-width: 3px; font-size: 10.5px; }
.node .letter { font-weight: 700; font-size: 11px; fill: #fff; }
.k-class .shape { fill: var(--k-class); }
.k-property .shape { fill: var(--k-prop); }
.k-pattern .shape { fill: var(--k-pattern); stroke-width: 1.6; }
.k-concept .shape, .k-scheme .shape { fill: var(--k-concept); }
.k-idiom .shape { fill: var(--k-idiom); }
.k-parameter .shape, .k-invariant .shape, .k-layer .shape, .k-term .shape, .k-component .shape, .k-work .shape, .k-claim .shape, .k-person .shape { fill: var(--k-other); }
.k-linkkind .shape { fill: var(--panel); stroke-width: 1.6; }
.k-linkkind text { font-size: 15px; }
.node.expanded .shape { stroke-width: 2; }
.node.selected .shape { stroke: var(--accent); stroke-width: 3; }
.node.on-path .shape { stroke: var(--accent); stroke-width: 2.6; }
.node:focus-visible .shape { stroke: var(--focus); stroke-width: 3.5; }
.node:focus-visible .ring { display: block; }
.ring { display: none; fill: none; stroke: var(--focus); stroke-width: 2; stroke-dasharray: 3 2; }

.noscript { padding: 16px; }

@media (max-width: 860px) {
  body { display: block; height: auto; }
  .layout { display: flex; flex-direction: column; padding: 8px; }
  .top { padding: 8px; gap: 6px 8px; }
  .search { max-width: none; flex-basis: 100%; order: 5; }
  .brand { min-width: 0; flex: 1 1 0; }
  .brand #release { display: none; }
  .examples { order: 4; }
  /* One swipeable row of filters, so the graph is on the first screen. */
  .toolbar { flex-wrap: nowrap; flex-direction: column; align-items: stretch; }
  .filters { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; }
  .stage { flex: none; height: 62vh; min-height: 320px; }
  .side { overflow: visible; }
  .seg, .btn { min-height: 36px; }
  .chk { min-height: 32px; }
  .tb-label { display: none; }
  .path-form { grid-template-columns: minmax(0, 1fr); }
  input, select { font-size: 16px; } /* below 16px, iOS zooms the page on focus */
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }

/* Ask. The same chips, kinds and glyphs as the rest of the explorer. */
.ask { display: grid; gap: 6px; }
.ask h2 { margin: 0; }
.ask-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; align-items: center; }
.ask-row[hidden] { display: none; } /* display: grid would otherwise override the attribute */
.ask p { margin: 4px 0; }
.btn-primary { background: var(--ink); color: var(--panel); border-color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; }
.btn:disabled { opacity: .55; cursor: progress; }
.linkish { font: inherit; color: var(--accent); background: none; border: 0; padding: 0; min-height: 24px; cursor: pointer; text-decoration: underline; }
.ask-answer:empty { display: none; }
.ask-answer { min-width: 0; overflow-wrap: anywhere; }
.ask-refusal { border: 1px solid var(--bad); border-radius: 6px; padding: 6px 9px; margin: 6px 0; }
.ask-refusal strong { color: var(--bad); }
.ask-claims { border-left: 3px solid var(--lk-guard); padding: 2px 0 2px 9px; margin: 6px 0; }
.ask-claim { margin: 4px 0; }
.cite { font: 11px var(--font-mono); margin-left: 2px; display: inline-block; padding: 3px 1px; }
.ask-items { list-style: decimal; margin: 4px 0; padding-left: 22px; }
.ask-items li { padding: 2px 0; overflow-wrap: anywhere; scroll-margin: 8px; }
.ask-items li > * { margin-right: 4px; vertical-align: baseline; }
.ask-lit { font-size: 12px; }
.tchip { font: inherit; font-size: 12px; color: inherit; border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; min-height: 26px; cursor: pointer; background: var(--k-other); overflow-wrap: anywhere; text-align: left; }
.tchip:hover { border-color: var(--muted); }
.tchip.k-class { background: var(--k-class); }
.tchip.k-property { background: var(--k-prop); border-radius: 13px; font-style: italic; }
.tchip.k-pattern { background: var(--k-pattern); font-weight: 600; border-radius: 3px; }
.tchip.k-concept { background: var(--k-concept); }
.tchip.k-idiom { background: var(--k-idiom); }
.tchip.k-layer { background: var(--k-layer); }
.tchip .letter { display: inline-block; width: 15px; height: 15px; line-height: 15px; border-radius: 50%; color: #fff; font-size: 10px; text-align: center; margin-right: 4px; font-style: normal; }
.tchip > span:not(.letter) { margin-right: 3px; }
.ask-handoff { margin: 8px 0; }
.ask-picks { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.chip-toggle { font: 11px var(--font-mono); background: var(--panel); min-height: 26px; cursor: pointer; margin: 0; }
.chip-toggle[aria-pressed="true"] { background: var(--ink); color: var(--panel); border-color: var(--ink); }
.ask-prov { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 6px; }
.ask-prov summary { cursor: pointer; font-size: 12px; font-weight: 600; min-height: 24px; }
.ask-plan { font: 11.5px/1.4 var(--font-mono); background: var(--paper); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; margin: 6px 0; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 220px; overflow: auto; }
.byo-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 6px; align-items: center; margin-top: 4px; }
.byo-row .ins-h { grid-column: 1 / -1; margin-top: 6px; }
.byo-code { background: var(--paper); border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; min-width: 0; }
@media (max-width: 860px) {
  .tchip, .chip-toggle, .linkish { min-height: 36px; }
  .cite { padding: 8px 4px; }
}
