/* Reader PSD : styles repris du lecteur de chapitres (Read.vue) + ajouts propres au PSD. */
/* Luminosite : filtre applique aux pages uniquement, les controles gardent leur aspect. */
#reader #reader-images{filter:brightness(var(--reader-brightness,1))}
#reader .rs-offset .rs-hint{margin-top:6px;font-size:12px;opacity:.75}
#reader[data-renderer="double-page"] #reader-images{gap:0;justify-content:center;align-items:center;width:100%}
#reader[data-renderer="double-page"] .reader-image-wrapper{padding:0!important;min-width:0;flex:0 1 50%}
#reader[data-renderer="double-page"] #reader-images[data-spread-count="1"] .reader-image-wrapper{flex-basis:100%;width:100%}
#reader[data-renderer="double-page"] .reader-image-wrapper img{object-fit:contain;object-position:right center}
#reader[data-renderer="double-page"] .reader-image-wrapper:last-child img{object-position:left center}
#reader[data-renderer="double-page"][data-direction="rtl"] .reader-image-wrapper img{object-position:left center}
#reader[data-renderer="double-page"][data-direction="rtl"] .reader-image-wrapper:last-child img{object-position:right center}
#reader[data-renderer="double-page"] #reader-images[data-spread-count="1"] img{object-position:center}
#reader[data-renderer="double-page"][data-display="fit-both"] #reader-images img{width:100%;height:100%;max-height:100%;max-width:100%}
#reader[data-renderer="double-page"][data-display="fit-both"] .reader-image-wrapper{height:100%}
/* Zoom applies to the pages only; controls retain their normal size. */
#reader[data-custom-zoom="true"] #reader-images{width:calc(100% * var(--reader-zoom))!important;max-width:100%;min-width:0;flex-shrink:0}
#reader[data-custom-zoom="true"][data-renderer="long-strip"] .reader-image-wrapper{width:100%;max-width:100%}
#reader[data-custom-zoom="true"][data-renderer="long-strip"] #reader-images img{max-width:100%;height:auto}
#reader[data-custom-zoom="true"][data-display="fit-height"]:not([data-renderer="long-strip"]) #reader-images,
#reader[data-custom-zoom="true"][data-display="fit-both"]:not([data-renderer="long-strip"]) #reader-images{height:calc((100vh - 3.5rem - 15px) * var(--reader-zoom))!important}
body.hide-header #reader[data-custom-zoom="true"][data-display="fit-height"]:not([data-renderer="long-strip"]) #reader-images,
body.hide-header #reader[data-custom-zoom="true"][data-display="fit-both"]:not([data-renderer="long-strip"]) #reader-images{height:calc((100vh - 15px) * var(--reader-zoom))!important}
#reader .reader-zoom-control .form-range{min-width:0;width:100%}
#reader[data-renderer="double-page"] #reader-images[data-equal-height]{max-width:none!important;max-height:none!important;gap:0!important}
#reader[data-renderer="double-page"] #reader-images[data-equal-height] .reader-image-wrapper{max-width:none!important;max-height:none!important;margin-top:0!important;margin-bottom:0!important}
#reader-controls-mode .btn-group label{white-space:normal;font-size:12px;display:flex;align-items:center;justify-content:center}
#reader[data-renderer="single-page"] #reader-images[data-equal-height]{max-width:none!important;max-height:none!important;min-width:0;flex:0 0 auto;justify-content:center}
#reader[data-renderer="single-page"] #reader-images[data-equal-height] .reader-image-wrapper{max-width:none!important;max-height:none!important;padding:0!important;margin:0!important}
#reader[data-renderer="single-page"] #reader-images[data-equal-height] img{object-fit:contain;object-position:center}
#reader #reader-controls-mode.rs-panel{padding:18px 16px;gap:0;width:100%;color:inherit}
#reader .rs-heading{display:flex;align-items:center;justify-content:space-between;font-size:14px;font-weight:700;padding:0 0 18px;gap:10px}
#reader .rs-heading .fas{opacity:.5;font-size:13px}
#reader .rs-section{border:0;border-top:1px solid #8883;margin:0;padding:18px 0;min-width:0;width:100%}
#reader .rs-section legend{float:none;width:auto;margin:0;padding:0 0 12px;font-size:11px;line-height:1.3;font-weight:700;letter-spacing:.6px;color:inherit;opacity:.65}
#reader .rs-modes{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px}
#reader .rs-mode,#reader .rs-direction label{position:relative;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:9px;border:1px solid #8883;border-radius:7px;margin:0;padding:12px 3px;background:#88808;color:inherit;cursor:pointer;line-height:1.2;font-size:11px;transition:background .15s,border-color .15s}
#reader .rs-mode>.fas{font-size:16px;opacity:.75}
#reader .rs-mode.is-selected,#reader .rs-direction .is-selected{background:#8f7beb1c;border-color:#9c8cda;color:inherit;box-shadow:inset 0 0 0 1px #9c8cda33}
#reader .rs-mode:hover,#reader .rs-direction label:hover{background:#8882}
#reader .rs-mode input,#reader .rs-direction input{position:absolute;opacity:0;width:1px;height:1px}
#reader .rs-mode:focus-within,#reader .rs-direction label:focus-within{outline:2px solid #9c8cda;outline-offset:2px}
#reader .rs-offset{padding-top:16px}#reader .rs-switch-row{display:flex;align-items:center;gap:10px;font-size:12px;margin:0;cursor:pointer;position:relative}#reader .rs-switch-row>span:first-child{flex:1}#reader .rs-switch-row.is-disabled{cursor:default;opacity:.55}
#reader .rs-switch-row input{position:absolute;right:0;opacity:0;width:34px;height:20px}
#reader .rs-switch{width:34px;height:20px;border-radius:20px;background:#8885;border:1px solid #8883;position:relative;flex-shrink:0}
#reader .rs-switch::after{content:'';position:absolute;left:3px;top:3px;width:12px;height:12px;background:#fff;border-radius:50%;box-shadow:0 1px 3px #0003;transition:transform .15s}
#reader .rs-switch-row input:checked+.rs-switch{background:#8170c3}#reader .rs-switch-row input:checked+.rs-switch::after{transform:translateX(14px)}#reader .rs-switch-row input:focus-visible+.rs-switch{outline:2px solid #9c8cda;outline-offset:3px}
#reader .rs-offset p{font-size:10px;opacity:.6;line-height:1.5;margin:8px 0 0}
#reader .rs-zoom-heading{display:flex;justify-content:space-between;align-items:center;font-size:12px;margin-bottom:12px}#reader .rs-zoom-heading output{font-variant-numeric:tabular-nums;border:1px solid #8883;border-radius:5px;padding:3px 8px;font-size:11px}
#reader .rs-zoom-track{display:flex;align-items:center;gap:12px}#reader .rs-zoom-track input{accent-color:#9c8cda;flex:1;width:0;min-width:0;cursor:pointer;height:20px}
#reader .rs-zoom-track button{border:1px solid #8883;border-radius:6px;background:#8881;color:inherit;width:28px;height:28px;flex-shrink:0;line-height:1;padding:0;font-size:19px;cursor:pointer}
#reader .rs-text-button{display:block;margin:10px 0 0 auto;border:0;background:none;color:inherit;opacity:.65;font-size:10px;padding:4px 0;cursor:pointer}
#reader .rs-direction{display:grid;grid-template-columns:1fr 1fr;gap:6px}#reader .rs-direction label{font-size:10px;padding:10px 5px;gap:7px}
#reader .rs-reset{border:1px solid #8883;border-radius:7px;background:transparent;color:inherit;font-size:11px;padding:10px 6px;cursor:pointer;width:100%;margin-top:2px}#reader .rs-reset .fas{margin-right:7px;opacity:.6}
#reader .rs-panel button:hover:not(:disabled){background:#8882}#reader .rs-panel button:disabled{opacity:.3;cursor:default}#reader .rs-panel button:focus-visible{outline:2px solid #9c8cda;outline-offset:3px}
@media(prefers-reduced-motion:reduce){#reader .rs-panel *{transition:none!important}}
/* Etat d'erreur d'une image (chargement impossible) + nouvelle tentative. */
#reader .reader-image-wrapper { position: relative; }
#reader .reader-image-error { position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 18px; background: #101116e8; color: #eceaf6; text-align: center; }
#reader .reader-image-error .fas { font-size: 26px; opacity: .75; }
#reader .reader-image-error p { margin: 0; font-size: 14px; line-height: 1.5; }
#reader .reader-image-error button { border: 0; border-radius: 9px; padding: 10px 18px; background: #7054d9; color: #fff; font-weight: 700; font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }
#reader .reader-image-error button:hover { filter: brightness(1.08); }
#reader .reader-image-wrapper img.is-broken { visibility: hidden; }
#reader[data-renderer="long-strip"] .reader-image-wrapper.has-error { min-height: 45vh; }
/* Webtoon ignores paged fitting constraints and keeps a continuous strip. */
#reader[data-renderer="long-strip"] #reader-main{height:auto!important;max-height:none!important;min-height:0}
#reader[data-renderer="long-strip"] #reader-images{display:flex!important;flex-direction:column!important;align-items:stretch;gap:0!important;height:auto!important;max-height:none!important;min-width:0!important;width:calc(100% * var(--reader-zoom,1))!important}
#reader[data-renderer="long-strip"] .reader-image-wrapper{display:block!important;flex:0 0 auto!important;width:100%!important;height:auto!important;max-height:none!important;padding:0!important;margin:0!important;scroll-margin-top:60px}
#reader[data-renderer="long-strip"] #reader-images img{display:block!important;width:100%!important;max-width:100%!important;height:auto!important;max-height:none!important;margin:0!important;object-fit:contain;cursor:default}
body.hide-header #reader[data-renderer="long-strip"] .reader-image-wrapper{scroll-margin-top:0}
/* Le menu est superpose (panneau retractable, voir mc-shared.css) : il ne reserve plus de colonne. Le webtoon garde sa largeur. */
@media(min-width:992px){
    #reader.layout-horizontal[data-renderer="long-strip"] #reader-images{width:calc(77vw * var(--reader-zoom,1))!important}
}
@media(max-width:991.98px){
    #reader-controls-mode:not(.d-none){animation:reader-settings-open 200ms ease-out}
}
@keyframes reader-settings-open{from{opacity:0;transform:translateY(-8px)}to{opacity:1;transform:translateY(0)}}
@media(prefers-reduced-motion:reduce){
    #reader #reader-controls-wrapper,#reader #reader-controls,#reader #reader-main,#reader #reader-page-bar,#reader #reader-controls-mode,#reader #reader-controls-collapser span,#reader #reader-page-counter{transition:none!important;animation:none!important}
}
/* Compteur de page : fixe en bas a droite, au-dessus de la barre de navigation.
   Il monte avec une petite animation a l'ouverture du chapitre et se decale quand le panneau s'ouvre. */
#reader{position:relative}
#reader-page-counter{position:fixed;right:calc(var(--mc-dock,0px) + 18px);bottom:34px;z-index:6;width:auto;max-width:none;display:flex;align-items:baseline;padding:3px 11px;border-radius:999px;background:rgba(0,0,0,.72);border:1px solid rgba(255,255,255,.28);box-shadow:0 2px 8px rgba(0,0,0,.45);color:#fff;font-size:13px;font-weight:700;line-height:1.5;font-variant-numeric:tabular-nums;pointer-events:none;user-select:none;text-shadow:0 1px 2px rgba(0,0,0,.6);transition:right 240ms cubic-bezier(.22,.61,.36,1),transform 260ms cubic-bezier(.22,.61,.36,1);animation:reader-counter-rise 420ms cubic-bezier(.22,.61,.36,1)}
/* Quand la petite barre se deploie (survol), le compteur monte avec elle. */
#reader:has(#reader-page-bar:hover) #reader-page-counter{transform:translateY(-26px)}
#reader-page-counter span{font-weight:600;opacity:.72;margin-left:2px}
@media(max-width:991px){#reader-page-counter{right:12px;bottom:22px}}
@keyframes reader-counter-rise{from{transform:translateY(20px);opacity:0}to{transform:translateY(0);opacity:1}}

/* ---- Ajouts PSD : les pages sont des canvas, pas des images ---- */
#reader #reader-images canvas{display:block;margin:auto;max-width:none;background:#fff}
#reader[data-renderer="long-strip"] #reader-images canvas{display:block!important;width:100%!important;max-width:100%!important;height:auto!important;max-height:none!important;margin:0!important;cursor:default}
#reader .reader-image-wrapper canvas.is-broken{visibility:hidden}
/* Le menu peut etre plus haut que l'ecran (calques) : il defile sans deplacer le reste. */
@media(min-width:992px){#reader.layout-horizontal #reader-controls{overflow-y:auto}}
#reader #reader-controls-groups small{display:block;font-weight:400;opacity:.65;word-break:break-all}
#reader #reader-controls-groups a{cursor:pointer}
#reader .rs-hint{margin:8px 0 0;font-size:10px;opacity:.6;line-height:1.5}
/* Zone de depot (etat vide) et depot au-dessus d'un lecteur deja ouvert. */
#psd-empty{display:none;width:min(560px,calc(100% - 32px));margin:auto}
#reader.is-empty #psd-empty{display:block}
#reader.is-empty #reader-images,#reader.is-empty #reader-page-bar,#reader.is-empty #reader-page-counter{display:none!important}
#psd-empty .psd-drop{border:2px dashed #8886;border-radius:14px;padding:44px 20px;text-align:center;cursor:pointer;transition:background .15s,border-color .15s}
#psd-empty .psd-drop:hover,#psd-empty .psd-drop:focus-visible,#reader.psd-dragging #psd-empty .psd-drop{background:#8f7beb1c;border-color:#9c8cda;outline:0}
#psd-empty .psd-drop .fas{font-size:38px;opacity:.55;margin-bottom:14px}
#psd-empty .psd-drop strong{display:block;font-size:18px;margin-bottom:6px}
#psd-empty .psd-drop small{display:block;opacity:.65;line-height:1.5}
/* Boutons de la zone de depot : « Choisir un dossier » et « Choisir des fichiers » cote a cote (a la ligne si l'ecran est etroit), icone + libelle centres. */
#psd-empty .psd-drop-actions{display:flex;flex-wrap:wrap;justify-content:center;gap:8px;margin-top:16px}
#psd-empty .psd-drop .btn{display:inline-flex;align-items:center;justify-content:center;gap:.5rem;min-height:2.5rem;line-height:1.25}
#psd-empty .psd-drop .btn .fas{margin:0;font-size:1em;opacity:1}
/* Lien magnet (lecteur local du staff) : champ + bouton sous la zone de depot. */
#psd-empty .psd-magnet{display:flex;gap:8px;margin-top:12px}
#psd-empty .psd-magnet input{flex:1;min-width:0}
#psd-empty .psd-magnet .btn{display:inline-flex;align-items:center;gap:.5rem;white-space:nowrap}
/* Choix des tomes avant lecture (torrent ou archive ZIP). */
.psd-volume-chooser{width:min(560px,calc(100% - 24px));max-height:calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));padding:0;border:1px solid #8885;border-radius:16px;background:var(--mc-surface,#fff);color:var(--mc-ink,#20202a);overflow:hidden;box-shadow:0 20px 70px #0006}
.psd-volume-chooser::backdrop{background:#0009}
.psd-volume-chooser[open],.psd-volume-chooser form{display:flex;flex-direction:column;min-height:0}
.psd-volume-chooser form{overflow:hidden}
.psd-volume-chooser header{padding:20px 20px 12px;flex-shrink:0}
.psd-volume-chooser h2{font-size:1.2rem;margin:0 0 8px}
.psd-volume-chooser p{font-size:.9rem;margin:0;opacity:.75}
.psd-volume-chooser .psd-volume-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin-bottom:6px}
.psd-volume-choices{padding:0 12px;overflow-y:auto;overscroll-behavior:contain;min-height:0}
.psd-volume-choices label{display:flex;align-items:center;gap:12px;padding:14px 8px;border-top:1px solid #8883;cursor:pointer}
.psd-volume-choices input{flex:0 0 auto;width:20px;height:20px;margin:0;accent-color:#8f7beb}
.psd-volume-cover{position:relative;display:flex;align-items:center;justify-content:center;flex:0 0 64px;width:64px;height:96px;border-radius:6px;overflow:hidden;background:#8882;color:var(--mc-accent,#8f7beb)}
.psd-volume-cover img{position:absolute;inset:0;width:100%;height:100%;object-fit:contain;background:var(--mc-surface,#fff)}
.psd-volume-choices span{min-width:0;overflow-wrap:anywhere}
.psd-volume-choices strong,.psd-volume-choices small{display:block}
.psd-volume-choices small{margin-top:3px;opacity:.7}
.psd-volume-chooser footer{display:flex;justify-content:flex-end;gap:8px;flex-wrap:wrap;padding:16px;border-top:1px solid #8883;flex-shrink:0}
.psd-volume-chooser .btn{min-height:44px;display:inline-flex;align-items:center;justify-content:center;white-space:normal}
#reader.psd-dragging #reader-main{outline:3px dashed #9c8cda;outline-offset:-10px}
#psd-notice{position:relative;z-index:5}
#psd-notice .alert{margin:8px 12px 0;padding:8px 36px 8px 12px;font-size:13.5px;position:relative}
#psd-notice .alert button{position:absolute;right:8px;top:6px;border:0;background:none;color:inherit;font-size:14px;cursor:pointer;opacity:.7}
/* Arbre des calques */
#psd-layers{max-height:40vh;overflow:auto;font-size:12.5px}
#psd-layers ul{list-style:none;margin:0;padding-left:14px}
#psd-layers>ul{padding-left:0}
#psd-layers li>label{display:flex;gap:6px;align-items:center;padding:2px 3px;border-radius:4px;cursor:pointer;margin:0}
#psd-layers li>label:hover{background:rgba(127,127,127,.15)}
#psd-layers li.psd-dim>label{opacity:.45}
#psd-layers .psd-name{overflow-wrap:anywhere}
#reader .psd-layer-tools{display:flex;gap:6px;margin-bottom:10px}
#reader .psd-layer-tools button{flex:1;border:1px solid #8883;border-radius:7px;background:transparent;color:inherit;font-size:11px;padding:7px 4px;cursor:pointer}
#reader .arrow-link.is-disabled{opacity:.3;pointer-events:none}

/* Version publique : site noir sobre, sans marque du site. */
body.psd-public{background:#070708;color:#d6d6da;--bkg:#070708;--mc-surface:#101012;--mc-ink:#dedee2;padding-top:0}
body.psd-public #reader-controls>div:not(:first-child){border-top-color:#26262a}
body.psd-public #reader-controls-collapser{border-color:#26262a}
body.psd-public .form-select,body.psd-public .form-control{background-color:#18181b;color:#dedee2;border-color:#2e2e33}
body.psd-public #reader-images canvas{background:#fff}
body.psd-public #psd-empty .psd-drop{border-color:#3a3a40}
/* Aide du lecteur public : hors de la zone cliquable, masquee automatiquement pendant la lecture. */
body.psd-local-public #header #results-box{top:100%;right:8px;min-width:0;width:min(430px,calc(100vw - 16px))}
body.psd-local-public #reader.psd-local.is-empty #reader-main{overflow-y:auto;min-height:calc(100vh - var(--mc-reader-header-height,0px))!important;min-height:calc(100dvh - var(--mc-reader-header-height,0px))!important}
body.psd-local-public #reader.psd-local #psd-empty{padding:32px 0;flex-shrink:0}
.psd-local-intro h1{font-size:clamp(22px,5vw,28px);line-height:1.25;margin:0 0 16px;color:inherit}
.psd-local-intro p{font-size:15px;line-height:1.65;margin:0 0 12px}
.psd-local-intro{margin-bottom:24px}
.psd-local-privacy{font-size:14px;line-height:1.6;margin:16px 0;color:inherit}
.psd-local-help{border-top:1px solid #3a3a40;font-size:14px;line-height:1.65}
.psd-local-help summary{padding:16px 0;cursor:pointer;font-weight:700}
.psd-local-help summary:focus-visible{outline:2px solid #9c8cda;outline-offset:2px}
.psd-local-help ol{padding-left:22px}
.psd-local-help li{padding-left:4px;margin-bottom:12px}
.psd-local-help p{margin:0 0 16px}
body.psd-public #reader-page-bar #track{background:linear-gradient(to top,#3a3a40,#3a3a40 2px,rgba(0,0,0,.7) 2px,rgba(0,0,0,.7))}
body.psd-public #psd-layers li>label:hover{background:rgba(255,255,255,.08)}
/* Contraste : le bouton secondaire gris etait trop sombre sur fond noir (3,9:1 -> plus de 7:1). */
body.dark #reader .btn-outline-secondary,body.psd-public #reader .btn-outline-secondary{color:#d6d6da;border-color:#6b6b73}
body.dark #reader .btn-outline-secondary:hover,body.psd-public #reader .btn-outline-secondary:hover{background:#2b2b31;color:#fff}

/* Lecteur local (telephone / tablette) : la page suit directement les commandes au lieu d'etre centree dans un ecran entier,
   ce qui evitait de voir la page en entier sans defiler. */
@media (max-width:991.98px){
    #reader.psd-local #reader-main{min-height:0!important;flex:0 0 auto}
    #reader.psd-local #reader-images{margin-top:0!important;margin-bottom:0!important}
}
@media (pointer:coarse){
    #psd-empty .psd-drop{padding:36px 16px;min-height:44vh;display:flex;flex-direction:column;align-items:center;justify-content:center}
    #psd-empty .psd-drop .btn{min-height:44px;padding-inline:18px}
}
