/* 《圣经主题分析》中译工程 —— 护眼淡绿主题 */

* { box-sizing: border-box; }

:root {
  --bg: #eff7ef;            /* 页面底色：护眼淡绿（更浅） */
  --card: #f2f9f2;          /* 卡片底色：浅绿（不再泛白） */
  --card-border: #d9e9d9;
  --text: #2b3a2e;
  --text-en: #3d4f44;
  --accent: #2f7d46;
  --accent-soft: #e4f0e6;
  --grammar-bg: #e9f3e9;
  --grammar-border: #b5d6ba;
  --chip-bg: #dfeee1;
  --tooltip-bg: #26382c;
  --tooltip-text: #f2f8f2;
}

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Source Han Serif SC", "Songti SC", "Noto Serif CJK SC", Georgia, "Times New Roman", serif;
  line-height: 1.75;
  font-size: 17px;
}

/* ---------- 顶部工具栏 ---------- */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 18px;
  background: rgba(239, 247, 239, 0.95);
  backdrop-filter: blur(4px);
  border-bottom: 1px solid var(--card-border);
}

.toolbar .home-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
}
.toolbar .home-link:hover { text-decoration: underline; }

.toolbar .spacer { flex: 1; }

.btn {
  appearance: none;
  border: 1px solid var(--grammar-border);
  background: var(--card);
  color: var(--text);
  border-radius: 16px;
  padding: 4px 14px;
  font-size: 14px;
  line-height: 1.5;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}
.btn:hover { background: var(--accent-soft); }
.btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ---------- 页面主体 ---------- */
main {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 20px 80px;
}

h1 {
  font-size: 26px;
  line-height: 1.4;
  margin: 10px 0 6px;
  color: #1f4d2c;
}

.source-note {
  font-size: 13.5px;
  color: #5a6f5e;
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  padding: 10px 14px;
  margin: 14px 0 26px;
}
.source-note p { margin: 4px 0; }

/* ---------- 小节卡片 ---------- */
.section {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 18px 22px;
  margin: 22px 0;
  box-shadow: 0 1px 3px rgba(47, 93, 58, 0.06);
}

.section-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.section-head h2 {
  font-size: 19px;
  margin: 0;
  color: #245633;
  flex: 1;
  line-height: 1.5;
}

.en-toggle {
  flex-shrink: 0;
  font-size: 12.5px;
  border-radius: 12px;
  padding: 2px 10px;
}

/* ---------- 对照块 ---------- */
.block { margin: 14px 0; }
.block + .block { border-top: 1px dashed #e3efe4; padding-top: 12px; }

.en {
  color: var(--text-en);
  font-family: Georgia, "Times New Roman", serif;
  margin: 0 0 6px;
}
.en .lbl, .zh .lbl {
  display: inline-block;
  font-size: 11px;
  font-weight: bold;
  color: #fff;
  background: #8fb897;
  border-radius: 4px;
  padding: 0 5px;
  margin-right: 8px;
  vertical-align: 2px;
  letter-spacing: 0.5px;
}
.zh .lbl { background: var(--accent); }

.zh { margin: 0; }

/* 现代英译（BSB）对照行 */
.bsb {
  margin: 0 0 6px;
  padding-left: 6px;
  border-left: 3px solid #b7d8bd;
  color: #4c6353;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15.5px;
}
.bsb .lbl {
  display: inline-block;
  font-size: 11px;
  font-weight: bold;
  color: #fff;
  background: #6a9e74;
  border-radius: 4px;
  padding: 0 5px;
  margin-right: 8px;
  vertical-align: 2px;
  letter-spacing: 0.5px;
}
.bsb .ref { color: #6b806f; font-size: 13px; margin-right: 6px; }
.bsb b { color: #2f7d46; font-weight: bold; font-size: 12px; }

body.hide-bsb .bsb { display: none; }

/* 小节内英文隐藏（原文、现代英译、语法一并隐藏） */
.section.en-hidden .en,
.section.en-hidden .bsb,
.section.en-hidden .grammar { display: none; }

/* ---------- 可查词 ---------- */
.w {
  border-bottom: 1px dotted #7fae89;
  cursor: help;
}
.w:hover { background: #e7f4e9; }

/* 未标注词：无视觉标记，悬停走兜底词典 */
.w2:hover { background: #ebf5ec; }

/* ---------- 悬停词典 tooltip ---------- */
#dict-tip {
  position: fixed;
  z-index: 200;
  max-width: 320px;
  background: var(--tooltip-bg);
  color: var(--tooltip-text);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.6;
  box-shadow: 0 4px 16px rgba(20, 40, 26, 0.35);
  pointer-events: auto;   /* 允许移入弹窗点击朗读按钮 */
  display: none;
}
#dict-tip .tip-word { font-weight: bold; font-size: 16px; }
#dict-tip .tip-ipa { color: #a6d9b0; margin-left: 8px; font-family: Georgia, serif; }
#dict-tip .tip-def { margin-top: 2px; }
#dict-tip .tip-src {
  display: inline-block;
  font-size: 11px;
  color: #cfe8d4;
  border: 1px solid #55705d;
  border-radius: 8px;
  padding: 0 6px;
  margin-left: 8px;
  vertical-align: 2px;
}
#dict-tip .tip-link {
  display: inline-block;
  margin-top: 4px;
  font-size: 13px;
  color: #a6d9b0;
  text-decoration: none;
}
#dict-tip .tip-link:hover { text-decoration: underline; }

/* 朗读按钮（弹窗内 / 词汇表内） */
.tip-speak, .speak {
  appearance: none;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 15px;
  padding: 0 4px;
  margin-left: 6px;
  vertical-align: 1px;
  line-height: 1;
}
.tip-speak:hover, .speak:hover { transform: scale(1.2); }
.speak { font-size: 14px; }

/* ---------- 语法说明 ---------- */
.grammar { display: none; }
body.show-grammar .grammar {
  display: block;
  background: var(--grammar-bg);
  border: 1px solid var(--grammar-border);
  border-radius: 8px;
  padding: 8px 12px;
  margin: 6px 0 8px;
  font-size: 14px;
  color: #33503a;
}

.grammar .gtag {
  display: inline-block;
  font-size: 11px;
  font-weight: bold;
  color: #fff;
  background: #6a9e74;
  border-radius: 4px;
  padding: 0 5px;
  margin-right: 6px;
  letter-spacing: 0.5px;
}

.gitem { margin: 4px 0; }
.gitem .gtitle { font-weight: bold; color: #245633; }

/* 首次出现：完整讲解 */
.gfull .gbody { margin-top: 3px; }

/* 引用注解 chip */
.gchip {
  display: inline-block;
  background: var(--chip-bg);
  border: 1px solid var(--grammar-border);
  border-radius: 12px;
  padding: 1px 10px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}
.gchip:hover { background: #cbe6cf; }
.gchip .arrow { color: var(--accent); font-weight: bold; }

.gexpand {
  display: none;
  margin-top: 5px;
  padding: 6px 10px;
  border-left: 3px solid var(--grammar-border);
  background: #f4faf4;
  border-radius: 0 6px 6px 0;
}
.gitem.expanded .gexpand { display: block; }

/* ---------- 词汇表 ---------- */
table.vocab {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
  background: var(--card);
}
table.vocab th, table.vocab td {
  border: 1px solid var(--card-border);
  padding: 6px 10px;
  text-align: left;
  vertical-align: top;
}
table.vocab th { background: var(--accent-soft); color: #245633; }
table.vocab td.ipa { font-family: Georgia, serif; white-space: nowrap; color: #4a6b52; }

/* ---------- 目录页 ---------- */
#toc-search {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 18px 0 6px;
  padding: 10px 0;
  background: var(--bg);
}
#toc-search input[type="search"] {
  flex: 1 1 260px;
  min-width: 0;
  font: inherit;
  font-size: 16px;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 10px 14px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
#toc-search input[type="search"]::-webkit-search-cancel-button { display: none; }
#toc-search input[type="search"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
#toc-search input[type="search"]::placeholder { color: #8aa08f; }
#toc-clear {
  font: inherit;
  line-height: 1;
  color: #4a6b52;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 9px 12px;
  cursor: pointer;
}
#toc-clear:hover { background: var(--accent-soft); }
#toc-clear[hidden] { display: none; }
#toc-count { font-size: 13px; color: #6b806f; white-space: nowrap; }
#toc-empty { color: #6b806f; padding: 18px 4px; }
ul.toc { list-style: none; padding: 0; }
ul.toc li[hidden] { display: none; }
ul.toc li {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  margin: 8px 0;
  padding: 10px 16px;
}
ul.toc li a { color: #245633; text-decoration: none; font-size: 17px; }
ul.toc li a:hover { text-decoration: underline; }
ul.toc li .meta { font-size: 13px; color: #6b806f; margin-left: 8px; }

/* ---------- 本页侧边导航 ---------- */
html { scroll-behavior: smooth; }
.section { scroll-margin-top: 66px; }

#side-toc {
  display: none;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 10px 6px;
  font-size: 13.5px;
  line-height: 1.5;
}
#side-toc .toc-title {
  font-weight: bold;
  color: #245633;
  padding: 4px 10px 8px;
  border-bottom: 1px solid var(--card-border);
  margin-bottom: 6px;
}
#side-toc a {
  display: block;
  color: #47604d;
  text-decoration: none;
  padding: 4px 10px;
  border-radius: 8px;
  border-left: 3px solid transparent;
}
#side-toc a:hover { background: var(--accent-soft); }
#side-toc a.active {
  background: var(--accent-soft);
  border-left-color: var(--accent);
  color: #1f4d2c;
  font-weight: bold;
}

/* 宽屏：固定在左侧 */
@media (min-width: 1150px) {
  #side-toc {
    display: block;
    position: fixed;
    left: 14px;
    top: 64px;
    width: 216px;
    max-height: calc(100vh - 84px);
    overflow-y: auto;
    z-index: 40;
  }
  main { margin-left: 252px; }
  #btn-toc { display: none; }
}

/* 窄屏：按钮唤出抽屉 */
@media (max-width: 1149.9px) {
  body.toc-open #side-toc {
    display: block;
    position: fixed;
    left: 10px;
    top: 58px;
    width: min(78vw, 300px);
    max-height: calc(100vh - 76px);
    overflow-y: auto;
    z-index: 95;
    box-shadow: 0 8px 28px rgba(20, 40, 26, 0.25);
  }
}

@media (max-width: 600px) {
  body { font-size: 16px; }
  main { padding: 16px 12px 60px; }
  .section { padding: 14px 14px; }
}

/* ── 主题索引页（topics.html）─────────────────────────────── */
ul.toc.topics > li {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) auto;
  gap: 4px 14px;
  align-items: baseline;
}

.topic-en {
  font-family: Georgia, "Times New Roman", serif;
  color: var(--text-en);
}

.topic-zh { color: var(--text); }

.topic-pages {
  justify-self: end;
  white-space: nowrap;
  font-size: 0.88em;
}

.topic-pages a {
  display: inline-block;
  padding: 1px 7px;
  margin-left: 4px;
  border: 1px solid var(--card-border);
  border-radius: 999px;
  text-decoration: none;
  color: var(--accent);
  background: var(--accent-soft);
}

.topic-pages a:hover { text-decoration: underline; }

.topic-pages .nolink {
  display: inline-block;
  padding: 1px 7px;
  margin-left: 4px;
  color: #8a9a8e;
}

p.back { margin-top: 26px; }

@media (max-width: 700px) {
  ul.toc.topics > li {
    grid-template-columns: 1fr auto;
  }
  .topic-zh { grid-column: 1; }
  .topic-pages { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
}

/* ── 生词总表（vocab.html）───────────────────────────────── */
.lvl-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 18px;
}

.lvl-filter button {
  padding: 5px 13px;
  border: 1px solid var(--card-border);
  border-radius: 999px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 0.9em;
  cursor: pointer;
}

.lvl-filter button b { color: var(--accent); font-weight: 600; }

.lvl-filter button:hover { background: var(--accent-soft); }

.lvl-filter button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.lvl-filter button.active b { color: #fff; }

ul.vocab-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

ul.vocab-list > li {
  display: grid;
  grid-template-columns: minmax(140px, 200px) minmax(110px, 160px) 1fr;
  gap: 4px 14px;
  align-items: baseline;
  padding: 9px 12px;
  border-bottom: 1px solid var(--card-border);
}

ul.vocab-list > li:nth-child(odd) { background: var(--card); }

ul.vocab-list > li[hidden] { display: none; }

.v-word {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 600;
  color: var(--text-en);
  overflow-wrap: anywhere;
}

.v-ipa { color: #6d8574; font-size: 0.92em; }

.v-senses { color: var(--text); }

.v-def { margin-right: 8px; }

.v-src a {
  display: inline-block;
  padding: 0 6px;
  margin-left: 3px;
  border: 1px solid var(--card-border);
  border-radius: 999px;
  font-size: 0.82em;
  text-decoration: none;
  color: var(--accent);
  background: var(--accent-soft);
}

.v-src a:hover { text-decoration: underline; }

@media (max-width: 700px) {
  ul.vocab-list > li { grid-template-columns: 1fr auto; }
  .v-ipa { justify-self: end; }
  .v-senses { grid-column: 1 / -1; }
}

/* ── 语法点总览（grammar.html）───────────────────────────── */
.gram-list > section {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 16px;
}

.gram-list > section[hidden] { display: none; }

.gram-list h2 {
  margin: 0 0 6px;
  font-size: 1.08em;
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.g-count {
  margin-left: auto;
  font-size: 0.78em;
  font-weight: 400;
  color: var(--accent);
  white-space: nowrap;
}

.g-meta {
  margin: 0 0 10px;
  font-size: 0.86em;
  color: #6d8574;
}

.g-meta code {
  background: var(--accent-soft);
  padding: 1px 7px;
  border-radius: 4px;
  color: var(--accent);
}

.g-body { margin: 0 0 12px; }

.g-where {
  margin: 0;
  font-size: 0.86em;
  color: #6d8574;
  line-height: 2;
}

.g-where a {
  display: inline-block;
  padding: 1px 7px;
  margin-right: 4px;
  border: 1px solid var(--card-border);
  border-radius: 999px;
  text-decoration: none;
  color: var(--accent);
  background: var(--card);
}

.g-where a:hover { background: var(--accent-soft); }

/* 英文全部隐藏时，现代英译开关暂不起作用 —— 标灰提示 */
body.en-all-hidden #btn-bsb { opacity: 0.45; }
