:root {
  --bg: #10131a;
  --panel: #171c26;
  --panel2: #202838;
  --text: #edf2ff;
  --muted: #9ca9c2;
  --line: #344057;
  --good: #4ade80;
  --warn: #facc15;
  --bad: #fb7185;
  --accent: #8ab4ff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #1b2440 0, var(--bg) 50%);
  color: var(--text);
}

.app {
  width: min(1200px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}

h1, h2, h3, p { margin-top: 0; }

p { color: var(--muted); }

.status-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

.pill {
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 999px;
  white-space: nowrap;
}

.pill-good { border-color: var(--good); color: var(--good); }
.pill-warn { border-color: var(--warn); color: var(--warn); }
.pill-bad { border-color: var(--bad); color: var(--bad); }

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  background: rgba(23, 28, 38, 0.85);
  border: 1px solid var(--line);
  padding: 12px;
  border-radius: 18px;
  margin-bottom: 18px;
}

button, select, input {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

button.primary {
  background: #23416d;
  border-color: #4e7fc9;
}

button.danger {
  background: #5f1b2a;
  border-color: var(--bad);
}

button.play {
  background: #1f3f2b;
  border-color: var(--good);
}

.advanced,
.channel-card,
.log-panel {
  background: rgba(23, 28, 38, 0.92);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
  box-shadow: 0 12px 50px rgba(0,0,0,0.25);
}

.hidden { display: none; }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
}

input, select {
  width: 100%;
  color: var(--text);
  background: #0f1420;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}

.note {
  margin: 14px 0 0;
  font-size: 0.95rem;
}

.channels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 18px;
}

.channel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.cap {
  color: var(--accent);
  font-weight: 700;
  white-space: nowrap;
}

.level-row {
  display: grid;
  grid-template-columns: 70px 1fr 70px;
  gap: 12px;
  align-items: stretch;
  margin: 16px 0;
}

.level-row button {
  font-size: 1.6rem;
  font-weight: 800;
}

.level-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #0f1420;
  border: 1px solid var(--line);
  border-radius: 16px;
  min-height: 78px;
}

.level-box span {
  color: var(--muted);
  font-size: 0.9rem;
}

.level-box strong {
  font-size: 2.4rem;
  line-height: 1;
}

.pattern-block {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.summary {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.45;
  min-height: 70px;
}

.control-row {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.control-row button {
  flex: 1;
}

.meter {
  height: 12px;
  background: #0b101a;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 16px;
}

.meter-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #4e7fc9, #8ab4ff);
  transition: width 80ms linear;
}

.live-readout {
  margin-top: 10px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.92rem;
  min-height: 42px;
}

.log-panel {
  margin-top: 18px;
}

pre {
  margin: 0;
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  color: #c8d3ea;
}

@media (max-width: 850px) {
  .hero, .channels {
    grid-template-columns: 1fr;
    display: grid;
  }

  .status-stack {
    align-items: flex-start;
  }

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