/* Palette roles come from the validated reference instance: categorical slot 1
   for the single chart series, the fixed status palette for probe state (always
   paired with an icon + label, never colour alone). */
:root {
  color-scheme: light;
  --plane:        #f9f9f7;
  --surface:      #fcfcfb;
  --ink:          #0b0b0b;
  --ink-2:        #52514e;
  --ink-muted:    #898781;
  --grid:         #e1e0d9;
  --axis:         #c3c2b7;
  --border:       rgba(11, 11, 11, 0.10);
  --series-1:     #2a78d6;
  --series-1-soft: rgba(42, 120, 214, 0.14);
  --good:         #0ca30c;
  --warning:      #fab219;
  --serious:      #ec835a;
  --critical:     #d03b3b;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --plane:   #0d0d0d;
    --surface: #1a1a19;
    --ink:     #ffffff;
    --ink-2:   #c3c2b7;
    --grid:    #2c2c2a;
    --axis:    #383835;
    --border:  rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --series-1-soft: rgba(57, 135, 229, 0.18);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --plane: #0d0d0d; --surface: #1a1a19; --ink: #fff; --ink-2: #c3c2b7;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255,255,255,0.10);
  --series-1: #3987e5; --series-1-soft: rgba(57,135,229,0.18);
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--plane); color: var(--ink);
  font: 14px/1.5 var(--sans);
}
.wrap { max-width: 1180px; margin: 0 auto; padding: 24px 20px 64px; }

header.top { display: flex; flex-wrap: wrap; gap: 12px; align-items: baseline; margin-bottom: 20px; }
header.top h1 { font-size: 20px; font-weight: 650; margin: 0; letter-spacing: -0.01em; }
.host { color: var(--ink-muted); font-family: var(--mono); font-size: 12px; }
.spacer { flex: 1; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border);
  font-size: 12px; color: var(--ink-2); background: var(--surface);
  white-space: nowrap;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-muted); }
.chip.good .dot { background: var(--good); }
.chip.warning .dot { background: var(--warning); }
.chip.serious .dot { background: var(--serious); }
.chip.critical .dot { background: var(--critical); }

button {
  font: inherit; font-size: 12px; color: var(--ink-2); cursor: pointer;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; padding: 4px 10px;
}
button:hover { color: var(--ink); }
button[aria-pressed="true"] { color: var(--ink); border-color: var(--axis); }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.tile .label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-muted); }
.tile .value { font-size: 30px; font-weight: 600; line-height: 1.15; margin-top: 4px; letter-spacing: -0.02em; }
.tile .value.value-text { font-size: 19px; line-height: 1.25; }
.tile .sub { font-size: 12px; color: var(--ink-2); margin-top: 2px; }

.card { background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px; margin-bottom: 16px; position: relative; }
.card > h2 { font-size: 13px; font-weight: 650; margin: 0 0 2px; }
.card > .note { font-size: 12px; color: var(--ink-muted); margin: 0 0 12px; }
.card-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.card-head h2 { margin: 0; font-size: 13px; font-weight: 650; }
.card-head .note { margin: 0; font-size: 12px; color: var(--ink-muted); }

.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 16px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 6px 10px 6px 0; border-bottom: 1px solid var(--grid); }
th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-muted); font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; padding-right: 14px; }
td.muted { color: var(--ink-muted); }
.mono { font-family: var(--mono); font-size: 12px; }
.scroll { overflow-x: auto; }
.empty { color: var(--ink-muted); font-size: 13px; padding: 8px 0; }

/* chart */
.chart-wrap { position: relative; }
/* The height attribute is computed from the row count, so CSS must not pin it —
   a fixed height leaves rows drawn outside the element's own hit area, where
   they render (overflow: visible) but cannot be hovered. */
svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
svg.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
svg.chart .axis-line { stroke: var(--axis); stroke-width: 1; }
svg.chart text { fill: var(--ink-muted); font-size: 10px; font-variant-numeric: tabular-nums; }
svg.chart .series { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
svg.chart .area { fill: var(--series-1-soft); stroke: none; }
svg.chart .crosshair { stroke: var(--axis); stroke-width: 1; stroke-dasharray: 3 3; }
svg.chart .marker { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
.tooltip {
  position: absolute; pointer-events: none; z-index: 3;
  background: var(--surface); border: 1px solid var(--axis); border-radius: 6px;
  padding: 6px 9px; font-size: 12px; color: var(--ink);
  box-shadow: 0 4px 14px rgba(0,0,0,0.14); white-space: nowrap;
}
.tooltip .t-val { font-weight: 650; font-variant-numeric: tabular-nums; }
.tooltip .t-ts { color: var(--ink-2); font-size: 11px; }

pre.capture {
  margin: 0; padding: 12px; overflow-x: auto; border-radius: 8px;
  background: var(--plane); border: 1px solid var(--border);
  font-family: var(--mono); font-size: 12px; line-height: 1.45; color: var(--ink-2);
  max-height: 340px;
}
.err { color: var(--critical); }
footer.foot { color: var(--ink-muted); font-size: 12px; margin-top: 24px; display: flex; gap: 14px; flex-wrap: wrap; }
footer.foot a { color: var(--ink-2); }

/* ---------------------------------------------------------------- characters */
/* align-items: start keeps each card at its own height — otherwise a card with
   full MegaMUD data stretches every sibling in its row and leaves dead space. */
.chars { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px; align-items: start; }
.char {
  border: 1px solid var(--border); border-radius: 10px; padding: 13px 14px;
  background: var(--plane); display: flex; flex-direction: column; gap: 9px;
}
.char.is-online { border-color: color-mix(in srgb, var(--good) 40%, var(--border)); }
.char-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.char-name { font-size: 15px; font-weight: 650; letter-spacing: -0.01em; }
.char-rank {
  font-size: 11px; font-variant-numeric: tabular-nums; color: var(--ink-muted);
  border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px;
}
.char-sub { font-size: 12px; color: var(--ink-2); }
.char-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); gap: 8px 10px; }
.char-stat .k { font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-muted); }
.char-stat .v { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.char-stat .v small { font-weight: 400; color: var(--ink-2); font-size: 11px; }
.char-where { font-size: 12px; color: var(--ink-2); }
.char-where b { font-weight: 600; color: var(--ink); }
.k-inline { font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--ink-muted); }
.char-status {
  font-size: 11.5px; color: var(--ink-2); font-family: var(--mono);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; padding: 5px 7px; word-break: break-word;
}
.char-foot { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--ink-muted); }

/* meters: 4px rounded ends, 2px gap between fill and track */
.meter { display: flex; flex-direction: column; gap: 3px; }
.meter-label { display: flex; justify-content: space-between; font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-muted); }
.meter-label .amt { font-variant-numeric: tabular-nums; text-transform: none;
  letter-spacing: 0; color: var(--ink-2); }
.meter-track { height: 8px; border-radius: 4px; background: var(--grid); padding: 0; overflow: hidden; }
.meter-fill { height: 100%; border-radius: 4px; background: var(--series-1);
  box-shadow: 0 0 0 2px var(--plane) inset; }
.meter-fill.hp-ok { background: var(--good); }
.meter-fill.hp-warn { background: var(--warning); }
.meter-fill.hp-low { background: var(--critical); }

.spark { width: 100%; height: 30px; display: block; overflow: visible; }
.spark path.series { fill: none; stroke: var(--series-1); stroke-width: 2;
  stroke-linejoin: round; stroke-linecap: round; }
.spark path.area { fill: var(--series-1-soft); stroke: none; }

/* horizontal bars */
svg.chart .bar { fill: var(--series-1); }
svg.chart .bar-track { fill: var(--grid); }
svg.chart .bar-label { fill: var(--ink-2); font-size: 11px; }
svg.chart .bar-value { fill: var(--ink); font-size: 11px; font-variant-numeric: tabular-nums; }

details.card > summary { cursor: pointer; list-style: none; display: flex;
  align-items: baseline; gap: 10px; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary h2 { margin: 0; font-size: 13px; font-weight: 650; display: inline; }
details.card > summary::before { content: "▸"; color: var(--ink-muted); font-size: 11px; }
details.card[open] > summary::before { content: "▾"; }
details.card > summary .note { font-size: 12px; color: var(--ink-muted); }
.badge-live { color: var(--good); }
.badge-deny { color: var(--warning); }
