:root {
  --accent: #6E2A3A;
  --accent-light: #F1DDE1;
  --bg: #FFFFFF;
  --surface: #FFFFFF;
  --text-primary: #1A1A1A;
  --text-secondary: #6B6B6B;
  --divider: #E5E5E5;
  --number-bg: #F0F0F0;
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #C77E8F;
    --accent-light: #3A2530;
    --bg: #121212;
    --surface: #121212;
    --text-primary: #F0F0F0;
    --text-secondary: #A0A0A0;
    --divider: #2A2A2A;
    --number-bg: #2A2A2A;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  height: 100%;
}

button {
  font-family: inherit;
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
}

.hidden { display: none !important; }

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 12px 14px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--divider);
}

.book-switcher {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 18px;
  font-weight: 700;
  padding: 6px 8px;
  border-radius: 8px;
  max-width: calc(100% - 48px);
}

.book-switcher span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
}

.icon-btn:active, .book-switcher:active {
  background: var(--divider);
}

/* ---------- Book switcher dropdown ---------- */
.book-menu {
  position: absolute;
  top: 60px;
  left: 12px;
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  min-width: 220px;
  z-index: 20;
  overflow: hidden;
}

.book-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  width: 100%;
  text-align: left;
  font-size: 14px;
}

.book-menu-item:active { background: var(--divider); }

.book-menu-item .check {
  width: 18px;
  flex-shrink: 0;
  color: var(--accent);
}

/* ---------- Search ---------- */
.search-bar {
  padding: 10px 16px;
  border-bottom: 1px solid var(--divider);
}

#searchInput {
  width: 100%;
  padding: 10px 14px;
  border-radius: 24px;
  border: none;
  background: var(--accent-light);
  color: var(--text-primary);
  font-size: 15px;
}

#searchInput::placeholder { color: var(--text-secondary); }

.search-scope {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.scope-chip {
  padding: 6px 14px;
  border-radius: 16px;
  font-size: 13px;
  color: var(--text-secondary);
}

.scope-chip.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

/* ---------- Song list ---------- */
.song-list {
  padding: 8px 16px 96px;
}

.song-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
}

.song-number {
  flex-shrink: 0;
  min-width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--number-bg);
  color: var(--accent);
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
}

.song-info { min-width: 0; flex: 1; }

.song-title {
  font-size: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.song-snippet {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-state {
  text-align: center;
  color: var(--text-secondary);
  margin-top: 60px;
  font-size: 15px;
}

/* ---------- Sort FAB ---------- */
.fab {
  position: fixed;
  right: 20px;
  bottom: 24px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  cursor: pointer;
  z-index: 15;
  user-select: none;
}

/* ---------- Detail view ---------- */
.detail-view {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 30;
  display: flex;
  flex-direction: column;
}

.detail-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--divider);
  flex-shrink: 0;
}

.detail-number {
  flex-shrink: 0;
  background: var(--number-bg);
  color: var(--accent);
  font-weight: 700;
  font-size: 16px;
  padding: 4px 10px;
  border-radius: 8px;
}

.detail-titles { min-width: 0; flex: 1; }

#detailTitle {
  font-size: 17px;
  font-weight: 700;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-composer {
  font-size: 12px;
  font-style: italic;
  color: var(--text-secondary);
  margin: 2px 0 0;
}

.text-size-controls {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.text-size-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
}

.text-size-btn span {
  font-size: 10px;
  vertical-align: super;
}

.text-size-btn:active { background: var(--divider); }

.lyrics {
  flex: 1;
  overflow-y: auto;
  padding: 20px 20px 60px;
  line-height: 1.7;
}

/* Each verse/chorus is its own block with consistent spacing below it, so the gap before and
   after a chorus is always the same — not left to however <br/> tags happen to collapse. */
.lyrics .verse,
.lyrics .chorus {
  margin-bottom: 22px;
}

.lyrics .line {
  display: flex;
}

.lyrics .num {
  flex: 0 0 26px;
  font-weight: 700;
}

.lyrics .text {
  flex: 1;
}

.lyrics .chorus {
  font-style: italic;
  color: var(--text-secondary);
  padding-left: 26px;
  /* Extra breathing room on top of the usual verse-to-verse gap, so the chorus reads as its
     own distinct section arriving, not just another verse. */
  margin-top: 12px;
}

.lyrics {
  transition: opacity 0.14s ease;
}
