/* 電子書閱讀器樣式(自行開發,不依賴任何第三方版面或舊系統樣式) */
:root { --ac: #ca333a; --ac2: #e0555b; --bg1: #1f2329; --bg2: #2b3038; --bar: rgba(20, 22, 26, .86); --ink: #f2f3f5; --mute: #aab0bb; --line: rgba(255, 255, 255, .14); --top: 54px; --bot: 70px; }
body.rd-skin-modern { --ac: #3b4cca; --ac2: #6d7df0; --bg1: #1d2230; --bg2: #272e42; }
body.rd-skin-shelf { --ac: #b98650; --ac2: #e8c26a; --bg1: #2a1a0e; --bg2: #3b2414; --bar: rgba(40, 24, 12, .9); }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg1); color: var(--ink); font: 15px/1.5 "Noto Sans TC", "Microsoft JhengHei", -apple-system, "Segoe UI", sans-serif; overscroll-behavior: none; }
button { font: inherit; color: inherit; cursor: pointer; }
.rd { position: fixed; inset: 0; height: 100vh; height: 100dvh; background: radial-gradient(ellipse at 50% 40%, var(--bg2), var(--bg1) 70%); user-select: none; -webkit-user-select: none; }

/* ---------- 舞台與書本 ---------- */
.rd-stage { position: absolute; inset: 0; overflow: hidden; touch-action: none; }
.rd-zoom { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; transform-origin: 50% 50%; will-change: transform; }
.rd-book { position: relative; width: calc(var(--pw) * 2); height: var(--ph); perspective: 2600px; transition: transform .55s cubic-bezier(.4, .1, .2, 1); }
.rd.single .rd-book { width: var(--pw); }
.rd-pg { position: absolute; top: 0; width: var(--pw); height: var(--ph); background: #fff; overflow: hidden; box-shadow: 0 12px 34px rgba(0, 0, 0, .5); }
.rd-pg.empty { background: transparent; box-shadow: none; }
.rd-pg .im { position: absolute; inset: 0; background-repeat: no-repeat; background-position: center; background-size: contain; background-color: #fff; }
.rd-pg.empty .im { display: none; }
.rd-pg.l { left: 0; } .rd-pg.r { left: var(--pw); }
/* 書脊暗影 */
.rd:not(.single) .rd-pg.l::after, .rd:not(.single) .rd-pg.r::after { content: ""; position: absolute; top: 0; bottom: 0; width: 14%; pointer-events: none; }
.rd:not(.single) .rd-pg.l::after { right: 0; background: linear-gradient(90deg, transparent, rgba(0, 0, 0, .28)); }
.rd:not(.single) .rd-pg.r::after { left: 0; background: linear-gradient(270deg, transparent, rgba(0, 0, 0, .28)); }
/* 翻動中的紙張 */
.rd-leaf { position: absolute; top: 0; width: var(--pw); height: var(--ph); transform-style: preserve-3d; z-index: 5; will-change: transform; }
.rd-leaf .f, .rd-leaf .k { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; background: #fff; overflow: hidden; }
.rd-leaf .k { transform: rotateY(180deg); }
.rd-leaf .im { position: absolute; inset: 0; background-repeat: no-repeat; background-position: center; background-size: contain; }
.rd-leaf .f::after, .rd-leaf .k::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; background: linear-gradient(90deg, rgba(0, 0, 0, .0), rgba(0, 0, 0, .35)); animation: rd-shade .7s ease-in-out forwards; }
.rd-leaf.from-left .f::after, .rd-leaf.from-left .k::after { background: linear-gradient(270deg, rgba(0, 0, 0, .0), rgba(0, 0, 0, .35)); }
@keyframes rd-shade { 0% { opacity: 0; } 50% { opacity: 1; } 100% { opacity: 0; } }
/* 單頁模式:三張頁面排成軌道,可拖曳 */
.rd.single .rd-track { position: absolute; inset: 0; }
.rd.single .rd-pg { left: 0; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); }

/* ---------- 載入畫面 ---------- */
.rd-load { position: absolute; inset: 0; z-index: 40; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; background: radial-gradient(ellipse at 50% 40%, var(--bg2), var(--bg1) 70%); transition: opacity .4s; }
.rd-load.hide { opacity: 0; pointer-events: none; }
.rd-load .cv { width: 150px; aspect-ratio: 5 / 7; background: #e8e8e8 center / cover no-repeat; box-shadow: 0 14px 34px rgba(0, 0, 0, .55); border-radius: 3px; }
.rd-load .t { font-size: 18px; font-weight: 700; max-width: 80vw; text-align: center; }
.rd-load .bar { width: 180px; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.rd-load .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--ac), var(--ac2)); transition: width .3s; }

/* ---------- 上下工具列 ---------- */
.rd-top, .rd-bot { position: absolute; left: 0; right: 0; z-index: 20; background: var(--bar); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); transition: transform .3s, opacity .3s; }
.rd-top { top: 0; height: var(--top); display: flex; align-items: center; gap: 6px; padding: 0 10px; padding-top: env(safe-area-inset-top); border-bottom: 1px solid var(--line); }
.rd-bot { bottom: 0; min-height: var(--bot); padding: 8px 14px calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.rd.idle .rd-top { transform: translateY(-100%); opacity: 0; } .rd.idle .rd-bot { transform: translateY(100%); opacity: 0; }
.rd-top .ttl { flex: 1; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 6px; }
.ib { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 40px; height: 40px; padding: 0 10px; border: 0; border-radius: 10px; background: transparent; color: var(--ink); }
.ib:hover { background: rgba(255, 255, 255, .1); } .ib:active { background: rgba(255, 255, 255, .18); }
.ib:focus-visible, .nv:focus-visible, .rd-slider:focus-visible { outline: 2px solid var(--ac2); outline-offset: 2px; }
.ib svg { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ib.on { background: var(--ac); }
.ib .tx { font-size: 13px; }
.rd-ctl { display: flex; align-items: center; gap: 4px; }
.rd-sl { display: flex; align-items: center; gap: 12px; margin-top: 2px; }
.rd-slider { flex: 1; height: 28px; background: transparent; accent-color: var(--ac2); }
.rd-slider { -webkit-appearance: none; appearance: none; }
.rd-slider::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .25); }
.rd-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -7px; border-radius: 50%; background: var(--ac2); border: 2px solid #fff; }
.rd-slider::-moz-range-track { height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .25); }
.rd-slider::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--ac2); border: 2px solid #fff; }
.rd.rtl .rd-slider { direction: rtl; }
.rd-pn { min-width: 92px; text-align: center; font-variant-numeric: tabular-nums; color: var(--mute); font-size: 14px; }
.rd-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; flex-wrap: wrap; }
.rd-row .grp { display: flex; align-items: center; gap: 2px; }

/* 兩側翻頁鈕 */
.nv { position: absolute; top: 50%; z-index: 15; width: 46px; height: 76px; margin-top: -38px; border: 0; border-radius: 12px; background: rgba(0, 0, 0, .32); color: #fff; display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity .25s; }
.nv svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.nv.pv { left: 10px; } .nv.nx { right: 10px; }
.rd:hover .nv:not([disabled]) { opacity: .75; } .nv:not([disabled]):hover { opacity: 1 !important; background: var(--ac); }
.nv[disabled] { display: none; }
@media (hover: none) { .nv { display: none; } }

/* ---------- 側邊面板 ---------- */
.rd-panel { position: absolute; z-index: 30; top: 0; bottom: 0; right: 0; width: min(400px, 100vw); background: #1a1d22; color: var(--ink); border-left: 1px solid var(--line); box-shadow: -14px 0 40px rgba(0, 0, 0, .45); transform: translateX(104%); transition: transform .3s cubic-bezier(.3, .1, .2, 1); display: flex; flex-direction: column; padding-top: env(safe-area-inset-top); }
.rd-panel.open { transform: none; }
.rd-panel .hd { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 17px; }
.rd-panel .bd { flex: 1; overflow: auto; padding: 14px; -webkit-overflow-scrolling: touch; }
.rd-scrim { position: absolute; inset: 0; z-index: 25; background: rgba(0, 0, 0, .35); opacity: 0; pointer-events: none; transition: opacity .3s; }
.rd-scrim.on { opacity: 1; pointer-events: auto; }
.muted { color: var(--mute); }
.li-list { list-style: none; margin: 0; padding: 0; }
.li-list li { margin: 0 0 6px; }
.li-list button { width: 100%; text-align: left; display: flex; gap: 10px; align-items: baseline; padding: 10px 12px; border: 0; border-radius: 10px; background: rgba(255, 255, 255, .06); }
.li-list button:hover { background: rgba(255, 255, 255, .12); }
.li-list .pn { flex: none; min-width: 42px; color: var(--ac2); font-variant-numeric: tabular-nums; font-size: 13px; }
.li-list .sn { color: var(--mute); font-size: 13px; display: block; margin-top: 2px; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.thumbs button { padding: 0; border: 2px solid transparent; border-radius: 6px; background: transparent; position: relative; }
.thumbs button.cur { border-color: var(--ac2); }
.thumbs .th { display: block; aspect-ratio: 5 / 7; background: #fff center / contain no-repeat; border-radius: 3px; box-shadow: 0 3px 8px rgba(0, 0, 0, .4); }
.thumbs .n { display: block; font-size: 12px; color: var(--mute); margin-top: 3px; text-align: center; }
.fld { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255, 255, 255, .07); color: var(--ink); font: inherit; }
.fld:focus { outline: 2px solid var(--ac2); outline-offset: 0; }
textarea.fld { min-height: 110px; resize: vertical; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 18px; border: 0; border-radius: 10px; background: linear-gradient(135deg, var(--ac), var(--ac2)); color: #fff; font-weight: 700; }
.btn.block { width: 100%; }
.sr-row { display: flex; gap: 8px; margin-bottom: 12px; }
.frm label { display: block; margin: 0 0 12px; font-size: 14px; color: var(--mute); }
.frm label .fld { margin-top: 4px; }
.err { color: #ff8a80; font-size: 14px; min-height: 20px; margin: 6px 0; }

/* 分享 */
.sharebtns { display: flex; flex-wrap: wrap; gap: 16px 18px; margin: 6px 0 16px; }
.sharebtns .sb { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 62px; border: 0; background: none; color: var(--ink); text-decoration: none; }
.sharebtns .sbi { width: 50px; height: 50px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, .35); transition: transform .15s; }
.sharebtns .sb:hover .sbi { transform: translateY(-3px) scale(1.06); }
.sharebtns .sbi svg { width: 25px; height: 25px; }
.sharebtns .sbi b { font: 800 12px/1 Arial, sans-serif; }
.sharebtns em { font-style: normal; font-size: 12px; color: var(--mute); }
.sb-fb .sbi { background: #1877f2; } .sb-line .sbi { background: #06c755; } .sb-x .sbi { background: #000; border: 1px solid #444; } .sb-mail .sbi { background: #7a869a; } .sb-copy .sbi { background: #e8832a; } .sb-copy.done .sbi { background: #2e9e5b; }
.qr { background: #fff; padding: 10px; border-radius: 12px; display: inline-block; }
.qr img { display: block; width: 168px; height: 168px; }

/* 提示 */
.rd-toast { position: absolute; left: 50%; bottom: 96px; z-index: 60; transform: translate(-50%, 18px); background: rgba(0, 0, 0, .88); color: #fff; padding: 10px 22px; border-radius: 24px; opacity: 0; transition: opacity .25s, transform .25s; pointer-events: none; max-width: 88vw; text-align: center; }
.rd-toast.show { opacity: 1; transform: translate(-50%, 0); }
/* 密碼畫面 */
.rd-lock { position: absolute; inset: 0; z-index: 45; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at 50% 40%, var(--bg2), var(--bg1) 70%); padding: 20px; }
.rd-lock .box { width: min(380px, 100%); background: #1a1d22; border: 1px solid var(--line); border-radius: 16px; padding: 26px 24px; box-shadow: 0 18px 50px rgba(0, 0, 0, .5); text-align: center; }
.rd-lock h2 { margin: 0 0 6px; font-size: 20px; } .rd-lock p { margin: 0 0 16px; color: var(--mute); }
.rd-lock .back { display: inline-block; margin-top: 14px; color: var(--mute); font-size: 14px; }
.rd-hint { position: absolute; left: 50%; top: 50%; z-index: 35; transform: translate(-50%, -50%); background: rgba(0, 0, 0, .78); padding: 18px 28px; border-radius: 16px; text-align: center; line-height: 1.8; pointer-events: none; animation: rd-fade 4.2s forwards; }
@keyframes rd-fade { 0%, 75% { opacity: 1; } 100% { opacity: 0; } }
@media (max-width: 720px) { :root { --top: 50px; --bot: 96px; } .rd-pn { min-width: 70px; } .ib .tx { display: none; } .rd-panel { width: 100vw; } }
@media print { .rd { display: none; } }
