:root {
  color-scheme: dark;
  --ink: #07111c;
  --ink-2: #0d2132;
  --accent: #36a8d4;
  --line: rgba(255,255,255,.15);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  overflow: hidden;
  background: radial-gradient(circle at 50% 30%, #173044 0, var(--ink) 56%, #02070b 100%);
  color: #fff;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

button, input { font: inherit; }
button { color: inherit; }

.topbar {
  position: fixed;
  z-index: 20;
  inset: 0 0 auto 0;
  height: calc(62px + var(--safe-top));
  padding: calc(10px + var(--safe-top)) 14px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: linear-gradient(180deg, rgba(4,12,19,.96), rgba(4,12,19,.72));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.eyebrow { color: var(--accent); font-size: 9px; letter-spacing: .14em; }
h1 { margin: 2px 0 0; font-size: 16px; font-weight: 650; }
.top-actions { display: flex; gap: 8px; }
.top-actions button, .drawer-head button {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.08);
  border-radius: 10px;
  min-width: 48px;
  height: 34px;
}

.reader {
  position: fixed;
  inset: calc(62px + var(--safe-top)) 0 calc(64px + var(--safe-bottom));
  display: grid;
  place-items: center;
  padding: 10px;
  touch-action: pan-y pinch-zoom;
  overflow: hidden;
}

.reader::after {
  content: "";
  position: absolute;
  inset: 12% 10%;
  background: rgba(0,0,0,.35);
  filter: blur(28px);
  border-radius: 28px;
  z-index: -1;
}

#pageImage {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  background: #fff;
  box-shadow: 0 20px 60px rgba(0,0,0,.48), 0 0 0 1px rgba(255,255,255,.14);
  transition: opacity .16s ease, transform .18s ease;
  transform: translateZ(0);
  touch-action: pinch-zoom;
}

#pageImage.changing { opacity: .25; transform: scale(.988); }
.loading {
  position: absolute;
  color: rgba(255,255,255,.65);
  font-size: 13px;
}
.hit { position: absolute; top: 0; bottom: 0; width: 22%; border: 0; background: transparent; }
.hit-left { left: 0; }
.hit-right { right: 0; }

.controls {
  position: fixed;
  z-index: 20;
  inset: auto 0 0 0;
  height: calc(64px + var(--safe-bottom));
  padding: 8px 12px calc(8px + var(--safe-bottom));
  display: grid;
  grid-template-columns: 46px 1fr 46px;
  align-items: center;
  gap: 10px;
  background: linear-gradient(0deg, rgba(4,12,19,.97), rgba(4,12,19,.78));
  border-top: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.controls button {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.08);
  border-radius: 12px;
  height: 44px;
  font-size: 28px;
}
.controls button:disabled { opacity: .25; }
.progress-wrap { display: grid; grid-template-columns: 1fr 58px; gap: 10px; align-items: center; }
.progress-wrap div { font-size: 12px; color: rgba(255,255,255,.72); text-align: right; }
.slash { margin: 0 3px; opacity: .45; }
input[type="range"] { width: 100%; accent-color: var(--accent); }

.drawer {
  position: fixed;
  z-index: 40;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(88vw, 410px);
  padding-top: var(--safe-top);
  background: #0a1824;
  transform: translateX(102%);
  transition: transform .22s ease;
  box-shadow: -20px 0 60px rgba(0,0,0,.45);
  display: grid;
  grid-template-rows: auto 1fr;
}
.drawer.open { transform: translateX(0); }
.drawer-head { padding: 16px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); }
.drawer-head strong, .drawer-head span { display: block; }
.drawer-head span { margin-top: 3px; color: rgba(255,255,255,.55); font-size: 11px; }
.drawer-head button { min-width: 38px; font-size: 22px; }
.thumb-grid { overflow-y: auto; padding: 12px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.thumb {
  border: 1px solid rgba(255,255,255,.12);
  padding: 0;
  background: #fff;
  border-radius: 7px;
  overflow: hidden;
  position: relative;
  aspect-ratio: 509 / 720;
}
.thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.thumb span { position: absolute; right: 4px; bottom: 4px; min-width: 22px; padding: 2px 5px; border-radius: 9px; background: rgba(0,0,0,.72); font-size: 9px; }
.thumb.current { outline: 2px solid var(--accent); outline-offset: 1px; }

.scrim { position: fixed; z-index: 30; inset: 0; background: rgba(0,0,0,.58); opacity: 0; pointer-events: none; transition: opacity .2s ease; }
.scrim.open { opacity: 1; pointer-events: auto; }
.tip {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: calc(82px + var(--safe-bottom));
  transform: translate(-50%, 12px);
  width: max-content;
  max-width: 86vw;
  padding: 9px 14px;
  border-radius: 18px;
  background: rgba(0,0,0,.78);
  color: rgba(255,255,255,.9);
  font-size: 12px;
  opacity: 0;
  animation: tip 3.2s .6s ease both;
}

@keyframes tip {
  0%, 100% { opacity: 0; transform: translate(-50%, 12px); }
  15%, 75% { opacity: 1; transform: translate(-50%, 0); }
}

@media (min-width: 900px) {
  .reader { padding: 18px 90px; }
  .hit { width: 30%; cursor: pointer; }
  .topbar { padding-left: 28px; padding-right: 28px; }
  .controls { padding-left: 28px; padding-right: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
