:root {
  --green: #1d3a2c;
  --green-2: #27503d;
  --green-ink: #183026;
  --ivory: #faf6ec;
  --ivory-2: #f3ecdb;
  --paper: #fffdf8;
  --gold: #b8955a;
  --gold-ink: #87672c;
  --gold-soft: #e8dcc2;
  --ink: #1f2a24;
  --muted: #5f6b64;
  --line: #e6dfcd;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Noto Serif", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 14px;
  --dock-h: 72px;
  --lyric-scale: 1;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 80px; }
body {
  margin: 0;
  background: var(--ivory);
  color: var(--ink);
  font: 16px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--dock-h) + env(safe-area-inset-bottom) + 16px);
}
img { max-width: 100%; display: block; }
a { color: var(--green-2); text-underline-offset: 2px; text-decoration-thickness: 1px; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; margin: -1px; }
.skip { position: absolute; left: 12px; top: -60px; background: var(--paper); padding: 8px 12px; border-radius: 8px; z-index: 50; }
.skip:focus { top: 12px; }
.wrap { max-width: 720px; margin: 0 auto; padding: 0 20px; }
[hidden] { display: none !important; }

/* ---------- Masthead ---------- */
.masthead {
  background: var(--green);
  color: var(--ivory);
  padding: calc(40px + env(safe-area-inset-top)) 0 0;
}
.eyebrow {
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--gold-soft);
}
.star { color: var(--gold); margin-right: 4px; }
.masthead h1 {
  font: 400 clamp(38px, 10vw, 56px)/1.04 var(--serif);
  letter-spacing: -.01em;
  margin: 0 0 14px;
}
.lede { margin: 0 0 24px; color: #dfe6df; font-size: 15px; max-width: 34em; }
.masthead-actions { margin-bottom: 28px; }
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 44px; padding: 10px 18px;
  border-radius: 999px; border: 1px solid transparent;
  font-size: 15px; font-weight: 500; text-decoration: none;
}
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.btn-ivory { background: var(--ivory); color: var(--green-ink); }
.btn-ivory:hover { background: #fff; }
.btn-green { background: var(--green); color: var(--ivory); }
.btn-green:hover { background: var(--green-2); }
.btn-sub { font-weight: 400; font-size: 13px; color: var(--muted); }

.modes { display: flex; gap: 28px; border-top: 1px solid rgba(250, 246, 236, .14); }
.modes button {
  background: none; border: 0; padding: 14px 0 12px;
  color: #b9c6bd; font-size: 15px; letter-spacing: .02em;
  border-bottom: 2px solid transparent;
}
.modes button[aria-selected="true"] { color: var(--ivory); border-bottom-color: var(--gold); }

/* ---------- Sticky toolbar ---------- */
.toolbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--ivory);
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}
.voices { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--ivory-2); border-radius: 999px; padding: 3px; }
.voices label { position: relative; display: block; }
.voices input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.voices span {
  display: flex; align-items: center; justify-content: center;
  min-height: 38px; padding: 0 4px; border-radius: 999px;
  font-size: 13.5px; color: var(--muted); white-space: nowrap;
  transition: background .15s, color .15s;
}
.voices input:checked + span { background: var(--green); color: var(--ivory); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.voices input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 1px; }

.lyric-tools { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.jump select {
  appearance: none; -webkit-appearance: none;
  background: var(--ivory-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%235f6b64' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right 14px center / 11px;
  border: 0; border-radius: 999px; min-height: 40px; padding: 0 36px 0 16px; font-size: 15px; max-width: 62vw;
}
.textsize { display: flex; gap: 6px; }
.textsize button { width: 44px; height: 40px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); font-family: var(--serif); font-size: 17px; }
.textsize .small { font-size: 12px; margin-left: 1px; }

/* ---------- Carol list ---------- */
.voice-note { margin: 14px 2px 10px; font-size: 13px; color: var(--muted); min-height: 1.5em; }
.voice-note a { color: inherit; }
.carols { list-style: none; margin: 0; padding: 0; }
.carol { border-bottom: 1px solid var(--line); }
.carol:first-child { border-top: 1px solid var(--line); }
.carol summary {
  list-style: none; display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 12px;
  padding: 16px 2px; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.carol summary::-webkit-details-marker { display: none; }
.num { font: 400 22px/1 var(--serif); color: var(--gold-ink); text-align: center; font-variant-numeric: oldstyle-nums; }
.num.extra { font-size: 13px; letter-spacing: .12em; text-transform: uppercase; }
.ttl { min-width: 0; }
.name { display: block; font: 400 19px/1.25 var(--serif); color: var(--ink); }
.meta { display: block; font-size: 13px; color: var(--muted); margin-top: 3px; }
.meta .eq { display: none; }
.carol.is-playing .meta .eq { display: inline-flex; }
.chev { width: 20px; height: 20px; stroke: var(--muted); fill: none; stroke-width: 1.6; transition: transform .2s; }
.carol[open] .chev { transform: rotate(180deg); }
.eq { gap: 2px; align-items: flex-end; height: 11px; margin-right: 6px; vertical-align: -1px; }
.eq i { width: 2px; background: var(--gold); border-radius: 1px; animation: eq 1s ease-in-out infinite; }
.eq i:nth-child(2) { animation-delay: -.35s; }
.eq i:nth-child(3) { animation-delay: -.7s; }
.is-paused .eq i { animation-play-state: paused; }
@keyframes eq { 0%, 100% { height: 3px; } 50% { height: 11px; } }

.carol-body { padding: 0 0 26px; }
.carol-notes { margin: -4px 0 16px; font-size: 14px; color: var(--muted); }
.carol-notes p { margin: 0 0 4px; }

/* Player */
.player {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 14px 12px; margin-bottom: 18px;
}
.player-top { display: grid; grid-template-columns: 52px 1fr; gap: 12px; align-items: center; }
.pp {
  width: 52px; height: 52px; border-radius: 50%; border: 0;
  background: var(--green); color: var(--ivory);
  display: grid; place-items: center;
}
.pp:active { transform: scale(.96); }
.pp svg, .icon-btn svg { width: 24px; height: 24px; }
.fill { fill: currentColor; }
.i-pause { display: none; }
.is-on .i-play { display: none; }
.is-on .i-pause { display: block; }
.pl-label { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 14px; margin-bottom: 6px; }
.pl-voice { font-weight: 600; color: var(--green-ink); }
.pl-time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }

input[type="range"].seek {
  -webkit-appearance: none; appearance: none; width: 100%; height: 28px; background: transparent; margin: 0; display: block;
  --pct: 0%;
}
.seek::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--gold) var(--pct), var(--line) var(--pct)); }
.seek::-moz-range-track { height: 4px; border-radius: 2px; background: var(--line); }
.seek::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--gold); }
.seek::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--green); border: 3px solid var(--paper); box-shadow: 0 0 0 1px var(--line); margin-top: -7px; }
.seek::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--green); border: 3px solid var(--paper); box-shadow: 0 0 0 1px var(--line); }

.pl-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.chip {
  min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--ivory);
  font-size: 13.5px; color: var(--ink); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.chip svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.chip[aria-pressed="true"] { background: var(--green); color: var(--ivory); border-color: var(--green); }
.speed { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--ivory); }
.speed button { border: 0; background: none; min-height: 34px; padding: 0 10px; font-size: 13.5px; font-variant-numeric: tabular-nums; color: var(--muted); }
.speed button[aria-pressed="true"] { background: var(--green); color: var(--ivory); }
.speed-label { font-size: 12px; color: var(--muted); margin-left: auto; }
.player-error { margin: 8px 0 0; font-size: 13px; color: #9a3b2b; }

/* Jingle Bells callout */
.callout {
  background: var(--paper); border: 1px solid var(--gold-soft); border-left: 3px solid var(--gold);
  border-radius: var(--radius); padding: 16px; margin-bottom: 18px;
}
.callout h3 { margin: 0 0 6px; font: 400 18px/1.3 var(--serif); color: var(--green-ink); }
.callout p { margin: 0 0 12px; font-size: 14.5px; color: var(--muted); }
.callout .btn { font-size: 14.5px; }
.callout-links { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-outline { border-color: var(--line); background: var(--ivory); color: var(--green-ink); }
.callout .btn svg { width: 16px; height: 16px; }

/* Score */
.score { margin: 0; }
.score-label { display: flex; flex-direction: column; gap: 4px; margin: 0 0 8px; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--gold-ink); }
.score-label .fallback { letter-spacing: 0; text-transform: none; font-size: 13px; color: #8a4b2c; }
.score-open {
  display: block; width: 100%; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  background: #fff; position: relative; margin-bottom: 10px;
}
.score-open img { width: 100%; height: auto; background: #fff; }
.score-open .enlarge {
  position: absolute; right: 10px; bottom: 10px; background: rgba(29, 58, 44, .9); color: var(--ivory);
  font-size: 13px; padding: 7px 12px; border-radius: 999px; display: inline-flex; gap: 6px; align-items: center;
}
.score-open .enlarge svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.score-links { font-size: 13px; color: var(--muted); margin: 2px 0 0; }

/* ---------- Lyrics mode ---------- */
.lyrics-intro { margin: 18px 2px 8px; font-size: 13.5px; color: var(--muted); }
.lyric-song { padding: 28px 0 30px; border-bottom: 1px solid var(--line); }
.lyric-song header { display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; align-items: center; margin-bottom: 16px; }
.lyric-song header .num { align-self: baseline; padding-top: 4px; }
.lyric-pp { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--paper); color: var(--green); display: grid; place-items: center; }
.lyric-pp svg { width: 20px; height: 20px; }
.lyric-pp.is-on { background: var(--green); border-color: var(--green); color: var(--ivory); }
.lyric-song h2 { margin: 0; font: 400 calc(24px * var(--lyric-scale))/1.2 var(--serif); }
.lyric-song .meta { margin-top: 4px; }
.lyric-body { padding-left: 46px; font: 400 calc(18px * var(--lyric-scale))/1.6 var(--serif); }
.stanza { margin: 0 0 1.1em; position: relative; }
.stanza .vn { position: absolute; left: -1.9em; width: 1.4em; text-align: right; color: var(--gold-ink); font-size: .8em; top: .15em; }
.stanza span { display: block; }
.stanza.refrain { font-style: italic; padding-left: 1.1em; border-left: 2px solid var(--gold-soft); }
.stanza.refrain-mark { font-style: italic; color: var(--muted); font-size: .85em; padding-left: 1.3em; }
.stanza .again { color: var(--muted); font-size: .8em; font-style: italic; }
.lyric-song .song-note { font-size: 13.5px; color: var(--muted); margin: 0 0 14px 46px; }
.lyric-song .song-note a { color: var(--green-2); }

/* ---------- Footer ---------- */
.colophon { margin-top: 44px; padding: 34px 0 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14.5px; }
.colophon h2 { font: 400 19px/1.3 var(--serif); color: var(--ink); margin: 26px 0 8px; }
.colophon h2:first-child { margin-top: 0; }
.colophon p { margin: 0 0 10px; }
.colophon strong { color: var(--ink); font-weight: 600; }
.fine { font-size: 13px; }
.signoff { margin-top: 28px !important; font-family: var(--serif); font-style: italic; color: var(--gold-ink); }
.nojs { padding: 16px; background: var(--paper); border-radius: var(--radius); }

/* ---------- Dock (mini player) ---------- */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--green); color: var(--ivory);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -6px 24px rgba(20, 35, 28, .18);
}
.dock-idle { max-width: 720px; margin: 0 auto; padding: 12px 20px; }
.dock-playall {
  width: 100%; min-height: 48px; border: 1px solid rgba(250, 246, 236, .25); background: transparent; color: var(--ivory);
  border-radius: 999px; display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 15.5px;
}
.dock-playall svg { width: 20px; height: 20px; color: var(--gold); }
.dock-voice { color: var(--gold-soft); }
.dock-voice::before { content: "· "; }
.dock-active { position: relative; }
/* Scrubber: 3px bar along the top edge of the dock, with a 28px touch area */
.dock-seek { position: absolute; left: 0; right: 0; top: -13px; height: 28px; touch-action: none; cursor: pointer; z-index: 1; -webkit-tap-highlight-color: transparent; }
.dock-track { position: absolute; left: 0; right: 0; top: 12px; height: 4px; background: rgba(250, 246, 236, .18); transition: height .12s, top .12s; }
.dock-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--gold); }
.dock-thumb { position: absolute; top: 50%; left: 0; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 3px rgba(29, 58, 44, .9); transition: transform .12s; }
.dock-seek.dragging .dock-track, .dock-seek:hover .dock-track { top: 11px; height: 6px; }
.dock-seek.dragging .dock-thumb { transform: scale(1.35); }
.dock-bubble {
  position: absolute; bottom: 26px; left: 0; transform: translateX(-50%);
  background: var(--ink); color: var(--ivory); font-size: 13px; font-variant-numeric: tabular-nums;
  padding: 4px 9px; border-radius: 999px; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .12s;
}
.dock-seek.dragging .dock-bubble { opacity: 1; }
.dock-seek:focus-visible { outline: none; }
.dock-seek:focus-visible .dock-thumb { box-shadow: 0 0 0 3px var(--ivory); }
.dock-row { padding-top: 14px !important; }
.dock-row { max-width: 720px; margin: 0 auto; padding: 9px 12px 9px 20px; display: flex; align-items: center; gap: 10px; }
.dock-info { flex: 1; min-width: 0; }
.dock-title { margin: 0; font: 400 16.5px/1.25 var(--serif); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dock-sub { margin: 2px 0 0; font-size: 12.5px; color: #c4d0c7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dock-cont { background: none; border: 0; padding: 4px 0; color: inherit; font-size: inherit; text-decoration: underline; text-decoration-color: rgba(250,246,236,.35); text-underline-offset: 3px; }
.dock-cont[aria-pressed="true"] .onoff { color: var(--gold-soft); font-weight: 600; }
.dock-buttons { display: flex; align-items: center; gap: 2px; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 0; background: none; color: var(--ivory); display: grid; place-items: center; }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn-lg { width: 50px; height: 50px; background: var(--ivory); color: var(--green); }
.icon-btn-lg svg { width: 24px; height: 24px; }

/* ---------- Score viewer ---------- */
.viewer { position: fixed; inset: 0; z-index: 60; background: #f4f1ea; display: flex; flex-direction: column; }
.viewer-bar {
  display: flex; align-items: center; gap: 10px; padding: calc(8px + env(safe-area-inset-top)) 12px 8px 16px;
  background: var(--green); color: var(--ivory);
}
.viewer-title { flex: 1; min-width: 0; margin: 0; font: 400 16px/1.2 var(--serif); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-zoom { display: flex; border: 1px solid rgba(250,246,236,.3); border-radius: 999px; overflow: hidden; }
.viewer-zoom button { background: none; border: 0; color: var(--ivory); min-width: 40px; height: 36px; font-size: 16px; }
.viewer-zoom button[data-zoom="fit"] { font-size: 13px; border-left: 1px solid rgba(250,246,236,.2); border-right: 1px solid rgba(250,246,236,.2); }
.viewer-close { background: var(--ivory); color: var(--green); border: 0; border-radius: 999px; height: 36px; padding: 0 14px; font-size: 14px; font-weight: 600; }
.viewer-scroll { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding-bottom: env(safe-area-inset-bottom); }
.viewer-pages { margin: 0 auto; padding: 10px; width: 100%; max-width: 980px; }
.viewer-pages.zoomed { max-width: none; }
.viewer-pages img { width: 100%; height: auto; background: #fff; margin: 0 auto 10px; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
body.viewer-open { overflow: hidden; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--dock-h) + env(safe-area-inset-bottom) + 16px); transform: translate(-50%, 20px);
  background: var(--ink); color: var(--ivory); padding: 10px 16px; border-radius: 999px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 70; max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 640px) {
  .masthead { padding-top: 64px; }
  .voices span { font-size: 14.5px; }
  .carol summary { padding: 18px 4px; }
  .name { font-size: 21px; }
  .player { padding: 16px 18px 14px; }
}
@media (max-width: 360px) {
  .wrap { padding: 0 14px; }
  .voices span { font-size: 12.5px; }
  .speed button { padding: 0 8px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
@media print {
  .toolbar, .dock, .masthead-actions, .modes, .player, .callout { display: none !important; }
}
