/* Reset */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Theme Variables */
:root[data-theme="light"],
:root {
  --bg-primary: #ffffff;
  --bg-overlay: rgba(255, 255, 255, 0.9);
  --text-primary: rgba(32, 32, 32, 0.8);
  --text-secondary: rgba(32, 32, 32, 0.7);
  --text-muted: #848484;
  --icon-fill: rgba(32, 32, 32, 0.7);
  --border-color: #dedede;
  --progress-bg: rgba(32, 32, 32, 0.2);
  --progress-fill: #646464;
  --accent-primary: #6dab3c;

  /* Text sizes - shared across all themes (inherited by dark/sepia) */
  --text-xs: 0.688rem; /* 11px */
  --text-sm: 0.813rem; /* 13px */
  --text-md: 0.875rem; /* 14px */
  --text-lg: 0.938rem; /* 15px */
  --text-xl: 1.75rem; /* 28px */

  /* Control colors */
  --control-selected-bg: var(--bg-primary);
  --control-unselected-bg: rgb(240, 240, 240);
  /* is-selected チップ（アイコントグル）。明るいボトムバー上で見える */
  --control-active-bg: rgba(32, 32, 32, 0.10);
}

:root[data-theme="dark"] {
  --bg-primary: #000000;
  --bg-overlay: rgba(0, 0, 0, 0.9);
  --text-primary: rgba(255, 255, 255, 0.8);
  --text-secondary: rgba(255, 255, 255, 0.7);
  --text-muted: #848484;
  --icon-fill: rgba(255, 255, 255, 0.7);
  --border-color: #333333;
  --progress-bg: rgba(255, 255, 255, 0.5);
  --progress-fill: #eaeaea;

  /* Control colors */
  --control-selected-bg: rgba(255, 255, 255, 0.20);
  --control-unselected-bg: #1a1a1a;
  /* is-selected チップ（アイコントグル）。暗いボトムバー上で見える */
  --control-active-bg: rgba(255, 255, 255, 0.20);

  /* Page theme colors - inherited from JS injection */
}

/* Base */
html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-size: 16px;
}

body {
  font-family: "Hiragino Kaku Gothic ProN", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  touch-action: manipulation;
}

/* Reader root */
#reader-root {
  width: 100dvw;
  height: 100dvh;
  position: relative;
}

#reader-content {
  position: relative;
  height: 100%;
  cursor: default;
}

.reader-html-book {
  cursor: default;
}

.reader-html-book a[href],
.reader-html-book a[data-reader-href] {
  cursor: pointer;
}

.hide-furigana rt {
  visibility: hidden;
}


/* TopBar Container */
/* アプリ（viewport-fit=cover）ではノッチとホームインジケーターを避ける。web では env() が 0。 */
.reader-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: calc(48px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  z-index: 10;
  display: flex;
  transform: translateY(-100%);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.reader-topbar.visible {
  transform: translateY(0);
  opacity: 1;
}

.reader-topbar-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  height: 100%;
  padding: 0 16px;
}

/* Button utilities */
.btn-icon {
  flex-shrink: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--icon-fill);
  transition: opacity 0.2s;
  background: none;
  border: none;
  padding: 0;
}

@media (hover: hover) {
  .btn-icon:hover {
    opacity: 0.7;
  }
}

.btn-icon svg {
  width: 100%;
  height: 100%;
}

.btn-icon.disabled,
.btn-icon:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-icon--sm {
  width: 24px;
  height: 24px;
}

/* 選択可能なボトムバーのアイコントグル（表示モード・読み上げ）。同じパディングチップを
   共有し、is-selected の背景位置を揃える。 */
#reader-btn-reading-mode,
#reader-btn-read-aloud {
  padding: 5px;
  border-radius: 8px;
  transition: background 0.15s;
}

.btn-icon.is-selected {
  background: var(--control-active-bg);
  border-radius: 8px;
}

/* === TTS read-aloud === */

/* Spoken-node highlight */
.tts-active {
  background-color: rgba(247, 185, 15, 0.28) !important;
  border-radius: 4px;
}

/* Transport buttons expand the existing bottom bar as its top row, but ONLY
   while read-aloud is active. The page indicator + reading-progress bar below
   are left untouched. (Explicit [hidden] rule beats the display:flex below.) */
.reader-tts-controls {
  display: flex;
  flex-direction: column;
}

.reader-tts-controls[hidden] {
  display: none;
}

.reader-tts-transport {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  position: relative;
}

.reader-tts-more {
  width: 24px;
  height: 24px;
  position: absolute;
  right: 0;
}

/* TTS settings popover (voice / speed), anchored above the "…" button. Follows
   the app chrome (UI) theme — not the page/reading theme. */
.tts-menu[hidden] {
  display: none;
}

.tts-menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
}

.tts-menu-panel {
  position: fixed;
  z-index: 61;
  min-width: 260px;
  max-width: min(360px, calc(100vw - 16px));
  max-height: 60vh;
  overflow-y: auto;
  background: var(--bg-overlay);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.25);
  padding: 0 0 4px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  -webkit-overflow-scrolling: touch;
}

.tts-menu-row,
.tts-menu-option-select {
  display: flex;
  align-items: center;
  width: 100%;
  background: none;
  border: none;
  color: inherit;
  font: inherit;
  text-align: left;
  padding: 14px 18px;
  cursor: pointer;
}

.tts-menu-row {
  justify-content: space-between;
  gap: 16px;
}

.tts-menu-row:not(:last-child) {
  border-bottom: 1px solid var(--border-color);
}

.tts-menu-row:active,
.tts-menu-option-select:active {
  background: var(--control-active-bg);
}

.tts-menu-row-label {
  font-size: var(--text-base, 16px);
}

.tts-menu-row-value {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-secondary);
}

.tts-menu-chevron {
  width: 16px;
  height: 16px;
  flex: none;
}

.tts-menu-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  background: var(--bg-primary);
  z-index: 1;
}

.tts-menu-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
}

.tts-menu-back-icon {
  width: 18px;
  height: 18px;
}

.tts-menu-title {
  font-size: var(--text-base, 16px);
  font-weight: 600;
}

.tts-menu-option {
  display: flex;
  align-items: center;
}

.tts-menu-option-select {
  flex: 1;
  gap: 10px;
}

.tts-menu-option-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex: none;
}

.tts-menu-option-check svg {
  width: 18px;
  height: 18px;
}

.tts-menu-option.is-selected .tts-menu-option-label {
  font-weight: 600;
}

.tts-menu-option-play {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 44px;
  height: 44px;
  margin-right: 6px;
  padding: 0;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
}

.tts-menu-option-play svg {
  width: 28px;
  height: 28px;
}

/* TTS playback status toast (再生中 / 停止 …) */
.tts-status-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 10px 22px;
  width: max-content;
  max-width: calc(100vw - 24px);
  border-radius: 18px;
  line-height: 1.4;
  background-color: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-align: center;
  overflow-wrap: anywhere;
  pointer-events: none;
  opacity: 0;
  z-index: 9997;
}

.tts-status-toast.active {
  animation: tts-status-toast-fade 1.4s ease both;
}

@keyframes tts-status-toast-fade {
  0% { opacity: 0; }
  12% { opacity: 1; }
  72% { opacity: 1; }
  100% { opacity: 0; }
}

/* BottomBar Container */
.reader-bottombar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-primary);
  border-top: 1px solid var(--border-color);
  z-index: 10;
  display: flex;
  flex-direction: column;
  padding: 8px calc(16px + env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
  gap: 6px;
  transform: translateY(100%);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.reader-bottombar.visible {
  transform: translateY(0);
  opacity: 1;
}

/* Page indicator */
.reader-page-indicator {
  display: flex;
  gap: 8px;
  z-index: 1;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 34px;
}

.reader-page-indicator p {
  line-height: 1.3;
  min-height: 1.3em;
  margin: 0;
  white-space: nowrap;
}
#reader-page-section {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
#reader-page-numbers {
  flex: none;
}

/* Progress bar */
.reader-progressbar-container {
  width: 100%;
  height: 13px;
  position: relative;
  cursor: pointer;
  z-index: 1;
  touch-action: none;
}

.reader-progressbar-track {
  width: 100%;
  height: 3px;
  background: var(--progress-bg);
  border-radius: 1.5px;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}

.reader-progressbar-fill {
  height: 100%;
  background: var(--progress-fill);
  border-radius: 1.5px;
  position: absolute;
  top: 0;
  transition: width 0.15s ease;
}

.reader-bottombar:not(.visible) .reader-progressbar-fill,
.reader-bottombar:not(.visible) .reader-progressbar-thumb,
.reader-progressbar-container.dragging .reader-progressbar-fill,
.reader-progressbar-container.dragging .reader-progressbar-thumb {
  transition: none;
}

.reader-progressbar-fill[data-direction="horizontal"] {
  left: 0;
  right: auto;
}

.reader-progressbar-fill[data-direction="vertical"] {
  right: 0;
  left: auto;
}

.reader-progressbar-thumb {
  width: 13px;
  height: 13px;
  background: var(--progress-fill);
  border-radius: 50%;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  transition: left 0.15s ease;
}

.reader-progressbar-thumb[data-direction="horizontal"] {
  left: 0;
}

.reader-progressbar-thumb[data-direction="vertical"] {
  right: 0;
  left: auto;
  transform: translate(50%, -50%);
}

/* Utility classes */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.self-stretch { align-self: stretch; }

/* Gap utilities */
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }

/* Padding utilities */
.p-2 { padding: 8px; }
.p-4 { padding: 16px; }

/* Text utilities */
.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-md { font-size: var(--text-md); }
.text-lg { font-size: var(--text-lg); }
.text-xl { font-size: var(--text-xl); }

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }

.font-light { font-weight: 300; }
.font-semibold { font-weight: 600; }

/* Spacing utilities */
.mt-1 { margin-top: 4px; }

/* Layout utilities */
.flex-1 { flex: 1; }

/* Padding utilities - horizontal/vertical */
.px-2 { padding-left: 8px; padding-right: 8px; }

/* Min-width utilities */
.min-w-0 { min-width: 0; }

/* Settings Panel */
.reader-settings-panel {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: var(--bg-primary);
  z-index: 100;
  display: none;
  flex-direction: column;
}

.reader-settings-panel.visible {
  display: flex;
  animation: slideUp 0.3s ease;
}

/* Preview Zone */
.reader-settings-preview {
  position: relative;
  height: 25dvh;
  min-height: 120px;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  max-width: 100%;
  max-height: 100%;
}

.reader-settings-preview-content {
  max-height: 100%;
  overflow: hidden;
  padding: 16px;
}

.reader-settings-preview-label {
  position: absolute;
  bottom: 8px;
  right: 12px;
}

/* Content Zone */
.reader-settings-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  border-top: 1px solid var(--border-color);
  overflow: hidden;
}

/* Settings Header */
.reader-settings-header {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  position: relative;
  padding: 0 16px;
}

.reader-settings-back-btn {
  position: absolute;
  left: 16px;
}

/* Global scrollbar styling - theme aware */
.reader-scrollbar {
  scrollbar-width: thin;
  scrollbar-color: var(--text-muted) transparent;
}

.reader-scrollbar::-webkit-scrollbar {
  width: 8px;
}

.reader-scrollbar::-webkit-scrollbar-track {
  background: transparent;
}

.reader-scrollbar::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 4px;
}

.reader-scrollbar::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* Settings Form */
.reader-settings-form {
  flex: 1;
  overflow-y: auto;
}

.reader-settings-form-inner {
  max-width: 700px;
  margin: 0 auto;
  padding: 0 16px;
}

.reader-settings-row {
  padding: 18px 0;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Base control component - shared by segmented, theme, and font controls */
.reader-control {
  flex: 1;
  border: 1px solid var(--border-color);
  background: var(--control-unselected-bg);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.reader-control:first-child {
  border-radius: 4px 0 0 4px;
}

.reader-control:last-child {
  border-radius: 0 4px 4px 0;
}

.reader-control.active {
  background: var(--control-selected-bg);
  color: var(--text-primary);
}

/* Control group container - consolidated base styles */
.reader-control-group {
  display: flex;
  width: 100%;
}

.reader-control-group.is-disabled {
  opacity: 0.5;
}

.reader-control-group.is-disabled .reader-control {
  cursor: not-allowed;
}

.reader-settings-slider-input {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.reader-settings-slider-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-primary);
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.reader-settings-slider-input::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-primary);
  cursor: pointer;
  border: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}



/* Font Grid */
.reader-settings-font-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}

.reader-settings-font-grid.is-disabled {
  opacity: 0.5;
}

.reader-settings-font-grid.is-disabled .reader-control {
  cursor: not-allowed;
}

/* Settings Footer */
.reader-settings-footer {
  padding: 16px;
  max-width: 700px;
  width: 100%;
  margin: 0 auto;
  flex-shrink: 0;
  display: flex;
  gap: 12px;
}

.reader-settings-reset-btn {
  flex: 1;
  padding: 14px 24px;
  background: transparent;
  color: var(--text-primary);
  border: 0;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

@media (hover: hover) {
  .reader-settings-reset-btn:hover {
    opacity: 0.7;
  }
}

.reader-settings-save-btn {
  flex: 1;
  padding: 14px 24px;
  background: var(--text-primary);
  color: var(--bg-primary);
  border: none;
  border-radius: 100px;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

@media (hover: hover) {
  .reader-settings-save-btn:hover {
    opacity: 0.85;
  }
}

/* Desktop */
@media (min-width: 768px) {
  .reader-settings-panel.visible {
    animation: fadeIn 0.3s ease;
  }
}

/* Animations */
@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes reader-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Loader Spinner */
.loading-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--text-muted);
  border-top-color: var(--text-primary);
  border-radius: 50%;
  margin: 0 auto 12px;
  animation: reader-spin 1s linear infinite;
}

/* Loader Card */
.loading-card {
  padding-top: 23px !important; padding-right: 32px !important; padding-bottom: 23px !important; padding-left: 32px !important;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  text-align: center;
}

/* Image Zoom Modal */
.image-zoom-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: rgba(0, 0, 0, 0.95);
  align-items: center;
  justify-content: center;
}

.image-zoom-modal--visible {
  display: flex;
}

.image-zoom-modal__stage {
  position: absolute;
  inset: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow: hidden;
}

.image-zoom-modal__img {
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

.image-zoom-modal__close {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top));
  right: calc(16px + env(safe-area-inset-right));
  z-index: 1;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (hover: hover) {
  .image-zoom-modal__close:hover {
    background: rgba(255, 255, 255, 0.25);
  }
}

/* Loader Overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-overlay.active {
  display: flex;
}

/* TOC Sidebar Overlay */
.reader-toc-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0);
  z-index: 40;
  pointer-events: none;
  opacity: 0;
  transition: background 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.reader-toc-overlay.visible {
  background: rgba(0, 0, 0, 0.5);
  pointer-events: auto;
  opacity: 1;
}

/* TOC Sidebar */
.reader-toc-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 343px;
  max-width: 85vw;
  height: 100%;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: var(--bg-primary);
  z-index: 50;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.reader-toc-sidebar.visible {
  transform: translateX(0);
}

/* TOC Header */
.reader-toc-header {
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  background: var(--bg-overlay);
}

.reader-toc-header-spacer {
  width: 24px;
  height: 24px;
  opacity: 0;
  flex-shrink: 0;
}

#reader-toc-book-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  line-height: 1.4;
}

#reader-toc-author-name {
  font-size: var(--text-xs);
  font-weight: 300;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  line-height: 1.4;
}

.reader-toc-close-btn {
  flex-shrink: 0;
}

/* TOC List */
.reader-toc-list {
  overflow-y: auto;
  padding: 8px 16px;
}

/* TOC Entry */
.reader-toc-entry {
  padding: 12px;
  padding-left: calc(12px + min(var(--toc-depth, 0), 4) * 1em);
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  margin-bottom: 4px;
}

@media (hover: hover) {
  .reader-toc-entry:hover {
    background-color: var(--control-unselected-bg);
  }
}

.reader-toc-entry.active {
  background-color: var(--control-unselected-bg);
}

.reader-toc-entry.heading {
  cursor: default;
  background-color: transparent;
}

.reader-toc-entry-title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.reader-toc-entry-title.has-ruby {
  line-height: 1.8;
  padding-top: 0.4em;
}

.reader-toc-entry-title ruby {
  ruby-position: over;
}

.reader-toc-entry-pages {
  font-size: var(--text-xs);
  font-weight: 300;
  color: var(--text-secondary);
  line-height: 1.4;
}

.reader-progressbar-return-marker {
  width: 6px;
  height: 6px;
  background: var(--progress-fill);
  border-radius: 50%;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.reader-progressbar-return-marker[hidden] {
  display: none;
}

.reader-progressbar-return-marker[data-direction="vertical"] {
  transform: translate(50%, -50%);
}

/* HTML page turns: capture only the clipped reading surface. */
:root.reader-html-turn::view-transition {
  pointer-events: none;
}

:root.reader-html-turn::view-transition-group(reader-page) {
  animation: none;
  overflow: hidden;
}

:root.reader-html-turn::view-transition-image-pair(reader-page) {
  isolation: isolate;
}

:root.reader-html-turn::view-transition-old(reader-page),
:root.reader-html-turn::view-transition-new(reader-page) {
  width: 100%;
  height: 100%;
  mix-blend-mode: normal;
  --reader-turn-offset: 100%;
  animation-duration: 160ms;
  animation-timing-function: cubic-bezier(0.33, 1, 0.68, 1);
  animation-fill-mode: both;
}

:root.reader-html-turn[data-reader-turn-direction="backward"]::view-transition-old(reader-page),
:root.reader-html-turn[data-reader-turn-direction="backward"]::view-transition-new(reader-page) {
  --reader-turn-offset: -100%;
}

:root.reader-html-turn::view-transition-old(reader-page) {
  animation-name: reader-page-out;
}

:root.reader-html-turn::view-transition-new(reader-page) {
  animation-name: reader-page-in;
}

@keyframes reader-page-out {
  from { transform: translateX(0); }
  to { transform: translateX(calc(-1 * var(--reader-turn-offset))); }
}

@keyframes reader-page-in {
  from { transform: translateX(var(--reader-turn-offset)); }
  to { transform: translateX(0); }
}
