:root {
  --bg: #000;
  --fg: #0f0;
  --accent: #0c6;
  --muted: rgba(0,255,0,0.25);
  --border: #0f0;
  --fg-rgb: 0,255,0;
  --crt-line-alpha: 0.08;
  --crt-glow-alpha: 0.02;
}
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
}
html[data-retro-theme-state="pending"] body {
  visibility: hidden;
}
body {
  /* Bridge the reliability shell onto the historical theme token set. */
  --background: var(--bg);
  --panel: var(--bg);
  --line: var(--border);
  --text: var(--fg);
  --reader-component-surface: var(--bg);
  --reader-component-text: var(--fg);
  --reader-component-border: var(--border);
  --reader-component-muted: var(--accent);
  --tts-popout-surface: var(--reader-component-surface);
  --tts-popout-text: var(--reader-component-text);
  --tts-popout-border: var(--reader-component-border);
  color: var(--fg);
  font-family: 'Press Start 2P', monospace;
  font-size: 12px;
  position: relative;
  overflow-x: hidden;
}
#screen {
  position: relative;
  min-height: 100vh;
}
a {
  color: var(--fg);
  text-decoration: none;
}
a:hover {
  color: var(--accent);
}
header {
  background: var(--bg);
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  box-sizing: border-box;
}
header h1 {
  margin: 0;
  font-size: 1rem;
}
header form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}
input[type="text"], input[type="search"], input[type="file"], select,
button {
  background: var(--bg);
  border: 2px solid var(--border);
  color: var(--fg);
  padding: 0.5rem;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.75rem;
}
button:hover {
  background: var(--fg);
  color: var(--bg);
}
.header-link {
  border: 2px solid var(--border);
  padding: 0.5rem;
}
.tts-settings-form {
  display: grid;
  gap: 0.75rem;
  max-width: 720px;
}
.tts-settings-label,
.tts-settings-help {
  font-size: 0.65rem;
  line-height: 1.7;
}
.tts-settings-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.container {
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: calc(100vh - 70px);
}
.sidebar-shell {
  position: relative;
  min-width: 0;
}
.sidebar {
  height: 100%;
  border-right: 1px solid var(--border);
  padding: 1rem;
  box-sizing: border-box;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
}
.sidebar-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.main {
  padding: 1.5rem;
  box-sizing: border-box;
  overflow: auto;
}
.reader-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.reader-chapter-label {
  font-size: 0.8rem;
  line-height: 1.4;
}
.reader-statuses {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.reader-status-form {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  margin: 0;
}
.reader-status-error {
  display: inline-block;
  max-width: 12rem;
  color: var(--accent);
  font-size: 0.55rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.reader-status-error:empty {
  display: none;
}
.reader-header .reader-status-form button,
.reader-header > .reader-statuses > button.reader-status-toggle {
  min-height: 32px;
  padding: 0.45rem 0.65rem;
}
.reader-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.55rem;
  line-height: 1.2;
  color: var(--fg);
}
.reader-status-toggle {
  background: transparent;
  border: none;
  color: inherit;
  padding: 0;
  font: inherit;
  cursor: pointer;
}
.reader-status-toggle:hover {
  background: transparent;
  color: var(--accent);
}
.reader-status-toggle:disabled {
  cursor: wait;
  opacity: 0.72;
}
button.reader-status-checkbox {
  appearance: none;
  -webkit-appearance: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
}
button.reader-status-checkbox.checked {
  cursor: pointer;
}
button.reader-status-checkbox:disabled {
  cursor: default;
}
.reader-status-checkbox {
  width: 12px;
  height: 12px;
  border: 2px solid var(--border);
  display: inline-grid;
  place-items: center;
  box-sizing: border-box;
  background: rgba(var(--fg-rgb), 0.06);
}
.reader-status-checkbox.checked::after {
  content: "";
  width: 6px;
  height: 6px;
  background: var(--fg);
}
.reader-status-pill.passive {
  opacity: 0.75;
  cursor: default;
}
.reader-status-pill.passive .reader-status-checkbox {
  background: rgba(var(--fg-rgb), 0.04);
}
.list-title {
  margin: 0 0 0.5rem 0;
  font-size: 0.85rem;
}
.sidebar-top-row .list-title {
  margin: 0;
}
.sidebar-shortcuts {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.crawler-shortcut {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 2px solid var(--border);
  padding: 0.35rem 0.55rem;
  font-size: 0.7rem;
  line-height: 1;
}
.crawler-shortcut:hover {
  background: var(--fg);
  color: var(--bg);
}
.crawler-shortcut-icon {
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  font-size: 0;
  position: relative;
  box-sizing: border-box;
  flex: 0 0 auto;
}
.crawler-shortcut-icon::after {
  content: "";
  width: 7px;
  height: 2px;
  background: currentColor;
  position: absolute;
  right: -6px;
  bottom: -3px;
  transform: rotate(45deg);
  transform-origin: left center;
}
.chapter-sidebar-toggle {
  position: absolute;
  z-index: 6;
  top: 1rem;
  right: -14px;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border: 2px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  font-family: 'Press Start 2P', monospace;
  font-size: 12px;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}
.chapter-sidebar-toggle:hover {
  background: var(--fg);
  color: var(--bg);
}
body.chapter-sidebar-collapsed .container {
  grid-template-columns: 64px 1fr;
}
body.chapter-sidebar-collapsed .sidebar {
  padding-left: 0.65rem;
  padding-right: 0.65rem;
}
body.chapter-sidebar-collapsed .sidebar .chapter-search,
body.chapter-sidebar-collapsed .sidebar .controls-row,
body.chapter-sidebar-collapsed .sidebar .scroll-list {
  display: none;
}
body.chapter-sidebar-collapsed .sidebar .list-title a {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  white-space: nowrap;
  display: inline-block;
}
body.chapter-sidebar-collapsed .sidebar-shortcuts {
  justify-content: center;
}
body.chapter-sidebar-collapsed .crawler-shortcut {
  width: 28px;
  height: 28px;
  padding: 0;
  justify-content: center;
  box-sizing: border-box;
}
body.chapter-sidebar-collapsed .crawler-shortcut-label {
  display: none;
}
body.chapter-sidebar-collapsed .crawler-shortcut-icon {
  width: 14px;
  height: 14px;
}
.list-item {
  padding: 0.25rem 0;
  border-bottom: 1px dashed var(--muted);
  word-break: break-word;
}
.list-item.active a {
  font-weight: bold;
  text-decoration: underline;
}
.book-list-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
  align-items: start;
}
.book-list-link {
  min-width: 0;
}
.book-remove-form {
  margin: 0;
}
.book-remove-button {
  width: 24px;
  height: 24px;
  min-height: 0;
  padding: 0;
  border-width: 1px;
  font-size: 0.65rem;
  line-height: 1;
  opacity: 0.65;
}
.book-remove-button:hover {
  opacity: 1;
  background: #ff3b3b;
  border-color: #ff3b3b;
  color: #000;
}
.scroll-list {
  overflow-y: auto;
  padding-right: 6px;
  max-height: calc(100vh - 210px);
  border: 1px dashed var(--muted);
}
.book-scroll-list {
  max-height: calc(100vh - 150px);
}
.scroll-list::-webkit-scrollbar {
  width: 10px;
}
.scroll-list::-webkit-scrollbar-thumb {
  background: var(--fg);
}
.scroll-list::-webkit-scrollbar-track {
  background: var(--bg);
  border-left: 1px solid var(--muted);
}
.controls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.controls-row button {
  min-height: 32px;
  padding: 0.35rem 0.5rem;
  font-size: 0.62rem;
}
.controls-row button.active,
.controls-row button[aria-pressed="true"] {
  background: var(--fg);
  color: var(--bg);
}
.book-sort-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem;
}
.book-sort-controls > button {
  min-width: 0;
  white-space: normal;
}
.reader-book-information {
  margin: 0.5rem 1rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line);
}
.reader-book-information > summary {
  cursor: pointer;
}
.reader-book-information dl {
  display: grid;
  gap: 0.35rem;
  margin: 0.5rem 0 0;
}
.reader-book-information dl > div {
  display: grid;
  grid-template-columns: minmax(7rem, 0.35fr) minmax(0, 1fr);
  gap: 0.5rem;
}
.reader-book-information dd {
  margin: 0;
  overflow-wrap: anywhere;
}
.header-search,
.chapter-search {
  display: grid;
  gap: 0.3rem;
  min-width: min(18rem, 100%);
  font-size: 0.58rem;
}
.header-search {
  margin-left: auto;
}
.header-search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.4rem;
}
.header-search input,
.chapter-search input {
  width: 100%;
  min-height: 36px;
  box-sizing: border-box;
}
.header-search-row button {
  min-height: 36px;
}
.book-author,
.book-progress-hint {
  display: block;
}
.book-author {
  opacity: 0.88;
}
.controls-row a {
  border: 2px solid var(--border);
  padding: 0.2rem 0.5rem;
  font-size: 0.7rem;
}
.controls-row a.active {
  background: var(--fg);
  color: var(--bg);
}
.dashboard-section {
  max-width: 900px;
  margin: 0 0 1.25rem 0;
}
.continue-list,
.queue-list {
  display: grid;
  gap: 0.5rem;
}
.continue-item,
.queue-item {
  display: grid;
  gap: 0.25rem;
  border: 1px dashed var(--muted);
  padding: 0.65rem 0.75rem;
  background: rgba(var(--fg-rgb), 0.035);
}
.continue-item:hover,
.queue-item:hover {
  background: rgba(var(--fg-rgb), 0.08);
}
.continue-book,
.queue-title {
  font-weight: bold;
  line-height: 1.35;
  word-break: break-word;
}
.continue-chapter,
.queue-meta {
  color: var(--accent);
  font-size: 0.72rem;
  line-height: 1.45;
  word-break: break-word;
}
.reader-service-status {
  max-width: min(32rem, calc(100vw - 2rem));
  margin: 0;
  color: var(--accent);
  font-size: 0.58rem;
  line-height: 1.45;
}
.tts-job-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  max-width: min(320px, calc(100vw - 28px));
}
.tts-job-actions button {
  min-height: 32px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--fg);
  font: inherit;
  font-size: 0.52rem;
  padding: 0.3rem 0.5rem;
  cursor: pointer;
}
.tts-job-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}
.tts-job-error {
  max-width: min(32rem, calc(100vw - 2rem));
  margin: 0;
  color: #ff8080;
  font-size: 0.58rem;
  line-height: 1.45;
}
.tts-job-error[hidden] {
  display: none;
}
.tts-dashboard {
  width: min(320px, calc(100vw - 28px));
  max-height: min(42vh, 20rem);
  overflow: auto;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.94);
  padding: 0.55rem 0.65rem;
}
.tts-dashboard[hidden] {
  display: none;
}
.tts-dashboard h3,
.tts-dashboard ol {
  margin: 0 0 0.4rem;
}
.reader-feature-control:disabled,
.reader-service-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}
.reader-content {
  max-width: 900px;
  line-height: 1.6;
  font-size: 0.9rem;
}

/* The theme owns the reader surface; the reliability wrapper is structural. */
.reader-content > article#activeChapterItem {
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.error,
.preview {
  color: var(--accent);
}

.reader-content > * {
  content-visibility: auto;
  contain-intrinsic-size: auto 2em;
}
.reader-content img {
  max-width: 100%;
  height: auto;
}
.reader-content h1, .reader-content h2, .reader-content h3 {
  margin-top: 1.5rem;
}
.reader-content .tts-current-sentence {
  /* Cue changes must remain paint-only: never alter line boxes or wrapping. */
  font-weight: inherit;
  font-style: inherit;
  line-height: inherit;
  letter-spacing: inherit;
  background: rgba(var(--fg-rgb), 0.12);
  box-shadow: 0 0 0 2px rgba(var(--fg-rgb), 0.08);
}
.reader-content .tts-current-word {
  border-radius: 0.2em;
  background: rgba(var(--accent-rgb), 0.28);
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.2);
}
.reader-content .tts-current-sentence .tts-current-word {
  background: rgba(var(--accent-rgb), 0.34);
}
.reader-content .tts-hover-sentence {
  background: rgba(var(--accent-rgb), 0.18);
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.14);
}
.reader-content .tts-current-sentence.tts-hover-sentence {
  background: linear-gradient(90deg, rgba(var(--fg-rgb), 0.14), rgba(var(--accent-rgb), 0.22));
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.2);
}
.reader-content.tts-click-seek {
  cursor: pointer;
}
.reader-content.tts-click-seek [data-tts-start] {
  cursor: pointer;
}
.nav-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: space-between;
  margin-top: 1.25rem;
}
.nav-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  min-width: 0;
  max-width: 100%;
  gap: 0.5rem;
}
.nav-row a {
  border: 2px solid var(--border);
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
}
.nav-row .disabled {
  opacity: 0.35;
  pointer-events: none;
}
@media (max-width: 915px) {
  body .reader-nav .nav-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    max-width: 100%;
    gap: 0.5rem;
    flex-wrap: nowrap;
  }
  body .reader-nav .nav-actions > a,
  body .reader-nav .nav-actions > .disabled {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-width: 0;
    margin: 0;
    text-align: center;
  }
}
.reader-navigation-status {
  display: none;
  flex: 1 1 100%;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  min-width: 0;
  font-size: 0.75rem;
  color: var(--fg);
  background: var(--bg);
  border-color: var(--border);
}
.reader-navigation-status.open {
  display: flex;
}
.reader-navigation-retry {
  min-height: 36px;
  padding: 0.35rem 0.65rem;
  border: 2px solid var(--border);
  background: var(--panel);
  color: var(--fg);
  font: inherit;
  cursor: pointer;
}
.reader-navigation-retry:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.reader-navigation-retry[hidden] {
  display: none !important;
}
.tts-widget {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  position: relative;
}
.tts-widget.tts-floating {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.45rem;
}
.tts-main-row {
  display: flex;
  align-items: flex-start;
}
.tts-control-column {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  width: auto;
}
.tts-playback-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.tts-progress-popout {
  display: none;
  width: min(320px, calc(100vw - 28px));
  padding: 0.55rem 0.65rem;
  color: var(--tts-popout-text);
  border: 2px solid var(--tts-popout-border);
  background: var(--tts-popout-surface);
  box-shadow: 0 0 0 1px rgba(var(--fg-rgb), 0.18), 0 0 14px rgba(var(--fg-rgb), 0.12);
}
.tts-progress-popout.active {
  display: grid;
  gap: 0.38rem;
}
.tts-progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.54rem;
  line-height: 1.3;
  opacity: 0.86;
}
.tts-progress-slider {
  width: 100%;
  accent-color: var(--fg);
}
.tts-queue-btn {
  --tts-progress: 0;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  display: grid;
  place-items: center;
  padding: 0;
  position: relative;
  cursor: pointer;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(var(--fg-rgb), 0.18), 0 0 16px rgba(var(--fg-rgb), 0.14);
}
.tts-progress-meter {
  --tts-progress: 0;
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
}
.tts-progress-meter::after {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.72);
  box-shadow: inset 0 0 0 1px rgba(var(--fg-rgb), 0.18);
}
.tts-progress-meter::before {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: 999px;
  background:
    radial-gradient(circle at center, transparent 62%, rgba(var(--fg-rgb), 0.08) 63%, rgba(var(--fg-rgb), 0.08) 70%, transparent 71%),
    conic-gradient(var(--fg) calc(var(--tts-progress) * 100%), rgba(var(--fg-rgb), 0.12) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 0);
  mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 0);
}
.tts-queue-btn[data-state="queued"] .tts-progress-meter::before {
  background:
    radial-gradient(circle at center, transparent 62%, rgba(var(--fg-rgb), 0.08) 63%, rgba(var(--fg-rgb), 0.08) 70%, transparent 71%),
    conic-gradient(var(--fg) calc(var(--tts-progress) * 100%), rgba(var(--fg-rgb), 0.12) 0);
}
.tts-queue-btn[data-state="running"] {
  box-shadow: 0 0 0 1px rgba(var(--fg-rgb), 0.24), 0 0 18px rgba(var(--fg-rgb), 0.22);
  animation: tts-pulse 1.8s ease-in-out infinite;
}
.tts-queue-btn[data-state="error"] {
  color: #ff6767;
  border-color: #ff6767;
}
.tts-queue-btn[data-state="error"] .tts-progress-meter::before {
  background:
    radial-gradient(circle at center, transparent 62%, rgba(255, 103, 103, 0.10) 63%, rgba(255, 103, 103, 0.10) 70%, transparent 71%),
    conic-gradient(#ff6767 0 100%);
  opacity: 0.35;
}
.tts-queue-btn.tts-queue-btn-warning {
  color: #ffd15c;
  border-color: #ffd15c;
}
.tts-queue-btn.tts-queue-btn-warning .tts-progress-meter::before {
  background:
    radial-gradient(circle at center, transparent 62%, rgba(255, 209, 92, 0.10) 63%, rgba(255, 209, 92, 0.10) 70%, transparent 71%),
    conic-gradient(rgba(255, 209, 92, 0.9) calc(var(--tts-progress) * 100%), rgba(255, 209, 92, 0.16) 0);
}
.tts-queue-btn.tts-queue-btn-warning-loud {
  box-shadow: 0 0 0 1px rgba(255, 209, 92, 0.3), 0 0 24px rgba(255, 209, 92, 0.28);
}
.tts-confirm {
  display: none;
  position: absolute;
  right: 110px;
  bottom: 50px;
  padding: 0.55rem 0.6rem;
  border: 2px solid var(--border);
  background: rgba(0, 0, 0, 0.92);
  box-shadow: 0 0 0 1px rgba(var(--fg-rgb), 0.18), 0 0 14px rgba(var(--fg-rgb), 0.1);
  min-width: 160px;
  z-index: 6;
}
.tts-confirm.active {
  display: block;
}
.tts-confirm-text {
  font-size: 0.55rem;
  line-height: 1.5;
  margin-bottom: 0.45rem;
}
.tts-confirm-actions {
  display: flex;
  gap: 0.45rem;
}
.tts-confirm-btn {
  flex: 1 1 0;
  border: 2px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-size: 0.55rem;
  padding: 0.4rem 0.45rem;
  cursor: pointer;
}
.tts-confirm-btn:hover {
  background: var(--fg);
  color: var(--bg);
}
.tts-queue-btn[data-state="done"] {
  box-shadow: 0 0 0 1px rgba(var(--fg-rgb), 0.3), 0 0 20px rgba(var(--fg-rgb), 0.26);
}
.tts-queue-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}
.tts-icon {
  width: 16px;
  height: 16px;
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 0 8px rgba(var(--fg-rgb), 0.35));
}
.tts-icon[data-tts-play-icon] {
  display: grid;
  place-items: center;
  line-height: 1;
  font-size: 0.95rem;
}
.tts-icon svg {
  width: 100%;
  height: 100%;
  display: block;
  fill: currentColor;
}
.tts-icon.warning-icon {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  font-size: 1rem;
  font-weight: bold;
  line-height: 1;
}
.tts-queue-btn-warning-loud .tts-icon.warning-icon {
  font-size: 1.35rem;
}
.tts-warning-mark {
  display: block;
}
.tts-meta {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}
.tts-meta {
  display: contents;
}
.tts-speed-row {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
}
.tts-jump-btn,
.tts-speed-trigger,
.tts-speed-preset {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-size: 0.7rem;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 1px rgba(var(--fg-rgb), 0.18), 0 0 12px rgba(var(--fg-rgb), 0.1);
}
.tts-jump-btn {
  font-size: 0.56rem;
  letter-spacing: -0.04em;
}
.tts-speed-trigger {
  width: auto;
  min-width: 108px;
  padding: 0 0.85rem;
  gap: 0.42rem;
  font-size: 0.56rem;
  letter-spacing: -0.02em;
}
.tts-speed-trigger-label {
  opacity: 0.72;
}
.tts-speed-trigger-value {
  font-size: 0.68rem;
}
.tts-jump-btn:disabled {
  opacity: 0.4;
  cursor: default;
}
.tts-speed-popup {
  display: none;
  position: absolute;
  bottom: calc(100% + 10px);
  right: 0;
  transform: translateX(135px);
  width: min(320px, calc(100vw - 42px));
  padding: 0.8rem;
  border: 2px solid var(--border);
  background: rgba(0, 0, 0, 0.96);
  box-shadow: 0 0 0 1px rgba(var(--fg-rgb), 0.18), 0 0 18px rgba(var(--fg-rgb), 0.16);
  z-index: 8;
}
.tts-speed-popup.active {
  display: grid;
  gap: 0.75rem;
}
html.mobile-touch .tts-speed-row {
  position: static;
}
html.mobile-touch .tts-speed-popup {
  position: fixed;
  left: 0;
  right: 0;
  top: auto;
  bottom: 0;
  transform: none;
  width: auto;
  max-width: none;
  padding: 0.95rem 0.95rem calc(0.95rem + env(safe-area-inset-bottom, 0px));
  border-width: 2px 0 0 0;
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.42), 0 0 0 1px rgba(var(--fg-rgb), 0.16);
}
html.mobile-touch .tts-speed-popup::before {
  content: "";
  width: 44px;
  height: 4px;
  border-radius: 999px;
  background: rgba(var(--fg-rgb), 0.45);
  justify-self: center;
  margin-bottom: 0.1rem;
}
html.mobile-touch .tts-speed-slider-row {
  grid-template-columns: 48px minmax(0, 1fr) 48px;
}
html.mobile-touch .tts-speed-slider-btn {
  width: 48px;
  height: 48px;
}
html.mobile-touch .tts-speed-presets {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
html.mobile-touch .tts-speed-preset {
  min-height: 42px;
}
.tts-speed-slider-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 42px;
  gap: 0.55rem;
  align-items: center;
}
.tts-speed-slider-btn {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-size: 0.95rem;
  line-height: 1;
  padding: 0;
  cursor: pointer;
}
.tts-speed-slider-wrap {
  display: grid;
  gap: 0.4rem;
}
.tts-speed-popup-value {
  font-size: 0.6rem;
  text-align: center;
}
.tts-speed-slider {
  width: 100%;
  accent-color: var(--fg);
}
.tts-speed-presets {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
}
.tts-speed-preset {
  width: auto;
  border-radius: 999px;
  font-size: 0.6rem;
  padding: 0 0.5rem;
}
.tts-speed-trigger.active,
.tts-speed-preset.active {
  background: var(--fg);
  color: var(--bg);
  box-shadow: 0 0 10px rgba(var(--fg-rgb), 0.22);
}
.tts-inline-audio {
  display: none;
}
@keyframes tts-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
@keyframes tts-pulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(var(--fg-rgb), 0.20), 0 0 12px rgba(var(--fg-rgb), 0.16); }
  50% { box-shadow: 0 0 0 1px rgba(var(--fg-rgb), 0.32), 0 0 22px rgba(var(--fg-rgb), 0.28); }
}
small {
  opacity: 0.75;
}
.theme-switcher {
  position: fixed;
  left: 14px;
  bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  width: calc(100vw - 28px);
  z-index: 5;
  transition: transform 0.25s ease, opacity 0.25s ease;
  pointer-events: none;
}
.theme-switcher.hidden {
  transform: translateX(-120%);
  opacity: 0.2;
}
.floating-reader-controls {
  position: fixed;
  left: 14px;
  bottom: 62px;
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: transform 0.25s ease, opacity 0.25s ease;
}
.theme-switcher.open + .floating-reader-controls {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.theme-switcher.hidden + .floating-reader-controls {
  transform: translateX(-120%);
  opacity: 0.2;
}
.theme-dot {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: grid;
  place-items: center;
  font-size: 12px;
  cursor: pointer;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.4) inset;
  background: var(--bg);
}
.theme-dot.small {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  font-size: 0;
  border: 2px solid #000;
}
.theme-options > button.theme-dot.small[data-theme] {
  border-radius: 4px;
}
.theme-dot.small.theme-effect-toggle {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  font-size: 10px;
  border-color: var(--border);
}
.reader-service-button.theme-dot.small {
  width: auto;
  height: auto;
  min-width: 34px;
  min-height: 34px;
  padding: 0.34rem 0.46rem;
  font-size: 0.55rem;
  line-height: 1.25;
  white-space: normal;
}
.theme-dot.small.translate-bubble-btn {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  padding: 0;
  color: var(--fg);
  font: inherit;
  font-size: 10px;
  border-color: var(--border);
}
.theme-dot.small.translate-bubble-btn.active {
  color: var(--accent);
}
.theme-dot.small.translate-bubble-btn:disabled {
  cursor: wait;
  opacity: 0.72;
}

.theme-dot.small.translate-range-btn {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  padding: 0;
  color: var(--fg);
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  line-height: 1;
  border: 2px solid var(--border);
  box-shadow: 0 0 0 1px rgba(var(--fg-rgb), 0.18), 0 0 10px rgba(var(--fg-rgb), 0.10);
}
.theme-dot.small.translate-range-btn.active,
.theme-dot.small.translate-range-btn:hover {
  background: var(--fg);
  color: var(--bg);
}
.theme-dot.small.translate-range-btn:disabled {
  cursor: wait;
  opacity: 0.72;
}
.theme-menu-core {
  position: fixed;
  left: 14px;
  bottom: 14px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  z-index: 9;
  transition: transform 0.25s ease, opacity 0.25s ease;
  pointer-events: auto;
}
.theme-switcher.hidden .theme-menu-core {
  transform: translateX(-120%);
  visibility: hidden;
  pointer-events: none;
  opacity: 0.2;
}
.theme-effect-toggle {
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: bold;
  letter-spacing: 0.04em;
  color: var(--fg);
  box-shadow: 0 0 0 1px rgba(var(--fg-rgb), 0.18), 0 0 12px rgba(var(--fg-rgb), 0.12);
  text-shadow: 0 0 6px rgba(var(--fg-rgb), 0.28);
}
.theme-effect-toggle.active {
  background: var(--fg);
  color: var(--bg);
}
.theme-load-status {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.theme-options {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 1 1 auto;
  flex-wrap: nowrap;
  min-width: 0;
  max-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0 20px;
  white-space: nowrap;
  scrollbar-width: thin;
  scrollbar-color: rgba(var(--fg-rgb), 0.65) transparent;
  mask-image: linear-gradient(90deg, transparent 0, #000 20px, #000 calc(100% - 20px), transparent 100%);
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 20px, #000 calc(100% - 20px), transparent 100%);
  transition: max-width 0.25s ease, opacity 0.25s ease;
  opacity: 0;
  margin-left: 56px;
  pointer-events: none;
}
.theme-switcher.open .theme-options {
  max-width: calc(100vw - 90px);
  opacity: 1;
  pointer-events: auto;
}
.theme-options::-webkit-scrollbar {
  height: 8px;
}
.theme-options::-webkit-scrollbar-thumb {
  background: rgba(var(--fg-rgb), 0.65);
  border-radius: 999px;
}
.theme-options::-webkit-scrollbar-track {
  background: transparent;
}
#themeToggle {
  position: relative;
  z-index: 6;
  font-size: 18px;
  line-height: 1;
}
/* Theme-picker geometry belongs to the shared component. Packaged themes may
   decorate the rail and swatches, but cannot grow, wrap, or re-pad them. */
.theme-switcher .theme-options {
  --reader-theme-swatch-size: 28px;
  --reader-theme-picker-block-size: 44px;
  box-sizing: border-box !important;
  block-size: var(--reader-theme-picker-block-size) !important;
  min-block-size: var(--reader-theme-picker-block-size) !important;
  max-block-size: var(--reader-theme-picker-block-size) !important;
  gap: 8px !important;
  padding-block: calc(
    (var(--reader-theme-picker-block-size) - var(--reader-theme-swatch-size) - 4px) / 2
  ) !important;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  flex-wrap: nowrap !important;
}
.theme-switcher .theme-options > button.theme-dot.small[data-theme] {
  box-sizing: border-box !important;
  inline-size: var(--reader-theme-swatch-size) !important;
  block-size: var(--reader-theme-swatch-size) !important;
  min-inline-size: var(--reader-theme-swatch-size) !important;
  min-block-size: var(--reader-theme-swatch-size) !important;
  max-inline-size: var(--reader-theme-swatch-size) !important;
  max-block-size: var(--reader-theme-swatch-size) !important;
  flex: 0 0 var(--reader-theme-swatch-size) !important;
  padding: 0 !important;
  overflow: hidden !important;
  border-radius: 4px !important;
}
/* Theme swatches own their preview paint. A loaded theme may decorate the
   picker frame, but it must never recolor another theme's intrinsic preview. */
.theme-switcher .theme-options > button.theme-dot.small[data-theme] {
  background: var(--theme-swatch-bg, #000) !important;
  border-color: var(--theme-swatch-edge, #fff) !important;
  box-shadow: inset 0 0 0 2px var(--theme-swatch-edge, #fff), 0 0 0 1px rgba(0,0,0,0.55) !important;
}
.theme-switcher .theme-options > button.theme-dot.small[data-theme]:hover,
.theme-switcher .theme-options > button.theme-dot.small[data-theme]:focus-visible {
  background: var(--theme-swatch-bg, #000) !important;
  border-color: var(--theme-swatch-edge, #fff) !important;
  outline: 2px solid var(--theme-swatch-edge, #fff);
  outline-offset: 2px;
}
.theme-switcher .theme-options > button.theme-dot.small[data-theme][aria-pressed="true"] {
  outline: 3px double var(--theme-swatch-edge, #fff);
  outline-offset: 2px;
}
.theme-options .theme-dot[data-theme][data-theme-ready="loading"] {
  cursor: progress;
  opacity: 0.55;
}
.theme-switcher .theme-options > button.theme-dot.small[data-theme][data-theme-ready="error"] {
  background: repeating-linear-gradient(135deg, #290000 0 4px, #b00020 4px 8px) !important;
  border-color: #ff8a8a !important;
  box-shadow: inset 0 0 0 2px #ff8a8a, 0 0 0 1px rgba(0,0,0,0.55) !important;
}
.theme-options [data-theme="theme-green"] { --theme-swatch-bg:#000; --theme-swatch-edge:#0f0; }
.theme-options [data-theme="theme-blackred"] { --theme-swatch-bg:#000; --theme-swatch-edge:#ff3b3b; }
.theme-options [data-theme="theme-blackorange"] { --theme-swatch-bg:#000; --theme-swatch-edge:#ff9f1a; }
.theme-options [data-theme="theme-blackblue"] { --theme-swatch-bg:#000; --theme-swatch-edge:#4169e1; }
.theme-options [data-theme="theme-blackpurple"] { --theme-swatch-bg:#000; --theme-swatch-edge:#c07cff; }
.theme-options [data-theme="theme-unix"] { --theme-swatch-bg:#002a7f; --theme-swatch-edge:#fff; }
.theme-options [data-theme="theme-tan"] { --theme-swatch-bg:#f4e7cf; --theme-swatch-edge:#4b2f1f; }
.theme-options [data-theme="theme-bluewhite"] { --theme-swatch-bg:#f5f7ff; --theme-swatch-edge:#0a2a6b; }
.theme-options [data-theme="theme-amberpaper"] { --theme-swatch-bg:#fff7df; --theme-swatch-edge:#7a4b00; }
.theme-options [data-theme="theme-forestpaper"] { --theme-swatch-bg:#f3f8f1; --theme-swatch-edge:#2f6d3b; }
.theme-options [data-theme="theme-rosepaper"] { --theme-swatch-bg:#fff4f6; --theme-swatch-edge:#8a3453; }
.theme-options [data-theme="theme-slatepaper"] { --theme-swatch-bg:#f3f5f7; --theme-swatch-edge:#324b63; }
.theme-options [data-theme="theme-mintnight"] { --theme-swatch-bg:#041914; --theme-swatch-edge:#4bdba8; }
.theme-options [data-theme="theme-goldnight"] { --theme-swatch-bg:#120d02; --theme-swatch-edge:#dba931; }
.theme-options [data-theme="theme-iceblue"] { --theme-swatch-bg:#eef8ff; --theme-swatch-edge:#1f5d87; }
.theme-options [data-theme="theme-terminalsunset"] { --theme-swatch-bg:#13000d; --theme-swatch-edge:#ff4fa3; }
.theme-options [data-theme="theme-oceanink"] { --theme-swatch-bg:#041b2d; --theme-swatch-edge:#56a7d9; }
.theme-options [data-theme="theme-lavendercream"] { --theme-swatch-bg:#fbf7ff; --theme-swatch-edge:#6a4da3; }
.theme-options [data-theme="theme-toxic"] { --theme-swatch-bg:#090f00; --theme-swatch-edge:#b8e800; }
.theme-options [data-theme="theme-cyberaqua"] { --theme-swatch-bg:#001417; --theme-swatch-edge:#28d8d0; }
.theme-options [data-theme="theme-deepsepia"] { --theme-swatch-bg:#17110b; --theme-swatch-edge:#b88a57; }
.theme-options [data-theme="theme-mulberrynight"] { --theme-swatch-bg:#140915; --theme-swatch-edge:#b96cae; }
.theme-options [data-theme="theme-emeraldink"] { --theme-swatch-bg:#081611; --theme-swatch-edge:#4fb88a; }
.theme-options [data-theme="theme-coppernight"] { --theme-swatch-bg:#18100b; --theme-swatch-edge:#b9773c; }
.theme-options [data-theme="theme-stormblue"] { --theme-swatch-bg:#0c1622; --theme-swatch-edge:#5f88c9; }
.theme-options [data-theme="theme-graphite"] { --theme-swatch-bg:#181a1f; --theme-swatch-edge:#727f95; }
.theme-options [data-theme="theme-plumink"] { --theme-swatch-bg:#160d1b; --theme-swatch-edge:#8e69d1; }
.theme-options [data-theme="theme-coalember"] { --theme-swatch-bg:#19110f; --theme-swatch-edge:#c46649; }
.theme-options [data-theme="theme-arcticnight"] { --theme-swatch-bg:#07131c; --theme-swatch-edge:#5ea6c7; }
.theme-options [data-theme="theme-mosscharcoal"] { --theme-swatch-bg:#12150f; --theme-swatch-edge:#839c54; }
.theme-options [data-theme="theme-duskteal"] { --theme-swatch-bg:#0a1718; --theme-swatch-edge:#489d95; }
.theme-options [data-theme="theme-crimsonvelvet"] { --theme-swatch-bg:#17080d; --theme-swatch-edge:#c34c69; }
.theme-options [data-theme="theme-violetfog"] { --theme-swatch-bg:#11101b; --theme-swatch-edge:#766ec9; }
.theme-options [data-theme="theme-sandnight"] { --theme-swatch-bg:#19150d; --theme-swatch-edge:#a4884e; }
.theme-options [data-theme="theme-midnightjade"] { --theme-swatch-bg:#061311; --theme-swatch-edge:#469876; }
.theme-options [data-theme="theme-nebula"] { --theme-swatch-bg:#0f1020; --theme-swatch-edge:#8f67c4; }
.theme-options [data-theme="theme-obsidiangold"] { --theme-swatch-bg:#0f0d08; --theme-swatch-edge:#b38b2f; }
.theme-options [data-theme="theme-inkrose"] { --theme-swatch-bg:#150f14; --theme-swatch-edge:#b86188; }
.theme-options [data-theme="theme-sapphiremist"] { --theme-swatch-bg:#0c1220; --theme-swatch-edge:#6078c0; }
.theme-options [data-theme="theme-pineglow"] { --theme-swatch-bg:#09110c; --theme-swatch-edge:#4f9c60; }
.theme-options [data-theme="theme-hack-imoq"] { --theme-swatch-bg:#07121d; --theme-swatch-edge:#ff7a1a; }
.theme-options [data-theme="theme-shadow-tower-abyss"] { --theme-swatch-bg:#101612; --theme-swatch-edge:#75c6c1; }
.theme-options [data-theme="theme-ff7"] { --theme-swatch-bg:#00127a; --theme-swatch-edge:#d8d8d8; }
.theme-options [data-theme="theme-ff8"] { --theme-swatch-bg:#666; --theme-swatch-edge:#bbb; }
.theme-options [data-theme="theme-dq1"] { --theme-swatch-bg:#000; --theme-swatch-edge:#fff; }
.theme-options [data-theme="theme-nier-automata"] { --theme-swatch-bg:#d8d2bc; --theme-swatch-edge:#45453e; }
.theme-options [data-theme="theme-undertale"] { --theme-swatch-bg:#000; --theme-swatch-edge:#f58220; }
.theme-options [data-theme="theme-pokemon-gb"] { --theme-swatch-bg:#f8f8d8; --theme-swatch-edge:#181818; }
.theme-options [data-theme="theme-octopath"] { --theme-swatch-bg:#17130f; --theme-swatch-edge:#b38a4f; }
.theme-options [data-theme="theme-zelda-oot"] { --theme-swatch-bg:#1a3b25; --theme-swatch-edge:#c39b3d; }
.theme-options [data-theme="theme-zelda-mm"] { --theme-swatch-bg:#211333; --theme-swatch-edge:#f0d657; }
.theme-options [data-theme="theme-kotor"] { --theme-swatch-bg:#000015; --theme-swatch-edge:#00adf8; }
.theme-options [data-theme="theme-persona5"] { --theme-swatch-bg:#080808; --theme-swatch-edge:#ed1c24; }
.theme-options [data-theme="theme-earthbound"] { --theme-swatch-bg:#39286b; --theme-swatch-edge:#ef519d; }
.theme-options [data-theme="theme-smt-terminal"] { --theme-swatch-bg:#020806; --theme-swatch-edge:#38d99a; }
.theme-options [data-theme="theme-persona3-fes"] { --theme-swatch-bg:#075aaa; --theme-swatch-edge:#8deaff; }
.theme-options [data-theme="theme-osrs"] { --theme-swatch-bg:#514735; --theme-swatch-edge:#ff981f; }
.theme-options [data-theme="theme-perfect-world"] { --theme-swatch-bg:#1f3442; --theme-swatch-edge:#e4c777; }
.theme-options [data-theme="theme-morrowind"] { --theme-swatch-bg:#c7b88d; --theme-swatch-edge:#59686c; }
.theme-options [data-theme="theme-daggerfall"] { --theme-swatch-bg:#3b3936; --theme-swatch-edge:#c59a42; }
.theme-options [data-theme="theme-skyrim"] { --theme-swatch-bg:#101214; --theme-swatch-edge:#b7c4c8; }
.theme-options [data-theme="theme-oblivion"] { --theme-swatch-bg:#e4d4ad; --theme-swatch-edge:#9b7137; }
html.mobile-touch .floating-reader-controls {
  left: 14px;
  bottom: 62px;
}
.theme-green { --bg:#000; --fg:#0f0; --accent:#0c6; --border:#0f0; --muted:rgba(0,255,0,0.25); --fg-rgb:0,255,0; --crt-line-alpha:0.08; --crt-glow-alpha:0.02; }
.theme-blackred { --bg:#000; --fg:#ff3b3b; --accent:#ff7a7a; --border:#ff3b3b; --muted:rgba(255,59,59,0.25); --fg-rgb:255,59,59; --crt-line-alpha:0.08; --crt-glow-alpha:0.02; }
.theme-blackorange { --bg:#000; --fg:#ff9f1a; --accent:#ffc266; --border:#ff9f1a; --muted:rgba(255,159,26,0.25); --fg-rgb:255,159,26; --crt-line-alpha:0.08; --crt-glow-alpha:0.02; }
.theme-blackblue { --bg:#000; --fg:#4169e1; --accent:#87a3ff; --border:#4169e1; --muted:rgba(65,105,225,0.28); --fg-rgb:65,105,225; --crt-line-alpha:0.08; --crt-glow-alpha:0.02; }
.theme-blackpurple { --bg:#000; --fg:#c07cff; --accent:#e1b7ff; --border:#c07cff; --muted:rgba(192,124,255,0.25); --fg-rgb:192,124,255; --crt-line-alpha:0.08; --crt-glow-alpha:0.02; }
.theme-unix { --bg:#002a7f; --fg:#fff; --accent:#9fd0ff; --border:#fff; --muted:rgba(255,255,255,0.28); --fg-rgb:255,255,255; --crt-line-alpha:0.04; --crt-glow-alpha:0.01; }
.theme-tan { --bg:#f4e7cf; --fg:#4b2f1f; --accent:#7a4b2a; --border:#4b2f1f; --muted:rgba(75,47,31,0.25); --fg-rgb:75,47,31; --crt-line-alpha:0.0; --crt-glow-alpha:0.0; }
.theme-bluewhite { --bg:#f5f7ff; --fg:#0a2a6b; --accent:#1e5bff; --border:#0a2a6b; --muted:rgba(10,42,107,0.25); --fg-rgb:10,42,107; --crt-line-alpha:0.0; --crt-glow-alpha:0.0; }
.theme-amberpaper { --bg:#fff7df; --fg:#5b3a00; --accent:#b56b00; --border:#7a4b00; --muted:rgba(91,58,0,0.22); --fg-rgb:91,58,0; --crt-line-alpha:0.0; --crt-glow-alpha:0.0; }
.theme-forestpaper { --bg:#f3f8f1; --fg:#1f4727; --accent:#3f8f55; --border:#2f6d3b; --muted:rgba(31,71,39,0.22); --fg-rgb:31,71,39; --crt-line-alpha:0.0; --crt-glow-alpha:0.0; }
.theme-rosepaper { --bg:#fff4f6; --fg:#6e2340; --accent:#c44d7a; --border:#8a3453; --muted:rgba(110,35,64,0.22); --fg-rgb:110,35,64; --crt-line-alpha:0.0; --crt-glow-alpha:0.0; }
.theme-slatepaper { --bg:#f3f5f7; --fg:#203040; --accent:#4b6b88; --border:#324b63; --muted:rgba(32,48,64,0.22); --fg-rgb:32,48,64; --crt-line-alpha:0.0; --crt-glow-alpha:0.0; }
.theme-mintnight { --bg:#041914; --fg:#7ef7cc; --accent:#b6ffe6; --border:#4bdba8; --muted:rgba(126,247,204,0.22); --fg-rgb:126,247,204; --crt-line-alpha:0.07; --crt-glow-alpha:0.02; }
.theme-goldnight { --bg:#120d02; --fg:#ffd15c; --accent:#ffe39f; --border:#dba931; --muted:rgba(255,209,92,0.22); --fg-rgb:255,209,92; --crt-line-alpha:0.06; --crt-glow-alpha:0.02; }
.theme-iceblue { --bg:#eef8ff; --fg:#114466; --accent:#2b7db7; --border:#1f5d87; --muted:rgba(17,68,102,0.2); --fg-rgb:17,68,102; --crt-line-alpha:0.0; --crt-glow-alpha:0.0; }
.theme-terminalsunset { --bg:#13000d; --fg:#ff79c6; --accent:#ffd166; --border:#ff4fa3; --muted:rgba(255,121,198,0.22); --fg-rgb:255,121,198; --crt-line-alpha:0.08; --crt-glow-alpha:0.03; }
.theme-oceanink { --bg:#041b2d; --fg:#8bd3ff; --accent:#d7f0ff; --border:#56a7d9; --muted:rgba(139,211,255,0.22); --fg-rgb:139,211,255; --crt-line-alpha:0.06; --crt-glow-alpha:0.02; }
.theme-lavendercream { --bg:#fbf7ff; --fg:#4f3a74; --accent:#8a69d6; --border:#6a4da3; --muted:rgba(79,58,116,0.2); --fg-rgb:79,58,116; --crt-line-alpha:0.0; --crt-glow-alpha:0.0; }
.theme-toxic { --bg:#090f00; --fg:#d7ff3f; --accent:#7dff67; --border:#b8e800; --muted:rgba(215,255,63,0.22); --fg-rgb:215,255,63; --crt-line-alpha:0.09; --crt-glow-alpha:0.03; }
.theme-cyberaqua { --bg:#001417; --fg:#5ffbf1; --accent:#c5fffb; --border:#28d8d0; --muted:rgba(95,251,241,0.22); --fg-rgb:95,251,241; --crt-line-alpha:0.08; --crt-glow-alpha:0.03; }
.theme-deepsepia { --bg:#17110b; --fg:#f0d7b3; --accent:#ffc27a; --border:#b88a57; --muted:rgba(240,215,179,0.20); --fg-rgb:240,215,179; --crt-line-alpha:0.03; --crt-glow-alpha:0.01; }
.theme-mulberrynight { --bg:#140915; --fg:#f2b8e8; --accent:#ff8ad8; --border:#b96cae; --muted:rgba(242,184,232,0.20); --fg-rgb:242,184,232; --crt-line-alpha:0.05; --crt-glow-alpha:0.02; }
.theme-emeraldink { --bg:#081611; --fg:#9af0c8; --accent:#c7ffe3; --border:#4fb88a; --muted:rgba(154,240,200,0.20); --fg-rgb:154,240,200; --crt-line-alpha:0.05; --crt-glow-alpha:0.02; }
.theme-coppernight { --bg:#18100b; --fg:#f1be8a; --accent:#ff9f5c; --border:#b9773c; --muted:rgba(241,190,138,0.20); --fg-rgb:241,190,138; --crt-line-alpha:0.05; --crt-glow-alpha:0.02; }
.theme-stormblue { --bg:#0c1622; --fg:#c3dcff; --accent:#78aefc; --border:#5f88c9; --muted:rgba(195,220,255,0.20); --fg-rgb:195,220,255; --crt-line-alpha:0.04; --crt-glow-alpha:0.01; }
.theme-graphite { --bg:#181a1f; --fg:#d8dde7; --accent:#8ea0bf; --border:#727f95; --muted:rgba(216,221,231,0.20); --fg-rgb:216,221,231; --crt-line-alpha:0.02; --crt-glow-alpha:0.0; }
.theme-plumink { --bg:#160d1b; --fg:#e0c8ff; --accent:#b58cff; --border:#8e69d1; --muted:rgba(224,200,255,0.20); --fg-rgb:224,200,255; --crt-line-alpha:0.05; --crt-glow-alpha:0.02; }
.theme-coalember { --bg:#19110f; --fg:#ffd0bf; --accent:#ff8c69; --border:#c46649; --muted:rgba(255,208,191,0.20); --fg-rgb:255,208,191; --crt-line-alpha:0.04; --crt-glow-alpha:0.01; }
.theme-arcticnight { --bg:#07131c; --fg:#d4f1ff; --accent:#7fdcff; --border:#5ea6c7; --muted:rgba(212,241,255,0.20); --fg-rgb:212,241,255; --crt-line-alpha:0.05; --crt-glow-alpha:0.02; }
.theme-mosscharcoal { --bg:#12150f; --fg:#d2dfb8; --accent:#a6d06c; --border:#839c54; --muted:rgba(210,223,184,0.20); --fg-rgb:210,223,184; --crt-line-alpha:0.04; --crt-glow-alpha:0.01; }
.theme-duskteal { --bg:#0a1718; --fg:#b6f2ee; --accent:#63d6cb; --border:#489d95; --muted:rgba(182,242,238,0.20); --fg-rgb:182,242,238; --crt-line-alpha:0.05; --crt-glow-alpha:0.02; }
.theme-crimsonvelvet { --bg:#17080d; --fg:#ffccd7; --accent:#ff6b8d; --border:#c34c69; --muted:rgba(255,204,215,0.20); --fg-rgb:255,204,215; --crt-line-alpha:0.05; --crt-glow-alpha:0.02; }
.theme-violetfog { --bg:#11101b; --fg:#d8d4ff; --accent:#9e92ff; --border:#766ec9; --muted:rgba(216,212,255,0.20); --fg-rgb:216,212,255; --crt-line-alpha:0.04; --crt-glow-alpha:0.01; }
.theme-sandnight { --bg:#19150d; --fg:#f5e3ba; --accent:#d7b56d; --border:#a4884e; --muted:rgba(245,227,186,0.20); --fg-rgb:245,227,186; --crt-line-alpha:0.03; --crt-glow-alpha:0.01; }
.theme-midnightjade { --bg:#061311; --fg:#bff3d8; --accent:#62d3a2; --border:#469876; --muted:rgba(191,243,216,0.20); --fg-rgb:191,243,216; --crt-line-alpha:0.05; --crt-glow-alpha:0.02; }
.theme-nebula { --bg:#0f1020; --fg:#f1d9ff; --accent:#c38cff; --border:#8f67c4; --muted:rgba(241,217,255,0.20); --fg-rgb:241,217,255; --crt-line-alpha:0.05; --crt-glow-alpha:0.02; }
.theme-obsidiangold { --bg:#0f0d08; --fg:#ffe6a8; --accent:#ffc94d; --border:#b38b2f; --muted:rgba(255,230,168,0.20); --fg-rgb:255,230,168; --crt-line-alpha:0.04; --crt-glow-alpha:0.01; }
.theme-inkrose { --bg:#150f14; --fg:#ffd8ea; --accent:#ff91bd; --border:#b86188; --muted:rgba(255,216,234,0.20); --fg-rgb:255,216,234; --crt-line-alpha:0.04; --crt-glow-alpha:0.01; }
.theme-sapphiremist { --bg:#0c1220; --fg:#d7e3ff; --accent:#89a9ff; --border:#6078c0; --muted:rgba(215,227,255,0.20); --fg-rgb:215,227,255; --crt-line-alpha:0.04; --crt-glow-alpha:0.01; }
.theme-pineglow { --bg:#09110c; --fg:#cbf5cf; --accent:#75dd8a; --border:#4f9c60; --muted:rgba(203,245,207,0.20); --fg-rgb:203,245,207; --crt-line-alpha:0.04; --crt-glow-alpha:0.01; }
.crt {
  position: relative;
  z-index: 1;
  overflow: hidden;
}
.crt::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(var(--fg-rgb), var(--crt-line-alpha)) 50%, rgba(var(--fg-rgb), 0) 50%),
    linear-gradient(90deg, rgba(var(--fg-rgb), var(--crt-glow-alpha)), rgba(var(--fg-rgb), var(--crt-glow-alpha)));
  background-size: 100% 2px, 3px 100%;
  pointer-events: none;
  opacity: 0.7;
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  mix-blend-mode: screen;
  z-index: 2;
  background-image: linear-gradient(
    to bottom,
    rgba(var(--fg-rgb),0.0) 0px,
    rgba(var(--fg-rgb),0.0) 6px,
    rgba(var(--fg-rgb),0.25) 8px,
    rgba(var(--fg-rgb),0.12) 30px,
    rgba(var(--fg-rgb),0.04) 44px,
    rgba(var(--fg-rgb),0.0) 48px
  );
  background-size: 100% 48px;
  background-repeat: no-repeat;
  animation:
    glowline-sweep 12.8s linear infinite,
    glowline-flicker 0.18s infinite;
}
body.glowline-off::after {
  display: none;
}
/* OSRS uses textured parchment, not a CRT surface. Its zero scanline theme
   variables do not affect the shared animated body overlay. */
body.theme-osrs::after {
  content: none;
  display: none;
  animation: none;
}
@keyframes glowline-sweep {
  0%   { background-position: 0 -48px; }
  100% { background-position: 0 100%; }
}
@keyframes glowline-flicker {
  0%,100% { opacity: 0.22; }
  50%     { opacity: 0.30; }
}
html.mobile-touch .container {
  grid-template-columns: 1fr;
}
html.mobile-touch .sidebar {
  border-right: none;
  border-bottom: 1px solid var(--border);
}
html.mobile-touch .scroll-list {
  max-height: 40vh;
}
html.mobile-touch .book-scroll-list {
  max-height: 52vh;
}
html.mobile-touch .chapter-sidebar-toggle {
  display: grid;
  top: 0.75rem;
  right: 0.75rem;
}
html.mobile-touch body.chapter-sidebar-collapsed .container {
  grid-template-columns: 1fr;
}
html.mobile-touch body.chapter-sidebar-collapsed .sidebar-shell {
  min-height: 52px;
}
html.mobile-touch body.chapter-sidebar-collapsed .sidebar {
  display: none;
}
@media (max-width: 1100px) {
  body.chapter-sidebar-collapsed .container { grid-template-columns: 1fr; }
  body.chapter-sidebar-collapsed .sidebar-shell { min-height: 52px; }
  body.chapter-sidebar-collapsed .sidebar { display: none; }
  .chapter-sidebar-toggle { top: 0.75rem; right: 0.75rem; }
}
@media (max-width: 1100px) and (hover: none) and (pointer: coarse), (max-width: 1100px) and (any-hover: none) and (any-pointer: coarse) {
  .container { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border); }
  .scroll-list { max-height: 40vh; }
  .book-scroll-list { max-height: 52vh; }
  .chapter-sidebar-toggle { display: grid; }
}

.raw-panel {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  background: rgba(0,0,0,0.72);
  padding: 16px;
  box-sizing: border-box;
}
.raw-panel.open { display: grid; place-items: center; }
.raw-panel-box {
  width: min(920px, 100%);
  max-height: min(760px, calc(100vh - 32px));
  overflow: auto;
  border: 2px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  padding: 1rem;
  display: grid;
  gap: 0.75rem;
}
.raw-panel-head, .raw-actions { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; }
.raw-panel label { display: grid; gap: 0.35rem; font-size: 0.7rem; }
.raw-panel input, .raw-panel select { background: var(--bg); border: 2px solid var(--border); color: var(--fg); padding: 0.5rem; font: inherit; }
.raw-status { border: 1px dashed var(--muted); padding: 0.55rem; min-height: 2rem; line-height: 1.5; }
.raw-preview-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.raw-preview-grid h3 { font-size: 0.7rem; margin: 0 0 0.45rem; }
.raw-panel pre { white-space: pre-wrap; word-break: break-word; border: 1px dashed var(--muted); padding: 0.65rem; max-height: 260px; overflow: auto; font-family: monospace; font-size: 0.8rem; line-height: 1.5; }
@media (max-width: 720px) { .raw-preview-grid { grid-template-columns: 1fr; } }

.bubble-row { display: flex; gap: 8px; align-items: center; }
.ai-panel {
  position: fixed;
  inset: 0;
  z-index: 31;
  display: none;
  background: rgba(0,0,0,0.72);
  padding: 16px;
  box-sizing: border-box;
}
.ai-panel.open { display: grid; place-items: center; }
.ai-panel-box {
  width: min(760px, 100%);
  max-height: min(720px, calc(100vh - 32px));
  overflow: auto;
  border: 2px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  padding: 1rem;
  display: grid;
  gap: 0.75rem;
}
.ai-panel-head, .ai-actions { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.ai-question { width: 100%; box-sizing: border-box; background: var(--bg); border: 2px solid var(--border); color: var(--fg); padding: 0.65rem; font: inherit; line-height: 1.5; }
.ai-status { border: 1px dashed var(--muted); padding: 0.55rem; min-height: 2rem; line-height: 1.5; }
.ai-answer { white-space: pre-wrap; word-break: break-word; border: 1px dashed var(--muted); padding: 0.75rem; max-height: 380px; overflow: auto; font-family: monospace; font-size: 0.85rem; line-height: 1.55; }


.bubble-row-wide {
  align-items: center;
}

.theme-dot.small.ai-source-btn,
.theme-dot.small.raw-source-btn {
  border: 2px solid var(--border);
  box-shadow: 0 0 0 1px rgba(var(--fg-rgb), 0.22), 0 0 12px rgba(var(--fg-rgb), 0.12);
}

.theme-dot.small.ai-source-btn,
.theme-dot.small.raw-source-btn {
  color: var(--fg);
  font-size: 9px;
  line-height: 1;
  font-family: 'Press Start 2P', monospace;
  text-align: center;
}
.theme-dot.small.raw-source-btn {
  font-size: 7px;
}
.theme-dot.small.ai-source-btn:hover,
.theme-dot.small.raw-source-btn:hover {
  background: var(--fg);
  color: var(--bg);
}
/* Reliable isolated reader-tools states. */
.reader-tools-status {
  margin-top: 0.45rem;
  max-width: min(92vw, 680px);
  border: 1px dashed var(--muted);
  background: var(--bg);
  color: var(--fg);
  padding: 0.45rem 0.6rem;
  font-size: 0.65rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.reader-tools-status:empty { display: none; }
.reader-tools-status[data-state="working"],
.reader-tools-status[data-state="queued"] { color: var(--accent); }
.reader-tools-status[data-state="error"],
.reader-tools-status[data-state="retryable-error"] { color: var(--danger, var(--accent)); }
.reader-translation-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 0;
  font: inherit;
  line-height: inherit;
}
.translation-confirm-panel,
.raw-panel,
.ai-panel {
  padding:
    max(16px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
}

.translation-confirm-panel {
  position: fixed;
  inset: 0;
  z-index: 32;
  display: none;
  place-items: center;
  background: rgba(0, 0, 0, .76);
}
.translation-confirm-panel.open { display: grid; }
.translation-confirm-box {
  box-sizing: border-box;
  width: min(36rem, 100%);
  max-height: calc(100dvh - 32px);
  overflow: auto;
  border: 2px solid var(--reader-component-border, var(--border));
  background: var(--reader-component-surface, var(--bg));
  color: var(--reader-component-text, var(--fg));
  padding: 1rem;
}
.translation-confirm-box dl {
  display: grid;
  grid-template-columns: minmax(10rem, auto) 1fr;
  gap: .45rem .8rem;
}
.translation-confirm-box dt { font-weight: bold; }
.translation-confirm-box dd { margin: 0; overflow-wrap: anywhere; }
.translation-confirm-actions { display: flex; gap: .65rem; flex-wrap: wrap; }
.translation-confirm-status { min-height: 1.5em; margin-block: .65rem; }
@media (max-width: 420px) {
  .translation-confirm-box dl { grid-template-columns: 1fr; }
}
/* UI/PWA repair: readable, non-intercepting floating navigation surfaces. */
.theme-switcher {
  z-index: 70;
}
.floating-reader-controls {
  z-index: 69;
}
.theme-options {
  visibility: hidden;
  box-sizing: border-box;
  min-height: 44px;
  color: var(--reader-component-text);
  background: var(--reader-component-surface);
  border: 1px solid var(--reader-component-border);
  box-shadow: 0 4px 18px rgba(0, 0, 0, .48);
}
.theme-switcher.open .theme-options {
  visibility: visible;
}
.theme-switcher:not(.open) .theme-options,
.theme-switcher.hidden .theme-options {
  pointer-events: none;
}
.floating-reader-controls .tts-widget {
  color: var(--reader-component-text);
  background: var(--reader-component-surface);
  border-color: var(--reader-component-border);
}
.reader-service-button.theme-dot.small,
.theme-dot.small.theme-effect-toggle {
  min-width: 44px;
  min-height: 44px;
  color: var(--reader-component-text);
  background-color: var(--reader-component-surface);
  border-color: var(--reader-component-border);
}
.bubble-row-wide {
  flex-wrap: wrap;
  max-width: min(36rem, calc(100vw - 28px));
}

/* Reader-menu component geometry is shared and deliberately stronger than
   historical theme-wide button shapes. Themes still own paint through the
   semantic variables and their color, border, texture, and shadow rules. */
.floating-reader-controls .reader-menu-action-grid {
  box-sizing: border-box;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
  gap: .5rem;
  width: min(24rem, calc(100vw - 28px));
  max-width: 100%;
}
.floating-reader-controls .reader-menu-action,
.floating-reader-controls .tts-job-actions > button {
  box-sizing: border-box !important;
  inline-size: 100% !important;
  min-inline-size: 0 !important;
  max-inline-size: 100% !important;
  block-size: auto !important;
  min-block-size: 44px !important;
  padding: .45rem .65rem !important;
  overflow: hidden !important;
  border-radius: var(--reader-menu-action-radius, 4px) !important;
  line-height: 1.25 !important;
  white-space: normal !important;
  overflow-wrap: anywhere;
  text-align: center;
}
.floating-reader-controls .reader-menu-action-grid > .reader-menu-action,
.floating-reader-controls .tts-job-actions > button {
  grid-row: auto !important;
  grid-column: auto !important;
}
.floating-reader-controls .tts-job-actions {
  box-sizing: border-box;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
  gap: .5rem;
  width: min(24rem, calc(100vw - 28px));
  max-width: 100%;
}
.theme-switcher:not(.open) + .floating-reader-controls .reader-menu-action-grid,
.theme-switcher.hidden + .floating-reader-controls .reader-menu-action-grid,
.floating-reader-controls [hidden],
.floating-reader-controls [aria-hidden="true"] {
  pointer-events: none !important;
}
@media (max-width: 915px) {
  .theme-options {
    max-height: min(42dvh, 19rem);
  }
  .floating-reader-controls {
    max-width: calc(100vw - max(20px, env(safe-area-inset-left) + env(safe-area-inset-right)));
  }
  .reader-service-button.theme-dot.small,
  .theme-dot.small.theme-effect-toggle {
    font-size: .62rem;
    line-height: 1.25;
  }
  .floating-reader-controls .reader-menu-action-grid,
  .floating-reader-controls .tts-job-actions {
    width: min(22rem, calc(100vw - 20px));
  }
}

/* Automatic restrained wide-screen layout; existing <= 2048px geometry is unchanged. */
@media (min-width: 2200px) {
  body[class*="theme-"] #screen {
    box-sizing: border-box;
    width: min(144rem, calc(100vw - 4rem));
    max-width: 144rem;
    margin-inline: auto;
  }
  body .container.reader-layout {
    grid-template-columns: minmax(20rem, 24rem) minmax(0, 1fr);
    width: min(138rem, calc(100vw - 8rem));
    margin-inline: auto;
  }
  body .container.reader-layout > .main {
    min-width: 0;
    padding-inline: clamp(2rem, 4vw, 5rem);
  }
  body .container.reader-layout .reader-header,
  body .container.reader-layout .reader-nav {
    max-width: 70rem;
    margin-inline: auto;
  }
  body .container.reader-layout .reader-content {
    box-sizing: border-box;
    width: min(62rem, 100%);
    max-width: 62rem;
    margin-inline: auto;
  }
  body.theme-osrs .container.reader-layout .reader-content {
    width: min(56.5rem, 100%);
    max-width: 56.5rem;
  }
  body .reader-content > section#activeChapterItem {
    max-width: 90ch;
    margin-inline: auto;
  }
}
@media (min-width: 3200px) {
  body[class*="theme-"] #screen {
    width: min(148rem, calc(100vw - 8rem));
    max-width: 148rem;
  }
  body .container.reader-layout {
    width: min(142rem, calc(100vw - 12rem));
  }
}

/* Expanded Reader menu: shared structure and interaction boundary.
   Theme packages own paint; this layer owns the panel, geometry, and shapes. */
body {
  --reader-menu-panel-surface: var(--reader-component-surface);
  --reader-menu-panel-text: var(--reader-component-text);
  --reader-menu-panel-border: var(--reader-component-border);
  --reader-menu-control-surface: color-mix(
    in srgb,
    var(--reader-component-text) 9%,
    var(--reader-component-surface)
  );
  --reader-menu-grid-gap: .5rem;
  --reader-menu-grid-width: min(24rem, calc(100vw - 28px));
  --reader-menu-action-cell-width: calc(
    (100% - var(--reader-menu-grid-gap)) / 2
  );
}

body:has(.theme-switcher.open) #screen {
  pointer-events: none;
  interactivity: inert;
}

/* Menu controls never inherit theme-wide link or button underlines.  The
   outline remains the accessible focus treatment in every theme. */
/* A closed panel has no painted surface at any viewport width, including
   while the independent launcher is moving. Do not animate hidden paint. */
#themeSwitcher:not(.open) .theme-options,
#themeSwitcher:not(.open) .theme-options *,
#themeSwitcher:not(.open) .theme-options::before,
#themeSwitcher:not(.open) .theme-options::after,
#themeSwitcher:not(.open) .theme-options *::before,
#themeSwitcher:not(.open) .theme-options *::after {
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
  background: transparent !important;
  background-image: none !important;
  border: 0 !important;
  outline: 0 !important;
  box-shadow: none !important;
  filter: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  text-decoration: none !important;
  transition: none !important;
}

#themeSwitcher + [data-reader-floating-controls][aria-hidden="true"],
#themeSwitcher + [data-reader-floating-controls][aria-hidden="true"] *,
#themeSwitcher + [data-reader-floating-controls] .bubble-row[aria-hidden="true"],
#themeSwitcher + [data-reader-floating-controls] .bubble-row[aria-hidden="true"] *,
#themeSwitcher + [data-reader-floating-controls] .bubble-row[aria-hidden="true"]::before,
#themeSwitcher + [data-reader-floating-controls] .bubble-row[aria-hidden="true"]::after,
#themeSwitcher + [data-reader-floating-controls] .bubble-row[aria-hidden="true"] *::before,
#themeSwitcher + [data-reader-floating-controls] .bubble-row[aria-hidden="true"] *::after,
#themeSwitcher + [data-reader-floating-controls][aria-hidden="true"]::before,
#themeSwitcher + [data-reader-floating-controls][aria-hidden="true"]::after,
#themeSwitcher + [data-reader-floating-controls][aria-hidden="true"] *::before,
#themeSwitcher + [data-reader-floating-controls][aria-hidden="true"] *::after {
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
  background: transparent !important;
  background-image: none !important;
  border: 0 !important;
  outline: 0 !important;
  box-shadow: none !important;
  filter: none !important;
  backdrop-filter: none !important;
  text-decoration: none !important;
  transition: none !important;
}

@media (max-width: 915px) {
  /* Reserve the fixed player's clearance once. Opening a menu or speed popup
     must not change document height and make scroll anchoring move the page. */
  body.theme-osrs {
    --osrs-active-clearance: 14.5rem !important;
  }
  body.theme-osrs #screen {
    padding-bottom: calc(var(--osrs-active-clearance) + env(safe-area-inset-bottom)) !important;
  }
}

#themeSwitcher :is(button, a, [role="button"]),
.theme-switcher + .floating-reader-controls :is(button, a, [role="button"]),
#themeSwitcher :is(button, a, [role="button"])::before,
#themeSwitcher :is(button, a, [role="button"])::after,
.theme-switcher + .floating-reader-controls :is(button, a, [role="button"])::before,
.theme-switcher + .floating-reader-controls :is(button, a, [role="button"])::after {
  text-decoration: none !important;
  text-decoration-line: none !important;
  text-decoration-color: transparent !important;
}

#themeSwitcher :is(button, a, [role="button"]):focus-visible,
.theme-switcher + .floating-reader-controls :is(button, a, [role="button"]):focus-visible {
  outline: 3px solid var(--reader-menu-focus, var(--reader-component-text)) !important;
  outline-offset: 2px !important;
}

.theme-switcher.open {
  isolation: isolate;
  z-index: 201;
}

.theme-switcher.open .theme-options {
  color: var(--reader-menu-panel-text);
  background-color: var(--reader-menu-panel-surface) !important;
  border-color: var(--reader-menu-panel-border);
  opacity: 1;
}

.theme-switcher.open + .floating-reader-controls {
  isolation: isolate;
  z-index: 200 !important;
  box-sizing: border-box !important;
  left: max(10px, env(safe-area-inset-left)) !important;
  right: auto !important;
  bottom: calc(70px + env(safe-area-inset-bottom)) !important;
  inline-size: min(
    26rem,
    calc(100vw - max(20px, env(safe-area-inset-left) + env(safe-area-inset-right)))
  ) !important;
  max-inline-size: calc(
    100vw - max(20px, env(safe-area-inset-left) + env(safe-area-inset-right))
  ) !important;
  max-block-size: calc(
    100dvh - 88px - env(safe-area-inset-top) - env(safe-area-inset-bottom)
  ) !important;
  padding: .72rem !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  color: var(--reader-menu-panel-text) !important;
  background-color: var(--reader-menu-panel-surface) !important;
  border: 2px solid var(--reader-menu-panel-border) !important;
  border-radius: 6px !important;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, .82),
    0 12px 32px rgba(0, 0, 0, .72) !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  transform: none !important;
}

.theme-switcher.open + .floating-reader-controls :is(
  .tts-widget,
  .tts-main-row,
  .tts-control-column,
  .reader-menu-action-grid,
  .bubble-row,
  .tts-job-actions,
  .tts-progress-popout,
  .tts-playback-row,
  .reader-service-status,
  .tts-job-error
) {
  box-sizing: border-box;
  min-inline-size: 0;
  max-inline-size: 100%;
}

.theme-switcher.open + .floating-reader-controls .tts-widget,
.theme-switcher.open + .floating-reader-controls .tts-main-row,
.theme-switcher.open + .floating-reader-controls .tts-control-column {
  inline-size: 100% !important;
}

.theme-switcher.open + .floating-reader-controls .tts-control-column {
  align-items: stretch;
}

.theme-switcher.open + .floating-reader-controls .reader-menu-action-grid,
.theme-switcher.open + .floating-reader-controls .tts-job-actions,
.theme-switcher.open + .floating-reader-controls .tts-progress-popout,
.theme-switcher.open + .floating-reader-controls .tts-playback-row,
.theme-switcher.open + .floating-reader-controls .reader-service-status,
.theme-switcher.open + .floating-reader-controls .tts-job-error {
  inline-size: 100% !important;
  max-inline-size: 100% !important;
}

.theme-switcher.open + .floating-reader-controls .bubble-row:not(.bubble-row-wide) {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  inline-size: var(--reader-menu-action-cell-width);
  max-inline-size: 100%;
}

.theme-switcher.open + .floating-reader-controls :is(
  .reader-menu-action,
  .tts-job-actions > button,
  .theme-effect-toggle,
  .tts-jump-btn,
  .tts-speed-trigger,
  .tts-speed-slider-btn,
  .tts-speed-preset,
  .osrs-tts-collapse,
  .reader-service-status,
  .reader-tools-status
) {
  box-sizing: border-box !important;
  min-block-size: 44px !important;
  max-inline-size: 100% !important;
  overflow: hidden !important;
  border-radius: var(--reader-menu-action-radius, 4px) !important;
  white-space: normal !important;
  overflow-wrap: anywhere;
}

.theme-switcher.open + .floating-reader-controls :is(
  .reader-menu-action,
  .tts-job-actions > button,
  .theme-effect-toggle,
  .tts-jump-btn,
  .tts-speed-trigger,
  .tts-speed-slider-btn,
  .tts-speed-preset,
  .osrs-tts-collapse
) {
  color: var(--reader-menu-panel-text) !important;
  background-color: var(--reader-menu-control-surface) !important;
  border-color: var(--reader-menu-panel-border) !important;
  opacity: 1;
  line-height: 1.3 !important;
  text-align: center;
}

.theme-switcher.open + .floating-reader-controls :is(
  .reader-menu-action,
  .tts-job-actions > button,
  .theme-effect-toggle
) {
  inline-size: 100% !important;
  min-inline-size: 0 !important;
  block-size: auto !important;
  padding: .5rem .62rem !important;
  font-size: max(.62rem, 10px) !important;
}

.theme-switcher.open + .floating-reader-controls :is(
  button,
  [role="button"]
):disabled {
  opacity: .62;
}

.theme-switcher.open + .floating-reader-controls .reader-service-status,
.theme-switcher.open + .floating-reader-controls .reader-tools-status {
  display: block;
  margin: 0;
  padding: .5rem .6rem;
  color: var(--reader-menu-panel-text) !important;
  background-color: var(--reader-menu-control-surface) !important;
  border: 1px solid var(--reader-menu-panel-border);
  font-size: max(.58rem, 9px);
  line-height: 1.45;
}

/* Empty Reader-tools live regions carry no state and therefore own no box.
   Meaningful working, queued, offline, unavailable, and error text restores
   the bounded status surface through the rule immediately above. */
.reader-tools-status:empty,
.theme-switcher.open + .floating-reader-controls .reader-tools-status:empty {
  display: none !important;
  min-block-size: 0 !important;
  block-size: 0 !important;
  min-inline-size: 0 !important;
  inline-size: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  background: none !important;
  box-shadow: none !important;
}

.theme-switcher.open + .floating-reader-controls .tts-progress-popout {
  color: var(--reader-menu-panel-text);
  background-color: var(--reader-menu-control-surface);
  border-color: var(--reader-menu-panel-border);
}

.theme-switcher.open + .floating-reader-controls .tts-playback-row {
  display: grid !important;
  grid-template-columns: minmax(44px, 1fr) 52px minmax(44px, 1fr) minmax(84px, 1.35fr);
  align-items: center;
  gap: .5rem;
}

.theme-switcher.open + .floating-reader-controls .tts-playback-row > * {
  min-inline-size: 0;
  margin: 0;
}

.theme-switcher.open + .floating-reader-controls .tts-jump-btn,
.theme-switcher.open + .floating-reader-controls .tts-speed-trigger {
  inline-size: 100% !important;
  min-inline-size: 44px !important;
  block-size: auto !important;
  padding: .45rem !important;
}

.theme-switcher.open + .floating-reader-controls .tts-speed-row {
  display: contents;
}

.theme-switcher.open + .floating-reader-controls .tts-queue-btn {
  box-sizing: border-box;
  inline-size: 52px !important;
  block-size: 52px !important;
  min-inline-size: 52px !important;
  max-inline-size: 52px !important;
  min-block-size: 52px !important;
  max-block-size: 52px !important;
  aspect-ratio: 1;
  place-self: center;
  flex: none;
  border-radius: 50% !important;
}

.theme-switcher.open + .floating-reader-controls [hidden],
.theme-switcher.open + .floating-reader-controls [aria-hidden="true"] {
  pointer-events: none !important;
}

@media (max-width: 915px) {
  body {
    --reader-menu-grid-width: min(22rem, calc(100vw - 20px));
  }
  .theme-switcher.open + .floating-reader-controls {
    inline-size: calc(
      100vw - max(20px, env(safe-area-inset-left) + env(safe-area-inset-right))
    ) !important;
    padding: .6rem !important;
  }
  .theme-switcher.open + .floating-reader-controls .reader-menu-action-grid,
  .theme-switcher.open + .floating-reader-controls .tts-job-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .theme-switcher.open + .floating-reader-controls .tts-speed-trigger-label {
    display: none;
  }
}

.theme-switcher.open + .floating-reader-controls .tts-job-actions {
  display: grid !important;
}

/* The OSRS desktop frame keeps its native proportions, including on ultrawide screens.
   The existing mobile theme ends at 915px and is intentionally unchanged. */
@media (min-width: 916px) {
  body.theme-osrs #screen {
    width: min(56.875rem, 100%);
    max-width: 56.875rem;
  }
  body.theme-osrs #screen > :is(.application-header, .reader-masthead) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    grid-template-rows: 8.5625rem;
    align-items: center;
    width: calc(100% - 7.5rem);
    min-height: 0;
    margin-inline: auto;
    padding: 0;
    gap: 0;
  }
  body.theme-osrs #screen > :is(.application-header, .reader-masthead) > h1 {
    grid-area: 1 / 2;
    flex: none;
    align-self: center;
    justify-self: center;
    width: max-content;
    max-width: none;
    height: auto;
    margin: 0;
    padding: .2rem .65rem;
    font-size: 1.35rem;
    line-height: 1.1;
    overflow-wrap: normal;
    white-space: nowrap;
  }
  body.theme-osrs #screen > :is(.application-header, .reader-masthead) > h1 > a {
    color: #fff;
  }
  body.theme-osrs #screen > .application-header > form {
    grid-area: 1 / 3;
    align-self: end;
    justify-self: end;
    margin: 0 0 .25rem;
  }
  body.theme-osrs #screen > .application-header > form > button {
    min-height: 40px;
    padding-inline: .9rem;
    font: 14px/1.2 var(--osrs-control-font);
  }
  body.theme-osrs #screen.reader-unified .container.reader-layout {
    width: 100%;
    max-width: 100%;
    margin-inline: 0;
  }
}
@media (min-width: 2200px) {
  body.theme-osrs #screen.reader-unified .container.reader-layout > .main {
    padding-inline: 1rem;
  }
}
