:root { --accent: #2f6bff; --green: #12a05c; --bg1: #ffffff; --bg2: #e6ecf8; --page-fg: #14182b; --tb-bg: #ffffff; --tb-fg: #14182b; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--page-fg); background: var(--page-bg, radial-gradient(1200px 800px at 50% 30%, var(--bg1), var(--bg2))); background-size: cover; background-position: center; }
[hidden] { display: none !important; }
#app { position: fixed; inset: 0; display: flex; flex-direction: column; }

#topbar { padding: 12px 20px; display: flex; align-items: center; min-height: 48px; }
.titles { display: flex; flex-direction: column; line-height: 1.2; }
.titles strong { font-size: 15px; }
.titles span { font-size: 12px; opacity: .65; }
body.embed #topbar { display: none; }

#mid { flex: 1; min-height: 0; display: flex; }
#center { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#stage { flex: 1; min-height: 0; padding: 8px 12px 72px; display: flex; align-items: center; justify-content: center; }
#book { width: 100%; height: 100%; }
.page { background: #fff; overflow: hidden; box-shadow: 0 0 0 1px rgba(20,40,100,.06); }
.page canvas, .page img { width: 100%; height: 100%; display: block; -webkit-user-drag: none; user-select: none; }
.page.hard { background: #fff; }

.center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; padding: 24px; }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 3px solid rgba(127,127,127,.25); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.card { position: absolute; inset: auto; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(92vw, 400px); background: #fff; color: #14182b; border-radius: 16px; padding: 28px; box-shadow: 0 20px 60px rgba(0,0,0,.45); text-align: left; align-items: stretch; }
.card h1 { font-size: 20px; margin: 0; }
.card p { margin: 0; color: #5d6680; font-size: 14px; }
.card label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; }
.card input { font: inherit; font-weight: 400; padding: 11px 12px; border: 1px solid #cdd5e6; border-radius: 8px; }
.card input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.card button { font: inherit; font-weight: 600; background: var(--accent); color: #fff; border: 0; border-radius: 10px; padding: 12px; cursor: pointer; }
.card button:disabled { opacity: .6; cursor: default; }
.gate-error { color: #b3261e !important; min-height: 18px; }

#toolbar { position: absolute; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 999px; background: var(--tb-bg); backdrop-filter: blur(10px); box-shadow: 0 8px 30px rgba(20,40,100,.18), 0 0 0 1px rgba(127,127,127,.15); max-width: calc(100vw - 16px); }
#toolbar button, #toolbar a { font: inherit; font-size: 14px; color: var(--tb-fg); background: transparent; border: 0; border-radius: 999px; min-width: 36px; height: 36px; padding: 0 10px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
#toolbar button:hover, #toolbar a:hover { background: rgba(127,127,127,.18); }
#prev, #next { font-size: 24px; line-height: 1; background: var(--accent) !important; color: #fff !important; }
#count { white-space: nowrap; font-size: 13px; text-align: center; font-variant-numeric: tabular-nums; display: inline-flex; align-items: center; gap: 4px; }
#pageinput { width: 44px; font: inherit; font-size: 16px; touch-action: manipulation; text-align: center; padding: 6px 2px; border: 1px solid rgba(127,127,127,.35); border-radius: 8px; background: transparent; color: var(--tb-fg); }
#pageinput:focus { outline: 2px solid var(--accent); }
#toolbar .lbl { display: none; margin-left: 6px; font-size: 13px; }
@media (min-width: 1100px) { #toolbar .lbl { display: inline; } }
#slider { width: clamp(80px, 22vw, 260px); accent-color: var(--accent); }
.sep { width: 1px; height: 22px; background: rgba(127,127,127,.3); }
@media (max-width: 640px) { #toolbar #slider, #toolbar #bprint, #toolbar #bsound, #toolbar #fs, #toolbar #first, #toolbar #last, #toolbar #bacc, #toolbar #download { display: none; } #toolbar button, #toolbar a { min-width: 32px; padding: 0 6px; } #pageinput { width: 40px; padding: 4px 2px; } #toolbar #share { font-size: 13px; } #toolbar { overflow-x: auto; max-width: calc(100vw - 12px); scrollbar-width: none; } #toolbar::-webkit-scrollbar { display: none; } #toolbar { gap: 4px; padding: 6px 8px; } }

.page .inner { position: relative; width: 100%; height: 100%; }
.page .layer { position: absolute; inset: 0; }
.lnk { position: absolute; display: block; border-radius: 2px; cursor: pointer; }
.lnk:hover, .lnk:focus-visible { background: rgba(18, 160, 92, .16); outline: 1px solid rgba(18, 160, 92, .7); }

#count { color: var(--tb-fg); }
#logo, #logo2 { display: flex; align-items: center; margin-right: 12px; }
#logo img, #logo2 img { max-height: 34px; max-width: 160px; display: block; }
#logo2 { position: absolute; top: 8px; left: 10px; z-index: 5; margin: 0; }
#logo2 img { max-height: 28px; }
#topbar { color: var(--page-fg); }
#toolbar button[aria-pressed="false"].toggle { opacity: .5; }
#toolbar button.on { background: rgba(127,127,127,.25); }

.lnk.media::after { content: "\25B6"; position: absolute; right: 4px; bottom: 4px; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 10px; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 8px rgba(0,0,0,.35); }
.lnk.media.gallery::after { content: "\25A3"; }
.lnk.media.note::after { content: "i"; font-style: italic; font-weight: 700; }
.lnk.media.audio::after { content: "\266B"; }
.hl { position: absolute; background: rgba(255, 214, 0, .45); mix-blend-mode: multiply; border-radius: 2px; pointer-events: none; }
.hl.cur { background: rgba(18, 160, 92, .45); outline: 2px solid rgba(18, 160, 92, .8); }

#side { position: absolute; top: 0; left: 0; bottom: 0; width: min(320px, 90vw); background: #fff; color: #14182b; z-index: 20; display: flex; flex-direction: column; box-shadow: 8px 0 40px rgba(0,0,0,.4); }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 0 10px; border-bottom: 1px solid #e3e8f2; }
.tabs { display: flex; gap: 2px; }
.tabs button, #sideclose { font: inherit; font-size: 14px; background: transparent; border: 0; padding: 10px 12px; cursor: pointer; color: #5d6680; border-bottom: 3px solid transparent; }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
#sideclose { font-size: 22px; padding: 4px 10px; }
.tabbody { flex: 1; overflow: auto; padding: 12px; }
#tab-pages { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-content: start; }
.thumb { border: 2px solid transparent; border-radius: 6px; padding: 4px; background: #eef2fa; cursor: pointer; text-align: center; font-size: 12px; color: #5d6680; }
.thumb.cur { border-color: var(--accent); }
.thumb canvas { width: 100%; display: block; background: #fff; min-height: 60px; }
#tab-contents ul { list-style: none; margin: 0; padding-left: 14px; }
#tab-contents > ul { padding-left: 0; }
#tab-contents a { display: block; padding: 7px 4px; color: #14182b; text-decoration: none; font-size: 14px; border-radius: 6px; cursor: pointer; }
#tab-contents a:hover { background: #eef2fa; }
.empty { color: #5d6680; font-size: 14px; }
#searchform input { width: 100%; font: inherit; padding: 10px 12px; border: 1px solid #cdd5e6; border-radius: 8px; }
#searchstatus { font-size: 12px; color: #5d6680; margin: 8px 2px; min-height: 16px; }
.hit { display: block; width: 100%; text-align: left; font: inherit; font-size: 13px; background: #fff; border: 0; border-bottom: 1px solid #e3e8f2; padding: 9px 4px; cursor: pointer; color: #14182b; }
.hit:hover, .hit.cur { background: #eef2fa; }
.hit b { color: var(--accent); margin-right: 6px; }

#zoomview { position: absolute; inset: 0; z-index: 15; background: rgba(10, 6, 16, .96); display: flex; flex-direction: column; }
.zbar { display: flex; gap: 8px; align-items: center; justify-content: center; padding: 10px; }
.zbar button { font: inherit; color: #fff; background: rgba(255,255,255,.12); border: 0; border-radius: 999px; min-width: 38px; height: 38px; padding: 0 14px; cursor: pointer; font-size: 18px; }
.zbar button#zclose { background: var(--accent); font-size: 14px; }
#zlevel { min-width: 52px; text-align: center; font-size: 13px; }
#zscroll { flex: 1; overflow: auto; cursor: grab; padding: 0 12px 24px; }
#zscroll.drag { cursor: grabbing; user-select: none; }
#zpage { position: relative; margin: 0 auto; background: #fff; width: fit-content; }
#zpage canvas { display: block; }

.modal { position: absolute; inset: 0; z-index: 30; background: rgba(10, 6, 16, .7); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-card, .lb-card { position: relative; background: #fff; color: #14182b; border-radius: 16px; padding: 24px; width: min(94vw, 460px); box-shadow: 0 20px 60px rgba(0,0,0,.5); display: flex; flex-direction: column; gap: 12px; }
.lb-card { width: min(94vw, 900px); padding: 14px; background: #0c0714; color: #fff; }
.modal-x { position: absolute; top: 6px; right: 10px; font-size: 26px; line-height: 1; background: transparent; border: 0; cursor: pointer; color: inherit; z-index: 2; }
.modal-card h2 { margin: 0; font-size: 18px; }
.modal-card input[type=text], #sharelink { font: inherit; padding: 10px 12px; border: 1px solid #cdd5e6; border-radius: 8px; width: 100%; }
.chk { font-size: 14px; display: flex; gap: 8px; align-items: center; }
.share-row { display: flex; flex-wrap: wrap; gap: 8px; }
.share-row button, .share-row a { font: inherit; font-size: 14px; font-weight: 600; background: var(--accent); color: #fff; border: 0; border-radius: 999px; padding: 9px 16px; cursor: pointer; text-decoration: none; }
.share-row a { background: #eaf0fd; color: #1f3c8f; }
#lbbody { min-height: 120px; }
#lbbody .frame { position: relative; width: 100%; aspect-ratio: 16 / 9; }
#lbbody iframe, #lbbody video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #000; border-radius: 8px; }
#lbbody audio { width: 100%; margin: 28px 0 12px; }
#lbbody .note { padding: 18px 8px 8px; font-size: 16px; line-height: 1.55; white-space: pre-wrap; }
.gal { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.gal img { max-width: 100%; max-height: 66vh; border-radius: 8px; display: block; }
.gal .cap { font-size: 14px; opacity: .85; min-height: 20px; text-align: center; }
.gal .nav { display: flex; gap: 12px; align-items: center; }
.gal .nav button { font: inherit; background: var(--accent); color: #fff; border: 0; border-radius: 999px; width: 38px; height: 38px; font-size: 20px; cursor: pointer; }
#printmsg { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); background: #fff; color: #14182b; padding: 10px 18px; border-radius: 999px; z-index: 40; font-size: 14px; box-shadow: 0 8px 30px rgba(0,0,0,.4); }

#printarea { display: none; }
@media print {
  html, body { overflow: visible; height: auto; background: #fff; }
  #app { display: none !important; }
  #printarea { display: block; }
  #printarea img { display: block; width: 100%; page-break-after: always; break-after: page; }
}

/* adverts */
#adbanner { flex: none; width: 100%; padding: 4px 12px 0; text-align: center; }
#adbanner a { display: block; }
#adbanner img { display: block; margin: 0 auto; width: 100%; max-height: 110px; object-fit: contain; border-radius: 4px; background: #fff; }
.sky { width: var(--skyw, 168px); flex: none; position: relative; align-self: flex-start; margin: 0 6px; }
.sky.ghost { visibility: hidden; }
.sky a { display: block; height: 100%; }
.sky img { display: block; width: 100%; height: 100%; object-fit: contain; object-position: top center; border-radius: 4px; }
.sky small { position: absolute; left: 0; right: 0; bottom: -14px; text-align: center; }
#adbanner small, .sky small, .ad-card small, .fp-ad figcaption { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; opacity: .6; }
@media (max-width: 599px) { .sky, #adfull { display: none !important; } }
.ad-card { position: relative; width: min(94vw, 560px); background: #fff; color: #14182b; border-radius: 14px; padding: 14px 14px 10px; display: flex; flex-direction: column; align-items: center; gap: 6px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.ad-card img { display: block; max-width: 100%; max-height: 70vh; width: auto; height: auto; border-radius: 8px; }
.ad-card .modal-x { top: -14px; right: -10px; width: 34px; height: 34px; border-radius: 50%; background: #fff; color: #14182b; font-size: 22px; box-shadow: 0 4px 14px rgba(0,0,0,.4); }
#adfull { position: absolute; inset: 0; z-index: 60; background: radial-gradient(1000px 700px at 50% 20%, var(--bg1), var(--bg2)); display: flex; align-items: center; justify-content: center; padding: 16px; overflow: auto; }
.fp { display: flex; gap: 28px; align-items: center; justify-content: center; width: min(1100px, 100%); }
.fp-ad { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 0 1 auto; min-width: 0; }
.fp-ad a { display: block; }
.fp-ad img { display: block; max-height: min(86vh, 900px); max-width: 100%; width: auto; height: auto; background: #fff; border-radius: 4px; box-shadow: 0 20px 70px rgba(0,0,0,.55); }
.fp-open { flex: 0 1 300px; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; min-width: 0; }
.fp-open img { max-width: 160px; border-radius: 4px; box-shadow: 0 12px 40px rgba(0,0,0,.5); }
.fp-open h2 { margin: 0; font-size: 22px; line-height: 1.15; }
.fp-open p { margin: 0; opacity: .7; font-size: 14px; }
#fp-go { font: inherit; font-weight: 700; background: var(--accent); color: #fff; border: 0; border-radius: 999px; padding: 13px 26px; cursor: pointer; }
#fp-go:disabled { opacity: .6; cursor: default; }
@media (max-width: 760px) { .fp { flex-direction: column; gap: 14px; } .fp-open { align-items: center; text-align: center; flex-basis: auto; } .fp-open img { display: none; } .fp-ad img { max-height: 62vh; } }
@media (max-width: 600px) { .ad-card { width: 100vw; border-radius: 0; padding: 12px 10px 8px; } .ad-card .modal-x { top: 6px; right: 8px; } }

.ov-card { position: relative; background: #fff; color: #14182b; border-radius: 16px; padding: 24px; width: min(96vw, 1100px); max-height: 92vh; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.ov-card h2 { margin: 0; font-size: 18px; }
#ovgrid { overflow: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; padding: 2px; }
#ovgrid .thumb img { width: 100%; display: block; background: #fff; }
body.hc #toolbar { background: #000; --tb-fg: #fff; box-shadow: 0 0 0 2px #fff; }
body.hc #toolbar button, body.hc #toolbar a { color: #fff; }
body.hc #prev, body.hc #next { background: #ffd400 !important; color: #000 !important; }
body.hc #pageinput { border-color: #fff; }
body.large #toolbar button, body.large #toolbar a { min-width: 46px; height: 46px; font-size: 17px; }
body.large #toolbar .lbl { display: inline; font-size: 15px; }
