/* ==========================================================================
   1. Global Styles & Variables
   ========================================================================== */

:root {
  /* Merged variables, preferring values from the new CSS block */
  --bg: #f1f5f9;
  --text: #1f2937;          /* slate-800 */
  --muted: #6b7280;         /* gray-500 */
  --brand: #1864a6;         /* blue-600 */
  --brand-hover: #1d4ed8;   /* blue-700 */
  --card: #f8fafc;          /* slate-50 */
  --border: #e5e7eb;        /* gray-200 */
  /* Kept from original block */
  --player-bg: #f1f5f9;     /* slate-100 */
  --hy-blue-1: #2882d1;
  --hy-blue-2: #1864a6;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji"; color: var(--text); background: var(--bg); line-height: 1.55; }
body.with-pinned-sidebar { padding-left: 320px; }
.no-scroll { overflow: hidden; }

/* ==========================================================================
   2. Application Shell (Global Header & Sidebar)
   ========================================================================== */

/* --- Header --- */
.hymns-app-header { position: sticky; top: 0; z-index: 1000; background: linear-gradient(to bottom, var(--hy-blue-1), var(--hy-blue-2)); color: #fff; padding: 12px 14px; transition: transform 0.25s ease; }
.hymns-app-header.header-hidden { transform: translateY(-100%); }
.hymns-app-header > .bar { display: flex; align-items: center; gap: 12px; max-width: 1200px; margin: 0 auto; }
.hymns-app-header .hymns-header-left, .hymns-app-header .hymns-header-right { display: flex; align-items: center; gap: 10px; }
.hymns-app-header .hymns-header-center { flex: 1; }
.hymns-app-header a { color: #fff; text-decoration: none; }
.logo-img { display: block; height: 32px; width: auto; }
.hymns-title-group { display: flex; flex-direction: column; line-height: 1; }
.hymns-title { font-weight: 700; font-size: 18px; }
.hymns-slogan { opacity: .85; font-size: 12px; margin-top: 4px; }
.hymns-menu-btn, .hymns-user-btn { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 10px; border: 0; cursor: pointer; background: rgba(255, 255, 255, .12); color: #fff; }
.hymns-user-btn .hymns-tools-label-text { margin-left: 6px; font-weight: 600; }

/* --- Tools Dropdown --- */
.hymns-user-dropdown { position: relative; }
.hymns-user-dropdown ul { display: none; list-style: none; margin: 0; padding: 6px; position: absolute; right: 0; top: 42px; min-width: 210px; background: var(--card); border-radius: 10px; border: 1px solid var(--border); box-shadow: 0 8px 24px rgba(0, 0, 0, .12); z-index: 1200; }
.hymns-user-dropdown ul.show { display: block; }
.hymns-user-dropdown li a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; text-decoration: none; color: var(--text); }
.hymns-user-dropdown li a:hover { background: var(--player-bg); }

/* --- Sidebar --- */
.hymns-sidebar { position: fixed; top: 0; left: 0; height: 100dvh; width: 320px; background: #fff; border-right: 1px solid var(--border); transform: translateX(-100%); transition: transform 0.25s ease, width 0.2s ease; z-index: 1300; display: flex; flex-direction: column; }
.hymns-sidebar.open, .hymns-sidebar.pinned { transform: translateX(0); }
.hymns-sidebar-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-bottom: 1px solid #eef1f4; background: #f8fafc; }
.hymns-sidebar-header .hymns-logo-link { display: flex; align-items: center; gap: 8px; text-decoration: none; }
.hymns-sidebar-header .hymns-title { color: #0f172a; font-weight: 700; font-size: 18px; }
.hymns-sidebar-header .logo-img { height: 32px; width: auto; }
.hymns-close-btn { width: 38px; height: 38px; border-radius: 10px; border: 0; background: #e5e7eb; cursor: pointer; }
.hymns-sidebar-content { padding: 10px 8px; overflow: auto; flex-grow: 1; }
.hymns-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; cursor: pointer; user-select: none; padding: 10px 12px; margin: 6px 8px; border-radius: 10px; background: #f8fafc; font-size: 14px; font-weight: 700; color: #0f172a; }
.hymns-section-heading .hymns-chevron { transition: transform 0.2s ease; }
.hymns-section-heading.is-open .hymns-chevron { transform: rotate(180deg); }
.hymns-nav-primary, .hymns-nav-secondary, .hymns-nav-tertiary { list-style: none; margin: 8px; padding: 0; }
.hymns-nav-item { margin: 2px 0; }
.hymns-nav-link { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 10px; text-decoration: none; color: #0f172a; }
.hymns-nav-link:hover { background: #eef2f7; }
.hymns-nav-link i { width: 20px; text-align: center; opacity: .9; }
.has-submenu > .hymns-submenu { list-style: none; margin: 6px 0 6px 38px; padding: 6px; border-left: 2px solid var(--border); display: block; }
.has-submenu.collapsed > .hymns-submenu { display: none; }

/* ==========================================================================
   3. Page-Specific (Hymn Index Page)
   ========================================================================== */
.container { max-width: 800px; margin: 0 auto; padding: 5px 16px 96px; }
header { margin-bottom: 16px; }
header h1 { margin: 0 0 8px; font-size: clamp(1.4rem, 2.5vw, 2rem); letter-spacing: 0.2px; }
header p { margin: 0; color: var(--muted); }
.alphabet { background: linear-gradient(var(--bg), var(--bg)); padding: 10px 0; border-bottom: 1px solid var(--border); display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 6px; }
.alphabet button { padding: 13px; font-weight: bold; color: #15549c; background-color: #f8f8f8; border: 1px solid #ddd; border-radius: 8px; cursor: pointer; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); transition: transform 0.06s ease, background 0.2s ease, color 0.2s ease, border-color 0.2s ease; }
.alphabet button:hover:not(:disabled) { background: var(--card); transform: translateY(-1px); }
.alphabet button:disabled { opacity: 0.35; cursor: not-allowed; background: #f1f5f9; }
.alphabet .hide-other-button { opacity: 0.25; }
.search-container { margin: 14px 0 22px; }
.search-container input[type="text"] { width: 100%; font-size: 1rem; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; outline: none; background: #fff; transition: box-shadow .15s ease, border-color .15s ease; }
.search-container input[type="text"]:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12); }
.song-list h2 { margin: 26px 0 8px; font-size: 1.85rem; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.song-list h2.num-section::after { content: "  (0–9)"; color: var(--muted); font-weight: 400; font-size: 0.95rem; }
.song-list h2.other-section::after { content: "  (Other)"; color: var(--muted); font-weight: 400; font-size: 0.95rem; }
.hymn-list { list-style: none; padding: 0; margin: 0; }
.hymn-list li { border-bottom: 1px dashed var(--border); }
.hymn-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 2px; }
.hymn-title { text-decoration: none; color: var(--text); font-weight: 600; font-size: 17px; }
.hymn-title:hover { text-decoration: underline; }
.hymn-icons { color: var(--muted); display: flex; gap: 10px; font-size: 0.95rem; }
.hymn-icons a { color: inherit; text-decoration: none; }
.hymn-icons a:hover { color: var(--brand); }
.hymn-icons i[title] { cursor: default;color:lightgray; }
.alpha-sticky { position: sticky; top: 0; z-index: 20; background: linear-gradient(var(--bg), var(--bg)); border-bottom: 1px solid var(--border); }
.alpha-sticky .alphabet { position: static; }
.alpha-toggle { width: 100%; background: none; border: 0; padding: 6px 0 10px; color: var(--brand); font-weight: 700; cursor: pointer; display: none; align-items: center; justify-content: center; gap: 6px; }
.alpha-sticky.expanded .alpha-toggle i.fa-chevron-down { display:none; }
.alpha-sticky.expanded .alpha-toggle i.fa-chevron-up { display:inline-block; }
.alpha-sticky.collapsed .alpha-toggle i.fa-chevron-up { display:none; }

/* ==========================================================================
   4. Page-Specific (Hymn Detail Page)
   ========================================================================== */

.page-wrapper { max-width: 1000px; margin: 24px auto; padding: 0 14px; }
.back-arrow-button { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 18px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); color: var(--text); font-weight: 700; text-decoration: none; transition: background-color 0.2s ease, border-color .2s ease, transform .05s ease; }
.back-arrow-button:hover { background-color: #eef2f7; border-color: #dce3ef; }
.back-arrow-button:active { transform: translateY(1px); }
.entry-header { margin-bottom: 8px; }
.entry-title { margin: 0; font-size: clamp(2rem, 4.8vw, 3rem); font-weight: 800; text-align: center; letter-spacing: -0.5px; }
.tabs-container { display: flex; justify-content: center; padding: 8px 8px 0; border-bottom: 0; }
.tabs { display: flex; align-items: center; gap: 6px; list-style: none; padding: 0; margin: 0; }
.tabs.tabs--single { gap: 0; }
.tab-item { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 14px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, .1); background: var(--brand); color: #fff; font-weight: 700; text-align: center; cursor: pointer; box-shadow: 0 4px 12px rgba(40, 130, 209, .25); }
.tab-item:not(.active) { opacity: .8; }
.tab-item:hover { background-color: var(--brand-hover); }
#custom-audio-player { background: var(--card); border-radius: 12px; border: 1px solid var(--border); box-shadow: 0 6px 22px rgba(0, 0, 0, 0.07); margin: 10px 0 20px; }
.player-controls { display: grid; grid-template-columns: auto 1fr auto auto auto auto; align-items: center; gap: 12px; padding: 14px 16px; }
#play-pause { display: inline-flex; align-items: center; justify-content: center; width: 56px; height: 56px; border-radius: 50%; border: none; background: var(--brand); color: #fff; font-size: 1.25rem; cursor: pointer; box-shadow: 0 10px 26px rgba(40, 130, 209, .35); transition: transform .06s ease; }
#play-pause:active { transform: translateY(1px); }
.control-btn { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%; border: none; background: none; color: var(--muted); font-size: 1.1rem; cursor: pointer; transition: background-color 0.2s ease, color .2s ease; }
.control-btn:hover { background-color: var(--player-bg); color: var(--text); }
#progress-container { position: relative; height: 6px; cursor: pointer; min-width: 140px; margin-bottom: 23px; }
#progress-bar { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; background: var(--border); outline: none; border-radius: 999px; margin: 0; padding: 0; min-width: 0; }
#progress-bar::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 16px; height: 16px; background: var(--brand); cursor: pointer; border-radius: 50%; margin-top: -5px; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); }
#progress-bar::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--brand); border: none; }
.time-display { color: var(--muted); font-size: 0.9rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.font-adjustment-controls { text-align: right; margin: 6px 0 10px; }
.font-adjustment-controls button { width: 44px; height: 36px; margin-left: 6px; border: 1px solid var(--border); border-radius: 8px; background-color: var(--card); cursor: pointer; font-weight: 800; transition: background-color 0.2s ease, border-color 0.2s ease; }
.font-adjustment-controls button:hover { background-color: var(--player-bg); border-color: #d1d5db; }
#lyrics-content {
  background-color: #fff;
  padding: 24px;
  border-radius: 12px;
  border: 1px solid var(--border);
  font-size: 16px;
  line-height: 1.75;
  white-space: pre-wrap;
  text-indent: 0;    /* 🚫 prevent automatic first-line indent */
  margin-left: 0;    /* 🚫 reset container margin */
  padding-left: 24px;/* keep consistent padding, no extra offset */
}

#lyrics-content strong {
  font-weight: 800;
}

#lyrics-content em {
  font-style: italic;
}

.share-container, .related-hymns { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--border); }
.share-text { font-weight: 700; margin-right: 12px; }
.share-icon { margin: 0 6px; color: var(--muted); font-size: 1.5rem; text-decoration: none; cursor: pointer; transition: color 0.2s ease, transform 0.2s ease; }
.share-icon:hover { color: var(--brand); transform: scale(1.1); }
.related-hymns h3 { margin-top: 0; }
.related-hymns ul { list-style: none; padding: 0; margin: 0; }
.related-hymns li a { display: block; padding: 10px; border-radius: 8px; text-decoration: none; color: var(--text); }
.related-hymns li a:hover { background-color: var(--player-bg); color: var(--brand); }

/* ==========================================================================
   5. Components & Utilities
   ========================================================================== */
.hidden { display: none; }
#error-message { padding: 15px; border: 1px solid #d9534f; border-radius: 8px; color: #d9534f; background-color: #f2dede; }
.fav-badge { display: inline-block; min-width: 1.25em; padding: .1em .45em; border-radius: 999px; background: #fff; color: #1864a6; font-weight: 800; font-size: .8em; margin-left: .4em; }
.fav-btn .star-on { display: none; }
.fav-btn.is-faved .star-off { display: none; }
.fav-btn.is-faved .star-on { display: inline; }
#back-to-top-button { position: fixed; bottom: 30px; right: 30px; z-index: 1000; opacity: 0; visibility: hidden; transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out, transform 0.12s ease; background-color: #3498db; color: white; border: none; border-radius: 50%; width: 50px; height: 50px; font-size: 1.2em; cursor: pointer; box-shadow: 0 4px 10px rgba(0,0,0,0.2); display: flex; align-items: center; justify-content: center; }
#back-to-top-button:hover { background-color: #2980b9; transform: translateY(-2px); }
#back-to-top-button.show { opacity: 1; visibility: visible; }

/* ==========================================================================
   6. Responsive Styles
   ========================================================================== */

@media (min-width: 768px) {
  .logo-img { height: 40px; }
}

@media (min-width: 1024px) {
  .hymns-sidebar { transform: translateX(-100%); }
  .hymns-sidebar.pinned { transform: none; }
}

/* Mobile: keep the controls on ONE line */
@media (max-width: 480px){
  .player-controls{
    display: grid;
    grid-auto-flow: column;    /* place items left→right in a single row */
    grid-auto-columns: 1fr;    /* equal widths (use max-content if you want tight buttons) */
    gap: 10px;
    overflow-x: auto;          /* no wrapping; scroll if it can’t all fit */
  }
  #progress-container {display:none;}
}


@media (max-width: 520px) {
  /* Hymn Index Page */
  .alphabet, .alpha-sticky .alphabet { grid-template-columns: repeat(8, minmax(0, 1fr)); }
  .hymn-item { flex-wrap: wrap; gap: 6px; }
  .alpha-sticky.stuck .alpha-toggle { display: flex; }
  .alpha-sticky.stuck.collapsed .alphabet button:nth-child(n+9) { display: none; }
  .alpha-sticky.stuck { box-shadow: 0 1px 0 var(--border); }
}