* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-color: #ffffff;
  --text-color: #1a1a1a;
  --sidebar-bg: #f8f9fa;
  --border-color: #dddddd;
  --accent-color: #3498db;
  --verse-num-color: #777777;
  --header-bg: #ffffff;
}

body.dark-mode {
  --bg-color: #121212;
  --text-color: #e0e0e0;
  --sidebar-bg: #1e1e1e;
  --border-color: rgba(255, 255, 255, 0.15);
  --accent-color: #5dade2;
  --verse-num-color: #aaaaaa;
  --header-bg: #121212;
}

/* Kill transitions during resize to stop ghosting/transparency */
body.resize-animation-stopper * {
  transition: none !important;
  animation: none !important;
}

/* --- THE GLOBALS --- */
html,
body {
  height: 100%;
  width: 100vh;
  height: -webkit-fill-available;
  margin: 0;
  padding-bottom: env(safe-area-inset-bottom);
  font-family: "Georgia", serif;
  overflow: hidden; /* This kills the main window scrollbars */
  background-color: var(--bg-color);
  color: var(--text-color);
}

/* Ensure only the reader and book list can scroll internally */
.reader-window,
#books-list {
  overflow-y: auto;
  overflow-x: hidden; /* Prevents accidental side-scrolling */
}

.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* --- SIDEBAR --- */
.sidebar {
  width: 260px;
  min-width: 260px;
  height: 100vh;
  background-color: var(--sidebar-bg) !important; /* Force solid color */
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 1500;
  position: fixed;
  left: 0;
  top: 0;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
}

.sidebar.open {
  transform: translateX(0);
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  background-color: var(--bg-color);
  transition:
    margin-left 0.3s ease,
    width 0.3s ease; /* Added width transition */
  width: 100%; /* Default width */
}
/* Desktop Push Logic: Shrink the width so it doesn't overflow the screen */
@media (min-width: 1025px) {
  body.sidebar-is-open .main-content {
    margin-left: 260px;
    width: calc(100% - 260px); /* This prevents the horizontal scrollbar */
  }
}
/* Desktop Push Logic */
@media (min-width: 1025px) {
  body.sidebar-is-open .main-content {
    margin-left: 260px;
  }
}

#view-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-color);
}

#chapter-label {
  /* Increased margin for breathing room */
  margin-left: 18px;
  /* Bumped size slightly larger than the title for hierarchy */
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-color) !important;
  display: inline-block;
  vertical-align: middle;
  /* Optional: a subtle border or underline to separate it visually */
  border-left: 2px solid var(--border-color);
  padding-left: 15px;
}

header {
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--header-bg);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 1000;
}
#menu-toggle {
  position: fixed;
  top: 5px;
  left: 10px;
  z-index: 2000;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-color);
  padding: 10px;
  transition: left 0.3s ease;
}

/* Move button on Desktop only */
@media (min-width: 1025px) {
  body.sidebar-is-open #menu-toggle {
    left: 270px;
  }
}

.sidebar-controls {
  padding: 60px 15px 15px 15px;
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-controls button {
  flex: 1;
  padding: 10px 5px;
  cursor: pointer;
  background-color: var(--bg-color);
  color: var(--text-color);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 0.75rem;
  white-space: nowrap;
}

#books-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

.book-btn {
  width: 100%;
  /* Increased padding for a larger touch/click target */
  padding: 16px 10px;
  margin-bottom: 6px;
  /* Perfectly centered text */
  text-align: center;
  cursor: pointer;
  background: transparent;
  color: var(--text-color);
  border-radius: 6px;
  border: none;
  /* Increased font size for better readability */
  font-size: 1.15rem;
  font-family: inherit;
  transition: all 0.2s ease;
}

.book-btn:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

body.dark-mode .book-btn:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

.book-btn.active {
  background-color: var(--border-color);
  color: var(--accent-color);
  font-weight: 700;
  /* Removing the side border keeps the text perfectly centered */
  border: none;
}

/* --- READER --- */
.reader-window {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
}

#reader-content {
  max-width: 800px;
  margin: 0 auto;
  line-height: 1.8;
  font-size: 1.25rem;
}

.chapter-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  /* Reduced from 4rem to 1.5rem to bring it closer to the top/previous chapter */
  margin: 1.5rem 0 1.5rem 0;
  text-transform: uppercase;
  font-size: 1.1rem;
  letter-spacing: 0.1rem;
  opacity: 0.8;
}

/* Also, ensure the first chapter of a book has NO top margin */
#reader-content .chapter-title:first-child {
  margin-top: 0.5rem;
}
#chapter-label {
  font-size: 1.1rem;
  font-weight: 400;
  opacity: 0.8;
  color: var(--accent-color);
}

/* Ensure chapter titles are detectable by the Intersection Observer */
.chapter-title {
  scroll-margin-top: 60px; /* Prevents title from being hidden under header when jumping */
}
.chapter-title::before,
.chapter-title::after {
  content: "";
  height: 1px;
  flex: 1;
  background-color: currentColor;
  opacity: 0.3;
}

.v-num {
  font-size: 0.75rem;
  vertical-align: super;
  margin-right: 12px;
  color: var(--verse-num-color);
  font-weight: 600;
}

body.hide-verses .v-num {
  display: none !important;
}
.verse-row {
  margin-bottom: 0.6rem;
}
/* Custom Scrollbar Styling (Optional) */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--sidebar-bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-color);
}

.reader-footer {
  background-color: var(--header-bg);
  border-top: 1px solid var(--border-color);
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  z-index: 100;
}

.chapter-nav {
  display: flex;
  justify-content: 间-between;
  gap: 10px;
}

.nav-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr 1.2fr; /* Outer buttons are slightly wider */
  gap: 8px;
  width: 100%;
}

.nav-btn {
  padding: 12px 5px;
  background-color: var(--bg-color);
  color: var(--text-color);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  transition: all 0.2s ease;
}

/* Subtle distinction for Book vs Chapter */
.outer-btn {
  background-color: var(--sidebar-bg);
  border-color: var(--accent-color);
  opacity: 0.9;
}

.nav-btn:hover {
  background-color: var(--accent-color);
  color: white;
  opacity: 1;
}

@media (max-width: 600px) {
  .nav-btn {
    font-size: 0.7rem; /* Keep them on one line on small phones */
    padding: 10px 2px;
  }
}
.bottom-menu {
  /* Force your buttons to stay above the 'danger zone' */
  bottom: env(safe-area-inset-bottom);
}
footer {
  padding-bottom: env(safe-area-inset-bottom, 20px);
}
/* Only apply hover effects on devices that actually have a mouse cursor */
@media (hover: hover) and (pointer: fine) {
  .nav-button:hover {
    background-color: #your-highlight-color;
    /* your existing hover styles */
  }
}

/* Use :active for the quick "tap" feedback on mobile instead */
.nav-button:active {
  background-color: #your-active-color;
  transition: background 0.1s;
}
