:root[data-theme="nur"] {
  --bg-base: #f6f4ee;
  --bg-surface: #ffffff;
  --bg-elevated: #ece8dd;
  --bg-card: rgba(255, 255, 255, 0.9);
  --border-subtle: #d8d0c0;
  --border-active: #b58d2c;
  --gold-primary: #9b721d;
  --gold-light: #543e0e;
  --gold-dim: rgba(155, 114, 29, 0.12);
  --emerald-glow: rgba(13, 138, 96, 0.12);
  --emerald-accent: #0c8a60;
  --terracotta: #a3482d;
  --text-main: #222926;
  --text-muted: #5e6e66;
  --text-dim: #90a098;
  --shadow-ambient: 0 8px 24px rgba(70, 60, 40, 0.08);
  --popover-bg: #ffffff;
}

:root[data-theme="qurtuba"] {
  --bg-base: #1b1714;
  --bg-surface: #241e19;
  --bg-elevated: #312821;
  --bg-card: rgba(36, 30, 25, 0.85);
  --border-subtle: #41352a;
  --border-active: #d68f56;
  --gold-primary: #d49a5b;
  --gold-light: #f5cf9c;
  --gold-dim: rgba(212, 154, 91, 0.15);
  --emerald-glow: rgba(186, 107, 72, 0.18);
  --emerald-accent: #3cb371;
  --terracotta: #c46849;
  --text-main: #ede3d8;
  --text-muted: #a6988a;
  --text-dim: #6e5e4f;
  --shadow-ambient: 0 10px 30px rgba(0,0,0,0.5);
  --popover-bg: #2b231c;
}

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

body {
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  background-color: var(--bg-base);
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  transition: background-color 0.25s ease, color 0.25s ease;
}

header {
  padding: 0 20px;
  padding-top: env(safe-area-inset-top, 0px);
  height: calc(62px + env(safe-area-inset-top, 0px));
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  flex-shrink: 0;
  z-index: 20;
}

.brand-section { display: flex; align-items: center; gap: 10px; }
.brand-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.center-bismillah {
  font-family: 'Amiri', serif;
  font-size: 1.45rem;
  color: var(--gold-primary);
  text-align: center;
  line-height: 1;
  user-select: none;
  white-space: nowrap;
}

.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }

.view-switcher {
  display: flex;
  background: var(--bg-base);
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  gap: 2px;
}

.switch-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.76rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}
.switch-btn.active {
  background: var(--bg-elevated);
  color: var(--gold-primary);
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
  font-weight: 600;
}

.theme-select {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.76rem;
  font-family: inherit;
  cursor: pointer;
  outline: none;
}

.menu-toggle {
  display: none;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 7px 11px;
  border-radius: 6px;
  font-size: 0.82rem;
  cursor: pointer;
}

.app-body { display: flex; flex: 1; overflow: hidden; position: relative; }

.sidebar {
  width: 300px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  overflow-y: auto;
  padding: 14px 10px 220px 10px;
  flex-shrink: 0;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 100;
  -webkit-overflow-scrolling: touch;
}

.sidebar-search-box {
  margin-bottom: 10px;
  position: sticky;
  top: 0;
  background: var(--bg-surface);
  padding: 2px 0 8px 0;
  z-index: 2;
}
.sidebar-search {
  width: 100%;
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-family: inherit;
  outline: none;
}
.sidebar-search:focus { border-color: var(--gold-primary); }

.sidebar-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  color: var(--gold-primary);
  letter-spacing: 0.1em;
  font-weight: 700;
  padding: 4px 8px 8px 8px;
}

.nav-item-btn {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  margin-bottom: 3px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.86rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.15s ease;
  font-family: inherit;
}
.nav-item-btn:hover { background: var(--bg-elevated); color: var(--text-main); }
.nav-item-btn.active {
  background: var(--gold-dim);
  border-color: rgba(212, 175, 55, 0.35);
  color: var(--gold-light);
  font-weight: 600;
}

.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  padding-bottom: 220px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  -webkit-overflow-scrolling: touch;
}

.hero-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-left: 4px solid var(--gold-primary);
  border-radius: 8px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 10;
}
.hero-title { font-weight: 600; font-size: 1.05rem; }
.hero-subtitle { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

.action-btn-group { display: flex; align-items: center; gap: 8px; }
.btn-islamic {
  padding: 7px 14px;
  background: transparent;
  color: var(--gold-primary);
  border: 1px solid var(--gold-primary);
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.18s;
  font-family: inherit;
}
.btn-islamic:hover { background: var(--gold-primary); color: #fff; }

.surah-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}
.surah-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 12px 14px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.15s;
}
.surah-card:hover { border-color: var(--gold-primary); background: var(--bg-elevated); }
.surah-card.playing { border-color: var(--emerald-accent); background: var(--emerald-glow); color: var(--emerald-accent); font-weight: 600; }
.surah-card-actions { display: flex; align-items: center; gap: 8px; }
.card-icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}
.card-icon-btn:hover { color: var(--gold-primary); }

.riwayat-stack { display: flex; flex-direction: column; gap: 8px; }
.riwayat-row {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.15s;
}
.riwayat-row:hover { border-color: var(--gold-primary); background: var(--bg-elevated); }
.riwayat-row.playing { border-color: var(--emerald-accent); background: var(--emerald-glow); }
.riwayat-meta-title { font-weight: 500; font-size: 0.9rem; }
.riwayat-meta-status { font-size: 0.75rem; color: var(--text-muted); }
.riwayat-row.playing .riwayat-meta-status { color: var(--emerald-accent); }

.master-player-dock {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  padding: 10px 20px calc(12px + env(safe-area-inset-bottom, 0px)) 20px;
  box-shadow: var(--shadow-ambient);
  z-index: 150;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.timeline-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}
.time-badge {
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  min-width: 40px;
  text-align: center;
}
.scrubber-track {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}
.ab-indicator-a, .ab-indicator-b {
  position: absolute;
  top: -3px;
  width: 3px;
  height: 12px;
  background: var(--terracotta);
  border-radius: 2px;
  pointer-events: none;
  z-index: 5;
  display: none;
}
.ab-indicator-b { background: var(--emerald-accent); }

.main-scrubber {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 4px;
  background: var(--border-subtle);
  outline: none;
  cursor: pointer;
  touch-action: none;
}
.main-scrubber::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--gold-primary);
  border: 2px solid var(--bg-surface);
  box-shadow: 0 0 8px rgba(155, 114, 29, 0.6);
  cursor: pointer;
}

.controls-main-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.now-playing-box {
  flex: 1.2;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.now-playing-title {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--gold-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.now-playing-sub {
  font-size: 0.74rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.transport-bar { display: flex; align-items: center; gap: 8px; }
.transport-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  padding: 6px;
  transition: all 0.15s;
}
.transport-btn:hover { color: var(--gold-primary); background: var(--bg-elevated); }
.transport-btn.play-circle {
  background: var(--gold-primary);
  color: #fff;
  width: 38px;
  height: 38px;
}
.transport-btn.play-circle:hover { transform: scale(1.05); }

.aux-bar {
  flex: 1.2;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  position: relative;
}

.aux-chip {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.72rem;
  padding: 5px 9px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 4px;
}
.aux-chip:hover { border-color: var(--gold-primary); color: var(--gold-primary); }
.aux-chip.active {
  border-color: var(--emerald-accent);
  color: var(--emerald-accent);
  background: var(--emerald-glow);
  font-weight: 600;
}

.popover-card {
  position: absolute;
  bottom: calc(100% + 10px);
  right: 0;
  background: var(--popover-bg);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 12px;
  box-shadow: var(--shadow-ambient);
  display: none;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  min-width: 240px;
  max-width: 300px;
}
.popover-card.open { display: flex; }
.popover-title { font-size: 0.75rem; font-weight: 700; color: var(--gold-primary); text-transform: uppercase; }

.speed-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}
.speed-opt {
  padding: 6px 2px;
  font-size: 0.75rem;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-base);
  color: var(--text-main);
  cursor: pointer;
  text-align: center;
  font-family: inherit;
}
.speed-opt.active {
  background: var(--gold-primary);
  color: #fff;
  border-color: var(--gold-primary);
  font-weight: 600;
}

.sleep-presets {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}
.sleep-opt {
  padding: 6px;
  font-size: 0.72rem;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-base);
  color: var(--text-main);
  cursor: pointer;
  text-align: center;
  font-family: inherit;
}
.sleep-custom-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 4px;
}
.sleep-input {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  background: var(--bg-base);
  color: var(--text-main);
  font-size: 0.75rem;
  outline: none;
  font-family: inherit;
}

.backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 95;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  max-width: 440px;
  width: 100%;
  overflow: hidden;
  box-shadow: var(--shadow-ambient);
}
.modal-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  font-size: 0.9rem;
}
.modal-body { padding: 16px; display: flex; flex-direction: column; gap: 8px; font-size: 0.82rem; }

@media (max-width: 1024px) {
  .menu-toggle { display: flex; }
  header { grid-template-columns: auto 1fr auto; gap: 8px; padding: 0 12px; }
  .center-bismillah { font-size: 1.15rem; }
  .brand-title { display: none; }
  .sidebar {
    position: absolute;
    top: 0; bottom: 0; left: 0;
    transform: translateX(-100%);
    box-shadow: 8px 0 24px rgba(0,0,0,0.4);
  }
  .sidebar.open { transform: translateX(0); }
  .backdrop.open { display: block; }
  .controls-main-row { flex-wrap: wrap; justify-content: center; }
  .now-playing-box { width: 100%; text-align: center; order: -1; }
  .aux-bar { width: 100%; justify-content: center; }
}
