:root {
  --bg: #0f1115;
  --card: #1a1d24;
  --card-2: #22262f;
  --text: #e6e8ec;
  --muted: #8b909b;
  --accent: #4f8cff;
  --accent-2: #3a6fd6;
  --ok: #3fb950;
  --err: #f06262;
  --border: #2c313b;
  --track-bg: #3a3f4b;
  --player-h: 78px;
  --topbar-h: 56px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; width: 100%; max-width: 100%; overflow-x: clip; }
body {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }

button {
  background: var(--accent); color: #fff; border: none;
  padding: 11px 18px; border-radius: 8px; font-size: 14px; font-weight: 600;
  cursor: pointer; min-height: 42px;
}
button:hover { background: var(--accent-2); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
input[type="text"], input[type="password"], input[type="email"] {
  background: var(--card-2); border: 1px solid var(--border); color: var(--text);
  padding: 11px 13px; border-radius: 8px; font-size: 15px; outline: none; width: 100%;
  min-height: 42px;
}
input:focus { border-color: var(--accent); }
.stack { display: flex; flex-direction: column; gap: 8px; }

/* ===== Icons ===== */
button, .save { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.ico { width: 20px; height: 20px; display: block; flex-shrink: 0; }
.btn-wide { width: 100%; }
.brand { color: var(--accent); }
.brand .ico { width: 24px; height: 24px; }
.auth-logo { color: var(--accent); display: flex; justify-content: center; }
.auth-logo .ico { width: 44px; height: 44px; }
.tab .ico { width: 22px; height: 22px; }
.row-actions .icon-btn, .del-btn.icon-btn { width: 38px; height: 38px; padding: 0; }
.pl-icon .ico { width: 26px; height: 26px; color: var(--accent); }
.chev .ico { width: 20px; height: 20px; }
.vol-icon { display: inline-flex; color: var(--muted); }
.vol-icon .ico { width: 18px; height: 18px; }

/* ===== Auth ===== */
.auth-view { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card {
  width: 100%; max-width: 360px; background: var(--card);
  border: 1px solid var(--border); border-radius: 16px; padding: 28px 24px;
  display: flex; flex-direction: column; gap: 12px; text-align: center;
}
.auth-logo { font-size: 40px; }
.auth-card h1 { margin: 0; font-size: 22px; }
.auth-card input { text-align: left; }
.auth-error { background: #3a1e1e; color: var(--err); border-radius: 8px; padding: 8px 12px; font-size: 13px; }
.auth-toggle { font-size: 13px; color: var(--muted); margin: 4px 0 0; }
.auth-toggle a { color: var(--accent); cursor: pointer; }

/* ===== Top bar / tabs ===== */
.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--topbar-h); display: flex; align-items: center; gap: 12px;
  padding: 0 16px; background: #12141a; border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 16px; white-space: nowrap; }
.brand span { display: none; }
.tabs { display: flex; gap: 4px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: 0 0 auto; }
.tab {
  background: transparent; color: var(--muted); border: none; font-weight: 600;
  padding: 8px 12px; border-radius: 8px; min-height: 38px;
}
.tab.active { color: var(--text); background: var(--card-2); }
.user-box { display: flex; align-items: center; gap: 8px; }
.user-box #who { white-space: nowrap; max-width: 90px; overflow: hidden; text-overflow: ellipsis; }
.user-box .ghost { padding: 7px 12px; min-height: 38px; }

main { max-width: 880px; margin: 0 auto; padding: 16px; }
body.has-player main { padding-bottom: calc(var(--player-h) + 16px); }

.searchbar { display: flex; gap: 8px; }
.searchbar input { flex: 1; min-width: 0; }
.searchbar button { flex: 0 0 auto; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.card h3 { margin: 0 0 8px; font-size: 15px; }
.note { text-align: center; }

/* ===== Home / Dashboard ===== */
.hero {
  position: relative; overflow: hidden; border-radius: 20px;
  padding: 44px 22px 36px; margin-bottom: 22px; text-align: center;
  border: 1px solid var(--border);
}
.hero-bg {
  position: absolute; inset: 0;
  background: linear-gradient(120deg, #1b2a4a, #3a1f5d, #123b46, #2a1f5d, #1b2a4a);
  background-size: 320% 320%; animation: heroShift 20s ease infinite;
}
@keyframes heroShift { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }
.hero-orb { position: absolute; border-radius: 50%; filter: blur(36px); opacity: .55; pointer-events: none; }
.orb1 { width: 220px; height: 220px; background: #4f8cff; top: -70px; right: -50px; animation: float 9s ease-in-out infinite; }
.orb2 { width: 180px; height: 180px; background: #b14ad8; bottom: -70px; left: -40px; animation: float 11s ease-in-out infinite reverse; }
.hero-content { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.hero-icon { color: #fff; animation: float 4s ease-in-out infinite; }
.hero-icon .ico { width: 46px; height: 46px; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
.hero h2 { margin: 0; font-size: 26px; color: #fff; }
.hero #home-sub { color: rgba(255,255,255,.7); }
.hero-search { position: relative; width: 100%; max-width: 480px; margin-top: 6px; }
.hero-search input {
  width: 100%; height: 50px; padding: 0 18px 0 44px; border-radius: 999px;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.22); color: #fff;
  transition: box-shadow .2s, background .2s, border-color .2s;
}
.hero-search input::placeholder { color: rgba(255,255,255,.6); }
.hero-search input:focus { background: rgba(255,255,255,.18); border-color: var(--accent); box-shadow: 0 0 0 4px rgba(79,140,255,.3); }
.hero-search-ico { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: rgba(255,255,255,.8); display: inline-flex; }
.hero-search-ico .ico { width: 20px; height: 20px; }
.home-stats { display: flex; gap: 10px; margin-top: 4px; flex-wrap: wrap; justify-content: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.2); color: #fff; padding: 5px 12px; border-radius: 999px; font-size: 13px; }
.chip .ico { width: 15px; height: 15px; }

.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 28px; }
.tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: 22px 12px; background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  cursor: pointer; color: var(--text); opacity: 0; animation: rise .5s ease forwards;
  animation-delay: calc(var(--d, 1) * .08s);
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.tile:hover { transform: translateY(-4px); border-color: var(--accent); background: var(--card-2); box-shadow: 0 12px 28px rgba(0,0,0,.35); }
.tile-ico { color: var(--accent); display: inline-flex; }
.tile-ico .ico { width: 30px; height: 30px; }
.tile-label { font-weight: 600; font-size: 14px; }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }

.home-recent .section-title { margin: 0 0 12px; }
.recent-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.recent-card {
  text-align: left; align-items: stretch; background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 10px; cursor: pointer; color: var(--text); display: flex; flex-direction: column; gap: 6px;
  opacity: 0; animation: rise .5s ease forwards; animation-delay: calc(var(--d, 1) * .06s);
  transition: transform .18s ease, border-color .18s ease;
}
.recent-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.recent-cover-wrap { position: relative; }
.recent-cover { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 8px; background: #000; display: block; }
.recent-play { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.4); border-radius: 8px; color: #fff; opacity: 0; transition: opacity .2s; }
.recent-card:hover .recent-play { opacity: 1; }
.recent-play .ico { width: 36px; height: 36px; }
.recent-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-sub { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (prefers-reduced-motion: reduce) {
  .hero-bg, .hero-orb, .hero-icon, .tile, .recent-card { animation: none; opacity: 1; }
}

/* ===== Rows (results + library) ===== */
.list { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.row {
  display: flex; align-items: center; gap: 12px;
  background: var(--card-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 10px;
}
.row.playing { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; background: #000; flex-shrink: 0; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.add-btn { white-space: nowrap; }
.row-actions { display: flex; align-items: center; gap: 8px; }
.play-btn { width: 40px; height: 40px; min-height: 40px; border-radius: 50%; padding: 0; font-size: 15px; }
.save { font-size: 18px; color: var(--accent); text-decoration: none; padding: 4px; }
.del-btn { padding: 6px 10px; min-height: 38px; }
.mini-bar { width: 90px; height: 7px; background: var(--card); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.mini-bar > div { height: 100%; background: var(--accent); transition: width .3s; }
.dl-pct { min-width: 32px; text-align: right; }

.users .user-line { padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 14px; color: var(--text); }
.badge { background: var(--card-2); border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px; font-size: 11px; color: var(--muted); }
.scan-progress { margin-top: 10px; min-height: 18px; }

/* ===== Player ===== */
.player {
  position: fixed; left: 0; right: 0; bottom: 0; height: var(--player-h);
  display: flex; align-items: center; gap: 16px; padding: 0 16px;
  background: rgba(18,20,26,.97); backdrop-filter: blur(10px);
  border-top: 1px solid var(--border); z-index: 50;
  padding-bottom: env(safe-area-inset-bottom);
}
.player-now { display: flex; align-items: center; gap: 12px; width: 230px; min-width: 0; }
.player-thumb { width: 52px; height: 52px; border-radius: 6px; object-fit: cover; background: #000; flex-shrink: 0; }
.player-meta { min-width: 0; }
.player-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-artist { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-center { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; max-width: 620px; margin: 0 auto; }
.player-controls { display: flex; align-items: center; gap: 14px; }
.icon-btn { background: transparent; color: var(--text); border: none; padding: 0; width: 38px; height: 38px; min-height: 38px; font-size: 18px; cursor: pointer; border-radius: 50%; }
.icon-btn:hover { background: transparent; color: var(--accent); }
.icon-btn.play { background: var(--accent); color: #fff; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; font-size: 16px; }
.icon-btn.play:hover { background: var(--accent-2); }
.player-seek { display: flex; align-items: center; gap: 10px; width: 100%; }
.time { font-size: 12px; color: var(--muted); width: 38px; text-align: center; flex-shrink: 0; }
.player-right { display: flex; align-items: center; gap: 8px; width: 150px; justify-content: flex-end; }

input[type="range"] {
  -webkit-appearance: none; appearance: none; height: 6px; border-radius: 999px;
  background: var(--track-bg); outline: none; cursor: pointer; margin: 0; min-height: 0;
}
.player-seek input[type="range"] { flex: 1; min-width: 0; }
.player-right input[type="range"] { width: 90px; }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; border: none; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.5);
}
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: none; }

/* ===== Track ⋮ menu + toast ===== */
.menu-btn { width: 38px; padding: 0; font-size: 20px; line-height: 1; }
.menu {
  position: fixed; z-index: 100; min-width: 210px; max-width: calc(100vw - 16px); max-height: 60vh; overflow: auto;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 6px; box-shadow: 0 10px 30px rgba(0,0,0,.55);
  display: flex; flex-direction: column; gap: 2px;
}
.menu-label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 6px 10px 2px; }
.menu-sep { height: 1px; background: var(--border); margin: 4px 2px; }
.menu-item {
  background: transparent; color: var(--text); border: none;
  padding: 10px; border-radius: 6px; font-weight: 500; font-size: 14px; min-height: 40px;
  display: flex; align-items: center; justify-content: flex-start; gap: 10px;
}
.menu-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item .ico { width: 16px; height: 16px; color: var(--muted); }
.menu-item:hover { background: var(--card-2); }

#toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--player-h) + 18px); z-index: 200;
  background: var(--card-2); border: 1px solid var(--border); color: var(--text);
  padding: 10px 16px; border-radius: 10px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
#toast.show { opacity: 1; }

/* ===== Playlists ===== */
.playlist-row { cursor: pointer; }
.playlist-row:hover { border-color: var(--accent); }
.pl-icon { width: 56px; height: 56px; border-radius: 6px; background: var(--card); display: flex; align-items: center; justify-content: center; font-size: 24px; flex-shrink: 0; }
.chev { color: var(--muted); font-size: 22px; padding-right: 4px; }
.pl-detail-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.pl-detail-head h3 { flex: 1; min-width: 0; margin: 0; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ghost.danger { border-color: var(--err); color: var(--err); }

/* ===== Segmented control / library modes ===== */
.segmented { display: inline-flex; background: var(--card-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; margin-bottom: 14px; gap: 2px; }
.seg { background: transparent; color: var(--muted); border: none; padding: 7px 16px; border-radius: 8px; font-size: 13px; min-height: 36px; }
.seg.active { background: var(--accent); color: #fff; }

/* ===== Albums grid ===== */
.albums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.album-card { text-align: left; align-items: stretch; background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 10px; cursor: pointer; color: var(--text); display: flex; flex-direction: column; gap: 6px; transition: transform .18s, border-color .18s; }
.album-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.album-cover-wrap { position: relative; }
.album-cover { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 8px; background: #000; display: block; }
.album-card:hover .recent-play { opacity: 1; }
.album-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.album-artist { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-cover { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; background: #000; flex-shrink: 0; }

/* ===== Favorites mark ===== */
.like-mark { display: inline-flex; align-items: center; color: var(--accent); }
.like-mark .ico { width: 16px; height: 16px; }

/* ===== Force-password banner ===== */
.force-pw { display: flex; align-items: center; gap: 8px; background: #3a2e16; color: #f0c674; border-bottom: 1px solid var(--border); padding: 8px 16px; font-size: 13px; }
.force-pw [data-icon] { display: inline-flex; }
.force-pw .ico { width: 16px; height: 16px; }
.force-pw a { color: #fff; cursor: pointer; text-decoration: underline; margin-left: auto; }

/* ===== Search history ===== */
.search-history { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 12px 0 0; }
.hist-chip { background: var(--card-2); border: 1px solid var(--border); color: var(--text); padding: 6px 12px; border-radius: 999px; font-size: 13px; min-height: 34px; }
.hist-chip:hover { border-color: var(--accent); background: var(--card); }

/* ===== Admin proxy ===== */
.proxy-line { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.ghost.small { padding: 6px 12px; min-height: 34px; font-size: 13px; }
.badge.ok { color: var(--ok); border-color: var(--ok); }
.badge.bad { color: var(--err); border-color: var(--err); }

/* ===== Player extra controls ===== */
.icon-btn.ctrl-sm { width: 32px; height: 32px; color: var(--muted); }
.icon-btn.ctrl-sm:hover { color: var(--text); }
.icon-btn.ctrl-sm.active { color: var(--accent); }
.icon-btn.ctrl-sm.one { position: relative; }
.icon-btn.ctrl-sm.one::after { content: "1"; position: absolute; top: 0; right: 0; font-size: 9px; font-weight: 700; background: var(--accent); color: #fff; border-radius: 50%; width: 12px; height: 12px; display: flex; align-items: center; justify-content: center; }

/* ===== Full-screen Now Playing ===== */
.now-playing {
  position: fixed; inset: 0; z-index: 80;
  background: linear-gradient(180deg, #1c2030 0%, var(--bg) 70%);
  display: flex; flex-direction: column; align-items: center;
  padding: 14px 20px calc(22px + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform .32s cubic-bezier(.4, 0, .2, 1);
  pointer-events: none;
}
.now-playing.open { transform: translateY(0); pointer-events: auto; }
.np-header { width: 100%; max-width: 520px; display: flex; align-items: center; justify-content: space-between; }
.np-head-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.np-head-spacer { width: 38px; }
.np-art-wrap { flex: 1; display: flex; align-items: center; justify-content: center; width: 100%; padding: 18px 0; min-height: 0; }
.np-art { width: min(78vw, 360px); height: min(78vw, 360px); max-height: 46vh; object-fit: cover; border-radius: 16px; background: #000; box-shadow: 0 20px 50px rgba(0, 0, 0, .5); }
.np-meta { width: 100%; max-width: 520px; text-align: center; }
.np-title { font-size: 20px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-artist { font-size: 14px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-seek { width: 100%; max-width: 520px; display: flex; align-items: center; gap: 10px; margin-top: 18px; }
.np-seek input[type="range"] { flex: 1; min-width: 0; }
.np-controls { display: flex; align-items: center; justify-content: center; gap: 22px; margin-top: 18px; }
.icon-btn.play.big { width: 64px; height: 64px; font-size: 22px; }
.icon-btn.play.big .ico { width: 28px; height: 28px; }
.player-now { cursor: pointer; }

/* Artist cards (circular covers) */
.artist-card { align-items: center; text-align: center; }
.artist-cover { border-radius: 50%; aspect-ratio: 1 / 1; }

/* ===== Mobile ===== */
@media (min-width: 620px) { .brand span { display: inline; } }
@media (max-width: 620px) {
  .player { gap: 8px; padding: 0 10px; }
  .player-now { width: auto; flex: 0 1 auto; min-width: 0; }
  .player-title, .player-artist { max-width: 92px; }
  .player-right { display: none; }
  .player-center { max-width: none; flex: 1 1 auto; }
  .player-controls { gap: 10px; }
  .player-thumb { width: 46px; height: 46px; }
  .user-box #who { display: none; }
  main { padding: 12px; }
  .topbar { gap: 6px; padding: 0 10px; }
  .brand { display: none; }
  .tabs { gap: 2px; justify-content: space-between; }
  .tab { padding: 8px 7px; }
  .tab .ico { width: 20px; height: 20px; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .recent-grid { grid-template-columns: repeat(2, 1fr); }
  .hero { padding: 32px 16px 28px; }
  .hero h2 { font-size: 22px; }
  .row { gap: 8px; padding: 8px; }
  .thumb { width: 48px; height: 48px; }
  .row-actions { gap: 4px; }
  .row-actions .icon-btn, .del-btn.icon-btn { width: 34px; height: 34px; }
  .albums { grid-template-columns: repeat(2, 1fr); }
  .player-controls .ctrl-sm { display: none; }
  .segmented { display: flex; width: 100%; }
  .seg { flex: 1; }
}
@media (max-width: 380px) {
  .add-btn { padding: 10px 10px; }
}
