/* ---------- Theme tokens ---------- */
:root {
  --accent: #c9a24b;
  --accent-soft: rgba(201, 162, 75, 0.15);
  --font-serif: Georgia, 'Iowan Old Style', 'Palatino Linotype', Palatino, serif;
  --font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

html[data-theme="dark"] {
  --bg: #14151a;
  --bg-elevated: #1c1e25;
  --bg-elevated-2: #24262f;
  --bg-hover: #2a2d38;
  --border: #2e313c;
  --text: #e7e5e0;
  --text-dim: #9a9ba3;
  --text-faint: #6b6c76;
  --wj-color: #ef8686;
  --highlight-bg: rgba(201, 162, 75, 0.22);
  --shadow: 0 8px 24px rgba(0,0,0,0.4);
}

html[data-theme="light"] {
  --bg: #f7f4ee;
  --bg-elevated: #ffffff;
  --bg-elevated-2: #f0ece2;
  --bg-hover: #ece7db;
  --border: #e2dcca;
  --text: #2b2a26;
  --text-dim: #6b6a63;
  --text-faint: #93928a;
  --wj-color: #a3271f;
  --highlight-bg: rgba(201, 162, 75, 0.35);
  --shadow: 0 8px 24px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hidden { display: none !important; }

/* ---------- App shell ---------- */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 64px;
  min-height: 64px;
  padding: 0 16px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  z-index: 20;
}

.menu-toggle { display: none; }

.brand {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  white-space: nowrap;
}
.brand-title {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.brand-sub {
  font-size: 11px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 1.2px;
}

.search-wrap {
  position: relative;
  flex: 1;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  color: var(--text-faint);
  pointer-events: none;
}
#searchInput {
  width: 100%;
  height: 38px;
  padding: 0 34px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elevated-2);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color .15s ease;
}
#searchInput:focus { border-color: var(--accent); }
.search-clear {
  position: absolute;
  right: 4px;
  display: none;
  width: 30px;
  height: 30px;
}
.search-clear svg { width: 14px; height: 14px; }
.search-wrap.has-text .search-clear { display: flex; }

.topbar-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.icon-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
}

#themeToggle .icon-moon { display: none; }
html[data-theme="dark"] #themeToggle .icon-sun { display: none; }
html[data-theme="dark"] #themeToggle .icon-moon { display: flex; }

/* ---------- Body layout ---------- */
.body-wrap {
  flex: 1;
  display: flex;
  min-height: 0;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 10px 8px 24px;
}
.sidebar-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-faint);
  padding: 14px 10px 6px;
}
.book-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.book-item { margin: 1px 0; }
.book-btn {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: var(--font-ui);
  font-size: 14px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.book-btn:hover { background: var(--bg-hover); color: var(--text); }
.book-btn.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.book-btn .chev {
  width: 14px; height: 14px;
  transition: transform .15s ease;
  color: var(--text-faint);
  flex-shrink: 0;
}
.book-item.open .book-btn .chev { transform: rotate(90deg); }

.chapter-grid {
  display: none;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 10px 12px 14px;
}
.book-item.open .chapter-grid { display: flex; }
.chapter-chip {
  min-width: 30px;
  height: 30px;
  padding: 0 6px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--bg-elevated-2);
  color: var(--text-dim);
  font-size: 12.5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chapter-chip:hover { background: var(--bg-hover); color: var(--text); }
.chapter-chip.active { background: var(--accent); border-color: var(--accent); color: #1a1408; font-weight: 700; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 15;
}

/* ---------- Reading pane ---------- */
.reading-pane {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 28px 20px 80px;
  display: flex;
  justify-content: center;
}

.reader-view, .search-view, .bookmarks-view {
  width: 100%;
  max-width: 760px;
}

.reader-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 22px;
}
.nav-btn {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.nav-btn:hover { color: var(--text); border-color: var(--accent); }
.nav-btn:disabled { opacity: 0.3; cursor: default; }
.nav-btn:disabled:hover { border-color: var(--border); }

.reader-title-wrap {
  display: flex;
  gap: 8px;
  align-items: center;
}
.chapter-select {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 700;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  text-align: center;
  border-radius: 8px;
  padding: 4px 6px;
}
.chapter-select:hover { background: var(--bg-hover); }
.chapter-select-num { width: 62px; }

.verses {
  font-family: var(--font-serif);
  font-size: 18px;
  line-height: 1.85;
  color: var(--text);
}

.verse {
  position: relative;
  padding: 3px 8px 3px 44px;
  margin: 0 -8px;
  border-radius: 8px;
  cursor: default;
}
.verse:hover { background: var(--bg-elevated); }
.verse.highlighted { background: var(--highlight-bg); }
.verse-num {
  position: absolute;
  left: 0;
  top: 6px;
  width: 34px;
  text-align: right;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  user-select: none;
}
.verse-text .wj { color: var(--wj-color); }

.verse-bookmark {
  display: none;
  position: absolute;
  right: 4px;
  top: 4px;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
}
.verse-bookmark svg { width: 15px; height: 15px; }
.verse:hover .verse-bookmark, .verse.bookmarked .verse-bookmark { display: flex; }
.verse.bookmarked .verse-bookmark { color: var(--accent); }
.verse.bookmarked .verse-bookmark svg { fill: currentColor; }
.verse-bookmark:hover { background: var(--bg-hover); }

.reader-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 36px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.footer-nav-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-family: var(--font-ui);
}
.footer-nav-btn:hover { color: var(--text); border-color: var(--accent); }
.footer-nav-btn:disabled { opacity: 0.3; cursor: default; }

/* ---------- Search / Bookmarks views ---------- */
.search-view-header { margin-bottom: 16px; }
.search-view-header h2 {
  font-family: var(--font-serif);
  font-size: 20px;
  margin: 0;
}
.search-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.result-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
}
.result-item:hover { border-color: var(--accent); }
.result-ref {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
}
.result-snippet {
  font-family: var(--font-serif);
  font-size: 15.5px;
  color: var(--text-dim);
  line-height: 1.5;
}
.result-snippet mark {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 0 2px;
  border-radius: 3px;
}
.empty-state {
  color: var(--text-faint);
  font-size: 14px;
  padding: 30px 6px;
  text-align: center;
}
.result-empty-icon { display:none; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .brand-sub { display: none; }
  .menu-toggle { display: flex; }
  .sidebar {
    position: fixed;
    top: 64px;
    bottom: 0;
    left: 0;
    z-index: 20;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar.open ~ .sidebar-overlay,
  .sidebar-overlay.show { display: block; }
  .reading-pane { padding: 20px 14px 70px; }
  .verses { font-size: 16.5px; }
}
