/* Discreet page-linked PDF question pill & native modal dialog (Frente 2) */

.readerPageQuestionPill {
  position: fixed;
  right: var(--rpq-right, 20px);
  bottom: var(--rpq-bottom, 22px);
  z-index: 520;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  max-width: min(calc(100vw - 24px), 420px);
  padding: 4px;
  border-radius: 999px;
  background: rgba(15, 23, 34, 0.92);
  border: 1px solid color-mix(in srgb, var(--accent, #3b82f6) 52%, rgba(148, 163, 184, 0.35));
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: transform 0.16s ease, opacity 0.16s ease;
}

.readerMode:has(.paper.pdfPaper):not(.cleanFullscreen) ~ .readerPageQuestionPill,
body.rpqInPdfOriginal .readerPageQuestionPill {
  bottom: var(--rpq-bottom, 68px);
  right: var(--rpq-right, 18px);
}

.readerPageQuestionPill.hidden {
  display: none !important;
}

body.theme-minimal .readerPageQuestionPill .readerPageQuestionOpenBtn,
.readerPageQuestionOpenBtn {
  display: inline-flex !important;
  align-items: center !important;
  gap: 8px !important;
  padding: 7px 12px !important;
  border-radius: 999px !important;
  border: 0 !important;
  background: transparent !important;
  color: #f1f5f9 !important;
  font-family: Inter, system-ui, sans-serif !important;
  font-size: 12.5px !important;
  font-weight: 600 !important;
  line-height: 1.25 !important;
  cursor: pointer !important;
  box-shadow: none !important;
  text-align: left !important;
}

body.theme-minimal .readerPageQuestionPill .readerPageQuestionOpenBtn:hover,
.readerPageQuestionOpenBtn:hover {
  background: rgba(59, 130, 246, 0.16) !important;
  color: #ffffff !important;
}

.readerPageQuestionDot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.22);
  flex: none;
}

.readerPageQuestionCta {
  color: #60a5fa;
  font-weight: 700;
  white-space: nowrap;
}

body.theme-minimal .readerPageQuestionPill .readerPageQuestionDismissBtn,
.readerPageQuestionDismissBtn {
  display: grid !important;
  place-items: center !important;
  width: 26px !important;
  height: 26px !important;
  min-width: 26px !important;
  padding: 0 !important;
  border-radius: 999px !important;
  border: 0 !important;
  background: transparent !important;
  color: #94a3b8 !important;
  font-size: 12px !important;
  line-height: 1 !important;
  cursor: pointer !important;
  box-shadow: none !important;
}

body.theme-minimal .readerPageQuestionPill .readerPageQuestionDismissBtn:hover,
.readerPageQuestionDismissBtn:hover {
  background: rgba(148, 163, 184, 0.2) !important;
  color: #ffffff !important;
}

body.theme-day .readerPageQuestionPill {
  background: rgba(255, 255, 255, 0.96);
  border-color: color-mix(in srgb, var(--info, #3478c5) 45%, #cbd5e1);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.14);
}

body.theme-day .readerPageQuestionPill .readerPageQuestionOpenBtn {
  color: #172033 !important;
}

body.theme-day .readerPageQuestionPill .readerPageQuestionOpenBtn:hover {
  background: rgba(52, 120, 197, 0.1) !important;
  color: #0f172a !important;
}

body.theme-day .readerPageQuestionCta {
  color: #1d4ed8;
}

body.theme-day .readerPageQuestionPill .readerPageQuestionDismissBtn {
  color: #64748b !important;
}

body.theme-day .readerPageQuestionPill .readerPageQuestionDismissBtn:hover {
  background: rgba(100, 116, 139, 0.14) !important;
  color: #0f172a !important;
}

@media (max-width: 850px) {
  .readerPageQuestionPill {
    right: 12px;
    left: auto;
    bottom: max(var(--rpq-bottom-mobile, 66px), calc(66px + env(safe-area-inset-bottom, 0px)));
    max-width: calc(100vw - 24px);
  }
  body.theme-minimal .readerPageQuestionPill .readerPageQuestionOpenBtn,
  .readerPageQuestionOpenBtn {
    min-height: 44px !important;
    font-size: 12px !important;
    padding: 6px 12px !important;
  }
  body.theme-minimal .readerPageQuestionPill .readerPageQuestionDismissBtn,
  .readerPageQuestionDismissBtn {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
  }
  body.theme-minimal #readerPageQuestionDialog .rpqCloseBtn,
  .rpqCloseBtn {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
  }
  body.theme-minimal #readerPageQuestionDialog .rpqOptionBtn,
  .rpqOptionBtn,
  body.theme-minimal #readerPageQuestionDialog .rpqNavBtn,
  .rpqNavBtn,
  body.theme-minimal #readerPageQuestionDialog .rpqSecondaryBtn,
  .rpqSecondaryBtn,
  body.theme-minimal #readerPageQuestionDialog .rpqPrimaryBtn,
  .rpqPrimaryBtn {
    min-height: 44px !important;
  }
  .rpqFooter {
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  }
}

/* Native <dialog> modal — top-layer isolation without locking html/body overflow */
dialog.readerPageQuestionDialog:not([open]) {
  display: none;
}

dialog.readerPageQuestionDialog[open] {
  display: flex;
  flex-direction: column;
  width: min(720px, calc(100vw - 24px));
  max-height: min(88dvh, 760px);
  margin: auto;
  padding: 0;
  border-radius: 14px;
  border: 1px solid #2b3648;
  background: #141a24;
  color: #e6edf3;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.56);
  overflow: hidden;
  font-family: Inter, Segoe UI, system-ui, sans-serif;
}

dialog.readerPageQuestionDialog:modal {
  overscroll-behavior: contain;
}

dialog.readerPageQuestionDialog::backdrop {
  background: rgba(6, 10, 15, 0.68);
  backdrop-filter: blur(3px);
  overflow: hidden;
  overscroll-behavior: contain;
}

.rpqHeader {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px 14px;
  border-bottom: 1px solid #232d3d;
  background: #10151e;
}

.rpqTitleGroup {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.rpqTitleRow {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.rpqTitle {
  margin: 0;
  font-size: 15.5px;
  font-weight: 800;
  color: #f8fafc;
}

.rpqBadge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.16);
  border: 1px solid rgba(59, 130, 246, 0.35);
  color: #93c5fd;
  font-size: 11.5px;
  font-weight: 700;
}

.rpqMeta {
  font-size: 12px;
  color: #94a3b8;
  line-height: 1.35;
}

body.theme-minimal #readerPageQuestionDialog .rpqCloseBtn,
.rpqCloseBtn {
  display: grid !important;
  place-items: center !important;
  width: 32px !important;
  height: 32px !important;
  min-width: 32px !important;
  padding: 0 !important;
  border-radius: 8px !important;
  border: 1px solid #2b3648 !important;
  background: #1b2230 !important;
  color: #cbd5e1 !important;
  font-size: 14px !important;
  line-height: 1 !important;
  cursor: pointer !important;
}

body.theme-minimal #readerPageQuestionDialog .rpqCloseBtn:hover,
.rpqCloseBtn:hover {
  background: #273247 !important;
  color: #ffffff !important;
}

.rpqBody {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 18px 20px;
  display: grid;
  gap: 14px;
  overscroll-behavior: contain;
}

.rpqPrompt {
  font-size: 15px;
  line-height: 1.62;
  color: #edf2f7;
}

.rpqPrompt p {
  margin: 0 0 10px;
}

.rpqPrompt p:last-child {
  margin-bottom: 0;
}

.rpqOptions {
  display: grid;
  gap: 8px;
}

body.theme-minimal #readerPageQuestionDialog .rpqOptionBtn,
.rpqOptionBtn {
  display: grid !important;
  grid-template-columns: 30px 1fr !important;
  gap: 10px !important;
  align-items: center !important;
  width: 100% !important;
  padding: 10px 12px !important;
  border-radius: 9px !important;
  border: 1px solid #2a3547 !important;
  background: #19212e !important;
  color: #e6edf3 !important;
  text-align: left !important;
  font-size: 14px !important;
  line-height: 1.48 !important;
  cursor: pointer !important;
  transition: background 0.14s ease, border-color 0.14s ease !important;
}

body.theme-minimal #readerPageQuestionDialog .rpqOptionBtn:not(:disabled):hover,
.rpqOptionBtn:not(:disabled):hover {
  border-color: #60a5fa !important;
  background: #202c3d !important;
}

body.theme-minimal #readerPageQuestionDialog .rpqOptionBtn.is-selected,
.rpqOptionBtn.is-selected {
  border-color: #3b82f6 !important;
  background: rgba(59, 130, 246, 0.18) !important;
}

body.theme-minimal #readerPageQuestionDialog .rpqOptionBtn.is-correct,
.rpqOptionBtn.is-correct {
  border-color: #22c55e !important;
  background: rgba(34, 197, 94, 0.16) !important;
  color: #dcfce7 !important;
}

body.theme-minimal #readerPageQuestionDialog .rpqOptionBtn.is-wrong,
.rpqOptionBtn.is-wrong {
  border-color: #ef4444 !important;
  background: rgba(239, 68, 68, 0.16) !important;
  color: #fee2e2 !important;
}

.rpqOptionBtn:disabled {
  cursor: default !important;
}

.rpqOptionKey {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid #475569;
  font-size: 12.5px;
  font-weight: 800;
  color: #93c5fd;
  background: rgba(15, 23, 42, 0.45);
}

.rpqOptionBtn.is-selected .rpqOptionKey {
  background: #2563eb;
  border-color: #3b82f6;
  color: #ffffff;
}

.rpqOptionBtn.is-correct .rpqOptionKey {
  background: #16a34a;
  border-color: #22c55e;
  color: #ffffff;
}

.rpqOptionBtn.is-wrong .rpqOptionKey {
  background: #dc2626;
  border-color: #ef4444;
  color: #ffffff;
}

.rpqOptionText {
  min-width: 0;
  overflow-wrap: anywhere;
}

.rpqFeedback {
  padding: 12px 14px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.45;
}

.rpqFeedback.is-correct {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.45);
  color: #bbf7d0;
}

.rpqFeedback.is-wrong {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.45);
  color: #fecaca;
}

.rpqCommentary {
  padding: 13px 15px;
  border-radius: 9px;
  background: rgba(15, 23, 42, 0.58);
  border: 1px solid #293548;
  font-size: 13.5px;
  line-height: 1.56;
  color: #cbd5e1;
}

.rpqCommentaryTitle {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #93c5fd;
}

.rpqError {
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.45);
  color: #fecaca;
  font-size: 13px;
}

.rpqFooter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 20px 14px;
  border-top: 1px solid #232d3d;
  background: #10151e;
}

.rpqScopeBar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 20px;
  border-bottom: 1px solid #232d3d;
  background: #121822;
}

body.theme-minimal #readerPageQuestionDialog .rpqScopeBtn,
.rpqScopeBtn {
  padding: 5px 10px !important;
  border-radius: 999px !important;
  border: 1px solid #2d3748 !important;
  background: #19212e !important;
  color: #cbd5e1 !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  cursor: pointer !important;
}

body.theme-minimal #readerPageQuestionDialog .rpqScopeBtn.is-active,
.rpqScopeBtn.is-active {
  background: #2563eb !important;
  border-color: #3b82f6 !important;
  color: #ffffff !important;
}

.rpqScopeBtn:disabled {
  opacity: 0.42 !important;
  cursor: not-allowed !important;
}

.rpqNavGroup,
.rpqActionGroup {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

body.theme-minimal #readerPageQuestionDialog .rpqNavBtn,
.rpqNavBtn {
  padding: 7px 11px !important;
  border-radius: 8px !important;
  border: 1px solid #2d3748 !important;
  background: #19212e !important;
  color: #cbd5e1 !important;
  font-size: 12.5px !important;
  font-weight: 600 !important;
  cursor: pointer !important;
}

.rpqNavBtn:disabled {
  opacity: 0.4 !important;
  cursor: not-allowed !important;
}

body.theme-minimal #readerPageQuestionDialog .rpqSecondaryBtn,
.rpqSecondaryBtn {
  padding: 9px 14px !important;
  border-radius: 8px !important;
  border: 1px solid #334155 !important;
  background: #1e293b !important;
  color: #e2e8f0 !important;
  font-size: 13.5px !important;
  font-weight: 600 !important;
  cursor: pointer !important;
}

body.theme-minimal #readerPageQuestionDialog .rpqSecondaryBtn:hover,
.rpqSecondaryBtn:hover {
  background: #293548 !important;
  color: #ffffff !important;
}

body.theme-minimal #readerPageQuestionDialog .rpqPrimaryBtn,
.rpqPrimaryBtn {
  padding: 9px 16px !important;
  border-radius: 8px !important;
  border: 1px solid #3b82f6 !important;
  background: #2563eb !important;
  color: #ffffff !important;
  font-size: 13.5px !important;
  font-weight: 700 !important;
  cursor: pointer !important;
}

body.theme-minimal #readerPageQuestionDialog .rpqPrimaryBtn:not(:disabled):hover,
.rpqPrimaryBtn:not(:disabled):hover {
  background: #1d4ed8 !important;
  border-color: #60a5fa !important;
}

.rpqPrimaryBtn:disabled {
  opacity: 0.48 !important;
  cursor: not-allowed !important;
}

/* Light theme overrides (theme-day) */
body.theme-day dialog.readerPageQuestionDialog[open] {
  background: #ffffff;
  color: #172033;
  border-color: #d0dae6;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.24);
}

body.theme-day dialog.readerPageQuestionDialog::backdrop {
  background: rgba(15, 23, 42, 0.48);
}

body.theme-day .rpqHeader,
body.theme-day .rpqFooter {
  background: #f8fafc;
  border-color: #e2e8f0;
}

body.theme-day .rpqTitle {
  color: #0f172a;
}

body.theme-day .rpqBadge {
  background: #e8f1fd;
  border-color: #bfd6f8;
  color: #1d4ed8;
}

body.theme-day .rpqMeta {
  color: #475569;
}

body.theme-day #readerPageQuestionDialog .rpqCloseBtn,
body.theme-day .rpqCloseBtn {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #334155 !important;
}

body.theme-day .rpqPrompt {
  color: #1e293b;
}

body.theme-day #readerPageQuestionDialog .rpqOptionBtn,
body.theme-day .rpqOptionBtn {
  background: #f8fafc !important;
  border-color: #d8e1ec !important;
  color: #1e293b !important;
}

body.theme-day #readerPageQuestionDialog .rpqOptionBtn:not(:disabled):hover,
body.theme-day .rpqOptionBtn:not(:disabled):hover {
  background: #eff6ff !important;
  border-color: #60a5fa !important;
}

body.theme-day #readerPageQuestionDialog .rpqOptionBtn.is-selected,
body.theme-day .rpqOptionBtn.is-selected {
  background: #e0edff !important;
  border-color: #2563eb !important;
}

body.theme-day #readerPageQuestionDialog .rpqOptionBtn.is-correct,
body.theme-day .rpqOptionBtn.is-correct {
  background: #dcfce7 !important;
  border-color: #22c55e !important;
  color: #14532d !important;
}

body.theme-day #readerPageQuestionDialog .rpqOptionBtn.is-wrong,
body.theme-day .rpqOptionBtn.is-wrong {
  background: #fee2e2 !important;
  border-color: #ef4444 !important;
  color: #7f1d1d !important;
}

body.theme-day .rpqOptionKey {
  background: #ffffff;
  border-color: #94a3b8;
  color: #1d4ed8;
}

body.theme-day .rpqFeedback.is-correct {
  background: #dcfce7;
  border-color: #4ade80;
  color: #166534;
}

body.theme-day .rpqFeedback.is-wrong {
  background: #fee2e2;
  border-color: #f87171;
  color: #991b1b;
}

body.theme-day .rpqCommentary {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #1e293b;
}

body.theme-day .rpqCommentaryTitle {
  color: #1d4ed8;
}

body.theme-day #readerPageQuestionDialog .rpqSecondaryBtn,
body.theme-day .rpqSecondaryBtn {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #1e293b !important;
}

body.theme-day .rpqScopeBar {
  background: #f8fafc;
  border-color: #e2e8f0;
}

body.theme-day #readerPageQuestionDialog .rpqScopeBtn,
body.theme-day .rpqScopeBtn,
body.theme-day #readerPageQuestionDialog .rpqNavBtn,
body.theme-day .rpqNavBtn {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #334155 !important;
}

body.theme-day #readerPageQuestionDialog .rpqScopeBtn.is-active,
body.theme-day .rpqScopeBtn.is-active {
  background: #2563eb !important;
  border-color: #2563eb !important;
  color: #ffffff !important;
}
