/* Quran Player v1 — mobile-first, thumb-friendly */
:root {
  --bg: #0b2e23;
  --bg-deep: #071f18;
  --card: #123b2d;
  --card-active: #17503c;
  --text: #f0f5ee;
  --muted: #9db8a9;
  --accent: #d9a441;
  --accent-soft: rgba(217, 164, 65, 0.16);
  --danger: #e0685c;
  --radius: 14px;
  --tap: 48px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-deep);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  overscroll-behavior-y: none;
}

.app {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px;
  padding-top: max(16px, env(safe-area-inset-top));
  min-height: 100vh;
}

.app-header { padding: 8px 4px 4px; }
.app-header h1 { margin: 0; font-size: 28px; letter-spacing: 0.5px; }
.subtitle { margin: 2px 0 0; color: var(--muted); font-size: 14px; }

/* Tabs */
.tabs {
  display: flex;
  gap: 8px;
  margin: 14px 0 4px;
  position: sticky;
  top: 0;
  background: var(--bg-deep);
  padding: 8px 0;
  z-index: 5;
}
.tab {
  flex: 1;
  min-height: var(--tap);
  border: 1px solid var(--card);
  background: var(--card);
  color: var(--muted);
  border-radius: var(--radius);
  font-size: 17px;
  font-weight: 600;
}
.tab.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

/* Search */
.search-wrap { margin: 10px 0 6px; }
#search {
  width: 100%;
  min-height: var(--tap);
  border-radius: var(--radius);
  border: 1px solid var(--card);
  background: var(--card);
  color: var(--text);
  font-size: 17px;
  padding: 0 16px;
  -webkit-appearance: none;
}
#search::placeholder { color: var(--muted); }

/* Track list */
.track-list, .playlist-list, .sheet-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}
.track-row {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--card);
  border-radius: var(--radius);
  margin-bottom: 8px;
  padding: 6px 6px 6px 4px;
}
.track-row.playing { background: var(--card-active); border: 1px solid var(--accent); }
.row-play {
  width: var(--tap); height: var(--tap);
  flex: 0 0 auto;
  border: none; border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 18px;
}
.row-main {
  flex: 1 1 auto;
  min-height: var(--tap);
  border: none; background: none; color: var(--text);
  font-size: 17px; text-align: left;
  display: flex; align-items: center; gap: 8px;
  padding: 0 4px;
}
.bm-dot {
  flex: 0 0 auto;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
}
.row-add {
  width: var(--tap); height: var(--tap);
  flex: 0 0 auto;
  border: none; border-radius: 50%;
  background: none; color: var(--muted);
  font-size: 24px; line-height: 1;
}

.empty { color: var(--muted); text-align: center; padding: 24px 12px; }
.hidden { display: none !important; }

/* Buttons */
.btn-primary {
  width: 100%; min-height: var(--tap);
  border: none; border-radius: var(--radius);
  background: var(--accent); color: #23180a;
  font-size: 17px; font-weight: 700;
  margin: 10px 0 4px;
}
.btn-secondary {
  width: 100%; min-height: var(--tap);
  border: 1px solid var(--accent); border-radius: var(--radius);
  background: none; color: var(--accent);
  font-size: 16px; font-weight: 600; margin-top: 8px;
}
.btn-ghost {
  width: 100%; min-height: var(--tap);
  border: none; background: none; color: var(--muted);
  font-size: 16px; margin-top: 4px;
}
.btn-small {
  min-height: 40px; padding: 0 14px;
  border-radius: 10px; border: 1px solid var(--accent);
  background: none; color: var(--accent);
  font-size: 15px; font-weight: 600; white-space: nowrap;
}
.btn-small.danger { border-color: var(--danger); color: var(--danger); }
.btn-row { display: flex; gap: 8px; margin-top: 12px; }
.btn-row .btn-primary, .btn-row .btn-ghost { margin: 0; }

/* Playlists */
.pl-row {
  background: var(--card);
  border-radius: var(--radius);
  margin-bottom: 8px;
  overflow: hidden;
}
.pl-head { display: flex; align-items: center; gap: 8px; padding: 6px 8px; }
.pl-name {
  flex: 1 1 auto; min-height: var(--tap);
  border: none; background: none; color: var(--text);
  font-size: 17px; font-weight: 600; text-align: left;
  display: flex; flex-direction: column; justify-content: center; gap: 2px;
  padding: 0 4px;
}
.pl-count { font-size: 13px; color: var(--muted); font-weight: 400; }
.pl-tracks { list-style: none; margin: 0; padding: 0 8px 8px; }
.pl-track {
  width: 100%; min-height: 44px;
  border: none; border-radius: 10px;
  background: var(--bg); color: var(--text);
  font-size: 15px; text-align: left;
  padding: 10px 12px; margin-bottom: 6px;
}

/* Mini player */
.bottom-spacer { height: 110px; }
.mini-player {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-width: 640px; margin: 0 auto;
  background: rgba(7, 31, 24, 0.97);
  border-top: 1px solid var(--card);
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px max(10px, env(safe-area-inset-bottom));
  z-index: 20;
}
.mini-progress {
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--card);
}
#mini-progress-fill { height: 100%; width: 0; background: var(--accent); }
.icon-btn {
  width: var(--tap); height: var(--tap); flex: 0 0 auto;
  border: none; border-radius: 50%;
  background: var(--accent); color: #23180a;
  font-size: 20px;
}
.mini-info {
  flex: 1 1 auto; min-height: var(--tap);
  border: none; background: none; color: var(--text);
  text-align: left; display: flex; flex-direction: column; justify-content: center;
  padding: 0 4px; overflow: hidden;
}
.mini-title { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-sub { font-size: 12px; color: var(--muted); }

/* Sheets (full player, add-to-playlist, modal) */
.sheet {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(0, 0, 0, 0.6);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-card {
  width: 100%; max-width: 640px;
  background: var(--bg);
  border-radius: 20px 20px 0 0;
  padding: 16px 20px max(20px, env(safe-area-inset-bottom));
  max-height: 88vh; overflow-y: auto;
  position: relative;
}
.sheet-card h3 { margin: 4px 0 8px; font-size: 20px; }
.sheet-sub { color: var(--muted); margin: 0 0 8px; font-size: 14px; }
.sheet-close {
  position: absolute; top: 8px; right: 12px;
  width: var(--tap); height: var(--tap);
  border: none; background: none; color: var(--muted);
  font-size: 28px;
}
.sheet-item {
  width: 100%; min-height: var(--tap);
  border: none; border-radius: 12px;
  background: var(--card); color: var(--text);
  font-size: 16px; text-align: left;
  padding: 12px 14px; margin-bottom: 8px;
}
#playlist-name {
  width: 100%; min-height: var(--tap);
  border-radius: var(--radius); border: 1px solid var(--card);
  background: var(--card); color: var(--text);
  font-size: 17px; padding: 0 16px;
}

/* Full player */
.player-kicker { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 1px; margin: 0 0 4px; }
.player-card h2 { margin: 0 40px 4px 0; font-size: 24px; }
.resume-note { color: var(--accent); font-size: 14px; margin: 4px 0 0; min-height: 20px; }
.seek-row { display: flex; align-items: center; gap: 10px; margin: 14px 0 6px; }
.time { font-size: 13px; color: var(--muted); min-width: 52px; font-variant-numeric: tabular-nums; }
.time:last-child { text-align: right; }
#seek {
  flex: 1 1 auto;
  accent-color: var(--accent);
  height: 32px;
}
.controls {
  display: flex; align-items: center; justify-content: center;
  gap: 6px; margin: 10px 0 4px;
}
.ctl-btn {
  width: 60px; height: 60px; flex: 0 0 auto;
  border: none; border-radius: 50%;
  background: var(--card); color: var(--text);
  font-size: 22px;
}
.ctl-btn.skip { font-size: 15px; font-weight: 700; color: var(--accent); }
.ctl-btn.big {
  width: 76px; height: 76px;
  background: var(--accent); color: #23180a;
  font-size: 28px;
}

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 110px;
  transform: translateX(-50%);
  background: var(--card-active);
  border: 1px solid var(--accent);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 18px;
  font-size: 15px;
  z-index: 50;
  max-width: 90vw;
  text-align: center;
}

/* ---------- v2 additions ---------- */

/* Header with burger */
.app-header { display: flex; align-items: center; gap: 10px; padding: 8px 4px 4px; }
.burger {
  width: var(--tap); height: var(--tap); flex: 0 0 auto;
  border: 1px solid var(--card); border-radius: 12px;
  background: var(--card); color: var(--text);
  font-size: 22px;
}
.hdr-text h1 { margin: 0; font-size: 24px; letter-spacing: 0.5px; }

/* Drawer */
.drawer-scrim {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(0, 0, 0, 0.55);
}
.drawer {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 41;
  width: min(84vw, 340px);
  background: var(--bg);
  border-right: 1px solid var(--card);
  padding: max(16px, env(safe-area-inset-top)) 14px 20px;
  overflow-y: auto;
}
.drawer-head { display: flex; align-items: center; justify-content: space-between; }
.drawer-head h2 { margin: 0; font-size: 19px; }
.drawer-cat { margin-top: 6px; }
.drawer-cat-head {
  width: 100%; min-height: var(--tap);
  display: flex; align-items: center; gap: 10px;
  border: none; background: var(--card); color: var(--text);
  border-radius: 12px; font-size: 16px; font-weight: 600;
  padding: 0 14px; margin-bottom: 6px;
}
.drawer-tracks { list-style: none; margin: 0 0 6px; padding: 0; }
.drawer-track {
  width: 100%; min-height: 44px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  border: none; background: none; color: var(--text);
  font-size: 15px; text-align: left; padding: 8px 10px;
  border-bottom: 1px solid var(--card);
}
.drawer-dur { color: var(--muted); font-size: 13px; flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.drawer-link {
  width: 100%; min-height: var(--tap); margin-top: 12px;
  border: 1px solid var(--accent); border-radius: 12px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 16px; font-weight: 600;
}

/* Category cards */
.cat-card {
  background: var(--bg);
  border: 1px solid var(--card);
  border-radius: var(--radius);
  margin: 12px 0;
  overflow: hidden;
}
.cat-head {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
}
.cat-toggle {
  flex: 1 1 auto; min-height: var(--tap);
  display: flex; align-items: center; gap: 10px;
  border: none; background: none; color: var(--text);
  font-size: 19px; font-weight: 700; text-align: left;
  padding: 0 4px;
}
.cat-arrow { color: var(--accent); font-size: 16px; flex: 0 0 auto; }
.cat-name { flex: 0 1 auto; }
.cat-count {
  font-size: 12px; font-weight: 600; color: var(--muted);
  background: var(--card); border-radius: 20px; padding: 3px 10px;
  white-space: nowrap;
}
.cat-card .track-list { margin: 0; padding: 0 10px 10px; }

/* Track rows v2 */
.track-row {
  display: flex; align-items: center; gap: 4px;
  background: var(--card);
  border-radius: var(--radius);
  margin-bottom: 8px;
  padding: 6px 4px;
}
.track-row.playing { background: var(--card-active); border: 1px solid var(--accent); }
.row-play {
  width: var(--tap); height: var(--tap); flex: 0 0 auto;
  border: none; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  font-size: 18px;
}
.row-stop {
  width: 40px; height: 40px; flex: 0 0 auto;
  border: 1px solid var(--card); border-radius: 50%;
  background: none; color: var(--muted);
  font-size: 14px;
}
.row-main {
  flex: 1 1 auto; min-width: 0;
  min-height: var(--tap);
  border: none; background: none; color: var(--text);
  display: flex; flex-direction: column; justify-content: center; gap: 4px;
  text-align: left; padding: 4px;
}
.row-title { font-size: 16px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.row-meta { display: flex; align-items: center; gap: 8px; }
.row-runtime {
  font-size: 12px; color: var(--muted); flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
}
.bm-bar {
  flex: 1 1 auto; height: 4px; min-width: 30px;
  background: var(--bg-deep); border-radius: 2px; overflow: hidden;
}
.bm-fill { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 2px; }
.speed-badge {
  flex: 0 0 auto;
  font-size: 11px; font-weight: 700; color: #23180a;
  background: var(--accent); border-radius: 10px; padding: 2px 8px;
}
.done-check { flex: 0 0 auto; color: var(--accent); font-weight: 700; }
.row-add {
  width: 44px; height: 44px; flex: 0 0 auto;
  border: 1px solid var(--accent); border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  font-size: 24px; line-height: 1; font-weight: 700;
}
.row-gear {
  width: 44px; height: 44px; flex: 0 0 auto;
  border: none; border-radius: 50%;
  background: none; color: var(--muted);
  font-size: 22px;
}

/* Progress ring around the main play button */
.ring-wrap {
  position: relative; flex: 0 0 auto;
  width: 88px; height: 88px;
  display: inline-flex; align-items: center; justify-content: center;
}
.progress-ring { position: absolute; inset: 0; width: 88px; height: 88px; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--card); stroke-width: 5; }
.ring-fg {
  fill: none; stroke: var(--accent); stroke-width: 5; stroke-linecap: round;
  stroke-dasharray: 251.33; stroke-dashoffset: 251.33;
}
.ring-wrap .ctl-btn.big { position: relative; z-index: 1; }

/* Gear sheet */
.speed-row { display: flex; gap: 8px; margin: 4px 0 12px; flex-wrap: wrap; }
.speed-btn {
  flex: 1 1 0; min-height: 44px; min-width: 56px;
  border: 1px solid var(--card); border-radius: 10px;
  background: var(--card); color: var(--text);
  font-size: 15px; font-weight: 600;
}
.speed-btn.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* Playlist rows v2 */
.pl-track-row {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 6px;
}
.pl-track {
  flex: 1 1 auto; min-width: 0;
  min-height: 44px;
  border: none; border-radius: 10px;
  background: var(--bg); color: var(--text);
  font-size: 15px; text-align: left;
  padding: 10px 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pl-mini-btn {
  width: 40px; height: 40px; flex: 0 0 auto;
  border: 1px solid var(--card); border-radius: 10px;
  background: none; color: var(--muted); font-size: 16px;
}
.pl-mini-btn.danger { border-color: var(--danger); color: var(--danger); }
.pl-tracks .btn-secondary { margin: 0 0 10px; }

/* Track picker */
.picker-row {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 0; border-bottom: 1px solid var(--card);
}
.picker-title { flex: 1 1 auto; font-size: 15px; }
.picker-add {
  width: 44px; height: 44px; flex: 0 0 auto;
  border: 1px solid var(--accent); border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  font-size: 22px; font-weight: 700;
}
.picker-add.added { opacity: 0.35; }
#picker-done { margin-top: 12px; }
