.profiling {
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --grid: #e3eaeb;
}

.snapshot-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: center;
  margin-top: 1.25rem;
  font-size: 0.9rem;
}

.snapshot-bar select {
  font: inherit;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
}

.snapshot-meta {
  color: var(--text-muted);
}

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.75rem;
  margin: 2rem 0 1rem;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem 1rem;
}

.kpi-value {
  font-size: 1.7rem;
  font-weight: 650;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.kpi-label {
  overflow-wrap: anywhere;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

.chart-card {
  margin: 1rem 0 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1rem 0.75rem;
}

.chart-card figcaption {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 0.5rem;
  max-width: 70ch;
}

.chart svg {
  max-width: 100%;
  height: auto;
  overflow: visible;
}

.chart-pair {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
}

.chart-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: center;
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.chart-controls input,
.chart-controls select {
  font: inherit;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  overflow: hidden;
}

.segmented button {
  font: inherit;
  border: 0;
  padding: 0.3rem 0.7rem;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.segmented button + button {
  border-left: 1px solid var(--border-strong);
}

.segmented button[aria-pressed="true"] {
  background: var(--primary);
  color: #fff;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  max-height: 32rem;
}

.fixture-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.fixture-table th,
.fixture-table td {
  padding: 0.4rem 0.7rem;
  border-bottom: 1px solid var(--grid);
  text-align: left;
  white-space: nowrap;
}

.fixture-table th {
  position: sticky;
  top: 0;
  background: var(--surface-muted);
  cursor: pointer;
  user-select: none;
}

.fixture-table th[aria-sort="descending"]::after {
  content: " \2193";
}

.fixture-table th[aria-sort="ascending"]::after {
  content: " \2191";
}

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

.fixture-table td.path {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.8rem;
}

.reading {
  max-width: 75ch;
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--primary);
  background: var(--primary-soft);
  border-radius: 0 8px 8px 0;
  line-height: 1.6;
}

.reading:empty {
  display: none;
}

.reading strong {
  font-weight: 650;
}

.method {
  max-width: 75ch;
  margin-top: 0.75rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.method summary {
  cursor: pointer;
  color: var(--primary);
  font-weight: 600;
}

.method ul {
  line-height: 1.6;
  padding-left: 1.2rem;
}

.snippet {
  max-width: 40rem;
  margin: 1rem 0 0;
}

.methodology ul {
  color: var(--text-muted);
  max-width: 75ch;
  line-height: 1.6;
}

@media (max-width: 600px) {
  .kpi-value {
    font-size: 1.35rem;
  }
}

.flame {
  width: 100%;
  overflow-x: hidden;
}

.flame .d3-flame-graph rect {
  stroke: var(--surface);
  stroke-width: 1px;
}

.flame .d3-flame-graph-label {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 11px;
  color: #fff;
}

.flame-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  margin-bottom: 0.6rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.flame-legend span::before {
  content: "";
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  margin-right: 0.35rem;
  border-radius: 2px;
  vertical-align: -1px;
  background: var(--swatch);
}

.flame-details {
  min-height: 1.4em;
  margin: 0.5rem 0 0;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.8rem;
  color: var(--text);
}

.flame-reset {
  font: inherit;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.fixture-table tr.linked {
  cursor: pointer;
}

.fixture-table tr.linked:hover td {
  background: var(--surface-hover);
}

.fixture-table td.path a {
  color: var(--primary);
  text-decoration: none;
}

.fixture-table td.path a:hover {
  text-decoration: underline;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.05rem 0.45rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.82em;
  line-height: 1.4;
  white-space: nowrap;
  vertical-align: 0.05em;
}

.chip-ctx::before {
  border-radius: 50%;
}

.chip-ctx::before,
.chip-dom::before {
  content: "";
  width: 0.55rem;
  height: 0.55rem;
  background: var(--swatch);
}

/* A square for a domain, a dot for a context, so the two never read as the same key. */
.chip-dom::before {
  border-radius: 2px;
}

.chip-prog {
  font-family: inherit;
  background: var(--surface-muted);
}

.flame-source {
  min-height: 1.4em;
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.flame-source a {
  font-family: var(--font-mono, ui-monospace, monospace);
  color: var(--primary);
}

.flame-open {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}

.flame-open:hover {
  text-decoration: underline;
}

.family-link {
  padding: 0;
  font: inherit;
  color: var(--primary);
  background: none;
  border: 0;
  cursor: pointer;
}

.family-link:hover {
  text-decoration: underline;
}

.family-dialog {
  width: min(720px, calc(100vw - 32px));
}

.family-dialog .examples-body {
  padding-top: 16px;
}

.family-dialog .snippet {
  margin: 0 0 14px;
}

.family-open {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}

.family-open:hover {
  text-decoration: underline;
}
