/* ============================================================
   SHELL DU LECTEUR
   ============================================================ */
.reader-shell {
  flex: 1 0 auto;
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(18rem, 24rem);
  align-items: start;
  gap: clamp(0.9rem, 1.6vw, 1.4rem);
  width: 100%;
  min-height: 0;
  min-width: 0;
  padding: 0.65rem clamp(0.8rem, 1.8vw, 1.6rem) 0.75rem;
  /* Pas de zoom au double-tap dans le lecteur (la carte des chemins garde son
     propre touch-action). Le pinch-zoom et le défilement restent possibles. */
  touch-action: manipulation;
}

.reader-panel {
  display: grid;
  grid-template-rows: auto auto;
  min-height: 0;
  min-width: 0;
}

.reader-heading {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.78rem;
  width: min(100%, 74rem);
  margin: 0 auto 0.55rem;
}

.reader-brand {
  flex: 0 0 auto;
}

.reader-chapter-jump {
  flex: 1 1 23rem;
  max-width: min(38rem, 100%);
}

.reader-title-block {
  display: flex;
  align-items: baseline;
  gap: 0.34rem;
  min-width: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
  letter-spacing: 0.01em;
  line-height: 1.1;
}

.reader-title-block::before {
  content: "/";
  color: rgba(244, 240, 232, 0.32);
}

.reader-title-block #page-title {
  color: inherit;
  font: inherit;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================
   CONTROLES DU LECTEUR - CONTENEUR
   ============================================================ */
.reader-controls {
  position: sticky;
  top: 0.8rem;
  display: grid;
  gap: 0.72rem;
  min-width: 0;
}

.control-card,
.route-follow-panel {
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
}

.control-card {
  display: grid;
  gap: 0.7rem;
  padding: 0.76rem;
}

/* ============================================================
   CARTE DU MODE DE LECTURE (omniscient / personnage)
   ============================================================ */
.reading-mode-card {
  position: fixed;
  left: max(clamp(0.75rem, 2vw, 1.25rem), env(safe-area-inset-left));
  bottom: max(clamp(0.75rem, 2vw, 1.25rem), env(safe-area-inset-bottom));
  z-index: 45;
  width: min(15.5rem, calc(100vw - 1.5rem));
  gap: 0.32rem;
  border: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.reading-mode-kicker {
  display: none;
}

.reading-mode-switch {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.56rem;
  width: 100%;
  min-height: 3.06rem;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.5rem 0.62rem;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), transparent),
    rgba(16, 20, 26, 0.94);
  cursor: pointer;
  overflow: visible;
  text-align: left;
  box-shadow: 0 0.9rem 2rem rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

body[data-reader-character] .reading-mode-switch {
  padding-right: 3.15rem;
}

body[data-reader-character] .reading-mode-switch::after {
  content: "";
  position: absolute;
  right: -0.36rem;
  bottom: -0.6rem;
  width: 3.25rem;
  aspect-ratio: 1;
  background: var(--reader-prop-image) center / contain no-repeat;
  filter:
    drop-shadow(0 0.55rem 0.72rem rgba(0, 0, 0, 0.48))
    drop-shadow(0 0 0.35rem rgba(var(--character-accent-rgb), 0.2));
  pointer-events: none;
  transform: rotate(var(--reader-prop-rotate, 0deg)) scale(var(--reader-prop-scale, 1));
  transform-origin: 50% 55%;
}

.reading-mode-switch:focus-visible {
  border-color: rgba(226, 180, 93, 0.75);
  outline: none;
}

@media (hover: hover) {
  .reading-mode-switch:hover {
    border-color: rgba(226, 180, 93, 0.75);
  }
}

.reading-mode-switch-copy {
  display: grid;
  gap: 0.12rem;
  min-width: 0;
}

.reading-mode-switch-copy span:first-child {
  overflow: hidden;
  font-size: 0.82rem;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reading-mode-switch-copy span:last-child {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reading-mode-visual {
  position: relative;
  display: grid;
  place-items: center;
  width: 1.9rem;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid rgba(226, 180, 93, 0.5);
  border-radius: 8px;
  color: var(--accent-strong);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.09), transparent 48%),
    rgba(226, 180, 93, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.reading-mode-visual[data-variant="omniscient"]::before {
  content: "";
  width: 1.32rem;
  aspect-ratio: 1;
  background: currentColor;
  -webkit-mask: var(--icon-eye) center / contain no-repeat;
  mask: var(--icon-eye) center / contain no-repeat;
}

.reading-mode-visual[data-variant="omniscient"]::after {
  display: none;
}

.reading-mode-visual[data-variant="character"] {
  border-radius: 999px;
}

.reading-mode-visual img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--avatar-position, 50% 28%);
  transform: scale(var(--avatar-zoom, 1));
  transform-origin: var(--avatar-origin, 50% 28%);
}

.side-panel[hidden] {
  display: none;
}

/* ============================================================
   SELECTEUR DE CHAPITRE
   ============================================================ */
.chapter-jump {
  position: relative;
  display: grid;
  gap: 0.26rem;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.chapter-select-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  min-width: min(22rem, 100%);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.54rem 0.64rem;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), transparent),
    rgba(16, 20, 26, 0.94);
  cursor: pointer;
  letter-spacing: 0;
  outline: none;
  text-align: left;
  text-transform: none;
  box-shadow: 0 0.9rem 2rem rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.chapter-select-button:focus-visible,
.chapter-jump[data-open] .chapter-select-button {
  border-color: rgba(226, 180, 93, 0.75);
}

@media (hover: hover) {
  .chapter-select-button:hover {
    border-color: rgba(226, 180, 93, 0.75);
  }
}

.chapter-select-button span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chapter-select-icon {
  display: grid;
  place-items: center;
  width: 1.25rem;
  aspect-ratio: 1;
  border: 1px solid rgba(226, 180, 93, 0.34);
  border-radius: 6px;
  color: var(--accent-strong);
  background: rgba(226, 180, 93, 0.08);
  font-size: 0.9rem;
  line-height: 1;
  transition: transform 160ms ease;
}

.chapter-jump[data-open] .chapter-select-icon {
  transform: rotate(180deg);
}

.chapter-select-menu {
  position: absolute;
  top: calc(100% + 0.42rem);
  left: 0;
  right: 0;
  z-index: 20;
  display: grid;
  gap: 0.24rem;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.32rem;
  background: rgba(12, 15, 19, 0.98);
  box-shadow: 0 1.2rem 2.4rem rgba(0, 0, 0, 0.42);
}

.chapter-select-menu[hidden] {
  display: none;
}

.chapter-option {
  display: grid;
  grid-template-columns: 1.2rem minmax(0, 1fr);
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 0.58rem 0.62rem;
  color: var(--muted-strong);
  background: transparent;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 750;
  letter-spacing: 0;
  line-height: 1.15;
  text-align: left;
  text-transform: none;
}

.chapter-option:focus-visible {
  border-color: rgba(226, 180, 93, 0.4);
  background: rgba(226, 180, 93, 0.1);
  color: var(--text);
  outline: none;
}

@media (hover: hover) {
  .chapter-option:hover {
    border-color: rgba(226, 180, 93, 0.4);
    background: rgba(226, 180, 93, 0.1);
    color: var(--text);
  }
}

.chapter-option[aria-selected="true"] {
  color: var(--text);
  background: rgba(226, 180, 93, 0.15);
}

.chapter-option:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.chapter-option-check {
  color: var(--accent-strong);
  font-weight: 900;
  opacity: 0;
}

.chapter-option[aria-selected="true"] .chapter-option-check {
  opacity: 1;
}

/* ============================================================
