/* Scoped v13 addition. No changes to the accepted normal/focus reader geometry. */
.tafsir-sheet {
  position: fixed; inset: 0; width: 100%; max-width: none;
  height: 100vh; height: 100dvh; max-height: none; margin: 0; padding: 0 4px;
  border: 0; border-radius: 0; overflow: hidden; color: var(--ink);
  background: transparent; overscroll-behavior: contain;
}
.tafsir-sheet::backdrop { background: #30261970; }
.tafsir-sheet:not([open]) { display: none; }
.tafsir-sheet[open] { display: block; }
.tafsir-layout { background: var(--paper); height: 100%; min-height: 0; display: grid; grid-template-rows: minmax(0, 52fr) minmax(0, 48fr); }
.tafsir-original { min-height: 0; display: flex; flex-direction: column; padding: env(safe-area-inset-top) max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left)); overflow: hidden; }
.tafsir-topbar { flex: 0 0 auto; position: relative; z-index: 2; background: var(--paper); width: 100%; max-width: 680px; margin: 0 auto; min-height: 44px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.tafsir-topbar h2 { font-size: calc(15px * var(--ui-text-scale,1)); line-height: 1.45; font-weight: 500; margin: 0; }
.tafsir-close { flex: 0 0 auto; }
.tafsir-image-scroll { flex: 1 1 auto; min-height: 0; width: 100%; max-width: 680px; margin-inline: auto; overflow-y: auto; overflow-x: hidden; direction: ltr; overscroll-behavior: contain; touch-action: pan-y; background: var(--paper); }
.tafsir-page-surface { position: relative; overflow: hidden; isolation: isolate; background: var(--paper); }
.tafsir-original-image { display: block; position: absolute; max-width: none; user-select: none; -webkit-user-drag: none; mix-blend-mode: darken; mask-size: 100% 100%; -webkit-mask-size: 100% 100%; mask-repeat: no-repeat; -webkit-mask-repeat: no-repeat; }
.tafsir-image-status { flex: 0 0 auto; margin: 0 auto; width: 100%; max-width: 680px; font-size: calc(12px * var(--ui-text-scale,1)); line-height: 1.5; }
.tafsir-image-status:empty { display: none; }
.tafsir-image-tools { flex: 0 0 auto; width: 100%; max-width: 680px; margin: 0 auto; display: flex; gap: 8px; align-items: center; min-height: 44px; }
.tafsir-image-tools p { flex: 1; margin: 0; font-size: calc(10px * var(--ui-text-scale,1)); line-height: 1.4; }
.tafsir-image-tools button { padding: 2px 6px; font-size: calc(11px * var(--ui-text-scale,1)); flex: 0 0 auto; }
.tafsir-image-tools button[aria-pressed=true] { background: var(--soft); border-radius: 8px; }
.tafsir-card { min-height: 0; display: flex; flex-direction: column; position: relative; background: var(--paper); border: 1px solid var(--line); border-bottom: 0; border-radius: 22px 22px 0 0; box-shadow: 0 -8px 24px #30261917; padding: 0 max(16px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(16px, env(safe-area-inset-left)); }
.tafsir-dismiss-handle { flex: 0 0 44px; width: 80px; min-height: 44px; padding: 0; margin: 0 auto; display: grid; place-items: center; touch-action: none; }
.tafsir-dismiss-handle::after { content: ''; width: 34px; height: 3px; border-radius: 8px; background: var(--line); }
.tafsir-card-close { flex: 0 0 44px; width: 44px; min-width: 44px; height: 44px; min-height: 44px; padding: 0; border: 0; border-radius: 50%; display: grid; place-items: center; background: transparent; }
.tafsir-card-close span { font: 400 calc(26px * var(--ui-text-scale,1))/1 sans-serif; }
.tafsir-card-heading h3 { flex: 1; }
.tafsir-card-heading .tafsir-chooser { flex: 0 0 auto; }
.tafsir-card-heading { touch-action: none; user-select: none; flex: 0 0 auto; min-height: 44px; max-width: 680px; width: 100%; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; position: relative; }
.tafsir-card-heading h3 { margin: 0; font-size: calc(16px * var(--ui-text-scale,1)); font-weight: 500; }
.tafsir-chooser { font-size: calc(12px * var(--ui-text-scale,1)); }
.tafsir-chooser summary { cursor: pointer; padding: 12px 4px; min-height: 44px; }
.tafsir-ref-form { position: absolute; top: 100%; inset-inline: 0; z-index: 1; padding: 12px; border: 1px solid var(--line); background: var(--paper); border-radius: 12px; box-shadow: 0 8px 20px #30261926; display: grid; grid-template-columns: minmax(0, 1fr) minmax(72px, .5fr) auto; gap: 8px; align-items: end; }
.tafsir-ref-form label { display: grid; gap: 4px; }
.tafsir-ref-form select { min-width: 0; width: 100%; min-height: 44px; padding: 5px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); font: inherit; }
.tafsir-load, .tafsir-retry { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; min-height: 44px; background: var(--soft); }
.tafsir-explanation-scroll { flex: 1 1 auto; min-height: 0; width: 100%; max-width: 680px; margin: 0 auto; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; touch-action: pan-y; padding: 0 2px 18px; overflow-wrap: break-word; }
.tafsir-explanation-scroll .tafsir-text { font-family: UI, sans-serif; font-size: calc(19px * var(--ui-text-scale,1)); line-height: 2.05; white-space: pre-wrap; margin: 4px 0 14px; }
.tafsir-explanation-scroll .tafsir-footnotes { white-space: pre-wrap; font-size: calc(13px * var(--ui-text-scale,1)); line-height: 1.9; }
.tafsir-status { font-size: calc(13px * var(--ui-text-scale,1)); margin: 4px 0; }
.tafsir-status:empty, .tafsir-text:empty { display: none; }
.tafsir-attribution { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 18px; font-size: calc(11px * var(--ui-text-scale,1)); }
.tafsir-sheet button:focus-visible, .tafsir-sheet summary:focus-visible, .tafsir-sheet select:focus-visible, .tafsir-sheet [tabindex]:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }
body[data-theme=night] .tafsir-original-image { filter: grayscale(1) invert(1); mix-blend-mode: screen; }
body[data-theme=night] .tafsir-card { box-shadow: 0 -8px 24px #0005; }
.tafsir-sheet[open] .tafsir-card { animation: tafsir-card-rise 180ms ease-out; }
.tafsir-sheet[open] .tafsir-original { animation: tafsir-ayah-lift 180ms ease-out; }
@keyframes tafsir-card-rise { from { transform: translateY(44px); opacity: .4; } to { transform: translateY(0); opacity: 1; } }
@keyframes tafsir-ayah-lift { from { transform: translateY(12px); opacity: .7; } to { transform: translateY(0); opacity: 1; } }
@media (orientation: landscape) and (max-height: 560px) {
  .tafsir-layout { grid-template-rows: minmax(0, 53fr) minmax(0, 47fr); }
  .tafsir-topbar { min-height: 36px; }
  .tafsir-topbar h2 { font-size: calc(13px * var(--ui-text-scale,1)); }
  .tafsir-image-tools { min-height: 36px; }
  .tafsir-image-tools p { font-size: calc(9px * var(--ui-text-scale,1)); }
  .tafsir-card-heading { min-height: 40px; }
  .tafsir-explanation-scroll .tafsir-text { font-size: calc(17px * var(--ui-text-scale,1)); line-height: 1.9; }
}
@media (max-width: 340px) {
  .tafsir-image-tools { gap: 2px; }
  .tafsir-image-tools button { padding-inline: 3px; font-size: calc(10px * var(--ui-text-scale,1)); }
  .tafsir-ref-form { grid-template-columns: minmax(0, 1fr) 70px; }
  .tafsir-load { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) {
  .tafsir-sheet[open] .tafsir-card, .tafsir-sheet[open] .tafsir-original { animation: none; }
}

.tafsir-card-heading button,.tafsir-card-heading summary,.tafsir-card-heading select{touch-action:manipulation}

.tafsir-content-label:not([hidden]) { display: grid; gap: 6px; margin: 8px 0; font-size: calc(14px * var(--ui-text-scale,1)); line-height: 1.5; }
.tafsir-content-select { width: 100%; min-width: 0; min-height: 44px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink); padding: 8px; font: inherit; }
.tafsir-explanation-scroll .tafsir-text[lang=en] { font-family: system-ui, sans-serif; font-size: calc(18px * var(--ui-text-scale,1)); line-height: 1.8; text-align: start; }
.tafsir-footnotes[lang=en] { font-family: system-ui, sans-serif; font-size: calc(14px * var(--ui-text-scale,1)); line-height: 1.7; }
.tafsir-content-label[hidden] { display: none; }

/* Compact shortcuts; the existing verse chooser remains independent. */
.tafsir-verse-navigation{flex:0 0 auto;display:flex;justify-content:space-between;gap:8px;width:100%;max-width:680px;margin:3px auto 8px}
.tafsir-verse-step{display:flex;align-items:center;justify-content:center;gap:6px;min-width:0;min-height:44px;max-width:240px;flex:1 1 0;padding:6px 9px;border:1px solid var(--line);border-radius:10px;background:var(--soft);color:var(--ink);font:inherit;font-size:calc(13px * var(--ui-text-scale,1));line-height:1.4;touch-action:manipulation}
.tafsir-verse-step[data-tafsir-step=next]{flex-direction:row-reverse}
.tafsir-verse-step svg{flex:0 0 16px;width:16px;height:18px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.tafsir-verse-step:disabled{opacity:.4;cursor:default}
