/* Inspired by membrane.stream: light navy / sea-blue canvas, geometric type. */
:root {
  color-scheme: light;
  --bg: #eceef5;
  --bg-wash: #dfe6f5;
  --panel: rgba(255, 255, 255, 0.72);
  --panel-strong: #ffffff;
  --line: #b2b9cc;
  --line-soft: rgba(0, 26, 114, 0.12);
  --text: #001a72;
  --muted: #424853;
  --accent: #2aa8c9;
  --accent-soft: #87cce8;
  --accent-wash: rgba(135, 204, 232, 0.35);
  --warn: #c47a1a;
  --bad: #ea336f;
  --ink: #1b1f26;
  --radius: 12px;
  --font-display: "Space Grotesk", "Aktiv Grotesk", sans-serif;
  --font-body: "Source Sans 3", "Aktiv Grotesk", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: 28px 24px 48px;
  color: var(--text);
  font: 400 15px/1.45 var(--font-body);
  background:
    radial-gradient(ellipse 90% 55% at 12% -10%, rgba(135, 204, 232, 0.55), transparent 55%),
    radial-gradient(ellipse 70% 45% at 95% 0%, rgba(234, 51, 111, 0.12), transparent 50%),
    linear-gradient(180deg, var(--bg-wash) 0%, var(--bg) 38%, #f7f8fc 100%);
}

main {
  max-width: 1120px;
  margin: 0 auto;
}

h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.05;
  color: var(--text);
}

h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  color: var(--ink);
}

.top {
  margin-bottom: 28px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line-soft);
}

.top .brand {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--bad);
}

.top .lede {
  margin: 10px 0 18px;
  max-width: 38rem;
  color: var(--muted);
  font-size: 1.05rem;
}

.top dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 16px;
  margin: 0;
}

.top dt {
  color: var(--muted);
  font-size: 0.85rem;
}

.top dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.status.ready,
.status.external {
  color: #0f7a92;
  font-weight: 600;
}

.status.starting {
  color: var(--warn);
  font-weight: 600;
}

.status.down {
  color: var(--bad);
  font-weight: 600;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 16px 18px 18px;
  margin-bottom: 16px;
  backdrop-filter: blur(8px);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset;
}

.panel header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
}

.subtitle,
.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.series {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 90px 180px;
  align-items: center;
  gap: 12px;
  padding: 5px 0;
  border-top: 1px solid var(--line-soft);
}

.series .name {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.series .value {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.spark {
  width: 180px;
  height: 28px;
  display: block;
}

.spark polyline {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.75;
  vector-effect: non-scaling-stroke;
}

table.relay {
  border-collapse: collapse;
  width: 100%;
  margin-bottom: 8px;
  font-variant-numeric: tabular-nums;
}

table.relay th,
table.relay td {
  border-bottom: 1px solid var(--line-soft);
  padding: 5px 8px;
  text-align: right;
}

table.relay th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.8rem;
}

table.relay td.name {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.knobs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px 18px;
  align-items: end;
}

.knobs .downlink {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.knobs button,
.grid-controls button {
  background: var(--panel-strong);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 14px;
  cursor: pointer;
  font: 500 0.9rem/1.2 var(--font-body);
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease;
}

.knobs button:hover,
.grid-controls button:hover {
  background: var(--accent-wash);
  border-color: var(--accent);
}

.grid-controls button[aria-pressed="true"] {
  background: var(--text);
  border-color: var(--text);
  color: #fff;
}

.knobs label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

.knobs output {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.knobs input[type="number"],
.knobs input[type="text"] {
  background: var(--panel-strong);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  font: inherit;
}

.knobs input[type="text"] {
  font-family: var(--font-mono);
}

.knobs input[type="range"] {
  width: 100%;
  margin: 0;
  accent-color: var(--accent);
}

/* On the downlink slider's scale; the inset matches the thumb's half width,
   which is how far from the input's edges its centre stops. */
.zones {
  position: relative;
  display: flex;
  height: 7px;
  margin: 0 8px 16px;
  border-radius: 999px;
  overflow: visible;
}

.zones .zone {
  height: 100%;
  opacity: 0.9;
}

.zones .zone:first-child {
  border-radius: 999px 0 0 999px;
}

.zones .zone.ok {
  border-radius: 0 999px 999px 0;
}

.zone.bad,
.key.bad {
  background: var(--bad);
}

.zone.warn,
.key.warn {
  background: var(--warn);
}

.zone.ok,
.key.ok {
  background: var(--accent);
}

.zones .tick {
  position: absolute;
  top: 10px;
  transform: translateX(-50%);
  font-size: 0.75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.zones .tick::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -12px;
  height: 10px;
  border-left: 1px solid var(--text);
}

.zones-hint {
  margin: 0;
}

ul.zones-hint {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  padding: 0;
  list-style: none;
}

.zones-hint .key {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  margin-right: 4px;
}

.knobs input:disabled {
  opacity: 0.6;
}

.knobs button:disabled {
  opacity: 0.6;
  cursor: default;
}

.publisher {
  margin: 0 0 8px;
}

.publisher .status {
  font-size: 0.9rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.publisher .status.publishing {
  color: #0f7a92;
}

.publisher .status.starting {
  color: var(--warn);
}

.publisher .status.reconnecting {
  color: var(--bad);
}

.error {
  color: var(--bad);
}

.series.strip-row {
  grid-template-columns: minmax(180px, 1fr) auto;
}

.series.strip-row .value {
  text-align: left;
  font-size: 0.85rem;
  color: var(--muted);
}

.strip {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 2px 0 4px;
}

.strip .cell {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  font-size: 9px;
  line-height: 14px;
  text-align: center;
  color: rgba(0, 0, 0, 0.55);
  background: #cfd5e4;
}

.strip .cell.labelled {
  width: auto;
  min-width: 14px;
  padding: 0 3px;
  font-variant-numeric: tabular-nums;
}

.strip .cell.ok {
  background: var(--accent-soft);
}

.strip .cell.partial {
  background: #f0a35a;
}

.strip .cell.missing {
  background: var(--bad);
}

.strip .cell.pending {
  background: #e0b34a;
}

.grid-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  margin-bottom: 14px;
}

.player-grid {
  display: grid;
  grid-template-columns: max-content 1fr 1fr;
  gap: 10px 14px;
  align-items: center;
}

.player-grid .col,
.player-grid .row {
  color: var(--muted);
  font-size: 0.85rem;
}

.player-grid .col strong {
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 600;
}

.player-grid .tile {
  align-self: start;
  min-width: 0;
  padding: 8px;
  background: var(--panel-strong);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
}

.player-grid .tile .series {
  grid-template-columns: minmax(90px, 1fr) 48px minmax(80px, 180px);
}

.player-grid .tile .series.strip-row {
  grid-template-columns: minmax(90px, 1fr) auto;
}

.player-grid .tile .spark {
  width: 100%;
}

.player-grid .row {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  text-align: center;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text);
}

.player-grid figure {
  margin: 0;
}

.player-grid canvas {
  display: block;
  width: 100%;
  aspect-ratio: 426 / 240;
  background: #0b1220;
  border-radius: 6px;
}

.player-grid figcaption {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  padding-top: 4px;
  overflow-wrap: anywhere;
}

.player-grid[data-show-expected="false"] .expected {
  display: none;
}

@media (max-width: 720px) {
  body {
    padding: 18px 14px 36px;
  }

  .player-grid {
    grid-template-columns: 1fr;
  }

  .player-grid .corner {
    display: none;
  }

  .player-grid .row {
    writing-mode: horizontal-tb;
    transform: none;
    text-align: left;
    padding-top: 8px;
  }

  .series {
    grid-template-columns: 1fr auto;
  }

  .series .spark {
    grid-column: 1 / -1;
    width: 100%;
  }
}
