/* Love Action Music — public player. Mobile-first (base = 375px). */
:root {
  --bg: #0f1115;
  --bg2: #171a21;
  --bg3: #1e222b;
  --line: #262b36;
  --text: #e8e8ee;
  --muted: #9aa0ad;
  --accent: #ff4d6d;
  --accent-dim: #c93a56;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
/* Ensure the `hidden` attribute always wins over component display rules
   (a class like .share-sheet{display:flex} otherwise overrides UA [hidden]).
   Without this the share overlay renders on load and blocks all clicks. */
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
body.has-np { padding-bottom: 132px; }
a { color: inherit; }
img { display: block; max-width: 100%; }
button { font: inherit; cursor: pointer; }

.skip-link { position: absolute; left: -999px; }
.skip-link:focus { left: 8px; top: 8px; background: var(--accent); color: #fff; padding: .5rem .8rem; border-radius: 8px; z-index: 100; }

/* ---------------- top bar ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
  padding: .7rem 1rem;
  background: rgba(15, 17, 21, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .45rem; text-decoration: none; font-weight: 800; letter-spacing: .01em; }
.brand-mark { color: var(--accent); font-size: 1.15rem; }
.brand-name { font-size: 1rem; }
.topnav { display: flex; gap: .25rem; margin-left: auto; }
.topnav a { text-decoration: none; color: var(--muted); font-size: .9rem; padding: .35rem .6rem; border-radius: 8px; }
.topnav a:hover { color: var(--text); background: var(--bg2); }
.topnav a.active { color: #fff; background: var(--accent-dim); }
.search { order: 3; flex: 1 1 100%; }
.search input {
  width: 100%; padding: .55rem .8rem; border-radius: 999px;
  background: var(--bg2); border: 1px solid var(--line); color: var(--text); font-size: .95rem;
}
.search input:focus { outline: 2px solid var(--accent); border-color: transparent; }

/* ---------------- view / layout ---------------- */
.view { padding: 1rem; max-width: 1200px; margin: 0 auto; }
.page-head h1 { font-size: 1.3rem; margin: .2rem 0 1rem; }
.empty, .searchnote { color: var(--muted); }
.searchnote a { color: var(--accent); }

.filters-bar { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filters-bar select {
  flex: 1 1 auto; min-width: 0; padding: .5rem .6rem; border-radius: 10px;
  background: var(--bg2); border: 1px solid var(--line); color: var(--text); font-size: .9rem;
}

/* ---------------- song grid ---------------- */
.grid {
  display: grid; gap: .9rem;
  grid-template-columns: repeat(2, 1fr);
}
.card { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.card-art { position: relative; border: 0; padding: 0; background: var(--bg3); aspect-ratio: 1 / 1; width: 100%; }
.card-art img { width: 100%; height: 100%; object-fit: cover; }
.card-playicon {
  position: absolute; right: .5rem; bottom: .5rem;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent); color: #fff; display: grid; place-items: center;
  font-size: .9rem; box-shadow: 0 4px 14px rgba(0,0,0,.4);
  opacity: 0; transform: translateY(6px); transition: .15s;
}
.card-art:hover .card-playicon, .card-art:focus-visible .card-playicon { opacity: 1; transform: none; }
.card-body { padding: .6rem .7rem .7rem; display: flex; flex-direction: column; gap: .3rem; }
.card-title { font-weight: 600; font-size: .92rem; text-decoration: none; line-height: 1.25; }
.card-sub { color: var(--muted); font-size: .8rem; }
.card-row { display: flex; align-items: center; gap: .35rem; margin-top: .2rem; }
.grow { flex: 1; }
.chip { font-size: .68rem; color: #ffd7df; background: rgba(255,77,109,.14); padding: .16rem .5rem; border-radius: 999px; text-transform: capitalize; }

/* ---------------- buttons ---------------- */
.icon-btn {
  background: transparent; border: 0; color: var(--muted);
  width: 34px; height: 34px; border-radius: 9px; font-size: 1.05rem; line-height: 1;
  display: inline-grid; place-items: center;
}
.icon-btn:hover { color: var(--text); background: var(--bg3); }
.fav-btn.on, .icon-btn.on { color: var(--accent); }
.btn-lg {
  background: var(--accent); color: #fff; border: 0; border-radius: 999px;
  padding: .65rem 1.4rem; font-weight: 600; font-size: .95rem;
}
.btn-lg:hover { background: var(--accent-dim); }
.btn.sm { background: var(--bg3); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: .35rem .7rem; font-size: .82rem; }
.btn.sm:hover { border-color: var(--accent); }
.loadmore-wrap { text-align: center; margin: 1.5rem 0; }

/* ---------------- song page ---------------- */
.song-page { display: flex; flex-direction: column; gap: 1rem; align-items: center; text-align: center; }
.song-art { width: min(320px, 80vw); height: min(320px, 80vw); border-radius: var(--radius); object-fit: cover; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.song-info h1 { margin: 0; font-size: 1.5rem; }
.song-artist { color: var(--muted); margin: .3rem 0; }
.song-desc { color: var(--muted); max-width: 560px; line-height: 1.55; }
.song-page .card-row { justify-content: center; }
.song-actions { display: flex; align-items: center; gap: .6rem; justify-content: center; margin-top: .3rem; }

/* ---------------- history list ---------------- */
.rlist { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .5rem; }
.rrow { display: flex; align-items: center; gap: .7rem; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: .5rem .7rem; }
.rrow img { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; flex: none; }
.rmeta { flex: 1; min-width: 0; }
.rtitle { font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rsub { color: var(--muted); font-size: .78rem; }

/* ---------------- now playing bar ---------------- */
.nowplaying {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem .8rem calc(.6rem + env(safe-area-inset-bottom));
  background: rgba(23, 26, 33, .97); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.np-track { display: flex; align-items: center; gap: .6rem; flex: 1 1 60%; min-width: 0; }
.np-art { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; background: var(--bg3); flex: none; }
.np-meta { min-width: 0; flex: 1; }
.np-title { font-weight: 600; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-artist { color: var(--muted); font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-center { order: 3; flex: 1 1 100%; display: flex; flex-direction: column; gap: .25rem; }
.np-controls { display: flex; align-items: center; justify-content: center; gap: 1rem; }
.play-btn { background: var(--accent); color: #fff; width: 42px; height: 42px; border-radius: 50%; font-size: .95rem; }
.play-btn:hover { background: var(--accent-dim); color: #fff; }
.np-seek { display: flex; align-items: center; gap: .5rem; }
.np-seek .t { color: var(--muted); font-size: .72rem; font-variant-numeric: tabular-nums; min-width: 34px; text-align: center; }
.np-right { display: flex; align-items: center; gap: .4rem; }

input[type=range] { -webkit-appearance: none; appearance: none; height: 4px; border-radius: 4px; background: var(--bg3); }
#seek { flex: 1; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); cursor: pointer; }
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: var(--accent); cursor: pointer; }
.volume { width: 90px; }

/* on small screens hide the desktop-only volume slider (device handles it) */
.np-right .volume { display: none; }

/* ---------------- share sheet ---------------- */
.share-sheet { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; }
.share-card { background: var(--bg2); border: 1px solid var(--line); border-radius: 18px 18px 0 0; width: 100%; max-width: 480px; padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom)); }
.share-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .8rem; }
.share-links { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; }
.share-link { display: block; text-align: center; text-decoration: none; background: var(--bg3); border: 1px solid var(--line); border-radius: 10px; padding: .7rem; color: var(--text); font-size: .9rem; }
.share-link:hover { border-color: var(--accent); }

/* ---------------- toast ---------------- */
.toast { position: fixed; left: 50%; bottom: 150px; transform: translateX(-50%); z-index: 70; background: #000; color: #fff; padding: .6rem 1rem; border-radius: 999px; font-size: .85rem; border: 1px solid var(--line); }

/* ---------------- ad zones ---------------- */
.ad-zone { max-width: 1200px; margin: 0 auto; padding: 0 1rem; }
.ad-zone[hidden] { display: none; }

/* ---------------- desktop ---------------- */
@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
  .search { order: 0; flex: 0 1 260px; margin-left: .5rem; }
  .topnav { margin-left: 1rem; }
  .np-center { order: 0; flex: 1 1 40%; }
  .np-right .volume { display: block; }
  .song-page { flex-direction: row; align-items: flex-start; text-align: left; padding-top: 1rem; }
  .song-page .card-row, .song-actions { justify-content: flex-start; }
  .song-info h1 { font-size: 2rem; }
  .share-sheet { align-items: center; }
  .share-card { border-radius: 18px; }
  body.has-np { padding-bottom: 96px; }
  .nowplaying { flex-wrap: nowrap; }
  .np-track { flex: 1 1 30%; }
  .np-right { flex: 1 1 30%; justify-content: flex-end; }
}
@media (min-width: 1000px) {
  .grid { grid-template-columns: repeat(4, 1fr); }
}

/* PWA install button */
.install-btn{background:#ff4d6d;color:#fff;border:none;border-radius:20px;
  padding:7px 14px;font-size:13px;font-weight:600;cursor:pointer;white-space:nowrap;
  transition:opacity .15s}
.install-btn:hover{opacity:.88}
