/* Colors: the dataviz skill's reference palette (references/palette.md), light and dark steps. */
:root {
  --bg: #f9f9f7; --panel: #fcfcfb; --text: #0b0b0b; --text-2: #52514e; --text-3: #898781;
  --hair: #e1e0d9; --edge: rgba(11, 11, 11, .1); --soft: rgba(11, 11, 11, .045);
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #4a3aa7; --s8: #e34948;
  --rail: #cde2fb; --fable: var(--s8);
  --good: #0ca30c; --serious: #ec835a; --critical: #d03b3b;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0d0d; --panel: #1a1a19; --text: #fff; --text-2: #c3c2b7; --text-3: #898781;
    --hair: #2c2c2a; --edge: rgba(255, 255, 255, .1); --soft: rgba(255, 255, 255, .055);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --rail: #184f95;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 40px max(14px, env(safe-area-inset-left));
}
main { display: grid; gap: 14px; max-width: 1120px; margin: 0 auto; }
@media (min-width: 880px) {
  main { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .wide { grid-column: span 2; }
}
[hidden] { display: none !important; }
a { color: var(--s1); }

header { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
h1 { margin: 0; font-size: 21px; font-weight: 700; letter-spacing: -.01em; }
#about { margin-left: auto; }
.small { font-size: 13px; }
.muted { color: var(--text-3); }
.stale { color: var(--critical); font-weight: 600; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; background: var(--soft); color: var(--text-2); font-size: 12px; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.sw.dash { width: 2px; border-radius: 0; background: repeating-linear-gradient(var(--text-2) 0 3px, transparent 3px 5px); margin: 0 9px 0 4px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

.panel { background: var(--panel); border: 1px solid var(--edge); border-radius: 14px; padding: 16px; min-width: 0; }
h2 { margin: 0 0 12px; font-size: 15px; font-weight: 650; }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.controls h2 { margin: 0; flex: 1 1 auto; }

/* Folding: the panel title toggles it; a folded panel keeps a one-line summary. */
.panel h2 { cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent; }
.panel h2::after { content: ""; display: inline-block; width: 6px; height: 6px; margin: 0 0 3px 9px; border: solid var(--text-3); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); transition: transform .15s; }
.panel[data-folded] h2::after { transform: rotate(-45deg); margin-bottom: 1px; }
.panel[data-folded] > :not(h2):not(.controls):not(.sum), .panel[data-folded] > .controls > :not(h2) { display: none !important; }
.panel[data-folded] h2, .panel[data-folded] > .controls { margin-bottom: 0; }
.sum { display: none; margin-top: 6px; font-size: 13px; color: var(--text-2); }
.panel[data-folded] .sum { display: block; }

.meter-row { display: grid; gap: 18px; }
.meter .top { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.meter .name { font-weight: 600; }
.meter .val { font-size: 32px; line-height: 1; font-weight: 700; font-variant-numeric: tabular-nums; }
.meter .bar { position: relative; height: 12px; margin: 9px 0 7px; border-radius: 6px; background: var(--rail); overflow: hidden; }
.meter .fill, .meter .proj { position: absolute; top: 0; bottom: 0; background: var(--s1); }
.meter .fill { left: 0; border-radius: 6px; }
.meter .proj { opacity: .4; }
.meter.fable .fill, .meter.fable .proj { background: var(--fable); }
.meter.fable .bar { background: color-mix(in oklab, var(--fable) 28%, var(--panel)); }
.meter .line { font-size: 13px; color: var(--text-2); }
.meter .line.warn { color: var(--serious); }
.meter .high { margin-left: 8px; font-size: 12px; font-weight: 650; color: var(--serious); }
.meter.hot .val { color: var(--serious); }
.meter.full .val { color: var(--critical); }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.stat .k { font-size: 12px; color: var(--text-2); }
.stat .v { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .s { font-size: 12px; color: var(--text-3); }
.mix { display: flex; gap: 2px; height: 8px; margin-top: 14px; border-radius: 4px; overflow: hidden; }
.mixlbl { display: flex; flex-wrap: wrap; gap: 2px 14px; margin-top: 7px; font-size: 12px; color: var(--text-2); }

.toggle { display: inline-flex; gap: 2px; padding: 3px; border-radius: 9px; background: var(--soft); }
.toggle button { padding: 4px 10px; border: 0; border-radius: 7px; background: none; color: var(--text-2); font: inherit; font-size: 13px; cursor: pointer; }
.toggle button[aria-pressed="true"] { background: var(--panel); color: var(--text); font-weight: 650; box-shadow: 0 1px 2px rgba(0, 0, 0, .15), 0 0 0 1px var(--edge); }
.chk { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--text-2); }

.chartbox { position: relative; touch-action: pan-y; }
.chartbox svg { display: block; width: 100%; overflow: visible; }
.chartbox svg text.end { fill: var(--text-2); font-size: 11px; }
.chartbox svg text { fill: var(--text-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 8px; font-size: 12px; color: var(--text-2); }
.tip {
  position: fixed; z-index: 10; min-width: 160px; padding: 8px 11px; pointer-events: none;
  background: var(--panel); color: var(--text); border: 1px solid var(--edge); border-radius: 9px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .2); font-size: 12px;
}
.tip .hd { margin-bottom: 4px; font-weight: 650; }
.tip .row { display: flex; justify-content: space-between; gap: 14px; font-variant-numeric: tabular-nums; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { padding: 5px 6px; text-align: left; font-size: 12px; font-weight: 600; color: var(--text-2); border-bottom: 1px solid var(--hair); }
td { padding: 8px 6px; vertical-align: top; border-bottom: 1px solid var(--hair); }
tr:last-child td { border-bottom: 0; }
th.n, td.n { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tr.total td { font-weight: 650; }
.pbar { height: 4px; margin-top: 6px; border-radius: 2px; }
.empty { padding: 8px 0; font-size: 14px; color: var(--text-3); }
@media (max-width: 540px) {
  .cr { display: none; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.btn { padding: 6px 13px; border: 0; border-radius: 9px; background: var(--soft); color: var(--text); font: inherit; font-size: 14px; cursor: pointer; }
dialog.about {
  width: min(580px, calc(100vw - 24px)); max-height: calc(100vh - 40px); overflow-y: auto; padding: 20px;
  background: var(--panel); color: var(--text-2); border: 1px solid var(--edge); border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .35); font-size: 14px; line-height: 1.55;
}
dialog.about::backdrop { background: rgba(0, 0, 0, .45); }
dialog.about h1 { margin: 0 0 8px; font-size: 18px; color: var(--text); }
dialog.about h2 { margin: 18px 0 4px; font-size: 15px; color: var(--text); cursor: default; }
dialog.about h2::after { content: none; }
dialog.about ul { margin: 4px 0; padding-left: 20px; }
dialog.about code { font-size: 12px; }
.row-end { display: flex; justify-content: flex-end; }
