:root {
  --bg: #12201A;
  --surface: #182A21;
  --raised: #24382E;
  --line: #24382E;
  --border: #3A5146;
  --text: #F6EFE2;
  --soft: #C9D2CA;
  --muted: #B9C6BC;
  --faint: #7F968A;
  --gold: #E2B75A;
  --gold-hover: #F0CC7A;
  --on-gold: #1A140A;
  --danger: #F0A08F;
  --serif: Fraunces, Georgia, serif;
  --lyric: Literata, Georgia, serif;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--gold); }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
/* Stops iOS Safari treating two quick taps as a double-tap zoom. */
html, button, a, input, textarea { touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.wrap { max-width: 640px; margin: 0 auto; }

/* Shared bits */
.top {
  display: flex; align-items: center; gap: 8px;
  padding: max(12px, env(safe-area-inset-top)) 12px 8px;
}
.top p { margin: 0; font-size: 15px; color: var(--muted); }
.icon-btn {
  width: 44px; height: 44px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 22px; border: 0; background: transparent; color: var(--text);
  text-decoration: none; padding: 0;
}
.icon-btn:hover { background: var(--raised); }
.page-title { margin: 0; font-family: var(--serif); font-weight: 600; font-size: 34px; line-height: 1.1; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 24px;
  font-size: 16px; font-weight: 600; text-decoration: none; border: 1px solid transparent;
}
.btn-gold { background: var(--gold); color: var(--on-gold); }
.btn-gold:hover { background: var(--gold-hover); }
.btn-line { background: transparent; color: var(--text); border-color: var(--border); font-weight: 500; }
.btn-line:hover { background: var(--raised); }
.btn-big { min-height: 56px; border-radius: 28px; font-size: 18px; width: 100%; }
.btn-danger { background: transparent; color: var(--danger); border-color: #5a3a33; font-weight: 500; }
.loading, .empty { padding: 48px 24px; text-align: center; color: var(--muted); line-height: 1.5; }

/* Home */
.home { min-height: 100dvh; display: flex; flex-direction: column; }
.home-photo { position: relative; height: 62dvh; min-height: 340px; max-height: 720px; background: #1D3128; }
.home-photo img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 35%; display: block; }
.home-photo::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 45%;
  background: linear-gradient(to bottom, rgba(18,32,26,0), rgba(18,32,26,0.85) 60%, var(--bg));
}
.home-text {
  position: relative; flex: 1; margin-top: -96px;
  display: flex; flex-direction: column; gap: 12px;
  padding: 0 24px max(40px, env(safe-area-inset-bottom));
}
.eyebrow { margin: 0; font-size: 13px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold); font-weight: 600; }
.home h1 { margin: 0; font-family: var(--serif); font-weight: 600; font-size: clamp(40px, 11vw, 56px); line-height: 1.05; }
.home .lede { margin: 0 0 16px; font-size: 16px; line-height: 1.5; color: var(--soft); }
.home .spacer { flex: 1; }

/* Menu */
.menu-head { padding: 8px 24px 16px; }
.carol-list { list-style: none; margin: 0; padding: 0 12px; }
.carol-list a {
  display: flex; align-items: center; gap: 16px; min-height: 60px; padding: 8px 12px;
  border-bottom: 1px solid var(--line); text-decoration: none; color: var(--text);
}
.carol-list a:hover { background: var(--surface); }
.carol-list .num { width: 28px; font-size: 15px; font-weight: 600; color: var(--gold); font-variant-numeric: tabular-nums; }
.carol-list .name { flex: 1; font-family: var(--serif); font-size: 21px; line-height: 1.25; }
.manage-link {
  display: flex; justify-content: center; padding: 20px 0 max(24px, env(safe-area-inset-bottom));
}
.manage-link a {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px;
  color: var(--muted); font-size: 15px; text-decoration: none;
}
.manage-link a:hover { color: var(--text); }

/* Player */
.player { height: 100dvh; display: flex; flex-direction: column; }
.player .top { border-bottom: 1px solid var(--line); padding-right: 16px; }
.player h1 { flex: 1; margin: 0; font-family: var(--serif); font-weight: 600; font-size: 20px; line-height: 1.2; }
.lyrics-box { position: relative; flex: 1; min-height: 0; }
.lyrics {
  position: absolute; inset: 0; overflow-y: auto; overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
  cursor: grab; user-select: none; -webkit-user-select: none;
}
.lyrics::-webkit-scrollbar { display: none; }
.lyrics.grabbing { cursor: grabbing; }
.lyrics-inner {
  max-width: 720px; margin: 0 auto;
  padding: 40px 20px 70vh; font-family: var(--lyric); line-height: 1.45;
}
.lyrics-inner p { margin: 0 0 1.4em; }
/* A long line that wraps is indented, so each sung line still reads as one line. */
.lyrics-inner .line { display: block; padding-left: 1em; text-indent: -1em; margin-bottom: 0.4em; }
.fade-top, .fade-bottom { position: absolute; left: 0; right: 0; pointer-events: none; }
.fade-top { top: 0; height: 48px; background: linear-gradient(var(--bg), rgba(18,32,26,0)); }
.fade-bottom { bottom: 0; height: 72px; background: linear-gradient(rgba(18,32,26,0), var(--bg)); }
.hint {
  position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 22px;
  background: #2A4236; font-size: 14px; font-weight: 500; white-space: nowrap; pointer-events: none;
  transition: opacity 0.3s;
}
.hint[hidden] { display: flex; opacity: 0; }
.progress { height: 3px; background: var(--line); }
.progress div { height: 3px; width: 0; background: var(--gold); }
.controls {
  background: var(--surface);
  padding: 14px 16px max(24px, env(safe-area-inset-bottom));
}
.controls-inner { max-width: 480px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; }
.control-group { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.control-group .row { display: flex; align-items: center; gap: 6px; }
.control-group .label { font-size: 12px; color: var(--muted); }
.round {
  width: 44px; height: 44px; border-radius: 22px; border: 1px solid var(--border);
  background: transparent; display: inline-flex; align-items: center; justify-content: center; padding: 0;
}
.round:hover { background: var(--raised); }
.round:disabled { opacity: 0.4; cursor: default; }
.speed-value { width: 46px; text-align: center; font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.play {
  width: 64px; height: 64px; border-radius: 32px; border: 0;
  background: var(--gold); color: var(--on-gold);
  display: inline-flex; align-items: center; justify-content: center; padding: 0;
}
.play:hover { background: var(--gold-hover); }
.size-a { font-family: var(--lyric); }

/* Admin */
.admin-head { padding: 4px 24px 12px; display: flex; flex-direction: column; gap: 6px; }
.admin-head p { margin: 0; font-size: 14px; color: var(--muted); line-height: 1.45; }
.admin-actions { display: flex; gap: 10px; padding: 0 16px 14px; }
.admin-actions .btn-gold { flex: 1; }
.admin-list { list-style: none; margin: 0; padding: 0 12px max(24px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 4px; }
.admin-list li {
  display: flex; align-items: center; gap: 4px; min-height: 56px; padding: 0 4px;
  border-radius: 12px; background: var(--surface); border: 1px solid var(--surface);
}
.admin-list li.dragging {
  background: var(--raised); border-color: var(--gold);
  box-shadow: 0 8px 24px rgba(0,0,0,0.45); position: relative; z-index: 2;
}
.admin-list .title { flex: 1; font-family: var(--serif); font-size: 19px; line-height: 1.25; padding: 8px 0; }
.handle { touch-action: none; color: var(--faint); cursor: grab; }
.handle:active { cursor: grabbing; }
.tag {
  font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--on-gold); background: var(--gold); border-radius: 10px; padding: 3px 8px;
}
.edit-link { color: var(--muted); }
.admin-section { margin: 8px 16px 0; padding: 20px 0 max(32px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.admin-section h2 { margin: 0 0 12px; font-family: var(--serif); font-weight: 600; font-size: 22px; }
.inline-form { display: flex; gap: 10px; }
.inline-form input { flex: 1; min-width: 0; font-family: var(--sans); font-size: 18px; }

.form-page { min-height: 100dvh; display: flex; flex-direction: column; }
.form-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: max(12px, env(safe-area-inset-top)) 16px 8px 8px; border-bottom: 1px solid var(--line);
}
.form-top h1 { margin: 0; font-family: var(--serif); font-weight: 600; font-size: 20px; }
.text-btn {
  min-height: 44px; display: inline-flex; align-items: center; padding: 0 12px;
  color: var(--muted); font-size: 16px; text-decoration: none; background: none; border: 0;
}
.text-btn:hover { color: var(--text); }
.form { flex: 1; display: flex; flex-direction: column; gap: 20px; padding: 20px 20px max(24px, env(safe-area-inset-bottom)); }
.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font-size: 14px; font-weight: 600; color: var(--soft); }
.field .help { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.45; }
.field input, .field textarea {
  border-radius: 12px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); padding: 0 16px;
}
.field input { height: 52px; font-family: var(--serif); font-size: 20px; }
.field input[type="password"] { font-family: var(--sans); font-size: 18px; }
.field textarea {
  min-height: 46dvh; padding: 14px 16px; font-family: var(--lyric); font-size: 17px; line-height: 1.5; resize: vertical;
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--gold); }
.error { margin: 0; color: var(--danger); font-size: 15px; }
.form-buttons { display: flex; flex-direction: column; gap: 12px; }

.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #2A4236; color: var(--text); padding: 12px 18px; border-radius: 22px;
  font-size: 15px; box-shadow: 0 8px 24px rgba(0,0,0,0.4); z-index: 10;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
