:root {
  color-scheme: light;
  --bg: #f7f6f3;
  --surface: #ffffff;
  --surface-2: #f0efeb;
  --border: #e2e0da;
  --text: #16150f;
  --text-2: #52514e;
  --text-3: #75736d;
  --accent: #b3261e;
  --accent-ink: #ffffff;
  --link: #1f5fb4;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --grid: #e7e5df;
  --good: #1d7a3e;
  --warn: #a35d00;
  --bad: #b3261e;
  --code-bg: #1d1c18;
  --code-text: #f0efec;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.05), 0 2px 8px rgb(0 0 0 / 0.04);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121210;
    --surface: #1a1a19;
    --surface-2: #232320;
    --border: #33332f;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --text-3: #9a998f;
    --accent: #e5574e;
    --accent-ink: #160707;
    --link: #7fb1f0;
    --series-1: #3987e5;
    --series-2: #d95926;
    --grid: #2c2c29;
    --good: #5cc883;
    --warn: #e0a24a;
    --bad: #f07a72;
    --code-bg: #0b0b0a;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121210;
  --surface: #1a1a19;
  --surface-2: #232320;
  --border: #33332f;
  --text: #f0efec;
  --text-2: #c3c2b7;
  --text-3: #9a998f;
  --accent: #e5574e;
  --accent-ink: #160707;
  --link: #7fb1f0;
  --series-1: #3987e5;
  --series-2: #d95926;
  --grid: #2c2c29;
  --good: #5cc883;
  --warn: #e0a24a;
  --bad: #f07a72;
  --code-bg: #0b0b0a;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 var(--font);
}
a { color: var(--link); }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 5vw, 3rem); margin: 0 0 0.5rem; }
h2 { font-size: 1.5rem; margin: 2.5rem 0 0.75rem; }
h3 { font-size: 1.1rem; margin: 1.5rem 0 0.5rem; }
p { margin: 0 0 1rem; }
code, pre { font-family: var(--mono); font-size: 0.875em; }
:not(pre) > code { background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 4px; }
pre {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  overflow-x: auto;
  line-height: 1.5;
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.site-header .wrap { display: flex; align-items: center; gap: 1.5rem; height: 60px; }
.brand { white-space: nowrap; font-weight: 700; color: var(--text); text-decoration: none; display: flex; align-items: center; gap: 0.5rem; }
.brand-mark { width: 24px; height: 24px; border-radius: 6px; background: var(--accent); display: grid; place-items: center; }
.brand-mark::after { content: ""; border-left: 8px solid var(--accent-ink); border-top: 5px solid transparent; border-bottom: 5px solid transparent; margin-left: 2px; }
.site-nav { display: flex; gap: 1.25rem; margin-left: auto; }
.site-nav a { color: var(--text-2); text-decoration: none; font-weight: 500; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--text); }
.site-footer { border-top: 1px solid var(--border); margin-top: 4rem; padding: 2rem 0; color: var(--text-3); font-size: 0.875rem; }

/* Buttons and forms */
.btn {
  display: inline-block; padding: 0.65rem 1.1rem; border-radius: 8px; font: inherit; font-weight: 600;
  text-decoration: none; border: 1px solid transparent; cursor: pointer;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn:disabled { opacity: 0.6; cursor: wait; }
label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.35rem; }
input[type="email"], input[type="password"] {
  width: 100%; padding: 0.65rem 0.75rem; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
}
input:focus-visible, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }

/* Landing */
.hero { padding: 4rem 0 2.5rem; }
.hero .lede { font-size: 1.2rem; color: var(--text-2); max-width: 40rem; }
.hero-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 1.5rem; }
.eyebrow { color: var(--accent); font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.8rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.card h3 { margin-top: 0; }
.card p { color: var(--text-2); margin: 0; }
.step-num { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--surface-2); font-weight: 700; margin-bottom: 0.5rem; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 0.925rem; }
th, td { text-align: left; padding: 0.6rem 0.85rem; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
th { font-weight: 600; color: var(--text-2); background: var(--surface-2); white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Guide */
.guide { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 3rem; padding-top: 2.5rem; }
.toc { position: sticky; top: 1rem; align-self: start; font-size: 0.925rem; }
.toc ol { list-style: none; padding: 0; margin: 0; }
.toc li { margin: 0.35rem 0; }
.toc a { color: var(--text-2); text-decoration: none; }
.toc a:hover { color: var(--text); }
.guide section { scroll-margin-top: 1rem; }
.guide section > h2:first-child { margin-top: 0; padding-top: 2rem; }
.changelog { max-width: 48rem; padding-top: 2.5rem; }
.changelog h2 { border-top: 1px solid var(--border); padding-top: 1.5rem; }
.changelog h3 { color: var(--text-2); font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.06em; }
.note { border-left: 3px solid var(--link); background: var(--surface); padding: 0.75rem 1rem; border-radius: 0 8px 8px 0; margin: 1rem 0; }
@media (max-width: 800px) {
  .guide { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .toc { position: static; border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; background: var(--surface); }
}

/* Account */
.login { max-width: 420px; margin: 4rem auto; }
.login form { display: grid; gap: 1rem; }
.hint { color: var(--text-3); font-size: 0.875rem; margin: 0.35rem 0 0; }
.error { color: var(--bad); font-weight: 600; min-height: 1.5em; margin: 0; }
.dash-head { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 1rem; padding: 2.5rem 0 1rem; }
.dash-head h1 { font-size: 2rem; margin: 0; }
.dash-head p { margin: 0.25rem 0 0; color: var(--text-2); }
.dash-actions { display: flex; gap: 0.5rem; }
.badge { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.8rem; font-weight: 600; padding: 0.1rem 0.55rem; border-radius: 999px; border: 1px solid currentColor; white-space: nowrap; }
.badge.good { color: var(--good); }
.badge.warn { color: var(--warn); }
.badge.bad { color: var(--bad); }
.badge.muted { color: var(--text-3); }
.tiles { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.tile .label { color: var(--text-2); font-size: 0.875rem; font-weight: 600; }
.tile .value { font-size: 1.9rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; margin-top: 0.25rem; }
.tile .sub { color: var(--text-3); font-size: 0.85rem; }
.meter { height: 8px; border-radius: 4px; background: var(--surface-2); margin-top: 0.75rem; overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 4px; background: var(--series-1); }
.meter.warn > span { background: var(--warn); }
.meter.bad > span { background: var(--bad); }
.panel { margin-top: 1.5rem; }
.panel h2 { font-size: 1.15rem; margin: 0 0 0.25rem; }
.panel h3 { font-size: 1.05rem; margin: 0 0 0.25rem; }
.panel .sub { color: var(--text-3); font-size: 0.875rem; margin: 0 0 1rem; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis { fill: var(--text-3); font-size: 11px; font-family: var(--font); }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .bar { fill: var(--series-1); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart .bar.active { opacity: 0.8; }
.chart .area-1 { fill: var(--series-1); }
.chart .area-2 { fill: var(--series-2); }
.chart .spacer { fill: none; stroke: var(--surface); stroke-width: 2; stroke-linejoin: round; }
.chart .crosshair { stroke: var(--text-3); stroke-width: 1; stroke-dasharray: 3 3; }
.live { margin-top: 2.5rem; }
.live-head { display: flex; align-items: baseline; gap: 0.75rem; flex-wrap: wrap; }
.live-head h2 { margin: 0; }
.live-narrative { color: var(--text-2); margin: 0.5rem 0 0; max-width: 46rem; }
.live-state { font-size: 0.8rem; font-weight: 600; padding: 0.15rem 0.55rem; border-radius: 999px; border: 1px solid var(--border); color: var(--text-2); }
.live-state::before { content: ""; display: inline-block; width: 0.5rem; height: 0.5rem; border-radius: 50%; margin-right: 0.4rem; background: var(--text-3); }
.live-state[data-state="quiet"]::before, .live-state[data-state="flowing"]::before { background: var(--good); }
.live-state[data-state="busy"]::before { background: var(--warn); }
.live-state[data-state="paused"]::before { background: var(--bad); }
.legend { display: flex; gap: 1rem; font-size: 0.8rem; color: var(--text-2); margin: 0.25rem 0 0.5rem; }
.legend .swatch { display: inline-block; width: 0.7rem; height: 0.7rem; border-radius: 3px; margin-right: 0.35rem; vertical-align: -1px; }
.legend .swatch-1 { background: var(--series-1); }
.legend .swatch-2 { background: var(--series-2); }
.tooltip {
  position: absolute; pointer-events: none; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 0.4rem 0.6rem; font-size: 0.8rem;
  box-shadow: var(--shadow); white-space: nowrap; transform: translate(-50%, calc(-100% - 8px));
}
.tooltip strong { display: block; }
.empty { color: var(--text-3); padding: 2rem 0; text-align: center; }
details.table-view { margin-top: 0.75rem; font-size: 0.875rem; }
details.table-view summary { cursor: pointer; color: var(--text-2); }
details.table-view .table-wrap { margin-top: 0.5rem; }
.cols-2 { margin-top: 1.5rem; display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.cols-2 > .panel { margin-top: 0; }
@media (max-width: 400px) { .cols-2 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 480px) { .site-header .wrap { gap: 1rem; } .site-nav { gap: 0.9rem; } }
[hidden] { display: none !important; }
