:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: #080a0d;
  color: #f3f4f6;
  --panel: #11151a;
  --line: #283039;
  --muted: #8c98a5;
  --accent: #68f0b2;
  --danger: #ff6b6b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 85% -10%, rgba(104, 240, 178, 0.12), transparent 34rem),
    #080a0d;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 0.55rem;
  padding: 0.72rem 1rem;
  background: var(--accent);
  color: #06130d;
  font-weight: 800;
  cursor: pointer;
}

button.secondary {
  background: #222a32;
  color: #e5e7eb;
}

button.danger {
  background: rgba(255, 107, 107, 0.15);
  color: #ff9d9d;
}

.shell {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 4rem;
}

.masthead,
.panel-heading,
.player-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 7vw, 4.8rem);
  letter-spacing: -0.065em;
}

h2 {
  margin-bottom: 0.35rem;
}

.eyebrow {
  margin-bottom: 0.45rem;
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 850;
  letter-spacing: 0.15em;
}

.state {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.55rem 0.8rem;
  color: var(--muted);
  font: 750 0.72rem ui-monospace, monospace;
}

.state-healthy {
  border-color: rgba(104, 240, 178, 0.5);
  background: rgba(104, 240, 178, 0.08);
  color: var(--accent);
}

.state-failed,
.state-recovering {
  border-color: rgba(255, 107, 107, 0.5);
  color: #ff9d9d;
}

.panel {
  margin-top: 1rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 1.35rem;
  background: rgba(17, 21, 26, 0.92);
}

.login-panel {
  display: grid;
  grid-template-columns: 1fr minmax(17rem, 26rem);
  gap: 3rem;
  margin-top: 5rem;
}

label {
  display: grid;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 0.72rem 0.75rem;
  background: #0b0e12;
  color: #f3f4f6;
}

form {
  display: grid;
  gap: 0.9rem;
}

.error {
  min-height: 1rem;
  color: #ff9d9d;
  font-size: 0.8rem;
}

.signal-flow-section {
  margin-top: 2rem;
  border: 1px solid rgba(104, 240, 178, 0.2);
  border-radius: 1rem;
  padding: 1.35rem;
  background: linear-gradient(135deg, rgba(104, 240, 178, 0.06), var(--panel) 55%);
  box-shadow: 0 1.2rem 4rem rgba(0, 0, 0, 0.2);
}

.signal-flow-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
}

.signal-flow-heading p:last-child {
  max-width: 26rem;
  margin-bottom: 0.2rem;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: right;
}

.signal-flow {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr auto 1fr;
  align-items: center;
  gap: 0.65rem;
  margin-top: 1.2rem;
}

.flow-node,
.metric {
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  padding: 1rem;
  background: var(--panel);
}

.flow-node {
  display: grid;
  min-height: 8.5rem;
  align-content: space-between;
  transition: border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.flow-node-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.flow-check {
  display: grid;
  width: 1.55rem;
  height: 1.55rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  place-items: center;
  color: transparent;
  font-size: 0.78rem;
  font-weight: 900;
}

.flow-node.is-active {
  border-color: rgba(104, 240, 178, 0.72);
  background: rgba(104, 240, 178, 0.1);
  box-shadow: 0 0 0 1px rgba(104, 240, 178, 0.08), 0 0 2rem rgba(104, 240, 178, 0.08);
}

.flow-node.is-active .flow-check {
  border-color: var(--accent);
  background: var(--accent);
  color: #06130d;
}

.flow-node.is-active strong,
.flow-node.is-active small {
  color: #e9fff5;
}

.flow-node.is-waiting {
  border-color: rgba(255, 204, 102, 0.42);
}

.flow-node.is-degraded {
  border-color: rgba(255, 107, 107, 0.55);
  background: rgba(255, 107, 107, 0.06);
}

.flow-node span,
.flow-node small,
.metric span {
  color: var(--muted);
}

.flow-line {
  width: 1.3rem;
  height: 1px;
  background: var(--line);
  transition: background 180ms ease, box-shadow 180ms ease;
}

.flow-line.is-active {
  background: var(--accent);
  box-shadow: 0 0 0.8rem rgba(104, 240, 178, 0.5);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.7rem;
  margin-top: 1.2rem;
}

.metric {
  display: grid;
  gap: 0.5rem;
}

.metric strong {
  font: 750 1.35rem ui-monospace, monospace;
}

audio {
  width: min(100%, 34rem);
}

.actions {
  display: flex;
  gap: 0.5rem;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

button.is-current:not(.is-pending) {
  outline: 1px solid rgba(104, 240, 178, 0.4);
  outline-offset: 2px;
}

button.is-pending {
  position: relative;
  padding-left: 2.25rem;
  opacity: 1;
}

button.is-pending::before {
  position: absolute;
  top: 50%;
  left: 0.85rem;
  width: 0.8rem;
  height: 0.8rem;
  border: 2px solid currentcolor;
  border-right-color: transparent;
  border-radius: 999px;
  content: '';
  animation: button-spin 700ms linear infinite;
  transform: translateY(-50%);
}

@keyframes button-spin {
  to {
    transform: translateY(-50%) rotate(360deg);
  }
}

.player-status,
.output-panel p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.output-panel {
  display: grid;
  grid-template-columns: minmax(15rem, 0.8fr) minmax(20rem, 1.2fr);
  align-items: end;
  gap: 2rem;
}

.output-url-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.6rem;
}

.config-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 1.2rem;
}

.wide {
  grid-column: 1 / -1;
}

.form-footer {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.events {
  display: grid;
  gap: 0.5rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}

.events li {
  display: grid;
  gap: 0.2rem;
  border-top: 1px solid var(--line);
  padding: 0.75rem 0;
}

.events span {
  color: var(--muted);
  font-size: 0.78rem;
}

.hidden {
  display: none !important;
}

@media (max-width: 760px) {
  .login-panel,
  .config-grid,
  .metric-grid,
  .output-panel {
    grid-template-columns: 1fr;
  }

  .output-url-row {
    grid-template-columns: 1fr;
  }

  .signal-flow {
    grid-template-columns: 1fr;
  }

  .signal-flow-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .signal-flow-heading p:last-child {
    text-align: left;
  }

  .flow-line {
    width: 1px;
    height: 1rem;
    margin-left: 50%;
  }

  .wide {
    grid-column: auto;
  }

  .masthead,
  .panel-heading,
  .player-panel {
    align-items: flex-start;
    flex-direction: column;
  }
}
