*{box-sizing:border-box}
html,body{margin:0;padding:0;background:#eef1f3;color:#17333d;font-family:system-ui,-apple-system,"Segoe UI",Tahoma,Arial,sans-serif;overscroll-behavior-y:auto}
button{font:inherit}
.app{width:100%;max-width:780px;margin:0 auto;padding:0;background:#eef1f3;overflow:hidden}
.loading,.fatal{padding:28px 18px;text-align:center}
.stagebar{position:sticky;top:0;z-index:30;display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:5px;padding:6px 6px 7px;background:rgba(238,241,243,.97);border-bottom:1px solid #d4dde1;backdrop-filter:blur(5px)}
.stage{appearance:none;border:1px solid #c5d8df;background:#fff;color:#24444f;border-radius:999px;padding:7px 2px;min-height:38px;font-size:.77rem;font-weight:700;white-space:nowrap;touch-action:manipulation}
.stage[aria-selected="true"]{background:#0072BC;color:#fff;border-color:#0072BC}
.stage:focus-visible{outline:3px solid #0072BC;outline-offset:2px}
.status{position:sticky;top:52px;z-index:29;min-height:0;text-align:center;background:#fff4d6;color:#725515;font-size:.74rem;line-height:1.4;overflow:hidden;max-height:0;padding:0 8px;transition:max-height .15s,padding .15s}
.status.show{max-height:48px;padding:6px 8px;border-bottom:1px solid #f0ddaa}
.book{display:block;width:100%;padding:0;margin:0}
.page-shell{width:100%;padding:0;margin:0;overflow:hidden;background:#fff}
.page-shell+.page-shell{margin-top:6px}
.page{position:relative;width:100%;padding:0;margin:0;background:#fff;line-height:0;transform:none!important}
.page img{width:100%;height:auto;display:block;user-select:none;-webkit-user-drag:none;pointer-events:none}
.page svg{position:absolute;inset:0;width:100%;height:100%;overflow:visible;touch-action:pan-x pan-y pinch-zoom}
.page rect.hit{fill:transparent;fill-opacity:0;pointer-events:all;cursor:pointer;outline:none;-webkit-tap-highlight-color:transparent}
.page .mark{fill:transparent;fill-opacity:0;stroke:none!important;pointer-events:none;transition:fill .06s,fill-opacity .06s}
.page .mark.pressed{fill:#FFE9A8;fill-opacity:.10;stroke:none!important}
.page .mark.playing{fill:#FFD84D;fill-opacity:.13;stroke:none!important}

.page rect.hit:focus,.page rect.hit:focus-visible{outline:none!important}
.page .uline{fill:none;stroke:transparent;stroke-width:0;pointer-events:none;stroke-linecap:round;stroke-linejoin:round;transition:stroke .06s,stroke-width .06s,opacity .06s;opacity:0}
.page .uline.pressed{stroke:#E8A32A;stroke-width:2;opacity:.72}
.page .uline.playing{stroke:#D97706;stroke-width:3;opacity:.96}

.error{color:#8b2525}
@media(max-width:767px){
  html,body,.app{width:100%;max-width:none}
  /* The source pages are native 575px-wide lossless PNGs. At common 360–430px mobile widths,
     112% display still remains below native image width, so the browser is downscaling rather than enlarging.
     The slight over-width crop reduces outer margins without changing scale on tap. */
  .page-shell{overflow:hidden}
  .page{width:112%;margin-inline:-6%}
  .page-shell+.page-shell{margin-top:4px}
}
@media(min-width:768px){
  .app{max-width:760px}
  .page{width:100%}
  .stagebar{padding-inline:10px}
}
@media(prefers-reduced-motion:reduce){.page .mark,.status{transition:none}}

.page rect.hit:focus,.page rect.hit:focus-visible{outline:none!important}

@media(max-width:767px){
  html,body{touch-action:pan-x pan-y pinch-zoom}
  .book,.page-shell,.page{touch-action:pan-x pan-y pinch-zoom}
}

/* زر كيف؟ وتعليمات ولي الأمر */
.lesson-topbar{width:100%;max-width:780px;margin:0 auto;padding:6px 8px 4px;background:#eef1f3;display:flex;justify-content:flex-start;direction:rtl}
.how-btn{appearance:none;border:1px solid #b9d3dd;background:#fff;color:#075f85;border-radius:999px;padding:6px 15px;font-weight:800;cursor:pointer;box-shadow:0 1px 2px rgba(0,0,0,.05)}
.how-btn:active{transform:translateY(1px)}
.how-dialog{border:0;padding:0;background:transparent;width:min(92vw,560px);max-height:86vh}
.how-dialog::backdrop{background:rgba(10,31,39,.48);backdrop-filter:blur(2px)}
.how-card{background:#fff;border-radius:18px;overflow:hidden;color:#17333d;box-shadow:0 18px 55px rgba(0,0,0,.24);direction:rtl;text-align:right}
.how-head{display:flex;align-items:center;gap:10px;padding:13px 16px;background:#f3f9fb;border-bottom:1px solid #d9e7ec}
.how-head h2{font-size:1.05rem;margin:0;flex:1}
.how-close{appearance:none;border:0;background:#e6eef1;color:#24444f;width:34px;height:34px;border-radius:50%;font-size:1.35rem;line-height:1;cursor:pointer}
.how-body{padding:14px 16px 18px;overflow:auto;max-height:calc(86vh - 60px);font-size:.92rem;line-height:1.8}
.how-body section{margin:0 0 12px}
.how-body h3{font-size:.95rem;margin:0 0 4px;color:#075f85}
.how-body p{margin:0}
.how-body ol{margin:4px 0 0;padding-right:23px}
.how-body li{margin:3px 0}
.how-note{background:#fff8df;border:1px solid #f0d993;border-radius:12px;padding:10px 12px;margin:10px 0 12px}
.how-note strong{color:#725515}
.how-path{text-align:center;font-weight:800;color:#075f85;background:#eef8fb;border-radius:12px;padding:9px 7px;margin-top:5px}
@media(max-width:767px){.lesson-topbar{max-width:none}.how-dialog{width:94vw}.how-body{font-size:.88rem}.how-btn{padding:5px 14px}}


/* أزرار التنقل ووضع الفصل */
.lesson-topbar{gap:7px;align-items:center;flex-wrap:wrap}
.topbar-spacer{flex:1}
.nav-btn{appearance:none;border:1px solid #b9d3dd;background:#fff;color:#075f85;border-radius:999px;padding:6px 13px;font-weight:800;cursor:pointer;box-shadow:0 1px 2px rgba(0,0,0,.05);text-decoration:none;line-height:1.45}
.nav-btn:active{transform:translateY(1px)}
.class-mode-btn[aria-pressed="true"]{background:#075f85;color:#fff;border-color:#075f85}
.info-btn{position:static;width:34px;height:34px;padding:0;display:grid;place-items:center;border:1px solid #b9d3dd;border-radius:50%;background:#fff;color:#075f85;font:900 .95rem/1 Arial,sans-serif;cursor:pointer;box-shadow:0 1px 2px rgba(0,0,0,.05)}.info-btn:hover{background:#e7f3f8}.info-btn:active{transform:translateY(1px)}
.class-info-okay{display:block;width:100%;margin-top:12px;border:0;border-radius:12px;background:#075f85;color:#fff;padding:10px 14px;font-weight:800;cursor:pointer}
.class-info-topbar{flex:0 0 auto;border-width:2px;background:#f8fcfd}.class-info-topbar[hidden]{display:none!important}
.class-controls{position:sticky;top:52px;z-index:29;display:flex;align-items:center;justify-content:center;gap:8px;flex-wrap:wrap;padding:8px;background:#e7f3f7;border-bottom:1px solid #c5d8df;direction:rtl}
.class-controls[hidden]{display:none!important}
.class-control-btn{appearance:none;border:1px solid #9fc6d4;background:#fff;color:#075f85;border-radius:999px;padding:7px 13px;font-weight:800;cursor:pointer;min-height:38px}
.class-control-btn.running{background:#075f85;color:#fff;border-color:#075f85}
.class-control-btn.pause-btn{min-width:105px}
.class-field{display:flex;align-items:center;gap:5px;font-size:.78rem;font-weight:800;color:#24444f;background:#fff;border:1px solid #c5d8df;border-radius:999px;padding:4px 9px}
.class-field select{border:0;background:transparent;color:#17333d;font:inherit;font-weight:800;outline:none;padding:2px}
.class-note{font-size:.78rem;color:#526a73;font-weight:700;text-align:center;width:100%}
.class-progress{font-size:.76rem;color:#075f85;font-weight:800;min-width:70px;text-align:center}
body.class-mode-active{background:#dde8ec}
body.class-mode-active .app,body.class-mode-active .lesson-topbar{max-width:1180px}
body.class-mode-active .lesson-topbar{position:sticky;top:0;z-index:50;background:rgba(238,241,243,.98);border-bottom:1px solid #d4dde1}
body.class-mode-active .lesson-topbar{justify-content:center;gap:.5cm}
body.class-mode-active .back-texts,body.class-mode-active .how-btn,body.class-mode-active .topbar-spacer{display:none!important}
body.class-mode-active .stagebar{top:49px}
body.class-mode-active .class-controls{top:101px}
body.class-mode-active .status{top:157px}
body.class-mode-active .page .mark.playing{fill-opacity:.18}
body.class-mode-active .page .uline.playing{stroke-width:4}
@media(max-width:767px){
 .lesson-topbar{gap:5px}.nav-btn,.how-btn{font-size:.78rem;padding:5px 10px}.info-btn{width:30px;height:30px;font-size:.82rem}.topbar-spacer{display:none}
 .back-texts{margin-left:auto}.class-controls{gap:5px;padding:6px}.class-field{font-size:.72rem;padding:3px 7px}.class-control-btn{font-size:.75rem;padding:6px 9px}
 body.class-mode-active .stagebar{top:45px}body.class-mode-active .class-controls{top:96px}body.class-mode-active .status{top:151px}
}

.class-controls.sentence-manual .class-field,.class-controls.sentence-manual .class-progress,.class-controls.sentence-manual .pause-btn{display:none!important}
