:root {
  --bg: #1f1b17;
  --bg2: #3a3027;
  --panel: #26211c;
  --line: rgba(255, 255, 255, .12);
  --text: #f3ece2;
  --muted: #b9ac9a;
  --gold: #c9a45c;
  --gold-strong: #e0bd75;
  --top: 56px;
  --bottom: 58px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--gold-strong); outline-offset: 2px; }

.app { position: fixed; inset: 0; display: flex; flex-direction: column; background: radial-gradient(120% 90% at 50% 35%, var(--bg2) 0%, var(--bg) 70%); }

/* top bar */
.topbar { height: var(--top); flex: none; display: flex; align-items: center; gap: 16px; padding: 0 16px; border-bottom: 1px solid var(--line); background: rgba(20, 17, 14, .55); backdrop-filter: blur(6px); }
.brand { display: flex; flex-direction: column; line-height: 1.15; text-decoration: none; color: var(--text); white-space: nowrap; }
.brand-name { letter-spacing: .22em; font-size: 13px; font-weight: 600; }
.brand-sub { font-size: 11px; color: var(--gold); letter-spacing: .12em; text-transform: uppercase; }
.search { flex: 1; max-width: 520px; margin: 0 auto; display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255, 255, 255, .06); color: var(--muted); }
.search:focus-within { border-color: var(--gold); color: var(--text); }
.search input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; color: var(--text); }
.search input::placeholder { color: var(--muted); }
.shop-btn { flex: none; text-decoration: none; color: #1f1b17; background: var(--gold); padding: 8px 14px; border-radius: 18px; font-weight: 600; font-size: 13px; white-space: nowrap; }
.shop-btn:hover { background: var(--gold-strong); }

/* stage */
.stage { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 14px 56px; }
.book-wrap { position: relative; margin: 0 auto; filter: drop-shadow(0 18px 30px rgba(0, 0, 0, .45)); }
.book { margin: 0 auto; }
.page { background: #fff; overflow: hidden; }
.pg-inner { position: absolute; inset: 0; }
.pg-inner img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; user-select: none; -webkit-user-drag: none; }
.pg-inner .ph { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #b9ac9a; font-size: 13px; background: #f6f1ea; }
.hot { position: absolute; display: block; border-radius: 3px; z-index: 3; }
.hot:hover, .hot:focus-visible { background: rgba(201, 164, 92, .18); box-shadow: 0 0 0 1px rgba(201, 164, 92, .7); outline: 0; }
.hl { position: absolute; background: rgba(255, 213, 0, .42); border-radius: 2px; z-index: 2; pointer-events: none; mix-blend-mode: multiply; }

.nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 72px; border-radius: 10px; color: var(--text); background: rgba(255, 255, 255, .07); display: flex; align-items: center; justify-content: center; z-index: 5; }
.nav:hover { background: rgba(255, 255, 255, .16); }
.nav[disabled] { opacity: .25; cursor: default; }
.nav svg { width: 26px; height: 26px; }
.nav-prev { left: 8px; }
.nav-next { right: 8px; }
.hint { position: absolute; left: 50%; bottom: 6px; transform: translateX(-50%); max-width: 92%; padding: 6px 12px; border-radius: 14px; background: rgba(0, 0, 0, .55); color: var(--text); font-size: 12px; text-align: center; transition: opacity .4s; pointer-events: none; z-index: 6; }
.hint.hide { opacity: 0; }

/* toolbar */
.toolbar { height: var(--bottom); flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 12px; border-top: 1px solid var(--line); background: rgba(20, 17, 14, .7); }
.tb-group { display: flex; align-items: center; gap: 4px; }
.toolbar button, .tb-link { height: 40px; min-width: 40px; padding: 0 10px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; color: var(--text); text-decoration: none; font-size: 13px; }
.toolbar button:hover, .tb-link:hover { background: rgba(255, 255, 255, .1); }
.toolbar button[disabled] { opacity: .3; cursor: default; }
.pagebox { display: flex; align-items: center; gap: 6px; margin: 0 4px; color: var(--muted); }
.pagebox input { width: 52px; height: 32px; text-align: center; border: 1px solid var(--line); border-radius: 6px; background: rgba(255, 255, 255, .06); color: var(--text); }
.pagebox input:focus { border-color: var(--gold); outline: 0; }

/* drawers */
.drawer, .sheet { position: absolute; z-index: 20; background: var(--panel); border: 1px solid var(--line); display: flex; flex-direction: column; transition: transform .25s ease, opacity .25s ease; }
.drawer { top: var(--top); bottom: var(--bottom); width: min(340px, 88vw); }
.drawer-left { left: 0; transform: translateX(-105%); border-left: 0; }
.drawer-right { right: 0; transform: translateX(105%); border-right: 0; }
.drawer.open { transform: none; }
.sheet { left: 0; right: 0; bottom: var(--bottom); height: min(62vh, 520px); transform: translateY(110%); border-left: 0; border-right: 0; }
.sheet.open { transform: none; }
.drawer-head { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line); letter-spacing: .06em; }
.x { width: 32px; height: 32px; border-radius: 16px; font-size: 22px; line-height: 1; color: var(--muted); }
.x:hover { background: rgba(255, 255, 255, .1); color: var(--text); }
.toc, .results, .thumbs { overflow: auto; flex: 1; min-height: 0; }
.toc a { display: flex; justify-content: space-between; gap: 12px; padding: 11px 16px; color: var(--text); text-decoration: none; border-bottom: 1px solid rgba(255, 255, 255, .05); }
.toc a:hover, .toc a.cur { background: rgba(201, 164, 92, .14); }
.toc a span:last-child { color: var(--gold); }
.results .res { display: flex; gap: 10px; width: 100%; text-align: left; padding: 10px 14px; border-bottom: 1px solid rgba(255, 255, 255, .05); }
.results .res:hover { background: rgba(201, 164, 92, .14); }
.results .res img { width: 46px; height: 65px; object-fit: cover; flex: none; border-radius: 2px; background: #fff; }
.results .res b { color: var(--gold); display: block; font-size: 12px; letter-spacing: .06em; margin-bottom: 2px; }
.results .res span { color: var(--muted); font-size: 12.5px; line-height: 1.35; }
.results .res mark { background: none; color: var(--gold-strong); font-weight: 600; }
.results .empty { padding: 18px 16px; color: var(--muted); }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 12px; padding: 14px; }
.thumbs button { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 4px; border-radius: 6px; color: var(--muted); font-size: 12px; }
.thumbs button:hover, .thumbs button.cur { background: rgba(201, 164, 92, .18); color: var(--text); }
.thumbs img { width: 100%; aspect-ratio: 420 / 596; object-fit: cover; background: #fff; border-radius: 2px; }

/* zoom */
.zoom { position: absolute; inset: 0; z-index: 40; background: rgba(15, 12, 10, .96); display: none; }
.zoom.open { display: block; }
.zoom-scroll { position: absolute; inset: 0; overflow: auto; cursor: grab; touch-action: pan-x pan-y pinch-zoom; }
.zoom-scroll.drag { cursor: grabbing; }
.zoom-inner { display: flex; margin: 0 auto; padding: 20px; width: max-content; min-width: 100%; justify-content: center; }
.zpage { position: relative; flex: none; background: #fff; }
.zpage img { display: block; width: 100%; height: 100%; user-select: none; -webkit-user-drag: none; }
.zoom-tools { position: absolute; right: 16px; top: 16px; display: flex; gap: 8px; }
.zoom-tools button { width: 42px; height: 42px; border-radius: 21px; background: rgba(255, 255, 255, .14); color: #fff; font-size: 24px; line-height: 1; }
.zoom-tools button:hover { background: rgba(255, 255, 255, .28); }

.toast { position: absolute; left: 50%; bottom: calc(var(--bottom) + 14px); transform: translateX(-50%); padding: 8px 14px; border-radius: 16px; background: #000; color: #fff; font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 50; }
.toast.show { opacity: .9; }

/* embedded (iframe) and small screens */
@media (max-width: 760px) {
  :root { --top: 50px; --bottom: 54px; }
  .brand-sub, .shop-btn, .toolbar button span, .tb-link span { display: none; }
  .brand-name { font-size: 11px; letter-spacing: .14em; }
  .topbar { gap: 10px; padding: 0 10px; }
  .stage { padding: 8px 6px; }
  .nav { display: none; }
  .toolbar { padding: 0 4px; gap: 2px; }
  .toolbar button, .tb-link { min-width: 36px; padding: 0 7px; }
  .pagebox input { width: 44px; }
  #btnFirst, #btnLast, #btnShare { display: none; }
  .hint { font-size: 11px; }
}
@media (max-height: 480px) {
  :root { --top: 44px; --bottom: 46px; }
  .hint { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .drawer, .sheet, .toast, .hint { transition: none; }
}
