/* 书库 · 全站样式（阅读器样式在 reader.css） */
:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --text: #1f2328;
  --muted: #6b6f76;
  --line: #e4e2dc;
  --accent: #2f6f5e;
  --accent-ink: #ffffff;
  --danger: #b3261e;
  --ok: #2e7d32;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 12px rgba(0,0,0,.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17181a;
    --surface: #212225;
    --text: #e8e6e3;
    --muted: #9a9ca1;
    --line: #34363a;
    --accent: #6cbfa5;
    --accent-ink: #0e1a16;
    --danger: #f2827a;
    --ok: #81c784;
    --shadow: 0 1px 2px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
img { display: block; max-width: 100%; }
small { font-size: .8em; }
.muted { color: var(--muted); }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.main { padding-top: 20px; padding-bottom: 60px; }
.inline { display: inline; margin: 0; }
[hidden] { display: none !important; }

/* 顶栏 */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 54px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 17px; color: var(--accent); }
.nav { display: flex; align-items: center; gap: 4px; }
.nav a, .nav .link { padding: 6px 12px; border-radius: 8px; color: var(--muted); font: inherit; }
.nav a[aria-current="page"] { color: var(--text); background: var(--bg); font-weight: 500; }
.link { background: none; border: 0; cursor: pointer; }
.link:hover { color: var(--accent); }

/* 按钮与表单 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); color: var(--accent-ink); }
.btn.block { display: flex; width: 100%; }
.danger-btn { color: var(--danger); }
.danger-btn:hover { border-color: var(--danger); color: var(--danger); }
.danger-btn.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); border-color: var(--accent); }
textarea { resize: vertical; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.msg { font-size: 14px; margin: 8px 0; }
.msg.error { color: var(--danger); }
.msg.ok { color: var(--ok); }

/* 登录 */
.login { min-height: 80vh; display: grid; place-items: center; }
.login-card { width: 100%; max-width: 360px; background: var(--surface); border-radius: 14px; padding: 32px 28px; box-shadow: var(--shadow); }
.login-logo { color: var(--accent); display: flex; justify-content: center; }
.login h1 { text-align: center; font-size: 20px; margin: 8px 0 24px; }

/* 区块 */
.section { margin-bottom: 28px; }
.section.narrow { max-width: 720px; margin-left: auto; margin-right: auto; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; }
.section-title { font-size: 16px; font-weight: 600; margin: 8px 0 14px; }
.section-title small { color: var(--muted); font-weight: 400; margin-left: 4px; }
.page-title { font-size: 22px; margin: 0 0 18px; }

/* 工具栏 */
.toolbar { display: flex; gap: 8px; margin-bottom: 12px; }
.toolbar .search { flex: 1; min-width: 0; }
.toolbar select { width: auto; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 12px; }
.chip { padding: 3px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.chip small { opacity: .7; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* 书卡 */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 22px 18px; }
@media (max-width: 520px) { .grid { grid-template-columns: repeat(3, 1fr); gap: 16px 10px; } }
.card { display: block; min-width: 0; }
.cover {
  position: relative; aspect-ratio: 2 / 3; border-radius: 6px; overflow: hidden;
  background: var(--line); box-shadow: var(--shadow);
}
.cover img { width: 100%; height: 100%; object-fit: cover; }
.card:hover .cover { transform: translateY(-2px); transition: transform .15s; }
.cover-fallback {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; padding: 12px;
  background: linear-gradient(160deg, hsl(var(--h) 35% 42%), hsl(calc(var(--h) + 30) 40% 28%));
  color: #fff; text-align: center; font-weight: 600; font-size: 15px; line-height: 1.4;
}
.cover-fallback span { display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; word-break: break-all; }
.badge { position: absolute; top: 6px; right: 6px; font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 4px; background: rgba(0,0,0,.55); color: #fff; letter-spacing: .5px; }
.bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(0,0,0,.25); }
.bar i { display: block; height: 100%; background: var(--accent); }
.bar.inline { position: static; border-radius: 2px; background: var(--line); margin-top: 6px; }
.card-title { margin-top: 8px; font-size: 14px; font-weight: 500; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-all; }
.card-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 最近在读 */
.reading { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.reading-item { display: flex; gap: 12px; background: var(--surface); border-radius: var(--radius); padding: 10px; box-shadow: var(--shadow); min-width: 0; }
.cover.sm { width: 54px; flex: none; }
.reading-meta { min-width: 0; flex: 1; align-self: center; }
.reading-meta .card-title { margin-top: 0; }

.pager { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 30px; }
.empty { text-align: center; padding: 60px 0; color: var(--muted); }
.empty .btn { margin-top: 8px; }

/* 上传 */
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  padding: 44px 20px; border: 2px dashed var(--line); border-radius: 14px; background: var(--surface);
  cursor: pointer; color: var(--muted); transition: border-color .15s, background .15s;
}
.dropzone strong { color: var(--text); font-weight: 500; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); color: var(--accent); }
.queue { list-style: none; padding: 0; margin: 18px 0 0; }
.queue li { background: var(--surface); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 8px; box-shadow: var(--shadow); }
.q-row { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.q-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.q-status { font-size: 13px; color: var(--muted); flex: none; }
.q-status.ok { color: var(--ok); }
.q-status.error { color: var(--danger); }
.q-bar { height: 4px; border-radius: 2px; background: var(--line); margin-top: 8px; overflow: hidden; }
.q-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.queue-actions { margin-top: 14px; text-align: center; }

/* 详情 */
.back { display: inline-block; margin-bottom: 16px; font-size: 14px; }
.detail { display: grid; grid-template-columns: 220px 1fr; gap: 32px; align-items: start; }
@media (max-width: 680px) { .detail { grid-template-columns: 1fr; } .detail-cover { max-width: 200px; margin: 0 auto; width: 100%; } }
.cover.lg { margin-bottom: 12px; }
.detail-title { font-size: 24px; margin: 0 0 4px; line-height: 1.35; word-break: break-word; }
.detail-author { margin: 0 0 16px; color: var(--muted); }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin: 0 0 16px; padding: 14px; background: var(--surface); border-radius: var(--radius); }
.facts dt { font-size: 12px; color: var(--muted); }
.facts dd { margin: 0; font-weight: 500; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0; }
.desc { white-space: pre-line; color: var(--text); background: var(--surface); padding: 14px 16px; border-radius: var(--radius); margin-bottom: 16px; max-height: 320px; overflow: auto; }
.edit { background: var(--surface); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; }
.edit summary { cursor: pointer; font-weight: 500; }
.edit .form { margin-top: 14px; }
.danger { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line); }
.danger form { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
