/* 样式 token 全量取自系统内老款（space-3）的 theme.css。 */
:root {
  --paper: #f5efe3;
  --surface: #fffdf6;
  --surface2: #eadfc9;
  --ink: #221c14;
  --dim: #6d6050;
  --line: #ddd0b8;
  --accent: #a63d21;
  --signal: #e2a15c;
  --warn: #8a5a00;
  --ok: #2e7d32;
  --grain-dot: rgba(34, 28, 20, 0.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #17120d;
    --surface: #241c12;
    --surface2: #2e2318;
    --ink: #f0e8d8;
    --dim: #b8a88f;
    --line: #4a3a28;
    --accent: #e0a184;
    --signal: #e8a868;
    --warn: #e8a868;
    --ok: #8fce8f;
    --grain-dot: rgba(240, 232, 216, 0.06);
  }
}
* { box-sizing: border-box; }
html { -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  background: var(--paper);
  background-image: radial-gradient(var(--grain-dot) 1px, transparent 1.5px);
  background-size: 5px 5px;
  color: var(--ink);
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  line-height: 1.6;
}
h1, h2, .book-title, .scan-count, .fb-title {
  font-family: "Noto Serif SC", "Songti SC", "SimSun", serif;
}
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hidden { display: none !important; }

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px 16px calc(88px + env(safe-area-inset-bottom));
}
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
}
.input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-size: 16px;
}
textarea.input { min-height: 96px; resize: vertical; }
.btn {
  min-height: 48px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
}
.btn.secondary {
  min-height: 44px;
  background: var(--surface2);
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn.danger {
  min-height: 44px;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}
.btn:disabled { opacity: 0.55; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.form { display: flex; flex-direction: column; gap: 12px; }
.form .row > div { flex: 1 1 100%; }
@media (min-width: 640px) {
  .form .row > div { flex: 1 1 45%; }
}
label { display: block; font-size: 14px; color: var(--dim); margin-bottom: 4px; }
.msg { font-size: 14px; min-height: 20px; }
.msg.ok { color: var(--ok); }
.msg.warn { color: var(--warn); }
.dim { color: var(--dim); font-size: 14px; }

/* 登录 */
.login-wrap {
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-panel { width: 100%; max-width: 420px; }
.login-panel h1 { margin: 0 0 16px; }

/* 书架：标题 34px 宋体，统计行只在有待处理时追加后半句
   （Pages 版没有待处理状态，所以只显示「共 N 册」）。 */
.shelf-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.shelf-head h1 { font-size: 34px; margin: 0; line-height: 1.2; }
.shelf-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.shelf-tools .who { font-size: 14px; color: var(--dim); }
.stats { color: var(--dim); font-size: 14px; margin: 0 0 12px; }
.search { margin-bottom: 16px; }
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
}
.card { cursor: pointer; }
.card .cover { aspect-ratio: 3 / 4; border-radius: 8px; overflow: hidden; background: var(--surface2); }
.card img { width: 100%; object-fit: cover; display: block; }
.cover-fallback {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px 16px 16px 26px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.cover-fallback::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
  opacity: 0.55;
}
.fb-title {
  font-size: 16px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.fb-author { font-size: 13px; color: var(--dim); margin-top: 6px; }
.card .book-title {
  font-size: 15px;
  line-height: 1.4;
  margin-top: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card .book-author { font-size: 13px; color: var(--dim); margin-top: 2px; }
.card .book-pub { font-size: 13px; color: var(--dim); }
.empty { color: var(--dim); text-align: center; padding: 40px 0; }

/* 扫码：取景 57svh / 最小 390px，扫码框 78% 宽、52% 高度处水平居中。
   未启动时不是黑屏，而是纸面占位 + 启动按钮（老款的黑屏不照搬）。 */
.scan-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.scan-mode { color: var(--dim); font-size: 15px; }
.scan-count { font-size: 26px; font-weight: 700; letter-spacing: 1px; }
.scan-shell {
  position: relative;
  height: 57vh;
  height: 57svh;
  min-height: 390px;
  border-radius: 14px;
  overflow: hidden;
  background: var(--surface2);
  border: 1px solid var(--line);
}
.scan-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}
.scan-video.on { display: block; }
.scan-frame {
  position: absolute;
  left: 50%;
  top: 52%;
  width: 78%;
  height: 160px;
  transform: translate(-50%, -50%);
  border: 2px solid var(--signal);
  border-radius: 12px;
  pointer-events: none;
  z-index: 2;
}
.scan-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--dim);
  text-align: center;
  padding: 20px;
  z-index: 1;
}
.scan-hint { color: var(--dim); font-size: 14px; text-align: center; margin: 14px 0; }

/* 详情：移动端底部弹出层（max-h 94svh、上圆角 18px），sm 起居中圆角 14px。 */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(34, 28, 20, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
}
.sheet {
  position: relative;
  background: var(--surface);
  width: 100%;
  max-height: 94svh;
  overflow-y: auto;
  border-radius: 18px 18px 0 0;
  padding: 24px 20px calc(20px + env(safe-area-inset-bottom));
}
@media (min-width: 640px) {
  .overlay { align-items: center; }
  .sheet { max-width: 560px; border-radius: 14px; max-height: 90svh; padding-bottom: 24px; }
}
.sheet-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  color: var(--dim);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}
.detail { display: flex; gap: 16px; flex-wrap: wrap; }
.detail .cover { width: 180px; flex: 0 0 auto; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 8px; }
.detail .cover-fallback { width: 180px; flex: 0 0 auto; }
.detail .info { flex: 1 1 220px; }
.detail h2 { margin: 0 0 8px; font-size: 22px; line-height: 1.3; }
.detail .field { font-size: 15px; margin: 4px 0; }
.detail .field .k { color: var(--dim); font-size: 13px; }
.detail .summary { margin-top: 16px; }
.detail .summary h3 { font-size: 15px; margin: 0 0 6px; }
.detail .summary p { font-size: 15px; margin: 0; white-space: pre-wrap; }
.detail .actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

/* 底部导航：固定底部、三项、66px、pb-safe（老款结构）。 */
.bottomnav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--line);
  min-height: 66px;
  padding-bottom: env(safe-area-inset-bottom);
}
.navbtn {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--dim);
  font-size: 15px;
  padding: 12px 4px;
  cursor: pointer;
  min-height: 66px;
}
.navbtn.active { color: var(--accent); font-weight: 600; }
