:root {
  --bg: #14171c;
  --card: #1d2229;
  --card-2: #262c35;
  --line: #333b47;
  --text: #eef1f5;
  --muted: #94a0b0;
  --accent: #f5b942;
  --accent-ink: #1a1405;
  --loop: #3d7bd9;
  --solo: #f5d442;
  --mute: #e0605a;
  --radius: 12px;
}
/* touch-action: no double-tap zoom anywhere (this runs as an installed app) */
* { box-sizing: border-box; touch-action: manipulation; }
/* Installed on an iPhone the page is shifted down by the status bar, which leaves
   a strip at the very bottom that pinned panels do not reach. Make the page that
   much taller, and let the pinned panels' colour run on below them. */
html { -webkit-text-size-adjust: 100%; background: var(--bg); min-height: calc(100% + env(safe-area-inset-top)); }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
h1, h2 { margin: 0; }
h2 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.muted { color: var(--muted); font-size: 0.875rem; }
code { background: var(--card-2); padding: 0.1em 0.4em; border-radius: 4px; }

.view { max-width: 1200px; margin: 0 auto; padding: 0 12px calc(160px + env(safe-area-inset-bottom)); }
.main { container-type: inline-size; min-width: 0; }
.empty { padding-top: calc(14px + env(safe-area-inset-top)); }
#admin-view { padding-top: env(safe-area-inset-top); }
.empty p { margin-top: 24px; }

.topbar { display: flex; align-items: center; gap: 10px; padding: 10px 2px; }
.song-head { flex: 1; min-width: 0; display: grid; gap: 6px; }
.topbar h1 { font-size: 1.15rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back-btn { font: inherit; font-size: 2rem; line-height: 1; color: var(--accent); background: none; border: 0; padding: 0 8px 4px 2px; cursor: pointer; flex: none; align-self: center; }
.art.art-sm { width: 40px; height: 40px; border-radius: 8px; }
.nav-toggle { flex: none; align-self: flex-start; white-space: nowrap; }
.meta { display: flex; gap: 6px; flex-wrap: wrap; }

/* Album picture (or a placeholder tile) */
.art {
  flex: none; width: 48px; height: 48px; border-radius: 8px; overflow: hidden;
  display: grid; place-items: center; font-size: 1.3rem; color: var(--accent-ink);
  background: linear-gradient(135deg, var(--accent), #c9742b);
}
.art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.art-lg { width: 72px; height: 72px; border-radius: 12px; font-size: 2rem; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45); }

/* Forms: sign-in and add-a-song */
label { display: grid; gap: 6px; font-weight: 600; }
.hint { font-weight: 400; color: var(--muted); font-size: 0.85rem; }
input[type='text'], input[type='password'], input[type='file'] {
  font: inherit; color: var(--text); background: var(--card-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 12px; width: 100%; min-width: 0;
}
input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.error { color: #ff8a80; margin: 0; }
.btn:disabled { opacity: 0.5; cursor: default; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; text-align: center; }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: min(360px, 100%); display: grid; gap: 14px; padding: 24px; margin: 0; }
.login h1 { font-size: 1.4rem; }
.login form { display: grid; gap: 14px; }
.login-hello { margin: 0; }
.add-form { display: grid; gap: 16px; max-width: 640px; padding: 16px; }
.add-form .progress { max-width: none; margin: 0; }
.form-actions { display: flex; gap: 8px; }

/* Navigation panel */
.nav {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 30; width: min(320px, 100vw);
  background: var(--card); border-right: 1px solid var(--line);
  padding: 0 12px calc(16px + env(safe-area-inset-bottom)); overflow-y: auto; overscroll-behavior: contain;
  transform: translateX(-100%); visibility: hidden; transition: transform 0.2s ease, visibility 0.2s;
}
body.nav-open .nav { transform: none; visibility: visible; box-shadow: 0 120px 0 var(--card); }
.nav-head { display: flex; align-items: center; justify-content: space-between; padding: calc(14px + env(safe-area-inset-top)) 4px 14px; position: sticky; top: 0; background: var(--card); z-index: 1; }
.nav-head h1 { font-size: 1.25rem; flex: 1; }
.nav-head { gap: 8px; }
.nav { display: flex; flex-direction: column; }
.nav-foot-actions { display: flex; gap: 6px; }
#sheet-group input { margin: 6px 0 12px; }
#sheet-group p.muted { margin: 0 0 14px; }
.nav-foot { margin-top: auto; padding: 16px 4px 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.nav-scrim { position: fixed; inset: 0; z-index: 25; background: rgba(0, 0, 0, 0.5); display: none; }
.pill { background: var(--card-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 0.85rem; font-weight: 600; white-space: nowrap; }

/* Song list */
.song-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.song-list a {
  display: grid; grid-template-columns: 48px 1fr; grid-template-areas: 'art name' 'art info' 'art who'; column-gap: 12px; align-items: center;
  background: var(--card-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 10px; color: inherit; text-decoration: none;
}
.song-list a:hover, .song-list a.active { border-color: var(--accent); }
.song-list li { position: relative; }
.song-list .song-group { margin: 10px 2px 0; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.song-list .song-group:first-child { margin-top: 0; }
.song-fold { display: flex; justify-content: space-between; align-items: center; gap: 8px; text-align: left; width: 100%; padding: 8px 0; font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
.song-list li.editable a { padding-right: 52px; }
.song-edit { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; display: grid; place-items: center; color: var(--muted); background: none; border: 0; border-radius: 10px; cursor: pointer; }
.song-edit:hover { color: var(--accent); background: var(--card); }
.song-edit svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.song-notes p { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.performers { list-style: none; margin: 0; padding: 0; }
.performers li { padding: 12px 2px; border-bottom: 1px solid var(--line); font-weight: 600; }
.performers li:last-child { border-bottom: 0; }
.edit-performers { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 8px; }
.edit-performers:empty { display: none; }
.perf-chip { font: inherit; color: var(--text); background: var(--card-2); border: 1px solid var(--line); border-radius: 999px; padding: 6px 8px 6px 14px; cursor: pointer; }
.perf-chip span { color: var(--muted); margin-left: 6px; }
select { font: inherit; color: var(--text); background: var(--card-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; width: 100%; }
#edit-add-performer { margin-bottom: 16px; }
textarea { font: inherit; color: var(--text); background: var(--card-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; width: 100%; resize: vertical; margin: 6px 0 12px; }
textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.danger-zone { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.danger-zone p { margin: 0 0 10px; }
.btn.danger { color: #ff8a80; border-color: #7a3b37; }
.btn.danger.solid { background: #c2443c; border-color: #c2443c; color: #fff; font-weight: 700; }
.song-list .art { grid-area: art; }
.song-name { grid-area: name; align-self: end; font-weight: 600; font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.song-list .muted { grid-area: info; align-self: start; }
.song-list .song-who { grid-area: who; font-size: 0.8rem; color: var(--accent); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.song-list .art { align-self: center; }

/* Buttons */
.btn {
  font: inherit; color: var(--text); background: var(--card-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 14px; cursor: pointer; min-height: 40px;
}
.btn:hover { border-color: var(--muted); }
.btn.small { padding: 4px 10px; min-height: 32px; font-size: 0.85rem; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.btn.round { width: 48px; height: 48px; border-radius: 50%; padding: 0; font-size: 1.1rem; flex: none; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; min-height: 32px; }

.loading { padding: 40px 12px; text-align: center; }
.progress { height: 6px; background: var(--card-2); border-radius: 3px; overflow: hidden; max-width: 320px; margin: 12px auto 0; }
.progress div { height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }

.notice { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; border-color: var(--accent); }

/* Now playing */
.now { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 12px; align-items: center; position: sticky; top: 0; z-index: 5; }
.label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.chord-big { font-size: clamp(2.4rem, 11vw, 4rem); font-weight: 800; line-height: 1.1; color: var(--accent); }
.chord-next { font-size: clamp(1.4rem, 6vw, 2.2rem); font-weight: 700; line-height: 1.2; }
.now-pos { text-align: right; }
.now-lyric { grid-column: 1 / -1; font-size: 1.05rem; color: var(--muted); border-top: 1px solid var(--line); padding-top: 8px; min-height: 2.2em; }
.now-lyric .on { color: var(--text); font-weight: 700; }
.beat-dots { display: flex; gap: 6px; justify-content: flex-end; margin-top: 10px; }
.beat-dots i { width: 14px; height: 14px; border-radius: 50%; background: var(--card-2); border: 1px solid var(--line); }
.beat-dots i.on { background: var(--accent); border-color: var(--accent); }

/* Chord chart */
.loop-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.sections { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chip { font: inherit; font-size: 0.85rem; color: var(--text); background: var(--card-2); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; cursor: pointer; }
.chip.active { background: var(--loop); border-color: var(--loop); }
.chart { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; position: relative; }
.bar {
  font: inherit; color: var(--text); text-align: left; cursor: pointer; position: relative;
  background: var(--card-2); border: 1px solid transparent; border-radius: 6px;
  padding: 14px 4px 6px; min-height: 52px; min-width: 0;
  display: flex; flex-direction: column; justify-content: flex-start; align-items: stretch;
}
.bar-num { position: absolute; top: 2px; left: 5px; font-size: 0.65rem; color: var(--muted); }
.chart-section { grid-column: 1 / -1; display: flex; align-items: baseline; gap: 10px; margin-top: 14px; padding: 4px 2px 2px; border-bottom: 1px solid var(--line); scroll-margin-top: calc(var(--top-h, 130px) + 6px); }
.chart-section:first-child { margin-top: 0; }
.chart-section h3 { margin: 0; font-size: 1rem; color: var(--loop); white-space: nowrap; }
.note-by { color: var(--muted); white-space: nowrap; }
.chart-section p { margin: 0; flex: 1; min-width: 0; color: var(--text); font-size: 0.75rem; line-height: 1.3; white-space: pre-wrap; overflow-wrap: anywhere; }
.chart-section .song-edit { position: static; transform: none; width: 32px; height: 32px; margin-left: auto; flex: none; align-self: center; }
.chart-section .song-edit svg { width: 17px; height: 17px; }
.bar-section { position: absolute; top: 2px; right: 5px; max-width: calc(100% - 26px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.65rem; font-weight: 700; color: var(--loop); }
.bar-chords { display: grid; align-items: center; gap: 2px; }
.ch { font-weight: 700; font-size: 0.95rem; white-space: nowrap; }
.bar-lyric { display: block; margin-top: 3px; font-size: 0.72rem; line-height: 1.2; color: var(--muted); min-height: 1.2em; overflow-wrap: anywhere; }
.bar.current .bar-lyric { color: var(--text); }
.ch.rep { color: var(--muted); font-weight: 400; }
.ch.current { color: var(--accent); }
.bar.pickup .bar-num { font-style: italic; }
.bar.in-loop { background: color-mix(in srgb, var(--loop) 28%, var(--card-2)); }
.bar.picked { border-color: var(--loop); }
.bar.current { border-color: var(--accent); }
.chart.picking .bar { border-style: dashed; border-color: var(--line); }
.chart.picking .bar.picked { border-style: solid; border-color: var(--loop); }

/* Bar-by-bar view */
.bars { display: none; }
/* Both views: a pinned header with the sections, then only the bars scroll. */
.now, .chart-card .card-head, .chart-card #sections { display: none; }
.song-top { position: sticky; top: 0; z-index: 6; background: var(--bg); padding-top: env(safe-area-inset-top); }
.chart-card { background: none; border: 0; padding: 0; margin: 0; }
body.view-bars .chart-card { display: none; }
.bar, .brow { scroll-margin-top: calc(var(--top-h, 130px) + 10px); }
.bar.current::after { content: ''; position: absolute; left: 0; bottom: 0; height: 3px; width: var(--beat, 0%); background: var(--accent); border-radius: 0 0 0 6px; }
.ch.carry, .beat.carry { color: var(--muted); font-weight: 600; }
.brow .beat.on.carry { color: var(--bg); }
body.view-bars .bars { display: block; max-width: 720px; margin: 0 auto; padding: 4px 4px 0; }

.brow { margin-bottom: 14px; }
.brow-head { display: flex; gap: 10px; align-items: baseline; font-size: 0.8rem; color: var(--muted); margin-bottom: 4px; }
.brow-section { color: var(--loop); font-weight: 700; }
.brow-cells { display: grid; gap: 3px; border-radius: 10px; overflow: hidden; border-left: 4px solid var(--line); }
.beat {
  font: inherit; font-weight: 700; font-size: clamp(1rem, 4.5vw, 1.4rem); color: var(--text); background: var(--card-2);
  border: 0; min-height: 64px; padding: 4px; cursor: pointer; overflow-wrap: anywhere;
}
.brow.in-loop .beat { background: color-mix(in srgb, var(--loop) 28%, var(--card-2)); }
.brow.current .brow-cells { border-left-color: var(--accent); }
.brow .beat.on { background: var(--text); color: var(--bg); }
.brow-lyric { display: grid; column-gap: 3px; padding-left: 4px; color: var(--muted); font-size: 1.05rem; line-height: 1.25; min-height: 1.5em; margin-top: 6px; }
.brow-lyric span { padding-left: 6px; min-width: 0; overflow-wrap: anywhere; }
.brow.current .brow-lyric span.on { color: var(--accent); }
.brow.current .brow-lyric { color: var(--text); font-weight: 600; }
.bars-sections { display: none; gap: 6px; overflow-x: auto; padding: 0 2px 10px; scrollbar-width: none; }
.bars-sections::-webkit-scrollbar { display: none; }
.bars-sections:not(:empty) { display: flex; }
.now-section { display: none; }
body.view-bars .now-section:not([hidden]) { display: flex; align-items: baseline; gap: 10px; padding: 0 4px 8px; border-bottom: 1px solid var(--line); }
.now-section b { color: var(--loop); white-space: nowrap; }
.now-section span { flex: 1; min-width: 0; font-size: 0.75rem; line-height: 1.3; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 3.9em; overflow: hidden; }
body.view-bars .loop-chip { display: none; }
.loop-chip { border-style: dashed; }
.loop-chip.active { border-style: solid; }
.bars-sections .chip { white-space: nowrap; flex: none; }
.mixer-card:not(.open) { display: none; }
#mixer-close { display: none; }
.mixer-card.open #mixer-close { display: inline-block; }
.mixer-actions { display: flex; gap: 6px; }

/* Panels that slide up from the bottom */
.sheet-scrim { display: none; position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0.5); }
.sheet-scrim.open { display: block; }
.panel { display: none; }
.panel.open, .mixer-card.open {
  display: block; position: fixed; z-index: 41; left: 0; right: 0; bottom: 0; margin: 0 auto; width: min(560px, 100%);
  max-height: 75vh; overflow-y: auto; background: var(--card); border: 1px solid var(--line); border-bottom: 0;
  border-radius: 18px 18px 0 0; padding: 22px 16px calc(18px + env(safe-area-inset-bottom));
  box-shadow: 0 -16px 40px rgba(0, 0, 0, 0.55), 0 120px 0 var(--card); animation: sheet-up 0.22s ease-out;
}
.panel.open::before, .mixer-card.open::before {
  content: ''; position: absolute; top: 8px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: var(--line);
}
@keyframes sheet-up { from { transform: translateY(100%); } }
@media (prefers-reduced-motion: reduce) { .panel.open, .mixer-card.open { animation: none; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sheet-value { margin: 0 0 12px; font-size: 1.6rem; font-weight: 800; text-align: center; flex: 1; }
.sheet-value .muted { font-size: 0.95rem; font-weight: 400; }
.sheet-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.sheet-row .btn { min-width: 52px; font-size: 1.3rem; }
.sheet-row .sheet-value { margin: 0; }
.key-ctl.changed #song-key { color: var(--accent); }
.btn.wide { width: 100%; }
.view-option { display: grid; gap: 2px; text-align: left; padding: 14px; margin-bottom: 8px; }
.view-option.active { border-color: var(--accent); }
.view-option.active b { color: var(--accent); }

/* Mixer */
.tracks { display: grid; gap: 8px; }
.track { display: grid; grid-template-columns: minmax(96px, 1.2fr) 40px 40px minmax(90px, 2fr) 2.2em; align-items: center; gap: 8px; }
.track.silent .track-name, .track.silent .vol-value { color: var(--muted); }
.track-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toggle { padding: 0; width: 40px; height: 40px; min-height: 0; font-weight: 700; }
.mute[aria-pressed='true'] { background: var(--mute); border-color: var(--mute); color: #fff; }
.solo[aria-pressed='true'] { background: var(--solo); border-color: var(--solo); color: #1a1405; }
.vol-value { font-size: 0.8rem; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

input[type='range'] { width: 100%; min-width: 0; accent-color: var(--accent); height: 32px; margin: 0; }

.exports { display: grid; gap: 8px; }
.head-actions { display: flex; gap: 2px; margin-left: auto; flex: none; }
.export-btn { flex: none; width: 40px; height: 40px; display: grid; place-items: center; color: var(--accent); background: none; border: 0; border-radius: 10px; cursor: pointer; }
.export-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.export-btn:hover { background: var(--card-2); }

/* Transport */
.transport {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: color-mix(in srgb, var(--card) 94%, transparent); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  padding: 6px 14px calc(8px + env(safe-area-inset-bottom));
  box-shadow: 0 120px 0 var(--card);
}
.tp-progress, .tp-controls { max-width: 560px; margin: 0 auto; }
.tp-progress input { height: 24px; }
.tp-times { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; margin-top: -2px; }
.tp-controls { display: flex; align-items: center; justify-content: space-between; margin-top: 2px; }
.tp-controls button { font: inherit; color: var(--text); background: none; border: 0; cursor: pointer; padding: 0; }
.tp-controls svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tp-controls svg .fill { fill: currentColor; stroke-width: 1; }
.tp-side { display: grid; justify-items: center; gap: 1px; min-width: 52px; min-height: 48px; align-content: center; border-radius: 10px; }
.tp-side b { font-size: 0.95rem; line-height: 26px; font-variant-numeric: tabular-nums; }
.tp-side small { font-size: 0.65rem; color: var(--muted); }
.tp-side.changed b { color: var(--accent); }
.tp-skip { width: 48px; height: 48px; display: grid; place-items: center; }
.tp-skip svg { width: 32px; height: 32px; }
.tp-play { width: 60px; height: 60px; border-radius: 50%; background: var(--accent) !important; color: var(--accent-ink) !important; font-size: 1.4rem !important; display: grid; place-items: center; }

@media (max-width: 899px) {
  /* Phone: the panel covers the screen */
  .nav { width: 100vw; border-right: 0; }
  /* The song list fills a phone screen, so the strip below it takes its colour too. */
  html:has(body.nav-open), body.nav-open { background: var(--card); }
  body:not(.has-song) #nav-close { display: none; }
  .view .nav-toggle:not(.back-btn) { padding: 6px 10px; min-height: 36px; font-size: 0.9rem; }
}

/* Wide player area: 8 bars per row */
@container (min-width: 700px) {
  .chart { grid-template-columns: repeat(8, 1fr); }
}

@media (min-width: 900px) {
  /* Desktop: the panel sits beside the player and pushes it over */
  body.nav-open .main { margin-left: 320px; }
  body.nav-open .transport { left: 320px; }
  body.nav-open .panel.open, body.nav-open.view-bars .mixer-card.open { left: 320px; }
  .main, .transport { transition: margin-left 0.2s ease, left 0.2s ease; }
  .view { padding-bottom: 160px; }
}

/* Print / export preview */
#print-view { position: fixed; inset: 0; z-index: 50; background: #e7e8ec; color: #111; overflow: auto; -webkit-overflow-scrolling: touch; }
/* Close on the left, the print/share button on the right, the choices in a row of their own underneath. */
.print-bar { position: sticky; top: 0; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: calc(10px + env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 10px max(12px, env(safe-area-inset-left)); background: var(--bg); z-index: 1; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25); }
.print-bar .btn { min-height: 44px; }
.print-bar .btn:disabled { opacity: 0.6; }
.print-opts { flex: 1 0 100%; display: flex; gap: 8px; }
.print-opts select { flex: 1; min-width: 0; font-size: 16px; }
.print-opts:not(:has(select:not([hidden]), label:not([hidden]))) { display: none; }
.print-check { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; white-space: nowrap; }
.print-check input { width: 18px; height: 18px; accent-color: var(--accent); }
#print-content { padding: 14px 12px calc(24px + env(safe-area-inset-bottom)); max-width: 900px; margin: 0 auto; overflow-x: auto; }
#print-content > .sheet { background: #fff; border-radius: 12px; padding: 18px 16px; box-shadow: 0 1px 6px rgba(0, 0, 0, 0.12); }
/* The notation is laid out for A4 (794px wide); once drawn (.fit) each page is a sheet
   of paper that shrinks to the width of the screen, and a tap enlarges it. */
#osmd { width: 794px; margin: 0 auto; }
@media screen {
  #osmd.fit { width: auto; max-width: 794px; }
  #osmd svg { display: block; width: 100%; height: auto; margin: 0 auto 12px; background: #fff; border-radius: 4px; box-shadow: 0 1px 8px rgba(0, 0, 0, 0.18); cursor: zoom-in; }
  #print-content.zoomed #osmd svg { width: 230%; max-width: none; cursor: zoom-out; }
  @media (min-width: 900px) { #print-content.zoomed #osmd svg { width: 100%; cursor: default; } #osmd svg { cursor: default; } }
}
.sheet h1 { font-size: 1.6rem; }
.sheet h2 { color: #111; font-size: 1rem; margin: 14px 0 6px; }
.sheet-meta { color: #555; margin: 4px 0 16px; }
.sheet-grid { display: grid; grid-template-columns: repeat(4, 1fr); }
.sheet-bar { border-left: 1.5px solid #111; border-right: 1.5px solid #111; margin-left: -1.5px; padding: 2px 6px 10px; min-height: 44px; break-inside: avoid; }
.sheet-bar small { color: #888; font-size: 0.6rem; display: block; }
.sheet-bar div { display: grid; font-weight: 700; font-size: 1rem; }
.sheet-bar p { margin: 4px 0 0; font-size: 0.75rem; font-weight: 400; }
.sheet-bar .rep { font-weight: 400; color: #666; }

.inst-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.inst { font: inherit; font-weight: 600; padding: 16px 12px; border: 1.5px solid #111; border-radius: 8px; background: #fff; color: #111; cursor: pointer; }
.inst:hover { background: #f3f3f3; }

@media print {
  body.printing .view, body.printing .nav, .print-bar { display: none !important; }
  body.printing .main { margin-left: 0 !important; }
  #print-view { position: static; overflow: visible; background: none; }
  #print-content { padding: 0; max-width: none; }
  #print-content > .sheet { box-shadow: none; padding: 0; }
}

/* ---------- The tour: a panel of slides, one per feature, each acted out on screenshots of the app ---------- */
.tour { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: max(14px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom)); background: rgba(5, 7, 11, 0.74); }
.tour[hidden] { display: none; }
.tour-card { position: relative; width: min(380px, 100%); max-height: 100%; overflow-y: auto; box-sizing: border-box; display: grid; gap: 14px; padding: 20px 18px 18px; border-radius: 22px; border: 1px solid var(--line); background: var(--card); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6); }
.tour-close { position: absolute; top: 10px; right: 10px; z-index: 2; width: 34px; height: 34px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, 0.1); color: var(--text); font-size: 0.95rem; cursor: pointer; }
.tour-slides { display: grid; }
.tour-slide { grid-area: 1 / 1; display: grid; gap: 10px; align-content: start; opacity: 0; visibility: hidden; transition: opacity 0.3s; }
.tour-slide.on { opacity: 1; visibility: visible; }
.tour-slide h3 { margin: 4px 0 0; font-size: 1.15rem; }
.tour-slide p { margin: 0; color: var(--muted); line-height: 1.45; font-size: 0.95rem; }
.tour-dots { display: flex; justify-content: center; gap: 7px; }
.tour-dots button { width: 8px; height: 8px; padding: 0; border-radius: 50%; border: 0; background: var(--line); cursor: pointer; }
.tour-dots button[aria-current='true'] { background: var(--accent); width: 20px; border-radius: 4px; }
.tour-nav { display: flex; gap: 10px; }
.tour-nav .btn { flex: 1; min-height: 44px; }
.tour-nav .btn:disabled { opacity: 0.4; }
/* the app itself, in a phone frame: two stacked screenshots (to fade from one to the next) and the finger */
.tour-phone { position: relative; justify-self: center; height: min(56vh, 520px); aspect-ratio: 390 / 844; border-radius: 22px; border: 2px solid #3d4656; background: var(--bg); overflow: hidden; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); }
.tour-phone img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.4s; }
.tour-phone img.show { opacity: 1; }
.tf { position: absolute; width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%; background: rgba(255, 255, 255, 0.35); border: 2px solid #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6), 0 0 0 0 rgba(245, 185, 66, 0); opacity: 0; left: 80%; top: 92%; pointer-events: none; transition: left 0.6s cubic-bezier(0.3, 0.7, 0.3, 1), top 0.6s cubic-bezier(0.3, 0.7, 0.3, 1), opacity 0.3s, transform 0.18s, box-shadow 0.5s; }
.tf.on { opacity: 1; }
.tf.down { transform: scale(0.7); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.6), 0 0 0 14px rgba(245, 185, 66, 0.45); }
.tour-slide p { min-height: 4.4em; }
@media (prefers-reduced-motion: reduce) { .tour-phone img, .tf { transition: none; } }

/* ---------- The snow globe panel (opened from the little globe at the top of the song list) ---------- */
.globe-btn { padding: 4px 7px; display: inline-grid; place-items: center; }
.globe-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.globe-btn svg .dot { stroke-width: 2; }
/* The panel slides up from the bottom over a dimmed page, like a sheet on an iPhone, and slides back down to close. */
.globe-wrap { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, 0); transition: background 0.35s; overflow: hidden; }
.globe-wrap[hidden] { display: none; }
.globe-wrap.open { background: rgba(0, 0, 0, 0.6); }
.globe { position: absolute; left: 0; right: 0; bottom: 0; top: calc(env(safe-area-inset-top) + 14px); max-width: 640px; margin: 0 auto; border-radius: 20px 20px 0 0; display: grid; grid-template-rows: auto minmax(0, 1fr); justify-items: center; padding: 0 18px calc(18px + env(safe-area-inset-bottom)); overflow: hidden; overscroll-behavior: none; box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
  background: radial-gradient(90% 55% at 50% 108%, rgba(245, 185, 66, 0.2), transparent 70%), linear-gradient(180deg, #090b10 0%, #12151b 55%, #1a1814 100%);
  transform: translateY(100%); transition: transform 0.45s cubic-bezier(0.32, 0.72, 0, 1); }
.globe-wrap.open .globe { transform: none; }
.globe.pulling { transition: none; }
.globe-head { position: relative; width: 100%; display: grid; justify-items: center; padding-top: 8px; touch-action: none; cursor: grab; -webkit-user-select: none; user-select: none; }
.globe-head .grab { width: 38px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.3); }
@media (prefers-reduced-motion: reduce) { .globe-wrap, .globe { transition: none; } }
.globe canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
/* the starry sky: three layers of stars (drawn by church.js); two brighten and dim slowly, out of step */
.globe .stars { position: absolute; inset: 0; pointer-events: none; }
.globe .stars canvas:nth-child(2) { animation: twinkle 4.6s ease-in-out infinite; }
.globe .stars canvas:nth-child(3) { animation: twinkle 6.3s ease-in-out -2.5s infinite; }
@keyframes twinkle { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) { .globe .stars canvas { animation: none; } }
.globe h2 { position: relative; margin: 18px 44px 0; max-width: 520px; text-align: center; font: 300 clamp(1.15rem, 5.2vw, 1.7rem) / 1.3 'Avenir Next', Avenir, 'Helvetica Neue', 'Segoe UI', system-ui, sans-serif; letter-spacing: 0.16em; text-transform: uppercase; color: #f8d48a; text-wrap: balance; }
.globe .tour-close { top: 12px; right: 12px; }
#church-slot { position: relative; width: 100%; touch-action: none; cursor: grab; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
#church-slot:active { cursor: grabbing; }
