:root {
  --bg: #eff5f0;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #3ac628;
  --accent-dark: #1d8e2a;
  --shadow: 0 18px 45px rgba(17, 24, 39, 0.12);
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  background: linear-gradient(180deg, #f5faf5 0%, #e6f1e5 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow: hidden;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
}

.app-shell {
  width: min(1400px, calc(100% - 32px));
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  padding: 18px 0 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

h1 {
  margin: 0;
  font-size: clamp(1.45rem, 2.7vw, 2.3rem);
  line-height: 1.1;
}

main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.controls {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  flex: 0 0 auto;
}

.select-wrap,
.viewer-toolbar,
.mobile-tip,
.viewer-status,
#issueTitle,
#pageInfo {
  display: none !important;
}

.btn {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  min-height: 44px;
  padding: 0 14px;
  font-size: 0.95rem;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
  border-color: #d2d6dc;
  box-shadow: 0 8px 20px rgba(17, 24, 39, 0.06);
}

.btn:active {
  transform: translateY(0);
}

#fullscreenBtn {
  width: auto;
  white-space: nowrap;
}

.viewer-card {
  flex: 1;
  min-height: 0;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(229, 231, 235, 0.95);
  border-radius: var(--radius);
  padding: 10px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
}

.book-shell {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  border-radius: 20px;
  background:
    radial-gradient(circle at top left, rgba(198, 40, 40, 0.08), transparent 30%),
    linear-gradient(180deg, #daefe2 0%, #d2e8d6 100%);
  padding: 10px;
  overflow: hidden;
}

#book {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

#book [class^="stf__"],
#book [class*=" stf__"] {
  background: transparent !important;
  box-shadow: none !important;
}

.page {
  position: relative;
  background: transparent;
  overflow: hidden;
  user-select: none;
}

.page img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  object-position: center center;
  user-select: none;
  -webkit-user-drag: none;
  background: transparent;
}


.blank-page {
  background:
    radial-gradient(circle at top left, rgba(198, 40, 40, 0.08), transparent 30%),
    linear-gradient(180deg, #daefe2 0%, #d2e8d6 100%) !important;
}

.blank-page::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at top left, rgba(198, 40, 40, 0.08), transparent 30%),
    linear-gradient(180deg, #daefe2 0%, #d2e8d6 100%);
}

.blank-page > * {
  display: none !important;
}

.page.cover-page::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 14px;
  box-shadow: inset 0 0 0 1px rgba(17, 24, 39, 0.08);
}

.page.cover-page img {
  border-radius: 14px;
}

.loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 10;
  font-weight: 600;
  color: var(--accent-dark);
  background: rgba(255, 255, 255, 0.38);
  backdrop-filter: blur(2px);
}

.zoom-overlay {
  position: absolute;
  inset: 10px;
  z-index: 20;
  display: none;
  overflow: hidden;
  border-radius: 18px;
  cursor: zoom-out;
  background:
    radial-gradient(circle at top left, rgba(198, 40, 40, 0.08), transparent 30%),
    linear-gradient(180deg, #daefe2 0%, #d2e8d6 100%);
}

.zoom-overlay.active {
  display: block;
}

.book-shell.zoom-active #book {
  pointer-events: none;
}

.zoom-image {
  position: absolute;
  left: 50%;
  top: 50%;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  transform-origin: center center;
  will-change: transform;
  user-select: none;
  -webkit-user-drag: none;
}

.zoom-hint {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 2;
  padding: 8px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  color: #0f172a;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(17, 24, 39, 0.08);
  backdrop-filter: blur(4px);
  pointer-events: none;
}

.zoom-mobile-nav {
  display: none;
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  z-index: 3;
  gap: 10px;
}

.zoom-nav-btn {
  min-width: 52px;
  min-height: 44px;
  border: 1px solid rgba(17, 24, 39, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  color: #0f172a;
  font-size: 1.1rem;
  font-weight: 700;
  backdrop-filter: blur(4px);
}

.zoom-overlay.is-touching {
  cursor: grab;
}

.zoom-overlay.is-touching:active {
  cursor: grabbing;
}

.fullscreen-mode {
  overflow: hidden;
}

.fullscreen-mode .app-shell {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  padding: 12px;
}

.fullscreen-mode .viewer-card {
  border-radius: 20px;
}

@media (pointer: coarse), (max-width: 980px) {
  .zoom-mobile-nav {
    display: flex;
  }

  .zoom-hint {
    right: 50%;
    transform: translateX(50%);
    bottom: 70px;
    text-align: center;
    max-width: calc(100% - 24px);
  }
}

@media (max-width: 980px) {
  .app-shell {
    width: min(100%, calc(100% - 16px));
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .topbar {
    align-items: center;
    gap: 12px;
  }

  .viewer-card {
    padding: 8px;
    border-radius: 18px;
  }

  .book-shell {
    padding: 8px;
  }
}

@media (max-width: 640px) {
  .eyebrow {
    margin-bottom: 4px;
  }

  h1 {
    font-size: clamp(1.25rem, 6vw, 1.8rem);
  }

  .btn {
    min-height: 40px;
    padding: 0 12px;
    font-size: 0.92rem;
  }

  #fullscreenBtn {
    align-self: flex-start;
  }
}

/* Correctif mobile/tablette : page simple sans double-page StPageFlip */
#book.flat-book {
  display: grid;
  place-items: center;
  max-width: 100%;
  max-height: 100%;
  touch-action: manipulation;
}

#book.flat-book .flat-page {
  width: 100%;
  height: 100%;
  border-radius: 14px;
  box-shadow: 0 10px 28px rgba(17, 24, 39, 0.16);
}

#book.flat-book .flat-page img {
  border-radius: 14px;
}

.zoom-overlay.active {
  touch-action: none;
}

.zoom-mobile-nav,
.zoom-nav-btn {
  pointer-events: auto;
  touch-action: manipulation;
}

.zoom-nav-btn {
  cursor: pointer;
}

@media (pointer: coarse), (max-width: 1099px) {
  .zoom-mobile-nav {
    display: flex;
  }
}
