/* ==========================================================================
   Praise for the Lord — Clothbound Burgundy & Warm Paper Theme (Stage 2 v3)
   Natural editorial/print utility aesthetic (no pill clutter or neon effects)
   ========================================================================== */

:root {
  --bg-paper: #FAF7F2;
  --bg-surface: #FFFFFF;
  --bg-subtle: #F3EEE6;
  --bg-supplement: #F5F1EB;

  --ink-primary: #1F1D1A;
  --ink-secondary: #5A544C;
  --ink-muted: #8A8277;

  --border-hairline: #E2DBD0;
  --border-strong: #CFC6B8;

  --accent: #7A1F2B;
  --accent-dark: #5C151F;
  --accent-tint: #F7ECEE;

  --supp-ink: #7A6340;
  --supp-border: #D9CBB3;
  --supp-bg: #F6F0E4;

  --font-serif: Georgia, "Palatino Linotype", "Book Antiqua", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --header-h: 50px;
  --nav-h: 56px;
  --radius-sm: 3px;
  --radius-md: 5px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-paper);
  color: var(--ink-primary);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: rgba(122, 31, 43, 0.12);
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

/* App Shell */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

/* Header */
.app-header {
  height: var(--header-h);
  flex-shrink: 0;
  background: var(--accent);
  color: #FAF7F2;
  border-bottom: 1px solid var(--accent-dark);
  padding: 0 14px;
  display: flex;
  align-items: center;
}

.header-inner {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
}

.brand-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.32rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-subtitle {
  font-size: 0.73rem;
  color: rgba(250, 247, 242, 0.82);
  font-variant-numeric: tabular-nums;
}

.btn-icon-text {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.14);
  color: #FFFFFF;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: var(--radius-sm);
  padding: 6px 11px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

.btn-icon-text:active {
  background: rgba(255, 255, 255, 0.24);
}

.hash-glyph {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 0.98rem;
}

/* Main Workspace */
.workspace {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  overflow: hidden;
}

.pane {
  display: none;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
  background: var(--bg-paper);
}

.pane.active-tab {
  display: flex;
}

/* Search & Compact Single-Row Filter Bar */
.search-controls {
  flex-shrink: 0;
  padding: 9px 12px 8px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-hairline);
}

.search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 11px;
  color: var(--ink-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 40px;
  padding: 7px 36px 7px 36px;
  font-family: var(--font-sans);
  font-size: 0.94rem;
  color: var(--ink-primary);
  background: var(--bg-paper);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  outline: none;
}

.search-input:focus {
  border-color: var(--accent);
  background: #FFFFFF;
}

.clear-btn {
  position: absolute;
  right: 6px;
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  color: var(--ink-secondary);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.filter-row {
  display: flex;
  align-items: stretch;
  gap: 6px;
  margin-top: 8px;
}

.topic-filter-group {
  flex: 1;
  display: grid;
  grid-template-columns: auto 1fr 1fr;
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-subtle);
}

.filter-tab {
  border: none;
  border-right: 1px solid var(--border-hairline);
  background: transparent;
  color: var(--ink-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 10px;
  cursor: pointer;
  white-space: nowrap;
}

.filter-tab:last-child {
  border-right: none;
}

.filter-tab.active {
  background: var(--accent);
  color: #FFFFFF;
}

/* Responsive short vs full labels for Invitation / Lord's Supper */
.lbl-full {
  display: none;
}

.lbl-short {
  display: inline;
}

/* Show full labels on wider single-column phones/tablets where list pane is >= 430px */
@media (min-width: 430px) and (max-width: 859px) {
  .lbl-short {
    display: none;
  }
  .lbl-full {
    display: inline;
  }
}

.scans-toggle-btn {
  flex-shrink: 0;
  border: 1px solid var(--border-strong);
  background: var(--bg-paper);
  color: var(--ink-secondary);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.scans-toggle-btn.active {
  background: var(--accent-tint);
  border-color: var(--accent);
  color: var(--accent-dark);
}

.results-summary {
  flex-shrink: 0;
  padding: 5px 14px;
  font-size: 0.77rem;
  color: var(--ink-muted);
  background: var(--bg-paper);
  border-bottom: 1px solid var(--border-hairline);
  font-variant-numeric: tabular-nums;
}

/* Hymn List */
.hymn-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  list-style: none;
  margin: 0;
  padding: 0;
}

.hymn-row {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 10px 14px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-hairline);
  cursor: pointer;
  text-align: left;
  width: 100%;
  border-left: 3px solid transparent;
}

.hymn-row:active {
  background: var(--bg-subtle);
}

.hymn-row.selected {
  background: var(--accent-tint);
  border-left-color: var(--accent);
}

.hymn-row.is-supplement {
  background: var(--bg-supplement);
}

.hymn-row.is-supplement.selected {
  background: #EFE4E5;
}

.hymn-num {
  font-family: var(--font-serif);
  font-size: 1.03rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
  padding-top: 1px;
}

.hymn-row.is-supplement .hymn-num {
  color: var(--supp-ink);
}

.hymn-info {
  min-width: 0;
}

.hymn-title-line {
  font-size: 0.96rem;
  font-weight: 600;
  color: var(--ink-primary);
  line-height: 1.3;
  word-wrap: break-word;
}

.hymn-row.is-supplement .hymn-title-line {
  color: #4A443C;
}

.hymn-alt {
  font-weight: 400;
  font-style: italic;
  color: var(--ink-secondary);
}

.hymn-sub-line {
  margin-top: 2px;
  font-size: 0.79rem;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hymn-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.key-tag {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink-secondary);
  background: var(--bg-subtle);
  border: 1px solid var(--border-hairline);
  border-radius: 2px;
  padding: 2px 6px;
  min-width: 28px;
  text-align: center;
  white-space: nowrap;
}

.supp-tag {
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--supp-ink);
  background: var(--supp-bg);
  border: 1px solid var(--supp-border);
  border-radius: 2px;
  padding: 1px 5px;
  white-space: nowrap;
}

.no-scan-dot {
  font-size: 0.68rem;
  color: var(--ink-muted);
}

/* Empty & Notice States */
.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--ink-secondary);
}

.empty-title {
  margin: 0 0 6px;
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink-primary);
}

.empty-subtitle {
  margin: 0;
  font-size: 0.88rem;
  color: var(--ink-muted);
}

.notice-banner {
  margin: 10px 12px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.83rem;
  line-height: 1.4;
}

.notice-error {
  background: #FDF2F2;
  border: 1px solid #E5B8BC;
  color: #6B1A22;
}

.notice-supplement {
  background: var(--supp-bg);
  border: 1px solid var(--supp-border);
  border-left: 3px solid var(--supp-ink);
  color: #56442A;
  margin: 0 0 10px;
}

.notice-title {
  margin: 0 0 4px;
  font-weight: 700;
}

.notice-body {
  margin: 0 0 10px;
}

/* Detail Pane (Mobile full overlay by default) */
.pane-detail {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--bg-paper);
  min-width: 0;
  overflow: hidden;
}

.pane-detail.mobile-open {
  display: flex;
}

.detail-empty {
  display: none;
}

.detail-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  min-width: 0;
  width: 100%;
}

.detail-header {
  height: 46px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-hairline);
  gap: 8px;
}

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 6px 6px 6px 0;
  cursor: pointer;
}

.detail-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-num {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.detail-key {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-secondary);
  background: var(--bg-subtle);
  border: 1px solid var(--border-hairline);
  border-radius: 2px;
  padding: 2px 7px;
}

.btn-text-link {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  padding: 6px 4px;
}

.detail-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 12px 16px;
}

.song-title-block {
  margin-bottom: 10px;
}

.song-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.24rem;
  font-weight: 700;
  line-height: 1.24;
  color: var(--ink-primary);
}

.song-alt-titles {
  margin: 2px 0 0;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.92rem;
  color: var(--ink-secondary);
}

.song-first-line {
  margin: 3px 0 0;
  font-size: 0.82rem;
  color: var(--ink-muted);
}

/* Sheet Music Viewer */
.sheet-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 14px;
}

.sheet-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 9px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-hairline);
  flex-wrap: wrap;
}

.sheet-toolbar-label {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-secondary);
}

.sheet-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.btn-tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--ink-primary);
  border-radius: 2px;
  height: 28px;
  min-width: 28px;
  padding: 0 8px;
  font-size: 0.79rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-tool:active {
  background: var(--bg-subtle);
}

.btn-fullscreen {
  border-color: var(--ink-secondary);
}

.btn-highres {
  border: 1px solid var(--accent);
  background: var(--bg-surface);
  color: var(--accent);
  border-radius: 2px;
  height: 28px;
  padding: 0 9px;
  font-size: 0.77rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-highres:disabled {
  opacity: 0.6;
  cursor: default;
}

.btn-highres.loaded {
  background: var(--accent-tint);
  color: var(--accent-dark);
}

/* Scrollable & Drag-to-Pan Sheet Viewport */
.sheet-viewport {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background: #FFFFFF;
  width: 100%;
  min-width: 0;
  min-height: 180px;
  max-height: 70dvh;
  position: relative;
}

.sheet-viewport.is-pannable,
.fs-viewport.is-pannable {
  cursor: grab;
}

.sheet-viewport.is-dragging,
.fs-viewport.is-dragging {
  cursor: grabbing;
  user-select: none;
  -webkit-user-select: none;
}

.sheet-pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px;
  gap: 10px;
  margin: 0 auto;
}

.sheet-page-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.sheet-page-img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid #ECE7DF;
  background: #FFFFFF;
  user-select: none;
  -webkit-user-drag: none;
}

.sheet-page-caption {
  margin-top: 4px;
  font-size: 0.74rem;
  color: var(--ink-muted);
}

.no-scan-fallback {
  padding: 26px 18px;
  text-align: center;
  background: var(--bg-paper);
}

.no-scan-title {
  margin: 0 0 6px;
  font-weight: 700;
  color: var(--ink-primary);
}

.no-scan-desc {
  margin: 0 0 14px;
  font-size: 0.85rem;
  color: var(--ink-secondary);
}

/* Metadata Section */
.meta-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.meta-group {
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
}

.meta-heading {
  margin: 0 0 6px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
}

.meta-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.meta-tag {
  font-size: 0.78rem;
  color: var(--ink-secondary);
  background: var(--bg-paper);
  border: 1px solid var(--border-hairline);
  border-radius: 2px;
  padding: 2px 7px;
}

/* Ultra-Condensed Single-Line Bottom Pitch Pipe Bar */
.pitch-bar {
  flex-shrink: 0;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-strong);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.manual-key-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border-hairline);
}

.manual-key-label {
  font-size: 0.75rem;
  color: var(--ink-secondary);
  font-weight: 600;
}

.manual-key-select {
  height: 26px;
  border: 1px solid var(--border-strong);
  border-radius: 2px;
  background: var(--bg-paper);
  color: var(--ink-primary);
  font-size: 0.8rem;
  padding: 0 6px;
}

.pitch-single-row {
  display: flex;
  align-items: stretch;
  gap: 6px;
  width: 100%;
}

.btn-pitch-hold {
  flex: 1 1 auto;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 8px;
  background: var(--accent);
  color: #FFFFFF;
  border: 1px solid var(--accent-dark);
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.btn-pitch-hold.playing {
  background: var(--accent-dark);
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.25);
}

.pitch-btn-key {
  font-family: var(--font-serif);
  font-size: 1.24rem;
  font-weight: 700;
  line-height: 1;
  color: #FFFFFF;
  letter-spacing: 0.01em;
}

.pitch-btn-sub {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1;
  padding-top: 2px;
  color: #EBD4D8;
}

.btn-pitch-arp {
  flex: 0 0 auto;
  height: 38px;
  padding: 0 9px;
  background: var(--bg-paper);
  color: var(--ink-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.btn-pitch-arp.playing {
  background: var(--accent-tint);
  border-color: var(--accent);
  color: var(--accent-dark);
}

.pitch-transpose-controls {
  flex: 0 0 auto;
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.btn-step {
  border: none;
  border-right: 1px solid var(--border-hairline);
  background: var(--bg-paper);
  color: var(--ink-secondary);
  font-size: 0.74rem;
  font-weight: 700;
  padding: 0 7px;
  height: 36px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}

.btn-step:last-child {
  border-right: none;
}

.btn-step.active {
  background: var(--accent);
  color: #FFFFFF;
}

@media (max-width: 380px) {
  .btn-step {
    padding: 0 5px;
    font-size: 0.71rem;
  }
  .btn-pitch-arp {
    padding: 0 7px;
    font-size: 0.74rem;
  }
  .btn-pitch-hold {
    padding: 0 6px;
    gap: 4px;
  }
  .pitch-btn-key {
    font-size: 1.12rem;
  }
  .pitch-btn-sub {
    font-size: 0.75rem;
  }
}

/* Fullscreen Sheet Music Overlay */
.fs-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: #FFFFFF;
  display: flex;
  flex-direction: column;
}

.fs-toolbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  background: var(--bg-paper);
  border-bottom: 1px solid var(--border-strong);
  flex-wrap: wrap;
}

.fs-title-wrap {
  display: flex;
  align-items: baseline;
  gap: 7px;
  min-width: 0;
  flex: 1 1 160px;
}

.fs-num {
  font-family: var(--font-serif);
  font-weight: 700;
  color: var(--accent);
  font-size: 0.98rem;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.fs-title {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--ink-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fs-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.btn-fs-pitch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 28px;
  padding: 0 9px;
  background: var(--accent);
  color: #FFFFFF;
  border: 1px solid var(--accent-dark);
  border-radius: 2px;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.btn-fs-pitch .pitch-btn-key {
  font-size: 0.96rem;
}

.btn-fs-pitch .pitch-btn-sub {
  font-size: 0.72rem;
  padding-top: 1px;
}

.btn-fs-pitch.playing {
  background: var(--accent-dark);
}

.btn-fs-close {
  height: 28px;
  padding: 0 11px;
  background: var(--ink-primary);
  color: #FFFFFF;
  border: 1px solid var(--ink-primary);
  border-radius: 2px;
  font-size: 0.79rem;
  font-weight: 600;
  cursor: pointer;
}

.fs-viewport {
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background: #FFFFFF;
  padding: 8px;
}

.fs-pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin: 0 auto;
}

/* Bottom Navigation Bar */
.bottom-nav {
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  flex-shrink: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--bg-surface);
  border-top: 1px solid var(--border-strong);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: none;
  background: transparent;
  color: var(--ink-muted);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  border-top: 2px solid transparent;
}

.nav-item.active {
  color: var(--accent);
  border-top-color: var(--accent);
}

/* Settings & Placeholder Panes */
.pane-placeholder {
  padding: 18px 14px;
  overflow-y: auto;
}

.placeholder-card {
  max-width: 520px;
  margin: 0 auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-sm);
  padding: 18px;
}

.placeholder-kicker {
  margin: 0 0 4px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.placeholder-card h2 {
  margin: 0 0 10px;
  font-family: var(--font-serif);
  font-size: 1.22rem;
}

.placeholder-card p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--ink-secondary);
}

.settings-list {
  margin-top: 12px;
  border-top: 1px solid var(--border-hairline);
  border-bottom: 1px solid var(--border-hairline);
}

.setting-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
}

.setting-toggle-row {
  cursor: pointer;
}

.setting-text strong {
  display: block;
  font-size: 0.94rem;
  color: var(--ink-primary);
}

.setting-desc {
  margin-top: 3px !important;
  font-size: 0.8rem !important;
  color: var(--ink-muted) !important;
}

.toggle-checkbox {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.settings-coming-soon {
  margin-top: 16px;
}

/* Shared Buttons */
.btn-primary {
  background: var(--accent);
  color: #FFFFFF;
  border: 1px solid var(--accent-dark);
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-secondary {
  display: inline-block;
  background: var(--bg-surface);
  color: var(--ink-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

/* Quick-Jump Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(31, 29, 26, 0.5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 14vh 16px 16px;
}

.modal-dialog {
  width: 100%;
  max-width: 340px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-hairline);
  background: var(--bg-paper);
}

.modal-header h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.05rem;
}

.modal-close {
  border: none;
  background: transparent;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--ink-secondary);
  cursor: pointer;
}

.quick-jump-form {
  padding: 14px;
}

.quick-jump-input {
  width: 100%;
  height: 48px;
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-paper);
  color: var(--ink-primary);
  outline: none;
}

.quick-jump-input:focus {
  border-color: var(--accent);
  background: #FFFFFF;
}

.quick-jump-error {
  margin: 8px 0 0;
  font-size: 0.82rem;
  color: var(--accent);
  text-align: center;
}

.modal-actions {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ==========================================================================
   Tablet / Wide Landscape Split-Pane Layout (>= 860px)
   ========================================================================== */
@media (min-width: 860px) {
  .workspace {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
  }

  .pane-list,
  .pane-placeholder {
    border-right: 1px solid var(--border-strong);
  }

  .pane-detail {
    display: flex;
    position: static;
    z-index: auto;
  }

  .detail-empty {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: center;
    padding: 32px;
    text-align: center;
    color: var(--ink-secondary);
  }

  .detail-empty-inner {
    max-width: 340px;
  }

  .ornament-rule {
    width: 48px;
    height: 2px;
    background: var(--accent);
    margin: 0 auto 14px;
  }

  .detail-empty h2 {
    margin: 0 0 6px;
    font-family: var(--font-serif);
    font-size: 1.3rem;
    color: var(--ink-primary);
  }

  .detail-empty p {
    margin: 0;
    font-size: 0.9rem;
  }

  .detail-header .btn-back {
    display: none;
  }

  .sheet-viewport {
    max-height: 74dvh;
  }
}


/* ==========================================================================
   Stage 3: Favorites, Custom Tags, "Don't Sing" Flag, Personal Notes, Backup
   ========================================================================== */

.icon-toggle-btn {
  flex-shrink: 0;
  border: 1px solid var(--border-strong);
  background: var(--bg-paper);
  color: var(--ink-muted);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 0.92rem;
  line-height: 1;
  cursor: pointer;
}

.icon-toggle-btn.active {
  background: var(--accent-tint);
  border-color: var(--accent);
  color: var(--accent);
}

.tag-filter-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 7px;
}

.tag-filter-label {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  flex-shrink: 0;
}

.tag-filter-select {
  flex: 1;
  min-width: 0;
  height: 30px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-paper);
  color: var(--ink-primary);
  font-size: 0.82rem;
  padding: 0 8px;
}

.btn-clear-tag {
  border: 1px solid var(--border-strong);
  background: var(--bg-paper);
  color: var(--ink-secondary);
  border-radius: var(--radius-sm);
  width: 30px;
  height: 30px;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

/* Favorite & "Don't Sing" Row Treatments */
.hymn-num-wrap {
  display: flex;
  align-items: center;
  gap: 3px;
}

.dontsing-icon-inline {
  color: #B4232C;
  font-weight: 700;
  font-size: 0.92rem;
  line-height: 1;
}

.hymn-row.is-dontsing {
  background: #F6F4F0;
}

.hymn-row.is-dontsing .hymn-num {
  color: #9C948A;
}

.hymn-row.is-dontsing .hymn-title-line {
  color: #8C857B;
  text-decoration: line-through;
  text-decoration-color: #B9B0A4;
}

.hymn-row.is-dontsing .hymn-sub-line {
  color: #A49C91;
}

.hymn-dontsing-reason {
  margin-top: 2px;
  font-size: 0.76rem;
  font-style: italic;
  color: #9E323A;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hymn-custom-tags-mini {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.mini-tag {
  font-size: 0.69rem;
  font-weight: 600;
  color: var(--accent-dark);
  background: var(--accent-tint);
  border: 1px solid #E4C5CA;
  border-radius: 2px;
  padding: 0px 5px;
  line-height: 1.45;
}

.hymn-right-top {
  display: flex;
  align-items: center;
  gap: 5px;
}

.fav-star-badge {
  color: var(--accent);
  font-size: 0.88rem;
  line-height: 1;
}

/* Detail Header Actions */
.detail-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-fav-header {
  border: 1px solid var(--border-strong);
  background: var(--bg-paper);
  color: var(--ink-muted);
  border-radius: var(--radius-sm);
  width: 32px;
  height: 30px;
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-fav-header.is-fav {
  background: var(--accent-tint);
  border-color: var(--accent);
  color: var(--accent);
}

/* "Don't Sing" Detail Banner */
.notice-dontsing {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: #FDF2F2;
  border: 1px solid #E5B8BC;
  border-left: 3px solid #B4232C;
  color: #6B1A22;
  margin: 0 0 10px;
}

.dontsing-glyph {
  font-size: 1.05rem;
  font-weight: 700;
  color: #B4232C;
  line-height: 1.25;
}

/* Personal Organization Section in Song Detail */
.personal-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.custom-tags-list {
  margin-bottom: 8px;
}

.custom-tags-list:empty {
  margin-bottom: 0;
}

.custom-tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent-dark);
  background: var(--accent-tint);
  border: 1px solid #DFB9C0;
  border-radius: 2px;
  padding: 2px 6px;
}

.custom-tag-remove {
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 0.95rem;
  line-height: 1;
  padding: 0 1px;
  cursor: pointer;
}

.add-tag-form {
  display: flex;
  gap: 6px;
}

.tag-input {
  flex: 1;
  min-width: 0;
  height: 34px;
  padding: 4px 9px;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--ink-primary);
  background: var(--bg-paper);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  outline: none;
}

.tag-input:focus {
  border-color: var(--accent);
  background: #FFFFFF;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 0.82rem;
  height: 34px;
}

.notes-textarea {
  width: 100%;
  min-height: 58px;
  padding: 7px 9px;
  font-family: var(--font-sans);
  font-size: 0.86rem;
  line-height: 1.4;
  color: var(--ink-primary);
  background: var(--bg-paper);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  resize: vertical;
  outline: none;
}

.notes-textarea:focus {
  border-color: var(--accent);
  background: #FFFFFF;
}

.dontsing-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dontsing-toggle-label {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 0.84rem;
  color: var(--ink-secondary);
  cursor: pointer;
}

.dontsing-toggle-label strong {
  color: var(--ink-primary);
}

.dontsing-reason-input {
  width: 100%;
  height: 34px;
  padding: 4px 9px;
  font-family: var(--font-sans);
  font-size: 0.84rem;
  color: #6B1A22;
  background: #FDF8F8;
  border: 1px solid #DFB9C0;
  border-radius: var(--radius-sm);
  outline: none;
}

.dontsing-reason-input:focus {
  border-color: #B4232C;
  background: #FFFFFF;
}

/* Settings Stats & Backup */
.settings-section {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border-hairline);
}

.settings-subheading {
  margin: 0 0 8px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.stat-box {
  background: var(--bg-paper);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-sm);
  padding: 8px 4px;
  text-align: center;
}

.stat-box strong {
  display: block;
  font-family: var(--font-serif);
  font-size: 1.15rem;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.stat-box span {
  font-size: 0.7rem;
  color: var(--ink-secondary);
}

.backup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.backup-status {
  margin: 10px 0 0 !important;
  font-size: 0.82rem !important;
  font-weight: 600;
  color: var(--accent) !important;
}

.settings-danger {
  display: flex;
  justify-content: flex-start;
}

.btn-danger-outline {
  background: transparent;
  color: #9E262E;
  border: 1px solid #D9A7AB;
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-danger-outline:active {
  background: #FDF2F2;
}


/* ==========================================================================
   Stage 4: Worship Setlists, Podium Runner Bar, & Singing History
   ========================================================================== */

.stats-grid {
  grid-template-columns: repeat(3, 1fr);
}

/* Subpanes (Setlists & History) */
.pane-setlists,
.pane-history {
  background: var(--bg-paper);
}

.subpane {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.subpane-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-hairline);
}

.subpane-header h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.12rem;
  color: var(--ink-primary);
}

.subpane-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Setlists Directory Cards */
.setlists-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setlist-card {
  width: 100%;
  text-align: left;
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.setlist-card:active {
  background: var(--bg-subtle);
}

.setlist-card-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.setlist-card-title {
  font-family: var(--font-serif);
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--ink-primary);
}

.setlist-card-date {
  font-size: 0.78rem;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.setlist-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.79rem;
  color: var(--ink-secondary);
}

.logged-badge {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #2A5B3C;
  background: #EBF5EE;
  border: 1px solid #BCDCC6;
  border-radius: 2px;
  padding: 1px 6px;
}

/* Setlist Editor */
.setlist-editor-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 12px 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.setlist-meta-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-sm);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.setlist-meta-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 7px;
}

.setlist-name-input {
  height: 36px;
  padding: 5px 9px;
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink-primary);
  background: var(--bg-paper);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  min-width: 0;
}

.setlist-date-input {
  height: 36px;
  padding: 4px 7px;
  font-family: var(--font-sans);
  font-size: 0.84rem;
  color: var(--ink-primary);
  background: var(--bg-paper);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}

.setlist-notes-input {
  height: 32px;
  padding: 4px 9px;
  font-family: var(--font-sans);
  font-size: 0.84rem;
  color: var(--ink-secondary);
  background: var(--bg-paper);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-sm);
}

/* Key Progression Strip */
.key-progression-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-sm);
  overflow-x: auto;
}

.key-prog-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  flex-shrink: 0;
}

.key-prog-items {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink-primary);
  white-space: nowrap;
}

.key-prog-arrow {
  color: var(--ink-muted);
  font-weight: 400;
}

/* Setlist Song Slot Rows */
.setlist-songs-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.setlist-song-item {
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.setlist-song-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.slot-select {
  height: 26px;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--accent-dark);
  background: var(--accent-tint);
  border: 1px solid #DFB9C0;
  border-radius: 2px;
  padding: 0 6px;
}

.slot-item-controls {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.btn-slot-move {
  border: 1px solid var(--border-hairline);
  background: var(--bg-paper);
  color: var(--ink-secondary);
  border-radius: 2px;
  width: 26px;
  height: 26px;
  font-size: 0.75rem;
  line-height: 1;
  cursor: pointer;
}

.btn-slot-move:disabled {
  opacity: 0.35;
  cursor: default;
}

.btn-slot-remove {
  border: 1px solid var(--border-hairline);
  background: var(--bg-paper);
  color: #9E262E;
  border-radius: 2px;
  width: 26px;
  height: 26px;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.setlist-song-main {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 8px;
  align-items: center;
  border: none;
  background: transparent;
  padding: 2px 0;
  text-align: left;
  cursor: pointer;
  width: 100%;
}

.setlist-song-num {
  font-family: var(--font-serif);
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.setlist-song-title {
  font-size: 0.94rem;
  font-weight: 600;
  color: var(--ink-primary);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.setlist-songs-empty {
  padding: 22px 14px;
  text-align: center;
  background: var(--bg-surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  color: var(--ink-secondary);
}

.setlist-footer-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.btn-precache {
  height: auto;
  padding: 8px 10px;
  font-size: 0.84rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.btn-add-song {
  padding: 8px 18px;
  white-space: nowrap;
}

.btn-log-full {
  grid-column: 1 / -1;
}

.setlist-status-msg {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: #2A5B3C;
}

.setlist-danger-zone {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border-hairline);
}

/* Podium / Setlist Runner Bar in Song Detail */
.runner-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 10px;
  background: var(--accent-tint);
  border-bottom: 1px solid #DFB9C0;
}

.runner-center {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  line-height: 1.2;
}

.runner-center strong {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent-dark);
}

.runner-center span {
  font-size: 0.73rem;
  color: var(--ink-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.btn-runner {
  border: 1px solid #D3A5AD;
  background: #FFFFFF;
  color: var(--accent-dark);
  border-radius: 2px;
  padding: 5px 9px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.btn-runner:disabled {
  opacity: 0.4;
  cursor: default;
}

.btn-runner-close {
  border: none;
  background: transparent;
  color: var(--accent-dark);
  font-size: 1.25rem;
  line-height: 1;
  padding: 2px 4px;
  cursor: pointer;
}

/* Quick Actions Row in Song Detail */
.song-quick-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.btn-quick-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--ink-primary);
  border-radius: var(--radius-sm);
  min-height: 30px;
  padding: 5px 10px;
  font-family: inherit;
  font-size: 0.79rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
}

.btn-quick-action:active {
  background: var(--bg-subtle);
}

.last-sung-pill {
  font-size: 0.76rem;
  color: var(--ink-secondary);
  background: var(--bg-subtle);
  border: 1px solid var(--border-hairline);
  border-radius: 2px;
  padding: 3px 8px;
}

/* Recency Indicator on Hymnal List Row */
.hymn-recency {
  font-size: 0.69rem;
  color: var(--ink-muted);
  white-space: nowrap;
}

.hymn-recency.is-recent {
  color: var(--accent);
  font-weight: 600;
}

/* Song-specific history list inside Song Detail */
.song-history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.song-history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--ink-secondary);
  padding: 4px 0;
  border-bottom: 1px solid var(--bg-subtle);
}

.song-history-item:last-child {
  border-bottom: none;
}

/* History Tab */
.history-search-wrap {
  flex-shrink: 0;
  padding: 8px 12px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-hairline);
}

.history-search-input {
  padding-left: 12px;
  height: 36px;
  font-size: 0.88rem;
}

.history-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-date-group {
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.history-date-heading {
  padding: 6px 10px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-hairline);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.history-entry-row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-hairline);
}

.history-entry-row:last-child {
  border-bottom: none;
}

.history-entry-open {
  display: contents;
  cursor: pointer;
}

.history-entry-num {
  font-family: var(--font-serif);
  font-weight: 700;
  color: var(--accent);
  font-size: 0.98rem;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}

.history-entry-info {
  min-width: 0;
  cursor: pointer;
}

.history-entry-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-entry-service {
  font-size: 0.76rem;
  color: var(--ink-muted);
}

.btn-history-del {
  border: none;
  background: transparent;
  color: var(--ink-muted);
  font-size: 1.15rem;
  line-height: 1;
  padding: 4px 6px;
  cursor: pointer;
}

.btn-history-del:hover {
  color: #9E262E;
}

/* Shared Modal Enhancements (Stage 4) */
.modal-wide {
  max-width: 400px;
}

.modal-picker {
  max-width: 440px;
  max-height: 76dvh;
  display: flex;
  flex-direction: column;
}

.modal-body-form {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.modal-song-ref {
  margin: 0;
  padding: 7px 10px;
  background: var(--bg-paper);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-sm);
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--accent-dark);
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-field label {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
}

.form-input,
.form-select {
  height: 38px;
  padding: 6px 9px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--ink-primary);
  background: var(--bg-paper);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}

.form-select-sm {
  height: 32px;
  font-size: 0.82rem;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.picker-controls {
  padding: 10px 12px;
  background: var(--bg-paper);
  border-bottom: 1px solid var(--border-hairline);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.picker-controls .search-input {
  padding-left: 12px;
}

.picker-slot-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.picker-slot-row label {
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.picker-slot-row .form-select {
  flex: 1;
}

.picker-results {
  flex: 1;
  min-height: 160px;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 0;
}

.picker-row {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--border-hairline);
  background: var(--bg-surface);
  padding: 9px 12px;
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 8px;
  align-items: center;
  text-align: left;
  cursor: pointer;
}

.picker-row:active {
  background: var(--bg-subtle);
}

.picker-row.is-dontsing {
  background: #F6F4F0;
  color: #8C857B;
}

.picker-row.is-supplement {
  background: var(--bg-supplement);
}


/* ==========================================================================
   Enhancements: Dark Mode, Prev/Next Hymn Nav, & Clickable Scripture Links
   ========================================================================== */

.settings-list .setting-row {
  border-bottom: 1px solid var(--border-hairline);
}

.settings-list .setting-row:last-child {
  border-bottom: none;
}

.setting-select {
  width: auto;
  min-width: 88px;
  flex-shrink: 0;
}

/* Compact Prev/Next Hymn Arrows in Detail Header & Fullscreen Toolbar */
.btn-hymn-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--border-strong);
  background: var(--bg-paper);
  color: var(--ink-primary);
  border-radius: var(--radius-sm);
  font-size: 1.15rem;
  line-height: 1;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

.btn-hymn-nav:active {
  background: var(--bg-subtle);
}

.btn-hymn-nav:disabled {
  opacity: 0.32;
  cursor: default;
}

.btn-hymn-nav-sm {
  width: 24px;
  height: 24px;
  font-size: 1.05rem;
}

/* Clickable Scripture Reference Badges */
.scripture-link {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  text-decoration: none;
  color: var(--accent-dark);
  background: var(--accent-tint);
  border-color: #DFB9C0;
  font-weight: 600;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}

.scripture-link:hover {
  border-color: var(--accent);
}

.scripture-link-arrow {
  font-size: 0.7rem;
  opacity: 0.75;
}

/* ==========================================================================
   Dark Mode ("Dimmed Sanctuary" Warm Charcoal & Oxblood Palette)
   ========================================================================== */
html[data-theme="dark"] {
  --bg-paper: #161413;
  --bg-surface: #1F1C1A;
  --bg-subtle: #2A2623;
  --bg-supplement: #26211A;

  --ink-primary: #EFECE6;
  --ink-secondary: #B9B1A5;
  --ink-muted: #8E867B;

  --border-hairline: #342F2B;
  --border-strong: #4A433D;

  --accent: #A93848;
  --accent-dark: #852836;
  --accent-tint: #341E22;

  --supp-ink: #D4B483;
  --supp-border: #594A34;
  --supp-bg: #2C251B;
}

html[data-theme="dark"] .app-header {
  background: #5E1722;
  border-bottom-color: #461018;
}

html[data-theme="dark"] .search-input:focus,
html[data-theme="dark"] .tag-input:focus,
html[data-theme="dark"] .notes-textarea:focus,
html[data-theme="dark"] .quick-jump-input:focus {
  background: #262220;
}

html[data-theme="dark"] .hymn-row.is-supplement .hymn-title-line {
  color: #D9CBB6;
}

html[data-theme="dark"] .hymn-row.is-supplement.selected {
  background: #3B282A;
}

html[data-theme="dark"] .hymn-row.is-dontsing,
html[data-theme="dark"] .picker-row.is-dontsing {
  background: #1A1816;
}

html[data-theme="dark"] .hymn-row.is-dontsing .hymn-num,
html[data-theme="dark"] .hymn-row.is-dontsing .hymn-title-line {
  color: #777068;
  text-decoration-color: #5C564F;
}

html[data-theme="dark"] .hymn-dontsing-reason {
  color: #E07A82;
}

html[data-theme="dark"] .mini-tag,
html[data-theme="dark"] .custom-tag-chip,
html[data-theme="dark"] .scripture-link {
  color: #F2C9CF;
  background: #361F23;
  border-color: #63343C;
}

html[data-theme="dark"] .notice-supplement {
  color: #DEC8A2;
}

html[data-theme="dark"] .notice-dontsing,
html[data-theme="dark"] .notice-error {
  background: #321B1E;
  border-color: #693138;
  color: #F2C1C6;
}

html[data-theme="dark"] .dontsing-reason-input {
  background: #29181B;
  border-color: #693138;
  color: #F2C1C6;
}

html[data-theme="dark"] .slot-select {
  color: #F2C9CF;
  background: #361F23;
  border-color: #63343C;
}

html[data-theme="dark"] .runner-bar {
  background: #321C20;
  border-bottom-color: #5D2E36;
}

html[data-theme="dark"] .runner-center strong,
html[data-theme="dark"] .btn-runner-close {
  color: #F2C9CF;
}

html[data-theme="dark"] .btn-runner {
  background: #241F1D;
  border-color: #6E3841;
  color: #F2C9CF;
}

html[data-theme="dark"] .logged-badge {
  color: #9ED8B0;
  background: #1C3124;
  border-color: #325941;
}

html[data-theme="dark"] .setlist-status-msg {
  color: #9ED8B0;
}

html[data-theme="dark"] .btn-danger-outline {
  color: #EB868E;
  border-color: #6E363B;
}

html[data-theme="dark"] .btn-fs-close {
  background: #3A3531;
  border-color: #524B45;
  color: #FAF7F2;
}

/* Keep sheet music crisp on a softly dimmed white page so it's readable without glare */
html[data-theme="dark"] .sheet-viewport,
html[data-theme="dark"] .fs-overlay,
html[data-theme="dark"] .fs-viewport {
  background: #1A1816;
}

html[data-theme="dark"] .sheet-page-img {
  border-color: #342F2B;
  filter: brightness(0.92) contrast(1.04);
}


/* ==========================================================================
   About This App Section (Settings)
   ========================================================================== */
.about-section {
  padding-bottom: 2px;
}

.about-text {
  margin: 0 !important;
  font-size: 0.78rem !important;
  line-height: 1.5;
  color: var(--ink-muted) !important;
}

/* ==========================================================================
   Readability: Large Size Mode (Balanced Larger Text & Taller Tap Targets)
   ========================================================================== */
html[data-readability="large"] {
  font-size: 17px;
  --header-h: 54px;
  --nav-h: 62px;
}

/* Search & Filter Buttons (taller & easier to tap) */
html[data-readability="large"] .search-input {
  height: 46px;
  font-size: 1rem;
}

html[data-readability="large"] .filter-tab {
  min-height: 38px;
  padding: 8px 10px;
  font-size: 0.88rem;
}

html[data-readability="large"] .icon-toggle-btn {
  min-height: 38px;
  padding: 8px 12px;
  font-size: 1.02rem;
}

html[data-readability="large"] .scans-toggle-btn {
  min-height: 38px;
  padding: 8px 12px;
  font-size: 0.86rem;
}

html[data-readability="large"] .tag-filter-select,
html[data-readability="large"] .btn-clear-tag {
  height: 36px;
  font-size: 0.88rem;
}

html[data-readability="large"] .results-summary {
  font-size: 0.84rem;
  padding: 6px 14px;
}

/* Hymnal List Rows */
html[data-readability="large"] .hymn-row {
  grid-template-columns: 54px 1fr auto;
  padding: 12px 14px;
}

html[data-readability="large"] .hymn-num {
  font-size: 1.12rem;
}

html[data-readability="large"] .hymn-title-line {
  font-size: 1.04rem;
}

html[data-readability="large"] .hymn-sub-line,
html[data-readability="large"] .hymn-dontsing-reason {
  font-size: 0.86rem;
}

html[data-readability="large"] .key-tag {
  font-size: 0.82rem;
  padding: 3px 7px;
}

html[data-readability="large"] .hymn-recency,
html[data-readability="large"] .mini-tag {
  font-size: 0.76rem;
}

/* Song Detail Header, Nav Arrows, & Quick Actions */
html[data-readability="large"] .detail-header {
  height: 52px;
}

html[data-readability="large"] .btn-back {
  font-size: 0.98rem;
  padding: 8px 8px 8px 0;
}

html[data-readability="large"] .btn-hymn-nav {
  width: 34px;
  height: 34px;
  font-size: 1.3rem;
}

html[data-readability="large"] .btn-hymn-nav-sm {
  width: 30px;
  height: 30px;
  font-size: 1.18rem;
}

html[data-readability="large"] .detail-num {
  font-size: 1.14rem;
}

html[data-readability="large"] .detail-key {
  font-size: 0.84rem;
  padding: 3px 8px;
}

html[data-readability="large"] .btn-fav-header {
  width: 38px;
  height: 36px;
  font-size: 1.2rem;
}

html[data-readability="large"] .btn-text-link {
  font-size: 0.9rem;
  padding: 8px 6px;
}

html[data-readability="large"] .song-title {
  font-size: 1.34rem;
}

html[data-readability="large"] .song-alt-titles {
  font-size: 0.98rem;
}

html[data-readability="large"] .song-first-line {
  font-size: 0.88rem;
}

html[data-readability="large"] .btn-quick-action {
  min-height: 36px;
  padding: 7px 13px;
  font-size: 0.88rem;
}

html[data-readability="large"] .last-sung-pill {
  font-size: 0.82rem;
  padding: 5px 9px;
}

/* Sheet Music Toolbar & Fullscreen Controls */
html[data-readability="large"] .sheet-toolbar {
  padding: 7px 10px;
}

html[data-readability="large"] .btn-tool {
  height: 35px;
  min-width: 35px;
  padding: 0 10px;
  font-size: 0.88rem;
}

html[data-readability="large"] .btn-highres {
  height: 35px;
  padding: 0 12px;
  font-size: 0.85rem;
}

html[data-readability="large"] .btn-fs-pitch {
  height: 34px;
  padding: 0 11px;
}

html[data-readability="large"] .btn-fs-close {
  height: 34px;
  padding: 0 13px;
  font-size: 0.86rem;
}

/* Song Page Personalization & Metadata Controls */
html[data-readability="large"] .tag-input,
html[data-readability="large"] .dontsing-reason-input,
html[data-readability="large"] .btn-sm {
  height: 40px;
  font-size: 0.92rem;
}

html[data-readability="large"] .notes-textarea {
  font-size: 0.94rem;
  min-height: 68px;
}

html[data-readability="large"] .meta-tag,
html[data-readability="large"] .custom-tag-chip {
  font-size: 0.86rem;
  padding: 4px 9px;
}

html[data-readability="large"] .custom-tag-remove {
  font-size: 1.08rem;
  padding: 0 3px;
}

html[data-readability="large"] .toggle-checkbox {
  width: 23px;
  height: 23px;
}

/* Pitch Bar (taller tap height while staying cleanly on one line) */
html[data-readability="large"] .btn-pitch-hold,
html[data-readability="large"] .btn-pitch-arp {
  height: 44px;
}

html[data-readability="large"] .pitch-btn-key {
  font-size: 1.32rem;
}

html[data-readability="large"] .pitch-btn-sub {
  font-size: 0.86rem;
}

html[data-readability="large"] .btn-pitch-arp {
  font-size: 0.84rem;
  padding: 0 10px;
}

html[data-readability="large"] .btn-step {
  height: 42px;
  padding: 0 8px;
  font-size: 0.82rem;
}

@media (max-width: 400px) {
  html[data-readability="large"] .btn-step {
    padding: 0 5px;
    font-size: 0.74rem;
  }
  html[data-readability="large"] .btn-pitch-arp {
    padding: 0 7px;
    font-size: 0.76rem;
  }
  html[data-readability="large"] .btn-pitch-hold {
    padding: 0 6px;
    gap: 4px;
  }
  html[data-readability="large"] .pitch-btn-key {
    font-size: 1.16rem;
  }
  html[data-readability="large"] .pitch-btn-sub {
    font-size: 0.76rem;
  }
}

/* Setlists & Podium Runner Controls */
html[data-readability="large"] .btn-runner {
  padding: 8px 12px;
  font-size: 0.86rem;
}

html[data-readability="large"] .btn-runner-close {
  font-size: 1.45rem;
  padding: 4px 6px;
}

html[data-readability="large"] .setlist-card {
  padding: 13px 14px;
}

html[data-readability="large"] .setlist-name-input,
html[data-readability="large"] .setlist-date-input {
  height: 42px;
}

html[data-readability="large"] .setlist-notes-input {
  height: 38px;
  font-size: 0.9rem;
}

html[data-readability="large"] .slot-select {
  height: 33px;
  font-size: 0.8rem;
  padding: 0 8px;
}

html[data-readability="large"] .btn-slot-move,
html[data-readability="large"] .btn-slot-remove {
  width: 34px;
  height: 34px;
  font-size: 0.92rem;
}

html[data-readability="large"] .btn-slot-remove {
  font-size: 1.2rem;
}

html[data-readability="large"] .setlist-song-main {
  padding: 5px 0;
}

html[data-readability="large"] .setlist-song-title {
  font-size: 1.02rem;
}

html[data-readability="large"] .btn-precache {
  height: auto;
  min-height: 42px;
  padding: 9px 10px;
  font-size: 0.84rem;
  white-space: nowrap;
}

html[data-readability="large"] .brand-title {
  font-size: 1.42rem;
}

html[data-readability="large"] .setlist-footer-actions .btn-add-song {
  padding: 9px 20px;
  font-size: 0.9rem;
  white-space: nowrap;
}

html[data-readability="large"] .btn-primary,
html[data-readability="large"] .btn-secondary {
  min-height: 42px;
  padding: 10px 16px;
  font-size: 0.94rem;
}

html[data-readability="large"] .btn-danger-outline {
  min-height: 38px;
  padding: 8px 14px;
  font-size: 0.88rem;
}

/* History & Bottom Navigation */
html[data-readability="large"] .btn-history-del {
  font-size: 1.35rem;
  padding: 6px 8px;
}

html[data-readability="large"] .nav-item {
  font-size: 0.78rem;
}

html[data-readability="large"] .nav-item svg {
  width: 22px;
  height: 22px;
}

/* Keep About text comfortably small even in Large Size */
html[data-readability="large"] .about-text {
  font-size: 0.82rem !important;
}


/* ==========================================================================
   Lightweight Bottom Toast (Back-to-Exit Guard & Quick Feedback)
   ========================================================================== */
.app-toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 14px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 95;
  background: rgba(31, 29, 26, 0.92);
  color: #FAF7F2;
  padding: 9px 16px;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.22);
}

html[data-theme="dark"] .app-toast {
  background: rgba(239, 236, 230, 0.94);
  color: #161413;
}

html[data-readability="large"] .app-toast {
  font-size: 0.92rem;
  padding: 10px 18px;
}


/* ==========================================================================
   Multi-Hymnal Support (Zero Visual Impact in Single-Book Mode)
   ========================================================================== */
.setting-select-wide {
  max-width: 175px;
}

.multibook-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 0 12px 4px;
  border-bottom: 1px solid var(--border-hairline);
}

.multibook-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.86rem;
  color: var(--ink-secondary);
  cursor: pointer;
}

.multibook-item strong {
  color: var(--accent);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  letter-spacing: 0.03em;
}

.multibook-item .toggle-checkbox {
  margin-top: 0;
}

/* Subtle Book Code Badge (only rendered in Multi-Book Mode or cross-book Setlist/History) */
.book-badge {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-secondary);
  background: var(--bg-subtle);
  border: 1px solid var(--border-strong);
  border-radius: 2px;
  padding: 1px 4px;
  line-height: 1.25;
  flex-shrink: 0;
}

.hymn-num-col {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.quick-jump-choices {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.qj-choice-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg-paper);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--ink-primary);
  font-size: 0.86rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.qj-choice-btn:active {
  background: var(--bg-subtle);
}

.qj-choice-title {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

html[data-readability="large"] .book-badge {
  font-size: 0.7rem;
  padding: 1px 5px;
}

html[data-readability="large"] .multibook-item {
  font-size: 0.94rem;
}


/* ==========================================================================
   First-Visit Hymnal Picker Landing Screen
   ========================================================================== */
.landing-screen {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: var(--bg-paper);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 18px;
  overflow-y: auto;
}

.landing-inner {
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.landing-header {
  text-align: center;
}

.landing-kicker {
  margin: 0 0 6px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
}

.landing-title {
  margin: 0 0 6px;
  font-family: var(--font-serif);
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--ink-primary);
  line-height: 1.2;
}

.landing-subtitle {
  margin: 0;
  font-size: 0.92rem;
  color: var(--ink-secondary);
}

.landing-books {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.landing-book-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px 18px;
  background: #6B1A24;
  color: #FAF7F2;
  border: 1px solid #52121A;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: center;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}

.landing-book-btn:hover {
  background: #7A1F2B;
  border-color: #5C151F;
}

.landing-book-btn:active {
  background: #52121A;
  color: #FFFFFF;
}

html[data-theme="dark"] .landing-book-btn {
  background: #5E1722;
  border-color: #7D2432;
  color: #FAF7F2;
}

html[data-theme="dark"] .landing-book-btn:hover {
  background: #721E2B;
}

.landing-book-name {
  font-family: var(--font-serif);
  font-size: 1.18rem;
  font-weight: 700;
  line-height: 1.25;
}

.landing-footnote {
  margin: 0;
  text-align: center;
  font-size: 0.78rem;
  color: var(--ink-muted);
}
/* ==========================================================================
   Inline Scripture Reader Modal & Button Badges
   ========================================================================== */
button.scripture-link {
  font-family: inherit;
  cursor: pointer;
}

.modal-scripture {
  max-width: 460px;
  max-height: 78dvh;
  display: flex;
  flex-direction: column;
}

.scripture-modal-heading {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.scripture-modal-version {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
}

.scripture-modal-body {
  padding: 14px 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  font-family: var(--font-serif);
  font-size: 1rem;
  line-height: 1.62;
  color: var(--ink-primary);
}

.scripture-loading,
.scripture-error {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  color: var(--ink-secondary);
}

.scripture-verse-text {
  margin: 0;
}

.scripture-verse-num {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  vertical-align: super;
  margin-right: 3px;
}

.scripture-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-top: 1px solid var(--border-hairline);
  background: var(--bg-paper);
}

html[data-readability="large"] .scripture-modal-body {
  font-size: 1.1rem;
  line-height: 1.68;
}

/* Constant width for zoom reset ("Fit" / "115%") buttons to prevent layout shift */
#zoomResetBtn,
#fsZoomResetBtn {
  width: 52px;
  padding: 0 4px;
  font-variant-numeric: tabular-nums;
}

html[data-readability="large"] #zoomResetBtn,
html[data-readability="large"] #fsZoomResetBtn {
  width: 58px;
  padding: 0 4px;
}

.btn-quick-link {
  text-decoration: none;
  color: var(--accent);
}

/* ==========================================================================
   Stage 5: Cues, Starting Melody Note, Cross-Hymnal Links, Browse & Rotation
   ========================================================================== */

/* Inline Per-Slot Verse/Cue Input (zero extra vertical space) */
.slot-cue-input {
  flex: 1 1 80px;
  min-width: 60px;
  height: 26px;
  padding: 2px 7px;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  color: var(--ink-primary);
  background: var(--bg-paper);
  border: 1px solid var(--border-hairline);
  border-radius: 2px;
  outline: none;
}

.slot-cue-input:focus {
  border-color: var(--accent);
  background: #FFFFFF;
}

html[data-theme="dark"] .slot-cue-input:focus {
  background: #262220;
}

html[data-readability="large"] .slot-cue-input {
  height: 33px;
  font-size: 0.86rem;
}

/* Starting Melody Note Row & Pitch Button */
.start-note-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.start-note-select {
  width: auto;
  min-width: 132px;
}

.btn-pitch-start {
  color: var(--accent-dark);
  border-color: #D3A5AD;
  background: var(--accent-tint);
}

html[data-theme="dark"] .btn-pitch-start {
  color: #F2C9CF;
  background: #361F23;
  border-color: #63343C;
}

/* Cross-Hymnal "Also In…" Pills */
button.also-in-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: inherit;
  font-weight: 600;
  color: var(--ink-primary);
  background: var(--bg-subtle);
  border-color: var(--border-strong);
  cursor: pointer;
}

button.also-in-btn:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

/* Active Browse / Rotation Filter Bar */
.active-browse-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 7px;
  padding: 4px 6px 4px 10px;
  background: var(--accent-tint);
  border: 1px solid #DFB9C0;
  border-radius: var(--radius-sm);
}

.active-browse-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-dark);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

html[data-theme="dark"] .active-browse-bar {
  background: #361F23;
  border-color: #63343C;
}

html[data-theme="dark"] .active-browse-label {
  color: #F2C9CF;
}

/* Browse & Rotation Modal Tabs & List */
.browse-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-hairline);
}

.browse-tab {
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--ink-secondary);
  font-size: 0.84rem;
  font-weight: 600;
  padding: 9px 6px;
  cursor: pointer;
}

.browse-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: var(--bg-surface);
}

.browse-item-row {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--border-hairline);
  background: var(--bg-surface);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
  cursor: pointer;
  color: var(--ink-primary);
  font-size: 0.9rem;
  font-weight: 500;
}

.browse-item-row:active {
  background: var(--bg-subtle);
}

.browse-item-sub {
  display: block;
  font-size: 0.76rem;
  color: var(--ink-muted);
  margin-top: 2px;
}

.browse-count {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--ink-secondary);
  background: var(--bg-subtle);
  border: 1px solid var(--border-hairline);
  border-radius: 2px;
  padding: 2px 7px;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

#browseModal.modal-backdrop {
  align-items: center;
  padding: 16px;
}


/* ==========================================================================
   Setlist Settings, Custom Song Roles, & Worship Elements
   ========================================================================== */
:root {
  --elem-accent: #2B5B6C;
  --elem-ink: #1E4452;
  --elem-bg: #EBF3F6;
  --elem-border: #B6CED7;
}

html[data-theme="dark"] {
  --elem-accent: #5C9DB3;
  --elem-ink: #C4E2EC;
  --elem-bg: #1B2D34;
  --elem-border: #365764;
}

.btn-icon-subtle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-paper);
  color: var(--ink-secondary);
  cursor: pointer;
  flex-shrink: 0;
}

.btn-icon-subtle:active {
  background: var(--bg-subtle);
  color: var(--accent);
}

html[data-readability="large"] .btn-icon-subtle {
  width: 40px;
  height: 40px;
}

/* Setlist Footer Equal-Width + Add Song & + Add Element */
.setlist-footer-actions.has-elements .btn-log-full {
  grid-column: auto;
}

.btn-add-song,
.btn-add-element {
  width: 100%;
  padding: 8px 14px;
  white-space: nowrap;
  text-align: center;
}

html[data-readability="large"] .setlist-footer-actions .btn-add-song,
html[data-readability="large"] .setlist-footer-actions .btn-add-element {
  width: 100%;
  padding: 9px 14px;
  font-size: 0.9rem;
  white-space: nowrap;
}

/* Setlist Settings Subpane Cards */
.setlist-settings-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.setlist-settings-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.custom-roles-count {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--ink-secondary);
  background: var(--bg-subtle);
  border: 1px solid var(--border-hairline);
  border-radius: 2px;
  padding: 1px 6px;
  font-variant-numeric: tabular-nums;
}

.custom-roles-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.custom-roles-list:empty {
  margin-top: 0;
}

.custom-role-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 8px;
  background: var(--bg-paper);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-sm);
}

.custom-role-name {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--accent-dark);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

html[data-theme="dark"] .custom-role-name {
  color: #F2C9CF;
}

.custom-role-edit-input {
  flex: 1;
  min-width: 0;
  height: 30px;
  padding: 3px 8px;
  font-family: var(--font-sans);
  font-size: 0.84rem;
  color: var(--ink-primary);
  background: var(--bg-surface);
  border: 1px solid var(--accent);
  border-radius: 2px;
  outline: none;
}

.custom-role-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.btn-role-action {
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--ink-secondary);
  border-radius: 2px;
  height: 28px;
  padding: 0 8px;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-role-action.is-save {
  background: var(--accent);
  border-color: var(--accent-dark);
  color: #FFFFFF;
}

.btn-role-action.is-delete {
  color: #9E262E;
  padding: 0 7px;
  font-size: 0.95rem;
}

html[data-theme="dark"] .btn-role-action.is-delete {
  color: #EB868E;
}

.default-roles-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.default-role-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 9px;
  background: var(--bg-paper);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.default-role-left {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.default-role-left .toggle-checkbox {
  margin-top: 0;
}

.default-role-label {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--ink-primary);
}

.default-role-row.is-hidden-role .default-role-label {
  color: var(--ink-muted);
  text-decoration: line-through;
}

.default-role-status {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  background: var(--bg-subtle);
  border: 1px solid var(--border-hairline);
  border-radius: 2px;
  padding: 1px 6px;
  flex-shrink: 0;
}

/* Worship Element Items inside Setlist Editor */
.setlist-element-item {
  border-left: 3px solid var(--elem-accent);
}

.slot-select.slot-select-element {
  color: var(--elem-ink);
  background: var(--elem-bg);
  border-color: var(--elem-border);
}

html[data-theme="dark"] .slot-select.slot-select-element {
  color: var(--elem-ink);
  background: var(--elem-bg);
  border-color: var(--elem-border);
}

.setlist-element-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: none;
  background: transparent;
  padding: 2px 0;
  text-align: left;
  cursor: pointer;
  width: 100%;
}

.setlist-element-title {
  font-family: var(--font-serif);
  font-size: 0.94rem;
  font-weight: 700;
  color: var(--elem-ink);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.setlist-element-detail {
  font-size: 0.82rem;
  color: var(--ink-secondary);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Worship Element Banner in Lead Service Mode */
.runner-bar.is-element {
  background: var(--elem-bg);
  border-bottom-color: var(--elem-border);
}

.runner-bar.is-element .runner-center strong,
.runner-bar.is-element .btn-runner-close {
  color: var(--elem-ink);
}

.runner-bar.is-element .btn-runner {
  border-color: var(--elem-border);
  color: var(--elem-ink);
}

html[data-theme="dark"] .runner-bar.is-element .btn-runner {
  background: #16242A;
  border-color: var(--elem-border);
  color: var(--elem-ink);
}

/* Worship Element Podium Card View */
.element-runner-view {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 18px;
  background: var(--bg-paper);
}

.element-runner-card {
  width: 100%;
  max-width: 460px;
  background: var(--bg-surface);
  border: 1px solid var(--elem-border);
  border-top: 4px solid var(--elem-accent);
  border-radius: var(--radius-md);
  padding: 28px 22px;
  text-align: center;
}

.element-runner-kicker {
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--elem-ink);
  background: var(--elem-bg);
  border: 1px solid var(--elem-border);
  border-radius: 2px;
  padding: 2px 8px;
  margin-bottom: 12px;
}

.element-runner-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--ink-primary);
  line-height: 1.25;
}

.element-runner-cue {
  margin: 12px 0 0;
  font-size: 1.05rem;
  color: var(--ink-secondary);
  line-height: 1.45;
  word-wrap: break-word;
}

.element-runner-upnext {
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid var(--border-hairline);
  font-size: 0.84rem;
  color: var(--ink-muted);
}

.element-runner-upnext strong {
  color: var(--ink-secondary);
}

/* Add Worship Element Modal */
#elementPickerModal.modal-backdrop {
  align-items: center;
  padding: 16px;
}

.element-picker-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.element-picker-row {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--border-hairline);
  background: var(--bg-surface);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  cursor: pointer;
  color: var(--ink-primary);
  font-size: 0.95rem;
  font-weight: 600;
}

.element-picker-row:last-child {
  border-bottom: none;
}

.element-picker-row:active {
  background: var(--elem-bg);
}

.element-picker-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--elem-ink);
  background: var(--elem-bg);
  border: 1px solid var(--elem-border);
  border-radius: 2px;
  padding: 2px 7px;
}

html[data-readability="large"] .element-runner-title {
  font-size: 1.85rem;
}

html[data-readability="large"] .element-runner-cue {
  font-size: 1.14rem;
}

html[data-readability="large"] .element-picker-row {
  padding: 14px 16px;
  font-size: 1.02rem;
}


/* ==========================================================================
   Quick-Action Button Colors & Inline YouTube Listen Modal
   ========================================================================== */
.song-quick-actions .btn-quick-action {
  font-family: var(--font-sans);
  font-size: 0.79rem;
  font-weight: 600;
  line-height: 1.2;
}

html[data-readability="large"] .song-quick-actions .btn-quick-action {
  font-size: 0.88rem;
}

.btn-quick-setlist {
  color: #2A5B3C;
  background: #EBF5EE;
  border-color: #BCDCC6;
}

html[data-theme="dark"] .btn-quick-setlist {
  color: #9ED8B0;
  background: #1C3124;
  border-color: #325941;
}

.btn-quick-sung {
  color: var(--accent-dark);
  border-color: #DFB9C0;
  background: var(--accent-tint);
}

html[data-theme="dark"] .btn-quick-sung {
  color: #F2C9CF;
  background: #361F23;
  border-color: #63343C;
}

#listenModal.modal-backdrop {
  align-items: center;
  padding: 16px;
}

.modal-listen {
  max-width: 560px;
}

.listen-video-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000000;
}

.listen-video-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* ==========================================================================
   Song Page Icon Actions, Bottom Resources, External Link Icons & About Contact
   ========================================================================== */
.about-contact {
  margin-top: 8px !important;
}

.about-email-link {
  color: var(--accent);
  text-decoration: underline;
}

.ext-link-inline {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.ext-link-icon {
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
}

/* Borderless Icon-Only + Setlist & Mark Sung Buttons */
.btn-icon-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  flex-shrink: 0;
}

.btn-icon-action:active {
  background: var(--bg-subtle);
}

.btn-icon-setlist {
  color: var(--accent);
}

html[data-theme="dark"] .btn-icon-setlist {
  color: #E26D7C;
}

/* Flat Rounded-Square Green Checkmark (Light & Dark inverted versions) */
.btn-icon-sung .sung-box {
  fill: #2A6B42;
}

.btn-icon-sung .sung-check {
  stroke: #FFFFFF;
}

html[data-theme="dark"] .btn-icon-sung .sung-box {
  fill: #78C693;
}

html[data-theme="dark"] .btn-icon-sung .sung-check {
  stroke: #161413;
}

html[data-readability="large"] .btn-icon-action {
  width: 40px;
  height: 40px;
}

html[data-readability="large"] .btn-icon-action svg {
  width: 26px;
  height: 26px;
}

/* Bottom Listen on YouTube & Hymn Studies Blog Row */
.song-bottom-resources {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.song-bottom-resources .btn-quick-action {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.2;
}

html[data-readability="large"] .song-bottom-resources .btn-quick-action {
  font-size: 0.9rem;
}

.scripture-link-arrow {
  display: inline-flex;
  align-items: center;
  opacity: 0.85;
}

/* ==========================================================================
   Header Centering, High-Res / Full Swap, Larger Icons, & Single-Line Links
   ========================================================================== */

/* Keep < #450 > centered and [Key] [☆] right-aligned on both mobile & desktop */
.detail-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}

.detail-header .btn-back {
  grid-column: 1;
  justify-self: start;
}

.detail-header-title {
  grid-column: 2;
  justify-self: center;
}

.detail-header-actions {
  grid-column: 3;
  justify-self: end;
}

/* Swap High-Res (neutral) and Full (red accent) button color schemes */
.btn-highres {
  border-color: var(--ink-secondary);
  color: var(--ink-primary);
}

.btn-highres.loaded {
  background: var(--bg-subtle);
  color: var(--ink-secondary);
}

.btn-fullscreen {
  border-color: var(--accent);
  color: var(--accent);
}

/* Larger Add-to-Setlist & Mark-Sung icons with extra horizontal spacing, no extra vertical bulk */
.song-title-block {
  margin-bottom: 6px;
}

.song-quick-actions {
  margin-top: 4px;
  gap: 8px;
}

.btn-icon-action {
  width: auto;
  height: 32px;
  padding: 0 10px;
}

.btn-icon-setlist svg {
  width: 28px;
  height: 28px;
}

.btn-icon-sung svg {
  width: 26px;
  height: 26px;
}

html[data-readability="large"] .btn-icon-action {
  width: auto;
  height: 36px;
  padding: 0 12px;
}

html[data-readability="large"] .btn-icon-setlist svg {
  width: 31px;
  height: 31px;
}

html[data-readability="large"] .btn-icon-sung svg {
  width: 29px;
  height: 29px;
}

/* Bottom Resource Buttons (fit 3 on 1 line on mobile in standard readability) */
.song-bottom-resources {
  gap: 5px;
}

.song-bottom-resources .btn-quick-action {
  padding: 5px 8px;
  font-size: 0.75rem;
  white-space: nowrap;
}

.song-bottom-resources .btn-quick-link {
  color: #000000;
}

html[data-theme="dark"] .song-bottom-resources .btn-quick-link {
  color: #FFFFFF;
}

html[data-readability="large"] .song-bottom-resources {
  gap: 8px;
}

html[data-readability="large"] .song-bottom-resources .btn-quick-action {
  padding: 7px 12px;
  font-size: 0.88rem;
}

.list-legal-footer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 12px;
  font-size: 0.72rem;
  color: var(--ink-muted);
  background: var(--bg-paper);
  border-top: 1px solid var(--border-hairline);
}
.list-legal-footer a {
  color: var(--accent);
  text-decoration: underline;
  white-space: nowrap;
}

.list-legal-footer.is-hidden-footer {
  display: none;
}