/* ============================================================
   KOMA — fiche en planche de manga, effets, notifications, modale
   ============================================================ */
:root { --accent: var(--red); --accent-soft: var(--red-soft); --display: var(--manga); }

/* ---------- Fiche ---------- */
.sheet {
  position: fixed; inset: 0; z-index: 60; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; padding: 34px 28px 50px;
  background: var(--paper); user-select: text;
}
.sheet::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; opacity: 0.5;
  background: radial-gradient(circle, rgba(20, 19, 18, 0.18) 1.1px, transparent 1.6px) 0 0 / 8px 8px;
  -webkit-mask-image: linear-gradient(135deg, #000, transparent 40%); mask-image: linear-gradient(135deg, #000, transparent 40%);
}
.sheet.open { animation: sheetIn 0.45s var(--ease); }
.sheet.settled .sh-panel { animation: none; }
.sheet.flying .sh-cover-tilt { visibility: hidden; }
.sheet.closing { animation: sheetOut 0.3s var(--ease) forwards; }
.sh-close {
  position: fixed; z-index: 3; top: 22px; right: 26px; width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center;
  background: var(--ink); box-shadow: 3px 4px 0 var(--red); transition: transform 0.35s var(--spring);
}
.sh-close svg { width: 24px; height: 24px; stroke: #fff; stroke-width: 3; stroke-linecap: round; }
.sh-close:hover { transform: rotate(90deg) scale(1.08); }

.sh-page {
  position: relative; max-width: 1220px; margin: 0 auto; display: grid; gap: 14px;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas: "cover head head" "cover syn read" "rev rev rev" "recs recs recs";
}
.sh-panel {
  position: relative; min-width: 0; background: var(--card-bg); border: 3.5px solid var(--ink); padding: 22px;
  box-shadow: 5px 6px 0 var(--ink); animation: panelIn 0.55s var(--spring) backwards;
}
.sh-panel:nth-child(1) { animation-delay: 0.05s; }
.sh-panel:nth-child(2) { animation-delay: 0.12s; }
.sh-panel:nth-child(3) { animation-delay: 0.2s; }
.sh-panel:nth-child(4) { animation-delay: 0.28s; }
.sh-panel:nth-child(5) { animation-delay: 0.36s; }
.sh-caption {
  display: inline-flex; align-items: center; gap: 8px; margin: -22px 0 16px -22px; padding: 7px 14px 8px;
  background: var(--ink); color: #fff; font: 400 13px/1 var(--manga); letter-spacing: 0.06em;
}
.sh-caption em { font: 600 10px/1 var(--ui); font-style: normal; opacity: 0.6; text-transform: uppercase; letter-spacing: 0.06em; }
.sh-muted { color: var(--muted); font-family: var(--round); font-weight: 500; margin: 0; }
.sk { border-radius: 8px; background: var(--paper-2); margin-bottom: 8px; animation: pulse 1s infinite; }

.sh-cover {
  grid-area: cover; padding: 26px; display: grid; place-items: center; overflow: hidden;
  background: var(--c, #ccc);
}
.sh-cover::before {
  content: ""; position: absolute; inset: 0; opacity: 0.35; mix-blend-mode: multiply;
  background: radial-gradient(circle, #000 1.4px, transparent 2px) 0 0 / 10px 10px;
}
.sh-cover-tilt {
  position: relative; width: 100%; aspect-ratio: 0.7; border: 3.5px solid var(--ink); border-radius: 4px; overflow: hidden;
  box-shadow: 8px 10px 0 var(--ink); transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform 0.6s var(--spring); --px: 50%; --py: 50%;
}
.sh-cover-tilt.hover { transition: transform 0.1s linear; }
.sh-cover-tilt.hover .card-glare { opacity: 1; }
.sh-cover-tilt img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sh-vertical {
  position: absolute; right: 8px; top: 16px; writing-mode: vertical-rl; font: 400 22px/1 var(--manga); color: #fff;
  text-shadow: 2px 2px 0 var(--ink), -1px -1px 0 var(--ink), 1px -1px 0 var(--ink), -1px 1px 0 var(--ink); max-height: 85%; overflow: hidden; z-index: 2;
}

.sh-head { grid-area: head; }
.sh-kicker { font: 400 12.5px/1 var(--manga); color: var(--red); letter-spacing: 0.1em; text-transform: uppercase; }
.sh-head h1 { margin: 10px 0 6px; font: 400 clamp(28px, 3.6vw, 46px)/1.08 var(--manga); letter-spacing: -0.005em; }
.sh-author { font: 700 14.5px/1.4 var(--round); color: var(--ink-2); }
.sh-author b { color: var(--ink); }
.sh-stats { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 18px; border: 3px solid var(--ink); }
.sh-stats div { padding: 12px 8px; text-align: center; border-left: 3px solid var(--ink); }
.sh-stats div:first-child { border-left: 0; }
.sh-stats b { display: block; font: 400 clamp(15px, 1.9vw, 22px)/1.1 var(--manga); white-space: nowrap; }
.sh-stats span { font: 700 11px/1 var(--round); color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.sh-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.sh-btn {
  display: inline-flex; align-items: center; gap: 9px; height: 46px; padding: 0 20px; border-radius: 99px; border: 3px solid var(--ink);
  background: #fff; font: 900 15px/1 var(--round); box-shadow: 3px 4px 0 var(--ink); transition: transform 0.25s var(--spring), background 0.2s, color 0.2s;
}
.sh-btn svg { width: 22px; height: 22px; fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linejoin: round; transition: fill 0.2s; }
.sh-btn:hover { transform: translateY(-2px) rotate(-1.5deg); }
.sh-btn:active { transform: scale(0.95); }
.sh-btn.on-fav svg { fill: var(--gold); }
.sh-btn.on-like { background: var(--red); color: #fff; }
.sh-btn.on-like svg { fill: #fff; stroke: #fff; }
.sh-genres { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.sh-genres span { padding: 5px 12px; border-radius: 99px; border: 2.5px solid var(--ink); font: 700 12.5px/1.2 var(--round); }
.sh-genres span.tag { border-style: dashed; color: var(--ink-2); }

.sh-synopsis { grid-area: syn; }
.sh-text { font: 500 15px/1.75 var(--round); color: var(--ink-2); max-height: 420px; overflow-y: auto; padding-right: 6px; scrollbar-width: thin; }
.sh-text p { margin: 0 0 12px; }

.sh-read { grid-area: read; display: flex; flex-direction: column; gap: 10px; }
.sh-read .sh-caption { align-self: flex-start; margin-bottom: 6px; }
.sh-play {
  display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-radius: 12px; background: var(--red); color: #fff; text-align: left;
  border: 3px solid var(--ink); box-shadow: 4px 5px 0 var(--ink); transition: transform 0.25s var(--spring);
}
.sh-play:hover { transform: translateY(-2px) rotate(-0.8deg); }
.sh-play svg { width: 30px; height: 30px; fill: #fff; flex: none; }
.sh-play b { display: block; font: 400 17px/1.2 var(--manga); }
.sh-play small { font: 700 12px/1.3 var(--round); opacity: 0.85; }
.sh-chapters { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; max-height: 170px; overflow-y: auto; }
.sh-ch { position: relative; }
.sh-ch > button:first-child {
  width: 100%; padding: 8px 10px; border-radius: 8px; border: 2.5px solid var(--ink); background: #fff; text-align: left; transition: transform 0.2s var(--spring);
}
.sh-ch > button:first-child:hover { transform: translateY(-2px); background: var(--paper); }
.sh-ch b { display: block; font: 900 13.5px/1.2 var(--round); }
.sh-ch small { font: 600 11px/1.2 var(--ui); color: var(--muted); }
.sh-ch.done > button:first-child { background: var(--paper-2); }
.sh-ch.done small { color: #2e8b57; }
.sh-ch-del { position: absolute; right: 4px; top: 4px; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 6px; opacity: 0; transition: opacity 0.2s; }
.sh-ch:hover .sh-ch-del { opacity: 1; }
.sh-ch-del svg { width: 14px; height: 14px; fill: none; stroke: var(--red); stroke-width: 2.2; stroke-linecap: round; }
.sh-links { display: grid; gap: 8px; }
.sh-link {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; border: 2.5px solid var(--ink); background: #fff;
  text-decoration: none; transition: transform 0.2s var(--spring), box-shadow 0.2s;
}
.sh-link:hover { transform: translateX(3px); box-shadow: -3px 3px 0 var(--red); }
.sh-dot { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; flex: none; overflow: hidden; color: #fff; font: 900 14px/1 var(--round); border: 2px solid var(--ink); }
.sh-dot img { width: 20px; height: 20px; }
.sh-link.ext { background: #fff8e1; }
.sh-link-txt { min-width: 0; flex: 1; }
.sh-link-txt b { display: block; font: 900 14px/1.2 var(--round); }
.sh-link-txt small { font: 600 11.5px/1.3 var(--ui); color: var(--muted); }
.sh-link > svg { width: 18px; height: 18px; fill: none; stroke: var(--ink); stroke-width: 2; flex: none; }
.sh-import {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 10px; border: 2.5px dashed var(--ink); text-align: left;
  transition: background 0.2s, border-color 0.2s;
}
.sh-import:hover { background: var(--red-soft); border-color: var(--red); }
.sh-import svg { width: 24px; height: 24px; fill: none; stroke: var(--red); stroke-width: 2.2; stroke-linecap: round; flex: none; }
.sh-import b { display: block; font: 900 14px/1.2 var(--round); }
.sh-import small { font: 600 11.5px/1.3 var(--ui); color: var(--muted); }

.sh-recs { grid-area: recs; }
.sh-recs-row { display: grid; grid-auto-flow: column; grid-auto-columns: 120px; gap: 16px; overflow-x: auto; padding: 4px 4px 12px; scrollbar-width: thin; }
.sh-rec { text-align: left; }
.sh-rec img { width: 120px; aspect-ratio: 0.7; object-fit: cover; border: 3px solid var(--ink); border-radius: 4px; box-shadow: 3px 4px 0 var(--ink); transition: transform 0.3s var(--spring), box-shadow 0.3s; display: block; background: var(--paper-2); }
.sh-rec:hover img { transform: translateY(-5px) rotate(-2deg); box-shadow: 5px 7px 0 var(--red); }
.sh-rec span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 8px; font: 700 12.5px/1.3 var(--round); }
.sh-credit { max-width: 1220px; margin: 18px auto 0; font: 600 11.5px/1 var(--ui); color: var(--muted); }

/* ---------- Effets ---------- */
.fx-layer { position: fixed; inset: 0; z-index: 200; pointer-events: none; overflow: hidden; }
.fx-speed { position: absolute; inset: 0; width: 100%; height: 100%; }
.fx-sfx {
  position: absolute; font-family: var(--manga); white-space: nowrap; line-height: 1; letter-spacing: -0.02em;
  -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 5px 5px 0 var(--ink);
}
.fx-particle { position: absolute; }
.fx-particle svg { width: 100%; height: 100%; fill: currentColor; stroke: var(--ink); stroke-width: 1.6; }
.fx-ink { position: absolute; border-radius: 50%; transform: translate(-50%, -50%); }
.fly-cover { position: fixed; z-index: 190; border: 3.5px solid var(--ink); border-radius: 5px; overflow: hidden; pointer-events: none; box-shadow: 8px 10px 0 var(--ink); }
.fly-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---------- Notifications ---------- */
.toasts { position: fixed; z-index: 220; top: 90px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 11px 18px; border-radius: 22px; max-width: min(460px, 90vw);
  background: var(--ink); color: #fff; font: 700 14px/1.35 var(--round); box-shadow: 3px 4px 0 var(--red); animation: toastIn 0.4s var(--spring);
}
.toast.out { animation: toastOut 0.3s var(--ease) forwards; }
.toast i { width: 9px; height: 9px; border-radius: 50%; background: #3ddc97; flex: none; }
.toast.error i { background: var(--red); }

/* ---------- Modale ---------- */
.modal { position: fixed; inset: 0; z-index: 150; display: grid; place-items: center; padding: 16px; background: rgba(243, 239, 230, 0.75); backdrop-filter: blur(6px); animation: fade 0.2s; }
.modal-card { width: min(520px, 100%); max-height: 86vh; overflow-y: auto; padding: 24px; background: var(--card-bg); border: 3.5px solid var(--ink); border-radius: 16px; box-shadow: 6px 8px 0 var(--ink); animation: panelIn 0.35s var(--spring); }
.modal-card h3 { margin: 0 0 6px; font: 400 20px/1.3 var(--manga); }
.modal-card p { margin: 0 0 16px; color: var(--ink-2); font: 500 14px/1.5 var(--round); }
.modal-card .field { display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 14px; border-radius: 10px; border: 3px solid var(--ink); background: #fff; }
.modal-card .field input { flex: 1; background: none; border: 0; outline: none; font-size: 15px; }
.modal-card .modal-list { display: grid; gap: 4px; margin-top: 12px; min-height: 60px; }
.modal-card .modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.m-item { display: grid; grid-template-columns: 40px 1fr; gap: 12px; align-items: center; padding: 6px 8px; border-radius: 10px; text-align: left; }
.m-item:hover { background: var(--paper); }
.m-item img { width: 40px; height: 56px; object-fit: cover; border: 2px solid var(--ink); border-radius: 3px; }
.m-item b { display: block; font: 900 14px/1.25 var(--round); }
.m-item small { color: var(--muted); font-size: 12px; }
.pbtn { height: 42px; padding: 0 18px; border-radius: 99px; border: 3px solid var(--ink); font: 900 14px/1 var(--round); background: #fff; box-shadow: 2px 3px 0 var(--ink); }
.pbtn.red { background: var(--red); color: #fff; }

/* ---------- Zone de dépôt (thème papier) ---------- */
.dropzone { background: rgba(243, 239, 230, 0.86); backdrop-filter: blur(8px); z-index: 180; }
.dropzone-inner { border: 3.5px dashed var(--ink); background: #fff; box-shadow: 8px 10px 0 var(--ink); }
.dropzone-inner strong { font-family: var(--manga); font-weight: 400; }
.dropzone-inner span { color: var(--ink-2); font-family: var(--round); font-weight: 700; }

/* ---------- Liseuse : jetons sombres ---------- */
.reader {
  --text: #eeedf5; --muted: #8f8ea6; --dim: #5d5c72; --line: rgba(255, 255, 255, 0.08); --line-2: rgba(255, 255, 255, 0.14);
  --bg-2: #0c0c15; --ok: #3ddc97; --panel: rgba(14, 14, 24, 0.72); --shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.8);
  --accent: var(--red); font-family: var(--ui); user-select: none;
}
.reader .icon-btn { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; transition: all 0.18s; }
.reader .btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 10px; font-weight: 600; font-size: 13px; white-space: nowrap; }
.reader .btn .ico { width: 16px; height: 16px; }
.reader .btn-primary { background: var(--red); color: #fff; }
.reader .btn-ghost { background: rgba(255, 255, 255, 0.08); border: 1px solid var(--line-2); color: #fff; }

@keyframes sheetIn { from { opacity: 0; } }
@keyframes sheetOut { to { opacity: 0; transform: scale(0.985); } }
@keyframes panelIn { from { opacity: 0; transform: scale(0.94) rotate(-1deg); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(-14px) scale(0.9); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-10px); } }
@keyframes fade { from { opacity: 0; } }

@media (max-width: 1100px) {
  .sh-page { grid-template-columns: minmax(190px, 270px) minmax(0, 1fr); grid-template-areas: "cover head" "read read" "syn syn" "rev rev" "recs recs"; }
  .sh-cover { padding: 18px; }
}
@media (max-width: 640px) {
  .sheet { padding: 76px 12px 40px; }
  .sh-page { grid-template-columns: minmax(0, 1fr); grid-template-areas: "cover" "head" "read" "syn" "rev" "recs"; }
  .sh-cover-tilt { max-width: min(240px, 62vw); }
  .sh-close { top: 14px; right: 14px; }
  .sh-stats b { font-size: 17px; }
}
.reader .icon-btn:disabled { opacity: 0.3; pointer-events: none; }
.reader .r-chapters { max-width: 150px; }
