:root {
  /* 自然 / 生物风：淡叶绿背景 + 森林绿主色 + 暖橙点缀 */
  --bg-1: #f7fcf8;
  --bg-2: #eef6f0;
  --sun: #f3fbf2;
  --panel: #ffffff;
  --panel-2: #f2f9f4;
  --border: #d7e9dc;
  --text: #243a2f;
  --muted: #6f8a7c;
  --accent: #2f9e6b;        /* 森林绿 */
  --accent-deep: #237a52;
  --accent-soft: #e6f5ec;
  --accent-2: #f2a541;      /* 暖橙（花/阳光点缀） */
  --accent-2-soft: #fdeccd;
  --mark: #ffe39a;          /* 暖黄高亮 */
  --mark-text: #6a4700;
  --badge: #eaf4ee;
  --leaf: #4caf7d;
  --topbar-grad: linear-gradient(135deg, #4cb486 0%, #2f9e6b 55%, #3aa98a 100%);
  --shadow: 0 8px 26px rgba(47, 158, 107, .10);
  --shadow-sm: 0 3px 12px rgba(47, 158, 107, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  /* 清晨森林光感：两团极淡的暖光 + 整体淡绿渐变 */
  background:
    radial-gradient(circle at 10% -5%, var(--sun) 0%, transparent 42%),
    radial-gradient(circle at 92% 4%, #e9f6f0 0%, transparent 40%),
    linear-gradient(180deg, var(--bg-1), var(--bg-2));
  background-attachment: fixed;
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Source Han Sans SC", system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  background: var(--topbar-grad);
  border-bottom: 1px solid rgba(255, 255, 255, .25);
  padding: 20px 26px;
  box-shadow: 0 4px 18px rgba(47, 158, 107, .18);
  position: relative;
  overflow: hidden;
}
/* 顶栏右上角一抹柔和光晕，增添轻盈感 */
.topbar::after {
  content: "";
  position: absolute;
  top: -60px; right: -40px;
  width: 220px; height: 220px;
  background: radial-gradient(circle, rgba(255, 255, 255, .28) 0%, transparent 70%);
  pointer-events: none;
}
.brand { display: flex; align-items: center; gap: 14px; position: relative; z-index: 1; }
.logo { font-size: 34px; line-height: 1; filter: drop-shadow(0 2px 3px rgba(0,0,0,.15)); }
.topbar h1 { font-size: 19px; margin: 0; font-weight: 700; letter-spacing: .3px; color: #fff; }
.topbar .sub { margin: 3px 0 0; color: rgba(255, 255, 255, .88); font-size: 13px; }

/* 两栏布局：左检索 / 右预览 */
.layout {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  padding: 22px 18px 44px;
  max-width: 1500px;
  margin: 0 auto;
}
.left { flex: 1 1 50%; min-width: 0; }

/* 右栏：PDF 预览 */
.preview {
  flex: 1 1 50%;
  position: sticky;
  top: 18px;
  align-self: flex-start;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 96px);
  box-shadow: var(--shadow);
}
.preview-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: linear-gradient(180deg, #f4fbf6, #eaf5ee);
  border-bottom: 1px solid var(--border);
}
.preview-title { font-size: 14px; font-weight: 700; color: var(--accent-deep); }
.fs-btn {
  background: #fff; border: 1px solid var(--border); color: var(--accent-deep);
  border-radius: 9px; padding: 5px 13px; font-size: 13px; cursor: pointer; transition: .15s;
  box-shadow: var(--shadow-sm);
}
.fs-btn:hover { border-color: var(--accent); background: var(--accent-soft); }

.preview-empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
  color: var(--muted); font-size: 14px; line-height: 1.9;
  background:
    radial-gradient(circle at 50% 30%, #f0faf3 0%, transparent 60%);
}
.preview-empty .big { font-size: 46px; margin-bottom: 10px; }

/* 兼容性：用 class 设 display 会覆盖 [hidden]，显式回归 */
.preview-empty[hidden],
.preview-body[hidden],
.dc-link[hidden],
.preview-note[hidden] { display: none !important; }

.preview-body { flex: 1; display: flex; flex-direction: column; overflow: hidden; padding: 14px 16px; gap: 9px; }
.pv-book { font-size: 16px; font-weight: 700; color: var(--text); }
.pv-loc { font-size: 13px; color: var(--muted); }
.pv-loc .sep { margin: 0 6px; opacity: .5; }
.pv-loc b { color: var(--accent-deep); font-weight: 600; }
.pv-page { font-size: 13px; color: var(--text); }
.pv-page b { color: var(--accent); }

.preview-canvas-wrap {
  flex: 1; overflow: auto; background: #eef4ef;
  border: 1px solid var(--border); border-radius: 10px;
  display: flex; justify-content: center; align-items: flex-start; padding: 10px;
}
#pdfCanvas {
  max-width: 100%; height: auto;
  box-shadow: 0 4px 18px rgba(47, 158, 107, .18);
  background: #fff;
  border-radius: 4px;
}

.dc-link {
  display: inline-block; text-align: center; text-decoration: none;
  background: var(--accent-2-soft); color: #b9742a; border: 1px solid #f0cf94;
  border-radius: 10px; padding: 9px 16px; font-size: 14px; font-weight: 600; cursor: pointer; transition: .15s;
}
.dc-link:hover { background: #fbe2b8; }

.preview-note {
  font-size: 13px; color: #a8553f; background: #fdeee8;
  border: 1px solid #f3c9b6; border-radius: 8px; padding: 8px 12px; line-height: 1.7;
}

/* ---------- 检索区 ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 20px 18px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.field-label { font-size: 14px; color: var(--accent-deep); font-weight: 700; }
.link-btn {
  background: none; border: none; color: var(--accent); cursor: pointer;
  font-size: 13px; padding: 2px 4px; font-weight: 600;
}
.link-btn:hover { text-decoration: underline; }

.book-list { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.book-chip {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 11px; padding: 9px 13px; cursor: pointer;
  font-size: 14px; user-select: none; transition: .15s;
}
.book-chip:hover { border-color: var(--accent); background: #eef8f1; }
.book-chip input { accent-color: var(--accent); width: 16px; height: 16px; cursor: pointer; }
.book-chip.checked { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-deep); font-weight: 600; }

.search-row { display: flex; gap: 10px; }
.search-input {
  flex: 1; background: #fff; border: 1px solid var(--border);
  color: var(--text); border-radius: 11px; padding: 12px 15px; font-size: 15px; outline: none;
  box-shadow: var(--shadow-sm);
}
.search-input::placeholder { color: #9bb0a3; }
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47, 158, 107, .15); }
.search-btn {
  background: linear-gradient(135deg, #3aa98a, #2f9e6b); color: #fff; border: none; border-radius: 11px;
  padding: 0 24px; font-size: 15px; font-weight: 700; cursor: pointer; transition: .15s;
  box-shadow: 0 4px 14px rgba(47, 158, 107, .28);
}
.search-btn:hover { filter: brightness(1.06); box-shadow: 0 6px 18px rgba(47, 158, 107, .34); }
.search-btn:disabled { opacity: .6; cursor: default; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 13px; }
.chip {
  background: var(--badge); border: 1px solid var(--border); color: var(--muted);
  border-radius: 999px; padding: 4px 13px; font-size: 13px; cursor: pointer; transition: .15s;
}
.chip:hover { color: var(--accent-deep); border-color: var(--accent); background: var(--accent-soft); }

.summary {
  background: #fff; border: 1px solid var(--border); border-left: 4px solid var(--leaf);
  border-radius: 12px; padding: 13px 17px; margin-bottom: 16px; font-size: 14px; color: var(--muted);
  box-shadow: var(--shadow-sm);
}
.summary b { color: var(--text); }

.results { display: flex; flex-direction: column; gap: 18px; }
.book-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px; overflow: hidden;
  box-shadow: var(--shadow);
}
.book-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; background: linear-gradient(180deg, #f4fbf6, #ecf6ef); border-bottom: 1px solid var(--border);
}
.book-head h2 { margin: 0; font-size: 16px; font-weight: 700; color: var(--accent-deep); }
.book-head .cnt { color: var(--muted); font-size: 13px; }

.match {
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background .12s, box-shadow .12s;
}
.match:last-child { border-bottom: none; }
.match:hover { background: #f1f9f3; }
.match.active { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.match-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.crumb { font-size: 13px; color: var(--muted); }
.crumb .sep { margin: 0 6px; opacity: .5; }
.crumb b { color: var(--accent-deep); font-weight: 600; }
.page-badge {
  background: var(--badge); border: 1px solid var(--border); color: var(--accent-deep);
  border-radius: 6px; padding: 1px 9px; font-size: 12px; font-weight: 700; white-space: nowrap;
}
.hit-badge { font-size: 12px; color: var(--accent); white-space: nowrap; font-weight: 600; }
.go-hint { margin-left: auto; font-size: 12px; color: var(--muted); opacity: 0; transition: .12s; font-weight: 600; }
.match:hover .go-hint, .match.active .go-hint { opacity: 1; color: var(--accent); }

.snippets { display: flex; flex-direction: column; gap: 6px; }
.snip {
  font-size: 14px; color: #3a4d42; background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 9px; padding: 9px 12px; line-height: 1.7;
}
.snip mark { background: var(--mark); color: var(--mark-text); padding: 0 3px; border-radius: 3px; font-weight: 700; }

.empty { text-align: center; color: var(--muted); padding: 44px 0; font-size: 15px; }
.empty .big { font-size: 42px; display: block; margin-bottom: 8px; }

.footer { text-align: center; color: var(--muted); font-size: 12.5px; padding: 20px; border-top: 1px solid var(--border); }

/* 窄屏：上下堆叠 */
@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .preview { position: static; width: 100%; height: auto; flex: none; max-height: 70vh; }
  .search-row { flex-direction: column; }
  .search-btn { padding: 12px; }
}
