/* Définition des variables locales au lecteur */
:root {
  --sidebar-info-width: 16rem;
  --sidebar-settings-width: 14rem;
  --global-controls-height: 4.5rem;
  --global-controls-height-mobile: var(--mobile-bars-height, 60px);
}

#manga-reader-root {
  height: calc(100vh - 60px);
  position: relative; /* Le cadre de référence pour ses enfants */
  background-color: var(--clr-bg-reader);
}

@media screen and (min-width: 768px) {
  #manga-reader-root {
    overflow: hidden;
  }

  body#readerpage {
    height: 100vh;
    overflow: hidden;
  }
}

/* --- Contrôles Globaux (en haut à gauche) --- */
#global-reader-controls {
  position: absolute;
  top: 0;
  left: 0;
  height: var(--global-controls-height);
  width: 100%; /* Prend toute la largeur */
  background: transparent;
  z-index: 1001;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 0.75rem;
  box-sizing: border-box;
}

#global-reader-controls button {
  background: transparent;
  color: var(--clr-reader-invert);
  border: 1.5px solid var(--clr-bg-reader-invert);
  font-size: 1.2rem;
  cursor: pointer;
  height: 36px;
  width: 36px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

#global-reader-controls button:hover {
  background: var(--clr-bg-reader-invert);
  color: var(--clr-text-invert);
}

#global-reader-controls button.active {
  border-color: var(--clr-bg-reader-invert);
  background: var(--clr-bg-reader-invert);
  color: var(--clr-text-invert);
}

#global-reader-controls #toggle-chapters-like.liked {
  background: var(--clr-accent);
  color: var(--clr-bg-reader);
  border-color: var(--clr-accent);
}

#global-reader-controls #toggle-chapters-like.liked i.fas.fa-heart {
  color: var(--clr-bg-reader);
}

#live-page-counter {
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--clr-text-sub);
}

/* --- Layout Principal (Sidebars + Viewer) --- */
.reader-layout-container {
  position: absolute;
  top: var(--global-controls-height);
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
}

/* --- NOUVELLE LOGIQUE D'ANIMATION POUR LES SIDEBARS --- */
.reader-sidebar {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  padding: 0rem 0 1.5rem 1.5rem;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  min-width: 0;
  transform: translateX(-100%);
  transition: transform 0.3s ease-in-out;
  z-index: 2;
  background-color: var(--clr-bg);
}

#info-sidebar {
  width: var(--sidebar-info-width);
  left: 0;
  z-index: 3;
}

#settings-sidebar {
  padding-left: 1rem;
  width: var(--sidebar-settings-width);
  z-index: 2;
}

.sidebar-content-wrapper {
  overflow-y: auto;
  flex-grow: 1;
  scrollbar-width: none;
  min-width: 0; /* <-- Permet le retour à la ligne du contenu */
}

.sidebar-content-wrapper::-webkit-scrollbar {
  display: none;
}

.reader-container {
  top: -4.5rem;
  padding: 1rem 1rem 20px 1rem;
  flex-grow: 1;
  min-width: 0;
  -webkit-user-select: none;
  user-select: none;
  margin-left: 0;
  transition: margin-left 0.3s ease-in-out;
  position: relative;
  z-index: 1;
  height: calc(100% + 4.5rem);
  /* On retire le padding ici car il sera sur le viewer */
}

.reader-viewer-container {
  background-color: var(--clr-bg-reader);
  height: 100%;
  -webkit-user-select: none;
  user-select: none;
  overflow-y: auto; /* MODIFIÉ: C'est LUI qui devient scrollable */
  -webkit-overflow-scrolling: touch;
}

.reader-viewer-container img {
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}

.reader-viewer-container:has(.licensed-notice) {
  display: flex;
  justify-content: center;
  align-items: center;
}

.licensed-notice > a {
  text-decoration: none;
  color: inherit;
  font-weight: 600;
  border-bottom: 2px solid;
  border-color: transparent;
}

.licensed-notice > a:hover {
  border-color: inherit;
}

.reader-viewer {
  display: flex;
  box-sizing: border-box;
}

.reader-viewer.fit-height-mode {
  height: 100%;
}

.reader-viewer img {
  max-width: 100%;
  height: auto;
  margin: 0;
}

.reader-viewer.stretch img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.reader-viewer.double-mode {
  display: grid;
  grid-template-columns: 1fr 1fr;
  /* La ligne suivante est la correction clé */
  grid-template-rows: minmax(
    0,
    100%
  ); /* Force la ligne de la grille à ne pas dépasser 100% de la hauteur du conteneur */
  justify-items: center; /* Centre les images horizontalement dans leurs colonnes */
  align-items: center; /* Centre les images verticalement dans leurs colonnes */
  min-height: 0;
}

/* Gère le cas d'une seule image PAYSAGE qui doit prendre toute la largeur */
.reader-viewer.double-mode.single-landscape-spread {
  /* On annule la grille et on passe en flex pour un centrage simple */
  display: flex;
  grid-template-columns: none; /* Annule la grille explicitement */
  justify-content: center;
  align-items: center;
}

/* Cas des images paysage en mode double */
.reader-viewer.double-mode.single-landscape-spread.fit-width img,
.reader-viewer.double-mode.single-landscape-spread.fit-both img {
  /* En mode largeur ou "les deux", l'image prend toute la largeur du conteneur */
  width: 100%;
  height: auto;
}

.reader-viewer.double-mode.single-landscape-spread.fit-height img {
  /* En mode hauteur, elle respecte les mêmes règles que les autres images en fit-height */
  max-height: 100%;
  max-width: 100%;
  object-fit: contain;
  width: auto;
  height: auto;
}

/* Styles par défaut pour les images en mode double (2 pages) */
.reader-viewer.double-mode img {
  justify-self: end; /* La 1ère image (logique) se colle à droite de sa colonne */
}
.reader-viewer.double-mode img:last-child {
  justify-self: start; /* La 2ème image (logique) se colle à gauche de sa colonne */
}

/* Pour le mode RTL, on inverse l'ordre visuel et l'alignement */
.reader-viewer.double-mode.rtl-mode > img:nth-child(2) {
  order: -1; /* Place la 2ème image avant la 1ère visuellement */
}
.reader-viewer.double-mode.rtl-mode img {
  justify-self: start; /* La 1ère (logique) se colle à gauche */
}
.reader-viewer.double-mode.rtl-mode img:last-child {
  justify-self: end; /* La 2ème (logique) se colle à droite */
}
.reader-viewer.double-mode.rtl-mode.last-page img {
  justify-self: start;
  grid-column: 2;
}

/* --- NOUVELLE LOGIQUE POUR LA PAGE UNIQUE (PORTRAIT) --- */

/* Pour la lecture de droite à gauche (RTL) */
/* La page unique se place dans la colonne de gauche et se colle à droite */
.reader-viewer.double-mode.rtl-mode .single-page-spread {
  grid-column: 1 / 2;
  justify-self: end;
}

/* Pour la lecture de gauche à droite (LTR) */
/* La page unique se place dans la colonne de droite et se colle à gauche */
.reader-viewer.double-mode.ltr-mode .single-page-spread {
  grid-column: 2 / 3;
  justify-self: start;
}

/* --- Styles de dimensionnement --- */

.reader-viewer.stretch.double-mode img {
  width: auto;
  height: 100%;
  object-fit: contain;
}
.reader-viewer.double-mode.fit-width img {
  width: 100%;
  height: auto;
  object-fit: contain;
}

.reader-viewer-container:has(.reader-viewer.fit-custom) {
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.reader-viewer.fit-height img {
  max-height: 100%;
  max-width: 100%;
  object-fit: contain;
}

.reader-viewer.fit-width img {
  width: 100%;
  height: auto;
}
.reader-viewer.fit-both img {
  max-width: 100%;
  max-height: calc(100vh - 70px - 22px - 1rem);
  object-fit: contain;
}
.reader-viewer.fit-original img {
  max-width: none;
  max-height: none;
}
.reader-viewer.webtoon-mode {
  justify-content: flex-start; /* Aligne le contenu en haut */
  flex-direction: column;
}

.reader-viewer.webtoon-mode img {
  margin-bottom: 0.75rem;
}

/* ...sauf la toute dernière, pour qu'elle colle à la section suivante. */
.reader-viewer.webtoon-mode img:last-child {
  margin-bottom: 0;
}

.reader-viewer.webtoon-mode::after {
  content: "";
  display: block;
}

.reader-sidebar .control-group {
  margin-bottom: 2rem;
}

.reader-sidebar .group-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--clr-text);
  margin-bottom: 0.4rem;
}

#info-series-link {
  color: var(--clr-text);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.2rem;
  display: inline-flex;
  align-items: flex-start;
  gap: 0.5rem;
  transition: color 0.2s;
  word-break: break-word; /* <-- Forcer le retour à la ligne si besoin */
}

#info-series-link:hover {
  color: var(--clr-text-sub);
}

#info-series-link i {
  color: var(--clr-text-sub);
  padding-top: 4px;
}

#info-chapters-group .chapter-list-wrapper {
  max-height: 350px;
  overflow-y: auto;
  scrollbar-width: none;
}

#info-chapters-group .chapter-list-wrapper::-webkit-scrollbar {
  display: none;
}

#info-chapters-group .chapter-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

#info-chapters-group .chapter-list a {
  background: var(--clr-bg-card);
  border-radius: 4px;
  padding: 0.6rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  transition: all 0.2s ease;
  text-decoration: none;
  overflow: hidden;
  cursor: pointer;
}

#info-chapters-group .chapter-list a:hover {
  background: var(--clr-bg-reader-invert);
}

#info-chapters-group .chapter-list a:hover .chapter-number,
#info-chapters-group .chapter-list a:hover .chapter-title {
  color: var(--clr-text-invert);
}

.chapter-info-main {
  display: flex;
  width: 100%;
  justify-content: flex-start;
  align-items: center;
}

.chapter-number {
  font-weight: 700;
  color: var(--clr-text-fifth);
  min-width: 30px;
  transition: color 0.2s ease;
}

.chapter-title {
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-left: 0.5rem;
  flex-grow: 1;
  color: var(--clr-text);
  transition: color 0.2s ease;
}

.chapter-stats-details {
  font-size: 0.75rem;
  margin-top: 0.4rem;
  padding-top: 0.4rem;
  border-top: 1.5px solid var(--clr-bg-reader);
  width: 100%;
  display: flex;
  justify-content: space-between;
  color: var(--clr-text-sub);
}

.chapter-stats-details i {
  color: var(--clr-text-sub);
  margin-right: 0.3rem;
}

#info-chapters-group .chapter-list a.active {
  background: var(--clr-bg-reader-invert);
}

#info-chapters-group .chapter-list a.active .chapter-number,
#info-chapters-group .chapter-list a.active .chapter-title {
  color: var(--clr-text-invert);
}

#info-chapters-group .chapter-list a.active .chapter-stats-details {
  color: var(--clr-bg-reader);
}

#info-chapters-group .chapter-list a.active .chapter-stats-details i {
  color: var(--clr-bg-reader);
}

#settings-sidebar .control-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.main-setting-btn {
  width: 100%;
  padding: 0.6rem 1rem;
  border-radius: 4px;
  background: var(--clr-bg-invert);
  border: none;
  color: var(--clr-text-invert);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.options-panel {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.secondary-toggle-btn {
  padding: 0.75rem 1rem;
  border-radius: 4px;
  background: var(--clr-bg-card);
  border: 1.5px solid transparent;
  color: var(--clr-text);
  text-align: left;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  transition: all 0.2s ease-in-out;
  opacity: 0.7;
  font-size: 0.85rem;
}

.secondary-toggle-btn:hover {
  opacity: 1;
  background-color: var(--clr-bg-reader);
}

.secondary-toggle-btn.active {
  opacity: 1;
  border-color: var(--clr-bg-invert);
}

.secondary-toggle-btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.secondary-toggle-btn .check-icon {
  font-size: 1.1em;
}

/* ================================== */
/* STYLES DU SLIDER SYNCHRONISÉS      */
/* ================================== */

.slider-control {
  padding: 0.75rem 1rem;
  border-radius: 4px;
  background: var(--clr-bg-card);
  border: 1.5px solid transparent;
  transition: all 0.2s ease-in-out;
  opacity: 0.7;
}

.slider-control.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.slider-header {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  cursor: pointer;
  user-select: none;
  font-size: 0.85rem;
  font-weight: 500;
}

.slider-label {
  color: var(--clr-text);
}

.check-icon {
  font-size: 1.1em;
  width: 1.1em;
  text-align: center;
}

.slider-body {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s ease-out, padding-top 0.3s ease-out;
  padding-top: 0;
}

.slider-control.active {
  opacity: 1;
  border-color: var(--clr-bg-card-invert);
}

.slider-control.active .slider-body {
  max-height: 100px;
  padding-top: 0.75rem;
}

.slider-control.active .check-icon::before {
  content: "\f14a";
  font-weight: 900;
}

.PB-range-slider-div {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.slider-control:hover {
  background: var(--clr-bg-reader);
}

.PB-range-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 4px;
  background: var(--clr-text-sub);
  outline: none;
  transition: opacity 0.2s;
}

.body.dark .PB-range-slider {
  background: #4a4a4a;
}

.PB-range-slidervalue {
  color: var(--clr-bg-sub);
  font-size: 0.8rem;
}

.PB-range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background-color: var(--clr-bg-invert);
  cursor: pointer;
  transition: 0.3s ease-in-out;
  border: 2px solid var(--clr-bg-card);
}

/* --- STYLES POUR LA SECTION COMMENTAIRES --- */

#info-comments-group .add-comment-box {
  background-color: var(--clr-bg-card);
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 1.5rem;
}

#info-comments-group textarea {
  width: 100%;
  min-height: 60px;
  max-height: 120px;
  resize: vertical;
  border: none;
  border-radius: 6px;
  padding: 0.75rem;
  font-size: 0.9rem;
  outline: none;
  caret-color: var(--clr-text);
  background-color: transparent;
  color: var(--clr-text);
  font-family: inherit;
}

#info-comments-group .add-comment-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 8px;
}

#info-comments-group .send-btn {
  background-color: var(--clr-bg-card-invert);
  color: var(--clr-text-invert);
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  border: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  transition: filter 0.2s;
}

#info-comments-group .send-btn:hover {
  filter: brightness(0.9);
}

.comments-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.comment-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.2rem;
}

.comment-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-pic {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--clr-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: clip;
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-info .username {
  display: block;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--clr-text);
}

.user-info .timestamp {
  display: block;
  font-weight: 500;
  font-size: 0.75rem;
  color: var(--clr-text-sub);
}

.comment-like-action,
.comment-report-action {
  background: none;
  border: none;
  color: var(--clr-text-sub);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 4px;
  font-size: 0.8rem;
  transition: all 0.2s;
}

.comment-like-action:hover {
  color: var(--clr-accent-invert);
}

.comment-report-action:hover {
  color: var(--clr-text);
}

.comment-like-action .fas.fa-heart {
  transition: color 0.2s;
}

.comment-content {
  font-size: 0.9rem;
  line-height: 1.6;
  font-weight: 500;
  color: var(--clr-text-sub);
  padding-left: 42px;
}

/* --- Bouton global like dans la barre de contrôle --- */
#global-reader-controls #toggle-chapters-like,
#global-reader-controls #toggle-episode-like {
  background: transparent;
  color: var(--clr-bg-reader-invert);
  border: 1.5px solid var(--clr-bg-reader-invert);
  font-size: 1.2rem;
  cursor: pointer;
  height: 36px;
  width: 36px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

#global-reader-controls #toggle-chapters-like.liked,
#global-reader-controls #toggle-episode-like.liked {
  background: var(--clr-accent);
  color: var(--clr-bg-reader);
  border-color: var(--clr-accent);
}

#global-reader-controls #toggle-chapters-like.liked i.fas.fa-heart,
#global-reader-controls #toggle-episode-like.liked i.fas.fa-heart {
  color: var(--clr-bg-reader);
}

#global-reader-controls #toggle-chapters-like:hover,
#global-reader-controls #toggle-episode-like:hover {
  background: var(--clr-bg-reader-invert);
  color: var(--clr-text-invert);
}

#global-reader-controls #toggle-chapters-like.liked:hover,
#global-reader-controls #toggle-episode-like.liked:hover {
  background: var(--clr-accent);
  color: var(--clr-text-invert);
}

/* --- Like dans la sidebar (stats chapitre) --- */
.chapter-stats-details .fa-heart,
.chapter-stats-details .chapter-likes-count {
  transition: color 0.2s;
}

.chapter-stats-details .fa-heart.liked,
.chapter-stats-details .chapter-likes-count.liked {
  color: var(--clr-accent) !important;
}

/* --- Like sur la page MangaList (exemple pour .chapter-card-list-likes) --- */
.chapter-card-list-likes,
.chapter-card-list-likes .fa-heart,
.chapter-card-list-likes .likes-count {
  transition: color 0.2s;
}

.chapter-card-list-likes.liked,
.chapter-card-list-likes.liked .fa-heart,
.chapter-card-list-likes.liked .likes-count {
  color: var(--clr-accent) !important;
}

/* --- Like sur les commentaires --- */
.comment-like-action.liked,
.comment-like-action.liked .fa-heart,
.comment-like-action.liked span,
.comment-like-action .fa-heart.liked,
.comment-like-action span.liked {
  color: var(--clr-accent) !important;
}

.image-placeholder {
  width: 100%;
  max-width: 500px; /* Limite la largeur pour ne pas être énorme */
  background-color: rgba(var(--clr-text-rgb), 0.05);
  border: 1px dashed rgba(var(--clr-text-rgb), 0.1);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: rgba(var(--clr-text-rgb), 0.2);
  margin: 0 auto;
}

#reader-progress-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 20px;
  background-color: rgba(var(--clr-bg-reader-rgb), 0.5);
  display: flex;
  align-items: center;
  padding: 0 5px;
  gap: 2px;
  z-index: 1001;
  transition: transform 0.3s ease-in-out, width 0.3s ease-in-out,
    left 0.3s ease-in-out;
  backdrop-filter: blur(8px);
}

body:not(.mobile-view) #reader-progress-bar.sidebar-open {
  left: var(--sidebar-total-width, 0px);
  width: calc(100% - var(--sidebar-total-width, 0px));
}

body.webtoon-mode-active #reader-progress-bar {
  display: none;
}

#reader-progress-bar.rtl-mode {
  flex-direction: row-reverse;
}

.progress-tick {
  flex-grow: 1;
  height: 7px;
  background-color: rgba(var(--clr-text-rgb), 0.05);
  border-radius: 2px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.progress-tick:hover,
.progress-tick.read:hover {
  background-color: var(--clr-text-sub);
}

.progress-tick.read {
  background-color: var(--clr-text-fifth);
}

.progress-tick.current {
  background-color: var(--clr-text);
  height: 0.75rem;
}

.mobile-only {
  display: none;
}

/* Par défaut, les éléments desktop sont visibles */
.desktop-only {
  display: block; /* ou flex, grid, etc. selon l'élément */
}

/***************************************/
/* --- SECTION RESPONSIVE (MOBILE) --- */
/***************************************/
@media (max-width: 768px) {
  /* --- Classes utilitaires pour le responsive --- */

  body#readerpage main {
    padding: 0;
  }

  .mobile-only {
    display: flex;
  }
  .desktop-only {
    display: none !important; /* Force le masquage */
  }

  /* Le conteneur racine devient le conteneur scrollable principal */
  #manga-reader-root {
    padding-top: 0;
  }

  #global-reader-controls {
    display: none;
  }

  .reader-layout-container {
    flex-direction: column;
    position: static;
  }

  #mobile-reader-controls.is-hidden + .reader-layout-container {
    margin-top: calc(var(--global-controls-height-mobile) * -1);
  }

  .reader-container {
    padding-top: calc(
      var(--mobile-bars-height) + var(--global-controls-height-mobile)
    );
    transition: padding-top 0.3s ease-in-out;
    height: 100%;
    top: 0;
  }

  .reader-viewer-container {
    margin: 0 -1rem 0 -1rem;
  }

  body.bars-hidden .reader-container {
    padding-top: 0;
  }

  .reader-layout-container,
  .reader-viewer,
  .reader-viewer-container {
    overflow: visible;
    position: static;
  }

  .reader-viewer {
    padding: 0;
  }

  #reader-bars-wrapper {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    transition: transform 0.3s ease-in-out;
    flex-wrap: wrap;
  }

  #reader-bars-wrapper.is-hidden {
    transform: translateY(-100%);
  }

  #reader-bars-wrapper > #main-header {
    width: 100%;
    position: static;
  }

  /* --- Barre d'actions mobile flottante et collante --- */
  #mobile-reader-controls {
    min-height: var(--global-controls-height-mobile);
    position: static;
    top: var(--mobile-bars-height);
    left: 0;
    width: 100%;
    z-index: 999;
    height: var(--mobile-bars-height);
    padding: 0.4rem 0.8rem;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 1.1rem;
    background-color: var(--clr-bg-card);
    transition: transform 0.3s ease-in-out;
    transform: translateY(0);
  }

  /* La classe .is-hidden fait glisser la barre vers le haut */
  #mobile-reader-controls.is-hidden {
    transform: translateY(-100%);
  }

  .mrc-info-wrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
  }

  .mrc-top-row,
  .mrc-bottom-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
  }

  .mrc-left-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
  }

  .mrc-series-title {
    color: var(--clr-text);
    font-size: 1rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-decoration: none;
    color: inherit;
  }

  .mrc-chapter-details {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mrc-chapter-number {
    font-weight: 700;
    font-size: 1rem;
    color: var(--clr-text);
  }

  .mrc-chapter-title {
    font-size: 0.85rem;
    color: var(--clr-text-fifth);
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #mobile-reader-controls button {
    background: none;
    border: none;
    color: var(--clr-text);
    padding: 0.25rem;
    line-height: 1;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
  }

  #mobile-toggle-settings-btn {
    font-size: 1.5rem;
  }

  .mrc-page-counter {
    color: var(--clr-text-sub);
    font-size: 0.9rem;
    flex-shrink: 0;
  }

  /* Style du groupe de stats */
  .mrc-stats-group {
    display: flex;
    align-items: center;
    gap: 1rem;
  }

  .mrc-stat-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--clr-text-sub);
    cursor: pointer;
  }

  .mrc-likes-count,
  .mrc-comments-count {
    font-weight: 400;
  }

  .mrc-stat-item.liked {
    color: var(--clr-accent);
  }

  /* --- Panneaux coulissants --- */
  .reader-sidebar {
    position: fixed;
    /* Ils commencent SOUS les deux barres */
    top: calc(var(--mobile-bars-height) + var(--global-controls-height-mobile));
    /* Ils prennent la hauteur RESTANTE */
    height: calc(
      100vh - (var(--mobile-bars-height) + var(--global-controls-height-mobile))
    );
    height: calc(
      100dvh -
        (var(--mobile-bars-height) + var(--global-controls-height-mobile))
    );
    left: 0;
    width: 90vw;
    max-width: 350px;
    background-color: var(--clr-bg-card);
    z-index: 2000;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  #info-chapters-group .chapter-list-wrapper {
    max-height: 250px;
  }

  .chapter-number {
    font-size: 0.95rem;
  }

  .chapter-title {
    font-size: 0.8rem;
  }

  .reader-sidebar .control-group {
    margin-bottom: 1.5rem;
  }

  .reader-sidebar .sidebar-content-wrapper .control-group:last-child {
    margin-bottom: 0;
  }

  .chapter-stats-details {
    padding-top: 0.3rem;
    margin-top: 0.1rem;
  }

  #info-chapters-group .chapter-list a {
    padding: 0.4rem 0.8rem;
  }

  .reader-sidebar.is-open {
    transform: translateX(0);
  }

  .reader-sidebar .sidebar-content-wrapper {
    padding: 1.05rem;
    margin-top: 0;
    overscroll-behavior-y: contain;
  }

  #webtoon-page-bubble {
    position: fixed;
    bottom: 0px;
    left: 50%;
    /* Centrage horizontal parfait */
    transform: translateX(-50%) translateY(100%);

    /* Apparence */
    background-color: rgba(0, 0, 0, 0.6);
    color: #ffffff;
    border-radius: 999px; /* Pour un cercle parfait */
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
    font-weight: 600;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);

    /* Animation et état initial */
    opacity: 1;
    pointer-events: none; /* Non cliquable */
    transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
    z-index: 1001; /* Au-dessus du lecteur, mais sous les sidebars */
  }

  body.bars-interactive
    #reader-bars-wrapper.is-hidden
    ~ main
    #webtoon-page-bubble {
    opacity: 1;
    transform: translateX(-50%) translateY(0); /* Animation d'apparition */
  }

  html.sidebar-is-open {
    overflow: hidden;
  }

  body.sidebar-is-open {
    position: fixed;
    inset: 0;
  }

  #settings-sidebar {
    background-color: var(--clr-bg-reader);
    padding: 0;
  }

  #settings-sidebar #info-chapters-group .group-title.desktop-only {
    display: none;
  }

  /* Overlay pour fermer les panneaux */
  .mobile-sidebar-overlay {
    position: fixed;
    top: calc(var(--mobile-bars-height) + var(--global-controls-height-mobile));
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1999;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }

  .mobile-sidebar-overlay.is-visible {
    opacity: 1;
    pointer-events: auto;
    z-index: 1;
  }

  /* --- Section commentaires mobile --- */
  #comments-mobile-section {
    display: none;
    padding: 0.75rem 0 0 0;
    background-color: var(--clr-bg);
  }

  #comments-mobile-section.is-visible {
    margin-top: 0;
    display: block;
  }

  #comments-mobile-section h4 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
  }

  #comments-mobile-section .add-comment-box {
    background-color: var(--clr-bg-card);
    border-radius: 8px;
    padding: 8px;
    margin-bottom: 1.5rem;
    /* font-size: 1rem; */
  }

  #comments-mobile-section textarea {
    width: 100%;
    background-color: transparent;
    border: none;
    color: var(--clr-text);
    outline: none;
    caret-color: var(--clr-text);
    padding: 0.75rem;
    height: 35px;
  }

  /* Style pour le texte indicatif (placeholder) */
  #comments-mobile-section textarea::placeholder {
    color: var(--clr-text-sub);
    opacity: 0.7;
  }

  /* Désactive le curseur et change l'opacité quand le textarea est en lecture seule */
  #comments-mobile-section textarea:read-only {
    width: 100%;
    cursor: not-allowed;
    opacity: 0.7;
    font-size: 0.85rem;
  }

  #comments-mobile-section .add-comment-actions {
    display: flex;
    justify-content: flex-end; /* Aligne le bouton à droite */
    padding-top: 8px;
  }

  #comments-mobile-section .send-btn {
    background-color: var(--clr-bg-card-invert);
    color: var(--clr-text-invert);
    padding: 8px 12px; /* Taille du bouton ajustée */
    border-radius: 6px;
    border: none;
    font-weight: 600;
    font-size: 0.9rem;
  }

  #comments-mobile-section .send-btn:hover {
    filter: brightness(0.9);
  }

  #comments-mobile-section * {
    font-size: 0.8rem;
  }

  #interactions-share {
    display: none; /* Caché par défaut */
    padding: 0.75rem 0 0 0;
    background-color: var(--clr-bg);
  }

  #interactions-share.is-visible {
    margin: 0;
    display: block;
  }

  .interactions-share-wrapper {
    display: flex;
    gap: 0.75rem;
    justify-content: space-between;
  }

  .interaction-btn {
    flex: 1; /* Les boutons partagent l'espace équitablement */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    height: 40px;
    padding: 1rem;
    border-radius: 8px;
    border: 1.5px solid var(--clr-bg-card-invert);
    background-color: var(--clr-bg-card);
    color: var(--clr-text-sub);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
  }

  .interaction-btn:first-child {
    border-color: var(--clr-accent);
  }

  .interaction-btn:hover {
    background-color: rgba(var(--clr-text-rgb), 0.05);
    border-color: rgba(var(--clr-text-rgb), 0.2);
    color: var(--clr-text);
  }

  #share-like-btn.liked {
    background-color: rgba(var(--clr-accent-rgb), 0.1);
    border-color: var(--clr-accent);
    color: var(--clr-accent);
  }

  #webtoon-chapter-navigation {
    padding: 0.75rem 0 0 0;
    background-color: var(--clr-bg);
    display: none; /* Caché par défaut, affiché par JS */
  }

  .chapter-navigation-wrapper {
    display: flex;
    gap: 0.75rem;
    justify-content: space-between;
  }

  .chapter-nav-button {
    flex: 1; /* Les boutons se partagent l'espace */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    height: 40px;
    padding: 1rem;
    border-radius: 8px;
    border: 1.5px solid var(--clr-bg-card-invert);
    background-color: var(--clr-bg-card);
    color: var(--clr-text);
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.2s;
  }

  .chapter-nav-button:hover {
    background-color: rgba(var(--clr-text-rgb), 0.05);
  }

  .chapter-nav-button.disabled {
    opacity: 0.4;
    pointer-events: none;
    cursor: not-allowed;
  }

  body.footer-focused #reader-bars-wrapper {
    transform: translateY(-100%);
  }

  /* Et on cache la bulle de page du mode webtoon */
  body.footer-focused #webtoon-page-bubble {
    opacity: 0;
    transform: translateX(-50%) translateY(100%);
    transition-delay: 0s; /* S'assure qu'elle disparaît immédiatement */
  }
}

.reader-viewer.single-mode {
  display: flex;
  justify-content: center;
  align-items: center;
}

.reader-viewer.single-mode.fit-width img {
  width: unset;
}

.reader-viewer.single-mode.fit-custom img {
  width: 100%;
  height: fit-content;
}

.report-popup {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(3px);
}

.report-popup.active {
  display: flex;
}

.report-popup-content {
  background: var(--clr-bg);
  border-radius: 8px;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
  animation: popup-in 0.3s ease-out;
}

.report-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--clr-bg-card-invert);
}

.report-popup-header h3 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--clr-text);
}

.report-popup-close {
  background: none;
  border: none;
  color: var(--clr-text-sub);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}

.report-popup-close:hover {
  background: var(--clr-bg-hover);
}

.report-popup-body {
  padding: 16px;
}

.report-popup-body p {
  margin: 0 0 12px;
  color: var(--clr-text-sub);
}

.report-popup-body textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--clr-bg-card-invert);
  border-radius: 4px;
  background: var(--clr-bg-sub);
  color: var(--clr-text);
  resize: vertical;
  min-height: 80px;
  font-size: 0.9rem;
}

.report-popup-body textarea.error {
  border-color: var(--clr-error);
}

.report-popup-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px;
}

.report-popup-cancel,
.report-popup-submit {
  padding: 8px 16px;
  border-radius: 4px;
  font-size: 1rem;
  cursor: pointer;
  font-weight: 500;
}

.report-popup-cancel {
  background-color: var(--clr-bg-sub);
  border: 1px solid var(--clr-bg-card-invert);
  color: var(--clr-text);
}

.report-popup-submit {
  background: var(--clr-bg-card-invert);
  border: none;
  color: var(--clr-text-invert);
}

.report-popup-submit:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.report-popup-submit.success {
  background: var(--clr-success);
}

.report-popup-submit.error {
  background: var(--clr-error);
}

@keyframes popup-in {
  from {
    opacity: 0;
    transform: scale(0.95);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@media (max-width: 768px) {
  .report-popup-content {
    width: 95%;
    margin: 16px;
  }
}
