/* Both modes are selected values, not a filter flip. Series colors live in the
   manifest (generated by powermix.py) so the palette has exactly one source of truth. */
:root {
  --surface: #fcfcfb;
  --surface-2: #f4f4f0;
  --ink: #16160f;
  --ink-2: #4a4a42;
  --ink-muted: #75746a;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --accent: #2171b5;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --surface: #1a1a19;
  --surface-2: #232321;
  --ink: #f2f1ea;
  --ink-2: #c8c7be;
  --ink-muted: #918f85;
  --grid: #2c2c2a;
  --axis: #383835;
  --accent: #3b8ad4;
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* Any explicit `display` beats the UA [hidden] rule, so .pill[hidden] would still
   render. Restate it with priority rather than avoiding `display` everywhere. */
[hidden] { display: none !important; }

body {
  margin: 0;
  padding: 32px 24px 64px;
  background: var(--surface);
  color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}
main { max-width: 1180px; margin: 0 auto; }

/* Share links point straight at this page, so it needs its own way back. The href
   is relative: deployed at /powermix/ it resolves to the tools index at /. */
.home {
  display: inline-block; margin: 0 0 10px;
  font-size: 13px; color: var(--ink-muted); text-decoration: none;
}
.home:hover, .home:focus-visible { color: var(--accent); }

h1 { font-size: 22px; font-weight: 620; margin: 0 0 6px; letter-spacing: -0.01em; }
.sub { margin: 0 0 22px; color: var(--ink-2); max-width: 68ch; }

/* ---- filter row: one row, above everything it scopes ---- */
.filters {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 18px;
  padding-bottom: 18px; margin-bottom: 18px;
  border-bottom: 1px solid var(--grid);
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12px; color: var(--ink-muted); letter-spacing: 0.02em; }
select {
  font: inherit; padding: 6px 10px; min-width: 160px;
  color: var(--ink); background: var(--surface-2);
  border: 1px solid var(--grid); border-radius: 7px;
}
.segmented { display: inline-flex; border: 1px solid var(--grid); border-radius: 7px; overflow: hidden; }
.segmented button {
  font: inherit; font-size: 13px; padding: 6px 12px; cursor: pointer;
  background: var(--surface-2); color: var(--ink-2);
  border: 0; border-right: 1px solid var(--grid);
}
.segmented button:last-child { border-right: 0; }
.segmented button:hover { background: var(--grid); }
.segmented button.is-active { background: var(--accent); color: #fff; }
.check { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink-2); }
.ghost {
  font: inherit; font-size: 13px; padding: 6px 12px; cursor: pointer;
  background: var(--surface-2); color: var(--ink-2);
  border: 1px solid var(--grid); border-radius: 7px;
}
.ghost:hover { background: var(--grid); }

/* ---- chart card. Height includes the x-axis band so it never gets a nested scroll. ---- */
.card { border: 1px solid var(--grid); border-radius: 12px; padding: 14px 14px 6px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 6px; }
.head-right { display: flex; align-items: center; gap: 10px; }
.pill {
  display: inline-block; font-size: 12px; font-weight: 560; padding: 3px 9px;
  border-radius: 999px; background: var(--surface-2); color: var(--ink-2);
  border: 1px solid var(--grid);
}
.pill-quiet { color: var(--ink-muted); font-weight: 400; }
.range-note { font-size: 13px; color: var(--ink-muted); margin-left: 10px; }
.muted { color: var(--ink-muted); font-size: 12px; }
.note { color: var(--ink-2); font-size: 13px; min-height: 1.2em; margin: 4px 0; }
.error { color: #b3261e; font-size: 14px; }

.plot { position: relative; height: 420px; outline: none; }
.plot.is-stale canvas { opacity: 0.45; }   /* hold the frame while detail loads */
.plot:focus-visible { box-shadow: 0 0 0 2px var(--accent); border-radius: 6px; }
.context { position: relative; height: 64px; margin-top: 2px; }
.plot canvas, .context canvas { position: absolute; }
.plot svg, .context svg { position: absolute; left: 0; top: 0; overflow: visible; }
.plot .capture { cursor: crosshair; touch-action: none; }

/* Solid hairlines, one shade off the surface. Never dashed. */
.grid line { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.axis text { fill: var(--ink-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.crosshair-line { stroke: var(--ink-2); stroke-width: 1; pointer-events: none; }
.direct-labels text { fill: var(--ink-2); font-size: 11px; font-weight: 560; }
.brush .selection { fill: var(--accent); fill-opacity: 0.14; stroke: var(--accent); stroke-width: 1; }
.brush .handle { fill: var(--accent); fill-opacity: 0.5; }

/* ---- info popover: anchored to the card head so opening it shifts no layout ---- */
.card-head { position: relative; }
.icon-btn {
  width: 22px; height: 22px; flex: none; padding: 0; cursor: pointer;
  font: 600 12px/1 Georgia, "Times New Roman", serif; font-style: italic;
  color: var(--ink-2); background: var(--surface-2);
  border: 1px solid var(--grid); border-radius: 999px;
}
.icon-btn:hover, .icon-btn[aria-expanded="true"] { background: var(--grid); color: var(--ink); }
.info-pop {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 20;
  width: min(400px, calc(100vw - 48px));
  padding: 14px 16px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--grid);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.16);
  font-size: 12.5px; color: var(--ink-2);
}
.info-pop p { margin: 0 0 9px; }
.info-pop p:last-child { margin-bottom: 0; }
.info-pop strong { color: var(--ink); font-weight: 620; }

/* ---- legend: always present, rect swatches because the marks are areas ---- */
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 12px 2px 10px; }
.legend-item {
  display: inline-flex; align-items: center; gap: 7px;
  font: inherit; font-size: 12.5px; color: var(--ink-2);
  background: none; border: 0; padding: 4px 2px; cursor: pointer; border-radius: 5px;
}
.legend-item:hover { color: var(--ink); }
.legend-item.is-off { opacity: 0.4; text-decoration: line-through; }
.legend-item.is-absent { opacity: 0.35; cursor: default; font-style: italic; }
.swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; }

/* ---- tooltip: values lead, labels follow; series keyed by a stroke, not a box ---- */
.tooltip {
  position: absolute; z-index: 10; pointer-events: none;
  min-width: 210px; padding: 9px 11px; border-radius: 9px;
  background: var(--surface); border: 1px solid var(--grid);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.13); font-size: 12.5px;
}
.tt-head { font-weight: 620; margin-bottom: 6px; color: var(--ink); }
.tt-row { display: grid; grid-template-columns: 12px 1fr auto; gap: 8px; align-items: center; padding: 1.5px 0; }
.tt-key { height: 2.5px; border-radius: 2px; }
.tt-name { color: var(--ink-muted); }
.tt-val { font-weight: 620; color: var(--ink); font-variant-numeric: tabular-nums; }
.tt-total { border-top: 1px solid var(--grid); margin-top: 5px; padding-top: 5px; }

/* ---- table twin ---- */
.table-wrap { margin-top: 22px; }
.table-wrap summary { cursor: pointer; font-size: 14px; color: var(--ink-2); }
.table-scroll { max-height: 420px; overflow: auto; margin-top: 10px; }
table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
th, td { padding: 5px 9px; border-bottom: 1px solid var(--grid); text-align: left; white-space: nowrap; }
th { position: sticky; top: 0; background: var(--surface); color: var(--ink-muted); font-weight: 560; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }

footer { margin-top: 28px; font-size: 13px; color: var(--ink-2); }
footer p { margin: 0 0 8px; max-width: 82ch; }
a { color: var(--accent); }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --surface: #1a1a19; --surface-2: #232321; --ink: #f2f1ea; --ink-2: #c8c7be;
    --ink-muted: #918f85; --grid: #2c2c2a; --axis: #383835; --accent: #3b8ad4;
    color-scheme: dark;
  }
}
