:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --text: #1b1d22;
  --muted: #6a6e77;
  --line: #e3e1da;
  --accent: #2c4fb8;
  --accent-soft: #e6ebf8;
  --accent-text: #ffffff;
  --mark: #ffe58a;
  --shadow: 0 1px 2px rgba(30, 30, 20, 0.06), 0 2px 8px rgba(30, 30, 20, 0.04);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --gutter: max(16px, env(safe-area-inset-left), env(safe-area-inset-right));
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111318;
    --surface: #1a1d24;
    --text: #e9eaee;
    --muted: #9a9fab;
    --line: #2b2f38;
    --accent: #8aa6ff;
    --accent-soft: #232b44;
    --accent-text: #0d1020;
    --mark: #5a4a10;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 17px/1.5 var(--sans);
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button, a, input { touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.view {
  max-width: 1440px; margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) var(--gutter) max(48px, env(safe-area-inset-bottom));
}
h1 { font-family: var(--serif); font-weight: 700; line-height: 1.15; text-wrap: balance; }
h2 { font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 28px 0 10px; }
.muted { color: var(--muted); font-size: 0.9rem; margin: 0; }

/* ---------- search ---------- */

.top {
  position: sticky; top: 0; z-index: 1; background: var(--bg);
  padding: 12px 0 14px; margin-top: calc(-1 * max(12px, env(safe-area-inset-top)));
  padding-top: max(12px, env(safe-area-inset-top));
  display: grid; gap: 10px;
}
.brand { font-size: 2rem; margin: 8px 0 2px; text-align: center; }
.search { position: relative; width: 100%; max-width: 760px; margin: 0 auto; }
#count { text-align: center; }
.search svg {
  position: absolute; left: 14px; top: 50%; width: 20px; height: 20px; transform: translateY(-50%);
  fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; pointer-events: none;
}
input[type=search] {
  width: 100%; font: inherit; font-size: max(17px, 1rem); /* 16px+ stops iPhone zooming in */
  padding: 13px 14px 13px 44px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); box-shadow: var(--shadow);
  -webkit-appearance: none; appearance: none;
}
input[type=search]:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }

.results { list-style: none; margin: 4px 0 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.results a {
  display: block; padding: 14px 16px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  color: inherit; text-decoration: none; min-width: 0;
}
.results .t { font-family: var(--serif); font-weight: 700; font-size: 1.15rem; line-height: 1.3; }
.results .s { color: var(--muted); font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.results li.muted { padding: 8px 4px; }
mark { background: var(--mark); color: inherit; border-radius: 2px; }
@media (hover: hover) {
  .results a:hover { border-color: var(--accent); }
}
.results a:active { background: var(--accent-soft); }

/* ---------- verse picker ---------- */

.back { display: inline-block; color: var(--accent); text-decoration: none; font-size: 1rem; padding: 10px 0; }
.picker h1 { font-size: 2rem; margin: 4px 0 0; }
.picker h2 { margin-top: 22px; }

.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  font: inherit; font-weight: 600; min-width: 56px; height: 52px; padding: 0 16px; border-radius: 12px; cursor: pointer;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--text);
}
.chip[aria-pressed=true] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.row { display: flex; gap: 20px; margin: 12px 0 4px; }
.link { font: inherit; background: none; border: 0; padding: 6px 0; color: var(--accent); cursor: pointer; }
.toggle { display: flex; align-items: center; gap: 12px; margin: 12px 0; cursor: pointer; }
/* "As it is in the file": every slide in order, so verse choices don't apply */
.asfile #verses, .asfile #all, .asfile #none, .asfile #repeat-wrap { opacity: 0.4; pointer-events: none; }
.whole #all, .whole #none, .whole #asfile-wrap { opacity: 0.4; cursor: default; }
.toggle input { width: 22px; height: 22px; margin: 0; accent-color: var(--accent); flex: none; }
.primary {
  display: block; width: 100%; max-width: 360px; margin-top: 18px;
  font: inherit; font-weight: 600; font-size: 1.1rem; padding: 15px 28px; border-radius: 12px;
  border: 0; background: var(--accent); color: var(--accent-text); cursor: pointer;
}
.primary:disabled { opacity: 0.4; cursor: default; }

.preview .sec { margin-bottom: 20px; }
.preview .sec.off { opacity: 0.35; }
.preview .lab { font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.preview .sec[data-v] { cursor: pointer; }
.preview .note { color: var(--muted); font-size: 0.85rem; margin: 0 0 16px; }
.preview .music { margin: 4px 0 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.preview .music summary { cursor: pointer; color: var(--accent); font-weight: 600; padding: 6px 0 12px; }
.preview p { margin: 0 0 8px; white-space: pre-line; }
.preview .thumb {
  display: block; width: 100%; max-width: 560px; height: auto; margin: 6px 0 10px;
  background: #fff; border: 1px solid var(--line); border-radius: 6px;
}

/* ---------- tablets and computers ----------
   Song list: 1 column on phones, 2 on tablets held upright, 3 on tablets sideways and laptops, 4 on large screens. */

@media (min-width: 600px) {
  .results { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .results li.muted { grid-column: 1 / -1; }
}
@media (min-width: 720px) {
  body { font-size: 18px; }
  .brand { font-size: 2.4rem; margin-top: 20px; }
  .results a { padding: 16px 18px; height: 100%; }
}
@media (min-width: 860px) {
  .song-grid { display: grid; grid-template-columns: minmax(300px, 380px) 1fr; gap: 56px; align-items: start; }
  .picker { position: sticky; top: max(16px, env(safe-area-inset-top)); }
  .picker h1 { font-size: 2.3rem; }
  .lyrics h2 { margin-top: 30px; }
  .lyrics .preview { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 22px 26px 6px; box-shadow: var(--shadow); }
}
@media (min-width: 1000px) {
  .results { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 1200px) {
  /* Song page: the lyrics side by side in two columns, so lines stay a comfortable length */
  .lyrics .preview { columns: 2; column-gap: 44px; }
  .preview .sec { break-inside: avoid; }
  .preview .note, .preview .music { column-span: all; }
  .preview .music[open] { columns: 2; column-gap: 24px; }
}
@media (min-width: 1400px) {
  .results { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ---------- slides: always dark, like a projector ---------- */

.show {
  position: fixed; inset: 0; background: #000; color: #fff; z-index: 10;
  user-select: none; -webkit-user-select: none; cursor: pointer; touch-action: manipulation;
}
.slide {
  position: absolute; inset: 0;
  padding: max(28px, env(safe-area-inset-top)) max(28px, env(safe-area-inset-right)) calc(52px + env(safe-area-inset-bottom)) max(28px, env(safe-area-inset-left));
  display: flex; align-items: center; justify-content: center;
}
.slide-text { text-align: center; line-height: 1.3; font-weight: 500; white-space: pre-line; max-width: 100%; }
.hud {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 6px max(16px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  color: #8a8f99; font-size: 0.85rem;
}
/* Sheet-music pictures: shown on white, as large as the screen allows */
.show.pic { background: #fff; }
.show.pic .slide { padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) calc(44px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
.show.pic .slide { flex-direction: column; align-items: stretch; }
/* The song title above the music, as on the PowerPoint slides */
.slide-title {
  flex: none; padding: 0 8px 4px; color: #1b1d22; font-family: var(--sans); font-weight: 700;
  font-size: clamp(1rem, 4.5vh, 1.9rem); line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.slide-img { display: block; width: 100%; height: 100%; min-height: 0; flex: 1; object-fit: contain; } /* small pictures are enlarged to fill the screen too */
.show.pic .hud, .show.pic #close { color: #6a6e77; }
.turn { display: none; }
@media (orientation: portrait) and (max-width: 600px) {
  .show.pic .turn {
    display: block; position: absolute; left: 0; right: 0; bottom: calc(48px + env(safe-area-inset-bottom)); margin: 0;
    text-align: center; color: #6a6e77; font-size: 0.9rem; pointer-events: none;
  }
}
#where { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#close { font: inherit; font-size: 1.2rem; background: none; border: 0; color: #8a8f99; width: 44px; height: 44px; cursor: pointer; flex: none; }
