:root {
  --bg-color: #fdfbf7;
  --text-color: #2c2c2c;
  --sidebar-bg: #f5f4f1;
  --accent-color: #2a3b4c;
  --font-serif: "Noto Serif SC", "Source Han Serif SC", STSong, serif;
  --font-sans:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
body {
  margin: 0;
  display: flex;
  height: 100vh;
  background-color: var(--bg-color);
  color: var(--text-color);
  font-family: var(--font-serif);
  overflow: hidden;
}
body.show-refs {
  background-color: #f7f5ef;
}

.sidebar {
  width: 320px;
  background-color: var(--sidebar-bg);
  border-right: 1px solid #eaddd5;
  display: flex;
  flex-direction: column;
  font-family: var(--font-sans);
  transition: transform 0.3s ease;
  z-index: 100;
  flex-shrink: 0;
}
.sidebar-header {
  padding: 20px;
  font-weight: 600;
  color: var(--accent-color);
  letter-spacing: 1px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.close-btn {
  display: none;
  cursor: pointer;
}

.help-btn-desktop {
  background: rgba(42, 59, 76, 0.1);
  border: none;
  color: var(--accent-color);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: all 0.2s;
}
.help-btn-desktop:hover {
  background: var(--accent-color);
  color: #fff;
}

.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid #eaddd5;
  flex-shrink: 0;
}
.tab-btn {
  flex: 1;
  padding: 12px 0;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-size: 13px;
  color: #777;
}
.tab-btn.active {
  color: var(--accent-color);
  border-bottom: 2px solid var(--accent-color);
  font-weight: bold;
}
.tab-content {
  display: none;
  flex: 1;
  overflow-y: auto;
  position: relative;
}
.tab-content.active {
  display: flex;
  flex-direction: column;
}

.book-item,
.bm-item,
.search-item {
  padding: 12px 20px;
  border-bottom: 1px solid #eaddd5;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 14px;
}
.book-item:hover,
.bm-item:hover,
.search-item:hover {
  background: #f2efe9;
}
.book-item.active {
  background: rgba(42, 59, 76, 0.1);
  color: var(--accent-color);
  font-weight: bold;
}

.search-container {
  padding: 16px 20px 10px;
  background: var(--sidebar-bg);
  z-index: 10;
  flex-shrink: 0;
}
#searchInput {
  width: 100%;
  padding: 10px 16px;
  background-color: #fff;
  border: 1px solid #eaddd5;
  border-radius: 20px;
  font-size: 14px;
  font-family: var(--font-sans);
  color: var(--text-color);
  outline: none;
  box-sizing: border-box;
  transition: all 0.2s ease;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.03);
}
#searchInput::placeholder {
  color: #aaa;
}
#searchInput:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(42, 59, 76, 0.1);
}

.search-filter-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}
.sfb-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.scope-drop .cd-header {
  padding: 4px 10px;
  font-size: 12px;
  background: transparent;
  border-color: #d4cfc6;
  color: #666;
  border-radius: 12px;
}
.scope-drop .cd-header:hover {
  background: #eaddd5;
  color: var(--accent-color);
}

.scope-drop .cd-list {
  bottom: auto;
  top: calc(100% + 6px);
  background: #fff;
  border: 1px solid #eaddd5;
  left: 0;
  transform: none;
  min-width: 130px;
  z-index: 1000;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}
@keyframes dropDownAnim {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.scope-drop .cd-list.open {
  display: flex;
  animation: dropDownAnim 0.2s ease-out forwards;
}
.scope-drop .cd-item {
  color: #555;
  text-align: left;
  padding: 6px 12px;
}
.scope-drop .cd-item:hover {
  background: #f5f4f1;
  color: var(--accent-color);
}
.scope-drop .cd-item.active {
  background: var(--accent-color);
  color: #fff;
}

.current-book-filter {
  font-size: 12px;
  color: #666;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  user-select: none;
}
.current-book-filter input {
  margin: 0;
  accent-color: var(--accent-color);
  cursor: pointer;
}

.search-stats {
  font-size: 12px;
  color: #888;
  background: rgba(0, 0, 0, 0.03);
  padding: 4px 8px;
  border-radius: 4px;
  line-height: 1.4;
  display: none;
}
.search-stats.show {
  display: block;
  animation: fadeUp 0.3s ease;
}

.sr-header,
.bm-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.sr-ref,
.bm-ref {
  color: var(--accent-color);
  font-weight: bold;
  font-size: 12px;
}
.sr-add-btn {
  background: #e0e0e0;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
}
.sr-add-btn.added {
  background: #4caf50;
  color: #fff;
}
.sr-highlight {
  color: #d32f2f;
  font-weight: bold;
  background: rgba(211, 47, 47, 0.1);
}
.bm-delete-btn {
  background: transparent;
  border: none;
  color: #aaa;
  cursor: pointer;
  padding: 4px 8px;
}
.bm-delete-btn:hover {
  color: #d32f2f;
}
.bm-text {
  color: #666;
  font-size: 13px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.smart-card {
  background: rgba(42, 59, 76, 0.04);
  border-left: 3px solid var(--accent-color);
  padding-left: 17px;
}
.smart-card:hover {
  background: rgba(42, 59, 76, 0.08);
}
.sc-desc {
  font-size: 12px;
  color: #777;
  margin-top: 6px;
}

.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 60px 20px 150px;
  position: relative;
  scroll-behavior: smooth;
}
.reader-container {
  max-width: 680px;
  margin: 0 auto;
}
.mobile-topbar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 50px;
  background: rgba(253, 251, 247, 0.9);
  backdrop-filter: blur(5px);
  z-index: 50;
  padding: 0 15px;
  align-items: center;
  border-bottom: 1px solid #eaddd5;
}
.topbar-title {
  flex: 1;
  text-align: center;
  font-weight: bold;
  color: var(--accent-color);
  letter-spacing: 2px;
}
.tool-btn {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--accent-color);
  cursor: pointer;
  padding: 5px;
  margin-left: 10px;
}
.book-title {
  font-size: 32px;
  font-weight: 600;
  text-align: center;
  margin: 40px 0;
  color: var(--accent-color);
  letter-spacing: 4px;
}

.verse-p {
  font-size: 19px;
  line-height: 1.8;
  margin-bottom: 12px;
  text-align: justify;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
}
.verse-p:hover {
  background: #f2efe9;
}
.verse-p.selected {
  background: #fef08a !important;
  color: #000;
}
.verse-p.bookmarked::before {
  content: "🔖";
  position: absolute;
  left: -22px;
  font-size: 14px;
  opacity: 0.6;
}
.verse-p:first-of-type::first-letter {
  font-size: 3.2em;
  float: left;
  line-height: 1;
  margin: 0.05em 0.1em 0 0;
  color: var(--accent-color);
}
.ref-num {
  display: none;
  font-family: var(--font-sans);
  font-size: 12px;
  color: #888;
  vertical-align: super;
  margin-right: 6px;
  user-select: none;
}
body.show-refs .ref-num {
  display: inline;
}

/* ================= 新增：串珠按钮与抽屉 ================= */
.tsk-link-btn {
  display: inline-block;
  font-size: 14px;
  margin-left: 8px;
  color: #ccc;
  cursor: pointer;
  opacity: 0;
  transition: all 0.2s;
  vertical-align: middle;
}
.verse-p:hover .tsk-link-btn {
  opacity: 1;
}
.tsk-link-btn:hover {
  color: var(--accent-color);
  font-weight: bold;
}

.tsk-drawer {
  position: fixed;
  right: -350px;
  top: 0;
  bottom: 0;
  width: 320px;
  background: #fff;
  box-shadow: -5px 0 20px rgba(0, 0, 0, 0.08);
  z-index: 1500;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  font-family: var(--font-sans);
}
.tsk-drawer.open {
  right: 0;
}
.tsk-header {
  padding: 20px;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: bold;
  color: var(--accent-color);
  background: #fafafa;
}
.tsk-close {
  cursor: pointer;
  color: #ccc;
  font-size: 20px;
  transition: color 0.2s;
}
.tsk-close:hover {
  color: #888;
}
.tsk-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}
.tsk-loading {
  text-align: center;
  color: #999;
  margin-top: 40px;
  font-size: 13px;
}
.tsk-item {
  padding: 12px;
  border-bottom: 1px solid #f9f9f9;
  cursor: pointer;
  transition: background 0.2s;
}
.tsk-item:hover {
  background: #f5f4f1;
}
.tsk-item-ref {
  color: var(--accent-color);
  font-weight: bold;
  font-size: 12px;
  margin-bottom: 4px;
}
.tsk-item-text {
  font-size: 14px;
  color: #666;
  line-height: 1.6;
  font-family: var(--font-serif);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  backdrop-filter: blur(2px);
}
.modal-overlay.show {
  display: flex;
}
.modal-card {
  background: #fff;
  width: 90%;
  max-width: 450px;
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  font-family: var(--font-sans);
  overflow: hidden;
}
.modal-header {
  padding: 15px 20px;
  border-bottom: 1px solid #eee;
  font-weight: bold;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--accent-color);
}
.modal-close {
  cursor: pointer;
  color: #aaa;
}
.modal-body {
  padding: 20px;
  max-height: 70vh;
  overflow-y: auto;
}
.modal-body h3 {
  font-size: 16px;
  margin: 15px 0 8px;
  color: #333;
}
.modal-body p {
  font-size: 14px;
  line-height: 1.6;
  color: #666;
  margin: 0 0 10px;
}

.action-bar {
  position: fixed;
  bottom: -150px;
  left: 50%;
  transform: translateX(-50%);
  background: #222;
  color: #fff;
  padding: 10px 18px;
  border-radius: 40px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  gap: 12px;
  transition: bottom 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
  z-index: 1000;
  font-family: var(--font-sans);
  white-space: nowrap;
  width: max-content;
  max-width: 95vw;
}
.action-bar.show {
  bottom: 30px;
}
.ab-info {
  font-size: 14px;
  font-weight: bold;
  margin-right: 4px;
  color: #ddd;
}

.ab-btn-text {
  background: transparent;
  border: 1px solid #555;
  color: #eee;
  padding: 6px 14px;
  border-radius: 18px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}
.ab-btn-text:hover {
  background: #444;
  border-color: #777;
  color: #fff;
}
.ab-btn-text.active {
  background: #4caf50;
  border-color: #4caf50;
  color: #fff;
}

.custom-dropdown {
  position: relative;
  user-select: none;
}
.cd-header {
  background: #333;
  padding: 7px 14px;
  border-radius: 18px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid #444;
  color: #eee;
}
.cd-header:hover {
  background: #444;
  border-color: #555;
}
.cd-list {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  background: #2c2c2c;
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  display: none;
  flex-direction: column;
  gap: 4px;
  border: 1px solid #444;
  min-width: 110px;
}
.cd-list.open {
  display: flex;
  animation: fadeUp 0.2s ease-out;
}
.cd-item {
  padding: 8px 12px;
  font-size: 13px;
  border-radius: 8px;
  cursor: pointer;
  text-align: center;
  color: #ccc;
  transition: all 0.2s;
}
.cd-item:hover {
  background: #444;
  color: #fff;
}
.cd-item.active {
  background: #555;
  color: #fff;
  font-weight: bold;
}

.split-btn {
  display: flex;
  align-items: center;
  background: var(--accent-color);
  border-radius: 20px;
  position: relative;
  box-shadow: 0 4px 10px rgba(42, 59, 76, 0.4);
}
.sb-main {
  background: transparent;
  color: #fff;
  border: none;
  padding: 8px 14px 8px 18px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  border-radius: 20px 0 0 20px;
  transition: background 0.2s;
}
.sb-main:hover {
  background: rgba(255, 255, 255, 0.1);
}
.sb-arrow {
  background: transparent;
  color: #fff;
  border: none;
  border-left: 1px solid rgba(255, 255, 255, 0.2);
  padding: 8px 12px;
  cursor: pointer;
  border-radius: 0 20px 20px 0;
  transition: background 0.2s;
}
.sb-arrow:hover {
  background: rgba(255, 255, 255, 0.1);
}
.sb-menu {
  position: absolute;
  bottom: calc(100% + 10px);
  right: 0;
  background: #2c2c2c;
  border: 1px solid #444;
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  display: none;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
}
.sb-menu.show {
  display: flex;
  animation: fadeUp 0.2s ease-out;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translate(-50%, 10px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

.ab-btn-close {
  background: transparent;
  border: none;
  color: #888;
  font-size: 20px;
  cursor: pointer;
  padding: 0 5px;
  transition: color 0.2s;
  line-height: 1;
}
.ab-btn-close:hover {
  color: #fff;
}

@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .close-btn {
    display: block;
  }
  .mobile-topbar {
    display: flex;
  }
  .main-content {
    padding-top: 60px;
    padding-bottom: 200px;
  }
  /* 移动端 TSK 抽屉适配 */
  .tsk-drawer {
    width: 100%;
    right: -100%;
  }
  .action-bar {
    flex-wrap: wrap;
    justify-content: center;
    border-radius: 20px;
    padding: 15px;
    bottom: -250px;
  }
  .action-bar.show {
    bottom: 20px;
  }
  .ab-info {
    width: 100%;
    text-align: center;
    margin-bottom: 5px;
    margin-right: 0;
  }
}

/* ================= 高亮与笔记系统样式 ================= */

.verse-p.highlighted {
  background-color: rgba(167, 219, 169, 0.25) !important;
}
.verse-p.highlighted:hover {
  background-color: rgba(167, 219, 169, 0.4) !important;
}

.note-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  background-color: #aaa;
  border-radius: 50%;
  margin-left: 8px;
  vertical-align: middle;
  cursor: pointer;
  transition: all 0.2s;
  opacity: 0.6;
}
.note-dot:hover {
  background-color: var(--accent-color);
  transform: scale(1.5);
  opacity: 1;
}

.note-card {
  padding: 16px 20px;
  border-bottom: 1px solid #eaddd5;
  cursor: pointer;
}
.note-card:hover {
  background: #f2efe9;
}
.nc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.nc-ref {
  font-weight: bold;
  color: var(--accent-color);
  font-size: 13px;
}
.nc-content {
  font-size: 14px;
  color: #444;
  line-height: 1.6;
  text-align: justify;
  word-break: break-all;
}
.nc-actions {
  margin-top: 10px;
  text-align: right;
  display: none;
}
.note-card:hover .nc-actions {
  display: block;
}
.nc-btn-del {
  background: none;
  border: none;
  color: #d32f2f;
  font-size: 12px;
  cursor: pointer;
}

.note-editor-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 3000;
  display: none;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(2px);
}
.note-editor-overlay.show {
  display: flex;
  animation: fadeInBg 0.2s;
}
.note-editor-panel {
  width: 100%;
  max-width: 680px;
  background: #fff;
  border-radius: 20px 20px 0 0;
  padding: 20px;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.2);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}
.note-editor-overlay.show .note-editor-panel {
  transform: translateY(0);
}
.ne-header {
  font-weight: bold;
  color: var(--accent-color);
  margin-bottom: 15px;
  font-size: 15px;
}
.ne-input {
  width: 100%;
  height: 150px;
  border: 1px solid #eaddd5;
  border-radius: 12px;
  padding: 15px;
  font-family: var(--font-serif);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-color);
  resize: none;
  outline: none;
  box-sizing: border-box;
  background: #fdfbf7;
}
.ne-input:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(42, 59, 76, 0.1);
}
.ne-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 15px;
}
.ne-btn {
  padding: 8px 20px;
  border-radius: 20px;
  border: none;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
}
.ne-btn.cancel {
  background: #eee;
  color: #666;
}
.ne-btn.save {
  background: var(--accent-color);
  color: #fff;
}

@keyframes fadeInBg {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ================= 本地数据备份面板（嵌入笔记底部） ================= */
.backup-mini-panel {
  position: sticky;
  bottom: 0;
  padding: 15px 20px;
  border-top: 1px solid #eaddd5;
  background: var(--sidebar-bg);
  margin-top: auto;
  flex-shrink: 0;
  z-index: 10;
}
.backup-mini-panel p {
  font-size: 12px;
  color: #888;
  margin: 0 0 10px 0;
  line-height: 1.4;
  text-align: center;
}
.backup-actions {
  display: flex;
  gap: 10px;
}
.backup-btn {
  flex: 1;
  padding: 8px 0;
  border: 1px solid var(--accent-color);
  background: transparent;
  color: var(--accent-color);
  border-radius: 6px;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}
.backup-btn:hover {
  background: var(--accent-color);
  color: #fff;
}
/* ================= 目标经文跳转高亮渐隐 ================= */
@keyframes targetFade {
  0% {
    background-color: #fef08a;
  }
  40% {
    background-color: #fef08a;
  } /* 前一半时间保持高亮 */
  100% {
    background-color: transparent;
  } /* 后一半时间缓慢淡出 */
}

.target-highlight {
  animation: targetFade 4s ease-out forwards !important;
}
