:root {
  --bg: #090411; --panel: #130921; --panel-alt: #1b0e2e;
  --pink: #ff2a85; --cyan: #00f0ff; --violet: #9d4edd;
  --text: #f5ecff; --muted: #9886b3; --ok: #00f59b;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0; background: radial-gradient(circle at top, #1b0b30 0%, var(--bg) 65%);
  color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh; display: flex; flex-direction: column; padding-bottom: 84px;
}
header {
  display: flex; justify-content: space-between; align-items: center; padding: 14px 18px;
  border-bottom: 1px solid rgba(255, 42, 133, 0.25); background: rgba(9, 4, 17, 0.85);
  backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 20;
}
.brand {
  font-weight: 800; letter-spacing: 2px; font-size: 1rem;
  background: linear-gradient(90deg, var(--pink), var(--cyan));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.btn-upload {
  background: rgba(0, 240, 255, 0.12); border: 1px solid var(--cyan); color: var(--cyan);
  padding: 6px 12px; border-radius: 20px; font-size: 0.8rem; font-weight: 600; cursor: pointer;
}
main { flex: 1; padding: 16px; max-width: 640px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.stage {
  background: var(--panel); border: 1px solid rgba(255, 42, 133, 0.25); border-radius: 20px;
  padding: 16px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.track-header { display: flex; align-items: center; gap: 14px; }
.cover-art {
  width: 72px; height: 72px; border-radius: 14px; object-fit: cover; flex-shrink: 0;
  border: 1px solid var(--pink); box-shadow: 0 0 16px rgba(255, 42, 133, 0.3); background: #1f0f36;
}
.track-meta h2 { margin: 0; font-size: 1.12rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track-meta p { margin: 3px 0 5px; font-size: 0.82rem; color: var(--cyan); }
.album-pill {
  display: inline-block; font-size: 0.7rem; padding: 2px 8px; border-radius: 10px;
  background: rgba(157, 78, 221, 0.2); border: 1px solid rgba(157, 78, 221, 0.45); color: #d8b4fe;
}
.btn-edit {
  background: rgba(255, 42, 133, 0.14); border: 1px solid var(--pink); color: var(--pink);
  padding: 6px 10px; border-radius: 12px; font-size: 0.75rem; font-weight: 700; cursor: pointer; flex-shrink: 0;
}
.vocal-hud {
  background: #0c0517; border: 1px solid rgba(0, 240, 255, 0.25); border-radius: 14px;
  padding: 12px; display: none; flex-direction: column; gap: 8px;
}
.vocal-hud.visible { display: flex; }
.hud-top { display: flex; justify-content: space-between; font-size: 0.8rem; font-weight: 700; }
.note-target { color: var(--cyan); }
.note-sung { color: var(--pink); }
.score-badge { color: var(--ok); }
.tuner-track { position: relative; height: 16px; background: #1a0d2e; border-radius: 8px; overflow: hidden; }
.tuner-center {
  position: absolute; left: 50%; top: 0; bottom: 0; width: 24%; transform: translateX(-50%);
  background: rgba(0, 245, 155, 0.18); border-left: 1px dashed var(--ok); border-right: 1px dashed var(--ok);
}
.tuner-needle {
  position: absolute; top: 2px; bottom: 2px; width: 10px; border-radius: 5px; background: var(--pink);
  left: 50%; transform: translateX(-50%); transition: left 0.06s linear, background 0.1s; box-shadow: 0 0 10px var(--pink);
}
.tuner-needle.on-pitch { background: var(--ok); box-shadow: 0 0 12px var(--ok); }
.lyrics-box {
  height: 175px; overflow-y: auto; background: rgba(7, 3, 14, 0.7); border-radius: 14px;
  padding: 55px 14px; text-align: center; scroll-behavior: smooth; border: 1px solid rgba(255, 255, 255, 0.06);
}
.lyric-line { font-size: 0.95rem; color: var(--muted); margin: 10px 0; transition: 0.25s; cursor: pointer; }
.lyric-line.active {
  color: #fff; font-size: 1.12rem; font-weight: 800;
  text-shadow: 0 0 12px var(--pink), 0 0 24px rgba(0, 240, 255, 0.5); transform: scale(1.03);
}
.progress-wrap { display: flex; flex-direction: column; gap: 4px; }
input[type="range"] { width: 100%; accent-color: var(--pink); cursor: pointer; }
.time-row { display: flex; justify-content: space-between; font-size: 0.72rem; color: var(--muted); }
.controls { display: flex; justify-content: center; align-items: center; gap: 14px; }
.ctrl-btn {
  background: var(--panel-alt); border: 1px solid rgba(255, 255, 255, 0.12); color: var(--text);
  width: 44px; height: 44px; border-radius: 50%; font-size: 1.05rem; cursor: pointer; display: grid; place-items: center;
}
.ctrl-btn.small { width: 36px; height: 36px; font-size: 0.9rem; opacity: 0.65; }
.ctrl-btn.small.active { opacity: 1; border-color: var(--cyan); color: var(--cyan); box-shadow: 0 0 10px rgba(0, 240, 255, 0.35); }
.ctrl-btn.play {
  width: 58px; height: 58px; background: linear-gradient(135deg, var(--pink), #b5179e);
  border: none; font-size: 1.35rem; box-shadow: 0 0 20px rgba(255, 42, 133, 0.55);
}
.practice-panel {
  display: none; flex-direction: column; gap: 10px; background: rgba(27, 14, 46, 0.7);
  padding: 12px; border-radius: 14px; border: 1px solid rgba(157, 78, 221, 0.3);
}
.practice-panel.visible { display: flex; }
.slider-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 0.8rem; }
.slider-row input { flex: 1; }
.ab-row { display: flex; gap: 8px; }
.ab-btn {
  flex: 1; background: #130921; border: 1px solid var(--cyan); color: var(--cyan);
  padding: 8px; border-radius: 10px; font-size: 0.78rem; font-weight: 700; cursor: pointer;
}
.ab-btn.active { background: var(--cyan); color: #090411; }

/* Sección Biblioteca / Playlist */
.playlist-section {
  background: var(--panel); border: 1px solid rgba(157, 78, 221, 0.25); border-radius: 20px;
  padding: 14px; display: flex; flex-direction: column; gap: 10px;
}
.playlist-header { display: flex; justify-content: space-between; align-items: center; }
.playlist-header h3 { margin: 0; font-size: 0.95rem; color: var(--cyan); letter-spacing: 0.5px; }
.muted-tag { font-size: 0.75rem; color: var(--muted); }
.album-filters { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.album-filters::-webkit-scrollbar { display: none; }
.filter-chip {
  flex: 0 0 auto; background: #0c0517; border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--muted); padding: 5px 11px; border-radius: 14px; font-size: 0.75rem; font-weight: 600; cursor: pointer;
}
.filter-chip.active { border-color: var(--pink); color: #fff; background: rgba(255, 42, 133, 0.18); }
.playlist-list { display: flex; flex-direction: column; gap: 8px; }
.pl-item {
  display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 12px;
  background: rgba(9, 4, 17, 0.65); border: 1px solid transparent; cursor: pointer; transition: 0.15s;
}
.pl-item:hover { background: var(--panel-alt); }
.pl-item.active { border-color: var(--pink); background: var(--panel-alt); box-shadow: 0 0 12px rgba(255, 42, 133, 0.25); }
.pl-item img { width: 44px; height: 44px; border-radius: 9px; object-fit: cover; background: #1f0f36; flex-shrink: 0; }
.pl-info { flex: 1; min-width: 0; }
.pl-title { font-size: 0.88rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-sub { font-size: 0.73rem; color: var(--muted); margin-top: 2px; }
.pl-badges { display: flex; gap: 4px; font-size: 0.72rem; }

.mode-nav {
  position: fixed; bottom: 0; left: 0; right: 0; height: 70px; background: rgba(13, 6, 24, 0.95);
  backdrop-filter: blur(12px); border-top: 1px solid rgba(255, 42, 133, 0.3);
  display: flex; justify-content: space-around; align-items: center; z-index: 30;
}
.mode-tab {
  flex: 1; height: 100%; background: none; border: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 0.75rem; font-weight: 700; cursor: pointer;
}
.mode-tab.active { color: var(--cyan); text-shadow: 0 0 10px rgba(0, 240, 255, 0.5); }
.modal { position: fixed; inset: 0; background: rgba(5, 2, 10, 0.88); display: none; place-items: center; padding: 16px; z-index: 50; }
.modal.open { display: grid; }
.modal-card {
  background: var(--panel); border: 1px solid var(--pink); border-radius: 20px; padding: 20px;
  width: 100%; max-width: 440px; max-height: 90dvh; overflow-y: auto; display: flex; flex-direction: column; gap: 12px;
}
.modal-card h3 { margin: 0; color: var(--cyan); }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 0.8rem; }
.field input[type="text"] { background: #090411; border: 1px solid rgba(255, 255, 255, 0.2); color: #fff; padding: 10px; border-radius: 10px; }
.field-head { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.file-ok { color: var(--ok); font-size: 0.72rem; font-weight: 700; }
.file-miss { color: var(--muted); font-size: 0.72rem; }
.file-del { background: none; border: none; color: #ff3b5c; font-size: 0.72rem; text-decoration: underline; cursor: pointer; padding: 0 0 0 6px; }
.btn-danger {
  background: rgba(255, 59, 92, 0.15); border: 1px solid #ff3b5c; color: #ff3b5c;
  padding: 5px 9px; border-radius: 10px; font-size: 0.72rem; font-weight: 700; cursor: pointer;
}
.rank-big { font-size: 3.5rem; font-weight: 900; text-align: center; color: var(--pink); text-shadow: 0 0 25px var(--pink); margin: 4px 0; }
.weak-line {
  background: #0c0517; padding: 8px 10px; border-radius: 10px; font-size: 0.8rem;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.weak-line button {
  background: var(--cyan); color: #090411; border: none; border-radius: 8px; padding: 5px 8px; font-weight: 700; font-size: 0.72rem; cursor: pointer;
}

.btn-sync {
  background: rgba(0, 240, 255, 0.14); border: 1px solid var(--cyan); color: var(--cyan);
  padding: 6px 10px; border-radius: 12px; font-size: 0.75rem; font-weight: 700; cursor: pointer;
}
textarea#rawLyricsInput {
  background: #090411; border: 1px solid rgba(255, 255, 255, 0.2); color: #fff;
  padding: 10px; border-radius: 10px; font-family: inherit; font-size: 0.85rem; resize: vertical;
}
.sync-player-bar {
  display: flex; align-items: center; justify-content: space-between;
  background: #0c0517; padding: 8px 12px; border-radius: 12px; border: 1px solid rgba(157, 78, 221, 0.3);
}
.btn-stamp {
  background: linear-gradient(135deg, var(--pink), #b5179e); color: #fff; border: none;
  padding: 13px; border-radius: 14px; font-size: 0.92rem; font-weight: 800; cursor: pointer;
  box-shadow: 0 0 16px rgba(255, 42, 133, 0.45);
}
.btn-stamp:active { transform: scale(0.98); }
.sync-list {
  max-height: 190px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px;
  background: #090411; padding: 8px; border-radius: 12px; border: 1px solid rgba(255, 255, 255, 0.08);
}
.sync-row {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: 6px 8px; border-radius: 8px; font-size: 0.8rem; background: #130921; cursor: pointer;
}
.sync-row.cursor { border: 1px solid var(--cyan); background: #1d1033; }
.sync-time { font-family: monospace; color: var(--ok); font-weight: 700; flex-shrink: 0; }
.sync-nudge {
  background: #1f1136; border: 1px solid rgba(255,255,255,0.15); color: var(--text);
  border-radius: 6px; padding: 2px 6px; font-size: 0.7rem; cursor: pointer;
}

.btn-session {
  background: #180c29; border: 1px solid rgba(255, 255, 255, 0.2); color: var(--muted);
  padding: 6px 10px; border-radius: 14px; font-size: 0.74rem; font-weight: 700; cursor: pointer;
}
.btn-session.unlocked {
  border-color: var(--ok); color: var(--ok); background: rgba(0, 245, 155, 0.12);
}

/* Roles Admin vs Invitado, Tracklist y Métricas */
body:not(.is-admin) .admin-only { display: none !important; }
.btn-session.unlocked { border-color: #00f5d4; color: #00f5d4; background: rgba(0, 245, 212, 0.12); }
.track-num { font-family: monospace; font-size: 0.78rem; color: var(--cyan); opacity: 0.85; min-width: 22px; text-align: center; }
.reorder-col { display: flex; flex-direction: column; gap: 2px; }
.btn-order { background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15); color: #fff; border-radius: 4px; font-size: 0.65rem; padding: 1px 5px; cursor: pointer; }
.btn-order:hover { background: var(--pink); }
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 8px 0; }
.stat-box { background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1); border-radius: 10px; padding: 10px; text-align: center; }
.stat-val { font-size: 1.3rem; font-weight: 800; color: var(--cyan); }
.stat-lbl { font-size: 0.72rem; color: var(--muted); }
.stats-list { max-height: 240px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.stat-row { display: flex; justify-content: space-between; align-items: center; background: rgba(255,255,255,0.04); padding: 8px 10px; border-radius: 8px; font-size: 0.82rem; }

/* Visualizador y botón compartir */
.btn-share-track { background: rgba(0, 245, 212, 0.08); border: 1px solid rgba(0, 245, 212, 0.25); color: #00f5d4; border-radius: 8px; padding: 5px 8px; font-size: 0.78rem; cursor: pointer; flex-shrink: 0; }
.btn-share-track:hover { background: rgba(0, 245, 212, 0.22); }
.cv-toast { position: fixed; bottom: 78px; left: 50%; transform: translateX(-50%); background: rgba(16, 8, 32, 0.96); border: 1px solid #00f5d4; color: #fff; padding: 8px 16px; border-radius: 999px; font-size: 0.82rem; font-weight: 600; z-index: 9999; box-shadow: 0 0 20px rgba(0, 245, 212, 0.35); pointer-events: none; opacity: 0; transition: opacity 0.2s ease; }
.cv-toast.show { opacity: 1; }

/* Tarjetas de Álbumes y Vista Agrupada */
.album-filters { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: thin; }
.album-card { display: flex; align-items: center; gap: 9px; background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.12); border-radius: 12px; padding: 6px 10px; color: #fff; cursor: pointer; flex-shrink: 0; transition: all 0.2s ease; text-align: left; }
.album-card img { width: 38px; height: 38px; border-radius: 8px; object-fit: cover; border: 1px solid rgba(0,245,212,0.25); }
.album-card.active { border-color: #ff2a85; background: rgba(255, 42, 133, 0.16); box-shadow: 0 0 14px rgba(255, 42, 133, 0.28); }
.album-card-title { font-size: 0.82rem; font-weight: 700; white-space: nowrap; }
.album-card-sub { font-size: 0.7rem; color: var(--muted); }
.album-move-row { display: flex; gap: 4px; margin-top: 3px; }
.album-banner { display: flex; justify-content: space-between; align-items: center; background: rgba(0, 245, 212, 0.07); border: 1px solid rgba(0, 245, 212, 0.22); border-radius: 10px; padding: 8px 12px; margin-bottom: 8px; }
.album-group-header { display: flex; justify-content: space-between; align-items: center; padding: 10px 4px 4px; margin-top: 6px; border-bottom: 1px solid rgba(0, 245, 212, 0.18); font-size: 0.78rem; font-weight: 700; color: var(--cyan); letter-spacing: 0.04em; text-transform: uppercase; }

/* Modo Ordenar (Drag & Drop) */
body:not(.edit-order) .order-only { display: none !important; }
.drag-handle { cursor: grab; color: var(--cyan); font-size: 1.05rem; padding: 6px 4px; touch-action: none; user-select: none; opacity: 0.85; flex-shrink: 0; }
.drag-handle:active { cursor: grabbing; }
.pl-item.dragging { opacity: 0.92; background: rgba(255, 42, 133, 0.24) !important; border: 1px dashed #00f5d4 !important; transform: scale(1.01); z-index: 20; box-shadow: 0 8px 24px rgba(0,0,0,0.45); }
.album-card.dragging { opacity: 0.85; border: 1px dashed #00f5d4 !important; }

/* Ajuste definitivo de header sin cortes laterales */
body { margin: 0; padding-left: 0; padding-right: 0; overflow-x: hidden; }
header { width: 100% !important; max-width: 100vw !important; padding: 10px 14px !important; box-sizing: border-box !important; display: flex !important; flex-wrap: wrap !important; justify-content: space-between !important; align-items: center !important; gap: 8px !important; }
header .brand { font-size: clamp(0.92rem, 3.2vw, 1.15rem) !important; white-space: nowrap; }
header > div:last-child { display: flex !important; flex-wrap: wrap !important; gap: 6px !important; justify-content: flex-end !important; max-width: 100% !important; }

/* Barra de Reacciones y Notas en Línea de Tiempo */
.cv-feedback-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; padding-top: 10px; border-top: 1px solid rgba(255,255,255,0.08); flex-wrap: wrap; }
.cv-rx-group { display: flex; gap: 8px; align-items: center; }
.cv-rx-btn { background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.14); color: #fff; border-radius: 999px; padding: 5px 12px; font-size: 0.82rem; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; transition: transform 0.15s ease, border-color 0.2s ease, background 0.2s ease; }
.cv-rx-btn:hover { border-color: #ff2a85; background: rgba(255,42,133,0.16); }
.cv-rx-btn:active { transform: scale(1.12); }
.cv-notes-drawer { margin-top: 10px; background: rgba(9, 4, 17, 0.65); border: 1px solid rgba(0, 245, 212, 0.2); border-radius: 12px; padding: 10px; display: none; }
.cv-notes-drawer.open { display: block; }
.cv-note-form { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.cv-note-form input { background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.15); color: #fff; border-radius: 8px; padding: 6px 9px; font-size: 0.8rem; }
.cv-note-form input.author-in { width: 105px; }
.cv-note-form input.text-in { flex: 1; min-width: 150px; }
.cv-note-list { max-height: 150px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.cv-note-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 0.78rem; background: rgba(255,255,255,0.03); padding: 5px 8px; border-radius: 8px; }
.cv-ts-badge { background: rgba(0,245,212,0.15); color: #00f5d4; border: 1px solid rgba(0,245,212,0.35); border-radius: 6px; padding: 2px 6px; font-family: monospace; font-size: 0.74rem; cursor: pointer; flex-shrink: 0; }
.cv-ts-badge:hover { background: rgba(0,245,212,0.3); }
