@font-face {
  font-family: 'Amiri Quran Local';
  src: url('../fonts/amiri-quran.woff2') format('woff2');
  font-display: block;
}

:root {
  --paper: #f7f3ea;
  --page: #fffdf7;
  --ink: #1d2b27;
  --muted: #6b7a74;
  --gold: #a8843a;
  --gold-soft: rgba(168, 132, 58, .18);
  --line: #e4dccb;
  --red: #d6362c;
  --green: #1f5c4a;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: 'Tajawal', system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.screen { display: none; min-height: 100dvh; }
.screen.active { display: flex; flex-direction: column; }
.screen.center { align-items: center; justify-content: center; padding: 24px; text-align: center; }

.brand { font-family: 'Amiri', serif; font-size: 64px; line-height: 1.1; }
.brand.small { font-size: 40px; margin-bottom: 4px; }
.lead { font-size: 18px; margin: 6px 0 18px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.hint { color: var(--muted); font-size: 13px; min-height: 1em; margin: 6px 0 0; }

.card {
  width: 100%; max-width: 420px;
  background: var(--page);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px 24px;
  box-shadow: 0 10px 30px rgba(29, 43, 39, .06);
  text-align: center;
}
.card label { display: block; text-align: right; font-weight: 500; margin: 14px 0 6px; font-size: 15px; }
.card input, .card select, dialog select {
  width: 100%; font: inherit; font-size: 16px;
  padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
}
.card input:focus, .card select:focus { outline: 2px solid var(--gold-soft); border-color: var(--gold); }

.btn {
  display: block; width: 100%; margin-top: 18px;
  font: inherit; font-size: 17px; font-weight: 700;
  padding: 14px; border-radius: 14px; border: 0; cursor: pointer;
}
.btn.primary { background: var(--green); color: #fff; }
.btn.primary:active { transform: translateY(1px); }
.btn.link { background: none; color: var(--muted); font-weight: 500; margin-top: 8px; }

.majlis-name { font-family: 'Amiri', serif; font-size: 30px; font-weight: 700; margin: 4px 0; }

/* ===== صفحة التلاوة ===== */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(247, 243, 234, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.live { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; min-width: 0; }
.live span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot {
  width: 12px; height: 12px; border-radius: 50%; flex: none;
  background: var(--red);
  box-shadow: 0 0 0 0 rgba(214, 54, 44, .6);
  animation: blink 1.4s ease-in-out infinite;
}
@keyframes blink {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(214, 54, 44, .55); }
  50% { opacity: .15; box-shadow: 0 0 0 6px rgba(214, 54, 44, 0); }
}
.meta { color: var(--muted); font-size: 14px; white-space: nowrap; }
.meta .sep { margin: 0 6px; }

.mushaf-wrap { flex: 1; padding: 16px 12px 8px; }
.mushaf-page {
  max-width: 680px; margin: 0 auto;
  background: var(--page);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 22px 20px 26px;
  box-shadow: 0 1px 0 var(--line), 0 12px 30px rgba(29, 43, 39, .05);
  font-family: 'Amiri Quran Local', 'Amiri Quran', serif;
  font-size: clamp(22px, 5.6vw, 30px);
  line-height: 2.25;
  text-align: justify;
  text-align-last: center;
}
.surah-head {
  display: block; text-align: center;
  font-family: 'Amiri', serif; font-weight: 700; font-size: .8em;
  border: 1px solid var(--gold); border-radius: 8px;
  margin: 10px 0 4px; padding: 0 0 2px;
  background: linear-gradient(var(--gold-soft), transparent);
}
.basmala { display: block; text-align: center; margin-bottom: 4px; }
.w { border-radius: 6px; padding: 0 1px; transition: background-color .25s, color .25s; }
.w.cur { background: var(--gold-soft); box-shadow: inset 0 -3px 0 var(--gold); }
.w.wrong { color: var(--red); }
.ayah-no { font-family: 'Amiri', serif; color: var(--gold); font-size: .8em; margin: 0 2px; }

.page-foot {
  display: flex; align-items: center; justify-content: center; gap: 18px;
  color: var(--muted); padding: 10px 0 4px; font-size: 15px;
}
.nav {
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--page); color: var(--ink);
  display: grid; place-items: center; cursor: pointer;
}

.controls {
  position: sticky; bottom: 0;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 10px 16px calc(14px + env(safe-area-inset-bottom));
  background: var(--paper);
  border-top: 1px solid var(--line);
}
.status { margin: 0; color: var(--muted); font-size: 14px; text-align: center; min-height: 1.4em; }
.mic {
  width: 66px; height: 66px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--green); color: #fff;
  display: grid; place-items: center;
  box-shadow: 0 8px 20px rgba(31, 92, 74, .3);
}
.mic svg { width: 30px; height: 30px; fill: currentColor; }
.mic.on { background: var(--red); box-shadow: 0 0 0 0 rgba(214, 54, 44, .5); animation: pulse 1.6s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 16px rgba(214, 54, 44, 0); } }

/* ===== النوافذ ===== */
dialog {
  border: 0; border-radius: 18px; padding: 0;
  width: min(92vw, 440px); background: var(--page); color: var(--ink);
}
dialog::backdrop { background: rgba(29, 43, 39, .45); }
.dialog-body { padding: 22px; text-align: right; }
.dialog-body h2 { margin: 0 0 10px; font-size: 20px; }
.tip { line-height: 1.8; margin: 0 0 10px; }
.tip.small { font-size: 14px; color: var(--muted); }
.dialog-body label { display: block; margin: 12px 0 6px; font-weight: 500; }
.meter-label { margin-top: 14px; font-size: 14px; }
.meter { height: 10px; background: #eee6d6; border-radius: 10px; overflow: hidden; margin-top: 8px; }
.meter > div { height: 100%; width: 0; background: var(--green); transition: width .08s; }
.row { display: flex; gap: 10px; }
.row .btn { margin-top: 16px; }

.overlay {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(247, 243, 234, .96);
  display: grid; place-items: center; padding: 24px;
}
.overlay[hidden] { display: none; }

.heard { margin: 0; font-size: 12px; color: var(--muted); opacity: .8; text-align: center; max-width: 680px; min-height: 1em; }
