:root {
  --bg:#f5f8f6; --card:#ffffff; --ink:#17352c; --muted:#657a73;
  --green:#0d6b50; --green2:#14966f; --gold:#c99a35; --red:#d61717;
  --line:#dce7e2; --shadow:0 14px 40px rgba(20,70,55,.10);
}
*{box-sizing:border-box}
html,body{max-width:100%;overflow-x:hidden}
html{font-family:"Noto Naskh Arabic","Amiri","Segoe UI",Tahoma,Arial,sans-serif;background:var(--bg);color:var(--ink)}
body{margin:0;min-height:100vh;background:radial-gradient(circle at 85% 0,#e4f5ed 0,transparent 28%),var(--bg)}
button,select,input{font:inherit}
button{cursor:pointer}
.topbar{height:72px;display:flex;align-items:center;justify-content:space-between;padding:10px 20px;background:rgba(255,255,255,.92);border-bottom:1px solid var(--line);position:sticky;top:0;z-index:20;backdrop-filter:blur(10px)}
.brand{display:flex;gap:10px;align-items:center}.brand h1{font-size:20px;margin:0}.brand p{margin:2px 0 0;color:var(--muted);font-size:12px}.brand img{border-radius:12px}
.icon-btn,.small-btn{border:1px solid var(--line);background:#fff;border-radius:12px;padding:8px 12px;color:var(--ink)}
.layout{display:grid;grid-template-columns:280px minmax(0,1fr);width:100%;max-width:1280px;margin:auto;min-height:calc(100vh - 72px)}
.sidebar{border-left:1px solid var(--line);padding:18px 14px;background:rgba(255,255,255,.7)}
.sidebar-head{position:sticky;top:88px;background:rgba(245,248,246,.96);padding-bottom:10px;z-index:3}.sidebar h2{margin:0 0 10px}.sidebar input{width:100%;border:1px solid var(--line);border-radius:12px;padding:10px 12px;background:#fff;outline:none}.sidebar input:focus{border-color:var(--green2)}
.surah-list{display:grid;gap:7px;margin-top:8px}.surah-item{width:100%;border:1px solid transparent;background:transparent;border-radius:13px;padding:10px;display:flex;align-items:center;gap:10px;text-align:right;color:var(--ink)}.surah-item:hover{background:#eef7f3}.surah-item.active{background:#e3f3ec;border-color:#b9dfcf}.surah-item .n{width:34px;height:34px;display:grid;place-items:center;border-radius:10px;background:#fff;border:1px solid var(--line);font-family:"Segoe UI",Arial}.surah-item.active .n{background:var(--green);color:#fff}.surah-item small{display:block;color:var(--muted)}
.lesson{min-width:0;padding:24px clamp(14px,4vw,48px) 50px}.lesson-head{display:flex;justify-content:space-between;gap:20px;align-items:center}.reciter-card,.surah-title-wrap{display:flex;gap:12px;align-items:center}.reciter-avatar{width:64px;height:64px;border-radius:50%;overflow:hidden;background:#eaf3ef;border:2px solid #fff;box-shadow:var(--shadow)}.reciter-avatar img{width:100%;height:100%;object-fit:cover}.reciter-card strong,.reciter-card small{display:block}.eyebrow{font-size:12px;color:var(--muted)}.surah-title-wrap h2{font-size:30px;margin:0}.surah-number{width:56px;height:56px;display:grid;place-items:center;border-radius:17px;background:var(--green);color:#fff;font:700 18px "Segoe UI",Arial}
.mode-tabs{display:flex;gap:8px;margin:22px 0 12px}.mode{border:1px solid var(--line);background:#fff;border-radius:999px;padding:8px 18px}.mode.active{background:var(--ink);color:#fff;border-color:var(--ink)}
.ayah-stage{background:var(--card);border:1px solid var(--line);border-radius:28px;padding:22px clamp(16px,4vw,42px);box-shadow:var(--shadow);min-height:360px}.ayah-meta{display:flex;justify-content:space-between;align-items:center;color:var(--muted);font-size:13px}.status{padding:5px 10px;border-radius:999px;background:#edf3f0}.status.playing{background:#e0f6eb;color:#0b7b54}.status.repeat{background:#fff3d9;color:#8a5d00}.status.error{background:#ffe7e7;color:#a21414}
.ayah-text{min-height:150px;display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:.18em;padding:26px 5px 16px;font-size:clamp(38px,6.2vw,78px);line-height:1.95;text-align:center;direction:rtl}.word{display:inline-flex;white-space:nowrap;border-radius:12px;padding:0 .04em;transition:.16s}.word.active{background:#fff0f0}.grapheme{display:inline-block;transition:.12s}.grapheme.active-char{color:var(--red)!important;font-weight:900;transform:scale(1.12);text-shadow:0 1px 0 #fff}
.word-rail{display:flex;gap:8px;flex-wrap:wrap;justify-content:center;margin:0 0 16px}.word-chip{border:1px solid var(--line);background:#fafcfb;border-radius:999px;padding:6px 12px;font-size:18px}.word-chip.active{border-color:#efb1b1;background:#fff0f0;color:#b90f0f;font-weight:800}
.child-prompt{display:flex;gap:10px;align-items:center;border-top:1px dashed var(--line);padding-top:16px}.prompt-icon{font-size:26px}.child-prompt strong,.child-prompt small{display:block}.child-prompt small{color:var(--muted)}
.tajweed-panel{margin:6px 0 16px;padding:14px;border-radius:16px;background:#fbf9f1;border:1px solid #eee3c6}.tajweed-head{display:flex;justify-content:space-between;align-items:center}.link-btn{border:0;background:transparent;color:var(--green);text-decoration:underline}.tajweed-text{font-size:clamp(27px,3.6vw,46px);line-height:1.8;text-align:center;margin-top:10px}.tajweed-text .ham_wasl,.tajweed-text .slnt{color:#888}.tajweed-text .madda_normal{color:#537FFF}.tajweed-text .madda_permissible{color:#4050FF}.tajweed-text .madda_necessary{color:#000EBC}.tajweed-text .qlq{color:#DD0008}.tajweed-text .madda_obligatory{color:#2144C1}.tajweed-text .ikhf_shfw{color:#D500B7}.tajweed-text .ikhf{color:#9400A8}.tajweed-text .idghm_shfw{color:#58B800}.tajweed-text .iqlb{color:#26BFFD}.tajweed-text .idgh_ghn{color:#169777}.tajweed-text .idgh_w_ghn{color:#169200}.tajweed-text .idgh_mus{color:#7c7c7c}.tajweed-text .ghn{color:#FF7E1E}
.controls{margin-top:18px}.primary-controls{display:flex;justify-content:center;align-items:center;gap:12px}.round,.play{border:0;box-shadow:var(--shadow)}.round{width:44px;height:44px;border-radius:50%;background:#fff;color:var(--ink)}.play{min-width:170px;border-radius:999px;padding:13px 24px;background:var(--green);color:#fff;font-weight:800;font-size:18px}.play:hover{background:#0a5c45}.control-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:10px;margin-top:14px}.control-grid label,.action{background:#fff;border:1px solid var(--line);border-radius:15px;padding:10px 12px}.control-grid label span{display:block;color:var(--muted);font-size:12px}.control-grid select{border:0;background:transparent;width:100%;color:var(--ink);outline:none}.action{font-weight:800;color:var(--green)}.action.secondary{color:var(--ink)}
.progress-card{background:#fff;border:1px solid var(--line);border-radius:15px;padding:12px 14px;margin-top:14px}.progress-card>div:first-child{display:flex;justify-content:space-between}.progress-card span{color:var(--muted)}.progress-track{height:8px;background:#e8eeeb;border-radius:999px;margin-top:8px;overflow:hidden}.progress-track span{display:block;height:100%;width:0;background:var(--green2);transition:.2s}
.dialog{border:0;border-radius:20px;padding:0;max-width:620px;width:calc(100% - 30px);box-shadow:0 25px 80px rgba(0,0,0,.25)}.dialog::backdrop{background:rgba(12,35,29,.5)}.dialog form{padding:24px;position:relative}.dialog-close{position:absolute;left:16px;top:14px;border:0;background:#eef2f0;border-radius:50%;width:34px;height:34px}.legend-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin-top:16px}.legend-grid span{display:flex;align-items:center;gap:8px}.dot{width:14px;height:14px;border-radius:4px;background:currentColor}.dot.madda_normal{color:#537FFF}.dot.madda_permissible{color:#4050FF}.dot.madda_necessary{color:#000EBC}.dot.qlq{color:#DD0008}.dot.ghn{color:#FF7E1E}.dot.ikhf{color:#9400A8}.dot.iqlb{color:#26BFFD}.dot.idgh_ghn{color:#169777}.dialog-note{font-size:13px;color:var(--muted);background:#f6f7f6;padding:10px;border-radius:12px}.toast{position:fixed;bottom:20px;left:50%;transform:translateX(-50%) translateY(20px);background:#1f332c;color:#fff;padding:10px 16px;border-radius:12px;opacity:0;pointer-events:none;transition:.2s;z-index:40}.toast.show{opacity:1;transform:translateX(-50%) translateY(0)}
@media(max-width:900px){
  .layout{display:block;min-height:0}
  .sidebar{width:100%;overflow:hidden;border:0;border-bottom:1px solid var(--line);padding:10px 12px}
  .sidebar-head{position:static;display:grid;grid-template-columns:auto minmax(0,1fr);align-items:center;gap:10px;padding-bottom:4px}
  .sidebar h2{margin:0;white-space:nowrap;font-size:18px}
  .surah-list{display:flex;flex-wrap:nowrap;overflow-x:auto;overflow-y:hidden;gap:7px;width:100%;max-width:100%;padding:2px 0 7px;scroll-snap-type:x proximity;overscroll-behavior-inline:contain}
  .surah-item{flex:0 0 auto;min-width:140px;scroll-snap-align:start}
  .lesson{padding:14px clamp(10px,3vw,24px) 34px}
  .lesson-head{align-items:flex-start}
  .reciter-card{display:none}
  .ayah-stage{min-height:0}
  .control-grid{grid-template-columns:1fr 1fr}
  .surah-title-wrap h2{font-size:25px}
}
@media(max-width:520px){
  body{padding-bottom:env(safe-area-inset-bottom)}
  .topbar{height:60px;padding:6px 8px;gap:6px}
  .brand{gap:7px;min-width:0;flex:1;justify-content:center}
  .brand img{width:34px;height:34px}
  .brand h1{font-size:16px;white-space:nowrap}
  .brand p{display:none}
  .icon-btn,.small-btn{min-width:40px;min-height:40px;padding:7px 9px}
  .sidebar{padding:8px 8px 6px}
  .sidebar-head{grid-template-columns:auto minmax(0,1fr);gap:8px}
  .sidebar h2{font-size:16px}
  .sidebar input{min-width:0;padding:8px 10px;font-size:14px}
  .surah-list{gap:6px;margin-top:4px;padding-bottom:5px}
  .surah-item{min-width:124px;padding:7px 8px;gap:7px}
  .surah-item .n{width:30px;height:30px;border-radius:9px}
  .surah-item strong{font-size:14px}
  .surah-item small{font-size:11px}
  .lesson{padding:10px 8px 28px}
  .lesson-head{gap:8px}
  .surah-title-wrap{gap:8px}
  .surah-number{width:48px;height:48px;border-radius:14px}
  .surah-title-wrap h2{font-size:22px}
  .mode-tabs{margin:12px 0 8px;gap:6px}
  .mode{flex:1;padding:7px 10px}
  .ayah-stage{padding:12px 8px;border-radius:18px;min-height:0}
  .ayah-meta{gap:6px;flex-wrap:wrap}
  .status{font-size:12px;padding:4px 8px}
  .ayah-text{min-height:110px;font-size:clamp(30px,9.8vw,44px);line-height:1.75;padding:18px 2px 10px;gap:.12em}
  .word{padding:0 .02em;border-radius:8px}
  .grapheme.active-char{transform:scale(1.08)}
  .word-rail{flex-wrap:nowrap;justify-content:flex-start;overflow-x:auto;overflow-y:hidden;margin:0 -2px 12px;padding:0 2px 7px;overscroll-behavior-inline:contain}
  .word-chip{flex:0 0 auto;font-size:16px;padding:5px 10px}
  .child-prompt{padding-top:12px}
  .child-prompt small{font-size:12px}
  .controls{margin-top:12px}
  .primary-controls{gap:8px;width:100%}
  .play{min-width:0;flex:1;max-width:210px;padding:12px 16px;font-size:17px}
  .round{flex:0 0 44px}
  .control-grid{grid-template-columns:1fr 1fr;gap:8px;margin-top:10px}
  .control-grid label,.action{min-width:0;padding:9px 10px}
  .action{min-height:46px}
  .progress-card{margin-top:10px}
  .legend-grid{grid-template-columns:1fr}
  .dialog form{padding:20px 16px}
  .toast{max-width:calc(100% - 24px);width:max-content;text-align:center}
}
@media(max-width:380px){
  .brand img{display:none}
  .brand h1{font-size:15px}
  .sidebar-head{grid-template-columns:1fr}
  .sidebar h2{display:none}
  .ayah-stage{padding-inline:6px}
  .ayah-text{font-size:clamp(29px,9.6vw,38px);line-height:1.72}
  .surah-title-wrap h2{font-size:20px}
  .control-grid{grid-template-columns:1fr}
}
@media(min-width:901px){
  .layout{height:calc(100dvh - 72px);min-height:0;overflow:hidden}
  .sidebar{height:100%;overflow-y:auto;overscroll-behavior:contain}
  .lesson{height:100%;overflow-y:auto;overscroll-behavior:contain}
}
@media(min-width:901px){
  .lesson{padding:16px clamp(20px,3vw,40px) 22px}
  .lesson-head{gap:16px}
  .reciter-avatar{width:56px;height:56px}
  .surah-number{width:52px;height:52px}
  .surah-title-wrap h2{font-size:27px}
  .mode-tabs{margin:10px 0 8px}
  .ayah-stage{padding:16px clamp(18px,3vw,34px);min-height:300px;border-radius:24px}
  .ayah-text{min-height:120px;font-size:clamp(36px,4.3vw,62px);line-height:1.72;padding:16px 5px 10px}
  .word-rail{margin-bottom:10px}
  .child-prompt{padding-top:10px}
  .controls{margin-top:10px}
  .control-grid{margin-top:9px}
  .progress-card{margin-top:9px}
}

.practice-voice-active{outline:2px solid #efb1b1;outline-offset:2px}.voice-missing{color:#9a6700!important;background:#fff7db!important}.child-prompt.child-turn{background:#f4fbff;border-radius:14px;padding:12px;border-top:1px solid #dceef8}.child-prompt.group-turn{background:#f7f4ff;border-radius:14px;padding:12px;border-top:1px solid #e6ddff}
@media(max-width:1100px) and (min-width:901px){.control-grid{grid-template-columns:repeat(2,1fr)}}
