:root {
  --brand: #222d5c;
  --brand-2: #2f3d7a;
  --accent: #009edb;
  --bg: #eef1f6;
  --panel: #ffffff;
  --text: #1c2230;
  --muted: #6b7384;
  --radius: 12px;
  --topbar-h: 56px;
  --toolbar-h: 52px;
  --footer-h: 36px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN",
    "Yu Gothic", "Microsoft YaHei", "PingFang SC", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* ---------- Top bar ---------- */
.topbar {
  height: var(--topbar-h);
  flex: 0 0 auto;
  background: linear-gradient(100deg, var(--brand), var(--brand-2));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  padding-top: env(safe-area-inset-top);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .12);
  z-index: 5;
}
.brand { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.brand-mark { font-weight: 800; font-size: 20px; letter-spacing: .3px; }
.brand-sub {
  font-size: 12px; color: #b9c4ea; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}

.lang-tabs { display: flex; gap: 4px; background: rgba(255,255,255,.12); padding: 3px; border-radius: 999px; }
.lang-tab {
  border: 0; background: transparent; color: #d7def6;
  font-size: 13px; font-weight: 600; padding: 6px 12px;
  border-radius: 999px; cursor: pointer; white-space: nowrap;
  transition: background .15s, color .15s;
}
.lang-tab.active { background: #fff; color: var(--brand); }
.lang-tab:active { transform: scale(.97); }

/* ---------- Toolbar ---------- */
.viewer { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
.toolbar {
  height: var(--toolbar-h);
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: flex-end;
  gap: 8px; padding: 0 12px;
  background: var(--panel);
  border-bottom: 1px solid #dde2ec;
}
.toolbar-right { display: flex; align-items: center; gap: 6px; }
.pageinfo { font-variant-numeric: tabular-nums; font-size: 15px; color: var(--text); min-width: 64px; text-align: center; font-weight: 600; }

.tbtn {
  appearance: none; border: 1px solid #d3d9e6; background: #f7f9fc;
  color: var(--text); border-radius: 9px; min-height: 38px; min-width: 38px;
  padding: 0 12px; font-size: 16px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none; line-height: 1; transition: background .12s, transform .08s;
}
.tbtn:hover { background: #eef2f9; }
.tbtn:active { transform: scale(.96); }
.tbtn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-size: 14px; padding: 0 16px; }
.tbtn.primary:hover { filter: brightness(1.05); }
.tbtn[disabled] { opacity: .4; pointer-events: none; }

/* ---------- PDF area ---------- */
.pdf-container {
  flex: 1 1 auto; min-height: 0; overflow: auto; position: relative;
  padding: 16px 0 24px; text-align: center; -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}
.pdf-page {
  /* 宽度由 JS 按 zoom 设置(默认 96%); zoom>1 时变宽并出现横向滚动 */
  margin: 0 auto 16px; background: #fff; width: 96%;
  box-shadow: 0 4px 18px rgba(20, 30, 60, .14);
}
.pdf-page canvas { display: block; width: 100%; height: auto; }

.loader, .errorbox {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px; color: var(--muted);
}
.errorbox { color: #b3261e; }
/* 作者样式的 display:flex 会盖过 [hidden] 自带的 display:none, 必须显式复位,
   否则 loader / errorbox 会一直浮在页面上(就算 PDF 已正常加载) */
.loader[hidden], .errorbox[hidden] { display: none; }
.spinner {
  width: 38px; height: 38px; border-radius: 50%;
  border: 4px solid #d3d9e6; border-top-color: var(--accent);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Bottom pager (移动端拇指友好) ---------- */
.pager {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: center;
  gap: 20px; padding: 8px 14px; background: var(--panel);
  border-top: 1px solid #dde2ec;
}
.pbtn {
  appearance: none; border: 1px solid #d3d9e6; background: #f7f9fc;
  color: var(--brand); border-radius: 11px; min-width: 76px; min-height: 46px;
  font-size: 24px; font-weight: 700; cursor: pointer; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .12s, transform .08s;
}
.pbtn:hover { background: #eef2f9; }
.pbtn:active { transform: scale(.96); }
.pbtn[disabled] { opacity: .35; pointer-events: none; }

/* ---------- Footer ---------- */
.footer {
  flex: 0 0 auto; height: var(--footer-h);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: var(--muted); background: var(--panel);
  border-top: 1px solid #dde2ec; padding-bottom: env(safe-area-inset-bottom);
}

/* 下载按钮的图标(内联 SVG, 跟随 currentColor) */
.tbtn .ico { width: 18px; height: 18px; display: block; flex: 0 0 auto; }
.tbtn.primary { gap: 7px; }

@media (max-width: 480px) {
  .brand-sub { display: none; }
  /* 手机上仅留图标(更紧凑), 不再用 emoji */
  .tbtn.primary span { display: none; }
  .tbtn.primary { padding: 0 12px; }
}
