:root {
  --pw: 120px;                 /* pocket width, set by app.js to fit the window */
  --ph: calc(var(--pw) * 88 / 63);
  --gap: calc(var(--pw) * 0.06);
  --pad: calc(var(--pw) * 0.12);
  --leather: #2b2f4a;
  --leather-dark: #1b1e33;
  --page: #121420;
  --pocket: rgba(255, 255, 255, 0.05);
  --flip-ms: 650ms;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: #e9ecf5;
  background: radial-gradient(ellipse at top, #3a3f63 0%, #14162a 70%);
  overflow: hidden;
}

.toolbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 12px 28px 0;
}
.toolbar h1 { margin: 0; font-size: 1.3rem; letter-spacing: 0.5px; }
.stats { font-size: 0.9rem; opacity: 0.75; }

.stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  perspective: 2400px;
}

.nav {
  width: 48px; height: 48px;
  border-radius: 50%;
  border: none;
  font-size: 2rem;
  line-height: 1;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
}
.nav:hover:not(:disabled) { background: rgba(255, 255, 255, 0.25); }
.nav:disabled { opacity: 0.2; cursor: default; }

/* ---------- Binder ---------- */
.binder {
  position: relative;
  display: flex;
  padding: 14px 10px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--leather), var(--leather-dark));
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.55), inset 0 0 0 2px rgba(255, 255, 255, 0.05);
  transform-style: preserve-3d;
}
.cover-edge { width: 8px; }

.page-slot {
  position: relative;
  transform-style: preserve-3d;
}

.page {
  width: calc(var(--pw) * var(--cols) + var(--gap) * (var(--cols) - 1) + var(--pad) * 2);
  height: calc(var(--ph) * var(--rows) + var(--gap) * (var(--rows) - 1) + var(--pad) * 2 + 22px);
  padding: var(--pad);
  padding-bottom: calc(var(--pad) + 22px);
  background: linear-gradient(180deg, #181b2c, var(--page));
  border-radius: 6px;
  box-shadow: inset 0 0 25px rgba(0, 0, 0, 0.6);
  position: relative;
}
.page.left  { border-radius: 8px 2px 2px 8px; }
.page.right { border-radius: 2px 8px 8px 2px; }

.page .grid {
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--pw));
  grid-auto-rows: var(--ph);
  gap: var(--gap);
}

.page .page-no {
  position: absolute;
  bottom: 6px;
  font-size: 0.75rem;
  opacity: 0.55;
}
.page.left .page-no  { left: 14px; }
.page.right .page-no { right: 14px; }

.page.cover-inside {
  display: flex;
  align-items: center;
  justify-content: center;
  background: repeating-linear-gradient(45deg, #1f2238 0 12px, #23274a 12px 24px);
}
.cover-inside .cover-text { opacity: 0.5; font-size: 1.1rem; letter-spacing: 2px; text-transform: uppercase; }

/* ---------- Pockets ---------- */
.pocket {
  position: relative;
  border-radius: calc(var(--pw) * 0.05);
  background: var(--pocket);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  overflow: hidden;
  cursor: pointer;
}
/* plastic sleeve sheen */
.pocket::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(120deg, rgba(255,255,255,0.12) 0%, rgba(255,255,255,0) 35%, rgba(255,255,255,0) 70%, rgba(255,255,255,0.06) 100%);
  pointer-events: none;
}
.pocket img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.2s;
}
.pocket.filled:hover img { transform: scale(1.04); }

.pocket.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px dashed rgba(255, 255, 255, 0.15);
  box-shadow: none;
}
.pocket.empty .pin { font-size: calc(var(--pw) * 0.28); filter: drop-shadow(0 2px 3px rgba(0,0,0,0.5)); opacity: 0.85; }
.pocket.empty .slot-no { margin-top: 6px; font-size: calc(var(--pw) * 0.1); opacity: 0.45; }
.pocket.empty:hover { background: rgba(255, 255, 255, 0.08); }

/* ---------- Wanted pockets ---------- */
.pocket.wanted { box-shadow: inset 0 0 0 calc(var(--pw) * 0.025) #e23b3b, 0 0 calc(var(--pw) * 0.06) rgba(226, 59, 59, 0.55); }
.pocket.wanted img { opacity: 0.55; filter: saturate(0.6); }
.pocket.wanted:hover img { opacity: 0.8; }
.want-band {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%) rotate(-54.4deg); /* bottom-left to top-right on a 63x88 card */
  width: 160%;
  text-align: center;
  font-weight: 900;
  font-size: calc(var(--pw) * 0.2);
  letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.9);
  background: rgba(200, 30, 30, 0.55);
  padding: calc(var(--pw) * 0.02) 0;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}
.want-nav {
  position: absolute; bottom: 4%;
  width: calc(var(--pw) * 0.2); height: calc(var(--pw) * 0.2);
  border: none; border-radius: 50%;
  background: rgba(0, 0, 0, 0.65); color: #fff;
  font-size: calc(var(--pw) * 0.16); line-height: 1;
  cursor: pointer; z-index: 2;
}
.want-nav.prev { left: 5%; }
.want-nav.next { right: 5%; }
.want-nav:hover { background: #e23b3b; }
.swap-badge {
  position: absolute; top: 4%; right: 5%; z-index: 2;
  width: calc(var(--pw) * 0.16); height: calc(var(--pw) * 0.16); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: #e23b3b; color: #fff; font-size: calc(var(--pw) * 0.1); font-weight: 700;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5); pointer-events: none;
}
.swap-detail { margin-top: 24px; border-top: 1px solid rgba(255, 255, 255, 0.15); padding-top: 16px; }
.want-count {
  position: absolute; bottom: 5%; left: 50%; transform: translateX(-50%);
  padding: 2px 8px; border-radius: 10px;
  background: rgba(0, 0, 0, 0.65); color: #fff;
  font-size: calc(var(--pw) * 0.09); z-index: 2;
}
.want-detail { min-width: 520px; max-height: 80vh; overflow-y: auto; }
.want-detail h2 { color: #ff6b6b; }
.want-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 18px; }
.want-item { display: flex; gap: 18px; align-items: flex-start; }
.modal-card .want-item img { width: 150px; }
.want-item h3 { margin: 0 0 2px; }
.dim { opacity: 0.55; font-size: 0.85em; }

/* ---------- Spine ---------- */
.spine {
  width: 34px;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  align-items: center;
  background: linear-gradient(90deg, #11131f, #2b2f48 50%, #11131f);
  z-index: 5;
}
.ring {
  width: 30px; height: 14px;
  border-radius: 8px;
  background: linear-gradient(180deg, #e6e9f2, #8a90a8);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

/* ---------- Page turn ---------- */
.leaf {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform var(--flip-ms) cubic-bezier(0.45, 0.05, 0.3, 1);
  z-index: 10;
}
.leaf.forward  { transform-origin: left center; }
.leaf.backward { transform-origin: right center; }
.leaf .face {
  position: absolute; top: 0; left: 0;
  backface-visibility: hidden;
}
.leaf .face.back { transform: rotateY(180deg); }
.leaf.forward.turn  { transform: rotateY(-180deg); }
.leaf.backward.turn { transform: rotateY(180deg); }

/* ---------- Footer ---------- */
.pager {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  padding: 0 0 14px;
  font-size: 0.95rem;
}
.pager select {
  background: #23274a;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  padding: 4px 8px;
}

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 6, 15, 0.75);
  z-index: 100;
}
.modal[hidden] { display: none; }
.modal-card {
  position: relative;
  display: flex;
  gap: 24px;
  max-width: 760px;
  padding: 24px;
  border-radius: 14px;
  background: #1c1f35;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}
.modal-card img { width: 300px; border-radius: 12px; }
.modal-card h2 { margin: 0 0 4px; }
.modal-card .sub { opacity: 0.7; margin-bottom: 14px; }
.modal-card dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 0.92rem; }
.modal-card dt { opacity: 0.6; }
.modal-card dd { margin: 0; }
.modal-card a { color: #8fb4ff; }
.modal-card .close {
  position: absolute; top: 8px; right: 12px;
  background: none; border: none; color: #fff;
  font-size: 1.8rem; cursor: pointer; opacity: 0.7;
}
.empty-detail { min-width: 320px; text-align: center; }
.empty-detail .pin { font-size: 3rem; }
