:root {
  --maroon: #6e2436; --maroon-dark: #4d1826; --ink: #3a121d;
  --cream: #faf6ee; --paper: #fffdf8; --tan: #ede3d2; --sand: #e2d3ba;
  --gold: #c08a2e; --gold-soft: #f3e2bf; --text: #2c2320; --muted: #6b5f57;
  --serif: 'Fraunces', Georgia, 'Times New Roman', serif;
  --sans: 'Nunito Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --lyric: 1.2rem;
  --top: 64px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: var(--sans); background: var(--cream); color: var(--text); line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { color: var(--maroon); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 6px; }
.sb-skip { position: absolute; left: -999px; top: 8px; background: #fff; padding: 8px 14px; z-index: 999; border-radius: 6px; }
.sb-skip:focus { left: 8px; }
svg { fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* Header */
.sb-top { position: sticky; top: 0; z-index: 60; background: var(--maroon-dark); color: #fff; box-shadow: 0 2px 12px rgba(0,0,0,.15); }
.sb-top-in { max-width: 1100px; margin: 0 auto; height: var(--top); padding: 0 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sb-brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-family: var(--serif); font-weight: 600; font-size: 1.1rem; line-height: 1.1; }
.sb-brand img { width: 40px; height: 40px; border-radius: 50%; box-shadow: 0 0 0 2px rgba(255,255,255,.5); }
.sb-brand small { display: block; font: 700 .68rem var(--sans); letter-spacing: .16em; text-transform: uppercase; opacity: .8; }
.sb-nav { display: flex; gap: 2px; }
.sb-nav a { color: #fff; text-decoration: none; font-weight: 600; font-size: .92rem; padding: 8px 12px; border-radius: 999px; }
.sb-nav a:hover { background: rgba(255,255,255,.14); }
@media (max-width: 640px) { .sb-nav a:not(:first-child) { display: none; } }

/* Hero */
.sb-hero { background: linear-gradient(160deg, var(--maroon), var(--maroon-dark)); color: #fff; padding: 22px 16px 26px; }
.sb-hero-in { max-width: 820px; margin: 0 auto; text-align: center; }
.sb-tabs { display: inline-flex; background: rgba(0,0,0,.2); border-radius: 999px; padding: 4px; gap: 4px; margin-bottom: 14px; }
.sb-tabs a { color: #f3e9e9; text-decoration: none; font-weight: 700; font-size: .92rem; padding: 8px 16px; border-radius: 999px; }
.sb-tabs a[aria-current] { background: var(--gold); color: var(--ink); }
.sb-hero h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(1.8rem, 6vw, 2.6rem); line-height: 1.1; }
.sb-hero p { opacity: .88; margin-top: 8px; font-size: .98rem; }

/* Tools: search + A-Z */
.sb-tools { position: sticky; top: var(--top); z-index: 50; background: rgba(250,246,238,.97); backdrop-filter: blur(8px); border-bottom: 1px solid var(--tan); }
.sb-tools-in { max-width: 820px; margin: 0 auto; padding: 12px 16px 6px; }
.sb-search { position: relative; display: block; }
.sb-search svg { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--muted); }
.sb-search input {
  width: 100%; font: 600 1.05rem var(--sans); color: var(--text);
  padding: 14px 46px 14px 46px; border-radius: 14px; border: 1.5px solid var(--sand); background: #fff;
  -webkit-appearance: none; appearance: none;
}
.sb-search input::-webkit-search-cancel-button { display: none; }
.sb-search input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 4px rgba(192,138,46,.18); }
.sb-clear { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; border: 0; border-radius: 50%; background: var(--tan); color: var(--maroon-dark); font-size: 1.3rem; line-height: 1; cursor: pointer; }
.sb-count { font-size: .82rem; color: var(--muted); text-align: center; min-height: 1.3em; margin-top: 4px; }
.sb-az { max-width: 820px; margin: 0 auto; display: flex; gap: 2px; overflow-x: auto; padding: 2px 12px 10px; scrollbar-width: none; justify-content: safe center; }
.sb-az::-webkit-scrollbar { display: none; }
.sb-az a { flex: none; min-width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; text-decoration: none; font-weight: 700; font-size: .9rem; color: var(--maroon-dark); }
.sb-az a:hover, .sb-az a.on { background: var(--maroon); color: #fff; }

/* List */
.sb-main { max-width: 820px; margin: 0 auto; padding: 8px 12px 40px; min-height: 60vh; }
.sb-list { list-style: none; }
.sb-letter { font-family: var(--serif); font-weight: 700; font-size: 1.25rem; color: var(--gold); padding: 18px 8px 6px; scroll-margin-top: calc(var(--top) + 150px); }
.sb-row {
  display: flex; align-items: center; gap: 14px; text-decoration: none; color: var(--text);
  padding: 12px 12px; border-radius: 14px; min-height: 60px; transition: background .15s;
}
.sb-row:hover, .sb-row:focus-visible { background: #fff; box-shadow: 0 2px 10px rgba(58,18,29,.06); }
.sb-num {
  flex: none; min-width: 48px; height: 40px; padding: 0 6px; border-radius: 10px; display: grid; place-items: center;
  background: var(--tan); color: var(--maroon-dark); font: 700 1.05rem var(--sans); font-variant-numeric: tabular-nums;
}
.sb-tt { min-width: 0; }
.sb-tt b { display: block; font-family: var(--serif); font-weight: 600; font-size: 1.12rem; color: var(--ink); line-height: 1.25; }
.sb-tt small { display: block; color: var(--muted); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-tt small mark, .sb-tt b mark { background: var(--gold-soft); color: inherit; border-radius: 3px; }
.sb-list li[hidden] { display: none; }
/* "Sung at church" YouTube links */
.sb-has-yt { display: flex; align-items: center; gap: 6px; }
.sb-has-yt .sb-row { flex: 1; min-width: 0; }
.sb-yt {
  flex: none; display: inline-flex; align-items: center; gap: 4px; text-decoration: none;
  font: 700 .8rem var(--sans); color: var(--maroon); background: var(--gold-soft);
  padding: 7px 11px 7px 8px; border-radius: 999px; white-space: nowrap;
}
.sb-yt:hover, .sb-yt:focus-visible { background: var(--maroon); color: #fff; }
.sb-yt svg, .sb-sung svg { width: 16px; height: 16px; fill: currentColor; flex: none; }
.sb-sung { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; margin: -10px auto 26px; max-width: 560px; }
.sb-sung > span { width: 100%; text-align: center; font: 700 .72rem var(--sans); letter-spacing: .18em; text-transform: uppercase; color: var(--gold); }
.sb-sung a {
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: var(--maroon-dark);
  background: var(--paper); border: 1px solid var(--sand); border-radius: 999px; padding: 7px 14px 7px 10px; font: 700 .9rem var(--sans);
}
.sb-sung a small { font-weight: 400; color: var(--muted); }
.sb-sung a:hover, .sb-sung a:focus-visible { background: var(--maroon); border-color: var(--maroon); color: #fff; }
.sb-sung a:hover small { color: #f3e2bf; }
.sb-row.exact .sb-num { background: var(--maroon); color: #fff; }
.sb-empty { text-align: center; color: var(--muted); padding: 40px 16px; }

/* Song view */
body.reading .sb-hero, body.reading .sb-tools, body.reading .sb-list, body.reading .sb-empty { display: none !important; }
.sb-song { max-width: 680px; margin: 0 auto; padding: 18px 8px 130px; }
.sb-song header { text-align: center; padding: 18px 0 22px; border-bottom: 1px solid var(--tan); margin-bottom: 26px; }
.sb-badge { display: inline-block; background: var(--maroon); color: #fff; font: 700 1.05rem var(--sans); padding: 4px 16px; border-radius: 999px; letter-spacing: .04em; }
.sb-song h2 { font-family: var(--serif); font-weight: 600; color: var(--ink); font-size: clamp(1.7rem, 6vw, 2.4rem); line-height: 1.15; margin-top: 12px; }
.sb-lyrics { font-family: Georgia, 'Times New Roman', serif; font-size: var(--lyric); line-height: 1.7; text-align: center; }
.sb-verse, .sb-chorus { margin: 0 auto 1.4em; }
.sb-chorus { font-style: italic; color: var(--maroon-dark); background: var(--paper); border: 1px solid var(--tan); border-left: 4px solid var(--gold); border-radius: 12px; padding: 14px 16px 16px; max-width: 560px; }
.sb-tag { display: block; font: 700 .72rem var(--sans); letter-spacing: .18em; text-transform: uppercase; color: var(--gold); font-style: normal; margin-bottom: 6px; }
.sb-missing { color: var(--muted); font-style: italic; }
.sb-song header { border-radius: 16px; }
.sb-song.flash header { animation: flash 1s ease forwards; }
@keyframes flash { from { background: var(--gold-soft); } to { background: transparent; } }

/* Bottom bar (reading) */
.sb-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: stretch;
  padding: 10px max(12px, calc((100% - 820px) / 2)) calc(10px + env(safe-area-inset-bottom));
  background: rgba(255,253,248,.97); backdrop-filter: blur(8px); border-top: 1px solid var(--tan);
  box-shadow: 0 -4px 18px rgba(58,18,29,.08);
}
.sb-bar[hidden] { display: none; }
.sb-bar a { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--maroon-dark); padding: 8px 10px; border-radius: 12px; min-height: 52px; min-width: 0; }
.sb-bar a:hover { background: var(--tan); }
.sb-bar svg { width: 22px; height: 22px; flex: none; }
.sb-bar span { min-width: 0; }
.sb-bar small { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 700; }
.sb-bar b { display: block; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-next { justify-content: flex-end; text-align: right; }
.sb-all { flex-direction: column; gap: 0 !important; justify-content: center; background: var(--maroon); color: #fff !important; padding: 6px 18px !important; font-weight: 700; font-size: .78rem; }
.sb-all:hover { background: var(--maroon-dark) !important; }
.sb-bar a.off { visibility: hidden; }
.sb-size { display: inline-flex; margin-top: 14px; background: #fff; border: 1px solid var(--sand); border-radius: 999px; box-shadow: 0 4px 14px rgba(58,18,29,.1); overflow: hidden; }
.sb-size[hidden] { display: none; }
.sb-song header .sb-size { display: flex; width: max-content; margin: 14px auto 0; }
.sb-size button { border: 0; background: none; font: 700 1rem var(--sans); color: var(--maroon-dark); width: 46px; height: 40px; cursor: pointer; }
.sb-size button + button { border-left: 1px solid var(--tan); font-size: 1.15rem; }
.sb-size button:hover { background: var(--tan); }

.sb-foot { text-align: center; color: var(--muted); font-size: .88rem; padding: 26px 16px 36px; border-top: 1px solid var(--tan); }
body.reading .sb-foot { display: none; }
.sb-foot p + p { margin-top: 6px; }

@media (max-width: 520px) {
  :root { --top: 58px; }
  .sb-brand img { width: 36px; height: 36px; }
  .sb-hero { padding: 16px 14px 20px; }
  .sb-hero p { font-size: .9rem; }
  .sb-row { padding: 10px 6px; gap: 12px; }
  .sb-num { min-width: 44px; height: 38px; font-size: 1rem; }
  .sb-bar b { font-size: .85rem; }
}
@media (prefers-reduced-motion: reduce) { .sb-song.flash header { animation: none; } }
@media print {
  .sb-top, .sb-tools, .sb-bar, .sb-size, .sb-foot, .sb-hero { display: none !important; }
  .sb-song { padding: 0; }
}
