/* Memory Differentiation — heap explorer. Tokens first; dark mode by system preference unless the
   user picked a theme (html[data-theme]). No inline styles: the CSP forbids them. */

:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --surface-3: #e7eaef;
  --border: #dde1e7;
  --border-strong: #c6ccd5;
  --text: #171a21;
  --muted: #4b5361;
  --faint: #5b6371;
  --accent: #4f5bd5;
  --accent-text: #3a45b8;
  --accent-soft: #e9ebfb;
  --on-accent: #ffffff;
  --edge-context: #7d3aa8;
  --select: #dfe3fb;
  --grow: #a8380a;
  --grow-soft: #fdebe1;
  --grow-bar: #f08a4b;
  --shrink: #10692f;
  --shrink-soft: #def4e6;
  --shrink-bar: #3fbf6f;
  --base-bar: #9aa4b5;
  --mod-bar: #4f5bd5;
  --warn: #855104;
  --warn-soft: #fdf3d5;
  --danger: #b91c1c;
  --code-bg: #f7f8fa;
  --del-bg: #fdecec;
  --del-hl: #f9caca;
  --ins-bg: #e7f6ec;
  --ins-hl: #bfe9cc;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 8%);
  --radius: 8px;
  --row: 30px;
  --mono: ui-monospace, 'SF Mono', 'Cascadia Code', 'JetBrains Mono', Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --bg: #0e1015;
    --surface: #161920;
    --surface-2: #1c2029;
    --surface-3: #252a35;
    --border: #2a2f3a;
    --border-strong: #3a4150;
    --text: #e6e8ee;
    --muted: #9aa2b1;
    --faint: #959dad;
    --accent: #8b96ff;
    --accent-text: #a9b1ff;
    --accent-soft: #232848;
    --on-accent: #0e1015;
    --edge-context: #cf9ef5;
    --select: #283062;
    --grow: #fb923c;
    --grow-soft: #3a2418;
    --grow-bar: #e8763a;
    --shrink: #4ade80;
    --shrink-soft: #14301f;
    --shrink-bar: #2fae5e;
    --base-bar: #5d6678;
    --mod-bar: #8b96ff;
    --warn: #facc15;
    --warn-soft: #3a3114;
    --danger: #fa8a8a;
    --code-bg: #12151b;
    --del-bg: #3a1c1f;
    --del-hl: #5c272b;
    --ins-bg: #15301f;
    --ins-hl: #1f5233;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%);
  }
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #0e1015;
  --surface: #161920;
  --surface-2: #1c2029;
  --surface-3: #252a35;
  --border: #2a2f3a;
  --border-strong: #3a4150;
  --text: #e6e8ee;
  --muted: #9aa2b1;
  --faint: #959dad;
  --accent: #8b96ff;
  --accent-text: #a9b1ff;
  --accent-soft: #232848;
  --on-accent: #0e1015;
  --edge-context: #cf9ef5;
  --select: #283062;
  --grow: #fb923c;
  --grow-soft: #3a2418;
  --grow-bar: #e8763a;
  --shrink: #4ade80;
  --shrink-soft: #14301f;
  --shrink-bar: #2fae5e;
  --base-bar: #5d6678;
  --mod-bar: #8b96ff;
  --warn: #facc15;
  --warn-soft: #3a3114;
  --danger: #fa8a8a;
  --code-bg: #12151b;
  --del-bg: #3a1c1f;
  --del-hl: #5c272b;
  --ins-bg: #15301f;
  --ins-hl: #1f5233;
  --shadow: 0 1px 2px rgb(0 0 0 / 40%);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
  margin: 0 0 8px;
  line-height: 1.25;
  font-weight: 600;
}

h1 {
  font-size: 20px;
}

h2 {
  font-size: 16px;
}

h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

a {
  color: var(--accent-text);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code,
pre,
kbd,
.mono {
  font-family: var(--mono);
  font-size: 12px;
}

pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

kbd {
  display: inline-block;
  min-width: 18px;
  padding: 0 4px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface);
  text-align: center;
  font-size: 11px;
  line-height: 16px;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
}

.tiny {
  font-size: 11px;
}

.strong {
  font-weight: 600;
}

.pad {
  padding: 12px 14px;
}

.error {
  color: var(--danger);
}

.warn {
  color: var(--warn);
}

.grow {
  color: var(--grow);
}

.shrink {
  color: var(--shrink);
}

.flat {
  color: var(--faint);
}

.spacer {
  flex: 1;
}

/* ---- Controls --------------------------------------------------------------------------- */

button,
.button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
}

button:hover,
.button:hover {
  filter: brightness(1.06);
  text-decoration: none;
}

button:disabled {
  opacity: 0.55;
  cursor: progress;
}

button.secondary,
.button.secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}

button.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-text);
}

button.link.danger {
  color: var(--danger);
}

button.icon {
  width: 30px;
  height: 30px;
  justify-content: center;
  padding: 0;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
}

button.icon:hover {
  background: var(--surface-2);
  color: var(--text);
}

input,
select {
  padding: 5px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

input.search {
  width: 240px;
  padding-left: 26px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%238a92a0' stroke-width='2' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 8px center;
}

input.search.small {
  width: 180px;
}

.segmented {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-2);
}

.segmented button {
  padding: 3px 10px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-weight: 500;
}

.segmented button.on {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.badge {
  display: inline-block;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  line-height: 17px;
  white-space: nowrap;
  vertical-align: 1px;
}

.badge.grow {
  background: var(--grow-soft);
  color: var(--grow);
}

.badge.shrink {
  background: var(--shrink-soft);
  color: var(--shrink);
}

.badge.accent {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.badge.warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge.side-base {
  background: var(--surface-3);
  color: var(--text);
}

.badge.side-modified {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.chip {
  display: inline-block;
  padding: 0 6px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 17px;
}

.chip.change {
  border-color: var(--accent);
  color: var(--accent-text);
  background: var(--accent-soft);
}

.card {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.empty {
  margin: 48px auto;
  max-width: 520px;
  text-align: center;
}

/* ---- Shell ------------------------------------------------------------------------------ */

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 46px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 700;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
}

.brand-mark.big {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  font-size: 22px;
  margin-bottom: 12px;
}

.crumb-sep {
  color: var(--faint);
}

.analysis-name {
  max-width: 260px;
  overflow: hidden;
  color: var(--text);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.view-tabs {
  display: flex;
  gap: 2px;
  margin-left: 12px;
}

.view-tab {
  padding: 6px 10px;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 500;
}

.view-tab:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}

.view-tab.on {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.view {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.view-classes,
.view-code,
.view-node,
.view-dominators,
.view-grown,
.view-sites,
.view-treemap,
.view-explain,
.view-subtree {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.toast-slot {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 20;
}

.toast {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 24px rgb(0 0 0 / 18%);
}

.toast.error {
  border-color: var(--danger);
  color: var(--danger);
}

.login {
  display: grid;
  min-height: 100%;
  place-items: center;
  padding: 24px;
}

.login-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(420px, 100%);
  padding: 28px;
}

.help {
  width: min(560px, calc(100% - 32px));
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 60px rgb(0 0 0 / 30%);
}

.help::backdrop {
  background: rgb(0 0 0 / 35%);
}

.shortcuts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 16px;
  margin: 12px 0;
}

.shortcuts dt {
  white-space: nowrap;
}

.shortcuts dd {
  margin: 0;
  color: var(--muted);
}

/* ---- Panes, toolbars, grids -------------------------------------------------------------- */

.split {
  display: grid;
  flex: 1;
  min-height: 0;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
}

.pane {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.pane:last-child {
  border-right: 0;
}

.pane.active .grid-head {
  box-shadow: inset 0 2px 0 var(--accent);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

.toolbar-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.toolbar-note {
  margin-left: auto;
  font-size: 12px;
}

.pane-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.grid-head,
.grid-row {
  display: grid;
  align-items: center;
  column-gap: 10px;
  padding: 0 10px;
}

.grid-head {
  height: 30px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  flex: none;
}

.grid-head button {
  justify-content: flex-start;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  white-space: nowrap;
}

.grid-head .num,
.grid-head button.num {
  justify-content: flex-end;
  text-align: right;
}

.grid-head [aria-sort='ascending'] button,
.grid-head [aria-sort='descending'] button {
  color: var(--accent-text);
}

.sort-mark {
  font-size: 9px;
}

.classes-grid {
  grid-template-columns:
    minmax(160px, 2.2fr) repeat(3, minmax(52px, 0.5fr)) minmax(150px, 1.25fr)
    repeat(3, minmax(66px, 0.62fr)) repeat(2, minmax(44px, 0.4fr)) 92px;
}

.objects-grid {
  grid-template-columns: minmax(0, 1fr) 64px 76px 86px;
}

.edges-grid {
  grid-template-columns: minmax(80px, 0.9fr) 14px minmax(0, 2.4fr) 46px 72px 84px;
}

.dom-grid {
  grid-template-columns: minmax(0, 1fr) 84px 96px 150px;
}

.linked-grid {
  grid-template-columns: 64px minmax(0, 1fr) 84px;
}

.cell {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.cell.name {
  font-weight: 500;
}

.value {
  color: var(--accent-text);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 400;
}

.node-id {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 400;
}

.edge-name {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
}

.edge-context {
  color: var(--edge-context);
}

.edge-element,
.edge-hidden {
  color: var(--muted);
}

.edge-weak {
  color: var(--faint);
  font-style: italic;
}

.arrow {
  color: var(--faint);
}

.grid-row.weak {
  opacity: 0.65;
}

/* Virtual list */
.vl {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: auto;
  outline: none;
}

.vl-spacer {
  position: relative;
}

.vl-row {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  border-bottom: 1px solid var(--surface-2);
  cursor: default;
}

.vl-row:hover {
  background: var(--surface-2);
}

.vl-row.current {
  box-shadow: inset 3px 0 0 var(--accent);
}

.vl-row.selected {
  background: var(--select);
}

.vl:focus-visible .vl-row.selected,
.vl:focus .vl-row.selected {
  box-shadow: inset 3px 0 0 var(--accent);
}

.vl-row.placeholder {
  display: flex;
  align-items: center;
  padding: 0 10px;
  color: var(--faint);
}

.vl-status {
  position: absolute;
  top: 10px;
  left: 12px;
  pointer-events: none;
}

.vl-status:empty {
  display: none;
}

/* Bars */
.bar-cell {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.dbar {
  position: relative;
  flex: 1;
  min-width: 40px;
  height: 8px;
  border-radius: 2px;
  background: linear-gradient(
    to right,
    transparent calc(50% - 0.5px),
    var(--border-strong) calc(50% - 0.5px),
    var(--border-strong) calc(50% + 0.5px),
    transparent calc(50% + 0.5px)
  );
}

.dbar-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 2px;
}

.dbar-fill.grow {
  background: var(--grow-bar);
}

.dbar-fill.shrink {
  background: var(--shrink-bar);
}

.pbar {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
}

.pbar-base,
.pbar-mod {
  height: 5px;
  border-radius: 2px;
}

.pbar-base {
  background: var(--base-bar);
}

.pbar-mod {
  background: var(--mod-bar);
}

/* ---- Home -------------------------------------------------------------------------------- */

.home {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.home-intro {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.section-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.analysis-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

.analysis-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.analysis-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.analysis-card h3 {
  margin: 0;
  color: var(--text);
  font-size: 15px;
  text-transform: none;
  letter-spacing: 0;
}

.analysis-card p {
  margin: 0;
}

.analysis-card .danger {
  align-self: flex-start;
  margin-top: 8px;
}

.card-stats {
  font-variant-numeric: tabular-nums;
}

.upload {
  display: grid;
  gap: 10px;
  max-width: 520px;
  margin-top: 12px;
}

.upload label {
  display: grid;
  gap: 4px;
  font-weight: 500;
}

details > summary {
  cursor: pointer;
  font-weight: 600;
}

/* ---- Overview ---------------------------------------------------------------------------- */

.overview {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 20px 60px;
}

.overview-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.overview-head h1 {
  margin: 0;
}

.run-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.run-form label {
  display: grid;
  gap: 2px;
  color: var(--muted);
  font-size: 11px;
}

.run-form input {
  width: 74px;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}

.kpi {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.kpi-label {
  color: var(--muted);
  font-size: 12px;
}

.kpi-value {
  font-size: 22px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.kpi-sub {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.span-2 {
  grid-column: span 2;
}

.span-3 {
  grid-column: span 3;
}

.top-legend {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) 1fr 1.2fr 90px 60px;
  gap: 10px;
  margin: 6px 0;
}

.legend::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 5px;
  margin-right: 5px;
  border-radius: 2px;
  vertical-align: middle;
}

.legend.base::before {
  background: var(--base-bar);
}

.legend.mod::before {
  background: var(--mod-bar);
}

.top-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) 1fr 1.2fr 90px 60px;
  gap: 10px;
  align-items: center;
  padding: 5px 6px;
  border-radius: 6px;
  color: var(--text);
}

.top-row:hover,
.top-row.selected {
  background: var(--select);
  text-decoration: none;
}

.top-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.top-bar {
  display: flex;
}

.sets {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 12px;
  margin: 0 0 8px;
}

.sets dt {
  font-weight: 600;
  text-transform: capitalize;
}

.sets dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.verdicts {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.verdict {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.verdict p {
  margin: 6px 0 0;
}

.verdict-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.verdict-leak,
.verdict-regression {
  background: var(--grow-soft);
  color: var(--grow);
}

.verdict-improvement,
.verdict-expected-growth {
  background: var(--shrink-soft);
  color: var(--shrink);
}

.snippet {
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--code-bg);
  border: 1px solid var(--border);
}

.markdown p,
.markdown ul,
.markdown ol {
  margin: 6px 0;
}

.markdown pre {
  padding: 10px;
  border-radius: 6px;
  background: var(--code-bg);
}

/* ---- Inspector --------------------------------------------------------------------------- */

.inspector {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
}

.trail {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 12px;
  flex: none;
}

.crumb {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crumb.current {
  font-weight: 600;
}

.inspector-grid {
  display: grid;
  flex: 1;
  min-height: 0;
  grid-template-columns: minmax(0, 1fr) 340px;
}

.inspector-main {
  display: flex;
  min-height: 0;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.inspector-side {
  min-height: 0;
  overflow: auto;
  padding: 14px;
  background: var(--surface);
}

.inspector-head {
  padding: 14px 16px 6px;
  flex: none;
}

.title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}

.node-title {
  margin: 0;
  font-size: 18px;
  word-break: break-word;
}

.node-value {
  max-height: 120px;
  margin: 8px 0;
  padding: 8px 10px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--code-bg);
  color: var(--accent-text);
}

.stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 24px;
  margin: 10px 0 6px;
}

.stat-value {
  font-size: 16px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  color: var(--muted);
  font-size: 11px;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 10px;
  border-bottom: 1px solid var(--border);
  flex: none;
}

.tabs input.search {
  margin-left: auto;
  margin-block: 4px;
}

.tab {
  padding: 8px 10px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: none;
  color: var(--muted);
}

.tab.on {
  border-bottom-color: var(--accent);
  color: var(--text);
}

.tab-count {
  padding: 0 5px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 11px;
}

.tab-body {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  overflow: auto;
}

.frames {
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
}

.frame {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
  padding: 5px 8px;
  border-left: 2px solid var(--border);
}

.frame.linked {
  border-left-color: var(--accent);
  background: var(--accent-soft);
}

.frame-fn {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
}

.frame-loc {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
}

.links {
  margin: 0;
  padding-left: 18px;
}

.links li {
  margin: 4px 0;
}

.paths {
  padding: 12px 16px;
}

.path {
  margin-bottom: 10px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.path-steps {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.step {
  position: relative;
  padding: 4px 0 4px 18px;
}

.step::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 5px;
  border-left: 1px dashed var(--border-strong);
}

.step::after {
  content: '';
  position: absolute;
  top: 11px;
  left: 2px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border-strong);
}

.step.self::after {
  background: var(--accent);
}

.path-edge {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

/* ---- Dominators -------------------------------------------------------------------------- */

.dominators {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  background: var(--surface);
}

.dominators > .pane {
  flex: 1;
}

.tree {
  flex: 1;
  min-height: 0;
  overflow: auto;
  outline: none;
}

.tree-row {
  min-height: var(--row);
  border-bottom: 1px solid var(--surface-2);
}

.tree-row.selected {
  background: var(--select);
  box-shadow: inset 3px 0 0 var(--accent);
}

.tree-row.more {
  display: flex;
  align-items: center;
}

.twisty {
  width: 18px;
  height: 18px;
  justify-content: center;
  margin-right: 4px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 11px;
}

.twisty:disabled {
  cursor: default;
  opacity: 0.6;
}

.share {
  position: relative;
}

.share-bar {
  position: absolute;
  top: 9px;
  left: 0;
  height: 12px;
  border-radius: 2px;
  background: var(--accent-soft);
  z-index: 0;
}

.share-text {
  position: relative;
  z-index: 1;
}

/* ---- Code ------------------------------------------------------------------------------- */

.code-layout {
  display: grid;
  flex: 1;
  min-height: 0;
  grid-template-columns: 340px minmax(0, 1fr) minmax(320px, 0.6fr);
}

.changes-pane {
  overflow: auto;
  outline: none;
}

.change-file {
  border-bottom: 1px solid var(--border);
}

.file-name {
  position: sticky;
  top: 0;
  padding: 6px 12px;
  background: var(--surface-2);
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  z-index: 1;
}

.change-item {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: 0;
  border-bottom: 1px solid var(--surface-2);
  border-radius: 0;
  background: none;
  color: var(--text);
  font-weight: 400;
  text-align: left;
}

.change-item:hover {
  background: var(--surface-2);
}

.change-item.selected {
  background: var(--select);
  box-shadow: inset 3px 0 0 var(--accent);
}

.change-line {
  display: flex;
  align-items: center;
  gap: 6px;
}

.excerpt {
  margin: 4px 0 2px;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: pre;
}

.change-stats {
  color: var(--muted);
}

.diff-pane {
  overflow: hidden;
}

.diff-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.diff {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-family: var(--mono);
  font-size: 12px;
}

.diff .ln-col {
  width: 48px;
}

.diff td {
  padding: 0 8px;
  vertical-align: top;
  white-space: pre-wrap;
  word-break: break-all;
}

.diff .ln {
  color: var(--faint);
  text-align: right;
  user-select: none;
  background: var(--surface-2);
}

.diff .ln.owned {
  color: var(--accent-text);
  cursor: pointer;
}

.diff .hunk td {
  padding: 3px 8px;
  background: var(--accent-soft);
  color: var(--muted);
}

.diff .code.delete {
  background: var(--del-bg);
}

.diff .code.insert {
  background: var(--ins-bg);
}

.diff .code.delete.hl {
  background: var(--del-hl);
  box-shadow: inset 3px 0 0 var(--grow);
}

.diff .code.insert.hl {
  background: var(--ins-hl);
  box-shadow: inset 3px 0 0 var(--shrink);
}

.diff .empty-side {
  background: var(--surface-2);
}

.sign {
  display: inline-block;
  width: 14px;
  color: var(--faint);
}

.objects-head p {
  margin: 4px 0 0;
}

/* ---- Object matching: counterpart, compare, grown --------------------------------------- */

.counterpart {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  margin: 8px 0 4px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
}

.counterpart.none {
  color: var(--muted);
}

.counterpart-delta {
  font-variant-numeric: tabular-nums;
}

.compare-grid {
  grid-template-columns:
    minmax(80px, 0.8fr) 74px minmax(0, 1.5fr) minmax(0, 1.5fr) 72px 72px
    96px;
}

.status-chip {
  display: inline-block;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 11px;
  line-height: 18px;
}

.status-chip.changed {
  background: var(--warn-soft);
  color: var(--warn);
}

.status-chip.added {
  background: var(--grow-soft);
  color: var(--grow);
}

.status-chip.removed {
  background: var(--shrink-soft);
  color: var(--shrink);
}

.grid-row.status-same {
  color: var(--muted);
}

.tabs-filter {
  margin-left: auto;
}

.pad-x {
  margin: 0;
  padding: 0 12px;
}

.pad-x:empty {
  display: none;
}

.single {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
}

.single .pane {
  flex: 1;
  border-right: 0;
}

.grown-grid {
  grid-template-columns: minmax(0, 2fr) 84px 108px 108px minmax(170px, 1fr);
}

/* ---- Allocation sites --------------------------------------------------------------------- */

.sites-grid {
  grid-template-columns:
    minmax(220px, 3fr) 56px 56px 64px minmax(120px, 1fr) 92px
    minmax(60px, 0.6fr);
}

/* Function name first; the location gives way from its start, so file and line stay visible. */
.site-name {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.site-name .mono {
  flex: 0 1 auto;
  min-width: 3ch;
  overflow: hidden;
  text-overflow: ellipsis;
}

.site-name .badge {
  flex: none;
}

.site-loc {
  flex: 1 1 0;
  min-width: 6ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  direction: rtl;
  text-align: left;
}

.site-loc bdi {
  direction: ltr;
  unicode-bidi: isolate;
}

.chips {
  display: flex;
  gap: 4px;
}

.site-pane {
  overflow: hidden;
}

.site-head {
  padding: 12px 14px 4px;
  flex: none;
}

.site-head .chip {
  align-self: center;
}

.stacks {
  display: grid;
  gap: 8px;
  max-height: 34%;
  padding: 0 14px 10px;
  overflow: auto;
  flex: none;
}

.stacks:empty {
  display: none;
}

.stack-side h4 {
  margin: 6px 0 4px;
  font-size: 12px;
}

.stack {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
}

.stack + .stack {
  margin-top: 4px;
}

.stack summary {
  font-weight: 400;
}

.stack .frames {
  margin: 6px 0 2px;
}

/* ---- Treemap ------------------------------------------------------------------------------ */

.treemap-view {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  background: var(--surface);
}

.treemap-body {
  display: grid;
  flex: 1;
  min-height: 0;
  grid-template-columns: minmax(0, 1fr) 300px;
}

.treemap-main {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  border-right: 1px solid var(--border);
}

.treemap-crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 12px;
}

.treemap-stage {
  position: relative;
  flex: 1;
  min-height: 240px;
  overflow: hidden;
}

.treemap-canvas {
  position: absolute;
  inset: 0;
  display: block;
  outline: none;
  cursor: pointer;
}

.treemap-canvas:focus-visible {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.treemap-status {
  margin: 0;
}

.treemap-tip {
  position: absolute;
  max-width: 260px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 12px;
  pointer-events: none;
  word-break: break-word;
}

.treemap-side {
  min-height: 0;
  padding: 14px;
  overflow: auto;
}

.treemap-side h3 {
  word-break: break-word;
}

.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 12px;
  margin: 10px 0;
  font-variant-numeric: tabular-nums;
}

.facts dt {
  color: var(--muted);
}

.facts dd {
  margin: 0;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 18px;
}

.legend-bar {
  height: 10px;
  border-radius: 3px;
  background: linear-gradient(to right, var(--shrink-bar), var(--surface-3) 50%, var(--grow-bar));
}

.legend-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 2px;
}

/* ---- Responsive -------------------------------------------------------------------------- */

@media (max-width: 1400px) {
  .code-layout {
    grid-template-columns: 280px minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) minmax(0, 0.8fr);
  }

  .code-layout .changes-pane {
    grid-row: span 2;
  }

  .code-layout .objects-pane {
    grid-column: 2;
    border-top: 1px solid var(--border);
  }

  .hide-md {
    display: none;
  }

  .sites-grid {
    grid-template-columns:
      minmax(200px, 3fr) 56px 56px minmax(110px, 1fr) 92px
      minmax(60px, 0.6fr);
  }

  .classes-grid {
    grid-template-columns:
      minmax(140px, 2.2fr) repeat(3, minmax(48px, 0.5fr)) minmax(140px, 1.3fr)
      minmax(66px, 0.62fr) repeat(2, minmax(40px, 0.4fr)) 92px;
  }
}

@media (max-width: 1000px) {
  .split {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1.2fr) minmax(0, 1fr);
  }

  .split .pane {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .inspector-grid {
    grid-template-columns: 1fr;
    overflow: auto;
  }

  .treemap-body {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
  }

  .treemap-main {
    border-right: 0;
  }

  .treemap-side {
    max-height: 30vh;
    border-top: 1px solid var(--border);
  }

  .compare-grid {
    grid-template-columns: minmax(70px, 0.8fr) 68px minmax(0, 1.4fr) minmax(0, 1.4fr) 88px;
  }

  .sites-grid {
    grid-template-columns: minmax(170px, 3fr) 48px 48px minmax(96px, 1fr) minmax(50px, 0.6fr);
  }

  .grown-grid {
    grid-template-columns: minmax(0, 2fr) 96px 96px minmax(140px, 1fr);
  }

  .inspector-main {
    min-height: 60vh;
  }

  .overview-grid {
    grid-template-columns: 1fr;
  }

  .span-2,
  .span-3 {
    grid-column: auto;
  }

  .view-tabs {
    margin-left: 0;
  }

  .hide-sm {
    display: none;
  }

  .classes-grid {
    grid-template-columns:
      minmax(120px, 2fr) repeat(3, minmax(44px, 0.5fr)) minmax(120px, 1.3fr)
      repeat(2, minmax(36px, 0.4fr)) 84px;
  }
}

@media (max-width: 700px) {
  .brand-name,
  .analysis-name {
    display: none;
  }

  .code-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    overflow: auto;
  }

  .code-layout .changes-pane,
  .code-layout .objects-pane {
    grid-row: auto;
    grid-column: auto;
    max-height: 60vh;
  }

  input.search {
    width: 100%;
  }
}

/* ---- Accessibility ------------------------------------------------------------------------ */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 100;
  transform: translateY(-200%);
}

.skip-link:focus-visible {
  transform: none;
}

/* Lists and the tree draw their selection; when they hold the focus, show a ring as well. */
.vl:focus-visible,
.tree:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.rgraph a:focus-visible {
  outline: none;
}

.rgraph a:focus-visible rect {
  stroke: var(--accent);
  stroke-width: 3;
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}

/* ---- Grids: sticky header inside the scrolling list ---------------------------------------- */

.vl-head {
  position: sticky;
  top: 0;
  z-index: 2;
}

.vl.has-head .vl-status {
  top: 40px;
}

:where(.grid-head [role='columnheader']) {
  display: flex;
  min-width: 0;
  overflow: hidden;
}

:where(.grid-head [role='columnheader'].num) {
  justify-content: flex-end;
}

.grid-head [role='columnheader'] > button {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- Jumps from a class: grown objects, allocation sites ------------------------------------ */

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
}

.row-actions .jump {
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--accent-text);
  font-size: 11px;
  line-height: 18px;
  opacity: 0;
}

.vl-row:hover .row-actions .jump,
.vl-row.selected .row-actions .jump {
  opacity: 1;
}

.row-actions .jump:hover {
  background: var(--accent-soft);
  text-decoration: none;
}

.pane-title .jump {
  margin-left: 8px;
  font-size: 12px;
  font-weight: 500;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 260px;
  padding: 1px 2px 1px 8px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent-soft);
  font-size: 12px;
}

.filter-chip .mono {
  overflow: hidden;
  color: var(--accent-text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip-remove {
  min-width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--accent-text);
  font-size: 14px;
  justify-content: center;
}

.chip-remove:hover {
  background: var(--surface);
}

.class-count {
  margin-left: 6px;
}

/* ---- Overview: object identity --------------------------------------------------------------- */

.id-bars {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 6px 10px;
  margin-bottom: 12px;
}

.id-bar {
  display: flex;
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-3);
}

.id-seg {
  flex-basis: 0;
  min-width: 0;
}

.id-seg.matched {
  background: var(--mod-bar);
}

.id-seg.only.grow {
  background: var(--grow-bar);
}

.id-seg.only.shrink {
  background: var(--shrink-bar);
}

/* ---- Command palette ------------------------------------------------------------------------- */

.palette-open {
  gap: 8px;
  padding: 4px 8px 4px 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--muted);
}

.palette-open:hover {
  color: var(--text);
}

.palette-open kbd {
  color: var(--muted);
}

.palette {
  width: min(640px, calc(100vw - 32px));
  margin-top: 12vh;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 50px rgb(0 0 0 / 30%);
}

.palette::backdrop {
  background: rgb(8 10 16 / 45%);
}

.palette-box {
  display: flex;
  flex-direction: column;
}

.palette-input {
  width: 100%;
  padding: 14px 16px;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 12px 12px 0 0;
  background: none;
  font-size: 15px;
}

.palette-input:focus-visible {
  outline: none;
  box-shadow: inset 0 -2px 0 var(--accent);
}

.palette-status {
  margin: 0;
  padding: 6px 16px 0;
}

.palette-list {
  max-height: min(52vh, 440px);
  margin: 0;
  padding: 6px;
  overflow: auto;
  list-style: none;
}

.palette-option {
  display: grid;
  grid-template-columns: 64px minmax(0, auto) minmax(0, 1fr);
  align-items: baseline;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.palette-option.active {
  background: var(--select);
  box-shadow: inset 3px 0 0 var(--accent);
}

.palette-kind {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.palette-kind.kind-object,
.palette-kind.kind-class {
  color: var(--accent-text);
}

.palette-kind.kind-site,
.palette-kind.kind-change {
  color: var(--grow);
}

.palette-title {
  overflow: hidden;
  font-family: var(--mono);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.palette-detail {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.palette-hint {
  margin: 0;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
}

/* ---- Inspector: tabs and the retainer graph ------------------------------------------------- */

.tab-list {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}

.tab-extras {
  display: flex;
  margin-left: auto;
}

.tab-extras input.search {
  margin-block: 4px;
}

.rgraph-card {
  margin-bottom: 16px;
}

.rgraph-scroll {
  max-height: 520px;
  overflow: auto;
}

.rgraph {
  display: block;
  margin-inline: auto;
  font-family: var(--sans);
}

.rgraph-details > summary {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  list-style: none;
}

.rgraph-details > summary::-webkit-details-marker {
  display: none;
}

.rgraph-details > summary::before {
  content: '▸';
  color: var(--muted);
  font-size: 11px;
}

.rgraph-details[open] > summary::before {
  content: '▾';
}

.rgraph-details > summary h3 {
  margin: 0;
}

.rgraph-body {
  margin-top: 8px;
}

.rgraph-notes {
  margin-top: 6px;
}

.rgraph-node.collapsed {
  cursor: pointer;
}

.rgraph-node.collapsed rect {
  fill: var(--surface);
  stroke: var(--border-strong);
  stroke-dasharray: 4 3;
}

.rgraph-node.collapsed:hover rect,
.rgraph-node.collapsed:focus-visible rect {
  fill: var(--accent-soft);
  stroke: var(--accent);
}

.rgraph-node.collapsed:focus-visible {
  outline: none;
}

.rgraph-node rect {
  fill: var(--surface-2);
  stroke: var(--border-strong);
  stroke-width: 1;
}

.rgraph a.rgraph-node {
  cursor: pointer;
}

.rgraph a.rgraph-node:hover rect {
  fill: var(--accent-soft);
  stroke: var(--accent);
}

.rgraph-node.self rect {
  fill: var(--accent-soft);
  stroke: var(--accent);
  stroke-width: 2;
}

.rgraph-node.grow rect {
  stroke: var(--grow);
}

.rgraph-node.shrink rect {
  stroke: var(--shrink);
}

.rgraph-name {
  fill: var(--text);
  font-size: 11px;
  font-weight: 600;
}

.rgraph-meta {
  fill: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
}

.rgraph-edge path {
  fill: none;
  stroke: var(--border-strong);
  stroke-width: 1.4;
}

.rgraph-edge.edge-weak path {
  stroke-dasharray: 3 3;
}

.rgraph-arrow {
  fill: var(--muted);
}

.rgraph-edge-label {
  fill: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  paint-order: stroke;
  stroke: var(--surface);
  stroke-width: 3px;
}

/* ---- Narrow windows (down to ~900 px) -------------------------------------------------------- */

@media (max-width: 1200px) {
  .analysis-name {
    max-width: 150px;
  }

  .palette-open kbd {
    display: none;
  }
}

@media (max-width: 1000px) {
  .topbar {
    gap: 6px;
    padding: 0 8px;
  }

  .brand-name {
    display: none;
  }

  .view-tab {
    padding: 6px 7px;
  }

  .palette-open {
    padding: 4px 8px;
  }

  .palette-label {
    display: none;
  }

  .toolbar-note {
    margin-left: 0;
  }

  .rgraph-scroll {
    max-height: none;
  }

  .inspector-side {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0 20px;
    border-top: 1px solid var(--border);
  }

  .view:focus {
    outline: none;
  }

  .row-actions .jump {
    opacity: 1;
  }
}

/* ---- Home: memory budget -------------------------------------------------------------------- */

.storage {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
}

.storage-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.storage-head .section-label {
  margin: 0;
}

.storage-bar {
  display: flex;
  height: 12px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--surface-3);
}

.storage-seg {
  height: 100%;
  min-width: 2px;
  background: var(--mod-bar);
  border-right: 2px solid var(--surface);
}

.storage-seg.next {
  background: var(--warn);
}

.storage-seg.running {
  background-image: repeating-linear-gradient(
    45deg,
    transparent 0 4px,
    rgb(255 255 255 / 25%) 4px 8px
  );
}

.storage-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.storage-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.storage-list .num {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

.storage-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--mod-bar);
}

.storage-swatch.next {
  background: var(--warn);
}

.storage p {
  margin: 0;
}

.card-memory {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

/* ---- Code: files of a multi-file diff ------------------------------------------------------- */

.ftree-card {
  border-bottom: 1px solid var(--border);
}

.ftree-card > summary {
  cursor: pointer;
}

.ftree {
  display: flex;
  flex-direction: column;
  max-height: 38vh;
  overflow: auto;
  padding-bottom: 6px;
}

.ftree-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px 42px 74px;
  align-items: center;
  gap: 4px;
  min-height: 24px;
  padding-right: 10px;
  font-size: 12px;
}

.ftree-row:hover {
  background: var(--surface-2);
}

.ftree-head {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.ftree-sort {
  padding: 4px 2px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  cursor: pointer;
}

.ftree-sort.num {
  text-align: right;
}

.ftree-sort:first-child {
  padding-left: 12px;
}

.ftree-sort.on {
  color: var(--accent-text);
}

.ftree-name {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}

.ftree-name .mono,
.ftree-name .link {
  overflow: hidden;
  text-overflow: ellipsis;
}

.ftree-dir .ftree-name {
  color: var(--muted);
  font-weight: 600;
}

.ftree-toggle {
  flex: none;
  width: 16px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
}

.ftree-bar {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ftree-hunk {
  grid-template-columns: minmax(0, 1fr) auto;
}

.ftree-hunk .ftree-name {
  justify-content: flex-start;
  border: 0;
  background: none;
  color: var(--accent-text);
  text-align: left;
  cursor: pointer;
}

.ftree-hunk .ftree-name:disabled {
  color: var(--muted);
  cursor: default;
}

.ftree-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.chip.change.on {
  background: var(--accent);
  color: var(--on-accent);
}

/* ---- Findings: pin dialog and panel ------------------------------------------------------- */

.findings-open {
  gap: 6px;
  padding: 4px 10px;
}

.pin-button {
  align-self: center;
  padding: 2px 10px;
  font-size: 12px;
}

.findings-pin form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.findings-pin h2 {
  margin: 0;
  font-size: 16px;
  overflow-wrap: anywhere;
}

.findings-pin p {
  margin: 0;
}

.finding-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-weight: 600;
}

.finding-note {
  width: 100%;
  min-height: 64px;
  padding: 6px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 400;
  resize: vertical;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.findings-panel {
  width: min(560px, 100vw);
  max-width: 100vw;
  height: 100vh;
  max-height: 100vh;
  margin: 0 0 0 auto;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  box-shadow: -10px 0 40px rgb(0 0 0 / 25%);
}

.findings-panel::backdrop {
  background: rgb(8 10 16 / 35%);
}

.findings-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.findings-head h2 {
  margin: 0;
  font-size: 16px;
}

.findings-panel > [role='status'] {
  margin: 10px 16px 0;
}

.findings-list {
  padding: 10px 16px 24px;
}

.findings-items {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.finding {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
}

.finding-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.finding-facts {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.finding-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.finding-actions .tiny {
  margin-left: auto;
}

@media (max-width: 1000px) {
  .findings-label {
    display: none;
  }
}

/* ---- Busy indicator (a run or a re-linking in a worker) ----------------------------------- */

.busy-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 1px 9px 1px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.spinner {
  width: 10px;
  height: 10px;
  border: 2px solid currentcolor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation: none;
    border-right-color: currentcolor;
    opacity: 0.6;
  }
}

/* ---- Explain this leak --------------------------------------------------------------------- */

.explain {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
}

.explain-head {
  padding: 12px 16px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.explain-head h1 {
  margin: 0 0 2px;
  font-size: 20px;
}

.explain-head p {
  margin: 2px 0;
  max-width: 980px;
}

.explain-body {
  display: grid;
  flex: 1;
  min-height: 0;
  grid-template-columns: minmax(280px, 0.9fr) minmax(0, 1.6fr);
}

.suspects {
  display: flex;
  min-height: 0;
  flex-direction: column;
  overflow: auto;
  border-right: 1px solid var(--border);
  background: var(--surface);
  outline: none;
}

.suspects.compact {
  overflow: visible;
  border: 0;
  margin-top: 8px;
}

.suspect {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 2px 8px;
  align-items: baseline;
  padding: 8px 12px;
  border-bottom: 1px solid var(--surface-2);
  color: inherit;
  text-decoration: none;
}

.suspect:hover {
  background: var(--surface-2);
}

.suspect.selected {
  background: var(--select);
  box-shadow: inset 3px 0 0 var(--accent);
}

.suspect.compact {
  grid-template-columns: 110px minmax(0, 2fr) minmax(150px, 1fr) minmax(0, 1fr);
  align-items: center;
  border: 0;
  border-radius: 6px;
}

.suspects:focus-visible .suspect.selected {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.suspect-title {
  overflow: hidden;
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suspect-growth {
  grid-column: 2;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.suspect-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  grid-column: 2;
}

.suspect.compact .suspect-growth,
.suspect.compact .suspect-links {
  grid-column: auto;
}

.badge.kind-object {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.badge.kind-class {
  background: var(--surface-3);
  color: var(--text);
}

.badge.kind-site {
  background: var(--warn-soft);
  color: var(--warn);
}

.trail-pane {
  min-height: 0;
  overflow: auto;
  padding: 4px 18px 40px;
}

.trail-step {
  position: relative;
  margin: 12px 0;
  padding: 10px 14px 12px 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.trail-step + .trail-step::before {
  content: '';
  position: absolute;
  top: -13px;
  left: 25px;
  height: 12px;
  border-left: 2px solid var(--border-strong);
}

.trail-step.current {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.trail-step h3 {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 0 0 8px;
  font-size: 14px;
}

.step-number {
  position: absolute;
  top: 9px;
  left: 12px;
  display: inline-grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.step-hint {
  font-weight: 400;
}

.trail-facts {
  display: grid;
  grid-template-columns: repeat(3, auto);
  justify-content: start;
  gap: 0 24px;
  margin: 6px 0 10px;
}

.trail-facts dt {
  grid-row: 1;
  color: var(--muted);
  font-size: 11px;
}

.trail-facts dd {
  grid-row: 2;
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.chain {
  margin: 8px 0 10px;
  padding: 0;
  list-style: none;
}

.chain-step {
  position: relative;
  padding: 3px 0 3px 18px;
}

.chain-step::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 5px;
  border-left: 1px solid var(--border-strong);
}

.chain-step::after {
  content: '';
  position: absolute;
  top: 10px;
  left: 2px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border-strong);
}

.chain-step.self::after {
  background: var(--grow-bar);
}

.chain-step.suspect-here {
  background: var(--accent-soft);
  border-radius: 4px;
}

.chain-step.suspect-here::after {
  background: var(--accent);
}

.chain-node {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 6px;
}

.chain-size {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

.chain-edge {
  display: block;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
}

.trail-hunk {
  max-height: 340px;
  margin: 6px 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.chip.change.on {
  background: var(--accent);
  color: var(--on-accent);
}

.explain-card .suspects {
  margin-top: 4px;
}

/* ---- Subtree side by side ------------------------------------------------------------------ */

.subtree {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  background: var(--surface);
}

.subtree > .pane {
  flex: 1;
}

.subtree-head {
  display: grid;
  gap: 6px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.subtree-head .node-title {
  margin: 0;
  font-size: 18px;
}

.subtree-grid {
  grid-template-columns: minmax(0, 1.5fr) 84px minmax(150px, 0.9fr) minmax(0, 1.2fr) 84px;
}

.twisty-cell {
  display: flex;
  align-items: center;
  gap: 4px;
}

.status-chip.grow {
  background: var(--grow-soft);
  color: var(--grow);
}

.status-chip.shrink {
  background: var(--shrink-soft);
  color: var(--shrink);
}

.cell.elsewhere {
  opacity: 0.6;
  font-style: italic;
}

.grid-row.status-added,
.grid-row.status-moved-in {
  background: linear-gradient(90deg, transparent 55%, var(--grow-soft));
}

.grid-row.status-removed,
.grid-row.status-moved-out {
  background: linear-gradient(90deg, var(--shrink-soft), transparent 45%);
}

.grid-row.selected {
  background: var(--select);
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

@media (max-width: 1000px) {
  .explain-body {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 0.8fr) minmax(0, 1.4fr);
  }

  .suspects {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .suspect.compact {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .suspect.compact .suspect-growth,
  .suspect.compact .suspect-links {
    grid-column: 2;
  }

  .subtree-grid {
    grid-template-columns: minmax(0, 1.4fr) 72px minmax(110px, 0.8fr) minmax(0, 1fr) 72px;
  }
}

.suspect > .badge {
  justify-self: start;
}

.storage-seg.transient {
  background: repeating-linear-gradient(135deg, var(--accent-soft) 0 5px, var(--accent) 5px 7px);
}
