:root {
  --bg: #0f1226;
  --bg-elev: #191d38;
  --bg-card: #1c2142;
  --text: #eef0fb;
  --text-dim: #a3a8cc;
  --accent: #6c7bff;
  --accent-2: #ff7bd5;
  --border: #2a2f55;
  --shadow: 0 8px 30px rgba(0,0,0,.45);
}
:root[data-theme="light"] {
  --bg: #f5f6fb;
  --bg-elev: #ffffff;
  --bg-card: #ffffff;
  --text: #14162b;
  --text-dim: #5a5f7d;
  --accent: #4a5bff;
  --accent-2: #d63daf;
  --border: #e3e5f0;
  --shadow: 0 6px 20px rgba(40,45,90,.12);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 128px;
  transition: background .25s, color .25s;
  min-height: 100vh;
}

.app-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: env(safe-area-inset-top) 16px 12px;
  padding-top: max(12px, env(safe-area-inset-top));
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { font-size: 24px; }
.app-header h1 { font-size: 20px; margin: 0; font-weight: 700; letter-spacing: -.02em; }
.theme-toggle {
  background: var(--bg-elev); border: 1px solid var(--border); color: var(--text);
  width: 40px; height: 40px; border-radius: 12px; font-size: 18px; cursor: pointer;
}

.tabs {
  display: flex; gap: 8px; padding: 12px 16px; overflow-x: auto;
  position: sticky; top: 61px; z-index: 15; background: var(--bg);
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto; padding: 8px 16px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg-elev); color: var(--text-dim);
  font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: all .18s;
}
.tab.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; border-color: transparent;
}

.search-wrap { padding: 0 16px 12px; }
#search {
  width: 100%; padding: 12px 16px; border-radius: 14px;
  border: 1px solid var(--border); background: var(--bg-elev); color: var(--text);
  font-size: 15px; outline: none;
}
#search:focus { border-color: var(--accent); }

.list { padding: 0 16px; display: flex; flex-direction: column; gap: 10px; }
.empty { text-align: center; color: var(--text-dim); padding: 48px 16px; }

.card {
  display: flex; align-items: center; gap: 14px;
  padding: 14px; border-radius: 16px;
  background: var(--bg-card); border: 1px solid var(--border);
  box-shadow: var(--shadow); cursor: pointer; transition: transform .12s, border-color .18s;
}
.card:active { transform: scale(.985); }
.card.playing { border-color: var(--accent); }
.card-icon {
  flex: 0 0 auto; width: 46px; height: 46px; border-radius: 12px;
  display: grid; place-items: center; font-size: 22px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
}
.card-body { flex: 1; min-width: 0; }
.card-title { font-size: 15px; font-weight: 600; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-sub { font-size: 12px; color: var(--text-dim); margin-top: 3px; }
.card-play { flex: 0 0 auto; font-size: 20px; color: var(--accent); }

/* Player */
.player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: 52px 1fr auto; gap: 12px; align-items: center;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--bg-elev); border-top: 1px solid var(--border);
  box-shadow: 0 -8px 30px rgba(0,0,0,.25);
}
.player.hidden { display: none; }
.player-art {
  width: 52px; height: 52px; border-radius: 12px; display: grid; place-items: center;
  font-size: 24px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
}
.player-meta { min-width: 0; }
.player-title { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-sub { font-size: 11px; color: var(--text-dim); margin: 1px 0 6px; }
.seek { width: 100%; accent-color: var(--accent); height: 4px; }
.player-times { display: flex; justify-content: space-between; font-size: 10px; color: var(--text-dim); margin-top: 2px; }
.player-controls { display: flex; align-items: center; gap: 6px; }
.ctrl { background: none; border: none; font-size: 22px; cursor: pointer; padding: 4px; }
.ctrl.play { font-size: 30px; }

@media (min-width: 640px) {
  .list { max-width: 720px; margin: 0 auto; }
  .player { max-width: 720px; margin: 0 auto; border-radius: 18px 18px 0 0; }
  .tabs, .search-wrap, .app-header { max-width: 720px; margin-left: auto; margin-right: auto; }
}

/* ---------- Password gate ---------- */
.lock {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: var(--bg);
}
.lock.hidden { display: none; }
.lock-card {
  width: 100%; max-width: 340px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 32px 24px;
  text-align: center;
}
.lock-logo { font-size: 48px; line-height: 1; margin-bottom: 8px; }
.lock-card h2 { margin: 4px 0 2px; font-size: 22px; }
.lock-sub { margin: 0 0 20px; color: var(--text-dim); font-size: 14px; }
.lock-card form { display: flex; flex-direction: column; gap: 12px; }
.lock-card input {
  width: 100%; padding: 14px 16px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--bg-elev); color: var(--text);
  font-size: 16px; outline: none;
}
.lock-card input:focus { border-color: var(--accent); }
.lock-card button {
  padding: 14px; border: none; border-radius: 12px;
  background: var(--accent); color: #fff;
  font-size: 16px; font-weight: 600; cursor: pointer;
  transition: transform .06s, opacity .2s;
}
.lock-card button:active { transform: scale(.98); }
.lock-err { margin-top: 12px; color: var(--accent-2); font-size: 13px; min-height: 16px; }
