/* 书架页和阅读页共用的外壳：底色、标题栏、按钮、木扣、加载画面。--accent 强调色、--card 卡纸色，book.json 的 theme 能换 */
:root { --safe-top: env(safe-area-inset-top, 0px); --safe-left: env(safe-area-inset-left, 0px); --safe-right: env(safe-area-inset-right, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px); --header-h: calc(44px + var(--safe-top)); --ink: #f4ead6; --dim: #b9a98c; --bar: rgba(28, 20, 14, .82); --accent: #f4c879; --card: #f6eedb; }
* { box-sizing: border-box; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #2a1c13; color: var(--ink);
  font-family: "Songti SC", "STSong", "Noto Serif SC", serif; overflow: hidden; }
canvas, img { -webkit-touch-callout: none; -webkit-user-drag: none; }
canvas { display: block; touch-action: none; outline: none; }
header { position: fixed; inset: 0 0 auto 0; height: 44px; display: flex; align-items: center;
  gap: 12px; padding: 0 16px; background: var(--bar); backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255,255,255,.08); z-index: 2; }
header h1 { font-size: 17px; letter-spacing: .2em; margin: 0; font-weight: 600; }
header h1:lang(en) { letter-spacing: .04em; font-family: Georgia, "Times New Roman", serif; }
header small { color: var(--dim); font-size: 12px; letter-spacing: .1em; }
header small:lang(en) { letter-spacing: .03em; font-family: Georgia, "Times New Roman", serif; }
button { background: rgba(255,255,255,.08); color: var(--ink); border: 1px solid rgba(255,255,255,.18);
  border-radius: 8px; height: 32px; min-width: 36px; padding: 0 10px; font: inherit; font-size: 14px;
  cursor: pointer; transition: background .2s, transform .12s, opacity .2s; }
button:hover:not(:disabled) { background: rgba(255,255,255,.18); }
button:active:not(:disabled) { transform: scale(.95); }
button:disabled { opacity: .3; cursor: default; }
#fullBtn { width: 36px; padding: 0; }
#fullBtn::before { content: ""; display: block; width: 16px; height: 16px; margin: auto; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M1.5 1.5h4.5v1.5h-3v3h-1.5v-4.5zM10 1.5h4.5v4.5h-1.5v-3h-3v-1.5zM1.5 10h1.5v3h3v1.5h-4.5v-4.5zM13 10h1.5v4.5h-4.5v-1.5h3v-3z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M1.5 1.5h4.5v1.5h-3v3h-1.5v-4.5zM10 1.5h4.5v4.5h-1.5v-3h-3v-1.5zM1.5 10h1.5v3h3v1.5h-4.5v-4.5zM13 10h1.5v4.5h-4.5v-1.5h3v-3z'/%3E%3C/svg%3E") center / contain no-repeat; }
#fullBtn[aria-pressed="true"]::before {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4.5 1.5h1.5v4.5h-4.5v-1.5h3v-3zM10 1.5h1.5v3h3v1.5h-4.5v-4.5zM1.5 10h4.5v4.5h-1.5v-3h-3v-1.5zM10 10h4.5v1.5h-3v3h-1.5v-4.5z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4.5 1.5h1.5v4.5h-4.5v-1.5h3v-3zM10 1.5h1.5v3h3v1.5h-4.5v-4.5zM1.5 10h4.5v4.5h-1.5v-3h-3v-1.5zM10 10h4.5v1.5h-3v3h-1.5v-4.5z'/%3E%3C/svg%3E"); }

/* 木扣：浅木色的圆角木片，选中的那颗颜色深、压进去；手指点得到，至少 44 像素高 */
.knobs { display: flex; gap: 6px; }
.knobs[hidden] { display: none; }
.knobs button { height: 44px; padding: 0 18px; border-radius: 22px; border: 1px solid #8f6a3c; color: #3d2a1a;
  font-size: 17px; letter-spacing: .1em; background: linear-gradient(#e6c896, #c99d62);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.45), 0 2px 0 #8f6a3c; }
.knobs button:lang(en) { letter-spacing: 0; font-family: Georgia, "Times New Roman", serif; }
.knobs button:hover:not(:disabled) { background: linear-gradient(#eed4a8, #d4aa70); }
.knobs button[aria-pressed="true"], .knobs button[aria-pressed="true"]:hover {
  background: linear-gradient(#8a5d33, #6d4725); color: var(--card); box-shadow: inset 0 2px 4px rgba(0,0,0,.35); }

/* 加载画面；从另一页跳过来时盖着上一页的最后一帧（engine/arrive.js），这一页画好了再淡出 */
#loading { position: fixed; inset: 0; display: grid; place-items: center; color: var(--dim);
  letter-spacing: .3em; z-index: 3; background: #2a1c13; transition: opacity .6s; }
#loading > img { position: absolute; }
/* 盖着的是上一页的最后一帧、跟这一页第一帧一样：很快揭开，书架放回书时不会看到两本书叠着动 */
#loading:has(> img) { transition-duration: .15s; }
#loading.error { white-space: pre-line; color: #f0a890; letter-spacing: .08em; line-height: 1.9;
  text-align: center; padding: 0 24px; }
#loading.error .errBox { max-width: min(560px, 100%); }
#loading.error .errBox p { margin: 0; overflow-wrap: anywhere; }
#loading.error .errActs { display: flex; gap: 12px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }
#loading.error .errActs button { height: auto; line-height: 1.4; padding: 8px 20px; border-radius: 999px; border: 1px solid rgba(240,168,144,.45);
  background: rgba(240,168,144,.14); color: #f6e6cf; cursor: pointer; font: inherit; letter-spacing: .08em; }
#loading.error .errActs button:hover { background: rgba(240,168,144,.26); }

/* 全屏时标题与浮层让开刘海、圆角和底部手势区 */
header { height: var(--header-h); padding-top: var(--safe-top); padding-left: max(16px, var(--safe-left)); padding-right: max(16px, var(--safe-right)); }
header h1 { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
