:root {
  --bg: #fbfaf7;
  --fg: #1f1d1a;
  --muted: #6b665e;
  --line: #e4e0d8;
  --accent: #a3262a;
  --chord: #1d5aa8;
  --card: #ffffff;
  --song-scale: 1;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171614;
    --fg: #ece8e1;
    --muted: #a39d93;
    --line: #34312c;
    --accent: #e0686b;
    --chord: #7fb2f0;
    --card: #211f1c;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
main { max-width: 860px; margin: 0 auto; padding: 16px; }
.top { border-bottom: 1px solid var(--line); padding: 10px 16px; font-size: 15px; }
.top nav { max-width: 860px; margin: 0 auto; }
.top span { color: var(--muted); padding: 0 4px; }
footer { max-width: 860px; margin: 40px auto 24px; padding: 0 16px; color: var(--muted); font-size: 14px; }
h1 { font-size: 1.9rem; line-height: 1.2; margin: 8px 0 4px; }
.facts, .copyright { color: var(--muted); margin: 0 0 6px; }
.copyright { font-size: 0.9rem; font-style: italic; }

.song-head { display: flex; gap: 16px; justify-content: space-between; align-items: flex-start; }
.qr { margin: 0; width: 108px; flex: none; text-align: center; }
.qr svg { width: 108px; height: 108px; background: #fff; border-radius: 6px; }
.qr figcaption { font-size: 11px; color: var(--muted); line-height: 1.3; }

/* Home and folder lists */
input[type=search] { width: 100%; padding: 10px 12px; font: inherit; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--fg); margin: 16px 0 8px; }
.folders { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.folders a { display: flex; flex-direction: column; padding: 16px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: var(--fg); }
.folders span { color: var(--muted); font-size: 14px; }
.song-list { padding-left: 1.6em; }
.song-list li { padding: 4px 0; }
.key-tag { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; margin-left: 4px; }

/* Song controls */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; padding: 10px 0; margin: 12px 0 8px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); z-index: 1; }
.toolbar .group { display: inline-flex; align-items: center; gap: 6px; }
.toolbar .label { color: var(--muted); font-size: 14px; }
.toolbar button { font: inherit; font-size: 15px; min-width: 36px; height: 34px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--fg); cursor: pointer; }
.toolbar button.link { border: none; background: none; color: var(--accent); min-width: 0; padding: 0 4px; }
.toolbar .key { min-width: 2.4em; text-align: center; color: var(--chord); font-size: 1.1rem; }
.toolbar label { font-size: 15px; cursor: pointer; }
.toolbar a { font-size: 15px; }

/* Song sheet: chords sit above the syllable they belong to */
.sheet { font-size: calc(1.1rem * var(--song-scale)); }
.notes { color: var(--muted); font-style: italic; margin-bottom: 8px; }
.notes p { margin: 0; }
.part h2 { font-size: 0.8em; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); margin: 1.2em 0 0.3em; }
.line { display: flex; flex-wrap: wrap; align-items: flex-end; min-height: 1.5em; }
.lyric-only { display: block; }
.seg { display: inline-flex; flex-direction: column; white-space: pre; }
.ch { color: var(--chord); font-weight: 650; font-size: 0.9em; min-height: 1.3em; padding-right: 0.35em; }
.ly { white-space: pre; }
.chord-only .seg { flex-direction: row; align-items: baseline; }
.chord-only .ly { color: var(--muted); }
.stanza-break { height: 0.8em; }
.no-chords .ch { display: none; }
.no-chords .chord-only { display: none; }

/* Print all songs: one song per page */
.print-song + .print-song { margin-top: 48px; padding-top: 32px; border-top: 1px solid var(--muted); }

@media (max-width: 560px) {
  .qr, .qr svg { width: 84px; }
  .qr svg { height: 84px; }
  h1 { font-size: 1.5rem; }
}

@media print {
  :root { --bg: #fff; --fg: #000; --chord: #000; --accent: #000; --muted: #444; }
  .top, footer, .toolbar, .noprint, input[type=search] { display: none; }
  main { max-width: none; padding: 0; }
  .sheet { font-size: 12pt; }
  .part { break-inside: avoid; }
  .print-song + .print-song { break-before: page; margin-top: 0; padding-top: 0; border-top: 0; }
}
