* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: #121212;
  color: #e6e6e6;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ==========================================================
   BARIS 1: STEPPER TRACK
   ========================================================== */
.baris-satu {
  height: 40px;
  background-color: #1c1c1c;
  border-bottom: 1px solid #292929;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  flex-shrink: 0;
  z-index: 20;
}

.stepper-track {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 520px;
  gap: 2px;
}

.btn-step {
  background-color: #282828;
  color: #c5a059;
  border: 1px solid #383838;
  border-radius: 4px;
  height: 28px;
  flex: 1 1 auto;
  min-width: 0;
  padding: 0 2px;
  font-size: 11px;
  font-weight: bold;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.btn-step:hover {
  background-color: #383838;
  border-color: #c5a059;
}

.btn-arrow {
  color: #ffffff;
  font-size: 12px;
  background-color: #333333;
}

.input-hlm-wrap {
  flex: 1 1 auto;
  max-width: 48px;
  min-width: 36px;
}

.input-hlm-wrap input {
  width: 100%;
  height: 28px;
  background: #0d0d0d;
  border: 1px solid #c5a059;
  border-radius: 4px;
  color: #c5a059;
  font-weight: bold;
  text-align: center;
  font-size: 12px;
  outline: none;
}

/* ==========================================================
   BARIS 2: CHIP & DROPDOWN RAMPING (SCROLL MENDATAR)
   ========================================================== */
.baris-dua {
  height: 36px;
  background-color: #141414;
  border-bottom: 1px solid #242424;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  gap: 4px;
  overflow-x: auto;
  white-space: nowrap;
  flex-shrink: 0;
  scrollbar-width: none;
}
.baris-dua::-webkit-scrollbar { display: none; }

.btn-chip {
  background-color: #242424;
  color: #e6e6e6;
  border: 1px solid #383838;
  padding: 0 8px;
  border-radius: 4px;
  height: 26px;
  font-size: 11px;
  font-weight: bold;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.btn-gold {
  background-color: #262016;
  border-color: #c5a059;
  color: #c5a059;
}

.btn-audio {
  background-color: #c5a059;
  color: #111;
  border: none;
  border-radius: 13px;
}

.btn-audio.playing {
  background-color: #d9534f;
  color: #fff;
}

.status-audio {
  font-size: 11px;
  color: #c5a059;
  font-weight: bold;
  flex-shrink: 0;
  margin-right: 2px;
}

.chip-select {
  background: #202020;
  color: #cccccc;
  border: 1px solid #333333;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 11px;
  height: 26px;
  outline: none;
  cursor: pointer;
  flex-shrink: 0;
}

.chip-select:focus { border-color: #c5a059; }

/* Lebar Maksimal Dropdown Baris 2 */
.chip-loop { max-width: 95px; border-color: #444444; color: #e6e6e6; }
.chip-count { max-width: 52px; border-color: #444444; color: #c5a059; font-weight: bold; text-align: center; }
.chip-yaum { max-width: 120px; }
.chip-syathr { max-width: 76px; }
.chip-qisth { max-width: 60px; }
.chip-reciter { max-width: 98px; }
.chip-speed { max-width: 66px; }

/* ==========================================================
   VIEWPORT MUSHAF
   ========================================================== */
.mushaf-viewport {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 4px 6px;
  overflow: hidden;
  user-select: none;
  width: 100%;
}

.book-container {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: auto;
  max-width: 100%;
  margin: 0 auto;
}

.page-frame {
  height: 100%;
  max-height: calc(100vh - 84px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.img-wrapper {
  height: calc(100% - 18px);
  display: flex;
  justify-content: center;
  align-items: center;
  background: #1c1a17;
  overflow: hidden;
  position: relative;
}

.img-wrapper img {
  height: 100%;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  display: block;
  background-color: #ffffff;
}

.img-wrapper.active-audio-page {
  box-shadow: inset 0 0 0 2px #c5a059;
}

.page-label {
  height: 18px;
  line-height: 18px;
  font-size: 11px;
  color: #777777;
  font-weight: bold;
  text-align: center;
}

/* ==========================================================
   PEMBATAS PUNGGUNG BUKU DI LAPTOP
   ========================================================== */
.mushaf-spine {
  display: none;
  width: 4px;
  height: calc(100% - 18px);
  background: linear-gradient(to right, #1f1b13, #383020 50%, #1f1b13);
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.9);
  flex-shrink: 0;
  z-index: 5;
  margin-bottom: 18px;
}

/* ATURAN LAYAR LAPTOP (> 768px): 2 HALAMAN MENYATU */
@media (min-width: 769px) {
  .book-container {
    flex-direction: row-reverse !important;
    gap: 0 !important;
  }
  .mushaf-spine {
    display: block !important;
  }
  .frame-right .img-wrapper {
    border-radius: 4px 0 0 4px;
    border-top: 1px solid #2e2a22;
    border-bottom: 1px solid #2e2a22;
    border-right: 1px solid #2e2a22;
    border-left: none;
    box-shadow: -6px 6px 20px rgba(0, 0, 0, 0.7);
  }
  .frame-left .img-wrapper {
    border-radius: 0 4px 4px 0;
    border-top: 1px solid #2e2a22;
    border-bottom: 1px solid #2e2a22;
    border-left: 1px solid #2e2a22;
    border-right: none;
    box-shadow: 6px 6px 20px rgba(0, 0, 0, 0.7);
  }
  #frame-right, #frame-left {
    display: flex !important;
  }
  .select-yaum { max-width: 170px; }
  .select-reciter { max-width: 130px; }
}

/* ATURAN LAYAR SMARTPHONE (<= 768px): MENEMPEL PAS DI ATAS TANPA JEDA */
@media (max-width: 768px) {
  .mushaf-viewport {
    padding: 0;
    align-items: flex-start;
  }
  .baris-dua {
    justify-content: flex-start;
  }
  .book-container {
    flex-direction: row !important;
    width: 100% !important;
    height: 100% !important;
    align-items: flex-start !important;
    gap: 0 !important;
  }
  .mushaf-spine {
    display: none !important;
  }
  #frame-left {
    display: none !important;
  }
  .page-frame {
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    max-height: calc(100vh - 78px) !important;
    justify-content: flex-start !important;
  }
  .img-wrapper {
    width: 100% !important;
    height: calc(100% - 18px) !important;
    border-radius: 0;
    border: none;
    box-shadow: none;
    background: transparent;
  }
  .img-wrapper img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
    object-position: top center;
  }
}

/* ==========================================================
   SIDEBAR DRAWER FIHRIS
   ========================================================== */
.sidebar {
  position: fixed;
  top: 0;
  left: -350px;
  width: 320px;
  height: 100%;
  background-color: #1c1c1c;
  border-right: 1px solid #333333;
  z-index: 100;
  transition: left 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  box-shadow: 10px 0 25px rgba(0, 0, 0, 0.7);
}

.sidebar.open { left: 0; }

.sidebar-header {
  padding: 10px 14px;
  border-bottom: 1px solid #333333;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-header h2 { font-size: 14px; color: #c5a059; }

.close-btn {
  background: transparent;
  border: none;
  color: #aaaaaa;
  font-size: 22px;
  cursor: pointer;
}

/* Sakelar Pilihan Edisi Mushaf */
.sidebar-edition-toggle {
  padding: 8px 12px;
  background-color: #161616;
  border-bottom: 1px solid #282828;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.edition-label {
  font-size: 11px;
  color: #aaaaaa;
  font-weight: 600;
}

.edition-segmented-control {
  display: inline-flex;
  background-color: #242424;
  border-radius: 6px;
  padding: 2px;
  border: 1px solid #383838;
}

.btn-edition {
  background: transparent;
  border: none;
  color: #999999;
  font-size: 11px;
  font-weight: bold;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-edition.active {
  background-color: #c5a059;
  color: #111111;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.sidebar-search { padding: 6px 10px; border-bottom: 1px solid #333333; }

.sidebar-search input {
  width: 100%;
  background: #141414;
  border: 1px solid #333333;
  padding: 6px 10px;
  border-radius: 4px;
  color: #ffffff;
  font-size: 12px;
}

.sidebar-list { flex: 1; overflow-y: auto; padding: 4px 0; }

.fatihah-card {
  background: #272218;
  border: 1px solid #c5a059;
  border-radius: 4px;
  margin: 6px 8px;
  padding: 8px 10px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

details.yaum-group { border-bottom: 1px solid #262626; }

details.yaum-group summary {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  background: #222222;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.yaum-title-btn {
  cursor: pointer;
  color: #ffffff;
  transition: color 0.15s;
}
.yaum-title-btn:hover { color: #c5a059; text-decoration: underline; }

.syathr-box {
  background-color: #181818;
  border-left: 2px solid #c5a059;
  margin: 3px 6px;
  border-radius: 3px;
  overflow: hidden;
}

.syathr-header {
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 600;
  color: #c5a059;
  background-color: #1f1f1f;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}
.syathr-header:hover { background-color: #292929; }

.qisth-item {
  padding: 5px 10px;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #141414;
  color: #cccccc;
}
.qisth-item:hover { background-color: #252525; color: #fff; }

/* Bagian Kanan Baris Item Fihris (Halaman + Tombol Putar Mini) */
.qisth-item-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Tombol Putar Cepat Mini di Fihris (Opsi 2) */
.btn-play-mini {
  background: transparent;
  border: 1px solid #444444;
  color: #c5a059;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1;
}

.btn-play-mini:hover {
  background: #c5a059;
  color: #111111;
  border-color: #c5a059;
  transform: scale(1.15);
}

.backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 90;
}
.backdrop.active { display: block; }