/* Layout: an open mushaf lying on its own leather cover. Each student's Quran has a jewel-toned cover;
   in the reader that leather frames the pages and carries the tools, so the open book always says whose it is.
   Around it: ivory paper, ink, and lapis, the blue of illuminated manuscripts. */
:root {
  --ground: #F5F1EA;      /* ivory ground of home and contents */
  --ground-2: #E9E1D5;    /* dividers, recessed wells */
  --paper: #FFFDF9;       /* a page */
  --paper-edge: #E5DACB;  /* page block, page edges */
  --ink: #1E1916;         /* text */
  --ink-2: #66594F;       /* secondary text, 6:1 on ivory */
  --accent: #23356E;      /* lapis: primary actions and marks */
  --accent-2: #3B5096;
  --accent-soft: #E4E6F0;
  --accent-deep: #16224A;
  --on-accent: #F8F3EA;
  --foil: #F6F0E4;        /* foil stamped on leather: text and icons in the reader */
  --laser: #FF2D20;
  --danger: #962323;
  --focus: #2F6FE0;
  --leather: #26397A;     /* set per student */
  --pattern-alpha: .075;

  --f-display: 'Cormorant Garamond', 'Amiri', Georgia, serif;
  --f-ui: 'Atkinson Hyperlegible Next', 'Noto Naskh Arabic', -apple-system, system-ui, sans-serif;
  --f-ar: 'Noto Naskh Arabic', 'Amiri', 'Geeza Pro', serif;
  --f-ar-display: 'Amiri', 'Noto Naskh Arabic', 'Geeza Pro', serif;
  --f-quran: 'Amiri Quran', 'Amiri', 'Geeza Pro', serif;

  --rail: clamp(94px, 8.6vw, 114px);
  --r-sm: 10px;
  --r-md: 18px;
  --ease-out: cubic-bezier(.22, .8, .24, 1);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
  color-scheme: light;
}
/* Rose: blush paper and garnet */
:root[data-theme="rose"] {
  --ground: #F8EFEC; --ground-2: #EEDDD7; --paper-edge: #E9D6CE;
  --ink: #241618; --ink-2: #6E5458;
  --accent: #7A2643; --accent-2: #9C3D5E; --accent-soft: #F3DFE4; --accent-deep: #531629; --on-accent: #FBF1EE;
}
/* Sand: warm stone and espresso */
:root[data-theme="sand"] {
  --ground: #F2ECE2; --ground-2: #E4DACB; --paper-edge: #E0D3C0;
  --ink: #221A15; --ink-2: #66584B;
  --accent: #3B2C23; --accent-2: #5C4739; --accent-soft: #E8DED1; --accent-deep: #241A14; --on-accent: #F8F1E6;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  background: var(--ground);
  color: var(--ink);
  font-family: var(--f-ui);
  font-size: 20px;
  line-height: 1.4;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
html[lang="ar"] body { font-family: var(--f-ar); font-size: 21px; line-height: 1.55; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; touch-action: manipulation; }
input, select, textarea { touch-action: manipulation; }
img { max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.ico { width: 32px; height: 32px; flex: none; display: block; }
html[dir="rtl"] .flip-rtl { transform: scaleX(-1); }
[lang="ar"] { font-family: var(--f-ar); }
.num { font-variant-numeric: tabular-nums; }

/* Language pairs inside the welcome screen show both languages */
.screen { position: fixed; inset: 0; display: flex; }

/* ---------- Brand mark: ن inside the eight-pointed star; its dot is the laser ---------- */
.brandmark { width: 76px; height: 76px; flex: none; color: var(--accent); }
.brandmark svg { width: 100%; height: 100%; display: block; overflow: visible; }
/* star-and-cross lattice, tinted with the theme accent */
.lattice { isolation: isolate; }
.lattice:not(.screen) { position: relative; }
.lattice::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: var(--accent); opacity: var(--pattern-alpha);
  -webkit-mask: url("../icons/pattern.svg") 0 0 / 132px 132px repeat; mask: url("../icons/pattern.svg") 0 0 / 132px 132px repeat;
}

/* ---------- Opening screen ---------- */
#splash { position: fixed; } /* outranks .lattice:not(.screen) */
.splash { position: fixed; inset: 0; z-index: 300; background: var(--ground); display: grid; place-items: center; transition: opacity .5s ease, visibility .5s; }
.splash.gone { opacity: 0; visibility: hidden; }
.splash-inner { display: grid; justify-items: center; padding: 40px 60px; background: var(--ground); border-radius: 40px; animation: splashIn .7s var(--ease-out) both; }
.splash .brandmark { width: 156px; height: 156px; margin-bottom: 22px; }
.splash .brandmark svg circle:nth-last-of-type(2) { animation: dotglow 1.6s ease-in-out infinite; }
.splash-en { margin: 0; font-family: var(--f-display); font-size: 72px; line-height: 1; font-weight: 600; letter-spacing: -.01em; color: var(--ink); }
.splash-ar { margin: 8px 0 0; font-family: var(--f-ar-display); font-size: 44px; line-height: 1.5; font-weight: 700; color: var(--accent); }
.splash-ver { margin: 26px 0 0; font-family: var(--f-ui); font-size: 15px; font-weight: 700; letter-spacing: .04em; color: var(--ink-2); font-variant-numeric: tabular-nums; }
@keyframes splashIn { from { opacity: 0; transform: translateY(14px) scale(.98); } }
@keyframes dotglow { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }

/* ---------- Contents header brand ---------- */
.ct-head { position: relative; }
.ct-brand { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -46%); display: flex; align-items: center; gap: 10px; color: var(--ink-2); pointer-events: none; white-space: nowrap; }
.ct-brand .brandmark { width: 40px; height: 40px; }
.ct-brand .en { font-family: var(--f-display); font-size: 28px; font-weight: 600; color: var(--ink); }
.ct-brand .ar { font-family: var(--f-ar-display); font-size: 22px; font-weight: 700; color: var(--accent); }
@media (max-width: 1000px) { .ct-brand .ar { display: none; } }
@media (orientation: portrait) and (max-width: 900px) { .ct-brand .en { display: none; } }

/* ---------- Welcome (language) ---------- */
#welcome { align-items: center; justify-content: center; padding: calc(24px + var(--sat)) 24px calc(24px + var(--sab)); background: var(--ground); }
.home-side.lattice::before, .fade-lattice::before {
  -webkit-mask: url("../icons/pattern.svg") 0 0 / 132px 132px repeat, linear-gradient(to top, #000 0%, rgba(0,0,0,.5) 35%, transparent 75%);
  -webkit-mask-composite: source-in;
  mask: url("../icons/pattern.svg") 0 0 / 132px 132px repeat, linear-gradient(to top, #000 0%, rgba(0,0,0,.5) 35%, transparent 75%);
  mask-composite: intersect;
  opacity: calc(var(--pattern-alpha) * 1.6);
}
.welcome-inner { display: grid; justify-items: center; gap: 20px; text-align: center; max-width: 720px; padding: 44px 56px 40px; background: var(--ground); border-radius: 32px; }
#welcome .brandmark { width: 116px; height: 116px; }
.welcome-title { margin: 0; display: grid; gap: 0; }
.welcome-title [lang="en"] { font-family: var(--f-display); font-size: 72px; line-height: 1; font-weight: 600; letter-spacing: -.01em; }
.welcome-title [lang="ar"] { font-family: var(--f-ar-display); font-size: 46px; font-weight: 700; color: var(--accent); line-height: 1.5; }
.welcome-q { margin: 14px 0 0; display: grid; gap: 2px; font-size: 23px; color: var(--ink-2); }
.welcome-langs { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; margin-top: 4px; }
.lang-big {
  min-width: 250px; min-height: 100px; padding: 0 28px;
  border-radius: 22px; background: var(--accent); color: var(--on-accent);
  font-size: 36px; font-weight: 700; line-height: 1;
  box-shadow: 0 1px 0 rgba(255,255,255,.18) inset, 0 3px 0 var(--accent-deep), 0 18px 34px -18px var(--accent-deep);
}
.lang-big[lang="ar"] { font-family: var(--f-ar-display); font-size: 40px; padding-bottom: 8px; }
.lang-big[lang="en"] { font-family: var(--f-display); font-size: 44px; font-weight: 600; }
.lang-big:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--accent-deep); }
.welcome-note { margin: 2px 0 0; display: grid; font-size: 18px; color: var(--ink-2); }

/* ---------- Install guide ---------- */
#install { background: var(--ground); overflow: auto; padding: calc(28px + var(--sat)) max(28px, var(--sar)) calc(28px + var(--sab)) max(28px, var(--sal)); }
.install-inner { margin: auto; width: min(1000px, 100%); display: grid; gap: 26px; }
.install-head { display: flex; gap: 22px; align-items: center; }
.install-head h1 { margin: 0; font-family: var(--f-display); font-size: 52px; line-height: 1.02; font-weight: 600; text-wrap: balance; }
html[lang="ar"] .install-head h1 { font-family: var(--f-ar-display); font-size: 42px; line-height: 1.4; }
.install-why { margin: 0; font-size: 22px; color: var(--ink-2); max-width: 46em; }
.install-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin: 0; padding: 0; list-style: none; }
.install-steps li { background: var(--paper); border-radius: var(--r-md); padding: 22px 22px 24px; display: grid; gap: 14px; align-content: start; box-shadow: 0 0 0 1px var(--paper-edge), 0 14px 30px -24px rgba(40, 30, 20, .5); }
.install-steps .step-n { font-family: var(--f-display); font-size: 52px; line-height: .8; color: var(--accent); font-weight: 600; font-variant-numeric: lining-nums; }
.install-steps .step-pic { height: 92px; display: flex; align-items: center; gap: 14px; }
.install-steps .step-pic .key { width: 74px; height: 74px; border-radius: 18px; background: var(--ground); display: grid; place-items: center; color: #0A63D8; }
.install-steps .step-pic .key .ico { width: 42px; height: 42px; }
.install-steps .step-pic .menu-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 14px; background: var(--ground); font-size: 20px; font-family: -apple-system, system-ui, sans-serif; }
.install-steps .step-pic .addbtn { padding: 12px 22px; border-radius: 14px; background: var(--ground); color: #0A63D8; font-weight: 700; font-family: -apple-system, system-ui, sans-serif; font-size: 22px; }
.install-steps p { margin: 0; font-size: 21px; }
.install-warn { margin: 0; padding: 18px 22px; border-radius: var(--r-md); background: var(--accent-soft); color: var(--ink); font-size: 20px; }
.install-actions { display: flex; gap: 16px; flex-wrap: wrap; }
.install-pointer { position: fixed; top: calc(6px + var(--sat)); right: 120px; width: 70px; height: 70px; color: var(--accent); animation: nudge 1.4s var(--ease-out) infinite; pointer-events: none; }
@keyframes nudge { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

/* ---------- Buttons ---------- */
.btn {
  min-height: 64px; padding: 0 28px; border-radius: 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 12px;
  font-size: 22px; font-weight: 700; text-align: center;
}
.btn-primary { background: var(--accent); color: var(--on-accent); box-shadow: 0 1px 0 rgba(255,255,255,.16) inset, 0 3px 0 var(--accent-deep); }
.btn-primary:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--accent-deep); }
.btn-secondary { background: var(--paper); color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); }
.btn-danger { background: var(--danger); color: #FFF7F2; box-shadow: 0 3px 0 #5E1212; }
.btn-quiet { display: inline-flex; align-items: center; gap: 12px; min-height: 56px; padding: 0 6px; font-size: 20px; color: var(--ink-2); font-weight: 700; }
.btn-back { display: inline-flex; align-items: center; gap: 8px; min-height: 64px; padding: 0 14px 0 4px; font-size: 22px; font-weight: 700; color: var(--accent); }
html[dir="rtl"] .btn-back { padding: 0 4px 0 14px; }

/* ---------- Home ---------- */
#home { padding: var(--sat) var(--sar) var(--sab) var(--sal); }
.home-side {
  width: 352px; flex: none; padding: 44px 34px 26px 42px;
  display: flex; flex-direction: column; gap: 26px;
  background: var(--paper);
  box-shadow: 1px 0 0 var(--ground-2);
}
html[dir="rtl"] .home-side { padding: 44px 42px 26px 34px; box-shadow: -1px 0 0 var(--ground-2); }
.home-brand { display: grid; gap: 4px; justify-items: start; }
.home-brand .brandmark { width: 84px; height: 84px; margin-bottom: 14px; }
.brand-name { margin: 0; font-family: var(--f-display); font-size: 64px; line-height: .92; font-weight: 600; letter-spacing: -.012em; }
.brand-ar { margin: 0; font-family: var(--f-ar-display); font-size: 34px; font-weight: 700; color: var(--accent); line-height: 1.6; }
html[lang="ar"] .brand-name { font-family: var(--f-ar-display); font-size: 54px; font-weight: 700; line-height: 1.3; }
html[lang="ar"] .brand-ar { font-family: var(--f-display); font-size: 34px; font-weight: 600; line-height: 1.2; }
.brand-sub { margin: 10px 0 0; font-size: 19px; color: var(--ink-2); max-width: 15em; }
.home-date { display: grid; gap: 2px; padding: 18px 20px; border-radius: var(--r-md); background: var(--ground); }
.home-date p { margin: 0; }
.date-greg { font-size: 21px; font-weight: 800; }
.date-hijri { font-family: var(--f-ar-display); font-size: 24px; color: var(--accent); }
html[lang="en"] .date-hijri { font-family: var(--f-display); font-size: 25px; font-weight: 600; font-style: italic; }
.home-settings { margin-top: auto; }
.home-main { flex: 1; min-width: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 46px 48px 70px; }
.home-head { display: grid; gap: 8px; margin-bottom: 38px; }
.home-q { margin: 0; font-family: var(--f-display); font-size: 52px; line-height: 1; font-weight: 600; letter-spacing: -.01em; }
html[lang="ar"] .home-q { font-family: var(--f-ar-display); font-size: 42px; font-weight: 700; line-height: 1.4; }
.home-hint { margin: 0; font-size: 20px; color: var(--ink-2); }

.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 46px 34px; align-items: start; }
.book-item { display: grid; gap: 16px; min-width: 0; }
.cover {
  position: relative; display: block; width: 100%; aspect-ratio: .7;
  border-radius: 12px 4px 4px 12px;
  background:
    linear-gradient(to left, rgba(0,0,0,.38), rgba(0,0,0,.1) 5.5%, rgba(255,255,255,.14) 6.6%, rgba(255,255,255,0) 10%),
    radial-gradient(130% 100% at 25% 15%, rgba(255,255,255,.16), rgba(255,255,255,0) 55%),
    radial-gradient(120% 90% at 80% 110%, rgba(0,0,0,.28), rgba(0,0,0,0) 60%),
    var(--grain),
    var(--c, var(--leather));
  background-blend-mode: normal, normal, normal, soft-light, normal;
  color: var(--foil);
  box-shadow:
    -3px 0 0 -1px var(--paper), -4px 0 0 -1px var(--paper-edge), -6px 1px 0 -2px var(--paper), -7px 1px 0 -2px var(--paper-edge),
    0 2px 0 rgba(0,0,0,.2), 0 26px 34px -20px rgba(30, 20, 15, .6);
  transform-origin: right center;
  transition: transform .5s var(--ease-out);
  isolation: isolate;
}
.cover::before { content: ""; position: absolute; inset: 10px 17px 10px 10px; border: 1.5px solid rgba(246, 240, 228, .55); border-radius: 6px 2px 2px 6px; pointer-events: none; }
.cover::after { content: ""; position: absolute; inset: 15px 22px 15px 15px; border: 1px solid rgba(246, 240, 228, .25); border-radius: 3px; pointer-events: none; }
.cover .cv-star { position: absolute; left: 50%; top: 26%; width: 44%; aspect-ratio: 1; transform: translate(-50%, -50%) translateX(-4%); color: rgba(246, 240, 228, .9); filter: drop-shadow(0 1px 0 rgba(0,0,0,.35)); }
.cover .cv-name {
  position: absolute; left: 12%; right: 18%; top: 50%; bottom: 13%;
  display: flex; align-items: center; justify-content: center; text-align: center;
  font-family: var(--f-display); font-weight: 700; font-size: 30px; line-height: 1.02;
  overflow-wrap: anywhere; text-wrap: balance;
  text-shadow: 0 1px 0 rgba(0,0,0,.4), 0 -1px 0 rgba(255,255,255,.08);
}
.cover .cv-name.ar { font-family: var(--f-ar-display); font-size: 30px; line-height: 1.35; }
.cover .ribbon {
  position: absolute; bottom: -13px; left: 24%; width: 15px; height: 40px; z-index: -1;
  background: linear-gradient(to right, rgba(0,0,0,.18), rgba(255,255,255,.12) 45%, rgba(0,0,0,.12)), var(--rib, #C9473A);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 80%, 0 100%);
}
.cover:active { transform: scale(.98); }
.cover.opening { transform: perspective(1400px) rotateY(-28deg) scale(1.02); }
.cover-meta { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: start; gap: 2px; padding-top: 2px; }
.cover-meta .more.share { color: var(--accent); }
.cover-meta .where { font-size: 18px; font-weight: 800; line-height: 1.3; }
.cover-meta .when { font-size: 17px; color: var(--ink-2); }
.cover-meta .more { width: 52px; height: 52px; margin: -10px -10px 0 0; display: grid; place-items: center; color: var(--ink-2); border-radius: 50%; }
html[dir="rtl"] .cover-meta .more { margin: -10px 0 0 -10px; }
.cover-add {
  position: relative; display: grid; place-items: center; align-content: center; gap: 14px; width: 100%; aspect-ratio: .7;
  border-radius: 12px 4px 4px 12px; color: var(--accent); background: var(--paper);
  box-shadow: inset 0 0 0 2px var(--ground-2);
  font-size: 21px; font-weight: 800; text-align: center; padding: 18px; line-height: 1.25;
}
.cover-add .plus { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--on-accent); box-shadow: 0 3px 0 var(--accent-deep); }
.cover-add .ico { width: 36px; height: 36px; }

/* ---------- Contents ---------- */
#contents { flex-direction: column; padding: var(--sat) var(--sar) var(--sab) var(--sal); }
.ct-head { display: flex; align-items: center; gap: 18px; padding: 12px 30px 8px 18px; min-height: 88px; }
html[dir="rtl"] .ct-head { padding: 12px 18px 8px 30px; }
.ct-who { display: flex; align-items: center; gap: 14px; margin-inline-start: auto; min-width: 0; }
.ct-who .chip { width: 32px; height: 46px; border-radius: 6px 2px 2px 6px; background: var(--grain), var(--c); background-blend-mode: soft-light, normal; box-shadow: -2px 0 0 -1px var(--paper), -3px 0 0 -1px var(--paper-edge), 0 6px 10px -6px rgba(0,0,0,.5); flex: none; }
.ct-who .nm { font-family: var(--f-display); font-size: 38px; line-height: 1; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html[lang="ar"] .ct-who .nm { font-family: var(--f-ar-display); font-size: 32px; line-height: 1.5; }
.ct-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(340px, 36%) minmax(0, 1fr); }
.ct-left { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 8px 26px 40px 30px; display: grid; gap: 32px; align-content: start; }
html[dir="rtl"] .ct-left { padding: 8px 30px 40px 26px; }
.ct-right { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--paper); border-start-start-radius: 28px; box-shadow: 0 0 0 1px var(--ground-2); }
html[dir="rtl"] .ct-right { border-start-start-radius: 0; border-start-end-radius: 28px; }

.continue {
  position: relative; overflow: hidden; isolation: isolate;
  display: grid; grid-template-columns: 116px minmax(0, 1fr); gap: 22px; align-items: center; text-align: start;
  padding: 20px; border-radius: 24px; background: var(--grain), var(--c, var(--accent)); background-blend-mode: soft-light, normal; color: var(--foil);
  box-shadow: 0 1px 0 rgba(255,255,255,.15) inset, 0 3px 0 rgba(0,0,0,.25), 0 24px 40px -26px rgba(20, 15, 10, .8);
}
.continue::after { content: ""; position: absolute; inset: 0; z-index: -1; background: radial-gradient(120% 120% at 100% 0%, rgba(255,255,255,.16), rgba(255,255,255,0) 50%); }
.continue:active { transform: translateY(2px); }
.continue .thumb { width: 116px; aspect-ratio: .626; background: var(--paper); border-radius: 3px 6px 6px 3px; padding: 8px 6px; box-shadow: 0 10px 18px -8px rgba(0,0,0,.6); transform: rotate(-2deg); }
.continue .thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.continue .k { font-size: 18px; opacity: .88; font-weight: 700; }
.continue .v { font-family: var(--f-display); font-size: 40px; line-height: 1; font-weight: 700; margin: 6px 0 8px; }
html[lang="ar"] .continue .v { font-family: var(--f-ar-display); font-size: 34px; line-height: 1.35; margin: 2px 0 4px; }
.continue .s { font-size: 19px; opacity: .95; }
.continue .go { display: inline-flex; align-items: center; gap: 6px; margin-top: 14px; padding: 10px 18px; background: var(--foil); color: var(--ink); border-radius: 12px; font-weight: 800; font-size: 20px; }
.continue .go .ico { width: 26px; height: 26px; }
.start-fresh { display: grid; gap: 12px; padding: 24px; border-radius: 24px; background: var(--paper); box-shadow: 0 0 0 1px var(--ground-2); }
.start-fresh h3 { margin: 0; font-family: var(--f-display); font-size: 36px; line-height: 1; font-weight: 700; }
html[lang="ar"] .start-fresh h3 { font-family: var(--f-ar-display); font-size: 30px; line-height: 1.4; }
.start-fresh p { margin: 0; color: var(--ink-2); }

.side-block { display: grid; gap: 8px; }
.side-block h3 { margin: 0 0 2px; font-family: var(--f-display); font-size: 28px; line-height: 1.1; font-weight: 700; color: var(--ink); }
html[lang="ar"] .side-block h3 { font-family: var(--f-ar-display); font-size: 26px; line-height: 1.4; }
.side-list { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.side-list li + li { box-shadow: 0 -1px 0 var(--ground-2); }
.side-row { width: 100%; min-height: 66px; display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 8px 4px; text-align: start; }
.side-row:active { background: var(--ground-2); }
.side-row .mk { width: 22px; height: 30px; color: #C0392B; justify-self: center; }
.side-row .t1 { font-weight: 800; font-size: 20px; line-height: 1.25; }
.side-row .t2 { font-size: 17px; color: var(--ink-2); }
.side-row .pg { font-family: var(--f-display); font-size: 30px; font-weight: 700; color: var(--accent); font-variant-numeric: lining-nums tabular-nums; }
html[lang="ar"] .side-row .pg { font-family: var(--f-ar-display); font-size: 26px; }
.side-empty { margin: 0; font-size: 18px; color: var(--ink-2); padding: 2px 0; }
.side-row .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); justify-self: center; }

.tabs { display: flex; gap: 6px; padding: 14px 24px 0; flex: none; box-shadow: inset 0 -1px 0 var(--ground-2); }
.tab { min-height: 64px; padding: 0 22px; font-size: 23px; font-weight: 800; color: var(--ink-2); position: relative; }
html[lang="ar"] .tab { font-size: 24px; }
.tab[aria-selected="true"] { color: var(--accent); }
.tab[aria-selected="true"]::after { content: ""; position: absolute; left: 14px; right: 14px; bottom: 0; height: 4px; border-radius: 4px 4px 0 0; background: var(--accent); }
.tab-panels { flex: 1; min-height: 0; position: relative; }
.panel { position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 22px 26px 50px; }

.juz-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.juz-tile {
  display: grid; grid-template-rows: auto 1fr auto; gap: 4px; min-height: 146px; padding: 14px 16px 13px;
  border-radius: 18px; background: var(--ground); text-align: start;
}
.juz-tile:active { background: var(--ground-2); }
.juz-tile .jn { display: flex; align-items: baseline; gap: 6px; }
.juz-tile .jn b { font-family: var(--f-display); font-size: 48px; line-height: .85; color: var(--accent); font-weight: 600; font-variant-numeric: lining-nums tabular-nums; }
html[lang="ar"] .juz-tile .jn b { font-family: var(--f-ar-display); font-size: 40px; line-height: 1.1; font-weight: 700; }
.juz-tile .jn span { font-size: 15px; color: var(--ink-2); font-weight: 800; letter-spacing: .06em; text-transform: uppercase; order: -1; }
.juz-tile .jw { font-family: var(--f-quran); font-size: 21px; line-height: 1.75; direction: rtl; text-align: right; color: var(--ink); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.juz-tile .jp { font-size: 16px; font-weight: 800; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.juz-tile.here { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }

.filter { position: relative; margin-bottom: 14px; }
.filter input { width: 100%; min-height: 62px; border-radius: 16px; border: 0; background: var(--ground); padding: 0 20px 0 58px; font-size: 22px; box-shadow: inset 0 0 0 2px transparent; }
html[dir="rtl"] .filter input { padding: 0 58px 0 20px; }
.filter .ico { position: absolute; top: 15px; left: 16px; color: var(--ink-2); }
html[dir="rtl"] .filter .ico { left: auto; right: 16px; }
.surah-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 0 22px; margin: 0; padding: 0; list-style: none; }
.surah-list li:not(.juz-divider) { box-shadow: 0 1px 0 var(--ground-2); }
.surah-row { width: 100%; display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 10px 6px; min-height: 80px; text-align: start; }
.surah-row:active { background: var(--ground); }
.surah-row.here { background: var(--accent-soft); border-radius: 14px; }
.sn { position: relative; width: 50px; height: 50px; display: grid; place-items: center; color: var(--accent); }
.sn svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.sn b { position: relative; font-size: 16px; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; }
.surah-row .names { min-width: 0; display: grid; }
.surah-row .ar { font-family: var(--f-ar-display); font-size: 29px; line-height: 1.3; font-weight: 700; }
.surah-row .tr { font-size: 18px; font-weight: 800; line-height: 1.25; }
.surah-row .en { font-size: 16px; color: var(--ink-2); line-height: 1.3; }
.surah-row .pp { text-align: end; display: grid; gap: 2px; }
.surah-row .pp b { font-size: 18px; color: var(--accent); font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 800; }
.surah-row .pp span { font-size: 15px; color: var(--ink-2); white-space: nowrap; }
.juz-divider { grid-column: 1 / -1; margin: 22px 4px 2px; font-family: var(--f-display); font-size: 26px; font-weight: 700; color: var(--accent); display: flex; align-items: center; gap: 14px; }
html[lang="ar"] .juz-divider { font-family: var(--f-ar-display); font-size: 22px; }
.juz-divider::after { content: ""; flex: 1; height: 1px; background: var(--ground-2); }
.juz-divider:first-child { margin-top: 0; }

.find { display: grid; gap: 34px; max-width: 760px; }
.find-block { display: grid; gap: 12px; }
.find-block h3 { margin: 0; font-family: var(--f-display); font-size: 36px; line-height: 1.05; font-weight: 700; }
html[lang="ar"] .find-block h3 { font-family: var(--f-ar-display); font-size: 30px; line-height: 1.4; }
.find-block p.help { margin: -6px 0 0; color: var(--ink-2); font-size: 18px; }
.find-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: stretch; }
.field { display: grid; gap: 6px; }
.field label { font-size: 17px; font-weight: 800; color: var(--ink-2); }
.field input, .field select {
  min-height: 66px; border-radius: 16px; border: 0; background: var(--ground);
  padding: 0 18px; font-size: 26px; font-weight: 700; min-width: 0;
}
.sheet .field input { background: var(--ground); }
.field select { padding-inline-end: 44px; -webkit-appearance: none; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(-45deg, transparent 50%, var(--ink) 50%); background-position: calc(100% - 26px) 30px, calc(100% - 18px) 30px; background-size: 8px 8px; background-repeat: no-repeat; }
html[dir="rtl"] .field select { background-position: 18px 30px, 26px 30px; }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }
.field input:focus, .field select:focus, .filter input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--accent); }
.find-row .btn { align-self: end; }
.find-answer { font-size: 19px; color: var(--ink-2); min-height: 1.4em; margin: 0; }
.results { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.result { width: 100%; display: grid; gap: 6px; padding: 14px 18px; border-radius: 18px; background: var(--ground); text-align: start; }
.result .rt { font-family: var(--f-quran); direction: rtl; text-align: right; font-size: 25px; line-height: 1.95; }
.result .rt mark { background: #FFE070; color: inherit; border-radius: 4px; padding: 0 2px; }
.result .rm { font-size: 17px; font-weight: 800; color: var(--accent); }

/* ---------- Reader ---------- */
/* the tools stay on the left in both languages */
#reader, #board { direction: ltr; }
html[dir="rtl"] #reader .rail, html[dir="rtl"] #board .rail, html[dir="rtl"] .flip-hint { direction: rtl; }
#reader, #board {
  background:
    radial-gradient(90% 80% at 50% 42%, rgba(255,255,255,.10), rgba(255,255,255,0) 60%),
    radial-gradient(140% 120% at 50% 50%, rgba(0,0,0,0) 40%, rgba(0,0,0,.34) 100%),
    var(--grain),
    var(--leather);
  background-blend-mode: normal, normal, soft-light, normal;
  padding: var(--sat) var(--sar) var(--sab) var(--sal);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.rail {
  width: var(--rail); flex: none; display: flex; flex-direction: column; align-items: center;
  gap: clamp(3px, .8vh, 8px); padding: clamp(8px, 1.4vh, 14px) 8px; margin: clamp(8px, 1.4vh, 14px) 0;
  color: var(--foil); position: relative; z-index: 5;
  background: rgba(10, 6, 4, .18); border-radius: 26px;
  box-shadow: inset 0 0 0 1px rgba(255, 248, 235, .09), inset 0 1px 0 rgba(255, 248, 235, .08);
}
.rail-tools { margin-inline-start: 10px; }
.rail-nav { margin-inline-end: 10px; }
#reader .rail-tools, #board .rail-tools { margin-left: 10px; margin-right: 0; }
#reader .rail-nav, #board .rail-nav { margin-right: 10px; margin-left: 0; }
.rail .sep { width: 54%; height: 1px; background: rgba(246, 240, 228, .2); margin: clamp(2px, .6vh, 6px) 0; flex: none; }
.rail .grow { flex: 1; }
.tool {
  width: 100%; min-height: clamp(60px, 9vh, 80px); border-radius: 18px;
  display: grid; place-items: center; align-content: center; gap: 4px;
  color: var(--foil); font-size: 15px; font-weight: 800; line-height: 1.1; text-align: center;
  font-family: var(--f-ui);
}
html[lang="ar"] .tool { font-family: var(--f-ar); font-size: 16px; font-weight: 700; }
.tool .ico { width: 34px; height: 34px; }
.tool[aria-pressed="true"] { background: var(--foil); color: #1E1916; box-shadow: 0 1px 0 rgba(255,255,255,.6) inset, 0 4px 0 rgba(0,0,0,.28), 0 10px 18px -8px rgba(0,0,0,.5); }
.tool.t-laser { min-height: clamp(76px, 11.5vh, 100px); }
.tool.t-laser .ico { width: 44px; height: 44px; color: #FF7D72; }
.tool.t-laser[aria-pressed="true"] { background: #FFF8F5; color: #8A140E; box-shadow: 0 0 0 3px var(--laser), 0 0 26px rgba(255, 45, 32, .6), 0 4px 0 rgba(0,0,0,.25); }
.tool.t-laser[aria-pressed="true"] .ico { color: var(--laser); filter: drop-shadow(0 0 6px rgba(255, 45, 32, .7)); }
.tool:disabled { opacity: .32; }
.tool:active:not(:disabled) { transform: translateY(1px); }

.swatches { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(6px, 1vh, 10px); width: 100%; justify-items: center; }
.swatch { width: clamp(38px, 5.6vh, 46px); height: clamp(38px, 5.6vh, 46px); border-radius: 50%; background: var(--sw); position: relative; box-shadow: inset 0 0 0 2px rgba(255,255,255,.25), 0 3px 6px rgba(0,0,0,.3); }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 3px rgba(10,6,4,.6), 0 0 0 6px var(--foil); }
.swatch.hl { border-radius: 10px; }
/* eight colours in the bar: the tool buttons give a little height so it fits an iPad mini */
.rail-tools .tool:not(.t-laser) { min-height: clamp(54px, 7.9vh, 76px); }
.sizes { display: flex; justify-content: space-between; width: 100%; padding: 0 2px; }
.size { width: 30px; height: 40px; display: grid; place-items: center; border-radius: 10px; }
.size i { display: block; border-radius: 50%; background: var(--foil); }
.size[aria-pressed="true"] { background: rgba(246, 240, 228, .18); box-shadow: inset 0 0 0 2px var(--foil); }
.tool-note { font-size: 14px; text-align: center; opacity: .88; padding: 0 4px; line-height: 1.25; margin: 0; }

.who {
  width: 100%; display: grid; justify-items: center; gap: 6px; padding: 8px 4px 10px; border-radius: 18px;
  color: var(--foil); font-weight: 800; font-size: 15px; text-align: center; line-height: 1.15;
  font-family: var(--f-display);
}
.who span { font-size: 21px; font-weight: 700; }
html[lang="ar"] .who span { font-family: var(--f-ar-display); font-size: 19px; }
.who .mini svg { width: 70%; height: auto; }
.who .mini { display: grid; place-items: center; color: rgba(246,240,228,.85); width: 34px; height: 46px; border-radius: 6px 2px 2px 6px; background: var(--grain), var(--leather); background-blend-mode: soft-light, normal; box-shadow: 0 0 0 1.5px rgba(246,240,228,.75), -3px 0 0 0 var(--paper-edge), 0 6px 10px rgba(0,0,0,.4); }
.who span { max-width: 100%; overflow-wrap: anywhere; }
.pageno { display: grid; justify-items: center; gap: 0; color: var(--foil); text-align: center; line-height: 1.1; padding: 0 2px; }
.pageno .pk { font-size: 13px; opacity: .8; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
html[lang="ar"] .pageno .pk { letter-spacing: 0; font-size: 15px; }
.pageno .pv { font-family: var(--f-display); font-size: 40px; line-height: 1; font-weight: 600; font-variant-numeric: lining-nums tabular-nums; white-space: nowrap; }
.pageno .pv.range { font-size: 29px; }
html[lang="ar"] .pageno .pv { font-family: var(--f-ar-display); font-size: 32px; line-height: 1.4; }
.pageno .ps { font-size: 14px; opacity: .88; max-width: 96px; overflow-wrap: anywhere; font-weight: 700; }
.navbtn {
  width: 100%; min-height: clamp(70px, 11vh, 96px); border-radius: 18px;
  display: grid; place-items: center; align-content: center; gap: 2px;
  background: rgba(246, 240, 228, .1); color: var(--foil); font-weight: 800; font-size: 15px;
  box-shadow: inset 0 0 0 1.5px rgba(246, 240, 228, .25);
}
html[lang="ar"] .navbtn { font-size: 16px; }
.navbtn .ico { width: 40px; height: 40px; }
.navbtn.next { background: var(--foil); color: #1E1916; box-shadow: 0 1px 0 rgba(255,255,255,.6) inset, 0 4px 0 rgba(0,0,0,.28), 0 12px 20px -10px rgba(0,0,0,.6); }
.navbtn:disabled { opacity: .3; }
.navbtn:active:not(:disabled) { transform: translateY(2px); }

.stage { position: relative; flex: 1; min-width: 0; touch-action: none; overflow: hidden; }
.book { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.laser { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 40; }

.paper {
  position: absolute; top: 0; overflow: hidden;
  background: var(--paper);
  contain: layout paint;
}
.paper > * { position: absolute; pointer-events: none; }
.paper .text { -webkit-user-drag: none; user-select: none; }
.paper .glow { background: rgba(255, 196, 0, .38); border-radius: 6px; animation: glow 4.2s ease-out forwards; mix-blend-mode: multiply; }
@keyframes glow { 0% { opacity: 0; } 8% { opacity: 1; } 20% { opacity: .55; } 32% { opacity: 1; } 70% { opacity: 1; } 100% { opacity: 0; } }
.paper .head, .paper .foot { left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; font-family: var(--f-ar-display); color: #57504A; direction: rtl; white-space: nowrap; }
.paper .foot { justify-content: center; }
.paper .owner { display: flex; align-items: center; justify-content: center; font-family: var(--f-display); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: .01em; }
.paper .owner.ar, .paper .owner-inline.ar { font-family: var(--f-ar-display); }
.paper .owner-inline { font-family: var(--f-display); font-size: 1.15em; font-weight: 700; }
.paper .imprint { display: flex; align-items: center; gap: .35em; font-family: var(--f-display); font-weight: 600; color: #958C7F; white-space: nowrap; direction: ltr; }
.paper .imprint .im-mark { display: block; width: 1.45em; height: 1.45em; color: var(--accent); }
.paper .imprint .im-mark svg { width: 100%; height: 100%; display: block; overflow: visible; }
.paper .mark { display: grid; justify-items: center; font-family: var(--f-ar-display); color: #2E4A8C; line-height: 1; transform: translate(-50%, -50%); }
.paper .mark .g { font-family: var(--f-quran); }
.paper .notes-label { left: 0; right: 0; text-align: center; font-family: var(--f-ui); color: #8C877B; letter-spacing: .02em; }
.paper.lined { background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--lh) - 1.5px), #D9E1EA calc(var(--lh) - 1.5px), #D9E1EA var(--lh)); background-position: 0 var(--lt); background-size: 100% var(--lh); background-repeat: repeat-y; }
.paper.grid { background-image: linear-gradient(to bottom, #E2E8EE 1px, transparent 1px), linear-gradient(to right, #E2E8EE 1px, transparent 1px); background-size: var(--gs) var(--gs); }
/* gutter shading on the spine side and the page block thickness on the outer side */
.paper .gutter { top: 0; bottom: 0; width: 9%; }
.paper.side-L .gutter { right: 0; background: linear-gradient(to left, rgba(60, 50, 30, .16), rgba(60, 50, 30, .05) 30%, rgba(60, 50, 30, 0)); }
.paper.side-R .gutter { left: 0; background: linear-gradient(to right, rgba(60, 50, 30, .16), rgba(60, 50, 30, .05) 30%, rgba(60, 50, 30, 0)); }
.paper.side-S .gutter { display: none; }
.paper .bm { top: -2px; width: 3.2%; height: 8.5%; background: #B23A3A; clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 86%, 0 100%); box-shadow: 0 2px 4px rgba(0,0,0,.3); }

.edges { position: absolute; top: 3px; bottom: -3px; pointer-events: none; }
.edges.L { background: repeating-linear-gradient(to right, #D8CFBD 0 1px, #FBF8F0 1px 2.4px); border-radius: 2px 0 0 2px; }
.edges.R { background: repeating-linear-gradient(to left, #D8CFBD 0 1px, #FBF8F0 1px 2.4px); border-radius: 0 2px 2px 0; }
.book-shadow { position: absolute; pointer-events: none; box-shadow: 0 34px 60px -24px rgba(0,0,0,.7), 0 6px 14px rgba(0,0,0,.25), 0 0 0 1px rgba(0,0,0,.08); border-radius: 3px; }

.paper .layer { left: 0; top: 0; width: 100%; height: 100%; }
.paper .layer canvas { position: absolute; left: 0; top: 0; width: 100%; height: 100%; }
/* tafsir page: the commentary beside the Quran page, set like a printed tafsir */
/* the tafsir names: big enough to read at a glance and to tap without aiming */
.paper .tf-tabs { left: 0; right: 0; display: flex; justify-content: center; align-items: center; gap: .45em; pointer-events: auto; font-size: max(20px, calc(var(--k) * 60px)); z-index: 3; }
.paper .tf-tabs button { padding: .12em .95em; border-radius: 999px; font-family: var(--f-ar-display); font-weight: 700; color: #5E574C; box-shadow: inset 0 0 0 2px #DCD1C0; background: transparent; line-height: 1.5; min-height: 44px; white-space: nowrap; }
.paper .tf-tabs button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); box-shadow: none; }
.paper .tf-scroll {
  overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  font-family: var(--f-ar); color: #2A2420; font-size: calc(var(--k) * 54px); line-height: 1.95; text-align: justify;
  background: transparent;
  padding: .3em .2em 2em;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 1.2em, #000 calc(100% - 1.6em), transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 1.2em, #000 calc(100% - 1.6em), transparent 100%);
  scrollbar-width: thin;
}
.paper .tf-wait { margin: 3em 0; text-align: center; color: #8C877B; font-family: var(--f-ar); }
.tf-group + .tf-group { margin-top: 1.3em; }
.tf-ref { display: flex; align-items: center; gap: .6em; margin: 0 0 .5em; font-family: var(--f-ar-display); font-weight: 700; color: var(--accent); font-size: .92em; line-height: 1.5; }
.tf-ref::before, .tf-ref::after { content: ""; flex: 1; height: 1px; background: #E4DACB; }
.tf-ref span { white-space: nowrap; }
.tf-body p { margin: 0 0 .55em; }
.tf-body h4 { margin: .9em 0 .35em; font-family: var(--f-ar-display); font-size: 1.04em; line-height: 1.7; font-weight: 700; color: #3B3127; }
.tf-body .qq { font-family: var(--f-quran); color: #2E4A8C; }
.tf-body h4 .qq { color: var(--accent); }
.tf-body p.r { color: #6E655A; font-size: .9em; line-height: 1.85; }
.tf-body .sref { color: #8C877B; font-size: .82em; }
.tf-body p.verse { text-align: center; font-family: var(--f-ar-display); color: #3B3127; }
.tf-body b { font-weight: 700; }
.tf-none { color: #8C877B; font-size: .92em; margin: 0; }
/* al-Muyassar opens each surah with a short note on its name and aims */
.tf-body .tf-intro { margin: 0 0 .9em; padding: .55em .85em .25em; border-radius: 12px; background: #F4EEE3; font-size: .86em; line-height: 1.85; color: #4A4238; }
.tf-body .tf-intro h4 { margin: .25em 0 .15em; font-size: 1em; color: var(--accent); }
.tf-body .tf-intro p { margin: 0 0 .45em; }
.tf-gap { margin: 1.6em 0 0; padding: .9em 1em 1em; border-radius: 14px; background: #F4EEE3; text-align: center; display: grid; gap: .7em; justify-items: center; }
.tf-group + .tf-gap { margin-top: 1.8em; }
.tf-gap p { margin: 0; color: #5E574C; font-size: .9em; line-height: 1.8; }
.tf-gap .tf-switch { pointer-events: auto; font-family: var(--f-ar-display); font-weight: 700; font-size: .92em; line-height: 1.5; padding: .3em 1.1em; min-height: 44px; border-radius: 999px; background: var(--accent); color: var(--on-accent); }
.tf-group.flash .tf-ref { animation: tfflash 1.8s ease-out; border-radius: 8px; }
@keyframes tfflash { 0%, 40% { background: rgba(255, 216, 61, .55); } 100% { background: transparent; } }
.off-rows { display: grid; gap: 8px; }
.off-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; }
.off-row b { font-size: 19px; }
.off-row span { font-size: 17px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.off-row span.ok { color: #1E7A47; font-weight: 800; }
.off-row .progress { grid-column: 1 / -1; height: 8px; }

/* page curl */
.curl-layer { position: absolute; left: 0; top: 0; overflow: hidden; z-index: 25; pointer-events: none; }
.curl-flap { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.curl-flap > .paper { box-shadow: none; }
.curl-clip { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; }
.curl-band { position: absolute; left: 0; top: 0; height: 6000px; transform-origin: 0 0; display: block; }
.sizes .ring { background: transparent !important; box-shadow: 0 0 0 2px var(--foil); }
.size i.laser-dot { background: #FF5A4E; box-shadow: 0 0 0 1.5px rgba(255,255,255,.85); }
.flip-hint {
  position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50;
  display: flex; align-items: center; gap: 18px; padding: 16px 22px 16px 18px; border-radius: 16px;
  background: rgba(20, 14, 10, .9); color: var(--foil); font-size: 19px; max-width: min(720px, 92%);
  box-shadow: 0 16px 40px rgba(0,0,0,.4), inset 0 0 0 1px rgba(255,248,235,.12); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.flip-hint b { font-weight: 800; }
.flip-hint .hand { font-size: 0; width: 58px; height: 46px; flex: none; position: relative; }
.flip-hint .hand::before { content: ""; position: absolute; left: 4px; top: 18px; width: 34px; height: 4px; border-radius: 2px; background: var(--foil); animation: swipe 1.6s var(--ease-out) infinite; }
@keyframes swipe { 0% { transform: translateX(0); opacity: 0; } 20% { opacity: 1; } 80% { transform: translateX(20px); opacity: 1; } 100% { transform: translateX(20px); opacity: 0; } }
.flip-hint button { min-height: 52px; padding: 0 20px; border-radius: 14px; background: var(--foil); color: var(--ink); font-weight: 800; font-size: 18px; flex: none; }

/* ---------- Sheets (dialogs) ---------- */
.sheet-layer { position: fixed; inset: 0; z-index: 100; background: rgba(24, 18, 14, .46); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); display: grid; place-items: center; padding: calc(20px + var(--sat)) 20px calc(20px + var(--sab)); animation: fadein .18s ease-out; }
@keyframes fadein { from { opacity: 0; } }
.sheet {
  width: min(620px, 100%); max-height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--paper); border-radius: 30px; padding: 30px 32px 30px;
  box-shadow: 0 40px 90px -20px rgba(20,12,8,.5), 0 0 0 1px rgba(0,0,0,.04); display: grid; gap: 20px;
  animation: rise .26s var(--ease-out);
}
.sheet.wide { width: min(860px, 100%); }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
.sheet-head { display: flex; align-items: flex-start; gap: 16px; }
.sheet-head h2 { margin: 0; flex: 1; font-family: var(--f-display); font-size: 42px; line-height: 1.02; font-weight: 700; text-wrap: balance; }
html[lang="ar"] .sheet-head h2 { font-family: var(--f-ar-display); font-size: 34px; line-height: 1.4; }
.sheet-head .x { width: 56px; height: 56px; margin: -10px -12px 0 0; display: grid; place-items: center; border-radius: 50%; color: var(--ink-2); flex: none; }
html[dir="rtl"] .sheet-head .x { margin: -10px 0 0 -12px; }
.sheet p { margin: 0; font-size: 21px; }
.sheet .muted { color: var(--ink-2); font-size: 19px; }
.sheet-actions { display: flex; gap: 14px; flex-wrap: wrap; justify-content: flex-end; margin-top: 4px; }
.sheet-actions .btn { flex: 1 1 200px; }
.sheet .field input { font-size: 28px; }
/* two neat rows of eight */
.colors { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 14px 12px; max-width: 560px; }
.color-pick { width: 100%; aspect-ratio: 62 / 86; height: auto; border-radius: 9px 3px 3px 9px; background: var(--grain), var(--c); background-blend-mode: soft-light, normal; box-shadow: -3px 0 0 -1px var(--paper), -4px 0 0 -1px var(--paper-edge), 0 8px 14px -8px rgba(0,0,0,.5); position: relative; }
.color-pick[aria-pressed="true"]::after { content: ""; position: absolute; inset: -6px; border-radius: 14px 7px 7px 14px; border: 3px solid var(--accent); }
.list-actions { display: grid; gap: 10px; }
.list-actions .btn { justify-content: flex-start; width: 100%; }
.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg { background: var(--ground); padding: 5px; border-radius: 18px; gap: 4px; }
.seg button { min-height: 56px; padding: 0 18px; border-radius: 14px; font-size: 20px; font-weight: 800; flex: 1 1 130px; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--paper); color: var(--accent); box-shadow: 0 2px 6px rgba(40,25,15,.18), 0 0 0 1px rgba(0,0,0,.03); }
.set-group { display: grid; gap: 10px; padding-top: 20px; border-top: 1px solid var(--ground-2); }
.set-group:first-of-type { border-top: 0; padding-top: 0; }
.set-group h3 { margin: 0; font-family: var(--f-display); font-size: 30px; line-height: 1.05; font-weight: 700; }
html[lang="ar"] .set-group h3 { font-family: var(--f-ar-display); font-size: 26px; line-height: 1.4; }
.set-group .muted { font-size: 18px; }
.progress { height: 12px; border-radius: 6px; background: var(--ground-2); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s linear; }
.juz-sheet-list { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.juz-sheet-list li + li { box-shadow: 0 -1px 0 var(--ground-2); }
.juz-sheet-row { width: 100%; display: grid; grid-template-columns: 70px minmax(0, 1fr) auto; gap: 14px; align-items: center; min-height: 66px; padding: 8px 6px; text-align: start; }
.juz-sheet-row:active { background: var(--ground); }
.juz-sheet-row .fr { font-family: var(--f-display); font-weight: 700; color: var(--accent); font-size: 26px; text-align: center; }
html[lang="ar"] .juz-sheet-row .fr { font-family: var(--f-ar-display); font-size: 20px; }
.juz-sheet-row .w { font-family: var(--f-quran); direction: rtl; text-align: right; font-size: 23px; line-height: 1.8; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.juz-sheet-row .w.ui { font-family: inherit; direction: inherit; text-align: start; font-size: 20px; font-weight: 700; }
.juz-sheet-row .p { font-family: var(--f-display); font-weight: 700; color: var(--accent); font-variant-numeric: lining-nums tabular-nums; font-size: 28px; white-space: nowrap; }
html[lang="ar"] .juz-sheet-row .p { font-family: var(--f-ar-display); font-size: 24px; }
.sheet h4 { margin: 8px 0 0; font-family: var(--f-display); font-size: 28px; line-height: 1.1; color: var(--ink); font-weight: 700; }
html[lang="ar"] .sheet h4 { font-family: var(--f-ar-display); font-size: 24px; line-height: 1.4; }
.about { font-size: 17px; color: var(--ink-2); display: grid; gap: 8px; }
.about p { font-size: 17px; }
.about a { color: var(--accent); font-weight: 700; }

.toast { position: fixed; left: 50%; bottom: calc(26px + var(--sab)); transform: translateX(-50%); z-index: 200; background: rgba(28, 20, 15, .94); color: var(--foil); padding: 16px 26px; border-radius: 18px; font-size: 20px; font-weight: 700; box-shadow: 0 16px 40px rgba(0,0,0,.35); max-width: min(640px, 90vw); text-align: center; animation: rise .24s var(--ease-out); }

/* right rail holds eight controls: a little tighter so it fits an iPad mini in landscape */
.rail-nav .tool { min-height: clamp(54px, 7.9vh, 76px); }
.rail-nav .tool.mode { min-height: clamp(48px, 7vh, 70px); gap: 2px; }
.rail-nav .tool.mode .ico { width: 30px; height: 30px; }
.rail-nav .navbtn { min-height: clamp(62px, 9.8vh, 92px); }
.rail-nav .who { padding: 6px 4px 6px; gap: 4px; }
.rail-nav .who .mini { width: 30px; height: 40px; }

/* ---------- PDF sheet ---------- */
/* the share sheet */
.pdf-how { margin: 0; font-size: 18px; line-height: 1.5; color: var(--ink-2); }
.pdf-step { display: flex; align-items: center; gap: 10px; margin: 8px 0 -4px; font-size: 21px; font-weight: 800; }
.pdf-step i { flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--on-accent); font-style: normal; font-size: 18px; line-height: 1; }
.pdf-tafsir small { font-size: 16px; font-weight: 600; color: var(--ink-2); line-height: 1.35; }
.pdf-opts { display: grid; gap: 10px; }
.pdf-opt { width: 100%; display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 14px; align-items: start; text-align: start; padding: 16px 18px; border-radius: 18px; background: var(--ground); }
.pdf-opt[aria-checked="true"] { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.pdf-opt:disabled { opacity: .45; }
.pdf-opt .dot { width: 28px; height: 28px; border-radius: 50%; box-shadow: inset 0 0 0 2.5px var(--ink-2); margin-top: 2px; }
.pdf-opt[aria-checked="true"] .dot { box-shadow: inset 0 0 0 2.5px var(--accent), inset 0 0 0 8px var(--paper), inset 0 0 0 14px var(--accent); }
.pdf-opt .txt { display: grid; gap: 2px; min-width: 0; }
.pdf-opt b { font-size: 22px; }
.pdf-opt .txt > span { font-size: 18px; color: var(--ink-2); }
.pdf-range { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.pdf-range label { font-size: 18px; font-weight: 700; color: var(--ink-2); }
.pdf-range input { min-height: 56px; border-radius: 14px; border: 0; background: var(--paper); padding: 0 14px; font-size: 24px; font-weight: 700; box-shadow: inset 0 0 0 2px var(--ground-2); }
.share-pdf { width: 100%; }

/* ---------- Portrait and small screens ---------- */
@media (orientation: portrait) {
  .home-side { width: 280px; padding: 32px 24px 24px 28px; }
  html[dir="rtl"] .home-side { padding: 32px 28px 24px 24px; }
  .brand-name { font-size: 42px; }
  .home-main { padding: 32px 28px 50px; }
  .shelf { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 34px 22px; }
  .ct-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .ct-left { padding: 4px 24px 18px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px 22px; overflow: visible; max-height: 42vh; overflow-y: auto; }
  .ct-left > .continue, .ct-left > .start-fresh { grid-column: 1 / -1; }
  .ct-right { border-inline-start: 0; border-top: 2px solid var(--ground-2); }
  .juz-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .surah-list { grid-template-columns: minmax(0, 1fr); }
  .install-steps { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 700px) {
  #home { flex-direction: column; overflow-y: auto; }
  .home-side { width: auto; border: 0; padding: 22px 20px 0; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 14px 24px; }
  .home-date { border: 0; padding: 0; }
  .home-settings { margin: 0; }
  .home-main { overflow: visible; padding: 22px 20px 40px; }
  .shelf { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 30px 18px; }
  .cover .cv-name { font-size: 20px; }
  .ct-left { grid-template-columns: minmax(0, 1fr); }
  .tabs { padding: 0 12px; }
  .tab { padding: 0 12px; font-size: 20px; }
  .panel { padding: 18px 16px 40px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

html[lang="ar"] .brand-sub { max-width: none; }

/* ---------- Home: whiteboard lessons ---------- */
.boards-head { margin: 64px 0 30px; }
.home-q.sub { font-size: 40px; }
html[lang="ar"] .home-q.sub { font-size: 34px; }
.shelf.boards { grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 40px 34px; }
.board-card {
  position: relative; display: block; width: 100%; aspect-ratio: 1.42; padding: 11px; border-radius: 10px;
  background:
    linear-gradient(to bottom, rgba(255,255,255,.18), rgba(255,255,255,0) 40%, rgba(0,0,0,.16)),
    var(--grain), var(--c, var(--leather));
  background-blend-mode: normal, soft-light, normal;
  box-shadow: 0 2px 0 rgba(0,0,0,.2), 0 24px 30px -20px rgba(30, 20, 15, .6);
  transition: transform .4s var(--ease-out);
}
.board-card:active { transform: scale(.98); }
.board-card .bc-surface {
  position: absolute; inset: 11px; border-radius: 3px; overflow: hidden;
  background-color: #FDFDFB;
  background-image: radial-gradient(circle, rgba(40, 52, 74, .2) 1.1px, transparent 1.5px);
  background-size: 18px 18px;
  box-shadow: inset 0 1px 3px rgba(0,0,0,.18);
  display: grid; place-items: center;
}
.board-card .bc-surface img { width: 100%; height: 100%; object-fit: contain; display: block; }
.board-card .bc-name {
  font-family: var(--f-display); font-size: 30px; font-weight: 700; line-height: 1.1; color: #1B4FC4;
  padding: 10px 18px; text-align: center; overflow-wrap: anywhere; text-wrap: balance;
}
.board-card .bc-name.ar { font-family: var(--f-ar-display); line-height: 1.5; }
.board-card .bc-tray {
  position: absolute; left: 22%; right: 22%; bottom: -7px; height: 9px; border-radius: 0 0 5px 5px;
  background: var(--grain), var(--c, var(--leather)); background-blend-mode: soft-light, normal;
  box-shadow: 0 3px 4px rgba(0,0,0,.25);
}
.board-card .bc-tray::before, .board-card .bc-tray::after { content: ""; position: absolute; top: -5px; height: 6px; width: 26%; border-radius: 3px; }
.board-card .bc-tray::before { left: 14%; background: #C81E28; }
.board-card .bc-tray::after { right: 18%; background: #1B4FC4; }
.cover-add.board-add { aspect-ratio: 1.42; border-radius: 10px; }

/* the choice at the top of "new": Quran or whiteboard */
.kind-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.kind-pick button {
  display: grid; justify-items: center; gap: 8px; padding: 16px 10px 14px; border-radius: 18px;
  font-size: 20px; font-weight: 800; color: var(--ink-2); background: var(--paper);
  box-shadow: inset 0 0 0 2px var(--ground-2);
}
.kind-pick button .ico { width: 44px; height: 44px; }
.kind-pick button[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 3px var(--accent); }

/* ---------- Whiteboard ---------- */
.bstage {
  margin: clamp(8px, 1.4vh, 14px) 12px; border-radius: 12px;
  background-color: #FDFDFB;
  background-image: radial-gradient(circle, rgba(40, 52, 74, .22) 1.25px, transparent 1.7px);
  box-shadow: 0 0 0 1px rgba(0,0,0,.1), 0 30px 60px -24px rgba(0,0,0,.6), 0 6px 14px rgba(0,0,0,.22);
}
.b-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; z-index: 1; pointer-events: none; }
.b-img {
  position: absolute; display: block; max-width: none; pointer-events: none;
  -webkit-user-drag: none; user-select: none; -webkit-user-select: none;
  box-shadow: 0 0 0 1px rgba(0,0,0,.08), 0 10px 22px -12px rgba(0,0,0,.4);
}
.b-cv { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }
#bInk { z-index: 3; }
#bLive { z-index: 4; }
.b-sel { position: absolute; z-index: 6; pointer-events: none; outline: 3px solid #2F6FE4; outline-offset: 2px; border-radius: 2px; }
.b-del {
  position: absolute; left: -26px; top: -26px; width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center; pointer-events: auto; color: #fff; background: #C42B2B;
  box-shadow: 0 0 0 3px #fff, 0 6px 12px rgba(0,0,0,.3);
}
.b-del .ico { width: 24px; height: 24px; }
.b-handle {
  position: absolute; right: -24px; bottom: -24px; width: 44px; height: 44px; border-radius: 50%; pointer-events: auto;
  background: #fff; box-shadow: 0 0 0 3px #2F6FE4, 0 6px 12px rgba(0,0,0,.3);
}
.b-handle::after { content: ""; position: absolute; inset: 13px; border-right: 3px solid #2F6FE4; border-bottom: 3px solid #2F6FE4; border-radius: 0 0 3px 0; }
.b-zoom {
  position: absolute; right: 14px; bottom: 12px; z-index: 7; pointer-events: none;
  padding: 5px 12px; border-radius: 999px; background: rgba(255,255,255,.88);
  font: 800 16px/1 var(--f-ui); color: rgba(30, 40, 60, .62); font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 1px rgba(0,0,0,.06);
}
.tool.big-add {
  background: var(--foil); color: #1E1916; min-height: clamp(70px, 11vh, 96px);
  box-shadow: 0 1px 0 rgba(255,255,255,.6) inset, 0 4px 0 rgba(0,0,0,.28), 0 12px 20px -10px rgba(0,0,0,.6);
}
.tool.big-add .ico { width: 40px; height: 40px; }
.who .mini.board { width: 44px; height: 32px; border-radius: 3px; background: #FDFDFB; box-shadow: 0 0 0 3px var(--leather), 0 0 0 4.5px rgba(246,240,228,.75), 0 6px 10px rgba(0,0,0,.4); }
.who .mini.board::after { content: ""; display: block; width: 60%; height: 2px; margin: auto; background: #1B4FC4; border-radius: 2px; box-shadow: 0 6px 0 -0.5px #C81E28; transform: translateY(-3px); }

/* Fajr School */
:root {
  --ground: #F7F2EC;
  --ground-2: #ECE3DA;
  --paper-edge: #E6DBCF;
  --accent: #3B2A5E;
  --accent-2: #564282;
  --accent-soft: #EAE5F1;
  --accent-deep: #241840;
  --on-accent: #FBF5EE;
  --leather: #3B2A5E;
}
