/* ============================================================
   Worship Setlist — dark, distraction-free, mobile-first.
   ============================================================ */

:root {
  --bg:        #0e0f13;
  --bg-raised: #171922;
  --bg-toolbar:#12141b;
  --border:    #262a36;
  --text:      #e8eaf0;
  --muted:     #8a90a2;
  --faint:     #5b6072;
  --accent:    #ffcf6b;   /* chords */
  --accent-2:  #7db8ff;   /* section labels */
  --primary:   #3d7cf0;

  --font-scale: 1.15;     /* adjusted live by the A−/A+ buttons */
  --lyric-size: calc(1rem * var(--font-scale));
  --line-gap:   0.55em;

  --toolbar-h: 52px;

  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

body {
  padding-top: var(--toolbar-h);
  min-height: 100vh;
}

button { font-family: inherit; }

/* ---------------- Toolbar ---------------- */
.toolbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg-toolbar) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: calc(env(safe-area-inset-top) * 0.5) 0 0;
}
.toolbar-row {
  height: var(--toolbar-h);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 max(10px, env(safe-area-inset-left)) 0 max(10px, env(safe-area-inset-right));
  max-width: 900px;
  margin: 0 auto;
  overflow-x: auto;
  scrollbar-width: none;
}
.toolbar-row::-webkit-scrollbar { display: none; }
.spacer { flex: 1 1 auto; }

.btn {
  appearance: none;
  background: var(--bg-raised);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 12px;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { border-color: #39405400; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.icon { padding: 8px 10px; min-width: 40px; text-align: center; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.seg-toggle { display: inline-flex; border-radius: 9px; overflow: hidden; border: 1px solid var(--border); }
.seg-btn { border: none; border-radius: 0; background: transparent; color: var(--muted); }
.seg-btn.is-active { background: var(--bg-raised); color: var(--text); }

.font-ctrl { display: inline-flex; gap: 4px; }

.btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #1a1400; }

.speed {
  -webkit-appearance: none;
  appearance: none;
  width: 96px;
  height: 4px;
  border-radius: 4px;
  background: var(--border);
  outline: none;
  flex: 0 0 auto;
}
.speed::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}
.speed::-moz-range-thumb {
  width: 18px; height: 18px; border: none; border-radius: 50%;
  background: var(--accent); cursor: pointer;
}

/* ---------------- Auto-scroll bar (sticky bottom) ---------------- */
.scrollbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg-toolbar) 94%, transparent);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.scrollbar-row {
  height: var(--toolbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
  max-width: 900px;
  margin: 0 auto;
}
.scroll-btn { flex: 0 0 auto; }
.scrollbar .speed { flex: 1 1 auto; width: auto; }
.speed-icon { flex: 0 0 auto; font-size: 1rem; line-height: 1; opacity: .8; }

/* ---------------- Stage (performance view) ---------------- */
.stage {
  max-width: 900px;
  margin: 0 auto;
  padding: 8px max(16px, env(safe-area-inset-left)) 40vh max(16px, env(safe-area-inset-right));
}

.song {
  padding: 22px 0 26px;
  border-top: 1px solid var(--border);
}
.song:first-child { border-top: none; }

.song-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 12px;
  margin-bottom: 14px;
}
.song-title {
  font-size: calc(1.35rem * var(--font-scale));
  font-weight: 700;
  margin: 0;
  letter-spacing: .2px;
}
.song-artist { color: var(--muted); font-size: 0.95rem; font-weight: 500; }
.song-keyinfo {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.song-keyinfo b { color: var(--accent); font-weight: 700; }

/* Per-song controls */
.song-ctrl {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
}
.song-ctrl .grp {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 2px;
}
.song-ctrl .mini {
  appearance: none;
  background: transparent;
  color: var(--text);
  border: none;
  border-radius: 7px;
  padding: 6px 9px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.song-ctrl .mini:hover { background: #ffffff10; }
.song-ctrl .mini.is-active { background: var(--accent); color: #1a1400; }
.song-ctrl .mini.wide { min-width: 108px; text-align: center; }
.song-ctrl .lbl { color: var(--faint); font-size: 0.75rem; padding: 0 4px 0 2px; }
.song-ctrl .mini[disabled] { opacity: .4; cursor: default; }

/* ---------------- Sections & lines ---------------- */
.section { margin: 0 0 18px; }
.section-label {
  display: inline-block;
  color: var(--accent-2);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  margin: 0 0 6px;
  opacity: .95;
}

.line {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  font-size: var(--lyric-size);
  line-height: 1.25;
  padding-bottom: var(--line-gap);
}
.line.chords-only { gap: 0 1.4ch; padding-bottom: calc(var(--line-gap) * 0.5); }
.line.gap { height: 0.7em; padding: 0; }

.seg { display: inline-flex; flex-direction: column; }
.seg .chord {
  color: var(--accent);
  font-weight: 700;
  font-size: 0.82em;
  line-height: 1.05;
  white-space: pre;
  padding-right: 0.6ch;
  min-height: 1.05em;
  font-variant-ligatures: none;
}
.seg .lyric { white-space: pre; }

/* Lyrics-only mode: drop the chord row and hide instrumental lines. */
body.mode-lyrics .seg .chord { display: none; }
body.mode-lyrics .line.chords-only { display: none; }
body.mode-lyrics .line { line-height: 1.5; }
body.mode-lyrics .song-ctrl { display: none; }

/* ---------------- Empty state ---------------- */
.empty {
  min-height: calc(100vh - var(--toolbar-h));
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
}
.empty-inner h1 { font-size: 1.8rem; margin: 0 0 10px; }
.empty-inner p { color: var(--muted); max-width: 34ch; margin: 0 auto; line-height: 1.6; }
.empty-inner code {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 0.9em;
  color: var(--text);
}

/* ---------------- Add-a-song page ---------------- */
.toolbar-title { color: var(--text); font-size: 0.95rem; font-weight: 700; }

.add {
  max-width: 900px;
  margin: 0 auto;
  padding: 16px max(16px, env(safe-area-inset-left)) 24vh max(16px, env(safe-area-inset-right));
}
.add-intro { color: var(--muted); line-height: 1.6; margin: 4px 0 20px; }
.add-intro code, .add-h code {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 0.9em;
  color: var(--text);
}
.add-h { font-size: 0.95rem; color: var(--muted); font-weight: 700; margin: 26px 0 10px; }

.fields { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; flex: 1 1 200px; }
.field.field-sm { flex: 1 1 90px; }
.field.field-full { flex-basis: 100%; }
.field > span { color: var(--faint); font-size: 0.78rem; font-weight: 600; letter-spacing: .3px; }
.field > span em { color: var(--faint); font-weight: 400; font-style: normal; opacity: .8; }

.field input, .field textarea, .output {
  width: 100%;
  background: var(--bg-raised);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 12px;
  font-size: 0.95rem;
  font-family: inherit;
}
.field textarea, .output {
  font-family: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre;
  overflow-wrap: normal;
  resize: vertical;
}
#sheet { min-height: 220px; }
.field input:focus, .field textarea:focus, .output:focus {
  outline: none;
  border-color: var(--primary);
}

.preview {
  border: 1px dashed var(--border);
  border-radius: 12px;
  min-height: 80px;
  padding: 4px 16px 12px;
}
.preview .song { border-top: none; padding-top: 12px; }
.preview-empty { color: var(--faint); text-align: center; padding: 24px 0; }

.output-wrap { display: flex; flex-direction: column; gap: 10px; }
.output-wrap .btn { align-self: flex-start; }
.output { min-height: 120px; }

@media (min-width: 600px) {
  :root { --toolbar-h: 56px; }
}
