:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-2: #f0f2f5;
  --line: #dfe3e8;
  --text: #1a1d21;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --pend: #9ca3af;
  --str: #0f766e;
  --num: #1d4ed8;
  --bool: #7c3aed;
  --nul: #9ca3af;
  --key: #374151;
  --dep-Browser: #2563eb;
  --dep-Page: #d97706;
  --dep-Runtime: #7c3aed;
  --dep-Both: #0d9488;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 1px 8px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --panel: #171a20;
    --panel-2: #1f232b;
    --line: #2a2f38;
    --text: #e6e8eb;
    --muted: #8b93a1;
    --accent: #5b8def;
    --accent-ink: #0b1220;
    --ok: #34d399;
    --warn: #fbbf24;
    --err: #f87171;
    --pend: #4b5563;
    --str: #5eead4;
    --num: #93c5fd;
    --bool: #c4b5fd;
    --nul: #6b7280;
    --key: #c9ced6;
    --dep-Browser: #60a5fa;
    --dep-Page: #fbbf24;
    --dep-Runtime: #c4b5fd;
    --dep-Both: #2dd4bf;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}

* { box-sizing: border-box; }
html { background: var(--bg); color: var(--text); font: 14px/1.45 var(--sans); }
body { margin: 0; }
a { color: var(--accent); }
code { font-family: var(--mono); font-size: .92em; background: var(--panel-2); padding: 0 .3em; border-radius: 4px; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.thin { font-weight: 400; color: var(--muted); }
.wrap { max-width: 1400px; margin: 0 auto; padding: 0 20px; }
[hidden] { display: none !important; }

/* header */
.top { background: var(--panel); border-bottom: 1px solid var(--line); padding: 18px 0 0; }
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
h1 { margin: 0; font-size: 22px; letter-spacing: -.01em; font-family: var(--mono); }
.lede { margin: 8px 0 14px; max-width: 900px; color: var(--muted); }
.lede b { color: var(--text); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
button {
  font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 12px; cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.link { background: none; border: none; color: var(--accent); padding: 0; }
button.link:hover { text-decoration: underline; }

.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; padding-bottom: 14px; }
.stat { background: var(--panel-2); border-radius: 8px; padding: 8px 10px; min-width: 0; }
.stat .k { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.stat .k i { font-style: normal; display: inline-block; width: 14px; height: 14px; line-height: 14px; text-align: center; border-radius: 50%; background: var(--line); font-size: 10px; margin-left: 4px; cursor: help; }
.stat .v { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat.hash .v { cursor: pointer; }
.stat.hash .v:hover { color: var(--accent); }
.progress { height: 3px; background: var(--line); }
.progress .bar { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.progress.done .bar { background: var(--ok); }

/* toolbar */
.toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin: 16px 0 12px; }
#filter { flex: 1; min-width: 240px; max-width: 520px; font: inherit; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text); }
.legend { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.legend .sep { width: 1px; height: 18px; background: var(--line); margin: 0 4px; }
.dep { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; padding: 2px 7px; border-radius: 999px; border: 1px solid; }
.dep-Browser { color: var(--dep-Browser); border-color: var(--dep-Browser); }
.dep-Page { color: var(--dep-Page); border-color: var(--dep-Page); }
.dep-Runtime { color: var(--dep-Runtime); border-color: var(--dep-Runtime); }
.dep-Both { color: var(--dep-Both); border-color: var(--dep-Both); }
/* dependency toggles: the pill is the checkbox */
.dep-toggle { position: relative; display: inline-flex; cursor: pointer; }
.dep-toggle input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dep-toggle input:checked + .dep { background: color-mix(in srgb, currentColor 14%, transparent); }
.dep-toggle input:not(:checked) + .dep { opacity: .4; border-style: dashed; text-decoration: line-through; }
.dep-toggle input:focus-visible + .dep { outline: 2px solid var(--accent); outline-offset: 2px; }
.dep-toggle:hover .dep { opacity: 1; }
.no-match { padding: 28px; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); text-align: center; }

/* cards: column flow packs cards vertically so a short card never leaves a hole beside a tall one */
.cards { columns: 3; column-gap: 14px; }
@media (max-width: 1100px) { .cards { columns: 2; } }
@media (max-width: 700px) { .cards { columns: 1; } }
.card { display: flow-root; break-inside: avoid; margin-bottom: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card.hidden { display: none; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; user-select: none; }
.card-head .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--pend); flex: none; }
.card.ok .dot { background: var(--ok); }
.card.gated .dot { background: var(--warn); }
.card.error .dot { background: var(--err); }
.card.pending .dot { animation: pulse 1s infinite alternate; }
@keyframes pulse { from { opacity: .3 } to { opacity: 1 } }
.card-head .name { font-family: var(--mono); font-weight: 700; font-size: 14px; }
.card-head .spacer { flex: 1; }
.card-head .ms { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.card-head .hash { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.card-head .hash:hover { color: var(--accent); }
.card-head .chev { color: var(--muted); font-size: 12px; transition: transform .15s; }
.card.collapsed .chev { transform: rotate(-90deg); }
.card-sub { padding: 6px 12px; color: var(--muted); font-size: 12.5px; border-bottom: 1px solid var(--line); display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline; }
.card-sub .surface { flex: 1 1 260px; }
.card-sub a { white-space: nowrap; }
.card-sq { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 12px 0; }
.sq { font-family: var(--mono); font-size: 10.5px; color: var(--muted); background: var(--panel-2); border-radius: 4px; padding: 1px 5px; }
.card-body { padding: 8px 12px 10px; max-height: 480px; overflow: auto; font-family: var(--mono); font-size: 12.5px; }
.card.tall .card-body { max-height: none; }
.card.collapsed .card-body, .card.collapsed .card-sub, .card.collapsed .card-sq, .card.collapsed .card-foot { display: none; }
.card-foot { padding: 4px 12px 8px; display: flex; gap: 12px; font-size: 12px; }
.card .status-note { color: var(--warn); font-family: var(--sans); padding: 4px 0 6px; }
.card .err { color: var(--err); white-space: pre-wrap; font-family: var(--mono); }

/* value tree */
.tree { margin: 0; }
.row { display: flex; gap: 8px; align-items: flex-start; padding: 1px 0; min-width: 0; }
.row > .key { color: var(--key); flex: none; max-width: 48%; overflow-wrap: anywhere; }
.row > .key .sqk { color: var(--muted); font-size: 10px; background: var(--panel-2); border-radius: 3px; padding: 0 3px; margin-left: 4px; vertical-align: middle; }
.row > .key.idx { color: var(--muted); }
.row > .key.lbl { color: var(--key); }
.row > .val { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.nest { border-left: 1px solid var(--line); margin-left: 4px; padding-left: 10px; }
.v-str { color: var(--str); white-space: pre-wrap; }
.v-num { color: var(--num); }
.v-bool { color: var(--bool); }
.v-nul { color: var(--nul); font-style: italic; }
.v-spec { color: var(--warn); }
.inline { color: var(--muted); }
details.node > summary { cursor: pointer; list-style: none; color: var(--muted); display: inline-block; }
details.node > summary::-webkit-details-marker { display: none; }
details.node > summary::before { content: "▸ "; font-size: 10px; }
details.node[open] > summary::before { content: "▾ "; }
details.node > summary .cnt { color: var(--muted); }
details.node > summary .peek { color: var(--muted); opacity: .8; }
details.node[open] > summary .peek { display: none; }
.trunc { cursor: pointer; }
.trunc .more { color: var(--accent); font-family: var(--sans); font-size: 11px; margin-left: 4px; }
.thumb { display: inline-block; vertical-align: middle; image-rendering: pixelated; border: 1px solid var(--line); background:
  repeating-conic-gradient(var(--panel-2) 0 25%, transparent 0 50%) 0 0 / 12px 12px; margin-right: 6px; }

/* compare */
.compare { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px; }
.compare-head { display: flex; align-items: center; justify-content: space-between; }
.compare h2 { margin: 0; font-size: 16px; }
.compare-input { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.compare-input textarea { flex: 1 1 400px; font: 12px/1.4 var(--mono); padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); color: var(--text); }
.compare-controls { display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.cmp-summary { margin: 12px 0 8px; display: flex; gap: 14px; flex-wrap: wrap; align-items: baseline; }
.cmp-summary .big { font-size: 20px; font-weight: 700; }
.cmp-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.cmp-table th, .cmp-table td { text-align: left; padding: 6px 8px; border-top: 1px solid var(--line); vertical-align: top; }
.cmp-table th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; border-top: none; }
.cmp-table .mod { font-family: var(--mono); font-weight: 600; white-space: nowrap; }
.cmp-same { color: var(--ok); }
.cmp-diff { color: var(--err); font-weight: 600; }
.cmp-only { color: var(--warn); }
.diff-list { margin: 4px 0 0; padding: 0; list-style: none; font-family: var(--mono); font-size: 12px; }
.diff-list li { padding: 4px 0; border-top: 1px dashed var(--line); }
.diff-list .path { color: var(--key); overflow-wrap: anywhere; }
.diff-list .a, .diff-list .b { display: block; padding-left: 12px; overflow-wrap: anywhere; white-space: pre-wrap; }
.diff-list .a::before { content: "this   "; color: var(--muted); }
.diff-list .b::before { content: "other  "; color: var(--muted); }
.diff-list .a { color: var(--ok); }
.diff-list .b { color: var(--err); }
.cmp-meta { font-size: 12.5px; color: var(--muted); }

/* about */
.about { margin: 28px 0 40px; color: var(--muted); }
.about summary { cursor: pointer; color: var(--text); font-weight: 600; }
.about div { max-width: 900px; }
.about li { margin: 4px 0; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 8px; font-size: 13px; box-shadow: var(--shadow); z-index: 10; }
