:root {
  --bg: #14121a; --panel: #1c1925; --raise: #282433; --line: #352f42;
  --text: #f3eff8; --mute: #9c94ad; --acc: #ff4d7e; --acc-ink: #1a0610;
  --side: 232px; --player: 84px; --tabs: 56px;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: inherit; text-decoration: none; }
svg { width: 24px; height: 24px; fill: currentColor; flex: none; }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
.hidden { display: none !important; }

/* Entrada */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.auth form { width: min(380px, 100%); display: grid; gap: 12px; }
.logo { font-weight: 800; letter-spacing: -.04em; font-size: 28px; }
.logo i { font-style: normal; color: var(--acc); }
.auth .logo { font-size: 52px; margin-bottom: 4px; }
.auth p { margin: 0 0 8px; color: var(--mute); }
.field { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 13px 14px; width: 100%; }
.field:focus { border-color: var(--acc); outline: none; }
.btn { background: var(--acc); color: var(--acc-ink); font-weight: 700; border-radius: 999px; padding: 11px 22px; }
.btn.ghost { background: var(--raise); color: var(--text); }
.btn.sm { padding: 7px 14px; font-size: 13px; }
.btn:disabled { opacity: .5; }
.err { color: #ff8da9; min-height: 1.4em; margin: 0; }

/* Estructura */
.app { display: grid; grid-template-columns: var(--side) 1fr; grid-template-rows: 1fr var(--player);
  height: 100dvh; grid-template-areas: "side main" "player player"; }
.side { grid-area: side; background: var(--panel); padding: 22px 12px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.side .logo { padding: 0 12px 18px; }
.nav a { display: flex; align-items: center; gap: 14px; padding: 10px 12px; border-radius: 10px; color: var(--mute); font-weight: 600; }
.nav a:hover { color: var(--text); }
.nav a.on { background: var(--raise); color: var(--text); }
.nav a.on svg { color: var(--acc); }
.side .who { margin-top: auto; padding: 12px; color: var(--mute); font-size: 13px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.side .who button { color: var(--mute); text-decoration: underline; }
main { grid-area: main; overflow-y: auto; padding: 28px 32px 40px; scroll-behavior: smooth; }
h1 { margin: 0 0 18px; font-size: 30px; letter-spacing: -.03em; }
h2 { margin: 30px 0 12px; font-size: 20px; letter-spacing: -.02em; }
.muted { color: var(--mute); }
.empty { padding: 48px 0; color: var(--mute); max-width: 46ch; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* Cuadrículas */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 20px 16px; }
.card { display: block; min-width: 0; }
.card .img { aspect-ratio: 1; border-radius: 8px; background: var(--raise); overflow: hidden; display: grid; place-items: center; color: var(--line); }
.card .img svg { width: 44%; height: 44%; }
.card img, .hero img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card b { display: block; margin-top: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card span { display: block; color: var(--mute); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card:hover .img { box-shadow: 0 0 0 2px var(--acc); }
.round .img { border-radius: 50%; }

.hero { display: flex; gap: 24px; align-items: flex-end; margin-bottom: 22px; }
.hero .img { width: 200px; aspect-ratio: 1; border-radius: 10px; background: var(--raise); overflow: hidden; flex: none; display: grid; place-items: center; color: var(--line); }
.hero h1 { margin-bottom: 8px; font-size: clamp(26px, 4vw, 46px); line-height: 1.05; }
.hero p { margin: 0 0 14px; color: var(--mute); }
.hero p a { color: var(--text); font-weight: 600; }
.hero p a:hover { text-decoration: underline; }

/* Pistas */
.trk { display: grid; grid-template-columns: 40px 1fr auto auto 40px 40px; gap: 10px; align-items: center; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.trk:hover { background: var(--panel); }
.trk.now { background: var(--raise); }
.trk.now .t { color: var(--acc); }
.trk .n { text-align: center; color: var(--mute); font-variant-numeric: tabular-nums; }
.trk .cv { width: 40px; height: 40px; border-radius: 5px; background: var(--raise); overflow: hidden; }
.trk .cv img { width: 100%; height: 100%; object-fit: cover; }
.trk .m { min-width: 0; }
.trk .t, .trk .a { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trk .a { color: var(--mute); font-size: 13px; }
.trk .d { color: var(--mute); font-variant-numeric: tabular-nums; font-size: 13px; }
.q { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 5px; background: var(--raise); color: var(--mute); white-space: nowrap; }
.q.hi { color: var(--acc); box-shadow: inset 0 0 0 1px var(--acc); background: none; }
.q.low { opacity: .55; }
.ic { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; color: var(--mute); }
.ic:hover { color: var(--text); background: var(--raise); }
.ic.on { color: var(--acc); }

/* Reproductor */
.player { grid-area: player; background: var(--panel); border-top: 1px solid var(--line); display: grid; grid-template-columns: 1fr 2fr 1fr; align-items: center; gap: 16px; padding: 0 16px; }
.np { display: flex; align-items: center; gap: 12px; min-width: 0; cursor: pointer; }
.np .cv { width: 56px; height: 56px; border-radius: 6px; background: var(--raise); overflow: hidden; flex: none; }
.np .cv img { width: 100%; height: 100%; object-fit: cover; }
.np div { min-width: 0; }
.np b, .np span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np span { color: var(--mute); font-size: 13px; }
.ctl { display: grid; gap: 4px; justify-items: center; }
.btns { display: flex; align-items: center; gap: 6px; }
.play { width: 44px; height: 44px; border-radius: 50%; background: var(--text); color: var(--bg); display: grid; place-items: center; }
.play:hover { background: var(--acc); }
.seek { display: grid; grid-template-columns: 44px 1fr 44px; gap: 8px; align-items: center; width: 100%; max-width: 640px; font-size: 12px; color: var(--mute); font-variant-numeric: tabular-nums; }
.seek span:first-child { text-align: right; }
.right { display: flex; justify-content: flex-end; align-items: center; gap: 6px; }
.right input { width: 100px; }

input[type=range] { -webkit-appearance: none; appearance: none; height: 16px; background: none; width: 100%; --p: 0%; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(90deg, var(--text) var(--p), var(--line) var(--p)); }
input[type=range]::-moz-range-track { height: 4px; border-radius: 2px; background: linear-gradient(90deg, var(--text) var(--p), var(--line) var(--p)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%; background: var(--text); margin-top: -4px; }
input[type=range]::-moz-range-thumb { width: 12px; height: 12px; border: 0; border-radius: 50%; background: var(--text); }
input[type=range]:hover::-webkit-slider-runnable-track { background: linear-gradient(90deg, var(--acc) var(--p), var(--line) var(--p)); }

/* Pantalla de reproducción */
.now-view { position: fixed; inset: 0; z-index: 30; background: var(--bg); overflow-y: auto; padding: max(16px, env(safe-area-inset-top)) 20px 28px; }
.now-view .wrap { max-width: 520px; margin: 0 auto; display: grid; gap: 16px; }
.now-view .top { display: flex; justify-content: space-between; align-items: center; }
.now-view .big { width: 100%; aspect-ratio: 1; border-radius: 12px; background: var(--raise); overflow: hidden; }
.now-view .big img { width: 100%; height: 100%; object-fit: cover; }
.now-view h2 { margin: 0; font-size: 24px; }
.now-view .btns { justify-content: space-between; width: 100%; }
.now-view .play { width: 64px; height: 64px; }
.now-view .play svg { width: 32px; height: 32px; }
.queue { margin-top: 8px; }
.queue .trk { grid-template-columns: 1fr auto 40px; }

/* Menús y avisos */
.sheet-bg { position: fixed; inset: 0; z-index: 40; background: rgba(8, 6, 12, .6); display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--raise); width: min(460px, 100%); border-radius: 18px 18px 0 0; padding: 8px 8px max(12px, env(safe-area-inset-bottom)); max-height: 80dvh; overflow-y: auto; }
.sheet h3 { margin: 10px 12px 6px; font-size: 14px; color: var(--mute); font-weight: 600; }
.sheet button { display: block; width: 100%; text-align: left; padding: 14px 12px; border-radius: 10px; }
.sheet button:hover { background: var(--line); }
@media (min-width: 801px) { .sheet-bg { align-items: center; } .sheet { border-radius: 18px; } }
.toast { position: fixed; left: 50%; bottom: calc(var(--player) + 16px); transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 600; z-index: 50; max-width: 90vw; }

table { width: 100%; border-collapse: collapse; margin: 8px 0 20px; }
td, th { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); }
th { color: var(--mute); font-weight: 600; font-size: 13px; }
.bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; max-width: 360px; margin: 8px 0; }
.bar i { display: block; height: 100%; background: var(--acc); width: 0; transition: width .3s; }
.panel { background: var(--panel); border-radius: 12px; padding: 18px; margin-bottom: 18px; }
.search { position: sticky; top: -28px; z-index: 5; padding: 8px 0; background: var(--bg); }

.tabs { display: none; }

/* Móvil */
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 1fr auto var(--tabs); grid-template-areas: "main" "player" "tabs"; }
  .side { display: none; }
  main { padding: 20px 16px 24px; }
  h1 { font-size: 26px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 16px 12px; }
  .hero { flex-direction: column; align-items: flex-start; }
  .hero .img { width: 100%; max-width: 280px; }
  .player { grid-template-columns: 1fr auto; height: 64px; padding: 0 8px 0 12px; position: relative; }
  .player .ctl, .player .right { display: none; }
  .player .mini { display: flex; }
  .np .cv { width: 44px; height: 44px; }
  .tabs { grid-area: tabs; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--panel); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); height: calc(var(--tabs) + env(safe-area-inset-bottom)); }
  .tabs a { display: grid; place-items: center; align-content: center; gap: 2px; color: var(--mute); font-size: 10px; font-weight: 600; }
  .tabs a.on { color: var(--text); }
  .tabs a.on svg { color: var(--acc); }
  .trk { grid-template-columns: 40px 1fr auto 40px; }
  .trk .d, .trk .q, .trk .favb { display: none; }
  .toast { bottom: calc(64px + var(--tabs) + 16px); }
}
.mini { display: none; align-items: center; gap: 2px; }
@media (min-width: 801px) { .mini { display: none !important; } }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }

.sheet .btn { display: inline-block; width: auto; text-align: center; }
.sheet #bl button { padding: 12px; }
.panel td .err { min-height: 0; }
.panel table td:first-child { word-break: break-all; }

/* Orden y vista */
.tools { display: flex; gap: 10px; align-items: center; margin: 0 0 16px; flex-wrap: wrap; }
.field.sel { width: auto; max-width: 260px; padding: 9px 12px; font-size: 14px; }
.seg { display: inline-flex; background: var(--panel); border-radius: 10px; padding: 3px; }
.seg button { width: 38px; height: 34px; display: grid; place-items: center; border-radius: 8px; color: var(--mute); }
.seg button svg { width: 20px; height: 20px; }
.seg button.on { background: var(--raise); color: var(--acc); }

/* Vista en lista de álbumes, artistas y listas */
.alist { display: grid; gap: 2px; }
.arow { display: grid; grid-template-columns: 52px 1fr auto; gap: 12px; align-items: center; padding: 6px 8px; border-radius: 8px; }
.arow:hover { background: var(--panel); }
.arow .img { width: 52px; height: 52px; border-radius: 6px; background: var(--raise); overflow: hidden; display: grid; place-items: center; color: var(--line); }
.arow.round .img { border-radius: 50%; }
.arow .img svg { width: 55%; height: 55%; }
.arow img { width: 100%; height: 100%; object-fit: cover; display: block; }
.arow .m { min-width: 0; }
.arow .m b, .arow .m span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.arow .m span { color: var(--mute); font-size: 13px; }
.arow .d { color: var(--mute); font-size: 13px; white-space: nowrap; }

/* Barra lateral de letras */
.az { position: fixed; right: 2px; top: 88px; bottom: calc(var(--player) + 14px); width: 24px; z-index: 6;
  display: flex; flex-direction: column; justify-content: space-between; align-items: center;
  font-size: 10px; font-weight: 700; color: var(--text); touch-action: none; user-select: none; -webkit-user-select: none; cursor: pointer; }
.az span { line-height: 1; padding: 1px 0; }
.az .dim { opacity: .3; }
.az-bubble { position: fixed; right: 44px; top: 50%; transform: translateY(-50%); width: 68px; height: 68px; z-index: 7;
  background: var(--acc); color: var(--acc-ink); font-size: 36px; font-weight: 800; display: grid; place-items: center; border-radius: 16px; pointer-events: none; }
main.has-az { padding-right: 36px; }
@media (max-width: 800px) { .az { bottom: calc(64px + var(--tabs) + 14px); top: 70px; } main.has-az { padding-right: 32px; } }
@media (max-height: 460px) { .az { display: none; } main.has-az { padding-right: 32px; } }

/* Perfil y calidad */
.avatar { display: inline-grid; place-items: center; border-radius: 50%; background: var(--acc); color: var(--acc-ink); font-weight: 800; object-fit: cover; flex: none; }
.acct { display: flex; gap: 18px; align-items: center; }
.acct-link { flex: none; display: block; border-radius: 50%; }
.ell { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.opt { display: flex; gap: 12px; align-items: flex-start; padding: 10px 4px; cursor: pointer; }
.opt input { margin-top: 5px; accent-color: var(--acc); width: 18px; height: 18px; flex: none; }
.opt b { display: block; }
.opt small { display: block; color: var(--mute); font-size: 13px; margin-top: 2px; }
select.field { color-scheme: dark; }

/* Formularios (programación y edición de usuarios) */
[hidden] { display: none !important; }
.frm { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 4px 14px; align-items: end; }
.frm label { display: block; color: var(--mute); font-size: 13px; margin-top: 8px; }
.frm .field { margin-top: 4px; }
.frm label.chk { display: flex; gap: 8px; align-items: center; color: var(--text); font-size: 15px; }
.frm label.chk input { accent-color: var(--acc); width: 18px; height: 18px; }
.frm > .row, .frm > .err { grid-column: 1 / -1; }
.sheet .frm { display: block; }
.sheet .frm .field { width: 100%; }
.sheet .btn { border-radius: 999px; padding: 11px 22px; }
.sheet .btn.sm { padding: 7px 14px; }
.sheet .btn:hover { background: var(--acc); }
.sheet .btn.ghost:hover { background: var(--line); }
