:root {
  --bg: #0d0d10;
  --surface: #17171d;
  --surface-2: #22222a;
  --line: #2c2c35;
  --text: #ececf1;
  --muted: #9a9aa8;
  --accent: #f0a63a;
  --accent-ink: #1b1204;
  --ok: #5cc98a;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
a { color: inherit; text-decoration: none; }
.empty { color: var(--muted); text-align: center; padding: 30vh 24px 0; }

/* --- en-têtes ------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: calc(12px + var(--safe-top)) 16px 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.topbar h1 { font-size: 20px; margin: 0; flex: 1; letter-spacing: .2px; }
.topbar h1 span { color: var(--accent); }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--surface); flex: none;
}
.icon-btn svg { width: 20px; height: 20px; }

/* --- bibliothèque ------------------------------------------------------------ */
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 12px 16px 10px; }
.grid {
  display: grid; gap: 14px 12px; padding: 0 16px 32px;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
}
.card { display: block; min-width: 0; }
.cover {
  aspect-ratio: 2 / 3; border-radius: 10px; overflow: hidden; background: var(--surface-2);
  position: relative; display: grid; place-items: center; color: var(--muted); font-size: 28px; font-weight: 700;
}
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover .bar { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--accent); }
.badge {
  position: absolute; top: 6px; right: 6px; background: var(--accent); color: var(--accent-ink);
  font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 99px;
}
.card .t { font-size: 13.5px; font-weight: 600; margin-top: 7px; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .s { font-size: 12px; color: var(--muted); margin-top: 2px; }

.continue-row { display: flex; gap: 12px; overflow-x: auto; padding: 0 16px 8px; scrollbar-width: none; }
.continue-row::-webkit-scrollbar { display: none; }
.resume {
  flex: none; width: 260px; display: flex; gap: 12px; padding: 10px; border-radius: 14px; background: var(--surface);
}
.resume .cover { width: 56px; border-radius: 8px; font-size: 18px; }
.resume .info { min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.resume .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.resume .s { font-size: 12.5px; color: var(--muted); }
.resume .go { color: var(--accent); font-size: 12.5px; font-weight: 600; margin-top: 4px; }

/* --- fiche série ---------------------------------------------------------------- */
.hero { position: relative; padding: 4px 16px 18px; display: flex; gap: 16px; align-items: flex-end; }
.hero .cover { width: 110px; flex: none; box-shadow: 0 10px 30px #0008; }
.hero h2 { margin: 0 0 4px; font-size: 21px; line-height: 1.2; }
.hero .s { color: var(--muted); font-size: 13px; }
.actions { padding: 0 16px 14px; display: flex; flex-direction: column; gap: 12px; }
.primary {
  background: var(--accent); color: var(--accent-ink); font-weight: 700; border-radius: 14px;
  padding: 14px 16px; text-align: center; display: block;
}
.primary small { display: block; font-weight: 500; opacity: .75; font-size: 12.5px; }
.seg { display: flex; background: var(--surface); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { flex: 1; padding: 8px 6px; border-radius: 9px; color: var(--muted); font-size: 13px; }
.seg button.on { background: var(--surface-2); color: var(--text); font-weight: 600; }
.chapters { list-style: none; margin: 0; padding: 0 0 calc(24px + var(--safe-bottom)); }
.chapters li { display: flex; align-items: center; border-top: 1px solid var(--line); }
.chapters a { flex: 1; padding: 14px 16px; min-width: 0; }
.chapters .n { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chapters .s { color: var(--muted); font-size: 12px; }
.chapters li.read .n { color: var(--muted); }
.chapters li.current { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.chapters li.current .n { color: var(--accent); font-weight: 600; }
.check { width: 52px; align-self: stretch; display: grid; place-items: center; color: var(--line); }
.check svg { width: 20px; height: 20px; }
li.read .check { color: var(--ok); }

/* --- lecteur ------------------------------------------------------------------- */
.reader { background: #000; min-height: 100vh; }
.reader.vertical .pages { max-width: 820px; margin: 0 auto; }
.reader.vertical .pages img { display: block; width: 100%; height: auto; background: #111; }
.reader.vertical .pages img:not([src]) { min-height: 70vh; }
.paged { position: fixed; inset: 0; display: grid; place-items: center; touch-action: pan-y pinch-zoom; }
.paged img { max-width: 100vw; max-height: 100vh; max-height: 100dvh; object-fit: contain; display: block; user-select: none; -webkit-user-select: none; }
.endcard {
  padding: 60px 24px calc(80px + var(--safe-bottom)); text-align: center; color: var(--muted);
  display: flex; flex-direction: column; gap: 14px; align-items: center;
}
.paged .endcard { padding: 24px; }
.endcard strong { color: var(--text); font-size: 17px; }
.endcard .primary { min-width: 240px; }
.endcard .ghost { color: var(--muted); padding: 10px; }

.overlay-top, .overlay-bottom {
  position: fixed; left: 0; right: 0; z-index: 10; background: #0d0d10e8;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: transform .2s ease, opacity .2s ease;
}
.overlay-top { top: 0; padding: calc(10px + var(--safe-top)) 12px 10px; display: flex; gap: 12px; align-items: center; }
.overlay-top .titles { min-width: 0; flex: 1; }
.overlay-top .titles div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.overlay-top .titles .s { font-size: 12.5px; color: var(--muted); }
.overlay-bottom { bottom: 0; padding: 10px 12px calc(10px + var(--safe-bottom)); display: flex; gap: 10px; align-items: center; }
.overlay-bottom input[type=range] { flex: 1; accent-color: var(--accent); }
.overlay-bottom .pg { font-size: 13px; color: var(--muted); min-width: 64px; text-align: center; font-variant-numeric: tabular-nums; }
.hide-ui .overlay-top { transform: translateY(-100%); opacity: 0; pointer-events: none; }
.hide-ui .overlay-bottom { transform: translateY(100%); opacity: 0; pointer-events: none; }
.icon-btn:disabled { opacity: .3; }

/* --- compte -------------------------------------------------------------------- */
.user-btn { background: var(--surface); border-radius: 99px; padding: 8px 14px; font-size: 13px; color: var(--muted); max-width: 45vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.login { max-width: 360px; margin: 0 auto; padding: calc(12vh + var(--safe-top)) 24px 40px; display: flex; flex-direction: column; gap: 12px; text-align: center; }
.login img { width: 72px; height: 72px; margin: 0 auto 4px; }
.login h1 { margin: 0; font-size: 26px; }
.login h1 span { color: var(--accent); }
.login p { color: var(--muted); margin: 0 0 8px; }
.login input { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; font: inherit; color: var(--text); }
.login input:focus { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); border-color: transparent; }
.login .primary { border: 0; font-size: 15px; }
.login .error { color: #ef6b6b; min-height: 1.4em; font-size: 13.5px; }
