:root {
  --bg: #2b2f36;
  --bg-2: #22252b;
  --ink: #f2f3f5;
  --ink-2: #b7bcc6;
  --accent: #e8792b;
  --navy: #1f3a6b;
  --panel: #ffffff;
  --panel-ink: #1d2330;
  --panel-line: #e7e9ee;
  --bar-h: 52px;
  --pager-h: 52px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(ellipse at 50% 40%, #3a3f48 0%, var(--bg) 55%, var(--bg-2) 100%);
  background-color: var(--bg);
  color: var(--ink);
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.bar {
  position: fixed; inset: 0 0 auto 0; height: calc(var(--bar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 10px 0; display: flex; align-items: center; gap: 8px;
  background: rgba(20, 22, 26, .55); backdrop-filter: blur(8px); z-index: 20;
}
.title { flex: 1; margin: 0; font-size: 15px; font-weight: 600; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tools { display: flex; gap: 2px; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 40px; min-width: 40px; padding: 0 9px;
  border: 0; border-radius: 8px; background: transparent; color: inherit; font: inherit; font-size: 14px;
  cursor: pointer; text-decoration: none; justify-content: center;
}
.btn:hover { background: rgba(255, 255, 255, .1); }
.btn:focus-visible, .nav:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.stage {
  position: fixed; left: 0; right: 0; top: calc(var(--bar-h) + env(safe-area-inset-top));
  bottom: calc(var(--pager-h) + env(safe-area-inset-bottom));
  display: flex; align-items: center; justify-content: center; padding: 14px 64px;
}
.book-wrap { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.page { background: #fff; overflow: hidden; box-shadow: 0 14px 40px rgba(0, 0, 0, .4); }
.page img { display: block; width: 100%; height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.page .hot { position: absolute; display: block; border-radius: 2px; }
.page .hot:hover { background: rgba(232, 121, 43, .14); }

.nav {
  position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 72px;
  border: 0; border-radius: 10px; background: rgba(255, 255, 255, .08); color: var(--ink); cursor: pointer; z-index: 5;
}
.nav:hover { background: rgba(255, 255, 255, .18); }
.nav:disabled { opacity: .25; cursor: default; }
.nav.prev { left: 10px; }
.nav.next { right: 10px; }
.loading { position: absolute; color: var(--ink-2); font-size: 14px; }

.pager {
  position: fixed; inset: auto 0 0 0; height: calc(var(--pager-h) + env(safe-area-inset-bottom));
  padding: 0 16px env(safe-area-inset-bottom); display: flex; align-items: center; gap: 14px; z-index: 20;
}
#slider { flex: 1; accent-color: var(--accent); min-width: 0; }
.goto { display: flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 14px; }
.goto b { color: var(--ink); font-weight: 600; }
#pageInput {
  width: 52px; height: 32px; border: 1px solid rgba(255, 255, 255, .2); border-radius: 6px;
  background: rgba(0, 0, 0, .25); color: var(--ink); text-align: center; font: inherit; font-size: 14px;
}

.toc {
  position: fixed; top: 0; bottom: 0; left: 0; width: min(380px, 88vw); z-index: 40;
  background: var(--panel); color: var(--panel-ink); transform: translateX(-102%);
  transition: transform .25s ease, visibility 0s linear .25s; visibility: hidden;
  display: flex; flex-direction: column; padding-top: env(safe-area-inset-top);
}
.toc.open { transform: none; visibility: visible; transition: transform .25s ease; }
.toc-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 8px 18px; border-bottom: 1px solid var(--panel-line); }
.toc-head b { font-size: 16px; color: var(--navy); }
#tocList { overflow-y: auto; padding: 6px 0 24px; }
#tocList a {
  display: flex; gap: 10px; justify-content: space-between; padding: 9px 18px; color: inherit;
  text-decoration: none; font-size: 14px; line-height: 1.4;
}
#tocList a:hover, #tocList a.cur { background: #fff4ec; }
#tocList a.cur { box-shadow: inset 3px 0 0 var(--accent); }
#tocList a.l1 { font-weight: 700; color: var(--navy); margin-top: 6px; }
#tocList a.l2 { padding-left: 30px; }
#tocList a.l3 { padding-left: 44px; color: #5b6475; font-size: 13px; }
#tocList a span:last-child { color: #8a93a3; font-variant-numeric: tabular-nums; flex: none; }
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 30; opacity: 0; pointer-events: none; transition: opacity .25s; }
.scrim.open { opacity: 1; pointer-events: auto; }

.zoom { position: fixed; inset: 0; z-index: 50; background: #1b1d21; display: none; flex-direction: column; }
.zoom.open { display: flex; }
.zoom-bar { display: flex; align-items: center; justify-content: center; gap: 8px; height: calc(var(--bar-h) + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top); position: relative; }
.zoom-bar #zClose { position: absolute; right: 10px; bottom: 6px; }
#zLabel { min-width: 70px; text-align: center; font-size: 14px; color: var(--ink-2); }
.zoom-scroll { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; padding: 0 12px 24px; }
#zImg { display: block; margin: 0 auto; width: min(100%, 1000px); height: auto; background: #fff; }

@media (max-width: 640px) {
  .stage { padding: 8px 6px; }
  .nav { display: none; }
  .btn .lbl { display: none; }
  .title { font-size: 14px; }
}
