:root {
  --bg-top: #1e293b; --text-top: #ffffff;
  --bg-main: #f8fafc; --text-main: #1f2937;
  --bg-sidebar: #ffffff; --border-color: #e5e7eb;
  --bg-hover: #f1f5f9; --accent: #2563eb; --reader-bg: #ffffff;
  --verse-num: #1e3a8a; /* Dark grayish blue */
}
body.theme-dark {
  --bg-top: #0f172a; --text-top: #f8fafc;
  --bg-main: #020617; --text-main: #d1d5db;
  --bg-sidebar: #0f172a; --border-color: #1e293b;
  --bg-hover: #1e293b; --accent: #60a5fa; --reader-bg: #0f172a;
  --verse-num: #93c5fd;
}
body.theme-papiro {
  --bg-top: #4a3728; --text-top: #fdf5e6;
  --bg-main: #f5e6d3; --text-main: #3e2723;
  --bg-sidebar: #fdf5e6; --border-color: #d2b48c;
  --bg-hover: #faebd7; --accent: #8b4513; --reader-bg: #fdf5e6;
  --verse-num: #5c4033;
}

* { box-sizing: border-box; }
body { margin: 0; padding: 0; display: flex; flex-direction: column; height: 100vh; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg-main); color: var(--text-main); }

.top-bar { position: sticky; top: 0; background: var(--bg-top); color: var(--text-top); display: flex; align-items: center; justify-content: space-between; padding: 0.75rem 1.5rem; z-index: 1000; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1); height: 80px; }
.logo a { color: var(--text-top); text-decoration: none; font-weight: 800; font-size: 1.25rem; }

/* Contextual Title - Bolder and Larger */
.current-book-title { font-size: 2.5rem; font-weight: 900; text-align: center; flex: 1; margin: 0 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -0.025em; text-transform: uppercase; }

.controls { display: flex; gap: 0.5rem; align-items: center; justify-content: flex-end; flex: 1; }
.controls select, .controls button, .search-box input { padding: 0.4rem 0.6rem; border-radius: 6px; border: 1px solid rgba(255,255,255,0.2); background: rgba(255,255,255,0.1); color: var(--text-top); outline: none; font-size: 0.9rem; cursor: pointer; transition: background 0.2s; }
.controls select option { background: var(--bg-main); color: var(--text-main); }
.controls button:hover { background: rgba(255,255,255,0.2); }
.search-box { position: relative; margin-left: 0.5rem; }
.search-box input { background: white; color: black; border: 1px solid #ccc; width: 220px; }

.main-wrapper { display: flex; flex: 1; overflow: hidden; background: var(--bg-main); }

/* Anchor scroll padding ensures titles don't hide under the sticky top bar */
.reader-view { flex: 1; overflow-y: auto; padding: 3rem 12%; font-size: 1.15rem; background: var(--reader-bg); scroll-behavior: smooth; scroll-padding-top: 100px; }
@media (max-width: 768px) { .reader-view { padding: 1.5rem 5%; } }

.chapter-title { font-size: 2rem; margin-top: 3rem; margin-bottom: 1.5rem; border-bottom: 2px solid var(--border-color); padding-bottom: 0.75rem; color: var(--accent); font-weight: 700; }
.chapter-title:first-child { margin-top: 0; }

/* Verses */
.versiculo { margin-bottom: 0.8rem; line-height: 1.7; }
.verse-num { font-weight: 800; color: var(--verse-num); font-size: 1.05em; margin-right: 0.75rem; }
.verse-text { display: inline; }
.verse-text:hover { background-color: var(--bg-hover); border-radius: 4px; box-shadow: 0 0 0 4px var(--bg-hover); }

/* Sidebar Accordion */
.sidebar-derecha { width: 300px; display: flex; flex-direction: column; background: var(--bg-sidebar); border-left: 1px solid var(--border-color); }
.sidebar-accordion { border-bottom: 1px solid var(--border-color); }
.sidebar-accordion summary { padding: 1.25rem 1rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; cursor: pointer; background: var(--bg-hover); font-size: 0.95rem; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.sidebar-accordion summary::-webkit-details-marker { display: none; }
.sidebar-accordion summary::after { content: '\25BC'; font-size: 0.8rem; color: var(--text-main); transition: transform 0.2s; }
.sidebar-accordion[open] summary::after { transform: rotate(180deg); }

.book-list { display: flex; flex-direction: column; padding: 0.25rem 0; overflow-y: auto; max-height: calc(100vh - 80px - 140px); }
.footer { text-align: center; margin-top: 4rem; padding: 2rem 0; color: var(--verse-num); font-size: 0.95rem; border-top: 1px solid var(--border-color); font-weight: 500; }

.book-link { display: block; padding: 0.17rem 1.5rem; color: var(--text-main); text-decoration: none; font-weight: 500; font-size: 0.9rem; transition: background 0.1s; }
.book-link.active { font-weight: 800; color: var(--accent); border-left: 3px solid var(--accent); padding-left: calc(1.5rem - 3px); background: var(--bg-hover); }
.book-link:hover:not(.active) { background: var(--bg-hover); }

/* Search results */
.search-results { position: absolute; top: calc(100% + 5px); right: 0; width: 450px; max-height: 60vh; overflow-y: auto; background: var(--bg-main); color: var(--text-main); border: 1px solid var(--border-color); box-shadow: 0 10px 15px -3px rgba(0,0,0,0.3); border-radius: 8px; flex-direction: column; font-size: 0.95rem; text-align: left; }
@media (max-width: 900px) {
  .sidebar-derecha { display: none; }
  .current-book-title { display: none; }
  .top-bar { flex-wrap: wrap; height: auto; justify-content: center; }
  .search-results { width: 100vw; right: 0; position: fixed; top: auto; bottom: 0; max-height: 50vh; }
}
.search-results.hidden { display: none; }
.search-result-item { padding: 1rem; border-bottom: 1px solid var(--border-color); cursor: pointer; transition: background 0.2s; }
.search-result-item:hover { background: var(--bg-hover); }
.search-result-item b { color: var(--accent); display: block; margin-bottom: 0.25rem; font-size: 0.9em; }