:root {
  --bg: #10141C;
  --panel: #171E29;
  --panel-raised: #1E2733;
  --line: #2B3444;
  --text: #ECEEF2;
  --text-dim: #8791A3;
  --amber: #E7B23A;
  --amber-dim: #6B5626;
  --signal: #5FBF8F;
  --warn: #D9694F;
  --radius: 6px;
  --font-display: "Fraunces", Georgia, serif;
  --font-ui: "IBM Plex Sans", -apple-system, sans-serif;
  --font-mono: "IBM Plex Mono", monospace;
}

* { box-sizing: border-box; }

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

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

/* ---------- Top bar ---------- */

.topbar {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 22px 28px 18px;
  border-bottom: 1px solid var(--line);
}

.wordmark {
  font-family: var(--font-display);
  font-optical-sizing: auto;
  font-weight: 600;
  font-size: 26px;
  letter-spacing: 0.01em;
  color: var(--text);
}

.tagline {
  font-size: 13px;
  color: var(--text-dim);
}

/* ---------- Layout ---------- */

.layout {
  display: flex;
  flex: 1;
  min-height: 0;
}

.rail {
  width: 260px;
  flex-shrink: 0;
  padding: 24px 20px 90px;
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.readout {
  margin-bottom: 28px;
}

.readout-number {
  font-family: var(--font-display);
  font-optical-sizing: auto;
  font-weight: 500;
  font-size: 44px;
  line-height: 1;
  color: var(--amber);
  font-variant-numeric: tabular-nums;
}

.readout-label {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}

.field {
  margin-bottom: 20px;
}

.field label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.field input[type="text"],
.field select {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  padding: 9px 10px;
}

.field input[type="text"]:focus-visible,
.field select:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 1px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  font-size: 12.5px;
  font-family: var(--font-ui);
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 5px 12px;
  cursor: pointer;
}

.chip:hover { color: var(--text); border-color: #3a4557; }

.chip.active {
  color: var(--bg);
  background: var(--amber);
  border-color: var(--amber);
}

.chip:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

.toggle-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-family: var(--font-ui);
  font-size: 13.5px;
  padding: 9px 10px;
  cursor: pointer;
}

.toggle-btn .icon {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
}

.toggle-btn[aria-pressed="true"] {
  color: var(--amber);
  border-color: var(--amber-dim);
}

.toggle-btn[aria-pressed="true"] .icon {
  fill: var(--amber);
  stroke: var(--amber);
}

.toggle-btn:focus-visible { outline: 2px solid var(--amber); outline-offset: 1px; }

.reset-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: var(--font-ui);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  padding: 0;
}

.reset-btn:hover { color: var(--text); }

.rail-toggle {
  display: none;
}

/* ---------- Station list ---------- */

.stationarea {
  flex: 1;
  min-width: 0;
  padding: 24px 28px 100px;
  overflow-y: auto;
}

.status {
  font-size: 13.5px;
  color: var(--text-dim);
  min-height: 18px;
  margin-bottom: 8px;
}

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

.stationlist {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
}

.station-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 13px 4px;
  border-bottom: 1px solid var(--line);
}

.station-row:hover { background: var(--panel); }

.station-row.playing {
  background: var(--panel-raised);
}

.station-main {
  flex: 1;
  min-width: 0;
}

.station-name {
  font-size: 14.5px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.station-sub {
  font-size: 12.5px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.station-readout {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  width: 92px;
  flex-shrink: 0;
  text-align: right;
}

.station-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.icon-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.icon-btn:hover { color: var(--text); }

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

.icon-btn.play-btn.is-playing {
  color: var(--signal);
  border-color: var(--signal);
}

.icon-btn:focus-visible { outline: 2px solid var(--amber); outline-offset: 1px; }

.loadmore-wrap {
  display: flex;
  justify-content: center;
  padding: 22px 0 10px;
}

.loadmore-btn {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 13.5px;
  border-radius: var(--radius);
  padding: 9px 18px;
  cursor: pointer;
}

.loadmore-btn:hover { border-color: var(--amber-dim); }

/* ---------- Player bar ---------- */

.playerbar {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px 28px;
  background: var(--panel);
  border-top: 1px solid var(--line);
}

.playerbar-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.signal-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--line);
  flex-shrink: 0;
}

.signal-dot.live {
  background: var(--signal);
  box-shadow: 0 0 0 3px rgba(95, 191, 143, 0.18);
}

@media (prefers-reduced-motion: no-preference) {
  .signal-dot.live { animation: pulse 2.4s ease-in-out infinite; }
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(95, 191, 143, 0.18); }
  50% { box-shadow: 0 0 0 6px rgba(95, 191, 143, 0.10); }
}

.playerbar-text { min-width: 0; }

.playerbar-name {
  font-family: var(--font-display);
  font-size: 15.5px;
  font-style: italic;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.playerbar-meta {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.playerbar-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.stop-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel-raised);
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.stop-btn svg { width: 16px; height: 16px; fill: currentColor; }

.stop-btn:not(:disabled):hover { color: var(--warn); border-color: var(--warn); }
.stop-btn:disabled { opacity: 0.4; cursor: default; }
.stop-btn:focus-visible { outline: 2px solid var(--amber); outline-offset: 1px; }

.volume-label {
  font-size: 12px;
  color: var(--text-dim);
  display: none;
}

#volumeSlider {
  width: 110px;
  accent-color: var(--amber);
}

/* ---------- Responsive ---------- */

@media (min-width: 720px) {
  .volume-label { display: inline; }
}

@media (max-width: 860px) {
  .layout { position: relative; }

  .rail {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 20;
    background: var(--bg);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    padding-top: 70px;
    width: 82vw;
    max-width: 300px;
  }

  .rail.open { transform: translateX(0); }

  .rail-toggle {
    display: block;
    position: fixed;
    top: 16px;
    right: 20px;
    z-index: 21;
    background: var(--panel);
    border: 1px solid var(--line);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 13px;
    border-radius: 999px;
    padding: 8px 16px;
    cursor: pointer;
  }

  .topbar { padding-right: 110px; }

  .stationarea { padding: 20px 16px 100px; }

  .station-sub { display: none; }

  .station-readout { width: 60px; }
}

@media (prefers-reduced-motion: reduce) {
  .rail { transition: none; }
}
