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

:root {
  --bg: #07070b;
  --surface: rgba(255,255,255,0.03);
  --border: rgba(255,255,255,0.07);
  --text: #d4d4d8;
  --text-dim: #71717a;
  --accent: #8b5cf6;
  --accent-dim: rgba(139,92,246,0.15);
  --font: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', monospace;
  --radius: 8px;
  --transition: 150ms ease;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 12px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

/* ── App Layout ──────────────────────────────────────── */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ── Top Bar ─────────────────────────────────────────── */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 40px;
  padding: 0 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
}
.top-left, .top-right { display: flex; align-items: center; gap: 10px; }
.logo {
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.05em;
  color: var(--accent);
}
.file-name {
  color: var(--text-dim);
  font-size: 11px;
  max-width: 400px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Listener Badge ──────────────────────────────────── */
.listener-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 12px;
  background: rgba(255,255,255,0.04);
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.listener-badge svg {
  opacity: 0.6;
}

/* ── Buttons ─────────────────────────────────────────── */
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: all var(--transition);
}
.icon-btn:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--text);
}

/* ── Canvas Area ─────────────────────────────────────── */
.canvas-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}
.canvas-wrap canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}
#glowCanvas {
  pointer-events: none;
  mix-blend-mode: screen;
  filter: blur(12px);
}

/* ── Transport (read-only) ───────────────────────────── */
.transport {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 44px;
  padding: 0 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
}

.transport-timeline {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}
.time-display {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
  min-width: 36px;
  text-align: center;
}

.progress-wrap {
  flex: 1;
  height: 28px;
  display: flex;
  align-items: center;
}
.progress-track {
  position: relative;
  width: 100%;
  height: 3px;
  background: rgba(255,255,255,0.06);
  border-radius: 2px;
  overflow: hidden;
}
.progress-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 80ms linear;
}

/* ── Info Badges ─────────────────────────────────────── */
.transport-info { display: flex; gap: 8px; }
.info-badge {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(255,255,255,0.04);
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

/* ── Start Overlay ───────────────────────────────────── */
.start-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 7, 11, 0.88);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: opacity 400ms ease, visibility 400ms ease;
}
.start-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.start-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.start-icon {
  font-size: 48px;
  color: var(--accent);
  animation: pulse 2s ease-in-out infinite;
}
.start-text {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: 0.02em;
}

@keyframes pulse {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.1); }
}

/* ── Next Song Notification Card ─────────────────────── */
.next-song-card {
  position: fixed;
  top: -120px;
  left: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: rgba(14, 14, 20, 0.92);
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: 12px;
  backdrop-filter: blur(16px);
  z-index: 60;
  transition: top 600ms cubic-bezier(0.34, 1.56, 0.64, 1),
              opacity 400ms ease;
  opacity: 0;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4),
              0 0 20px rgba(139, 92, 246, 0.1);
}
.next-song-card.visible {
  top: 52px;
  opacity: 1;
}
.next-song-icon {
  font-size: 24px;
  color: var(--accent);
  animation: noteFloat 2s ease-in-out infinite;
}
@keyframes noteFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}
.next-song-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.next-song-label {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--accent);
}
.next-song-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Chat Panel ──────────────────────────────────────── */
.chat-panel {
  position: fixed;
  top: 48px;
  right: 12px;
  width: min(340px, calc(100vw - 24px));
  height: min(420px, calc(100vh - 120px));
  background: rgba(10, 10, 16, 0.88);
  border: 1px solid var(--border);
  border-radius: 12px;
  backdrop-filter: blur(20px);
  z-index: 50;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px) scale(0.97);
  transition: opacity 200ms ease,
              visibility 200ms ease,
              transform 200ms cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}
.chat-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.chat-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-dim);
  font-size: 16px;
  cursor: pointer;
  transition: all var(--transition);
}
.chat-close-btn:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text);
}

/* ── Chat Messages ───────────────────────────────────── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-msg {
  font-size: 11px;
  line-height: 1.5;
  padding: 3px 0;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.chat-name {
  font-weight: 600;
  margin-right: 6px;
}
.chat-text {
  color: var(--text);
}
.chat-system {
  color: var(--text-dim);
  font-style: italic;
  font-size: 10px;
}

/* ── Chat Input ──────────────────────────────────────── */
.chat-input-wrap {
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-input {
  flex: 1;
  padding: 7px 10px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font);
  font-size: 11px;
  outline: none;
  transition: border-color var(--transition);
}
.chat-input:focus {
  border-color: var(--accent);
}
.chat-input::placeholder {
  color: var(--text-dim);
}
.chat-send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent-dim);
  color: var(--accent);
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}
.chat-send-btn:hover {
  background: var(--accent);
  color: #fff;
}

/* ── Queue Panel ─────────────────────────────────────── */
.queue-panel {
  position: fixed;
  top: 48px;
  right: 12px;
  width: min(320px, calc(100vw - 24px));
  max-height: min(450px, calc(100vh - 120px));
  background: rgba(10, 10, 16, 0.92);
  border: 1px solid var(--border);
  border-radius: 12px;
  backdrop-filter: blur(20px);
  z-index: 50;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px) scale(0.97);
  transition: opacity 200ms ease,
              visibility 200ms ease,
              transform 200ms cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}
.queue-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.queue-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.queue-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.queue-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}

.queue-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  transition: background 150ms ease;
}
.queue-item:hover {
  background: rgba(255,255,255,0.03);
}

.queue-num {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-dim);
  min-width: 16px;
  text-align: center;
  opacity: 0.5;
}

.queue-info {
  flex: 1;
  min-width: 0;
}
.queue-song-name {
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.queue-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 1px;
  font-variant-numeric: tabular-nums;
}
.queue-sep {
  opacity: 0.3;
}
.queue-starts-in {
  color: var(--accent);
  font-weight: 500;
}

.queue-empty {
  padding: 24px 14px;
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
}

/* ── Scrollbar ───────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

/* ── Responsive: Tablets ─────────────────────────────── */
@media (max-width: 768px) {
  .top-bar { height: 36px; padding: 0 10px; }
  .logo { font-size: 12px; }
  .file-name { max-width: 180px; font-size: 10px; }
  .top-left, .top-right { gap: 6px; }
  .icon-btn { width: 28px; height: 28px; }
  .icon-btn svg { width: 15px; height: 15px; }

  .transport { height: 36px; padding: 0 10px; gap: 10px; }
  .time-display { font-size: 10px; min-width: 30px; }
  .transport-timeline { gap: 6px; }
  .transport-info { display: none; }

  .next-song-card {
    left: 8px;
    right: 8px;
    padding: 10px 14px;
    gap: 10px;
    top: -100px;
  }
  .next-song-card.visible { top: 44px; }
  .next-song-icon { font-size: 20px; }
  .next-song-label { font-size: 8px; }
  .next-song-name { font-size: 11px; max-width: none; }

  .listener-badge { font-size: 9px; padding: 2px 6px; }

  .queue-panel {
    top: 36px;
    right: 8px;
    left: 8px;
    width: auto;
  }
}

/* ── Responsive: Mobile ─────────────────────────────── */
@media (max-width: 480px) {
  .top-bar { height: 34px; padding: 0 8px; }
  .logo { font-size: 11px; letter-spacing: 0; }
  .file-name { max-width: 120px; font-size: 9px; }

  .transport { height: 32px; padding: 0 8px; gap: 6px; }
  .time-display { font-size: 9px; min-width: 26px; }

  .start-icon { font-size: 36px; }
  .start-text { font-size: 13px; }

  .chat-panel {
    top: 34px;
    right: 0;
    left: 0;
    width: 100%;
    height: calc(100vh - 34px - 32px);
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
  .chat-input { font-size: 14px; padding: 8px 10px; }
  .chat-msg { font-size: 12px; }
  .chat-name { font-size: 12px; }

  .next-song-card {
    left: 6px;
    right: 6px;
    padding: 8px 12px;
  }
  .next-song-card.visible { top: 40px; }

  .queue-panel {
    top: 34px;
    right: 0;
    left: 0;
    width: 100%;
    max-height: calc(100vh - 34px - 32px);
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
}
