:root {
  --bg: #0b0f19;
  --surface: #131a2a;
  --surface-2: #1b2438;
  --border: rgba(255, 255, 255, 0.08);
  --text: #f3f6fc;
  --muted: #94a3b8;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --accent: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 16px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Tahoma, Arial, sans-serif;
  background: radial-gradient(circle at top, #172036 0%, var(--bg) 65%);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.app-shell {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 14px 36px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 8px 4px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.7);
}

.brand h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.badge {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.badge-idle {
  background: rgba(148, 163, 184, 0.12);
  color: var(--muted);
}

.badge-waiting {
  background: rgba(245, 158, 11, 0.14);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.3);
}

.badge-online {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.35);
}

.card {
  background: rgba(19, 26, 42, 0.9);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

.hidden {
  display: none !important;
}

/* Lobby */
.lobby-card {
  text-align: center;
  padding: 28px 20px;
}

.hero-icon {
  font-size: 3rem;
  margin-bottom: 10px;
}

.lobby-card h2 {
  font-size: 1.35rem;
  margin-bottom: 8px;
}

.subtitle {
  color: var(--muted);
  font-size: 0.92rem;
  margin-bottom: 24px;
}

.lobby-actions {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.85rem;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.join-row,
.url-row,
.chat-form {
  display: flex;
  gap: 8px;
}

input[type="text"],
input[type="url"] {
  flex: 1;
  min-width: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 14px;
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

input[type="text"]:focus,
input[type="url"]:focus {
  border-color: var(--primary);
}

/* Buttons */
.btn {
  border: none;
  border-radius: 12px;
  padding: 11px 16px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.1s, opacity 0.2s, background 0.2s;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-lg {
  padding: 14px 20px;
  font-size: 1.02rem;
  width: 100%;
}

.btn-sm {
  padding: 7px 12px;
  font-size: 0.84rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #4f46e5);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #7477f5, var(--primary-hover));
}

.btn-secondary {
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.btn-outline {
  background: transparent;
  border: 1px solid rgba(99, 102, 241, 0.5);
  color: #a5b4fc;
}

.btn-danger-ghost {
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
}

.icon-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 0.9rem;
}

.error-text {
  margin-top: 14px;
  color: #f87171;
  font-size: 0.9rem;
}

/* Room */
.room-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.room-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
}

.room-code-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.room-code-wrap strong {
  font-size: 1.3rem;
  letter-spacing: 2px;
  color: #c7d2fe;
}

.status-strip {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--muted);
}

.ping-pill {
  background: var(--surface-2);
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  color: var(--accent);
  direction: ltr;
}

.banner-warn {
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.86rem;
  color: #fde68a;
}

/* Source Card */
.source-card h3,
.chat-header h3 {
  font-size: 1rem;
  margin-bottom: 12px;
}

.source-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.file-label {
  width: 100%;
}

.transfer-box {
  margin-top: 14px;
  background: var(--surface-2);
  padding: 10px 12px;
  border-radius: 12px;
}

.transfer-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.84rem;
  margin-bottom: 6px;
}

.progress-track {
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 0.15s ease;
}

/* Player */
.track-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.eq-bars {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--surface-2);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  padding: 8px;
  flex-shrink: 0;
}

.eq-bars span {
  width: 4px;
  height: 6px;
  background: var(--primary);
  border-radius: 2px;
  transition: height 0.2s;
}

.eq-bars.playing span {
  animation: eqBounce 0.8s infinite ease-in-out;
}

.eq-bars.playing span:nth-child(2) { animation-delay: 0.15s; background: var(--accent); }
.eq-bars.playing span:nth-child(3) { animation-delay: 0.3s; }
.eq-bars.playing span:nth-child(4) { animation-delay: 0.45s; background: var(--accent); }

@keyframes eqBounce {
  0%, 100% { height: 5px; }
  50% { height: 20px; }
}

.track-info {
  min-width: 0;
}

.track-title {
  font-weight: 700;
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-sub {
  font-size: 0.82rem;
  color: var(--muted);
}

.seek-area {
  margin-bottom: 14px;
}

#seekSlider {
  width: 100%;
  accent-color: var(--primary);
  cursor: pointer;
  direction: ltr;
}

.time-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 4px;
  direction: ltr;
}

.player-buttons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

.btn-play {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  font-size: 1.4rem;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.btn-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.85rem;
}

/* Chat */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.chat-header h3 {
  margin-bottom: 0;
}

.chat-messages {
  max-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: var(--surface-2);
  border-radius: 12px;
  margin-bottom: 10px;
}

.chat-sys {
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
}

.chat-msg {
  max-width: 82%;
  padding: 7px 11px;
  border-radius: 12px;
  font-size: 0.88rem;
  word-break: break-word;
}

.chat-me {
  align-self: flex-start;
  background: rgba(99, 102, 241, 0.25);
  border: 1px solid rgba(99, 102, 241, 0.35);
}

.chat-peer {
  align-self: flex-end;
  background: rgba(16, 185, 129, 0.18);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.btn-icon {
  padding: 10px 12px;
  font-size: 1.05rem;
  flex-shrink: 0;
}

.voice-record-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: 12px;
  padding: 8px 10px;
  margin-bottom: 10px;
  font-size: 0.85rem;
}

.rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
  animation: recPulse 1s infinite;
  flex-shrink: 0;
}

@keyframes recPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

.rec-label {
  flex: 1;
  color: #fecaca;
  font-size: 0.82rem;
}

.voice-bubble {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 210px;
}

.voice-bubble audio {
  width: 100%;
  height: 34px;
  outline: none;
}

.voice-meta {
  font-size: 0.72rem;
  color: var(--muted);
}
