/* ============ 圣经研读 BibleReader ============ */
:root {
  --paper: #faf6ec;
  --panel: #fffdf7;
  --panel-2: #f6f0e0;
  --ink: #33291d;
  --ink-2: #6d5f4b;
  --line: #e6dcc3;
  --accent: #b4832a;
  --accent-2: #8a641f;
  --olive: #6b7a3f;
  --wine: #7c3b3b;
  --shadow: 0 1px 3px rgba(80, 60, 20, .08), 0 6px 24px rgba(80, 60, 20, .07);
  --radius: 12px;
  --serif: "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --sans: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--sans); color: var(--ink);
  background: var(--paper);
  background-image: radial-gradient(rgba(180, 131, 42, .04) 1px, transparent 1px);
  background-size: 22px 22px;
}

:root { --study-w: 440px; }
#app {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 6px var(--study-w);
  grid-template-rows: 56px minmax(0, 1fr);
  grid-template-areas:
    "top top top top"
    "side reader grip study";
  height: 100vh;
}

/* ============ 拖动条 ============ */
.study-resize {
  grid-area: grip; cursor: col-resize; position: relative; z-index: 950; touch-action: none;
}
.study-resize::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 2px;
  transform: translateX(-50%); background: var(--line); transition: background .15s;
}
.study-resize:hover::after, .study-resize.dragging::after {
  background: var(--accent); box-shadow: 0 0 6px rgba(180, 131, 42, .45);
}

/* ============ 顶栏 ============ */
.topbar {
  grid-area: top; display: flex; align-items: center; gap: 14px; padding: 0 16px;
  background: linear-gradient(180deg, #fffdf7, #f8f2e2);
  border-bottom: 1px solid var(--line); z-index: 1200;
}
.brand { font-family: var(--serif); font-weight: 700; font-size: 18px; letter-spacing: 1px; white-space: nowrap; }
.brand-en { font-size: 12px; color: var(--ink-2); font-weight: 400; letter-spacing: 2px; }
.nav-controls { display: flex; gap: 8px; align-items: center; margin-left: auto; flex-wrap: nowrap; min-width: 0; overflow-x: auto; }
select {
  font: 14px/1 var(--sans); color: var(--ink); padding: 7px 10px; max-width: 160px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.btn {
  font: 14px/1 var(--sans); color: var(--ink); padding: 8px 14px; cursor: pointer; white-space: nowrap;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; transition: all .15s;
}
.btn:hover { border-color: var(--accent); color: var(--accent-2); }
.btn.primary {
  background: linear-gradient(180deg, #c8963a, #ab7c25); color: #fff; border: none; font-weight: 600;
}
.btn.primary:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.version-badge {
  font-family: var(--serif); font-size: 12px; color: var(--accent-2);
  border: 1px solid var(--accent); border-radius: 999px; padding: 4px 10px; white-space: nowrap;
}
.icon-btn {
  font-size: 17px; background: none; border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 10px; cursor: pointer; display: none;
}

/* ============ 侧栏 ============ */
.sidebar {
  grid-area: side; background: var(--panel); border-right: 1px solid var(--line);
  overflow-y: auto; z-index: 1100;
}
.sidebar-head { position: sticky; top: 0; padding: 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
.seg { display: flex; background: var(--panel-2); border-radius: 9px; padding: 3px; }
.seg-btn {
  flex: 1; border: none; background: none; padding: 7px 4px; font: 13px var(--sans); color: var(--ink-2);
  border-radius: 7px; cursor: pointer;
}
.seg-btn.active { background: #fff; color: var(--accent-2); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.book-list { list-style: none; margin: 0; padding: 8px; }
.book-list li {
  padding: 9px 12px; border-radius: 8px; cursor: pointer; display: flex; justify-content: space-between;
  font-size: 14.5px; transition: background .12s;
}
.book-list li:hover { background: var(--panel-2); }
.book-list li.active { background: #f3e8cd; color: var(--accent-2); font-weight: 600; }
.book-list li .cnt { color: var(--ink-2); font-size: 12px; }
.sidebar-mask { display: none; }

/* ============ 阅读区 ============ */
.reader { grid-area: reader; overflow-y: auto; scroll-behavior: smooth; }
.reader-scroll { max-width: 720px; margin: 0 auto; padding: 36px 40px 80px; }
.chapter-head h1 { font-family: var(--serif); font-size: 30px; margin: 0 0 6px; }
.chapter-meta { color: var(--ink-2); font-size: 13px; margin-bottom: 26px; }
.verses { font-family: var(--serif); font-size: 19px; line-height: 2.05; }
.verses .loading { font-family: var(--sans); color: var(--ink-2); padding: 40px 0; text-align: center; }
/* 逐节注释卡 */
.verse { position: relative; }
.vnote {
  position: absolute; left: 6px; right: 24px; top: calc(100% + 2px); z-index: 900;
  background: #fffdf6; border: 1px solid var(--accent); border-radius: 10px;
  box-shadow: 0 10px 28px rgba(60, 40, 10, .28);
  padding: 10px 12px; font-family: var(--sans); font-size: 13px; line-height: 1.75;
  text-align: left; max-height: 320px; overflow-y: auto; cursor: default;
}
.vnote.pinned { border-width: 2px; }
.vn-head {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px;
  font-weight: 700; color: var(--accent-2); font-size: 13px;
}
.vn-close { border: none; background: none; cursor: pointer; color: var(--ink-2); font-size: 16px; padding: 0 2px; line-height: 1; }
.vn-sec { margin-bottom: 9px; }
.vn-sec:last-child { margin-bottom: 0; }
.vn-sec-label { font-size: 11.5px; color: var(--accent-2); font-weight: 700; margin-bottom: 2px; }
.vn-range { font-size: 11px; color: var(--ink-2); font-weight: 400; margin-left: 4px; }
.vn-sec-text { color: var(--ink); white-space: pre-wrap; }
.vn-translating { color: #9a8b6f; font-size: 12px; font-style: italic; }
/* 对照模式：每节独立成组，译文另起一行 */
.verses.parallel .verse {
  display: block; margin-bottom: 16px; padding-bottom: 12px;
  border-bottom: 1px dashed var(--line);
}
.verses.parallel .verse:last-child { border-bottom: none; }
.verse .verse-alt {
  display: block; margin-top: 4px;
  font-size: 16px; line-height: 1.8; color: #8a7a5f;
}
.verse .verse-alt.en {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15.5px; line-height: 1.7; color: #6d5f4b;
}
.verse { margin: 0 0 .55em; transition: background .2s; border-radius: 6px; padding: 1px 6px; cursor: pointer; }
.verse:hover { background: rgba(180, 131, 42, .08); }
.verse.selected { background: rgba(180, 131, 42, .16); outline: 1px dashed var(--accent); }
.verse sup {
  color: var(--accent-2); font-family: var(--sans); font-size: 11px; font-weight: 700;
  margin-right: 5px; position: relative; top: -2px;
}
.pager { display: flex; justify-content: space-between; margin-top: 44px; gap: 12px; }

/* ============ 研经面板 ============ */
.study {
  grid-area: study; background: var(--panel); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0; z-index: 1000;
}
.tabs {
  display: flex; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, #fffdf7, #f8f2e2);
  overflow-x: auto; flex: none;
}
.tab {
  flex: 1; border: none; background: none; padding: 12px 6px; cursor: pointer; white-space: nowrap;
  font: 14px var(--sans); color: var(--ink-2); border-bottom: 2.5px solid transparent;
}
.tab.active { color: var(--accent-2); font-weight: 700; border-bottom-color: var(--accent); background: #fff; }
.pane { display: none; flex: 1; min-height: 0; }
.pane.active { display: flex; }
.pane-inner { flex: 1; min-height: 0; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.pane-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.field-label { font-size: 12.5px; color: var(--ink-2); }
.status-text { font-size: 12.5px; color: var(--ink-2); }
.hint { font-size: 12.5px; color: #9a8b6f; line-height: 1.6; margin: 0; }
.loading { color: var(--ink-2); padding: 24px 0; text-align: center; font-size: 14px; }

.chk { font-size: 13.5px; color: var(--ink); display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }

/* ---- 地图 ---- */
.map-pane { padding-bottom: 8px; }
.map-box { height: 46%; min-height: 300px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); box-shadow: var(--shadow); position: relative; }
.map-placeholder { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--ink-2); background: var(--panel-2); z-index: 500; font-size: 14px; }
#map { height: 100%; width: 100%; }
.place-marker {
  width: 16px; height: 16px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  background: linear-gradient(140deg, #d09b35, #8a641f); border: 2px solid #fff;
  box-shadow: 0 2px 5px rgba(0,0,0,.35);
}
.place-list { display: flex; flex-wrap: wrap; gap: 8px; }
.place-chip {
  border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 13px;
  font-size: 13px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; transition: all .12s;
}
.place-chip:hover { border-color: var(--accent); color: var(--accent-2); }
.place-chip .vref { color: var(--accent-2); font-size: 11px; }
.place-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }

/* ---- 图像 ---- */
.prompt-box {
  width: 100%; resize: vertical; border: 1px solid var(--line); border-radius: 9px; padding: 10px;
  font: 12.5px/1.6 var(--sans); color: var(--ink); background: #fff;
}
.gallery { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.gallery .img-card {
  position: relative; border-radius: 10px; overflow: hidden; border: 1px solid var(--line);
  aspect-ratio: 16/10; background: var(--panel-2); cursor: zoom-in;
}
.gallery .img-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery .img-card .img-cap {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 10px 7px; color: #fff; font-size: 11.5px;
  background: linear-gradient(transparent, rgba(0,0,0,.65));
}
.skeleton { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 8px; align-items: center; justify-content: center; color: var(--ink-2); font-size: 12px; }
.skeleton::before {
  content: ""; width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent); animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.img-error { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--wine); font-size: 12.5px; padding: 10px; text-align: center; }
.lightbox { border: none; border-radius: 12px; padding: 14px; max-width: min(92vw, 900px); background: #1d1810; }
.lightbox img { max-width: 100%; max-height: 74vh; border-radius: 8px; display: block; }
.lightbox::backdrop { background: rgba(20, 14, 5, .72); }
.lightbox button { margin-top: 10px; background: #fff; }

/* ---- 解释 ---- */
.commentary { display: flex; flex-direction: column; gap: 14px; font-size: 14.5px; line-height: 1.85; }
.commentary .c-head { display: flex; align-items: center; gap: 10px; }
.commentary h2 { font-family: var(--serif); font-size: 20px; margin: 0; }
.badge { font-size: 11px; border-radius: 999px; padding: 3px 9px; }
.badge.curated { background: #eef3e2; color: #55672c; border: 1px solid #cdd9a8; }
.badge.auto { background: var(--panel-2); color: var(--ink-2); border: 1px solid var(--line); }
.c-card { background: #fff; border: 1px solid var(--line); border-radius: 11px; padding: 14px 16px; box-shadow: var(--shadow); }
.c-card h3 {
  margin: 0 0 8px; font-size: 14px; color: var(--accent-2); letter-spacing: 1px;
  display: flex; align-items: center; gap: 8px;
}
.c-card h3 .range { font-size: 11.5px; color: var(--ink-2); font-weight: 400; }
.c-card p { margin: 0 0 8px; }
.c-card p:last-child { margin-bottom: 0; }
.c-outline { margin: 0; padding-left: 18px; }
.c-outline li { margin-bottom: 6px; }
.c-outline .r { color: var(--accent-2); font-weight: 600; margin-right: 6px; }
.key-verse {
  background: linear-gradient(120deg, #fdf6e3, #faf0d8); border: 1px solid #ecd9a8; border-radius: 11px;
  padding: 13px 16px; font-family: var(--serif);
}
.key-verse .kv-ref { color: var(--accent-2); font-weight: 700; font-size: 13px; font-family: var(--sans); display: block; margin-bottom: 4px; }
.c-qa { padding-left: 18px; margin: 0; }
.c-qa li { margin-bottom: 6px; }
/* 本章档案 */
.cs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
.cs-row { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; padding: 3px 0; border-bottom: 1px dotted var(--line); }
.cs-row b { color: var(--accent-2); }
/* 人物与场景 */
.pp-label { font-size: 12px; color: var(--ink-2); margin-bottom: 5px; }
.pp-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.pp-chips .place-chip { padding: 4px 10px; }
.pp-chips .vref { margin-left: 2px; }
/* 分段鸟瞰 */
.seg-list .seg-kw { font-size: 12px; color: var(--accent-2); margin-top: 2px; }
.seg-list li { margin-bottom: 10px; }
.seg-list .r { background: var(--panel-2); border-radius: 5px; padding: 1px 6px; margin-right: 6px; font-size: 12px; }
/* 信息图 */
.inf-wrap {
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  background: var(--paper); box-shadow: var(--shadow);
}
.inf-wrap img { display: block; width: 100%; height: auto; }

/* 全书串珠 */
.echo-list { display: flex; flex-wrap: wrap; gap: 6px; }
.echo-chip { font-size: 12.5px; }
/* 历代注释 */
.cs-para { font-size: 14px; line-height: 1.85; margin: 0 0 12px; color: var(--ink); }

/* ---- 视频 ---- */
.progress-area { display: flex; flex-direction: column; gap: 6px; }
.prog-step { font-size: 13px; color: var(--ink-2); display: flex; gap: 8px; align-items: center; }
.prog-step.done { color: #55672c; }
.prog-step.doing { color: var(--accent-2); font-weight: 600; }
.video-stage video { width: 100%; border-radius: 10px; border: 1px solid var(--line); background: #000; }
.video-stage .dl-row { display: flex; gap: 10px; margin-top: 10px; align-items: center; }

/* ---- 人物旅程 ---- */
.row-label { font-size: 12.5px; color: var(--accent-2); font-weight: 600; letter-spacing: .5px; }
.row-hint { color: #9a8b6f; font-weight: 400; }
.chips .chip .cnt {
  display: inline-block; margin-left: 5px; min-width: 16px; text-align: center;
  background: rgba(180,131,42,.15); color: var(--accent-2);
  border-radius: 999px; font-size: 10.5px; padding: 1px 5px;
}
.chips .chip.active .cnt { background: rgba(255,255,255,.25); color: #fff; }
.character-detail { display: flex; flex-direction: column; gap: 10px; }
.character-detail .cd-desc { margin: 0; font-size: 14px; line-height: 1.8; color: var(--ink); }
.character-detail .cd-chapterinfo {
  background: #f3e8cd; border-radius: 9px; padding: 8px 12px; font-size: 13px; color: var(--accent-2);
}
.character-detail .cd-summary { font-size: 13px; color: var(--ink-2); }
.cd-book { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.cd-book-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; font-size: 14px; }
.cd-book-head span { font-size: 12px; color: var(--ink-2); }
.cd-chs { display: flex; flex-wrap: wrap; gap: 5px; }
.cd-ch {
  border: 1px solid var(--line); background: var(--panel-2); border-radius: 6px;
  padding: 3px 8px; font: 12px var(--sans); cursor: pointer; color: var(--ink);
}
.cd-ch:hover { border-color: var(--accent); color: var(--accent-2); }
.journey-timeline { position: relative; display: flex; flex-direction: column; padding: 2px 0 2px 2px; }
.journey-timeline .stop {
  position: relative; display: flex; gap: 12px; padding: 10px 10px 10px 2px;
  cursor: pointer; border-radius: 10px; transition: background .12s;
}
.journey-timeline .stop:hover { background: var(--panel-2); }
.journey-timeline .stop.active { background: #f3e8cd; }
.journey-timeline .stop::before {
  content: ""; position: absolute; left: 17px; top: 0; bottom: 0; width: 2px; background: var(--line);
}
.journey-timeline .stop:first-child::before { top: 20px; }
.journey-timeline .stop:last-child::before { bottom: auto; height: 20px; }
.journey-timeline .stop-num {
  width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff;
  font: 700 13px var(--sans); display: flex; align-items: center; justify-content: center;
  flex: none; position: relative; z-index: 1; box-shadow: 0 0 0 3px var(--panel);
}
.journey-timeline .stop-body { min-width: 0; }
.journey-timeline .stop-meta { font-size: 11.5px; color: var(--accent-2); }
.journey-timeline .stop-title { font-family: var(--serif); font-size: 15.5px; font-weight: 700; margin: 1px 0 3px; }
.journey-timeline .stop-detail { font-size: 13px; color: var(--ink-2); line-height: 1.65; }
.journey-timeline .stop-ref { font-size: 11px; color: #9a8b6f; margin-top: 3px; }
.stop-marker {
  width: 24px; height: 24px; border-radius: 50%; background: #b4832a; color: #fff;
  font: 700 12px var(--sans); display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.4);
}

/* ---- 3D ---- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 14px;
  font-size: 13px; cursor: pointer; transition: all .12s;
}
.chip:hover { border-color: var(--accent); }
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.chip .rec { font-size: 10px; color: var(--wine); margin-left: 4px; }
.chip.active .rec { color: #ffe9c2; }
.three-mount {
  flex: 1; min-height: 340px; border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--line); box-shadow: var(--shadow); position: relative; background: linear-gradient(#20304a, #0e1626);
}
.three-mount .map-placeholder { color: #b9c4d8; background: transparent; }

/* ============ 提示气泡 ============ */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%); z-index: 3000;
  background: #33291d; color: #fff; border-radius: 10px; padding: 11px 20px; font-size: 13.5px;
  box-shadow: 0 8px 30px rgba(0,0,0,.25); max-width: 80vw;
}

/* ============ 滚动条 ============ */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #d9cba7; border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ============ 响应式 ============ */
@media (max-width: 1280px) {
  #app { grid-template-columns: 230px minmax(0, 1fr) 6px var(--study-w); }
}
@media (max-width: 1080px) {
  #app {
    grid-template-columns: minmax(0, 1fr) var(--study-w);
    grid-template-areas: "top top" "reader study";
  }
  .study-resize { display: none; }
  .sidebar {
    position: fixed; left: 0; top: 56px; bottom: 0; width: 270px; transform: translateX(-100%);
    transition: transform .22s; box-shadow: 4px 0 24px rgba(0,0,0,.15);
  }
  .sidebar.open { transform: none; }
  .sidebar-mask { display: none; position: fixed; inset: 56px 0 0 0; background: rgba(0,0,0,.3); z-index: 1050; }
  .sidebar-mask.show { display: block; }
  .icon-btn { display: inline-block; }
  .brand-en { display: none; }
}
@media (max-width: 840px) {
  #app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 112px minmax(0, 1fr) 52vh;
    grid-template-areas: "top" "reader" "study";
  }
  .study { border-left: none; border-top: 1px solid var(--line); }
  .reader-scroll { padding: 24px 18px 60px; }
  .nav-controls select { max-width: 110px; }
  .brand { font-size: 16px; }
  .topbar { flex-wrap: wrap; padding: 8px 12px; gap: 6px; }
  .topbar .brand { flex: 1; }
  .nav-controls { order: 1; flex: 0 0 100%; margin: 0; padding-bottom: 3px; }
  .nav-controls > * { flex-shrink: 0; }
  .sidebar { top: 112px; }
  .sidebar-mask { top: 112px; }
  .study, .reader, .pane { min-width: 0; }
}

/* Pre-generated chapter artwork */
.chapter-artwork img { display:block; width:100%; height:auto; border-radius:8px; cursor:zoom-in; }
.custom-image-controls { margin-top:24px; }
.custom-image-controls summary { cursor:pointer; margin-bottom:16px; }
[hidden] { display:none !important; }
