:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f3f2ee;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-wash: rgba(42, 120, 214, 0.10);
  --accent-wash-strong: rgba(42, 120, 214, 0.22);
  --unversioned: #dedcd5;
  --unversioned-ink: #52514e;
  --added: #006300;
  --removed: #d03b3b;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.05), 0 8px 24px rgba(11, 11, 11, 0.06);
  /* Blue sequential ramp, steps 250..700 (ordinal: nearest-to-surface step clears 2:1). */
  --r0: #86b6ef; --r1: #6da7ec; --r2: #5598e7; --r3: #3987e5; --r4: #2a78d6;
  --r5: #256abf; --r6: #1c5cab; --r7: #184f95; --r8: #104281; --r9: #0d366b;
  --ramp-ink-dark: #ffffff;
  --ramp-ink-light: #0b0b0b;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #222220;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --accent-wash: rgba(57, 135, 229, 0.16);
    --accent-wash-strong: rgba(57, 135, 229, 0.30);
    --unversioned: #3a3a37;
    --unversioned-ink: #c3c2b7;
    --added: #0ca30c;
    --removed: #e66767;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
    /* Same ramp, dimmest step nearest the dark surface, brightening with each bump. */
    --r0: #184f95; --r1: #1c5cab; --r2: #256abf; --r3: #2a78d6; --r4: #3987e5;
    --r5: #5598e7; --r6: #6da7ec; --r7: #86b6ef; --r8: #9ec5f4; --r9: #b7d3f6;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #222220;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --accent: #3987e5;
  --accent-wash: rgba(57, 135, 229, 0.16);
  --accent-wash-strong: rgba(57, 135, 229, 0.30);
  --unversioned: #3a3a37;
  --unversioned-ink: #c3c2b7;
  --added: #0ca30c;
  --removed: #e66767;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  --r0: #184f95; --r1: #1c5cab; --r2: #256abf; --r3: #2a78d6; --r4: #3987e5;
  --r5: #5598e7; --r6: #6da7ec; --r7: #86b6ef; --r8: #9ec5f4; --r9: #b7d3f6;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font: 0.9em ui-monospace, SFMono-Regular, Menlo, monospace; }
button, input, select { font: inherit; color: inherit; }

.skip {
  position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 6px;
}
.skip:focus { left: 16px; z-index: 50; }

.masthead { border-bottom: 1px solid var(--border); background: var(--surface); }
.masthead-inner {
  padding: 12px 16px;
  display: flex; gap: 16px; align-items: center; justify-content: space-between;
}
.title-block { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; }
.masthead h1 { margin: 0; font-size: 20px; font-weight: 650; letter-spacing: -0.01em; line-height: 1.2; }
.lede { margin: 0; color: var(--ink-2); font-size: 13.5px; }
.masthead-actions { display: flex; gap: 8px; flex-shrink: 0; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { color: var(--ink); background: var(--surface-2); text-decoration: none; }
.icon-btn .moon { display: none; }
:root[data-theme="dark"] .icon-btn .sun { display: none; }
:root[data-theme="dark"] .icon-btn .moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-btn .sun { display: none; }
  :root:not([data-theme="light"]) .icon-btn .moon { display: block; }
}

.page { padding: 14px 16px 40px; }

.controls {
  display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin-bottom: 12px;
}
.search {
  display: flex; align-items: center; gap: 8px; padding: 0 10px; height: 34px; min-width: 220px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; color: var(--muted);
}
.search input { border: 0; background: transparent; outline: none; width: 100%; color: var(--ink); }
.search:focus-within { border-color: var(--accent); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button {
  border: 0; background: transparent; padding: 0 12px; height: 32px; cursor: pointer; color: var(--ink-2);
}
.seg button + button { border-left: 1px solid var(--border); }
.seg button.on { background: var(--accent-wash); color: var(--ink); font-weight: 600; }
.select-wrap { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 14px; }
.select-wrap select {
  height: 34px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); padding: 0 8px;
}
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 14px; }
.check input { accent-color: var(--accent); }
.view-seg { margin-left: auto; }

.matrix-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
  padding: 12px 0 8px; overflow: clip;
}
.legend {
  display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 0 16px 10px; color: var(--ink-2); font-size: 12.5px;
}
.legend-item { display: inline-flex; align-items: center; gap: 7px; }
.sw { display: inline-block; width: 26px; height: 12px; border-radius: 3px; }
.sw-ramp { background: linear-gradient(90deg, var(--r0), var(--r9)); }
.sw-unversioned { background: var(--unversioned); }
.sw-upgradable { background: repeating-linear-gradient(45deg, var(--r4) 0 3px, var(--surface) 3px 4.5px); }
.sw-unreg { width: 26px; height: 0; border-radius: 0; border-bottom: 2px dotted var(--muted); }
.sw-selected { background: var(--accent-wash-strong); border: 1px solid var(--accent); box-sizing: border-box; }

/* The matrix takes its full height and the page scrolls. Only when the columns are wider
   than the card (Compact / Wide) does it become a horizontal scroll container. */
.matrix-scroll {
  position: relative; overflow: visible;
  border-top: 1px solid var(--grid); border-bottom: 1px solid var(--grid);
}
.matrix-scroll.overflowing { overflow-x: auto; overscroll-behavior-x: contain; }
/* Sticky header row and sticky label column: flex rows so each sticky item is
   constrained by the full-width row, not by a grid cell. */
.matrix-inner { width: max-content; }
.matrix-inner svg { display: block; flex: none; }
.matrix-head { display: flex; position: sticky; top: 0; z-index: 3; background: var(--surface); }
.matrix-body { display: flex; }
#corner { position: sticky; left: 0; z-index: 4; background: var(--surface); }
#labels { position: sticky; left: 0; z-index: 2; background: var(--surface); }

.hint { margin: 10px 16px 4px; color: var(--muted); font-size: 12.5px; }

/* SVG parts */
svg text { font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
.hdr-group { fill: var(--ink); font-weight: 650; }
.hdr-col { fill: var(--ink-2); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.hdr-band { fill: var(--surface-2); }
.hdr-band.alt { fill: transparent; }
.hdr-hit { fill: transparent; cursor: pointer; }
.hdr-hit:hover { fill: var(--accent-wash); }
.hdr-col.selected, .hdr-group.selected { fill: var(--accent); }
.hdr-sel { fill: var(--accent-wash-strong); }
.hdr-underline { stroke: var(--axis); stroke-width: 1; }

.row-label { fill: var(--ink); font-size: 12px; cursor: pointer; }
.row-label.jll { fill: var(--ink-2); }
.row-label.unregistered { text-decoration: underline dotted; text-underline-offset: 3px; text-decoration-color: var(--muted); }
.row-label.selected { fill: var(--accent); font-weight: 650; }
.row-hit { fill: transparent; cursor: pointer; }
.row-hit:hover { fill: var(--accent-wash); }
.row-hit.selected { fill: var(--accent-wash); }
.group-label { fill: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.dep-badge { fill: var(--accent); font-size: 10px; font-weight: 600; }

.row-band { fill: var(--surface-2); opacity: 0.5; }
.col-sel-outline { fill: none; stroke: var(--accent); stroke-width: 1.5; pointer-events: none; }
.col-sep { stroke: var(--grid); stroke-width: 1; }
.col-sel { fill: var(--accent-wash); }
.run { rx: 4; ry: 4; stroke: var(--surface); stroke-width: 1; transition: opacity 120ms; }
.run.unversioned { fill: var(--unversioned); }
.run.r0 { fill: var(--r0); } .run.r1 { fill: var(--r1); } .run.r2 { fill: var(--r2); } .run.r3 { fill: var(--r3); }
.run.r4 { fill: var(--r4); } .run.r5 { fill: var(--r5); } .run.r6 { fill: var(--r6); } .run.r7 { fill: var(--r7); }
.run.r8 { fill: var(--r8); } .run.r9 { fill: var(--r9); }
.run-hatch { pointer-events: none; rx: 4; ry: 4; }
.hatch-line { stroke: var(--surface); stroke-width: 1.6; opacity: 0.7; }
.run-label {
  pointer-events: none; font-variant-numeric: tabular-nums; font-weight: 600;
  paint-order: stroke; stroke-width: 3px; stroke-linejoin: round;
}
.run-label.unversioned { fill: var(--unversioned-ink); }
.run-hit { fill: transparent; cursor: default; }
.run-hit:hover + .run-outline, .run-outline.hover { stroke: var(--ink); }
.run-outline { fill: none; stroke: transparent; stroke-width: 1.5; rx: 4; ry: 4; pointer-events: none; }
.dimmed .run { opacity: 0.25; }
.dimmed .row-focus .run { opacity: 1; }
.dep-mark { fill: none; stroke: var(--accent); stroke-width: 1.5; rx: 5; ry: 5; pointer-events: none; }

/* Tooltip */
.tooltip {
  position: fixed; z-index: 20; pointer-events: none; max-width: 320px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: var(--shadow); padding: 8px 10px; font-size: 12.5px; line-height: 1.4;
}
.tooltip b { font-weight: 650; }
.tooltip .tt-ver { font-size: 15px; font-weight: 650; font-variant-numeric: tabular-nums; }
.tooltip .tt-sub { color: var(--ink-2); }
.tooltip .tt-deps { color: var(--ink-2); margin-top: 4px; }

/* Details panel */
.panel {
  margin-top: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); padding: 14px 18px 18px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel h2 { margin: 0; font-size: 18px; font-weight: 650; }
.panel-body { margin-top: 8px; }
.panel-body h3 { margin: 14px 0 6px; font-size: 13px; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.05em; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2); font-size: 12.5px; cursor: pointer; color: var(--ink);
}
.chip:hover { border-color: var(--accent); }
.chip .v { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.chip .arrow { color: var(--muted); }
.chip.added { border-color: color-mix(in srgb, var(--added) 50%, transparent); }
.chip.removed { border-color: color-mix(in srgb, var(--removed) 50%, transparent); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.chip.added .dot { background: var(--added); }
.chip.removed .dot { background: var(--removed); }
.chip.bumped .dot { background: var(--accent); }
.empty { color: var(--muted); font-size: 13px; }
.hist { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 13.5px; align-items: baseline; }
.hist .hv { font-variant-numeric: tabular-nums; font-weight: 600; }
.hist .hr { color: var(--ink-2); }
.hist .hv .hu { margin-left: 8px; font-size: 11px; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: 0.04em; }
.hist .hv .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.meta-line { color: var(--ink-2); font-size: 13.5px; margin: 4px 0 0; }
.meta-line code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.cols-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 0 28px; }

/* Table view */
.table-view { overflow-x: auto; }
.table-view table { border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
.table-view th, .table-view td {
  padding: 4px 8px; white-space: nowrap; border-bottom: 1px solid var(--grid); text-align: left;
  font-variant-numeric: tabular-nums;
}
.table-view thead th { position: sticky; top: 0; background: var(--surface); z-index: 2; color: var(--ink-2); font-weight: 600; }
.table-view tbody th { position: sticky; left: 0; background: var(--surface); z-index: 1; font-weight: 600; }
.table-view thead th:first-child { left: 0; z-index: 3; }
.table-view td.changed { color: var(--accent); font-weight: 600; }
.table-view td.absent { color: var(--grid); }
.table-view td.unversioned { color: var(--muted); }
.table-view td.upgradable { text-decoration: underline dotted; text-underline-offset: 3px; }

.foot {
  padding: 0 16px 40px; color: var(--muted); font-size: 12.5px;
  display: flex; flex-wrap: wrap; gap: 4px 24px;
}

@media (max-width: 900px) {
  .masthead-inner { align-items: flex-start; }
  .view-seg { margin-left: 0; }
}
@media (max-width: 520px) {
  .search { min-width: 0; flex: 1 1 100%; }
}
@media (prefers-reduced-motion: reduce) { .run { transition: none; } }

/* Dependency graph view */
.graph-view { padding: 0 16px 8px; }
.slider-row { display: flex; align-items: center; gap: 10px; padding: 4px 0 10px; }
.slider-row input[type="range"] { flex: 1; min-width: 120px; accent-color: var(--accent); }
.slider-row .icon-btn:disabled { opacity: 0.4; cursor: default; }
.slider-label { display: flex; flex-direction: column; min-width: 220px; line-height: 1.25; }
#slider-release { font-weight: 650; }
.slider-delta { color: var(--ink-2); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.graph-scroll { overflow-x: auto; }
#graph { display: block; width: 100%; height: auto; }
.edge { fill: none; stroke: var(--muted); stroke-opacity: 0.55; stroke-width: 1.2; transition: opacity 200ms, stroke 200ms; }
.edge.weak { stroke-dasharray: 4 3; }
.arrow-head { fill: var(--muted); }
.node { cursor: pointer; transition: opacity 200ms; }
.node-bg { stroke: var(--surface); stroke-width: 1; transition: fill 200ms; }
.node-bg.unregistered { stroke: var(--muted); stroke-dasharray: 2 2; }
.node-hatch { pointer-events: none; }
.node-label {
  font-size: 12px; font-weight: 600; pointer-events: none;
  paint-order: stroke; stroke-width: 3px; stroke-linejoin: round;
}
#graph .off { opacity: 0 !important; pointer-events: none; }
#graph.focus .node:not(.lit), #graph.focus .edge:not(.lit) { opacity: 0.12; }
#graph.focus .edge.lit { stroke: var(--accent); stroke-opacity: 1; stroke-width: 1.8; }
.graph-only { display: none; }
body.view-graph .graph-only { display: block; }
body.view-graph .legend-item.graph-only { display: inline-flex; }
body.view-graph .chart-only { display: none; }
.sw-weak { width: 26px; height: 0; border-radius: 0; border-bottom: 2px dashed var(--axis); }
@media (prefers-reduced-motion: reduce) { .edge, .node, .node-bg { transition: none; } }

/* Controls that have no effect on the current view are hidden rather than left dead. */
body[data-view="table"] .density-seg, body[data-view="graph"] .density-seg { display: none; }
body[data-view="graph"] .select-wrap { display: none; }
