:root {
  --bg: #14120E;
  --surface: #1D1A15;
  --surface-2: #24201A;
  --line: #2E2A22;
  --line-2: #3A342A;
  --text: #ECE4D3;
  --text-2: #D8CFBD;
  --muted: #B4AB98;
  --faint: #A79E8C;
  --accent: #E8A65A;
  --on-accent: #14120E;
  --wood: #2A2119;
  --wood-top: #3A2D21;
  --cover: #3B1F1A;
  --gold: #D9B26B;
  --serif: 'Gowun Batang', 'Noto Serif KR', 'Noto Serif CJK KR', 'Nanum Myeongjo', 'AppleMyungjo', serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Noto Sans KR', 'Noto Sans CJK KR', 'Malgun Gothic', system-ui, sans-serif;
  --reading-size: 19px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[tabindex="-1"]:focus { outline: none; }

.app { max-width: 480px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; position: relative; }
.view { min-height: 100vh; min-height: 100dvh; }

/* 공통 버튼 */
.icon-btn, .pill-btn {
  min-width: 44px; height: 44px; border-radius: 22px;
  border: 1px solid var(--line-2); background: transparent; color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  text-decoration: none; cursor: pointer; flex-shrink: 0;
}
.icon-btn { width: 44px; padding: 0; }
.pill-btn { padding: 0 16px; font-size: 14px; }
.icon-btn:hover, .pill-btn:hover { border-color: #5A5142; }
.primary-btn {
  height: 48px; padding: 0 28px; border-radius: 24px; border: none;
  background: var(--accent); color: var(--on-accent); font-size: 15px; font-weight: 600; cursor: pointer;
}
.primary-btn:hover { background: #F0B46C; }
.text-btn {
  min-height: 44px; padding: 0 12px; border: none; background: none; color: var(--faint);
  font-size: 13px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}

/* 촛불 */
.glow circle, .flame path { fill: var(--accent); }
.flame, .glow { opacity: 0; transition: opacity 1.2s ease; }
[data-lit="true"] .flame, [data-lit="true"] .glow { opacity: 1; }
.flame { transform-box: fill-box; transform-origin: 50% 100%; }
[data-lit="true"] .flame { animation: flicker 3.2s ease-in-out infinite; }
[data-lit="true"] .glow-core { animation: breathe 3.2s ease-in-out infinite; }
@keyframes flicker {
  0%, 100% { transform: scale(1, 1) skewX(0deg); }
  20% { transform: scale(0.97, 1.03) skewX(-1.5deg); }
  45% { transform: scale(1.02, 0.97) skewX(1deg); }
  70% { transform: scale(0.98, 1.02) skewX(-0.5deg); }
}
@keyframes breathe { 0%, 100% { opacity: 0.14; } 50% { opacity: 0.2; } }
@media (prefers-reduced-motion: reduce) {
  [data-lit="true"] .flame, [data-lit="true"] .glow-core { animation: none; }
  .flame, .glow { transition: none; }
}

/* 자리 */
.seat { display: flex; flex-direction: column; padding-bottom: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + var(--safe-top)) 16px 4px 20px; min-height: 64px;
}
.logo { margin: 0; font-family: var(--serif); font-size: 20px; font-weight: 700; letter-spacing: 0.04em; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar-actions .icon-btn, .topbar-actions .pill-btn { color: var(--muted); border-color: var(--line); }
#bell-toggle .bell-off { display: none; }
#bell-toggle[aria-pressed="false"] .bell-on { display: none; }
#bell-toggle[aria-pressed="false"] .bell-off { display: block; }

.presence {
  margin: 0; min-height: 32px; display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 14px; color: var(--muted); text-align: center; padding: 0 16px;
}
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 6px; height: 6px; border-radius: 3px; background: #6F6656; display: block; }
.dots i.me { background: var(--accent); }

.altar { flex: 1 1 220px; min-height: 180px; display: flex; align-items: flex-end; justify-content: center; }
.altar-art { width: 100%; height: 100%; max-height: 350px; display: block; overflow: visible; }
.mini-candle { overflow: visible; }

.session { min-height: 104px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 8px 16px 4px; }
.session > div { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.durations { border: none; margin: 0; padding: 0; display: flex; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.chip span {
  min-width: 64px; height: 40px; padding: 0 14px; border-radius: 20px; border: 1px solid var(--line-2);
  display: flex; align-items: center; justify-content: center; font-size: 14px; color: var(--muted);
}
.chip input:checked + span { border-color: var(--accent); color: var(--text); background: rgba(232, 166, 90, 0.12); }
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.timer-text { margin: 0; font-size: 14px; color: var(--muted); }
.timer-text #timer-left { color: var(--text); }
.progress { width: 160px; height: 3px; border-radius: 2px; background: var(--line); overflow: hidden; }
.progress-fill { width: 0%; height: 3px; background: var(--accent); transition: width 1s linear; }
.done-text { margin: 0; font-family: var(--serif); font-size: 17px; color: var(--text); }
.session [data-session="running"] { gap: 8px; }

.votd {
  display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
  padding: 8px 36px 16px; text-decoration: none; color: inherit;
}
.eyebrow { font-size: 12px; letter-spacing: 0.12em; color: var(--faint); }
.votd-text {
  font-family: var(--serif); font-size: 18px; line-height: 1.6; color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.votd-ref { font-size: 13px; color: var(--faint); }
.votd:hover .votd-text { color: #fff; }

.pew {
  position: relative; height: calc(190px + var(--safe-bottom)); flex-shrink: 0;
  background: var(--wood); border-top: 14px solid var(--wood-top);
}
.pew-bible {
  position: absolute; left: 70px; top: 0; width: 58px; height: 140px;
  background: var(--cover); border-radius: 3px 6px 6px 3px; box-shadow: 0 2px 0 #1A0F0C;
  display: flex; flex-direction: column; align-items: center; padding-top: 12px; text-decoration: none;
  transition: transform 0.25s ease;
}
.pew-bible:hover, .pew-bible:focus-visible { transform: translateY(-6px); }
.spine-line { width: 40px; height: 1px; background: #8C6A3A; }
.spine-title { writing-mode: vertical-rl; font-family: var(--serif); font-size: 17px; font-weight: 700; letter-spacing: 0.3em; color: var(--gold); margin-top: 8px; }
.pew-pocket {
  position: absolute; left: 46px; top: 76px; width: 106px; height: 110px; pointer-events: none;
  background: #1F1812; border-radius: 3px 3px 6px 6px; border-top: 2px solid #4A3A2A;
}
.pew-hint { position: absolute; left: 176px; right: 16px; top: 80px; margin: 0; display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--text-2); }
.pew-sub { font-size: 12px; color: var(--faint); }

@media (max-height: 700px) {
  .topbar { min-height: 56px; padding-top: calc(8px + var(--safe-top)); }
  .presence { min-height: 28px; }
  .session { min-height: 92px; }
  .session > div { gap: 10px; }
  .votd { gap: 6px; padding-top: 4px; }
  .pew { height: calc(160px + var(--safe-bottom)); }
  .pew-bible { height: 124px; }
  .pew-pocket { top: 64px; height: 92px; }
  .pew-hint { top: 66px; }
  .votd { padding-bottom: 10px; }
  .votd-text { font-size: 17px; -webkit-line-clamp: 2; }
  .altar { min-height: 110px; flex-basis: 140px; }
}

/* 성경 */
.reader { display: flex; flex-direction: column; height: 100vh; height: 100dvh; min-height: 0; }
.reader-top {
  flex-shrink: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px;
  padding: calc(12px + var(--safe-top)) 16px 14px; min-height: 150px;
}
.presence-small { min-height: 20px; font-size: 13px; }
.sheet {
  flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column;
  background: var(--surface); border-radius: 20px 20px 0 0; border-top: 1px solid var(--line-2);
}
.grabber { width: 36px; height: 4px; border-radius: 2px; background: var(--line-2); margin: 10px auto 0; flex-shrink: 0; }
.panel { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px 12px; flex-shrink: 0; }
.title { margin: 0; font-family: var(--serif); font-size: 21px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
#panel-books .sheet-head { padding-left: 20px; }
.title-link { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 44px; padding: 4px 8px; text-decoration: none; color: var(--text); border-radius: 10px; min-width: 0; }
.title-link:hover { background: var(--surface-2); }
.sub { font-size: 12px; color: var(--faint); }
.head-actions { display: flex; align-items: center; gap: 8px; }
.head-title { flex: 1 1 auto; display: flex; flex-direction: column; gap: 2px; padding-left: 4px; min-width: 0; }
.size-btn { align-items: baseline; padding-top: 10px; font-family: var(--serif); gap: 1px; }
.size-btn .s1 { font-size: 12px; } .size-btn .s2 { font-size: 17px; }
.rule { height: 1px; background: var(--line); margin: 0 16px; flex-shrink: 0; }

.chapter-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 22px 28px 28px 14px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.verse {
  margin: 0 0 14px; display: grid; grid-template-columns: 24px 1fr; column-gap: 10px; align-items: baseline;
  font-family: var(--serif); font-size: var(--reading-size); line-height: 1.85; color: var(--text); word-break: keep-all; overflow-wrap: anywhere;
}
.vnum { font-family: var(--sans); font-size: 12px; color: var(--accent); text-align: right; }
.verse-heading { margin: 8px 0 10px 34px; font-family: var(--sans); font-size: 13px; color: var(--faint); letter-spacing: 0.02em; }
.attribution { margin: 28px 0 0 34px; font-size: 11px; color: var(--faint); }
.notice { margin: 32px 20px; text-align: center; color: var(--muted); font-size: 14px; line-height: 1.7; }

.chapter-nav {
  flex-shrink: 0; display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px calc(16px + var(--safe-bottom)); border-top: 1px solid var(--line);
}
.nav-btn { color: var(--text-2); padding: 0 16px 0 10px; }
#next-chapter { padding: 0 10px 0 16px; }
.nav-btn[aria-disabled="true"] { visibility: hidden; }
.pos { font-size: 12px; color: var(--faint); }

.last-read {
  margin: 4px 16px 0; min-height: 60px; padding: 10px 14px 10px 16px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface-2); border-radius: 12px; text-decoration: none; color: var(--text);
}
.last-read-text { display: flex; flex-direction: column; gap: 2px; }
.eyebrow-sm { font-size: 12px; color: var(--faint); }
.last-read-label { font-family: var(--serif); font-size: 16px; }
.tabs { margin: 12px 16px 4px; padding: 3px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; border: 1px solid var(--line-2); border-radius: 12px; flex-shrink: 0; }
.tab { height: 44px; border: none; border-radius: 9px; background: transparent; color: var(--muted); font-size: 14px; cursor: pointer; }
.tab[aria-pressed="true"] { background: var(--line); color: var(--text); }
.scroll-area { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 0 16px calc(24px + var(--safe-bottom)); overscroll-behavior: contain; }
.group { padding-top: 16px; }
.group-title { margin: 0 0 8px; font-size: 12px; letter-spacing: 0.08em; color: var(--faint); font-weight: 400; }
.book-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.book-btn {
  height: 44px; padding: 0 4px; border-radius: 10px; border: 1px solid var(--line-2);
  display: flex; align-items: center; justify-content: center; text-decoration: none;
  font-family: var(--serif); font-size: 14px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.book-btn:hover, .chap-btn:hover { border-color: #5A5142; }
.book-btn[aria-current="true"] { border-color: var(--accent); color: var(--accent); font-weight: 700; }
.chapter-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; padding-top: 16px; }
.chap-btn {
  height: 46px; border-radius: 10px; border: 1px solid var(--line-2);
  display: flex; align-items: center; justify-content: center; text-decoration: none;
  font-size: 15px; font-variant-numeric: tabular-nums; color: var(--text);
}
.chap-btn[aria-current="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 700; }

/* 나간 뒤 */
.exit { display: flex; align-items: center; justify-content: center; padding: 24px; }
.exit-body { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.exit-title { margin: 0; font-family: var(--serif); font-size: 26px; font-weight: 700; }
.exit-sub { margin: 0 0 12px; color: var(--muted); font-size: 14px; }

.noscript { padding: 32px; text-align: center; color: var(--muted); }

@media (min-width: 481px) {
  .app { border-left: 1px solid #1E1B16; border-right: 1px solid #1E1B16; }
}
