:root {
  --bg: #1d1530;
  --bg-2: #2a1f44;
  --accent: #7d4bd6;
  --accent-2: #b89bf0;
  --ink: #f3eef9;
  --toolbar-h: 52px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(120% 120% at 50% 0%, var(--bg-2), var(--bg));
  color: var(--ink);
  font-family: -apple-system, "PingFang TC", "Noto Sans CJK TC", "Microsoft JhengHei", "Segoe UI", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- toolbar ---------- */
.toolbar {
  height: var(--toolbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  background: rgba(20, 14, 34, .72);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  user-select: none;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 15px; letter-spacing: .02em; }
.brand .dot { width: 9px; height: 9px; border-radius: 50%; background: linear-gradient(135deg, var(--accent-2), var(--accent)); box-shadow: 0 0 12px var(--accent); }

.controls { display: flex; align-items: center; gap: 6px; }
.controls button {
  appearance: none; border: 1px solid rgba(255,255,255,.14); background: rgba(255,255,255,.06);
  color: var(--ink); width: 34px; height: 34px; border-radius: 9px; font-size: 17px; line-height: 1;
  cursor: pointer; transition: background .15s, transform .05s, border-color .15s;
}
.controls button:hover { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.28); }
.controls button:active { transform: translateY(1px); }
.controls button:disabled { opacity: .3; cursor: default; }
#indicator { min-width: 96px; text-align: center; font-variant-numeric: tabular-nums; font-size: 13px; opacity: .9; }
#goto-form { display: inline; }
#goto {
  width: 64px; height: 34px; border-radius: 9px; border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.06); color: var(--ink); text-align: center; font-size: 13px;
}
#goto::placeholder { color: rgba(255,255,255,.4); }
/* hide number spinners */
#goto::-webkit-outer-spin-button, #goto::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

@media (max-width: 640px) {
  .brand #title { display: none; }
  #last, #first { display: none; }
  #goto { width: 52px; }
}

/* ---------- stage / book ---------- */
#stage {
  position: absolute;
  inset: var(--toolbar-h) 0 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  overflow: hidden;
}
/* #book-wrap 的寬高由 app.js 依視窗大小、保持「跨頁(雙頁) / 單頁」比例算好，
   讓 StPageFlip 拿到穩定且正確的尺寸 —— 避免它先把跨頁攤到視窗左右兩端、再「啪」一下縮回中間。 */
#book-wrap { position: relative; flex: 0 0 auto; }
#book { width: 100%; height: 100%; min-width: 0 !important; min-height: 0 !important; }
/* 蓋掉 StPageFlip 內部 wrapper 的 padding-bottom 自動高度，改成吃滿 #book-wrap */
#book .stf__wrapper { height: 100%; padding-bottom: 0 !important; }
#book .stf__block { width: 100%; height: 100%; }

/* page-flip pages */
.page {
  position: relative;
  width: 100%;
  height: 100%;
  background: #fff;
  background-image: repeating-linear-gradient(45deg, #f4f1f8 0 12px, #efe9f6 12px 24px);
  overflow: hidden;
}
.page .page-img { width: 100%; height: 100%; display: block; object-fit: cover; }
.page--hard { background: #4a2c7a; }

/* spinner shown until a page image is loaded */
.page:not(.is-loaded)::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 26px; height: 26px;
  border: 3px solid rgba(123,75,214,.25); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- boot overlay ---------- */
#boot {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--bg); color: var(--accent-2); font-size: 15px; letter-spacing: .1em;
  transition: opacity .4s; z-index: 50;
}
#boot.hide { opacity: 0; pointer-events: none; }

:fullscreen #stage { inset: 0; }
:-webkit-full-screen #stage { inset: 0; }
