:root {
  --bg: #0f1512;
  --surface: #161f1a;
  --surface-raised: #1c2620;
  --line: #29352e;
  --text: #edefea;
  --text-muted: #8a978f;
  --text-dim: #5c6862;
  --amber: #e8a33d;
  --danger: #e5484d;
  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-display);
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ─────────────────────────────────────────────── */

.board-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 28px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(232, 163, 61, 0.15);
  flex-shrink: 0;
  animation: pulse-mark 2.4s ease-in-out infinite;
}

@keyframes pulse-mark {
  0%, 100% {
    box-shadow: 0 0 0 4px rgba(232, 163, 61, 0.15);
  }

  50% {
    box-shadow: 0 0 0 8px rgba(232, 163, 61, 0.06);
  }
}

.brand-text h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-sub {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  text-transform: lowercase;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.summary {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-muted);
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

  .summary #summary-connected {
    color: var(--amber);
    font-weight: 600;
  }

.btn {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 14px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

  .btn:hover {
    border-color: var(--amber);
    background: var(--surface-raised);
  }

  .btn.active {
    color: var(--amber);
    border-color: var(--amber);
  }

/* ── Grid & cards ───────────────────────────────────────── */

.grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 16px;
  padding: 20px 28px 28px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 3px solid var(--source-color, var(--amber));
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  min-height: 320px;
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  gap: 10px;
}

.card-id {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

  .dot.connected {
    background: var(--source-color, var(--amber));
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--source-color, var(--amber)) 25%, transparent);
  }

  .dot.connecting {
    background: var(--text-muted);
    animation: blink 1s step-start infinite;
  }

  .dot.offline {
    background: var(--danger);
  }

@keyframes blink {
  50% {
    opacity: 0.2;
  }
}

.card-name {
  font-family: var(--font-mono);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.event-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}

/* VU meter — the signature element. Bars flick up on each event received. */
.vu {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 16px;
}

  .vu span {
    width: 3px;
    height: 4px;
    border-radius: 1px;
    background: var(--line);
    transition: height 0.15s ease, background 0.15s ease;
  }

.card-icon-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
}

  .card-icon-btn:hover {
    color: var(--text);
    background: var(--surface-raised);
  }

.log {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.log-empty {
  color: var(--text-dim);
  font-style: italic;
  margin: auto 0;
  text-align: center;
}

.log-entry {
  border-left: 2px solid var(--line);
  padding-left: 8px;
  animation: enter 0.2s ease;
}

@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(-2px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.log-entry .ts {
  color: var(--text-dim);
  margin-right: 8px;
}

.log-entry .payload {
  color: var(--text);
  word-break: break-word;
  white-space: pre-wrap;
}

.log-entry.system {
  border-left-color: var(--text-dim);
  color: var(--text-muted);
  font-style: italic;
}

.log::-webkit-scrollbar {
  width: 8px;
}

.log::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 4px;
}

/* ── Footer ─────────────────────────────────────────────── */

.board-footer {
  padding: 10px 28px;
  border-top: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}

@media (prefers-reduced-motion: reduce) {
  .brand-mark, .dot.connecting, .log-entry {
    animation: none;
  }
}
