/* =====================================================================
   WAVE — Stylesheet
   Design tokens:
   --ink        #0B0C0F  near-black canvas (not pure #000)
   --surface    #14161B  elevated panels
   --surface-2  #1C1F26  cards / hover
   --line       #262A33  hairline borders
   --text       #F2F1ED  primary text (warm-off-white, not pure white)
   --text-dim   #9A9BA5  secondary text
   --violet     #8B5CF6  signature start
   --magenta    #EC4899  signature end
   --violet-dim #6D28D9
   Display font: "Clash Display" — geometric, confident
   Body font: "Inter" — neutral workhorse
   ===================================================================== */

@font-face {
  font-family: 'Clash Display';
  src: local('Clash Display'), local('ClashDisplay-Variable');
  font-weight: 200 700;
  font-display: swap;
}

:root {
  --ink: #0b0c0f;
  --surface: #14161b;
  --surface-2: #1c1f26;
  --surface-3: #262a33;
  --line: #262a33;
  --text: #f2f1ed;
  --text-dim: #9a9ba5;
  --text-dimmer: #5c5e68;
  --violet: #8b5cf6;
  --magenta: #ec4899;
  --violet-dim: #6d28d9;
  --wave-grad: linear-gradient(120deg, var(--violet) 0%, var(--magenta) 100%);
  --wave-grad-soft: linear-gradient(120deg, rgba(139, 92, 246, 0.16) 0%, rgba(236, 72, 153, 0.16) 100%);
  --danger: #f2555a;
  --success: #34d399;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --sidebar-w: 248px;
  --player-h: 88px;
  --topbar-h: 64px;
  --font-display: 'Clash Display', 'Segoe UI Semibold', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100dvh;
  background: var(--ink); color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
}
body { font-size: 14px; line-height: 1.5; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.02em; margin: 0; }
a { color: inherit; text-decoration: none; }
button { font-family: var(--font-body); cursor: pointer; }
ul { list-style: none; margin: 0; padding: 0; }
img { display: block; max-width: 100%; }
::selection { background: var(--violet); color: #fff; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 10px; border: 2px solid var(--ink); }
::-webkit-scrollbar-thumb:hover { background: #34394a; }

:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; border-radius: 4px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------------------------------------------------------------------
   APP SHELL
   Mobile-first: single column; sidebar becomes a bottom tab bar and the
   player collapses to a slim mini-bar (native app pattern). Desktop
   layout (sidebar + full player bar) kicks in at 900px, see media query.
   --------------------------------------------------------------------- */
#app {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr auto auto;
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
}

/* ---------------------------------------------------------------------
   SIDEBAR — desktop only (900px+). On mobile navigation lives in the
   bottom tab bar instead (see .bottom-nav further down).
   --------------------------------------------------------------------- */
.sidebar {
  display: none;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px 22px;
}
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--wave-grad);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.brand-mark svg { width: 18px; height: 18px; }
.brand-name { font-family: var(--font-display); font-size: 19px; font-weight: 600; }

.nav-group { margin-bottom: 18px; }
.nav-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-dimmer); padding: 8px 12px 6px; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-dim); font-size: 14px; font-weight: 500;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
  position: relative;
}
.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; stroke: currentColor; }
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active { color: var(--text); background: var(--surface-2); }
.nav-item.active::before {
  content: ''; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px;
  background: var(--wave-grad); border-radius: 4px;
}

.sidebar-playlists { flex: 1; overflow-y: auto; }
.playlist-mini-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  border-radius: var(--radius-sm); color: var(--text-dim); font-size: 13.5px;
}
.playlist-mini-item:hover { background: var(--surface); color: var(--text); }
.playlist-mini-cover {
  width: 30px; height: 30px; border-radius: 6px; background: var(--surface-2);
  flex-shrink: 0; object-fit: cover;
}
.playlist-mini-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.upload-cta {
  margin-top: 12px; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px; border-radius: var(--radius-md); border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font-weight: 600; font-size: 13.5px;
  transition: transform 0.15s var(--ease), border-color 0.15s var(--ease);
}
.upload-cta:hover { border-color: var(--violet); transform: translateY(-1px); }
.upload-cta svg { width: 17px; height: 17px; }

/* ---------------------------------------------------------------------
   TOP BAR + MAIN CONTENT
   Mobile-first: main column always spans full width; the desktop
   sidebar column is added back in the 900px+ media query.
   --------------------------------------------------------------------- */
.main-col {
  grid-column: 1 / 2; grid-row: 1 / 2;
  display: flex; flex-direction: column;
  overflow: hidden;
  min-height: 0;
  background: linear-gradient(180deg, #191320 0%, var(--ink) 340px);
}
.topbar {
  min-height: var(--topbar-h); flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; gap: 10px;
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: blur(14px);
  background: rgba(11, 12, 15, 0.72);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s var(--ease);
}
.topbar.scrolled { border-bottom-color: var(--line); }
.nav-arrows { display: none; }
.nav-arrows button {
  width: 32px; height: 32px; border-radius: 50%; border: none;
  background: var(--surface); color: var(--text); display: flex; align-items: center; justify-content: center;
}
.nav-arrows svg { width: 16px; height: 16px; }
.search-wrap { flex: 1; min-width: 0; position: relative; }
.search-wrap svg {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--text-dimmer); pointer-events: none;
}
.search-input {
  width: 100%; min-width: 0; padding: 10px 12px 10px 38px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); color: var(--text);
  font-size: 13.5px; transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}
.search-input:focus { border-color: var(--violet); background: var(--surface-2); outline: none; }
.search-input::placeholder { color: var(--text-dimmer); overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--surface); display: flex; align-items: center; justify-content: center; color: var(--text-dim);
  transition: color 0.15s, border-color 0.15s, transform 0.15s var(--ease);
}
.icon-btn:hover { color: var(--text); border-color: var(--violet); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn svg { width: 16px; height: 16px; }
.btn-primary {
  padding: 10px 18px; border-radius: 999px; border: none; flex-shrink: 0;
  background: var(--wave-grad); color: #fff; font-weight: 600; font-size: 13.5px;
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  transition: filter 0.15s var(--ease), transform 0.1s var(--ease);
}
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-primary:active { transform: scale(0.96); }
.btn-primary svg { width: 15px; height: 15px; flex-shrink: 0; }
.btn-ghost {
  padding: 9px 18px; border-radius: 999px; border: 1px solid var(--line);
  background: transparent; color: var(--text); font-weight: 600; font-size: 13.5px;
}
.btn-ghost:hover { border-color: var(--text-dim); }

.view-scroll { flex: 1; overflow-y: auto; padding: 24px 28px 40px; }
.view { display: none; animation: fadein 0.28s var(--ease); }
.view.active { display: block; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.page-head { margin-bottom: 24px; }
.page-eyebrow { font-size: 12px; color: var(--violet); font-weight: 700; text-transform: uppercase; letter-spacing: 0.09em; margin-bottom: 6px; }
.page-title { font-size: 32px; }
.page-sub { color: var(--text-dim); margin-top: 6px; font-size: 14px; max-width: 560px; }

.section { margin-bottom: 38px; }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px;
}
.section-title { font-size: 20px; }
.section-link { font-size: 13px; color: var(--text-dim); font-weight: 600; }
.section-link:hover { color: var(--text); }

/* ---------------------------------------------------------------------
   GRIDS + CARDS
   --------------------------------------------------------------------- */
.grid-cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 14px;
}
.card {
  background: var(--surface); border-radius: var(--radius-md); padding: 14px;
  position: relative; transition: background 0.2s var(--ease), transform 0.2s var(--ease), border-color 0.2s var(--ease);
  border: 1px solid transparent;
  opacity: 0; animation: cardIn 0.4s var(--ease) forwards;
  animation-delay: calc(var(--card-i, 0) * 35ms);
}
@keyframes cardIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.card:hover { background: var(--surface-2); transform: translateY(-3px); border-color: var(--line); }
.card:active { transform: translateY(-1px) scale(0.98); }
.card.now-playing-card { border-color: var(--violet); background: var(--surface-2); }
.card.now-playing-card .card-title { color: var(--violet); }
.card-cover-wrap { position: relative; aspect-ratio: 1/1; border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 12px; background: var(--surface-3); }
.card-cover-wrap img { width: 100%; height: 100%; object-fit: cover; }
.card-cover-fallback {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  background: var(--wave-grad-soft); position: relative;
}
.card-cover-fallback > svg:last-child { width: 34%; height: 34%; color: rgba(255,255,255,0.9); opacity: 0.9; position: relative; z-index: 1; }
.card-play-btn {
  position: absolute; right: 8px; bottom: 8px; width: 42px; height: 42px; border-radius: 50%;
  background: var(--wave-grad); display: flex; align-items: center; justify-content: center; border: none;
  opacity: 0; transform: translateY(6px); transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
  box-shadow: 0 8px 20px rgba(139, 92, 246, 0.35);
}
.card:hover .card-play-btn { opacity: 1; transform: translateY(0); }
.card-play-btn svg { width: 18px; height: 18px; color: #fff; margin-left: 2px; }
.card-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 3px; }
.card-sub { font-size: 12.5px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------------------------------------------------------------------
   HERO (home)
   --------------------------------------------------------------------- */
.hero {
  display: grid; grid-template-columns: 1fr; gap: 24px; align-items: center;
  padding: 20px 4px 30px; margin-bottom: 4px;
}
.hero-eyebrow {
  color: var(--violet); font-weight: 700; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
  margin-bottom: 12px; opacity: 0; animation: heroFadeUp 0.5s var(--ease) 0.05s forwards;
}
.hero-title {
  font-size: 32px; line-height: 1.08; margin-bottom: 14px;
  opacity: 0; animation: heroFadeUp 0.55s var(--ease) 0.12s forwards;
}
.hero-title span { background: var(--wave-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-desc {
  color: var(--text-dim); font-size: 14px; max-width: 420px; margin-bottom: 20px;
  opacity: 0; animation: heroFadeUp 0.55s var(--ease) 0.2s forwards;
}
.hero-actions {
  display: flex; gap: 10px; flex-wrap: wrap;
  opacity: 0; animation: heroFadeUp 0.55s var(--ease) 0.28s forwards;
}
@keyframes heroFadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.hero-visual {
  display: none; height: 220px; border-radius: var(--radius-lg); position: relative; overflow: hidden;
  background: radial-gradient(circle at 30% 20%, rgba(139,92,246,0.35), transparent 60%),
              radial-gradient(circle at 80% 80%, rgba(236,72,153,0.28), transparent 55%),
              var(--surface);
  align-items: flex-end; padding: 20px;
}
#heroWaveCanvas { width: 100%; height: 100px; }

/* ---------------------------------------------------------------------
   ROW LIST (queue / playlist detail / search results)
   --------------------------------------------------------------------- */
.track-row {
  display: grid; grid-template-columns: 28px 40px 1fr auto auto auto; align-items: center; gap: 14px;
  padding: 9px 12px; border-radius: var(--radius-sm);
}
.track-row:hover { background: var(--surface); }
.track-row.playing { background: var(--wave-grad-soft); }
.track-index { color: var(--text-dimmer); font-size: 13px; text-align: center; }
.track-row.playing .track-index { color: var(--violet); }
.track-cover { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; background: var(--surface-3); }
.track-info { min-width: 0; }
.track-title { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track-artist { font-size: 12.5px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track-meta { font-size: 12.5px; color: var(--text-dimmer); }
.track-actions { display: flex; gap: 4px; opacity: 0; transition: opacity 0.15s; }
.track-row:hover .track-actions { opacity: 1; }
.track-actions button { width: 30px; height: 30px; border-radius: 50%; border: none; background: transparent; color: var(--text-dim); display: flex; align-items: center; justify-content: center; }
.track-actions button:hover { color: var(--text); background: var(--surface-2); }
.track-actions svg { width: 16px; height: 16px; }
.list-head {
  display: grid; grid-template-columns: 28px 40px 1fr auto auto auto; gap: 14px; padding: 0 12px 8px;
  border-bottom: 1px solid var(--line); margin-bottom: 6px; font-size: 11px; color: var(--text-dimmer);
  text-transform: uppercase; letter-spacing: 0.06em;
}

/* ---------------------------------------------------------------------
   PLAYLIST / ARTIST / ALBUM DETAIL HEADER
   --------------------------------------------------------------------- */
.detail-head { display: flex; gap: 26px; align-items: flex-end; margin-bottom: 28px; }
.detail-cover { width: 200px; height: 200px; border-radius: var(--radius-lg); object-fit: cover; box-shadow: 0 24px 50px rgba(0,0,0,0.45); background: var(--wave-grad); flex-shrink: 0; }
.detail-cover-fallback { width: 200px; height: 200px; border-radius: var(--radius-lg); background: var(--wave-grad); display: flex; align-items: center; justify-content: center; flex-shrink: 0; position: relative; }
.detail-cover-fallback > svg { width: 30%; height: 30%; color: rgba(255,255,255,0.85); position: relative; z-index: 1; }
.detail-kind { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); }
.detail-title { font-size: 40px; margin: 10px 0 12px; }
.detail-meta { color: var(--text-dim); font-size: 13.5px; }
.detail-actions { display: flex; align-items: center; gap: 14px; margin: 20px 0 18px; }
.play-fab { width: 58px; height: 58px; border-radius: 50%; background: var(--wave-grad); border: none; display: flex; align-items: center; justify-content: center; box-shadow: 0 10px 24px rgba(139,92,246,0.4); }
.play-fab svg { width: 22px; height: 22px; color: #fff; margin-left: 2px; }

/* ---------------------------------------------------------------------
   UPLOAD FORM
   --------------------------------------------------------------------- */
.upload-layout { display: grid; grid-template-columns: 240px 1fr; gap: 32px; max-width: 780px; }
.cover-drop {
  aspect-ratio: 1/1; border-radius: var(--radius-lg); border: 1.5px dashed var(--line);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  color: var(--text-dim); background: var(--surface); position: relative; overflow: hidden;
  transition: border-color 0.2s var(--ease);
}
.cover-drop:hover { border-color: var(--violet); }
.cover-drop img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover-drop svg { width: 32px; height: 32px; }
.cover-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-dim); margin-bottom: 7px; }
.form-input, .form-textarea, .form-select {
  width: 100%; padding: 11px 14px; border-radius: var(--radius-sm); background: var(--surface);
  border: 1px solid var(--line); color: var(--text); font-size: 13.5px; font-family: var(--font-body);
}
.form-input:focus, .form-textarea:focus, .form-select:focus { border-color: var(--violet); outline: none; }
.form-textarea { resize: vertical; min-height: 90px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.audio-drop {
  border: 1.5px dashed var(--line); border-radius: var(--radius-md); padding: 20px;
  display: flex; align-items: center; gap: 14px; color: var(--text-dim); position: relative; background: var(--surface);
}
.audio-drop.has-file { border-color: var(--success); border-style: solid; }
.audio-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.audio-drop svg { width: 26px; height: 26px; flex-shrink: 0; }
.form-hint { font-size: 12px; color: var(--text-dimmer); margin-top: 6px; }
.form-error { font-size: 12.5px; color: var(--danger); margin-top: 10px; display: none; }
.form-error.show { display: block; }
.rate-banner {
  background: var(--wave-grad-soft); border: 1px solid rgba(139,92,246,0.35); border-radius: var(--radius-md);
  padding: 12px 16px; font-size: 12.5px; color: var(--text-dim); margin-bottom: 20px; display: flex; gap: 10px; align-items: center;
}
.rate-banner svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--violet); }

/* ---------------------------------------------------------------------
   UPLOAD LOGIN GATE + GOOGLE BUTTON + CHANNEL BADGE
   --------------------------------------------------------------------- */
.upload-login-gate {
  max-width: 420px; text-align: center; padding: 48px 24px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-lg);
}
.upload-login-gate-icon {
  width: 56px; height: 56px; border-radius: 50%; background: var(--wave-grad-soft);
  display: flex; align-items: center; justify-content: center; margin: 0 auto 18px; color: var(--violet);
}
.upload-login-gate-icon svg { width: 26px; height: 26px; }
.upload-login-gate h3 { font-size: 19px; margin-bottom: 10px; }
.upload-login-gate p { color: var(--text-dim); font-size: 13.5px; line-height: 1.6; margin-bottom: 22px; }
.btn-google {
  display: inline-flex; align-items: center; gap: 10px; padding: 11px 22px;
  border-radius: 999px; border: 1px solid var(--line); background: #fff; color: #1f1f1f;
  font-weight: 600; font-size: 14px; transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.btn-google:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(0,0,0,0.25); }
.btn-google:active { transform: scale(0.96); }

.upload-as-badge {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; margin-bottom: 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md);
  font-size: 13px; color: var(--text-dim);
}
.upload-as-badge img { width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; }
.upload-as-badge strong { color: var(--text); }

/* honeypot — visually hidden but present for bots to fill */
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------------------------------------------------------------------
   LYRICS VIEW
   --------------------------------------------------------------------- */
.lyrics-wrap { max-width: 680px; margin: 0 auto; text-align: center; padding: 30px 0; }
.lyrics-cover { width: 140px; height: 140px; border-radius: var(--radius-md); margin: 0 auto 22px; object-fit: cover; }
.lyrics-text { font-family: var(--font-display); font-size: 22px; line-height: 1.7; color: var(--text-dim); white-space: pre-wrap; }

/* ---------------------------------------------------------------------
   EMPTY STATES + TOASTS
   --------------------------------------------------------------------- */
.skeleton-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 14px; }
.skeleton-card { display: flex; flex-direction: column; gap: 10px; }
.skeleton-box {
  border-radius: var(--radius-sm); background: linear-gradient(100deg, var(--surface) 30%, var(--surface-3) 50%, var(--surface) 70%);
  background-size: 200% 100%; animation: shimmer 1.4s ease-in-out infinite;
}
.skeleton-cover { aspect-ratio: 1/1; border-radius: var(--radius-md); }
.skeleton-line { height: 11px; width: 80%; }
.skeleton-line.short { width: 50%; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-dim); animation: fadein 0.3s var(--ease); }
.empty-state svg { width: 52px; height: 52px; margin-bottom: 16px; color: var(--text-dimmer); }
.empty-state-title { font-size: 17px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.toast-stack { position: fixed; bottom: calc(var(--player-h) + 20px); right: 24px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 16px; font-size: 13px; color: var(--text); box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  display: flex; align-items: center; gap: 10px; animation: toastin 0.25s var(--ease);
  max-width: 320px;
}
.toast.error { border-color: rgba(242,85,90,0.4); }
.toast.success { border-color: rgba(52,211,153,0.4); }
@keyframes toastin { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ---------------------------------------------------------------------
   PLAYER BAR — mobile-first mini player (one compact row + thin
   progress line on top). Expands into the full 3-column desktop
   layout at 900px, see media query at the bottom of this file.
   --------------------------------------------------------------------- */
.player-bar {
  grid-row: 2 / 3;
  background: var(--surface); border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; position: relative;
  animation: playerSlideUp 0.3s var(--ease);
}
.player-bar.empty { display: none; }
@keyframes playerSlideUp { from { transform: translateY(100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.player-bar::before {
  content: ''; position: absolute; top: -2px; left: 0; right: 0; height: 2px;
  background: var(--surface-3); overflow: hidden;
}
.player-bar::after {
  content: ''; position: absolute; top: -2px; left: 0; height: 2px;
  width: var(--progress-pct, 0%);
  background: var(--wave-grad); transition: width 0.15s linear;
}

.player-track { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; cursor: pointer; }
.player-cover { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--surface-3); flex-shrink: 0; }
.player-track-info { min-width: 0; }
.player-track-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-track-artist { font-size: 11.5px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-like-btn { width: 32px; height: 32px; border: none; background: transparent; color: var(--text-dim); flex-shrink: 0; border-radius: 50%; transition: transform 0.15s var(--ease), color 0.15s; }
.player-like-btn svg { width: 17px; height: 17px; transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1); }
.player-like-btn.liked { color: var(--magenta); }
.player-like-btn.liked svg { transform: scale(1.15); }
.player-like-btn:active { transform: scale(0.88); }

.player-center { display: none; }

.mobile-player-controls { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.mobile-player-controls button {
  background: transparent; border: none; color: var(--text);
  width: 38px; height: 38px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; transition: transform 0.12s var(--ease), background 0.15s;
}
.mobile-player-controls button:active { transform: scale(0.88); background: var(--surface-2); }
.mobile-player-controls svg { width: 19px; height: 19px; }
.mobile-play-pause {
  width: 40px !important; height: 40px !important;
  background: var(--text) !important; color: var(--ink) !important; border-radius: 50% !important;
}
.mobile-play-pause svg { width: 17px; height: 17px; }

.player-controls { display: flex; align-items: center; gap: 18px; }
.player-controls button { background: transparent; border: none; color: var(--text-dim); display: flex; align-items: center; justify-content: center; border-radius: 50%; transition: color 0.15s, transform 0.12s var(--ease); }
.player-controls button:hover { color: var(--text); }
.player-controls button:active { transform: scale(0.88); }
.player-controls button.active { color: var(--violet); }
.player-controls svg { width: 18px; height: 18px; }
.play-pause-btn {
  width: 36px; height: 36px; border-radius: 50%; background: var(--text) !important; color: var(--ink) !important;
}
.play-pause-btn svg { width: 16px; height: 16px; }
.progress-row { display: flex; align-items: center; gap: 10px; width: 100%; }
.time-label { font-size: 11px; color: var(--text-dimmer); width: 36px; flex-shrink: 0; }
.time-label.end { text-align: right; }
.progress-track {
  flex: 1; height: 26px; position: relative; cursor: pointer; display: flex; align-items: center;
}
#progressCanvas { width: 100%; height: 26px; }

.player-right { display: none; }
.player-right button { background: transparent; border: none; color: var(--text-dim); border-radius: 50%; transition: color 0.15s, transform 0.12s var(--ease); }
.player-right button:hover { color: var(--text); }
.player-right button:active { transform: scale(0.9); }
.player-right button.active { color: var(--violet); }
.player-right svg { width: 17px; height: 17px; }
.volume-row { display: flex; align-items: center; gap: 8px; width: 110px; }
.volume-track { flex: 1; height: 16px; position: relative; cursor: pointer; }
#volumeCanvas { width: 100%; height: 16px; }
.now-playing-toggle svg { width: 17px; height: 17px; }

/* ---------------------------------------------------------------------
   BOTTOM NAV (mobile only)
   --------------------------------------------------------------------- */
.bottom-nav {
  grid-row: 3 / 4;
  display: flex; align-items: center; justify-content: space-around;
  background: var(--ink); border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
  z-index: 30;
}
.bnav-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--text-dimmer); font-size: 10.5px; font-weight: 600;
  padding: 4px 10px; border-radius: var(--radius-sm); flex: 1;
  transition: color 0.15s var(--ease), transform 0.12s var(--ease);
}
.bnav-item svg { width: 22px; height: 22px; transition: transform 0.15s var(--ease); }
.bnav-item.active { color: var(--text); }
.bnav-item.active svg { color: var(--violet); transform: translateY(-1px); }
.bnav-item:active { transform: scale(0.92); }
.bnav-upload { flex: 0 0 auto; }
.bnav-upload-circle {
  width: 46px; height: 46px; border-radius: 50%; background: var(--wave-grad);
  display: flex; align-items: center; justify-content: center; margin-top: -22px;
  box-shadow: 0 6px 18px rgba(139, 92, 246, 0.45); border: 4px solid var(--ink);
  transition: transform 0.15s var(--ease);
}
.bnav-upload:active .bnav-upload-circle { transform: scale(0.9); }
.bnav-upload-circle svg { width: 20px; height: 20px; }

/* ---------------------------------------------------------------------
   MORE SHEET (mobile only) — bottom sheet for genre/queue/settings/about
   --------------------------------------------------------------------- */
.mobile-only-flex { display: flex; }
.more-sheet-overlay {
  position: fixed; inset: 0; background: rgba(4,4,6,0.6); backdrop-filter: blur(3px);
  z-index: 250; display: none; align-items: flex-end;
  opacity: 0; transition: opacity 0.2s var(--ease);
}
.more-sheet-overlay.open { display: flex; opacity: 1; }
.more-sheet {
  background: var(--surface-2); border: 1px solid var(--line); border-bottom: none;
  border-radius: 22px 22px 0 0; width: 100%; padding: 10px 10px calc(14px + env(safe-area-inset-bottom, 0px));
  transform: translateY(100%); transition: transform 0.28s var(--ease);
}
.more-sheet-overlay.open .more-sheet { transform: translateY(0); }
.more-sheet-handle { width: 36px; height: 4px; border-radius: 3px; background: var(--surface-3); margin: 6px auto 14px; }
.more-sheet-item {
  display: flex; align-items: center; gap: 14px; padding: 14px 12px; border-radius: var(--radius-sm);
  color: var(--text); font-weight: 600; font-size: 14.5px;
}
.more-sheet-item svg { width: 20px; height: 20px; color: var(--text-dim); }
.more-sheet-item:active { background: var(--surface-3); }

/* ---------------------------------------------------------------------
   NOW PLAYING — full-screen player (Apple Music-style).
   Blurred, oversaturated artwork fills the background; a large square
   cover floats above it; big transport controls sit below. Opens by
   sliding up from the mini-player and covers the whole viewport.
   --------------------------------------------------------------------- */
.now-playing {
  position: fixed; inset: 0; z-index: 400;
  background: var(--ink);
  transform: translateY(100%);
  transition: transform 0.38s var(--ease);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.now-playing.open { transform: translateY(0); }

.np-backdrop {
  position: absolute; inset: -15%; z-index: 0;
  background-size: cover; background-position: center;
  filter: blur(80px) saturate(1.8) brightness(0.5);
  transform: scale(1.2);
  transition: background-image 0.5s var(--ease);
  opacity: 0.9;
}
.np-backdrop::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(11,12,15,0.25) 0%, rgba(11,12,15,0.5) 45%, rgba(11,12,15,0.95) 100%);
}
.np-backdrop.fallback { background: var(--wave-grad); opacity: 0.7; }

.np-content {
  position: relative; z-index: 1;
  flex: 1; display: flex; flex-direction: column;
  padding: 14px 22px calc(24px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  min-height: 0;
}

.np-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 0 10px; flex-shrink: 0;
}
.np-collapse-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.1); color: var(--text);
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s var(--ease), background 0.15s;
  backdrop-filter: blur(12px);
  box-shadow: 0 2px 10px rgba(0,0,0,0.25);
}
.np-collapse-btn:active { transform: scale(0.9); background: rgba(255,255,255,0.18); }
.np-collapse-btn svg { width: 16px; height: 16px; }
.np-context-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  color: rgba(255,255,255,0.65); text-align: center;
}
.np-more-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.1); color: var(--text);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(12px); transition: transform 0.15s var(--ease), background 0.15s;
  box-shadow: 0 2px 10px rgba(0,0,0,0.25);
}
.np-more-btn:active { transform: scale(0.9); background: rgba(255,255,255,0.18); }
.np-more-btn svg { width: 17px; height: 17px; }

.np-artwork-wrap {
  flex-shrink: 0;
  display: flex; justify-content: center;
  padding: 12px 0 28px;
  animation: npArtIn 0.45s var(--ease);
}
@keyframes npArtIn { from { opacity: 0; transform: scale(0.92) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.np-artwork {
  width: min(78vw, 340px); aspect-ratio: 1/1; border-radius: 16px;
  object-fit: cover; box-shadow: 0 30px 60px rgba(0,0,0,0.5), 0 8px 20px rgba(0,0,0,0.4);
  background: var(--surface-3);
  transition: transform 0.3s var(--ease);
}
.np-artwork.paused { transform: scale(0.94); }
.np-artwork-fallback {
  width: min(78vw, 340px); aspect-ratio: 1/1; border-radius: 16px;
  background: var(--wave-grad); display: flex; align-items: center; justify-content: center;
  box-shadow: 0 30px 60px rgba(0,0,0,0.5);
}
.np-artwork-fallback svg { width: 28%; height: 28%; color: rgba(255,255,255,0.85); }

.np-track-info {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; padding: 4px 4px 22px; flex-shrink: 0;
}
.np-track-text { min-width: 0; }
.np-track-title { font-family: var(--font-display); font-size: 22px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-track-artist { font-size: 14.5px; color: rgba(255,255,255,0.65); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 3px; cursor: pointer; }
.np-track-artist:active { opacity: 0.7; }
.np-like-btn {
  width: 40px; height: 40px; border-radius: 50%; border: none; background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.75); flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s var(--ease), background 0.15s var(--ease);
}
.np-like-btn svg { width: 21px; height: 21px; transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); }
.np-like-btn.liked { color: var(--magenta); background: rgba(236, 72, 153, 0.16); }
.np-like-btn.liked svg { transform: scale(1.2); }
.np-like-btn:active { transform: scale(0.82); background: rgba(255,255,255,0.16); }
.np-like-btn.liked:active { background: rgba(236, 72, 153, 0.28); }

.np-progress-wrap { flex-shrink: 0; padding: 0 2px 18px; }
.np-progress-track { height: 36px; position: relative; cursor: pointer; display: flex; align-items: center; }
#npProgressCanvas { width: 100%; height: 36px; }
.np-time-row { display: flex; justify-content: space-between; margin-top: 2px; }
.np-time-label { font-size: 11px; color: rgba(255,255,255,0.55); font-variant-numeric: tabular-nums; }

.np-controls { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 26px; flex-shrink: 0; }
.np-controls button {
  background: transparent; border: none; color: var(--text);
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.12s var(--ease), color 0.15s;
}
.np-controls button:active { transform: scale(0.88); }
.np-controls button.active { color: var(--magenta); }
.np-shuffle-btn svg, .np-repeat-btn svg { width: 20px; height: 20px; }
.np-prev-btn svg, .np-next-btn svg { width: 30px; height: 30px; }
.np-play-btn {
  width: 68px; height: 68px; border-radius: 50%;
  background: #fff !important; color: #000 !important;
  box-shadow: 0 10px 26px rgba(0,0,0,0.4);
}
.np-play-btn svg { width: 28px; height: 28px; }

.np-bottom-row { display: flex; align-items: center; justify-content: space-between; padding: 2px 8px; flex-shrink: 0; }
.np-bottom-row button {
  background: transparent; border: none; color: rgba(255,255,255,0.7);
  display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 10.5px; font-weight: 600;
  transition: transform 0.12s var(--ease), color 0.15s;
}
.np-bottom-row button:active { transform: scale(0.9); }
.np-bottom-row button.active { color: var(--violet); }
.np-bottom-row svg { width: 19px; height: 19px; }

.np-stats-row {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 18px 0 4px; color: rgba(255,255,255,0.5); font-size: 12px; flex-shrink: 0;
}
.np-stats-row svg { width: 14px; height: 14px; }

.np-lyrics-panel {
  margin-top: 10px; padding: 20px 4px 4px; flex-shrink: 0;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.np-lyrics-panel-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: rgba(255,255,255,0.5); margin-bottom: 12px; }
.np-lyrics-panel-text { font-family: var(--font-display); font-size: 18px; line-height: 1.7; color: rgba(255,255,255,0.9); white-space: pre-wrap; }

.np-nextup-panel { margin-top: 22px; padding: 18px 4px 4px; flex-shrink: 0; border-top: 1px solid rgba(255,255,255,0.08); }
.np-nextup-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: rgba(255,255,255,0.5); margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; }
.np-nextup-title button { background: transparent; border: none; color: rgba(255,255,255,0.5); font-size: 11px; font-weight: 600; }
.np-nextup-row {
  display: flex; align-items: center; gap: 12px; padding: 9px 6px; border-radius: var(--radius-sm);
  transition: background 0.15s var(--ease);
}
.np-nextup-row:active { background: rgba(255,255,255,0.08); }
.np-nextup-cover { width: 42px; height: 42px; border-radius: 7px; object-fit: cover; background: var(--surface-3); flex-shrink: 0; }
.np-nextup-info { min-width: 0; flex: 1; }
.np-nextup-title-text { font-size: 13.5px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-nextup-artist-text { font-size: 12px; color: rgba(255,255,255,0.55); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }

/* ---- Add to playlist modal (reused pattern, dark glass) ---- */
.np-playlist-pick-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-radius: var(--radius-sm);
  color: var(--text); font-size: 13.5px; font-weight: 600;
}
.np-playlist-pick-item:active { background: var(--surface-3); }
.np-playlist-pick-cover {
  width: 38px; height: 38px; border-radius: 6px; object-fit: cover; background: var(--surface-3); flex-shrink: 0;
}

/* ---- Desktop: Now Playing becomes a centered modal-like panel, and the
   mini-player click target still opens it, but sized more like a dialog ---- */
@media (min-width: 900px) {
  .now-playing { }
  .np-artwork, .np-artwork-fallback { width: min(38vw, 380px); }
  .np-content { padding: 20px 60px 40px; max-width: 640px; margin: 0 auto; width: 100%; }
}

/* ---------------------------------------------------------------------
   QUEUE / OFFLINE PANEL (slide-over)
   --------------------------------------------------------------------- */
.side-panel {
  position: fixed; top: 0; right: -400px; width: 380px; height: 100%; background: var(--surface);
  border-left: 1px solid var(--line); z-index: 450; transition: right 0.28s var(--ease);
  display: flex; flex-direction: column; padding: 20px;
}
.side-panel.open { right: 0; }
.side-panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.side-panel-close { width: 30px; height: 30px; border-radius: 50%; border: none; background: var(--surface-2); color: var(--text); }
.side-panel-body { flex: 1; overflow-y: auto; }

/* ---------------------------------------------------------------------
   MODAL (create playlist / add to playlist)
   --------------------------------------------------------------------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(4,4,6,0.7); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center; z-index: 500;
}
.modal-overlay.open { display: flex; }
.modal-box { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 24px; width: 420px; max-width: 90vw; }
.modal-title { font-size: 19px; margin-bottom: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ---------------------------------------------------------------------
   SETTINGS / ABOUT
   --------------------------------------------------------------------- */
.settings-row { display: flex; align-items: center; justify-content: space-between; padding: 16px 0; border-bottom: 1px solid var(--line); max-width: 560px; }
.settings-row:last-child { border-bottom: none; }
.settings-stat-number { font-family: var(--font-display); font-size: 24px; font-weight: 600; color: var(--text); background: var(--wave-grad); -webkit-background-clip: text; background-clip: text; color: transparent; flex-shrink: 0; }

/* ---------------------------------------------------------------------
   LEGAL PAGES (Terms, Security) + FAQ + About links
   --------------------------------------------------------------------- */
.about-legal-links { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 24px; }
.about-legal-link {
  padding: 9px 16px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--text-dim); font-size: 13px; font-weight: 600; transition: border-color 0.15s, color 0.15s;
}
.about-legal-link:hover { border-color: var(--violet); color: var(--text); }

.legal-content { max-width: 640px; color: var(--text-dim); font-size: 14.5px; line-height: 1.8; }
.legal-content h3 { color: var(--text); font-size: 16px; margin: 22px 0 8px; }
.legal-content h3:first-child { margin-top: 0; }

.faq-list { max-width: 640px; }
.faq-item { border-bottom: 1px solid var(--line); }
.faq-question {
  width: 100%; text-align: left; background: transparent; border: none; padding: 16px 4px;
  display: flex; align-items: center; justify-content: space-between; color: var(--text);
  font-size: 14.5px; font-weight: 600;
}
.faq-chevron { transition: transform 0.2s var(--ease); color: var(--text-dim); font-size: 16px; }
.faq-item.open .faq-chevron { transform: rotate(180deg); }
.faq-answer {
  max-height: 0; overflow: hidden; color: var(--text-dim); font-size: 13.5px; line-height: 1.7;
  transition: max-height 0.25s var(--ease), padding 0.25s var(--ease); padding: 0 4px;
}
.faq-item.open .faq-answer { max-height: 200px; padding: 0 4px 16px; }
.settings-label { font-weight: 600; font-size: 14px; }
.settings-desc { font-size: 12.5px; color: var(--text-dim); margin-top: 3px; }
.toggle-switch { width: 42px; height: 24px; border-radius: 999px; background: var(--surface-3); position: relative; border: none; flex-shrink: 0; }
.toggle-switch::after { content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%; background: var(--text-dim); top: 3px; left: 3px; transition: transform 0.2s var(--ease), background 0.2s; }
.toggle-switch.on { background: var(--wave-grad); }
.toggle-switch.on::after { transform: translateX(18px); background: #fff; }

/* ---------------------------------------------------------------------
   GENRE CHIPS (browse)
   --------------------------------------------------------------------- */
.chip-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.genre-chip {
  height: 90px; border-radius: var(--radius-md); padding: 14px; display: flex; align-items: flex-end;
  font-family: var(--font-display); font-size: 16px; font-weight: 600; position: relative; overflow: hidden;
}
.genre-chip::before { content: ''; position: absolute; inset: 0; opacity: 0.85; }
.genre-chip span { position: relative; z-index: 1; }

/* ---------------------------------------------------------------------
   LIVE CHAT
   Mobile-first: rooms list and conversation are two separate "screens"
   toggled by a class on .chat-shell — only one is visible at a time.
   Desktop shows both side by side (WhatsApp Web style), see media query.
   --------------------------------------------------------------------- */
#view-chat { height: 100%; }
.chat-shell {
  display: flex; height: calc(100dvh - var(--topbar-h) - var(--player-h) - 58px);
  margin: -24px -28px 0; background: var(--surface);
  border-radius: 0; overflow: hidden; position: relative;
}

.chat-rooms-col {
  width: 100%; flex-shrink: 0; display: flex; flex-direction: column;
  background: var(--ink); border-right: 1px solid var(--line);
  transition: transform 0.28s var(--ease);
}
.chat-shell.conversation-open .chat-rooms-col { transform: translateX(-100%); position: absolute; inset: 0; }

.chat-rooms-head { padding: 18px 18px 14px; }
.chat-username-badge {
  margin-top: 6px; font-size: 12px; color: var(--text-dim);
  display: inline-flex; padding: 5px 12px; border-radius: 999px; background: var(--surface-2);
}

.chat-room-divider {
  padding: 14px 18px 8px; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-dimmer);
}
.chat-room-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 18px;
  transition: background 0.15s var(--ease); cursor: pointer;
}
.chat-room-item:hover, .chat-room-item.active { background: var(--surface); }
.chat-room-avatar {
  width: 46px; height: 46px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--wave-grad-soft); color: var(--violet); overflow: hidden;
}
.chat-room-avatar svg { width: 22px; height: 22px; }
.chat-room-avatar-global { background: var(--wave-grad); color: #fff; }
.chat-room-info { min-width: 0; flex: 1; }
.chat-room-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-room-preview { font-size: 12.5px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }

.chat-main-col {
  width: 100%; flex-shrink: 0; display: flex; flex-direction: column; min-width: 0;
  position: absolute; inset: 0; transform: translateX(100%); transition: transform 0.28s var(--ease);
  background: var(--surface);
}
.chat-shell.conversation-open .chat-main-col { transform: translateX(0); position: relative; }

.chat-header {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.chat-back-btn {
  width: 34px; height: 34px; border-radius: 50%; border: none; background: var(--surface-2);
  color: var(--text); display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.chat-back-btn svg { width: 17px; height: 17px; }
.chat-header-info { min-width: 0; }
.chat-header-name { font-size: 15px; font-weight: 600; }
.chat-header-sub { font-size: 11.5px; color: var(--text-dimmer); margin-top: 1px; }

.chat-messages {
  flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 2px;
}

.chat-bubble-row { display: flex; margin-bottom: 6px; touch-action: pan-y; position: relative; }
.chat-bubble-row.mine { justify-content: flex-end; }
.chat-bubble-row.swiping .chat-bubble { transition: none; }
.chat-bubble {
  max-width: 76%; background: var(--surface-2); border-radius: 16px 16px 16px 4px;
  padding: 9px 13px; position: relative; transition: transform 0.15s var(--ease);
}
.chat-bubble-row.mine .chat-bubble { background: var(--wave-grad); border-radius: 16px 16px 4px 16px; }
.chat-bubble-sender { font-size: 11.5px; font-weight: 700; color: var(--violet); margin-bottom: 3px; }
.chat-bubble-row.mine .chat-bubble-sender { display: none; }
.chat-bubble-reply-ref {
  font-size: 11.5px; color: var(--text-dim); border-left: 2px solid var(--violet);
  padding-left: 8px; margin-bottom: 6px; opacity: 0.85; cursor: pointer;
}
.chat-bubble-row.mine .chat-bubble-reply-ref { color: rgba(255,255,255,0.8); border-left-color: rgba(255,255,255,0.6); }
.chat-bubble-text { font-size: 14px; line-height: 1.45; word-wrap: break-word; white-space: pre-wrap; }
.chat-bubble-text .mention { color: var(--violet); font-weight: 700; }
.chat-bubble-row.mine .chat-bubble-text .mention { color: #fff; text-decoration: underline; }
.chat-bubble-time { font-size: 10px; color: var(--text-dimmer); margin-top: 4px; text-align: right; }
.chat-bubble-row.mine .chat-bubble-time { color: rgba(255,255,255,0.7); }
.chat-bubble-media { margin-top: 6px; border-radius: 10px; overflow: hidden; max-width: 220px; }
.chat-bubble-media img, .chat-bubble-media video { width: 100%; display: block; }
.chat-bubble-audio { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.chat-bubble-audio audio { max-width: 200px; height: 32px; }

.chat-swipe-reply-icon {
  position: absolute; top: 50%; left: -34px; transform: translateY(-50%);
  width: 26px; height: 26px; border-radius: 50%; background: var(--surface-2);
  display: flex; align-items: center; justify-content: center; color: var(--text-dim);
  opacity: 0; transition: opacity 0.15s var(--ease);
}
.chat-swipe-reply-icon svg { width: 14px; height: 14px; }
.chat-bubble-row.mine .chat-swipe-reply-icon { left: auto; right: -34px; }

.chat-reply-preview {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  border-top: 1px solid var(--line); background: var(--surface-2); flex-shrink: 0;
}
.chat-reply-preview-bar { width: 3px; align-self: stretch; background: var(--violet); border-radius: 2px; flex-shrink: 0; }
.chat-reply-preview-body { flex: 1; min-width: 0; }
.chat-reply-preview-name { font-size: 12px; font-weight: 700; color: var(--violet); }
.chat-reply-preview-text { font-size: 12.5px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#chatReplyCancelBtn { background: transparent; border: none; color: var(--text-dim); width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
#chatReplyCancelBtn svg { width: 15px; height: 15px; }

.chat-input-bar {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  border-top: 1px solid var(--line); flex-shrink: 0;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
}
.chat-attach-btn {
  width: 40px; height: 40px; border-radius: 50%; background: var(--surface-2); color: var(--text-dim);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; position: relative;
  transition: transform 0.12s var(--ease), color 0.15s;
}
.chat-attach-btn:active { transform: scale(0.9); }
.chat-attach-btn svg { width: 19px; height: 19px; }
.chat-text-input {
  flex: 1; min-width: 0; padding: 11px 16px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text); font-size: 14px;
}
.chat-text-input:focus { border-color: var(--violet); outline: none; }
.chat-send-btn {
  width: 40px; height: 40px; border-radius: 50%; border: none; background: var(--wave-grad);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: transform 0.12s var(--ease), opacity 0.15s;
}
.chat-send-btn:active { transform: scale(0.88); }
.chat-send-btn svg { width: 17px; height: 17px; color: #fff; }
.chat-send-btn:disabled { opacity: 0.4; }

.chat-media-preview {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  border-top: 1px solid var(--line); background: var(--surface-2); flex-shrink: 0;
}
.chat-media-preview img, .chat-media-preview video { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; }
.chat-media-preview-info { flex: 1; min-width: 0; font-size: 12.5px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-media-preview-remove { background: transparent; border: none; color: var(--text-dim); width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; }

.chat-username-gate {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 40px 24px; gap: 6px;
}
.chat-username-gate-icon { color: var(--text-dimmer); margin-bottom: 8px; }
.chat-username-gate-icon svg { width: 44px; height: 44px; }
.chat-username-gate h3 { font-size: 18px; }
.chat-username-gate p { color: var(--text-dim); font-size: 13.5px; max-width: 320px; margin-bottom: 16px; }
.chat-username-gate form { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 300px; }
.chat-username-gate input {
  padding: 12px 16px; border-radius: 999px; background: var(--surface-2);
  border: 1px solid var(--line); color: var(--text); font-size: 14px; text-align: center;
}
.chat-username-gate input:focus { border-color: var(--violet); outline: none; }

/* ---- Reaction chips ---- */
.chat-bubble-reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.chat-reaction-chip {
  font-size: 11.5px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface-3); color: var(--text-dim); transition: transform 0.12s var(--ease), border-color 0.15s;
}
.chat-reaction-chip.mine { border-color: var(--violet); color: var(--text); background: var(--wave-grad-soft); }
.chat-reaction-chip:active { transform: scale(0.9); }

/* ---- Deleted message ---- */
.chat-bubble-deleted { opacity: 0.6; font-style: italic; }
.chat-bubble-deleted-text { color: var(--text-dimmer); font-size: 13px; }
.chat-bubble-edited { font-size: 10px; opacity: 0.7; margin-right: 5px; font-style: italic; }

.chat-inline-edit-input {
  width: 100%; background: rgba(0,0,0,0.2); border: 1px solid rgba(255,255,255,0.3);
  border-radius: 8px; padding: 6px 10px; color: inherit; font-size: 14px; font-family: var(--font-body);
}
.chat-inline-edit-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.chat-inline-edit-actions button { background: transparent; border: none; font-size: 12px; font-weight: 700; color: inherit; opacity: 0.85; }
.chat-inline-edit-actions button:hover { opacity: 1; }

/* ---- Per-message "more" button (react/reply/edit/delete) ---- */
.chat-bubble-more-btn {
  position: absolute; top: 2px; right: -30px; width: 26px; height: 26px; border-radius: 50%;
  background: transparent; border: none; color: var(--text-dimmer); font-size: 15px; line-height: 1;
  opacity: 0; transition: opacity 0.15s var(--ease);
}
.chat-bubble-row:hover .chat-bubble-more-btn, .chat-bubble-row:active .chat-bubble-more-btn { opacity: 1; }
.chat-bubble-row.mine .chat-bubble-more-btn { right: auto; left: -30px; }
.chat-bubble-row { padding-right: 34px; }
.chat-bubble-row.mine { padding-right: 0; padding-left: 34px; }

.chat-msg-menu-overlay {
  position: fixed; inset: 0; background: rgba(4,4,6,0.65); backdrop-filter: blur(3px);
  z-index: 350; display: none; align-items: flex-end;
}
.chat-msg-menu-overlay.open { display: flex; }
.chat-msg-menu {
  background: var(--surface-2); border: 1px solid var(--line); border-bottom: none;
  border-radius: 20px 20px 0 0; width: 100%; padding: 16px 16px calc(20px + env(safe-area-inset-bottom, 0px));
}
.chat-msg-menu-emojis { display: flex; justify-content: space-between; margin-bottom: 14px; padding: 0 4px; }
.chat-msg-menu-emojis button { font-size: 26px; background: transparent; border: none; transition: transform 0.15s var(--ease); }
.chat-msg-menu-emojis button:active { transform: scale(1.3); }
.chat-msg-menu button[data-menu-action] {
  display: block; width: 100%; text-align: left; padding: 13px 8px; background: transparent; border: none;
  color: var(--text); font-size: 14.5px; font-weight: 500; border-top: 1px solid var(--line);
}
.chat-msg-menu button[data-menu-action].danger { color: var(--danger); }

/* ---- Voice note recorder ---- */
.chat-voice-btn {
  width: 40px; height: 40px; border-radius: 50%; background: var(--surface-2); color: var(--text-dim);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; border: none;
  transition: transform 0.12s var(--ease), background 0.15s, color 0.15s;
}
.chat-voice-btn.recording { background: var(--danger); color: #fff; animation: recordPulse 1.2s ease-in-out infinite; }
@keyframes recordPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(242,85,90,0.5); } 50% { box-shadow: 0 0 0 8px rgba(242,85,90,0); } }
.chat-voice-btn svg { width: 19px; height: 19px; }
.chat-recording-banner {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--surface-2);
  border-top: 1px solid var(--line);
}
.chat-recording-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--danger); animation: recordPulse 1s ease-in-out infinite; }
.chat-recording-time { font-size: 13px; color: var(--text); font-variant-numeric: tabular-nums; }
.chat-recording-cancel { margin-left: auto; background: transparent; border: none; color: var(--text-dim); font-size: 13px; font-weight: 600; }

/* ---- Group chat items + management ---- */
.chat-group-item-avatar { background: var(--wave-grad); color: #fff; }
.chat-create-group-row { padding: 10px 18px; }
.chat-create-group-btn {
  width: 100%; padding: 10px; border-radius: var(--radius-sm); border: 1px dashed var(--line);
  background: transparent; color: var(--text-dim); font-size: 13px; font-weight: 600;
}
.chat-create-group-btn:hover { border-color: var(--violet); color: var(--text); }

.group-members-list { max-height: 320px; overflow-y: auto; margin: 14px 0; }
.group-member-row { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--line); }
.group-member-name { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.group-member-role { font-size: 11px; color: var(--text-dim); padding: 2px 8px; border-radius: 999px; background: var(--surface-3); }
.group-member-role.admin { color: var(--violet); background: var(--wave-grad-soft); }
.group-member-actions { display: flex; gap: 4px; }
.group-member-actions button { background: transparent; border: none; color: var(--text-dim); font-size: 11.5px; font-weight: 600; padding: 4px 8px; border-radius: 6px; }
.group-member-actions button:hover { background: var(--surface-3); color: var(--text); }
.group-invite-link-box {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--surface-3); font-size: 12.5px; color: var(--text-dim); margin-bottom: 14px;
}
.group-invite-link-box code { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }

@media (min-width: 900px) {
  .chat-shell { height: calc(100vh - var(--topbar-h) - var(--player-h) - 48px); border-radius: var(--radius-lg); border: 1px solid var(--line); }
  .chat-rooms-col { width: 320px; position: relative !important; transform: none !important; }
  .chat-main-col { width: auto; flex: 1; position: relative !important; transform: none !important; }
  .chat-back-btn { display: none; }
}

/* ---------------------------------------------------------------------
   RESPONSIVE — mobile-first base styles are above. This is where the
   layout progressively upgrades to tablet, then full desktop.
   --------------------------------------------------------------------- */

/* ---- Small phones: tighten spacing further ---- */
@media (max-width: 380px) {
  .hero-title { font-size: 34px; }
  .page-title { font-size: 24px; }
  .detail-cover, .detail-cover-fallback { width: 128px; height: 128px; }
  .detail-title { font-size: 26px; }
  .grid-cards { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
  .btn-label { display: none; }
  #topUploadBtn { padding: 10px; }
  #topUploadBtn svg { margin: 0; }
}

/* ---- Tablet: 2-column layout for upload form comes back a bit earlier ---- */
@media (min-width: 620px) {
  .upload-layout { grid-template-columns: 220px 1fr; }
}
@media (max-width: 619px) {
  .upload-layout { grid-template-columns: 1fr; gap: 20px; }
  .cover-drop { max-width: 220px; margin: 0 auto; }
  .form-row { grid-template-columns: 1fr; }
}

/* ---- Desktop (900px+): sidebar returns, full player bar, hide mobile chrome ---- */
@media (min-width: 900px) {
  #app {
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-rows: 1fr var(--player-h);
  }
  .sidebar {
    display: flex; flex-direction: column;
    grid-row: 1 / 2; grid-column: 1 / 2;
    background: var(--ink); border-right: 1px solid var(--line);
    padding: 20px 14px; overflow-y: auto;
  }
  .main-col { grid-column: 2 / 3; }
  .bottom-nav, .mobile-only-flex, .more-sheet-overlay, .mobile-player-controls { display: none !important; }
  .btn-label { display: inline; }

  .nav-arrows { display: flex; }
  .topbar { padding: 0 28px; height: var(--topbar-h); }
  .search-wrap { max-width: 480px; flex: 1; }

  .player-bar {
    grid-row: 2 / 3; grid-column: 1 / 3;
    display: grid; grid-template-columns: 300px 1fr 300px; align-items: center;
    padding: 0 18px; gap: 20px;
  }
  .player-bar::before, .player-bar::after { display: none; }
  .player-track { flex: none; }
  .player-cover { width: 54px; height: 54px; }
  .player-track-title { font-size: 13.5px; }
  .player-track-artist { font-size: 12px; }
  .player-center {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    max-width: 560px; margin: 0 auto; width: 100%;
  }
  .player-right { display: flex; align-items: center; justify-content: flex-end; gap: 14px; }

  .hero { grid-template-columns: 1.1fr 0.9fr; }
  .hero-visual { display: flex; }
}

/* ---- Wide desktop: a bit more breathing room ---- */
@media (min-width: 1400px) {
  .view-scroll { padding: 28px 40px 48px; }
  .grid-cards { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}
