/* ====================================================
   대순진리회 요람 — 스타일
   라이트/다크 테마, 글자 크기 단계, 공통 네비바 포함
   ==================================================== */

:root {
  --bg: #f8f3ea;
  --surface: #ffffff;
  --surface2: #f4eee2;
  --text: #2a2118;
  --text2: #6b5e4f;
  --muted: #9b8c70;
  --accent: #9B6F1F;
  --accent-soft: rgba(155,111,31,0.12);
  --border: #e3ddd0;
  --shadow: 0 2px 12px rgba(155,111,31,0.08);
  --content-fs: 17px;
  --header-h: 56px;
}
html[data-fs="lg"]  { --content-fs: 19px; }
html[data-fs="xl"]  { --content-fs: 21px; }
html[data-fs="xxl"] { --content-fs: 23px; }

html[data-theme="dark"] {
  --bg: #1a1614;
  --surface: #25201c;
  --surface2: #2e2823;
  --text: #ede4d2;
  --text2: #b8a98f;
  --muted: #8a7e6a;
  --accent: #d4a557;
  --accent-soft: rgba(212,165,87,0.15);
  --border: #3a3128;
  --shadow: 0 2px 12px rgba(0,0,0,0.4);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: 'Noto Sans KR','Apple SD Gothic Neo','Malgun Gothic',sans-serif;
  -webkit-text-size-adjust: 100%;
}
a { color: inherit; }

/* ── 공통 자료실 네비바 ── */
#jw-header { background:#f5ede0; padding:14px 20px; box-sizing:border-box;
  position:sticky; top:0; z-index:1100; transition:transform 0.28s ease; }
#jw-navbar { background:#b5312a; border-radius:50px; max-width:1200px;
  margin:0 auto; display:flex; align-items:center; justify-content:space-between;
  padding:10px 26px; box-sizing:border-box; }
.jw-logo { display:flex; align-items:center; gap:12px; text-decoration:none; }
.jw-logo img { width:42px; height:42px; border-radius:50%;
  object-fit:cover; background:#fff; }
.jw-logo-text { color:#fff; font-size:17px; font-weight:700;
  white-space:nowrap; letter-spacing:-0.3px; font-family:'Noto Sans KR',sans-serif; }
.jw-nav { display:flex; align-items:center; gap:4px;
  list-style:none; margin:0; padding:0; }
.jw-nav li a, .jw-nav li a:link, .jw-nav li a:visited {
  color:#fff !important; text-decoration:none !important;
  font-size:16px; font-weight:700;
  padding:8px 18px; border-radius:30px;
  transition:background 0.2s; white-space:nowrap; display:block;
  letter-spacing:0.5px; font-family:'Noto Sans KR',sans-serif; }
.jw-nav li a:hover, .jw-nav li a.jw-active {
  background:rgba(255,255,255,0.25); color:#fff !important; }
.jw-nav li .jw-soon {
  color:rgba(255,255,255,0.55); font-size:16px; font-weight:700;
  padding:8px 18px; border-radius:30px; display:block;
  white-space:nowrap; letter-spacing:0.5px;
  cursor:not-allowed; font-family:'Noto Sans KR',sans-serif; }
.jw-toggle { display:none; background:transparent; border:none; cursor:pointer;
  padding:6px 4px; width:36px; height:36px;
  flex-direction:column; gap:6px; align-items:center; justify-content:center; }
.jw-toggle span { display:block; width:24px; height:2px; background:#fff; border-radius:2px; }
@media (max-width:780px) {
  .jw-logo-text { font-size:15px; }
  .jw-toggle { display:flex; }
  .jw-nav { display:none; flex-direction:column; width:100%; gap:6px; margin-top:10px; }
  .jw-nav.jw-open { display:flex; }
  #jw-navbar { flex-wrap:wrap; border-radius:20px; padding:10px 18px; }
  .jw-nav li { width:100%; }
  .jw-nav li a, .jw-nav li .jw-soon { text-align:center; font-size:15px; padding:10px 12px; }
}
body.jw-hide-top #jw-header { transform:translateY(-100%); }

/* ── 요람 자체 헤더 ── */
.app-header {
  position: sticky; top: 90px; z-index: 100;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 16px; gap: 12px;
  transition: transform 0.28s ease, top 0.28s ease;
}
@media (max-width:780px) { .app-header { top: 80px; } }
body.jw-hide-top .app-header { transform: translateY(-100%); }

.app-title {
  flex: 1; font-family:'Noto Serif KR',serif;
  font-size: 18px; font-weight: 700; letter-spacing: 0.06em;
  color: var(--accent);
}
.app-title .hanja { color: var(--text2); font-weight: 500; margin-left: 6px; }

.app-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 8px;
  background: transparent; border: 1px solid transparent;
  color: var(--text); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.15s, border-color 0.15s;
}
.icon-btn:hover { background: var(--accent-soft); border-color: var(--accent); }
.icon-btn svg { width: 20px; height: 20px; display: block; fill: none; stroke: currentColor; stroke-width: 2; }
.icon-btn .icon-sun { display: none; }
html[data-theme="dark"] .icon-btn .icon-moon { display: none; }
html[data-theme="dark"] .icon-btn .icon-sun { display: block; }

/* ── 레이아웃: 좌측 장 목록 + 우측 본문 ── */
.layout {
  display: grid; grid-template-columns: 240px 1fr;
  max-width: 1200px; margin: 0 auto;
}
@media (max-width:900px) {
  .layout { grid-template-columns: 1fr; }
}

/* 좌측 장 메뉴 */
.chap-nav {
  position: sticky; top: calc(90px + var(--header-h));
  height: calc(100vh - 90px - var(--header-h));
  overflow-y: auto;
  padding: 16px 12px;
  border-right: 1px solid var(--border);
  background: var(--surface2);
}
@media (max-width:780px) { .chap-nav { top: calc(80px + var(--header-h)); height: auto; max-height: 240px; } }
@media (max-width:900px) {
  .chap-nav {
    position: static; height: auto; max-height: none;
    border-right: none; border-bottom: 1px solid var(--border);
    padding: 12px 16px;
  }
}
.chap-nav a {
  display: block;
  padding: 7px 10px;
  border-radius: 6px;
  color: var(--text2); text-decoration: none;
  font-size: 14px; line-height: 1.5;
  margin-bottom: 2px;
}
.chap-nav a:hover { background: var(--accent-soft); color: var(--text); }
.chap-nav a.is-current {
  background: var(--accent); color: #fff !important;
  font-weight: 700;
}
.chap-nav .nav-no { display: inline-block; min-width: 22px; opacity: 0.7; font-weight: 700; }

/* 본문 영역 */
main.content {
  padding: 28px 32px 80px;
  max-width: 820px;
  margin: 0 auto;
  width: 100%;
}
@media (max-width:780px) { main.content { padding: 18px 18px 80px; } }

.chap-title {
  font-family: 'Noto Serif KR', serif;
  font-size: 26px; font-weight: 700;
  color: var(--accent);
  margin: 4px 0 6px;
  letter-spacing: -0.01em;
}
.chap-title .hanja { color: var(--text2); font-weight: 500; margin-left: 8px; font-size: 0.85em; }
.chap-meta { font-size: 13px; color: var(--muted); margin-bottom: 26px; }

.par-text {
  font-size: var(--content-fs);
  line-height: 1.95;
  color: var(--text);
  margin: 0 0 18px;
  word-break: keep-all;
}
.par-text mark {
  background: var(--accent-soft); color: var(--accent);
  padding: 2px 4px; border-radius: 4px;
}
.par-image {
  margin: 22px 0; text-align: center;
}
.par-image img {
  max-width: 100%; height: auto;
  border-radius: 6px; border: 1px solid var(--border);
}
.par-image figcaption {
  font-size: 13px; color: var(--muted);
  margin-top: 6px;
}
html[data-theme="dark"] .par-image img {
  filter: invert(0.92) hue-rotate(180deg);
}

/* 페이지 이동 (이전/다음) */
.chap-paging {
  display: flex; justify-content: space-between;
  margin-top: 40px; padding-top: 20px;
  border-top: 1px solid var(--border);
  gap: 12px;
}
.chap-paging a {
  flex: 1; padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text); text-decoration: none;
  font-size: 14px; font-weight: 600;
  transition: background 0.15s, border-color 0.15s;
}
.chap-paging a:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chap-paging a.prev::before { content: '◀ '; opacity: 0.7; }
.chap-paging a.next { text-align: right; }
.chap-paging a.next::after { content: ' ▶'; opacity: 0.7; }
.chap-paging .empty { flex: 1; }

/* ── 검색 오버레이 ── */
.search-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: none; z-index: 2000;
  align-items: flex-start; justify-content: center;
  padding-top: 80px;
}
.search-overlay.is-open { display: flex; }
.search-panel {
  background: var(--surface);
  width: 90%; max-width: 600px;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
  overflow: hidden;
}
.search-input-wrap {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.search-input-wrap input {
  flex: 1; border: none; outline: none;
  background: transparent; font-size: 16px;
  color: var(--text); font-family: inherit;
}
.search-close-btn {
  background: transparent; border: none; cursor: pointer;
  color: var(--text2); font-size: 20px;
}
.search-results {
  max-height: 60vh; overflow-y: auto;
  padding: 12px 0;
}
.search-results .hint, .search-results .empty {
  padding: 24px; text-align: center; color: var(--muted); font-size: 14px;
}
.search-result {
  display: block; padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  text-decoration: none; color: var(--text);
  cursor: pointer;
}
.search-result:hover { background: var(--accent-soft); }
.search-result .where {
  font-size: 12px; color: var(--accent); font-weight: 700;
  margin-bottom: 4px;
}
.search-result .snippet {
  font-size: 13px; color: var(--text2); line-height: 1.55;
}
.search-result .snippet mark { background: var(--accent-soft); color: var(--accent); }

/* ── 플레이어 바 (audio 있을 때만) ── */
.player-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 10px 16px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
  z-index: 500;
}
.player-bar[hidden] { display: none; }
.player-bar audio { flex: 1; min-width: 0; }
