:root {
  color-scheme: light;
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  background: #e8eee8;
  color: #182420;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; height: 100dvh; overflow: hidden; background: #e8eee8; }
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.reader-shell { height: 100dvh; display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; overflow: hidden; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: calc(12px + env(safe-area-inset-top)) 18px 11px; background: #173d37; color: #fffdf7; }
.book-identity { display: flex; align-items: center; gap: 10px; }
.book-mark { display: grid; place-items: center; width: 45px; height: 36px; border: 1px solid #d7b964; border-radius: 5px; color: #f2da92; font-family: "Noto Serif TC", serif; font-size: 12px; font-weight: 700; line-height: 1.13; text-align: center; letter-spacing: .08em; }
.eyebrow { margin: 0 0 2px; color: #9ecfc1; font-size: 10px; font-weight: 700; letter-spacing: .025em; white-space: nowrap; }
h1 { margin: 0; font-family: "Noto Serif TC", "PMingLiU", serif; font-size: 17px; font-weight: 600; letter-spacing: .04em; }
.top-actions { display: flex; align-items: center; gap: 7px; }
.browser-link { display: inline-flex; align-items: center; gap: 4px; min-height: 32px; color: #f2da92; text-decoration: none; font-size: 11px; font-weight: 800; white-space: nowrap; }
.icon-button, .step-button, .zoom-button, .dock-button, .dialog-close { border: 0; cursor: pointer; }
.icon-button { width: 32px; height: 32px; color: #fffdf7; background: transparent; border: 1px solid rgba(255,255,255,.4); border-radius: 50%; font-weight: 700; }

.page-status { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 51px; padding: 7px 18px; background: #fffdf7; border-bottom: 1px solid #d2dbd2; }
.step-button { width: 35px; height: 35px; border-radius: 50%; background: #e4ede7; color: #173d37; font-size: 31px; line-height: .8; }
.step-button:disabled { opacity: .35; }
.page-input-wrap { display: flex; align-items: center; justify-content: center; gap: 5px; min-width: 166px; color: #53635d; font-size: 13px; font-weight: 700; }
#pageInput { width: 53px; padding: 4px 1px; color: #173d37; border: 0; border-bottom: 2px solid #d2aa3d; background: transparent; text-align: center; font-weight: 800; font-variant-numeric: tabular-nums; }
#pageInput:focus { outline: 2px solid #1e7668; outline-offset: 3px; border-radius: 2px; }

.viewport { position: relative; min-height: 0; overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y pinch-zoom; padding: 0; background: #dce6dd; }
.page-stage { width: max-content; max-width: none; margin: 0 auto; transform-origin: center top; line-height: 0; background: #fff; }
.page-stage.with-margin { margin-top: 14px; margin-bottom: 18px; box-shadow: 0 7px 22px rgba(28, 49, 40, .22); }
.page-stage.page-turn-next { animation: page-turn-next .18s ease-out; }
.page-stage.page-turn-previous { animation: page-turn-previous .18s ease-out; }
#pdfCanvas { display: block; }
.loading-card[hidden] { display: none !important; }
.loading-card { position: absolute; inset: 12px auto auto 50%; z-index: 3; transform: translateX(-50%); padding: 6px 10px; color: #436258; background: rgba(255, 253, 247, .95); border-radius: 99px; box-shadow: 0 2px 8px rgba(28, 49, 40, .12); font-size: 12px; }
.gesture-hint { position: absolute; z-index: 2; bottom: 13px; left: 50%; transform: translateX(-50%); padding: 7px 12px; color: #31554c; background: rgba(255, 253, 247, .92); border: 1px solid rgba(94, 128, 116, .3); border-radius: 99px; box-shadow: 0 2px 10px rgba(28, 49, 40, .14); font-size: 12px; font-weight: 800; white-space: nowrap; pointer-events: none; }
.gesture-hint[hidden] { display: none !important; }

.control-dock { position: relative; z-index: 4; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 7px; padding: 9px max(13px, env(safe-area-inset-right)) calc(9px + env(safe-area-inset-bottom)) max(13px, env(safe-area-inset-left)); background: #fffdf7; border-top: 1px solid #d2dbd2; }
.dock-button { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-height: 38px; color: #295148; background: transparent; font-size: 12px; font-weight: 800; white-space: nowrap; }
.dock-button span:first-child { color: #b48121; font-size: 19px; font-weight: 500; }
.zoom-controls { display: flex; align-items: center; gap: 5px; padding: 4px; background: #e4ede7; border-radius: 22px; }
.zoom-button { width: 31px; height: 31px; border-radius: 50%; background: #fffdf7; color: #173d37; font-size: 20px; line-height: 1; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
#zoomLabel { width: 42px; color: #173d37; text-align: center; font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; }

dialog { width: min(360px, calc(100vw - 32px)); padding: 28px 23px 22px; border: 0; border-radius: 14px; color: #182420; box-shadow: 0 18px 65px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(10, 31, 26, .54); }
dialog h2 { margin: 0 0 16px; color: #173d37; font-family: "Noto Serif TC", serif; font-size: 22px; }
dialog li { margin: 0 0 11px; color: #44524d; line-height: 1.55; font-size: 14px; }
.dialog-close { position: absolute; top: 10px; right: 11px; width: 32px; height: 32px; border-radius: 50%; color: #426259; background: #e4ede7; font-size: 23px; }

button:focus-visible { outline: 3px solid #d2aa3d; outline-offset: 2px; }
@keyframes page-turn-next { from { opacity: .6; transform: translateX(14px); } to { opacity: 1; transform: translateX(0); } }
@keyframes page-turn-previous { from { opacity: .6; transform: translateX(-14px); } to { opacity: 1; transform: translateX(0); } }
@media (max-width: 480px) { .browser-link span { display: none; } }
@media (max-width: 370px) { .eyebrow { font-size: 9px; letter-spacing: 0; } }
@media (min-width: 700px) { .page-status { min-height: 58px; } }
@media (prefers-reduced-motion: reduce) { .page-stage { animation: none !important; } }
