:root {
  --bg: #14161b;
  --panel: #1c1f26;
  --panel-2: #262a33;
  --text: #eceef2;
  --muted: #9aa1ae;
  --accent: #7f93ff;
  --on-accent: #10131c;
  --line: #2b303a;
  --danger: #ff8a8a;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f7f9;
    --panel: #ffffff;
    --panel-2: #e9ebf0;
    --text: #1a1d24;
    --muted: #5d6573;
    --accent: #4458d8;
    --on-accent: #ffffff;
    --line: #dde0e7;
    --danger: #b3261e;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
body.noscroll { overflow: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
ul { list-style: none; margin: 0; padding: 0; }
h1, h2, h3 { margin: 0; }
.muted { color: var(--muted); }
.pad { padding: 12px 16px; }
.error { color: var(--danger); }

#app {
  max-width: 720px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}
#app.has-mini #main { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
#main { padding-bottom: env(safe-area-inset-bottom); }

/* top bar */
#topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 4px;
  min-height: 56px;
  padding: env(safe-area-inset-top) 4px 0 8px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
#title {
  flex: 1; min-width: 0;
  font-size: 1.15rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  padding-left: 8px;
}
#btn-back + #title { padding-left: 0; }
.tag {
  font-size: 0.75rem; padding: 2px 8px; border-radius: 99px;
  background: var(--panel-2); color: var(--muted);
}
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: 100%; z-index: 20;
  min-width: 210px; padding: 6px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.menu button { display: block; width: 100%; min-height: 48px; padding: 0 14px; text-align: left; border-radius: 8px; }
.menu button:hover { background: var(--panel-2); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 48px; height: 48px; min-width: 44px; flex: none;
  border-radius: 50%;
  color: var(--text);
}
.icon-btn:hover { background: var(--panel-2); }
.icon-btn.active { color: var(--accent); }
.icon-btn svg { display: block; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 0 22px; border-radius: 24px;
  background: var(--panel-2); color: var(--text);
  text-decoration: none; font-weight: 600;
}
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn:disabled { opacity: 0.6; }

.center-screen {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; text-align: center; min-height: 70vh; padding: 24px;
}
.logo { border-radius: 22px; }

.actions { display: flex; gap: 10px; padding: 14px 16px 6px; flex-wrap: wrap; }

/* lists */
.list { padding: 6px 0; }
.row {
  display: flex; align-items: center;
  min-height: 56px; padding-right: 4px;
  border-bottom: 1px solid var(--line);
}
.row-main {
  flex: 1; min-width: 0; min-height: 56px;
  display: flex; align-items: center; gap: 14px;
  padding: 6px 8px 6px 16px; text-align: left;
}
.row-icon { color: var(--muted); display: inline-flex; flex: none; }
.row-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.row-text:not(:has(.t1)) { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t1, .t2 { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t2 { font-size: 0.85rem; color: var(--muted); }
.t2:empty { display: none; }
.row.playing .t1 { color: var(--accent); font-weight: 600; }
.row.playing .row-icon { color: var(--accent); }

/* mini player */
#mini {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 8;
  max-width: 720px; margin: 0 auto;
  display: flex; align-items: center; gap: 2px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom)) calc(8px + env(safe-area-inset-left));
  background: var(--panel); border-top: 1px solid var(--line);
}
.mini-info { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; min-height: 56px; text-align: left; }
.mini-info img { width: 48px; height: 48px; border-radius: 6px; object-fit: cover; background: var(--panel-2); flex: none; }
.mini-text { display: flex; flex-direction: column; min-width: 0; }
#mini-bar { position: absolute; left: 0; right: 0; top: -1px; height: 2px; background: transparent; }
#mini-fill { height: 100%; width: 0; background: var(--accent); }

/* full player */
#full {
  position: fixed; inset: 0; z-index: 10;
  background: var(--bg);
  display: flex; flex-direction: column;
  max-width: 720px; margin: 0 auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.full-top { display: flex; align-items: center; gap: 8px; padding: 4px 8px; flex: none; }
.full-label { color: var(--muted); font-size: 0.9rem; }
.full-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 0 20px 24px; }
#full-art {
  display: block; width: min(100%, 360px, 48vh); aspect-ratio: 1; object-fit: cover;
  margin: 8px auto 18px; border-radius: 12px; background: var(--panel-2);
}
.full-meta { text-align: center; margin-bottom: 14px; }
.ft { font-size: 1.3rem; font-weight: 600; overflow-wrap: anywhere; }
.fa { color: var(--text); overflow-wrap: anywhere; }
.fa.muted { color: var(--muted); font-size: 0.9rem; }
.seek input[type=range] { width: 100%; height: 44px; margin: 0; accent-color: var(--accent); background: transparent; }
.times { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; margin-top: -6px; }
.controls { display: flex; align-items: center; justify-content: space-between; max-width: 420px; margin: 8px auto 20px; }
.icon-btn.big { width: 56px; height: 56px; }
.icon-btn.big svg { width: 32px; height: 32px; }
.icon-btn.play-big { width: 68px; height: 68px; background: var(--accent); color: var(--on-accent); }
.icon-btn.play-big:hover { background: var(--accent); }
.icon-btn.play-big svg { width: 36px; height: 36px; }
#full-repeat { position: relative; }
#full-repeat[data-state='one']::after {
  content: '1'; position: absolute; font-size: 0.65rem; font-weight: 700; top: 12px; right: 12px; color: var(--accent);
}
.queue-title { font-size: 1rem; color: var(--muted); font-weight: 600; padding: 8px 0 0; }
#queue-list .row-main { padding-left: 4px; }

/* options sheet */
#sheet-backdrop {
  position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, 0.5);
  display: flex; align-items: flex-end; justify-content: center;
}
#sheet {
  width: 100%; max-width: 720px; background: var(--panel);
  border-radius: 16px 16px 0 0; padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
}
.sheet-title { padding: 10px 14px; color: var(--muted); font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#sheet button { display: block; width: 100%; min-height: 52px; padding: 0 14px; text-align: left; border-radius: 10px; }
#sheet button:hover { background: var(--panel-2); }

#toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 40;
  bottom: calc(96px + env(safe-area-inset-bottom));
  background: var(--panel-2); color: var(--text);
  padding: 10px 16px; border-radius: 99px; font-size: 0.9rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

@media (min-width: 760px) {
  #app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
  #full, #mini { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}
