:root {
  --accent: #8b5cf6;
  --bg: #0c0c11;
  --bg-2: #111118;
  --panel: #16161f;
  --panel-2: #1d1d28;
  --border: #272735;
  --text: #ececf3;
  --muted: #9494a8;
  --danger: #ef4444;
  --success: #22c55e;
  --radius: 14px;
  --accent-soft: color-mix(in srgb, var(--accent) 16%, transparent);
  --accent-strong: color-mix(in srgb, var(--accent) 85%, white);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: radial-gradient(1200px 600px at 100% -10%, var(--accent-soft), transparent 60%), var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
h1, h2 { margin: 0; line-height: 1.25; }
h2 { font-size: 15px; font-weight: 600; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.strong { font-weight: 600; }
.grow { flex: 1; min-width: 0; }
.left { text-align: left; }
.pad { padding: 0 12px; }

/* ───── Carga y avisos ───── */
.boot, .loading { display: grid; place-items: center; min-height: 40vh; }
.boot { min-height: 100vh; }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.alert {
  background: color-mix(in srgb, var(--danger) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent);
  color: #fecaca; padding: 10px 14px; border-radius: 10px;
}
.notice {
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  padding: 12px 14px; border-radius: 10px; display: grid; gap: 6px;
}
.code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 18px; letter-spacing: 2px; }

#toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 50; }
.toast {
  background: var(--panel-2); border: 1px solid var(--border); border-left: 4px solid var(--accent);
  padding: 10px 14px; border-radius: 10px; max-width: 360px; box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
  transition: opacity .4s, transform .4s;
}
.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast.hide { opacity: 0; transform: translateY(6px); }

/* ───── Botones y campos ───── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 14px; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); }
.btn-danger { color: #fca5a5; }
.btn-danger:hover { border-color: var(--danger); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-xs { padding: 2px 8px; font-size: 12px; border-radius: 8px; }
.btn-discord { background: #5865f2; border-color: #5865f2; color: #fff; padding: 11px 18px; font-weight: 600; }
.btn-discord:hover { background: #4752c4; }

.icon-btn {
  display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 50%;
  background: var(--panel-2); border: 1px solid var(--border); cursor: pointer; font-size: 17px;
}
.icon-btn:hover:not(:disabled) { border-color: var(--accent); }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }
.icon-btn-primary { width: 54px; height: 54px; background: var(--accent); border-color: var(--accent); color: #fff; font-size: 20px; }
.icon-btn-sm { width: 30px; height: 30px; font-size: 13px; }
.icon-btn-danger:hover:not(:disabled) { border-color: var(--danger); color: #fca5a5; }

.input {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; min-width: 0;
}
.input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.input-sm { padding: 5px 8px; font-size: 13px; }
input[type="range"] { accent-color: var(--accent); }
input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }

.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.stack { display: grid; gap: 18px; align-content: start; }
.check { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }

/* ───── Login ───── */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card {
  width: min(420px, 100%); background: var(--panel); border: 1px solid var(--border); border-radius: 20px;
  padding: 36px 30px; display: grid; gap: 16px; justify-items: center; text-align: center;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .45);
}
.login-card h1 { font-size: 26px; }
.login-avatar { width: 84px; height: 84px; border-radius: 50%; box-shadow: 0 0 0 4px var(--accent-soft); }
.login-lang { margin-top: 6px; }
.placeholder { display: grid; place-items: center; background: var(--accent-soft); color: var(--text); font-weight: 600; }

/* ───── Estructura ───── */
.layout { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--bg-2); border-right: 1px solid var(--border); padding: 18px 12px;
  display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; padding: 4px 10px 14px; }
.brand-avatar { width: 34px; height: 34px; border-radius: 10px; }
.nav { display: grid; gap: 4px; }
.nav-item, .guild-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: 10px;
  background: transparent; border: 0; cursor: pointer; text-align: left; color: var(--muted);
}
.nav-item:hover, .guild-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active, .guild-item.active { background: var(--accent-soft); color: var(--text); }
.nav-icon { width: 20px; text-align: center; }
.nav-title { margin: 16px 10px 4px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.guild-list { display: grid; gap: 2px; }
.guild-item.disabled { cursor: default; opacity: .7; }
.guild-item.disabled:hover { background: transparent; }
.guild-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.guild-icon { width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0; font-size: 11px; object-fit: cover; }
.guild-icon.lg { width: 52px; height: 52px; font-size: 16px; }

.main-area { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 28px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--bg) 80%, transparent);
  position: sticky; top: 0; backdrop-filter: blur(8px); z-index: 10;
}
.page-title { font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-user { display: flex; align-items: center; gap: 10px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; }
.badge { background: var(--accent-soft); color: var(--accent-strong); border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600; }
.content { padding: 24px 28px 40px; display: grid; gap: 18px; align-content: start; max-width: 1280px; width: 100%; }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; display: grid; gap: 14px; align-content: start; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

/* ───── Estadísticas ───── */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: grid; gap: 4px; }
.card-icon { font-size: 20px; }
.card-value { font-size: 24px; font-weight: 700; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.table th { color: var(--muted); font-weight: 500; font-size: 12px; }
.status { display: inline-flex; align-items: center; gap: 6px; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status.ok::before { background: var(--success); box-shadow: 0 0 8px var(--success); }
.status.off::before { background: var(--danger); }
.active-list { display: grid; gap: 6px; }
.active-item {
  display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid transparent; cursor: pointer; text-align: left; color: var(--text);
}
.active-item:hover { border-color: var(--border); }

/* ───── Servidor ───── */
.guild-header { display: flex; align-items: center; gap: 14px; }
.guild-header h1 { font-size: 22px; }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); }
.tab { background: transparent; border: 0; border-bottom: 2px solid transparent; padding: 10px 14px; cursor: pointer; color: var(--muted); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

.player-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.now-top { display: flex; gap: 18px; align-items: center; }
.cover { width: 132px; height: 132px; border-radius: 12px; object-fit: cover; flex-shrink: 0; box-shadow: 0 12px 30px rgba(0, 0, 0, .45); }
.cover-empty { display: grid; place-items: center; background: var(--panel-2); font-size: 42px; }
.track-info { display: grid; gap: 4px; min-width: 0; }
.eyebrow { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-strong); font-weight: 600; }
.track-title { font-size: 19px; font-weight: 700; text-decoration: none; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
a.track-title:hover { text-decoration: underline; }
.progress-wrap { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; }
.progress { width: 100%; }
.time { font-variant-numeric: tabular-nums; }
.live { color: #fca5a5; font-weight: 600; }
.controls { display: flex; justify-content: center; align-items: center; gap: 14px; }
.options { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.field { display: grid; gap: 6px; }
.field-label { color: var(--muted); font-size: 12px; }
.field.inline { grid-template-columns: 1fr; }
.volume-row { display: flex; gap: 8px; align-items: center; }
.volume-row input { flex: 1; }
.now-footer { display: flex; justify-content: space-between; align-items: center; gap: 10px; border-top: 1px solid var(--border); padding-top: 12px; }
.empty { display: grid; gap: 10px; justify-items: center; text-align: center; padding: 20px 0; }
.empty-icon { font-size: 36px; }

.add-form { display: grid; gap: 10px; }

.queue { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: 640px; overflow-y: auto; }
.queue-item { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 10px; }
.queue-item:hover { background: var(--panel-2); }
.queue-index { width: 26px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; background: var(--panel-2); flex-shrink: 0; }
.queue-text { display: grid; min-width: 0; flex: 1; }
.queue-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; font-weight: 500; }
a.queue-title:hover { text-decoration: underline; }
.queue-actions { display: flex; gap: 4px; opacity: .55; transition: opacity .15s; }
.queue-item:hover .queue-actions { opacity: 1; }

/* ───── Ajustes ───── */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.check-field { display: flex; align-items: flex-start; gap: 10px; }

/* ───── Playlists ───── */
.playlist-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.playlist-card { display: flex; align-items: center; gap: 12px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.playlist-icon { font-size: 26px; }
.playlist-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ───── Responsive ───── */
@media (max-width: 980px) {
  .player-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .guild-list { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
  .topbar { padding: 12px 16px; flex-wrap: wrap; }
  .content { padding: 16px; }
  .username { display: none; }
  .now-top { flex-direction: column; text-align: center; }
  .cover { width: 180px; height: 180px; }
}
