:root {
  color-scheme: dark;
  --bg: #05070a;
  --panel: rgba(15, 18, 24, .94);
  --panel2: #171b23;
  --line: rgba(255,255,255,.12);
  --text: #f4f7fb;
  --muted: #a4afbd;
  --accent: #ef4444;
  --ok: #34d399;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: #000;
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow: hidden;
}
button, input, select { font: inherit; }
.app {
  width: 100vw;
  height: 100vh;
  display: grid;
  grid-template-columns: 1fr min(380px, 32vw);
  background: var(--bg);
}
.app.side-collapsed {
  grid-template-columns: 1fr;
}
.auth {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(0,0,0,.86);
}
.standalone-auth {
  position: static;
  min-height: 100vh;
}
.auth-loading {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  background: #05070a;
  color: var(--muted);
  z-index: 30;
  font-weight: 700;
}
.auth-loading::before {
  content: "";
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,.2);
  border-top-color: var(--accent);
  animation: spin .9s linear infinite;
}
.auth-loading[hidden] { display: none; }
@keyframes spin {
  to { transform: rotate(360deg); }
}
.auth[hidden] { display: none; }
.auth-box {
  width: min(420px, calc(100vw - 28px));
  display: grid;
  gap: 10px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel2);
}
.auth-box h1 { margin: 0 0 8px; }
.auth-brand {
  display: grid;
  place-items: center;
  gap: 8px;
}
#authLogo {
  max-width: 96px;
  max-height: 96px;
  object-fit: contain;
}
.auth-lottie {
  width: 140px;
  height: 140px;
}
.auth-mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.auth-box input {
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0f131a;
  color: var(--text);
  padding: 0 12px;
}
.auth-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.player-shell {
  position: relative;
  min-width: 0;
  min-height: 0;
  background: #000;
  overflow: hidden;
}
canvas {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
}
.empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 10px;
  text-align: center;
  pointer-events: none;
}
.empty[hidden] { display: none; }
.empty-title { font-size: clamp(28px, 5vw, 72px); font-weight: 800; }
.empty-sub { color: var(--muted); font-size: clamp(14px, 2vw, 22px); }
.topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: linear-gradient(180deg, rgba(0,0,0,.75), transparent);
}
.brand-dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 22px rgba(239,68,68,.6);
}
.title {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-weight: 750;
}
.icon-btn, .control-btn, .primary-btn, .small-btn, .wide-btn, .tab, .item-actions button, .group-row button {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: rgba(255,255,255,.08);
  cursor: pointer;
}
.icon-btn {
  margin-left: auto;
  width: 42px;
  height: 38px;
}
.fs-menu-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 30;
  display: none;
}
.app.in-fullscreen .fs-menu-btn { display: block; }
.app.in-fullscreen #panelToggle { display: none; }
.controls {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(5,7,10,.82);
  backdrop-filter: blur(14px);
}
.controls.fs-hidden {
  opacity: 0;
  pointer-events: none;
}
.timeline-row {
  display: grid;
  grid-template-columns: 58px 1fr 58px;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
input[type="range"] { width: 100%; accent-color: var(--accent); }
.button-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.control-btn, .primary-btn, .select {
  min-height: 42px;
  padding: 0 14px;
}
.primary-btn {
  background: var(--accent);
  border-color: transparent;
  min-width: 110px;
  font-weight: 800;
}
.select {
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #12161d;
  color: var(--text);
}
.mini-range { max-width: 120px; }
.side {
  min-width: 0;
  min-height: 0;
  border-left: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  flex-direction: column;
}
.app.in-fullscreen .side {
  display: none;
}
.app.in-fullscreen .side.float-open {
  display: flex;
  position: fixed;
  right: 8px;
  top: 56px;
  width: min(360px, 92vw);
  max-height: calc(100vh - 64px);
  border: 1px solid var(--line);
  border-radius: 10px;
  z-index: 40;
  box-shadow: 0 8px 30px rgba(0,0,0,.45);
}
.app.side-collapsed .side {
  display: none;
}
.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
}
.tab { min-height: 38px; }
.tab.on { background: var(--accent); border-color: transparent; font-weight: 800; }
.tabpage {
  display: none;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
}
.tabpage.on { display: block; }
.list-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  color: var(--muted);
}
.small-btn { min-height: 32px; padding: 0 10px; }
.playlist { display: grid; gap: 8px; }
.item {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.045);
  cursor: pointer;
}
.item.on { border-color: var(--accent); background: rgba(239,68,68,.14); }
.mega-playlist-folder {
  margin: 6px 0 4px;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}
.item-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}
.item-meta { color: var(--muted); font-size: 12px; }
.item-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.item-actions button,
.group-row button {
  min-height: 30px;
  padding: 0 8px;
  font-size: 12px;
}
.danger {
  border-color: rgba(239,68,68,.7) !important;
  color: #fecaca !important;
}
.group-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}
.group-row {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.045);
}
.group-row div {
  display: flex;
  gap: 6px;
}
.drop {
  min-height: 180px;
  display: grid;
  place-items: center;
  border: 1px dashed rgba(255,255,255,.24);
  border-radius: 8px;
  background: rgba(255,255,255,.04);
  color: var(--muted);
  text-align: center;
  padding: 18px;
}
.drop input { display: none; }
.upload-progress {
  margin-top: 14px;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255,255,255,.12);
}
.upload-progress span {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--ok);
  transition: width .2s ease;
}
.muted { margin-top: 10px; color: var(--muted); }
.tabpage label {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  color: var(--muted);
}
.tabpage label select,
.tabpage label input {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #11161d;
  color: var(--text);
  padding: 0 10px;
}
.wide-btn {
  width: 100%;
  min-height: 44px;
  font-weight: 800;
  margin-bottom: 8px;
}
.wide-btn.secondary {
  background: rgba(255,255,255,.08);
  color: var(--text);
}
.groupbox {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 10px;
  background: rgba(255,255,255,.03);
}
.groupbox h3 {
  margin: 0 0 8px;
  font-size: 14px;
}
.mega-tree-head {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
}
.mega-tree-head .muted {
  margin: 0;
  font-size: 12px;
}
.mega-tree-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 6px;
  align-items: center;
}
.mega-tree-row .path {
  min-width: 0;
  overflow-wrap: anywhere;
  white-space: normal;
}
@media (max-width: 900px) {
  body { overflow: auto; }
  .app {
    min-height: 100vh;
    height: auto;
    grid-template-columns: 1fr;
    grid-template-rows: 62vh auto;
  }
  .side {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  .button-row { flex-wrap: wrap; }
  .tabs { grid-template-columns: repeat(2, 1fr); }
  .mega-tree-row {
    grid-template-columns: 1fr auto;
  }
  .mega-tree-row button.small-btn {
    min-height: 28px;
    padding: 0 8px;
  }
}
