:root {
  --bg: #fafaf8;
  --fg: #1c1c1a;
  --muted: #7a7a74;
  --line: #e3e3de;
  --panel: #ffffff;
  --accent: #b5442a;
  --accent-soft: #f6e6e0;
  --hover: #f1f1ec;
  --sidebar-w: 300px;
  --song-fs: 18px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161615;
    --fg: #ececе7;
    --fg: #ecece7;
    --muted: #8f8f88;
    --line: #2b2b29;
    --panel: #1e1e1c;
    --accent: #e8825f;
    --accent-soft: #3a2620;
    --hover: #262624;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button {
  font: inherit;
  color: inherit;
  background: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
  line-height: 1.2;
}
button:hover { background: var(--hover); }
button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
input[type=search] {
  width: 100%;
  font: inherit;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  outline: none;
}
input[type=search]:focus { border-color: var(--accent); }

/* ---------- sidebar ---------- */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform .2s ease;
  z-index: 20;
}
body.sidebar-open .sidebar { transform: none; }
.sidebar-head { padding: 12px; border-bottom: 1px solid var(--line); }
.sort { display: flex; gap: 6px; margin-top: 8px; }
.sort button { flex: 1; font-size: 13px; padding: 5px 4px; }
.list { overflow-y: auto; flex: 1; padding: 6px 0 20px; }
.list .group { padding: 10px 14px 2px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.list a {
  display: block;
  padding: 7px 14px;
  color: inherit;
  text-decoration: none;
  border-left: 3px solid transparent;
}
.list a:hover { background: var(--hover); }
.list a.active { border-left-color: var(--accent); background: var(--accent-soft); }
.list a small { display: block; color: var(--muted); font-size: 12px; }
.list .none { padding: 20px 14px; color: var(--muted); }

.backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 15;
  display: none;
}

/* ---------- main ---------- */
.main { min-height: 100%; transition: padding-left .2s ease; }
.bar {
  position: sticky; top: 0;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  z-index: 10;
  flex-wrap: wrap;
}
.bar .icon { font-size: 18px; padding: 3px 9px; }
.modes { display: flex; }
.modes button { border-radius: 0; margin-left: -1px; }
.modes button:first-child { border-radius: 6px 0 0 6px; margin-left: 0; }
.modes button:last-child { border-radius: 0 6px 6px 0; }
.spacer { flex: 1; }
.transpose, .font { display: flex; align-items: center; gap: 4px; }
.transpose span { min-width: 2.2em; text-align: center; font-variant-numeric: tabular-nums; }
.transpose button, .font button { padding: 4px 9px; }

.song { padding: 18px 20px 80px; max-width: 900px; font-size: var(--song-fs); }
.empty { color: var(--muted); padding: 40px 0; text-align: center; }
.song h1 { margin: 0 0 2px; font-size: 1.5em; line-height: 1.2; }
.song .artist { color: var(--muted); margin: 0 0 6px; }
.song .meta { color: var(--muted); font-size: .8em; margin-bottom: 14px; }
.song .meta span + span::before { content: " · "; }

/* chord panels */
.chords { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0 20px; }
.chords:empty { display: none; }
.chord-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px 4px;
  background: var(--panel);
  text-align: center;
  font-size: 13px;
}
.chord-card .name { font-weight: 600; color: var(--accent); }
.chord-card .notes { color: var(--muted); font-size: 12px; margin-top: 2px; white-space: nowrap; }
.chord-card svg { display: block; margin: 4px auto 0; }
.chord-card.nodiagram .name { color: var(--muted); }

/* lyrics */
.body { line-height: 1.35; }
.section { margin: 0 0 1.2em; }
.section.chorus { border-left: 3px solid var(--accent); padding-left: 12px; }
.section .label { font-size: .75em; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: .3em; }
.line { white-space: pre-wrap; min-height: 1.35em; }
.seg { display: inline-block; vertical-align: bottom; white-space: pre; }
.seg .ch {
  display: block;
  color: var(--accent);
  font-weight: 600;
  font-size: .9em;
  line-height: 1.2;
  min-height: 1.2em;
  padding-right: .35em;
}
.seg .tx { display: block; }
.seg.nochord .ch { visibility: hidden; }
.comment { color: var(--muted); font-style: italic; }
body.mode-text .seg .ch { display: none; }
body.mode-text .seg { white-space: pre-wrap; display: inline; }
body.mode-text .seg .tx { display: inline; }
body.mode-text .line.chords-only { display: none; }
body.mode-text .chords { display: none; }

/* svg */
.dg-line { stroke: var(--fg); stroke-width: 1; }
.dg-nut { stroke: var(--fg); stroke-width: 3; }
.dg-dot { fill: var(--fg); }
.dg-barre { stroke: var(--fg); stroke-width: 7; stroke-linecap: round; }
.dg-mark { font-size: 9px; fill: var(--muted); }
.dg-fret { font-size: 9px; fill: var(--muted); }
.pk-white { fill: #fff; stroke: #555; stroke-width: .8; }
.pk-black { fill: #222; stroke: #222; }
.pk-white.on { fill: var(--accent); }
.pk-black.on { fill: var(--accent); stroke: var(--accent); }
.pk-white.root, .pk-black.root { fill: #7a2a17; stroke: #7a2a17; }

/* ---------- desktop ---------- */
@media (min-width: 900px) {
  body.sidebar-open .main { padding-left: var(--sidebar-w); }
  body.sidebar-open .backdrop { display: none !important; }
}
@media (max-width: 899px) {
  body.sidebar-open .backdrop { display: block; }
  .bar { gap: 6px; padding: 6px 8px; }
  .modes button { padding: 5px 8px; }
  .song { padding: 14px 12px 80px; }
}
