:root {
  --bg: #0f1d17; --bar: #13261e; --bar2: #1a3328; --gold: #d4af37; --text: #f1ead2;
  --muted: #9fb3a8; --btn: #21402f; --btnh: #2c5540; --accent: #3fa36b; --panel: 380px; --card: #0b1612;
}
body.light { --bg: #e9e2cf; --bar: #2a4a3a; --bar2: #345a47; --btn: #3c6a53; --btnh: #4b8066; --card: #f8f3e3; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: "Segoe UI", Tahoma, sans-serif; overflow: hidden; user-select: none; }
header { height: 54px; display: flex; align-items: center; gap: 6px; padding: 0 12px;
  background: linear-gradient(var(--bar2), var(--bar)); border-bottom: 2px solid var(--gold); }
.title { font-size: 20px; color: var(--gold); font-weight: 600; margin-right: 8px; white-space: nowrap; }
.grow { flex: 1; }
button, select, input { font: inherit; font-size: 14px; color: var(--text); background: var(--btn);
  border: 1px solid #ffffff22; border-radius: 8px; padding: 6px 10px; cursor: pointer; }
select option { background: #13261e; }
button:hover, select:hover { background: var(--btnh); }
button.on { background: var(--accent); border-color: var(--gold); }
input[type=number] { width: 64px; cursor: text; }
.grp { display: flex; gap: 6px; align-items: center; padding: 0 6px; border-left: 1px solid #ffffff22; }

main { position: absolute; top: 56px; bottom: 44px; left: 0; right: 0; display: flex;
  align-items: center; justify-content: center; transition: right .2s; }
body.panel main { right: var(--panel); }
.nav { position: absolute; top: 50%; transform: translateY(-50%); width: 50px; height: 120px; font-size: 34px;
  background: #00000040; border: none; border-radius: 12px; z-index: 5; }
.nav:hover { background: #00000080; }
#prevBtn { right: 8px; } #nextBtn { left: 8px; }
#book { display: flex; flex-direction: row-reverse; height: 100%; padding: 10px 64px;
  align-items: center; justify-content: center; }
.page { position: relative; height: 100%; display: flex; align-items: center; cursor: pointer; }
.page canvas { height: 100%; max-width: 100%; object-fit: contain; display: block;
  box-shadow: 0 6px 24px #000a; background: #fffbe8; }
#loading { position: fixed; inset: 0; background: var(--bg); display: none; align-items: center; justify-content: center;
  z-index: 25; font-size: 22px; color: var(--gold); text-align: center; direction: rtl; line-height: 2; }
#loading.show { display: flex; }
#loading p { font-size: 16px; color: var(--text); }
.pickbtn { display: inline-block; background: var(--accent); color: #fff; padding: 10px 26px; border-radius: 10px; cursor: pointer; font-size: 18px; }
#book.two .page { max-width: 50%; }
.cover { position: absolute; background: repeating-linear-gradient(45deg,#1d3a2c,#1d3a2c 12px,#234634 12px,#234634 24px);
  border-top: 3px solid var(--gold); display: none; pointer-events: none; }
body.hifz .cover { display: block; }

aside { position: absolute; top: 56px; bottom: 44px; right: 0; width: var(--panel); background: var(--bar);
  border-left: 2px solid var(--gold); display: none; flex-direction: column; direction: rtl; }
body.panel aside { display: flex; }
.tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; padding: 6px;
  background: var(--bar2); border-bottom: 1px solid #00000033; box-shadow: 0 2px 6px #0003; flex: 0 0 auto; }
.tabs button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-width: 0;
  padding: 5px 2px 4px; font-size: 12px; line-height: 1.25; color: #e3eadf; background: #ffffff0d;
  border: 1px solid #ffffff14; border-radius: 9px; transition: background .15s, border-color .15s, transform .1s; }
.tabs button:hover { background: #ffffff1f; border-color: #ffffff30; }
.tabs button:active { transform: scale(.97); }
.tabs button.on { background: var(--accent); color: #fff; border-color: var(--gold); box-shadow: 0 2px 8px #0005, inset 0 -2px 0 var(--gold); font-weight: 600; }
.tabs .ti { font-size: 18px; line-height: 1.15; }
.tabs .tl { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-height: 820px) {   /* short screens: icon beside label to save height */
  .tabs button { flex-direction: row; gap: 4px; padding: 6px 2px; }
  .tabs .ti { font-size: 15px; }
}
.tab { display: none; padding: 10px 14px; overflow-y: auto; flex: 1; font-size: 14px; }
.tab.on { display: block; }
.row { display: flex; align-items: center; gap: 8px; margin: 7px 0; }
.row label { min-width: 62px; color: var(--muted); }
.row select { flex: 1; min-width: 0; }
.chk { display: block; margin: 8px 0; line-height: 1.5; cursor: pointer; }
.note { color: var(--muted); font-size: 12.5px; line-height: 1.6; }
.ayahbox { background: var(--card); border: 1px solid var(--gold); border-radius: 12px; padding: 12px; margin: 6px 0 10px; min-height: 90px; }
.arabic { font-family: "Traditional Arabic", "Amiri", "Scheherazade New", "Segoe UI"; font-size: 28px; line-height: 1.9;
  text-align: center; color: var(--text); direction: rtl; }
body.light .arabic { color: #1b2a22; }
.arabic.blur { filter: blur(9px); }
.tr { font-size: 14.5px; line-height: 1.8; color: var(--muted); text-align: right; margin-top: 6px; }
.info { text-align: center; color: var(--gold); font-size: 13.5px; margin-top: 6px; }
.ctrl { display: flex; gap: 8px; justify-content: center; margin: 8px 0; }
.ctrl button { min-width: 48px; font-size: 18px; }
button.big { font-size: 22px; min-width: 70px; background: var(--accent); }
button.wide { display: block; width: 100%; margin: 8px 0; padding: 9px; }
button.good { background: #2f7d4f; } button.bad { background: #8a3a32; }
.stats { display: flex; gap: 8px; margin: 4px 0 8px; }
.stats div { flex: 1; background: var(--card); border: 1px solid #ffffff22; border-radius: 10px; text-align: center; padding: 8px 2px; }
.stats b { display: block; font-size: 24px; color: var(--gold); }
.stats span { font-size: 12px; color: var(--muted); }
#paraGrid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; margin: 8px 0; }
#paraGrid button { padding: 6px 0; font-size: 13px; }
#paraGrid button.s1 { background: #8a7420; } #paraGrid button.s2 { background: #2f7d4f; border-color: var(--gold); }
.goalbar { height: 10px; background: #ffffff15; border-radius: 6px; overflow: hidden; }
#goalFill { height: 100%; width: 0; background: var(--gold); transition: width .3s; }
#log div { font-size: 13px; padding: 4px 0; border-bottom: 1px solid #ffffff12; color: var(--muted); }
#rList .rec { background: var(--card); border-radius: 10px; padding: 8px; margin: 8px 0; }
#rList audio { width: 100%; }
#rList .rec div { display: flex; gap: 6px; margin-top: 6px; }
#rList .rec button { flex: 1; font-size: 13px; }
#rBtn.recording { background: #a33; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .65; } }

footer { position: absolute; bottom: 0; left: 0; right: 0; height: 44px; display: flex; align-items: center;
  gap: 12px; padding: 0 14px; background: var(--bar); border-top: 1px solid #ffffff22; font-size: 14px; color: var(--muted); }
#slider { flex: 1; direction: rtl; accent-color: var(--gold); }
#status b { color: var(--gold); }
.toast { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); background: #000d; color: #fff;
  padding: 8px 18px; border-radius: 20px; opacity: 0; transition: opacity .3s; pointer-events: none; z-index: 20; }
.toast.show { opacity: 1; }
#help { position: fixed; inset: 0; background: #000b; display: none; align-items: center; justify-content: center; z-index: 30; }
#help.show { display: flex; }
#help > div { background: var(--bar); border: 2px solid var(--gold); border-radius: 14px; padding: 22px 30px; max-width: 640px; line-height: 2; direction: rtl; }
#help h2 { margin: 0 0 8px; color: var(--gold); }
kbd { background: #ffffff22; border-radius: 4px; padding: 1px 6px; }
