/* Shared book layout; application behavior stays in the shared app. */
@font-face{font-family:BookQuran;src:url('../data/AmiriQuran-Regular.ttf') format('truetype');font-weight:400;font-style:normal;font-display:swap}
/* One bundled Unicode font for the Quran and recognized Arabic alike. */
.book-view .word,.book-view .bismillah-line .word,.book-view [lang=ar],.book-view .ayah-number{font-family:BookQuran,serif}
.book-view #word-info.is-review .word-info-arabic{font-family:BookQuran,serif;font-size:20px;font-weight:400;line-height:1.8}
body.book-view{background:#e9e6dd;min-height:100vh}
body.book-view.dark{background:#0e1712}
.book-view .header{height:0;padding:0;margin:0}
.book-view .header .bismillah{display:none}
.book-view .header .app-version{position:fixed;top:10px;right:10px;z-index:12;background:var(--paper)}
/* The mobile document keeps its loaded version in markup, without a badge. */
.book-view main{max-width:1180px;padding:38px 24px 32px;margin:0 auto}
.book-view .reader{margin:0 auto;padding:0 28px;border-radius:3px;box-shadow:0 20px 65px #0002,inset 0 0 0 5px var(--paper),inset 0 0 0 6px var(--border);background:linear-gradient(90deg,#00000004,transparent 5%,transparent 95%,#00000005),var(--paper)}
.book-view .surah-heading{padding:12px 0}
.book-view #surah-title{font-family:BookQuran,serif;font-size:16px;line-height:1.6;direction:rtl;text-align:right;justify-self:end;align-self:center;min-width:0;max-width:100%;white-space:normal;overflow-wrap:anywhere}
.book-view .reader-footer{font-size:10px;padding:13px 0}
.book-view .reader-footer .legend{display:none}
/* The desktop rail uses the gutter; the page never shifts for controls. */
.book-view .practice{position:fixed;top:80px;bottom:auto;left:16px;z-index:10;width:54px;margin:0;padding:6px;border-radius:28px;background:var(--card);box-shadow:0 8px 35px #0002}
.book-view .recorder{padding:0;border:0}
.book-view .recorder-main{gap:8px;flex-wrap:nowrap;flex-direction:column}
.book-view .recorder-main>.book-control{display:flex;align-items:center;justify-content:center;flex:0 0 40px;width:40px;height:40px;min-width:40px;min-height:40px;border:0;border-radius:50%;padding:8px;transition:background 220ms ease,color 220ms ease,box-shadow 220ms ease,transform 220ms ease}
.book-view .recorder-main>.book-control:hover:not(:disabled){transform:translateY(-1px)}
.book-view .recorder-main>.book-control:active:not(:disabled){transform:scale(.94)}
.book-view .book-control svg,.book-view #teacher-icon-on,.book-view #teacher-icon-off{display:flex;align-items:center;justify-content:center}
/* Original Teacher symbol: separate on/off palettes for each color theme. */
.book-view #teacher-enabled{position:relative;--teacher-figure:#919ca4;--teacher-line:#73818a;--teacher-board:#e6ebe8;--teacher-accent:#84969a;--teacher-mark:#73818a;padding:4px}
.book-view #teacher-enabled[aria-pressed=true]{--teacher-figure:#194968;--teacher-line:#204f68;--teacher-board:#d6eee4;--teacher-accent:#16836b;--teacher-mark:#145d50;background:color-mix(in srgb,var(--teacher-accent) 14%,var(--card));color:var(--teacher-accent);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--teacher-accent) 35%,transparent)}
.book-view.dark #teacher-enabled{--teacher-figure:#70827b;--teacher-line:#a4b2ab;--teacher-board:#2a3b31;--teacher-accent:#8c9f94;--teacher-mark:#aebbb3}
.book-view.dark #teacher-enabled[aria-pressed=true]{--teacher-figure:#80d8bc;--teacher-line:#c9e8dc;--teacher-board:#294a3b;--teacher-accent:#dff5e8;--teacher-mark:#e0f5e8}
.book-view #teacher-icon-on,.book-view #teacher-icon-off{flex:0 0 32px}
@keyframes book-teacher-icon{from{opacity:0;transform:scale(.7) rotate(-8deg)}to{opacity:1;transform:scale(1) rotate(0)}}
.book-view #teacher-enabled svg{display:block;width:32px;height:32px;flex:none;animation:book-teacher-icon 260ms ease-out}
.book-view #teacher-tooltip{position:absolute;display:block;z-index:20;left:calc(100% + 14px);top:50%;width:270px;max-width:calc(100vw - 24px);padding:13px 15px;border:1px solid var(--border);border-radius:14px;background:color-mix(in srgb,var(--card) 94%,transparent);color:var(--ink);box-shadow:0 10px 32px #0002;backdrop-filter:blur(8px);font-size:12px;font-weight:400;line-height:1.65;text-align:left;white-space:normal;pointer-events:none;opacity:0;visibility:hidden;transform:translateY(-50%) scale(.9);transform-origin:left center;transition:opacity 240ms ease,transform 240ms ease,visibility 240ms}
.book-view #teacher-enabled:hover #teacher-tooltip,.book-view #teacher-enabled:focus-visible #teacher-tooltip{opacity:1;visibility:visible;transform:translateY(-50%) scale(1)}
.book-view #status,.book-view #model-picker{width:min(280px,calc(100vw - 100px));white-space:normal;font-size:12px;padding:10px;background:var(--card);border:1px solid var(--border);border-radius:10px}
.book-view #download{width:40px}
.book-view #model-picker input{max-width:100%}
.book-view #mic-notice{bottom:calc(110px + env(safe-area-inset-bottom))}
#book-settings{position:fixed;inset:0 auto 0 0;margin:0;width:min(360px,calc(100vw - 24px));height:100dvh;max-height:100dvh;box-sizing:border-box;overflow:auto;padding:24px;border:0;border-right:1px solid var(--border);border-radius:0;background:var(--card);color:var(--ink);box-shadow:8px 0 40px #0002;z-index:15}
#book-settings::backdrop{background:#07181050}
#book-settings .book-session .recitation-counts{display:flex;justify-content:space-between;gap:10px;font-size:11px}
#book-settings .book-session strong{display:block;font-size:20px}
#book-settings .session-inline{display:block;width:100%;max-width:none;margin-top:14px}
.book-settings-heading{display:flex;justify-content:flex-end;align-items:center;margin-bottom:4px}
#book-close{font-size:26px}
#book-settings section:first-of-type{border-top:0;padding-top:0}
#book-settings section{padding:16px 0;border-top:1px solid var(--border)}
#book-settings h3{font-size:12px;font-weight:600;margin:0 0 12px}
#book-settings .search-surah-row{display:grid;grid-template-columns:42px minmax(0,1fr);gap:8px}
#book-settings .unified-search{grid-column:1 / -1;grid-row:2}
#book-settings #search-hint{grid-column:1 / -1;grid-row:3;margin:0;line-height:1.6}
#book-settings #search-lock-info{inset:0;height:100%}
#book-settings #search-lock-tip{top:100%}
#book-settings .practice-actions{justify-content:flex-start;flex-wrap:wrap;margin:0;gap:8px}
#book-settings .practice-actions #theme{flex-shrink:0;width:34px;min-width:34px;padding:6px}
#book-settings .font-controls{margin-left:auto}
#book-settings .history{margin:12px 0;padding:12px}
#book-settings footer{margin-top:16px}
.book-view #word-info .word-info-madd{border-top:1px solid var(--border);margin-top:10px;padding-top:10px}
/* Feedback floats over the existing margin; it never resizes the Mushaf. */
.book-view #teacher-feedback{position:fixed;z-index:14;left:50%;top:12px;translate:-50% 0;width:min(280px,calc(100vw - 28px));max-width:calc(100vw - 28px);box-sizing:border-box;padding:12px 15px 14px;border:1px solid var(--border);border-radius:18px;background:color-mix(in srgb,var(--card) 94%,transparent);color:var(--ink);box-shadow:0 12px 38px #0002;backdrop-filter:blur(12px);opacity:1;scale:1;transform-origin:center;transition:scale 420ms cubic-bezier(.2,.7,.2,1),opacity 420ms ease,display 420ms allow-discrete}
.book-view #teacher-feedback[data-placement=gutter]{top:50dvh;translate:0 -50%}
.book-view #teacher-feedback[hidden]{display:none;opacity:0;scale:.85;pointer-events:none}
.book-view #teacher-feedback:not(.is-visible){opacity:0;scale:.85;pointer-events:none}
.book-view #teacher-feedback{margin:0;right:auto;bottom:auto}
.book-view #teacher-feedback-word:empty{display:none}
.book-view #teacher-feedback[data-state=countdown]{padding-bottom:12px}
.book-view .teacher-feedback-heading{display:flex;align-items:center;justify-content:space-between;gap:8px}
.book-view #teacher-feedback-label{font-size:11px;font-weight:600;color:var(--muted)}
.book-view #teacher-dismiss{display:flex;align-items:center;justify-content:center;width:26px;height:26px;min-width:26px;min-height:26px;padding:0;border:0;font-size:23px;line-height:1;background:transparent;color:var(--muted)}
.book-view #teacher-feedback-word{font-family:BookQuran,serif;font-size:28px;font-weight:400;line-height:1.8;margin:3px 0 6px;text-align:center;overflow-wrap:anywhere}
.book-view #teacher-feedback-detail{font-size:12px;line-height:1.5;margin:0}
.book-view #teacher-replay{display:block;margin:10px auto 0;padding:6px 12px;font-size:11px}
@starting-style{.book-view #teacher-feedback:not([hidden]){opacity:0;scale:.85}}
@media(prefers-reduced-motion:reduce){.book-view #teacher-feedback{transition:none}}
/* Opening and closing motion. Discrete display/overlay
   transitions keep the closing surface visible until its shrink finishes. */
@keyframes book-popup-in{from{opacity:0;transform:scale(0)}to{opacity:1;transform:scale(1)}}
.book-view :is(#book-settings,#voice-dialog,#word-info,#mic-notice,#search-lock-tip,#model-picker){
  opacity:1;scale:1;transform-origin:center;
  transition:scale 320ms cubic-bezier(.2,.7,.2,1),opacity 320ms ease,display 320ms allow-discrete,overlay 320ms allow-discrete;
}
.book-view #book-settings{transform-origin:left center}
.book-view :is(#voice-dialog:not([open]),#word-info[hidden],#mic-notice[hidden],#search-lock-tip[hidden],#model-picker[hidden]){opacity:0;scale:0;pointer-events:none}
.book-view #book-settings:not([open]){opacity:0;scale:0 1;pointer-events:none}
.book-view :is(#book-settings,#voice-dialog)::backdrop{opacity:0;transition:opacity 320ms ease,display 320ms allow-discrete,overlay 320ms allow-discrete}
.book-view :is(#book-settings,#voice-dialog)[open]::backdrop{opacity:1}
@starting-style{
  .book-view #book-settings[open]{opacity:0;scale:0 1}
  .book-view #voice-dialog[open],.book-view #word-info:not([hidden]),.book-view #mic-notice:not([hidden]),.book-view #search-lock-tip:not([hidden]),.book-view #model-picker:not([hidden]){opacity:0;scale:0}
  .book-view :is(#book-settings,#voice-dialog)[open]::backdrop{opacity:0}
}
.book-view #word-info details[open] .word-info-reference{transform-origin:top left;animation:book-popup-in 320ms cubic-bezier(.2,.7,.2,1)}
@media(prefers-reduced-motion:reduce){
  .book-view :is(#book-settings,#voice-dialog,#word-info,#mic-notice,#search-lock-tip,#model-picker),.book-view :is(#book-settings,#voice-dialog)::backdrop{transition:none}
  .book-view #word-info details[open] .word-info-reference{animation:none}
}

/* Leave the top-row badge space available on the dedicated phone layout. */
html[data-layout=mobile] .book-view.mobile-reciting main{padding-bottom:calc(32px + var(--mobile-reading-tail,0px))}

/* The preview panel reserves the measured toolbar area and leaves the page
   centered. JS delays hidden on close for browsers without display animation. */
html[data-teacher-voices=preview] #teacher-voices{position:fixed;z-index:16;top:16px;left:82px;width:min(320px,calc(100vw - 98px));max-height:calc(100vh - 32px);max-height:calc(100dvh - 32px);overflow:auto;box-sizing:border-box;padding:18px;border:1px solid var(--border);border-radius:20px;background:var(--card);background:color-mix(in srgb,var(--card) 96%,transparent);color:var(--ink);box-shadow:8px 12px 44px #0003;backdrop-filter:blur(12px);opacity:0;pointer-events:none;transform:translateX(-10px) scale(.88,.92);clip-path:inset(8% 100% 8% 0 round 20px);transform-origin:left center;transition:transform 480ms cubic-bezier(.22,1,.36,1),clip-path 480ms cubic-bezier(.22,1,.36,1),opacity 260ms ease;scrollbar-width:thin;scrollbar-color:var(--border) transparent}
html[data-teacher-voices=preview] #teacher-voices[data-placement=row]{transform:translateY(-10px) scale(.92,.92);clip-path:inset(0 0 100% 0 round 20px);transform-origin:center top}
html[data-teacher-voices=preview] #teacher-voices.is-open{opacity:1;pointer-events:auto;transform:translate(0) scale(1);clip-path:inset(0 round 20px)}
html[data-teacher-voices=preview] #teacher-voices>:not(.teacher-voices-heading){opacity:0;transform:translateY(8px);transition:opacity 180ms ease,transform 320ms cubic-bezier(.22,1,.36,1)}
html[data-teacher-voices=preview] #teacher-voices.is-open>:not(.teacher-voices-heading){opacity:1;transform:translateY(0);transition-duration:300ms,420ms;transition-delay:90ms}
html[data-teacher-voices=preview] .teacher-voices-heading{display:flex;align-items:center;justify-content:space-between;gap:12px;margin:0 0 8px}
html[data-teacher-voices=preview] .teacher-voices-heading h2{font-size:17px;font-weight:650;line-height:1.4;margin:0}
html[data-teacher-voices=preview] .teacher-voices-close{display:flex;align-items:center;justify-content:center;width:30px;height:30px;min-width:30px;min-height:30px;padding:0;font-size:26px;line-height:1;border-radius:50%;color:var(--muted)}
html[data-teacher-voices=preview] .teacher-voices-help{font-size:12px;line-height:1.65;color:var(--muted);margin:0 0 14px}
html[data-teacher-voices=preview] .teacher-voices-enable-row{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:11px 12px;border:1px solid var(--border);border-radius:13px;background:var(--paper);font-size:13px;font-weight:650}
html[data-teacher-voices=preview] .teacher-voices-toggle{display:flex;align-items:center;justify-content:center;gap:8px;flex:0 0 87px;min-width:87px;min-height:36px;padding:7px 8px;border:1px solid var(--border);border-radius:22px;background:var(--card);color:var(--muted);font-size:12px;font-weight:650;line-height:1;transition:background 220ms ease,color 220ms ease,border-color 220ms ease}
html[data-teacher-voices=preview] .teacher-voices-toggle[aria-checked=true]{border-color:var(--green);background:var(--soft);color:var(--green)}
html[data-teacher-voices=preview] .teacher-voices-toggle:focus-visible{outline:2px solid var(--green);outline-offset:3px}
html[data-teacher-voices=preview] .teacher-voices-switch-track{display:block;position:relative;flex:0 0 32px;width:32px;height:18px;border-radius:12px;background:var(--border);transition:background 220ms ease}
html[data-teacher-voices=preview] .teacher-voices-switch-track::after{content:'';position:absolute;top:3px;left:3px;width:12px;height:12px;border-radius:50%;background:var(--paper);box-shadow:0 1px 3px #0003;transition:transform 260ms cubic-bezier(.22,1,.36,1)}
html[data-teacher-voices=preview] .teacher-voices-toggle[aria-checked=true] .teacher-voices-switch-track{background:var(--green)}
html[data-teacher-voices=preview] .teacher-voices-toggle[aria-checked=true] .teacher-voices-switch-track::after{transform:translateX(14px)}
html[data-teacher-voices=preview] .teacher-voices-switch-state{min-width:20px;text-align:left}
html[data-teacher-voices=preview] .teacher-voices-instruction{font-size:11px;line-height:1.5;color:var(--muted);margin:12px 0 9px}
html[data-teacher-voices=preview] .teacher-voice-choices{min-width:0;padding:0;border:0;margin:0}
html[data-teacher-voices=preview] .teacher-voice-group{display:grid;gap:5px;margin:0 0 12px}
html[data-teacher-voices=preview] .teacher-voice-group h3{font-size:11px;font-weight:650;color:var(--muted);margin:2px 0 3px}
html[data-teacher-voices=preview] .teacher-voice-choice{display:flex;align-items:center;gap:10px;min-height:39px;margin:0;padding:8px 10px;border:1px solid var(--border);border-radius:10px;color:var(--ink);background:var(--paper);font-size:12px;font-weight:400;letter-spacing:0;line-height:1.4;cursor:pointer;transition:background 180ms ease,border-color 180ms ease}
html[data-teacher-voices=preview] .teacher-voice-choice:hover:not(.is-disabled){background:var(--soft)}
html[data-teacher-voices=preview] .teacher-voice-choice.is-selected{background:var(--soft);border-color:var(--green)}
html[data-teacher-voices=preview] .teacher-voice-choice.is-disabled{opacity:.6;cursor:default}
html[data-teacher-voices=preview] .teacher-voice-choice input[type=radio]{flex:0 0 15px;width:15px;height:15px;min-width:15px;min-height:15px;margin:0;padding:0;accent-color:var(--green)}
html[data-teacher-voices=preview] #teacher-voice-notice{font-size:11px;line-height:1.6;color:var(--muted);margin:0;padding-top:10px;border-top:1px solid var(--border)}
html[data-teacher-voices=preview] #teacher-voices-status{font-size:11px;line-height:1.6;color:var(--ink);margin:8px 0 0}
html[data-teacher-voices=preview] #teacher-voices-status:empty{display:none}
html[data-teacher-voices=preview] .teacher-panel-open #teacher-tooltip{display:none}
@media(prefers-reduced-motion:reduce){html[data-teacher-voices=preview] #teacher-voices,html[data-teacher-voices=preview] #teacher-voices>:not(.teacher-voices-heading),html[data-teacher-voices=preview] .teacher-voice-choice,html[data-teacher-voices=preview] .teacher-voices-toggle,html[data-teacher-voices=preview] .teacher-voices-switch-track,html[data-teacher-voices=preview] .teacher-voices-switch-track::after{transition:none}}
/* Details follow the hovered word without changing the centered page. */
.book-view #word-info,.book-view #word-info.is-review{right:auto;bottom:auto;translate:none;width:max-content;max-width:min(340px,calc(100vw - 16px));max-height:calc(100dvh - 16px);padding:10px 12px;transform-origin:center;transition:scale 320ms cubic-bezier(.2,.7,.2,1),opacity 320ms ease,display 320ms allow-discrete;}
@media(max-width:899px){
 .book-view #word-info,.book-view #word-info.is-review{padding:10px}
}
@media(prefers-reduced-motion:reduce){.book-view #word-info{transition:none}}

/* Measured page margins choose the desktop rail, not a browser-width guess.
   A top row stays in document flow so it cannot cover any Quran line. */
.book-view.book-controls-top main{padding-top:12px}
.book-view.book-controls-top .practice{position:relative;top:auto;bottom:auto;left:auto;right:auto;width:max-content;margin:0 auto 16px;padding:6px;transform:none}
.book-view.book-controls-top .recorder-main{flex-direction:row;gap:8px!important}
.book-view.book-controls-top .recorder-main>.book-control{flex:0 0 44px;width:44px;height:44px;min-width:44px;min-height:44px;padding:8px}
.book-view.book-controls-top #teacher-tooltip{left:-52px;top:calc(100% + 14px);transform:scale(.9);transform-origin:top left}
.book-view.book-controls-top #teacher-enabled:hover #teacher-tooltip,.book-view.book-controls-top #teacher-enabled:focus-visible #teacher-tooltip{transform:scale(1)}
.book-view.book-controls-top #status,.book-view.book-controls-top #model-picker{position:absolute;top:calc(100% + 8px);left:0;width:min(320px,calc(100vw - 24px));z-index:11;margin:0}
.book-view.book-controls-top #download{position:absolute;left:12px;right:12px;bottom:2px;width:calc(100% - 24px);height:2px;margin:0}
@media(max-width:600px){
  .book-view main{padding:12px 8px 24px;margin:0}
  .book-view.book-controls-top .practice{margin-left:0;margin-right:48px;margin-bottom:12px}
  .book-view.book-controls-top .recorder-main{gap:4px!important}
  .book-view.book-controls-top #teacher-tooltip{left:-48px}
  .book-view .header .app-version{top:24px}
  .book-view .reader{padding:0 12px}
  .book-view .surah-heading{gap:4px}
  .book-view .surah-heading h2{font-size:17px}
  .book-view #surah-title{font-size:14px}
  #book-settings{padding:20px}
}
@media(prefers-reduced-motion:reduce){
  .book-view .book-control{transition:none}
  .book-view #teacher-enabled svg{animation:none}
  .book-view #teacher-tooltip{transition:none}
}



