/* Complete replacement, scoped to companion controls and panels. */
[data-iha-superseded],[data-iha-superseded][open]{display:none!important}
.r276-actions{display:flex;flex-wrap:wrap;gap:8px;margin-block:12px;max-width:100%}
.r276-action{font:inherit;font-size:14px;font-weight:600;line-height:1.4;min-height:44px;min-width:0;flex:1 1 100px;padding:9px 12px;border:1px solid #9db8aa;border-radius:8px;background:#fff;color:#135b3b;cursor:pointer;white-space:normal}
.r276-action:hover,.r276-action[aria-expanded=true]{background:#e4f1e8;border-color:#20744b;color:#075c35}
.r276-action:focus-visible{outline:3px solid #075c35;outline-offset:3px}
.r276-action[aria-busy=true]{cursor:progress}
.r276-reader-panel{box-sizing:border-box;grid-column:1/-1;max-width:100%;min-width:0;max-height:65vh;overflow:auto;overscroll-behavior:contain;margin-block:14px;padding:clamp(14px,3vw,28px);border:1px solid #cbdccf;border-radius:10px;background:#fbfdfb;color:#173f2f;overflow-wrap:anywhere;text-align:start}
.r276-reader-panel[hidden]{display:none!important}
.r276-reader-panel .r276-source+ .r276-source{border-top:1px solid #cbdccf;margin-top:24px;padding-top:20px}
.r276-reader-panel h3{font:600 17px/1.6 system-ui}
.r276-reader-panel .r276-arabic,.qh-page .r276-reader-panel .qh-arabic,.qh-facsimile .r276-reader-panel .qh-arabic{font-size:clamp(22px,2vw,28px)!important;line-height:2!important;direction:rtl;text-align:start;white-space:pre-line}
.r276-reader-panel .r276-citation,.r276-reader-panel .r276-empty{font-size:15px;line-height:1.7}
.r276-reader-panel a{color:#146447;text-decoration:underline}
.r276-reader-panel details{max-width:100%}
.r276-reader-panel summary{cursor:pointer;min-height:44px;padding-block:10px;line-height:1.6}
.r276-reader-panel .iha-r275-inner{font-size:16px;line-height:1.85;text-align:start}
.r276-reader-panel .iha-r275-edition{display:flex;gap:10px;align-items:center;flex-wrap:wrap}
.r276-reader-panel select{max-width:100%;min-height:44px;font:inherit}
.r276-reader-panel [hidden]{display:none!important}
@media(max-width:400px){.r276-actions{gap:6px}.r276-action{flex-basis:85px;font-size:13px;padding:8px 5px}}

/* The page stage is the only fullscreen surface. */
.qh-facsimile-stage.iha-mushaf-only-fullscreen:is(:fullscreen,.is-reading-fullscreen){
 position:fixed!important;inset:0!important;z-index:2147483000!important;display:flex!important;
 align-items:center!important;justify-content:center!important;box-sizing:border-box!important;
 width:100%!important;height:100vh!important;height:100dvh!important;min-height:0!important;max-height:none!important;
 max-width:none!important;margin:0!important;border:0!important;border-radius:0!important;
 padding:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left)!important;
 background:#eee9df!important;overflow:auto!important;overscroll-behavior:contain;scrollbar-gutter:auto!important;
}
.qh-facsimile-stage.iha-mushaf-only-fullscreen:is(:fullscreen,.is-reading-fullscreen)>:not(.qh-facsimile-image):not(.iha-mushaf-fs-exit){display:none!important}
.qh-facsimile-stage.iha-mushaf-only-fullscreen:is(:fullscreen,.is-reading-fullscreen)>.qh-facsimile-image{
 position:relative!important;flex:0 0 auto!important;box-sizing:border-box!important;
 width:min(100%,calc((100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom)) * 1120 / 1776))!important;
 max-width:100%!important;max-height:none!important;margin:auto!important;transform:none!important;
}
.qh-facsimile-stage.iha-mushaf-only-fullscreen:is(:fullscreen,.is-reading-fullscreen) .qh-page-image{
 display:block!important;width:91.4285714286%!important;height:auto!important;max-width:91.4285714286%!important;max-height:none!important;object-fit:contain!important;
}
.qh-facsimile-stage.iha-mushaf-only-fullscreen .qh-ayah-regions{display:none!important}
.qh-facsimile-stage.iha-mushaf-only-fullscreen .iha-mushaf-fs-exit{
 position:fixed!important;top:max(8px,env(safe-area-inset-top))!important;right:max(8px,env(safe-area-inset-right))!important;
 z-index:2147483001!important;display:flex!important;align-items:center;justify-content:center;
 min-width:44px!important;min-height:44px!important;width:auto!important;max-width:90px!important;
 padding:8px 12px!important;border:1px solid #a6b7ab!important;border-radius:8px!important;
 font:600 12px/1.4 system-ui!important;background:#fffffff2!important;color:#174b35!important;
}
.iha-mushaf-fs-exit:focus-visible{outline:3px solid #075c35;outline-offset:2px}
@media(prefers-reduced-motion:reduce){.iha-mushaf-only-fullscreen *{scroll-behavior:auto!important}}

/* R318: companion results stay adjacent to their action and follow document scroll. */
.r276-reader-panel{max-height:none;overflow:visible;overscroll-behavior:auto;margin-block:8px 12px;padding:clamp(12px,2vw,20px)}
.r276-actions + .r276-reader-panel{width:100%;align-self:stretch}
@media(max-width:600px){.r276-reader-panel{padding:12px;border-radius:10px}.r276-actions{margin-block:8px}.r276-reader-panel .r276-source+.r276-source{margin-top:12px;padding-top:12px}}

/* R365 | Compact source selection table with full interpretation on demand. */
.qh-page .r276-reader-panel .r365-table-heading{margin:0 0 10px;font:650 14px/1.6 system-ui,sans-serif;color:#28543a}
.qh-page .r276-reader-panel .r365-table-wrap{width:100%;max-width:100%;overflow-x:auto;border:1px solid #dae5db;border-radius:10px;background:#fff}
.qh-page .r276-reader-panel .r365-source-table{width:100%;border-collapse:collapse;table-layout:fixed;min-width:0}
.qh-page .r276-reader-panel .r365-source-table th{padding:10px 12px;background:#f2f6f0;color:#425b4c;font:600 12px/1.5 system-ui;text-align:start;border-bottom:1px solid #dde6da}
.qh-page .r276-reader-panel .r365-source-table th:nth-child(1){width:27%}
.qh-page .r276-reader-panel .r365-source-table th:nth-child(2){width:59%}
.qh-page .r276-reader-panel .r365-source-table th:nth-child(3){width:14%;text-align:center}
.qh-page .r276-reader-panel .r365-source-table td{padding:12px;vertical-align:middle;border-bottom:1px solid #e1e9e1;overflow-wrap:anywhere}
.qh-page .r276-reader-panel .r365-source-table tr:last-child td{border-bottom:0}
.qh-page .r276-reader-panel .r365-source-name strong{display:block;font:600 13px/1.6 system-ui;color:#1c5637}
.qh-page .r276-reader-panel .r365-source-name small{display:block;color:#647469;font:12px/1.5 system-ui;margin-top:3px}
.qh-page .r276-reader-panel .r365-source-excerpt bdi{display:block;direction:rtl;unicode-bidi:isolate;text-align:right;font:clamp(17px,1.5vw,21px)/1.9 'IHA LPMQ',serif;color:#1a3d30}
.qh-page .r276-reader-panel .r365-pending-excerpt{font:12px/1.65 system-ui;color:#6d7e71}
.qh-page .r276-reader-panel .r365-source-action{text-align:center}
.qh-page .r276-reader-panel .r365-source-open,
.qh-page .r276-reader-panel .r365-reader-back{display:inline-flex;justify-content:center;align-items:center;min-height:44px;padding:8px 13px;max-width:100%;border:1px solid #9dbca7;border-radius:8px;background:#fbfdf9;color:#16593b;font:600 13px/1.5 system-ui;cursor:pointer}
.qh-page .r276-reader-panel :is(.r365-source-open,.r365-reader-back):hover{background:#eaf3e9}
.qh-page .r276-reader-panel :is(.r365-source-open,.r365-reader-back):focus-visible{outline:3px solid #b39042;outline-offset:2px}
.qh-page .r276-reader-panel .r365-reader-back{margin:0 0 14px}
.qh-page .r276-reader-panel .r365-full-reader{min-width:0;max-width:100%}
.qh-page .r276-reader-panel .r365-source-full>h3{font:600 15px/1.6 system-ui;margin:0 0 8px}
/* The primary verse/matn remains more prominent than any commentary. */
body.qh-page .r276-reader-panel .r365-interpretation,
body.qh-page .r276-reader-panel .r365-interpretation :is(.qh-prose,.qh-arabic,.qh-prose-paragraph),
body.qh-page .r276-reader-panel .r365-full-reader .qh-hadith-record-body :is(.qh-prose,.qh-arabic,.qh-prose-paragraph){
 font-size:clamp(16px,calc(var(--search-arabic-size,28px)*.82),25px)!important;
 line-height:2.05!important;letter-spacing:normal!important;
}
body.qh-page .qh-reading-dialog .qh-reader-explanation :is(.qh-prose,.qh-arabic,.qh-prose-paragraph),
body.qh-page .qh-reading-dialog .qh-reader-explanation [data-source-region] {
 font-size:clamp(16px,calc(var(--search-arabic-size,28px)*.82),25px)!important;
 line-height:2.05!important;
}
@media(max-width:640px){
 .qh-page .r276-reader-panel .r365-table-wrap{overflow:visible;border:0;background:transparent}
 .qh-page .r276-reader-panel .r365-source-table,.qh-page .r276-reader-panel .r365-source-table tbody,.qh-page .r276-reader-panel .r365-source-table tr,.qh-page .r276-reader-panel .r365-source-table td{display:block;width:100%;box-sizing:border-box}
 .qh-page .r276-reader-panel .r365-source-table thead{display:none}
 .qh-page .r276-reader-panel .r365-source-table tr{margin-bottom:10px;border:1px solid #dbe6dc;border-radius:9px;background:#fff;overflow:hidden}
 .qh-page .r276-reader-panel .r365-source-table td{padding:8px 12px;border:0}
 .qh-page .r276-reader-panel .r365-source-table .r365-source-name{padding-top:12px}
 .qh-page .r276-reader-panel .r365-source-table .r365-source-action{padding-bottom:12px;text-align:start}
 .qh-page .r276-reader-panel .r365-source-excerpt bdi{font-size:19px}
}


/* R366 — one scholarly reading surface across Quran, Hadith and Murajaah.
 * Widen the reading dialog on laptop without changing the underlying data or
 * the mushaf page-turn engine. Avoid a three-column commentary table in a
 * narrow sidebar; its content must have sufficient writing width. */
@media (min-width: 651px) {
  body.qh-page .qh-reading-dialog:not(.qh-reader-mushaf) {
    width:min(1080px, calc(100vw - 56px));
    height:min(94dvh, 980px);
  }
  body.qh-page .qh-reading-dialog.qh-reader-mushaf {
    width:min(1290px, calc(100vw - 42px));
    height:min(95dvh, 1000px);
  }
  body.qh-page .qh-reading-dialog .qh-reader-scroll {
    padding:clamp(14px,2vw,26px);
    scrollbar-gutter:stable;
  }
}
/* The primary Arabic text is comfortable, but not excessively stretched.
 * Separate commentary sizes stay smaller than the source matn or ayah. */
body.qh-page .qh-reading-dialog:not(.qh-reader-mushaf) .qh-reader-primary,
body.qh-page .qh-reading-dialog:not(.qh-reader-mushaf) .qh-hadith-view {
  width:100%; max-width:950px; margin-inline:auto;
}
body.qh-page .qh-reading-dialog .qh-reader-primary .qh-prose {
  max-width:950px;
}
/* In the dialog, both the image and the actions live on a full-width reading
 * canvas. It is particularly important when Tafsir's three-column source
 * table is displayed: a 250px sidebar cannot legibly hold Arabic excerpts. */
body.qh-page .qh-reading-dialog.qh-reader-mushaf .qh-reader-grid {
  display:grid!important;
  grid-template-columns:minmax(0,1fr)!important;
  gap:clamp(10px,1.4vw,18px)!important;
  width:100%; min-width:0;
}
body.qh-page .qh-reading-dialog.qh-reader-mushaf .qh-reader-grid>.qh-facsimile-stage {
  grid-column:1!important; grid-row:1!important;
  width:100%; min-width:0; max-width:100%;
  order:0;
}
body.qh-page .qh-reading-dialog.qh-reader-mushaf .qh-reader-grid>.qh-reader-action-pane {
  grid-column:1!important; grid-row:2!important;
  position:static!important; top:auto!important;
  width:100%!important; max-width:100%; min-width:0;
  order:1;
  padding:clamp(12px,1.5vw,20px)!important;
}
body.qh-page .qh-reading-dialog.qh-reader-mushaf .qh-facsimile,
body.qh-page .qh-reading-dialog.qh-reader-mushaf .qh-leaves {
  max-width:100%;
}
/* Scientific source tables must remain compact, with a legible title and a
 * real action column. Never break labels into vertical letter stacks. */
body.qh-page .qh-reading-dialog .r276-reader-panel .r365-source-table {
  width:100%; table-layout:fixed;
}
body.qh-page .qh-reading-dialog .r276-reader-panel .r365-source-table :is(th,td) {
  overflow-wrap:normal; word-break:normal;
}
body.qh-page .qh-reading-dialog .r276-reader-panel .r365-source-table th:nth-child(1) {width:28%;}
body.qh-page .qh-reading-dialog .r276-reader-panel .r365-source-table th:nth-child(2) {width:auto;}
body.qh-page .qh-reading-dialog .r276-reader-panel .r365-source-table th:nth-child(3) {
  width:94px; white-space:nowrap;
}
body.qh-page .qh-reading-dialog .r276-reader-panel .r365-source-table .r365-source-name strong {
  overflow-wrap:break-word;
}
body.qh-page .qh-reading-dialog .r276-reader-panel .r365-source-table .r365-source-excerpt bdi {
  overflow-wrap:anywhere;
}
/* On phones use the existing stacked source rows, but keep one uninterrupted
 * scroll surface and no horizontal overflow. */
@media (max-width: 650px) {
  body.qh-page .qh-reading-dialog,
  body.qh-page .qh-reading-dialog.qh-reader-mushaf {
    width:100vw; max-width:100vw; height:100dvh;
    border-radius:0;
  }
  body.qh-page .qh-reading-dialog .qh-reader-scroll {padding:12px 10px;}
  body.qh-page .qh-reading-dialog.qh-reader-mushaf .qh-reader-grid {
    display:flex!important;flex-direction:column!important;
  }
  body.qh-page .qh-reading-dialog .r276-reader-panel .r365-source-table th:nth-child(3) {
    width:auto;
  }
}
@media (min-width:651px) and (max-width:900px) {
  body.qh-page .qh-reading-dialog .r276-reader-panel .r365-source-table th:nth-child(1) {width:31%;}
  body.qh-page .qh-reading-dialog .r276-reader-panel .r365-source-table th:nth-child(3) {width:88px;}
  body.qh-page .qh-reading-dialog .r276-reader-panel .r365-source-table td {padding:9px;}
}
/* The search result's single source page must never balloon to the full
 * width of a double-page reader. A true two-page spread keeps its own width. */
body.qh-page .qh-reading-dialog.qh-reader-mushaf .qh-reader-grid>.qh-facsimile-stage:not(:has(.qh-leaves)) {
 max-width:min(100%,560px);margin-inline:auto;
}
body.qh-page .qh-reading-dialog.qh-reader-mushaf .qh-reader-grid>.qh-facsimile-stage:has(.qh-leaves) {
 max-width:min(100%,1090px);margin-inline:auto;
}
