:root {
	--bg: #0a0a10;
	--surface: #13131b;
	--surface-2: #1b1b26;
	--surface-3: #242432;
	--border: rgba(255, 255, 255, 0.07);
	--text: #f0f0f7;
	--muted: #9494aa;
	--accent: #8b5cf6;
	--accent-2: #ff5fa8;
	--accent-grad: linear-gradient(135deg, #ff5fa8 0%, #8b5cf6 100%);
	--ok: #3ddc97;
	--danger: #ff6b81;
	--radius: 14px;
	--player-h: 92px;
	--art: none;
	color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	-webkit-font-smoothing: antialiased;
	overflow: hidden;
}
.hidden { display: none !important; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: inherit; }
svg { width: 1em; height: 1em; fill: currentColor; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 10px; border: 2px solid transparent; background-clip: content-box; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- boot / login ---- */
.boot { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 50; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--surface-3); border-top-color: var(--accent-2); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.login {
	position: fixed; inset: 0; display: grid; place-items: center; padding: 24px;
	background:
		radial-gradient(60% 50% at 20% 10%, rgba(255, 95, 168, 0.22), transparent 70%),
		radial-gradient(60% 60% at 90% 90%, rgba(139, 92, 246, 0.28), transparent 70%),
		var(--bg);
}
.login-card {
	width: min(420px, 100%); text-align: center; padding: 40px 32px;
	background: rgba(19, 19, 27, 0.75); backdrop-filter: blur(20px);
	border: 1px solid var(--border); border-radius: 24px;
	box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}
.login-card h1 { margin: 18px 0 8px; font-size: 28px; letter-spacing: -0.02em; }
.login-card p { color: var(--muted); margin: 0 0 24px; }
.logo { display: inline-grid; place-items: center; background: var(--accent-grad); border-radius: 16px; color: #fff; }
.logo.big { width: 72px; height: 72px; font-size: 44px; box-shadow: 0 10px 40px rgba(139, 92, 246, 0.5); }
.logo svg { width: 1em; height: 1em; }

.btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 8px;
	padding: 10px 18px; border-radius: 999px; font-weight: 600; text-decoration: none;
	background: var(--surface-3); transition: transform 0.12s, background 0.15s, opacity 0.15s;
}
.btn:hover { background: #2e2e40; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn svg { font-size: 18px; }
.btn.primary { background: var(--accent-grad); color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.discord { background: #5865f2; color: #fff; padding: 13px 24px; font-size: 15px; }
.btn.discord:hover { background: #6b77f5; }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 6px 12px; font-size: 13px; }

/* ---- layout ---- */
.app {
	position: fixed; inset: 0;
	display: grid;
	grid-template-columns: 76px minmax(0, 1fr) 340px;
	grid-template-rows: minmax(0, 1fr) var(--player-h);
	grid-template-areas: "rail main queue" "player player player";
	background: var(--bg);
}
.rail { grid-area: rail; overflow-y: auto; padding: 14px 0; display: flex; flex-direction: column; align-items: center; gap: 10px; border-right: 1px solid var(--border); background: var(--surface); }
.main {
	grid-area: main; min-width: 0; display: flex; flex-direction: column; position: relative; overflow: hidden;
}
.main::before {
	content: ""; position: absolute; inset: -40px; z-index: 0; pointer-events: none;
	background-image: var(--art); background-size: cover; background-position: center;
	filter: blur(70px) saturate(1.4); opacity: 0.28; transition: opacity 0.6s;
}
.main::after {
	content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
	background: linear-gradient(180deg, rgba(10, 10, 16, 0.2), var(--bg) 70%);
}
.main > * { position: relative; z-index: 1; }
.queue { grid-area: queue; border-left: 1px solid var(--border); background: var(--surface); overflow-y: auto; }
.player { grid-area: player; border-top: 1px solid var(--border); background: rgba(19, 19, 27, 0.92); backdrop-filter: blur(20px); z-index: 5; }

/* ---- rail ---- */
.guild {
	position: relative; width: 52px; height: 52px; border-radius: 14px; overflow: hidden; flex: none;
	background: var(--surface-3); display: grid; place-items: center; font-weight: 700; font-size: 15px;
	transition: transform 0.12s; border: 0;
}
.guild:hover { transform: translateY(-2px); }
.guild img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.guild.active { box-shadow: 0 0 0 2px var(--accent); }
.guild .live {
	position: absolute; right: 2px; bottom: 2px; width: 12px; height: 12px; border-radius: 50%;
	background: var(--ok); border: 2px solid var(--surface);
}

/* ---- topbar ---- */
.topbar { display: flex; align-items: center; gap: 20px; padding: 18px 28px 6px; flex-wrap: wrap; }
.title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.title h2 { margin: 0; font-size: 22px; letter-spacing: -0.02em; }
.pill { font-size: 12px; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.pill.on { color: var(--ok); border-color: rgba(61, 220, 151, 0.35); background: rgba(61, 220, 151, 0.08); }
.tabs { display: flex; gap: 4px; margin-left: auto; background: var(--surface); padding: 4px; border-radius: 999px; border: 1px solid var(--border); }
.tabs button { padding: 7px 16px; border-radius: 999px; color: var(--muted); font-weight: 600; transition: color 0.15s, background 0.15s; }
.tabs button:hover { color: var(--text); }
.tabs button.active { background: var(--surface-3); color: var(--text); box-shadow: 0 1px 6px rgba(0, 0, 0, 0.35); }
.user { display: flex; align-items: center; gap: 10px; }
.user img { width: 34px; height: 34px; border-radius: 50%; }
.icon-btn { width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 18px; color: var(--muted); transition: background 0.15s, color 0.15s; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }

.view { flex: 1; overflow-y: auto; padding: 18px 28px 32px; }

/* ---- toolbar / search ---- */
.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.search { position: relative; flex: 1; min-width: 200px; max-width: 420px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 16px; }
.search input, .field {
	width: 100%; padding: 10px 14px 10px 38px; border-radius: 999px; background: var(--surface);
	border: 1px solid var(--border); outline: none; transition: border-color 0.15s;
}
.field { padding-left: 16px; }
.search input:focus, .field:focus { border-color: var(--accent); }
.addbar { display: flex; gap: 10px; flex: 1; min-width: 260px; }
.section-title { margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }

/* ---- covers ---- */
.cover {
	position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--surface-3);
	display: grid; place-items: center; color: rgba(255, 255, 255, 0.4); font-size: 28px; flex: none;
}
.cover::before { content: ""; position: absolute; inset: 0; background: var(--cover-grad, linear-gradient(135deg, #3a2a63, #6b2a52)); opacity: 0.85; }
.cover svg { position: relative; }
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

/* ---- grid cards (Suno) ---- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 20px 18px; }
.card { position: relative; padding: 12px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); transition: transform 0.15s, background 0.15s, border-color 0.15s; }
.card:hover { background: var(--surface-2); transform: translateY(-3px); border-color: rgba(255, 255, 255, 0.12); }
.card .cover { width: 100%; border-radius: 10px; margin-bottom: 12px; }
.card .name { font-weight: 600; }
.card .meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.card .fab { position: absolute; right: 22px; top: calc(12px + (100% - 24px) * 0); }
.fab {
	width: 46px; height: 46px; border-radius: 50%; background: var(--accent-grad); color: #fff;
	display: grid; place-items: center; font-size: 22px; box-shadow: 0 8px 22px rgba(139, 92, 246, 0.5);
	opacity: 0; transform: translateY(8px); transition: opacity 0.18s, transform 0.18s;
}
.card:hover .fab, .card:focus-within .fab, .fab:focus-visible { opacity: 1; transform: none; }
.card .fab { top: auto; bottom: 78px; }
.card .dl { position: absolute; top: 18px; right: 18px; opacity: 0; transition: opacity 0.18s; }
.card .dl .icon-btn { background: rgba(10, 10, 16, 0.7); color: #fff; backdrop-filter: blur(6px); }
.card:hover .dl, .card:focus-within .dl { opacity: 1; }
@media (hover: none) { .card .dl { opacity: 1; } }
@media (hover: none) { .fab { opacity: 1; transform: none; } }

/* ---- rows (recent / mp3) ---- */
.rows { display: flex; flex-direction: column; gap: 2px; }
.row {
	display: grid; grid-template-columns: 52px minmax(0, 1fr) auto auto; align-items: center; gap: 14px;
	padding: 8px 12px 8px 8px; border-radius: 12px; transition: background 0.12s;
}
.row:hover { background: var(--surface); }
.row .cover { width: 52px; border-radius: 8px; font-size: 20px; }
.row .name { font-weight: 600; }
.row.now .name { color: var(--accent-2); }
.row .sub { color: var(--muted); font-size: 12px; }
.row .when { color: var(--muted); font-size: 12px; text-align: right; white-space: nowrap; }
.row .acts { display: flex; gap: 4px; }
.row .acts .icon-btn { opacity: 0.6; }
.row:hover .acts .icon-btn { opacity: 1; }
.who { display: inline-flex; align-items: center; gap: 5px; vertical-align: bottom; max-width: 100%; }
.who img { width: 16px; height: 16px; border-radius: 50%; flex: none; background: var(--surface-3); }
.badge { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: 0.06em; padding: 1px 6px; border-radius: 5px; background: var(--surface-3); color: var(--muted); vertical-align: 1px; margin-left: 6px; }
.equalizer { display: inline-flex; gap: 2px; align-items: flex-end; height: 12px; margin-right: 6px; vertical-align: -1px; }
.equalizer i { width: 3px; background: var(--accent-2); border-radius: 2px; animation: eq 0.9s ease-in-out infinite; height: 40%; }
.equalizer i:nth-child(2) { animation-delay: 0.2s; }
.equalizer i:nth-child(3) { animation-delay: 0.4s; }
.equalizer.paused i { animation-play-state: paused; }
@keyframes eq { 0%, 100% { height: 25%; } 50% { height: 100%; } }

.dropzone {
	border: 2px dashed var(--surface-3); border-radius: var(--radius); padding: 22px; text-align: center;
	color: var(--muted); margin-bottom: 22px; transition: border-color 0.15s, background 0.15s;
}
.dropzone.over { border-color: var(--accent); background: rgba(139, 92, 246, 0.08); color: var(--text); }
.dropzone .btn { margin-top: 10px; }
.empty { text-align: center; color: var(--muted); padding: 60px 20px; }
.empty .big { font-size: 44px; opacity: 0.4; margin-bottom: 8px; }

/* ---- voice ---- */
.vgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.vcard { padding: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 14px; }
.vcard.here { border-color: rgba(61, 220, 151, 0.5); background: linear-gradient(180deg, rgba(61, 220, 151, 0.08), var(--surface)); }
.vcard h3 { margin: 0; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.vcard h3 svg { color: var(--muted); }
.vcard .cat { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.avatars { display: flex; min-height: 30px; align-items: center; }
.avatars img { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--surface); margin-right: -8px; background: var(--surface-3); }
.avatars span { margin-left: 16px; color: var(--muted); font-size: 12px; }
.vcard .btn { align-self: flex-start; }

/* ---- queue panel ---- */
.queue-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 20px 12px; position: sticky; top: 0; background: var(--surface); z-index: 2; }
.queue-head h3 { margin: 0; font-size: 16px; }
.qitem { display: grid; grid-template-columns: 22px 44px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 6px 12px 6px 14px; }
.qitem:hover { background: var(--surface-2); }
.qitem .idx { color: var(--muted); font-size: 12px; text-align: center; }
.qitem .cover { width: 44px; border-radius: 6px; font-size: 16px; }
.qitem .name { font-weight: 600; font-size: 13px; }
.qitem .sub { font-size: 12px; color: var(--muted); }
.qitem .icon-btn { width: 28px; height: 28px; font-size: 14px; opacity: 0; }
.qitem:hover .icon-btn { opacity: 1; }
.qnow { margin: 0 14px 6px; padding: 12px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); display: flex; gap: 12px; align-items: center; }
.qnow .cover { width: 56px; }
.qlabel { padding: 14px 20px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.alert { margin: 10px 14px; padding: 10px 12px; border-radius: 10px; background: rgba(255, 107, 129, 0.1); border: 1px solid rgba(255, 107, 129, 0.3); color: #ffb3bf; font-size: 13px; }

/* ---- player bar ---- */
.player { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 560px) minmax(0, 1fr); align-items: center; gap: 24px; padding: 0 22px; }
.p-track { display: flex; align-items: center; gap: 14px; min-width: 0; }
.p-track .cover { width: 60px; border-radius: 8px; font-size: 22px; }
.p-track .name { font-weight: 600; }
.p-center { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.p-controls { display: flex; align-items: center; gap: 14px; }
.p-play { width: 44px; height: 44px; border-radius: 50%; background: #fff; color: #111; display: grid; place-items: center; font-size: 22px; transition: transform 0.12s; }
.p-play:hover { transform: scale(1.06); }
.p-play:disabled { opacity: 0.35; transform: none; cursor: default; }
.p-ctl { font-size: 22px; color: var(--muted); width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; }
.p-ctl:hover:not(:disabled) { color: var(--text); }
.p-ctl:disabled { opacity: 0.35; cursor: default; }
.p-bar { display: flex; align-items: center; gap: 10px; width: 100%; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.p-bar .time { width: 38px; }
.p-bar .time:last-child { text-align: left; }
.p-bar .time:first-child { text-align: right; }
.track { position: relative; flex: 1; height: 5px; border-radius: 5px; background: var(--surface-3); overflow: hidden; }
.track i { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent-grad); border-radius: 5px; }
.p-right { display: flex; justify-content: flex-end; align-items: center; gap: 10px; color: var(--muted); }
.p-right svg { font-size: 20px; }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 120px; height: 5px; border-radius: 5px; background: linear-gradient(90deg, #fff var(--v, 50%), var(--surface-3) var(--v, 50%)); outline: none; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 1px 6px rgba(0,0,0,0.5); }
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 0; }
.q-toggle { display: none; }

/* ---- toasts ---- */
.toasts { position: fixed; left: 50%; bottom: calc(var(--player-h) + 18px); transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; z-index: 80; pointer-events: none; }
.toast { padding: 10px 16px; border-radius: 12px; background: var(--surface-3); border: 1px solid var(--border); box-shadow: 0 10px 30px rgba(0,0,0,0.5); animation: pop 0.2s ease-out; max-width: min(520px, 92vw); }
.toast.error { border-color: rgba(255, 107, 129, 0.5); color: #ffc2cb; }
.toast.ok { border-color: rgba(61, 220, 151, 0.4); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.97); } }

/* ---- responsive ---- */
@media (max-width: 1100px) {
	.app { grid-template-columns: 76px minmax(0, 1fr); grid-template-areas: "rail main" "player player"; }
	.queue {
		position: fixed; right: 0; top: 0; bottom: var(--player-h); width: min(380px, 100%); z-index: 20;
		transform: translateX(100%); transition: transform 0.25s; box-shadow: -20px 0 60px rgba(0,0,0,0.5);
	}
	.queue.open { transform: none; }
	.q-toggle { display: inline-grid; }
}
@media (max-width: 720px) {
	:root { --player-h: 128px; }
	.app { grid-template-columns: minmax(0, 1fr); grid-template-rows: 64px minmax(0, 1fr) var(--player-h); grid-template-areas: "rail" "main" "player"; }
	.rail { flex-direction: row; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--border); overflow-x: auto; overflow-y: hidden; justify-content: flex-start; }
	.topbar { padding: 14px 16px 4px; gap: 12px; }
	.tabs { margin-left: 0; width: 100%; overflow-x: auto; }
	.tabs button { flex: 1; padding: 7px 10px; white-space: nowrap; }
	.view { padding: 14px 16px 24px; }
	.player { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto; gap: 6px 12px; padding: 10px 14px; }
	.p-track { grid-column: 1; }
	.p-right { grid-column: 2; }
	.p-right input[type="range"], .p-right > svg, .p-right > span { display: none; }
	.p-center { grid-column: 1 / -1; grid-row: 2; }
	.row { grid-template-columns: 46px minmax(0, 1fr) auto; }
	.row .when { display: none; }
	.queue { bottom: var(--player-h); top: 64px; }
	.grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px 12px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
