/* ---------- Header ---------- */
header{
  display:grid;
  grid-template-columns: 1fr auto 1fr;
  align-items:center;
  gap:16px;
  padding:14px 22px;
  border-bottom:1px solid var(--line);
  background:linear-gradient(180deg, var(--ink-soft), var(--ink));
  flex-shrink:0;
}
.header-center{ display:flex; gap:10px; justify-self:center; }
.header-center button{ font-size:14px; padding:9px 18px; }
#btn-toggle-live.live{ background:var(--vermillion); color:var(--parchment); border-color:var(--vermillion); font-weight:600; }
.brand{ display:flex; align-items:center; gap:10px; }
.brand .mark{
  font-family:var(--font-ethiopic);
  color:var(--gold);
  font-size:22px;
}
.brand h1{
  font-family:var(--font-display);
  font-weight:600;
  font-size:20px;
  margin:0;
  letter-spacing:0.02em;
}
.header-actions{ display:flex; gap:10px; align-items:center; justify-content:flex-end; flex-wrap:wrap; }
button{
  font-family:var(--font-ui);
  cursor:pointer;
  border-radius:8px;
  border:1px solid var(--line);
  background:var(--ink-softer);
  color:var(--parchment);
  padding:9px 14px;
  font-size:13px;
  font-weight:500;
  transition:background .15s ease, transform .1s ease, border-color .15s ease;
}
button:hover{ background:#3d456f; border-color:rgba(201,162,39,0.4); }
button:active{ transform:scale(0.98); }
button:disabled, select:disabled{ opacity:0.5; cursor:not-allowed; }
button:disabled:hover{ background:var(--ink-softer); }
button.primary{ background:var(--gold); color:var(--ink); border-color:var(--gold); font-weight:600; }
button.primary:hover{ background:var(--gold-bright); }
button.danger{ color:var(--vermillion); }
button.mini{ padding:5px 9px; font-size:11.5px; }
#update-status-wrap{ display:none; flex-direction:column; gap:3px; width:min(320px, 100%); }
#update-status-wrap.active{ display:flex; }
#update-status{
  font-size:12px; color:var(--text-dim); white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
#update-progress-track{
  height:4px; border-radius:2px; background:var(--ink-softer); overflow:hidden;
}
#update-progress-bar{
  height:100%; width:0%; background:var(--gold); border-radius:2px; transition:width .2s ease;
}
#btn-stop-update{ display:none; }
#btn-stop-update.active{ display:inline-block; }
#generate-latin-status-wrap{ display:none; flex-direction:column; gap:3px; width:min(320px, 100%); }
#generate-latin-status-wrap.active{ display:flex; }
#generate-latin-status{
  font-size:12px; color:var(--text-dim); white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
#generate-latin-progress-track{
  height:4px; border-radius:2px; background:var(--ink-softer); overflow:hidden;
}
#generate-latin-progress-bar{
  height:100%; width:0%; background:var(--gold); border-radius:2px; transition:width .2s ease;
}
#btn-stop-generate-latin{ display:none; }
#btn-stop-generate-latin.active{ display:inline-block; }
#dup-scan-status-wrap{ display:none; flex-direction:column; gap:3px; width:min(320px, 100%); }
#dup-scan-status-wrap.active{ display:flex; }
#dup-scan-status{
  font-size:12px; color:var(--text-dim); white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
#dup-scan-progress-track{
  height:4px; border-radius:2px; background:var(--ink-softer); overflow:hidden;
}
#dup-scan-progress-bar{
  height:100%; width:0%; background:var(--gold); border-radius:2px; transition:width .2s ease;
}
#btn-stop-dup-scan{ display:none; }
#btn-stop-dup-scan.active{ display:inline-block; }
#cleanup-scan-status-wrap{ display:none; flex-direction:column; gap:3px; width:min(320px, 100%); }
#cleanup-scan-status-wrap.active{ display:flex; }
#cleanup-scan-status{
  font-size:12px; color:var(--text-dim); white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
#cleanup-scan-progress-track{
  height:4px; border-radius:2px; background:var(--ink-softer); overflow:hidden;
}
#cleanup-scan-progress-bar{
  height:100%; width:0%; background:var(--gold); border-radius:2px; transition:width .2s ease;
}
#btn-stop-cleanup-scan{ display:none; }
#btn-stop-cleanup-scan.active{ display:inline-block; }
#cleanup-preview-saveall-progress-wrap{ display:none; flex-direction:column; gap:3px; margin-bottom:12px; }
#cleanup-preview-saveall-progress-wrap.active{ display:flex; }
#cleanup-preview-saveall-status{
  font-size:12px; color:var(--text-dim); white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
#cleanup-preview-saveall-progress-track{
  height:4px; border-radius:2px; background:var(--ink-softer); overflow:hidden;
}
#cleanup-preview-saveall-progress-bar{
  height:100%; width:0%; background:var(--gold); border-radius:2px; transition:width .2s ease;
}
#download-bible-status-wrap{ display:none; flex-direction:column; gap:3px; width:min(320px, 100%); }
#download-bible-status-wrap.active{ display:flex; }
#download-bible-status-line1, #download-bible-status-line2{
  font-size:12px; color:var(--text-dim); white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
#download-bible-progress-track{
  height:4px; border-radius:2px; background:var(--ink-softer); overflow:hidden;
}
#download-bible-progress-bar{
  height:100%; width:0%; background:var(--gold); border-radius:2px; transition:width .2s ease;
}
#btn-stop-download-bible{ display:none; }
#btn-stop-download-bible.active{ display:inline-block; }
/* Database panel splits into Song/Bible modes (see
   updateDatabasePanelForCategory()) — only one group set is visible at
   a time, matching whichever left-sidebar tab is active. */
.bible-db-group{ display:none; }
/* Database panel action rows: primary button fills the row on its own
   (Stop hidden, the common case), shrinking to make room once Stop
   becomes .active rather than the two splitting the row evenly.
   flex-basis:0 (not "auto") matters here: a wrapping flex container
   decides line breaks using each item's un-shrunk hypothetical size —
   with "auto" a long label like "Generate Latin Transcription" is wide
   enough on its own to push Stop onto its own line regardless of
   flex-shrink. Basis 0 makes the primary button contribute ~nothing to
   that decision, so both buttons pack onto one line and flex-grow then
   hands the primary button whatever space Stop doesn't need. */
#btn-update, #btn-generate-latin, #btn-find-duplicates, #btn-cleanup-songs,
#btn-export, #btn-import, #btn-download-bible,
#btn-show-bible-summary, #btn-check-bible-consistency,
#btn-export-all-bible, #btn-import-bible{ flex:1 1 0; min-width:0; }
#btn-stop-update, #btn-stop-generate-latin, #btn-stop-dup-scan,
#btn-stop-cleanup-scan, #btn-cleanup-rules, #btn-stop-download-bible{ flex:0 0 auto; }

/* ---------- Layout ---------- */
/* Two independently closable left panels (tabs, now-selected+playlist) plus
   the main column. Collapse is done via custom properties feeding the grid
   track width (not an inline grid-template-columns) so the mobile
   single-column overrides below can keep flatly winning the cascade. */
.layout{ flex:1; display:grid; grid-template-columns: var(--col-tabs-w, 340px) var(--col-now-w, 300px) 1fr; gap:0; min-height:0; }
/* min-width:0 matters once .layout collapses to a single 1fr track on
   mobile (see the @media rules below): a CSS Grid item's automatic
   min-width is "auto" (its content's min-content size), so without this
   the track — and every .panel in it — refuses to shrink below whatever
   its widest unwrapped content needs, silently causing horizontal
   overflow even though nothing here has an explicit fixed width.
   min-height:0 already existed for the same reason on the vertical
   axis (lets a scrollable child like .playlist actually get clipped by
   its ancestor's height instead of pushing it taller). */
.panel{ display:flex; flex-direction:column; min-height:0; min-width:0; }
.col-left{ border-right:1px solid var(--line); background:rgba(0,0,0,0.12); }
.col-left.collapsed{ overflow:hidden; border-right:none; }
.col-main{ background:var(--ink); }

/* ---------- Category tabs (Songs / Bible / Presentations / Multimedia) ---------- */
.category-tabs{ display:flex; gap:4px; padding:12px 16px 0; }
.category-tabs button{
  flex:1; min-width:0; padding:8px 4px; font-size:12px; background:transparent; border-radius:8px 8px 0 0;
  border-bottom:2px solid transparent; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.category-tabs button.active{ background:var(--ink-soft); border-bottom-color:var(--gold); color:var(--gold); }
.category-tabs button:disabled{ opacity:0.35; cursor:not-allowed; }
.category-tabs .icon-btn{ flex:0 0 auto; }
.category-panel{ display:flex; flex-direction:column; min-height:0; }

.section-label{
  font-size:11px; letter-spacing:0.09em; text-transform:uppercase;
  color:var(--text-dim); padding:16px 16px 8px;
}
.section-label-row{
  display:flex; align-items:center; justify-content:space-between; padding:16px 16px 8px;
}
.section-label-row .section-label{ padding:0; }
.section-label-row .actions{ display:flex; gap:6px; }
.search-header-toggles{ display:flex; align-items:center; gap:10px; }

.now-selected-strip{
  margin:10px 16px 0; padding:10px 12px; border-radius:10px;
  background:rgba(201,162,39,0.12); border:1px solid rgba(201,162,39,0.35);
}
.now-selected-label{
  font-size:10px; letter-spacing:0.08em; text-transform:uppercase; color:var(--gold);
}
.now-selected-title{ font-family:var(--font-display); font-size:14px; font-weight:600; margin-top:2px; }
.now-selected-sub{ font-size:11.5px; color:var(--text-dim); }

