/* ============================================================
   Universal Music — Premium UI · IURD Brand
   Paleta: Rojo #CC1016 · Azul marino #1B3A6B · Blanco
   ============================================================ */

:root {
  /* Brand IURD Universal */
  --brand-red:   #CC1016;
  --brand-navy:  #1B3A6B;
  --brand-red-2: #e8191f;

  --accent:     #CC1016;
  --accent-2:   #1B3A6B;
  --accent-grd: linear-gradient(135deg, #CC1016, #1B3A6B);
  --accent-grd-h: linear-gradient(135deg, #e8191f, #254d8f);

  --radius:    16px;
  --radius-sm: 10px;
  --radius-xs: 7px;
  --player-h:  82px;
  --tabbar-h:  64px;
  --sidebar-w: 252px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", system-ui, sans-serif;
}

/* ---- Dark theme ---- */
[data-theme="dark"] {
  --bg:            #0e0e18;
  --bg-elev:       #15151f;
  --bg-card:       rgba(255,255,255,0.05);
  --bg-card-hover: rgba(255,255,255,0.085);
  --bg-input:      rgba(255,255,255,0.065);
  --border:        rgba(255,255,255,0.09);
  --border-focus:  rgba(204,16,22,0.7);
  --text:          #f0f1f8;
  --text-dim:      #8a94a8;
  --text-faint:    #505a70;
  --fg-dim:        #505a70;
  --shadow:        0 16px 48px rgba(0,0,0,0.75);
  --shadow-sm:     0 4px 16px rgba(0,0,0,0.45);
  --glow:          0 0 28px rgba(204,16,22,0.2);
  --sidebar-bg:    #0b0b16;
  --sidebar-grd:   linear-gradient(180deg, #0f0f1c 0%, #0b0b16 100%);
  --active-bg:     linear-gradient(135deg, rgba(204,16,22,.14), rgba(27,58,107,.12));
  --active-border: rgba(204,16,22,.28);
  --player-bg:     rgba(18,18,28,0.95);
}

/* ---- Light theme ---- */
[data-theme="light"] {
  --bg:            #f0f2f7;
  --bg-elev:       #ffffff;
  --bg-card:       #ffffff;
  --bg-card-hover: #eaecf3;
  --bg-input:      #f4f5fa;
  --border:        rgba(0,0,0,0.08);
  --border-focus:  rgba(204,16,22,0.55);
  --text:          #0d1018;
  --text-dim:      #576070;
  --text-faint:    #9aa2b4;
  --fg-dim:        #9aa2b4;
  --shadow:        0 12px 40px rgba(10,15,40,0.14);
  --shadow-sm:     0 3px 12px rgba(10,15,40,0.09);
  --glow:          0 0 20px rgba(204,16,22,0.1);
  --sidebar-bg:    #ffffff;
  --sidebar-grd:   linear-gradient(180deg, #ffffff 0%, #f8f9fc 100%);
  --active-bg:     linear-gradient(135deg, rgba(204,16,22,.08), rgba(27,58,107,.06));
  --active-border: rgba(204,16,22,.2);
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; border: none; }
a { text-decoration: none; color: inherit; }
img { display: block; max-width: 100%; }
input[type="range"] { -webkit-appearance: none; appearance: none; background: transparent; }
.hidden { display: none !important; }

/* ============================================================
   LAYOUT
   ============================================================ */
#app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh; height: 100dvh;
}

/* ---------- Sidebar ---------- */
#sidebar {
  background: var(--sidebar-bg);
  background: var(--sidebar-grd);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 20px 12px; gap: 6px;
  position: relative; z-index: 10;
}

/* ---- Brand / Logo ---- */
.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 10px 22px;
}
.brand-logo {
  width: 48px; height: 48px; flex-shrink: 0;
  filter: drop-shadow(0 4px 12px rgba(204,16,22,0.5));
}
.brand-text {
  display: flex; flex-direction: column; gap: 0;
}
.brand-text strong {
  font-size: 15px; font-weight: 900; letter-spacing: .4px;
  display: block; line-height: 1.1;
  background: var(--accent-grd);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.brand-text .brand-tagline {
  font-size: 9.5px; color: var(--text-faint); letter-spacing: .3px;
  margin-top: 2px; font-style: italic;
}

/* ---- Nav ---- */
#nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 14px; border-radius: 12px;
  color: var(--text-dim); font-size: 14.5px; font-weight: 500;
  transition: background .14s, color .14s;
}
.nav-item .ni-ico { font-size: 18px; width: 22px; text-align: center; flex-shrink: 0; }
.nav-item:hover { background: var(--bg-card-hover); color: var(--text); }
.nav-item.active {
  background: var(--active-bg);
  color: var(--brand-red);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--active-border);
}

.sidebar-foot { margin-top: auto; padding-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.ghost-btn {
  width: 100%; padding: 10px 14px; border-radius: 12px;
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-dim); font-size: 13.5px; text-align: left;
  transition: background .14s, color .14s;
}
.ghost-btn:hover { background: var(--bg-card-hover); color: var(--text); }

/* ---------- Main view ---------- */
#view {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 30px 36px calc(var(--player-h) + 48px);
  outline: none; scroll-behavior: smooth;
}

/* ============================================================
   COMPONENTS
   ============================================================ */
.page-head { margin-bottom: 28px; }
.page-head h1 { font-size: 32px; font-weight: 800; letter-spacing: -0.025em; }
.page-head p { color: var(--text-dim); margin-top: 5px; font-size: 15px; }

.section-label {
  font-size: 11.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .1em; color: var(--accent); margin: 28px 0 14px;
}

/* Grids */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(182px, 1fr));
  gap: 16px;
}

/* Category card */
.cat-card {
  position: relative; border-radius: var(--radius);
  overflow: hidden; aspect-ratio: 1 / 1;
  background: var(--bg-card); border: 1px solid var(--border);
  cursor: pointer; transition: transform .2s cubic-bezier(.4,0,.2,1), box-shadow .2s;
  display: flex; flex-direction: column; justify-content: flex-end;
}
.cat-card:hover { transform: translateY(-4px) scale(1.01); box-shadow: var(--shadow); }
.cat-card:active { transform: translateY(-1px) scale(1); }
.cat-card .cc-bg {
  position: absolute; inset: 0; background-size: cover; background-position: center;
  transition: transform .3s;
}
.cat-card:hover .cc-bg { transform: scale(1.04); }
.cat-card .cc-grad {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 25%, rgba(0,0,0,.82) 100%);
}
.cat-card.no-img .cc-bg { opacity: 1; }
.cat-card .cc-emoji {
  position: absolute; top: 14px; left: 16px; font-size: 32px;
  filter: drop-shadow(0 3px 8px rgba(0,0,0,.5));
}
.cat-card .cc-body { position: relative; padding: 14px 16px; }
.cat-card .cc-title { font-size: 16.5px; font-weight: 700; color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,.5); }
.cat-card .cc-count { font-size: 12px; color: rgba(255,255,255,.72); margin-top: 2px; }
.cat-card.has-cover .cc-bg { opacity: 1; background-size: cover; }
.cc-chip {
  position: absolute; right: 9px; bottom: 9px; z-index: 2;
  background: rgba(0,0,0,.58); color: #fff;
  font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  backdrop-filter: blur(6px); border: 1px solid rgba(255,255,255,.12);
}

/* Sub-category pills */
.sub-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.sub-pill {
  padding: 7px 16px; border-radius: 999px;
  background: var(--bg-card); border: 1px solid var(--border);
  font-size: 13.5px; font-weight: 500; color: var(--text-dim);
  transition: background .13s, color .13s, border-color .13s;
}
.sub-pill.active { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: 0 3px 10px rgba(204,16,22,.35); }
.sub-pill:hover:not(.active) { background: var(--bg-card-hover); color: var(--text); }

/* ============================================================
   SONG LIST — lista vertical (sin grid)
   ============================================================ */
.song-list { display: flex; flex-direction: column; gap: 4px; }

.song-row {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px 9px 6px; border-radius: 12px;
  background: var(--bg-card); border: 1px solid transparent;
  cursor: pointer; transition: background .13s, border-color .13s, box-shadow .13s;
  position: relative;
}
.song-row:hover { background: var(--bg-card-hover); border-color: var(--border); }
.song-row:active { background: var(--bg-card-hover); transform: scale(.995); }
.song-row.playing {
  border-color: rgba(204,16,22,.4);
  background: linear-gradient(90deg, rgba(204,16,22,.1), rgba(27,58,107,.05));
  box-shadow: var(--glow);
}

/* Drag handle */
.drag-handle {
  color: var(--text-faint); font-size: 16px;
  padding: 0 4px; cursor: grab; flex-shrink: 0;
  opacity: 0; transition: opacity .15s;
  user-select: none;
}
.song-row:hover .drag-handle { opacity: 1; }
.song-row.dragging { opacity: .45; box-shadow: var(--shadow); transform: scale(1.01); }
.song-row.drag-over {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(204,16,22,.35);
}
.song-row.drag-over::before {
  content: ''; position: absolute; top: -3px; left: 12px; right: 12px;
  height: 2px; background: var(--accent); border-radius: 2px;
}

/* Song cover / art */
.song-cover {
  width: 52px; height: 52px; border-radius: 10px; flex-shrink: 0;
  background: var(--accent-grd);
  background-size: cover; background-position: center;
}
.song-cover.no-art {
  display: grid; place-items: center; font-size: 22px;
}

/* Song info */
.song-info { flex: 1; min-width: 0; }
.s-title {
  font-size: 15px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 4px;
}
.s-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.s-cat { font-size: 12px; color: var(--text-dim); }

/* Tag chip — pequeño, coloreado */
.tag-chip {
  display: inline-block; font-size: 10.5px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px; color: #fff;
  letter-spacing: .02em; white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0,0,0,.3);
}
.tag-chip-dim {
  background: var(--bg-card-hover) !important;
  color: var(--text-faint) !important;
  text-shadow: none;
}

/* Badges */
.badge-warn { font-size: 11px; color: #f59e0b; background: rgba(245,158,11,.12); padding: 2px 7px; border-radius: 999px; }
.badge-lyric { font-size: 13px; }

/* Song actions */
.song-actions { display: flex; gap: 2px; flex-shrink: 0; align-items: center; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 8px;
  background: transparent; color: var(--text-dim); font-size: 15px;
  display: grid; place-items: center;
  transition: background .13s, color .13s;
}
.icon-btn:hover { background: var(--bg-card-hover); color: var(--text); }
.icon-btn.on { color: #f59e0b; }
/* Cola (reproducir a continuación) */
.act-queue { font-size: 17px; font-weight: 700; color: var(--brand-red); opacity: .55; }
.act-queue:hover { opacity: 1; background: color-mix(in srgb, var(--brand-red) 12%, transparent); color: var(--brand-red); }
/* Botón reproducir — destaca */
.act-play { color: var(--brand-red); opacity: .7; }
.act-play:hover { opacity: 1; background: color-mix(in srgb, var(--brand-red) 12%, transparent); }

/* ============================================================
   SEARCH BOX
   ============================================================ */
/* ---- Playlists home header ---- */
.pl-home-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 20px; flex-wrap: wrap;
}
.pl-home-title { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; }
.pl-home-sub { color: var(--text-dim); margin-top: 4px; font-size: 14px; }
.pl-home-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; padding-top: 6px; }

.pl-view-toggle {
  padding: 8px 16px; border-radius: 999px;
  font-size: 13px; font-weight: 600;
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-dim);
  transition: background .13s, color .13s;
  cursor: pointer;
}
.pl-view-toggle:hover { background: var(--bg-card-hover); color: var(--text); }

/* ---- List view rows ---- */
.pl-list { display: flex; flex-direction: column; gap: 4px; }
.pl-list-row {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 14px; border-radius: 14px;
  background: var(--bg-card); border: 1px solid var(--border);
  cursor: pointer;
  transition: background .13s, transform .13s;
}
.pl-list-row:hover { background: var(--bg-card-hover); transform: translateX(3px); }
.plr-thumb {
  width: 52px; height: 52px; border-radius: 12px; flex-shrink: 0;
  background-size: cover; background-position: center;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
}
.plr-info { flex: 1; min-width: 0; }
.plr-name { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plr-meta { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.plr-tags { color: var(--text-faint); }
.plr-chevron { font-size: 20px; color: var(--text-faint); flex-shrink: 0; }

.search-box {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 14px; padding: 13px 18px; margin-bottom: 22px;
  transition: border-color .15s, box-shadow .15s;
}
.search-box:focus-within { border-color: var(--border-focus); box-shadow: var(--glow); }
.search-box input {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--text); font-size: 16px; font-family: inherit;
}
.search-box input::placeholder { color: var(--text-faint); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--radius-sm);
  background: var(--accent-grd); color: #fff;
  font-size: 14.5px; font-weight: 600;
  transition: opacity .13s, transform .13s, box-shadow .13s;
  box-shadow: 0 4px 14px rgba(204,16,22,.35);
}
.btn:hover { opacity: .9; transform: translateY(-1px); box-shadow: 0 6px 20px rgba(204,16,22,.45); }
.btn:active { transform: translateY(0); }
.btn.secondary {
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text); box-shadow: none;
}
.btn.secondary:hover { background: var(--bg-card-hover); box-shadow: var(--shadow-sm); }
.btn.danger { background: linear-gradient(135deg,#dc2626,#b91c1c); box-shadow: 0 4px 14px rgba(220,38,38,.35); }
.btn.small { padding: 7px 14px; font-size: 13px; }

/* Empty state */
.empty { text-align: center; padding: 64px 20px; color: var(--text-faint); }
.empty .e-ico { font-size: 52px; margin-bottom: 14px; }
.empty h3 { font-size: 19px; color: var(--text-dim); margin-bottom: 6px; }

/* Breadcrumb */
/* ---- Playlist dock (acceso rápido horizontal) ---- */
.pl-dock {
  position: sticky; top: -30px; z-index: 20;
  margin: -30px -36px 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 10px 0 10px;
}
.pl-dock-scroll {
  display: flex; gap: 8px; align-items: flex-start;
  overflow-x: auto; scroll-snap-type: x mandatory;
  padding: 0 20px;
  -ms-overflow-style: none; scrollbar-width: none;
}
.pl-dock-scroll::-webkit-scrollbar { display: none; }
.pld-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  flex-shrink: 0; scroll-snap-align: start;
  background: none; border: none; cursor: pointer;
  padding: 2px 4px; border-radius: 10px;
  transition: opacity .15s, transform .15s;
  min-width: 58px; max-width: 72px;
}
.pld-item:hover { opacity: .85; transform: translateY(-2px); }
.pld-item.active .pld-thumb {
  box-shadow: 0 0 0 2.5px var(--brand-red), 0 4px 14px rgba(204,16,22,.4);
}
.pld-thumb {
  width: 48px; height: 48px; border-radius: 12px;
  background-size: cover; background-position: center;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
  transition: box-shadow .15s;
}
.pld-name {
  font-size: 10px; font-weight: 600; color: var(--text-dim);
  text-align: center; line-height: 1.2;
  max-width: 64px; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.pld-item.active .pld-name { color: var(--brand-red); }

.crumb { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-dim); margin-bottom: 16px; flex-wrap: wrap; }
.crumb a:hover { color: var(--accent); }
.crumb .sep { color: var(--text-faint); }

/* ============================================================
   ADMIN
   ============================================================ */
.admin-tabs { display: flex; gap: 8px; margin-bottom: 24px; flex-wrap: wrap; }
.admin-tab {
  padding: 9px 18px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text-dim); font-size: 14px; font-weight: 500;
  transition: background .13s, color .13s;
}
.admin-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: 0 3px 10px rgba(204,16,22,.35); }

.list-item {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--bg-card); border: 1px solid var(--border); margin-bottom: 8px;
  transition: background .13s;
}
.list-item:hover { background: var(--bg-card-hover); }
.list-item .li-handle { cursor: grab; color: var(--text-faint); font-size: 18px; }
.list-item.dragging { opacity: .5; }
.list-item .li-swatch { width: 18px; height: 18px; border-radius: 5px; flex-shrink: 0; }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-main strong { font-size: 15px; }
.list-item .li-main small { display: block; color: var(--text-dim); font-size: 12px; }

/* ============================================================
   MODAL — premium
   ============================================================ */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.65);
  backdrop-filter: blur(10px); display: grid; place-items: center;
  z-index: 200; padding: 20px;
}
.modal {
  width: 100%; max-width: 540px; max-height: 90vh; overflow-y: auto;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 22px; padding: 0; box-shadow: var(--shadow);
  animation: modal-in .18s cubic-bezier(.4,0,.2,1);
}
@keyframes modal-in {
  from { opacity: 0; transform: scale(.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 0;
}
.modal-header h2 { font-size: 20px; font-weight: 700; }
.modal-close {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--bg-card); color: var(--text-dim); font-size: 14px;
  display: grid; place-items: center; border: 1px solid var(--border);
  transition: background .13s, color .13s;
}
.modal-close:hover { background: var(--bg-card-hover); color: var(--text); }

.field { padding: 0 24px; margin-bottom: 16px; }
.field:first-of-type { margin-top: 16px; }
.field label {
  display: block; font-size: 12.5px; font-weight: 600;
  color: var(--text-dim); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .04em;
}
.hint-inline { font-size: 11px; font-weight: 400; color: var(--text-faint); text-transform: none; letter-spacing: 0; }
.field input[type="text"],
.field input[type="number"],
.field select,
.field textarea {
  width: 100%; padding: 11px 14px; border-radius: 10px;
  background: var(--bg-input); border: 1px solid var(--border);
  color: var(--text); font-size: 15px; font-family: inherit; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--border-focus); box-shadow: var(--glow);
}
.field textarea { min-height: 160px; resize: vertical; line-height: 1.65; }
.field .hint { font-size: 12px; color: var(--text-faint); margin-top: 5px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; padding: 16px 24px 24px; }

/* Edit song modal specifics */
.edit-modal {}
.es-thumb-row {
  display: flex; align-items: center; gap: 16px;
  padding: 20px 24px 16px; border-bottom: 1px solid var(--border);
}
.es-thumb-preview {
  width: 88px; height: 88px; border-radius: 14px; flex-shrink: 0;
  background: var(--accent-grd);
  background-size: cover; background-position: center;
  display: grid; place-items: center; font-size: 36px;
  border: 2px solid var(--border); transition: border-color .15s;
  cursor: pointer;
}
.es-thumb-preview.drag-over { border-color: var(--accent); box-shadow: var(--glow); }
.es-thumb-btns { display: flex; flex-direction: column; gap: 8px; }
.es-thumb-btns .hint { font-size: 12px; color: var(--text-faint); }

/* Tag input with suggestions */
.tag-input-wrap { position: relative; }
.tag-suggestions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.tag-sug {
  font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px;
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text-dim);
  cursor: pointer; transition: background .12s, color .12s;
}
.tag-sug:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Info box */
.info-box {
  display: flex; align-items: flex-start; gap: 10px;
  background: rgba(245,158,11,.08); border: 1px solid rgba(245,158,11,.25);
  border-radius: 10px; padding: 12px 14px; font-size: 13px; color: var(--text-dim);
  margin-bottom: 16px;
}

/* Form fields: emoji + color picker */
.emoji-pick, .color-pick { display: flex; gap: 8px; flex-wrap: wrap; }
.emoji-opt, .color-opt {
  width: 40px; height: 40px; border-radius: 10px; border: 2px solid transparent;
  display: grid; place-items: center; font-size: 20px; background: var(--bg-card);
  cursor: pointer; transition: border-color .13s, transform .13s;
}
.emoji-opt.sel { border-color: var(--accent); }
.color-opt.sel { border-color: var(--text); transform: scale(1.1); }
.file-drop {
  border: 2px dashed var(--border); border-radius: var(--radius-sm);
  padding: 22px; text-align: center; color: var(--text-dim); font-size: 14px;
  transition: border-color .15s;
}
.file-drop.has-file { border-color: var(--accent); color: var(--text); }

/* Toggle */
.switch { position: relative; width: 46px; height: 27px; flex-shrink: 0; }
.switch input { display: none; }
.switch .track {
  position: absolute; inset: 0; border-radius: 999px;
  background: var(--text-faint); transition: background .2s;
}
.switch .track::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 21px; height: 21px; border-radius: 50%; background: #fff;
  transition: transform .2s; box-shadow: 0 1px 4px rgba(0,0,0,.3);
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(19px); }

/* ============================================================
   PERSISTENT PLAYER — Premium redesign
   ============================================================ */
:root { --player-h: 96px; }

#player {
  position: fixed; left: var(--sidebar-w); right: 0; bottom: 0;
  height: var(--player-h);
  background: var(--player-bg, var(--bg-elev));
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 120;
  box-shadow: 0 -8px 32px rgba(0,0,0,.35);
  backdrop-filter: blur(28px) saturate(1.4);
  -webkit-backdrop-filter: blur(28px) saturate(1.4);
}

/* Top row: cover + meta + controls */
.player-inner {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 20px 4px; flex: 1;
}

.player-cover {
  width: 58px; height: 58px; border-radius: 11px; flex-shrink: 0;
  background: var(--accent-grd);
  background-size: cover; background-position: center;
  box-shadow: 0 4px 16px rgba(0,0,0,.45);
  transition: transform .2s;
}
.player-cover:hover { transform: scale(1.05); cursor: pointer; }

.player-meta { flex: 1; min-width: 0; }
.pl-title {
  font-size: 14.5px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pl-sub {
  font-size: 12px; color: var(--text-dim); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Bottom row: seek bar full-width */
.pl-seek-row {
  display: flex; align-items: center; gap: 10px;
  padding: 0 20px 8px;
}
.pl-seek-row span {
  font-size: 11px; color: var(--text-faint);
  width: 36px; text-align: center; flex-shrink: 0; font-variant-numeric: tabular-nums;
}
#pl-seek { flex: 1; cursor: pointer; }

/* Range inputs */
input[type="range"] { cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent) var(--pct,0%), var(--border) var(--pct,0%));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; margin-top: -5px; box-shadow: 0 1px 6px rgba(0,0,0,.5);
  cursor: pointer; transition: transform .12s;
}
input[type="range"]:hover::-webkit-slider-thumb { transform: scale(1.3); }
/* Larger hit target for seek bar */
#pl-seek::-webkit-slider-runnable-track { height: 5px; }
#pl-seek::-webkit-slider-thumb { width: 16px; height: 16px; margin-top: -5.5px; }

.vol { width: 82px; }
.vol::-webkit-slider-runnable-track { --pct: 100%; }

.player-controls { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.pc-btn {
  width: 42px; height: 42px; border-radius: 50%;
  background: transparent; color: var(--text); font-size: 17px;
  display: grid; place-items: center; transition: background .13s, transform .13s;
}
.pc-btn:hover { background: var(--bg-card-hover); }
.pc-btn.play {
  width: 46px; height: 46px; font-size: 18px;
  background: var(--accent); color: #fff;
  box-shadow: 0 4px 16px rgba(204,16,22,.45);
}
.pc-btn.play:hover { transform: scale(1.07); box-shadow: 0 6px 22px rgba(204,16,22,.6); }
.pc-btn.small { width: 36px; height: 36px; font-size: 15px; }

/* ============================================================
   LYRICS / KARAOKE
   ============================================================ */
#lyrics-screen {
  position: fixed; inset: 0; z-index: 180;
  background: #000; display: flex; flex-direction: column;
}
.ly-top {
  display: flex; align-items: center; gap: 14px;
  padding: calc(14px + env(safe-area-inset-top)) 18px 16px;
  background: linear-gradient(180deg,rgba(0,0,0,.85),rgba(0,0,0,.45) 70%,transparent);
  position: absolute; top: 0; left: 0; right: 0; z-index: 5;
}
.ly-top .ly-meta { flex: 1; min-width: 0; }
.ly-top .ly-meta strong { font-size: 17px; display: block; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ly-top .ly-meta span { font-size: 13px; color: rgba(255,255,255,.7); }
.ly-fit, .ly-close, .ly-mini {
  width: 46px; height: 46px; border-radius: 50%;
  background: rgba(255,255,255,.16); color: #fff; font-size: 19px; flex-shrink: 0;
  transition: background .15s, transform .12s;
}
.ly-mini { width: 42px; height: 42px; font-size: 15px; font-weight: 700; }
.ly-fit:hover, .ly-close:hover, .ly-mini:hover { background: rgba(255,255,255,.28); }
.ly-fit:active, .ly-close:active, .ly-mini:active { transform: scale(.9); }

.ly-body {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: #f5f5fa;
  padding: calc(78px + env(safe-area-inset-top)) 24px calc(188px + env(safe-area-inset-bottom));
}
[data-theme="dark"] .ly-body { background: #0e0e18; }
.ly-paper { max-width: 820px; margin: 0 auto; text-align: center; }
.ly-title {
  font-size: calc(clamp(26px,4.5vw,50px) * var(--ly-scale,1)); font-weight: 800; letter-spacing: -.01em;
  color: #12121c; font-family: "SF Pro Display", Georgia, serif;
}
[data-theme="dark"] .ly-title { color: #f0f0ff; }
.ly-rule {
  width: 200px; height: 3px; margin: 14px auto 32px;
  background: linear-gradient(90deg, transparent, var(--brand-red), transparent);
}
.ly-stanza { margin: 0 0 34px; }
.ly-line {
  font-size: calc(clamp(21px,3.2vw,38px) * var(--ly-scale,1));
  font-weight: 600; line-height: 1.5;
  color: #22222e; padding: 3px 0; transition: color .2s;
}
[data-theme="dark"] .ly-line { color: #dde0f0; }

/* Coro: cada línea marcada con * se pone en rojo */
.ly-line.chorus-line { color: #cc1016 !important; font-weight: 700; }
[data-theme="dark"] .ly-line.chorus-line { color: #ff5c5c !important; }

/* Marca de repetición (✕2 / Coro ✕2) — centrada, al final de la estrofa */
.ly-repeat {
  font-size: calc(clamp(16px,2vw,24px) * var(--ly-scale,1)); font-weight: 800;
  letter-spacing: .08em; text-transform: uppercase;
  color: #cc1016; opacity: .82; margin: 12px 0 4px;
}
[data-theme="dark"] .ly-repeat { color: #ff7a7a; }

.ly-stage {
  flex: 1; display: flex; align-items: center; justify-content: center;
  overflow: hidden; cursor: pointer; background: #000;
}
.ly-img { width: 100%; height: 100%; object-fit: contain; }
.ly-noimg { text-align: center; color: #fff; padding: 30px; }
.ly-noimg h2 { font-size: 28px; margin: 10px 0; }
.ly-noimg p { color: rgba(255,255,255,.6); }

/* ---- Barra inferior de la pantalla de letra (siempre visible) ---- */
.ly-bar {
  position: absolute; bottom: 0; left: 0; right: 0;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  background: linear-gradient(0deg, rgba(0,0,0,.94) 35%, rgba(0,0,0,.55) 75%, transparent);
  z-index: 5;
  padding: 46px 22px calc(20px + env(safe-area-inset-bottom));
}

/* Fila de progreso + tiempos */
.ly-seek-row {
  display: flex; align-items: center; gap: 12px;
  width: 100%; max-width: 760px; margin: 0 auto;
}
.ly-seek-row span {
  font-size: 12px; color: rgba(255,255,255,.72);
  width: 40px; text-align: center; flex-shrink: 0; font-variant-numeric: tabular-nums;
}
#ly-seek { flex: 1; cursor: pointer; --pct: 0%; }
#ly-seek::-webkit-slider-runnable-track {
  height: 6px; border-radius: 999px;
  background: linear-gradient(90deg, #cc1016 var(--pct,0%), rgba(255,255,255,.25) var(--pct,0%));
}
#ly-seek::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; margin-top: -7px; box-shadow: 0 1px 6px rgba(0,0,0,.6);
  transition: transform .12s;
}
#ly-seek:active::-webkit-slider-thumb { transform: scale(1.25); }

/* Controles ⏮ ▶ ⏭ */
.ly-bar-controls {
  display: flex; align-items: center; justify-content: center; gap: 30px;
}
.ly-bar button {
  width: 56px; height: 56px; border-radius: 50%;
  background: rgba(255,255,255,.14); color: #fff; font-size: 22px;
  border: 1px solid rgba(255,255,255,.16);
  transition: background .13s, transform .12s;
}
.ly-bar button.main {
  width: 74px; height: 74px;
  background: #cc1016; color: #fff; font-size: 28px;
  border: none; box-shadow: 0 6px 24px rgba(204,16,22,.55);
}
.ly-bar button:hover { background: rgba(255,255,255,.26); }
.ly-bar button:active { transform: scale(.9); }
.ly-bar button.main:active { transform: scale(.94); }

/* ============================================================
   TOAST
   ============================================================ */
#toast {
  position: fixed; bottom: calc(var(--player-h) + 22px); left: 50%;
  transform: translateX(-50%); z-index: 300;
  background: var(--text); color: var(--bg);
  padding: 11px 22px; border-radius: 999px; font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow); white-space: nowrap;
  animation: toast-in .18s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ============================================================
   TAB BAR (iPhone)
   ============================================================ */
#tabbar { display: none; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
  #app { grid-template-columns: 1fr; }
  #sidebar { display: none; }
  /* Respeta el notch arriba y la barra de tabs + home indicator abajo */
  #view { padding: calc(env(safe-area-inset-top) + 14px) 18px calc(var(--player-h) + var(--tabbar-h) + env(safe-area-inset-bottom) + 30px); }
  #player { left: 0; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
  #tabbar {
    position: fixed; left: 0; right: 0; bottom: 0;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    display: flex; background: var(--bg-elev); border-top: 1px solid var(--border);
    z-index: 130; padding-bottom: env(safe-area-inset-bottom);
  }
  #tabbar a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; font-size: 11px; color: var(--text-dim); font-weight: 500;
  }
  #tabbar a span { font-size: 21px; }
  #tabbar a.active { color: var(--accent); }

  /* Dock de playlists: en móvil NO es pegajoso (evita tapar el título y los
     botones). Fluye normal arriba; el padding del #view ya libra el notch. */
  .pl-dock {
    position: static; top: auto;
    margin: 0 -18px 18px;
    padding: 2px 0 12px;
    background: transparent;
  }

  /* El aviso flota por encima del reproductor y la barra de tabs */
  #toast { bottom: calc(var(--player-h) + var(--tabbar-h) + env(safe-area-inset-bottom) + 18px); }
}

@media (max-width: 560px) {
  .page-head h1 { font-size: 25px; }
  #view { padding: calc(env(safe-area-inset-top) + 12px) 14px calc(var(--player-h) + var(--tabbar-h) + env(safe-area-inset-bottom) + 24px); }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
  .pl-dock { margin-left: -14px; margin-right: -14px; }
  /* Reproductor: altura automática para que la barra de progreso y los tiempos SE VEAN */
  #player { height: auto; padding: 0; gap: 0; }
  .player-inner { padding: 9px 14px 3px; gap: 11px; }
  .player-cover { width: 48px; height: 48px; }
  .pl-seek-row { padding: 0 14px 9px; }
  .pl-progress { display: none; }
  .vol, #pl-full { display: none; }          /* ⏮ (pl-prev) AHORA SÍ se muestra */
  .player-controls { gap: 4px; }
  .pc-btn { width: 40px; height: 40px; }
  .modal { border-radius: 18px; }
  .es-thumb-row { flex-direction: column; align-items: flex-start; }
  /* Título en su línea; botones (descargar / añadir) en la línea de abajo */
  .cat-header { gap: 12px; }
  .cat-header .page-head { flex: 1 1 100%; }
  .cat-actions { flex: 1 1 100%; }
}

@media (min-width: 1280px) {
  #view { padding-left: 56px; padding-right: 56px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
}

/* ============================================================
   Cabecera de categoría con botón Añadir
   ============================================================ */
.cat-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.add-song-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: 12px;
  background: var(--accent-grd); color: #fff;
  font-size: 14px; font-weight: 700;
  box-shadow: 0 4px 16px rgba(204,16,22,.4);
  transition: transform .15s, box-shadow .15s, opacity .15s;
  white-space: nowrap; flex-shrink: 0;
}
.add-song-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(204,16,22,.5); }
.add-song-btn:active { transform: translateY(0); }
.add-song-btn span { font-size: 18px; font-weight: 400; }

/* ---- Descargar lista (offline) ---- */
.cat-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dl-controls { display: inline-flex; align-items: center; gap: 8px; }
.dl-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 15px; border-radius: 12px; cursor: pointer;
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text); font-size: 13.5px; font-weight: 600; white-space: nowrap;
  transition: background .13s, transform .1s;
}
.dl-btn:hover { background: var(--bg-card-hover); }
.dl-btn:active { transform: scale(.96); }
.dl-remove { color: var(--text-dim); }
.dl-ok {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 13px; font-weight: 700; color: #16a34a;
  background: color-mix(in srgb, #16a34a 14%, transparent);
  padding: 7px 12px; border-radius: 999px; white-space: nowrap;
}
.dl-progress {
  display: inline-flex; align-items: center;
  font-size: 13px; font-weight: 600; color: var(--accent);
  padding: 7px 4px; white-space: nowrap;
}

/* ============================================================
   Filtro de etiquetas (tag filter row)
   ============================================================ */
.tag-filter-row {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-bottom: 18px;
  padding: 2px 0;
}
.tag-filter-pill {
  padding: 6px 14px; border-radius: 999px;
  font-size: 13px; font-weight: 600;
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-dim);
  transition: background .13s, color .13s, border-color .13s, box-shadow .13s;
  cursor: pointer;
}
.tag-filter-pill:hover { background: var(--bg-card-hover); color: var(--text); }
.tag-filter-pill.active {
  background: var(--tc, var(--accent));
  border-color: var(--tc, var(--accent));
  color: #fff;
  box-shadow: 0 3px 10px rgba(0,0,0,.25);
}

/* ---- Botón Agrupar ---- */
.group-toggle-btn {
  margin-left: auto;
  display: flex; align-items: center; gap: 5px;
  padding: 6px 14px; border-radius: 999px;
  font-size: 13px; font-weight: 600;
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  transition: background .13s, color .13s, border-color .13s, box-shadow .13s;
}
.group-toggle-btn:hover { background: var(--bg-card-hover); color: var(--text); }
.group-toggle-btn.active {
  background: var(--accent-grd);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 3px 10px rgba(0,0,0,.25);
}
.group-toggle-ico { font-size: 14px; }

/* ---- Vista agrupada por etiqueta ---- */
.tag-group { margin-bottom: 28px; }
.tag-group-header {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 4px 10px;
  border-bottom: 1.5px solid color-mix(in srgb, var(--tg-color) 30%, transparent);
  margin-bottom: 6px;
}
.tg-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--tg-color);
  flex-shrink: 0;
}
.tg-name {
  font-size: 14px; font-weight: 700; letter-spacing: .3px;
  color: var(--tg-color);
  text-transform: capitalize;
}
.tg-count {
  font-size: 12px; font-weight: 600;
  color: var(--text-faint);
  background: var(--bg-card);
  padding: 1px 7px; border-radius: 999px;
  border: 1px solid var(--border);
}
.tg-reorder {
  margin-left: auto; display: flex; gap: 2px;
}
.tg-move {
  background: none; border: none; cursor: pointer;
  color: var(--text-faint); font-size: 11px; padding: 2px 5px;
  border-radius: 5px; line-height: 1; transition: color .15s, background .15s;
}
.tg-move:hover:not(:disabled) { color: var(--fg); background: var(--bg-card); }
.tg-move:disabled { opacity: .25; cursor: default; }

/* Botón marcar coro en editor */
.lyrics-label-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.lyrics-label-row label { margin-bottom: 0; }
.chorus-btns { display: flex; gap: 6px; flex-shrink: 0; }
.btn-chorus {
  font-size: 12px; padding: 4px 11px; border-radius: 999px;
  background: color-mix(in srgb, var(--brand-red) 12%, transparent);
  color: var(--brand-red); border: 1px solid color-mix(in srgb, var(--brand-red) 40%, transparent);
  cursor: pointer; font-weight: 600; transition: background .15s, transform .1s;
}
.btn-chorus:hover { background: color-mix(in srgb, var(--brand-red) 22%, transparent); }
.btn-chorus:active { transform: scale(.94); }
/* Botón "Quitar coro" en gris para distinguirlo */
.btn-chorus-off {
  background: var(--bg-card); color: var(--text-dim);
  border-color: var(--border);
}
.btn-chorus-off:hover { background: var(--bg-card-hover); color: var(--text); }

/* ============================================================
   Modal: Crear nueva Playlist
   ============================================================ */
.create-pl-modal { max-width: 480px; }

.cpl-preview {
  margin: 4px 24px 20px;
  border-radius: 18px;
  height: 110px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 6px;
  transition: background .3s;
}
.cpl-preview-emoji { font-size: 40px; line-height: 1; }
.cpl-preview-name {
  font-size: 15px; font-weight: 700; color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,.5);
  max-width: 90%; text-align: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.cpl-emoji-grid {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 4px;
}
.cpl-emoji-btn {
  width: 40px; height: 40px; border-radius: 10px;
  font-size: 20px; background: var(--bg-card);
  border: 1.5px solid var(--border);
  cursor: pointer; transition: transform .1s, border-color .15s;
  display: flex; align-items: center; justify-content: center;
}
.cpl-emoji-btn:hover { transform: scale(1.15); }
.cpl-emoji-btn.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
  transform: scale(1.15);
}

.cpl-color-row {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-top: 4px;
}
.cpl-color-btn {
  width: 32px; height: 32px; border-radius: 50%;
  border: 2.5px solid transparent;
  cursor: pointer; transition: transform .1s, border-color .15s;
}
.cpl-color-btn:hover { transform: scale(1.2); }
.cpl-color-btn.active {
  border-color: var(--text);
  transform: scale(1.2);
  box-shadow: 0 0 0 2px var(--bg-elev), 0 0 0 4px currentColor;
}

/* ============================================================
   Modal upload de canción
   ============================================================ */
.upload-modal { max-width: 560px; }

.up-dropzone {
  margin: 16px 24px; padding: 32px 20px;
  border: 2px dashed var(--border); border-radius: 14px;
  text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.up-dropzone:hover, .up-dropzone.active {
  border-color: var(--accent);
  background: rgba(204,16,22,.06);
}
.up-drop-ico { font-size: 44px; margin-bottom: 10px; }
.up-drop-title { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.up-drop-sub { font-size: 13px; color: var(--text-dim); }

.up-file-info {
  display: flex; align-items: center; gap: 12px;
  margin: 12px 24px 4px;
  padding: 12px 14px; border-radius: 10px;
  background: rgba(204,16,22,.1); border: 1px solid rgba(204,16,22,.25);
}
.up-file-ico { font-size: 24px; }
.up-file-info span:nth-child(2) { flex: 1; font-size: 13px; font-weight: 600; color: var(--text); word-break: break-all; }
.up-file-clear {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-dim); font-size: 13px;
  display: grid; place-items: center;
  cursor: pointer; flex-shrink: 0;
}

/* Tag suggestions (upload + edit) */
.tag-suggestions { display: flex; gap: 6px; flex-wrap: wrap; }
.tag-sug {
  font-size: 12px; font-weight: 600; padding: 4px 12px; border-radius: 999px;
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-dim); cursor: pointer;
  transition: background .12s, color .12s, border-color .12s, box-shadow .12s;
}
.tag-sug:hover {
  background: var(--tc, var(--accent));
  border-color: var(--tc, var(--accent));
  color: #fff;
}
.tag-sug.active {
  background: var(--tc, var(--accent));
  border-color: var(--tc, var(--accent));
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}

.upload-tag-pills { margin-bottom: 4px; }
