:root {
  --bg: #1f2125;
  --bg-elev: #25272c;
  --card: #343a40;
  --ink: #eef1f4;
  --muted: #9aa3ad;
  --line: rgba(255, 255, 255, 0.08);
  --accent: #2ca4ab;
  --accent-soft: rgba(44, 164, 171, 0.16);
  --play: #2ca4ab;
  --playing: rgba(44, 164, 171, 0.12);
  --sans: "Plus Jakarta Sans", "Segoe UI", sans-serif;
  --naskh: "Amiri Quran", "Noto Naskh Arabic", serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font-scale: 1;
  --top: 60px;
  --sub: 52px;
  --player: 68px;
  --max: 1120px;
}

[data-theme="light"] {
  --bg: #f8f8f8;
  --bg-elev: #ffffff;
  --card: #ffffff;
  --ink: #1f2125;
  --muted: #66707a;
  --line: rgba(31, 33, 37, 0.1);
  --accent: #1f8e95;
  --accent-soft: rgba(31, 142, 149, 0.12);
  --play: #1f8e95;
  --playing: rgba(31, 142, 149, 0.1);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; overflow-x: clip; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0);
}

.top {
  position: sticky; top: 0; z-index: 8;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.top-inner {
  max-width: var(--max);
  margin: 0 auto;
  min-height: var(--top);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.logo {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.04em;
}
.top-actions { display: flex; align-items: center; gap: 8px; }
.search-wrap {
  display: flex; align-items: center; gap: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  min-width: min(280px, 46vw);
  color: var(--muted);
}
.search-wrap input {
  border: 0; outline: 0; background: transparent; width: 100%; color: var(--ink);
}
.icon-btn, .chip, .text-btn, .play-main, .verse-play, .pill, .icon-quiet {
  border: 0; background: transparent;
}
.icon-btn {
  width: 38px; height: 38px; border-radius: 999px;
  display: grid; place-items: center;
  color: var(--ink);
}
.icon-btn:hover { background: var(--card); }
[data-theme="light"] .i-moon,
[data-theme="dark"] .i-sun { display: none; }
body:not(.is-playing) .i-pause { display: none; }
body.is-playing .i-play { display: none; }

.subnav {
  position: sticky; top: var(--top); z-index: 7;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.subnav[hidden] { display: none; }
.subnav-inner {
  max-width: var(--max);
  margin: 0 auto;
  min-height: var(--sub);
  padding: 0 20px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
}
.surah-jump select {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 8px 22px 8px 0;
  font-weight: 600;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2 4l4 4 4-4' fill='none' stroke='%239aa3ad' stroke-width='1.6' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right center;
}
.tabs { display: flex; justify-content: center; }
.tab {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  padding: 14px 10px 12px;
  border-bottom: 2px solid var(--accent);
}
.subnav-meta {
  text-align: right;
  color: var(--muted);
  font-size: 13px;
}

#app {
  max-width: var(--max);
  width: 100%;
  margin: 0 auto;
  padding: 24px 20px calc(var(--player) + 32px);
}

.home-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 8px 0 18px;
}
.home-head h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.04em;
}
.home-head p { margin: 6px 0 0; color: var(--muted); }
.status { color: var(--muted); font-size: 13px; margin: 0 0 16px; }

.surah-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.surah {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  min-width: 0;
  transition: border-color 200ms var(--ease), background 200ms var(--ease);
}
.surah:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.surah-num {
  width: 40px; height: 40px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--bg-elev);
  color: var(--accent);
  font-weight: 700;
}
.surah-names h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
}
.surah-names p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.surah-ar {
  font-family: var(--naskh);
  font-size: 28px;
  line-height: 1;
}

.chapter-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 18px;
  align-items: center;
  background: var(--card);
  border-radius: 18px;
  padding: 18px 20px;
  margin-bottom: 28px;
}
.chapter-ar {
  font-family: var(--naskh);
  font-size: clamp(2.4rem, 5vw, 3.4rem);
  line-height: 1.1;
}
.chapter-copy h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
}
.chapter-copy h1 em {
  font-style: normal;
  font-weight: 500;
  color: var(--muted);
}
.chapter-copy p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}
.chapter-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 220px;
}
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--bg-elev);
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 14px;
  border: 1px solid var(--line);
}
.pill:hover { border-color: var(--accent); }
.pill.primary {
  background: var(--bg-elev);
}

.verse {
  padding: 14px 4px 8px;
  scroll-margin-top: calc(var(--top) + var(--sub) + 12px);
}
.verse + .verse { margin-top: 6px; }
.verse-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}
.verse-tools-left, .verse-tools-right {
  display: flex; align-items: center; gap: 8px;
}
.icon-quiet {
  width: 32px; height: 32px; border-radius: 8px;
  display: grid; place-items: center;
  color: var(--muted);
}
.icon-quiet:hover { background: var(--card); color: var(--ink); }
.verse.is-current .icon-quiet.verse-play {
  color: var(--accent);
}

.ar-line {
  margin: 18px 0 20px;
  font-family: var(--naskh);
  font-size: calc(2.7rem * var(--font-scale));
  line-height: 1.9;
  text-align: right;
  direction: rtl;
}
.ayah-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  margin: 0 6px 0 10px;
  vertical-align: middle;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 650;
  position: relative;
}
.ayah-mark::after {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid var(--ink);
  border-radius: 50%;
  opacity: 0.45;
}

.tr-text {
  font-size: calc(1.12rem * var(--font-scale));
  line-height: 1.7;
  max-width: 46rem;
}
.el-text { margin: 0; }
.en-text { margin: 8px 0 0; color: var(--muted); }
.verse-foot {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.bismillah {
  text-align: center;
  padding: 8px 0 22px;
  scroll-margin-top: calc(var(--top) + var(--sub) + 12px);
}
.bismillah .ar {
  font-family: var(--naskh);
  font-size: calc(2.1rem * var(--font-scale));
  color: var(--ink);
}
.bismillah .el {
  color: var(--muted);
  margin-top: 8px;
}
.bismillah.is-current,
.verse.is-current {
  background: var(--playing);
  border-radius: 16px;
  padding-inline: 12px;
}

body.hide-ar .ar-line,
body.hide-ar .bismillah .ar,
body.hide-el .el-text,
body.hide-el .bismillah .el,
body.hide-en .en-text { display: none; }

.nav-chapters {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 28px;
}
.nav-chapters a {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
}
.nav-chapters small { color: var(--muted); display: block; margin-bottom: 4px; }

.sheet {
  position: fixed; inset: 0; z-index: 12;
  background: rgba(0, 0, 0, 0.45);
  display: grid; place-items: end center;
}
.sheet[hidden] { display: none; }
.sheet-card {
  width: min(460px, 100%);
  background: var(--bg-elev);
  border-radius: 20px 20px 0 0;
  padding: 18px 18px 28px;
  border: 1px solid var(--line);
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet-head h2 { margin: 0; font-size: 18px; }
.sheet-label {
  margin: 18px 0 8px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.info-rows { display: grid; gap: 10px; margin-top: 8px; }
.info-rows div {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.info-rows dt { color: var(--muted); }
.chips, .font-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 8px 14px;
}
.chip.is-on { background: var(--accent); color: #102224; border-color: transparent; }
.hint { color: var(--muted); font-size: 13px; line-height: 1.5; }

.player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 7;
  background: var(--bg);
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.18);
}
.player[hidden] { display: none; }
.seek-track {
  position: absolute;
  left: 0; right: 0; top: -6px;
  height: 12px;
  display: flex;
  align-items: center;
}
#seek {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  margin: 0;
  background: var(--line);
  outline: none;
  cursor: pointer;
}
#seek::-webkit-slider-runnable-track {
  height: 4px;
  background: linear-gradient(to right, var(--accent) var(--seek, 0%), var(--line) var(--seek, 0%));
  border-radius: 99px;
}
#seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px; height: 12px;
  margin-top: -4px;
  border-radius: 50%;
  background: var(--accent);
  border: 0;
  opacity: 0;
}
.seek-track:hover #seek::-webkit-slider-thumb { opacity: 1; }
#seek::-moz-range-track {
  height: 4px;
  background: var(--line);
  border-radius: 99px;
}
#seek::-moz-range-progress {
  height: 4px;
  background: var(--accent);
  border-radius: 99px;
}
#seek::-moz-range-thumb {
  width: 12px; height: 12px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
}
.player-inner {
  max-width: var(--max);
  margin: 0 auto;
  min-height: var(--player);
  padding: 10px 16px 12px;
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
}
.time {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
#time-duration { text-align: right; }
.player-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.ctrl {
  width: 40px; height: 40px; border-radius: 999px;
  display: grid; place-items: center;
  color: var(--ink);
  background: transparent;
  border: 0;
}
.ctrl:hover { background: var(--card); }
.play-main { width: 44px; height: 44px; }
.more-wrap { position: relative; }
.more-menu {
  position: absolute;
  bottom: 48px;
  left: 50%;
  transform: translateX(-20%);
  width: 240px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
  text-align: left;
  z-index: 8;
}
.more-menu button,
.more-row {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: transparent;
  border: 0;
  color: var(--ink);
  padding: 10px 8px;
  border-radius: 8px;
  font-size: 14px;
}
.more-menu > button:hover { background: var(--card); }
.more-menu > button[aria-pressed="true"] { color: var(--accent); }
.speed-pills { display: flex; gap: 4px; }
.speed-pills button {
  width: auto;
  padding: 4px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font-size: 12px;
}
.speed-pills button.is-on {
  background: var(--accent);
  color: #102224;
  border-color: transparent;
}
.reciter-row strong { font-weight: 600; }
body.is-muted .i-vol { display: none; }
body:not(.is-muted) .i-mute { display: none; }
.empty { color: var(--muted); padding: 40px 0; }

@media (max-width: 860px) {
  .surah-list { grid-template-columns: 1fr; }
  .chapter-card {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .chapter-ar {
    font-size: 2.4rem;
    text-align: right;
    width: 100%;
  }
  .chapter-actions { min-width: 0; width: 100%; }
  .subnav-inner { grid-template-columns: 1fr auto; }
  .subnav-meta { display: none; }
  .player-inner { grid-template-columns: 44px 1fr 44px; padding-inline: 10px; }
  .ctrl { width: 36px; height: 36px; }
  .player-controls { gap: 2px; }
  .ar-line { font-size: calc(1.55rem * var(--font-scale)); overflow-wrap: anywhere; }
  .ayah-mark { width: 28px; height: 28px; font-size: 11px; }
  .tr-text, .el-text { overflow-wrap: anywhere; }
  .search-wrap { min-width: 0; width: 42px; padding-inline: 11px; }
  .search-wrap input { display: none; }
  .search-wrap:focus-within { width: min(70vw, 240px); }
  .search-wrap:focus-within input { display: block; }
}
