/* ===================== 公版英语原著阅读 · 精简样式 ===================== */
:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --text: #1f2933;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-soft: #e8f0fe;
  --border: #e5e7eb;
  --pd: #b45309;       /* 公版 主题色（琥珀/棕色，呼应"古典"） */
  --pd-soft: #fef3c7;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 20px; }
a { color: var(--primary); text-decoration: none; }

/* ---------- Header ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;   /* 标题栏锁定：滚动页面时始终固定在顶部 */
  top: 0;
  z-index: 30;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .06);
}
.site-header .wrap { padding-top: 18px; padding-bottom: 18px; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand-logo { font-size: 34px; }
.brand h1 { margin: 0; font-size: 22px; }
.tagline { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

/* ---------- 公版横幅 ---------- */
.public-domain-banner {
  background: var(--pd-soft);
  border-bottom: 1px solid #fde68a;
  color: #78350f;
  font-size: 14px;
}
.public-domain-banner .wrap { padding: 10px 20px; display: flex; align-items: center; gap: 10px; }
.pd-badge {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--pd); color: #fff; font-weight: 700; font-size: 12px;
  padding: 2px 8px; border-radius: 999px; white-space: nowrap; flex: none;
}
.pd-badge.small { font-size: 11px; padding: 1px 7px; }

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between;
  margin: 22px 0 0;
  position: sticky;                 /* 随标题栏一起锁定 */
  top: var(--sticky-h, 74px);       /* 高度由 JS 动态测量标题栏得到 */
  z-index: 29;
  background: var(--bg);
  padding-bottom: 10px;
}
.level-filter { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 6px 14px; border-radius: 999px; cursor: pointer; font-size: 13px; transition: .15s;
}
.chip:hover { border-color: var(--primary); }
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.search-box input {
  width: 240px; max-width: 60vw; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: 999px; font-size: 14px; outline: none;
}
.search-box input:focus { border-color: var(--primary); }

.book-count {
  color: var(--muted); font-size: 13px;
  margin: 0 0 14px;
  position: sticky;                 /* 跟在标题栏+等级栏下方一起锁定 */
  top: var(--sticky-h2, 116px);
  z-index: 28;
  background: var(--bg);
  padding: 0 0 8px;
}

/* ---------- Book grid ---------- */
/* ---------- 分页 ---------- */
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; margin: 26px 0 8px; }
.pager button {
  min-width: 36px; height: 36px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text);
  font-size: 14px; cursor: pointer; transition: all .15s;
}
.pager button:hover:not(:disabled):not(.active) { border-color: var(--primary); color: var(--primary); }
.pager button.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.pager button:disabled { opacity: .4; cursor: not-allowed; }
.pager .ellipsis { color: var(--muted); padding: 0 2px; user-select: none; }

.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
.book-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 16px; cursor: pointer; transition: .15s; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 8px; position: relative;
}
.book-card:hover { transform: translateY(-3px); border-color: var(--primary); }
.book-cover { font-size: 40px; line-height: 1; }
.book-title { font-weight: 600; font-size: 15px; margin: 0; }
.book-author { color: var(--muted); font-size: 13px; margin: 0; }
.book-foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; }
.book-level { font-size: 12px; color: var(--muted); }
.card-pd { position: absolute; top: 10px; right: 10px; }
.empty-hint { color: var(--muted); text-align: center; padding: 40px 0; }

/* ---------- Footer ---------- */
.site-footer { margin-top: 40px; background: var(--surface); border-top: 1px solid var(--border); }
.site-footer .wrap { padding: 18px 20px; color: var(--muted); font-size: 13px; }
.site-footer p { margin: 4px 0; }
.icp .placeholder { color: #9aa3ad; }

/* ---------- Reader ---------- */
.reader-page { background: var(--surface); }
.reader-header { border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 5; }
.reader-header-inner { display: flex; align-items: center; gap: 16px; padding: 12px 20px; }
.back-link { font-size: 14px; flex: none; }
.reader-title { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.book-cover-mini { font-size: 28px; }
.reader-title h1 { font-size: 18px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reader-meta { margin: 0; color: var(--muted); font-size: 12px; }
.reader-tools { display: flex; gap: 8px; flex: none; }
.tool-btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: 13px;
}
.tool-btn.active { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }

.reader-main { max-width: 760px; padding-top: 20px; padding-bottom: 90px; }

/* 底部翻页条 */
.reader-pager {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; align-items: center; justify-content: center; gap: 18px;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 10px 16px; box-shadow: 0 -2px 10px rgba(0,0,0,.05);
}
.reader-pager[hidden] { display: none; }
.pg-btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 7px 16px; border-radius: 8px; cursor: pointer; font-size: 14px; transition: .15s;
}
.pg-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.pg-btn:disabled { opacity: .4; cursor: default; }
.pg-info { font-size: 14px; color: var(--muted); min-width: 70px; text-align: center; }

/* 目录侧栏 */
.toc-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.35); z-index: 40; }
.toc-overlay[hidden] { display: none; }
.toc-panel {
  position: fixed; top: 0; left: 0; bottom: 0; width: 300px; max-width: 82vw; z-index: 41;
  background: var(--surface); box-shadow: 2px 0 24px rgba(0,0,0,.18);
  transform: translateX(-100%); transition: transform .22s ease; display: flex; flex-direction: column;
}
.toc-panel.open { transform: translateX(0); }
.toc-panel[hidden] { display: none; }
.toc-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--border); flex: none;
}
.toc-title { font-size: 16px; font-weight: 700; }
.toc-close { border: none; background: none; font-size: 24px; cursor: pointer; color: var(--muted); line-height: 1; }
.toc-list { list-style: none; margin: 0; padding: 8px 0; overflow-y: auto; flex: 1; }
.toc-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 18px; cursor: pointer; font-size: 14px; border-left: 3px solid transparent; transition: .12s;
}
.toc-item:hover { background: var(--primary-soft); border-left-color: var(--primary); }
.toc-name { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toc-page { color: var(--muted); font-size: 12px; flex: none; }
.toc-empty { padding: 16px 18px; color: var(--muted); font-size: 14px; }
.reader-hint { background: var(--pd-soft); color: #78350f; font-size: 13px; padding: 10px 14px; border-radius: 10px; margin-bottom: 18px; }
.reader-content { font-size: 18px; }
.para { margin: 0 0 18px; }
.para .en { font-family: Georgia, "Times New Roman", serif; line-height: 1.8; text-align: justify; white-space: pre-line; }
.para .en .word { cursor: pointer; border-bottom: 1px dotted #c4b5fd; }
.para .en .word:hover { background: var(--primary-soft); }
.para .zh { color: var(--muted); font-size: 15px; margin-top: 4px; white-space: pre-line; }
/* 译文/解析开关：hide-zh、hide-analysis 加在祖先 .reader-content 上 */
.reader-content.hide-zh .zh { display: none; }
.reader-content.hide-analysis .analysis { display: none; }

/* 解析块 */
.analysis { margin: 8px 0 0; padding: 10px 14px; background: #f8fafc; border-left: 3px solid var(--primary); border-radius: 6px; font-size: 14px; }
.analysis .a-item { margin: 4px 0; }
.analysis .a-term { font-weight: 600; color: #0f172a; }
.analysis .a-type { display: inline-block; font-size: 11px; padding: 0 6px; border-radius: 4px; margin-right: 6px; }
.analysis .a-type.vocab { background: #dbeafe; color: #1d4ed8; }
.analysis .a-type.sentence { background: #dcfce7; color: #15803d; }
.analysis .a-note { color: #334155; }

/* 章节标题 */
.chapter-title { margin: 30px 0 14px; font-size: 17px; color: var(--primary); border-bottom: 1px solid var(--border); padding-bottom: 6px; }

/* ---------- Dictionary modal ---------- */
.dict-modal { position: fixed; inset: 0; background: rgba(15,23,42,.35); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.dict-modal[hidden] { display: none; }
.dict-card {
  background: var(--surface); border-radius: 14px; box-shadow: 0 10px 40px rgba(0,0,0,.2);
  max-width: 420px; width: 100%; padding: 22px; position: relative; max-height: 80vh; overflow: auto;
}
.dict-close { position: absolute; top: 10px; right: 14px; border: none; background: none; font-size: 24px; cursor: pointer; color: var(--muted); line-height: 1; }
.dict-word { font-size: 22px; font-weight: 700; }
.dict-phon { color: var(--muted); margin: 2px 0 8px; }
.dict-pos { display: inline-block; background: var(--primary-soft); color: var(--primary); font-size: 12px; padding: 1px 8px; border-radius: 6px; margin-bottom: 8px; }
.dict-meaning { font-size: 16px; margin-bottom: 10px; white-space: pre-line; }
.dict-defs { font-size: 14px; margin-bottom: 10px; }
.dict-defs .def { display: block; margin: 6px 0; line-height: 1.6; }
.dict-defs .def .pos { font-weight: 700; margin-right: 6px; padding: 0 2px; border-radius: 4px; }
/* 不同词性不同颜色（加粗 + 彩色），便于一眼区分多词性 */
.dict-defs .def .pos.pos--n      { color: #1d4ed8; }
.dict-defs .def .pos.pos--v      { color: #15803d; }
.dict-defs .def .pos.pos--adj    { color: #c2410c; }
.dict-defs .def .pos.pos--adv    { color: #be123c; }
.dict-defs .def .pos.pos--prep   { color: #0e7490; }
.dict-defs .def .pos.pos--conj   { color: #4f46e5; }
.dict-defs .def .pos.pos--pron   { color: #92400e; }
.dict-defs .def .pos.pos--int    { color: #a21caf; }
.dict-defs .def .pos.pos--abbr   { color: #475569; }
.dict-defs .def .pos.pos--art    { color: #64748b; }
.dict-defs .def .pos.pos--det    { color: #64748b; }
.dict-defs .def .pos.pos--num    { color: #7c3aed; }
.dict-defs .def .pos.pos--phrase { color: #0d9488; }
.dict-defs .def .pos.pos--other  { color: var(--primary); }
.dict-examples { font-size: 13px; color: #475569; }
.dict-examples .ex { margin: 4px 0; }
.dict-source { margin-top: 12px; font-size: 11px; color: #9aa3ad; }

@media (max-width: 600px) {
  .reader-header-inner { flex-wrap: wrap; }
  .reader-tools { order: 3; width: 100%; }
  .reader-content { font-size: 17px; }
}
