/* ── Reset & Basis ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg0:     #0d0d12;
  --bg1:     #13131a;
  --bg2:     #1a1a24;
  --bg3:     #22222f;
  --bg4:     #2c2c3e;
  --accent:  #e85d04;
  --accent2: #ff8533;
  --green:   #22c55e;
  --blue:    #3b82f6;
  --yellow:  #eab308;
  --red:     #ef4444;
  --purple:  #a855f7;
  --text1:   #f0f0f8;
  --text2:   #a0a0b8;
  --text3:   #606078;
  --border:  #2a2a3a;
  --radius:  8px;
  --mono:    'JetBrains Mono', 'Fira Mono', 'Cascadia Code', monospace;
  --sans:    'Inter', 'Segoe UI', system-ui, sans-serif;
}

html, body {
  height: 100%;
  background: var(--bg0);
  color: var(--text1);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
}

#app {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 0 48px;
  min-height: 100vh;
}

/* ── Header ─────────────────────────────────────────────────────────────────── */
.page-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  background: var(--bg1);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

/* Now-Playing im Header */
.header-np {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  overflow: hidden;
}

.header-np-cover {
  width: 38px;
  height: 38px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg3);
}

.header-np-info {
  min-width: 0;
  flex: 1;
}

.header-np-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-np-artist {
  font-size: 11px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 1.3em;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.01em;
}

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

.status-group {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text2);
  font-family: var(--mono);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-idle    { background: var(--text3); }
.dot-playing { background: var(--green); box-shadow: 0 0 6px var(--green); animation: pulse 2s infinite; }
.dot-error   { background: var(--red); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.45; }
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text2);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.btn-icon:hover { background: var(--bg4); color: var(--text1); }

/* ── Stream Player ──────────────────────────────────────────────────────────── */
.stream-section {
  padding: 12px 20px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
}

#audio-player {
  width: 100%;
  height: 36px;
  accent-color: var(--accent);
  filter: invert(0.9) hue-rotate(200deg) brightness(0.85);
}

/* ── Section Label ──────────────────────────────────────────────────────────── */
.section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text3);
  margin-bottom: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--bg4);
  border-radius: 9px;
  font-size: 10px;
  font-family: var(--mono);
  color: var(--text2);
}

/* ── List Sections (History & Queue) ────────────────────────────────────────── */
.list-section {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

.compact-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.empty-hint {
  font-size: 12px;
  color: var(--text3);
  padding: 6px 0;
  font-style: italic;
}

/* Compact track row (used in history and queue) */
.ctrack {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 6px;
  transition: background 0.1s;
}
.ctrack:hover { background: var(--bg2); }

.ctrack-num {
  font-size: 10px;
  font-family: var(--mono);
  color: var(--text3);
  min-width: 16px;
  text-align: right;
  flex-shrink: 0;
}

.ctime {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text3);
  min-width: 52px;
  flex-shrink: 0;
}

.ctrack-info {
  flex: 1;
  min-width: 0;
}

.ctrack-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ctrack-artist {
  font-size: 11px;
  color: var(--text2);
  min-height: 1.4em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ctrack-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex-shrink: 0;
}

.ctrack-dur {
  font-size: 10px;
  font-family: var(--mono);
  color: var(--text3);
}

/* ── Typ-Badges ─────────────────────────────────────────────────────────────── */
.typ-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--mono);
  letter-spacing: 0.04em;
  background: var(--bg4);
  color: var(--text2);
  border: 1px solid var(--border);
  flex-shrink: 0;
}
/* Musik */
.typ-M,  .typ-MU  { background: rgba(59,130,246,0.15); color: #93c5fd; border-color: rgba(59,130,246,0.3); }
/* Jingle/Station-ID */
.typ-J,  .typ-JI  { background: rgba(34,197,94,0.15);  color: #86efac; border-color: rgba(34,197,94,0.3); }
/* Nachrichten */
.typ-N,  .typ-NA  { background: rgba(234,179,8,0.15);  color: #fde047; border-color: rgba(234,179,8,0.3); }
/* Werbung */
.typ-W,  .typ-WB  { background: rgba(168,85,247,0.15); color: #d8b4fe; border-color: rgba(168,85,247,0.3); }
/* Sondersendung */
.typ-S,  .typ-SP  { background: rgba(239,68,68,0.15);  color: #fca5a5; border-color: rgba(239,68,68,0.3); }
/* Kinderprogramm */
.typ-K            { background: rgba(251,146,60,0.15); color: #fdba74; border-color: rgba(251,146,60,0.3); }

/* ── Player Stage ───────────────────────────────────────────────────────────── */
.player-stage-section {
  padding: 14px 20px 18px;
  background: var(--bg1);
  border-bottom: 1px solid var(--border);
}

.stage-slots {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ── Slot: prev (läuft gerade aus → leicht rot) ───────────────────── */
.stage-slot--prev {
  opacity: 0.45;
  transition: opacity 0.6s, background 0.6s;
  padding: 8px 12px;
  min-height: 60px;
  border-radius: var(--radius);
  background: rgba(239, 68, 68, 0.07);
  border-left: 3px solid rgba(239, 68, 68, 0.3);
  margin-bottom: 4px;
}

.slot-prev-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.slot-prev-row .ctrack-title  { font-size: 12px; color: var(--text2); }
.slot-prev-row .ctrack-artist { font-size: 11px; color: var(--text3); min-height: 1.4em; }

/* ── Slot: current (On Air → rot) ─────────────────────────────────── */
.stage-slot--current {
  padding: 8px 12px;
  min-height: 60px;
  border-radius: var(--radius);
  background: rgba(239, 68, 68, 0.13);
  border-left: 3px solid rgba(239, 68, 68, 0.7);
  margin-bottom: 4px;
}

@keyframes slideInUp {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.stage-slot--current.animate-in {
  animation: slideInUp 0.45s ease forwards;
}

.slot-current-inner {
  display: block;
}

.slot-current-header {
  display: flex;
  align-items: stretch;
  gap: 10px;
}

/* Titel/Interpret im Waveform-Overlay */
.slot-current-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 4px rgba(0,0,0,0.9);
  line-height: 1.3;
}

.slot-current-artist {
  font-size: 10px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 4px rgba(0,0,0,0.9);
  line-height: 1.3;
}

.slot-current-idle {
  font-size: 12px;
  color: var(--text3);
  font-style: italic;
}

/* Waveform – jetzt im Header-Row eingebettet */
.waveform-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}

.waveform-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-radius: 4px;
  padding: 4px 7px;
  background:
    linear-gradient(to bottom, rgba(8,8,12,0.75) 0%, transparent 50%),
    linear-gradient(to top,    rgba(8,8,12,0.75) 0%, transparent 50%);
}

.waveform-overlay-top { display: flex; flex-direction: column; }

.waveform-overlay-bottom {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text2);
}

.waveform-canvas {
  display: block;
  width: 100%;
  height: 44px;
  border-radius: 4px;
  background: var(--bg3);
}

/* ── Slot: next (bereit → grün) ────────────────────────────────────── */
.stage-slot--next {
  opacity: 0.65;
  transition: opacity 0.6s, background 0.6s;
  padding: 8px 12px;
  min-height: 60px;
  border-radius: var(--radius);
  background: rgba(34, 197, 94, 0.10);
  border-left: 3px solid rgba(34, 197, 94, 0.5);
}

.slot-next-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.slot-time {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text3);
  min-width: 52px;
  flex-shrink: 0;
  align-self: center;
}

.slot-current-header .typ-badge {
  align-self: center;
}

.slot-current-header .ctrack-meta {
  align-self: center;
}

.slot-next-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text3);
  font-family: var(--mono);
  flex-shrink: 0;
  min-width: 32px;
}

.slot-next-row .ctrack-title  { font-size: 12px; }
.slot-next-row .ctrack-artist { font-size: 11px; min-height: 1.4em; }

/* ── Log-Viewer ─────────────────────────────────────────────────────────────── */
.log-section {
  padding: 12px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.log-output {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.55;
  height: 220px;
  overflow-y: auto;
  background: var(--bg0);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  color: var(--text2);
}

.log-line { padding: 0; white-space: pre-wrap; word-break: break-all; }
.log-line.log-warn  { color: var(--yellow); }
.log-line.log-error { color: var(--red); }

.log-ts {
  color: var(--text3);
  margin-right: 8px;
  user-select: none;
}

.btn-small {
  width: 22px;
  height: 22px;
}

.btn-active {
  background: var(--bg4);
  color: var(--accent);
  border-color: var(--accent);
}

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .page-header       { padding: 12px 14px; }
  .header-brand      { font-size: 15px; }
  .stream-section    { padding: 10px 14px; }
  .list-section      { padding: 12px 14px; }
  .player-stage-section { padding: 12px 14px 16px; }
  .slot-cover-wrap   { width: 76px; height: 76px; }
  .slot-current-title { font-size: 16px; }
}
