/* Canopy viewer in the Blockwerk design: dark, monochrome, calm. Colour is kept
   for states. The tokens below are copied unchanged from the design's
   globals.css, everything after them is derived from those tokens. */

@font-face { font-family: "Geist"; src: url("fonts/Geist-Variable.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url("fonts/GeistMono-Variable.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

:root {
  color-scheme: light;
  --radius: 0.75rem;
  --background: oklch(0.985 0.001 286.375);
  --foreground: oklch(0.141 0.005 285.823);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.141 0.005 285.823);
  --popover: oklch(1 0 0);
  --popover-foreground: oklch(0.141 0.005 285.823);
  --primary: oklch(0.21 0.006 285.885);
  --primary-foreground: oklch(0.985 0 0);
  --secondary: oklch(0.967 0.001 286.375);
  --secondary-foreground: oklch(0.21 0.006 285.885);
  --muted: oklch(0.967 0.001 286.375);
  --muted-foreground: oklch(0.552 0.016 285.938);
  --accent: oklch(0.967 0.001 286.375);
  --accent-foreground: oklch(0.21 0.006 285.885);
  --destructive: oklch(0.577 0.245 27.325);
  --success: oklch(0.627 0.17 149.214);
  --warning: oklch(0.705 0.16 70.08);
  --border: oklch(0.92 0.004 286.32);
  --input: oklch(0.92 0.004 286.32);
  --ring: oklch(0.705 0.015 286.067);
  --chart-1: oklch(0.87 0 0);
  --chart-2: oklch(0.556 0 0);
  --chart-3: oklch(0.439 0 0);
  --chart-4: oklch(0.371 0 0);
  --chart-5: oklch(0.269 0 0);
  --sidebar: oklch(0.955 0.002 286.32);
  --sidebar-foreground: oklch(0.141 0.005 285.823);
  --sidebar-primary: oklch(0.21 0.006 285.885);
  --sidebar-primary-foreground: oklch(0.985 0 0);
  --sidebar-accent: oklch(0.92 0.004 286.32);
  --sidebar-accent-foreground: oklch(0.21 0.006 285.885);
  --sidebar-border: oklch(0.92 0.004 286.32);
  --sidebar-ring: oklch(0.705 0.015 286.067);
}

.dark {
  color-scheme: dark;
  --background: oklch(0.141 0.005 285.823);
  --foreground: oklch(0.985 0 0);
  --card: oklch(0.185 0.006 285.885);
  --card-foreground: oklch(0.985 0 0);
  --popover: oklch(0.21 0.006 285.885);
  --popover-foreground: oklch(0.985 0 0);
  --primary: oklch(0.985 0 0);
  --primary-foreground: oklch(0.21 0.006 285.885);
  --secondary: oklch(0.274 0.006 286.033);
  --secondary-foreground: oklch(0.985 0 0);
  --muted: oklch(0.274 0.006 286.033);
  --muted-foreground: oklch(0.705 0.015 286.067);
  --accent: oklch(0.274 0.006 286.033);
  --accent-foreground: oklch(0.985 0 0);
  --destructive: oklch(0.704 0.191 22.216);
  --success: oklch(0.765 0.177 163.223);
  --warning: oklch(0.828 0.189 84.429);
  --border: oklch(1 0 0 / 9%);
  --input: oklch(1 0 0 / 14%);
  --ring: oklch(0.552 0.016 285.938);
  --chart-1: oklch(0.87 0 0);
  --chart-2: oklch(0.556 0 0);
  --chart-3: oklch(0.439 0 0);
  --chart-4: oklch(0.371 0 0);
  --chart-5: oklch(0.269 0 0);
  --sidebar: oklch(0.115 0.004 285.823);
  --sidebar-foreground: oklch(0.985 0 0);
  --sidebar-primary: oklch(0.985 0 0);
  --sidebar-primary-foreground: oklch(0.21 0.006 285.885);
  --sidebar-accent: oklch(0.21 0.006 285.885);
  --sidebar-accent-foreground: oklch(0.985 0 0);
  --sidebar-border: oklch(1 0 0 / 9%);
  --sidebar-ring: oklch(0.552 0.016 285.938);
}

/* Derived tokens */

:root {
  --radius-md: calc(var(--radius) * 0.8);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) * 1.4);

  --font-sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-geist-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --success-soft: color-mix(in oklch, var(--success) 12%, transparent);
  --warning-soft: color-mix(in oklch, var(--warning) 12%, transparent);
  --destructive-soft: color-mix(in oklch, var(--destructive) 10%, transparent);
  --muted-soft: color-mix(in oklch, var(--muted) 50%, transparent);
  --muted-strong: color-mix(in oklch, var(--muted) 60%, transparent);
  --card-ring: color-mix(in oklch, var(--foreground) 10%, transparent);
  --scrim: oklch(0 0 0 / 50%);

  /* State colours as text. The light tokens are too pale to read on white. */
  --success-text: color-mix(in oklch, var(--success) 72%, black);
  --warning-text: color-mix(in oklch, var(--warning) 62%, black);
  --destructive-text: var(--destructive);

  --field: transparent;
  --tab-active: var(--background);
  --tab-active-border: transparent;

  /* Marks of charts, meters and sparklines. */
  --meter: var(--chart-2);
  --series-1: var(--chart-4);
  --series-2: var(--chart-2);
  --spark: var(--muted-foreground);
  --match: var(--warning);
  --match-ink: oklch(0.21 0.006 285.885);

  /* Flamegraph: the origin of a frame is a band of grey. */
  --flame-plugin-1: oklch(0.36 0.006 286); --flame-plugin-2: oklch(0.39 0.006 286); --flame-plugin-3: oklch(0.42 0.006 286); --flame-plugin-4: oklch(0.45 0.006 286);
  --flame-other-1: oklch(0.66 0.006 286); --flame-other-2: oklch(0.68 0.006 286); --flame-other-3: oklch(0.70 0.006 286); --flame-other-4: oklch(0.72 0.006 286);
  --flame-server-1: oklch(0.79 0.005 286); --flame-server-2: oklch(0.81 0.005 286); --flame-server-3: oklch(0.83 0.005 286); --flame-server-4: oklch(0.85 0.005 286);
  --flame-runtime-1: oklch(0.90 0.003 286); --flame-runtime-2: oklch(0.915 0.003 286); --flame-runtime-3: oklch(0.93 0.003 286); --flame-runtime-4: oklch(0.945 0.003 286);
  --flame-plugin-ink: oklch(0.985 0 0);
  --flame-other-ink: oklch(0.141 0.005 285.823);
  --flame-server-ink: oklch(0.141 0.005 285.823);
  --flame-runtime-ink: oklch(0.141 0.005 285.823);

  --row-tree: 28px;
  --row-region: 66px;
  --row-flame: 20px;
  --row-hotspot: 48px;
  --tree-indent: 14px;
}

.dark {
  --success-text: var(--success);
  --warning-text: var(--warning);

  --field: color-mix(in oklch, var(--input) 30%, transparent);
  --tab-active: color-mix(in oklch, var(--input) 30%, transparent);
  --tab-active-border: var(--input);

  --series-1: var(--chart-1);
  --series-2: var(--chart-2);

  --flame-runtime-1: oklch(0.29 0.006 286); --flame-runtime-2: oklch(0.31 0.006 286); --flame-runtime-3: oklch(0.33 0.006 286); --flame-runtime-4: oklch(0.35 0.006 286);
  --flame-server-1: oklch(0.40 0.006 286); --flame-server-2: oklch(0.425 0.006 286); --flame-server-3: oklch(0.45 0.006 286); --flame-server-4: oklch(0.475 0.006 286);
  --flame-other-1: oklch(0.62 0.006 286); --flame-other-2: oklch(0.64 0.006 286); --flame-other-3: oklch(0.66 0.006 286); --flame-other-4: oklch(0.68 0.006 286);
  --flame-plugin-1: oklch(0.78 0.005 286); --flame-plugin-2: oklch(0.81 0.005 286); --flame-plugin-3: oklch(0.84 0.005 286); --flame-plugin-4: oklch(0.87 0.005 286);
  --flame-plugin-ink: oklch(0.141 0.005 285.823);
  --flame-other-ink: oklch(0.141 0.005 285.823);
  --flame-server-ink: oklch(0.985 0 0);
  --flame-runtime-ink: oklch(0.985 0 0);
}

/* Base */

* { box-sizing: border-box; border-color: var(--border); }
[hidden] { display: none !important; }

html { height: 100%; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  min-height: 100%;
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font: 400 0.875rem/1.5 var(--font-sans);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, p, dl, dd, ol, figure { margin: 0; padding: 0; }
ol { list-style: none; }
a { color: inherit; }
button, input { color: inherit; font: inherit; font-variant-numeric: inherit; }
button:not(:disabled) { cursor: pointer; }
code, .mono { font-family: var(--font-geist-mono); }
mark { border-radius: 2px; background: var(--match); color: var(--match-ink); }

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

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

.icon {
  flex: none;
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-moon { display: block; }
.icon-sun { display: none; }
.dark .icon-moon { display: none; }
.dark .icon-sun { display: block; }

/* Controls */

.btn {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 2.25rem;
  padding: 0 0.875rem;
  border: 1px solid var(--input);
  border-radius: var(--radius-lg);
  background: var(--field);
  color: var(--foreground);
  font-weight: 500;
  font-size: 0.875rem;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover:not(:disabled) { background: var(--muted); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { border-color: transparent; background: var(--primary); color: var(--primary-foreground); }
.btn-primary:hover:not(:disabled) { background: color-mix(in oklch, var(--primary) 80%, transparent); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--muted-soft); }
.btn-square { width: 2.25rem; padding: 0; }
.btn-icon { width: 2.25rem; padding: 0; }

.field {
  height: 2.25rem;
  min-width: 0;
  padding: 0 0.75rem;
  border: 1px solid var(--input);
  border-radius: var(--radius-lg);
  background: var(--field);
  color: var(--foreground);
  font-size: 0.875rem;
  transition: border-color 0.15s;
}
.field::placeholder { color: var(--muted-foreground); opacity: 1; }
.field:focus { outline: none; border-color: var(--ring); }

.chip {
  max-width: 16rem;
  height: 1.75rem;
  padding: 0 0.75rem;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: var(--muted);
  color: var(--foreground);
  font-weight: 500;
  font-size: 0.75rem;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background-color 0.15s;
}
.chip:hover { background: var(--input); }

.pill {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 0.375rem;
  padding: 0.125rem 0.625rem;
  border-radius: 999px;
  background: var(--muted);
  font-weight: 500;
  font-size: 0.75rem;
  white-space: nowrap;
}
.pill::before { width: 0.375rem; height: 0.375rem; border-radius: 50%; background: currentColor; content: ""; }
.pill-ok { background: var(--success-soft); color: var(--success-text); }
.pill-warn { background: var(--warning-soft); color: var(--warning-text); }
.pill-crit { background: var(--destructive-soft); color: var(--destructive-text); }
.pill-live::before { animation: canopy-pulse 1.6s ease-in-out infinite; }
.live-age { color: var(--muted-foreground); font-size: 0.8125rem; font-variant-numeric: tabular-nums; white-space: nowrap; }

.badge {
  display: inline-block;
  flex: none;
  max-width: 9rem;
  overflow: hidden;
  padding: 0 0.5rem;
  border-radius: 999px;
  background: var(--muted);
  color: var(--muted-foreground);
  font: 500 0.6875rem/1.125rem var(--font-sans);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.swatch { display: inline-block; flex: none; width: 0.625rem; height: 0.625rem; border-radius: 3px; }
.swatch-server { background: var(--flame-server-3); }
.swatch-plugin { background: var(--flame-plugin-3); }
.swatch-runtime { background: var(--flame-runtime-3); }
.swatch-other { background: var(--flame-other-3); }

.card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--card-ring);
  border-radius: var(--radius-xl);
  background: var(--card);
  color: var(--card-foreground);
}

.hint {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-xl);
  background: var(--muted-strong);
  color: var(--muted-foreground);
}
.hint .icon { margin-top: 0.125rem; }
.hint-warning { background: var(--warning-soft); color: var(--warning-text); }
.hint-destructive { background: var(--destructive-soft); color: var(--destructive-text); }

.brand {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 0.5rem;
  min-height: 2rem;
  color: var(--foreground);
  font-weight: 600;
  font-size: 0.9375rem;
  letter-spacing: -0.01em;
  text-decoration: none;
}
.brand svg { display: block; width: 1.375rem; height: 1.375rem; }

.legal { display: flex; flex: none; gap: 1rem; }
.legal a { color: var(--muted-foreground); text-underline-offset: 3px; transition: color 0.15s; }
.legal a:hover { color: var(--foreground); }

/* Panel shell */

.shell {
  display: grid;
  grid-template-columns: 18rem minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}
.shell.is-collapsed { grid-template-columns: minmax(0, 1fr); }
.shell.is-collapsed .regions { display: none; }

.inset { display: flex; flex-direction: column; min-width: 0; min-height: 100vh; min-height: 100dvh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  height: 3.5rem;
  padding: 0 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--background);
}
.crumbs { display: flex; flex: 1 1 auto; align-items: center; gap: 0.375rem; min-width: 0; color: var(--muted-foreground); }
.crumbs a { padding: 0.25rem 0; text-decoration: none; transition: color 0.15s; }
.crumbs a:hover { color: var(--foreground); }
.crumbs .icon { width: 0.875rem; height: 0.875rem; }
.crumbs [aria-current] { color: var(--foreground); }

.content {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
  padding: 1.25rem 1.5rem 1.5rem;
}

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem 1rem; }
.page-title { flex: 1 1 0; min-width: 0; }
.page-title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.75rem; }
.page-title h1 { min-width: 0; font-weight: 600; font-size: 1.875rem; line-height: 2.25rem; letter-spacing: -0.025em; overflow-wrap: anywhere; }
.page-title h1 .mono { font-weight: 500; font-size: 0.86em; letter-spacing: -0.03em; }
.page-actions { display: flex; flex: none; flex-wrap: wrap; gap: 0.5rem; }

.facts { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; margin-top: 0.5rem; }
.facts > div { display: flex; gap: 0.375rem; min-width: 0; max-width: 100%; }
.facts dt { flex: none; color: var(--muted-foreground); white-space: nowrap; }
.facts dd { min-width: 0; max-width: 20rem; overflow: hidden; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }

/* Stat cards */

.stats { display: grid; grid-template-columns: repeat(20, minmax(0, 1fr)); gap: 0.75rem; }
.stat {
  display: grid;
  grid-column: span 4;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas: "head head" "value spark" "note note";
  align-items: center;
  column-gap: 0.75rem;
  min-width: 0;
  padding: 0.625rem 0.875rem;
  overflow: hidden;
  border: 1px solid var(--card-ring);
  border-radius: var(--radius-xl);
  background: var(--card);
  color: var(--card-foreground);
  text-align: left;
  transition: background-color 0.15s;
}
.stat:nth-child(-n+4) { grid-column: span 5; }
button.stat:hover { background: color-mix(in oklch, var(--card), var(--foreground) 3%); }
.stat-head { display: flex; grid-area: head; align-items: center; justify-content: space-between; gap: 0.5rem; min-width: 0; min-height: 1.25rem; }
.stat-label { min-width: 0; overflow: hidden; color: var(--muted-foreground); font-size: 0.8125rem; text-overflow: ellipsis; white-space: nowrap; }
.stat-value {
  grid-area: value;
  min-width: 0;
  overflow: hidden;
  font-weight: 600;
  font-size: 1.375rem;
  line-height: 1.875rem;
  letter-spacing: -0.025em;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stat-spark { display: block; grid-area: spark; width: 100%; height: 1.75rem; }
.stat-note {
  grid-area: note;
  min-width: 0;
  overflow: hidden;
  color: var(--muted-foreground);
  font-size: 0.75rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stat .pill { padding: 0 0.5rem; font-size: 0.6875rem; line-height: 1.125rem; }
.stat-loading .stat-value { color: var(--muted-foreground); animation: canopy-pulse 2s ease-in-out infinite; }

/* Sidebar */

.region-switch { display: none; }
.scrim { display: none; }

.regions {
  position: sticky;
  top: 0;
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  border-right: 1px solid var(--sidebar-border);
  background: var(--sidebar);
  color: var(--sidebar-foreground);
}
.regions-brand { display: flex; align-items: center; justify-content: space-between; height: 3.5rem; padding: 0 1rem; }
.regions-close { display: none; }
.regions-head { display: flex; align-items: center; justify-content: space-between; padding: 0.25rem 1rem 0.5rem; color: var(--muted-foreground); font-size: 0.75rem; }
.regions-head h2 { font-weight: 500; font-size: 0.75rem; }
.regions > .field { margin: 0 0.75rem 0.5rem; }
.regions-fixed { display: grid; gap: 2px; padding: 0 0.5rem 0.5rem; border-bottom: 1px solid var(--sidebar-border); }

.region {
  position: relative;
  display: block;
  width: 100%;
  padding: 0.4375rem 0.5rem;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s;
}
.region:hover, .region.is-selected { background: var(--sidebar-accent); color: var(--sidebar-accent-foreground); }
.regions-list:focus-visible .region.is-cursor { outline: 1px solid var(--sidebar-ring); outline-offset: -1px; }
.region-fixed .region-world { font: 500 0.875rem var(--font-sans); }
.region-fixed .region-stats { font-size: 0.75rem; }
.region-head { display: flex; align-items: baseline; gap: 0.375rem; min-width: 0; }
.region-id { flex: none; color: var(--muted-foreground); font-size: 0.75rem; }
.region-world {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  font: 400 0.8125rem var(--font-geist-mono);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.region-share { flex: none; margin-left: auto; font-weight: 500; font-size: 0.8125rem; }
.region-stats { display: flex; gap: 0.625rem; margin-top: 1px; color: var(--muted-foreground); font-size: 0.75rem; line-height: 1.125rem; }
.region-stat.is-bad { color: var(--destructive-text); }
.region-chunk { margin-left: auto; font-family: var(--font-geist-mono); font-size: 0.6875rem; }
.share-track { height: 2px; margin-top: 0.3125rem; border-radius: 999px; background: var(--muted); }
.share-track i { display: block; height: 100%; border-radius: 999px; background: var(--meter); }

.vlist { position: relative; overflow: auto; scrollbar-width: thin; scrollbar-color: var(--input) transparent; }
.vlist-inner { position: relative; }
.vlist-layer { position: sticky; top: 0; height: 0; }
.vlist-layer > * { position: absolute; top: 0; right: 0; left: 0; }
.vlist.is-empty::after {
  display: block;
  padding: 1.5rem 1rem;
  color: var(--muted-foreground);
  content: attr(data-empty);
  text-align: center;
}
.regions-list { overscroll-behavior: contain; }
.regions-list .vlist-layer > .region { right: 0.5rem; left: 0.5rem; width: auto; height: calc(var(--row-region) - 2px); }
.regions-list:focus-visible { outline-offset: -2px; }

/* Tabs and panes */

.tabs-wrap {
  position: sticky;
  top: 3.5rem;
  z-index: 10;
  flex: none;
  margin: -0.25rem -0.25rem 0;
  padding: 0.25rem;
  overflow-x: auto;
  background: var(--background);
  scrollbar-width: none;
}
.tabs-wrap::-webkit-scrollbar { display: none; }
.tabs {
  display: inline-flex;
  gap: 2px;
  width: max-content;
  height: 2.5rem;
  padding: 0.25rem;
  border-radius: var(--radius-lg);
  background: var(--muted);
}
.tabs button {
  flex: none;
  height: 100%;
  padding: 0 0.875rem;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: none;
  color: var(--muted-foreground);
  font-weight: 500;
  font-size: 0.875rem;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.tabs button:hover { color: var(--foreground); }
.tabs button[aria-selected="true"] { border-color: var(--tab-active-border); background: var(--tab-active); color: var(--foreground); }

.pane { min-width: 0; }
.pane-fill {
  display: flex;
  flex: 1 1 24rem;
  flex-direction: column;
  min-height: 24rem;
  overflow: hidden;
  border: 1px solid var(--card-ring);
  border-radius: var(--radius-xl);
  background: var(--card);
}

.toolbar {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
.toolbar .btn { height: 2rem; padding: 0 0.75rem; border-radius: var(--radius-md); font-size: 0.8125rem; }
.toolbar .btn-icon { width: 2rem; padding: 0; }
.toolbar .field { height: 2rem; border-radius: var(--radius-md); font-size: 0.8125rem; }
.toolbar-search { flex: 0 1 18rem; min-width: 7.5rem; }
.toolbar-count { color: var(--muted-foreground); font-size: 0.75rem; white-space: nowrap; }
.toolbar-spacer { flex: 1 1 0; }

/* Call tree */

.thead, .trow {
  display: grid;
  grid-template-columns: 56px 72px 88px minmax(0, 1fr);
  align-items: center;
  column-gap: 0.75rem;
  padding: 0 0.875rem;
}
.thead {
  flex: none;
  height: 2rem;
  border-bottom: 1px solid var(--border);
  color: var(--muted-foreground);
  font-size: 0.75rem;
}
.thead > :first-child, .thead-ms { text-align: right; }
.tlist { flex: 1 1 auto; min-height: 0; }
.tlist:focus-visible { outline-offset: -2px; border-radius: 0 0 var(--radius-xl) var(--radius-xl); }

.trow {
  height: var(--row-tree);
  font-size: 0.8125rem;
  cursor: pointer;
  transition: background-color 0.1s;
}
.trow:hover { background: var(--muted-soft); }
.trow.is-focus { background: var(--muted); }
.trow.is-focus::before { position: absolute; top: 0; bottom: 0; left: 0; width: 2px; background: var(--foreground); content: ""; }
.trow.is-match { background: var(--warning-soft); }

.t-pct, .t-ms { text-align: right; white-space: nowrap; }
.t-pct { font-weight: 500; }
.t-ms { color: var(--muted-foreground); }
.t-track { display: block; height: 0.25rem; border-radius: 999px; background: var(--muted); }
.t-track i { display: block; min-width: 1px; height: 100%; border-radius: 999px; background: var(--meter); }
.trow:hover .t-track, .trow.is-focus .t-track { background: var(--input); }

.t-frame {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.375rem;
  min-width: 0;
  height: 100%;
  padding-left: var(--pad, 0);
  font: 400 0.75rem var(--font-geist-mono);
}
.t-arrow { position: relative; flex: none; width: 0.75rem; height: 0.75rem; color: var(--muted-foreground); }
.t-arrow[data-state]::before {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0.3125rem;
  height: 0.3125rem;
  margin: -0.1875rem 0 0 -0.1875rem;
  border: solid currentColor;
  border-width: 0 1.5px 1.5px 0;
  content: "";
  transform: rotate(-45deg);
}
.t-arrow[data-state="open"]::before { margin-top: -0.25rem; transform: rotate(45deg); }
.trow:hover .t-arrow { color: var(--foreground); }
.t-label { display: flex; min-width: 0; overflow: hidden; white-space: nowrap; }
.t-class { min-width: 0; overflow: hidden; color: var(--muted-foreground); text-overflow: ellipsis; }
.t-method { flex: none; max-width: 100%; overflow: hidden; font-weight: 500; text-overflow: ellipsis; }
.trow.is-hot .t-method { font-weight: 700; }
.t-below { flex: none; width: 0.375rem; height: 0.375rem; border-radius: 50%; background: var(--match); }

/* Flamegraph */

.flame-info {
  display: flex;
  flex: none;
  gap: 0.875rem;
  height: 2rem;
  align-items: center;
  padding: 0 0.875rem;
  overflow: hidden;
  font: 400 0.75rem var(--font-geist-mono);
  white-space: nowrap;
}
.flame-crumb { flex: none; max-width: 45%; overflow: hidden; text-overflow: ellipsis; }
.flame-detail { min-width: 0; overflow: hidden; color: var(--muted-foreground); text-overflow: ellipsis; }
.flame-scroll { position: relative; flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; scrollbar-color: var(--input) transparent; cursor: pointer; }
.flame-scroll:focus-visible { outline-offset: -2px; }
.flame-space { position: relative; }
.flame-canvas { position: sticky; top: 0; display: block; touch-action: pan-y; }
.flame-legend { display: flex; flex: none; flex-wrap: wrap; gap: 0.25rem 1rem; padding: 0.5rem 0.875rem; border-top: 1px solid var(--border); color: var(--muted-foreground); font-size: 0.75rem; }
.legend-item { display: inline-flex; align-items: center; gap: 0.375rem; }

.tip {
  position: fixed;
  z-index: 40;
  display: grid;
  gap: 2px;
  max-width: min(520px, calc(100vw - 16px));
  padding: 0.375rem 0.625rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--popover);
  color: var(--muted-foreground);
  font: 400 0.75rem/1.4 var(--font-geist-mono);
  overflow-wrap: anywhere;
  pointer-events: none;
}
.tip strong { color: var(--popover-foreground); font-weight: 500; }

/* Report-style panes */

.section-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 0.75rem; margin-bottom: 0.75rem; }
.section-head h2 { font-weight: 600; font-size: 1.125rem; letter-spacing: -0.015em; }
.section-note { min-width: 0; overflow: hidden; color: var(--muted-foreground); text-overflow: ellipsis; white-space: nowrap; }
.section-foot { margin-top: 0.75rem; color: var(--muted-foreground); font-size: 0.8125rem; }
.section-empty { margin-bottom: 1.5rem; color: var(--muted-foreground); }
.charts-page .hint { margin-bottom: 0.75rem; }

.stack { display: flex; gap: 2px; height: 0.5rem; margin-bottom: 1rem; }
.stack i { min-width: 3px; flex-basis: 0; }
.stack i:first-child { border-radius: 999px 0 0 999px; }
.stack i:last-child { border-radius: 0 999px 999px 0; }
.stack-server { background: var(--series-1); }
.stack-plugin { background: var(--chart-2); }
.stack-other { background: var(--chart-3); }
.stack-rest { background: var(--chart-4); }

.source-list { overflow: hidden; border: 1px solid var(--card-ring); border-radius: var(--radius-xl); background: var(--card); }
.source-list li + li { border-top: 1px solid var(--border); }
.source {
  display: grid;
  grid-template-columns: minmax(150px, 260px) minmax(40px, 1fr) 72px 104px;
  align-items: center;
  column-gap: 1rem;
  width: 100%;
  min-height: 2.75rem;
  padding: 0.5rem 1.25rem;
  border: 0;
  background: none;
  text-align: left;
  transition: background-color 0.15s;
}
.source:hover:not(:disabled) { background: var(--muted-soft); }
.source:focus-visible { outline-offset: -2px; }
.source:disabled { color: var(--muted-foreground); cursor: default; }
.source.is-selected { background: var(--muted); }
.source-name { display: flex; align-items: center; gap: 0.5rem; min-width: 0; overflow: hidden; white-space: nowrap; }
.source-name b { min-width: 0; overflow: hidden; font-weight: 500; text-overflow: ellipsis; }
.source-name small { min-width: 0; overflow: hidden; color: var(--muted-foreground); font: 400 0.6875rem var(--font-geist-mono); text-overflow: ellipsis; }
.source-track { height: 0.25rem; border-radius: 999px; background: var(--muted); }
.source-track i { display: block; height: 100%; min-width: 0; border-radius: 999px; background: var(--meter); }
.source-share, .source-ms { text-align: right; white-space: nowrap; }
.source-share { font-weight: 500; }
.source-ms { color: var(--muted-foreground); }

/* Hotspots */

.hhead, .hrow {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 96px 66px 96px;
  align-items: center;
  column-gap: 0.75rem;
  padding: 0 0.875rem;
}
.hhead { flex: none; height: 2rem; border-bottom: 1px solid var(--border); color: var(--muted-foreground); font-size: 0.75rem; }
.hlist { flex: 1 1 auto; min-height: 0; }
.hrow {
  height: var(--row-hotspot);
  border-bottom: 1px solid var(--border);
  font-size: 0.8125rem;
  cursor: pointer;
  transition: background-color 0.1s;
}
.hrow:hover { background: var(--muted-soft); }
.hrow > i { position: absolute; bottom: -1px; left: 0; max-width: 100%; height: 2px; background: var(--ring); }
.h-rank { color: var(--muted-foreground); text-align: right; }
.h-name { display: grid; min-width: 0; font-family: var(--font-geist-mono); font-size: 0.75rem; line-height: 1.125rem; }
.h-line { display: flex; align-items: center; gap: 0.375rem; min-width: 0; }
.h-line .t-method { flex: 0 1 auto; font-weight: 500; }
.h-name .t-class { font-size: 0.6875rem; white-space: nowrap; }
.h-num { text-align: right; white-space: nowrap; }
.h-total { color: var(--muted-foreground); }

/* Charts */

.chart-key { display: inline-flex; align-items: center; gap: 0.375rem; margin-left: auto; color: var(--muted-foreground); font-size: 0.75rem; }
.chart-key-band { width: 0.875rem; height: 0.625rem; border: 1px solid var(--destructive-text); border-radius: 2px; background: var(--destructive-soft); }
.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
.chart { min-width: 0; padding: 0.75rem 1rem; border: 1px solid var(--card-ring); border-radius: var(--radius-xl); background: var(--card); transition: border-color 0.15s; }
.chart.is-focus { border-color: var(--ring); }
.chart figcaption { display: flex; align-items: baseline; gap: 0.5rem; margin-bottom: 0.25rem; }
.chart-title { font-weight: 500; }
.chart-scope { color: var(--muted-foreground); font-size: 0.75rem; }
.chart-body { min-width: 0; min-height: 60px; }
.chart-empty { padding: 1.875rem 0; color: var(--muted-foreground); text-align: center; }

.uplot { color: var(--muted-foreground); font-family: var(--font-sans); line-height: 1.3; }
.uplot .u-legend { padding: 0; font-size: 0.75rem; text-align: left; }
.uplot .u-legend th { font-weight: 400; }
.u-legend .u-marker { width: 0.625rem; height: 0.625rem; margin-right: 0.25rem; border-radius: 2px; }
.u-legend .u-series { padding: 0; }
.u-legend .u-series > * { padding: 1px 3px; }
.u-legend .u-label { color: var(--muted-foreground); }
.u-legend .u-value { color: var(--foreground); }
.u-cursor-x, .u-cursor-y { border-color: var(--muted-foreground) !important; }

/* System */

.spec {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 1rem 1.5rem;
  margin-bottom: 1.75rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--card-ring);
  border-radius: var(--radius-xl);
  background: var(--card);
}
.spec > div { min-width: 0; }
.spec dt { color: var(--muted-foreground); font-size: 0.8125rem; }
.spec dd { font-weight: 500; overflow-wrap: anywhere; }

.table-wrap { max-width: 100%; margin-bottom: 1.75rem; overflow-x: auto; border: 1px solid var(--card-ring); border-radius: var(--radius-xl); background: var(--card); }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border); color: var(--muted-foreground); font-weight: 400; font-size: 0.8125rem; text-align: left; white-space: nowrap; }
.data-table td { padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border); overflow-wrap: break-word; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr { transition: background-color 0.15s; }
.data-table tbody tr:hover { background: var(--muted-soft); }
.data-table th:first-child, .data-table td:first-child { padding-left: 1.25rem; }
.data-table th:last-child, .data-table td:last-child { padding-right: 1.25rem; }
.data-table td.mono { font-size: 0.8125rem; }
.data-table .num { text-align: right; white-space: nowrap; }
.link { padding: 0; border: 0; background: none; color: var(--foreground); font-weight: 500; text-align: left; text-underline-offset: 3px; overflow-wrap: break-word; }
.link:hover { text-decoration: underline; }

/* States */

.pane-state { flex: 1 1 auto; min-height: 0; display: flex; }
.state {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  min-height: 15rem;
  padding: 1.5rem;
  color: var(--muted-foreground);
  text-align: center;
}
.pane > .state { border: 1px solid var(--card-ring); border-radius: var(--radius-xl); background: var(--card); }
.state h3 { color: var(--foreground); font-weight: 600; font-size: 1rem; letter-spacing: -0.01em; }
.state p { max-width: 46ch; }
.state .btn { margin-top: 0.5rem; }
.state-error h3 { color: var(--destructive-text); }
.state-bars { display: grid; gap: 3px; justify-items: center; margin-bottom: 0.625rem; }
.state-bars i { display: block; height: 7px; border-radius: 999px; background: var(--muted-foreground); animation: canopy-pulse 1.6s ease-in-out infinite; }
.state-bars i:nth-child(1) { width: 42px; animation-delay: 0.4s; }
.state-bars i:nth-child(2) { width: 74px; animation-delay: 0.3s; }
.state-bars i:nth-child(3) { width: 96px; animation-delay: 0.2s; }
.state-bars i:nth-child(4) { width: 58px; animation-delay: 0.1s; }
.state-bars i:nth-child(5) { width: 10px; height: 12px; border-radius: 2px; animation-delay: 0s; }
@keyframes canopy-pulse { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }

.statusbar {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 2.25rem;
  padding: 0 1.5rem;
  border-top: 1px solid var(--border);
  color: var(--muted-foreground);
  font-size: 0.75rem;
}
.statusbar-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  z-index: 50;
  max-width: calc(100vw - 2rem);
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--popover);
  color: var(--popover-foreground);
  font-weight: 500;
  transform: translateX(-50%);
}
.noscript { position: fixed; inset: auto 0 0; padding: 0.625rem; background: var(--muted); text-align: center; }

/* Home and not-found pages */

.site { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.container { width: 100%; max-width: 64rem; margin: 0 auto; padding: 0 1.5rem; }
.site-head { border-bottom: 1px solid var(--border); }
.site-head-row { display: flex; align-items: center; justify-content: space-between; height: 3.5rem; }
.site-main { flex: 1 1 auto; }
.hero { max-width: 42rem; padding: 5rem 0 2.5rem; }
.hero h1 { font-weight: 600; font-size: 2.25rem; line-height: 2.5rem; letter-spacing: -0.025em; text-wrap: balance; }
.hero p { margin-top: 0.75rem; color: var(--muted-foreground); font-size: 1.125rem; line-height: 1.75rem; }

.steps { counter-reset: step; }
.steps li {
  display: grid;
  grid-template-columns: 1.5rem 11rem minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 1.25rem;
  padding: 1.25rem 1.5rem;
  counter-increment: step;
}
.steps li + li { border-top: 1px solid var(--border); }
.steps li::before { color: var(--muted-foreground); content: counter(step); }
.step-name { font-weight: 600; }
.step-text { color: var(--muted-foreground); }
.steps code { padding: 0.125rem 0.625rem; border-radius: var(--radius-md); background: var(--muted); font-size: 0.8125rem; white-space: nowrap; }

.site-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1.25rem 1.5rem; padding: 2.5rem 0; }
.site-facts dt { color: var(--muted-foreground); }
.site-facts dd { margin-top: 0.125rem; font-weight: 500; }

.empty { display: flex; flex-direction: column; align-items: flex-start; gap: 1rem; margin-bottom: 2.5rem; padding: 1.25rem 1.5rem; }
.empty p { color: var(--muted-foreground); }

.site-foot { border-top: 1px solid var(--border); color: var(--muted-foreground); font-size: 0.8125rem; }
.site-foot-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 1rem; padding-top: 1rem; padding-bottom: 1rem; }

/* Narrow layouts */

@media (max-width: 1279px) {
  .stat, .stat:nth-child(-n+4) { grid-column: span 5; }
  .stat:nth-child(n+5) { grid-column: span 4; }
}

@media (max-width: 1023px) {
  .shell, .shell.is-collapsed { grid-template-columns: minmax(0, 1fr); }

  .regions, .shell.is-collapsed .regions {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    display: none;
    width: min(20rem, calc(100vw - 2.5rem));
    height: auto;
  }
  .regions.is-open, .shell.is-collapsed .regions.is-open { display: grid; }
  .regions-close { display: inline-flex; }
  .regions .field { height: 2.5rem; font-size: 1rem; }
  .regions-fixed .region { min-height: 2.75rem; }
  .scrim { position: fixed; inset: 0; z-index: 29; display: block; background: var(--scrim); }

  .region-switch {
    display: flex;
    flex: none;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    height: 2.5rem;
    padding: 0 0.75rem;
    border: 1px solid var(--input);
    border-radius: var(--radius-lg);
    background: var(--field);
    text-align: left;
    transition: background-color 0.15s;
  }
  .region-switch:hover { background: var(--muted); }
  .region-switch::after {
    flex: none;
    width: 0.4375rem;
    height: 0.4375rem;
    margin: -0.1875rem 0.25rem 0 0.25rem;
    border: solid var(--muted-foreground);
    border-width: 0 1.5px 1.5px 0;
    content: "";
    transform: rotate(45deg);
  }
  .region-switch-label { flex: none; color: var(--muted-foreground); font-size: 0.75rem; }
  .region-switch-value { flex: 1 1 auto; min-width: 0; overflow: hidden; font-family: var(--font-geist-mono); font-size: 0.8125rem; text-overflow: ellipsis; white-space: nowrap; }
  .region-switch-share { flex: none; font-weight: 500; font-size: 0.8125rem; }

  .content { padding: 1rem; }
  .statusbar { padding: 0 1rem; }
  .charts { grid-template-columns: minmax(0, 1fr); }
  .pane-fill { flex-basis: calc(100vh - 7.5rem); flex-basis: calc(100svh - 7.5rem); min-height: calc(100vh - 7.5rem); min-height: calc(100svh - 7.5rem); }
  .toolbar .btn, .toolbar .field { height: 2.25rem; }
  .toolbar .btn-icon { width: 2.25rem; }
  .toolbar .field { font-size: 1rem; }
}

@media (max-width: 767px) {
  :root { --row-tree: 46px; --row-flame: 24px; --tree-indent: 7px; --row-hotspot: 56px; --row-region: 62px; }

  .page-head { flex-direction: column; align-items: stretch; }
  .page-title { flex: none; }
  .page-title h1 { font-size: 1.5rem; line-height: 2rem; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1 1 0; }
  .facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem 1rem; }
  .facts > div { display: block; }
  .facts > div:first-child { grid-column: 1 / -1; }
  .facts dt { font-size: 0.75rem; }
  .facts dd { max-width: 100%; }

  .stats { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0.5rem; }
  .stat, .stat:nth-child(-n+4) { grid-column: span 3; grid-template-areas: "head head" "value value" "spark spark" "note note"; padding: 0.5rem 0.75rem; }
  .stat:nth-child(n+5) { grid-column: span 2; }
  .stat:nth-child(n+8) { grid-column: span 3; }
  .stat-value { font-size: 1.25rem; line-height: 1.625rem; }
  .stat:nth-child(n+5):nth-child(-n+7) .stat-value { font-size: 1.0625rem; }
  .stat-spark { height: 1.25rem; }

  .toolbar-search { flex: 1 1 100%; }
  .toolbar-spacer { display: none; }

  .thead { display: none; }
  .trow {
    grid-template-columns: 54px 72px minmax(0, 1fr);
    grid-template-rows: 22px 16px;
    grid-template-areas: "frame frame frame" "pct ms track";
    align-content: center;
    column-gap: 0.5rem;
    padding: 0 0.75rem;
  }
  .t-frame { grid-area: frame; }
  .t-pct { grid-area: pct; font-size: 0.75rem; text-align: left; }
  .t-ms { grid-area: ms; font-size: 0.75rem; text-align: left; }
  .t-track { grid-area: track; }
  .badge { max-width: 5.25rem; }

  .source { grid-template-columns: minmax(0, 1fr) 60px 88px; grid-template-rows: auto 8px; row-gap: 0.25rem; padding: 0.5rem 0.75rem; column-gap: 0.5rem; }
  .source-track { grid-column: 1 / -1; grid-row: 2; }

  .hhead, .hrow { grid-template-columns: 26px minmax(0, 1fr) 76px 50px; column-gap: 0.375rem; padding: 0 0.75rem; }
  .h-total { display: none; }
  .section-note { white-space: normal; }
  .chart-key { margin-left: 0; }
  .chart { padding: 0.625rem 0.75rem; }
  .flame-info { height: auto; min-height: 2rem; flex-direction: column; align-items: stretch; gap: 0; padding: 0.25rem 0.75rem; }
  .flame-crumb { max-width: 100%; }
  .statusbar .legal { display: none; }

  .container { padding: 0 1rem; }
  .hero { padding: 3rem 0 2rem; }
  .hero h1 { font-size: 1.875rem; line-height: 2.25rem; }
  .steps li { grid-template-columns: 1.25rem minmax(0, 1fr); row-gap: 0.25rem; column-gap: 0.75rem; padding: 1rem; align-items: baseline; }
  .step-text, .steps code { grid-column: 2; }
  .steps code { justify-self: start; max-width: 100%; overflow-x: auto; }
  .site-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 400px) {
  /* The note below keeps the state colour, the pill shrinks to its dot. */
  .stat .pill { justify-content: center; width: 1.125rem; height: 1.125rem; gap: 0; padding: 0; font-size: 0; }
  .stat, .stat:nth-child(-n+4) { padding: 0.5rem 0.625rem; }
  .stat-note { font-size: 0.6875rem; }
  .stats { gap: 0.375rem; }
  .stat:nth-child(n+5):nth-child(-n+7) { padding: 0.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  .state-bars i, .stat-loading .stat-value { animation: none; opacity: 0.8; }
  .pill-live::before { animation: none; }
}
