/* =====================================================
   도전님 훈시 — 오디오 리더
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@300;400;500;700&family=Noto+Serif+KR:wght@400;600;700&display=swap');

/* ── 라이트 테마 (Mobirise 화이트 계열에 어울리도록) ── */
:root {
  --bg:             #F8F3EA;
  --bg2:            #EFE7D8;
  --surface:        #FFFFFF;
  --surface2:       #FAF6EF;
  --border:         #E0D4BF;
  --text:           #1C1508;
  --text2:          #6B5C46;
  --accent:         #9B6F1F;
  --accent-h:       #C08A2A;
  --gold:           #D4A930;
  --gold-glow:      rgba(212,169,48,.20);
  --active-bg:      rgba(212,169,48,.09);
  --active-bd:      #D4A930;
  --shadow-xs:      0 1px 3px rgba(0,0,0,.07);
  --shadow-sm:      0 2px 10px rgba(0,0,0,.09);
  --shadow-md:      0 4px 24px rgba(0,0,0,.12);
  --radius:         12px;
  --radius-sm:      8px;
  --player-h:       108px;
  --hdr-h:          64px;
  --font-size:      1rem;
  --ease:           cubic-bezier(.4,0,.2,1);
}

/* ── 다크 테마 ── */
[data-theme="dark"] {
  --bg:             #100C06;
  --bg2:            #180E06;
  --surface:        #1C1409;
  --surface2:       #231A0E;
  --border:         #2E2214;
  --text:           #EDE2CA;
  --text2:          #9B8B72;
  --accent:         #D4A930;
  --accent-h:       #F0C848;
  --gold:           #D4A930;
  --gold-glow:      rgba(212,169,48,.13);
  --active-bg:      rgba(212,169,48,.09);
  --active-bd:      #D4A930;
  --shadow-xs:      0 1px 2px rgba(0,0,0,.3);
  --shadow-sm:      0 2px 8px rgba(0,0,0,.45);
  --shadow-md:      0 4px 20px rgba(0,0,0,.55);
}

/* ── 리셋 ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; font-size: var(--font-size); }

/* 글자 크기 단계 */
html[data-fontsize="md"]  { --font-size: 1rem; }
html[data-fontsize="lg"]  { --font-size: 1.1rem; }
html[data-fontsize="xl"]  { --font-size: 1.22rem; }
html[data-fontsize="xxl"] { --font-size: 1.38rem; }

body {
  font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, select { font-family: inherit; }

/* =====================================================
   INDEX 페이지
   ===================================================== */
.page-index { min-height: 100dvh; }

.site-header {
  background: var(--surface);
  color: var(--text);
  padding: 20px 20px 0;
  text-align: center;
  position: relative;
  border-bottom: none;
}

.site-header::after {
  content: '';
  display: block;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, var(--gold) 30%, var(--gold) 70%, transparent 100%);
  margin-top: 16px;
}

.site-header h1 {
  font-family: 'Noto Serif KR', serif;
  font-size: 26px;
  letter-spacing: 10px;
  text-indent: 10px;
  margin-bottom: 6px;
  color: var(--accent);
  font-weight: 700;
}

.site-header .sub {
  font-size: 11px;
  color: var(--text2);
  letter-spacing: 6px;
  text-indent: 6px;
  text-transform: none;
}

/* 헤더 우측 버튼 (테마 토글) */
.site-header .hdr-btns {
  position: absolute;
  top: 16px;
  right: 14px;
  display: flex;
  gap: 6px;
}

.hdr-icon-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  background: var(--surface2);
  border-radius: 50%;
  cursor: pointer;
  color: var(--text2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s, color .2s;
}
.hdr-icon-btn:hover { background: var(--border); color: var(--text); }
.hdr-icon-btn svg { width: 17px; height: 17px; }

.visit-count {
  font-size: 11px;
  color: var(--text2);
  margin-top: 8px;
  letter-spacing: .03em;
  opacity: .7;
}

.resume-bar {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 20px;
  font-size: 15px;
  text-decoration: none;
  color: var(--text);
  transition: background .2s, border-color .2s;
}
.resume-bar:hover { background: var(--border); border-color: var(--gold); }
.resume-bar .ri { color: var(--gold); }

.ep-count {
  text-align: center;
  padding: 13px;
  font-size: 14px;
  color: var(--text2);
}

.ep-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  padding: 4px 16px 36px;
  max-width: 900px;
  margin: 0 auto;
}

.ep-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px 12px 16px;
  text-align: center;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow-xs);
  border: 2px solid transparent;
  transition: transform .18s var(--ease), box-shadow .18s, border-color .18s;
  display: block;
}
.ep-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--gold);
}
.ep-card.inactive { opacity: .38; pointer-events: none; }

.ep-card .ho  { font-size: 13px; color: var(--text2); }
.ep-card .num { font-family: 'Noto Serif KR', serif; font-size: 36px; font-weight: 900; color: var(--accent); line-height: 1.1; }
.ep-card .date {
  font-size: 12px;
  color: var(--text2);
  margin-top: 6px;
  margin-bottom: 4px;
  letter-spacing: .02em;
}
.ep-card .badge {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 20px;
  margin-top: 7px;
}

/* =====================================================
   PLAYER 페이지
   ===================================================== */
.page-player {
  min-height: 100dvh;
  background: var(--bg);
}

/* ── 헤더 ── */
#hdr {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 10px 12px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  transition: transform 0.35s var(--ease), opacity 0.35s var(--ease);
}

.hdr-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
}

.ep-headline {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.5;
  padding: 6px 2px 4px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  letter-spacing: .01em;
  text-align: center;
}

#hdr .back {
  color: var(--accent);
  text-decoration: none;
  font-size: 1.6rem;
  line-height: 1;
  flex-shrink: 0;
}

#hdr .info { flex: 1; overflow: hidden; }

#hdr .ep-main {
  font-family: 'Noto Serif KR', serif;
  font-size: 1.25rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--accent);
  letter-spacing: .04em;
}

#hdr .ep-sub {
  font-size: 0.75rem;
  color: var(--text2);
  margin-top: 1px;
}

/* 헤더 우측 버튼들 */
#hdr .hdr-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border: none;
  background: var(--surface2);
  border-radius: 50%;
  cursor: pointer;
  color: var(--text2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .18s, color .18s;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--border); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; }

/* 다크/라이트 아이콘 표시 제어 (player + index 공용) */
[data-theme="light"] .icon-sun  { display: none; }
[data-theme="dark"]  .icon-moon { display: none; }

/* 다크모드에서 index 헤더 */
[data-theme="dark"] .site-header { background: var(--surface); }
[data-theme="dark"] .site-header h1 { color: var(--accent); }
[data-theme="dark"] .site-header .sub { color: var(--text2); }

/* 미니 회차 nav */
#hdr .nav-mini {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}
#hdr .nav-mini button {
  background: var(--surface2);
  color: var(--text2);
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 28px;
  height: 28px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
#hdr .nav-mini button:hover { background: var(--border); }
#hdr .nav-mini button:disabled { opacity: .3; cursor: default; }
#hdr .nav-mini .cnt { font-size: 11px; color: var(--text2); white-space: nowrap; }

/* ── 본문 영역 (문서 자체가 스크롤) ── */
#tc {
  padding: calc(var(--hdr-h) + 12px) 14px calc(var(--player-h) + 24px);
  max-width: 860px;
  margin: 0 auto;
}

.loading {
  text-align: center;
  padding: 52px 16px;
  color: var(--text2);
  font-size: .9rem;
}

/* ── 세그먼트 ── */
.seg {
  display: flex;
  gap: 10px;
  padding: 9px 14px;
  border-radius: 9px;
  margin-bottom: 2px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background .15s, border-color .15s;
  min-width: 0;
  width: 100%;
}
.seg:hover { background: var(--bg2); }

.seg.active {
  background: var(--active-bg);
  border-left-color: var(--active-bd);
}
.seg.active .st {
  color: var(--text);
  font-weight: 600;
}

/* 재생 중 문장: 일시정지 힌트 (호버 시) */
.seg.active:hover {
  background: rgba(212,169,48,.14);
}
.seg.active:hover .st::after {
  content: ' ⏸';
  font-size: .75em;
  color: var(--gold);
  opacity: .7;
}

.sn { display: none; }

.st {
  font-size: var(--font-size);
  line-height: 1.8;
  word-break: keep-all;
  overflow-wrap: break-word;
  color: var(--text);
  min-width: 0;
  flex: 1;
}

/* =====================================================
   플레이어 바 — 전경(典經)과 동일 구조
   ===================================================== */
.player-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 860px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 24px rgba(0,0,0,.10);
  z-index: 200;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  transition: transform 0.35s var(--ease), opacity 0.35s var(--ease);
}

/* 진행 바 영역 */
.player-progress {
  padding: 10px 16px 3px;
}

.progress-track {
  position: relative;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  cursor: pointer;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(to right, var(--accent), var(--gold));
  border-radius: 2px;
  width: 0%;
  pointer-events: none;
  transition: width .1s linear;
}

.progress-input {
  position: absolute;
  top: -10px;
  left: 0;
  right: 0;
  width: 100%;
  opacity: 0;
  cursor: pointer;
  margin: 0;
}

.progress-times {
  display: flex;
  justify-content: space-between;
  font-size: .78rem;
  color: var(--text2);
  margin-top: 5px;
  font-variant-numeric: tabular-nums;
}

/* 메인 컨트롤 행 */
.player-main {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 4px 16px 12px;
}

/* 재생 컨트롤 버튼 */
.player-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  justify-content: center;
}

.ctrl-btn {
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
}
.ctrl-btn:hover { background: var(--bg2); }
.ctrl-btn svg { width: 24px; height: 24px; }

.ctrl-play {
  width: 52px;
  height: 52px;
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
  transition: background .15s, transform .1s;
  position: relative;
  overflow: hidden;
}
.ctrl-play:hover { background: var(--accent-h); }
.ctrl-play:active { transform: scale(.93); }

/* 재생/일시정지 아이콘 전환 — absolute 방식으로 크기 변화 없음 */
.ctrl-play .icon-play,
.ctrl-play .icon-pause {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 26px;
  height: 26px;
  transition: opacity .12s;
  pointer-events: none;
}
.ctrl-play .icon-pause { opacity: 0; }
body.is-playing .ctrl-play .icon-play  { opacity: 0; }
body.is-playing .ctrl-play .icon-pause { opacity: 1; }

/* 재생 속도 select */
#speed-select {
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: .82rem;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  outline: none;
  flex-shrink: 0;
  font-family: inherit;
  transition: border-color .15s;
}
#speed-select:focus { border-color: var(--accent); }

/* 수면 타이머 */
.sleep-wrap {
  position: relative;
  flex-shrink: 0;
}

.sleep-btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  padding: 0 4px;
  min-width: 40px;
  transition: background .15s, color .15s, border-color .15s;
}
.sleep-btn svg { width: 18px; height: 18px; }
.sleep-btn:hover { background: var(--border); }
.sleep-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.sleep-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  min-width: 78px;
  z-index: 400;
}
.sleep-menu button {
  display: block;
  width: 100%;
  padding: 11px 18px;
  border: none;
  background: none;
  color: var(--text);
  font-size: .95rem;
  cursor: pointer;
  text-align: left;
  transition: background .15s;
}
.sleep-menu button:hover { background: var(--surface2); }

/* ── 오버레이 ── */
#overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}
#overlay.hidden { display: none; }

.ov-box {
  background: var(--surface);
  border-radius: 18px;
  padding: 32px 24px;
  max-width: 320px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow-md);
}

.ov-icon  { font-size: 40px; margin-bottom: 12px; }
.ov-title { font-family: 'Noto Serif KR', serif; font-size: 20px; font-weight: 700; color: var(--accent); margin-bottom: 8px; }
.ov-msg   { font-size: 14px; color: var(--text2); line-height: 1.65; margin-bottom: 24px; }

.ov-btns { display: flex; flex-direction: column; gap: 10px; }
.ov-btns button, .ov-btns a {
  display: block;
  padding: 13px;
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  border: none;
  transition: opacity .15s;
}
.ov-btns button:first-child { background: var(--accent); color: #fff; font-weight: 700; }
.ov-btns .btn-sec { background: var(--bg2); color: var(--text); }
.ov-btns a { background: var(--bg2); color: var(--text); text-align: center; }

/* ── 사용설명 & 앱설치 안내 섹션 ── */
.guide-wrap {
  max-width: 900px;
  margin: 0 auto 6px;
  padding: 0 14px;
}

.guide-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: background .15s, border-color .15s;
}
.guide-toggle:hover { background: var(--bg2); border-color: var(--gold); }
.guide-toggle svg { color: var(--accent); flex-shrink: 0; }
.guide-arrow { margin-left: auto; color: var(--text2); font-size: 13px; }

.guide-body {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 20px 20px 24px;
}

.guide-section { margin-bottom: 24px; }
.guide-section:last-child { margin-bottom: 0; }

.guide-section-title {
  font-family: 'Noto Serif KR', serif;
  font-size: 17px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.guide-list {
  padding-left: 20px;
  color: var(--text);
  line-height: 2;
  font-size: 15px;
}
.guide-list li { margin-bottom: 2px; }

.guide-desc {
  font-size: 14px;
  color: var(--text2);
  line-height: 1.8;
  margin-bottom: 16px;
}

.install-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.install-item {
  background: var(--bg2);
  border-radius: var(--radius-sm);
  padding: 16px;
}

.install-label {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}

.install-steps {
  padding-left: 18px;
  font-size: 14px;
  color: var(--text);
  line-height: 2;
  margin: 0;
}

.install-note {
  margin-top: 10px;
  font-size: 13px;
  color: var(--text2);
  line-height: 1.6;
}

/* ── PWA 설치 안내 (iOS) ── */
#ios-guide {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 500;
  padding: 0 0 env(safe-area-inset-bottom, 0);
}

.ios-guide-box {
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  padding: 28px 24px 32px;
  width: 100%;
  max-width: 480px;
}

.ios-guide-title {
  font-family: 'Noto Serif KR', serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 16px;
  text-align: center;
}

.ios-guide-steps {
  padding-left: 20px;
  color: var(--text);
  line-height: 2;
  font-size: 15px;
  margin-bottom: 20px;
}

.ios-guide-box button {
  width: 100%;
  padding: 13px;
  background: var(--bg2);
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
}

/* ── 메인 페이지 전체 검색 ── */
.main-search-wrap {
  max-width: 900px;
  margin: 0 auto 8px;
  padding: 0 14px;
}

.main-search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 13px 16px;
  transition: border-color .18s, box-shadow .18s;
  box-shadow: var(--shadow-xs);
}
.main-search-bar:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--gold-glow);
}
.main-search-bar > svg { color: var(--text2); flex-shrink: 0; }

#main-search {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  min-width: 0;
  -webkit-appearance: none;
}
#main-search::placeholder { color: var(--text2); }
#main-search::-webkit-search-cancel-button { display: none; }

.main-search-clear {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background .15s, color .15s;
  padding: 0;
}
.main-search-clear:hover { background: var(--bg2); color: var(--text); }

.main-search-results {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 14px 14px;
  overflow: hidden;
  margin-top: -4px;
  box-shadow: var(--shadow-sm);
}

.main-search-count {
  padding: 10px 16px 9px;
  font-size: 0.82rem;
  color: var(--text2);
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
}

.main-search-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 16px;
  text-decoration: none;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  transition: background .15s;
}
.main-search-item:last-child { border-bottom: none; }
.main-search-item:hover { background: var(--active-bg); }

.msi-ep {
  flex-shrink: 0;
  font-size: 0.78rem;
  color: var(--gold);
  font-weight: 700;
  min-width: 52px;
  padding-top: 3px;
  line-height: 1.6;
}
.msi-date {
  display: block;
  color: var(--text2);
  font-size: 0.7rem;
  font-weight: 400;
}

.msi-text {
  flex: 1;
  font-size: 0.92rem;
  line-height: 1.75;
  word-break: keep-all;
  overflow-wrap: break-word;
}
.msi-text mark {
  background: var(--gold-glow);
  color: var(--gold);
  border-radius: 3px;
  padding: 0 2px;
  font-weight: 700;
  font-style: normal;
}

.main-search-empty {
  padding: 44px 20px;
  text-align: center;
  font-size: 0.9rem;
  color: var(--text2);
  line-height: 2.2;
}

/* ── 세그먼트 액션 버튼 (즐겨찾기 + 공유) ── */
.seg-actions {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex-shrink: 0;
  align-self: flex-start;
  opacity: 0;
  transition: opacity .15s;
  padding-top: 4px;
}
.seg:hover .seg-actions { opacity: 1; }

.seg-bm, .seg-share {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background .15s, color .15s;
}
.seg-bm:hover  { background: var(--gold-glow); color: var(--gold); }
.seg-share:hover { background: var(--bg2); color: var(--accent); }
.seg-bm svg, .seg-share svg { width: 15px; height: 15px; }

.seg-bm.on { color: var(--gold); }

/* 터치 기기: 항상 버튼 표시 */
@media (hover: none) and (pointer: coarse) {
  .seg-actions { opacity: 1; }
}

/* ── 각주 ── */
sup.fn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .72em;
  font-weight: 700;
  color: #fff;
  background: #D32F2F;
  border-radius: 3px;
  padding: 0 4px;
  margin: 0 2px;
  cursor: pointer;
  vertical-align: super;
  line-height: 1.4;
  white-space: nowrap;
}

.fn-popup {
  position: fixed;
  bottom: calc(var(--player-h) + 10px);
  left: 12px;
  right: 12px;
  background: var(--bg2);
  border: 1.5px solid var(--primary);
  border-radius: 12px;
  padding: 12px 14px;
  z-index: 250;
  box-shadow: 0 4px 24px rgba(0,0,0,.25);
}
.fn-popup.hidden { display: none; }

.fn-popup-notice {
  font-size: .78em;
  color: #888;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  line-height: 1.5;
}

.fn-popup-inner {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.fn-num {
  font-size: .75em;
  color: var(--primary);
  font-weight: 700;
  flex-shrink: 0;
  padding-top: 2px;
}
.fn-text {
  font-size: .92em;
  line-height: 1.65;
  color: var(--text);
  flex: 1;
}
.fn-close {
  background: none;
  border: none;
  color: var(--text2);
  font-size: 1.1em;
  cursor: pointer;
  padding: 0 2px;
  flex-shrink: 0;
  line-height: 1;
}

/* ── 토스트 알림 ── */
#toast {
  position: fixed;
  bottom: calc(var(--player-h) + 20px);
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: rgba(30,20,10,.92);
  color: #f5e8cc;
  padding: 10px 22px;
  border-radius: 22px;
  font-size: 0.88rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 600;
  box-shadow: var(--shadow-md);
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── 즐겨찾기 패널 (바텀 시트) ── */
.bm-panel {
  position: fixed;
  inset: 0;
  z-index: 500;
}
.bm-hidden { display: none; }
.bm-panel.bm-open .bm-backdrop { opacity: 1; }
.bm-panel.bm-open .bm-sheet { transform: translateY(0); }

.bm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.5);
  opacity: 0;
  transition: opacity .28s var(--ease);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.bm-sheet {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  max-height: 72vh;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform .3s var(--ease);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.bm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.bm-title {
  font-family: 'Noto Serif KR', serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent);
}

.bm-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px 12px;
  -webkit-overflow-scrolling: touch;
}

.bm-empty {
  text-align: center;
  padding: 40px 20px;
  font-size: 0.9rem;
  color: var(--text2);
  line-height: 2;
}

.bm-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border-radius: 10px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background .15s;
  border: 1px solid var(--border);
}
.bm-item:hover { background: var(--bg2); border-color: var(--gold); }

.bm-meta {
  font-size: 0.76rem;
  color: var(--gold);
  flex-shrink: 0;
  min-width: 40px;
  padding-top: 3px;
  font-weight: 600;
}

.bm-text {
  flex: 1;
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text);
  word-break: keep-all;
  overflow-wrap: break-word;
}

.bm-del {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 6px;
  flex-shrink: 0;
  transition: background .15s, color .15s;
}
.bm-del:hover { background: var(--bg2); color: var(--text); }

/* ── 들은 회차 카드 표시 ── */
.ep-views {
  font-size: 11px;
  color: var(--text2);
  margin-top: 5px;
}

.ep-card { position: relative; }
.ep-card.listened { border-color: var(--gold); }
.ep-card.listened .badge { background: var(--gold); }
.ep-card.listened::after {
  content: '✓';
  position: absolute;
  top: 8px;
  right: 9px;
  font-size: 13px;
  color: var(--gold);
  font-weight: 900;
  line-height: 1;
}

/* ── 반응형 ── */
@media (max-width: 480px) {
  .st { font-size: var(--font-size); }
  .ep-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
  .ep-card .num { font-size: 30px; }
  .site-header h1 { font-size: 26px; letter-spacing: 6px; }

  html[data-fontsize="md"]  { --font-size: 0.95rem; }
  html[data-fontsize="lg"]  { --font-size: 1.06rem; }
  html[data-fontsize="xl"]  { --font-size: 1.18rem; }
  html[data-fontsize="xxl"] { --font-size: 1.32rem; }
}

@media (hover: none) and (pointer: coarse) {
  .seg:hover { background: transparent; }
  .seg.active { background: var(--active-bg); }
}

/* ── 가로 모드 최적화 ── */
@media (orientation: landscape) and (max-height: 500px) {
  #hdr { padding: 6px 10px; }
  .hdr-row { min-height: 34px; }
  #hdr .ep-main { font-size: 1rem; }
  #hdr .ep-sub  { display: none; }
  .icon-btn { width: 32px; height: 32px; }
  .icon-btn svg { width: 17px; height: 17px; }

  #tc { padding: calc(var(--hdr-h) + 8px) 12px calc(76px + 14px); }

  .player-progress { padding: 6px 14px 2px; }
  .player-main     { padding: 3px 12px 6px; }
  .ctrl-play  { width: 42px; height: 42px; }
  .ctrl-btn   { width: 36px; height: 36px; }
  .ctrl-btn svg { width: 20px; height: 20px; }
  .sleep-btn  { width: 34px; height: 34px; }

  #toast { bottom: 80px; }
}

/* ── UI 자동 숨김 (재생 중 무조건 대기 후 숨김) ── */
body.ui-hidden #hdr {
  transform: translateY(-110%);
  opacity: 0;
  pointer-events: none;
}
body.ui-hidden .player-bar {
  transform: translateX(-50%) translateY(110%);
  opacity: 0;
  pointer-events: none;
}
