/* ===== CSS Variables ===== */
:root {
  --bg-primary: #0a0a12;
  --bg-secondary: #10101c;
  --bg-tertiary: #181830;
  --bg-elevated: #1e1e3a;
  --bg-hover: rgba(255, 255, 255, 0.04);
  --accent: #7c3aed;
  --accent-light: #a78bfa;
  --accent-dark: #632ebe;
  --accent-glow: rgba(124, 58, 237, 0.25);
  --cyan: #06b6d4;
  --green: #10b981;
  --yellow: #f59e0b;
  --red: #ef4444;
  --pink: #ec4899;
  --text-primary: #eeeef2;
  --text-secondary: #9494b0;
  --text-muted: #55556e;
  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--accent);
  color: white;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-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); }

/* ===== Pages ===== */
.page {
  display: none;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
}
.page.active { display: flex; }

/* ===== Landing Page ===== */
#landing {
  position: relative;
  align-items: center;
  justify-content: center;
  overflow-x: hidden;
  overflow-y: auto;
}

.landing-bg {
  position: absolute;
  inset: 0;
  background: linear-gradient(-45deg, #0a0a20, #1a0a30, #0a1a2e, #0a0a20);
  background-size: 400% 400%;
  animation: gradientShift 20s ease infinite;
  z-index: 0;
}

.landing-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 30% 40%, rgba(124,58,237,0.08) 0%, transparent 60%),
              radial-gradient(circle at 70% 60%, rgba(6,182,212,0.06) 0%, transparent 60%);
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.landing-content {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
  padding: 24px;
}

.landing-card {
  background: rgba(16, 16, 28, 0.8);
  backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 48px 40px;
  box-shadow: var(--shadow-lg);
}

.logo-large {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 12px;
}

.logo-icon { width: 44px; height: 44px; }

.logo-large h1 {
  font-size: 26px;
  font-weight: 800;
  background: linear-gradient(135deg, #fff 0%, var(--accent-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

.landing-subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 32px;
}

.landing-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.divider {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--text-muted);
  font-size: 13px;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.join-row {
  display: flex;
  gap: 10px;
}
.join-row .input { flex: 1; }

/* ===== Inputs ===== */
.input {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 11px 16px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
}
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.input::placeholder { color: var(--text-muted); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  font-size: 14px;
  padding: 11px 24px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #000));
  color: white;
  box-shadow: 0 4px 16px var(--accent-glow);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px var(--accent-glow);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: rgba(255,255,255,0.06);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: rgba(255,255,255,0.1);
  border-color: var(--border-hover);
}

.btn-accent {
  background: var(--accent);
  color: white;
}
.btn-accent:hover { filter: brightness(0.85); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 6px 12px;
}
.btn-ghost:hover { color: var(--text-primary); background: var(--bg-hover); }

.btn-large { padding: 14px 32px; font-size: 15px; width: 100%; }
.btn-sm { padding: 8px 12px; font-size: 13px; }

/* ===== Room Layout ===== */
#room {
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

.room-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 56px;
  min-height: 56px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon-sm { width: 28px; height: 28px; }

.header-title {
  font-size: 15px;
  font-weight: 700;
  background: linear-gradient(135deg, #fff, var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-center {
  display: flex;
  align-items: center;
  gap: 10px;
}

.room-badge {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-light);
  background: var(--accent-glow);
  padding: 4px 12px;
  border-radius: 6px;
  letter-spacing: 2px;
}

.copy-text { font-size: 12px; }

.header-right {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
}

.users-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
  font-size: 13px;
  color: var(--text-secondary);
}
.users-badge:hover { background: var(--bg-hover); }

.online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
  animation: pulse 2s ease infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.users-label { color: var(--text-muted); }

.users-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px;
  min-width: 260px;
  box-shadow: var(--shadow-lg);
  z-index: 100;
}
.users-dropdown.open { display: block; }

.dropdown-header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  padding: 6px 8px;
}

.user-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 6px;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.user-name { font-size: 13px; font-weight: 500; flex: 1; min-width: 0; }
.user-you { font-size: 11px; color: var(--text-muted); margin-left: 4px; }
.user-host { font-size: 10px; color: var(--accent-light); margin-left: 4px; font-weight: 600; }
.user-muted { font-size: 10px; color: var(--red); margin-left: 4px; font-weight: 600; }
.user-locked { font-size: 10px; color: var(--yellow); margin-left: 4px; font-weight: 600; }

.user-actions {
  display: flex;
  gap: 2px;
  margin-left: auto;
  flex-shrink: 0;
}

.user-action-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.user-action-btn:hover { color: var(--text-primary); background: var(--bg-hover); }
.user-action-btn.active { color: var(--accent-light); }
.user-action-btn.danger:hover { color: var(--red); background: rgba(239, 68, 68, 0.1); }

/* Lock Toggle */
.lock-toggle.active { color: var(--accent-light); }

/* Locked Controls */
.controls-bar.locked .btn-control,
.controls-bar.locked .btn-play,
.controls-bar.locked .seek-bar { opacity: 0.4; }

/* ===== Accent Color Picker ===== */
.accent-picker {
  position: relative;
  display: none;
  align-items: center;
}
.accent-picker.visible {
  display: flex;
}

.accent-toggle {
  color: var(--accent-light);
}

.accent-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  min-width: 170px;
}
.accent-dropdown.open { display: block; }

.accent-swatches {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.accent-swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  padding: 0;
}
.accent-swatch:hover {
  transform: scale(1.15);
}
.accent-swatch.active {
  border-color: white;
  box-shadow: 0 0 12px var(--accent-glow);
}

.custom-color-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.custom-color-label {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.custom-color-input {
  -webkit-appearance: none;
  appearance: none;
  width: 32px;
  height: 32px;
  border: 2px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  background: none;
  padding: 0;
  overflow: hidden;
}
.custom-color-input::-webkit-color-swatch-wrapper {
  padding: 0;
}
.custom-color-input::-webkit-color-swatch {
  border: none;
  border-radius: 50%;
}
.custom-color-input::-moz-color-swatch {
  border: none;
  border-radius: 50%;
}

/* ===== Mobile Tabs ===== */
.mobile-tabs {
  display: none;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  gap: 0;
}

.mobile-tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 0;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.mobile-tab.active {
  color: var(--accent-light);
  border-bottom-color: var(--accent);
}

/* ===== Main Layout ===== */
.room-main {
  display: grid;
  grid-template-columns: 300px 1fr 300px;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ===== Panels ===== */
.panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  flex-shrink: 0;
}

.panel-header h2 {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
}

.panel-badge {
  font-size: 11px;
  font-weight: 700;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: 10px;
  margin-right: auto;
  margin-left: 8px;
}

.panel-header .btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: color 0.15s, background 0.15s;
}
.panel-header .btn-icon:hover {
  color: var(--accent);
  background: var(--bg-tertiary);
}

.panel-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 6px;
  color: var(--text-muted);
  font-size: 14px;
}
.panel-empty .hint { font-size: 12px; }

/* ===== Playlist Panel ===== */
.playlist-panel {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
}

.add-video-tabs {
  display: flex;
  gap: 0;
  padding: 0 12px 8px;
  flex-shrink: 0;
}

.add-video-tab {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 0;
  cursor: pointer;
  transition: all 0.2s;
}
.add-video-tab:hover { color: var(--text-secondary); }
.add-video-tab.active {
  color: var(--accent-light);
  border-bottom-color: var(--accent);
}

.add-video-area {
  display: flex;
  gap: 8px;
  padding: 0 12px 12px;
  flex-shrink: 0;
}
.add-video-area .input {
  font-size: 13px;
  padding: 9px 12px;
}

.search-results {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 8px 8px;
  border-bottom: 1px solid var(--border);
}


.search-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.search-result-item:hover { background: var(--bg-hover); }

.search-result-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.search-result-title {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-meta {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-add {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
}
.search-result-add:hover {
  color: var(--accent-light);
  border-color: var(--accent);
  background: var(--accent-glow);
}

.search-result-channel {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color 0.15s;
}
.search-result-channel:hover { color: var(--text-primary); }

.search-result-channel-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex-shrink: 0;
}

.search-channel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.search-back-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}
.search-back-btn:hover { color: var(--text-primary); background: var(--bg-hover); }

.search-channel-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
}

.search-channel-name {
  font-size: 14px;
  font-weight: 600;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-loading, .search-empty {
  text-align: center;
  padding: 16px;
  color: var(--text-muted);
  font-size: 13px;
}

.search-loading::after {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--text-muted);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-left: 8px;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.playlist-items {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 8px;
}

.playlist-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
  user-select: none;
}
.playlist-item:hover { background: var(--bg-hover); }
.playlist-item.active {
  background: var(--accent-glow);
}
.playlist-item.active .pl-meta {
  color: var(--accent-light);
}
.playlist-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  background: var(--accent);
  border-radius: 2px;
}

.playlist-item.dragging {
  opacity: 0.4;
}

.playlist-item.drag-over {
  border-top: 2px solid var(--accent);
}

.pl-thumb {
  width: 56px;
  height: 32px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-tertiary);
}

.pl-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pl-title {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pl-meta {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pl-time {
  font-size: 11px;
  color: var(--accent-light);
  display: block;
  margin-top: 2px;
}

.pl-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s;
  flex-shrink: 0;
}
.playlist-item:hover .pl-actions { opacity: 1; }

.pl-action-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pl-action-btn:hover { color: var(--red); background: rgba(239, 68, 68, 0.1); }

.pl-drag-handle {
  color: var(--text-muted);
  cursor: grab;
  padding: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}
.playlist-item:hover .pl-drag-handle { opacity: 0.5; }
.pl-drag-handle:active { cursor: grabbing; }

/* ===== Player Panel ===== */
.player-panel {
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  overflow: hidden;
}

.player-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

#player-container {
  position: relative;
  width: 100%;
  height: 100%;
}

#yt-player {
  width: 100%;
  height: 100%;
}

#player-container iframe {
  width: 100%;
  height: 100%;
  display: block;
}

.player-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
}

.overlay-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  transform: scale(0.9);
  cursor: pointer;
}

.overlay-skip {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(8px);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s, background 0.15s;
  transform: scale(0.9);
}
.overlay-skip:hover {
  background: rgba(255,255,255,0.18);
}
.overlay-skip:active {
  transform: scale(0.92) !important;
}
.overlay-skip .skip-label {
  position: absolute;
  font-size: 9px;
  font-weight: 700;
  color: white;
  bottom: 3px;
  pointer-events: none;
}

.player-overlay.show-controls .overlay-icon,
.player-overlay.show-controls .overlay-skip {
  opacity: 1;
  transform: scale(1);
}

.player-overlay.hide-cursor {
  cursor: none;
}

.empty-player {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 15px;
  z-index: 3;
  background: var(--bg-primary);
}

/* ===== Now Playing ===== */
.now-playing {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  flex-shrink: 0;
}

.now-playing-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.equalizer {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 16px;
  flex-shrink: 0;
}

.equalizer .bar {
  width: 3px;
  background: var(--accent);
  border-radius: 1px;
}
.equalizer .bar:nth-child(1) { height: 40%; animation: eq 0.6s ease-in-out infinite alternate; }
.equalizer .bar:nth-child(2) { height: 70%; animation: eq 0.6s 0.2s ease-in-out infinite alternate; }
.equalizer .bar:nth-child(3) { height: 50%; animation: eq 0.6s 0.4s ease-in-out infinite alternate; }
.equalizer.paused .bar { animation: none; height: 20%; }

@keyframes eq {
  0% { height: 15%; }
  100% { height: 100%; }
}

.now-playing-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.now-playing-title {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.now-playing-channel {
  font-size: 11px;
  color: var(--text-muted);
}

/* ===== Chat Panel ===== */
.chat-panel {
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-msg {
  animation: msgIn 0.25s ease;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-msg-user {
  padding: 4px 0;
}

.chat-username {
  font-size: 13px;
  font-weight: 600;
  margin-right: 6px;
}

.chat-text {
  font-size: 13px;
  color: var(--text-secondary);
  word-break: break-word;
  line-height: 1.4;
}

.chat-time {
  font-size: 10px;
  color: var(--text-muted);
  margin-left: 6px;
}

.chat-msg-system {
  text-align: center;
  padding: 6px 0;
}

.chat-msg-system .chat-text {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

.chat-input-area {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-input-area .input {
  font-size: 13px;
  padding: 9px 12px;
}

/* ===== Controls Bar ===== */
.controls-bar {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 8px 20px 12px;
  flex-shrink: 0;
  z-index: 10;
}

.progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.time-display {
  font-size: 11px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--text-muted);
  min-width: 40px;
  text-align: center;
}

.seek-container {
  flex: 1;
  display: flex;
  align-items: center;
}

/* Range Inputs */
.seek-bar, .volume-bar {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-tertiary);
  outline: none;
  border: none;
  cursor: pointer;
  transition: height 0.15s;
}

.seek-bar:hover { height: 8px; }

.seek-bar::-webkit-slider-thumb,
.volume-bar::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
  box-shadow: 0 0 6px var(--accent-glow);
  transition: transform 0.15s;
  margin-top: -4px;
}

.seek-bar::-webkit-slider-thumb:hover,
.volume-bar::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.seek-bar::-moz-range-thumb,
.volume-bar::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
  box-shadow: 0 0 6px var(--accent-glow);
}

.seek-bar::-webkit-slider-runnable-track,
.volume-bar::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: transparent;
}

.seek-bar::-moz-range-track,
.volume-bar::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: var(--bg-tertiary);
}

.seek-bar::-moz-range-progress,
.volume-bar::-moz-range-progress {
  height: 6px;
  border-radius: 3px;
  background: var(--accent);
}

.volume-bar {
  width: 90px;
}

.controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.controls-left, .controls-right {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 160px;
}

.controls-right { justify-content: flex-end; }

.controls-center {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-control {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-control:hover { color: var(--text-primary); background: var(--bg-hover); }
.btn-control.active { color: var(--accent-light); }

.btn-skip {
  position: relative;
}
.btn-skip .skip-text {
  position: absolute;
  font-size: 8px;
  font-weight: 700;
  bottom: 0px;
  color: inherit;
  pointer-events: none;
}

.btn-play {
  background: var(--accent);
  border: none;
  color: white;
  cursor: pointer;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  box-shadow: 0 2px 12px var(--accent-glow);
}
.btn-play:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 20px var(--accent-glow);
}
.btn-play:active { transform: scale(0.98); }

/* ===== Toast Notifications ===== */
.toast-container {
  position: fixed;
  top: 70px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 18px;
  font-size: 13px;
  color: var(--text-primary);
  box-shadow: var(--shadow);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.info { border-left: 3px solid var(--cyan); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(60px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(60px); }
}

/* ===== Connection Status ===== */
.connection-status {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated);
  border: 1px solid var(--yellow);
  border-radius: var(--radius-md);
  padding: 8px 18px;
  font-size: 13px;
  color: var(--yellow);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 999;
  box-shadow: var(--shadow);
}

.connection-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--yellow);
  animation: pulse 1s ease infinite;
}

/* ===== Fullscreen ===== */
#room.is-fullscreen {
  position: relative;
}

#room.is-fullscreen .room-header,
#room.is-fullscreen .mobile-tabs {
  display: none !important;
}

#room.is-fullscreen .room-main {
  grid-template-columns: 1fr;
}

#room.is-fullscreen .playlist-panel,
#room.is-fullscreen .chat-panel {
  display: none !important;
}

#room.is-fullscreen .player-panel {
  background: #000;
}

#room.is-fullscreen .now-playing {
  display: none !important;
}

#room.is-fullscreen .controls-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(12px);
  border-top: none;
  z-index: 20;
  opacity: 0;
  transform: translateY(100%);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
}

#room.is-fullscreen.fs-show-controls .controls-bar {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

#room.is-fullscreen.fs-hide-cursor {
  cursor: none;
}

#room.is-fullscreen.fs-hide-cursor * {
  cursor: none !important;
}

/* ===== Room Creation Notice ===== */
.room-creation-notice {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  color: var(--yellow);
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
}

/* ===== Admin Section ===== */
.admin-section {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.admin-link {
  font-size: 12px;
  color: var(--text-muted);
  gap: 4px;
}
.admin-link:hover { color: var(--text-secondary); }

.admin-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--yellow);
  background: rgba(245, 158, 11, 0.12);
  padding: 3px 10px;
  border-radius: 10px;
}

.user-admin-badge {
  font-size: 10px;
  color: var(--yellow);
  margin-left: 4px;
  font-weight: 600;
}

/* ===== Admin Login Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow-lg);
}

.modal-card h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  justify-content: flex-end;
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .room-main {
    grid-template-columns: 260px 1fr 260px;
  }
}

@media (max-width: 768px) {
  .mobile-tabs {
    display: flex;
  }

  .room-main {
    display: flex;
    flex-direction: column;
    position: relative;
  }

  /* Hide panels by default, show via mobile-visible */
  .playlist-panel, .chat-panel {
    display: none;
    border-right: none;
    border-left: none;
  }

  .playlist-panel.mobile-visible,
  .chat-panel.mobile-visible {
    display: flex;
    flex: 1;
    min-height: 0;
  }

  /* Hide player when viewing playlist or chat */
  .player-panel.mobile-hidden {
    display: none !important;
  }

  .player-panel {
    flex: 1;
    min-height: 0;
  }

  .player-wrapper {
    flex: 1;
    min-height: 0;
    width: 100%;
  }

  /* Header compact */
  .room-header {
    padding: 0 12px;
    height: 48px;
    min-height: 48px;
  }

  .header-left .header-title { display: none; }
  .copy-text { display: none; }
  .users-label { display: none; }

  .room-badge {
    font-size: 12px;
    padding: 3px 8px;
    letter-spacing: 1.5px;
  }

  /* Controls bar compact */
  .controls-bar {
    padding: 6px 12px 10px;
  }

  .controls-left, .controls-right {
    min-width: auto;
  }

  .controls-center {
    gap: 4px;
  }

  .btn-control {
    padding: 6px;
  }

  .btn-play {
    width: 40px;
    height: 40px;
  }

  .btn-play svg {
    width: 24px;
    height: 24px;
  }

  .volume-bar { width: 60px; }

  /* Hide skip +-5 buttons on mobile, overlay has them */
  .btn-skip { display: none; }

  /* Now playing compact */
  .now-playing {
    padding: 8px 12px;
  }

  /* Toast positioning */
  .toast-container { top: auto; bottom: 80px; right: 12px; left: 12px; }

  /* Player overlay: just a tap target on mobile, no visible buttons */
  .player-overlay {
    pointer-events: auto;
  }

  /* Chat input area */
  .chat-input-area {
    padding: 8px 12px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }

  /* Users dropdown mobile */
  .users-dropdown {
    position: fixed;
    top: 48px;
    right: 8px;
    left: 8px;
    min-width: unset;
  }

  /* Accent dropdown mobile */
  .accent-dropdown {
    position: fixed;
    top: 48px;
    right: 8px;
    min-width: 170px;
  }

  /* Search results full height in mobile */
  .search-results {
    flex: 1;
    min-height: 0;
  }
}

@media (max-width: 480px) {
  .landing-card { padding: 32px 20px; }
  .logo-large h1 { font-size: 20px; }
  .logo-large { gap: 10px; }
  .logo-icon { width: 36px; height: 36px; }
  .landing-subtitle { font-size: 13px; margin-bottom: 24px; }

  .volume-bar { display: none; }

  /* Even more compact controls */
  .controls-bar { padding: 4px 8px 8px; }
  .progress-row { gap: 6px; }
  .time-display { font-size: 10px; min-width: 34px; }

  /* Header even more compact */
  .room-header { padding: 0 8px; }
  .header-center { gap: 6px; }
}

/* Touch devices: hide overlay buttons (works in fullscreen too) */
@media (hover: none), (pointer: coarse) {
  .player-overlay .overlay-icon,
  .player-overlay .overlay-skip {
    display: none !important;
  }
}
