/* ============================================================
   读书笔记 · 共用样式（前台 + 后台），移动端优先
   ============================================================ */
:root {
  --paper: #faf6ef;
  --card: #ffffff;
  --ink: #3d3425;
  --ink-soft: #7a6f5c;
  --ink-faint: #a89f8c;
  --accent: #b0804a;
  --accent-dark: #96683a;
  --line: #e8e0cf;
  --ok: #4a8f5e;
  --warn: #c08a3e;
  --bad: #c05a4a;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(93, 74, 42, 0.10);
  --serif: Georgia, "Times New Roman", "Songti SC", "SimSun", serif;
  --sans: -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.7;
  min-height: 100vh;
}

a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  transition: background .15s ease, transform .05s ease;
}
button:active { transform: scale(.98); }
button:disabled { opacity: .55; cursor: not-allowed; }

input, textarea {
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(176, 128, 74, .15);
}
textarea { resize: vertical; min-height: 120px; }

.container { max-width: 860px; margin: 0 auto; padding: 0 16px; }

/* ---------- 顶部栏 ---------- */
.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo { font-size: 24px; }
.brand .title {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--ink);
}
.brand .title:hover { text-decoration: none; }
.header-actions { display: flex; gap: 8px; }
.header-actions a, .header-actions button {
  font-size: 14px;
  padding: 8px 14px;
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
}
.header-actions a:hover { background: var(--line); text-decoration: none; }

/* ---------- 主要按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
.btn:hover { background: var(--accent-dark); }
.btn-lg { font-size: 16px; padding: 14px 30px; border-radius: 12px; }
.btn-ghost { background: transparent; color: var(--ink-soft); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--paper); }
.btn-danger { background: var(--bad); }
.btn-danger:hover { background: #a84a3c; }
.btn-ok { background: var(--ok); }
.btn-ok:hover { background: #3c7a4e; }
.btn-sm { font-size: 13px; padding: 6px 12px; border-radius: 8px; }

/* ---------- 首页 ---------- */
.home-main { padding: 28px 0 120px; text-align: center; }
.page-intro { margin-bottom: 22px; }
.page-intro h1 {
  font-family: var(--serif);
  font-size: clamp(24px, 4vw, 32px);
  color: var(--ink);
  letter-spacing: 1px;
}
.page-intro p { color: var(--ink-soft); font-size: 15px; margin-top: 4px; }

.note-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  text-align: left;
  display: flex;
  flex-wrap: wrap;
  gap: 26px;
  animation: fadeIn .35s ease;
  max-width: 720px;
  margin: 0 auto;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.cover-wrap { flex: 0 0 190px; }
.cover-wrap img {
  width: 190px;
  height: 270px;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(93, 74, 42, .18);
  background: var(--paper);
  display: block;
}
.cover-placeholder {
  width: 190px;
  height: 270px;
  border-radius: 8px;
  background: linear-gradient(160deg, #f3ecdd, #e9e0cb);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--ink-faint);
  font-size: 46px;
  box-shadow: 0 4px 16px rgba(93, 74, 42, .12);
}
.cover-placeholder span { font-size: 13px; }

.note-info { flex: 1; min-width: 0; }
.book-title {
  font-family: var(--serif);
  font-size: 26px;
  line-height: 1.3;
  color: var(--ink);
}
.book-meta { margin-top: 6px; font-size: 14px; color: var(--ink-soft); }
.book-meta .sep { margin: 0 8px; color: var(--ink-faint); }
.douban-link { font-size: 13px; }

.divider { height: 1px; background: var(--line); margin: 16px 0; }

.note-content {
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.9;
  color: var(--ink);
  border-left: 3px solid var(--accent);
  padding-left: 16px;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 320px;
  overflow-y: auto;
}

.note-footer {
  margin-top: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--ink-faint);
}
.note-footer .uploader { font-weight: 600; color: var(--ink-soft); }

/* 「换一换」固定在屏幕底部，评论再多也不会被推到看不见 */
.home-actions {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
  background: rgba(250, 246, 239, 0.94);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: 0 -2px 14px rgba(93, 74, 42, 0.10);
}
.home-actions .btn-lg {
  min-width: 220px;
  max-width: 90vw;
}
.home-actions .count { color: var(--ink-faint); font-size: 13px; }

.empty-state { padding: 48px 20px; color: var(--ink-soft); }
.empty-state .big { font-size: 48px; margin-bottom: 10px; }

/* ---------- 页脚 ---------- */
.site-footer {
  text-align: center;
  padding: 20px 0 130px;
  color: var(--ink-faint);
  font-size: 13px;
}

/* ---------- 弹窗 ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(61, 52, 37, .45);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  z-index: 50;
  overflow-y: auto;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 560px;
  padding: 26px;
  animation: fadeIn .25s ease;
}
.modal h2 {
  font-family: var(--serif);
  font-size: 22px;
  margin-bottom: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal .close {
  background: none;
  font-size: 24px;
  color: var(--ink-faint);
  padding: 0 4px;
  line-height: 1;
}
.modal .close:hover { color: var(--ink); }

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.form-group label .req { color: var(--bad); }
.form-group .hint { font-size: 12px; color: var(--ink-faint); margin-top: 4px; }

.douban-row { display: flex; gap: 8px; align-items: flex-start; }
.douban-row input { flex: 1; }
.douban-row .btn-sm { white-space: nowrap; padding-top: 11px; padding-bottom: 11px; }

.cover-preview { margin-top: 8px; }
.cover-preview img { width: 64px; height: 90px; object-fit: cover; border-radius: 6px; box-shadow: var(--shadow); }
.cover-preview .none { font-size: 12px; color: var(--ink-faint); }

/* 豆瓣搜索结果列表 */
.douban-results {
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}
.db-result {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: #fff;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
}
.db-result:last-child { border-bottom: none; }
.db-result:hover { background: var(--paper); }
.db-cover {
  width: 34px;
  height: 48px;
  object-fit: cover;
  border-radius: 4px;
  flex: 0 0 34px;
  box-shadow: 0 2px 6px rgba(93, 74, 42, .15);
}
.db-cover-ph {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  font-size: 16px;
}
.db-info { display: flex; flex-direction: column; min-width: 0; }
.db-title { font-weight: 600; font-size: 14px; color: var(--ink); }
.db-meta { font-size: 12px; color: var(--ink-faint); }
.db-loading, .db-empty {
  padding: 12px;
  text-align: center;
  font-size: 13px;
  color: var(--ink-faint);
}

/* 已选书籍摘要 */
.book-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}
.book-summary img {
  width: 44px;
  height: 62px;
  object-fit: cover;
  border-radius: 5px;
  flex: 0 0 44px;
  box-shadow: 0 2px 8px rgba(93, 74, 42, .15);
}
.book-summary-info { min-width: 0; }
#book-summary-title { font-weight: 700; font-size: 15px; color: var(--ink); }
#book-summary-meta { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }

/* 未审核/被驳回的提示条（重复内容跳转查看时） */
.status-banner {
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 10px;
  margin-bottom: 16px;
  flex: 0 0 100%;
  width: 100%;
}
.status-banner.pending { background: #f7ecd8; color: #96683a; }
.status-banner.rejected { background: #fbe7e3; color: #a84a3c; }

/* ---------- 点赞 & 评论（前台卡片内） ---------- */
.note-actions { flex: 0 0 100%; width: 100%; margin-top: 6px; }

.action-bar {
  display: flex;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.like-btn, .comment-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 7px 16px;
  font-size: 14px;
  color: var(--ink-soft);
}
.like-btn:hover, .comment-toggle:hover { border-color: var(--accent); color: var(--ink); }
.like-btn.liked {
  background: #fdf1e3;
  border-color: var(--accent);
  color: var(--accent-dark);
  font-weight: 600;
}

.comments-section { margin-top: 16px; }
.comment-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.comment-item {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 10px 14px;
}
.comment-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; }
.commenter {
  font-weight: 600;
  font-size: 13px;
  color: var(--accent-dark);
  background: #f7ecd8;
  padding: 2px 10px;
  border-radius: 12px;
}
.comment-date { font-size: 12px; color: var(--ink-faint); }
.comment-content { font-size: 14px; color: var(--ink); line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.comment-empty { text-align: center; color: var(--ink-faint); font-size: 13px; padding: 12px 0; }

.comment-form { border-top: 1px dashed var(--line); padding-top: 12px; }
.comment-fields { display: flex; flex-direction: column; gap: 12px; }
.comment-fields input,
.comment-fields textarea { width: 100%; }
.comment-fields input[data-commenter] { max-width: 240px; }
.comment-fields textarea[data-comment-text] {
  min-height: 104px;
  resize: vertical;
  font-size: 15px;
}
.comment-form .captcha-row {
  max-width: 300px;
  margin-top: 12px; /* 与评论填写区留间距 */
}
.comment-submit-row { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.comment-msg { font-size: 13px; color: var(--ink-soft); }
.comment-msg.ok { color: var(--ok); }
.comment-msg.error { color: var(--bad); }

/* ---------- 后台导航切换 ---------- */
.admin-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 5px;
}
.nav-btn {
  flex: 1;
  padding: 10px 14px;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 15px;
}
.nav-btn.active { background: var(--accent); color: #fff; font-weight: 600; }

/* 当前登录账号名 */
.whoami {
  font-size: 13px;
  color: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  padding: 0 6px;
}

/* 下拉选择框 */
select {
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 34px 10px 12px;
  width: 100%;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238a7a5c' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(176, 128, 74, .15);
}

/* 复选/单选统一配色 */
input[type="checkbox"], input[type="radio"] {
  width: auto;
  accent-color: var(--accent);
}

/* 权限勾选 */
.perm-checkboxes { display: flex; flex-direction: column; gap: 8px; }
.perm-checkboxes label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
  padding: 8px 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.perm-checkboxes label.sub {
  margin-left: 22px;
  background: #fff;
  padding-left: 14px;
}
.perm-checkboxes input { width: auto; }

/* 开关切换 */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
  padding: 6px 2px;
}
.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  flex: 0 0 46px;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.switch-slider {
  position: absolute;
  inset: 0;
  background: var(--line);
  border-radius: 26px;
  transition: background .2s ease;
}
.switch-slider::before {
  content: "";
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
}
.switch input:checked + .switch-slider { background: var(--ok); }
.switch input:checked + .switch-slider::before { transform: translateX(20px); }

/* 上传按钮（label 模拟按钮） */
.upload-btn { display: inline-flex; align-items: center; white-space: nowrap; cursor: pointer; }

/* 评论审核·笔记详情弹窗 */
.note-detail { display: flex; gap: 20px; }
.note-detail .nd-cover { flex: 0 0 130px; }
.note-detail .nd-cover img { width: 130px; height: 185px; object-fit: cover; border-radius: 8px; box-shadow: var(--shadow); }
.note-detail .nd-cover .cover-placeholder { width: 130px; height: 185px; }
.note-detail .nd-info { flex: 1; min-width: 0; }
.note-detail .note-content { max-height: 260px; margin-top: 12px; }
.note-detail .note-footer { margin-top: 14px; flex-wrap: wrap; gap: 8px; }

.captcha-row { display: flex; gap: 10px; align-items: center; }
.captcha-row input { flex: 1; }
.captcha-img {
  height: 40px;
  width: 100px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid var(--line);
  background: #fff;
  display: block;
}
.captcha-hint { font-size: 12px; color: var(--ink-faint); margin-top: 4px; }

.form-actions { display: flex; gap: 10px; margin-top: 20px; }
.form-actions .btn { flex: 1; }
.form-msg { font-size: 14px; margin-top: 12px; min-height: 20px; }
.form-msg.error { color: var(--bad); }
.form-msg.ok { color: var(--ok); }

/* ---------- 管理后台 ---------- */
.admin-main { padding: 24px 0 60px; }
.admin-title { font-family: var(--serif); font-size: 24px; margin-bottom: 18px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.stat-card {
  background: var(--card);
  border-radius: 12px;
  padding: 14px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(93, 74, 42, .06);
  cursor: pointer;
  border: 2px solid transparent;
}
.stat-card.active { border-color: var(--accent); }
.stat-card .num { font-size: 24px; font-weight: 700; color: var(--ink); }
.stat-card .label { font-size: 12px; color: var(--ink-soft); }

.toolbar { display: flex; justify-content: flex-end; margin-bottom: 14px; }

.note-list { display: flex; flex-direction: column; gap: 12px; }
.note-item {
  background: var(--card);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 2px 8px rgba(93, 74, 42, .06);
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.note-item .thumb {
  width: 46px;
  height: 64px;
  object-fit: cover;
  border-radius: 5px;
  flex: 0 0 46px;
  background: var(--paper);
}
.note-item .thumb-ph { width: 46px; height: 64px; border-radius: 5px; background: var(--paper); display: flex; align-items: center; justify-content: center; font-size: 20px; flex: 0 0 46px; }
.note-item .body { flex: 1; min-width: 0; }
.note-item .title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.note-item .t { font-family: var(--serif); font-size: 16px; font-weight: 700; }
.note-item .meta { font-size: 12px; color: var(--ink-faint); margin-top: 2px; }
.note-item .content-preview {
  font-size: 13px;
  color: var(--ink-soft);
  margin-top: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.note-item .ops { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 600;
  white-space: nowrap;
}
.badge.pending { background: #f7ecd8; color: #96683a; }
.badge.approved { background: #e3f1e7; color: #3c7a4e; }
.badge.rejected { background: #fbe7e3; color: #a84a3c; }

.empty-list { text-align: center; color: var(--ink-faint); padding: 40px 0; }

/* ---------- 登录 ---------- */
.login-wrap { max-width: 380px; margin: 8vh auto 0; }
.login-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 30px;
}
.login-card h2 { font-family: var(--serif); margin-bottom: 20px; text-align: center; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: #fff;
  padding: 12px 22px;
  border-radius: 12px;
  font-size: 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  z-index: 100;
  max-width: 90vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--bad); }
.toast.ok { background: var(--ok); }

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
  .site-header .container { height: 54px; }
  .brand .title { font-size: 17px; }
  .brand .logo { font-size: 20px; }
  .header-actions a, .header-actions button { font-size: 13px; padding: 7px 11px; }

  .note-card { flex-direction: column; align-items: center; padding: 20px 16px; gap: 18px; }
  .cover-wrap, .cover-wrap img, .cover-placeholder { width: 150px; height: 214px; flex: none; }
  .note-info { width: 100%; }
  .book-title { font-size: 22px; }
  .note-content { font-size: 16px; max-height: none; }

  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal {
    border-radius: 18px 18px 0 0;
    max-width: none;
    max-height: 92vh;
    overflow-y: auto;
    padding: 22px 18px calc(22px + env(safe-area-inset-bottom));
  }

  .stats { grid-template-columns: repeat(2, 1fr); }
  .note-item { flex-wrap: wrap; }
  .note-item .ops { width: 100%; justify-content: flex-end; }
  .douban-row { flex-direction: column; }

  .comment-fields { flex-direction: column; }
  .comment-fields input[data-comment-text] { flex: none; }
  .action-bar { gap: 8px; }
  .like-btn, .comment-toggle { flex: 1; justify-content: center; padding: 8px 10px; }
  .comment-submit-row { flex-wrap: wrap; }
  .admin-nav .nav-btn { font-size: 14px; padding: 9px 8px; }
  .note-detail { flex-direction: column; }
  .note-detail .nd-cover { flex: none; }
  .whoami { display: none; }
}
