/*
 * MeloSurge v9 — Atmosphere
 * ──────────────────────────
 * Floating glass on velvet dark & creamy light.
 * The vibe tints everything.
 */

@import url('https://fonts.googleapis.com/css2?family=Lexend+Deca:wght@400;500;600;700&display=swap');


/* ═══════ THEMES — Dark ═══════ */

[data-theme="moss"][data-mode="dark"] {
  --canvas:   #0a0b0a;
  --bg-glow:  radial-gradient(ellipse 80% 60% at 50% 40%, rgba(138,173,114,0.07) 0%, transparent 70%);
  --glass:    rgba(18,22,18,0.72);
  --glass-border: rgba(138,173,114,0.10);
  --glass-highlight: rgba(255,255,255,0.03);
  --surface:  rgba(255,255,255,0.05);
  --surface-hover: rgba(255,255,255,0.08);
  --border:   rgba(138,173,114,0.12);
  --tx:       #dce0d6;
  --tx2:      rgba(180,200,168,0.7);
  --txf:      rgba(138,160,120,0.55);
  --ac:       #8aad72;
  --ac-rgb:   138,173,114;
  --glow:     rgba(138,173,114,0.06);
  --glow-strong: rgba(138,173,114,0.14);
}

[data-theme="dusk"][data-mode="dark"] {
  --canvas:   #0a0a0c;
  --bg-glow:  radial-gradient(ellipse 80% 60% at 50% 40%, rgba(196,160,112,0.07) 0%, transparent 70%);
  --glass:    rgba(16,15,20,0.72);
  --glass-border: rgba(196,160,112,0.10);
  --glass-highlight: rgba(255,255,255,0.03);
  --surface:  rgba(255,255,255,0.05);
  --surface-hover: rgba(255,255,255,0.08);
  --border:   rgba(196,160,112,0.12);
  --tx:       #e0ddd4;
  --tx2:      rgba(190,185,170,0.7);
  --txf:      rgba(140,135,120,0.55);
  --ac:       #c4a070;
  --ac-rgb:   196,160,112;
  --glow:     rgba(196,160,112,0.06);
  --glow-strong: rgba(196,160,112,0.14);
}

[data-theme="ember"][data-mode="dark"] {
  --canvas:   #0c0a0a;
  --bg-glow:  radial-gradient(ellipse 80% 60% at 50% 40%, rgba(176,96,96,0.07) 0%, transparent 70%);
  --glass:    rgba(20,14,14,0.72);
  --glass-border: rgba(176,96,96,0.10);
  --glass-highlight: rgba(255,255,255,0.03);
  --surface:  rgba(255,255,255,0.05);
  --surface-hover: rgba(255,255,255,0.08);
  --border:   rgba(176,96,96,0.12);
  --tx:       #e4dcd4;
  --tx2:      rgba(210,178,165,0.7);
  --txf:      rgba(170,130,120,0.55);
  --ac:       #b06060;
  --ac-rgb:   176,96,96;
  --glow:     rgba(176,96,96,0.06);
  --glow-strong: rgba(176,96,96,0.14);
}

/* ═══════ THEMES — Light ═══════ */

[data-theme="moss"][data-mode="light"] {
  --canvas:   #f4f2ee;
  --bg-glow:  radial-gradient(ellipse 80% 60% at 50% 40%, rgba(109,146,84,0.06) 0%, transparent 70%);
  --glass:    rgba(255,255,255,0.68);
  --glass-border: rgba(100,140,80,0.12);
  --glass-highlight: rgba(255,255,255,0.4);
  --surface:  rgba(0,0,0,0.03);
  --surface-hover: rgba(0,0,0,0.06);
  --border:   rgba(100,140,80,0.14);
  --tx:       #1a2018;
  --tx2:      rgba(60,80,50,0.7);
  --txf:      rgba(80,100,68,0.5);
  --ac:       #6d9254;
  --ac-rgb:   109,146,84;
  --glow:     rgba(109,146,84,0.06);
  --glow-strong: rgba(109,146,84,0.12);
}

[data-theme="dusk"][data-mode="light"] {
  --canvas:   #f5f3ef;
  --bg-glow:  radial-gradient(ellipse 80% 60% at 50% 40%, rgba(168,132,76,0.06) 0%, transparent 70%);
  --glass:    rgba(255,255,255,0.68);
  --glass-border: rgba(160,128,70,0.12);
  --glass-highlight: rgba(255,255,255,0.4);
  --surface:  rgba(0,0,0,0.03);
  --surface-hover: rgba(0,0,0,0.06);
  --border:   rgba(160,128,70,0.14);
  --tx:       #1a1812;
  --tx2:      rgba(80,70,50,0.7);
  --txf:      rgba(100,90,70,0.5);
  --ac:       #a8844c;
  --ac-rgb:   168,132,76;
  --glow:     rgba(168,132,76,0.06);
  --glow-strong: rgba(168,132,76,0.12);
}

[data-theme="ember"][data-mode="light"] {
  --canvas:   #f5f1ee;
  --bg-glow:  radial-gradient(ellipse 80% 60% at 50% 40%, rgba(153,74,74,0.06) 0%, transparent 70%);
  --glass:    rgba(255,255,255,0.68);
  --glass-border: rgba(160,70,70,0.12);
  --glass-highlight: rgba(255,255,255,0.4);
  --surface:  rgba(0,0,0,0.03);
  --surface-hover: rgba(0,0,0,0.06);
  --border:   rgba(160,70,70,0.14);
  --tx:       #201816;
  --tx2:      rgba(100,60,55,0.7);
  --txf:      rgba(130,80,75,0.5);
  --ac:       #994a4a;
  --ac-rgb:   153,74,74;
  --glow:     rgba(153,74,74,0.06);
  --glow-strong: rgba(153,74,74,0.12);
}

:root {
  --f: 'Lexend Deca', system-ui, -apple-system, sans-serif;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --radius: 20px;
  --radius-sm: 14px;
  --gap: 10px;
}


/* ═══════ RESET ═══════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%; overflow: hidden;
  background: var(--canvas);
  color: var(--tx);
  font-family: var(--f);
  font-weight: 600;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.6s var(--ease);
}

::selection {
  background: rgba(var(--ac-rgb), 0.25);
  color: var(--tx);
}


/* ═══════ BACKGROUND ═══════ */

.ms-bg-video { display: none; }
.ms-dot-grid { display: none; }

.ms-bg-dim {
  position: fixed; inset: 0;
  z-index: 0;
  background: var(--bg-glow);
  pointer-events: none;
  transition: background 0.8s var(--ease);
}


/* ═══════ GLASS BASE ═══════ */

.ms-glass {
  background: var(--glass);
  backdrop-filter: blur(40px) saturate(1.2);
  -webkit-backdrop-filter: blur(40px) saturate(1.2);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow:
    0 2px 20px rgba(0,0,0,0.08),
    inset 0 1px 0 var(--glass-highlight);
  transition:
    background 0.6s var(--ease),
    border-color 0.6s var(--ease),
    box-shadow 0.6s var(--ease);
}


/* ═══════ SHELL ═══════ */

#melosurge {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  padding: var(--gap);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}


/* ═══════ HEADER ═══════ */

.ms-header {
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  height: 56px;
  flex-shrink: 0;
  z-index: 50;
}

.ms-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.ms-logo-mark {
  width: 38px; height: 38px;
  color: var(--ac);
  cursor: pointer;
  transition: color 0.8s, filter 0.3s, transform 0.3s;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ms-logo-mark::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  transition: background 0.6s var(--ease), box-shadow 0.6s var(--ease);
}
[data-mode="dark"] .ms-logo-mark::before {
  background: rgba(255,255,255,0.12);
  box-shadow: 0 0 12px rgba(var(--ac-rgb), 0.15);
}
[data-mode="light"] .ms-logo-mark::before {
  background: rgba(var(--ac-rgb), 0.1);
  box-shadow: 0 0 12px rgba(var(--ac-rgb), 0.08);
}
.ms-logo-mark svg { width: 26px; height: 26px; position: relative; z-index: 1; transform: translateY(1.5px); }
.ms-logo-mark:hover {
  filter: drop-shadow(0 0 8px rgba(var(--ac-rgb), 0.5));
  transform: scale(1.1);
}

.ms-logo-name {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.07em;
  color: var(--tx2);
  display: none;
  text-transform: lowercase;
}

.ms-search-wrap {
  flex: 1;
  position: relative;
  min-width: 0;
  max-width: 460px;
}

.ms-search-icon {
  position: absolute; left: 14px; top: 50%;
  transform: translateY(-50%);
  width: 18px; height: 18px;
  color: var(--txf);
  pointer-events: none;
  transition: color 0.3s;
}

.ms-search-input {
  width: 100%;
  padding: 10px 16px 10px 42px;
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--tx);
  font-family: var(--f);
  font-size: 1.2rem;
  font-weight: 600;
  outline: none;
  letter-spacing: 0.01em;
  transition: border-color 0.3s, background 0.3s;
}
.ms-search-input::placeholder { color: var(--txf); font-weight: 500; }
.ms-search-input:focus {
  background: var(--surface-hover);
  border-color: rgba(var(--ac-rgb), 0.2);
}
.ms-search-wrap:focus-within .ms-search-icon { color: var(--ac); }

.ms-search-spinner {
  position: absolute; right: 14px; top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--ac);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: none;
}
.ms-search-wrap.loading .ms-search-spinner { display: block; }

/* Room + mode buttons */
.ms-room-btn,
.ms-mode-toggle {
  appearance: none;
  border: none;
  background: transparent;
  width: 36px; height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
  color: var(--tx2);
  flex-shrink: 0;
  transition: color 0.3s, background 0.3s;
}
.ms-room-btn:hover,
.ms-mode-toggle:hover { color: var(--ac); background: var(--surface); }
.ms-room-btn svg,
.ms-mode-toggle svg { width: 20px; height: 20px; }

[data-mode="dark"] .ms-icon-sun  { display: block; }
[data-mode="dark"] .ms-icon-moon { display: none; }
[data-mode="light"] .ms-icon-sun  { display: none; }
[data-mode="light"] .ms-icon-moon { display: block; }

.ms-header-end { display: none; margin-left: auto; }

.ms-tabs { display: flex; gap: 4px; }

.ms-nav-link {
  padding: 8px 16px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--tx2);
  font-family: var(--f);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.ms-nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.ms-nav-link:hover { color: var(--tx); background: var(--surface); }
.ms-nav-link.active { color: var(--ac); background: rgba(var(--ac-rgb), 0.08); }

.ms-atmo-dots {
  display: flex;
  gap: 8px;
  margin-left: 12px;
}

.ms-atmo-dot {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: all 0.3s;
  background: transparent;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ms-atmo-dot span {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: block;
  transition: transform 0.3s;
}
.ms-atmo-dot[data-theme="moss"] span  { background: #8aad72; }
.ms-atmo-dot[data-theme="dusk"] span  { background: #c4a070; }
.ms-atmo-dot[data-theme="ember"] span { background: #b06060; }
.ms-atmo-dot:hover { transform: scale(1.15); }
.ms-atmo-dot.active {
  border-color: var(--ac);
  box-shadow: 0 0 10px rgba(var(--ac-rgb), 0.2);
}


/* ═══════ BODY: MAIN + NOWPLAYING ═══════ */

.ms-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  min-height: 0;
  overflow: hidden;
}

.ms-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.ms-scroll-area {
  flex: 1; overflow-y: auto;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
}
.ms-scroll-area::-webkit-scrollbar { width: 3px; }
.ms-scroll-area::-webkit-scrollbar-track { background: transparent; }
.ms-scroll-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }


/* ═══════ IDLE ═══════ */

.ms-idle {
  flex: 1;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px;
  gap: 16px;
}

.ms-idle-glyph {
  width: 64px;
  height: 64px;
  color: var(--tx2);
  opacity: 0.18;
}

.ms-idle-title {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--tx);
  opacity: 0.12;
  line-height: 1.1;
}

.ms-idle-sub {
  font-size: 0.8rem;
  color: var(--tx2);
  opacity: 0.35;
  letter-spacing: 0.12em;
  font-weight: 700;
}

.ms-moods {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 400px;
}

.ms-mood {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.25s ease;
  color: var(--tx2);
}
.ms-mood:hover {
  background: var(--surface-hover);
  border-color: rgba(var(--ac-rgb), 0.25);
  color: var(--ac);
  transform: translateY(-2px);
}
.ms-mood:active {
  transform: translateY(0);
}

.ms-mood-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.55;
  transition: opacity 0.25s;
}
.ms-mood-icon svg { width: 100%; height: 100%; }
.ms-mood:hover .ms-mood-icon { opacity: 1; }

.ms-mood-name {
  font-family: var(--f);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  white-space: nowrap;
}


/* ═══════ RESULTS ═══════ */

.ms-results {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ms-result {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  animation: emerge 0.4s var(--ease) both;
}
.ms-result:hover { background: var(--surface); }
.ms-result:active { transform: scale(0.995); }
.ms-result.active { background: rgba(var(--ac-rgb), 0.08); }

.ms-result-thumb {
  width: 48px; height: 48px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
}

.ms-result-meta { flex: 1; min-width: 0; }

.ms-result-title {
  font-size: 1.2rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
  line-height: 1.3;
}

.ms-result-artist {
  font-size: 1.2rem;
  color: var(--tx2);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ms-result-heart {
  width: 36px; height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--txf);
  cursor: pointer;
  flex-shrink: 0;
  border-radius: 50%;
  transition: all 0.2s;
  opacity: 0.65;
}
.ms-result-heart svg { width: 18px; height: 18px; }
.ms-result:hover .ms-result-heart { opacity: 0.8; }
.ms-result-heart:hover { color: var(--ac); opacity: 1 !important; transform: scale(1.15); }
.ms-result-heart.favorited { color: var(--ac); opacity: 1 !important; }
.ms-result-heart.favorited svg { fill: var(--ac); }


/* ═══════ RESONANCE ═══════ */

.ms-section-title {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 6px;
}

.ms-section-sub {
  font-size: 1.2rem;
  color: var(--txf);
  font-weight: 500;
  margin-bottom: 20px;
}

.ms-resonance-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ms-resonance-empty {
  text-align: center;
  padding: 48px 0;
  color: var(--txf);
  font-size: 1.2rem;
  font-weight: 500;
}


/* ═══════ SETUP ═══════ */

.ms-setup {
  position: absolute; inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  background: var(--glass);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border-radius: var(--radius);
}

.ms-setup-card {
  text-align: center;
  max-width: 340px;
  padding: 40px 28px;
}

.ms-setup-card h2 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-bottom: 14px;
}

.ms-setup-sub {
  font-size: 1.2rem;
  color: var(--tx2);
  line-height: 1.8;
  margin-bottom: 28px;
}
.ms-setup a { color: var(--ac); text-decoration: none; }
.ms-setup a:hover { text-decoration: underline; }

.ms-setup-input {
  width: 100%;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--tx);
  font-family: var(--f);
  font-size: 1.2rem;
  font-weight: 600;
  outline: none;
  text-align: center;
  margin-bottom: 18px;
  transition: border-color 0.3s;
}
.ms-setup-input:focus { border-color: rgba(var(--ac-rgb), 0.25); }

.ms-setup-btn {
  padding: 14px 40px;
  background: var(--ac);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--f);
  font-weight: 600;
  font-size: 1.2rem;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: all 0.2s;
}
.ms-setup-btn:hover { filter: brightness(1.1); transform: translateY(-1px); }


/* ═══════ NOW PLAYING ═══════ */

.ms-nowplaying {
  display: none;
  position: fixed; inset: 0;
  z-index: 100;
  flex-direction: column;
  align-items: center;
  padding: 24px 28px 140px;
  gap: 0;
  overflow-y: auto;
}

.ms-np-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: 100%;
}
.ms-nowplaying.open { display: flex; }

.ms-np-close {
  position: absolute;
  top: 16px; right: 16px;
  width: 40px; height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--tx2);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  z-index: 5;
}
.ms-np-close:hover { color: var(--tx); border-color: var(--surface-hover); }
.ms-np-close svg { width: 18px; height: 18px; }

.ms-np-header {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--tx2);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  width: 100%;
}

.ms-eq-bars { display: flex; align-items: flex-end; gap: 3px; height: 16px; }
.ms-eq-bars span {
  display: block;
  width: 3px;
  background: var(--ac);
  border-radius: 1px;
  opacity: 0.65;
  height: 4px;
  transition: all 0.3s;
}
.ms-eq-bars.playing span { opacity: 0.85; animation: eq 0.8s ease-in-out infinite alternate; }
.ms-eq-bars.playing span:nth-child(1) { animation-delay: 0s; }
.ms-eq-bars.playing span:nth-child(2) { animation-delay: 0.15s; }
.ms-eq-bars.playing span:nth-child(3) { animation-delay: 0.3s; }
.ms-eq-bars.playing span:nth-child(4) { animation-delay: 0.1s; }
@keyframes eq { 0% { height: 4px; } 100% { height: 16px; } }


/* ═══════ ALBUM ART + GLOW + SPIN ═══════ */

.ms-album-wrap {
  position: relative;
  width: 100%;
  max-width: 220px;
  aspect-ratio: 1;
  margin: 4px 0;
  flex-shrink: 1;
  min-height: 0;
}

.ms-album-glow {
  position: absolute;
  inset: -20%;
  border-radius: 50%;
  background: radial-gradient(circle, var(--glow-strong) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 1.2s var(--ease);
  pointer-events: none;
}
.ms-nowplaying.has-track .ms-album-glow {
  opacity: 1;
  animation: glowPulse 6s ease-in-out infinite;
}

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

.ms-album-art {
  position: relative;
  width: 100%; height: 100%;
  border-radius: 50%;
  overflow: hidden;
  background: var(--surface);
  z-index: 2;
  box-shadow:
    0 2px 16px rgba(0,0,0,0.12),
    0 0 0 1px var(--glass-border);
  transition: box-shadow 0.6s;
}

.ms-album-art.spinning { animation: spin 8s linear infinite; }
.ms-album-art.paused { animation-play-state: paused; }

.ms-album-img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: none;
}
.ms-album-img.visible { display: block; }

.ms-album-placeholder {
  position: absolute; inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--txf);
}
.ms-album-placeholder svg { width: 48px; height: 48px; }
.ms-album-img.visible ~ .ms-album-placeholder { display: none; }

.ms-np-meta {
  text-align: center;
  width: 100%;
  max-width: 300px;
}

.ms-np-title {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  margin-bottom: 6px;
  line-height: 1.3;
}

.ms-np-artist {
  font-size: 1.2rem;
  color: var(--tx2);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
}


/* ═══════ PLAYER BAR ═══════ */

.ms-bar {
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 14px;
  height: 76px;
  flex-shrink: 0;
  z-index: 110;
}

.ms-bar-track {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
  cursor: pointer;
}

.ms-bar-info { flex: 1; min-width: 0; }

.ms-bar-thumb {
  width: 48px; height: 48px;
  border-radius: 10px;
  object-fit: cover;
  display: none;
  flex-shrink: 0;
}
.ms-bar-thumb.visible { display: block; }

.ms-bar-title {
  font-size: 1.2rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

.ms-bar-artist {
  font-size: 1.2rem;
  color: var(--tx2);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

.ms-bar-heart {
  width: 36px; height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--txf);
  cursor: pointer;
  flex-shrink: 0;
  border-radius: 50%;
  transition: all 0.2s;
}
.ms-bar-heart svg { width: 18px; height: 18px; }
.ms-bar-heart:hover { color: var(--ac); transform: scale(1.15); }
.ms-bar-heart.favorited { color: var(--ac); }
.ms-bar-heart.favorited svg { fill: var(--ac); }

/* Center: controls + waveform + time */
.ms-bar-center {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.ms-bar-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.ms-bar-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--tx2);
  width: 38px; height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.15s;
}
.ms-bar-btn svg { width: 18px; height: 18px; }
.ms-bar-btn:hover { color: var(--tx); }
.ms-bar-btn:active { transform: scale(0.9); }

.ms-btn-play {
  width: 44px; height: 44px;
  background: var(--ac);
  color: #fff !important;
  transition: all 0.2s, background 0.8s;
}
.ms-btn-play:hover { transform: scale(1.06); }
.ms-btn-play svg { width: 18px; height: 18px; }

/* Mobile: hide prev/next, waveform, time labels */
.ms-btn-prev, .ms-btn-next { display: none; }
.ms-bar-wave { display: none; }
.ms-bar-time-label { display: none; }

/* Waveform */
.ms-bar-wave {
  flex: 1;
  position: relative;
  height: 36px;
  cursor: pointer;
  min-width: 0;
}

.ms-bar-wave-bars {
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  gap: 2px;
  overflow: hidden;
}

.ms-wv-bar {
  flex: 0 1 2px;
  border-radius: 2px;
  background: rgba(var(--ac-rgb), 0.1);
  transition: background 0.2s, opacity 0.2s;
}
.ms-wv-bar.played {
  background: var(--ac);
  opacity: 0.65;
}
.ms-wv-bar.current {
  background: var(--ac);
  opacity: 0.9;
  box-shadow: 0 0 4px rgba(var(--ac-rgb), 0.3);
}

.ms-bar-wave-head {
  position: absolute;
  top: 50%;
  width: 10px; height: 10px;
  background: var(--tx);
  border-radius: 5px;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 12px rgba(var(--ac-rgb), 0.3);
  transition: left 0.15s linear;
  left: 0%;
  z-index: 2;
}

.ms-bar-time-label {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--txf);
  letter-spacing: 0.03em;
  flex-shrink: 0;
  white-space: nowrap;
}


/* ═══════ ROOM PILL ═══════ */

.ms-room-pill {
  position: fixed;
  bottom: calc(var(--gap) + 60px + var(--gap) + 76px + var(--gap));
  left: 0;
  right: 0;
  margin: 0 auto;
  width: fit-content;
  z-index: 120;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 30px;
  font-size: 1.2rem;
  font-weight: 500;
  animation: emerge 0.4s var(--ease) both;
}

.ms-room-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #6dd66d;
  animation: roomPulse 2s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes roomPulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(109,214,109,0.4); }
  50%      { opacity: 0.7; box-shadow: 0 0 0 4px rgba(109,214,109,0); }
}

.ms-room-code {
  letter-spacing: 0.15em;
  font-weight: 700;
  color: var(--ac);
}

.ms-room-listeners {
  color: var(--tx2);
  font-weight: 600;
  font-size: 1.1rem;
}

.ms-room-copy,
.ms-room-leave,
.ms-room-dismiss {
  appearance: none;
  border: none;
  background: transparent;
  width: 28px; height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
  color: var(--tx2);
  transition: color 0.2s, background 0.2s;
}
.ms-room-copy:hover,
.ms-room-dismiss:hover { color: var(--ac); background: var(--surface); }
.ms-room-leave:hover { color: #c44; background: rgba(200,60,60,0.08); }
.ms-room-copy svg,
.ms-room-leave svg,
.ms-room-dismiss svg { width: 16px; height: 16px; }


/* ═══════ ROOM MODAL ═══════ */

.ms-room-overlay {
  position: fixed; inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fadeIn 0.2s var(--ease);
}

.ms-room-modal {
  position: relative;
  width: 90%;
  max-width: 360px;
  padding: 36px 28px 28px;
  text-align: center;
}

.ms-room-modal h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.ms-room-modal-sub {
  font-size: 1.2rem;
  color: var(--tx2);
  font-weight: 500;
  margin-bottom: 24px;
}

.ms-room-modal-close {
  position: absolute;
  top: 12px; right: 12px;
  width: 32px; height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--tx2);
  cursor: pointer;
  border-radius: 50%;
  transition: color 0.2s;
}
.ms-room-modal-close:hover { color: var(--tx); }
.ms-room-modal-close svg { width: 16px; height: 16px; }

.ms-room-create-btn {
  width: 100%;
  padding: 14px 0;
  background: var(--ac);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--f);
  font-weight: 600;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.02em;
}
.ms-room-create-btn:hover { filter: brightness(1.1); transform: translateY(-1px); }

.ms-room-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  color: var(--txf);
  font-size: 1.1rem;
}
.ms-room-divider::before,
.ms-room-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.ms-room-input {
  width: 100%;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--tx);
  font-family: var(--f);
  font-size: 1.3rem;
  font-weight: 600;
  outline: none;
  text-align: center;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 12px;
  transition: border-color 0.3s;
}
.ms-room-input::placeholder {
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: none;
}
.ms-room-input:focus { border-color: rgba(var(--ac-rgb), 0.3); }

.ms-room-join-btn {
  width: 100%;
  padding: 14px 0;
  background: transparent;
  color: var(--ac);
  border: 1px solid var(--ac);
  border-radius: var(--radius-sm);
  font-family: var(--f);
  font-weight: 600;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.2s;
}
.ms-room-join-btn:hover { background: rgba(var(--ac-rgb), 0.08); }



/* ═══════ MOBILE NAV ═══════ */

.ms-mobile-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  height: 60px;
  flex-shrink: 0;
  z-index: 110;
}

.ms-mob-btn {
  appearance: none;
  border: none;
  background: none;
  color: var(--txf);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 10px;
  opacity: 0.55;
  transition: all 0.2s;
}
.ms-mob-btn.active { color: var(--ac); opacity: 1; }
.ms-mob-btn svg { width: 28px; height: 28px; }


/* ═══════ NOW PLAYING — WAVEFORM (mobile flow) ═══════ */

.ms-np-progress {
  width: 100%;
  max-width: 320px;
  padding: 0 4px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.ms-np-time-label {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--txf);
  letter-spacing: 0.03em;
  flex-shrink: 0;
  white-space: nowrap;
}

.ms-np-wave {
  flex: 1;
  position: relative;
  height: 36px;
  cursor: pointer;
  min-width: 0;
  overflow: hidden;
}

.ms-np-wave-bars {
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  gap: 2px;
  overflow: hidden;
}

.ms-np-wave-head {
  position: absolute;
  top: 50%;
  width: 10px; height: 10px;
  background: var(--tx);
  border-radius: 5px;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 12px rgba(var(--ac-rgb), 0.3);
  transition: left 0.15s linear;
  left: 0%;
  z-index: 2;
}


/* ═══════ VIBE PANEL (mobile traffic light) ═══════ */

.ms-vibe-panel {
  position: fixed;
  z-index: 115;
  padding: 10px;
  border-radius: 20px;
  animation: vibeFloat 0.35s var(--ease) both;
  /* positioned via JS to sit above vibe icon */
}

@keyframes vibeFloat {
  from { opacity: 0; transform: translateY(10px) scale(0.9); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.ms-vibe-dots {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}


/* ═══════ TOAST ═══════ */

.ms-toast {
  position: fixed;
  bottom: calc(var(--gap) + 76px + var(--gap) + 60px + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  color: var(--tx2);
  padding: 12px 24px;
  border-radius: 30px;
  font-size: 1.2rem;
  opacity: 0;
  transition: all 0.3s var(--ease);
  z-index: 200;
  pointer-events: none;
}
.ms-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

#ms-yt-player {
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
}


/* ═══════ ANIMATIONS ═══════ */

@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes emerge { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes breathe { 0%, 100% { opacity: 0.7; } 50% { opacity: 0.9; } }
@keyframes heartpop { 0% { transform: scale(1); } 30% { transform: scale(1.3); } 100% { transform: scale(1); } }
.ms-heart-pop { animation: heartpop 0.35s var(--ease); }


/* Mode transition */
html.mode-transitioning,
html.mode-transitioning *,
html.mode-transitioning *::before,
html.mode-transitioning *::after {
  transition:
    background-color 0.6s var(--ease),
    background 0.6s var(--ease),
    border-color 0.6s var(--ease),
    color 0.6s var(--ease),
    box-shadow 0.6s var(--ease),
    filter 0.6s var(--ease),
    opacity 0.6s var(--ease) !important;
}

.ms-mode-toggle.switching { animation: modeFlip 0.5s var(--ease); }
@keyframes modeFlip {
  0%   { transform: rotate(0deg) scale(1); }
  40%  { transform: rotate(180deg) scale(0.8); }
  100% { transform: rotate(360deg) scale(1); }
}


/* ═══════ TABLET — 640px+ ═══════ */

@media (min-width: 640px) {
  :root { --gap: 12px; }

  .ms-header { padding: 0 20px; gap: 14px; height: 60px; }
  .ms-logo-name { display: inline; }
  .ms-search-wrap { max-width: 440px; }
  .ms-scroll-area { padding: 22px 24px; }
  .ms-idle-title { font-size: 2.6rem; }

  .ms-result { padding: 12px 14px; gap: 16px; }
  .ms-result-thumb { width: 52px; height: 52px; }
  .ms-result-heart { opacity: 0.65; }

  .ms-bar { padding: 0 24px; gap: 18px; height: 84px; }
  .ms-bar-track { max-width: 240px; gap: 12px; flex: 0 1 auto; }
  .ms-bar-thumb { width: 52px; height: 52px; }
  .ms-bar-title { max-width: 180px; }
  .ms-bar-artist { max-width: 180px; }
  .ms-bar-heart { display: flex; }
  .ms-btn-prev, .ms-btn-next { display: flex; }
  .ms-bar-controls { gap: 6px; }
  .ms-bar-wave { display: block; }
  .ms-bar-time-label { display: block; }
  .ms-bar-center { flex: 1; gap: 12px; }

  .ms-room-pill {
    bottom: calc(var(--gap) + 60px + var(--gap) + 84px + var(--gap));
  }
}


/* ═══════ DESKTOP — 960px+ ═══════ */

@media (min-width: 960px) {
  :root { --gap: 14px; }

  .ms-header { padding: 0 24px; gap: 18px; height: 64px; }

  .ms-header-end {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
  }

  .ms-search-wrap { max-width: 500px; }
  .ms-scroll-area { padding: 24px 28px; }
  .ms-idle { min-height: 280px; }
  .ms-idle-title { font-size: 2.8rem; }
  .ms-moods { max-width: 460px; }

  /* Side-by-side layout */
  .ms-body {
    flex-direction: row;
  }

  .ms-main { flex: 1; }

  /* Now Playing — right column, always visible */
  .ms-nowplaying {
    display: flex;
    position: static;
    width: 300px;
    flex-shrink: 0;
    flex-direction: column;
    align-items: center;
    padding: 20px 18px;
    gap: 0;
    z-index: auto;
    overflow-y: auto;
  }
  .ms-nowplaying.open { display: flex; }
  .ms-np-close { display: none; }
  .ms-album-wrap { max-width: 220px; flex-shrink: 0; }

  .ms-mobile-nav { display: none; }

  .ms-bar { padding: 0 28px; gap: 24px; height: 88px; }
  .ms-bar-track { max-width: 260px; min-width: 160px; cursor: default; }
  .ms-bar-title { max-width: 200px; }
  .ms-bar-artist { max-width: 200px; }
  .ms-btn-play { width: 48px; height: 48px; }
  .ms-btn-play svg { width: 20px; height: 20px; }
  .ms-bar-btn { width: 42px; height: 42px; }
  .ms-bar-btn svg { width: 20px; height: 20px; }
  .ms-bar-controls { gap: 6px; }
  .ms-bar-center { gap: 14px; }
  .ms-bar-wave { height: 40px; }

  .ms-np-progress { display: none; }
  .ms-vibe-panel { display: none !important; }

  .ms-room-pill {
    bottom: calc(var(--gap) + 88px + var(--gap));
  }

  .ms-toast {
    bottom: calc(var(--gap) + 88px + 16px);
  }
}


/* ═══════ LARGE — 1200px+ ═══════ */

@media (min-width: 1200px) {
  :root { --gap: 16px; }

  .ms-header { padding: 0 28px; }
  .ms-scroll-area { padding: 26px 32px; }
  .ms-search-wrap { max-width: 560px; }
  .ms-idle-title { font-size: 3rem; }

  .ms-nowplaying { width: 340px; padding: 24px 22px; gap: 20px; }
  .ms-album-wrap { max-width: 250px; }
  .ms-np-title { font-size: 1.4rem; }

  .ms-bar { padding: 0 32px; gap: 28px; }
  .ms-bar-track { max-width: 280px; min-width: 180px; }
  .ms-bar-title { max-width: 240px; }
  .ms-bar-artist { max-width: 240px; }
  .ms-bar-center { gap: 16px; }
}


/* ═══════ ULTRAWIDE — 1440px+ ═══════ */

@media (min-width: 1440px) {
  .ms-nowplaying { width: 380px; }
  .ms-scroll-area { padding: 28px 40px; }
  .ms-album-wrap { max-width: 280px; }
  .ms-bar-track { max-width: 320px; }
  .ms-bar-title { max-width: 280px; }
  .ms-bar-artist { max-width: 280px; }
}
