/* ═══════════════════════════════════════════
   CLOUDIO — Ready Player One inspired
   Cyan + Warm Amber · Dual Coordinated Accents
   ═══════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600&family=Noto+Sans+SC:wght@300;400;500;700&family=JetBrains+Mono:wght@300;400;500;700&display=swap');

/* ── Dark Mode: deep navy + cyan primary + warm amber ── */
:root {
  --bg: #080d16;
  --bg-card: #0e1420;
  --bg-input: #111828;
  --bg-elevated: #151c2a;
  --text: #c0c8d4;
  --text-dim: #586474;
  --text-bright: #e4eaf2;
  /* 主色: 青色 — 系统UI、进度条、播放状态 */
  --accent: #00d4e0;
  --accent-soft: rgba(0, 212, 224, 0.08);
  --accent-glow: 0 0 12px rgba(0, 212, 224, 0.2);
  --accent-glow-strong: 0 0 20px rgba(0, 212, 224, 0.35);
  /* 暖色: 琥珀 — 用户消息、发送按钮、高亮 */
  --warm: #e89440;
  --warm-soft: rgba(232, 148, 64, 0.08);
  --warm-glow: 0 0 12px rgba(232, 148, 64, 0.2);
  --warm-glow-strong: 0 0 20px rgba(232, 148, 64, 0.3);
  --border: #182028;
  --border-active: #1e2a38;
  --radius: 3px;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  --font-body: 'Space Grotesk', 'Noto Sans SC', sans-serif;
  --bg-gradient: radial-gradient(ellipse at 50% 0%, rgba(0, 212, 224, 0.03) 0%, transparent 60%),
                  linear-gradient(180deg, #080d16 0%, #0b101a 100%);
}

/* ── Light Mode ── */
[data-theme="light"] {
  --bg: #f0f2f5;
  --bg-card: #e8eaef;
  --bg-input: #e0e3e8;
  --bg-elevated: #ebeef3;
  --text: #2a2e35;
  --text-dim: #7a7f8a;
  --text-bright: #1a1e25;
  --accent: #008899;
  --accent-soft: rgba(0, 136, 153, 0.08);
  --accent-glow: 0 0 8px rgba(0, 136, 153, 0.15);
  --accent-glow-strong: 0 0 16px rgba(0, 136, 153, 0.2);
  --warm: #c07030;
  --warm-soft: rgba(192, 112, 48, 0.08);
  --warm-glow: 0 0 8px rgba(192, 112, 48, 0.15);
  --warm-glow-strong: none;
  --border: #d5d3ce;
  --border-active: #b8b5af;
  --bg-gradient: none;
}

/* ══════════════════════════════════════════
   RESET & BASE
   ══════════════════════════════════════════ */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  background-image:
    /* vignette */
    radial-gradient(ellipse at 50% 30%, rgba(0,212,224,0.04) 0%, transparent 70%),
    /* subtle noise-like dots */
    radial-gradient(circle at 20% 40%, rgba(0,212,224,0.015) 0%, transparent 50%),
    radial-gradient(circle at 80% 60%, rgba(232,148,64,0.01) 0%, transparent 50%),
    /* base gradient */
    linear-gradient(180deg, #080d16 0%, #0b111c 50%, #080d16 100%);
  color: var(--text);
  overflow: hidden;
  height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  -webkit-font-smoothing: antialiased;
  font-weight: 350;
}

/* ── Scanline + grid overlay ── */
#scanlines {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.05;
  background-image:
    /* horizontal scanlines */
    repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,212,224,0.025) 2px, rgba(0,212,224,0.025) 3px),
    /* subtle vertical grid lines */
    linear-gradient(90deg, rgba(0,212,224,0.015) 1px, transparent 1px);
  background-size: 100% 4px, 64px 100%;
}

.screen { display: none; }
.screen.active { display: flex; }

/* ══════════════════════════════════════════
   TOP BAR
   ══════════════════════════════════════════ */
#top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  z-index: 50;
}

#top-bar .top-brand {
  color: var(--accent);
  font-weight: 500;
  letter-spacing: 0.15em;
  font-size: 11px;
  opacity: 0.7;
  text-shadow: var(--accent-glow);
}

#top-bar .top-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

#top-bar button {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 9px;
  font-family: var(--font-mono);
  cursor: pointer;
  padding: 3px 8px;
  letter-spacing: 0.06em;
  border-radius: var(--radius);
  transition: all 0.2s;
}

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

#btn-logout:hover {
  border-color: var(--warm) !important;
  color: var(--warm) !important;
}

#theme-toggle {
  font-size: 14px !important;
  padding: 2px 6px !important;
  line-height: 1;
}

/* ══════════════════════════════════════════
   LOGIN SCREEN
   ══════════════════════════════════════════ */
#login-screen {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100dvh;
  padding: 24px;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 44px 36px;
  max-width: 400px;
  width: 100%;
}

.login-card h1 {
  font-family: var(--font-mono);
  font-size: 28px;
  text-align: center;
  margin-bottom: 6px;
  color: var(--accent);
  letter-spacing: 0.2em;
  font-weight: 500;
  text-shadow: 0 0 20px rgba(0,212,224,0.2), 0 0 60px rgba(0,212,224,0.06);
}

[data-theme="light"] .login-card h1 { text-shadow: none; }

.subtitle {
  text-align: center;
  color: var(--text-dim);
  margin-bottom: 40px;
  font-size: 11px;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  font-weight: 350;
}

.login-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 18px;
  font-size: 10px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  letter-spacing: 0.1em;
  font-weight: 400;
}

.login-card input,
.login-card select {
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-body);
  width: 100%;
  caret-color: var(--accent);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-weight: 400;
}

.login-card input:focus,
.login-card select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft), var(--accent-glow);
}

.login-card select {
  appearance: none;
  cursor: pointer;
}

.login-card select option {
  background: var(--bg-card);
  color: var(--text);
}

.login-card button {
  width: 100%;
  padding: 13px;
  border-radius: var(--radius);
  border: 1px solid var(--warm);
  background: transparent;
  color: var(--warm);
  font-size: 13px;
  font-family: var(--font-mono);
  font-weight: 500;
  cursor: pointer;
  margin-top: 10px;
  letter-spacing: 0.15em;
  transition: all 0.2s;
}

.login-card button:hover {
  background: var(--warm);
  color: var(--bg);
  box-shadow: var(--warm-glow-strong);
}

.error-msg {
  color: var(--warm);
  font-size: 12px;
  margin-top: 16px;
  text-align: center;
  font-family: var(--font-mono);
}

/* ══════════════════════════════════════════
   APP LAYOUT (flex column fallback)
   ══════════════════════════════════════════ */
#app-screen {
  flex-direction: column;
  height: 100dvh;
}

/* ══════════════════════════════════════════
   NOW BAR
   ══════════════════════════════════════════ */
#now-bar {
  background: var(--bg-card);
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

#now-info {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
}

#now-status {
  font-size: 9px;
  letter-spacing: 0.15em;
  color: var(--accent);
  text-shadow: var(--accent-glow);
  font-family: var(--font-mono);
  font-weight: 500;
  border: 1px solid var(--accent);
  padding: 2px 8px;
  border-radius: var(--radius);
  opacity: 0.85;
}

#now-title {
  font-size: 18px;
  font-weight: 450;
  color: var(--text-bright);
  font-family: var(--font-body);
}

#now-artist {
  font-size: 13px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-weight: 350;
}

#now-reason {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 5px;
  font-style: italic;
  font-family: var(--font-body);
  font-weight: 300;
}

/* ══════════════════════════════════════════
   VISUALIZER
   ══════════════════════════════════════════ */
#visualizer-wrap {
  padding: 6px 20px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: center;
}

#visualizer {
  display: block;
  width: 100%;
  max-width: 600px;
  height: 48px;
  opacity: 0.8;
}

/* ══════════════════════════════════════════
   CHAT
   ══════════════════════════════════════════ */
#chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-msg {
  max-width: 80%;
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.6;
  font-family: var(--font-body);
  animation: fadeIn 0.15s ease;
  position: relative;
  border: 1px solid var(--border);
  background: var(--bg-card);
  border-radius: var(--radius);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-msg .meta {
  font-size: 9px;
  color: var(--text-dim);
  margin-bottom: 5px;
  letter-spacing: 0.05em;
  font-family: var(--font-mono);
}

.chat-msg .body {
  word-break: break-word;
  color: var(--text);
  font-weight: 380;
}

/* ── User message — warm amber accent ── */
.chat-msg.user {
  align-self: flex-end;
  border-left: 2px solid var(--warm);
  background: var(--warm-soft);
}

/* ── DJ message — cyan accent ── */
.chat-msg.dj {
  align-self: flex-start;
  border-left: 2px solid var(--accent);
  background: var(--accent-soft);
}

.chat-msg.dj .playlist-preview {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  padding-top: 8px;
  font-family: var(--font-mono);
}

.chat-msg.dj .playlist-preview span {
  display: block;
  padding: 2px 0;
}

.msg-reason {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 6px;
  border-top: 1px solid var(--border);
  padding-top: 6px;
  font-style: italic;
  font-weight: 300;
  font-family: var(--font-mono);
}

/* ══════════════════════════════════════════
   QUEUE PREVIEW
   ══════════════════════════════════════════ */
#queue-preview {
  padding: 7px 20px;
  font-size: 11px;
  color: var(--text-dim);
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  min-height: 26px;
  font-family: var(--font-mono);
  letter-spacing: 0.03em;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-weight: 350;
}

/* ══════════════════════════════════════════
   INPUT AREA
   ══════════════════════════════════════════ */
#input-area {
  padding: 12px 20px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
}

#chat-form {
  display: flex;
  gap: 10px;
}

#chat-input {
  flex: 1;
  padding: 11px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font-size: 13px;
  font-family: var(--font-body);
  caret-color: var(--accent);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-weight: 400;
}

#chat-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft), var(--accent-glow);
}

#chat-input::placeholder {
  color: var(--text-dim);
}

#btn-send {
  padding: 11px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--warm);
  background: transparent;
  color: var(--warm);
  font-size: 12px;
  font-family: var(--font-mono);
  cursor: pointer;
  letter-spacing: 0.1em;
  transition: all 0.2s;
  white-space: nowrap;
  font-weight: 500;
}

#btn-send:hover {
  background: var(--warm);
  color: var(--bg);
  box-shadow: var(--warm-glow-strong);
}

#btn-send:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

#btn-send:disabled:hover {
  background: transparent;
  color: var(--warm);
  box-shadow: none;
}

/* ══════════════════════════════════════════
   PROGRESS BAR AREA (full-width, above controls)
   ══════════════════════════════════════════ */
#progress-bar-area {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 8px 20px 6px;
  display: flex;
  align-items: center;
  gap: 16px;
}

#progress-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
}

#progress-bar {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  cursor: pointer;
  outline: none;
}

#progress-bar::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
  box-shadow: 0 0 10px var(--accent);
  transition: transform 0.15s;
}

#progress-bar::-webkit-slider-thumb:hover {
  transform: scale(1.3);
}

#progress-bar::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
  box-shadow: 0 0 10px var(--accent);
}

#progress-bar::-moz-range-progress {
  background: var(--accent);
  height: 4px;
  border-radius: 2px;
}

#time-current, #time-duration {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  min-width: 36px;
}

#time-current { text-align: right; }

/* Status subline */
#status-subline {
  font-size: 9px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
}

#status-subline .status-dot {
  display: inline-block;
  width: 5px; height: 5px;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
  border-radius: 50%;
}

#status-subline .version {
  opacity: 0.3;
  font-size: 8px;
  margin-left: auto;
}

/* ══════════════════════════════════════════
   PLAYER CONTROLS (bottom, centered)
   ══════════════════════════════════════════ */
#player-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 10px 20px 12px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
}

.ctrl-btn {
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: 16px;
  font-family: var(--font-mono);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  transition: all 0.2s;
}

.ctrl-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: var(--accent-glow);
}

.ctrl-btn:active {
  background: var(--accent-soft);
}

/* Play button — slight emphasis */
#btn-play {
  border-color: var(--accent);
  color: var(--accent);
  font-size: 15px;
}

#btn-play:hover {
  box-shadow: var(--accent-glow-strong);
  background: var(--accent-soft);
}

/* Volume */
#volume-wrap { width: 80px; flex-shrink: 0; }

#volume-slider {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
  height: 3px;
}

/* ══════════════════════════════════════════
   PLAYLIST PANEL (slide-in overlay from right)
   ══════════════════════════════════════════ */
#playlist-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 280px;
  background: var(--bg-card);
  border-left: 1px solid var(--border-active);
  box-shadow: -4px 0 24px rgba(0,0,0,0.4);
  z-index: 150;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transform: translateX(100%);
  transition: transform 0.25s ease;
}

#playlist-panel.open {
  transform: translateX(0);
}

/* Playlist backdrop */
#playlist-backdrop {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.35);
  z-index: 149;
}

#playlist-backdrop.show {
  display: block;
}

#playlist-panel .pl-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--accent);
  letter-spacing: 0.12em;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  font-weight: 500;
  text-shadow: var(--accent-glow);
}

.pl-close {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  line-height: 1;
}

.pl-close:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.pl-song {
  padding: 8px 10px;
  font-size: 13px;
  font-family: var(--font-body);
  cursor: pointer;
  border-radius: var(--radius);
  transition: background 0.15s, border-color 0.15s;
  border-left: 2px solid transparent;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pl-song:hover {
  background: var(--bg-input);
  border-left-color: var(--text-dim);
}

.pl-song.playing {
  border-left-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 12px rgba(0,212,224,0.06);
}

.pl-song.playing .pl-name {
  color: var(--accent);
  font-weight: 500;
  text-shadow: var(--accent-glow);
}

.pl-song.played {
  opacity: 0.45;
}

.pl-song .pl-name {
  color: var(--text);
  font-weight: 400;
  font-size: 12px;
  line-height: 1.4;
}

.pl-song .pl-time {
  color: var(--text-dim);
  font-size: 10px;
  font-family: var(--font-mono);
  opacity: 0.6;
}

/* ══════════════════════════════════════════
   TYPING INDICATOR
   ══════════════════════════════════════════ */
.typing-dots {
  display: inline-flex;
  gap: 5px;
  padding: 3px 0;
}

.typing-dots span {
  width: 5px; height: 5px;
  background: var(--accent);
  border-radius: 50%;
  animation: dotPulse 1.4s infinite ease both;
  box-shadow: 0 0 4px var(--accent);
}

.typing-dots span:nth-child(1) { animation-delay: 0s; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
  0%, 100% { opacity: 0.2; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.1); }
}

/* ══════════════════════════════════════════
   SCROLLBAR
   ══════════════════════════════════════════ */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-active); }

/* ══════════════════════════════════════════
   MOBILE (< 768px)
   ══════════════════════════════════════════ */
@media (max-width: 767px) {
  #now-title { font-size: 16px; }
  .chat-msg { max-width: 88%; }
  .ctrl-btn { width: 48px; height: 48px; font-size: 18px; }
  #chat-input { font-size: 16px; }
  .login-card { padding: 32px 20px; }
  .login-card h1 { font-size: 22px; letter-spacing: 0.15em; }
  #visualizer-wrap { padding: 4px 12px; }
  #visualizer { height: 36px; }

  #playlist-panel {
    width: 100%;
    right: 0;
    max-height: 50vh;
    top: auto;
    transform: translateY(100%);
    border-left: none;
    border-top: 1px solid var(--border-active);
    box-shadow: 0 -8px 24px rgba(0,0,0,0.5);
  }
  #playlist-panel.open {
    transform: translateY(0);
  }

  #progress-bar-area {
    padding: 8px 12px 6px;
  }
  #progress-wrap {
    max-width: 100%;
  }
  #status-subline {
    display: none;
  }

  #player-controls {
    padding: 10px 12px 16px;
    gap: 20px;
  }
}
