:root {
  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #6b6b6b;
  --border: #e2e2e2;
  --accent: #b3261e;
  --hover: #f5f5f5;
  --input-bg: #f2f2f2;
  --chord: #1a56db;
  --song-font-scale: 1;
  --author-bg: #000000;
  --author-fg: #ffffff;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --fg: #eaeaea;
    --muted: #9b9b9b;
    --border: #2c2c2c;
    --accent: #ff6b5e;
    --hover: #1c1c1c;
    --input-bg: #1e1e1e;
    --chord: #6ea8fe;
    --author-bg: #9b9b9b;
    --author-fg: #000000;
  }
}

/* Explicit overrides from the day/night toggle (assets/theme.js), which
   always win over the OS-level prefers-color-scheme above. */
:root[data-theme="dark"] {
  --bg: #121212;
  --fg: #eaeaea;
  --muted: #9b9b9b;
  --border: #2c2c2c;
  --accent: #ff6b5e;
  --hover: #1c1c1c;
  --input-bg: #1e1e1e;
  --chord: #6ea8fe;
  --author-bg: #9b9b9b;
  --author-fg: #000000;
}
:root[data-theme="light"] {
  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #6b6b6b;
  --border: #e2e2e2;
  --accent: #b3261e;
  --hover: #f5f5f5;
  --input-bg: #f2f2f2;
  --chord: #1a56db;
  --author-bg: #000000;
  --author-fg: #ffffff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  line-height: 1.4;
}

a { color: inherit; text-decoration: none; }

.topbar {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}
.topbar h1 { margin: 0; font-size: 1.3rem; flex: 1; }
.topbar { display: flex; align-items: center; gap: 10px; }
.topbar h1 a { display: inline-flex; align-items: center; gap: 8px; }
.brand-icon { display: inline-flex; line-height: 1; }
.brand-icon svg { width: 1.3em; height: 1.3em; }

.theme-toggle,
.font-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--fg);
  border-radius: 8px;
  line-height: 1;
  cursor: pointer;
}
.theme-toggle:hover, .font-btn:hover { background: var(--hover); }

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
}

.search input[type="search"] {
  width: 100%;
  font-size: 1.05rem;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--fg);
}
.search input:focus { outline: 2px solid var(--accent); }

.song-list { list-style: none; margin: 12px 0 0; padding: 0; }
.song-list li { border-bottom: 1px solid var(--border); }
.song-list a {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 12px 6px;
}
.song-list a:hover, .song-list a:active { background: var(--hover); }
.song-id { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 2.5em; }
.song-title { flex: 1; font-weight: 600; }
.song-author { color: var(--muted); font-size: 0.9rem; }

.letters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}
.letters a {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 13px;
  min-width: 2.3em;
  text-align: center;
  font-size: 1.15rem;
  font-weight: 600;
}
.letters a.active { border-color: var(--accent); color: var(--accent); }

@media (max-width: 600px) {
  /* Fixed 5-column grid rather than flex-wrap, so the row count is
     deterministic instead of depending on how many letters happen to
     fit at the current width. */
  .letters {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
  }
  .letters a {
    padding: 10px 0;
    min-width: 0;
    font-size: 1.3rem;
  }
}

.hint { color: var(--muted); margin-top: 18px; }

.site-footer {
  max-width: 640px;
  margin: 32px auto 0;
  padding: 12px 16px 20px;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

.song-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 10px;
}
.back { margin: 0; }
.back a { color: var(--muted); }

.font-ctrl { display: flex; gap: 6px; flex: none; }
.font-btn { font-size: 0.95rem; font-weight: 700; }

.song-nav { display: flex; gap: 6px; flex: none; }
.song-nav .font-btn { font-size: 1.2rem; }
.song-nav .disabled { opacity: 0.35; pointer-events: none; }

.song-title-h { margin: 4px 0 0; font-size: 1.4rem; }
.song-title-h .song-id { font-size: 1rem; }
/* Full-width black bar with the artist/source in bold white, the way
   the original songbook prints it directly under the title. */
.song-author-p {
  background: var(--author-bg);
  color: var(--author-fg);
  font-weight: 700;
  font-style: normal;
  margin: 6px 0 20px;
  padding: 4px 10px;
}

.song-body {
  font-size: calc(1.05rem * var(--song-font-scale, 1));
}
.song-body .verse {
  margin: 0 0 22px;
  /* generous leading so the chord row above each line has room to sit
     close to *its own* line without crowding the line above it */
  line-height: 2.5;
}
.song-body .verse.chorus {
  /* the source book italicizes chorus lyrics only, not the chords
     above them - matches the print PDF's chorus styling */
  font-style: italic;
}
.song-body .verse.chorus .chord,
.song-body .verse.chorus .chord-tag {
  font-style: normal;
}
.song-body .comment {
  color: var(--muted);
  font-style: italic;
  font-size: 0.9rem;
  margin: 0 0 10px;
}

/* Chord-over-word: an inline-block per word keeps the chord glued to
   its word when the line wraps on a narrow screen. The chord is
   anchored to the *bottom* of its own space (bottom: 100%, i.e. right
   at the top edge of the word it belongs to) rather than floated from
   the top of a padded box - that way it always hugs the word below it,
   with the (larger) gap up to the previous line living above it. */
.cw {
  position: relative;
  display: inline-block;
  line-height: 1;
}
.cw .chord {
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: 0.1em;
  font-weight: 700;
  font-size: 0.8em;
  color: var(--chord);
  white-space: nowrap;
  line-height: 1;
}
.chord-tag {
  font-weight: 700;
  color: var(--chord);
  margin-right: 0.5em;
  display: inline-block;
}
/* Chord quality (7, sus4, maj7, ...) rendered smaller and dropped, the
   way the original songbook sets it against the root note. */
.cw .chord sub, .chord-tag sub {
  font-size: 0.7em;
  bottom: -0.3em;
}
