* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
:root {
  --primary: #2c3e50;
  --accent: #3498db;
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #222;
  --muted: #888;
  --border: #e3e6ea;
}
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  overscroll-behavior-y: none;
}
.page { min-height: 100vh; display: flex; flex-direction: column; }
.hidden { display: none !important; }

/* 登录 */
#login-page { align-items: center; justify-content: center; padding: 20px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--card);
  border-radius: 14px; padding: 28px 22px;
  box-shadow: 0 8px 30px rgba(0,0,0,.08);
}
.login-card h1 { font-size: 22px; text-align: center; margin-bottom: 20px; }
.login-card label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 5px; }
.login-card input {
  width: 100%; padding: 11px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 15px;
}
.login-card input:focus { outline: none; border-color: var(--accent); }
.primary {
  width: 100%; margin-top: 20px; padding: 12px; background: var(--accent);
  color: #fff; border: none; border-radius: 8px; font-size: 16px; font-weight: 600;
}
.primary:active { opacity: .85; }
.error { color: #e74c3c; font-size: 13px; margin-top: 10px; min-height: 18px; text-align: center; }

/* 顶栏 */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  background: var(--primary); color: #fff;
  padding: calc(8px + env(safe-area-inset-top)) 10px 8px;
}
.title-text { flex: 1; font-size: 16px; font-weight: 600; }
.icon-btn {
  background: none; border: none; color: #fff; font-size: 19px;
  padding: 6px 8px; cursor: pointer;
}
#search {
  flex: 1; border: none; border-radius: 8px; padding: 8px 12px; font-size: 14px;
  background: rgba(255,255,255,.9);
}

/* 状态筛选 */
#status-tabs { display: flex; gap: 6px; padding: 8px 10px; overflow-x: auto; background: var(--card); border-bottom: 1px solid var(--border); }
.status-tab {
  flex: 1; min-width: 56px; padding: 6px 4px; font-size: 13px;
  border: 1px solid var(--border); background: #fff; border-radius: 16px; color: var(--muted);
}
.status-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* 书籍网格 */
#book-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px; padding: 12px;
}
.book-card {
  background: var(--card); border-radius: 10px; overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,.07); cursor: pointer;
  display: flex; flex-direction: column;
}
.book-cover {
  width: 100%; aspect-ratio: 3/4; object-fit: cover; background: #eef1f4;
}
.book-cover-placeholder {
  width: 100%; aspect-ratio: 3/4; display: flex; align-items: center;
  justify-content: center; color: #b5bdc6; font-size: 34px; background: #eef1f4;
}
.book-meta { padding: 7px 8px 9px; }
.book-name { font-size: 13px; font-weight: 600; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.book-author { font-size: 11px; color: var(--muted); margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { display: inline-block; font-size: 10px; padding: 1px 6px; border-radius: 8px; margin-top: 5px; }
.badge-0 { background: #eee; color: #888; }
.badge-1 { background: #e3f2fd; color: #1976d2; }
.badge-2 { background: #e8f5e9; color: #388e3c; }
.badge-3 { background: #fff3e0; color: #f57c00; }

.list-info { text-align: center; color: var(--muted); font-size: 12px; padding: 10px; }

/* 悬浮添加按钮 */
.fab {
  position: fixed; right: 20px; bottom: calc(24px + env(safe-area-inset-bottom));
  width: 56px; height: 56px; border-radius: 50%; border: none;
  background: var(--accent); color: #fff; font-size: 28px; line-height: 56px;
  box-shadow: 0 4px 14px rgba(52,152,219,.5); cursor: pointer;
}

/* 详情页 */
#detail-body { padding: 14px; }
.detail-images { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; }
.detail-images img { height: 260px; border-radius: 8px; flex-shrink: 0; }
.detail-section { background: var(--card); border-radius: 10px; padding: 14px; margin-top: 12px; }
.detail-row { display: flex; padding: 6px 0; font-size: 14px; border-bottom: 1px solid #f0f2f4; }
.detail-row:last-child { border-bottom: none; }
.detail-row .k { width: 84px; color: var(--muted); flex-shrink: 0; }
.detail-row .v { flex: 1; white-space: pre-wrap; word-break: break-word; }
.detail-desc { font-size: 14px; line-height: 1.7; white-space: pre-wrap; }
.detail-comments { font-size: 13px; }
.detail-comments .c { padding: 6px 0; border-bottom: 1px solid #f0f2f4; }

/* 编辑表单 */
.form-row { display: flex; flex-direction: column; margin-bottom: 10px; }
.form-row label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.form-row input, .form-row select, .form-row textarea {
  padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
  font-family: inherit; background: #fff;
}
.form-row textarea { min-height: 70px; resize: vertical; }
.save-bar { display: flex; gap: 10px; margin-top: 14px; }
.save-bar button { flex: 1; padding: 12px; border-radius: 8px; border: none; font-size: 15px; font-weight: 600; }
.save-bar .save { background: var(--accent); color: #fff; }
.save-bar .cancel { background: #eee; color: #555; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: rgba(0,0,0,.8); color: #fff; padding: 10px 18px;
  border-radius: 20px; font-size: 14px; z-index: 100;
  max-width: 86%; text-align: center;
}

/* 详情小节标题 */
.detail-h { font-size: 12px; color: var(--muted); margin-bottom: 6px; }

/* ISBN 行与获取按钮 */
.isbn-row { display: flex; gap: 8px; }
.isbn-row input { flex: 1; }
.isbn-row button {
  padding: 0 14px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; font-size: 17px;
}
.fetch-row { display: flex; gap: 8px; margin-top: 8px; }
.fetch-btn {
  flex: 1; padding: 9px; border: 1px solid var(--accent); color: var(--accent);
  background: #fff; border-radius: 8px; font-size: 14px; font-weight: 600;
}
.fetch-btn:active { background: var(--accent); color: #fff; }

/* 评论编辑 */
.comment-item {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 6px 0; border-bottom: 1px solid #f0f2f4; font-size: 13px;
}
.comment-item span { flex: 1; white-space: pre-wrap; word-break: break-word; }
.comment-del { border: none; background: none; color: #e74c3c; font-size: 16px; padding: 0 4px; }
.comment-add { display: flex; gap: 8px; margin-top: 8px; }
.comment-add input { flex: 1; }
.comment-add button {
  padding: 0 14px; border: none; border-radius: 8px;
  background: var(--accent); color: #fff; font-size: 14px;
}

/* 扫码弹窗 */
.modal {
  position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-card {
  width: 100%; max-width: 420px; background: var(--card);
  border-radius: 12px; padding: 16px;
}
.modal-title { font-size: 14px; color: var(--muted); text-align: center; margin-bottom: 10px; }
#scan-reader { width: 100%; border-radius: 8px; overflow: hidden; background: #000; }
#scan-reader video { width: 100%; }
#scan-close {
  width: 100%; margin-top: 12px; padding: 11px; border: none;
  border-radius: 8px; background: #eee; color: #555; font-size: 15px;
}
