/* ───────── 색과 치수 ───────── */
:root {
  --bg: #F5F4EF;
  --surface: #FFFFFF;
  --surface-2: #FAF9F5;
  --ink: #1A1E26;
  --ink-2: #3B414D;
  --muted: #7C818C;
  --faint: #A9ADB5;
  --line: #E6E3DA;
  --line-2: #EFEDE6;
  --accent: #3446A0;
  --accent-ink: #FFFFFF;
  --accent-soft: #EDEFFA;
  --accent-line: #CBD1F1;
  --focus-bg: #FFF5D6;
  --focus-line: #E0A526;
  --m-yellow: #FFE8A0;
  --m-green: #CBEFD5;
  --m-blue: #D3E4FF;
  --m-pink: #FFD8E1;
  --shadow-sm: 0 1px 2px rgba(22, 26, 35, .05);
  --shadow: 0 1px 2px rgba(22, 26, 35, .04), 0 10px 30px rgba(22, 26, 35, .07);
  --shadow-lg: 0 24px 64px rgba(22, 26, 35, .18);
  --radius: 16px;
  --topbar-h: 64px;
  --passbar-h: 60px;
  --fs: 19px;
  --lh: 1.8;
  --sans: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', system-ui, sans-serif;
  --serif: 'Noto Serif KR', 'Nanum Myeongjo', AppleMyungjo, 'Batang', serif;
  --body-font: var(--sans);
  color-scheme: light;
}

[data-theme="sepia"] {
  --bg: #EFE7D6;
  --surface: #FBF6EA;
  --surface-2: #F6EFDF;
  --ink: #3A2F22;
  --ink-2: #4E4232;
  --muted: #8C7C66;
  --faint: #B3A58F;
  --line: #E2D6BE;
  --line-2: #EADFC9;
  --accent: #8A5A1F;
  --accent-soft: #F3E6CC;
  --accent-line: #DFC497;
  --focus-bg: #F8E3B0;
  --focus-line: #B9822A;
  --m-yellow: #F7DE93;
  --m-green: #D4E6C3;
  --m-blue: #D6E0EC;
  --m-pink: #F2D4D0;
}

[data-theme="dark"],
[data-theme="transparent"] {
  --bg: #0F1115;
  --surface: #161920;
  --surface-2: #1B1F27;
  --ink: #ECEDF1;
  --ink-2: #C9CCD4;
  --muted: #8A8F9B;
  --faint: #5E636E;
  --line: #262A33;
  --line-2: #20242C;
  --accent: #9AABFF;
  --accent-ink: #0F1115;
  --accent-soft: #1F2540;
  --accent-line: #34406F;
  --focus-bg: rgba(236, 184, 76, .14);
  --focus-line: #ECB84C;
  --m-yellow: rgba(255, 214, 102, .26);
  --m-green: rgba(110, 214, 147, .22);
  --m-blue: rgba(120, 168, 255, .25);
  --m-pink: rgba(255, 130, 160, .24);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

[data-font="serif"] { --body-font: var(--serif); }
[data-lh="wide"] { --lh: 2.05; }
[data-lh="tight"] { --lh: 1.6; }

/* ───────── 기본 ───────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
code { font-size: .92em; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 5px; word-break: break-all; }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; display: block; }

/* ───────── 상단 막대 ───────── */
.topbar {
  height: var(--topbar-h);
  flex: none;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 max(20px, env(safe-area-inset-right)) 0 max(20px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; min-width: 0; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M7 10.5c3-1 6-1 9 1 3-2 6-2 9-1V23c-3-1-6-1-9 1-3-2-6-2-9-1z' fill='none' stroke='white' stroke-width='1.8' stroke-linejoin='round'/%3E%3Cpath d='M16 11.5V24' stroke='white' stroke-width='1.8'/%3E%3C/svg%3E") center/100% no-repeat;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12), 0 2px 8px color-mix(in srgb, var(--accent) 35%, transparent);
}
[data-theme="dark"] .brand-mark { background-color: #3446A0; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; white-space: nowrap; }
.brand-text strong { font-size: 16px; font-weight: 750; letter-spacing: -.02em; }
.brand-text small { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

.topbar-center { flex: 1; display: flex; justify-content: center; gap: 8px; min-width: 0; }
.pill {
  height: 40px; display: inline-flex; align-items: center; gap: 8px;
  padding: 0 16px 0 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  font-weight: 600; font-size: 14.5px; color: var(--ink-2);
  min-width: 0; transition: border-color .15s, background .15s;
}
.pill:hover { border-color: var(--accent-line); background: var(--accent-soft); }
.pill-icon { color: var(--accent); }
.pill-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill b { color: var(--accent); font-weight: 750; }
.pill .short { display: none; }

.topbar-tools { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; display: inline-grid; place-items: center;
  color: var(--ink-2); transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--line-2); }
.icon-btn.small { width: 34px; height: 34px; border-radius: 10px; }
.icon-btn[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); }
.seg { display: inline-flex; background: var(--line-2); border-radius: 12px; padding: 3px; }
.seg button { height: 34px; min-width: 38px; padding: 0 8px; border-radius: 9px; font-weight: 700; font-size: 15px; color: var(--ink-2); }
.seg button sup { font-size: 10px; margin-left: 1px; }
.seg button:hover { background: var(--surface); box-shadow: var(--shadow-sm); }
.lecture-btn {
  height: 40px; display: inline-flex; align-items: center; gap: 8px; padding: 0 16px 0 13px;
  border-radius: 12px; background: var(--ink); color: var(--bg); font-weight: 700; font-size: 14px;
  margin-left: 4px; transition: transform .15s, opacity .15s;
}
.lecture-btn:hover { opacity: .9; }
.lecture-btn:active { transform: scale(.97); }

/* ───────── 본문 이동 막대 ───────── */
.passbar {
  height: var(--passbar-h); flex: none;
  display: flex; align-items: center; gap: 10px;
  padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  background: var(--bg);
  position: relative; z-index: 10;
}
.passbar-main { flex: 1; min-width: 0; text-align: center; }
.passbar-eyebrow { font-size: 12.5px; font-weight: 600; color: var(--accent); letter-spacing: .01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.passbar-title { margin: 1px 0 0; font-size: 18px; font-weight: 750; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-arrow {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); box-shadow: var(--shadow-sm);
  transition: background .15s, transform .15s;
}
.nav-arrow:hover { background: var(--accent-soft); color: var(--accent); }
.nav-arrow:active { transform: scale(.94); }
.nav-arrow:disabled { opacity: .35; pointer-events: none; }
.read-toggle {
  height: 36px; display: inline-flex; align-items: center; gap: 6px; padding: 0 14px 0 10px; flex: none;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  font-size: 13.5px; font-weight: 650; transition: all .15s;
}
.read-toggle svg.i { width: 16px; height: 16px; stroke-width: 2.4; }
.read-toggle:hover { color: var(--ink-2); }
.read-toggle[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.read-toggle[hidden] { display: none; }

/* ───────── 편 요약 ───────── */
.summary {
  flex: none; display: grid; grid-template-rows: 1fr;
  max-width: 1680px; width: 100%; margin: 0 auto;
  padding: 0 max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
  transition: grid-template-rows .3s ease, opacity .25s ease, padding-bottom .3s ease;
}
.summary[hidden] { display: none; }
.summary.collapsed { grid-template-rows: 0fr; opacity: 0; padding-bottom: 0; pointer-events: none; }
.summary-clip { min-height: 0; overflow: hidden; }
.summary-in {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 14px 22px;
  background: color-mix(in srgb, var(--accent-soft) 60%, var(--surface));
  border: 1px solid var(--accent-line); border-radius: var(--radius);
}
.summary-label {
  flex: none; margin-top: 2px; padding: 2px 10px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 750; letter-spacing: .02em;
}
.summary-in p { margin: 0; font-size: 15.5px; line-height: 1.7; color: var(--ink-2); word-break: keep-all; overflow-wrap: anywhere; }
.content > .summary-in { margin: 4px .7em 16px; }

/* ───────── 읽기 영역 ───────── */
.reader {
  flex: 1; min-height: 0;
  display: flex; gap: 16px;
  padding: 4px max(16px, env(safe-area-inset-right)) 16px max(16px, env(safe-area-inset-left));
  max-width: 1680px; width: 100%; margin: 0 auto;
  transition: opacity .18s;
}
.reader.is-loading { opacity: .35; }

.pane, .single {
  flex: 1 1 0; min-width: 0;
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.reader.solo .pane { max-width: 860px; margin: 0 auto; }
.pane-head, .grid-head {
  flex: none; display: flex; align-items: baseline; gap: 10px;
  padding: 14px 28px 12px; border-bottom: 1px solid var(--line-2);
  background: var(--surface);
}
.pane-head strong, .grid-head strong { font-size: 14px; font-weight: 750; letter-spacing: -.01em; white-space: nowrap; }
.pane-head span, .grid-head span { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scroller {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  position: relative; scroll-padding: 24px;
  scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}
.scroller::-webkit-scrollbar { width: 10px; }
.scroller::-webkit-scrollbar-thumb { background: var(--line); border-radius: 10px; border: 3px solid var(--surface); }
.content { padding: 14px 18px 40vh; }

/* 절 */
.v {
  display: grid; grid-template-columns: 2.1em minmax(0, 1fr); column-gap: .55em;
  padding: .5em .7em; margin: 0 0 2px; border-radius: 12px;
  font-family: var(--body-font); font-size: var(--fs); line-height: var(--lh);
  color: var(--ink); cursor: pointer; position: relative;
  transition: background .2s, opacity .25s, box-shadow .2s;
  word-break: keep-all; overflow-wrap: anywhere;
}
.v:hover { background: var(--surface-2); }
.vn {
  font-family: var(--sans); font-size: .62em; font-weight: 700; color: var(--faint);
  text-align: right; padding-top: .62em; line-height: 1.2; font-variant-numeric: tabular-nums;
  user-select: none;
}
.vt { margin: 0; min-width: 0; }
.vt.missing, .vt.blank { color: var(--faint); font-size: .8em; font-family: var(--sans); padding-top: .25em; }
.vt.missing::before { content: '—  '; }
.no-nums .vn { visibility: hidden; }
.no-nums .v { grid-template-columns: .2em minmax(0, 1fr); }

.v.mk-yellow { background: var(--m-yellow); }
.v.mk-green { background: var(--m-green); }
.v.mk-blue { background: var(--m-blue); }
.v.mk-pink { background: var(--m-pink); }
.v.is-focus { background: var(--focus-bg); box-shadow: inset 4px 0 0 var(--focus-line); }
.v.is-focus .vn { color: var(--focus-line); }
.v.is-focus[class*="mk-"] { box-shadow: inset 4px 0 0 var(--focus-line), inset 0 0 0 2px color-mix(in srgb, var(--focus-line) 45%, transparent); }

.chap {
  display: flex; align-items: center; gap: 12px; margin: 22px .7em 10px;
  font-size: 13px; font-weight: 750; color: var(--accent); letter-spacing: .04em;
}
.chap::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.content > .chap:first-child { margin-top: 6px; }
.hide-chap .chap { display: none; }

.vh {
  margin: 26px .7em 8px; padding: 12px 16px; border-radius: 12px;
  background: var(--accent-soft); border: 1px solid var(--accent-line);
  font-size: 14px; line-height: 1.6; color: var(--ink-2);
}
.vh strong { display: block; color: var(--accent); font-size: 15px; margin-bottom: 2px; }
.vh span { font-size: 13px; color: var(--muted); }

/* 나란히·절 맞춤(한 화면에서 줄 맞춤)과 위아래 */
.grid-head { display: grid; grid-template-columns: 2.1em minmax(0, 1fr) minmax(0, 1fr); column-gap: 28px; padding-left: 18px; padding-right: 18px; }
.grid-head > div { display: flex; align-items: baseline; gap: 10px; min-width: 0; padding-left: .7em; }
.row .vt.r { color: var(--ink-2); }
.layout-rows .v { grid-template-columns: 2.1em minmax(0, 1fr) minmax(0, 1fr); column-gap: 28px; }
.layout-rows .v .vt.r { padding-left: 28px; border-left: 1px solid var(--line-2); margin-left: -14px; }
.layout-rows .vh.r { margin-left: calc(50% + 1em); }
.layout-stack .v .vt.r {
  grid-column: 2; margin-top: .45em; padding-top: .45em; border-top: 1px dashed var(--line);
  font-size: .9em; color: var(--ink-2);
}
.layout-stack .v .vt.r::before {
  content: attr(data-label); display: inline-block; margin-right: .6em; padding: 0 .5em;
  font-family: var(--sans); font-size: .66em; font-weight: 700; color: var(--accent);
  background: var(--accent-soft); border-radius: 5px; vertical-align: .18em; line-height: 1.7;
}
.layout-stack .v .vt.l::before {
  content: attr(data-label); display: none;
}

/* 본문 아래 질문 */
.qa {
  margin: 32px .7em 0; padding: 20px 22px;
  border-radius: 16px; border: 1px solid var(--line);
  background: var(--surface-2);
  font-family: var(--sans);
}
.qa-label {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  background: var(--focus-line); color: #fff; font-size: 12px; font-weight: 750; letter-spacing: .02em;
}
[data-theme="dark"] .qa-label { color: #1A1E26; }
.qa-q { margin: 10px 0 0; font-size: 17.5px; font-weight: 700; line-height: 1.6; letter-spacing: -.01em; color: var(--ink); word-break: keep-all; }
.qa-a { margin-top: 14px; }
.qa-a summary {
  cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--accent-line); background: var(--surface); color: var(--accent);
  font-size: 14px; font-weight: 700; transition: background .15s;
}
.qa-a summary::-webkit-details-marker { display: none; }
.qa-a summary:hover { background: var(--accent-soft); }
.qa-a summary svg.i { width: 16px; height: 16px; transition: transform .2s; }
.qa-a[open] summary svg.i { transform: rotate(180deg); }
.qa-a .qa-hide, .qa-a[open] .qa-show { display: none; }
.qa-a[open] .qa-hide { display: inline; }
.qa-a p {
  margin: 14px 0 0; padding-top: 14px; border-top: 1px dashed var(--line);
  font-size: 15.5px; line-height: 1.8; color: var(--ink-2); word-break: keep-all; overflow-wrap: anywhere;
  animation: fade .25s ease;
}
@keyframes fade { from { opacity: 0; transform: translateY(-4px); } }

/* 번역 주석 */
.notes { margin: 36px .7em 0; border-top: 1px solid var(--line); padding-top: 18px; }
.notes summary {
  cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 750; color: var(--ink-2);
}
.notes summary::-webkit-details-marker { display: none; }
.notes summary .count { font-size: 12px; font-weight: 700; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 1px 8px; }
.notes summary svg.i { width: 16px; height: 16px; transition: transform .2s; color: var(--muted); }
.notes[open] summary svg.i { transform: rotate(180deg); }
.note { margin-top: 14px; padding: 14px 16px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line-2); font-size: 14px; line-height: 1.75; color: var(--ink-2); }
.note-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin-bottom: 4px; }
.note-ref { font-size: 12px; font-weight: 750; color: var(--accent); font-variant-numeric: tabular-nums; }
.note-title { font-weight: 700; color: var(--ink); }
.credit { margin: 28px .7em 0; font-size: 12px; line-height: 1.6; color: var(--faint); }
.credit a { color: inherit; }

/* ───────── 선택한 절 도구 ───────── */
.verse-bar {
  position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow-lg);
  z-index: 30; animation: rise .22s ease;
  max-width: calc(100vw - 24px);
}
.verse-bar[hidden] { display: none; }
.verse-bar-ref { font-weight: 750; font-size: 14px; white-space: nowrap; }
.swatches { display: flex; gap: 6px; padding: 0 4px; border-left: 1px solid var(--line); border-right: 1px solid var(--line); padding: 0 10px; }
.sw { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line); display: grid; place-items: center; color: var(--muted); }
.sw svg.i { width: 14px; height: 14px; }
.sw-yellow { background: #FFD966; } .sw-green { background: #7FD69B; } .sw-blue { background: #8DB6FF; } .sw-pink { background: #FF9CB4; }
.sw-none { background: var(--surface-2); }
.sw[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ink); }
.text-btn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 999px; font-size: 13.5px; font-weight: 650; color: var(--ink-2); white-space: nowrap; }
.text-btn:hover { background: var(--line-2); }
.text-btn svg.i { width: 16px; height: 16px; }
.text-btn.strong { background: var(--accent); color: var(--accent-ink); }
.text-btn.strong:hover { background: var(--accent); opacity: .9; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 10px); } }

.toast {
  position: fixed; left: 50%; top: calc(var(--topbar-h) + 14px); transform: translate(-50%, -8px);
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 600; box-shadow: var(--shadow-lg); z-index: 60;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ───────── 시트(대화상자) ───────── */
dialog.sheet {
  width: min(760px, calc(100vw - 32px)); max-height: min(86vh, 900px);
  padding: 0; border: 1px solid var(--line); border-radius: 22px;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg);
  display: none; flex-direction: column; overflow: hidden;
}
dialog.sheet[open] { display: flex; animation: pop .2s ease; }
dialog.sheet.narrow { width: min(520px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(15, 17, 21, .42); backdrop-filter: blur(3px); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.985); } }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 20px 12px 24px; }
.sheet-head h2 { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.sheet-sub { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }
.sheet-tools { display: flex; gap: 8px; padding: 4px 20px 12px 24px; }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 24px 24px; overscroll-behavior: contain; }
.search { flex: 1; display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 6px 0 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 15px; height: 100%; }
.search input::-webkit-search-cancel-button { display: none; }
.progress { height: 6px; margin: 0 24px 12px; border-radius: 99px; background: var(--line-2); overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .3s; }

.book-chips { display: flex; gap: 6px; overflow-x: auto; padding: 0 24px 12px; scrollbar-width: none; flex: none; }
.book-chips::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); font-size: 13px; font-weight: 650; color: var(--ink-2); background: var(--surface); }
.chip:hover { border-color: var(--accent-line); color: var(--accent); }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.plan-book { margin-bottom: 8px; }
.plan-book h3 {
  position: sticky; top: -4px; z-index: 1; margin: 0; padding: 12px 4px 8px;
  background: var(--surface); font-size: 13px; font-weight: 800; color: var(--muted); letter-spacing: .02em;
  display: flex; justify-content: space-between;
}
.plan-book h3 small { font-weight: 600; }
.plan-item {
  width: 100%; display: grid; grid-template-columns: 3.2em minmax(0, 1fr) 28px; align-items: center; gap: 10px;
  padding: 10px 8px; border-radius: 12px; text-align: left; transition: background .12s;
}
.plan-item:hover { background: var(--surface-2); }
.plan-item.current { background: var(--accent-soft); }
.plan-item.flash { animation: flash 1.2s ease; }
@keyframes flash { 30% { background: var(--focus-bg); } }
.pn { font-size: 13px; font-weight: 800; color: var(--faint); text-align: right; font-variant-numeric: tabular-nums; }
.plan-item.current .pn { color: var(--accent); }
.pt { min-width: 0; display: flex; flex-direction: column; }
.pt b { font-weight: 650; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pt small { color: var(--muted); font-size: 12.5px; margin-top: 1px; }
.pc { width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--line); display: grid; place-items: center; color: transparent; }
.pc svg.i { width: 14px; height: 14px; stroke-width: 3; }
.plan-item.done .pc { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.plan-item.done .pt b { color: var(--muted); }
.empty { padding: 40px 0; text-align: center; color: var(--muted); }

.crumbs { display: flex; align-items: center; gap: 4px; min-width: 0; }
.crumbs button { font-size: 20px; font-weight: 800; color: var(--muted); letter-spacing: -.02em; }
.crumbs button:hover { color: var(--accent); }
.crumbs .sep { color: var(--faint); }
.crumbs .sep svg.i { width: 18px; height: 18px; }
.crumbs h2 { white-space: nowrap; }
.find-hint { margin: -4px 24px 10px; font-size: 13px; color: var(--accent); min-height: 1em; }
.find-hint:empty { display: none; }
.group-label { margin: 14px 0 8px; font-size: 12.5px; font-weight: 800; color: var(--muted); letter-spacing: .03em; }
.group-label:first-child { margin-top: 2px; }
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.book-btn {
  height: 58px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface);
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center; padding: 0 14px;
  transition: all .12s; text-align: left;
}
.book-btn b { font-size: 15px; font-weight: 700; letter-spacing: -.02em; }
.book-btn small { font-size: 12px; color: var(--muted); }
.book-btn:hover, .num-btn:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.book-btn.current { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.num-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 8px; }
.num-btn { height: 52px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; transition: all .12s; }
.num-btn.current { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.find-actions { display: flex; gap: 8px; margin-bottom: 14px; }

/* 설정 */
.settings fieldset { border: 0; margin: 0 0 20px; padding: 0; }
.settings legend { font-size: 13px; font-weight: 800; color: var(--muted); margin-bottom: 8px; letter-spacing: .02em; }
.settings .two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.settings label.select { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.settings select {
  height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); padding: 0 12px;
  font-size: 15px; font-weight: 600;
}
.choice { display: flex; flex-wrap: wrap; gap: 6px; }
.choice label { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.choice span {
  display: inline-flex; align-items: center; height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line);
  font-size: 14px; font-weight: 600; color: var(--ink-2); background: var(--surface); transition: all .12s;
}
.choice input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.choice input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.range-row { display: flex; align-items: center; gap: 12px; margin-top: 6px; }
.range-row span { font-size: 13px; color: var(--muted); width: 5.5em; flex: none; }
.range-row output { width: 3.2em; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.range-row input[type="range"] { flex: 1; accent-color: var(--accent); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line-2); font-size: 14.5px; font-weight: 600; }
.switch-row small { display: block; color: var(--muted); font-weight: 500; font-size: 12.5px; }
.switch-row input { appearance: none; width: 44px; height: 26px; border-radius: 99px; background: var(--line); position: relative; cursor: pointer; flex: none; transition: background .15s; }
.switch-row input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.switch-row input:checked { background: var(--accent); }
.switch-row input:checked::after { transform: translateX(18px); }
.settings .foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; margin: 0 0 18px; font-size: 14px; }
.keys dt { white-space: nowrap; }
.keys dd { margin: 0; color: var(--ink-2); }
kbd { display: inline-block; min-width: 1.8em; padding: 1px 6px; border-radius: 6px; border: 1px solid var(--line); border-bottom-width: 2px; background: var(--surface-2); font: 600 12.5px var(--sans); text-align: center; }

/* ───────── 강의 모드 ───────── */
.dock { display: none; }
body.lecture .topbar, body.lecture .verse-bar, body.lecture .read-toggle, body.lecture .passbar .nav-arrow { display: none; }
body.lecture {
  --fs: var(--lfs, 34px);
  --passbar-h: auto;
}
body.lecture .passbar { padding: 22px 48px 14px; background: transparent; }
body.lecture .passbar-main { text-align: left; display: flex; align-items: baseline; gap: 18px; }
body.lecture .passbar-title { font-size: clamp(22px, 2.2vw, 34px); order: 1; }
body.lecture .passbar-eyebrow { font-size: clamp(14px, 1.2vw, 18px); order: 2; color: var(--muted); }
body.lecture .reader { max-width: none; padding: 0 40px 28px; gap: 24px; }
body.lecture .pane, body.lecture .single { border-radius: 20px; }
body.lecture .pane-head, body.lecture .grid-head { padding: 16px 36px 14px; }
body.lecture .pane-head strong, body.lecture .grid-head strong { font-size: 16px; }
body.lecture .content { padding: 22px 26px 45vh; }
body.lecture .v { padding: .42em .65em; border-radius: 16px; cursor: default; }
body.lecture .v:hover { background: none; }
body.lecture .v[class*="mk-"]:hover { background: unset; }
body.lecture .v.mk-yellow { background: var(--m-yellow); } body.lecture .v.mk-green { background: var(--m-green); }
body.lecture .v.mk-blue { background: var(--m-blue); } body.lecture .v.mk-pink { background: var(--m-pink); }
body.lecture .v.is-focus { background: var(--focus-bg); box-shadow: inset 6px 0 0 var(--focus-line); }
body.lecture.dim.has-focus .v:not(.is-focus) { opacity: .28; }
body.lecture .notes, body.lecture .credit { display: none; }
body.lecture .qa { margin: 40px .65em 0; padding: 26px 30px; border-radius: 20px; }
body.lecture .qa-label { font-size: clamp(12px, 1vw, 15px); }
body.lecture .qa-q { font-size: clamp(20px, 1.9vw, 32px); }
body.lecture .qa-a p { font-size: clamp(17px, 1.5vw, 26px); }
body.lecture .qa-a summary { height: 42px; font-size: 15px; }
body.lecture .summary { padding: 0 40px 16px; }
body.lecture .summary-in { padding: 16px 28px; gap: 18px; border-radius: 20px; }
body.lecture .summary-label { font-size: clamp(12px, 1vw, 15px); margin-top: .35em; }
body.lecture .summary-in p { font-size: clamp(17px, 1.45vw, 26px); line-height: 1.65; }
body.lecture .scroller { scrollbar-width: none; }
body.lecture .scroller::-webkit-scrollbar { display: none; }
body.lecture.idle, body.lecture.idle * { cursor: none !important; }

body.lecture .dock {
  display: flex; align-items: center; gap: 4px; position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  padding: 6px; border-radius: 18px; background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(16px); border: 1px solid var(--line); box-shadow: var(--shadow-lg); z-index: 40;
  transition: opacity .3s, transform .3s;
}
body.lecture.idle .dock { opacity: 0; transform: translate(-50%, 12px); pointer-events: none; }
.dock button { height: 44px; min-width: 44px; padding: 0 10px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; white-space: nowrap; color: var(--ink-2); font-weight: 700; font-size: 15px; }
.dock button:hover { background: var(--line-2); }
.dock button[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); }
.dock button sup { font-size: 10px; }
.dock i { width: 1px; height: 24px; background: var(--line); margin: 0 4px; }
.dock .dock-exit { padding: 0 16px; background: var(--ink); color: var(--bg); }
.dock .dock-exit:hover { background: var(--ink); opacity: .88; }

/* OBS 투명 배경 */
[data-theme="transparent"] body { background: transparent; }
[data-theme="transparent"] .pane, [data-theme="transparent"] .single { background: rgba(10, 12, 16, .55); border-color: rgba(255, 255, 255, .08); box-shadow: none; }
[data-theme="transparent"] .pane-head, [data-theme="transparent"] .grid-head { background: transparent; border-color: rgba(255, 255, 255, .1); }
[data-theme="transparent"] .v { text-shadow: 0 1px 3px rgba(0, 0, 0, .6); }
[data-theme="transparent"] .qa,
[data-theme="transparent"] .summary-in { background: rgba(10, 12, 16, .6); border-color: rgba(255, 255, 255, .1); }
[data-theme="transparent"] .passbar-title { text-shadow: 0 2px 8px rgba(0, 0, 0, .6); }

/* ───────── 반응형 ───────── */
@media (max-width: 1100px) {
  .brand-text small { display: none; }
  .lecture-btn-label { display: none; }
  .lecture-btn { padding: 0 11px; }
}
@media (max-width: 900px) {
  .font-step { display: none; }
  .pane-head, .grid-head { padding: 12px 20px 10px; }
  .content { padding: 10px 10px 40vh; }
  .reader { gap: 10px; padding-left: 10px; padding-right: 10px; }
  .layout-rows .v, .grid-head { column-gap: 18px; }
  .grid-head span { display: none; }
}
@media (max-width: 720px) {
  :root { --topbar-h: 56px; --passbar-h: 56px; --radius: 14px; }
  .topbar { gap: 8px; padding-left: 12px; padding-right: 8px; }
  .brand-text { display: none; }
  .brand-mark { width: 32px; height: 32px; }
  .topbar-center { justify-content: flex-start; gap: 6px; }
  .pill { height: 36px; padding: 0 12px 0 9px; font-size: 13.5px; gap: 6px; }
  #btnPlan .pill-icon, .pill-pre, .pill .long { display: none; }
  .pill .short { display: inline; }
  .topbar-center .pill { flex: none; }
  #btnFind { flex: 0 1 auto; }
  #btnPlan { padding-left: 12px; }
  #btnSync { display: none; }
  .topbar-tools { gap: 2px; }
  .icon-btn { width: 38px; height: 38px; }
  .lecture-btn { height: 38px; width: 38px; padding: 0; justify-content: center; margin-left: 2px; }
  .passbar { gap: 8px; padding-left: 10px; padding-right: 10px; }
  .nav-arrow { width: 38px; height: 38px; }
  .passbar-title { font-size: 16px; }
  .passbar-eyebrow { font-size: 12px; }
  .read-toggle { width: 36px; padding: 0; justify-content: center; }
  .read-label { display: none; }
  .reader { padding: 0 0 0; }
  .pane, .single { border-radius: 18px 18px 0 0; border-bottom: 0; }
  .pane-head, .grid-head { padding: 12px 18px 10px; }
  .content { padding: 8px 6px 45vh; }
  .v { padding: .45em .55em; }
  .vh { margin-left: .5em; margin-right: .5em; }
  .content > .summary-in { margin: 6px .5em 14px; padding: 12px 14px; flex-direction: column; gap: 6px; }
  .summary-in p { font-size: 15px; }
  .qa { margin: 26px .5em 0; padding: 16px 16px; }
  .qa-q { font-size: 16.5px; }
  body.lecture .summary { padding: 0 8px 10px; }
  dialog.sheet, dialog.sheet.narrow {
    width: 100vw; max-width: 100vw; max-height: 92vh; margin: auto 0 0; border-radius: 22px 22px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  dialog.sheet[open] { animation: slide .25s ease; }
  .sheet-head { padding: 18px 16px 10px 20px; }
  .sheet-tools { padding: 4px 16px 10px 20px; }
  .sheet-body { padding: 4px 16px 24px 20px; }
  .book-chips, .progress { margin-left: 20px; margin-right: 16px; padding-left: 0; padding-right: 0; }
  .find-hint { margin-left: 20px; }
  .book-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .book-btn { padding: 0 10px; }
  .book-btn b { font-size: 13.5px; letter-spacing: -.045em; white-space: nowrap; }
  .verse-bar { gap: 6px; padding: 6px 6px 6px 14px; bottom: max(12px, env(safe-area-inset-bottom)); }
  .verse-bar .text-btn { padding: 0 8px; }
  .swatches { gap: 4px; padding: 0 6px; }
  .sw { width: 24px; height: 24px; }
  body.lecture .passbar { padding: 14px 18px 10px; }
  body.lecture .passbar-main { flex-direction: column; gap: 2px; }
  body.lecture .reader { padding: 0 8px 8px; }
  body.lecture .content { padding: 12px 8px 45vh; }
  body.lecture .dock { bottom: 10px; max-width: calc(100vw - 16px); overflow-x: auto; }
  body.lecture .dock button { min-width: 40px; height: 40px; padding: 0 8px; }
}
@keyframes slide { from { transform: translateY(40px); opacity: .4; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
