:root,
[data-theme="light"],
[data-theme="auto"] {
  color-scheme: light;
  --background: #edf0ea;
  --surface: #f5f6f1;
  --surface-hover: #e6ebe5;
  --text: #182322;
  --muted: #60706c;
  --heading-muted: #52615e;
  --border: #aab5ae;
  --subtle-border: #c7cfca;
  --accent: #177a70;
  --accent-label: #176c61;
  --waiting: #9a6658;
  --waiting-ring: #9a665826;
  --live: #19796b;
  --live-ring: #19796b26;
}

[data-theme="dark"] {
  color-scheme: dark;
  --background: #17201f;
  --surface: #202a28;
  --surface-hover: #2c3936;
  --text: #e3e8e2;
  --muted: #9fada8;
  --heading-muted: #9fada8;
  --border: #46524f;
  --subtle-border: #46524f;
  --accent: #6bc6b7;
  --accent-label: #65bbae;
  --waiting: #c47d67;
  --waiting-ring: #c47d6738;
  --live: #6bc6b7;
  --live-ring: #6bc6b738;
}

[data-theme="amber"] {
  color-scheme: dark;
  --background: #21170c;
  --surface: #2c1e0e;
  --surface-hover: #3a2811;
  --text: #edc36b;
  --muted: #b98a47;
  --heading-muted: #c7964a;
  --border: #684718;
  --subtle-border: #513713;
  --accent: #ffb31a;
  --accent-label: #dda02e;
  --waiting: #b45f32;
  --waiting-ring: #b45f3240;
  --live: #ffb31a;
  --live-ring: #ffb31a38;
  font-family: ui-monospace, "Cascadia Mono", "Liberation Mono", monospace;
}

[data-theme="solarized-light"] {
  color-scheme: light;
  --background: #eee8d5;
  --surface: #fdf6e3;
  --surface-hover: #e5ddc7;
  --text: #475b62;
  --muted: #657b83;
  --heading-muted: #586e75;
  --border: #b8ad91;
  --subtle-border: #d4cbb5;
  --accent: #268bd2;
  --accent-label: #2a7f9e;
  --waiting: #cb4b16;
  --waiting-ring: #cb4b1633;
  --live: #2aa198;
  --live-ring: #2aa19833;
}

[data-theme="solarized-dark"] {
  color-scheme: dark;
  --background: #002b36;
  --surface: #073642;
  --surface-hover: #164552;
  --text: #93a1a1;
  --muted: #839496;
  --heading-muted: #93a1a1;
  --border: #315866;
  --subtle-border: #244c59;
  --accent: #2aa198;
  --accent-label: #69b8b1;
  --waiting: #cb4b16;
  --waiting-ring: #cb4b163d;
  --live: #859900;
  --live-ring: #8599003d;
}

@media (prefers-color-scheme: dark) {
  [data-theme="auto"] {
    color-scheme: dark;
    --background: #17201f;
    --surface: #202a28;
    --surface-hover: #2c3936;
    --text: #e3e8e2;
    --muted: #9fada8;
    --heading-muted: #9fada8;
    --border: #46524f;
    --subtle-border: #46524f;
    --accent: #6bc6b7;
    --accent-label: #65bbae;
    --waiting: #c47d67;
    --waiting-ring: #c47d6738;
    --live: #6bc6b7;
    --live-ring: #6bc6b738;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--background); color: var(--text); font: 16px/1.4 system-ui, sans-serif; }
[data-theme="amber"] body { font-family: inherit; }
main { width: min(1180px, calc(100% - 32px)); margin: auto; padding: 30px 0 64px; }
header { display: flex; justify-content: space-between; align-items: end; gap: 24px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
h1 { font-size: clamp(1.8rem, 4vw, 3rem); letter-spacing: -.05em; line-height: 1; margin: .15rem 0; }
.eyebrow { color: var(--accent-label); font-size: .72rem; font-weight: 800; letter-spacing: .16em; margin: 0; }
.header-actions { display: flex; align-items: end; justify-content: end; gap: 22px; }
.theme-picker { display: grid; gap: 4px; color: var(--muted); font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.theme-picker select,
.explorer input,
.explorer select,
.explorer button { border: 1px solid var(--border); border-radius: 3px; background: var(--surface); color: var(--text); font: inherit; padding: 8px 10px; }
.theme-picker select { min-width: 132px; font-size: .82rem; letter-spacing: 0; text-transform: none; }
.connection { display: flex; align-items: center; gap: 12px; text-align: right; }
.connection div { display: grid; }
.connection small { color: var(--muted); }
#signal { width: 11px; height: 11px; border-radius: 50%; background: var(--waiting); box-shadow: 0 0 0 5px var(--waiting-ring); }
#signal.live { background: var(--live); box-shadow: 0 0 0 5px var(--live-ring); }
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); margin-top: 24px; }
.metrics article { background: var(--surface); padding: 18px; min-width: 0; }
.metrics h2 { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--heading-muted); margin: 0; }
.metrics p { margin: 14px 0 8px; display: flex; align-items: baseline; gap: 8px; }
.metrics strong { font-size: clamp(2rem, 4vw, 3.1rem); font-weight: 550; letter-spacing: -.05em; }
.metrics span { color: var(--muted); }
.metrics svg { display: block; width: 100%; height: 90px; border-bottom: 1px solid var(--subtle-border); }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }
.chart-interpolation { stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 5 4; opacity: .62; vector-effect: non-scaling-stroke; }
.chart-point { fill: var(--accent); }
.history-metrics article { position: relative; }
.history-metrics svg { cursor: crosshair; touch-action: none; }
.chart-cursor-line { stroke: var(--text); stroke-width: 1; opacity: 0; pointer-events: none; vector-effect: non-scaling-stroke; }
.chart-cursor-point { fill: var(--surface); stroke: var(--text); stroke-width: 2; opacity: 0; pointer-events: none; vector-effect: non-scaling-stroke; }
.chart-cursor-line.is-visible, .chart-cursor-point.is-visible { opacity: 1; }
.chart-tooltip { position: absolute; z-index: 3; display: grid; min-width: 152px; max-width: calc(100% - 24px); gap: 2px; padding: 7px 9px; border: 1px solid var(--border); border-radius: 3px; color: var(--text); background: var(--surface); box-shadow: 0 5px 18px var(--waiting-ring); opacity: 0; pointer-events: none; transform: translate(-50%, -100%); transition: opacity 100ms ease; }
.chart-tooltip.is-visible { opacity: 1; }
.chart-tooltip strong { font-size: .88rem; font-weight: 750; letter-spacing: 0; }
.chart-tooltip small { color: var(--muted); font-size: .68rem; line-height: 1.25; }
.details { display: flex; gap: 28px; border-top: 1px solid var(--border); margin-top: 14px; flex-wrap: wrap; }
.details div { display: flex; align-items: baseline; gap: 8px; padding: 10px 0 0; }
.details span { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; }
.live-metrics { grid-template-columns: repeat(6, minmax(0, 1fr)); margin-top: 16px; }
.live-metrics article { padding: 10px 14px; }
.live-metrics h2 { font-size: .65rem; }
.live-metrics p { margin: 4px 0 0; gap: 5px; }
.live-metrics strong { font-size: clamp(1.15rem, 2vw, 1.6rem); letter-spacing: -.035em; }
.live-metrics span { font-size: .78rem; }
.explorer { margin-top: 36px; border-top: 1px solid var(--border); padding-top: 24px; }
.explorer-heading { display: flex; justify-content: space-between; align-items: start; gap: 24px; }
.explorer h2 { font-size: clamp(1.5rem, 3vw, 2.3rem); letter-spacing: -.04em; margin: .15rem 0 0; }
.explorer-controls { display: grid; gap: 10px; justify-items: end; min-width: 0; }
.explorer-tools { display: flex; align-items: end; gap: 12px; color: var(--heading-muted); font-size: .85rem; }
.explorer-tools label { display: grid; gap: 5px; }
.explorer button { cursor: pointer; font-weight: 650; }
.explorer button:hover { background: var(--surface-hover); }
.explorer button:disabled { cursor: not-allowed; opacity: .5; }
.range-presets { display: flex; flex-wrap: wrap; justify-content: end; gap: 6px; margin: 0; }
.range-presets button { padding: 6px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); font: inherit; font-size: .78rem; }
.range-presets button.is-selected { border-color: var(--accent); color: var(--background); background: var(--accent); }
.explorer-note { color: var(--muted); font-size: .82rem; margin: 10px 0 4px; }
.chart-legend { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.legend-line { display: inline-block; width: 24px; height: 0; border-top: 2px solid var(--accent); }
.legend-line--interpolated { border-top-style: dashed; opacity: .62; margin-left: 8px; }
.legend-gap { display: inline-block; width: 24px; height: 8px; margin-left: 8px; border-left: 2px solid var(--accent); border-right: 2px solid var(--accent); opacity: .42; }
.history-count { margin-top: 0; }
.history-metrics { margin-top: 10px; }

@media (max-width: 980px) {
  .explorer-heading { align-items: stretch; flex-direction: column; }
  .explorer-controls { width: 100%; justify-items: stretch; }
  .range-presets { justify-content: start; }
  .explorer-tools { flex-wrap: wrap; }
}

@media (max-width: 760px) {
  main { width: min(100% - 24px, 1180px); padding-top: 20px; }
  header { align-items: stretch; flex-direction: column; gap: 16px; }
  .header-actions { width: 100%; align-items: end; justify-content: space-between; flex-direction: row-reverse; gap: 16px; }
  .theme-picker { min-width: 0; }
  .theme-picker select { min-width: 118px; max-width: 42vw; }
  .connection { text-align: left; }
  .live-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .live-metrics article { min-height: 78px; padding: 12px; }
  .history-metrics { grid-template-columns: 1fr; }
  .details { display: grid; gap: 0; }
  .details div { justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--subtle-border); }
  .details div:last-child { border-bottom: 0; }
  .connection strong { font-size: .8rem; }
  .explorer { margin-top: 26px; }
  .explorer-tools { display: grid; width: 100%; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
  .explorer-tools label { min-width: 0; }
  .explorer-tools label[for="range-start"],
  .explorer-tools label[for="range-end"] { grid-column: 1 / -1; }
  .explorer-tools input,
  .explorer-tools select,
  .explorer-tools button { width: 100%; min-width: 0; min-height: 44px; }
  #export { grid-column: 1 / -1; }
  .range-presets { gap: 7px; }
  .range-presets button { min-height: 38px; padding-inline: 12px; }
  .chart-legend { gap: 6px 5px; }
  .history-metrics article { padding: 16px; }
}

@media (max-width: 390px) {
  h1 { font-size: 2rem; }
  .header-actions { align-items: stretch; flex-direction: column; }
  .connection { order: -1; }
  .theme-picker select { max-width: none; width: 100%; min-height: 44px; }
  .connection { justify-content: flex-start; }
  .live-metrics strong { font-size: 1.2rem; }
}
