/* Taranim design layer, Phase 1 (layout, sizes, spacing, alignment).
   Loaded after Tailwind. Colours here are the CURRENT look, held in tokens
   so Phase 2 (identity) changes values in one place. */

:root {
  --t-header-h: 56px;
  --t-dock-h: 64px; --t-dock-gap: 12px;
  /* space the floating dock occupies from the bottom edge (height + inset); the safe-area inset is added where it is used */
  --t-player-h: calc(var(--t-dock-h) + var(--t-dock-gap));
  --t-tap: 44px;
  /* Palette: Deep Forest Green / Warm Ivory / Muted Copper / Charcoal */
  --t-forest: #1F3D2B; --t-forest-2: #2D5A40;
  --t-ivory: #F7F1E3;  --t-copper: #B87333; --t-copper-ink: #8A531F; --t-charcoal: #2B2B2B;
  --t-bg: #F7F1E3;
  --t-surface: #FFFCF5;
  --t-surface-2: #EFE7D3;
  --t-text: #2B2B2B;
  --t-text-2: #5A554B;
  --t-border: #E0D5BA;
  --t-primary: #1F3D2B;
  --t-primary-ink: #F7F1E3;
  --t-accent: #B87333;
  --t-accent-text: #8A531F;
  --t-play: #1F3D2B;
  --t-playing: #9A5A22;       /* copper, white text 5.3:1 */
  --t-neutral-btn: #3A3A36;
  --t-badge: #A8431F;
  --t-shadow: 0 1px 2px rgba(43,43,43,.06), 0 6px 18px rgba(31,61,43,.08);
  --t-radius: 14px;
  --t-safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
html[data-theme="dark"] {
  --t-bg: #111812; --t-surface: #1A241D; --t-surface-2: #24322A;
  --t-text: #EDE7D6; --t-text-2: #B3AE9F; --t-border: #2E3E34;
  --t-primary: #7DBE98; --t-primary-ink: #0E1A12;
  --t-accent: #D9A066; --t-accent-text: #E0AE7C;
  --t-play: #2F6B4A; --t-playing: #A8602A; --t-neutral-btn: #34423A;
  --t-badge: #C4552B;
  --t-shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.35);
  color-scheme: dark;
}

html { -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; }

/* ---------- Header ---------- */
.t-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--t-surface);
  border-bottom: 1px solid var(--t-border);
}
.t-header__row {
  max-width: 56rem; margin: 0 auto;
  height: var(--t-header-h);
  padding: 0 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.t-brand {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 17px; line-height: 1.2; color: var(--t-text);
  white-space: nowrap; min-width: 0;
}
.t-brand__mark { font-size: 20px; line-height: 1; }
.t-actions { display: flex; align-items: center; gap: 2px; min-width: 0; }
.t-navlink {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--t-tap); min-width: var(--t-tap);
  padding: 0 12px; border-radius: 999px;
  font-size: 14px; line-height: 1; color: var(--t-text-2);
  white-space: nowrap; text-decoration: none;
  transition: background-color .15s ease;
}
.t-navlink:hover, .t-navlink:focus-visible { background: var(--t-surface-2); }
.t-navlink--accent { color: var(--t-primary); font-weight: 600; }
.t-iconbtn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: var(--t-tap); height: var(--t-tap); border-radius: 999px;
  font-size: 18px; line-height: 1; background: transparent;
}
.t-iconbtn:hover, .t-iconbtn:focus-visible { background: var(--t-surface-2); }
.t-badge {
  position: absolute; top: 4px; left: 2px;
  min-width: 18px; height: 18px; padding: 0 4px;
  border-radius: 999px; background: var(--t-badge); color: #fff;
  font-size: 11px; font-weight: 600; line-height: 18px; text-align: center;
}
.t-userbtn {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px; max-width: 132px;
  padding: 0 12px; border-radius: 999px;
  background: var(--t-surface-2); color: var(--t-text);
  font-size: 14px; font-weight: 600; line-height: 1;
}
.t-userbtn__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-userbtn__chev { font-size: 10px; opacity: .7; }
.t-loginbtn {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 16px;
  border-radius: 999px; background: var(--t-primary); color: var(--t-primary-ink);
  font-size: 14px; font-weight: 600; text-decoration: none;
}

/* second row on phones: three equal tabs, scrolls away with the page */
.t-subnav { display: none; }
@media (max-width: 639px) {
  .t-navlink--desk { display: none; }
  .t-subnav {
    display: grid; grid-template-columns: repeat(3, 1fr);
    background: var(--t-surface); border-bottom: 1px solid var(--t-border);
  }
  .t-subnav .t-navlink {
    border-radius: 0; min-height: var(--t-tap); font-size: 13px; padding: 0 4px;
  }
}
@media (min-width: 640px) { :root { --t-header-h: 60px; } }

/* ---------- Filters bar (chips + search) ---------- */
.t-filters {
  position: sticky; top: var(--t-header-h); z-index: 40;
  transition: transform .2s ease;
  background: color-mix(in srgb, var(--t-bg) 94%, transparent);
  border-bottom: 1px solid var(--t-border);
}
.t-filters__in { max-width: 56rem; margin: 0 auto; padding: 10px 16px 12px; }
.t-chips {
  display: flex; gap: 8px; overflow-x: auto; white-space: nowrap;
  padding: 2px 2px 10px; margin: 0 -2px;
  scrollbar-width: none; -ms-overflow-style: none;
  /* soft fade on the end edge hints more chips are scrollable */
  -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 28px), transparent);
          mask-image: linear-gradient(to left, #000 calc(100% - 28px), transparent);
}
.t-chips::-webkit-scrollbar { display: none; }
.t-chips .filter-btn {
  flex: 0 0 auto; min-height: var(--t-tap); padding: 0 16px;
  border: 1px solid var(--t-border); border-radius: 999px;
  background: var(--t-surface); color: var(--t-text);
  font-size: 14px; line-height: 1;
}
.t-chips .filter-btn.bg-gray-200 { background: var(--t-primary); color: var(--t-primary-ink); border-color: var(--t-primary); }
.t-search {
  width: 100%; min-height: var(--t-tap); padding: 0 14px;
  border: 1px solid var(--t-border); border-radius: var(--t-radius);
  background: var(--t-surface); color: var(--t-text); font-size: 16px; /* 16px stops iOS zoom */
}
.t-search:focus { outline: 2px solid var(--t-primary); outline-offset: 1px; }

/* ---------- Page frame ---------- */
.t-main { max-width: 56rem; margin: 0 auto; padding: 20px 16px calc(var(--t-player-h) + var(--t-safe-b) + 24px); }
.t-title { font-size: 22px; font-weight: 700; line-height: 1.3; margin: 4px 0 16px; color: var(--t-text); }
.t-footer { text-align: center; font-size: 13px; color: var(--t-text-2); padding: 8px 16px 20px; }

/* ---------- Hymn list rows (offline page) ---------- */
.t-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; margin-bottom: 10px;
  background: var(--t-surface); border: 1px solid var(--t-border); border-radius: var(--t-radius);
}
.t-row__text { min-width: 0; flex: 1 1 auto; }
.t-row__title { display: block; font-size: 16px; font-weight: 600; line-height: 1.4; color: var(--t-text); }
.t-row__meta { display: block; font-size: 13px; color: var(--t-text-2); margin-top: 2px; }
.t-row__actions { display: flex; gap: 8px; flex: 0 0 auto; }
@media (min-width: 820px) {
  .t-row { padding: 14px 18px; }
}

/* ---------- Buttons (play / download) ---------- */
.play-btn {
  min-height: var(--t-tap); min-width: 84px; padding: 0 16px;
  border-radius: 10px; font-size: 14px; font-weight: 600; line-height: 1;
  background-color: var(--t-play); color: #fff;
}
.play-btn.bg-red-600 { background-color: var(--t-playing); }
.play-btn.bg-green-600 { background-color: var(--t-play); }
.download-btn {
  width: var(--t-tap); height: var(--t-tap); min-width: var(--t-tap); padding: 0;
  border-radius: 10px; font-size: 16px; line-height: 1;
  background-color: var(--t-neutral-btn); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
}
.download-progress { height: 3px; }

/* ---------- Mini player: a floating inset dock, 64px tall, never touches the page edges ---------- */
.t-player {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 50;
  width: min(620px, calc(100vw - 24px)); height: var(--t-dock-h);
  bottom: calc(var(--t-dock-gap) + var(--t-safe-b));
  background: var(--t-surface); border: 1px solid var(--t-border); border-radius: 16px;
  box-shadow: 0 10px 32px rgba(31,61,43,.22);
  padding: 0 8px; box-sizing: border-box; overflow: visible;
}
.t-player__in { display: flex; align-items: center; gap: 8px; height: 100%; max-width: none; margin: 0; }
.t-player__art { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; flex: 0 0 auto; background: var(--t-forest); }
.t-player__block { position: relative; flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 8px; height: 100%; }
/* the whole block (cover + title + times) is one tap target; the seek input sits above it */
.t-player__open { position: absolute; inset: 4px -2px; border-radius: 12px; background: transparent; border: 0; padding: 0; cursor: pointer; }
.t-player__open:focus { outline: none; }
.t-player__open:focus-visible { outline: 2px solid var(--t-playing); outline-offset: 0; background: rgba(154,90,34,.10); }
/* expand glyph over the cover's corner: costs no layout space */
.t-player__open::after {
  content: ""; position: absolute; top: 2px; inset-inline-start: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: rgba(0,0,0,.58) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4.5 9.8 8 6.3l3.5 3.5' fill='none' stroke='%23fff' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 16px 16px no-repeat;
  opacity: .6; transition: opacity .15s; pointer-events: none;
}
.t-player__open:hover::after, .t-player__open:focus-visible::after, .t-player__block:hover .t-player__open::after { opacity: 1; }
.t-player__art, .t-player__title, .t-player__time span { pointer-events: none; }
.t-player__time input[type=range] { position: relative; z-index: 1; }
.t-player__mid { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 0; }
.t-player__title {
  display: block; font-size: 13px; font-weight: 600; line-height: 20px; color: var(--t-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 0; text-align: start;
}
.t-player__time { display: flex; align-items: center; gap: 6px; font-size: 11px; line-height: 16px; color: var(--t-text-2); font-variant-numeric: tabular-nums; direction: ltr; }
.t-player__time span { flex: 0 0 auto; min-width: 2.4em; }
#currentTime { text-align: left; } #duration { text-align: right; }
.t-player__time input[type=range] { flex: 1 1 auto; min-width: 0; height: 16px; margin: 0; }
.t-player__controls { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; margin: 0; }
.t-player .t-ctl { width: 34px; height: 34px; font-size: 15px; }
.t-player .t-ctl--main { width: 40px; height: 40px; font-size: 17px; }
/* narrow screens: mode and volume stay reachable in the full player */
@media (max-width: 519px) {
  .t-player { padding: 0 6px; }
  .t-player__in { gap: 6px; }
  .t-player__art { width: 40px; height: 40px; border-radius: 8px; }
  .t-player .t-ctl { width: 30px; height: 30px; font-size: 14px; }
  .t-player .t-ctl--main { width: 36px; height: 36px; font-size: 16px; }
  .t-player__controls { gap: 0; }
  .t-player__time { gap: 4px; }
  .t-player__time span { min-width: 0; }
}
.t-ctl {
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--t-tap); height: var(--t-tap); border-radius: 999px;
  background: var(--t-surface-2); color: var(--t-text);
  font-size: 18px; line-height: 1; flex-shrink: 0; aspect-ratio: 1 / 1;
}
.t-ctl--main { width: 56px; height: 56px; background: var(--t-play); color: #fff; font-size: 20px; }
/* prev/next glyphs point the wrong way in RTL: mirror them */
[dir="rtl"] #prevBtn, [dir="rtl"] #nextBtn,
[dir="rtl"] #fullPrevBtn, [dir="rtl"] #fullNextBtn { transform: scaleX(-1); }
.t-loading { position: fixed; left: 50%; transform: translateX(-50%); width: min(620px, calc(100vw - 24px)); bottom: calc(var(--t-player-h) + var(--t-safe-b)); z-index: 40; }

/* ---------- Online app: hymn cards ---------- */
.hymn-item { margin-bottom: 16px; gap: 0 !important; }
.hymn-cover { height: 200px; }
@media (min-width: 820px) { .hymn-cover { height: 240px; } }
.hymn-body { height: 76px; padding: 0 14px !important; justify-content: center; }
.hymn-actions { padding-top: 0 !important; border-top: 0 !important; gap: 8px; }
.hymn-item .absolute.bottom-20 { bottom: 76px; }   /* title strip sits on the cover edge, no blank band */
.hymn-item .text-\[10px\] { font-size: 12px; }      /* category label under 12px was unreadable */
.like-btn, .hymn-actions > button:not(.play-btn):not(.download-btn) {
  min-height: var(--t-tap); min-width: var(--t-tap); padding: 0 10px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.fav-btn { width: var(--t-tap); height: var(--t-tap); display: inline-flex; align-items: center; justify-content: center; font-size: 28px; line-height: 1; }
.add-friend-btn { min-width: 32px; min-height: 32px; }

/* ---------- About page ---------- */
.t-page { max-width: 48rem; margin: 0 auto; padding: 16px; }
.t-topbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.t-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--t-tap); padding: 0 16px; border-radius: 10px;
  font-size: 14px; font-weight: 600; text-decoration: none; color: #fff;
}
.t-btn--primary { background: var(--t-primary); }
.t-btn--neutral { background: var(--t-neutral-btn); }
.t-prose { background: var(--t-surface); border: 1px solid var(--t-border); border-radius: 16px; padding: 24px 20px; }
.t-prose h1 { font-size: 24px; font-weight: 700; margin: 0 0 16px; text-align: center; }
.t-prose h2 { font-size: 18px; font-weight: 600; margin: 28px 0 8px; }
.t-prose p, .t-prose li { font-size: 16px; line-height: 1.9; color: var(--t-text-2); }
.t-prose p { margin: 0 0 14px; }
.t-prose ul { padding-inline-start: 20px; list-style: disc; }
@media (min-width: 820px) { .t-prose { padding: 36px 44px; } }

@media (prefers-reduced-motion: reduce) {
  .play-btn, .t-filters, .playing { animation: none !important; transition: none !important; }
}

/* ---------- Downloaded-hymns page (hymns.html) ---------- */
.t-filters--inline { padding: 8px 16px 0; margin: 0 -16px 12px; }
.t-filters--inline .t-chips { padding-bottom: 12px; }
.chip.active { background: var(--t-primary) !important; color: var(--t-primary-ink) !important; border-color: var(--t-primary) !important; box-shadow: none !important; }
.chip { flex: 0 0 auto; min-height: var(--t-tap); padding: 0 16px !important; font-size: 14px !important; font-weight: 500 !important;
  border: 1px solid var(--t-border); border-radius: 999px; background: var(--t-surface) !important; color: var(--t-text) !important; transform: none !important; }
#downloadedGrid { padding-bottom: 8px; }
.t-topbar .t-btn { flex: 1 1 200px; }

/* =====================================================================
   PHASE 2: identity (fonts, palette, icons, dark mode)
   ===================================================================== */
@font-face { font-family: "IBM Plex Sans Arabic"; font-weight: 400; font-display: swap; src: url(../fonts/plex-arabic-400.woff2) format("woff2"); unicode-range: U+0600-06FF,U+0750-077F,U+08A0-08FF,U+FB50-FDFF,U+FE70-FEFF,U+200C-200F; }
@font-face { font-family: "IBM Plex Sans Arabic"; font-weight: 500; font-display: swap; src: url(../fonts/plex-arabic-500.woff2) format("woff2"); unicode-range: U+0600-06FF,U+0750-077F,U+08A0-08FF,U+FB50-FDFF,U+FE70-FEFF,U+200C-200F; }
@font-face { font-family: "IBM Plex Sans Arabic"; font-weight: 600; font-display: swap; src: url(../fonts/plex-arabic-600.woff2) format("woff2"); unicode-range: U+0600-06FF,U+0750-077F,U+08A0-08FF,U+FB50-FDFF,U+FE70-FEFF,U+200C-200F; }
@font-face { font-family: "IBM Plex Sans Arabic"; font-weight: 700; font-display: swap; src: url(../fonts/plex-arabic-700.woff2) format("woff2"); unicode-range: U+0600-06FF,U+0750-077F,U+08A0-08FF,U+FB50-FDFF,U+FE70-FEFF,U+200C-200F; }
@font-face { font-family: "Inter"; font-weight: 400; font-display: swap; src: url(../fonts/inter-400.woff2) format("woff2"); unicode-range: U+0000-00FF,U+0131,U+2000-206F,U+20AC,U+2212; }
@font-face { font-family: "Inter"; font-weight: 600; font-display: swap; src: url(../fonts/inter-600.woff2) format("woff2"); unicode-range: U+0000-00FF,U+0131,U+2000-206F,U+20AC,U+2212; }
@font-face { font-family: "Inter"; font-weight: 700; font-display: swap; src: url(../fonts/inter-700.woff2) format("woff2"); unicode-range: U+0000-00FF,U+0131,U+2000-206F,U+20AC,U+2212; }

html body, html body button, html body input, html body select, html body textarea {
  font-family: "Inter", "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
}
html body { background: var(--t-bg) !important; color: var(--t-text) !important; line-height: 1.6; }
html[data-theme="dark"] body { background-image: none !important; }

/* Tailwind utility classes still used by the app scripts, mapped to the palette */
html body .bg-gray-50, html body .bg-gray-100 { background-color: var(--t-bg) !important; }
html body .bg-white { background-color: var(--t-surface) !important; }
html body .bg-gray-200 { background-color: var(--t-surface-2) !important; color: var(--t-text) !important; }
html body .bg-gray-400, html body .bg-gray-600, html body .bg-gray-700 { background-color: var(--t-neutral-btn) !important; color: #fff !important; }
html body .bg-green-600, html body .bg-green-500 { background-color: var(--t-play) !important; color: #fff !important; }
html body .bg-red-600, html body .bg-red-500 { background-color: var(--t-playing) !important; color: #fff !important; }
html body .bg-blue-600, html body .bg-blue-700, html body .bg-indigo-600 { background-color: var(--t-primary) !important; color: var(--t-primary-ink) !important; }
html body .hover\:bg-blue-700:hover, html body .hover\:bg-green-700:hover, html body .hover\:bg-red-700:hover { filter: brightness(1.12); }
html body .text-gray-800, html body .text-gray-700 { color: var(--t-text) !important; }
html body .text-gray-600, html body .text-gray-500, html body .text-gray-400 { color: var(--t-text-2) !important; }
html body .text-blue-600, html body .text-green-600, html body .text-indigo-600 { color: var(--t-primary) !important; }
html body .text-red-600 { color: var(--t-badge) !important; }
html body .text-yellow-400, html body .text-yellow-500, html body .text-yellow-600 { color: var(--t-accent) !important; }
html body .border-gray-200, html body .border-gray-300 { border-color: var(--t-border) !important; }
html body .shadow, html body .shadow-md, html body .shadow-lg, html body .shadow-sm { box-shadow: var(--t-shadow) !important; }
html body .bg-gradient-to-r.from-green-400 { background-image: linear-gradient(90deg, var(--t-accent), var(--t-primary)) !important; }
html body .bg-gradient-to-br.from-blue-500, html body .bg-gradient-to-br.from-sky-400 {
  background-image: radial-gradient(circle at 80% 15%, rgba(184,115,51,.55), transparent 55%), linear-gradient(145deg, #2D5A40, #1F3D2B 70%) !important; color: #F7F1E3;
}
html body input[type="range"] { accent-color: var(--t-accent); }

/* Header: ivory/forest with a thin copper line, brand mark in a rounded tile */
.t-header { box-shadow: 0 1px 0 var(--t-border), 0 2px 0 color-mix(in srgb, var(--t-accent) 35%, transparent); }
.t-brand { letter-spacing: -.01em; color: var(--t-primary); font-weight: 700; }
.t-brand__mark {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 10px;
  background: var(--t-forest); color: var(--t-ivory); font-size: 18px;
  box-shadow: inset 0 -3px 0 var(--t-copper);
}
.t-navlink--accent { color: var(--t-accent-text); }
.t-userbtn { background: var(--t-surface-2); border: 1px solid var(--t-border); }
.t-userbtn__chev .ti { width: .9em; height: .9em; }
.t-loginbtn { background: var(--t-forest); color: var(--t-ivory); }
html[data-theme="dark"] .t-brand__mark { background: var(--t-ivory); color: var(--t-forest); }

/* Cards and rows: warm surface, soft forest shadow, copper hairline on top */
.hymn-item, .t-row, .t-prose { background: var(--t-surface) !important; border: 1px solid var(--t-border); box-shadow: var(--t-shadow); border-radius: var(--t-radius); }
.t-title { color: var(--t-primary); letter-spacing: -.01em; }
.t-title::after { content: ""; display: block; width: 44px; height: 3px; border-radius: 3px; background: var(--t-accent); margin-top: 8px; }
.t-prose h1, .t-prose h2 { color: var(--t-primary); }
.t-chips .filter-btn, .chip { font-weight: 500; }
.t-chips .filter-btn:hover, .chip:hover { border-color: var(--t-accent); }
.t-search:focus, :focus-visible { outline-color: var(--t-accent); }
.t-btn--primary { background: var(--t-forest); color: var(--t-ivory); }
html[data-theme="dark"] .t-btn--primary { background: var(--t-play); color: #fff; }
.t-btn--neutral { background: var(--t-surface-2); color: var(--t-text); border: 1px solid var(--t-border); }
.download-btn { background-color: var(--t-surface-2) !important; color: var(--t-text) !important; border: 1px solid var(--t-border); }
.t-ctl { border: 1px solid var(--t-border); }
.t-ctl--main { border: 0; box-shadow: 0 4px 12px rgba(31,61,43,.35); }

/* Inline SVG icons */
.ti { display: inline-block; width: 1.15em; height: 1.15em; vertical-align: -.2em; flex: 0 0 auto; }
.t-ctl .ti, .t-iconbtn .ti { width: 1.25em; height: 1.25em; vertical-align: middle; }
.t-ctl--main .ti { width: 1.4em; height: 1.4em; }
.fav-btn .ti { width: 1em; height: 1em; color: var(--t-accent); }
.fav-btn:not(.active) .ti-star-fill { opacity: 1; }
.ti-check-circle { color: var(--t-primary); }
.ti-x-circle { color: var(--t-badge); }
.t-badge .ti { display: none; }
/* prev/next are mirrored for RTL in Phase 1; arrow icons we draw stay as drawn */
[dir="rtl"] .ti-arrow-right { transform: scaleX(-1); }
.like-btn.liked .ti-thumb { fill: currentColor; }
.fav-btn.favorited .ti-star-fill, .fav-btn.active .ti-star-fill { fill: currentColor; }

/* Page backdrop (replaces the old blue wash) */
html body::before {
  background: radial-gradient(120% 60% at 90% 0%, rgba(184,115,51,.14), transparent 60%),
              linear-gradient(180deg, #F7F1E3 0%, #EFE7D3 100%) !important;
  filter: none !important;
}
html[data-theme="dark"] body::before {
  background: radial-gradient(120% 60% at 90% 0%, rgba(217,160,102,.10), transparent 60%),
              linear-gradient(180deg, #111812 0%, #0D130F 100%) !important;
}
html body.playing-bg::before {
  background-image: linear-gradient(rgba(31,61,43,.62), rgba(31,61,43,.62)), var(--bg-image) !important;
  background-size: cover !important; background-position: center !important;
  filter: blur(34px) saturate(115%) !important;
}
.like-btn.liked .like-icon, .like-btn.liked { color: var(--t-primary); }
.like-btn.liked { background-color: var(--t-surface-2); border-color: var(--t-border); }
.like-icon { color: var(--t-text-2); }
html body .bg-white\/90 { background-color: color-mix(in srgb, var(--t-surface) 90%, transparent) !important; }
html body .bg-black\/25, html body .bg-black\/30 { background-color: rgba(17,24,18,.55) !important; }

/* =====================================================================
   PHASE 3: components and layout
   ===================================================================== */

/* ---- Navigation: current page marker ---- */
.t-navlink[aria-current="page"] { color: var(--t-primary); font-weight: 700; background: var(--t-surface-2); }
.t-subnav .t-navlink[aria-current="page"] { background: transparent; box-shadow: inset 0 -3px 0 var(--t-accent); }

/* ---- Wider frame and grids on tablet / laptop ---- */
@media (min-width: 820px) {
  .t-header__row, .t-filters__in, .t-player__in { max-width: 72rem; }
  .t-header__row { padding: 0 24px; }
  .t-main { max-width: 72rem; padding-left: 24px; padding-right: 24px; }
}
/* minmax(0, 1fr), not 1fr: a bare 1fr takes its minimum from the widest
   child's min-content, and the filter chips row is wider than a phone, so the
   whole page grew and scrolled sideways. */
.t-main { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.t-main > * { min-width: 0; }
.t-main > *:not(.hymn-item):not(.t-row) { grid-column: 1 / -1; }
.t-main > .hymn-item, .t-main > .t-row { margin-bottom: 0; }
@media (min-width: 720px)  { .t-main { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; } }
@media (min-width: 1180px) { .t-main { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
/* The hymn rows live inside #hymnList, not directly under .t-main, so the grid
   above never reached them and desktop showed one oversized column. Make the
   list itself the grid on tablet and up; below 720px it stays one column. */
@media (min-width: 720px) {
  #hymnList { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: stretch; }
  #hymnList > .hymn-item { margin-bottom: 0; height: 100%; }
}
@media (min-width: 1180px) { #hymnList { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.t-main > .t-row { height: 100%; }
@media (min-width: 720px) {
  .t-main > .t-row { flex-wrap: wrap; align-content: center; }
}

/* ---- Hymn cards: lift on hover, tidier action row ---- */
.hymn-item { overflow: hidden; transition: transform .18s ease, box-shadow .18s ease; }
@media (hover: hover) { .hymn-item:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(43,43,43,.08), 0 14px 28px rgba(31,61,43,.14); } }
.hymn-cover { width: 100%; object-fit: cover; background: var(--t-forest); }
.hymn-body { gap: 4px; }
.hymn-actions { display: flex; align-items: center; justify-content: space-between; }
.hymn-actions .play-btn { flex: 1 1 auto; max-width: 160px; }
@media (min-width: 1180px) { .hymn-cover { height: 190px; } }

/* ---- Full player ---- */
#fullPlayer { background: var(--t-bg) !important; color: var(--t-text); }
#fullPlayer > .absolute { opacity: .28; }
/* The blurred cover is an absolutely positioned layer. Without this it painted over every
   non-positioned sibling, so real taps on close, play, seek and the mode button hit the
   background instead of the control. */
/* the site header is z 60 (profile panel), so the full player has to sit above it or it hides the close and mode buttons on phones */
#fullPlayer { z-index: 70; }
#fullBg { z-index: 0; pointer-events: none; }
#fullPlayer > :not(#fullBg) { position: relative; z-index: 1; }
html[data-theme="dark"] #fullPlayer > .absolute { opacity: .22; }
#fullPlayer .border-b { border-color: var(--t-border) !important; }
#fullPlayer #closeFullPlayer, #fullPlayer #fullShuffleBtn {
  width: var(--t-tap); height: var(--t-tap); display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px; background: var(--t-surface-2) !important; color: var(--t-text); opacity: 1; font-size: 20px; }
#fullPlayer .t-modechip { display: inline-flex; align-items: center; gap: 2px; height: var(--t-tap); padding-inline-end: 14px; border-radius: 999px; background: var(--t-surface-2); }
#fullPlayer .t-modechip #fullShuffleBtn { background: transparent !important; }
#fullPlayer #fullModeLabel { font-size: 13px; font-weight: 600; color: var(--t-text); cursor: pointer; white-space: nowrap; }
body.fp-open #miniPlayer { visibility: hidden; }
#fullPlayer .bg-gradient-to-br { background: none !important; width: auto; height: auto; box-shadow: none; }
#fullCover { width: min(72vw, 300px); height: min(72vw, 300px); border-radius: 24px;
  box-shadow: 0 18px 44px rgba(31,61,43,.35); border: 1px solid color-mix(in srgb, var(--t-accent) 50%, transparent); }
#fullNowTitle { color: var(--t-text) !important; }
#fullPlayer > .flex-1 { max-width: 560px; width: 100%; margin: 0 auto; }
#fullPlayer .flex.items-center.justify-center.gap-4 button, #fullPlayer .flex-1 button { color: var(--t-text); }
#fullPlayer input[type=range] { accent-color: var(--t-accent); }
@media (min-width: 900px) {
  #fullPlayer { left: 50% !important; right: auto !important; width: 560px; margin-left: -280px; top: 24px; bottom: 24px;
    border-radius: 28px; border: 1px solid var(--t-border); box-shadow: 0 30px 80px rgba(0,0,0,.35); overflow: hidden; }
}
@media (max-height: 640px) { #fullCover { width: 140px; height: 140px; } }

/* ---- Friends / Chats ---- */
.t-friends { padding-top: 16px; }
#friendsSearchBar { top: calc(var(--t-header-h) + 8px); background: var(--t-surface) !important; border: 1px solid var(--t-border); border-radius: var(--t-radius); box-shadow: var(--t-shadow) !important; }
#friendsSearchBar input { background: var(--t-surface-2); border: 1px solid var(--t-border); color: var(--t-text); min-height: var(--t-tap); border-radius: 12px; font-size: 16px; }
#friendsSearchBar input:focus { outline: 2px solid var(--t-accent); box-shadow: none; }
.t-friends nav.flex { gap: 4px; }
.t-friends .tab-btn { min-height: var(--t-tap); padding: 0 14px; font-size: 15px; border-bottom-width: 3px; }
.t-friends .tab-btn.border-blue-600, html body .border-blue-600 { border-color: var(--t-accent) !important; color: var(--t-primary) !important; }
html body .hover\:text-blue-600:hover { color: var(--t-primary) !important; }
.t-friends .border-b { border-color: var(--t-border) !important; }
.t-friends .rounded-xl.shadow { background: var(--t-surface) !important; border: 1px solid var(--t-border); }
#chatBox, #chatFriends { border-radius: var(--t-radius); }
#chatBox input, #chatBox textarea, .t-friends input[type=text] { background: var(--t-surface-2); color: var(--t-text); border-color: var(--t-border); }
.t-friends button.bg-blue-600, .t-friends button.bg-green-600, .t-friends a.bg-blue-600 { min-height: 40px; border-radius: 10px; }
.t-friends .bg-blue-100 { background-color: color-mix(in srgb, var(--t-primary) 14%, var(--t-surface)) !important; color: var(--t-text) !important; }
.t-friends .bg-gray-100 { background-color: var(--t-surface-2) !important; color: var(--t-text) !important; }
#chatLayout { align-items: stretch; }
@media (min-width: 1000px) { .t-friends { max-width: 64rem; } #chatBox { height: 72vh; } }

/* ---- About page ---- */
.t-hero { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 18px; }
.t-hero__mark { width: 56px; height: 56px; border-radius: 18px; font-size: 28px; }
.t-hero h1 { margin: 0; }
.t-prose { position: relative; }
.t-prose h2 { display: flex; align-items: center; gap: 10px; }
.t-prose h2::before { content: ""; width: 4px; height: 1.1em; border-radius: 3px; background: var(--t-accent); }
@media (min-width: 820px) { .t-page { max-width: 52rem; padding-top: 28px; } }

/* ---- Login / register / other pages that use the shared head ---- */
html body.min-h-screen .rounded.shadow, html body form { border-radius: var(--t-radius); }
html body a.bg-blue-600, html body button.bg-blue-600 { border-radius: 12px; min-height: var(--t-tap); display: inline-flex; align-items: center; justify-content: center; }
html body input[type=text], html body input[type=password], html body input[type=email], html body input[type=number], html body input[type=tel], html body select, html body textarea {
  background-color: var(--t-surface); color: var(--t-text); border-color: var(--t-border); }
html body input::placeholder { color: var(--t-text-2); opacity: .8; }

/* ---- Admin and settings pages ---- */
.t-admin { max-width: 64rem; margin: 0 auto; padding: 20px 16px 48px; }
.t-admin > h1 { font-size: 22px; font-weight: 700; color: var(--t-primary); margin: 4px 0 18px !important; }
.t-admin > h1::after { content: ""; display: block; width: 44px; height: 3px; border-radius: 3px; background: var(--t-accent); margin-top: 8px; }
.t-admin .bg-white.rounded, .t-admin details.bg-white, html body.min-h-screen > .bg-white {
  border: 1px solid var(--t-border); border-radius: var(--t-radius) !important; box-shadow: var(--t-shadow) !important; }
.t-admin .grid > .bg-white { padding: 20px; border-top: 3px solid var(--t-accent); }
.t-admin .grid > .bg-white h3 { font-size: 15px; color: var(--t-text-2); margin-bottom: 6px; }
.t-admin .text-3xl { color: var(--t-primary) !important; font-weight: 700; font-variant-numeric: tabular-nums; }
.t-admin .border-purple-600, .t-admin .border-t-4 { border-top-color: var(--t-accent) !important; }
html body .text-blue-500, html body .text-blue-800, html body .text-purple-600, html body .hover\:text-blue-800:hover { color: var(--t-primary) !important; }
.t-admin a.hover\:underline, .t-admin a.underline { min-height: 32px; display: inline-flex; align-items: center; font-weight: 600; }
.t-admin form[action*="logout"] button { color: var(--t-badge) !important; min-height: var(--t-tap); font-weight: 600; }
.t-admin button.bg-green-600, .t-admin button.bg-red-600, .t-admin button.bg-blue-600 { min-height: var(--t-tap); padding: 0 20px; border-radius: 12px; font-weight: 600; }
.t-admin button.bg-red-600 { background-color: var(--t-badge) !important; }
.t-admin input:not([type=hidden]):not([type=file]), .t-admin select, .t-admin textarea { min-height: var(--t-tap); border-radius: 10px; padding: 0 12px; font-size: 16px; background: var(--t-surface-2); }
.t-admin input[type=file] { padding: 8px 0; font-size: 14px; }
.t-admin input:focus, .t-admin select:focus { outline: 2px solid var(--t-accent); outline-offset: 1px; }
.t-admin form.max-w-md, .t-admin .max-w-md { max-width: 32rem; }
.t-admin .bg-green-100 { background-color: color-mix(in srgb, var(--t-primary) 14%, var(--t-surface)) !important; color: var(--t-text) !important; }
.t-admin .bg-red-100 { background-color: color-mix(in srgb, var(--t-badge) 16%, var(--t-surface)) !important; color: var(--t-text) !important; }
.t-admin .text-green-800, .t-admin .text-red-800 { color: var(--t-text) !important; }
.t-admin [style*="fff3cd"] { background: color-mix(in srgb, var(--t-accent) 16%, var(--t-surface)) !important; border-color: var(--t-accent) !important; color: var(--t-text); border-radius: var(--t-radius) !important; padding: 14px !important; font-size: 14px !important; }
.t-admin > .bg-white p, .t-admin > .bg-white b { color: var(--t-text); }
@media (min-width: 900px) {
  .t-admin > .bg-white.p-4.mb-4 { padding: 20px 24px; }
}
/* login-type pages (centered card) */
html body.min-h-screen .bg-white, html body.h-screen .bg-white { border: 1px solid var(--t-border); border-radius: 18px !important; box-shadow: var(--t-shadow) !important; }

/* ---- Phase 5 QA fixes ---- */
.t-brand { min-height: var(--t-tap); }
#fullPrevBtn, #fullNextBtn, #prevBtn, #nextBtn { min-width: var(--t-tap); min-height: var(--t-tap); display: inline-flex; align-items: center; justify-content: center; }
#fullPlayer #fullPrevBtn .ti, #fullPlayer #fullNextBtn .ti { width: 1.1em; height: 1.1em; }
#notifDropdown button, #userDropdown a, #userDropdown button { min-height: var(--t-tap); }
.t-friends button.text-red-600, .t-friends button.hover\:underline { min-height: var(--t-tap); padding: 0 10px; font-size: 13px; }
.t-badge { font-size: 12px; }
.t-userbtn__chev { font-size: 12px; }

/* ---------- Base styles moved out of page-inline <style> (app-shell refactor) ---------- */
.hymn-item {
  display: flex; flex-direction: column; gap: 10px;
  border-radius: 16px; overflow: hidden;
  box-shadow: 0 4px 14px rgba(0,0,0,.08);
  background: #fff; position: relative;
}
.hymn-cover { width: 100%; height: 180px; object-fit: cover; background: #e5e7eb; display: block; }
.hymn-body { padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.hymn-actions {
  display: flex; justify-content: space-between; align-items: center;
  border-top: 1px solid #eee; padding-top: 8px;
}

@keyframes pulse {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.08); }
  100% { transform: scale(1); }
}
.playing { animation: pulse 1s infinite; }

.play-btn { transition: transform 0.08s ease, box-shadow 0.08s ease; }
.play-btn:active { transform: scale(0.96); box-shadow: inset 0 2px 6px rgba(0,0,0,0.25); }

.like-icon { color: #9ca3af; }
.like-btn.liked .like-icon { color: #2563eb; }
.like-btn.liked {
  border: 1px solid #d1d5db; background-color: #f3f4f6;
  border-radius: 9999px; padding: 2px 8px;
}

/* Page backdrop base (colors/overrides live above with the theme rules) */
body::before {
  content: ''; position: fixed; inset: 0; z-index: -1;
  background: linear-gradient(135deg, #e8f2ff 0%, #cfe4ff 50%, #b6d4ff 100%);
  transition: background-image 0.6s ease, filter 0.6s ease;
}

#loadingBar.hidden { display: none; }
#fullPlayer { pointer-events: none; }
#fullPlayer:not(.translate-y-full) { pointer-events: auto; }

@keyframes marquee-rtl {
  0%   { transform: translateX(0%); }
  100% { transform: translateX(-100%); }
}
.animate-marquee { animation: marquee-rtl 10s linear infinite; }

/* PJAX: content fades slightly while the next page loads */
#app { transition: opacity 0.12s ease; }
#app.pjax-loading { opacity: 0.55; pointer-events: none; }

/* ---------- Login gate (router notice) ----------
   Shown when a page answers a logged-out visitor with a redirect to the login
   page. It replaces a full page load, so the shell and the audio element stay
   alive and the music keeps playing. */
.t-gate {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--t-player-h) + var(--t-safe-b) + 16px);
  z-index: 60; display: flex; align-items: center; gap: 12px;
  max-width: min(92vw, 520px); padding: 12px 14px;
  background: var(--t-primary, #1F3D2B); color: #fff;
  border-radius: 14px; box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
  font-size: 0.95rem; line-height: 1.5;
}
.t-gate__text { flex: 1 1 auto; }
.t-gate__btn {
  flex: 0 0 auto; background: #fff; color: var(--t-primary, #1F3D2B);
  font-weight: 700; padding: 8px 14px; border-radius: 10px; white-space: nowrap;
}
.t-gate__x {
  flex: 0 0 auto; background: transparent; border: 0; color: #fff;
  opacity: 0.75; font-size: 1rem; line-height: 1; padding: 6px; cursor: pointer;
}
@media (max-width: 480px) {
  .t-gate {
    left: 12px; right: 12px; transform: none; max-width: none;
    flex-direction: column; align-items: stretch; gap: 8px;
    padding: 10px 12px 12px;
  }
  .t-gate__text { font-size: 0.9rem; padding-inline-end: 22px; }
  .t-gate__btn { text-align: center; }
  .t-gate__x { position: absolute; top: 2px; inset-inline-end: 4px; padding: 6px; }
}

/* Offline mode: the list is a mode, not a dead end. The note states the mode
   and carries the way back, matching the nav switch. */
.t-offline-note {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 8px 12px; margin: 0 0 14px; padding: 12px 14px;
  background: var(--t-surface-2); border: 1px solid var(--t-border);
  border-radius: var(--t-radius); color: var(--t-text-2);
  font-size: 14px; line-height: 1.5;
}
.t-offline-note__link {
  color: var(--t-accent-text); font-weight: 700; text-decoration: underline;
  white-space: nowrap;
}

/* Seek inputs run left to right even inside the RTL shell, so the fill and the
   thumb follow the numbers (elapsed left, duration right) instead of mirroring. */

/* The profile panel is an overlay inside the sticky header: it must paint above
   the page content and above the player bar, and it must never grow taller than
   the space above the bar or the logout button ends up underneath it. */
.t-header { z-index: 60; }
#userDropdown {
  z-index: 60;
  max-height: calc(100vh - var(--t-header-h) - var(--t-player-h) - var(--t-safe-b) - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* ======== Ledger player (direction A): solid card, 1px border, copper only on play + seek fill ======== */
.t-player { background: var(--t-surface); border: 1px solid var(--t-border); border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.18); }
.t-player__art { width: 44px; height: 44px; border-radius: 10px; }
.t-player__title { font-size: 14px; font-weight: 600; line-height: 20px; }
/* RTL: the time row follows the page direction, elapsed on the right */
.t-player__time { direction: rtl; font-size: 11px; gap: 8px; }
.t-player__time span { min-width: 0; pointer-events: none; }
#currentTime, #duration { text-align: center; }
.t-player .t-ctl { width: 34px; height: 34px; border: 0; background: transparent; color: var(--t-text-2); box-shadow: none; }
.t-player .t-ctl--main { width: 40px; height: 40px; background: var(--t-accent); color: #1a1208; box-shadow: none; }
.t-player .t-ctl--main .ti { width: 1.2em; height: 1.2em; }
.t-player__open::after { display: none; }
.t-player__open:focus-visible { outline: 2px solid var(--t-text); background: transparent; }
@media (max-width: 519px) {
  .t-player__art { width: 44px; height: 44px; border-radius: 10px; }
  .t-player .t-ctl { width: 28px; height: 28px; }
  .t-player .t-ctl--main { width: 40px; height: 40px; }
  .t-player { padding: 0 8px; }
  .t-player__in, .t-player__block { gap: 8px; }
  .t-player__time { gap: 6px; }
}

/* range inputs: 4px rail, fill from the start (right in RTL) via --p */
#seek, #fullSeek, #volumeSlider {
  -webkit-appearance: none; appearance: none; background: transparent; direction: rtl; width: 100%; margin: 0; cursor: pointer;
  --fill: var(--t-accent); --rail: var(--t-border); --p: 0%;
}
#volumeSlider { --fill: var(--t-text-2); --p: 100%; }
#seek::-webkit-slider-runnable-track, #fullSeek::-webkit-slider-runnable-track, #volumeSlider::-webkit-slider-runnable-track {
  height: 4px; border-radius: 4px; background: linear-gradient(to left, var(--fill) var(--p), var(--rail) var(--p)); }
#seek::-moz-range-track, #fullSeek::-moz-range-track, #volumeSlider::-moz-range-track { height: 4px; border-radius: 4px; background: var(--rail); }
#seek::-moz-range-progress, #fullSeek::-moz-range-progress, #volumeSlider::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--fill); }
#seek::-webkit-slider-thumb { -webkit-appearance: none; width: 0; height: 0; border: 0; }
#seek::-moz-range-thumb { width: 0; height: 0; border: 0; background: transparent; }
#fullSeek::-webkit-slider-thumb, #volumeSlider::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; margin-top: -5px; background: var(--t-text); border: 0; }
#fullSeek::-moz-range-thumb, #volumeSlider::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--t-text); border: 0; }
#volumeSlider::-webkit-slider-thumb { width: 12px; height: 12px; margin-top: -4px; background: var(--t-text-2); }
#seek:focus-visible, #fullSeek:focus-visible, #volumeSlider:focus-visible { outline: 2px solid var(--t-text); outline-offset: 4px; border-radius: 4px; }
#seek { height: 16px; }
#fullSeek, #volumeSlider { height: 24px; }

/* full player */
#fullPlayer { background: var(--t-surface) !important; }
#fullBg { display: none; }
@media (min-width: 900px) { #fullPlayer { border-radius: 18px; } }
#fullCover { width: min(300px, 78vw); height: min(300px, 78vw); border-radius: 18px; box-shadow: none; border: 1px solid var(--t-border); }
.t-fulltitle { width: 100%; max-width: 480px; text-align: start; }
#fullNowTitle { font-size: 22px; font-weight: 700; line-height: 1.35; color: var(--t-text) !important; white-space: normal; }
#fullNowSub { font-size: 14px; color: var(--t-text-2); margin-top: 4px; }
.t-fulltimes { display: flex; justify-content: space-between; width: 100%; max-width: 480px; font-size: 11px; color: var(--t-text-2); font-variant-numeric: tabular-nums; margin-top: -14px; direction: rtl; }
#fullPlayer .flex-1 > .flex.items-center.gap-3 { max-width: 480px; }
#fullPlayer #fullPlayBtn { width: 68px; height: 68px; border-radius: 50%; background: var(--t-accent) !important; color: #1a1208 !important; box-shadow: none; }
#fullPlayer #fullPlayBtn .ti { width: 1.4em; height: 1.4em; }
#fullPlayer #fullPrevBtn, #fullPlayer #fullNextBtn { width: 48px; height: 48px; min-width: 48px; min-height: 48px; color: var(--t-text); }
#fullPlayer #muteBtn { background: transparent !important; color: var(--t-text-2); width: 40px; height: 40px; font-size: 18px; }
#fullPlayer #closeFullPlayer, #fullPlayer .t-modechip { background: transparent; border: 1px solid var(--t-border); }
#fullPlayer #closeFullPlayer { background: transparent !important; }
#fullPlayer .t-modechip #fullShuffleBtn { background: transparent !important; }
/* desktop: the panel is inset 24px top and bottom, so a plain 100% slide left its top 24px (and shadow) on screen under the dock */
@media (min-width: 900px) { #fullPlayer.translate-y-full { transform: translateY(calc(100% + 140px)); } }
@media (max-width: 359px) {
  .t-player { padding: 0 6px; }
  .t-player__in, .t-player__block { gap: 6px; }
  .t-player__art { width: 40px; height: 40px; }
  .t-player .t-ctl, #prevBtn, #nextBtn { min-width: 36px; width: 36px; }
  .t-player__time { gap: 4px; }
}

/* ======== Full player fits any viewport height (cover box is sized by CSS only, never by the image) ======== */
#fullPlayer {
  --fp-chrome: 0px;                         /* vertical inset of the panel (24px top + 24px bottom on desktop) */
  --fp-head: 77px;                          /* header row */
  --fp-g: clamp(6px, 2.2dvh, 22px);         /* gap between blocks */
  --fp-play: clamp(52px, 8.5dvh, 68px);
  /* everything except the cover: header, 8 gaps, title+subtitle (54, plus 30 for a second title line), seek 24, times 18, play, volume 24, 16 slack */
  --fp-cover: min(78vw, clamp(96px, calc(100dvh - var(--fp-chrome) - var(--fp-head) - 8 * var(--fp-g) - 54px - 30px - 24px - 18px - var(--fp-play) - 24px - 16px), 300px));
  max-height: 100dvh;
}
@media (min-width: 900px) { #fullPlayer { --fp-chrome: 48px; max-height: calc(100dvh - 48px); } }
@media (max-height: 700px) { #fullPlayer { --fp-head: 61px; } #fullPlayer > .border-b { padding: 8px 16px; } }
#fullCover { width: var(--fp-cover); height: var(--fp-cover); }
#fullPlayer > .flex-1 { gap: var(--fp-g); padding: var(--fp-g) 24px; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
#fullPlayer > .flex-1 > .mt-4 { margin-top: 0; }
#fullPlayer .t-fulltimes { margin-top: calc(var(--fp-g) * -0.6); }
#fullPlayer #fullNowTitle { font-size: clamp(18px, 3dvh, 22px); line-height: 1.3; }
#fullPlayer #fullPlayBtn { width: var(--fp-play); height: var(--fp-play); }
@media (max-height: 560px) {
  #fullPlayer #fullPrevBtn, #fullPlayer #fullNextBtn { width: 44px; height: 44px; min-width: 44px; min-height: 44px; }
  #fullPlayer #fullSeek, #fullPlayer #volumeSlider { height: 20px; }
}
/* short, wide phones (landscape): cover on one side, controls on the other */
@media (max-height: 500px) and (min-width: 480px) {
  #fullPlayer { --fp-head: 61px; --fp-chrome: 0px; max-height: 100dvh; left: 0 !important; right: 0 !important; width: 100%; margin-left: 0; top: 0; bottom: 0; border-radius: 0; border: 0; box-shadow: none; }
  #fullPlayer.translate-y-full { transform: translateY(100%); }
  #fullPlayer {  --fp-cover: min(300px, calc(100dvh - 61px - 24px)); }
  #fullPlayer > .flex-1 { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-auto-rows: min-content; align-content: center;
    column-gap: 28px; max-width: 760px; padding: 8px 24px; }
  #fullPlayer > .flex-1 > :first-child { grid-row: 1 / span 5; align-self: center; }
  #fullPlayer > .flex-1 > :nth-child(n+2) { max-width: none; }
  #fullPlayer > .flex-1 > .t-fulltitle { justify-self: stretch; }
}

/* Reserve two title lines so the cover and controls never move when the next track's title wraps differently */
#fullPlayer #fullNowTitle { min-height: 2.6em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; text-align: center; } /* clamped to 2 lines so the cover and controls never move */

/* ======== Laptop: the full player is a side panel (right side, under the header) ======== */
@media (min-width: 1100px) {
  :root { --t-sp-w: 340px; }
  body { transition: padding-right .3s ease; }
  body.fp-open { padding-right: var(--t-sp-w); }
  /* the header keeps the full width */
  .t-header { transition: margin-right .3s ease; }
  body.fp-open .t-header { margin-right: calc(var(--t-sp-w) * -1); }
  #fullPlayer {
    --fp-chrome: calc(var(--t-header-h) + 1px);
    right: 0 !important; left: auto !important; margin: 0 !important;
    top: calc(var(--t-header-h) + 1px) !important; bottom: 0 !important;
    width: var(--t-sp-w) !important; max-height: none !important;
    border-radius: 0 !important; box-shadow: none !important;
    border: 0 !important; border-left: 1px solid var(--t-border) !important;
    z-index: 45;
  }
  #fullPlayer.translate-y-full { transform: translateX(100%) !important; visibility: hidden; transition: transform .3s ease, visibility 0s linear .3s; }
  #fullPlayer:not(.translate-y-full) { transform: none !important; visibility: visible; }
  #fullPlayer > .flex-1 { padding-left: 20px; padding-right: 20px; }
  #fullPlayer { --fp-cover: min(300px, clamp(96px, calc(100dvh - var(--fp-chrome) - var(--fp-head) - 8 * var(--fp-g) - 54px - 30px - 24px - 18px - var(--fp-play) - 24px - 16px), 300px)); }
}


/* ======== Karaoke lyrics in the full player (only when a timing file exists) ======== */
#fullLyrics { position: relative; width: 100%; max-width: 480px; flex: 1 1 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  text-align: right; padding: 0 8px; scrollbar-width: none;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 18%, #000 82%, transparent);
  mask-image: linear-gradient(to bottom, transparent, #000 18%, #000 82%, transparent); }
#fullLyrics::-webkit-scrollbar { display: none; }
#fullLyrics .t-lyr { color: var(--t-text-2); opacity: .55; font-size: clamp(15px, 2.4dvh, 19px); line-height: 1.55; padding: 3px 4px;
  cursor: pointer; transition: opacity .2s ease, color .2s ease; }
#fullLyrics .t-lyr.on { color: var(--t-accent); opacity: 1; font-weight: 700; }
/* lyrics take the space, so the cover steps down (still sized by CSS only, never by the image) */
#fullPlayer.has-lyrics { --fp-cover: min(52vw, clamp(64px, calc(100dvh - var(--fp-chrome) - var(--fp-head) - 9 * var(--fp-g) - 54px - 30px - 120px - 24px - 18px - var(--fp-play) - 24px - 16px), 190px)); }
/* siblings never shrink: the cover frame stays exactly its CSS size, overflow scrolls instead */
#fullPlayer > .flex-1 > * { flex-shrink: 0; }
/* the short-landscape two-column mode keeps only the controls: no room for lyrics */
@media (max-height: 500px) and (min-width: 480px) {
  #fullLyrics { display: none !important; }
  #fullPlayer.has-lyrics { --fp-cover: min(300px, calc(100dvh - 61px - 24px)); }
}
