/* 고척교회 찬양 아카이브 */
:root {
  --navy: #1a3a6b;
  --navy-d: #12294d;
  --gold: #c8a24a;
  --bg: #f4f6fa;
  --card: #ffffff;
  --ink: #1c2430;
  --sub: #6a7688;
  --line: #e3e8f0;
  --shadow: 0 2px 12px rgba(26, 58, 107, .08);
}
html.dark {
  --bg: #0f141c;
  --card: #182230;
  --ink: #e8edf5;
  --sub: #93a1b5;
  --line: #26313f;
  --shadow: 0 2px 12px rgba(0, 0, 0, .35);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "Noto Sans KR", system-ui, sans-serif;
  background: var(--bg); color: var(--ink);
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;   /* 가로 밀림/넘침 방지 */
}
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }

/* ---------- 스플래시 ---------- */
#splash {
  position: fixed; inset: 0; z-index: 999;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, var(--navy), var(--navy-d));
  transition: opacity .4s;
}
#splash.hide { opacity: 0; pointer-events: none; }
.splash-inner { text-align: center; color: #fff; }
/* 로고만 흰 배경(액자) 위에 */
#splash-logo {
  box-sizing: content-box; width: 84px; height: auto; padding: 16px; margin: 0 auto 20px;
  background: #fff; border-radius: 22px; box-shadow: 0 8px 24px rgba(0,0,0,.28);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.07); } }
@media (prefers-reduced-motion: reduce) { #splash-logo { animation: none; } }
.splash-title { font-size: 20px; font-weight: 800; letter-spacing: .5px; }
.splash-sub { margin-top: 8px; font-size: 13px; opacity: .85; }
.splash-ver { margin-top: 22px; font-size: 11px; opacity: .5; }

/* ---------- 상단바 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 16px;
  background: linear-gradient(160deg, var(--navy), var(--navy-d));
  color: #fff; box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { width: 38px; height: 38px; object-fit: contain; }
.brand-txt { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-txt b { font-size: 17px; font-weight: 800; }
.brand-txt span { font-size: 11px; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  background: rgba(255,255,255,.15); border: none; color: #fff;
  width: 38px; height: 38px; border-radius: 50%; font-size: 17px; flex: none;
}

/* ---------- 컨트롤 ---------- */
#app { max-width: 1100px; margin: 0 auto; padding: 14px 14px 96px; }
#controls { display: flex; flex-direction: column; gap: 10px; }
.search-row input {
  width: 100%; padding: 12px 16px; font-size: 15px;
  border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--card); color: var(--ink);
}
.search-row input:focus { outline: none; border-color: var(--navy); }
.tab-row { display: flex; gap: 8px; }
.tab {
  flex: 1; padding: 10px; font-size: 14px; font-weight: 700;
  border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--sub);
}
.tab.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.fav-toggle {
  padding: 10px 14px; font-size: 13px; font-weight: 700;
  border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--sub); flex: none;
}
.fav-toggle.on { background: var(--gold); color: #fff; border-color: var(--gold); }
.chip-row { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  padding: 7px 14px; font-size: 13px; border-radius: 20px;
  border: 1.5px solid var(--line); background: var(--card); color: var(--sub);
}
.chip.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.sort-row { display: flex; justify-content: flex-end; }
.sort-row select {
  padding: 8px 12px; font-size: 13px; border-radius: 8px;
  border: 1.5px solid var(--line); background: var(--card); color: var(--ink);
}
/* 구분·찬양대·정렬 드롭다운 */
.filter-row { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-row .sel {
  flex: 1; min-width: 100px; padding: 10px 12px; font-size: 13.5px; font-weight: 600;
  border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--ink); cursor: pointer;
}
.filter-row .sel:focus { outline: none; border-color: var(--navy); }
/* 기간(From ~ To) */
.period-row { display: flex; align-items: center; gap: 5px; }
.period-row .date {
  flex: 1; min-width: 0; padding: 9px 4px; font-size: 13px; font-weight: 600; text-align: center;
  border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--ink); font-family: inherit;
}
.period-row .date::-webkit-datetime-edit { text-align: center; }
.period-row .date:focus { outline: none; border-color: var(--navy); }
.period-row .tilde { color: var(--sub); font-weight: 700; flex: none; }
.period-row .period-all {
  flex: none; padding: 10px 14px; font-size: 12.5px; font-weight: 700;
  border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--sub); white-space: nowrap; cursor: pointer;
}
.period-row .period-all.on { background: var(--navy); color: #fff; border-color: var(--navy); }
html.dark .period-row .date::-webkit-calendar-picker-indicator { filter: invert(1); }
.count-line { margin: 14px 2px 8px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.count-line .cnt-num { font-size: 13px; color: var(--sub); font-weight: 600; }
.count-line .cnt-right { display: flex; align-items: center; gap: 8px; }
.count-line .sort-sel { flex: none; width: auto; min-width: 0; padding: 7px 12px; font-size: 12.5px; }
.count-line .fav-toggle { padding: 7px 12px; font-size: 12.5px; }

/* 필터 트리거 버튼(탭하면 바텀시트) */
.filter-btn {
  flex: 1; min-width: 0; padding: 11px 12px; font-size: 13.5px; font-weight: 600;
  border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--ink); cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
}
.filter-btn > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filter-btn::after { content: "▾"; color: var(--sub); font-size: 11px; flex: none; }
.period-row .filter-btn { padding: 10px 8px; font-size: 12.5px; }
.count-line .sort-btn { flex: none; width: auto; padding: 7px 10px 7px 13px; font-size: 12.5px; }

/* 바텀시트 */
#sheet { position: fixed; inset: 0; z-index: 300; }
#sheet .sheet-bg { position: absolute; inset: 0; background: rgba(0,0,0,.4); opacity: 0; transition: opacity .25s; }
#sheet.show .sheet-bg { opacity: 1; }
#sheet .sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: var(--card); border-radius: 22px 22px 0 0; overflow: hidden;
  max-height: 80vh; display: flex; flex-direction: column;
  transform: translateY(101%); transition: transform .3s cubic-bezier(.2,.8,.2,1);
  box-shadow: 0 -12px 40px rgba(0,0,0,.32);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
#sheet.show .sheet-panel { transform: translateY(0); }
.sheet-grip { width: 42px; height: 4px; border-radius: 3px; background: var(--line); margin: 10px auto 2px; }
.sheet-title { text-align: center; font-weight: 800; font-size: 15.5px; padding: 8px 16px; color: var(--ink); border-bottom: 1px solid var(--line); }
.sheet-list { flex: 1; min-height: 0; overflow-y: auto; padding: 6px 10px 16px; -webkit-overflow-scrolling: touch; }
.sheet-item {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 15px 14px; font-size: 16px; font-weight: 600;
  background: transparent; border: none; color: var(--ink); border-radius: 12px; cursor: pointer;
}
.sheet-item.on { background: rgba(26,58,107,.09); color: var(--navy); font-weight: 800; }
.sheet-item .chk { color: var(--navy); font-weight: 800; }
html.dark .sheet-item.on { background: rgba(255,255,255,.1); color: #a9c2ec; }
html.dark .sheet-item.on .chk { color: #a9c2ec; }

/* 기간 시트 */
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; padding: 4px 12px 10px; }
.psec-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 10px 2px 9px; }
.period-sheet .psec-label { font-size: 14.5px; font-weight: 800; color: var(--ink); }
.ystep { display: flex; align-items: center; gap: 6px; flex: none; }
.ybtn {
  flex: none; width: 34px; height: 38px; font-size: 19px; font-weight: 800; line-height: 1;
  border: 1.5px solid var(--line); border-radius: 9px; background: var(--card); color: var(--navy); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.psel {
  flex: none; min-width: 90px; padding: 10px 30px 10px 12px; font-size: 14.5px; font-weight: 700;
  font-family: inherit; color: var(--ink); background-color: var(--card);
  border: 1.5px solid var(--line); border-radius: 10px; cursor: pointer; -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat; background-position: right 10px center;
}
.psel:focus { outline: none; border-color: var(--navy); }
.pchip-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 5px; }
.pchip {
  padding: 11px 0; font-size: 12.5px; font-weight: 700; white-space: nowrap; overflow: hidden;
  border: 1.5px solid var(--line); border-radius: 9px; background: var(--card); color: var(--ink); cursor: pointer;
}
.pchip.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.psep { height: 1px; background: var(--line); margin: 14px 0 2px; }
.sheet-foot { display: flex; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--line); }
.sf-all { flex: 1; padding: 13px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--card); color: var(--sub); font-weight: 700; font-size: 14px; cursor: pointer; }
.sf-apply { flex: 2; padding: 13px; border: none; border-radius: 12px; background: var(--navy); color: #fff; font-weight: 800; font-size: 15px; cursor: pointer; }
.play-all {
  background: var(--navy); color: #fff; border: none;
  padding: 6px 13px; border-radius: 999px; font-size: 12px; font-weight: 700;
  white-space: nowrap;
}

/* ---------- 목록(가로형 카드) ---------- */
.grid { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 780px) { .grid { grid-template-columns: 1fr 1fr; } }
.loading, .empty { grid-column: 1 / -1; text-align: center; padding: 50px 0; color: var(--sub); }
.card {
  display: flex; align-items: center; gap: 12px; padding: 8px;
  background: var(--card); border-radius: 12px;
  box-shadow: var(--shadow); cursor: pointer;
  transition: transform .12s, box-shadow .12s;
}
.card:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(26,58,107,.14); }
.card.unsel { opacity: .45; }
/* 왼쪽 작은 썸네일 */
.thumb {
  position: relative; flex: none; width: clamp(104px, 32vw, 140px);
  aspect-ratio: 16/9; background: #000; border-radius: 8px; overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.play-ov {
  position: absolute; inset: 0; margin: auto; width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(26,58,107,.82); color: #fff; border-radius: 50%;
  font-size: 16px; opacity: 0; transition: opacity .15s;
}
.card:hover .play-ov { opacity: 1; }
/* 텍스트 3줄 */
.c-body { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 3px; }
.c-title { font-size: 15px; font-weight: 700; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-sub { font-size: 12.5px; color: var(--sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-meta { font-size: 11.5px; color: var(--sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-cat {
  display: inline-block; padding: 1px 7px; border-radius: 10px;
  background: rgba(26,58,107,.1); color: var(--navy); font-weight: 700; font-size: 11px;
}
html.dark .c-cat { background: rgba(255,255,255,.1); color: #a9c2ec; }
/* 오른쪽 액션(선택 체크 + 즐겨찾기) */
.c-actions { flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 0 2px; }
.c-actions .pick-cb { width: 20px; height: 20px; cursor: pointer; accent-color: var(--gold); }
.c-actions .star { background: transparent; border: none; font-size: 20px; line-height: 1; color: var(--sub); cursor: pointer; padding: 0; }
.c-actions .star.on { color: var(--gold); }

/* ---------- 플레이어 모달 ---------- */
.modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; }
.modal[hidden] { display: none; }
.modal-bg { position: absolute; inset: 0; background: rgba(0,0,0,.72); }
.modal-box {
  position: relative; width: min(880px, 94vw); max-height: 92vh; overflow-y: auto;
  background: var(--card); border-radius: 16px; box-shadow: 0 10px 40px rgba(0,0,0,.4);
}
.modal-x {
  position: absolute; right: 10px; top: 10px; z-index: 2;
  background: rgba(0,0,0,.5); border: none; color: #fff;
  width: 34px; height: 34px; border-radius: 50%; font-size: 15px;
}
/* 동영상 베이지 매트 액자 */
.yt-wrap { background: #f1ead9; padding: 7px; border-radius: 16px 16px 0 0; }
.yt-frame {
  position: relative; aspect-ratio: 16/9; background: #000;
  border-radius: 8px; overflow: hidden;
  box-shadow: 0 4px 14px rgba(0,0,0,.28), inset 0 0 0 0.5px rgba(0,0,0,.12);
}
.yt-frame #yt-player, .yt-frame iframe {
  position: absolute; inset: 0; width: 100% !important; height: 100% !important; border: 0;
}
@media (max-width: 480px) { .yt-wrap { padding: 5px; } }
.pl-meta { padding: 14px 18px 6px; }
.pl-meta h3 { font-size: 17px; font-weight: 800; line-height: 1.4; }
.pl-meta p { margin-top: 5px; font-size: 13px; color: var(--sub); }
.pl-controls { display: flex; flex-direction: column; gap: 12px; padding: 12px 16px 20px; }
.pl-toggles { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.pl-nav { display: flex; gap: 10px; }
.pl-btn {
  flex: 1; text-align: center;
  padding: 13px 14px; font-size: 15px; font-weight: 800;
  border: none; border-radius: 12px; cursor: pointer;
  background: var(--navy); color: #fff;
  box-shadow: 0 2px 8px rgba(26,58,107,.22);
  transition: opacity .15s, transform .08s, background .15s;
}
.pl-btn:hover:not(:disabled) { opacity: .92; }
.pl-btn:active:not(:disabled) { transform: scale(.98); }
.pl-btn:disabled { background: var(--line); color: var(--sub); box-shadow: none; cursor: default; }
html.dark .pl-btn:disabled { background: #2a3646; }
.pl-auto { font-size: 13px; color: var(--sub); display: flex; align-items: center; gap: 5px; }
.pl-auto input { width: 16px; height: 16px; accent-color: var(--navy); }
.pl-tog {
  padding: 8px 14px; font-size: 12.5px; font-weight: 700;
  border: 1.5px solid transparent; border-radius: 999px;
  background: rgba(26,58,107,.09); color: var(--navy); cursor: pointer;
  transition: background .15s, color .15s;
}
html.dark .pl-tog { background: rgba(255,255,255,.1); color: #a9c2ec; }
.pl-tog.on { background: var(--gold); color: #fff; border-color: var(--gold); }

/* ---------- 선택 바(여러 곡 담아 듣기) ---------- */
#selbar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 16px; z-index: 150;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px 10px 18px; border-radius: 999px;
  background: var(--navy); color: #fff;
  box-shadow: 0 6px 24px rgba(0,0,0,.3);
  max-width: 94vw;
}
#selbar .sb-count { font-size: 14px; font-weight: 700; white-space: nowrap; }
#selbar .sb-play {
  background: var(--gold); color: #fff; border: none;
  padding: 10px 18px; border-radius: 999px; font-size: 14px; font-weight: 800; white-space: nowrap;
}
#selbar .sb-clear {
  background: rgba(255,255,255,.15); color: #fff; border: none;
  padding: 10px 14px; border-radius: 999px; font-size: 13px; white-space: nowrap;
}
#selbar .sb-toggle {
  background: rgba(255,255,255,.15); color: #fff; border: none;
  padding: 10px 14px; border-radius: 999px; font-size: 13px; font-weight: 700; white-space: nowrap;
}
#selbar .sb-play:disabled { opacity: .4; }

/* ---------- 푸터 ---------- */
.foot { text-align: center; padding: 24px 16px 40px; font-size: 12px; color: var(--sub); }
