﻿.flip-body { background: #1b2426; color: #f5ede6; }
.flip-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  background: #0e2a30;
}
.flip-bar a, .flip-bar button {
  color: #fff;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 999px;
  padding: 8px 14px;
  text-decoration: none;
  cursor: pointer;
  font-size: 14px;
}
.flip-bar h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  flex: 1;
}
.flip-stage {
  position: relative;
  min-height: calc(100vh - 168px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px 12px 8px;
  perspective: 2200px;
}
.spread {
  --page-w: 420px;
  --page-h: 580px;
  position: relative;
  width: calc(var(--page-w) * 2);
  height: var(--page-h);
  transform-style: preserve-3d;
}
.spread.cover-mode { width: var(--page-w); }
.spread.cover-mode .leaf.left { display: none; }
.leaf {
  position: absolute;
  top: 0;
  width: var(--page-w);
  height: var(--page-h);
  background: #fff;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 16px 40px rgba(0,0,0,0.35);
}
.leaf.left { left: 0; border-radius: 6px 0 0 6px; }
.leaf.right { right: 0; border-radius: 0 6px 6px 0; }
.leaf canvas, .flip-face canvas {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: #fff;
}
.flipper {
  position: absolute;
  top: 0;
  right: 0;
  width: var(--page-w);
  height: var(--page-h);
  transform-origin: left center;
  transform-style: preserve-3d;
  pointer-events: none;
  opacity: 0;
  z-index: 5;
}
.flipper.flipping-forward,
.flipper.flipping-back { opacity: 1; }
.flipper.flipping-forward.turn {
  transition: transform 0.6s ease-in-out;
  transform: rotateY(-180deg);
}
.flipper.flipping-back {
  transform: rotateY(-180deg);
}
.flipper.flipping-back.turn {
  transition: transform 0.6s ease-in-out;
  transform: rotateY(0deg);
}
.flip-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  background: #fff;
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(0,0,0,0.28);
}
.flip-face.back { transform: rotateY(180deg); }
.flip-nav { display: none; }
.flip-toolbar {
  position: sticky;
  bottom: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 10px 12px;
  background: rgba(14, 42, 48, 0.94);
}
.flip-toolbar button,
.flip-toolbar a {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  cursor: pointer;
  text-decoration: none;
}
.flip-toolbar button:hover,
.flip-toolbar a:hover,
.flip-toolbar button.copied {
  background: rgba(255,255,255,0.12);
}
.flip-toolbar svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tb-gap { width: 10px; }
.page-jump {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #fff;
  font-size: 13px;
  margin: 0 6px;
}
.page-jump input {
  width: 52px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  border-radius: 6px;
  padding: 4px 6px;
  text-align: center;
}
.flip-stage.zoomed {
  overflow: auto;
  align-items: flex-start;
  justify-content: flex-start;
  min-height: 0;
  height: calc(100vh - 168px);
  max-height: calc(100vh - 168px);
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.flip-stage.zoomed .spread { flex-shrink: 0; }
.flip-stage.zoomed .leaf { cursor: grab; }
.flip-stage.zoomed.panning,
.flip-stage.zoomed.panning .leaf { cursor: grabbing; }
.thumbs {
  position: absolute;
  left: 12px;
  top: 12px;
  bottom: 12px;
  width: min(280px, 70vw);
  background: #10191b;
  border-radius: 12px;
  overflow: auto;
  z-index: 6;
  box-shadow: 0 12px 40px rgba(0,0,0,0.4);
}
.thumbs-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  color: #fff;
  font-size: 13px;
  position: sticky;
  top: 0;
  background: #10191b;
}
.thumbs-head button {
  background: none;
  border: 0;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
}
.thumbs-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 0 10px 12px;
}
.thumb {
  background: #1b2628;
  border: 0;
  border-radius: 6px;
  padding: 6px;
  cursor: pointer;
  color: #ddd;
  font-size: 11px;
}
.thumb canvas { width: 100%; height: auto; display: block; background: #fff; }
.portrait .spread,
.portrait.cover-mode .spread {
  width: var(--page-w);
}
.portrait .leaf.left { display: none; }
.portrait .leaf.right { right: 0; border-radius: 6px; }

html, body { margin: 0; }
body.flip-body { font-family: Georgia, 'Times New Roman', serif; }
.thumb { background: #1b2628; border: 0; border-radius: 6px; padding: 6px; cursor: pointer; color: #ddd; font-size: 11px; }
.thumb canvas { width: 100%; height: auto; display: block; background: #fff; }
@media (max-width: 720px) {
  .flip-bar { flex-wrap: wrap; padding: 10px 12px; }
  .flip-bar h1 { font-size: 14px; order: 3; flex: 1 1 100%; }
}
