:root {
  --bg: #fbfbfa; --fg: #1a1a19; --muted: #6b6b66; --line: #e2e2dd;
  --card: #ffffff; --accent: #7a4b2a; --code: #f2f2ee;
  --node-fill: #f7f7f4; --node-line: #cfcfc7; --edge-line: #b0b0a8;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16171a; --fg: #e6e6e3; --muted: #9a9a94; --line: #2c2e33;
    --card: #1d1f23; --accent: #d79a6a; --code: #23252a;
    --node-fill: #262930; --node-line: #3f434c; --edge-line: #565b66;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}
.wrap { max-width: 62rem; margin: 0 auto; padding: 1.5rem 1.25rem 5rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
nav { border-bottom: 1px solid var(--line); margin-bottom: 1.75rem;
      padding-bottom: .75rem; font-size: .9rem; display: flex; gap: 1rem;
      align-items: center; }
nav .home { font-weight: 600; white-space: nowrap; }
h1 { font-size: 1.9rem; line-height: 1.25; margin: 0 0 .4rem; }
h2 { font-size: 1.25rem; margin: 2.5rem 0 .5rem; }
h3 { font-size: 1rem; margin: 1.75rem 0 .5rem; text-transform: uppercase;
     letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.lede { color: var(--muted); margin: 0 0 1.5rem; }
.meta { color: var(--muted); font-size: .875rem; margin: 0 0 1.25rem; }
.summary { font-size: 1.05rem; margin: 0 0 1.5rem; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em;
       background: var(--code); padding: .1em .35em; border-radius: 3px; }
.cards { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px;
        padding: .85rem 1rem; }
.card h4 { margin: 0 0 .25rem; font-size: 1rem; }
.card p { margin: 0; color: var(--muted); font-size: .85rem; }
.edges { list-style: none; padding: 0; margin: 0; }
.edges li { padding: .55rem 0; border-top: 1px solid var(--line); }
.edges li:first-child { border-top: 0; }
.rel { display: inline-block; font-size: .72rem; text-transform: uppercase;
       letter-spacing: .07em; padding: .12em .5em; border-radius: 3px;
       background: var(--code); color: var(--muted); margin-right: .5rem;
       font-family: ui-monospace, monospace; }
.why { color: var(--muted); display: block; margin-top: .15rem; font-size: .92rem; }

/* ---- search ---- */
.find { position: relative; flex: 1; max-width: 26rem; }
#q { width: 100%; padding: .42rem .7rem; font-size: .92rem; border-radius: 6px;
     border: 1px solid var(--line); background: var(--card); color: var(--fg); }
#q:focus { outline: none; border-color: var(--accent); }
#hits { position: absolute; z-index: 20; left: 0; right: 0; top: 2.3rem;
        background: var(--card); border: 1px solid var(--line); border-radius: 7px;
        list-style: none; margin: 0; padding: .25rem; max-height: 60vh;
        overflow-y: auto; display: none; box-shadow: 0 8px 26px rgba(0,0,0,.14); }
#hits.open { display: block; }
#hits li { padding: .35rem .5rem; border-radius: 5px; cursor: pointer;
           display: flex; gap: .5rem; align-items: baseline; }
#hits li.sel, #hits li:hover { background: var(--code); }
#hits .c { color: var(--muted); font-size: .78rem; margin-left: auto; }
#hits .none { color: var(--muted); cursor: default; }
kbd { font: .72rem ui-monospace, monospace; border: 1px solid var(--line);
      border-bottom-width: 2px; border-radius: 4px; padding: 0 .3em; color: var(--muted); }

/* ---- figures ---- */
.figure { margin: .75rem 0 2rem; }
/* Break out of the text column: a 29-node graph needs the whole window. */
.figure.wide { width: min(97vw, 1700px); margin-left: calc(50% - min(48.5vw, 850px)); }
.fig-head { display: flex; align-items: center; gap: .75rem; margin-bottom: .4rem;
            font-size: .78rem; color: var(--muted); }
.fig-head .hint { flex: 1; }
.found { font-variant-numeric: tabular-nums; }
.found.on { color: var(--accent); }
.diagram { position: relative; background: var(--card); border: 1px solid var(--line);
           border-radius: 8px; padding: .75rem; overflow: auto; }
/* Only once pan/zoom is live does the box become a fixed viewport. Without it
   the svg simply sits at its natural size and the page scrolls. */
.diagram.pz { overflow: hidden; min-height: 9rem; cursor: grab;
              user-select: none; -webkit-user-select: none; touch-action: none; }
.diagram.pz.grabbing { cursor: grabbing; }
.diagram.pz svg { width: 100%; height: 100%; max-width: none; display: block; }
.diagram:fullscreen { height: 100vh; width: 100vw; margin: 0; border-radius: 0; }
.tools { display: none; gap: .25rem; }
.figure.ready .tools { display: flex; }
.tools button { font: 600 .78rem/1 ui-monospace, monospace; color: var(--muted);
                background: var(--bg); border: 1px solid var(--line);
                border-radius: 5px; padding: .35rem .5rem; cursor: pointer; }
.tools button:hover { color: var(--fg); border-color: var(--muted); }

/* ---- the graph itself ---- */
.diagram svg { font-family: Helvetica, Arial, sans-serif; }
.diagram svg .graph > polygon { fill: none; stroke: none; }
.diagram svg .node > path, .diagram svg .node > polygon {
  fill: var(--node-fill); stroke: var(--node-line); }
.diagram svg .node text { fill: var(--fg); }
.diagram svg .node a:hover > path { stroke: var(--accent); stroke-width: 1.8; }
.diagram svg .node.ext > path { stroke-dasharray: 5 3; fill: none; }
.diagram svg .node.focus > path { stroke: var(--accent); stroke-width: 2.2; }
.diagram svg .edge > path { stroke: var(--edge-line); fill: none; }
.diagram svg .edge > polygon { fill: var(--edge-line); stroke: var(--edge-line); }
.diagram svg .edge text { fill: var(--muted); }
.diagram svg a { text-decoration: none; }
.diagram svg .node, .diagram svg .edge { transition: opacity .14s ease; }
.diagram svg .node.dim, .diagram svg .edge.dim { opacity: .12; }
.diagram svg .node.hit > path { stroke: var(--accent); stroke-width: 2.4; }
.diagram svg .node.hit text { font-weight: bold; }

.legend { list-style: none; padding: 0; margin: 0 0 .35rem; display: flex;
          flex-wrap: wrap; gap: .3rem 1.6rem; font-size: .82rem; color: var(--muted); }
.legend li { display: flex; align-items: baseline; gap: .5rem; }
.legend b { font-weight: 600; color: var(--fg); font-size: .74rem;
            text-transform: uppercase; letter-spacing: .05em; }
.legend .ln { display: inline-flex; align-items: center; gap: .35rem; }
.legend i { width: 1.5rem; border-top-width: 2.5px; display: inline-block; }
.legend-note { font-size: .78rem; color: var(--muted); margin: 0 0 1.25rem; }
.refs { list-style: none; padding: 0; }
.refs li { padding: .4rem 0; color: var(--muted); font-size: .92rem; }
.refs .t { color: var(--fg); }
.stat { display: flex; gap: 2rem; flex-wrap: wrap; margin: 0 0 2rem; }
.stat b { display: block; font-size: 1.5rem; }
.count { font-weight: 400; font-size: .8rem; color: var(--muted); }
.stat span { color: var(--muted); font-size: .8rem; text-transform: uppercase;
             letter-spacing: .06em; }
footer { margin-top: 4rem; padding-top: 1rem; border-top: 1px solid var(--line);
         color: var(--muted); font-size: .85rem; }
@media (max-width: 640px) {
  nav .repo { display: none; }
  .figure.wide { width: 100%; margin-left: 0; }
}
:root {
  --fam-supersede: #2a78d6;
  --fam-structure: #008300;
  --fam-substitute: #e87ba4;
  --fam-support: #eda100;
}
@media (prefers-color-scheme: dark) { :root {
  --fam-supersede: #3987e5;
  --fam-structure: #008300;
  --fam-substitute: #d55181;
  --fam-support: #c98500;
} }
.diagram svg .e-corrects > path { stroke: var(--fam-supersede); }
.diagram svg .e-corrects > polygon { fill: var(--fam-supersede); stroke: var(--fam-supersede); }
.legend .r-corrects { border-top-color: var(--fam-supersede); border-top-style: solid; }
.rel.k-corrects { border-left: 3px solid var(--fam-supersede); }
.diagram svg .e-extends > path { stroke: var(--fam-supersede); stroke-dasharray: 7 5; }
.diagram svg .e-extends > polygon { fill: var(--fam-supersede); stroke: var(--fam-supersede); }
.legend .r-extends { border-top-color: var(--fam-supersede); border-top-style: dashed; }
.rel.k-extends { border-left: 3px solid var(--fam-supersede); }
.diagram svg .e-specializes > path { stroke: var(--fam-structure); }
.diagram svg .e-specializes > polygon { fill: var(--fam-structure); stroke: var(--fam-structure); }
.legend .r-specializes { border-top-color: var(--fam-structure); border-top-style: solid; }
.rel.k-specializes { border-left: 3px solid var(--fam-structure); }
.diagram svg .e-part-of > path { stroke: var(--fam-structure); stroke-dasharray: 7 5; }
.diagram svg .e-part-of > polygon { fill: var(--fam-structure); stroke: var(--fam-structure); }
.legend .r-part-of { border-top-color: var(--fam-structure); border-top-style: dashed; }
.rel.k-part-of { border-left: 3px solid var(--fam-structure); }
.diagram svg .e-approximates > path { stroke: var(--fam-substitute); }
.diagram svg .e-approximates > polygon { fill: var(--fam-substitute); stroke: var(--fam-substitute); }
.legend .r-approximates { border-top-color: var(--fam-substitute); border-top-style: solid; }
.rel.k-approximates { border-left: 3px solid var(--fam-substitute); }
.diagram svg .e-alternative-to > path { stroke: var(--fam-substitute); stroke-dasharray: 7 5; }
.diagram svg .e-alternative-to > polygon { fill: var(--fam-substitute); stroke: var(--fam-substitute); }
.legend .r-alternative-to { border-top-color: var(--fam-substitute); border-top-style: dashed; }
.rel.k-alternative-to { border-left: 3px solid var(--fam-substitute); }
.diagram svg .e-requires > path { stroke: var(--fam-support); }
.diagram svg .e-requires > polygon { fill: var(--fam-support); stroke: var(--fam-support); }
.legend .r-requires { border-top-color: var(--fam-support); border-top-style: solid; }
.rel.k-requires { border-left: 3px solid var(--fam-support); }
.diagram svg .e-validates > path { stroke: var(--fam-support); stroke-dasharray: 7 5; }
.diagram svg .e-validates > polygon { fill: var(--fam-support); stroke: var(--fam-support); }
.legend .r-validates { border-top-color: var(--fam-support); border-top-style: dashed; }
.rel.k-validates { border-left: 3px solid var(--fam-support); }
