:root {
  --bg: #161616;
  --bg-soft: #1c1c1e;
  --panel: #222226;
  --panel-hover: #2a2a2f;
  --line: #333338;
  --text: #f5f5f7;
  --text-2: #a1a1a6;
  --text-3: #6e6e73;
  --accent: #fa2d48;
  --accent-soft: rgba(250, 45, 72, 0.12);
  --radius: 10px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  --sidebar-w: 232px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

::selection { background: var(--accent); color: #fff; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #3a3a40; border-radius: 5px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

.app { display: flex; height: 100%; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: linear-gradient(180deg, #1a1a1c 0%, var(--bg) 100%);
  border-right: 1px solid var(--line);
  padding: 22px 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  overflow-y: auto;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
}
.logo-badge {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, #ff2d55, #b3002d);
  color: #fff;
  font-weight: 800;
  font-size: 19px;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 14px rgba(250, 45, 72, 0.45);
}
.logo-text { font-size: 20px; font-weight: 700; letter-spacing: 0.2px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--text-2);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, color 0.15s;
}
.nav-item svg { width: 19px; height: 19px; flex: 0 0 19px; }
.nav-item:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.nav-item.active { color: #fff; background: rgba(255, 255, 255, 0.09); }
.nav-count {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-3);
  background: rgba(255, 255, 255, 0.07);
  border-radius: 999px;
  padding: 2px 8px;
}

.divider { height: 1px; background: var(--line); margin: 0 8px; }
.side-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-3);
  padding: 0 10px;
}
.chips { flex-direction: row; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid transparent;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s;
}
.chip:hover { color: var(--text); background: rgba(255, 255, 255, 0.09); }
.chip.active {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 3px 12px rgba(250, 45, 72, 0.35);
}

.side-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 10px 2px;
  color: var(--text-3);
  font-size: 11px;
  border-top: 1px solid var(--line);
}
.side-foot svg { width: 14px; height: 14px; flex: 0 0 14px; }

.scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 35;
}

/* ---------- Main ---------- */
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 28px;
  background: rgba(22, 22, 22, 0.78);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid transparent;
}
.topbar.scrolled { border-bottom-color: var(--line); }

.title {
  font-size: 22px;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: 0.2px;
}

.icon-btn {
  width: 34px; height: 34px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.08); color: var(--text); }
.icon-btn svg { width: 19px; height: 19px; }
#sidebarToggle { display: none; }

.search {
  flex: 1;
  max-width: 420px;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 9px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  height: 38px;
  transition: border-color 0.15s, background 0.15s;
}
.search:focus-within {
  border-color: rgba(250, 45, 72, 0.55);
  background: rgba(255, 255, 255, 0.08);
}
.search svg { width: 16px; height: 16px; color: var(--text-3); flex: 0 0 16px; }
.search input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
}
.search input::placeholder { color: var(--text-3); }

.btn-upload {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 18px;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(250, 45, 72, 0.35);
  transition: transform 0.12s, filter 0.12s;
  white-space: nowrap;
}
.btn-upload:hover { filter: brightness(1.1); }
.btn-upload:active { transform: scale(0.97); }
.btn-upload svg { width: 17px; height: 17px; }

.content {
  flex: 1;
  overflow-y: auto;
  padding: 26px 28px 110px;
}

/* ---------- Grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 18px;
}

.card {
  min-width: 0;
  cursor: pointer;
  transition: transform 0.18s ease;
}
.card:hover { transform: translateY(-3px); }

.cover {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}
.cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease, filter 0.25s ease;
}
.card:hover .cover img { transform: scale(1.05); filter: brightness(0.6); }

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.5), transparent 55%);
}
.card:hover .overlay { opacity: 1; }

.play {
  width: 52px; height: 52px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}
.play:hover { background: var(--accent); transform: scale(1.06); }
.play svg { width: 22px; height: 22px; margin-left: 2px; }

.quick {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: flex;
  gap: 7px;
}
.q-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.15s;
}
.q-btn:hover { background: var(--accent); }
.q-btn svg { width: 15px; height: 15px; }

.meta { padding: 9px 4px 0; min-width: 0; }
.meta .name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.meta .sub {
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* skeleton */
.skeleton .card .cover { background: linear-gradient(100deg, #1e1e20 40%, #26262a 50%, #1e1e20 60%); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Empty ---------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 90px 20px;
  color: var(--text-3);
  text-align: center;
}
.empty svg { width: 64px; height: 64px; opacity: 0.5; }
.empty h3 { font-size: 17px; font-weight: 600; color: var(--text-2); }
.empty p { font-size: 13px; }

/* ---------- Now playing bar ---------- */
.now-bar {
  position: fixed;
  left: var(--sidebar-w);
  right: 0;
  bottom: 0;
  z-index: 30;
  height: 70px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 28px;
  background: rgba(30, 30, 33, 0.85);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  border-top: 1px solid var(--line);
}
.now-thumb {
  width: 46px; height: 46px;
  border-radius: 8px;
  object-fit: cover;
  box-shadow: var(--shadow);
  flex: 0 0 46px;
}
.now-meta { min-width: 0; flex: 1; }
.now-name {
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.now-sub { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }

.btn-ghost {
  height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.1); border-color: #4a4a52; }
.btn-danger {
  height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(250, 45, 72, 0.4);
  background: rgba(250, 45, 72, 0.08);
  color: #ff6b7f;
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-danger:hover { background: rgba(250, 45, 72, 0.2); }

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 70px 90px 120px;
}
.lb-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.6);
  animation: lb-in 0.25s ease;
}
@keyframes lb-in { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }

.lb-btn {
  position: absolute;
  width: 42px; height: 42px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.15s;
  z-index: 2;
}
.lb-btn:hover { background: rgba(250, 45, 72, 0.85); }
.lb-btn svg { width: 20px; height: 20px; }
.lb-close { top: 22px; right: 26px; }
.lb-prev { left: 22px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 22px; top: 50%; transform: translateY(-50%); }

.lb-bar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 26px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.75), transparent);
}
.lb-meta { flex: 1; min-width: 0; }
.lb-meta b {
  display: block;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lb-meta span { font-size: 12px; color: var(--text-3); }
.lb-actions { display: flex; gap: 10px; }

/* ---------- Modal / upload ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-card {
  width: 460px;
  max-width: 100%;
  max-height: 86vh;
  overflow-y: auto;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
  box-shadow: var(--shadow);
  animation: lb-in 0.22s ease;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal-head h2 { font-size: 19px; font-weight: 700; }

.key-row {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 14px;
}
.key-row span { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.key-row input {
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
  padding: 0 13px;
  outline: none;
  transition: border-color 0.15s;
}
.key-row input:focus { border-color: rgba(250, 45, 72, 0.6); }

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 34px 20px;
  border: 1.5px dashed #45454d;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.18s;
  text-align: center;
}
.dropzone svg { width: 40px; height: 40px; color: var(--text-3); }
.dropzone p { font-size: 14px; font-weight: 600; }
.drop-hint { font-size: 11.5px; color: var(--text-3); }
.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dropzone.dragover svg, .dropzone:hover svg { color: var(--accent); }

.upload-list { margin-top: 14px; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.upload-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  padding: 9px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
}
.upload-list .u-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-list .u-status { color: var(--text-3); white-space: nowrap; }
.upload-list .u-status.ok { color: #34c759; }
.upload-list .u-status.fail { color: #ff6b7f; }
.upload-list .u-bar { width: 60px; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.upload-list .u-bar i { display: block; height: 100%; background: var(--accent); transition: width 0.3s; }

/* ---------- Dialog ---------- */
.dialog {
  position: fixed;
  inset: 0;
  z-index: 65;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.dialog-card {
  width: 400px;
  max-width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
  box-shadow: var(--shadow);
  animation: lb-in 0.2s ease;
}
.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.dialog-head h3 { font-size: 17px; font-weight: 700; }
.dialog-msg {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-2);
  word-break: break-all;
}
.dialog .key-row { margin-top: 14px; margin-bottom: 0; }
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}
.dialog-actions .btn-upload { height: 34px; padding: 0 18px; font-size: 13px; }
.dialog-actions .btn-danger {
  height: 34px;
  padding: 0 18px;
  font-size: 13px;
  background: var(--accent);
  border: none;
  color: #fff;
  box-shadow: 0 4px 16px rgba(250, 45, 72, 0.35);
}
.dialog-actions .btn-danger:hover { filter: brightness(1.1); background: var(--accent); }

.admin-nav { border-top: 1px solid var(--line); padding-top: 10px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%) translateY(10px);
  z-index: 70;
  background: rgba(40, 40, 44, 0.92);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  max-width: 80vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { background: rgba(30, 130, 60, 0.92); }
.toast.err { background: rgba(160, 30, 50, 0.95); }

.hidden { display: none !important; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.25s ease; }
  .sidebar.open { transform: translateX(0); }
  .scrim.show { display: block; }
  #sidebarToggle { display: grid; }
  .main { margin-left: 0; }
  .now-bar { left: 0; }
  .lightbox { padding: 60px 50px 110px; }
  .lb-prev { left: 8px; }
  .lb-next { right: 8px; }
}
@media (max-width: 600px) {
  .topbar { padding: 12px 14px; }
  .search { max-width: none; }
  .btn-upload span { display: none; }
  .btn-upload { padding: 0 13px; }
  .content { padding: 18px 14px 100px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
  .now-bar { padding: 0 14px; }
  .now-bar .btn-ghost { display: none; }
}
