/* Absent Pianist — colors taken from the logo */
:root {
  --paper: #FDF7F0;       /* logo background */
  --ivory: #F6E2B1;       /* the piano's ivory keys: selected choices */
  --rule: #E7DAC6;
  --teal: #184E4D;        /* wordmark */
  --lacquer: #0E3433;     /* deep piano finish: text */
  --brass: #ED891B;       /* stars and bench: the Play button */
  --gold: #A9771A;        /* tagline gold, darkened for legible small text */
  --muted: #5B6B68;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --pad: 18px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
html { touch-action: manipulation; }   /* no double-tap zoom on phones */
body {
  background: var(--paper);
  color: var(--lacquer);
  font: 17px/1.45 var(--sans);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--brass); outline-offset: 2px; }

.screen { display: none; min-height: 100dvh; max-width: 640px; margin: 0 auto; }
.screen.active { display: flex; flex-direction: column; }

/* ---------- 1. Splash ---------- */
#splash { align-items: center; justify-content: center; padding: var(--pad); gap: 28px; text-align: center; }
.splash-art { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.splash-piano { width: min(78vw, 360px); height: auto; }
.splash-word { width: min(84vw, 400px); height: auto; display: block; }
.splash-title { margin: 0; line-height: 0; }
.splash-library { margin-top: -14px; font-size: 15px; color: var(--teal); text-underline-offset: 3px; }
.splash-also { margin: -14px 0 0; max-width: 30em; font: italic 16px/1.5 var(--serif); color: var(--teal); }
.splash-about { max-width: 30em; margin: 0; font: 16px/1.5 var(--serif); color: var(--muted); }
.begin {
  border: 0; border-radius: 999px; padding: 15px 34px; min-height: 52px;
  background: var(--teal); color: var(--paper); font-weight: 650; font-size: 18px; cursor: pointer;
}
@media (prefers-reduced-motion: no-preference) {
  .splash-piano { animation: rise .9s ease-out both; }
  .splash-word { animation: rise .9s .25s ease-out both; }
  .begin { animation: rise .9s .5s ease-out both; }
  .splash-about, .splash-library, .splash-also { animation: rise .9s .75s ease-out both; }
  @keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
}

/* ---------- 2. Hymn index ---------- */
.list-head {
  position: sticky; top: 0; z-index: 2; background: var(--paper);
  padding: calc(env(safe-area-inset-top) + 14px) var(--pad) 12px; border-bottom: 1px solid var(--rule);
}
.list-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.list-title { display: flex; align-items: center; gap: 2px; margin-left: -12px; }   /* chevron sits in the left gutter so "Hymns" keeps its place */
.list-title h1 { margin: 0; }
h1 { font: 600 30px/1.1 var(--serif); margin: 0 0 12px; color: var(--teal); }
.text-button { background: none; border: 0; padding: 10px 4px; color: var(--teal); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.search input {
  width: 100%; font: 17px var(--sans); padding: 12px 14px; border-radius: 12px;
  border: 1.5px solid var(--rule); background: #fff; color: var(--lacquer);
}
.search input:focus { border-color: var(--teal); outline: none; }

/* A hymnal's index: title, dotted leader, number */
.index { list-style: none; margin: 0; padding: 4px 0 calc(env(safe-area-inset-bottom) + 24px); }
.index li a {
  display: flex; align-items: baseline; gap: 8px; padding: 13px var(--pad); min-height: 52px;
  color: inherit; text-decoration: none; font: 19px/1.3 var(--serif);
}
.index li + li a { border-top: 1px solid var(--rule); }
.index li a:active { background: var(--ivory); }
.index .leader { flex: 1; min-width: 16px; }   /* space that pushes the hymn number to the right */
.index .badge { flex: none; align-self: center; margin-left: 8px; padding: 1px 8px; border-radius: 9px; background: var(--brass); color: var(--lacquer); font: 600 12px/1.6 var(--sans); }
.index .num { color: var(--gold); font-variant-numeric: tabular-nums oldstyle-nums; font-size: 18px; }
.empty { padding: 24px var(--pad); color: var(--muted); }

/* ---------- 3. Options ---------- */
.hymn-head {
  position: sticky; top: 0; z-index: 2; background: var(--paper);
  display: flex; align-items: flex-start; gap: 4px;
  padding: calc(env(safe-area-inset-top) + 4px) var(--pad) 6px 6px; border-bottom: 1px solid var(--rule);
}
.back { background: none; border: 0; width: 44px; height: 44px; display: grid; place-items: center; color: var(--teal); cursor: pointer; flex: none; }
.hymn-heading h2 { font: 600 21px/1.15 var(--serif); margin: 8px 0 1px; color: var(--teal); }
.hymn-heading p { margin: 0; color: var(--gold); font-size: 14px; }

.hymn-info { padding: 14px var(--pad) 10px; border-bottom: 1px solid var(--rule); margin-bottom: 4px; }
.hymn-info .credits { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; padding: 14px 16px; background: #F6EBDD; border-radius: 12px; font-size: 15px; line-height: 1.4; }
.hymn-info .credits dt { color: var(--gold); font-weight: 600; }
.hymn-info .credits dd { margin: 0; }
.hymn-info .about { margin: 12px 0 0; font-size: 16px; line-height: 1.5; }
.options { flex: 1; padding: 0 var(--pad) 6px; }     /* phones: the play bar sits at the bottom, under your thumb */
@media (min-width: 700px) {
  .options { flex: none; }                              /* larger screens: the play bar follows right after the options */
  .playbar { border-radius: 0 0 14px 14px; }
}
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset:disabled { opacity: .55; }

/* One compact row per setting: label on the left, control on the right */
.row {
  display: grid; grid-template-columns: 102px 1fr 104px; align-items: center; gap: 8px;
  min-height: 46px; padding: 3px 0; border-bottom: 1px solid var(--rule);
}
.row[hidden] { display: none; }
.row-label { font-weight: 600; font-size: 15px; color: var(--teal); }
.row > select, .row > .chips, .row > .stepper { grid-column: 2 / 4; }
.row > .stepper { justify-self: start; }

select {
  font: 16px var(--sans); color: var(--lacquer); width: 100%;
  padding: 8px 34px 8px 12px; min-height: 40px; border-radius: 10px;
  border: 1.5px solid var(--rule); background: #fff; -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23184E4D' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
select:focus { border-color: var(--teal); outline: none; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips label { position: relative; }
.chips input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chips span {
  display: inline-flex; align-items: center; min-height: 38px; padding: 6px 13px;
  border: 1.5px solid var(--rule); border-radius: 19px; background: #fff; font-size: 15px;
}
.chips input:checked + span { background: var(--ivory); border-color: var(--teal); color: var(--teal); font-weight: 650; }
.chips input:focus-visible + span { outline: 3px solid var(--brass); outline-offset: 2px; }

.stepper { display: inline-flex; align-items: center; border: 1.5px solid var(--rule); border-radius: 20px; background: #fff; }
.stepper button { width: 44px; height: 38px; border: 0; background: none; font-size: 22px; color: var(--teal); cursor: pointer; }
.stepper button:disabled { opacity: .3; }
.stepper output { width: 64px; text-align: center; font-weight: 650; font-size: 15px; }

.row.switch { grid-template-columns: 1fr auto; cursor: pointer; }
.switch input { appearance: none; -webkit-appearance: none; flex: none; width: 46px; height: 28px; border-radius: 14px; background: #D9CFC0; position: relative; margin: 0; cursor: pointer; transition: background .15s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(14,52,51,.3); transition: transform .15s; }
.switch input:checked { background: var(--teal); }
.switch input:checked::after { transform: translateX(18px); }

.row output { text-align: right; font-variant-numeric: tabular-nums; font-size: 14px; white-space: nowrap; overflow: hidden; }
.row.off { opacity: .4; }
input[type=range] { width: 100%; accent-color: var(--teal); height: 28px; margin: 0; }

.saved { display: flex; align-items: center; gap: 0 18px; padding: 0; font-size: 14px; min-height: 36px; }
.saved .text-button { padding: 6px 0; font-size: 14px; white-space: nowrap; flex: none; }
.saved-note { margin: 0; min-height: 20px; font-size: 13px; line-height: 20px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.saved-note b { color: var(--teal); font-weight: 650; }

/* ---------- Play bar ---------- */
.playbar {
  position: sticky; bottom: 0; background: var(--lacquer); color: var(--paper);
  padding: 0 var(--pad) calc(env(safe-area-inset-bottom) + 10px);
}
.progress { height: 4px; margin: 0 calc(-1 * var(--pad)); background: rgba(253,247,240,.15); }
.progress div { height: 100%; width: 0; background: var(--brass); transition: width .2s linear; }
.playbar-row { display: flex; align-items: center; gap: 12px; padding-top: 10px; }
.play {
  flex: 1; min-height: 50px; border: 0; border-radius: 14px; background: var(--brass); color: var(--lacquer);
  font-weight: 750; font-size: 20px; cursor: pointer;
}
.play.small { flex: none; min-height: 44px; padding: 0 26px; font-size: 17px; }
.secondary { flex: 1; min-height: 50px; border-radius: 14px; border: 1.5px solid rgba(253,247,240,.5); background: none; color: var(--paper); font-weight: 650; font-size: 18px; cursor: pointer; }
.play[hidden], .secondary[hidden] { display: none; }
.time { font-variant-numeric: tabular-nums; font-size: 15px; color: rgba(253,247,240,.8); width: 88px; text-align: right; white-space: nowrap; }
.time:empty { display: none; }
/* Messages float just above the play bar, so they never push the screen around */
.playbar { position: sticky; }
.status { position: absolute; left: 0; right: 0; bottom: 100%; margin: 0; padding: 8px var(--pad); font-size: 14px; background: var(--teal); color: var(--paper); }
.status:empty { display: none; }

/* ---------- Menu and its pages ---------- */
dialog.menu { padding: 8px 0 4px; width: min(80vw, 300px); }
.menu nav { display: flex; flex-direction: column; }
.menu nav button { background: none; border: 0; text-align: left; padding: 13px 22px; min-height: 48px; font: 18px/1.2 var(--serif); color: var(--teal); cursor: pointer; }
.menu nav button:active { background: var(--ivory); }
.menu nav:focus { outline: none; }
.menu form { padding: 0 22px; margin-top: 0; }
dialog { max-height: 86dvh; overflow-y: auto; }
dialog b { color: var(--lacquer); }
.steps { padding-left: 20px; margin: 0 0 4px; font-size: 15px; color: var(--muted); }
.steps li { margin-bottom: 8px; }
.tiers { list-style: none; padding: 0; margin: 0; }
.tiers li { display: grid; gap: 2px; padding: 10px 0; border-top: 1px solid var(--rule); font-size: 15px; }
.tiers li span { color: var(--muted); }
#settings .row { grid-template-columns: 1fr; gap: 6px; padding: 8px 0; }
#settings .row > .chips { grid-column: auto; }
dialog h2:focus { outline: none; }
#settings .row.switch { grid-template-columns: 1fr auto; }
.copyright { font-size: 13px !important; border-top: 1px solid var(--rule); padding-top: 10px; }
.hint { font-size: 13px !important; margin: 6px 0 2px; }
#settings .row .hint { margin: 0; }

/* Demo video */
dialog.video { width: min(94vw, 760px); max-width: none; padding: 16px; }
.video-frame { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: 10px; overflow: hidden; }
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
dialog.video form { display: flex; justify-content: space-between; align-items: center; }

/* Short messages that float near the bottom of any screen */
.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 24px); transform: translateX(-50%); z-index: 10;
  margin: 0; max-width: min(92vw, 440px); padding: 10px 16px; border-radius: 12px; background: var(--teal); color: var(--paper); font-size: 14px; box-shadow: 0 4px 14px rgba(14,52,51,.25); }
.toast[hidden] { display: none; }

/* ---------- Dialogs ---------- */
dialog { border: 0; border-radius: 18px; padding: 22px; max-width: min(92vw, 440px); background: var(--paper); color: var(--lacquer); }
dialog::backdrop { background: rgba(14,52,51,.45); }
dialog h2 { font: 600 22px var(--serif); color: var(--teal); margin: 0 0 8px; }
dialog p { font-size: 15px; color: var(--muted); }
dialog form { text-align: right; margin-top: 8px; }

/* ---------- Registration ---------- */
dialog.register form { text-align: left; }
.field { display: block; margin: 0 0 12px; }
.field span { display: block; font-size: 14px; font-weight: 600; color: var(--teal); margin-bottom: 4px; }
.field i { font-weight: 400; color: var(--muted); }
.field input, .field textarea {
  width: 100%; font: 17px var(--sans); padding: 11px 12px; border-radius: 10px;
  border: 1.5px solid var(--rule); background: #fff; color: var(--lacquer); resize: vertical;
}
.field input:focus, .field textarea:focus { border-color: var(--teal); outline: none; }
.reg-error { margin: 0 0 8px; color: #A23B2A; font-size: 14px; }
.reg-buttons { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 4px; }

/* How To: speaker links */
dialog p a { color: var(--teal); font-weight: 600; text-underline-offset: 3px; }
dialog p.affiliate { font-size: 13px; font-style: italic; }
dialog p.howto-heading { margin: 22px 0 -6px; font-size: 16px; }

#optHymnal { grid-column: 1 / -1; margin-top: 4px; }
