/* ── CSS Variables ─────────────────────────────────────── */
:root {
  --bg:              #1a1a24;
  --bg-card:         #0d0d14;
  --text:            #e8e8f0;
  --text-muted:      #888;
  --accent:          #e74c3c;
  --accent-hover:    #c0392b;
  --accent-secondary:#f39c12;
  --border:          #2a2a3a;
  --success:         #2ecc71;
  --danger:          #e74c3c;
  --surface:         #14141e;
}

/* ── Reset ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[x-cloak] { display: none !important; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100vh;
}

/* ── Reader active mode ───────────────────────────────── */
body.is-reader-active {
  overflow: hidden;
  background: #000;
}

/* ════════════════════════════════════════════════════════
   SHELL HEADER
   ════════════════════════════════════════════════════════ */

header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  line-height: 0;
  gap: 0.5rem;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.site-logo span {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.02em;
}

/* ── Header Search ────────────────────────────────────── */
.header-search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
}
.header-search input[type="search"] {
  flex: 1;
  min-width: 0;
  max-width: 320px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  font-size: 0.875rem;
}
.header-search input[type="search"]:focus { outline: none; border-color: var(--accent); }
.header-search input[type="search"]::placeholder { color: var(--text-muted); }

.search-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: 360px;
  max-width: calc(100vw - 2rem);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  max-height: 400px;
  overflow-y: auto;
  z-index: 100;
}
.search-loading, .search-empty {
  padding: 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
}
.search-result {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 0.6rem 0.75rem;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  transition: background 0.1s;
}
.search-result:last-child { border-bottom: none; }
.search-result:hover { background: rgba(255,255,255,0.05); }
.search-thumb {
  width: 48px;
  height: 64px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
  background: var(--border);
}
.search-info { flex: 1; min-width: 0; }
.search-title { font-size: 0.875rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-meta  { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-count { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }

/* ── Header Actions ───────────────────────────────────── */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  flex-shrink: 0;
}
.header-actions a, .header-actions button.btn-admin {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: none;
  border: 1px solid var(--border);
  padding: 0.25rem 0.75rem;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}
.header-actions a:hover, .header-actions button.btn-admin:hover { border-color: var(--accent); color: var(--text); }
.header-actions a.active { border-color: var(--accent); color: var(--text); background: rgba(231,76,60,0.08); }

.btn-logout {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.25rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
}
.btn-logout:hover { border-color: var(--accent); color: var(--text); }

/* ── Breadcrumb ───────────────────────────────────────── */
#breadcrumb, .series-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}
.bc-item {
  cursor: pointer;
  color: var(--text-muted);
  transition: color 0.15s;
  background: none;
  border: none;
  padding: 0;
  font-size: 0.85rem;
  text-decoration: none;
}
.bc-item:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.bc-item.active { color: var(--text); cursor: default; pointer-events: none; text-decoration: none; }
.bc-sep { color: #555; user-select: none; }

/* ── Section title ────────────────────────────────────── */
.section-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent-secondary);
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.section-title-bordered {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent-secondary);
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}
.count-badge {
  background: var(--border);
  border-radius: 10px;
  padding: 0.1rem 0.45rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* ── Type badges ──────────────────────────────────────── */
.type-badge {
  display: inline-block;
  border-radius: 4px;
  padding: 0.15rem 0.45rem;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.type-badge.kiosque   { background: rgba(231,76,60,0.2);  color: #e74c3c; }
.type-badge.librairie { background: rgba(243,156,18,0.2); color: #f39c12; }
.type-badge.issues_us { background: rgba(52,152,219,0.2); color: #3498db; }
.type-badge.events    { background: rgba(155,89,182,0.2); color: #9b59b6; }
.type-badge.reading-order { background: rgba(46,204,113,0.2); color: #2ecc71; }

/* ── Cards common ─────────────────────────────────────── */
.series-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  position: relative;
  contain: layout style paint;
  will-change: transform;
  content-visibility: auto;
  contain-intrinsic-size: 160px 300px;
}
.series-card::after {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  box-shadow: 0 8px 24px rgba(231,76,60,0.18);
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
  z-index: -1;
}
.series-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.series-card:hover::after { opacity: 1; }
.series-card.in-progress { border-color: var(--success); box-shadow: 0 0 0 1px var(--success); }
.series-card .reading-badge {
  position: absolute; top: 0.4rem; right: 0.4rem;
  background: var(--success); color: #fff;
  font-size: 0.55rem; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase; padding: 0.15rem 0.4rem;
  border-radius: 4px; z-index: 1; box-shadow: 0 2px 6px rgba(0,0,0,0.5);
}
.series-card .cover {
  width: 100%; aspect-ratio: 2/3; object-fit: cover;
  background: var(--border); display: block;
}
.series-card .cover-placeholder {
  width: 100%; aspect-ratio: 2/3; background: var(--border);
  display: flex; align-items: center; justify-content: center; font-size: 2.5rem;
}
.series-card .info { flex: 1; padding: 0.75rem; display: flex; flex-direction: column; gap: 0.2rem; }
.series-card .s-title { font-weight: 600; font-size: 0.85rem; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.series-card .s-year { font-size: 0.7rem; color: var(--text-muted); }
.series-card .s-issues { font-size: 0.68rem; color: var(--text-muted); opacity: 0.75; }

/* ── Auth overlay ─────────────────────────────────────── */
#auth-overlay {
  position: fixed; inset: 0; background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1.5rem; z-index: 100;
}
#auth-overlay .logo-big { display: flex; flex-direction: column; align-items: center; gap: 0.75rem; }
#auth-overlay h2 { color: var(--accent); font-size: 2rem; font-weight: 900; letter-spacing: -0.03em; }
#auth-overlay p { color: var(--text-muted); font-size: 0.9rem; }
#login-btn {
  background: var(--accent); color: #fff; border: none;
  padding: 0.75rem 2rem; border-radius: 8px;
  font-size: 1rem; font-weight: 700; cursor: pointer; transition: background 0.15s;
}
#login-btn:hover { background: var(--accent-hover); }

/* ── Shimmer / skeleton ───────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position:  400px 0; }
}
.skeleton { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.skeleton-cover { width: 100%; aspect-ratio: 2/3; background: linear-gradient(90deg, var(--border) 25%, #22222e 50%, var(--border) 75%); background-size: 400px 100%; animation: shimmer 1.4s infinite linear; }
.skeleton-info { padding: 0.75rem; display: flex; flex-direction: column; gap: 0.5rem; }
.skeleton-line { height: 12px; border-radius: 4px; background: linear-gradient(90deg, var(--border) 25%, #22222e 50%, var(--border) 75%); background-size: 400px 100%; animation: shimmer 1.4s infinite linear; }
.skeleton-line.short { width: 60%; }

/* ── Image fade-in ────────────────────────────────────── */
.cover-img {
  opacity: 0; transition: opacity 0.4s ease;
  background: linear-gradient(90deg, var(--border) 25%, #22222e 50%, var(--border) 75%);
  background-size: 400px 100%; animation: shimmer 1.4s infinite linear;
}
.cover-img.img-loaded { opacity: 1; animation: none; background: var(--border); }

/* ── State messages ───────────────────────────────────── */
.state-msg { text-align: center; padding: 4rem 1rem; color: var(--text-muted); }
.state-msg.error { color: var(--danger); }
.state-error { text-align: center; padding: 4rem 1rem; color: var(--danger); }
.no-results { grid-column: 1 / -1; text-align: center; padding: 3rem 0; color: var(--text-muted); }
.loading-center { text-align: center; padding: 3rem; color: var(--text-muted); }
.error-msg { text-align: center; padding: 2rem; color: var(--danger); }
.empty-msg { text-align: center; padding: 2rem; color: var(--text-muted); font-size: 0.85rem; }

/* ════════════════════════════════════════════════════════
   HOME
   ════════════════════════════════════════════════════════ */

/* Publisher grid */
#publishers-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1.25rem; }
.publisher-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 1.5rem 1.5rem 1.25rem; cursor: pointer; transition: transform 0.15s, border-color 0.15s; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 0.75rem; position: relative; contain: layout style paint; will-change: transform; }
.publisher-card::after { content: ''; position: absolute; inset: -1px; border-radius: inherit; box-shadow: 0 8px 24px rgba(231,76,60,0.18); opacity: 0; transition: opacity 0.15s; pointer-events: none; z-index: -1; }
.publisher-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.publisher-card:hover::after { opacity: 1; }
.publisher-name { font-size: 1.2rem; font-weight: 800; color: var(--text); letter-spacing: -0.01em; }
.publisher-meta { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: center; font-size: 0.78rem; color: var(--text-muted); }
.meta-tag { background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 0.1rem 0.4rem; }
.publisher-logo { min-height: 80px; display: flex; align-items: center; justify-content: center; }
.publisher-logo svg { max-width: 140px; max-height: 80px; }

/* Categories grid */
#categories-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1.25rem; }
.category-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 1.25rem; cursor: pointer; transition: transform 0.15s, border-color 0.15s; display: flex; flex-direction: column; gap: 0.5rem; position: relative; contain: layout style paint; will-change: transform; }
.category-card::after { content: ''; position: absolute; inset: -1px; border-radius: inherit; box-shadow: 0 8px 24px rgba(231,76,60,0.18); opacity: 0; transition: opacity 0.15s; pointer-events: none; z-index: -1; }
.category-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.category-card:hover::after { opacity: 1; }
.category-name { font-size: 1rem; font-weight: 600; color: var(--text); }
.category-count { font-size: 0.78rem; color: var(--text-muted); margin-top: auto; }
.category-card .cat-preview { width: 100%; height: 80px; border-radius: 8px; overflow: hidden; background: var(--bg); display: flex; gap: 3px; margin-bottom: 0.5rem; }
.category-card .cat-preview img { height: 100%; flex: 1; min-width: 0; object-fit: cover; border-radius: 4px; }
.category-card .cat-preview .cat-preview-ph { height: 100%; flex: 1; background: var(--border); border-radius: 4px; display: flex; align-items: center; justify-content: center; }

/* Reading progress row */
.reading-progress-row { display: flex; gap: 1rem; overflow-x: auto; padding-bottom: 0.5rem; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.rp-card { flex: 0 0 auto; width: 160px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; text-decoration: none; color: inherit; transition: transform 0.15s, border-color 0.15s; display: flex; flex-direction: column; position: relative; contain: layout style paint; will-change: transform; }
.rp-card::after { content: ''; position: absolute; inset: -1px; border-radius: inherit; box-shadow: 0 8px 24px rgba(231,76,60,0.18); opacity: 0; transition: opacity 0.15s; pointer-events: none; z-index: -1; }
.rp-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.rp-card:hover::after { opacity: 1; }
.rp-remove-btn { position: absolute; top: 4px; right: 4px; z-index: 10; width: 20px; height: 20px; border-radius: 50%; background: rgba(0,0,0,.65); border: none; cursor: pointer; color: #ccc; font-size: 14px; line-height: 1; display: none; align-items: center; justify-content: center; padding: 0; transition: background .15s, color .15s; }
.rp-card:hover .rp-remove-btn { display: flex; }
.rp-remove-btn:hover { background: var(--accent); color: #fff; }
.rp-cover { width: 100%; aspect-ratio: 2/3; object-fit: cover; background: var(--border); display: block; }
.rp-cover-ph { width: 100%; aspect-ratio: 2/3; background: var(--border); display: flex; align-items: center; justify-content: center; }
.rp-info { padding: 0.5rem; flex: 1; display: flex; flex-direction: column; gap: 0.15rem; }
.rp-title { font-weight: 600; font-size: 0.78rem; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rp-detail { font-size: 0.68rem; color: var(--accent-secondary); }
.rp-progress-bar { height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; margin-top: 0.25rem; }
.rp-progress-bar .rp-progress-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.3s ease; }

/* Series grid */
#series-grid-main, .series-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1.25rem; }

/* Issue card (canonical — all-issues flat view) */
.series-card .issue-number { position: absolute; top: 0.4rem; right: 0.4rem; background: var(--accent); color: #fff; font-size: 0.75rem; font-weight: 700; min-width: 1.6rem; height: 1.6rem; line-height: 1.6rem; text-align: center; border-radius: 50%; padding: 0 0.3rem; box-shadow: 0 2px 6px rgba(0,0,0,0.5); z-index: 1; }

.issue-card .global-badge { background: linear-gradient(135deg, #e74c3c, #c0392b); color: #fff; font-size: 0.95rem; font-weight: 800; letter-spacing: 0.04em; text-align: center; padding: 0.35rem 0; position: relative; }
.ic-reading-badge { position: absolute; right: 0.35rem; top: 50%; transform: translateY(-50%); font-size: 0.55rem; font-weight: 600; letter-spacing: 0.03em; background: var(--success); color: #fff; padding: 0.1rem 0.35rem; border-radius: 3px; text-transform: uppercase; }

.issue-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; cursor: pointer; text-decoration: none; color: inherit; display: block; transition: transform 0.15s, border-color 0.15s; position: relative; contain: layout style paint; will-change: transform; content-visibility: auto; contain-intrinsic-size: 160px 320px; }
.issue-card::after { content: ''; position: absolute; inset: -1px; border-radius: inherit; box-shadow: 0 8px 24px rgba(231,76,60,0.18); opacity: 0; transition: opacity 0.15s; pointer-events: none; z-index: -1; }
.issue-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.issue-card:hover::after { opacity: 1; }
.issue-card.current { border-color: var(--success); box-shadow: 0 0 0 1px var(--success); }

.issue-card .ic-cover { width: 100%; aspect-ratio: 2/3; object-fit: cover; background: var(--border); display: block; }
.issue-card .ic-cover-ph { width: 100%; aspect-ratio: 2/3; background: var(--border); display: flex; align-items: center; justify-content: center; font-size: 1.8rem; }
.issue-card .ic-info { padding: 0.5rem; }
.issue-card .ic-series { font-weight: 600; font-size: 0.78rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; height: 1.25em; line-height: 1.25; }
.issue-card .ic-detail { font-size: 0.72rem; margin-top: 0.2rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.issue-card .ic-detail .ic-num { font-weight: 700; color: var(--accent); }
.issue-card .ic-detail .ic-issue-title { color: var(--text-muted); }
.issue-card .ic-pages { font-size: 0.7rem; color: var(--text-muted); margin-top: 0.1rem; }
.ic-series-link { font-size: 0.7rem; color: var(--accent); cursor: pointer; opacity: 0; transition: opacity 0.15s; }
.issue-card:hover .ic-series-link { opacity: 0.7; }
.ic-series-link:hover { opacity: 1 !important; text-decoration: underline; }

.show-more-wrap { grid-column: 1 / -1; text-align: center; padding: 1rem 0; }
.btn-show-more { background: transparent; border: 1px solid var(--border); color: var(--text-muted); padding: 0.5rem 1.5rem; border-radius: 8px; cursor: pointer; font-size: 0.85rem; transition: border-color 0.15s, color 0.15s; }
.btn-show-more:hover { border-color: var(--accent); color: var(--text); }

/* Filter chips */
.filter-chip { background: transparent; border: 1px solid var(--border); color: var(--text-muted); padding: 0.2rem 0.6rem; border-radius: 6px; cursor: pointer; font-size: 0.75rem; transition: border-color 0.15s, color 0.15s, background 0.15s; }
.filter-chip:hover { border-color: var(--accent); color: var(--text); }
.filter-chip.active { border-color: var(--accent); color: var(--text); background: rgba(231,76,60,0.08); }

/* ════════════════════════════════════════════════════════
   SERIES
   ════════════════════════════════════════════════════════ */

/* Series state */
.series-state-msg { text-align: center; padding: 4rem 1rem; color: var(--text-muted); }
.series-state-msg.error { color: var(--danger); }

/* Hero */
.series-hero-wrap { position: relative; margin-bottom: 2.5rem; border-radius: 16px; overflow: hidden; }
.series-hero-backdrop { position: absolute; inset: 0; background-size: cover; background-position: center; filter: blur(40px) saturate(0.6) brightness(0.3); transform: scale(1.2); z-index: 0; }
.series-hero { position: relative; z-index: 1; display: flex; gap: 2rem; align-items: flex-start; padding: 1.5rem; }
.series-hero-cover { width: 180px; flex-shrink: 0; }
.series-hero-cover img, .series-hero-cover .cover-ph { width: 180px; aspect-ratio: 2/3; object-fit: cover; border-radius: 10px; background: var(--border); display: block; box-shadow: 0 8px 32px rgba(0,0,0,0.5); }
.series-hero-cover .cover-ph { display: flex; align-items: center; justify-content: center; font-size: 3.5rem; }
.series-hero-info { flex: 1; display: flex; flex-direction: column; gap: 0.5rem; padding-top: 0.5rem; }
.series-hero-title { font-size: 1.7rem; font-weight: 800; line-height: 1.2; }
.series-hero-meta { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; font-size: 0.875rem; color: var(--text-muted); }
.meta-chip { background: var(--bg-card); border: 1px solid var(--border); border-radius: 6px; padding: 0.2rem 0.55rem; font-size: 0.8rem; }
.series-hero-description { font-size: 0.875rem; color: var(--text-muted); line-height: 1.6; max-width: 600px; margin-top: 0.25rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; align-items: center; }
.btn-continue { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.6rem 1.25rem; background: var(--accent); color: #fff; border: none; border-radius: 8px; font-size: 0.9rem; font-weight: 700; cursor: pointer; text-decoration: none; }
.btn-continue:hover { background: var(--accent-hover); }
.status-select { padding: 0.5rem 0.75rem; border-radius: 8px; background: rgba(0,0,0,0.4); border: 1.5px solid rgba(255,255,255,0.15); color: var(--text); cursor: pointer; font-size: 0.875rem; }
.status-select:focus { outline: none; border-color: var(--accent); }
.status-select option { background: var(--bg-card); }
.fav-btn { width: 36px; height: 36px; padding: 0; border-radius: 50%; background: rgba(0,0,0,0.4); border: 1.5px solid rgba(255,255,255,0.15); color: #ccc; cursor: pointer; font-size: 1.1rem; display: inline-flex; align-items: center; justify-content: center; }
.fav-btn.active { color: var(--accent-secondary); border-color: rgba(243,156,18,0.5); }
.fav-btn:hover { border-color: var(--accent-secondary); }

/* Series issues section */
.series-issues-section { margin-bottom: 2.5rem; }
.series-issues-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 1rem; }

/* Series-specific issue card additions */
.ic-num { font-weight: 700; font-size: 0.82rem; color: var(--accent); }
.ic-title { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 0.1rem; }
.badge-current { position: absolute; top: 6px; right: 6px; background: var(--success); color: #fff; font-size: 0.58rem; font-weight: 700; padding: 0.15rem 0.4rem; border-radius: 4px; text-transform: uppercase; }
.badge-new { position: absolute; top: 6px; left: 6px; background: var(--success); color: #fff; font-size: 0.58rem; font-weight: 700; padding: 0.15rem 0.4rem; border-radius: 4px; }
.badge-archived { position: absolute; bottom: 6px; left: 6px; background: #5dade2; color: #fff; font-size: 0.56rem; font-weight: 700; padding: 0.15rem 0.4rem; border-radius: 4px; text-transform: uppercase; letter-spacing: 0.04em; }

/* ════════════════════════════════════════════════════════
   READER
   ════════════════════════════════════════════════════════ */

:root {
  --reader-bg: #000;
  --reader-surface: rgba(13, 13, 20, 0.9);
  --reader-border: rgba(255,255,255,0.1);
  --reader-accent: #e74c3c;
  --reader-text: #e8e8f0;
  --reader-muted: #888;
  --reader-toolbar-h: 52px;
  --reader-sat: env(safe-area-inset-top, 0px);
}

header.reader-toolbar { background: var(--reader-surface); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--reader-border); height: calc(var(--reader-toolbar-h) + var(--reader-sat)); position: fixed; top: 0; left: 0; right: 0; z-index: 50; transition: transform 0.3s cubic-bezier(0.4,0,0.2,1); display: flex; align-items: flex-end; padding: 0 0.75rem; padding-top: var(--reader-sat); padding-bottom: 0; }
header.toolbar-hidden { transform: translateY(-100%); }
.reader-tb-row { display: flex; align-items: center; width: 100%; height: var(--reader-toolbar-h); gap: 0.4rem; }
.reader-tb-group { display: flex; align-items: center; gap: 0.35rem; }
#reader-back-btn { color: var(--reader-muted); text-decoration: none; font-size: 1.1rem; padding: 0 0.4rem; flex-shrink: 0; cursor: pointer; }
#reader-back-btn:hover { color: var(--reader-text); }
.reader-tb-title { flex: 1; font-size: 0.82rem; font-weight: 600; color: var(--reader-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#reader-page-info { color: #fff; font-size: 0.88rem; display: flex; align-items: baseline; gap: 2px; white-space: nowrap; }
#reader-page-info .cur { font-weight: 800; font-size: 1rem; color: var(--reader-accent); font-variant-numeric: tabular-nums; min-width: 2ch; text-align: right; display: inline-block; }
#reader-page-info .tot { color: var(--reader-muted); font-size: 0.78rem; }
.reader-toolbar-btn { background: rgba(255,255,255,0.07); border: 1px solid var(--reader-border); color: var(--reader-text); width: 32px; height: 32px; border-radius: 8px; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 0.75rem; flex-shrink: 0; }
.reader-toolbar-btn:hover { background: rgba(255,255,255,0.15); }
.reader-toolbar-btn.active { background: var(--reader-accent); border-color: var(--reader-accent); }

#reader-viewer { position: fixed; top: 0; bottom: 0; left: 0; right: 0; background: #000; display: flex; touch-action: none; user-select: none; -webkit-user-select: none; padding-top: calc(var(--reader-toolbar-h) + var(--reader-sat)); padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px)); }
#reader-viewer.full-center { padding-top: 0 !important; padding-bottom: 0 !important; }
.reader-carousel-container { display: flex; width: 100%; height: 100%; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; background: #000; }
.reader-carousel-container::-webkit-scrollbar { display: none; }
.reader-carousel-container.no-snap { scroll-snap-type: none; scroll-behavior: auto; }
.reader-carousel-item { flex: 0 0 100%; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; scroll-snap-align: center; scroll-snap-stop: always; background: #000; position: relative; overflow: hidden; }
.reader-carousel-img { max-height: 100%; max-width: 100%; object-fit: contain; transform: translate3d(0,0,0); }

#reader-slider-wrap { position: fixed; bottom: 0; left: 0; right: 0; height: calc(56px + env(safe-area-inset-bottom, 0px)); padding-bottom: env(safe-area-inset-bottom, 0px); z-index: 60; display: flex; align-items: center; -webkit-tap-highlight-color: transparent; user-select: none; opacity: 0; transition: opacity 0.4s ease; }
#reader-slider-wrap:hover, #reader-slider-wrap.slider-visible { opacity: 1; }
#reader-slider-bg { height: 4px; width: calc(100% - 40px); margin: 0 auto; background: rgba(255,255,255,0.12); border-radius: 2px; position: relative; }
#reader-slider-fill { position: absolute; top: 0; bottom: 0; left: 0; background: var(--reader-accent); border-radius: 2px; width: 0; transition: width 0.2s ease-out; }
#reader-slider-wrap.is-sliding #reader-slider-fill { transition: none; }
#reader-slider-thumb { position: absolute; top: 50%; left: var(--tp, 0%); width: 14px; height: 14px; background: #fff; border-radius: 50%; transform: translate(-50%, -50%); z-index: 3; pointer-events: none; box-shadow: 0 2px 8px rgba(0,0,0,0.5); opacity: 0; transition: opacity 0.2s; }
#reader-slider-wrap.is-sliding #reader-slider-thumb { opacity: 1; }
#reader-slider-pop { position: absolute; bottom: 28px; left: clamp(24px, var(--tp, 0%), calc(100% - 24px)); transform: translateX(-50%) translateY(10px); background: var(--reader-accent); color: #fff; width: 3rem; height: 2rem; display: flex; align-items: center; justify-content: center; border-radius: 10px; font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; pointer-events: none; opacity: 0; box-shadow: 0 5px 20px rgba(0,0,0,0.5); transition: opacity 0.2s, transform 0.2s; }
#reader-slider-wrap.is-sliding #reader-slider-pop { opacity: 1; transform: translateX(-50%) translateY(0); }
#reader-slider-input { position: absolute; top: 50%; left: 0; width: 100%; height: 44px; transform: translateY(-50%); opacity: 0; margin: 0; padding: 0; cursor: pointer; -webkit-appearance: none; appearance: none; touch-action: pan-x; }

/* ── Reader page placeholder (3-dot loader) ── */
.reader-page-placeholder { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; position: absolute; top: 0; left: 0; z-index: 1; }
.dot-loader { position: relative; width: 10px; height: 10px; border-radius: 50%; background: rgba(255,255,255,0.35); animation: dot-pulse 1.2s ease-in-out 0.2s infinite; }
.dot-loader::before, .dot-loader::after { content: ''; position: absolute; top: 0; width: 10px; height: 10px; border-radius: 50%; background: rgba(255,255,255,0.35); }
.dot-loader::before { left: -18px; animation: dot-pulse 1.2s ease-in-out 0s infinite; }
.dot-loader::after { left: 18px; animation: dot-pulse 1.2s ease-in-out 0.4s infinite; }
@keyframes dot-pulse { 0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; } 40% { transform: scale(1); opacity: 1; } }
.reader-page-placeholder { flex-direction: column; gap: 12px; }
.placeholder-page-num { color: rgba(255,255,255,0.2); font-size: 0.75rem; font-variant-numeric: tabular-nums; }

#reader-loading-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--reader-muted); font-size: 0.95rem; background: rgba(0,0,0,0.5); z-index: 10; }
#reader-zoom-indicator { position: fixed; top: calc(var(--reader-toolbar-h) + var(--reader-sat) + 10px); right: 10px; background: rgba(0,0,0,0.6); color: #fff; padding: 3px 10px; border-radius: 20px; font-size: 11px; z-index: 60; opacity: 0; transition: opacity 0.3s; pointer-events: none; }
#reader-zoom-indicator.active { opacity: 1; }
#reader-next-toast { position: fixed; bottom: 4.5rem; left: 50%; transform: translateX(-50%); background: var(--reader-surface); backdrop-filter: blur(15px); border: 1px solid var(--reader-accent); border-radius: 16px; padding: 0.7rem 1.2rem; display: none; align-items: center; gap: 1rem; z-index: 100; box-shadow: 0 10px 40px rgba(0,0,0,0.7); white-space: nowrap; }
#reader-next-toast.visible { display: flex; }
#reader-keyboard-hint { position: fixed; bottom: 5rem; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,0.8); backdrop-filter: blur(8px); color: var(--reader-muted); padding: 0.5rem 1rem; border-radius: 10px; font-size: 0.75rem; z-index: 70; pointer-events: none; opacity: 1; transition: opacity 0.5s; white-space: nowrap; }
#reader-keyboard-hint.fade-out { opacity: 0; }
#reader-keyboard-hint kbd { background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.15); border-radius: 4px; padding: 0.1rem 0.35rem; font-family: inherit; font-size: 0.72rem; color: var(--reader-text); }

/* ════════════════════════════════════════════════════════
   ADMIN
   ════════════════════════════════════════════════════════ */

.admin-section { margin-bottom: 2.5rem; }
.section-header { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1rem; }
.stat-card { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 1rem 1rem 1rem 1.25rem; text-align: left; border-left: 3px solid var(--accent); transition: border-color 0.15s; }
.stat-card:nth-child(1) { border-left-color: #e74c3c; }
.stat-card:nth-child(2) { border-left-color: #f39c12; }
.stat-card:nth-child(3) { border-left-color: #3498db; }
.stat-card:nth-child(4) { border-left-color: #2ecc71; }
.stat-card:nth-child(5) { border-left-color: #9b59b6; }
.stat-card:nth-child(6) { border-left-color: #e67e22; }
.stat-value { font-size: 1.8rem; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat-label { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.25rem; }
.btn-rebuild { background: var(--accent-secondary); color: #1a1a24; border: none; padding: 0.6rem 1.5rem; border-radius: 8px; font-size: 0.9rem; font-weight: 700; cursor: pointer; }
.btn-rebuild:hover { background: #e67e22; }
.btn-rebuild:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-danger { background: transparent; border: 1px solid rgba(231,76,60,0.4); color: var(--danger); padding: 0.3rem 0.7rem; border-radius: 6px; font-size: 0.8rem; cursor: pointer; }
.btn-danger:hover { background: rgba(231,76,60,0.1); }
.btn-primary { background: var(--accent); color: #fff; border: none; padding: 0.45rem 1rem; border-radius: 7px; cursor: pointer; font-size: 0.85rem; font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary { background: transparent; border: 1px solid var(--border); color: var(--text-muted); padding: 0.3rem 0.75rem; border-radius: 6px; cursor: pointer; font-size: 0.8rem; }
.btn-secondary:hover { border-color: var(--accent); color: var(--text); }
.btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.data-table th, .data-table td { text-align: left; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); }
.data-table th { color: var(--text-muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,0.02); }
.status-badge { display: inline-block; border-radius: 4px; padding: 0.12rem 0.4rem; font-size: 0.68rem; font-weight: 700; text-transform: uppercase; }
.status-badge.confirmed { background: rgba(46,204,113,0.2); color: #2ecc71; }
.status-badge.force-pwd { background: rgba(243,156,18,0.2); color: #f39c12; }
.status-badge.other { background: rgba(136,136,136,0.2); color: #888; }
.toggle-wrap { display: flex; align-items: center; gap: 0.5rem; }
.toggle { position: relative; width: 36px; height: 20px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; inset: 0; background: var(--border); border-radius: 20px; transition: background 0.2s; }
.toggle-slider::before { content: ''; position: absolute; width: 14px; height: 14px; left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: transform 0.2s; }
.toggle input:checked + .toggle-slider { background: var(--success); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); }
.series-search { display: flex; gap: 0.75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.search-input { flex: 1; min-width: 200px; background: var(--bg); border: 1px solid var(--border); color: var(--text); padding: 0.45rem 0.75rem; border-radius: 8px; font-size: 0.875rem; }
.search-input:focus { outline: none; border-color: var(--accent); }
.create-user-form { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1.25rem; padding-bottom: 1.25rem; border-bottom: 1px solid var(--border); }
.form-group { display: flex; flex-direction: column; gap: 0.3rem; }
.form-label { font-size: 0.78rem; color: var(--text-muted); }
.form-input { background: var(--bg); border: 1px solid var(--border); color: var(--text); padding: 0.45rem 0.75rem; border-radius: 7px; font-size: 0.875rem; min-width: 200px; }
.form-input:focus { outline: none; border-color: var(--accent); }
.admin-toast { position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%); padding: 0.6rem 1.25rem; border-radius: 8px; font-size: 0.85rem; z-index: 999; }
.admin-toast.ok { background: rgba(46,204,113,0.15); border: 1px solid #2ecc71; color: #2ecc71; }
.admin-toast.err { background: rgba(231,76,60,0.15); border: 1px solid #e74c3c; color: #e74c3c; }
.admin-access-denied { text-align: center; padding: 4rem 1rem; }
.admin-access-denied h2 { color: var(--accent); font-size: 1.5rem; margin-bottom: 1rem; }
.admin-access-denied p { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1.5rem; }

/* ════════════════════════════════════════════════════════
   READING ORDER
   ════════════════════════════════════════════════════════ */

.ro-toolbar { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.ro-description { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 1.5rem; line-height: 1.5; }
.items-grid { display: flex; flex-direction: column; gap: 0.5rem; }
.ro-item { display: flex; align-items: center; gap: 1rem; background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 0.6rem 1rem; transition: border-color 0.15s; }
.ro-item:hover { border-color: rgba(231,76,60,0.4); }
.ro-item-num { color: var(--text-muted); font-size: 0.75rem; font-weight: 700; min-width: 28px; text-align: center; }
.ro-item-thumb { width: 44px; height: 60px; object-fit: cover; border-radius: 4px; flex-shrink: 0; background: var(--border); }
.ro-item-info { flex: 1; min-width: 0; }
.ro-item-series-row { display: flex; align-items: center; gap: 0.4rem; overflow: hidden; }
.ro-item-series { font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 1; }
.ro-item-title { font-size: 0.875rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ro-item-issue { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }
.ro-item-actions { display: flex; gap: 0.3rem; flex-shrink: 0; }
.ro-item-actions button { background: transparent; border: 1px solid var(--border); color: var(--text-muted); width: 28px; height: 28px; border-radius: 6px; cursor: pointer; font-size: 0.75rem; display: flex; align-items: center; justify-content: center; }
.ro-item-actions button:hover { border-color: var(--accent); color: var(--text); }
.ro-item-actions button.btn-danger:hover { border-color: var(--danger); color: var(--danger); }
.ro-item.in-progress { border-color: var(--success); box-shadow: 0 0 0 1px var(--success); }
.ro-item-thumb-wrap { position: relative; flex-shrink: 0; }
.ro-reading-badge { display: inline-block; flex-shrink: 0; background: var(--success); color: #fff; font-size: 0.5rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; padding: 0.1rem 0.3rem; border-radius: 3px; white-space: nowrap; }
@keyframes ro-highlight-fade { 0% { box-shadow: 0 0 0 2px rgba(255,255,255,0.5), 0 0 20px rgba(255,255,255,0.18); } 60% { box-shadow: 0 0 0 1px rgba(255,255,255,0.2), 0 0 12px rgba(255,255,255,0.08); } 100% { box-shadow: none; } }
.ro-item.ro-highlight { animation: ro-highlight-fade 2.5s ease-out forwards; }
.ro-item.dragging { opacity: 0.3; }
.ro-item.drag-over-top { border-top: 2px solid var(--accent); margin-top: -1px; }
.ro-item.drag-over-bottom { border-bottom: 2px solid var(--accent); margin-bottom: -1px; }
.ro-item .drag-handle { cursor: grab; color: var(--text-muted); font-size: 1.1rem; padding: 0 0.2rem; user-select: none; line-height: 1; }
.ro-item .drag-handle:active { cursor: grabbing; }
.edit-panel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 1.25rem; margin-bottom: 1.5rem; }
.edit-panel h3 { font-size: 0.9rem; color: var(--accent-secondary); margin-bottom: 0.75rem; }
.edit-search-input { width: 100%; background: var(--bg); border: 1px solid var(--border); color: var(--text); padding: 0.5rem 0.75rem; border-radius: 8px; font-size: 0.875rem; margin-bottom: 0.75rem; }
.edit-search-input:focus { outline: none; border-color: var(--accent); }
.search-results-list { display: flex; flex-direction: column; gap: 0.3rem; max-height: 600px; overflow-y: auto; }
.sr-item { display: flex; gap: 0.75rem; align-items: center; padding: 0.5rem 0.6rem; border-radius: 8px; cursor: pointer; transition: background 0.1s; }
.sr-item:hover { background: rgba(255,255,255,0.05); }
.sr-item.selected { background: rgba(46,204,113,0.1); border: 1px solid rgba(46,204,113,0.3); }
.sr-item.sr-issue { border-left: 3px solid #3498db; padding-left: 0.55rem; }
.sr-item.sr-added { opacity: 0.5; }
.sr-thumb { width: 36px; height: 48px; object-fit: cover; border-radius: 3px; flex-shrink: 0; background: var(--border); }
.sr-info { flex: 1; min-width: 0; }
.sr-title { font-size: 0.8rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-meta { font-size: 0.7rem; color: var(--text-muted); }
.sr-badge-issue { background: rgba(52,152,219,0.2); color: #3498db; padding: 0.1rem 0.4rem; border-radius: 4px; font-size: 0.65rem; margin-left: 0.3rem; }
.sr-added-tag { color: var(--text-muted); font-size: 0.7rem; flex-shrink: 0; }
.issues-picker { margin-top: 0.75rem; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 0.75rem; max-height: 300px; overflow-y: auto; }
.issues-picker h4 { font-size: 0.8rem; color: var(--accent-secondary); margin-bottom: 0.5rem; }
.issue-pick-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.35rem 0.5rem; border-radius: 6px; font-size: 0.8rem; cursor: pointer; transition: background 0.1s; }
.issue-pick-row:hover { background: rgba(255,255,255,0.05); }
.issue-pick-row.added { opacity: 0.5; cursor: default; }
.issue-pick-num { font-weight: 700; color: var(--text-muted); min-width: 32px; }
.issue-pick-title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.issue-pick-btn { background: var(--success); color: #fff; border: none; border-radius: 4px; padding: 0.15rem 0.5rem; font-size: 0.7rem; cursor: pointer; font-weight: 600; }
.issue-pick-btn:disabled { background: var(--border); cursor: default; }
.btn-sm { background: transparent; border: 1px solid var(--border); color: var(--text-muted); padding: 0.25rem 0.6rem; border-radius: 6px; cursor: pointer; font-size: 0.78rem; }
.btn-sm:hover { border-color: var(--accent); color: var(--text); }
.btn-sm.active { border-color: var(--success); color: var(--success); }
.btn-sm.danger:hover { border-color: var(--danger); color: var(--danger); }

/* ── View container (SPA shell) ───────────────────────── */
#view-container {
  padding: 1.5rem 2rem;
  max-width: 1600px;
  margin: 0 auto;
}

/* Reader has no padding — full viewport */
body.is-reader-active #view-container {
  padding: 0;
  max-width: none;
}

/* ════════════════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  main { padding: 1.5rem 1rem; }
  #publishers-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
  #series-grid-main, .series-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

@media (max-width: 600px) {
  :root { --reader-toolbar-h: 46px; }
  .series-hero { flex-direction: column; gap: 1.25rem; padding: 1rem; }
  .series-hero-cover { width: 140px; }
  .series-hero-cover img, .series-hero-cover .cover-ph { width: 140px; }
  .ro-item { padding: 0.5rem 0.6rem; gap: 0.6rem; }
  .ro-item-thumb { width: 36px; height: 50px; }
}

@media (max-width: 480px) {
  header { padding: 0.5rem 0.75rem; gap: 0.5rem; }
  main { padding: 1rem 0.75rem; }
  .header-search input[type="search"] { max-width: 100%; }
  .header-actions > span { display: none; }
  #series-grid-main, .series-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 0.75rem; }
  .series-hero-cover { width: 110px; }
  .series-hero-cover img, .series-hero-cover .cover-ph { width: 110px; }
  .series-hero-title { font-size: 1.1rem; }
  .series-issues-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 0.75rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .data-table { font-size: 0.78rem; }
  .data-table th, .data-table td { padding: 0.4rem 0.5rem; }
}
