:root {
  /* LAYER 1 - PRIMITIVES */
  --blue-400:#7ba0ff;  --blue-500:#618dff;  --blue-600:#4d7dff;  --blue-700:#3865f8;  --blue-800:#2f5fff;  --gray-900:#0b0b0f;  --gray-850:#121218;  --gray-800:#1b1b20;  --gray-750:#22222a;
  --gray-700:#6d6d75;  --gray-600:#8a8a93;  --gray-500:#b0b0b8;  --gray-100:#f5f5f7;
  --green-500:#1db954; --green-700:#15803d;
  --red-400:#f87171;   --amber-400:#ffcf6b; --focus-tone:#8ab0ff;
  /* LAYER 2 - SEMANTIC (dark default) */
  --bg: var(--gray-900, #0b0b0f);                      /* alias -> #0b0b0f (unchanged)          */
  --surface: var(--gray-850, #121216);                 /* alias -> #121218 (was #121216)         */
  --surface2: var(--gray-800, #1a1a1f);                /* alias -> #1b1b20 (was #1a1a1f)         */
  --surface-1: var(--gray-850, #121218);               /* NEW page bg -> #121218                  */
  --surface-2: var(--gray-800, #1b1b20);               /* NEW cards/sidebar/bottom bar -> #1b1b20 */
  --surface-3: var(--gray-750, #22222a);               /* NEW inputs/buttons/rows -> #22222a      */
  --surface-4: var(--gray-750, #22222a);               /* NEW hovered rows/knob host (unused T2)  */
  --surface-5: var(--gray-850, #121218);               /* NEW modals/fullscreen (unused T2)       */
  --text: var(--gray-100, #f5f5f7);                    /* NEW (was UNDEFINED; 4 fallback sites)   */
  --on-surface: var(--gray-100, #f5f5f7);              /* NEW primary text                        */
  --on-surface-sub: var(--gray-500, #b0b0b8);          /* NEW secondary text                      */
  --on-surface-faint: var(--gray-600, #8a8a93);        /* NEW 12px labels                         */
  --subtext: var(--on-surface-sub);                    /* alias -> #b0b0b8 (was #a0a0a8)          */
  --faint: var(--on-surface-faint);                    /* alias -> #8a8a93 (was #6b6b73) FIX 4.5:1*/
  --grid: var(--gray-700, #6d6d75);                    /* alias -> #6d6d75 (was #2a2a2a) FIX 3:1  */
  --hover: #24242b;                                    /* alias, LITERAL (proposal slip: gray-800 would resolve #1b1b20) */
  --accent: var(--blue-600, #4d7dff);                  /* alias -> #4d7dff TEXT-only token        */
  --accent-hover: var(--blue-400, #7ba0ff);            /* alias -> #7ba0ff (unused, kept)         */
  --accent-fill: var(--blue-700, #3865f8);             /* NEW filled-button bg (unused T2)        */
  --on-accent: #fff;                                   /* NEW                                    */
  --accent-2: var(--green-500, #1db954);               /* NEW green text (unused T2)              */
  --accent-2-fill: var(--green-700, #15803d);          /* NEW green fill (unused T2)              */
  --outline: var(--gray-700, #6d6d75);                 /* NEW control borders (unused T2)         */
  --focus: var(--focus-tone, #8ab0ff);                 /* NEW focus ring (unused T2)              */
  --danger: var(--red-400, #f87171);                   /* NEW (was UNDEFINED; 1 fallback site)    */
  --warn: var(--amber-400, #ffcf6b);                   /* NEW                                    */
  /* rgba washes (T3) */
  --border-soft: rgba(42, 42, 42, 0.5);
  --scrim: rgba(0, 0, 0, 0.6);
  --overlay-scrim: rgba(8, 8, 12, 0.72);
  --pwa-scrim: rgba(0, 0, 0, 0.55);
  --topbar-glass: rgba(11, 11, 15, 0.95);
  --wash: rgba(255, 255, 255, 0.05);
  --wash-strong: rgba(255, 255, 255, 0.1);
  --wash-soft: rgba(255, 255, 255, 0.04);
  --accent-wash: rgba(29, 185, 84, 0.14);
  --accent-wash-soft: rgba(29, 185, 84, 0.06);
  --warn-wash: rgba(255, 200, 60, 0.16);
  /* typography (§4) */ --fs-xs:12px; --fs-sm:13px; --fs-md:14px; --fs-base:16px; --fs-lg:18px; --fs-xl:20px; --fs-2xl:24px; --fs-3xl:30px;
  /* line-height (§4) */ --lh-ui:1.45; --lh-title:1.2;
  /* spacing (§5) */ --space-1:4px; --space-2:8px; --space-3:12px; --space-4:16px; --space-5:20px; --space-6:24px; --space-7:32px; --space-8:40px; --space-page-bottom:96px;
  /* radius (§5) */ --radius-sm:6px; --radius-md:10px; --radius-lg:14px; --radius-pill:999px; --radius-round:50%;
  /* shadow (§5) */ --shadow-1:0 1px 3px rgba(0,0,0,0.4); --shadow-2:0 10px 15px -3px rgba(0,0,0,0.4); --shadow-3:0 25px 50px -12px rgba(0,0,0,0.8);
  /* motion (§8) */ --dur-fast:0.15s; --dur:0.2s; --dur-slow:0.25s; --ease:cubic-bezier(0.4,0,0.2,1);
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;  /* alias, verbatim */
}

[data-theme="light"] {
  --bg:#f5f5f7; --surface:#ffffff; --surface2:#e9e9ee;
  --surface-1:#f5f5f7; --surface-2:#ffffff; --surface-3:#e9e9ee; --surface-4:#e0e0e6; --surface-5:#ffffff;
  --on-surface:#1a1a1f; --on-surface-sub:#4a4a55; --on-surface-faint:#666670;
  --text:#1a1a1f; --subtext:#4a4a55; --faint:#666670;
  --grid:#6d6d75; --hover:rgba(0,0,0,0.05);
  --accent:#2f5fff; --accent-fill:#2f5fff; --on-accent:#fff; --outline:#6d6d75; --focus:#2a5df2;
  --accent-2:#15803d; /* M4: green-700 no light — #1db954 falha AA (2.59:1) sobre branco; #15803d = 5.02:1 */
  --border-soft:rgba(0,0,0,0.12); --topbar-glass:rgba(255,255,255,0.9);
  --wash:rgba(0,0,0,0.04); --wash-strong:rgba(0,0,0,0.08); --wash-soft:rgba(0,0,0,0.03);
  --accent-wash:rgba(29,185,84,0.12); --accent-wash-soft:rgba(29,185,84,0.06); --warn-wash:rgba(255,200,60,0.25);
}

/* ---------- Focus (global keyboard ring, T4) ---------- */

:focus-visible {
  outline: 2px solid var(--focus, #8ab0ff);
  outline-offset: 2px;
}

/* Older engines: no :focus-visible support — fall back to plain :focus. */
@supports not selector(:focus-visible) {
  :focus {
    outline: 2px solid var(--focus, #8ab0ff);
    outline-offset: 2px;
  }
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  height: 100%;
  margin: 0;
}

/* Dynamic viewport: the URL bar shrinking on mobile must not overflow the app. */
@supports (height: 100dvh) {
  html,
  body,
  #app {
    height: 100dvh;
  }
}

body {
  background: var(--bg);
  color: var(--text, #ffffff);
  font-family: var(--font-sans);
  line-height: var(--lh-ui, 1.45);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

::-webkit-scrollbar {
  width: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--grid);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--outline, #3a3a42);
}

button {
  font-family: inherit;
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 0;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

input {
  font-family: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
}

/* ---------- Layout ---------- */

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.main-area {
  position: relative;
  flex: 1;
  overflow-y: auto;
  background: linear-gradient(to bottom, rgba(26, 26, 31, 0.6), var(--bg));
}

.page {
  padding-bottom: 96px;
}

/* Mobile bottom bar is taller (now playing + controls + progress). */
@media (max-width: 767px) {
  .page {
    padding-bottom: 196px;
  }
}

/* ---------- Sidebar ---------- */

.sidebar {
  display: flex;
  flex-direction: column;
  width: 240px;
  flex-shrink: 0;
  border-right: 1px solid var(--border-soft, rgba(42, 42, 42, 0.5));
  background: var(--surface-2, #1b1b20);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sidebar-brand svg {
  color: var(--accent);
}

.sidebar-close {
  display: none;
  padding: 4px;
  border-radius: 9999px;
  color: var(--subtext);
}

.sidebar-close:hover {
  color: var(--text, #fff);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 12px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--subtext);
  cursor: pointer;
  transition: color 0.15s;
}

.nav-link:hover {
  color: var(--text, #fff);
}

.nav-link.active {
  color: var(--text, #fff);
  background: var(--hover);
}

.sidebar-playlists-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 20px 20px 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
}

.sidebar-playlists {
  flex: 1;
  overflow-y: auto;
  margin-top: 4px;
  padding: 0 12px 12px;
}

.playlist-link {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 14px;
  color: var(--subtext);
  cursor: pointer;
  transition: color var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1));
}

.playlist-link:hover {
  color: var(--text, #fff);
}

.playlist-link.active {
  color: var(--text, #fff);
  background: var(--hover);
}

.playlists-empty {
  padding: 6px 12px;
  font-size: 12px;
  color: var(--faint);
}

.sidebar-footer {
  border-top: 1px solid var(--border-soft, rgba(42, 42, 42, 0.5));
  padding: 12px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
}

.sidebar-user-info {
  min-width: 0;
}

.sidebar-user-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 500;
}

.sidebar-user-handle {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--faint);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border-radius: 9999px;
  color: var(--subtext);
  transition: background var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1)), color var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1));
}

.icon-btn:hover {
  background: var(--hover);
  color: var(--text, #fff);
}

/* ---------- Mobile top bar ---------- */

.mobile-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: none;
  align-items: center;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
  background: var(--topbar-glass, rgba(11, 11, 15, 0.95));
  backdrop-filter: blur(8px);
}

.mobile-topbar span {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
}

.mobile-topbar span svg {
  color: var(--accent);
}

.mobile-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
}

.mobile-overlay.open {
  display: block;
}

.mobile-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: var(--scrim, rgba(0, 0, 0, 0.6));
}

.mobile-sidebar {
  position: absolute;
  inset: 0 auto 0 0;
  width: 288px;
  background: var(--surface-2, #1b1b20);
  box-shadow: var(--shadow-3);
}

/* ---------- Cards / sections ---------- */

.page-padding {
  padding: 24px 24px 0;
}

.page-title {
  margin: 0 0 8px;
  font-size: clamp(30px, 3vw + 1rem, 48px);
  font-weight: 700;
  line-height: var(--lh-title, 1.2);
}

.section {
  padding: 12px 24px;
}

.section-title {
  margin: 0 0 12px;
  font-size: 20px;
  font-weight: 700;
}

.card-row {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.card {
  width: 144px;
  flex-shrink: 0;
  border-radius: var(--radius-md, 10px);
  background: var(--surface-2, #1b1b20);
  border: 1px solid var(--outline, #6d6d75);
  padding: 12px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.2s;
}

.card:hover {
  background: var(--hover);
  transform: translateY(-2px);
}

.card-image-wrap {
  position: relative;
  overflow: hidden;
  border-radius: 6px;
}

.card-image-wrap.square {
  aspect-ratio: 1 / 1;
}

.card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-play {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 9999px;
  background: var(--accent-fill, #3865f8);
  color: #fff;
  box-shadow: var(--shadow-2);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.15s, transform 0.15s, background 0.15s;
}

.card:hover .card-play {
  opacity: 1;
  transform: translateY(0);
}

.card-title {
  margin: 8px 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 600;
}

.card-subtitle {
  margin: 2px 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--subtext);
}

.genre-card {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  width: 144px;
  height: 96px;
  flex-shrink: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(97, 141, 255, 0.4), var(--grid));
  box-shadow: inset 0 0 0 1px var(--outline, #6d6d75);
  padding: 12px;
  text-align: left;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s;
}

.genre-card:hover {
  transform: scale(1.05);
}

.genre-count {
  font-size: 12px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.7);
}

.empty-state {
  padding: 40px;
  text-align: center;
  color: var(--subtext);
}

.empty-state p:first-child {
  margin: 0;
  font-size: 18px;
}

.empty-state p:last-child {
  margin: 4px 0 0;
  font-size: 14px;
}

/* ---------- Tabs ---------- */

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.tab-btn {
  border-radius: 9999px;
  padding: 6px 16px;
  font-size: 14px;
  font-weight: 500;
  background: var(--surface);
  color: var(--subtext);
  transition: color 0.15s;
}

.tab-btn:hover {
  color: var(--text, #fff);
}

.tab-btn.active {
  background: #fff;
  color: #000;
}

.card-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

/* ---------- Track rows ---------- */

.track-list {
  border-radius: 12px;
  background: rgba(18, 18, 22, 0.3);
  padding: 8px;
}

.track-row {
  display: grid;
  grid-template-columns: 2.5rem 1fr auto;
  align-items: center;
  gap: 12px;
  border-radius: 8px;
  padding: 8px 12px;
  transition: background 0.15s;
}

.track-row:hover {
  background: var(--hover);
}

.track-number {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  color: var(--subtext);
}

.track-play-btn {
  display: none;
  color: #fff;
}

.track-row:hover .track-number .track-num-text {
  display: none;
}

.track-row:hover .track-play-btn {
  display: block;
}

/* Linha em reprodução (sincronizada pelo player). */
.track-row.playing .track-title {
  color: var(--accent);
}

.track-row.playing .track-num-text {
  display: none;
}

.track-row.playing .track-number::before {
  content: '▶';
  font-size: 11px;
  color: var(--accent);
}

.track-row.playing:hover .track-number::before {
  display: none;
}

.track-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.track-main:focus-visible {
  border-radius: 6px;
}

.track-art {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  object-fit: cover;
  display: block;
}

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

.track-title {
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 14px;
  font-weight: 500;
}

.track-artist {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--subtext);
}

.track-album {
  display: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 8px;
  font-size: 14px;
  color: var(--subtext);
}

.track-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.track-like {
  padding: 4px;
  color: var(--subtext);
  opacity: 0;
  transition: opacity var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1)), color var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1));
}

.track-row:hover .track-like {
  opacity: 1;
}

.track-like.liked {
  color: var(--accent);
  opacity: 1;
}

.track-duration {
  width: 40px;
  text-align: right;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--subtext);
}

@media (min-width: 640px) {
  .track-row {
    grid-template-columns: 2.5rem 1fr 1fr auto auto;
  }

  .track-num-text {
    display: inline;
  }

  .track-art {
    display: block;
  }

  .track-album {
    display: block;
  }

  .track-like {
    opacity: 0;
  }

  .track-row:hover .track-like {
    opacity: 1;
  }
}

/* ---------- Detail headers (album/artist/playlist) ---------- */

.detail-header {
  display: flex;
  flex-direction: column;
  gap: 24px;
  background: linear-gradient(to bottom, rgba(42, 42, 42, 0.4), transparent);
  padding: 24px;
}

.detail-header.horizontal {
  flex-direction: row;
  align-items: flex-end;
}

.detail-art {
  width: 176px;
  height: 176px;
  flex-shrink: 0;
  border-radius: 12px;
  object-fit: cover;
  box-shadow: var(--shadow-3);
}

.detail-art.round {
  border-radius: 9999px;
}

.detail-art-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 176px;
  height: 176px;
  flex-shrink: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), rgba(97, 141, 255, 0.4));
  font-size: 60px;
  box-shadow: var(--shadow-3);
}

.detail-info {
  min-width: 0;
  text-align: center;
}

.detail-type {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--subtext);
}

.detail-title {
  margin: 4px 0 0;
  word-break: break-word;
  font-size: clamp(36px, 3.5vw + 1rem, 48px);
  font-weight: 700;
  line-height: var(--lh-title, 1.2);
}

.detail-meta {
  margin: 8px 0 0;
  font-size: 14px;
  color: var(--subtext);
}

.detail-meta .link {
  cursor: pointer;
  font-weight: 500;
  color: var(--text, #fff);
}

.detail-meta .link:hover {
  text-decoration: underline;
}

.detail-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 16px;
}

.btn-accent {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 9999px;
  background: var(--accent-fill, #3865f8);
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  transition: transform 0.15s;
}

.btn-accent:hover {
  transform: scale(1.05);
}

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

.btn-accent:disabled:hover {
  transform: none;
}

.btn-icon-lg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  border-radius: 9999px;
  color: var(--subtext);
  transition: background var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1)), color var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1));
}

.btn-icon-lg:hover {
  background: var(--hover);
  color: var(--text, #fff);
}

.btn-icon-lg.liked {
  color: var(--accent);
}

@media (min-width: 640px) {
  .detail-header.horizontal {
    align-items: flex-end;
  }

  .detail-art,
  .detail-art-icon {
    width: 224px;
    height: 224px;
  }

  .detail-info {
    text-align: left;
  }

  .detail-title {
    font-size: clamp(36px, 3.5vw + 1rem, 48px);
  }

  .detail-actions {
    justify-content: flex-start;
  }
}

.detail-content {
  padding: 0 24px;
}

.track-list-header {
  display: none;
  grid-template-columns: 2.5rem 1fr 1fr auto;
  gap: 12px;
  border-bottom: 1px solid var(--border-soft, rgba(42, 42, 42, 0.5));
  padding: 0 12px 8px;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--faint);
}

@media (min-width: 640px) {
  .track-list-header {
    display: grid;
  }
}

.section-block {
  margin-top: 24px;
}

.section-block h2 {
  margin: 0 0 12px;
  font-size: 20px;
  font-weight: 700;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
  font-size: 14px;
  color: var(--subtext);
  cursor: pointer;
  transition: color var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1));
}

.back-link:hover {
  color: var(--text, #fff);
}

.playlist-track-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.playlist-track-row > .flex-1 {
  flex: 1;
  min-width: 0;
}

.remove-track-btn {
  padding: 8px;
  color: var(--subtext);
  opacity: 0;
  transition: opacity var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1)), color var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1));
}

.playlist-track-row:hover .remove-track-btn {
  opacity: 1;
}

.remove-track-btn:hover {
  color: var(--danger, #f87171);
}

/* ---------- Login ---------- */

.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 16px;
  background: linear-gradient(to bottom, rgba(26, 26, 31, 0.6), var(--bg));
}

.login-box {
  width: 100%;
  max-width: 384px;
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}

.login-brand svg {
  color: var(--accent);
}

.login-brand h1 {
  margin: 0;
  font-size: clamp(30px, 2.5vw + 1rem, 40px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: var(--lh-title, 1.2);
}

.login-brand p {
  margin: 0;
  font-size: 14px;
  color: var(--subtext);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-radius: 16px;
  background: var(--surface-2, #1b1b20);
  border: 1px solid var(--outline, #6d6d75);
  padding: 24px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.4);
}

.form-input {
  border-radius: 8px;
  background: var(--surface-3, #22222a);
  padding: 12px 16px;
  font-size: 14px;
  color: var(--text, #fff);
  border: none;
  outline: none;
  box-shadow: 0 0 0 1px var(--outline, #6d6d75);
}

.form-input:focus {
  box-shadow: 0 0 0 2px var(--accent);
}

.form-input::placeholder {
  color: var(--faint);
}

.login-error {
  margin: 0;
  font-size: 12px;
  color: var(--danger, #f87171);
}

.login-submit {
  margin-top: 8px;
  border-radius: 9999px;
  background: var(--accent-fill, #3865f8);
  padding: 12px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  transition: opacity 0.15s;
}

.login-submit:hover {
  opacity: 0.9;
}

.login-submit:disabled {
  opacity: 0.4;
}

.login-admin-link {
  display: block;
  width: fit-content;
  margin: 20px auto 0;
  color: var(--subtext);
  font-size: 13px;
  text-align: center;
  text-decoration: none;
  transition: color var(--dur-fast, 0.15s) var(--ease, ease);
}

.login-admin-link:hover,
.login-admin-link:focus-visible {
  color: var(--accent);
  text-decoration: underline;
}

.login-screen.admin-login-screen {
  background:
    radial-gradient(ellipse 70% 55% at 50% -5%, rgba(176, 136, 75, 0.16), transparent 70%),
    linear-gradient(to bottom, rgba(26, 26, 31, 0.6), var(--bg));
}

.admin-login-box { max-width: 420px; }
.admin-login-box .login-brand { margin-bottom: 26px; }
.admin-login-box .login-brand svg {
  color: #f1c77b;
  background: linear-gradient(135deg, #775a2c, #b0884b);
}
.admin-login-form { border-color: color-mix(in srgb, #b0884b 55%, var(--outline, #6d6d75)); }
.admin-login-form:focus-within { box-shadow: var(--shadow-3), 0 0 0 1px #b0884b; }
.admin-login-form .login-submit {
  background: linear-gradient(135deg, #8d6935, #b0884b);
  color: #fff;
  box-shadow: 0 8px 20px rgba(176, 136, 75, 0.22);
}
.admin-login-form .login-submit:hover:not(:disabled) { box-shadow: 0 10px 24px rgba(176, 136, 75, 0.32); }
.admin-login-back { margin-top: 22px; }

@media (max-width: 480px) {
  .admin-login-box { max-width: 100%; }
  .admin-login-form { padding: 20px; }
}

/* ---------- Search ---------- */

.search-bar {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.search-input-wrap {
  position: relative;
  max-width: 576px;
  margin-bottom: 24px;
  flex: 1 1 260px;
}

.search-type-select {
  appearance: none;
  -webkit-appearance: none;
  border-radius: 9999px;
  background: var(--surface-3, #22222a);
  border: none;
  outline: none;
  padding: 12px 40px 12px 16px;
  font-size: 14px;
  color: var(--text, #fff);
  box-shadow: 0 0 0 1px var(--outline, #6d6d75);
  cursor: pointer;
  min-width: 150px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23a0a0b0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

.search-type-select:focus {
  box-shadow: 0 0 0 2px var(--accent);
}

.search-type-select option {
  background: var(--surface-3, #22222a);
  color: var(--text, #fff);
}

.search-input {
  width: 100%;
  border-radius: 9999px;
  background: var(--surface-3, #22222a);
  border: none;
  outline: none;
  padding: 12px 16px 12px 44px;
  font-size: 14px;
  color: var(--text, #fff);
  box-shadow: 0 0 0 1px var(--outline, #6d6d75);
}

.search-input:focus {
  box-shadow: 0 0 0 2px var(--accent);
}

.search-input::placeholder {
  color: var(--faint);
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--faint);
  pointer-events: none;
}

/* ---------- Bottom bar (player) ---------- */

.bottom-bar {
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  border-top: 1px solid var(--border-soft, rgba(42, 42, 42, 0.5));
  background: var(--surface-2, #1b1b20);
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
}

@media (min-width: 768px) {
  .bottom-bar {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
    height: 96px;
    padding: 0 16px;
  }
}

.now-playing {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  cursor: pointer;
  border-radius: 10px;
  padding: 4px;
  transition: background var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1));
}

@media (hover: hover) {
  .now-playing:hover {
    background: var(--hover);
  }
}

.now-playing-art {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 6px;
  object-fit: cover;
  cursor: pointer;
}

@media (min-width: 768px) {
  .now-playing-art {
    width: 56px;
    height: 56px;
  }
}

.now-playing-info {
  min-width: 0;
}

.now-playing-title {
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 14px;
  font-weight: 500;
}

.now-playing-artist {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--subtext);
  cursor: pointer;
}

.now-playing-artist:hover {
  color: var(--text, #fff);
  text-decoration: underline;
}

.player-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  order: 2;
}

@media (min-width: 768px) {
  .player-controls {
    order: 0;
  }
}

.player-buttons {
  display: flex;
  align-items: center;
  gap: 16px;
}

.player-btn {
  padding: 4px;
  color: var(--subtext);
  transition: color var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1));
}

.player-btn:hover {
  color: var(--text, #fff);
}

.player-btn.active {
  color: var(--accent);
}

.player-btn-main {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 9999px;
  background: #fff;
  color: #000;
  transition: transform var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1));
}

.player-btn-main:hover {
  transform: scale(1.05);
}

.player-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 576px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--subtext);
}

.progress-time {
  width: 40px;
  text-align: right;
}

.progress-time:first-child {
  text-align: right;
}

.progress-time:last-child {
  text-align: left;
}

.progress-track {
  position: relative;
  height: 20px;
  flex: 1;
  display: flex;
  align-items: center;
  border-radius: 9999px;
  background: var(--grid);
  cursor: pointer;
  touch-action: none;
}

.progress-fill {
  position: absolute;
  left: 0;
  top: 50%;
  height: 4px;
  border-radius: 9999px;
  background: var(--accent-fill, #3865f8);
  transform: translateY(-50%);
  pointer-events: none;
}

.progress-fill::after {
  content: '';
  position: absolute;
  right: -6px;
  top: 50%;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent-fill, #3865f8);
  transform: translateY(-50%);
  opacity: 0;
}

.progress-track:hover .progress-fill,
.progress-track.dragging .progress-fill {
  background: var(--accent-fill, #3865f8);
}

.progress-track:hover .progress-fill::after,
.progress-track.dragging .progress-fill::after {
  opacity: 1;
}

.player-volume {
  display: none;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

@media (min-width: 768px) {
  .player-volume {
    display: flex;
  }
}

.volume-slider {
  width: 96px;
  accent-color: var(--accent-fill, #3865f8);
}

.vol-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--subtext);
}

/* ---------- Fullscreen player ---------- */

.fullscreen-player {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  background: linear-gradient(to bottom, var(--surface2), var(--bg));
  padding: 24px 24px calc(24px + env(safe-area-inset-bottom));
}

.fullscreen-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.fullscreen-content {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  min-height: 0;
}

.fullscreen-art {
  width: min(72vw, 384px, 40vh);
  height: auto;
  aspect-ratio: 1 / 1;
  border-radius: 16px;
  object-fit: cover;
  box-shadow: var(--shadow-3);
}

.fullscreen-track-info {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  width: 100%;
  max-width: 384px;
}

.fullscreen-title {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 24px;
  font-weight: 700;
}

.fullscreen-artist {
  margin: 4px 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
  color: var(--subtext);
  cursor: pointer;
}

.fullscreen-artist:hover {
  color: var(--text, #fff);
  text-decoration: underline;
}

.fullscreen-buttons {
  display: flex;
  align-items: center;
  gap: 24px;
}

.fullscreen-btn-main {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 9999px;
  background: #fff;
  color: #000;
  transition: transform var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1));
}

.fullscreen-btn-main:hover {
  transform: scale(1.05);
}

/* ---------- Settings ---------- */

.settings-page {
  max-width: 672px;
  margin: 0 auto;
  padding: 24px 16px;
}

.settings-card {
  margin-bottom: 24px;
  border-radius: 16px;
  background: var(--surface-2, #1b1b20);
  border: 1px solid var(--outline, #6d6d75);
  padding: 24px;
}

.settings-card h2 {
  margin: 0 0 16px;
  font-size: 18px;
  font-weight: 700;
}

.settings-text {
  margin: 0;
  font-size: 14px;
  color: var(--subtext);
}

.settings-text strong {
  color: var(--text, #fff);
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
}

.settings-playlists {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.settings-playlist-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border-radius: 10px;
  background: var(--surface2);
  border: none;
  padding: 12px 16px;
  font-size: 14px;
  color: var(--text, #fff);
  cursor: pointer;
  transition: box-shadow var(--dur, 0.2s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1));
}

.settings-playlist-item:hover {
  box-shadow: 0 0 0 1px var(--grid);
}

/* ---------- Upload form (admin) ---------- */

.modal-upload {
  max-width: 480px;
}

.upload-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.upload-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--subtext);
}

.upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 480px) {
  .upload-grid {
    grid-template-columns: 1fr;
  }
}

.upload-file-input {
  display: none;
}

.upload-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 120px;
  border: 1.5px dashed var(--outline, #6d6d75);
  border-radius: 14px;
  background: var(--surface2);
  cursor: pointer;
  text-align: center;
  padding: 16px;
  transition: border-color 0.15s, background 0.15s;
}

.upload-dropzone:hover,
.upload-dropzone.drag {
  border-color: var(--accent);
  background: var(--accent-wash-soft, rgba(29, 185, 84, 0.06));
}

.upload-dropzone.error {
  border-color: var(--danger, #f87171);
}

.upload-dropzone-icon {
  font-size: 28px;
  color: var(--accent);
}

.upload-dropzone-title {
  margin: 4px 0 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text, #fff);
}

.upload-dropzone-hint {
  margin: 0;
  font-size: 12px;
  color: var(--faint);
}

.upload-photo-drop {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1.5px dashed var(--outline, #6d6d75);
  border-radius: 12px;
  background: var(--surface2);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--subtext);
  cursor: pointer;
}

.upload-photo-drop:hover {
  border-color: var(--accent);
}

.upload-info {
  font-size: 12px;
  color: var(--subtext);
  margin: 8px 0 0;
}

.upload-progress {
  margin: 12px 0 0;
}

.upload-progress-bar {
  height: 8px;
  border-radius: 9999px;
  background: var(--surface2);
  overflow: hidden;
}

.upload-progress-fill {
  height: 100%;
  border-radius: 9999px;
  background: var(--accent-fill, #3865f8);
  transition: width 0.25s ease;
}

.upload-progress-text {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--subtext);
  overflow-wrap: anywhere;
}

.upload-fails {
  margin: 10px 0 0;
  max-height: 140px;
  overflow-y: auto;
}

.upload-fail {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--danger, #f87171);
  overflow-wrap: anywhere;
}

.upload-fail strong {
  color: var(--text, #fff);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 9999px;
  background: var(--surface2);
  padding: 8px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--subtext);
  transition: color var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1));
}

.btn-secondary:hover {
  color: var(--text, #fff);
}

.settings-message {
  margin: 12px 0 0;
  font-size: 14px;
  color: var(--accent);
}

.settings-dl {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
  font-size: 14px;
}

.settings-dl > div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.settings-dt {
  color: var(--subtext);
}

.settings-dd {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.settings-dd.mono {
  font-family: monospace;
  font-size: 12px;
}

/* ---------- Queue ---------- */

.queue-current-marker {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  color: var(--accent);
}

.queue-track-wrap {
  position: relative;
  padding-left: 12px;
}

/* ---------- Spinner ---------- */

.spinner-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--subtext);
}

.spinner {
  width: 28px;
  height: 28px;
  margin-right: 8px;
  border: 3px solid var(--grid);
  border-top-color: var(--accent-fill, #3865f8);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- Misc ---------- */

.loading-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--subtext);
}

.mobile-only {
  display: none;
}

@media (max-width: 767px) {
  .sidebar {
    display: none;
  }

  .mobile-topbar {
    display: flex;
  }

  .sidebar-close {
    display: block;
  }

  .fullscreen-buttons {
    gap: 10px;
  }
}

@media (min-width: 768px) {
  .mobile-overlay {
    display: none !important;
  }
}

/* ---------- Touch / mobile-first ---------- */

/* iOS zooms into inputs with font-size < 16px on focus; keep it readable. */
@media (hover: none) and (pointer: coarse) {
  input,
  select,
  textarea {
    font-size: 16px !important;
  }
}


/* ================= Admin / modals / login toggle ================= */

.login-toggle {
  display: flex;
  gap: 4px;
  background: var(--surface2, #1a1a21);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 16px;
}
.login-toggle-btn {
  flex: 1;
  padding: 8px 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--subtext, #9a9aa5);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1)), color var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1));
}
.login-toggle-btn.active {
  background: var(--accent-fill, #3865f8);
  color: var(--on-accent, #fff);
}
.login-toggle-btn:hover:not(.active) { color: var(--text, #f0f0f4); }

.track-add {
  display: none;
  border: none;
  background: transparent;
  color: var(--subtext, #9a9aa5);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: color var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1)), background var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1));
}
.track-share { display: inline-flex; }
.track-row:hover .track-add,
.track-add:focus-visible { display: inline-flex; }
.track-add:hover { color: var(--accent-2, #1db954); background: var(--wash-soft, rgba(255, 255, 255, 0.06)); }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-scrim, rgba(8, 8, 12, 0.72));
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal {
  background: var(--surface-5, #1c1c24);
  border: 1px solid var(--outline, #2c2c36);
  border-radius: 14px;
  padding: 20px;
  width: 100%;
  max-width: 420px;
  max-height: 82vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.modal-wide { max-width: 620px; }
.modal h3 { margin: 0; font-size: 18px; }
.modal-sub { margin: 0 0 4px; color: var(--subtext, #9a9aa5); font-size: 13px; }
.modal-empty { color: var(--subtext, #9a9aa5); font-size: 13px; margin: 4px 0; }
.modal-item {
  text-align: left;
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  background: var(--wash, rgba(255, 255, 255, 0.05));
  color: var(--text, #f0f0f4);
  cursor: pointer;
  font-size: 14px;
  transition: background var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1));
}
.modal-item:hover { background: var(--wash-strong, rgba(255, 255, 255, 0.1)); }
.modal-item.new { color: var(--accent-2, #1db954); font-weight: 600; }
.modal-close {
  padding: 8px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--subtext, #9a9aa5);
  cursor: pointer;
  font-size: 14px;
  transition: background var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1)), color var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1));
}
.modal-close:hover { background: var(--wash-soft, rgba(255, 255, 255, 0.06)); color: var(--text, #f0f0f4); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }
.modal-section-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--subtext, #9a9aa5);
  margin-top: 8px;
}
.modal-check { font-size: 14px; color: var(--text, #f0f0f4); cursor: pointer; padding: 4px 0; }
.modal-check input { margin-right: 8px; accent-color: var(--accent-2, #1db954); }
.modal-scroll { max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; border: 1px solid var(--outline, #2c2c36); border-radius: 8px; padding: 8px; }

.admin-toolbar { display: flex; gap: 8px; margin: 12px 0; }
.admin-table { display: flex; flex-direction: column; gap: 8px; }
.admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--wash-soft, rgba(255, 255, 255, 0.04));
  border: 1px solid var(--outline, #26262f);
  border-radius: 10px;
  padding: 10px 14px;
}
.admin-row-main { flex: 1; min-width: 0; }
.admin-row-title { margin: 0; font-size: 15px; font-weight: 600; }
.admin-row-sub { margin: 2px 0 0; font-size: 13px; color: var(--subtext, #9a9aa5); }
.admin-row-actions { display: flex; gap: 6px; align-items: center; }
.admin-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.chip {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-wash, rgba(29, 185, 84, 0.14));
  color: var(--accent-2, #1db954);
}
.badge {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--warn-wash, rgba(255, 200, 60, 0.16));
  color: var(--warn, #ffcf6b);
  vertical-align: middle;
}

/* ---------- Touch / mobile-first (kept last so it wins the cascade) ---------- */

/* Touch has no hover: reveal the per-row actions and bigger tap targets. */
@media (hover: none) {
  .track-row .track-play-btn {
    display: block;
  }

  .track-row .track-like {
    opacity: 1;
  }

  .track-row .track-add {
    display: inline-flex;
  }

  /* The play button replaces the row number on touch. */
  .track-row .track-num-text {
    display: none;
  }

  .card-play {
    opacity: 1;
    transform: translateY(0);
  }

  .player-btn {
    padding: 8px;
  }

  .player-btn-main {
    width: 44px;
    height: 44px;
  }

  .icon-btn {
    padding: 10px;
  }
}

/* ---------- PWA install popup ---------- */

.pwa-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--pwa-scrim, rgba(0, 0, 0, 0.55));
  backdrop-filter: blur(2px);
}

.pwa-card {
  width: 100%;
  max-width: 380px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface-5, #121218);
  border: 1px solid var(--grid);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.pwa-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pwa-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent-fill, #3865f8);
  color: var(--on-accent, #fff);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.pwa-header h2 {
  margin: 0;
  font-size: 18px;
}

.pwa-desc {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--subtext);
}

.pwa-tips {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pwa-tips li {
  display: flex;
  gap: 8px;
  font-size: 13px;
  color: var(--subtext);
}

.pwa-tips li::before {
  content: '?';
  color: var(--accent);
  flex-shrink: 0;
}

.pwa-steps-title {
  margin: 16px 0 8px;
  font-size: 13px;
  font-weight: 600;
}

.pwa-steps {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pwa-steps li {
  font-size: 13px;
  color: var(--subtext);
}

.pwa-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.pwa-btn {
  flex: 1;
  border-radius: 9999px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  background: var(--surface2);
  color: var(--subtext);
  cursor: pointer;
  transition: color var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1));
}

.pwa-btn:hover {
  color: var(--text, #fff);
}

.pwa-btn.primary {
  background: var(--accent-fill, #3865f8);
  color: var(--on-accent, #fff);
}

/* ================= M4 — Polimento visual profissional (additive, sobre os tokens) ================= */

/* --- Login: ambiente com glow + logo em tile + card elevado + erro em pill --- */

.login-screen {
  background:
    radial-gradient(ellipse 65% 55% at 50% -5%, rgba(77, 125, 255, 0.12), transparent 70%),
    linear-gradient(to bottom, rgba(26, 26, 31, 0.6), var(--bg));
}

.login-brand svg {
  width: 54px;
  height: 54px;
  padding: 14px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent-fill, #3865f8), rgba(97, 141, 255, 0.55));
  color: #fff;
  box-shadow: var(--shadow-2);
}

.login-form {
  transition: box-shadow var(--dur, 0.2s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1));
  box-shadow: var(--shadow-3);
}

.login-form:focus-within {
  box-shadow: var(--shadow-3), 0 0 0 1px var(--accent);
}

.login-form:has(.login-error:not(:empty)) {
  border-color: rgba(248, 113, 113, 0.55);
}

.login-error:not(:empty) {
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(248, 113, 113, 0.12);
}

.login-toggle {
  box-shadow: inset 0 0 0 1px var(--outline, #6d6d75);
}

.login-toggle-btn.active {
  box-shadow: var(--shadow-1);
}

.login-submit {
  transition: opacity var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1)), transform var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1)), box-shadow var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1));
  box-shadow: 0 8px 20px rgba(56, 101, 248, 0.25);
}

.login-submit:hover:not(:disabled) {
  opacity: 1;
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(56, 101, 248, 0.35);
}

.login-submit:active:not(:disabled) {
  transform: translateY(0) scale(0.98);
}

/* --- Player bar: elevação, capa com sombra, controles com hover/active --- */

.bottom-bar {
  box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.35);
}

.now-playing-art {
  box-shadow: var(--shadow-1);
}

.player-btn {
  transition: color var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1)), transform var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1));
}

.player-btn:hover {
  transform: scale(1.12);
}

.player-btn:active {
  transform: scale(0.92);
}

.player-btn-main {
  box-shadow: var(--shadow-1);
}

.player-btn-main:hover {
  box-shadow: 0 0 0 4px var(--wash-strong, rgba(255, 255, 255, 0.1)), var(--shadow-2);
}

.player-btn-main:active {
  transform: scale(0.94);
}

.progress-fill {
  transition: height var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1)), background var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1));
}

.progress-track:hover .progress-fill,
.progress-track.dragging .progress-fill {
  height: 6px;
}

.fullscreen-btn-main {
  box-shadow: var(--shadow-2);
}

.fullscreen-btn-main:active {
  transform: scale(0.95);
}

/* --- Cards: hover-lift + sombra + overlay play com feedback --- */

.card {
  transition: background 0.15s, border-color 0.15s, transform 0.2s, box-shadow 0.2s;
}

.card:hover {
  transform: translateY(-4px);
  border-color: var(--grid);
  box-shadow: var(--shadow-2);
}

.card-play {
  transition: opacity 0.15s, transform 0.15s, background 0.15s, box-shadow 0.15s;
}

.card-play:hover {
  transform: translateY(0) scale(1.08);
}

.card-play:focus-visible {
  opacity: 1;
  transform: translateY(0);
}

.genre-card {
  transition: transform 0.2s, box-shadow 0.2s;
}

.genre-card:hover {
  box-shadow: var(--shadow-2);
}

.card-row {
  scrollbar-width: thin;
  scrollbar-color: var(--grid) transparent;
}

.card-row::-webkit-scrollbar {
  height: 8px;
}

.card-row::-webkit-scrollbar-thumb {
  border-radius: 999px;
}

/* --- Sidebar: logo em tile + item ativo com indicador lateral --- */

.sidebar-brand svg {
  padding: 4px;
  border-radius: 8px;
  background: var(--accent-wash, rgba(29, 185, 84, 0.14));
}

.nav-link {
  position: relative;
  transition: color var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1)), background var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1));
}

.nav-link:hover {
  background: var(--wash-soft, rgba(255, 255, 255, 0.04));
}

.nav-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 20%;
  bottom: 20%;
  width: 3px;
  border-radius: 999px;
  background: var(--accent);
}

/* --- Admin: tabs, rows, badges, chips e botões com estados --- */

.tab-btn {
  transition: color var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1)), background var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1)), box-shadow var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1));
}

.tab-btn:hover:not(.active) {
  background: var(--wash-soft, rgba(255, 255, 255, 0.04));
}

.tab-btn.active {
  box-shadow: var(--shadow-1);
}

.admin-row {
  transition: background var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1)), border-color var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1)), box-shadow var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1));
}

.admin-row:hover {
  background: var(--surface-3, #22222a);
  border-color: var(--grid, #6d6d75);
  box-shadow: var(--shadow-1);
}

.badge {
  background: rgba(255, 200, 60, 0.22);
  box-shadow: inset 0 0 0 1px rgba(255, 200, 60, 0.3);
}

.chip {
  box-shadow: inset 0 0 0 1px rgba(29, 185, 84, 0.2);
}

.btn-accent {
  transition: transform var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1)), box-shadow var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1)), background var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1));
  box-shadow: 0 6px 16px rgba(56, 101, 248, 0.28);
}

.btn-accent:hover:not(:disabled) {
  box-shadow: 0 8px 22px rgba(56, 101, 248, 0.4);
}

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

.btn-secondary {
  transition: color var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1)), background var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1)), transform var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1));
}

.btn-secondary:hover {
  background: var(--surface-3, #22222a);
}

.btn-secondary:active {
  transform: scale(0.97);
}

.form-input {
  transition: box-shadow var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1)), background var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1));
}

.modal {
  box-shadow: var(--shadow-3);
  animation: modal-in var(--dur, 0.2s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1));
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* --- Micro-interações: ícones e toques consistentes --- */

.icon-btn {
  transition: background var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1)), color var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1)), transform var(--dur-fast, 0.15s) var(--ease, cubic-bezier(0.4, 0, 0.2, 1));
}

.icon-btn:active {
  transform: scale(0.92);
}

/* --- Empty states: card tracejado sutil --- */

.empty-state {
  border: 1.5px dashed var(--outline, #6d6d75);
  border-radius: var(--radius-lg, 14px);
  background: var(--wash-soft, rgba(255, 255, 255, 0.04));
  margin: 8px 0;
}

/* ================= Reduced motion (T4 — must stay LAST) ================= */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}


@media (max-width: 768px) {
  .player-buttons { gap: 4px; }
}

/* Play Music: streaming layout */
:root {
  --bg: #000; --surface: #121212; --surface2: #181818;
  --surface-1: #121212; --surface-2: #121212; --surface-3: #242424;
  --surface-4: #2a2a2a; --surface-5: #181818;
  --text: #fff; --on-surface: #fff; --subtext: #b3b3b3;
  --on-surface-sub: #b3b3b3; --faint: #b3b3b3; --on-surface-faint: #b3b3b3;
  --accent: #1ed760; --accent-hover: #3be477; --accent-fill: #1ed760;
  --on-accent: #000; --focus: #fff; --hover: #292929;
  --outline: #727272; --grid: #555; --topbar-glass: rgba(18,18,18,.96);
}
[data-theme="light"] {
  --accent: #117d38; --accent-fill: #117d38; --on-accent: #fff;
  --focus: #117d38; --topbar-glass: rgba(255,255,255,.96);
}
.app-shell { background: var(--bg); }
.app-body { gap: 8px; padding: 8px 8px 0; min-height: 0; }
.sidebar { width: 280px; border: 0; border-radius: 8px; background: var(--surface); overflow: hidden; }
.sidebar-header { padding: 20px 24px 12px; }
.sidebar-brand { font-size: 19px; font-weight: 800; }
.sidebar-brand svg { color: var(--accent); background: transparent; }
.sidebar-nav { padding: 4px 12px; }
.nav-link { min-height: 42px; font-size: 15px; font-weight: 700; }
.nav-link.active { background: var(--surface-3); }
.nav-link.active::before { display: none; }
.sidebar-playlists-label { margin: 22px 24px 8px; color: var(--subtext); letter-spacing: 0; text-transform: none; font-size: 15px; }
.playlist-link { min-height: 40px; padding: 10px 12px; }
.sidebar-footer { border-color: var(--border-soft); }
.main-area { min-width: 0; border-radius: 8px; background: linear-gradient(180deg, #252525 0, var(--surface) 340px); }
[data-theme="light"] .main-area { background: linear-gradient(180deg, #e7e7e7, var(--surface) 340px); }
.page-padding { padding: 32px 28px 0; }
.page-title { font-size: clamp(28px, 3vw, 42px); letter-spacing: -.035em; font-weight: 800; }
.section { padding: 18px 28px; }
.page-padding > .section { padding-left: 0; padding-right: 0; }
.section-title { margin-bottom: 16px; font-size: 23px; letter-spacing: -.025em; font-weight: 800; }
.card-row { gap: 8px; }
.card { width: 180px; padding: 12px; border: 0; border-radius: 8px; background: transparent; box-shadow: none; text-align: left; }
.card:hover, .card:focus-within { background: var(--surface-3); transform: none; border: 0; box-shadow: none; }
.card-image-wrap { border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.35); }
.card-title { margin-top: 12px; font-size: 15px; font-weight: 700; }
.card-subtitle { font-size: 13px; }
.card-play { width: 46px; height: 46px; background: #1ed760; color: #000; }
.genre-card { width: 180px; height: 120px; border: 0; box-shadow: none; background: linear-gradient(135deg, #235c43, #163d32); font-size: 17px; }
.genre-card:hover { transform: none; filter: brightness(1.15); }
.track-list { background: transparent; }
.track-row { min-width: 0; }
.search-input { min-height: 48px; box-shadow: none; background: var(--surface-3); }
.tabs { overflow-x: auto; }
.tab-btn { flex-shrink: 0; background: var(--surface-3); color: var(--text); }
.tab-btn.active { background: var(--text); color: var(--bg); }
.bottom-bar { background: var(--bg); border: 0; box-shadow: none; }
.progress-fill { background: #fff; }
.progress-track:hover .progress-fill, .progress-track.dragging .progress-fill { background: #1ed760; }
.player-btn-main, .fullscreen-btn-main { background: #fff; color: #000; }
.fullscreen-player { background: linear-gradient(180deg, #385448, #121212 75%); }
.login-screen { background: linear-gradient(180deg, #292929, #000); }
.login-form { background: var(--surface); border-radius: 8px; }
.login-brand svg { background: #1ed760; color: #000; box-shadow: none; }
.login-submit, .login-toggle-btn.active, .btn-accent, .pwa-btn-primary { background: var(--accent-fill); color: var(--on-accent); box-shadow: none; }
.login-submit:hover:not(:disabled), .btn-accent:hover:not(:disabled) { box-shadow: none; filter: brightness(1.08); }
.admin-row, .settings-card, .modal { background: var(--surface-3); border-radius: 8px; }
.empty-state { border: 0; background: var(--surface-3); border-radius: 8px; }
.mobile-nav { display: none; }
@media (max-width: 767px) {
  .app-body { padding: 0; gap: 0; }
  .main-area { border-radius: 0; }
  .page { padding-bottom: 28px; }
  .page-padding { padding: 24px 16px 0; }
  .section { padding: 14px 16px; }
  .section-title { font-size: 21px; }
  .card { width: 150px; padding: 8px; }
  .genre-card { width: 150px; height: 100px; }
  .mobile-topbar { padding-left: 12px; }
  .mobile-nav { display: flex; flex-shrink: 0; justify-content: space-around; background: var(--bg); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
  .mobile-nav-item { display: flex; flex: 1; min-width: 0; min-height: 52px; align-items: center; justify-content: center; flex-direction: column; gap: 2px; color: var(--subtext); font-size: 11px; font-weight: 700; }
  .mobile-nav-item.active { color: var(--text); }
  .mobile-nav-item svg { width: 22px; height: 22px; }
  .bottom-bar { margin: 0 8px 4px; padding: 6px 8px; border-radius: 8px; background: var(--surface-3); }
  .now-playing-art { width: 42px; height: 42px; }
  .player-buttons { gap: 6px; }
  .mobile-sidebar { display: flex; flex-direction: column; max-width: 85vw; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
[data-theme="light"] .login-screen { background: linear-gradient(180deg, #e2e2e2, #f5f5f7); }
[data-theme="light"] .fullscreen-player { background: linear-gradient(180deg, #c8ded1, #f5f5f7 75%); }
.genre-card { color: #fff; }
[data-theme="light"] .progress-fill { background: #117d38; }
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  .app-body { padding: 0; }
  .sidebar { display: none; }
  .main-area { border-radius: 0; }
  .mobile-topbar { display: flex; }
  .mobile-nav { display: flex; flex-shrink: 0; justify-content: space-around; background: var(--bg); padding: 2px 4px env(safe-area-inset-bottom); }
  .mobile-nav-item { display: flex; flex: 1; min-height: 42px; align-items: center; justify-content: center; gap: 6px; color: var(--subtext); font-size: 11px; font-weight: 700; }
  .mobile-nav-item.active { color: var(--text); }
  .mobile-nav-item svg { width: 20px; height: 20px; }
  .bottom-bar { height: 68px; }
  .now-playing-art { width: 44px; height: 44px; }
  .page { padding-bottom: 16px; }
}
@media (orientation: landscape) and (max-height: 500px) and (max-width: 767px) and (pointer: coarse) {
  .bottom-bar { grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 8px; }
  .player-controls { min-width: 0; }
  .player-buttons { gap: 2px; }
  .player-progress { width: 100%; }
}
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  .bottom-bar { height: 80px; }
}
/* Installation and required notification activation */
.mobile-topbar { display: flex; }
.mobile-topbar .install-app-btn { margin-left: auto; }
.topbar-menu { display: none; }
.install-app-btn { border: 1px solid var(--accent); border-radius: 999px; background: transparent; color: var(--text); padding: 8px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.notification-gate { min-height: 100dvh; background: var(--bg); color: var(--text); }
.notification-gate-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px; }
.notification-gate-content { max-width: 540px; margin: 8vh auto; padding: 20px; }
.notification-gate-content .settings-card { margin: 20px 0; }
@media (max-width: 768px) { .topbar-menu { display: inline-flex; } .install-app-btn { font-size: 12px; padding: 7px 9px; } }
/* Notification activation: mobile-first single-action card. */
.notification-gate { min-height: 100dvh; display: flex; flex-direction: column; color: var(--text); background: radial-gradient(ellipse at 50% 8%, rgba(30,215,96,.13), transparent 48%), var(--bg); }
.notification-gate-brand { display: flex; align-items: center; gap: 10px; padding: max(20px, env(safe-area-inset-top)) 22px 12px; font-size: 16px; letter-spacing: -.02em; }
.notification-gate-brand svg { color: var(--accent); }
.notification-gate-content { box-sizing: border-box; width: calc(100% - 32px); max-width: 440px; margin: auto; padding: 32px 24px; text-align: center; background: var(--surface, #121212); border: 1px solid rgba(255,255,255,.09); border-radius: 24px; box-shadow: 0 24px 70px rgba(0,0,0,.28); }
.notification-gate-icon { display: inline-flex; align-items: center; justify-content: center; width: 68px; height: 68px; border-radius: 22px; color: var(--accent); background: rgba(30,215,96,.13); }
.notification-gate-icon svg { width: 33px; height: 33px; }
.notification-gate-eyebrow { margin: 24px 0 10px; color: var(--accent); font-size: 11px; font-weight: 700; letter-spacing: .14em; }
.notification-gate-content h1 { margin: 0; font-size: clamp(24px,6vw,30px); line-height: 1.15; letter-spacing: -.035em; }
.notification-gate-description { margin: 14px auto 24px; max-width: 330px; color: var(--muted, #aaa); font-size: 15px; line-height: 1.55; }
.notification-gate-action .btn-accent { width: 100%; min-height: 50px; border-radius: 999px; font-size: 15px; font-weight: 700; }
.notification-gate-action .btn-accent:focus-visible { outline: 3px solid var(--text); outline-offset: 3px; }
.notification-gate-action .btn-accent:disabled { opacity: .55; }
.notification-gate-status { margin: 12px 0 0; color: var(--muted, #aaa); font-size: 13px; line-height: 1.45; }
.notification-gate-status:empty { display: none; }
.notification-gate::after { content: ''; min-height: 56px; }
@media (min-width: 768px) { .notification-gate-brand { padding: 28px 36px; } .notification-gate-content { padding: 42px 38px; } }
.ad-overlay { position: fixed; inset: 0; z-index: 10000; background: #111; color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; text-align: center; }
.ad-overlay h2, .ad-overlay p { margin: 0; }
.ad-overlay a { color: #72e6a1; }
.ad-media { width: min(100%, 800px); max-height: 65vh; display: flex; align-items: center; justify-content: center; }
.ad-media img, .ad-media video { display: block; max-width: 100%; max-height: 65vh; object-fit: contain; }

.download-history-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; border-bottom: 1px solid var(--border, #333); }
.download-history-row > div { min-width: 0; }

.download-button { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; padding: 6px; color: var(--subtext); background: transparent; border: 0; cursor: pointer; }
.download-button:hover, .download-button:focus-visible { color: var(--accent); }
.download-button:disabled { opacity: .5; cursor: wait; }

/* OpenSpot-inspired player refinements */
.now-playing {
  min-width: 0;
}

.now-playing-open {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 12px;
  min-width: 0;
  border: 0;
  border-radius: 10px;
  padding: 4px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

@media (hover: hover) {
  .now-playing-open:hover {
    background: var(--hover);
  }
}

.now-playing-open:focus-visible {
  outline: 2px solid var(--accent-2-fill, #1db954);
  outline-offset: 2px;
}

.fullscreen-player {
  background: radial-gradient(ellipse at 50% 0%, rgba(42, 108, 75, 0.55), transparent 58%),
    linear-gradient(180deg, var(--surface2), var(--bg) 80%);
}

.fullscreen-art {
  border-radius: 16px;
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.38);
}

.fullscreen-buttons .player-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
}

@media (max-width: 767px) {
  .bottom-bar {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    grid-template-areas: 'track actions' 'progress progress';
    gap: 0 8px;
    margin: 4px 8px;
    border: 1px solid var(--outline, rgba(109, 109, 117, 0.35));
    border-radius: 14px;
    padding: 6px 8px 2px;
    background: var(--surface-3, #22222a);
    box-shadow: 0 8px 26px rgba(0, 0, 0, 0.24);
  }

  .now-playing {
    grid-area: track;
    gap: 6px;
    padding: 0;
  }

  .now-playing-open {
    gap: 8px;
    padding: 0;
  }

  .now-playing-art {
    width: 44px;
    height: 44px;
    border-radius: 7px;
  }

  .now-playing-info {
    flex: 1;
    min-width: 0;
  }

  .now-playing-title {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
    overflow: hidden;
    font-size: 13px;
  }

  .now-playing-artist {
    font-size: 11px;
  }

  .now-playing .icon-btn {
    width: 38px;
    min-width: 38px;
    height: 40px;
  }

  .player-controls {
    display: contents;
    order: initial;
  }

  .player-buttons {
    grid-area: actions;
    justify-content: flex-end;
    gap: 2px;
  }

  .player-buttons > .player-btn:not(.player-btn-main):not(:nth-child(6)) {
    display: none;
  }

  .player-buttons > .player-btn:nth-child(6) {
    display: inline-flex;
    width: 42px;
    min-width: 42px;
    height: 42px;
    align-items: center;
    justify-content: center;
  }

  .player-btn-main {
    width: 42px;
    min-width: 42px;
    height: 42px;
  }

  .player-progress {
    grid-area: progress;
    width: 100%;
    max-width: none;
    gap: 0;
  }

  .bottom-bar .progress-time {
    display: none;
  }

  .bottom-bar .progress-track {
    height: 16px;
  }

  .bottom-bar .progress-fill {
    height: 3px;
    background: var(--accent-2-fill, #1db954);
  }

  .bottom-bar .progress-fill::after {
    width: 8px;
    height: 8px;
    background: var(--accent-2-fill, #1db954);
    opacity: 1;
  }

  .fullscreen-player {
    padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
  }

  .fullscreen-top .icon-btn {
    width: 44px;
    min-width: 44px;
    height: 44px;
  }

  .fullscreen-content {
    gap: clamp(12px, 2.6vh, 22px);
    padding-bottom: 8px;
  }

  .fullscreen-art {
    width: min(82vw, 384px, 40vh);
    max-height: 40vh;
    border-radius: 14px;
  }

  .fullscreen-track-info {
    width: min(100%, 420px);
  }

  .fullscreen-title {
    font-size: clamp(20px, 5.8vw, 25px);
  }

  .fullscreen-buttons {
    width: min(100%, 420px);
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 2px;
  }

  .fullscreen-buttons .player-btn {
    width: 44px;
    min-width: 44px;
    height: 44px;
  }

  .fullscreen-buttons .fullscreen-btn-main {
    width: 60px;
    min-width: 60px;
    height: 60px;
  }

  .fullscreen-player .progress-track {
    height: 24px;
  }
}

@media (max-width: 767px) and (max-height: 650px) and (orientation: portrait) {
  .fullscreen-player {
    padding-top: 6px;
  }

  .fullscreen-content {
    gap: 8px;
    padding-bottom: 0;
  }

  .fullscreen-art {
    width: min(68vw, 300px, 30vh);
    max-height: 30vh;
  }

  .fullscreen-title {
    font-size: 19px;
  }
}

@media (max-width: 900px) and (max-height: 520px) and (orientation: landscape) and (pointer: coarse) {
  .fullscreen-player {
    padding: 6px 16px calc(8px + env(safe-area-inset-bottom));
  }

  .fullscreen-content {
    display: grid;
    grid-template-columns: min(38vh, 220px) minmax(0, 1fr);
    grid-template-rows: auto auto auto;
    gap: 8px 20px;
    padding: 0 0 4px;
  }

  .fullscreen-art {
    grid-column: 1;
    grid-row: 1 / 4;
    width: min(38vh, 220px);
    max-height: 100%;
    align-self: center;
  }

  .fullscreen-track-info {
    grid-column: 2;
    grid-row: 1;
    width: 100%;
  }

  .fullscreen-content > .player-progress {
    grid-column: 2;
    grid-row: 2;
    width: 100%;
  }

  .fullscreen-buttons {
    grid-column: 2;
    grid-row: 3;
    width: 100%;
    max-width: none;
    flex-wrap: nowrap;
    justify-content: space-between;
    gap: 2px;
  }

  .fullscreen-buttons .player-btn {
    width: 40px;
    min-width: 40px;
    height: 40px;
  }

  .fullscreen-buttons .fullscreen-btn-main {
    width: 54px;
    min-width: 54px;
    height: 54px;
  }
}

/* Album browsing and track selection, tuned for narrow phone screens. */
.album-artist-link {
  margin-top: 10px;
  color: var(--subtext);
  font-size: 14px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.album-save.liked {
  color: var(--accent);
}

.album-save:disabled {
  cursor: wait;
  opacity: 0.7;
}

.liked-section-title {
  margin: 20px 0 12px;
}

.album-tracks-title {
  margin: 0 0 12px;
}

.app-toast {
  position: fixed;
  z-index: 300;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  max-width: min(90vw, 420px);
  padding: 12px 18px;
  border: 1px solid var(--outline);
  border-radius: 999px;
  background: var(--surface-5);
  color: var(--text);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.app-toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 639px) {
  .album-detail-header.horizontal {
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 24px 16px;
  }

  .album-detail-header .detail-art {
    width: min(72vw, 260px);
    height: auto;
    aspect-ratio: 1;
  }

  .album-detail-header .detail-info {
    width: 100%;
    text-align: center;
  }

  .album-detail-header .detail-title {
    font-size: clamp(28px, 8vw, 38px);
  }

  .album-detail-header .detail-actions {
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
  }

  .album-detail-header .btn-accent,
  .album-detail-header .btn-secondary {
    min-height: 44px;
    padding-inline: 18px;
  }

  .album-track-list .track-row {
    grid-template-columns: 2rem minmax(0, 1fr) auto;
    gap: 8px;
    padding: 8px 4px;
  }

  .album-track-list .track-actions {
    gap: 6px;
  }

  .album-track-list .track-actions .track-like,
  .album-track-list .track-actions .track-queue {
    width: 32px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .album-track-list .track-duration {
    width: 34px;
  }

  .album-detail-content {
    padding: 0 12px;
  }

  .app-toast {
    bottom: calc(112px + env(safe-area-inset-bottom));
  }
}
