:root {
  --bg: #0d0b14;
  --bg2: #14111f;
  --card: #1a1628;
  --card2: #221d33;
  --line: #2e2844;
  --text: #ece9f5;
  --muted: #9a93b3;
  --accent: #8b5cf6;
  --accent2: #ec4899;
  --ok: #22c55e;
  --warn: #f59e0b;
  --err: #ef4444;
  --radius: 14px;
  --grad: linear-gradient(135deg, var(--accent), var(--accent2));
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: radial-gradient(1200px 600px at 80% -10%, #2a1748 0%, transparent 60%), var(--bg);
  color: var(--text); min-height: 100vh; display: flex; flex-direction: column;
}
a { color: #c4b5fd; text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .6em; line-height: 1.25; }
h1 { font-size: 1.6rem; } h3 { font-size: 1.05rem; }
code, .mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; }
code { background: var(--card2); padding: 1px 6px; border-radius: 6px; font-size: .9em; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; }
.mt { margin-top: 1.4rem; } .grow { flex: 1; }
[hidden] { display: none !important; }

/* ---------- layout */
.topbar {
  display: flex; align-items: center; gap: 1.2rem; padding: .7rem 1.4rem; position: sticky; top: 0; z-index: 20;
  background: rgba(13, 11, 20, .82); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .55rem; color: var(--text); font-weight: 700; font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: .3rem; flex: 1; overflow-x: auto; }
.nav a { color: var(--muted); padding: .45rem .8rem; border-radius: 10px; white-space: nowrap; }
.nav a:hover { color: var(--text); background: var(--card); text-decoration: none; }
.nav a.active { color: var(--text); background: var(--card2); }
.me { display: flex; align-items: center; gap: .7rem; margin-left: auto; }
.me form { margin: 0; }
.points { background: var(--grad); color: #fff; padding: .3rem .75rem; border-radius: 99px; font-weight: 600; font-size: .9rem; white-space: nowrap; }
.points:hover { text-decoration: none; filter: brightness(1.1); }
.avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.avatar.letter { display: inline-grid; place-items: center; background: var(--card2); font-weight: 700; }
.avatar.lg { width: 64px; height: 64px; font-size: 1.6rem; }
.announce { background: linear-gradient(90deg, #3b1d6e, #5b1846); padding: .5rem 1.4rem; text-align: center; font-size: .92rem; }
main { width: 100%; max-width: 1040px; margin: 0 auto; padding: 1.6rem 1.2rem 4rem; flex: 1; }
main.wide { max-width: 1320px; }
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 1.2rem; border-top: 1px solid var(--line); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.row { display: flex; align-items: center; } .gap { gap: .6rem; } .end { justify-content: flex-end; }
.row.center { justify-content: center; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .9rem; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .9rem; }
@media (max-width: 820px) { .grid2, .grid3, .grid4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .grid2, .grid3, .grid4 { grid-template-columns: 1fr; } .me .btn { display: none; } }

/* ---------- components */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem; margin-bottom: 1rem; }
.card.narrow { max-width: 420px; margin: 2rem auto; }
.narrow-left { max-width: 620px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; border: 0; cursor: pointer;
  background: var(--grad); color: #fff; font: inherit; font-weight: 600; padding: .6rem 1.1rem; border-radius: 10px;
  transition: filter .15s, transform .05s; white-space: nowrap;
}
.btn:hover { filter: brightness(1.12); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn.ghost:hover { background: var(--card2); }
.btn.danger { background: transparent; border: 1px solid #5a2330; color: #fca5a5; }
.btn.danger:hover { background: #3a1620; }
.btn.sm { padding: .32rem .7rem; font-size: .85rem; border-radius: 8px; }
.btn.lg { padding: .8rem 1.5rem; font-size: 1.05rem; }
.btn.block { width: 100%; }
.btn.google { background: #fff; color: #222; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--bg2); border: 1px solid var(--line);
  border-radius: 10px; padding: .55rem .7rem; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(139, 92, 246, .2); }
textarea { resize: vertical; }
input[type=range] { padding: 0; accent-color: var(--accent); background: none; border: 0; box-shadow: none; }
input[type=checkbox] { width: auto; accent-color: var(--accent); transform: scale(1.2); }
.form { display: flex; flex-direction: column; gap: .8rem; }
.form label, .field { display: flex; flex-direction: column; gap: .35rem; font-size: .92rem; color: #d6d1e6; }
.field { margin-bottom: 1rem; }
.field output { color: var(--accent2); font-weight: 600; }
label.check { flex-direction: row; align-items: center; gap: .7rem; }
label.check span { display: flex; flex-direction: column; }
.label-row { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; margin-bottom: .35rem; }
.label-row h3 { margin: 0; }
.alert { padding: .65rem .9rem; border-radius: 10px; background: var(--card2); margin-bottom: 1rem; border: 1px solid var(--line); }
.alert.error { background: #3a1620; border-color: #5a2330; color: #fecaca; }
.alert.ok { background: #12301f; border-color: #1e5133; color: #bbf7d0; }
.sep { display: flex; align-items: center; gap: .8rem; color: var(--muted); margin: 1rem 0; font-size: .85rem; }
.sep::before, .sep::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 99px; background: var(--card2); border: 1px solid var(--line); font-size: .78rem; }
.badge.ok { background: #12301f; border-color: #1e5133; color: #86efac; }
.badge.warn { background: #3a2a0c; border-color: #6b4b10; color: #fcd34d; }
.badge.err { background: #3a1620; border-color: #5a2330; color: #fca5a5; }
.badge.info { background: #1e1b4b; border-color: #3730a3; color: #c7d2fe; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0; }
.chip { background: var(--card2); border: 1px solid var(--line); color: var(--muted); border-radius: 99px; padding: .22rem .7rem; font: inherit; font-size: .82rem; cursor: pointer; }
.chip:hover, .chip.on { color: #fff; border-color: var(--accent); background: rgba(139, 92, 246, .18); }
.chip.tag { font-family: ui-monospace, Consolas, monospace; }

/* ---------- home / auth */
.hero { text-align: center; padding: 4rem 1rem 3rem; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.2rem); }
.grad { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lead { color: var(--muted); font-size: 1.15rem; max-width: 640px; margin: 0 auto 2rem; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.ico { font-size: 1.8rem; }

/* ---------- studio */
.studio { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 1.2rem; align-items: start; }
@media (max-width: 980px) { .studio { grid-template-columns: 1fr; } }
.studio-side { position: sticky; top: 76px; }
.mode-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; margin-bottom: 1.2rem; }
.mode-tab { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: .1rem; padding: .8rem 1rem; border: 1px solid var(--line); border-radius: 12px; background: var(--bg2); cursor: pointer; transition: border-color .15s, background .15s; }
.mode-tab input { position: absolute; opacity: 0; pointer-events: none; }
.mode-tab small { color: var(--muted); font-size: .8rem; }
.mode-tab:has(input:checked) { border-color: var(--accent); background: rgba(139, 92, 246, .13); box-shadow: 0 0 0 3px rgba(139, 92, 246, .15); }
.mode-tab.locked { opacity: .5; cursor: not-allowed; }
@media (max-width: 600px) { .mode-tabs { grid-template-columns: 1fr; } }
.dropzone { border: 2px dashed var(--line); border-radius: 12px; padding: 1.3rem; text-align: center; cursor: pointer; margin-bottom: 1rem; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: rgba(139, 92, 246, .07); }
.dz-empty { display: flex; flex-direction: column; align-items: center; gap: .2rem; }
.dz-file { display: flex; align-items: center; gap: .7rem; justify-content: center; }
.dz-name { font-weight: 600; word-break: break-all; }
.advanced { border: 1px solid var(--line); border-radius: 12px; padding: .7rem 1rem; margin-bottom: 1rem; background: var(--bg2); }
.advanced summary { cursor: pointer; font-weight: 600; }
.advanced[open] summary { margin-bottom: 1rem; }
.advanced .field { margin: 0; }
.locked { opacity: .55; }
.submit-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding-top: .4rem; }
.cost { font-size: 1.05rem; } .cost b { font-size: 1.35rem; color: var(--accent2); }
.job-list { display: flex; flex-direction: column; gap: .6rem; }
.job { padding: .7rem .8rem; border-radius: 10px; background: var(--bg2); border: 1px solid var(--line); }
.job-top { display: flex; justify-content: space-between; gap: .5rem; align-items: center; }
.job-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-progress { font-size: .85rem; color: var(--muted); margin-top: .3rem; }
.job .bar { height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; margin-top: .5rem; }
.job .bar i { display: block; height: 100%; width: 40%; background: var(--grad); animation: slide 1.4s ease-in-out infinite; }
@keyframes slide { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }
.job audio { width: 100%; height: 36px; margin-top: .5rem; }
.empty { margin: 0; font-size: .9rem; }
.tips ul { padding-left: 1.1rem; margin: 0; font-size: .88rem; } .tips li { margin-bottom: .35rem; }

/* ---------- songs */
.song-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; }
.song { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; display: flex; flex-direction: column; gap: .6rem; }
.song-head { display: flex; gap: .8rem; align-items: center; }
.cover-art { width: 56px; height: 56px; flex: none; border-radius: 12px; display: grid; place-items: center; font-size: 1.5rem; cursor: pointer; border: 0; color: #fff; }
.cover-art:hover { filter: brightness(1.15); }
.song-title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.song-style { font-size: .82rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.song-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.pager { display: flex; justify-content: center; gap: .4rem; margin-top: 1.2rem; }
.player { position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%); width: min(720px, calc(100% - 2rem)); display: flex; align-items: center; gap: 1rem; padding: .7rem 1rem; background: rgba(34, 29, 51, .96); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); z-index: 30; }
.player-info { display: flex; flex-direction: column; min-width: 0; flex: 0 1 200px; }
.player-info b, .player-info small { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.player audio { flex: 1; min-width: 0; }
.dialog { background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.3rem; width: min(560px, calc(100% - 2rem)); }
.dialog::backdrop { background: rgba(0, 0, 0, .6); backdrop-filter: blur(3px); }
.lyrics { white-space: pre-wrap; font-family: inherit; max-height: 55vh; overflow: auto; background: var(--bg2); padding: .8rem; border-radius: 10px; }

/* ---------- account */
.profile { display: flex; gap: 1rem; align-items: center; margin-bottom: 1rem; }
.profile h2 { margin: 0; }
.balance { display: flex; justify-content: space-between; align-items: center; padding: .8rem 1rem; border-radius: 12px; background: var(--grad); margin-bottom: 1rem; }
.balance .muted { color: rgba(255, 255, 255, .8); } .balance b { font-size: 1.4rem; }
.google-link { margin-top: 1rem; }

/* ---------- tables / admin */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.table-wrap.tall { max-height: 560px; overflow-y: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { padding: .55rem .7rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { background: var(--card2); color: var(--muted); font-weight: 600; position: sticky; top: 0; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: rgba(255, 255, 255, .02); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { white-space: nowrap; text-align: right; }
.table .actions .btn { margin-left: .25rem; }
.pos { color: #86efac; } .neg { color: #fca5a5; }
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--line); margin-bottom: 1.2rem; overflow-x: auto; }
.tabs button { background: none; border: 0; color: var(--muted); font: inherit; padding: .6rem 1rem; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.toolbar p { margin: 0; max-width: 760px; }
.toolbar form input, .toolbar form select { width: auto; min-width: 140px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.stat b { display: block; font-size: 1.7rem; } .stat span { color: var(--muted); font-size: .85rem; }
.roles { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; }
.role h3 { display: flex; justify-content: space-between; align-items: center; }
.perm-list { display: flex; flex-wrap: wrap; gap: .3rem; margin: .6rem 0; }
.perm-grid { display: grid; grid-template-columns: 1fr; gap: .4rem; max-height: 320px; overflow: auto; padding: .3rem; }
.perm-grid label { flex-direction: row; align-items: center; gap: .6rem; }
.codes textarea { margin-top: .4rem; }
#modal-body { display: flex; flex-direction: column; gap: .8rem; margin-bottom: 1rem; }

/* ---------- toasts */
#toasts { position: fixed; top: 76px; right: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 50; }
.toast { background: var(--card2); border: 1px solid var(--line); border-left: 4px solid var(--accent); padding: .7rem 1rem; border-radius: 10px; min-width: 240px; max-width: 380px; box-shadow: 0 8px 30px rgba(0, 0, 0, .4); animation: pop .2s ease-out; }
.toast.ok { border-left-color: var(--ok); } .toast.err { border-left-color: var(--err); }
@keyframes pop { from { transform: translateY(-6px); opacity: 0; } }
.song-meta { min-width: 0; }
