/* ==========================================================================
   Ahlan Quran Platform — theme.css
   Single source of truth for tokens + component classes.
   Django: move to static/css/theme.css and load via {% static %}.
   Rules baked in:
     • Colors are RGB channel triplets so Tailwind can apply /alpha.
     • Every directional property is LOGICAL (inline-start/end) → RTL-safe.
     • Portal density is set by <html data-portal="…"> changing the root
       font-size; all rem-based spacing and type scale together.
   ========================================================================== */

:root {
  /* Brand — navy (structure, action) */
  --navy-50: 238 242 249;  --navy-100: 220 228 241; --navy-200: 185 200 226;
  --navy-300: 141 163 201; --navy-400: 91 122 174;  --navy-500: 58 90 147;
  --navy-600: 42 71 120;   --navy-700: 31 56 100;   --navy-800: 24 44 80;
  --navy-900: 17 32 64;    --navy-950: 11 22 48;

  /* Brand — gold (progress, recognition; never body text on light) */
  --gold-50: 252 248 234;  --gold-100: 247 236 201; --gold-200: 238 217 154;
  --gold-300: 224 189 94;  --gold-400: 208 160 42;  --gold-500: 184 134 11;
  --gold-600: 150 107 8;   --gold-700: 117 83 7;    --gold-800: 85 59 5;

  /* Paper — warm neutrals for grounds and hairlines */
  --paper-50: 251 250 247; --paper-100: 246 244 238; --paper-200: 236 232 222;
  --paper-300: 221 215 200; --paper-400: 194 187 168;

  /* Ink — navy-biased cool neutrals for text and controls */
  --ink-50: 243 244 247;  --ink-100: 232 234 238; --ink-200: 213 217 224;
  --ink-300: 180 186 198; --ink-400: 141 149 165; --ink-500: 102 112 131;
  --ink-600: 78 88 107;   --ink-700: 58 68 87;    --ink-800: 38 47 66;
  --ink-900: 23 32 51;

  /* Semantic — separate from brand hues */
  --ok-50: 230 243 236;    --ok-600: 47 125 91;    --ok-700: 31 92 66;
  --warn-50: 252 238 220;  --warn-600: 180 84 10;  --warn-700: 138 63 5;
  --danger-50: 251 231 229; --danger-600: 179 38 30; --danger-700: 140 28 22;
  --info-50: 230 239 249;  --info-600: 43 108 176; --info-700: 31 78 133;

  /* Shape & elevation */
  --r-sm: 6px; --r-md: 8px; --r-lg: 12px; --r-xl: 20px;
  --shadow-pop: 0 8px 24px -6px rgb(var(--navy-950) / .22), 0 0 0 1px rgb(var(--navy-950) / .06);
  --shadow-modal: 0 24px 60px -12px rgb(var(--navy-950) / .40);

  --dir: 1; /* flips to -1 under RTL; used for transforms */
  --sidebar-w: 16rem;
  --topbar-h: 3.75rem;
}
[dir="rtl"] { --dir: -1; }

/* ---- Density per portal ------------------------------------------------- */
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
html[data-portal="admin"]   { font-size: 14px; }
html[data-portal="teacher"] { font-size: 15px; }
html[data-portal="student"], html[data-portal="parent"] { font-size: 16px; }

/* ---- Base --------------------------------------------------------------- */
body {
  background: rgb(var(--paper-100));
  color: rgb(var(--ink-900));
  font-family: "Readex Pro", "Segoe UI", system-ui, -apple-system, "Noto Sans Arabic", sans-serif;
  font-size: 1rem; line-height: 1.55;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
::selection { background: rgb(var(--gold-200)); color: rgb(var(--navy-900)); }
:focus-visible { outline: 2px solid rgb(var(--navy-500)); outline-offset: 2px; border-radius: 4px; }
.on-dark :focus-visible { outline-color: rgb(var(--gold-300)); }
[hidden] { display: none !important; }

/* ---- Type scale --------------------------------------------------------- */
.t-display { font-size: 2.5rem; line-height: 1.1; font-weight: 600; letter-spacing: -0.02em; text-wrap: balance; }
.t-h1 { font-size: 1.75rem; line-height: 1.2; font-weight: 600; letter-spacing: -0.015em; text-wrap: balance; }
.t-h2 { font-size: 1.25rem; line-height: 1.3; font-weight: 600; letter-spacing: -0.01em; }
.t-h3 { font-size: 1rem; line-height: 1.4; font-weight: 600; }
.t-body { font-size: 1rem; line-height: 1.55; }
.t-small { font-size: .875rem; line-height: 1.5; }
.t-caption { font-size: .75rem; line-height: 1.4; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; }
.t-mono { font-family: "IBM Plex Mono", ui-monospace, Consolas, monospace; font-size: .8125rem; letter-spacing: 0; }
.t-num { font-variant-numeric: tabular-nums; }
.quran { font-family: "Amiri", "Amiri Quran", "Traditional Arabic", serif; line-height: 2.2; font-size: 1.75rem; }
.text-2 { color: rgb(var(--ink-600)); }
.text-3 { color: rgb(var(--ink-500)); }

/* ---- Icons -------------------------------------------------------------- */
.i { width: 1.25rem; height: 1.25rem; flex: none; fill: none; stroke: currentColor;
     stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.i-sm { width: 1rem; height: 1rem; }
.i-lg { width: 1.5rem; height: 1.5rem; }
[dir="rtl"] .i-flip { transform: scaleX(-1); }

/* ---- Geometric pattern (8-point star lattice) --------------------------- */
.pattern-dark, .pattern-light { background-size: 56px 56px; }
.pattern-dark {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56' fill='none' stroke='%23D0A02A' stroke-opacity='.20' stroke-width='1'%3E%3Crect x='13' y='13' width='30' height='30'/%3E%3Crect x='13' y='13' width='30' height='30' transform='rotate(45 28 28)'/%3E%3Ccircle cx='28' cy='28' r='4'/%3E%3Cpath d='M0 28H6.8M49.2 28H56M28 0V6.8M28 49.2V56'/%3E%3C/svg%3E");
}
.pattern-light {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56' fill='none' stroke='%231F3864' stroke-opacity='.07' stroke-width='1'%3E%3Crect x='13' y='13' width='30' height='30'/%3E%3Crect x='13' y='13' width='30' height='30' transform='rotate(45 28 28)'/%3E%3Ccircle cx='28' cy='28' r='4'/%3E%3Cpath d='M0 28H6.8M49.2 28H56M28 0V6.8M28 49.2V56'/%3E%3C/svg%3E");
}
/* Fade the pattern out toward the inline-end so it never fights content */
.pattern-fade { -webkit-mask-image: linear-gradient(to left, #000 0%, transparent 85%); mask-image: linear-gradient(to left, #000 0%, transparent 85%); }
[dir="rtl"] .pattern-fade { -webkit-mask-image: linear-gradient(to right, #000 0%, transparent 85%); mask-image: linear-gradient(to right, #000 0%, transparent 85%); }

/* Ornamental rule: line — star — line. Used once per page header, max. */
.ornament { display: flex; align-items: center; gap: .75rem; color: rgb(var(--gold-500)); }
.ornament::before, .ornament::after { content: ""; height: 1px; flex: 1; background: currentColor; opacity: .45; }

/* ---- Buttons ------------------------------------------------------------ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 2.5rem; padding: 0 1rem; border: 1px solid transparent; border-radius: var(--r-md);
  font-family: inherit; font-size: .9375rem; font-weight: 500; line-height: 1; white-space: nowrap;
  cursor: pointer; text-decoration: none; transition: background-color .15s, border-color .15s, color .15s, transform .05s; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: rgb(var(--navy-700)); color: #fff; }
.btn-primary:hover { background: rgb(var(--navy-800)); }
.btn-secondary { background: #fff; color: rgb(var(--navy-800)); border-color: rgb(var(--ink-300)); }
.btn-secondary:hover { border-color: rgb(var(--navy-400)); background: rgb(var(--navy-50)); }
.btn-ghost { background: transparent; color: rgb(var(--navy-700)); }
.btn-ghost:hover { background: rgb(var(--navy-50)); }
.btn-accent { background: rgb(var(--gold-400)); color: rgb(var(--navy-900)); }   /* for use on navy surfaces */
.btn-accent:hover { background: rgb(var(--gold-300)); }
.btn-danger { background: rgb(var(--danger-600)); color: #fff; }
.btn-danger:hover { background: rgb(var(--danger-700)); }
.btn-danger-soft { background: rgb(var(--danger-50)); color: rgb(var(--danger-700)); }
.btn-danger-soft:hover { background: rgb(var(--danger-600)); color: #fff; }
.btn-sm { min-height: 2rem; padding: 0 .75rem; font-size: .8125rem; }
.btn-lg { min-height: 3rem; padding: 0 1.25rem; font-size: 1rem; }
.btn-icon { padding: 0; width: 2.5rem; }
.btn-sm.btn-icon { width: 2rem; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; pointer-events: none; }
.btn[aria-busy="true"] { pointer-events: none; }
.btn[aria-busy="true"]::before { content: ""; width: 1em; height: 1em; border-radius: 50%;
  border: 2px solid currentColor; border-inline-end-color: transparent; animation: spin .7s linear infinite; }

/* ---- Forms -------------------------------------------------------------- */
.label { display: block; margin-block-end: .375rem; font-size: .8125rem; font-weight: 500; color: rgb(var(--ink-700)); }
.hint { margin-block-start: .375rem; font-size: .75rem; color: rgb(var(--ink-600)); }
.hint-error { color: rgb(var(--danger-700)); display: flex; gap: .25rem; align-items: flex-start; }
.input, .select, .textarea { width: 100%; min-height: 2.5rem; padding: .5rem .75rem;
  background: #fff; color: rgb(var(--ink-900)); font: inherit; font-size: .9375rem;
  border: 1px solid rgb(var(--ink-400)); border-radius: var(--r-md);
  transition: border-color .15s, box-shadow .15s; }
.input::placeholder, .textarea::placeholder { color: rgb(var(--ink-400)); }
.input:hover, .select:hover, .textarea:hover { border-color: rgb(var(--ink-500)); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: rgb(var(--navy-600)); box-shadow: 0 0 0 3px rgb(var(--navy-500) / .22); }
.input[aria-invalid="true"] { border-color: rgb(var(--danger-600)); box-shadow: 0 0 0 3px rgb(var(--danger-600) / .12); }
.input:disabled { background: rgb(var(--paper-100)); color: rgb(var(--ink-500)); border-color: rgb(var(--ink-200)); }
.textarea { min-height: 5.5rem; resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-inline-end: 2.25rem; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23667083' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .75rem center; }
[dir="rtl"] .select { background-position: left .75rem center; }
.field-icon { position: relative; }
.field-icon > .i { position: absolute; inset-inline-start: .75rem; top: 50%; transform: translateY(-50%); color: rgb(var(--ink-500)); pointer-events: none; }
.field-icon > .input { padding-inline-start: 2.5rem; }
.check, .radio { width: 1.125rem; height: 1.125rem; accent-color: rgb(var(--navy-700)); cursor: pointer; }
.switch { appearance: none; position: relative; width: 2.5rem; height: 1.5rem; flex: none; cursor: pointer;
  background: rgb(var(--ink-300)); border-radius: 999px; transition: background-color .15s; }
.switch::before { content: ""; position: absolute; top: 2px; inset-inline-start: 2px; width: calc(1.5rem - 4px); height: calc(1.5rem - 4px);
  background: #fff; border-radius: 50%; box-shadow: 0 1px 2px rgb(0 0 0 / .25); transition: transform .15s; }
.switch:checked { background: rgb(var(--navy-700)); }
.switch:checked::before { transform: translateX(calc(1rem * var(--dir))); }
/* Segmented control (used for role choice, filters, portal switch) */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: rgb(var(--paper-200)); border-radius: var(--r-md); }
.seg > button, .seg > label { min-height: 2rem; padding: 0 .875rem; border: 0; border-radius: 6px; background: transparent;
  font: inherit; font-size: .8125rem; font-weight: 500; color: rgb(var(--ink-600)); cursor: pointer; display: inline-flex; align-items: center; gap: .375rem; }
.seg > [aria-pressed="true"], .seg > [aria-selected="true"] { background: #fff; color: rgb(var(--navy-800)); box-shadow: 0 1px 2px rgb(var(--navy-950) / .12); }

/* ---- Cards & surfaces --------------------------------------------------- */
.card { background: #fff; border: 1px solid rgb(var(--paper-200)); border-radius: var(--r-lg); }
.card-pad { padding: 1.25rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .875rem 1.25rem; border-block-end: 1px solid rgb(var(--paper-200)); }
.card-title { font-size: .9375rem; font-weight: 600; }
.divide > * + * { border-block-start: 1px solid rgb(var(--paper-200)); }
/* KPI ribbon: ONE surface, cells split by hairlines — not four separate cards */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); background: #fff;
  border: 1px solid rgb(var(--paper-200)); border-radius: var(--r-lg); overflow: hidden; }
.kpi { padding: 1rem 1.25rem; border-inline-end: 1px solid rgb(var(--paper-200)); border-block-end: 1px solid rgb(var(--paper-200)); margin-inline-end: -1px; margin-block-end: -1px; }
.kpi-label { font-size: .75rem; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: rgb(var(--ink-600)); }
.kpi-value { margin-block-start: .25rem; font-size: 1.75rem; line-height: 1.15; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi-note { margin-block-start: .25rem; font-size: .8125rem; color: rgb(var(--ink-600)); display: flex; align-items: center; gap: .375rem; }
/* Feature surface: navy with pattern (greeting bands, live-session card) */
.surface-navy { position: relative; overflow: hidden; background: rgb(var(--navy-800)); color: #fff; border-radius: var(--r-lg); isolation: isolate; }
.surface-navy > .pattern-dark { position: absolute; inset: 0; z-index: -1; }

/* ---- Badges / status tags ---------------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: .375rem; padding: .1875rem .625rem; border-radius: 999px;
  font-size: .75rem; font-weight: 500; line-height: 1.3; white-space: nowrap;
  background: rgb(var(--ink-100)); color: rgb(var(--ink-700)); }
.badge::before { content: ""; width: .375rem; height: .375rem; border-radius: 50%; background: currentColor; opacity: .85; }
.badge-plain::before { display: none; }
.badge-ok { background: rgb(var(--ok-50)); color: rgb(var(--ok-700)); }
.badge-warn { background: rgb(var(--warn-50)); color: rgb(var(--warn-700)); }
.badge-danger { background: rgb(var(--danger-50)); color: rgb(var(--danger-700)); }
.badge-info { background: rgb(var(--info-50)); color: rgb(var(--info-700)); }
.badge-navy { background: rgb(var(--navy-100)); color: rgb(var(--navy-800)); }
.badge-gold { background: rgb(var(--gold-100)); color: rgb(var(--gold-800)); }
.badge-live { background: rgb(var(--ok-600)); color: #fff; }
.badge-live::before { background: #fff; animation: pulse 1.6s ease-in-out infinite; }
.count { display: inline-flex; align-items: center; justify-content: center; min-width: 1.25rem; height: 1.25rem; padding: 0 .375rem;
  border-radius: 999px; font-size: .6875rem; font-weight: 600; background: rgb(var(--gold-400)); color: rgb(var(--navy-900)); font-variant-numeric: tabular-nums; }

/* ---- Avatars ------------------------------------------------------------ */
.avatar { display: inline-grid; place-items: center; flex: none; width: 2.25rem; height: 2.25rem; border-radius: 50%;
  background: rgb(var(--navy-100)); color: rgb(var(--navy-800)); font-size: .8125rem; font-weight: 600; letter-spacing: .02em; }
.avatar-gold { background: rgb(var(--gold-100)); color: rgb(var(--gold-800)); }
.avatar-sm { width: 1.75rem; height: 1.75rem; font-size: .6875rem; }
.avatar-lg { width: 3rem; height: 3rem; font-size: 1rem; }
.avatar-xl { width: 4rem; height: 4rem; font-size: 1.25rem; }

/* ---- Tables ------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th { padding: .625rem 1rem; text-align: start; white-space: nowrap; font-size: .6875rem; font-weight: 600;
  letter-spacing: .07em; text-transform: uppercase; color: rgb(var(--ink-600)); background: rgb(var(--paper-50));
  border-block-end: 1px solid rgb(var(--paper-200)); }
.table td { padding: .75rem 1rem; vertical-align: middle; border-block-end: 1px solid rgb(var(--paper-200)); }
.table tbody tr:last-child td { border-block-end: 0; }
.table tbody tr:hover { background: rgb(var(--paper-50)); }
.table .num { text-align: end; font-variant-numeric: tabular-nums; }
.table .actions { text-align: end; white-space: nowrap; width: 1%; }
/* On phones a row becomes a labelled stack (needs data-label on each <td>) */
@media (max-width: 639px) {
  .table-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack tr { padding: .75rem 1rem; border-block-end: 1px solid rgb(var(--paper-200)); }
  .table-stack tbody tr:last-child { border-block-end: 0; }
  .table-stack td { display: flex; justify-content: space-between; gap: 1rem; padding: .25rem 0; border: 0; text-align: end; }
  .table-stack td::before { content: attr(data-label); color: rgb(var(--ink-600)); font-size: .75rem; font-weight: 500; text-align: start; }
  .table-stack td.actions { justify-content: flex-end; width: 100%; padding-block-start: .5rem; }
  .table-stack td.actions::before { display: none; }
}

/* ---- Modal (native <dialog>) ------------------------------------------- */
dialog.modal { padding: 0; border: 0; border-radius: var(--r-xl); width: calc(100% - 2rem); max-width: 32rem; max-height: calc(100% - 2rem);
  background: #fff; color: rgb(var(--ink-900)); box-shadow: var(--shadow-modal); overflow: hidden; }
dialog.modal[open] { display: flex; flex-direction: column; animation: rise .18s ease-out; }
dialog.modal::backdrop { background: rgb(var(--navy-950) / .55); backdrop-filter: blur(2px); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 1.25rem 1.5rem 0; }
.modal-body { padding: 1rem 1.5rem; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: .5rem; padding: 1rem 1.5rem; background: rgb(var(--paper-50)); border-block-start: 1px solid rgb(var(--paper-200)); }
@media (max-width: 639px) {   /* bottom sheet on phones */
  dialog.modal { margin: auto 0 0; width: 100%; max-width: none; border-radius: var(--r-xl) var(--r-xl) 0 0; }
  .modal-foot { padding-block-end: calc(1rem + env(safe-area-inset-bottom, 0px)); flex-direction: column-reverse; }
  .modal-foot .btn { width: 100%; }
}

/* ---- Dropdown / tabs / toast / alert ----------------------------------- */
.dropdown { position: relative; }
.menu { position: absolute; inset-inline-end: 0; top: calc(100% + .375rem); z-index: 40; min-width: 13rem; padding: .375rem;
  background: #fff; border-radius: var(--r-lg); box-shadow: var(--shadow-pop); }
.menu-item { display: flex; align-items: center; gap: .625rem; width: 100%; padding: .5rem .625rem; border: 0; border-radius: var(--r-sm);
  background: none; font: inherit; font-size: .875rem; color: rgb(var(--ink-800)); text-align: start; cursor: pointer; text-decoration: none; }
.menu-item:hover { background: rgb(var(--navy-50)); }
.menu-item.danger { color: rgb(var(--danger-700)); }
.menu-item.danger:hover { background: rgb(var(--danger-50)); }
.menu-sep { height: 1px; margin: .375rem -.375rem; background: rgb(var(--paper-200)); }
.tabs { display: flex; gap: 1.5rem; border-block-end: 1px solid rgb(var(--paper-200)); overflow-x: auto; }
.tab { position: relative; padding: .625rem 0; border: 0; background: none; font: inherit; font-size: .9375rem; font-weight: 500;
  color: rgb(var(--ink-600)); cursor: pointer; white-space: nowrap; display: inline-flex; gap: .5rem; align-items: center; }
.tab:hover { color: rgb(var(--navy-800)); }
.tab[aria-selected="true"] { color: rgb(var(--navy-800)); }
.tab[aria-selected="true"]::after { content: ""; position: absolute; inset-inline: 0; bottom: -1px; height: 2px; background: rgb(var(--navy-700)); border-radius: 2px; }
.alert { display: flex; gap: .75rem; padding: .875rem 1rem; border-radius: var(--r-md); font-size: .875rem; }
.alert > .i { margin-block-start: .0625rem; }
.alert-info { background: rgb(var(--info-50)); color: rgb(var(--info-700)); }
.alert-ok { background: rgb(var(--ok-50)); color: rgb(var(--ok-700)); }
.alert-warn { background: rgb(var(--warn-50)); color: rgb(var(--warn-700)); }
.alert-danger { background: rgb(var(--danger-50)); color: rgb(var(--danger-700)); }
.toast { display: flex; align-items: center; gap: .75rem; padding: .75rem 1rem; border-radius: var(--r-md);
  background: rgb(var(--navy-900)); color: #fff; font-size: .875rem; box-shadow: var(--shadow-pop); }
.toast > .i { color: rgb(var(--gold-300)); }

/* ---- Loading & empty states -------------------------------------------- */
.skeleton { display: block; border-radius: var(--r-sm); background: linear-gradient(90deg, rgb(var(--paper-200)) 0%, rgb(var(--paper-100)) 50%, rgb(var(--paper-200)) 100%);
  background-size: 200% 100%; animation: shimmer 1.4s ease-in-out infinite; }
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: .5rem; padding: 2.5rem 1.5rem; }
.empty-mark { width: 4.5rem; height: 4.5rem; color: rgb(var(--gold-500)); }

/* ---- Domain: Quran progress -------------------------------------------- */
.meter { height: .5rem; border-radius: 999px; background: rgb(var(--paper-200)); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: inherit; background: rgb(var(--gold-500)); }
.meter-navy > span { background: rgb(var(--navy-600)); }
/* 30 Juz' strip: done = gold, current = navy w/ ring, upcoming = paper */
.juz { display: grid; grid-template-columns: repeat(15, 1fr); gap: 4px; }
.juz > li { list-style: none; aspect-ratio: 1; border-radius: 4px; background: rgb(var(--paper-200)); display: grid; place-items: center;
  font-size: .625rem; font-weight: 600; color: rgb(var(--ink-500)); font-variant-numeric: tabular-nums; }
.juz > li.done { background: rgb(var(--gold-500)); color: #fff; }
.juz > li.part { background: linear-gradient(to right, rgb(var(--gold-500)) 55%, rgb(var(--paper-200)) 55%); color: rgb(var(--navy-900)); }
[dir="rtl"] .juz > li.part { background: linear-gradient(to left, rgb(var(--gold-500)) 55%, rgb(var(--paper-200)) 55%); }
.juz > li.now { background: rgb(var(--navy-700)); color: #fff; box-shadow: 0 0 0 2px #fff, 0 0 0 4px rgb(var(--navy-700)); }
@media (max-width: 479px) { .juz { grid-template-columns: repeat(10, 1fr); } }
/* Surah number in an ayah-end style roundel */
.ayah-no { position: relative; display: inline-grid; place-items: center; flex: none; width: 2.25rem; height: 2.25rem;
  font-size: .8125rem; font-weight: 600; color: rgb(var(--navy-800)); font-variant-numeric: tabular-nums; }
.ayah-no > svg { position: absolute; inset: 0; width: 100%; height: 100%; fill: rgb(var(--gold-50)); stroke: rgb(var(--gold-500)); stroke-width: 1.25; }
.ayah-no > span { position: relative; }

/* ---- Shell -------------------------------------------------------------- */
.shell { display: grid; grid-template-columns: minmax(0, 1fr); min-height: 100%; }
@media (min-width: 1024px) { .shell { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); } }
.sidebar { position: fixed; z-index: 50; inset-block: 0; inset-inline-start: 0; width: min(18rem, 86vw);
  display: flex; flex-direction: column; overflow-y: auto; transform: translateX(calc(-100% * var(--dir)));
  transition: transform .22s ease; background: rgb(var(--navy-900)); color: rgb(var(--navy-100)); }
.sidebar[data-open="true"] { transform: none; box-shadow: var(--shadow-modal); }
@media (min-width: 1024px) {
  .sidebar { position: sticky; top: 0; height: 100vh; width: auto; transform: none; box-shadow: none; }
  [data-drawer-toggle] { display: none; }
}
.scrim { position: fixed; inset: 0; z-index: 45; background: rgb(var(--navy-950) / .5); }
.sidebar-light { background: #fff; color: rgb(var(--ink-800)); border-inline-end: 1px solid rgb(var(--paper-200)); }
.nav-group { padding: 1rem .75rem .25rem; }
.nav-label { padding: 0 .75rem .375rem; font-size: .6875rem; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: rgb(var(--navy-300)); }
.sidebar-light .nav-label { color: rgb(var(--ink-500)); }
.nav-item { position: relative; display: flex; align-items: center; gap: .75rem; min-height: 2.5rem; padding: .5rem .75rem;
  border-radius: var(--r-md); font-size: .9375rem; font-weight: 450; color: rgb(var(--navy-200)); text-decoration: none; transition: background-color .12s, color .12s; }
.nav-item:hover { background: rgb(255 255 255 / .07); color: #fff; }
.nav-item[aria-current="page"] { background: rgb(255 255 255 / .11); color: #fff; font-weight: 500; }
.nav-item[aria-current="page"] > .i:first-child { color: rgb(var(--gold-300)); }
.nav-item[aria-current="page"]::after { content: ""; margin-inline-start: auto; width: .5rem; height: .5rem; flex: none; background: rgb(var(--gold-400));
  clip-path: polygon(50% 0, 62% 24%, 88% 12%, 76% 38%, 100% 50%, 76% 62%, 88% 88%, 62% 76%, 50% 100%, 38% 76%, 12% 88%, 24% 62%, 0 50%, 24% 38%, 12% 12%, 38% 24%); }
.nav-item .count { margin-inline-start: auto; }
.nav-item[aria-current="page"] .count { margin-inline-start: 0; }
.sidebar-light .nav-item { color: rgb(var(--ink-700)); }
.sidebar-light .nav-item:hover { background: rgb(var(--navy-50)); color: rgb(var(--navy-800)); }
.sidebar-light .nav-item[aria-current="page"] { background: rgb(var(--navy-50)); color: rgb(var(--navy-800)); }
.sidebar-light .nav-item[aria-current="page"] > .i:first-child { color: rgb(var(--gold-600)); }
.sidebar-light .nav-item[aria-current="page"]::after { background: rgb(var(--gold-500)); }

.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 30; display: flex; align-items: center; gap: .75rem;
  height: var(--topbar-h); padding-inline: 1rem; background: rgb(var(--paper-100) / .88); backdrop-filter: blur(10px);
  border-block-end: 1px solid rgb(var(--paper-200)); }
@media (min-width: 1024px) { .topbar { padding-inline: 2rem; } }
.page { padding: 1.5rem 1rem 2rem; max-width: 80rem; margin-inline: auto; width: 100%; }
@media (min-width: 1024px) { .page { padding: 2rem 2rem 3rem; } }
.has-bottom-nav .page { padding-block-end: calc(5.5rem + env(safe-area-inset-bottom, 0px)); }
@media (min-width: 1024px) { .has-bottom-nav .page { padding-block-end: 3rem; } }
.bottom-nav { position: fixed; z-index: 40; inset-inline: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, 1fr);
  padding: .375rem .5rem calc(.375rem + env(safe-area-inset-bottom, 0px)); background: #fff; border-block-start: 1px solid rgb(var(--paper-200)); }
@media (min-width: 1024px) { .bottom-nav { display: none; } }
.bottom-nav a { position: relative; display: flex; flex-direction: column; align-items: center; gap: .125rem; padding: .375rem 0;
  font-size: .6875rem; font-weight: 500; color: rgb(var(--ink-600)); text-decoration: none; }
.bottom-nav a[aria-current="page"] { color: rgb(var(--navy-800)); }
.bottom-nav a[aria-current="page"] > .i { color: rgb(var(--navy-700)); }
.bottom-nav a[aria-current="page"]::before { content: ""; position: absolute; top: -.375rem; width: 1.5rem; height: 3px; border-radius: 0 0 3px 3px; background: rgb(var(--gold-500)); }

/* ---- Motion ------------------------------------------------------------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.7); } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* ---- Brand lockup ------------------------------------------------------- */
.logo { display: inline-flex; align-items: center; gap: .625rem; color: #fff; text-decoration: none; }
.logo-mark { width: 2rem; height: 2rem; flex: none; color: rgb(var(--gold-400)); --core: var(--navy-900); }
.logo-word { font-size: 1.125rem; font-weight: 600; letter-spacing: -.015em; line-height: 1; }
.logo-word > span { font-weight: 300; }
.logo-on-light { color: rgb(var(--navy-800)); }
.logo-on-light .logo-mark { color: rgb(var(--navy-700)); --core: var(--paper-50); }
.logo-on-light .logo-mark > use { color: inherit; }
