:root {
  --bg: #0e0e12;
  --panel: rgba(24, 24, 31, 0.78);
  --panel-solid: #18181f;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f2f2f5;
  --muted: #9a9aa8;
  --accent: #ff5a1f;
  --accent-2: #ff8a3d;
  --danger: #ff4d5e;
  --ok: #3ddc97;
  --radius: 18px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; }
a { color: var(--accent-2); }
img { display: block; }

.backdrop {
  position: fixed; inset: -80px; z-index: -1;
  background: radial-gradient(1200px 700px at 20% -10%, rgba(255, 90, 31, .18), transparent 60%), var(--bg);
  background-size: cover; background-position: center;
  filter: blur(60px) saturate(1.3) brightness(.45);
  transition: background-image .6s ease;
}
.backdrop.has-art { filter: blur(70px) saturate(1.4) brightness(.35); }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px clamp(16px, 4vw, 40px);
  position: sticky; top: 0; z-index: 10;
  background: linear-gradient(to bottom, rgba(14,14,18,.9), rgba(14,14,18,0));
  backdrop-filter: blur(6px);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-size: 18px; }
.brand b { color: var(--accent); }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--accent) url("/static/favicon.svg") center/cover;
}
.userbox { display: flex; align-items: center; gap: 10px; }
.userbox img { width: 32px; height: 32px; border-radius: 50%; }
.userbox .name { color: var(--muted); font-size: 14px; }

.app { max-width: 1180px; margin: 0 auto; padding: 8px clamp(16px, 4vw, 40px) 60px; }

/* ---------- generic ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(18px);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: rgba(255,255,255,.06);
  padding: 9px 16px; border-radius: 999px; cursor: pointer;
  transition: background .15s, transform .1s, opacity .15s;
  text-decoration: none; color: var(--text); white-space: nowrap;
}
.btn:hover { background: rgba(255,255,255,.12); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--accent-2); }
.btn.discord { background: #5865f2; border-color: transparent; font-weight: 600; padding: 13px 26px; font-size: 16px; }
.btn.discord:hover { background: #6d78f5; }
.btn.danger:hover { background: rgba(255, 77, 94, .2); border-color: rgba(255,77,94,.5); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 0; background: transparent;
  display: inline-grid; place-items: center; cursor: pointer; color: var(--muted);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: rgba(255,255,255,.1); color: var(--text); }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }
.icon-btn svg, .btn svg { width: 18px; height: 18px; fill: currentColor; }
.muted { color: var(--muted); }
.center-msg { min-height: 60vh; display: grid; place-items: center; text-align: center; gap: 14px; }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.12); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- landing ---------- */
.hero { min-height: 70vh; display: grid; place-items: center; text-align: center; }
.hero h1 { font-size: clamp(30px, 6vw, 54px); line-height: 1.1; margin: 0 0 14px; letter-spacing: -.02em; }
.hero h1 span { color: var(--accent); }
.hero p { color: var(--muted); max-width: 520px; margin: 0 auto 28px; font-size: 17px; }
.hero .features { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 34px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px; font-size: 13px;
  background: rgba(255,255,255,.06); border: 1px solid var(--line); color: var(--muted);
}
.chip.accent { color: var(--accent-2); border-color: rgba(255,90,31,.35); background: rgba(255,90,31,.1); }

/* ---------- sessions list ---------- */
.section-title { font-size: 22px; margin: 18px 0 16px; }
.sessions { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.session-card {
  display: flex; gap: 14px; padding: 14px; align-items: center;
  text-decoration: none; color: var(--text); transition: transform .15s, border-color .15s;
}
.session-card:hover { transform: translateY(-2px); border-color: rgba(255,90,31,.45); }
.session-card .art { width: 64px; height: 64px; border-radius: 12px; flex: none; }
.session-card .meta { min-width: 0; }
.session-card .t { font-weight: 600; }
.session-card .s { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { padding: 34px; text-align: center; color: var(--muted); }
.empty code { background: rgba(255,255,255,.08); padding: 2px 7px; border-radius: 6px; color: var(--text); }

/* ---------- player layout ---------- */
.crumbs { display: flex; align-items: center; gap: 10px; margin: 6px 0 18px; color: var(--muted); font-size: 14px; flex-wrap: wrap; }
.crumbs img { width: 24px; height: 24px; border-radius: 7px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--text); }
.layout { display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 22px; align-items: start; }
.layout > * { min-width: 0; }
@media (max-width: 900px) { .layout { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 520px) {
  .now { padding: 16px; }
  .cover { max-width: 320px; margin: 0 auto; }
  .userbox .name { display: none; }
  .tab { padding: 8px 11px; font-size: 14px; }
  .row-item { grid-template-columns: 20px 44px minmax(0, 1fr) auto; gap: 10px; padding: 8px 4px; }
  .row-item .thumb { width: 44px; height: 44px; }
  .row-item .acts .icon-btn { width: 32px; height: 32px; }
  .row-item.no-num .acts .btn span { display: none; }
}

.now { padding: 22px; position: sticky; top: 76px; }
@media (max-width: 900px) { .now { position: static; } }
.cover {
  width: 100%; aspect-ratio: 1; border-radius: 14px; overflow: hidden;
  background: linear-gradient(135deg, #2a2a35, #1a1a22);
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
  display: grid; place-items: center;
}
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover .ph svg { width: 34%; height: 34%; fill: rgba(255,255,255,.18); }
.track-title { font-size: 22px; font-weight: 700; margin: 18px 0 2px; line-height: 1.25; word-break: break-word; }
.track-title a { color: inherit; text-decoration: none; }
.track-title a:hover { text-decoration: underline; }
.track-artist { color: var(--muted); margin: 0; }
.mode-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; min-height: 26px; }

.progress { margin-top: 18px; }
.bar { height: 5px; border-radius: 3px; background: rgba(255,255,255,.12); overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 3px; transition: width .9s linear; }
.times { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-top: 6px; font-variant-numeric: tabular-nums; }

.controls { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }
.controls .icon-btn { width: 44px; height: 44px; }
.controls .icon-btn svg { width: 22px; height: 22px; }
.controls .icon-btn.on { color: var(--accent); }
.controls .play {
  width: 64px; height: 64px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--text); color: #111; display: grid; place-items: center;
  transition: transform .12s, background .15s;
}
.controls .play:hover { transform: scale(1.05); }
.controls .play:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.controls .play svg { width: 28px; height: 28px; fill: currentColor; }
.loop-badge { position: relative; }
.loop-badge::after {
  content: attr(data-badge); position: absolute; right: 4px; bottom: 4px;
  font-size: 9px; font-weight: 700; color: var(--accent);
}
.sub-controls { display: flex; gap: 8px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }

.people { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.people .row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.people img { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--panel-solid); margin-left: -8px; }
.people img:first-child { margin-left: 0; }
.people .lbl { font-size: 13px; color: var(--muted); }
.notice {
  margin-top: 14px; padding: 10px 14px; border-radius: 12px; font-size: 13px;
  background: rgba(255, 90, 31, .1); border: 1px solid rgba(255,90,31,.3); color: #ffc7ad;
}

/* ---------- right side ---------- */
.side { padding: 8px; min-height: 420px; }
.tabs { display: flex; gap: 4px; padding: 6px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  border: 0; background: transparent; padding: 9px 16px; border-radius: 12px; cursor: pointer;
  color: var(--muted); font-weight: 600; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { background: rgba(255,255,255,.09); color: var(--text); }
.tab .count { font-weight: 500; color: var(--muted); margin-left: 4px; font-size: 13px; }
.pane { padding: 8px 8px 12px; }

.list { list-style: none; margin: 0; padding: 0; }
.row-item {
  display: grid; grid-template-columns: 28px 48px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 8px 10px; border-radius: 12px; transition: background .12s;
}
.row-item:hover { background: rgba(255,255,255,.05); }
.row-item .num { color: var(--muted); font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; }
.row-item .thumb { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; background: #23232c; }
.row-item .thumb.ph { display: grid; place-items: center; }
.row-item .thumb.ph svg { width: 20px; height: 20px; fill: rgba(255,255,255,.2); }
.row-item .info { min-width: 0; }
.row-item .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.row-item .s { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 13px; }
.row-item .acts { display: flex; gap: 2px; opacity: .0; transition: opacity .12s; }
.row-item:hover .acts, .row-item:focus-within .acts { opacity: 1; }
@media (hover: none) { .row-item .acts { opacity: 1; } }
.row-item.no-num { grid-template-columns: 48px minmax(0, 1fr) auto; }
.row-item.no-num .acts { opacity: 1; }
.more { text-align: center; color: var(--muted); font-size: 13px; padding: 10px; }

.searchbar { display: flex; gap: 8px; padding: 4px 4px 12px; flex-wrap: wrap; }
.input {
  flex: 1 1 220px; min-width: 0; padding: 11px 16px; border-radius: 999px;
  border: 1px solid var(--line); background: rgba(0,0,0,.25); color: var(--text); outline: none;
  font: inherit;
}
.input:focus { border-color: rgba(255,90,31,.6); }
.select {
  padding: 10px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: rgba(0,0,0,.25); color: var(--text); font: inherit;
}
.select option { background: var(--panel-solid); }

.vibes { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 4px; }
@media (max-width: 560px) { .vibes { grid-template-columns: 1fr; } }
.vibe-card {
  border: 1px solid var(--line); border-radius: 16px; padding: 20px; cursor: pointer; text-align: left;
  background: linear-gradient(135deg, rgba(64, 140, 255, .18), rgba(30, 30, 40, .6));
  transition: transform .15s, border-color .15s;
}
.vibe-card.plus { background: linear-gradient(135deg, rgba(255, 90, 31, .25), rgba(180, 60, 255, .18)); }
.vibe-card:hover { transform: translateY(-2px); border-color: rgba(255,255,255,.25); }
.vibe-card:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.vibe-card .e { font-size: 30px; }
.vibe-card h3 { margin: 8px 0 4px; font-size: 18px; }
.vibe-card p { margin: 0; color: var(--muted); font-size: 13px; }

/* ---------- toasts ---------- */
.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 50; width: min(92vw, 440px); }
.toast {
  padding: 11px 16px; border-radius: 12px; background: #23232d; border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(0,0,0,.4); font-size: 14px; animation: rise .2s ease;
}
.toast.err { border-color: rgba(255,77,94,.5); }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

.conn { display: inline-flex; align-items: center; gap: 6px; }
.conn::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.conn.off::before { background: var(--danger); }

/* ---------- independent scroll for the right panel ---------- */
.side {
  display: flex; flex-direction: column;
  position: sticky; top: 76px;
  max-height: calc(100vh - 96px); max-height: calc(100dvh - 96px);
}
.side .tabs { flex: none; }
.side .pane {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  overscroll-behavior: contain; scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.18) transparent;
}
.side .pane::-webkit-scrollbar { width: 8px; }
.side .pane::-webkit-scrollbar-thumb { background: rgba(255,255,255,.16); border-radius: 4px; }
@media (max-width: 900px) {
  .side { position: static; max-height: 78vh; max-height: 78dvh; min-height: 360px; }
}

.pane-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 2px 6px 10px; font-size: 13px; flex-wrap: wrap;
}

/* ---------- drag & drop ---------- */
.grip {
  display: grid; place-items: center; width: 28px; height: 40px; cursor: grab;
  color: var(--muted); touch-action: none; border-radius: 8px; user-select: none;
}
.grip:hover { color: var(--text); background: rgba(255,255,255,.06); }
.grip svg { width: 18px; height: 18px; fill: currentColor; }
.drag-ghost {
  position: fixed; z-index: 100; pointer-events: none; margin: 0;
  background: var(--panel-solid); border: 1px solid rgba(255,90,31,.5);
  box-shadow: 0 16px 40px rgba(0,0,0,.55); border-radius: 12px; list-style: none;
  transform: scale(1.02); opacity: .96;
}
.drag-ghost .acts { opacity: 0 !important; }
.drag-placeholder { opacity: .25; background: rgba(255,90,31,.12); }
body:has(.drag-ghost) { cursor: grabbing; user-select: none; }

/* ---------- playlist editor ---------- */
.clickable { cursor: pointer; }
.pl-head { display: flex; align-items: center; gap: 6px; padding: 0 2px 10px; }
.pl-title { flex: 1; min-width: 0; }
.pl-title .t { font-size: 18px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-title .s { font-size: 13px; }
.pl-tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 0 4px 12px; }
.pl-results { margin: 0 0 12px; padding: 8px 4px; border-radius: 14px; background: rgba(255,255,255,.04); }
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; }
.toggle input { accent-color: var(--accent); width: 16px; height: 16px; }
.icon-btn.danger-hover:hover { color: var(--danger); background: rgba(255,77,94,.12); }
.select.sm { padding: 6px 10px; font-size: 13px; max-width: 150px; }
@media (max-width: 520px) {
  .grip { width: 24px; }
  .row-item.sortable { grid-template-columns: 24px 44px minmax(0, 1fr) auto; }
  .select.sm { max-width: 110px; }
  .pl-tools .btn span { display: inline; }
}
