:root {
  --bg: #0a0c11;
  --surface: #12151e;
  --surface2: #1a1f2b;
  --border: #232936;
  --text: #f4f6fb;
  --muted: #9aa3b5;
  --primary: #7c5cff;
  --accent: #22d3ee;
  --ok: #34d399;
  --danger: #f87171;
}

* { box-sizing: border-box; }
html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input { font: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app {
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) 94px;
  height: 100vh;
  height: 100dvh;
}

/* ------------------------------------------------------------ sidebar */
.sidebar {
  grid-row: 1 / 3;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 18px 10px 14px;
  z-index: 40;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 20px; }
.brand .logo {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: grid; place-items: center; font-size: 21px; color: #fff;
  box-shadow: 0 6px 18px rgba(124, 92, 255, .35);
}
.brand b { display: block; font-size: 15px; letter-spacing: -.2px; }
.brand span { display: block; font-size: 10.5px; color: var(--muted); }

.label { font-size: 10px; letter-spacing: 1.2px; color: var(--muted); padding: 0 12px 8px; }
nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 11px; border-radius: 10px;
  color: var(--muted); font-size: 13px; font-weight: 500;
  text-align: left; transition: background .13s, color .13s;
}
.nav-item svg { width: 18px; height: 18px; }
.nav-item:hover { background: rgba(255, 255, 255, .035); color: var(--text); }
.nav-item.active { background: rgba(124, 92, 255, .16); color: var(--text); font-weight: 700; }
.nav-item.active svg { color: var(--primary); }

.spacer { flex: 1; }
.stat-card {
  margin: 10px 4px; padding: 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.stat-row { display: flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; }
.stat-row #pct { margin-left: auto; color: var(--muted); font-weight: 400; }
.live { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.bar { height: 5px; border-radius: 4px; background: var(--border); margin: 10px 0 8px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--primary); border-radius: 4px; transition: width .5s; }
.stat-text { font-size: 10.5px; color: var(--muted); line-height: 1.5; }
.version { font-size: 10px; color: var(--muted); padding: 0 12px; }

.scrim {
  display: none;
  position: fixed; inset: 0; z-index: 35;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(2px);
}
.scrim.show { display: block; }

/* --------------------------------------------------------------- main */
.main {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 20px 24px 14px;
  flex: none;
}
.titles { min-width: 0; flex: 1; }
.titles h1 { margin: 0; font-size: 26px; letter-spacing: -.5px; }
.titles p { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); }
.search {
  display: flex; align-items: center; gap: 8px;
  width: min(380px, 42vw);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0 10px;
  height: 42px;
}
.search:focus-within { border-color: var(--primary); }
.search svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.search input {
  flex: 1; min-width: 0; border: 0; outline: 0;
  background: transparent; color: var(--text); font-size: 13.5px;
}
.search input::-webkit-search-cancel-button { display: none; }
.clear { color: var(--muted); font-size: 20px; line-height: 1; padding: 4px; }
.menu { display: none; font-size: 20px; }

.chips {
  display: flex; gap: 7px; overflow-x: auto; flex: none;
  padding: 0 24px 12px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  padding: 7px 12px; border-radius: 20px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 11.5px; white-space: nowrap;
}
.chip:hover { border-color: #354055; }
.chip.active { background: rgba(124, 92, 255, .18); border-color: rgba(124, 92, 255, .55); color: var(--text); font-weight: 600; }

.content {
  flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden;
  padding-bottom: 18px;
  scrollbar-width: thin;
  scrollbar-color: #2c3444 transparent;
}
.content::-webkit-scrollbar { width: 8px; }
.content::-webkit-scrollbar-thumb { background: #2c3444; border-radius: 8px; }

/* --------------------------------------------------------------- lista */
.list { padding: 0 12px; }
.row {
  display: grid;
  grid-template-columns: 30px 42px minmax(0, 1fr) 120px 58px 72px 34px;
  align-items: center;
  gap: 10px;
  height: 58px;
  padding: 0 10px;
  margin: 1px 0;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  min-width: 0;
}
.row:hover { background: rgba(255, 255, 255, .035); }
.row.playing { background: rgba(124, 92, 255, .14); border-color: rgba(124, 92, 255, .35); }
.row.missing .meta b { color: var(--muted); }
.idx { font-size: 11px; color: var(--muted); text-align: center; }
.row.playing .idx { color: var(--primary); }
.cover {
  position: relative;
  width: 42px; height: 42px; border-radius: 10px; flex: none;
  background: linear-gradient(135deg, var(--c1, #7c5cff), var(--c2, #3b1e8f));
  display: grid; place-items: center;
  overflow: hidden; color: #fff; font-size: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .25);
}
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.meta { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.meta b { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta small { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill {
  width: fit-content; max-width: 100%;
  padding: 3px 8px; border-radius: 20px;
  background: rgba(34, 211, 238, .10);
  border: 1px solid rgba(34, 211, 238, .22);
  color: var(--accent);
  font-size: 10.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nro { font-size: 11px; color: var(--muted); text-align: right; }
.status { display: flex; align-items: center; gap: 5px; font-size: 10.5px; color: var(--muted); }
.status i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.status.ok { color: var(--ok); }
.status.ok i { background: var(--ok); }
.heart { color: var(--muted); font-size: 18px; line-height: 1; padding: 4px; justify-self: center; }
.heart:hover { color: var(--text); }
.heart.on { color: var(--accent); }
.heart.big { font-size: 21px; }

/* ------------------------------------------------------------- grids */
.genre-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; padding: 0 14px 24px; }
.genre-card {
  padding: 15px; border-radius: 14px; text-align: left;
  background: linear-gradient(135deg, color-mix(in srgb, var(--c1) 30%, transparent), var(--surface2));
  border: 1px solid color-mix(in srgb, var(--c1) 30%, var(--border));
  display: flex; flex-direction: column; gap: 14px; min-height: 92px;
}
.genre-card:hover { filter: brightness(1.15); }
.genre-card b { font-size: 14px; }
.genre-card span { font-size: 11px; color: var(--muted); }

.artist-list { padding: 0 14px; }
.artist-row {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 9px 12px; border-radius: 10px; text-align: left;
}
.artist-row:hover { background: rgba(255, 255, 255, .035); }
.artist-avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 15px;
  background: linear-gradient(135deg, var(--c1), var(--c2));
}
.artist-row b { flex: 1; min-width: 0; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.artist-row span { font-size: 11px; color: var(--muted); }

.server-view { padding: 4px 24px 24px; display: grid; gap: 14px; max-width: 760px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 18px; }
.card h3 { margin: 0 0 10px; font-size: 13.5px; }
.card p, .card li { font-size: 12.5px; color: var(--muted); line-height: 1.65; }
.card code { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 2px 6px; font-size: 12px; color: var(--accent); }
.card a { color: var(--accent); font-weight: 600; }
.server-stat { display: flex; gap: 26px; flex-wrap: wrap; margin-top: 6px; }
.server-stat div { font-size: 22px; font-weight: 700; }
.server-stat small { display: block; font-size: 10.5px; color: var(--muted); font-weight: 400; margin-top: 2px; }

.empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 60px 20px; color: var(--muted); text-align: center; }
.empty b { color: var(--text); font-size: 15px; }
.empty span { font-size: 12.5px; }
.empty-icon { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: var(--surface2); border: 1px solid var(--border); color: var(--primary); font-size: 24px; margin-bottom: 8px; }
.hidden { display: none !important; }

/* -------------------------------------------------------------- player */
.player {
  grid-column: 2;
  grid-row: 2;
  display: grid;
  grid-template-columns: minmax(190px, 1fr) minmax(300px, 1.5fr) minmax(170px, 1fr);
  align-items: center;
  gap: 18px;
  padding: 0 18px;
  background: linear-gradient(180deg, #141826, #0d1017);
  border-top: 1px solid var(--border);
  box-shadow: 0 -12px 30px rgba(0, 0, 0, .35);
  z-index: 30;
}
.now { display: flex; align-items: center; gap: 12px; min-width: 0; }
.now .cover { width: 54px; height: 54px; border-radius: 12px; font-size: 20px; }
.now .meta { flex: 1; }
.now .meta b { font-size: 13.5px; }
.now .meta span { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.center { display: flex; flex-direction: column; align-items: stretch; gap: 4px; }
.buttons { display: flex; align-items: center; justify-content: center; gap: 10px; }
.icon-btn { color: var(--muted); padding: 6px; border-radius: 8px; line-height: 1; }
.icon-btn:hover { color: var(--text); background: rgba(255, 255, 255, .05); }
.icon-btn.on { color: var(--primary); }
.icon-btn.skip { font-size: 25px; color: var(--text); }
.play-btn {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: grid; place-items: center;
  font-size: 15px; padding-left: 3px;
  box-shadow: 0 6px 18px rgba(124, 92, 255, .4);
}
.play-btn:hover { filter: brightness(1.1); }
.seek { display: flex; align-items: center; gap: 9px; }
.seek span { width: 40px; font-size: 10.5px; color: var(--muted); }
.seek span:last-child { text-align: right; }
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  height: 3px; border-radius: 3px;
  background: var(--border);
  accent-color: var(--primary);
  outline: none;
  flex: 1; min-width: 0;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 0 4px rgba(124, 92, 255, .18);
}
.extras { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.extras .vol { width: 18px; height: 18px; color: var(--muted); flex: none; }
.extras input[type="range"] { width: 86px; flex: none; }

.sheet {
  position: fixed; right: 16px; bottom: 106px; z-index: 60;
  width: min(420px, calc(100vw - 32px)); max-height: 60vh;
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .55);
  overflow: hidden;
}
.sheet-head { display: flex; align-items: center; padding: 14px 16px 10px; border-bottom: 1px solid var(--border); }
.sheet-head b { font-size: 13.5px; flex: 1; }
.queue { overflow-y: auto; padding: 6px; }
.queue-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; cursor: pointer; }
.queue-item:hover { background: rgba(255, 255, 255, .04); }
.queue-item.active { background: rgba(124, 92, 255, .14); }
.queue-item .qmeta { flex: 1; min-width: 0; }
.queue-item b { display: block; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-item small { font-size: 11px; color: var(--muted); }

.toast {
  position: fixed; left: 50%; bottom: 112px; transform: translate(-50%, 20px);
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); font-size: 12.5px;
  padding: 10px 16px; border-radius: 10px;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 80;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* --------------------------------------------------------------- acceso */
.auth {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  padding: 20px;
  background: radial-gradient(800px 500px at 50% 0%, #241b4d 0%, var(--bg) 65%);
}
.auth.hidden { display: none; }
.auth-card {
  width: min(390px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px 24px 22px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .55);
  text-align: center;
}
.auth-logo {
  width: 56px; height: 56px; margin: 0 auto 14px;
  border-radius: 16px; display: grid; place-items: center;
  font-size: 28px; color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 10px 28px rgba(124, 92, 255, .35);
}
.auth-card h2 { margin: 0 0 8px; font-size: 20px; }
.auth-card p { margin: 0 0 18px; font-size: 12.5px; color: var(--muted); line-height: 1.55; }
.auth-card input {
  width: 100%; padding: 13px 14px;
  border-radius: 11px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--text);
  font-size: 15px; letter-spacing: 1px; text-align: center;
  outline: none;
}
.auth-card input:focus { border-color: var(--primary); }
.auth-card button {
  width: 100%; margin-top: 12px; padding: 13px;
  border-radius: 11px; background: var(--primary); color: #fff;
  font-weight: 700; font-size: 14px;
}
.auth-card button:hover { filter: brightness(1.1); }
.auth-error { min-height: 16px; margin: 10px 0 0 !important; color: var(--danger) !important; font-size: 12px !important; }

/* ------------------------------------------------------------- mobile */
@media (max-width: 920px) {
  .app { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0;
    width: 252px; transform: translateX(-105%);
    transition: transform .22s ease;
    grid-row: auto;
  }
  .sidebar.open { transform: none; }
  .main { grid-column: 1; grid-row: 1; }
  .player { grid-column: 1; grid-row: 2; height: auto; grid-template-columns: 1fr; gap: 2px; padding: 8px 12px 10px; }
  .menu { display: block; }
  .topbar { padding: 14px 14px 10px; gap: 10px; flex-wrap: wrap; }
  .titles h1 { font-size: 21px; }
  .search { width: 100%; order: 3; }
  .chips { padding: 0 14px 10px; }
  .list { padding: 0 6px; }
  .row { grid-template-columns: 26px 40px minmax(0, 1fr) 58px 30px; height: 56px; gap: 8px; }
  .row .pill, .row .nro { display: none; }
  .extras { display: none; }
  .center { gap: 0; }
  .seek span { width: 36px; }
  .now .cover { width: 46px; height: 46px; }
  .now .meta b { font-size: 12.5px; }
  .now .heart { font-size: 19px; }
  .sheet { bottom: 150px; }
  .toast { bottom: 150px; }
  .server-view { padding: 4px 14px 20px; }
}

@media (max-width: 520px) {
  .status { font-size: 0; gap: 0; }
  .status i { width: 7px; height: 7px; }
  .genre-grid { grid-template-columns: 1fr 1fr; gap: 9px; padding: 0 10px 18px; }
  .genre-card { min-height: 84px; padding: 12px; }
}
