/* ==========================================================================
   Design 9 — final cascade pass.
   Loaded last so it wins over page-level bundles that hardcode the old
   emerald identity. Everything here is either an indigo remap of a leftover
   green or a contrast fix in dark mode.
   ========================================================================== */

/* 1. Reader hero: never green, in either theme ---------------------------- */
html body .dr-hero,
html body.dark .dr-hero,
html body.ds-reader .dr-hero{
  background:radial-gradient(500px 260px at 100% 0,rgba(45,212,191,.22),transparent 70%),
             linear-gradient(155deg,#0f766e,#0f2a27 78%)!important;
  color:#e6f4f1!important;
  border:1px solid transparent!important;
}
html body.dark .dr-hero{
  background:radial-gradient(500px 260px at 100% 0,rgba(45,212,191,.18),transparent 70%),
             linear-gradient(155deg,#0f4a42,#07130f 78%)!important;
  border-color:rgba(255,255,255,.09)!important;
}
html body .dr-hero p,html body .dr-hero .dr-hero-en,html body .dr-hero small{color:#c4e4dc!important}

/* 2. Search results: cards, not green panels ------------------------------ */
html body .search-result{
  background:var(--d9-card)!important;
  border:1px solid var(--d9-line)!important;
  border-radius:16px!important;
}
html body .search-meta,html body .search-meta b,html body .search-count,
html body .result-tools a{color:var(--d9-accent-2)!important}
html body .voice-search-btn{color:var(--d9-accent-2)!important}
html body.dark .voice-search-btn{color:#5eead4!important}

/* 3. Green pills and icons that survived the remap ------------------------ */
html body .radio-play{background:#0f766e!important;color:#fff!important;border:0!important}
html body.dark .radio-play{background:#2dd4bf!important;color:#07130f!important}
html body .reciter-avatar{background:#e6f4f1!important;color:#0f766e!important;border-color:#a7d8cf!important}
html body.dark .reciter-avatar{background:#12302b!important;color:#5eead4!important;border-color:#24504a!important}
html body .reciter-card .rc-play,html body .reciter-card a.play,html body .reciter-play{
  background:#0f766e!important;color:#fff!important;border:0!important
}
html body.dark .reciter-card .rc-play,html body.dark .reciter-card a.play,html body.dark .reciter-play{
  background:#2dd4bf!important;color:#07130f!important
}
html body .continue-icon{background:#e6f4f1!important;color:#0f766e!important}
html body.dark .continue-icon{background:#12302b!important;color:#5eead4!important}
html body .om-btn{background:#0f766e!important;color:#fff!important;border:0!important}
html body.dark .om-btn{background:#2dd4bf!important;color:#07130f!important}
html body .ds-lang-menu button.is-active{color:#0f766e!important}
html body.dark .ds-lang-menu button.is-active{color:#5eead4!important}
html body .dash19 strong,html body .progress-page strong,html body .stats-row strong{color:var(--d9-accent-2)!important}
html body.dark .dash19 strong,html body.dark .progress-page strong,html body.dark .stats-row strong{color:#5eead4!important}

/* 4. Theme switch: indigo knob, not amber --------------------------------- */
html body .d9-theme:after{background:#0f766e!important}
html body.dark .d9-theme:after{background:#2dd4bf!important}
html body .d9-theme[aria-pressed="true"]:after{background:#0f766e!important}

/* 5. Tafseer / inner-page small pills ------------------------------------ */
html body .tafseer-hero .tf-chip,html body .pill--gold,html body .btn-gold{
  background:#e6f4f1!important;color:#115e59!important;border:1px solid #a7d8cf!important
}
html body.dark .tafseer-hero .tf-chip,html body.dark .pill--gold,html body.dark .btn-gold{
  background:#12302b!important;color:#a7d8cf!important;border-color:#24504a!important
}

/* 6. Dark page canvas: the old premium theme painted it green ------------- */
html body.dark{background:#07130f!important;color:#e4f5f1!important}
html body.dark .wrap,html body.dark main,html body.dark main.wrap,
html body.dark .tafseer-shell,html body.dark .premium-shell{background:transparent!important}
html body .search-form.advanced-search{background:var(--d9-card)!important;border:1px solid var(--d9-line)!important;border-radius:20px!important}
html body .qpk-btn{background:#e6f4f1!important;color:#115e59!important;border-color:#a7d8cf!important}
html body.dark .qpk-btn{background:#12302b!important;color:#a7d8cf!important;border-color:#24504a!important}
html body .dr-toolbar{background:var(--d9-card)!important;border:1px solid var(--d9-line)!important}

/* 7. Dark tokens: ds.css still ships the old emerald dark palette and loads
   after d9.css on some pages. Re-assert the design-9 dark palette last. */
html body.dark{
  --d9-bg:#07130f; --d9-card:#0e1f1b; --d9-ink:#e4f5f1; --d9-ink-2:#a7d8cf;
  --d9-muted:#8fb0a8; --d9-line:#1d3a34; --d9-line-2:#132a26;
  --d9-soft:#12302b; --d9-accent:#2dd4bf; --d9-accent-2:#5eead4; --d9-accent-ink:#07130f;
  --d9-hero-a:#0f4a42; --d9-hero-b:#115e59;
  --ds-bg:#07130f; --ds-bg-soft:#0b1815; --ds-surface:#0e1f1b; --ds-surface-2:#0b1815;
  --ds-ink:#e4f5f1; --ds-ink-2:#a7d8cf; --ds-muted:#8fb0a8;
  --ds-line:#1d3a34; --ds-line-strong:#2b4f48; --ds-card:#0e1f1b;
  --ds-primary:#2dd4bf; --ds-primary-hover:#5eead4; --ds-on-primary:#07130f;
  --ds-primary-soft:#12302b; --ds-primary-ink:#a7d8cf;
  --ds-accent:#5eead4; --ds-accent-ink:#a7d8cf; --ds-accent-soft:#12302b;
  --ds-focus:#5eead4; --ds-header-bg:rgba(7,19,15,.9); --ds-quran-ink:#e6f4f1;
  --ds-hero-a:#0f201c; --ds-hero-b:#07130f;
}

/* 8. Dark: legacy bundles hardcode green surfaces; force design-9 surfaces */
html body.dark .d9-hdr{background:rgba(7,19,15,.94)!important;border-color:#1d3a34!important}
html body.dark .d9-search{background:#0e1f1b!important;border:1px solid #1d3a34!important}
html body.dark .tafseer-ayah,html body.dark .tafseer-card,html body.dark .tafseer-body,
html body.dark .tafseer-hero form,html body.dark .tafseer-hero select,html body.dark .tafseer-hero a{
  background-color:#0e1f1b!important;color:#e4f5f1!important;border-color:#1d3a34!important}
html body.dark .tafseer-hero select{background-color:#0b1815!important}
html body.dark .tafseer-ayah{border-right-color:#2dd4bf!important}
html body.dark .tafseer-hero .tafseer-ayah{background-color:#0e1f1b!important}
html body.dark .premium-page,html body.dark .premium-page main{background:#07130f!important}
html body.dark :is(.search-form,.khatma-card,.card,.panel,.dash2-card){border-color:#1d3a34}

/* 9. Reciter card actions */
html body .reciter-card-actions button,html body .reciter-card-actions .listen{background:#0f766e!important;color:#fff!important;border:0!important}
html body.dark .reciter-card-actions button{background:#2dd4bf!important;color:#07130f!important}
html body .reciter-card-actions a{color:#0f766e!important}
html body.dark .reciter-card-actions a{color:#5eead4!important}

/* 10. Dark: dashboard/plan/stat cards from the premium bundles ------------- */
html body.dark :is(.dash2-card,.dash2-stat,.dash2-stats>*,.q30-plan-card,.dash19-activity,
  .progress-card,.stat-card,.stats-row>*,.premium-card,.q30-card){
  background:#0e1f1b!important;border-color:#1d3a34!important;color:#e4f5f1!important
}
html body.dark .q30-plan{background:rgba(45,212,191,.08)!important;border-color:#1d3a34!important}
html body.dark select,html body.dark textarea,
html body.dark input:not([type=range]):not([type=checkbox]):not([type=radio]){
  background:#0b1815!important;color:#e4f5f1!important;border-color:#1d3a34!important
}
html body.dark option{background:#0b1815!important;color:#e4f5f1!important}
html body.dark :is(.dash2-card,.dash2-stats>*,.q30-plan-card,.dash19-activity,.progress-card) :is(strong,b,.num,.value){color:#5eead4!important}
html body.dark .dash2-stats>* span,html body.dark .dash2-stats>* small{color:#8fb0a8!important}

/* 11. Reciter toolbar search: the "/" key hint is meaningless on touch ---- */
@media(max-width:640px){
  html body .toolbar-search{width:100%!important;display:flex!important;align-items:center!important;gap:8px!important}
  html body .toolbar-search kbd{display:none!important}
  html body .toolbar-search input{flex:1 1 auto!important;min-width:0!important;width:auto!important}
  html body .reciter-toolbar{flex-wrap:wrap!important;gap:10px!important}
}

/* 12. Header search: one pill, the input never draws its own box ---------- */
html body .d9-search input,html body .d9-search input[type=search]{
  background:transparent!important;border:0!important;box-shadow:none!important;
  padding:0 4px!important;height:auto!important;border-radius:0!important;appearance:none
}
html body .toolbar-search{background:var(--d9-card)!important;border:1px solid var(--d9-line)!important;border-radius:999px!important;padding:0 14px!important}
html body .toolbar-search input{background:transparent!important;border:0!important;box-shadow:none!important}
html body #reciterSearch{background:transparent!important;border:0!important;border-radius:0!important;box-shadow:none!important;padding:0!important}
html body .toolbar-search{overflow:hidden}

/* 13. Dark reciter cards + mobile reader toolbar ------------------------- */
html body.dark :is(.premium-reciter-card,.reciter-card,.reciter-toolbar .toolbar-search){
  background:#0e1f1b!important;border-color:#1d3a34!important;color:#e4f5f1!important
}
html body.dark .premium-reciter-card :is(h2,strong){color:#e4f5f1!important}
html body.dark .premium-reciter-card :is(p,small){color:#8fb0a8!important}
@media(max-width:640px){
  html body .dr-toolbar{
    display:flex!important;flex-wrap:wrap!important;gap:8px!important;
    padding:10px!important;border-radius:16px!important;overflow:visible!important
  }
  html body .dr-toolbar .dr-tool{
    flex:0 0 auto!important;min-height:40px!important;padding:8px 12px!important;
    font-size:.82rem!important;white-space:nowrap!important;border-radius:12px!important
  }
  html body .dr-toolbar .dr-tool--play{flex:1 1 100%!important;justify-content:center!important}
}
html body .dr-toolbar .dr-tool--play{background:#0f766e!important;color:#fff!important;border:1px solid transparent!important;font-weight:700!important}
html body .dr-toolbar .dr-tool--play svg{color:#fff!important;fill:currentColor}
html body.dark .dr-toolbar .dr-tool--play{background:#2dd4bf!important;color:#07130f!important}
html body.dark .dr-toolbar .dr-tool--play svg{color:#07130f!important}

/* 14. Header search input must never paint its own box (id beats page CSS) */
html body form.d9-search input[name="q"],html body .d9-search input[name="q"]{
  background:transparent!important;background-color:transparent!important;
  border:0!important;box-shadow:none!important;outline:none!important;
  border-radius:0!important;padding:0 4px!important;height:auto!important;appearance:none!important
}
html body form.d9-search{border:1px solid var(--d9-line)!important;background:var(--d9-soft)!important;border-radius:999px!important}
html body.dark form.d9-search{border-color:#1d3a34!important;background:#12302b!important}
html body #d9SearchInput{background:transparent!important;background-color:transparent!important;border:0!important;box-shadow:none!important;border-radius:0!important;padding:0 4px!important;height:auto!important}

/* ===== v12: theme button, footer, audio player ===== */
html body .d9-theme{width:40px!important;height:40px!important;min-width:40px;padding:0!important;border-radius:50%!important;display:inline-flex!important;align-items:center;justify-content:center;background:#e6f4f1!important;color:#0f766e!important;border:1px solid #a7d8cf!important;flex:none;line-height:0;cursor:pointer;transition:background .2s,color .2s}
html body .d9-theme:after{display:none!important;content:none!important}
html body .d9-theme svg{width:19px!important;height:19px!important;margin:0!important;display:block}
html body .d9-theme .i-sun{display:none!important}
html body.dark .d9-theme .i-sun{display:block!important}
html body.dark .d9-theme .i-moon{display:none!important}
html body .d9-theme:hover{background:#0f766e!important;color:#fff!important}
html body.dark .d9-theme{background:#12302b!important;color:#fcd34d!important;border-color:#24504a!important}
html body.dark .d9-theme:hover{background:#24504a!important}

html body .ds-footer{background:#063b36!important;color:#cfeae4!important;margin-top:40px;border-top:3px solid #0f766e}
html body .ds-footer::before{display:none!important}
html body .ds-footer h3,html body .ds-footer-col h3{color:#fff!important;font-size:15px!important;font-weight:800;margin:0 0 12px!important;padding-bottom:10px;border-bottom:2px solid #0f766e;display:inline-block}
html body .ds-footer a,html body .ds-footer-col a{color:#cfeae4!important}
html body .ds-footer-col a{display:block;padding:5px 0!important;font-size:14.5px!important;opacity:1}
html body .ds-footer a:hover{color:#fff!important;text-decoration:underline}
html body .ds-footer p,html body .ds-footer-brand small{color:#b6d8d1!important}
html body .ds-footer-stats span{color:#b6d8d1!important}
html body .ds-footer-stats b{color:#fff!important}
html body .ds-footer-bottom{border-top:1px solid rgba(255,255,255,.14)!important;color:#b6d8d1!important;padding:16px 0!important}
html body .ds-footer-bottom div,html body .ds-footer-bottom span{color:#b6d8d1!important}
html body .ds-footer-bottom a{color:#fff!important}
html body.dark .ds-footer{background:#050e0c!important;border-top-color:#2dd4bf}
@media(max-width:719px){
 html body .ds-footer-inner{grid-template-columns:1fr 1fr!important;gap:22px 16px!important;padding:32px 0 20px!important}
 html body .ds-footer-inner>.ds-footer-col:first-child{grid-column:1/-1}
 html body .ds-footer-inner>.ds-footer-col:last-child{grid-column:1/-1}
 html body .ds-footer-bottom div{flex-direction:column;align-items:flex-start;gap:8px}
}

html body .dr-player{background:#fff!important;border-top:1px solid #a7d8cf!important;box-shadow:0 -8px 28px rgba(15,118,110,.16)!important;color:#0f2a27!important}
html body .dr-player *{color:inherit}
html body .dr-player .player-symbol{background:#e6f4f1!important;color:#0f766e!important}
html body .dr-player .player-live{background:#e6f4f1!important;color:#0f766e!important}
html body .dr-player button{background:#e6f4f1!important;color:#0f766e!important;border:1px solid #a7d8cf!important}
html body .dr-player button:hover{background:#cfeae4!important}
html body .dr-player .player-play{background:#0f766e!important;color:#fff!important;border-color:transparent!important}
html body .dr-player .player-play:hover{background:#115e59!important}
html body .dr-player-progress{color:#56706b!important}
html body .dr-player input[type=range]{accent-color:#0f766e!important}
html body .dr-player select{background:#e6f4f1!important;color:#0f2a27!important;border:1px solid #a7d8cf!important}
html body.dark .dr-player{background:#0c1a17!important;border-top-color:#24504a!important;color:#e4f5f1!important;box-shadow:0 -8px 28px rgba(0,0,0,.5)!important}
html body.dark .dr-player .player-symbol,html body.dark .dr-player .player-live,html body.dark .dr-player button,html body.dark .dr-player select{background:#12302b!important;color:#a7d8cf!important;border-color:#24504a!important}
html body.dark .dr-player .player-play{background:#2dd4bf!important;color:#07130f!important}
html body.dark .dr-player-progress{color:#5eead4!important}
html body.dark .dr-player input[type=range]{accent-color:#2dd4bf!important}

/* ===== v13: mobile top bar ===== */
@media (max-width:760px){
 html body .d9-hdr{display:grid!important;grid-template-columns:1fr auto;grid-template-areas:"brand acts" "search search";align-items:center;gap:10px 8px!important;padding:10px 14px 12px!important;background:#fff;border-bottom:0}
 html body.dark .d9-hdr{background:#0c1a17}
 html body .d9-brand{grid-area:brand;min-width:0;gap:10px}
 html body .d9-brand-mark{width:42px!important;height:42px!important;border-radius:12px}
 html body .d9-brand-tag{display:block!important;font-size:11.5px!important;line-height:1.3;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:46vw}
 html body .d9-brand-word{height:auto;width:104px!important}
 html body .d9-actions{grid-area:acts;display:flex!important;align-items:center;gap:6px!important;margin:0!important}
 html body .d9-actions .d9-icon,html body .d9-actions .d9-theme{width:40px!important;height:40px!important;min-width:40px;padding:0!important;border-radius:50%!important;display:inline-flex!important;align-items:center;justify-content:center;background:#e6f4f1!important;color:#0f766e!important;border:1px solid #cfeae4!important;font-size:0}
 html body .d9-actions .d9-icon svg{width:19px!important;height:19px!important}
 html body .d9-actions #langToggle{flex-direction:column;gap:0;font-size:9px!important;font-weight:800;line-height:1}
 html body .d9-actions #langToggle svg{width:16px!important;height:16px!important}
 html body .d9-actions #menuToggle{background:#0f766e!important;color:#fff!important;border-color:#0f766e!important}
 html body.dark .d9-actions .d9-icon{background:#12302b!important;color:#a7d8cf!important;border-color:#24504a!important}
 html body.dark .d9-actions #menuToggle{background:#2dd4bf!important;color:#07130f!important}
 html body .d9-search{grid-area:search;height:44px!important;border-radius:14px!important;margin:0}
 html body .d9-chips{padding:10px 14px!important;gap:8px!important;border-top:1px solid #e3efec;scroll-padding-inline:14px}
 html body .d9-chip{padding:7px 15px!important;font-size:13px!important;font-weight:700;flex:none}
 html body .ds-drawer{border-radius:0;box-shadow:0 0 40px rgba(15,23,80,.28)}
 html body .ds-drawer-top{padding:14px 16px!important;background:#f1f9f7}
 html body.dark .ds-drawer-top{background:#060f0d}
 html body .ds-drawer-group{padding:12px 12px 4px!important}
 html body .ds-drawer-group h2{font-size:12px!important;font-weight:800;color:#5f7d77!important;margin:0 10px 6px!important}
 html body .ds-drawer-group a{padding:11px 12px!important;border-radius:12px!important;font-size:15px;font-weight:600}
 html body .ds-drawer-group a .ds-i{width:20px;height:20px;color:#0f766e!important}
 html body .ds-drawer-group a.is-active{background:#e6f4f1!important;color:#115e59!important}
}
@media (max-width:760px){
 html body .d9-actions a.d9-icon[href="/search"]{display:none!important}
 html body .d9-actions .d9-install[hidden]{display:none!important}
 html body.dark .d9-actions .d9-theme{background:#12302b!important;color:#fcd34d!important;border-color:#24504a!important}
}

/* v14: hero action rows spacing, dark search field */
.reciter-hero-actions{margin-top:18px!important;display:flex!important;flex-wrap:wrap;align-items:center;gap:12px 14px}
.reciter-hero-actions>*{margin:0!important}
html body.dark .ds-field,html body[class*="dark"] .ds-field,html[data-theme="dark"] .ds-field{background:#0b1815!important;border:1px solid #1d3a34!important;box-shadow:none!important}
html body.dark .ds-field input,html body[class*="dark"] .ds-field input{background:transparent!important;color:#e4f5f1!important}
