:root {
  --bg: #fdf6e3;
  --card: #fffef9;
  --ink: #1a1a2e;
  --mild: #555570;
  --fade: #9999b0;
  --border: #1a1a2e;
  --red: #ff4d6a;
  --blue: #3b82f6;
  --yellow: #facc15;
  --green: #22c55e;
  --shadow: 4px 4px 0 #1a1a2e;
  --shadow-sm: 3px 3px 0 #1a1a2e;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "DM Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-image:
    radial-gradient(circle at 20% 80%, #ff4d6a12 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, #3b82f612 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, #facc1510 0%, transparent 50%);
}

.topbar {
  display: flex; align-items: center; gap: 0; padding: 12px 16px; flex-shrink: 0; flex-wrap: wrap;
}
.logo {
  font-size: 24px; font-weight: 900; letter-spacing: -1px;
  padding: 6px 14px; background: var(--yellow);
  border: 3px solid var(--border); box-shadow: var(--shadow-sm);
  margin-right: 12px; white-space: nowrap; text-decoration: none; color: inherit;
  user-select: none; cursor: pointer;
}
body.admin-mode .logo {
  box-shadow: 3px 3px 0 var(--red);
}
/* Hidden for guests; JS + body.admin-mode reveals */
.admin-only { display: none !important; }
body.admin-mode .top-tabs > button.admin-only,
body.admin-mode .rp-header .tools > button.admin-only {
  display: inline-block !important;
}
body.admin-mode .np-actions > button.admin-only.is-visible {
  display: inline-flex !important;
}
body.admin-mode .np-cache-badge.admin-only.is-on {
  display: inline-block !important;
}
body.admin-mode .pl-item .pl-cache.admin-only {
  display: flex !important;
}
.search-wrap { flex: 1; min-width: 180px; max-width: 520px; display: flex; }
.search-wrap input {
  flex: 1; border: 3px solid var(--border); border-right: none;
  padding: 10px 16px; font-size: 15px; font-weight: 600; background: var(--card); outline: none;
}
.search-wrap button {
  background: var(--blue); color: #fff; border: 3px solid var(--border);
  padding: 10px 20px; font-size: 15px; font-weight: 800; cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.search-wrap button:hover { transform: translate(-1px,-1px); }
.top-tabs { display: flex; gap: 0; margin-left: 10px; flex-wrap: wrap; }
.top-tabs button {
  background: var(--card); border: 3px solid var(--border);
  padding: 8px 12px; font-size: 13px; font-weight: 700; cursor: pointer; margin-left: -3px;
}
.top-tabs button:hover { background: var(--yellow); }
.top-tabs button.active { background: var(--ink); color: #fff; }

.main {
  flex: 1; display: flex; gap: 0; padding: 0 16px 10px;
  overflow: hidden; min-height: 0;
}
.left-player {
  width: 320px; flex-shrink: 0; border: 3px solid var(--border); border-right: none;
  background: var(--card); display: flex; flex-direction: column; align-items: center;
  padding: 24px 16px 16px; gap: 12px; overflow-y: auto;
}
.np-cover-wrap {
  width: 168px; height: 168px; position: relative;
  border: 5px solid var(--border); background: #f0ebe0; overflow: hidden; box-shadow: var(--shadow);
}
.np-cover-wrap .placeholder {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 52px; color: var(--fade);
}
.np-cover-wrap img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: none; z-index: 1;
}
.np-cover-wrap.has-cover .placeholder { display: none; }
.np-cover-wrap.has-cover img { display: block; }
.np-title { font-size: 18px; font-weight: 900; text-align: center; line-height: 1.25; word-break: break-word; max-width: 100%; }
.np-artist { font-size: 13px; font-weight: 600; color: var(--mild); text-align: center; }
.np-quality {
  font-size: 10px; font-weight: 800; padding: 3px 10px;
  border: 2px solid var(--border); background: var(--yellow); display: none;
}
.np-cache-badge {
  font-size: 10px; font-weight: 800; padding: 3px 10px;
  border: 2px solid var(--border); background: #bbf7d0; display: none;
}
.mini-badge {
  font-size: 10px; font-weight: 800; background: #bbf7d0;
  border: 1px solid var(--border); padding: 0 4px; margin-left: 4px;
}
.card-badge {
  position: absolute; left: 6px; top: 6px; font-size: 12px; z-index: 2;
}
.pl-cache {
  width: 28px; height: 28px; border: 2px solid transparent; background: transparent;
  font-size: 13px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  opacity: 0; color: var(--fade);
}
.pl-item:hover .pl-cache { opacity: 1; }
.pl-cache:hover { color: var(--green); border-color: var(--green); }
.np-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.np-actions button {
  padding: 6px 10px; border: 2px solid var(--border); background: var(--card);
  font-size: 11px; font-weight: 700; cursor: pointer; box-shadow: 2px 2px 0 var(--ink);
  display: none; align-items: center; gap: 3px;
}
.np-actions button:hover { background: var(--yellow); transform: translate(-1px,-1px); }
.np-controls { display: flex; gap: 8px; }
.np-controls button {
  width: 40px; height: 40px; border: 3px solid var(--border); background: var(--card);
  font-size: 16px; cursor: pointer; font-weight: bold; box-shadow: var(--shadow-sm);
  display: flex; align-items: center; justify-content: center;
}
.np-controls .play-btn { width: 50px; height: 50px; font-size: 20px; background: var(--red); color: #fff; }
.progress-wrap { width: 100%; display: flex; align-items: center; gap: 8px; }
.progress-wrap span {
  font-size: 10px; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--mild); min-width: 28px;
}
.prog-track { flex: 1; height: 10px; border: 3px solid var(--border); background: #f0ebe0; cursor: pointer; }
.prog-fill { height: 100%; background: var(--green); width: 0%; }
.vol-row { display: flex; align-items: center; gap: 8px; }
.vol-row button {
  width: 32px; height: 32px; border: 3px solid var(--border); background: var(--card);
  font-size: 13px; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.vol-row input { width: 90px; accent-color: var(--ink); }
.right-panel {
  flex: 1; min-width: 0; border: 3px solid var(--border); background: var(--card);
  display: flex; flex-direction: column; overflow: hidden;
}
.rp-header {
  padding: 10px 14px; border-bottom: 3px solid var(--border);
  font-weight: 800; font-size: 12px; letter-spacing: 1px; color: var(--mild);
  display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; gap: 8px;
}
.rp-header .tools { display: flex; gap: 6px; }
.rp-header .tools button {
  border: 2px solid var(--border); background: var(--card); padding: 4px 8px;
  font-size: 11px; font-weight: 700; cursor: pointer;
}
.rp-header .tools button:hover { background: var(--yellow); }
.rp-body { flex: 1; overflow-y: auto; }
.rp-body::-webkit-scrollbar { width: 8px; }
.rp-body::-webkit-scrollbar-thumb { background: var(--border); }

.card-grid {
  padding: 10px; display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 8px; align-content: start;
}
.card {
  background: var(--card); border: 3px solid var(--border); padding: 10px;
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  box-shadow: var(--shadow-sm); position: relative;
}
.card:hover { transform: translate(-2px,-2px); box-shadow: 5px 5px 0 var(--ink); }
.card:hover .card-dl { opacity: 1; }
.card.playing { background: var(--green); color: #fff; }
.card.playing .sub { color: rgba(255,255,255,.75); }
.card-dl {
  position: absolute; top: 6px; right: 6px; width: 26px; height: 26px;
  border: 2px solid var(--border); background: var(--card); font-size: 12px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  opacity: 0; z-index: 2;
}
.card .thumb-wrap {
  width: 44px; height: 44px; flex-shrink: 0; border: 3px solid var(--border);
  display: flex; align-items: center; justify-content: center; background: #f0ebe0;
  font-size: 20px; color: var(--fade); overflow: hidden;
}
.card .thumb-wrap img { width: 100%; height: 100%; object-fit: cover; }
.card .info { flex: 1; min-width: 0; padding-right: 4px; }
.card .info .title { font-weight: 800; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .info .sub { font-size: 11px; font-weight: 600; color: var(--mild); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }

.pl-item {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  border: 2px solid transparent; cursor: pointer; font-weight: 600; font-size: 13px;
}
.pl-item:hover { border-color: var(--border); background: #f8f5ec; }
.pl-item.active { background: var(--ink); color: #fff; }
.pl-item .idx { width: 24px; text-align: center; font-size: 11px; font-weight: 800; color: var(--fade); }
.pl-item.active .idx { color: var(--yellow); }
.pl-item .name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-dl, .pl-del {
  width: 28px; height: 28px; border: 2px solid transparent; background: transparent;
  font-size: 13px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  opacity: 0; color: var(--fade);
}
.pl-item:hover .pl-dl, .pl-item:hover .pl-del { opacity: 1; }
.pl-dl:hover { color: var(--blue); border-color: var(--blue); }
.pl-del:hover { color: var(--red); border-color: var(--red); }

.lyric-line { padding: 10px 0; transition: all .25s; }
.lyric-line .orig { font-size: 18px; color: var(--fade); line-height: 1.45; }
.lyric-line .tran { font-size: 13px; color: var(--fade); opacity: .45; margin-top: 3px; }
.lyric-line.active .orig { font-size: 24px; color: var(--ink); font-weight: 900; }
.lyric-line.active .tran { font-size: 15px; color: var(--mild); opacity: .7; }
.lyrics-pad { padding: 20px 24px 40px; }

.empty { text-align: center; padding: 50px 16px; color: var(--fade); font-weight: 700; }
.empty .icon { font-size: 36px; margin-bottom: 8px; }
.empty .hint { font-size: 12px; opacity: .65; margin-top: 6px; line-height: 1.5; }

.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; border: 3px solid var(--ink);
  box-shadow: var(--shadow); padding: 10px 22px; font-size: 13px; font-weight: 700;
  z-index: 100; opacity: 0; pointer-events: none; transition: opacity .25s; max-width: 90vw;
}
.toast.show { opacity: 1; }

.footer-link {
  position: fixed; right: 12px; bottom: 10px; font-size: 11px; font-weight: 700;
  color: var(--mild); text-decoration: none; opacity: .7; z-index: 50;
}
.footer-link:hover { opacity: 1; color: var(--ink); }

@media (max-width: 860px) {
  body { overflow: auto; height: auto; min-height: 100%; }
  .main { flex-direction: column; height: auto; overflow: visible; padding-bottom: 20px; }
  .left-player {
    width: 100%; border-right: 3px solid var(--border); border-bottom: none;
    flex-direction: row; flex-wrap: wrap; justify-content: center; max-height: none;
  }
  .right-panel { min-height: 50vh; border-top: none; }
  .np-cover-wrap { width: 120px; height: 120px; }
}

/* embed mini */
.embed-body {
  margin: 0; min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg); font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
}
.embed-card {
  width: min(420px, 94vw); border: 3px solid var(--border); background: var(--card);
  box-shadow: var(--shadow); padding: 16px; display: flex; gap: 12px; align-items: center;
}
.embed-card img {
  width: 72px; height: 72px; object-fit: cover; border: 3px solid var(--border); flex-shrink: 0;
}
.embed-meta { flex: 1; min-width: 0; }
.embed-meta .t { font-weight: 900; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.embed-meta .a { font-size: 12px; color: var(--mild); margin-top: 2px; }
.embed-meta .controls { display: flex; gap: 8px; margin-top: 10px; align-items: center; }
.embed-meta button {
  border: 2px solid var(--border); background: var(--red); color: #fff;
  font-weight: 800; padding: 6px 12px; cursor: pointer;
}
.embed-meta a { font-size: 11px; font-weight: 700; color: var(--blue); }
