/* Modo Leitura Mobile (Beta Exclusivo Admin) — Evolua Estudos */

.rhmSegmented {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border-radius: 9px;
  border: 1px solid var(--border-subtle);
  background: var(--surface-inset);
  flex-shrink: 0;
}

.rhmSegmented.hidden,
.readerHtmlPanel.hidden {
  display: none !important;
}

#readerMode .rhmSegBtn {
  border: 0 !important;
  border-radius: 7px;
  padding: 5px 8px;
  min-height: 32px;
  background: transparent !important;
  color: var(--text-primary) !important;
  font: 700 var(--font-size-xs)/1.2 var(--font-family-sans);
  white-space: nowrap;
}

#readerMode .rhmSegBtn.active {
  background: var(--btn-primary-bg) !important;
  color: var(--btn-primary-text) !important;
}

:is(#readerMode, #rhmTocDialog, #rhmMoreSheet)[data-rhm-theme] {
  color-scheme: light;
  --rhm-bg: var(--reader-paper-light);
  --rhm-text: var(--reader-ink-light);
  --rhm-accent: var(--brand-primary-hover);
  --rhm-success: var(--color-green-700);
  --rhm-error: var(--color-red-700);
  --rhm-warn: var(--color-amber-800);
  --rhm-muted: color-mix(in srgb, var(--rhm-text) 72%, var(--rhm-bg));
  --rhm-border: color-mix(in srgb, var(--rhm-text) 22%, var(--rhm-bg));
  --rhm-soft: color-mix(in srgb, var(--rhm-text) 5%, var(--rhm-bg));
  --rhm-code-bg: color-mix(in srgb, var(--rhm-text) 7%, var(--rhm-bg));
  --rhm-code-border: color-mix(in srgb, var(--rhm-text) 14%, var(--rhm-bg));
  --rhm-accent-soft: color-mix(in srgb, var(--rhm-accent) 10%, var(--rhm-bg));
  --rhm-mark-bg: color-mix(in srgb, var(--color-amber-400) 38%, var(--rhm-bg));
  --rhm-warn-bg: color-mix(in srgb, var(--rhm-warn) 9%, var(--rhm-bg));
  --rhm-tip-bg: color-mix(in srgb, var(--rhm-success) 10%, var(--rhm-bg));
}

:is(#readerMode, #rhmTocDialog, #rhmMoreSheet)[data-rhm-theme="sepia"] {
  color-scheme: light;
  --rhm-bg: var(--reader-paper-sepia);
  --rhm-text: var(--reader-ink-sepia);
  --rhm-soft: color-mix(in srgb, #6b4b19 8%, var(--rhm-bg));
  --rhm-code-bg: color-mix(in srgb, #6b4b19 14%, var(--rhm-bg));
  --rhm-code-border: color-mix(in srgb, #6b4b19 26%, var(--rhm-bg));
}

:is(#readerMode, #rhmTocDialog, #rhmMoreSheet)[data-rhm-theme="dark"] {
  color-scheme: dark;
  --rhm-bg: var(--reader-paper-dark);
  --rhm-text: var(--reader-ink-dark);
  --rhm-accent: var(--brand-accent);
  --rhm-success: var(--color-green-300);
  --rhm-error: var(--color-red-300);
  --rhm-warn: var(--color-amber-300);
  --rhm-code-bg: color-mix(in srgb, var(--rhm-text) 10%, var(--rhm-bg));
  --rhm-code-border: color-mix(in srgb, var(--rhm-text) 18%, var(--rhm-bg));
}

#readerMode.rhmReadingActive:has(#readerHtmlPanel) .readerMain {
  display: block !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  overflow-anchor: none !important;
  background: var(--rhm-bg) !important;
  scroll-behavior: auto;
  scroll-padding-top: calc(var(--rhm-toolbar-height, 76px) + 8px);
}

#readerMode.rhmReadingActive #paper,
#readerMode.rhmReadingActive #practice {
  display: none !important;
}

#readerMode.rhmReadingActive .readerProgressTrack {
  display: block !important;
  position: sticky;
  top: 0;
  z-index: 5;
  height: 3px !important;
  padding: 0 !important;
  border: 0 !important;
  background: var(--rhm-soft) !important;
}

#readerMode.rhmReadingActive .readerProgressBar {
  height: 3px !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: var(--rhm-soft) !important;
}

#readerMode.rhmReadingActive #readerProgressFill {
  background: var(--rs-fill, var(--brand-primary)) !important;
}

#readerMode.rhmReadingActive:not(:has(.rhmReady)) .readerProgressTrack {
  visibility: hidden;
}

#readerMode.rhmReadingActive .readerTop {
  background: var(--rhm-bg) !important;
  border-color: var(--rhm-border) !important;
  color: var(--rhm-text) !important;
}

#readerMode.rhmReadingActive .readerTop {
  position: relative !important;
}

#readerMode.rhmReadingActive:not(.immersiveMode) .readerTop {
  display: flex !important;
}

#readerMode.rhmReadingActive .readerTop :is(#readerTopicTitle, .readerSubStatusLine, .readerSubStatusLine span) {
  color: var(--rhm-text) !important;
}

#readerMode.rhmReadingActive[data-rhm-theme] .readerTop button:not(.rhmSegBtn),
#readerMode.rhmReadingActive[data-rhm-theme] .readerTop button:not(.rhmSegBtn):hover {
  background: var(--rhm-soft) !important;
  border-color: var(--rhm-border) !important;
  color: var(--rhm-text) !important;
  box-shadow: none !important;
}

#readerMode.rhmReadingActive:has(#readerHtmlPanel) .readerShell {
  display: block !important;
  height: auto !important;
  min-height: 0 !important;
  min-width: 0;
  padding: 0 !important;
  overflow: visible !important;
  background: var(--rhm-bg) !important;
}

#readerMode.rhmReadingActive :is(#readerZoomControls, #readerPaperModeGroup),
#readerMode.rhmReadingActive:has(.rhmReady) .rhmSegmented {
  display: none !important;
}

.readerHtmlPanel {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  background: var(--rhm-bg);
  color: var(--rhm-text);
}

.rhmStickyChrome {
  position: sticky;
  top: 3px;
  z-index: 6;
  background: var(--rhm-bg);
  border-bottom: 1px solid var(--rhm-border);
}

.rhmMicroBar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 5px 12px;
  background: var(--rhm-bg);
  min-height: 40px;
  box-sizing: border-box;
}

.rhmMicroBarLeft,
.rhmMicroBarRight {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

#readerMode .rhmMicroBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 30px;
  padding: 4px 9px !important;
  border-radius: 8px;
  border: 1px solid var(--rhm-border) !important;
  background: var(--rhm-soft) !important;
  color: var(--rhm-text) !important;
  font-family: Inter, system-ui, sans-serif;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: none !important;
}

#readerMode .rhmMicroBtn:hover {
  border-color: var(--rhm-accent) !important;
}

.rhmMicroProgress {
  font-family: Inter, system-ui, sans-serif;
  font-size: 11.5px;
  font-weight: 800;
  color: var(--rhm-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.rhmToolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 7px 14px;
  background: var(--rhm-bg);
  border-top: 1px solid var(--rhm-border);
  max-height: 220px;
  overflow: hidden;
  transition: opacity 140ms ease, max-height 160ms ease, padding 140ms ease;
}

.rhmToolbarGroup {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

#readerMode .rhmBarBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--rhm-border) !important;
  background: var(--rhm-soft) !important;
  color: var(--rhm-text) !important;
  font-family: Inter, system-ui, sans-serif;
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
}

#readerMode .rhmBarBtn:hover {
  border-color: var(--rhm-accent) !important;
}

#readerMode .rhmBarBtn.active,
#readerMode .rhmBarBtn.active:hover {
  background: var(--rhm-accent-soft) !important;
  border-color: var(--rhm-accent) !important;
  color: var(--rhm-accent) !important;
}

.rhmFontLabel {
  min-width: 31px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--rhm-muted);
}

.rhmContainer {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 18px 16px 88px;
  box-sizing: border-box;
}

.rhmArticle {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  background: var(--rhm-bg);
  color: var(--rhm-text);
  border: 1px solid var(--rhm-border);
  border-radius: 14px;
  padding: 26px 28px 40px;
  font-family: "Inter", "DM Sans", system-ui, -apple-system, sans-serif;
  font-size: var(--rhm-font-size, 16px);
  line-height: 1.7;
  overflow-wrap: break-word;
  word-break: normal;
}

.rhmArticle :is(a, pre) {
  overflow-wrap: anywhere;
}

#readerMode .rhmArticle :is(h1, h2, h3, h4, h5) {
  color: var(--rhm-text) !important;
}

.rhmArticle h1 {
  font-size: 1.55em;
  line-height: 1.24;
  margin: 0.35em 0 0.7em;
  font-weight: 800;
}

.rhmArticle h2 {
  font-size: 1.26em;
  line-height: 1.3;
  margin: 1.45em 0 0.55em;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--rhm-border);
  font-weight: 800;
  scroll-margin-top: 0.35em;
}

.rhmArticle h3 {
  font-size: 1.09em;
  line-height: 1.35;
  margin: 1.25em 0 0.45em;
  font-weight: 700;
  scroll-margin-top: 0.35em;
}

.rhmArticle h4,
.rhmArticle h5 {
  font-size: 1em;
  line-height: 1.38;
  margin: 1em 0 0.4em;
  font-weight: 700;
}

.rhmArticle p {
  margin: 0 0 0.95em;
}

.rhmArticle ul,
.rhmArticle ol {
  margin: 0 0 1em;
  padding-left: 1.4em;
}

.rhmArticle li {
  margin: 0.3em 0;
}

.rhmArticle a {
  color: var(--rhm-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.rhmArticle mark,
.rhmArticle .hl {
  background: var(--rhm-mark-bg);
  color: var(--rhm-text);
  padding: 0.05em 0.25em;
  border-radius: 4px;
}

.rhmArticle :is(code, kbd, samp, tt, .phonetic, .ipa) {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.9em;
  background: var(--rhm-code-bg) !important;
  border: 1px solid var(--rhm-code-border) !important;
  color: var(--rhm-text) !important;
  padding: 0.08em 0.36em;
  border-radius: 5px;
  overflow-wrap: anywhere;
}

.rhmArticle pre {
  max-width: 100%;
  overflow-x: auto;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--rhm-soft);
  border: 1px solid var(--rhm-border);
  font-size: 0.88em;
  line-height: 1.5;
}

.rhmArticle figure {
  margin: 1.2em 0;
  max-width: 100%;
}

.rhmArticle figcaption {
  margin-top: 6px;
  font-size: 0.85em;
  color: var(--rhm-muted);
  text-align: center;
}

.rhmArticle svg {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 8px auto;
}

.rhmArticle .lesson-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--rhm-accent-soft);
  color: var(--rhm-accent);
  font-size: 0.78em;
  font-weight: 800;
  letter-spacing: 0.02em;
  margin-bottom: 10px;
}

.rhmArticle .badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.76em;
  font-weight: 700;
  border: 1px solid var(--rhm-border);
  background: var(--rhm-soft);
}

.rhmArticle .badge-vigente {
  background: var(--rhm-tip-bg);
  border-color: var(--rhm-success);
  color: var(--rhm-success);
}

.rhmArticle .badge-alterado {
  background: var(--rhm-warn-bg);
  border-color: var(--rhm-warn);
  color: var(--rhm-warn);
}

.rhmArticle .badge-revogado {
  opacity: 0.78;
}

.rhmArticle .law-quote,
.rhmArticle blockquote,
.rhmArticle .art-card {
  margin: 1.1em 0;
  padding: 13px 15px;
  border-radius: 10px;
  background: var(--rhm-soft);
  border: 1px solid var(--rhm-border);
  border-left: 4px solid var(--rhm-border);
}

.rhmArticle .law-ref {
  display: block;
  margin-bottom: 6px;
  font-size: 0.82em;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--rhm-accent);
}

.rhmArticle .callout,
.rhmArticle .callout-box {
  margin: 1.1em 0;
  padding: 13px 15px;
  border-radius: 10px;
  background: var(--rhm-soft);
  border: 1px solid var(--rhm-border);
  border-left: 4px solid var(--rhm-accent);
}

.rhmArticle .callout-warn {
  background: var(--rhm-warn-bg);
  border-left-color: var(--rhm-warn);
}

.rhmArticle .callout-tip {
  background: var(--rhm-tip-bg);
  border-left-color: var(--rhm-success);
}

.rhmArticle .callout-title {
  font-weight: 800;
  font-size: 0.94em;
  margin-bottom: 6px;
  color: var(--rhm-accent);
}

.rhmArticle .callout-warn .callout-title {
  color: var(--rhm-warn);
}

.rhmArticle .callout-tip .callout-title {
  color: var(--rhm-success);
}

.rhmArticle .example-card {
  margin: 1.1em 0;
  padding: 13px 15px;
  border-radius: 10px;
  background: var(--rhm-soft);
  border: 1px solid var(--rhm-border);
  border-left: 4px solid var(--rhm-accent);
}

.rhmArticle .example-label {
  font-weight: 800;
  font-size: 0.82em;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--rhm-accent);
  margin-bottom: 6px;
}

.rhmArticle .summary-card {
  margin: 1.1em 0;
  padding: 13px 15px;
  border-radius: 10px;
  background: var(--rhm-warn-bg);
  border: 1px solid var(--rhm-border);
  border-left: 4px solid var(--rhm-warn);
}

.rhmArticle .summary-label {
  font-weight: 800;
  font-size: 0.82em;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--rhm-warn);
  margin-bottom: 6px;
}

.rhmArticle .tbl-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  margin: 1.1em 0;
  border-radius: 10px;
  border: 1px solid var(--rhm-border);
  background: var(--rhm-bg);
}

.rhmArticle .tbl-scroll > table {
  width: auto;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 0.88em;
  line-height: 1.48;
  text-align: left;
  table-layout: auto;
}

.rhmArticle th {
  background: var(--rhm-soft);
  color: var(--rhm-text);
  font-weight: 800;
  padding: 9px 11px;
  border-bottom: 2px solid var(--rhm-border);
  white-space: normal;
  word-break: normal !important;
  overflow-wrap: normal !important;
  hyphens: none !important;
}

.rhmArticle td {
  padding: 9px 11px;
  border-bottom: 1px solid var(--rhm-border);
  vertical-align: top;
  white-space: normal;
  word-break: normal !important;
  overflow-wrap: normal !important;
  hyphens: none !important;
}

.rhmArticle .q-block {
  margin: 1.15em 0;
  padding: 14px 15px;
  border-radius: 10px;
  background: var(--rhm-soft);
  border: 1px solid var(--rhm-border);
}

.rhmArticle .q-stem {
  margin-bottom: 8px;
}

.rhmArticle .q-opts {
  list-style: none;
  padding-left: 0;
  margin: 0 0 8px;
  display: grid;
  gap: 5px;
}

.rhmArticle .q-opts li {
  margin: 0;
}

.rhmBinaryOptions {
  display: flex;
  gap: 6px;
}

#readerMode .rhmArticle .rhmChoice {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 7px 10px;
  border: 1px solid var(--rhm-border) !important;
  border-radius: 7px;
  background: var(--rhm-bg) !important;
  color: var(--rhm-text) !important;
  font: inherit;
  text-align: left;
  white-space: normal;
}

.rhmBinaryOptions .rhmChoice {
  text-align: center;
}

.rhmChoice[aria-disabled="true"] {
  cursor: default;
}

#readerMode .rhmArticle .rhmChoice:hover:not([aria-disabled="true"]) {
  border-color: var(--rhm-accent) !important;
}

#readerMode .rhmArticle .rhmChoice:is(.isCorrect, .isWrong) {
  border-color: var(--rhm-result) !important;
  background: color-mix(in srgb, var(--rhm-result) 12%, var(--rhm-bg)) !important;
  color: var(--rhm-result) !important;
}

.rhmChoice.isCorrect { --rhm-result: var(--rhm-success); }
.rhmChoice.isWrong { --rhm-result: var(--rhm-error); }

#readerMode .rhmArticle .rhmRevealAnswer {
  min-height: 32px;
  padding: 4px 6px;
  border: 0 !important;
  background: transparent !important;
  color: var(--rhm-accent) !important;
  font: 700 var(--font-size-xs)/1.2 var(--font-family-sans);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.rhmQuestionFeedback {
  color: var(--rhm-text);
  font-size: 0.88em;
  font-weight: 700;
}

.rhmArticle [hidden] {
  display: none !important;
}

.rhmTocEmpty {
  margin: 8px;
  color: var(--rhm-muted);
  font-size: var(--font-size-sm);
}

:is(#readerMode .rhmSegmented, .readerHtmlPanel, #rhmTocDialog) button:focus-visible {
  outline: 2px solid var(--rhm-accent, var(--brand-primary));
  outline-offset: 2px;
}

.rhmArticle .q-ans {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--rhm-border);
  font-size: 0.92em;
  color: var(--rhm-muted);
}

.rhmStateCard {
  background: var(--rhm-bg);
  color: var(--rhm-text);
  border: 1px solid var(--rhm-border);
  border-radius: 14px;
  padding: 24px 20px;
  display: grid;
  gap: 12px;
  text-align: left;
  box-shadow: var(--shadow-sm);
}

.rhmStateTitle {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
}

.rhmStateDesc {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  color: var(--rhm-muted);
}

.rhmStateActions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

#readerMode .rhmPrimaryBtn {
  appearance: none;
  border: 0;
  border-radius: 10px;
  padding: 11px 16px;
  background: var(--btn-primary-bg) !important;
  color: var(--btn-primary-text) !important;
  font-family: Inter, system-ui, sans-serif;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

#readerMode .rhmSecondaryBtn {
  appearance: none;
  border: 1px solid var(--rhm-border) !important;
  border-radius: 10px;
  padding: 10px 14px;
  background: var(--rhm-soft) !important;
  color: var(--rhm-text) !important;
  font-family: Inter, system-ui, sans-serif;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
}

.rhmSpinnerRow {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--rhm-accent);
}

.rhmSpinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid var(--rhm-border);
  border-top-color: var(--rhm-accent);
  animation: rhmSpin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes rhmSpin {
  to {
    transform: rotate(360deg);
  }
}

dialog.rhmTocDialog {
  padding: 0;
  border: 0;
  background: transparent;
}

dialog.rhmTocDialog[open],
body.theme-minimal.theme-day dialog.rhmTocDialog[open] {
  display: flex;
  flex-direction: column;
  width: min(460px, calc(100vw - 24px));
  max-height: min(82dvh, 660px);
  margin: auto;
  border-radius: 14px;
  border: 1px solid var(--rhm-border) !important;
  background: var(--rhm-bg) !important;
  color: var(--rhm-text) !important;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  font-family: Inter, system-ui, sans-serif;
}

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

dialog.rhmTocDialog::backdrop {
  background: color-mix(in srgb, var(--color-gray-950) 65%, transparent);
  backdrop-filter: blur(2px);
  overflow: hidden;
  overscroll-behavior: contain;
}

.rhmTocHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--rhm-border);
  background: var(--rhm-soft);
}

.rhmTocTitle {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  color: var(--rhm-text) !important;
}

#rhmTocDialog .rhmTocCloseBtn,
body.theme-minimal.theme-day #rhmTocDialog .rhmTocCloseBtn,
dialog.rhmMoreSheet .rhmMoreSheetCloseBtn,
body.theme-minimal.theme-day dialog.rhmMoreSheet .rhmMoreSheetCloseBtn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 44px !important;
  height: 44px !important;
  min-width: 44px !important;
  min-height: 44px !important;
  padding: 0 !important;
  flex: none !important;
  border-radius: 10px !important;
  border: 1px solid var(--rhm-border, #2e3846) !important;
  background: var(--rhm-bg, #151a23) !important;
  color: var(--rhm-text, #e6edf3) !important;
  font-size: 22px !important;
  font-weight: 700 !important;
  line-height: 1 !important;
  cursor: pointer;
  box-shadow: none !important;
}

.rhmTocList {
  overflow-y: auto;
  padding: 10px 12px 16px;
  display: grid;
  gap: 6px;
}

#rhmTocDialog .rhmTocItem {
  text-align: left;
  width: 100%;
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid transparent !important;
  background: var(--rhm-soft) !important;
  color: var(--rhm-text) !important;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.35;
  cursor: pointer;
}

#rhmTocDialog .rhmTocItem:hover {
  background: var(--rhm-accent-soft) !important;
  border-color: var(--rhm-accent) !important;
}

#rhmTocDialog .rhmTocItem.level-3 {
  padding-left: 22px;
  font-size: 12.8px;
  font-weight: 500;
  color: var(--rhm-muted) !important;
}

#readerMode.rhmReadingActive.immersiveMode {
  background: var(--rhm-bg) !important;
}

#readerMode.rhmReadingActive.immersiveMode:has(#readerHtmlPanel) .readerMain {
  height: 100dvh !important;
  scroll-behavior: auto !important;
  scroll-padding-top: max(8px, env(safe-area-inset-top));
}

#readerMode.rhmReadingActive.immersiveMode :is(.readerTop, .rhmStickyChrome, .rhmMicroBar, .rhmToolbar, #studyTimerReader, #toggleImmersiveBtn) {
  display: none !important;
}

#readerMode.rhmReadingActive.immersiveMode .rhmContainer {
  padding-top: max(10px, env(safe-area-inset-top));
  padding-bottom: calc(58px + env(safe-area-inset-bottom));
}

#readerMode.rhmReadingActive.immersiveMode #readerImmersiveExitBtn {
  top: calc(10px + env(safe-area-inset-top, 0px)) !important;
  right: max(12px, env(safe-area-inset-right, 0px)) !important;
  bottom: auto !important;
  min-width: 44px !important;
  min-height: 44px !important;
  padding: 10px 16px !important;
  z-index: 1015 !important;
  opacity: 0 !important;
  pointer-events: none !important;
  visibility: hidden !important;
  transform: translateY(-10px) !important;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22) !important;
  background: var(--rhm-bg) !important;
  border: 1px solid var(--rhm-border) !important;
  color: var(--rhm-text) !important;
  transition: opacity 180ms ease, transform 180ms ease, visibility 180ms ease !important;
}

#readerMode.rhmReadingActive.immersiveMode.rhmImmersiveExitVisible #readerImmersiveExitBtn,
#readerMode.rhmReadingActive.immersiveMode #readerImmersiveExitBtn:focus-visible {
  opacity: 1 !important;
  pointer-events: auto !important;
  visibility: visible !important;
  transform: translateY(0) !important;
}

#readerMode.rhmReadingActive.immersiveMode #readerImmersiveExitBtn:focus:not(:focus-visible) {
  outline: none !important;
}

#readerMode.rhmReadingActive.immersiveMode #readerImmersiveExitBtn:focus-visible {
  outline-color: var(--rhm-accent) !important;
}

.rhmToolbarHidden .rhmToolbar:not(:has(:focus-visible)) {
  max-height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  gap: 0 !important;
  border-top-width: 0 !important;
  overflow: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

#readerMode.rhmReadingActive:not(.immersiveMode) .rhmToolbarHidden:not(:has(.rhmToolbar :focus-visible)) {
  scroll-padding-top: 48px;
}

@media (prefers-reduced-motion: reduce) {
  #readerMode.rhmReadingActive :is(.rhmToolbar, #readerProgressFill, #readerImmersiveExitBtn) {
    transition: none !important;
  }
}

.rhmMobileOnlyBtn {
  display: none !important;
}

.rhmFooterActions {
  margin-top: 24px;
  padding: 18px 14px calc(24px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--rhm-border);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

#readerMode .rhmFooterActions button {
  min-height: 44px;
  flex: 1 1 160px;
  font-size: 13.5px;
  padding: 8px 14px;
}

dialog.rhmMoreSheet {
  padding: 0;
  border: 0;
  background: transparent;
  --rhm-bg: #151c27;
  --rhm-text: #eef2f7;
  --rhm-border: #2c3849;
  --rhm-soft: #1d2635;
  --rhm-muted: #94a3b8;
  --rhm-accent: #3b82f6;
  --rhm-accent-soft: rgba(59, 130, 246, 0.16);
}

body.theme-day dialog.rhmMoreSheet:not([data-rhm-theme]),
body.theme-minimal.theme-day dialog.rhmMoreSheet:not([data-rhm-theme]) {
  --rhm-bg: #ffffff;
  --rhm-text: #152820;
  --rhm-border: #d4ded8;
  --rhm-soft: #f3f6f4;
  --rhm-muted: #52635a;
  --rhm-accent: #256d63;
  --rhm-accent-soft: rgba(37, 109, 99, 0.12);
}

dialog.rhmMoreSheet[open],
body.theme-minimal.theme-day dialog.rhmMoreSheet[open] {
  display: flex;
  flex-direction: column;
  width: min(500px, calc(100vw - 16px));
  max-height: 82dvh;
  margin: auto auto calc(8px + env(safe-area-inset-bottom, 0px)) auto;
  border-radius: 18px;
  border: 1px solid var(--rhm-border) !important;
  background: var(--rhm-bg) !important;
  color: var(--rhm-text) !important;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.48);
  overflow: hidden;
  font-family: Inter, system-ui, sans-serif;
}

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

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

.rhmMoreSheetHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--rhm-border);
  background: var(--rhm-soft);
}

.rhmMoreSheetTitle {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  color: var(--rhm-text) !important;
}

.rhmMoreSheetBody {
  overflow-y: auto;
  padding: 14px 16px calc(18px + env(safe-area-inset-bottom, 0px));
  display: grid;
  gap: 16px;
  overscroll-behavior: contain;
}

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

.rhmSheetLabel {
  font-size: 11.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--rhm-muted);
}

.rhmSheetFontRow,
.rhmSheetThemeRow {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rhmSheetFontVal {
  min-width: 48px;
  text-align: center;
  font-size: 13.5px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

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

:is(#rhmMoreSheet, #readerMoreSheet) .rhmMoreSheetCloseBtn,
:is(#rhmMoreSheet, #readerMoreSheet) .rhmMoreSheetCloseBtn:hover {
  min-width: 44px !important;
  min-height: 44px !important;
  border: 1px solid var(--rhm-border) !important;
  border-radius: 10px !important;
  background: var(--rhm-bg) !important;
  color: var(--rhm-text) !important;
  font-size: 20px !important;
  font-weight: 700 !important;
  line-height: 1 !important;
  cursor: pointer !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-shadow: none !important;
}

dialog.rhmMoreSheet .rhmSheetChipBtn,
dialog.rhmMoreSheet .rhmSheetActionBtn,
body.theme-minimal.theme-day dialog.rhmMoreSheet .rhmSheetChipBtn,
body.theme-minimal.theme-day dialog.rhmMoreSheet .rhmSheetActionBtn,
:is(#rhmMoreSheet, #readerMoreSheet) .rhmSheetChipBtn,
:is(#rhmMoreSheet, #readerMoreSheet) .rhmSheetActionBtn,
:is(#rhmMoreSheet, #readerMoreSheet) .rhmSheetChipBtn:hover,
:is(#rhmMoreSheet, #readerMoreSheet) .rhmSheetActionBtn:hover {
  min-height: 44px !important;
  padding: 10px 14px !important;
  border-radius: 10px !important;
  border: 1px solid var(--rhm-border) !important;
  background: var(--rhm-soft) !important;
  color: var(--rhm-text) !important;
  font-size: 14px !important;
  font-weight: 700 !important;
  cursor: pointer !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-shadow: none !important;
}

dialog.rhmMoreSheet .rhmSheetChipBtn {
  flex: 1 1 0%;
}

dialog.rhmMoreSheet .rhmSheetChipBtn.active,
body.theme-minimal.theme-day dialog.rhmMoreSheet .rhmSheetChipBtn.active,
:is(#rhmMoreSheet, #readerMoreSheet) .rhmSheetChipBtn.active,
:is(#rhmMoreSheet, #readerMoreSheet) .rhmSheetChipBtn.active:hover {
  background: var(--rhm-accent-soft) !important;
  border-color: var(--rhm-accent) !important;
  color: var(--rhm-accent) !important;
}

dialog.rhmMoreSheet .rhmSheetActionBtn {
  width: 100% !important;
  justify-content: flex-start !important;
}

@media (max-width: 850px) {
  #readerMode.rhmReadingActive:has(.rhmReady):not(.immersiveMode) .readerTop,
  #readerMode.rhmReadingActive:has(.rhmReady) .readerTop,
  #readerMode.rhmReadingActive .rhmToolbar,
  #readerMode.rhmReadingActive .rhmDesktopOnlyBtn,
  #readerMode.rhmReadingActive .rhmDeskLabel {
    display: none !important;
  }
  #readerMode.rhmReadingActive .rhmMobileOnlyBtn {
    display: inline-flex !important;
  }
  #readerMode.rhmReadingActive .readerProgressTrack {
    top: 0 !important;
    z-index: 7 !important;
    height: auto !important;
    padding-top: env(safe-area-inset-top, 0px) !important;
    background: var(--rhm-bg) !important;
  }
  .rhmStickyChrome {
    top: calc(3px + env(safe-area-inset-top, 0px));
  }
  .rhmMicroBar {
    min-height: 52px;
    padding: 4px 8px;
    gap: 4px;
    flex-wrap: nowrap;
    overflow: hidden;
  }
  .rhmMicroBarLeft,
  .rhmMicroBarRight {
    gap: 4px;
    flex-shrink: 0;
  }
  #readerMode .rhmMicroBtn {
    min-width: 44px !important;
    width: 44px !important;
    min-height: 44px !important;
    height: 44px !important;
    padding: 0 !important;
    font-size: 16px !important;
  }
  .rhmMicroProgress {
    font-size: 11px;
    min-width: 26px;
    text-align: right;
  }
  #readerMode.hasStudyTimer .rhmContainer {
    padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)) !important;
  }
  dialog.rhmMoreSheet[open],
  body.theme-minimal.theme-day dialog.rhmMoreSheet[open] {
    width: 100vw;
    max-width: 100vw;
    margin: auto 0 0 0;
    border-radius: 18px 18px 0 0;
  }
}

@media (max-width: 640px) {
  .rhmContainer {
    padding: 0 0 48px;
  }
  .rhmArticle {
    padding: 12px 12px 24px;
    border: 0;
  }
}
