:root {
  --bg: #f4f7f5;
  --surface: #ffffff;
  --surface-soft: #eef5f1;
  --primary: #11362a;
  --primary-mid: #1f5c47;
  --gold: #b8861e;
  --gold-bright: #d4af37;
  --gold-soft: #fbf5e6;
  --blue: #1d4ed8;
  --blue-soft: #eff6ff;
  --rose: #be123c;
  --rose-soft: #fff1f2;
  --purple: #6d28d9;
  --purple-soft: #f5f3ff;
  --text: #1c2824;
  --muted: #50645c;
  --border: #d5e2dc;
  --ar-scale: 1.0;
  --ms-scale: 1.0;
  --shadow: 0 6px 22px rgba(17, 54, 42, 0.08);
  --ar-font: 'Amiri', 'Traditional Arabic', 'Scheherazade New', serif;
}

body.dark {
  --bg: #0c1914;
  --surface: #13251f;
  --surface-soft: #1a332b;
  --primary: #8be0be;
  --primary-mid: #52b788;
  --gold: #eab308;
  --gold-bright: #f5c542;
  --gold-soft: #292313;
  --blue: #93c5fd;
  --blue-soft: #172554;
  --rose: #fda4af;
  --rose-soft: #3f121d;
  --purple: #c4b5fd;
  --purple-soft: #2e1065;
  --text: #e8f1ed;
  --muted: #9eb5ac;
  --border: #264238;
  --shadow: 0 8px 26px rgba(0, 0, 0, 0.38);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.62;
}

.hidden { display: none !important; }

/* ===== TOPBAR ===== */
.topbar {
  background: linear-gradient(135deg, #0b241c 0%, #143d2f 60%, #1d5642 100%);
  color: #fff;
  padding: 12px 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 3px solid #d4af37;
  position: sticky;
  top: 0;
  z-index: 60;
}

.brand { display: flex; align-items: center; gap: 11px; }
.brand img {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  border: 1.5px solid #d4af37;
  background: #0d2b21;
}
.brand-title { font-size: 1.06rem; font-weight: 800; letter-spacing: -0.01em; }
.brand-ar {
  font-family: var(--ar-font);
  font-size: 1.35rem;
  color: #f6dc84;
  font-weight: 700;
  margin-left: 6px;
}
.brand-sub { font-size: 0.79rem; color: #cde5da; }

.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.btn {
  background: rgba(255, 255, 255, 0.13);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.28);
  padding: 6px 11px;
  border-radius: 8px;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.btn:hover, .btn.active {
  background: #d4af37;
  color: #11241d;
  border-color: #d4af37;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.scale-badge {
  background: rgba(0, 0, 0, 0.28);
  color: #f5d77f;
  padding: 5px 9px;
  border-radius: 7px;
  font-size: 0.79rem;
  font-weight: 700;
}

/* ===== 3-PILLAR MASTER SWITCHER ===== */
.pillar-bar {
  background: #102e24;
  padding: 10px 16px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  border-bottom: 1px solid rgba(212, 175, 55, 0.35);
}
.pillar-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: 12px;
  border: 1.5px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
  color: #dceee6;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.16s ease;
}
.pillar-btn:hover {
  background: rgba(212, 175, 55, 0.2);
  border-color: #d4af37;
  color: #fff;
}
.pillar-btn.active {
  background: linear-gradient(135deg, #d4af37, #f1cf65);
  color: #11241d;
  border-color: #f6dc84;
  box-shadow: 0 4px 14px rgba(212, 175, 55, 0.32);
}
.pillar-pill-tag {
  font-size: 0.71rem;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.2);
  color: inherit;
  font-weight: 800;
}
.pillar-btn.active .pillar-pill-tag {
  background: rgba(17, 36, 29, 0.18);
}

/* ===== VOICE STRIP ===== */
.voice-strip {
  background: var(--gold-soft);
  border-bottom: 1px solid var(--border);
  padding: 7px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 0.84rem;
}

/* ===== SUB-TABS ===== */
.nav-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  justify-content: center;
}
.tab-btn {
  background: var(--surface-soft);
  color: var(--primary);
  border: 1.5px solid var(--border);
  padding: 7px 14px;
  border-radius: 999px;
  font: inherit;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.tab-btn:hover { border-color: var(--gold); }
.tab-btn.active {
  background: #11362a;
  color: #fff;
  border-color: #11362a;
}
body.dark .tab-btn.active {
  background: #52b788;
  color: #0c1914;
  border-color: #52b788;
}

/* ===== CONTAINER ===== */
.container {
  max-width: 1140px;
  margin: 18px auto 48px;
  padding: 0 16px;
}

/* ===== COMMON CARDS & TEXT ===== */
.hero {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  padding: 16px 20px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.ms-text { font-size: calc(0.96rem * var(--ms-scale)); }
.ar-inline {
  font-family: var(--ar-font);
  font-size: calc(1.7rem * var(--ar-scale));
  font-weight: 700;
  color: var(--primary);
  padding: 0 3px;
}

.info-panel, .info-section {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.info-header, .info-head {
  background: linear-gradient(90deg, #11362a, #1f5c47);
  color: #fff;
  padding: 12px 18px;
  font-weight: 700;
  font-size: calc(1rem * var(--ms-scale));
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.info-head h2 { margin: 0; font-size: calc(1rem * var(--ms-scale)); }
.info-head .ar-h { font-family: var(--ar-font); font-size: calc(1.42rem * var(--ar-scale)); color: #f6dc84; }
.info-body { padding: 18px; }

.info-grid-2, .grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  gap: 14px;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}
.grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}

/* ===== PILLAR 1: TAJWID ===== */
.rule-box {
  border-radius: 12px;
  padding: 13px 15px;
  border: 1.5px solid var(--border);
  background: var(--surface-soft);
  overflow-wrap: break-word;
}
.rule-box h4 {
  margin: 0 0 6px;
  font-size: calc(0.97rem * var(--ms-scale));
  color: var(--primary);
}
.ar-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 8px;
  direction: rtl;
}
.ar-chip {
  background: var(--surface);
  border: 1.5px solid var(--primary-mid);
  color: var(--primary);
  border-radius: 8px;
  padding: 4px 11px;
  font-family: var(--ar-font);
  font-size: calc(1.85rem * var(--ar-scale));
  font-weight: 700;
  cursor: pointer;
}
.ar-chip:hover { background: #d4af37; color: #11241d; border-color: #b8861e; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}
.toolbar input {
  flex: 1 1 260px;
  padding: 9px 13px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
}

.lesson-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.lesson-head {
  background: linear-gradient(135deg, #133c2e, #1f5c47);
  color: #fff;
  padding: 14px 18px;
}
.lesson-head.adv { background: linear-gradient(135deg, #1d3557, #2b547e); }
.badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.2);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.77rem;
  font-weight: 700;
}
.lesson-body { padding: 18px; }
.lesson-illus {
  width: 100%;
  max-height: 500px;
  object-fit: contain;
  background: #f7fbf9;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 14px;
  display: block;
}
.musyafahah-box {
  background: var(--gold-soft);
  border-left: 4px solid var(--gold);
  padding: 12px 15px;
  border-radius: 8px;
  margin: 12px 0;
  font-size: calc(0.93rem * var(--ms-scale));
}
.examples-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 11px;
  margin-top: 14px;
}
.ex-item {
  background: var(--surface-soft);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.ex-ar {
  font-family: 'Amiri Quran', 'Scheherazade New', var(--ar-font);
  font-size: calc(2.1rem * var(--ar-scale));
  color: var(--primary);
  font-weight: 400;
  direction: rtl;
  line-height: 2.05;
}
.ex-note {
  font-size: calc(0.84rem * var(--ms-scale));
  color: var(--muted);
  margin: 6px 0 8px;
}
.audio-pair { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.speak-btn {
  background: #11362a;
  color: #fff;
  border: none;
  padding: 6px 11px;
  border-radius: 7px;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}
.speak-btn:hover { background: #1e5b46; }
.speak-btn.slow { background: #2d6a4f; }

.letters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(calc(104px * var(--ar-scale)), 1fr));
  gap: 10px;
  margin: 14px 0;
  direction: rtl;
}
.let-btn {
  background: var(--surface-soft);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 10px 6px;
  min-height: calc(100px * var(--ar-scale));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
}
.let-btn .let-ch {
  font-family: var(--ar-font);
  font-size: calc(2.55rem * var(--ar-scale));
  font-weight: 700;
  color: var(--primary);
  line-height: 1.5;
}
.let-btn .let-nm {
  font-size: calc(0.75rem * var(--ms-scale));
  font-weight: 600;
  color: var(--muted);
  direction: ltr;
  margin-top: 4px;
}
.let-btn:hover, .let-btn.active { background: #d4af37; border-color: #b8861e; }
.let-btn:hover .let-ch, .let-btn.active .let-ch,
.let-btn:hover .let-nm, .let-btn.active .let-nm { color: #11241d; }

.letter-detail {
  background: var(--surface);
  border: 2px solid var(--gold);
  border-radius: 14px;
  padding: 18px;
  margin-top: 14px;
}

.quiz-opt {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  margin: 7px 0;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  font: inherit;
  font-size: calc(0.93rem * var(--ms-scale));
  font-weight: 600;
  cursor: pointer;
}
.quiz-opt:hover { border-color: var(--gold); }
.quiz-opt.correct { background: #d1fae5; border-color: #059669; color: #064e3b; }
.quiz-opt.wrong { background: #fee2e2; border-color: #dc2626; color: #7f1d1d; }

.musyafahah-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: #fef3c7;
  color: #92400e;
  border: 1.5px solid #d97706;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: calc(0.75rem * var(--ms-scale));
  font-weight: 700;
  margin: 4px auto 8px;
}
body.dark .musyafahah-tag { background: #451a03; color: #fde68a; border-color: #f59e0b; }

.tts-notice {
  background: #fffbeb;
  border: 1.5px solid #f59e0b;
  color: #78350f;
  border-radius: 10px;
  padding: 9px 14px;
  margin-bottom: 14px;
  font-size: calc(0.86rem * var(--ms-scale));
  display: flex;
  align-items: center;
  gap: 8px;
}
body.dark .tts-notice { background: #291d0a; border-color: #d97706; color: #fde68a; }

/* ===== PILLAR 2: TUHFATUL ATFAL ===== */
.hero-banner {
  background: linear-gradient(135deg, #0d2b21 0%, #174938 60%, #1f5c47 100%);
  color: #fff;
  border-radius: 18px;
  padding: 20px 24px;
  margin-bottom: 18px;
  border: 1.5px solid #d4af37;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
}
.hero-ar {
  font-family: var(--ar-font);
  font-size: calc(2.15rem * var(--ar-scale));
  color: #f7df8b;
  line-height: 1.35;
  margin: 0;
}
.hero-meta { color: #d5ece2; font-size: calc(0.9rem * var(--ms-scale)); margin: 6px 0 0; }
.stat-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.stat-chip {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(212, 175, 55, 0.55);
  border-radius: 12px;
  padding: 8px 14px;
  text-align: center;
  min-width: 96px;
}
.stat-chip strong { display: block; font-size: 1.22rem; color: #f7df8b; line-height: 1.1; }
.stat-chip span { font-size: 0.74rem; color: #d7eee4; }

.roadmap { display: grid; grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); gap: 10px; }
.rm-node {
  background: var(--surface-soft);
  border: 1.5px solid var(--border);
  border-top: 4px solid var(--primary-mid);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease;
}
.rm-node:hover { transform: translateY(-2px); border-color: var(--gold); }
.rm-num { font-size: 0.72rem; font-weight: 800; color: var(--gold); text-transform: uppercase; }
.rm-ar { font-family: var(--ar-font); font-size: calc(1.3rem * var(--ar-scale)); font-weight: 700; color: var(--primary); direction: rtl; line-height: 1.4; }
.rm-bm { font-size: 0.82rem; font-weight: 700; color: var(--text); }
.rm-rng { font-size: 0.74rem; color: var(--muted); }

.rule-card {
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  background: var(--surface-soft);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rule-card.gold { background: var(--gold-soft); border-color: var(--gold); }
.rule-card.blue { background: var(--blue-soft); border-color: var(--blue); }
.rule-card.rose { background: var(--rose-soft); border-color: var(--rose); }
.rule-card.purple { background: var(--purple-soft); border-color: var(--purple); }
.rule-top { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.rule-title { font-weight: 800; font-size: calc(0.95rem * var(--ms-scale)); color: var(--primary); }
.rule-badge {
  font-size: 0.73rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.ar-big {
  font-family: var(--ar-font);
  font-size: calc(1.85rem * var(--ar-scale));
  font-weight: 700;
  direction: rtl;
  text-align: center;
  color: var(--primary);
  line-height: 1.65;
}
.ar-letters { display: flex; flex-wrap: wrap; gap: 6px; direction: rtl; justify-content: center; }
.l-pill {
  font-family: var(--ar-font);
  font-size: calc(1.55rem * var(--ar-scale));
  font-weight: 700;
  min-width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  color: var(--primary);
}
.l-pill.hl { background: #d4af37; color: #11241d; border-color: #b8861e; }

.mnemonic-box {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface);
  border: 1.5px dashed var(--gold);
  text-align: center;
}
.mnemonic-words { display: flex; flex-wrap: wrap; gap: 8px; direction: rtl; justify-content: center; margin-top: 8px; }
.m-word {
  font-family: var(--ar-font);
  font-size: calc(1.7rem * var(--ar-scale));
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 8px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
}
.m-word .first { color: #be123c; text-decoration: underline; text-underline-offset: 5px; }
body.dark .m-word .first { color: #facc15; }

.callout-warn {
  margin-top: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--rose-soft);
  border-left: 4px solid var(--rose);
  font-size: calc(0.87rem * var(--ms-scale));
}
.callout-tip {
  margin-top: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--gold-soft);
  border-left: 4px solid var(--gold);
  font-size: calc(0.87rem * var(--ms-scale));
}

table.mat-tbl, table.cmp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: calc(0.88rem * var(--ms-scale));
  margin-top: 8px;
}
table.mat-tbl th, table.mat-tbl td,
table.cmp-table th, table.cmp-table td {
  border: 1px solid var(--border);
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
}
table.mat-tbl th, table.cmp-table th { background: #11362a; color: #fff; }
table.mat-tbl tr:nth-child(even), table.cmp-table tr:nth-child(even) { background: var(--surface-soft); }

.jummal-row { display: flex; flex-wrap: wrap; gap: 6px; direction: rtl; justify-content: center; margin: 10px 0; }
.j-box { min-width: 52px; padding: 6px 8px; border-radius: 9px; background: var(--surface); border: 1.5px solid var(--gold); text-align: center; }
.j-box .ch { display: block; font-family: var(--ar-font); font-size: 1.65rem; font-weight: 700; color: var(--primary); line-height: 1.2; }
.j-box .val { display: block; font-size: 0.78rem; font-weight: 800; color: var(--gold); }

.filter-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; align-items: center; }
.filter-row input, .filter-row select {
  padding: 9px 12px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
}
.filter-row input { flex: 1 1 240px; }

.sec-divider {
  background: linear-gradient(90deg, #11362a, #1f5c47);
  color: #fff;
  padding: 11px 16px;
  border-radius: 12px;
  margin: 18px 0 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.sec-divider .ar { font-family: var(--ar-font); font-size: calc(1.5rem * var(--ar-scale)); color: #f6dc84; font-weight: 700; }

.bait-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 14px 18px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.bait-card.playing-bait {
  border-color: var(--gold-bright);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.30);
  background: var(--gold-soft);
}
.bait-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.bait-head-left { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bait-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.bait-time-tag {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 999px;
}
.speak-mini.song {
  background: #11362a;
  color: #fff;
  border-color: #11362a;
}
.speak-mini.song:hover { background: #1e5b46; color: #fff; border-color: #1e5b46; }
.speak-mini.loop-on {
  background: #d4af37;
  color: #11241d;
  border-color: #b8861e;
}
.tapsync-panel {
  margin-top: 12px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--surface-soft);
  border: 2px dashed var(--gold);
}
.tapsync-next {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  margin: 10px 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.tapsync-big-btn {
  width: 100%;
  padding: 13px 16px;
  border-radius: 12px;
  border: 2px solid #b8861e;
  background: linear-gradient(135deg, #d4af37, #f1cf65);
  color: #11241d;
  font: inherit;
  font-size: 0.96rem;
  font-weight: 800;
  cursor: pointer;
  margin-bottom: 10px;
}
.tapsync-big-btn:hover { filter: brightness(1.04); }
.bait-no {
  font-size: 0.78rem;
  font-weight: 800;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--gold);
  border: 1px solid var(--gold);
}
.bait-ar-line {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  direction: rtl;
  font-family: var(--ar-font);
  font-size: calc(2rem * var(--ar-scale));
  font-weight: 700;
  color: var(--primary);
  line-height: 1.75;
  padding: 6px 0;
}
.bait-sadr { text-align: left; }
.bait-ajuz { text-align: right; }
.bait-sep { color: var(--gold); font-size: 1.35rem; }
.bait-bm {
  font-size: calc(0.93rem * var(--ms-scale));
  color: var(--muted);
  border-top: 1px dashed var(--border);
  padding-top: 8px;
  margin-top: 6px;
}
.speak-mini {
  background: var(--surface-soft);
  color: var(--primary);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 7px;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}
.speak-mini:hover { background: #d4af37; color: #11241d; border-color: #b8861e; }

/* ===== TUHFAH NAZAM YOUTUBE HAFALAN DECK ===== */
.nazam-deck {
  background: var(--surface);
  border: 1.5px solid var(--gold);
  border-radius: 16px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.nazam-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.nazam-tracks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.nazam-track-btn {
  flex: 1 1 250px;
  text-align: left;
  padding: 9px 13px;
  border-radius: 11px;
  border: 1.5px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}
.nazam-track-btn small {
  display: block;
  font-weight: 500;
  color: var(--muted);
  font-size: 0.77rem;
  margin-top: 2px;
}
.nazam-track-btn.active {
  background: linear-gradient(135deg, #11362a, #1f5c47);
  color: #fff;
  border-color: #d4af37;
}
.nazam-track-btn.active small { color: #d8eee4; }
.nazam-stage {
  display: grid;
  grid-template-columns: minmax(260px, 420px) 1fr;
  gap: 14px;
  align-items: start;
}
.nazam-stage.compact {
  grid-template-columns: 200px 1fr;
}
.nazam-video-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #0b241c;
  border-radius: 12px;
  overflow: hidden;
  border: 1.5px solid var(--border);
}
.nazam-video-wrap iframe,
.nazam-video-wrap #ytNazamPlayer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.nazam-ctrl-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.nazam-ctrl-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}
.nazam-pill {
  background: var(--surface-soft);
  color: var(--primary);
  border: 1px solid var(--border);
  padding: 6px 11px;
  border-radius: 8px;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}
.nazam-pill:hover { border-color: var(--gold); }
.nazam-pill.active {
  background: #d4af37;
  color: #11241d;
  border-color: #b8861e;
}
.nazam-pill.primary {
  background: #11362a;
  color: #fff;
  border-color: #11362a;
}
.nazam-pill.primary:hover { background: #1e5b46; }
.nazam-ab-status {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--gold);
  background: var(--gold-soft);
  border: 1px dashed var(--gold);
  padding: 6px 10px;
  border-radius: 8px;
}
@media (max-width: 780px) {
  .nazam-stage, .nazam-stage.compact { grid-template-columns: 1fr; }
}

/* ===== PILLAR 3: STUDIO 7 MAQAM ===== */
.studio-deck {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.deck-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.stage-badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 12px; }
.stage-pill {
  font-size: 0.78rem;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  color: var(--muted);
  font-weight: 600;
}
.stage-pill.now {
  background: var(--gold-soft);
  border-color: var(--gold);
  color: var(--gold);
  font-weight: 700;
}
.deck-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.deck-controls audio { flex: 1 1 300px; max-width: 520px; height: 40px; }

.maqam-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 16px;
}
.m-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.15s, border-color 0.15s;
}
.m-card.playing {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.25);
}
.m-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.m-num {
  display: inline-block;
  background: #11362a;
  color: #f5d77f;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 6px;
  margin-bottom: 4px;
}
.m-title { font-size: 1.12rem; font-weight: 700; color: var(--primary); margin: 0; }
.m-arab { font-size: calc(1.38rem * var(--ar-scale)); font-weight: 700; color: var(--gold); font-family: var(--ar-font); }
.m-meta { font-size: calc(0.84rem * var(--ms-scale)); color: var(--muted); margin: 5px 0; }
.m-meta strong { color: var(--text); }
.m-ear {
  background: var(--surface-soft);
  border-left: 3px solid var(--primary-mid);
  padding: 8px 10px;
  border-radius: 6px;
  font-size: calc(0.83rem * var(--ms-scale));
  margin: 8px 0 12px;
}
.m-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.play-btn {
  flex: 1;
  background: #11362a;
  color: #fff;
  border: none;
  padding: 9px 12px;
  border-radius: 8px;
  font: inherit;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
}
.play-btn:hover { background: #1d5744; }
.piano-btn {
  background: var(--gold-soft);
  color: var(--text);
  border: 1px solid var(--gold);
  padding: 9px 11px;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
}
.piano-btn:hover { background: #d4af37; color: #11241d; }

.panel-box {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.scale-keys { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.key-btn {
  flex: 1 1 95px;
  min-height: 76px;
  background: var(--surface-soft);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 10px 8px;
  text-align: center;
  cursor: pointer;
  transition: 0.12s;
  font: inherit;
}
.key-btn:active, .key-btn.lit {
  background: #d4af37;
  color: #11241d;
  transform: translateY(2px);
  border-color: #b88924;
}
.key-btn.quarter {
  border-style: dashed;
  border-color: var(--gold);
  background: var(--gold-soft);
}

/* ===== AL-FATIHAH 7 MAQAM VIDEO CHAPTERS ===== */
.fatihah-maqam-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
  gap: 9px;
}
.fm-card {
  background: var(--surface-soft);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.fm-card.active {
  background: var(--gold-soft);
  border-color: var(--gold-bright);
  box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.28);
}
.fm-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
}
.fm-name { font-weight: 800; font-size: 0.9rem; color: var(--primary); }
.fm-ar { font-family: var(--ar-font); font-size: 1.25rem; font-weight: 700; color: var(--gold); }
.fm-time { font-size: 0.74rem; font-weight: 700; color: var(--muted); }
.fm-btns { display: flex; gap: 5px; flex-wrap: wrap; }
.fatihah-ayah-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
  direction: ltr;
}
.fatihah-ayah-row {
  background: var(--surface-soft);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 13px 16px;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(260px, 1.25fr);
  align-items: center;
  gap: 18px;
}
.fatihah-ayah-left {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  text-align: left;
  direction: ltr;
}
.fatihah-ayah-ms {
  font-size: calc(0.93rem * var(--ms-scale));
  color: var(--text);
  line-height: 1.58;
}
.fatihah-ayah-ar {
  font-family: 'Amiri Quran', 'Scheherazade New', 'Amiri', 'Traditional Arabic', serif;
  font-size: calc(2.05rem * var(--ar-scale));
  font-weight: 400;
  color: var(--primary);
  line-height: 2.2;
  text-align: right;
  direction: rtl;
}
.fatihah-ayah-end {
  color: var(--gold);
  font-size: 0.85em;
  margin-right: 4px;
}
.fatihah-ayah-num {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--gold-soft);
  border: 1.5px solid var(--gold);
  color: var(--gold);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 800;
  margin-top: 2px;
}
@media (max-width: 720px) {
  .fatihah-ayah-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .fatihah-ayah-ar { order: -1; }
}

/* ===== FOOTER ===== */
.app-footer {
  margin-top: 28px;
  padding: 18px 16px 26px;
  border-top: 1.5px solid var(--border);
  background: var(--surface);
  text-align: center;
  font-size: 0.84rem;
  color: var(--muted);
}
.app-footer strong { color: var(--primary); }

@media (max-width: 720px) {
  .hero-banner { grid-template-columns: 1fr; }
  .stat-chips { justify-content: flex-start; }
  .bait-ar-line { grid-template-columns: 1fr; text-align: center; gap: 2px; font-size: calc(1.75rem * var(--ar-scale)); }
  .bait-sadr, .bait-ajuz { text-align: center; }
  .pillar-btn { width: 100%; justify-content: center; }
}

@media print {
  .topbar, .pillar-bar, .voice-strip, .nav-tabs, .toolbar, .filter-row, .audio-pair, .speak-mini, .studio-deck, .nazam-deck, .m-actions { display: none !important; }
  .lesson-card, .info-section, .bait-card, .m-card { break-inside: avoid; box-shadow: none; }
}
