:root {
  /* 읽음 색(앱 DEFAULT_COLOR_FOR_CHECKED)과 읽는 중 색(DEFAULT_COLOR_FOR_READING). 라이트·다크 같게 */
  --read: #9e3737;
  --reading: #ba5757;
  --bg: #fff;
  --fg: #222;
  --muted: #666;
  --line: #ddd;
  --bar: #f6f6f6;
  --accent: #1a73e8;
  --accent-bg: #e8f0fe;
  --error: #b00020;
  --verse-size: 18px; /* app.js가 저장해 둔 글자 크기로 바꾼다 */
  /* 본문화면 글자색·배경색(본문화면설정). 고르지 않았으면 테마 색. app.js가 고른 색으로 바꾼다 */
  --page-fg: var(--fg);
  --page-bg: var(--bg);
  /* 절 번호, (없음) 같은 흐린 글자는 고른 글자색을 배경 쪽으로 흐리게 */
  --page-muted: color-mix(in srgb, var(--page-fg) 60%, var(--page-bg));
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --fg: #e6e6e6;
    --muted: #9a9a9a;
    --line: #333;
    --bar: #1e1e1e;
    --accent: #8ab4f8;
    --accent-bg: #23324a;
    --error: #ff6b81;
  }
}

* { box-sizing: border-box; }
html { color-scheme: light dark; }
body {
  margin: 0;
  /* 책·장 바를 아래에 둘 때 내용이 짧아도 바가 화면 맨 아래에 붙게 */
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  background: var(--page-bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  line-height: 1.7;
}
button, select { font: inherit; color: inherit; }
button {
  min-height: 40px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  cursor: pointer;
}
button:disabled { opacity: 0.4; cursor: default; }
select {
  min-height: 40px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
}

/* ---- 위쪽 막대 ---- */
/* 책·장 바. 앱처럼 아래가 기본(text_pref_header_bottom). 아래일 때는 wrap-reverse로 첫 줄(◀ 책 장 ▶ ☰)이
   맨 아래(엄지 닿는 곳)에 오고, 검색·글자 크기 줄이 그 위에 온다. html.bar-top이면 위쪽, 첫 줄이 맨 위 */
.bar {
  position: sticky;
  bottom: 0;
  order: 2; /* main 뒤 */
  z-index: 1;
  display: flex;
  flex-wrap: wrap-reverse;
  gap: 6px;
  padding: 6px 8px;
  background: var(--bar);
  border-top: 1px solid var(--line);
}
.bar-top .bar {
  top: 0;
  bottom: auto;
  order: 0;
  flex-wrap: wrap;
  border-top: 0;
  border-bottom: 1px solid var(--line);
}
.nav { display: flex; gap: 4px; flex: 1 1 200px; min-width: 0; }
.tools { display: flex; gap: 4px; flex: none; justify-content: flex-end; }
/* ☰는 늘 바의 오른쪽 끝(앱의 메뉴 자리). 책·장·절·읽음 🔍 ☰가 폰 폭(360px)에서 한 줄에 들어간다.
   더 좁아서 두 줄이 되면 ☰는 책 장 절 줄 끝에 오고 검색이 다른 줄로 간다(그 줄은 오른쪽으로 붙인다).
   글자 크기 가-/가+는 본문화면설정으로 옮겼다.
   316px = 패딩 16 + 책 장 절 읽음 200 + 🔍 44 + ☰ 44 + 틈 12 (읽음 체크 상자를 넣어 290px에서 늘었다. 320px 폰은 한 줄) */
#menuBtn { flex: none; order: 3; }
@media (max-width: 315px) {
  .tools { flex: 1 1 100%; }
  .nav { order: 1; }
  #menuBtn { order: 2; }
  .tools { order: 3; }
}
.icon { min-width: 44px; padding: 4px 6px; }
.ref {
  flex: 1 1 auto;
  padding: 4px 6px; /* "데살로니가전서 5장"도 폰 폭에서 잘리지 않게 */
  min-width: 0;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* 장 단추: 숫자만(앱처럼). 세 자리(시 150)도 들어가게 */
.chap { flex: none; min-width: 44px; padding: 4px 6px; font-weight: 600; }
/* 절 단추: 맨 위 절 / 마지막 절을 두 줄로 작게(앱 verse_select, 12sp) */
.verse {
  flex: none;
  min-width: 44px;
  padding: 2px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
#verseNow { font-weight: 600; }
#verseLast { color: var(--muted); border-top: 1px solid var(--line); min-width: 2.2em; text-align: center; }
#verseLast:empty { display: none; }
/* 읽음 체크 상자(앱 read_check). 라벨 전체를 눌러도 되게 칸을 키운다 */
.read-check { flex: none; display: flex; align-items: center; justify-content: center; min-width: 34px; cursor: pointer; }
.read-check input { width: 22px; height: 22px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.read-check:has(input:disabled) { opacity: 0.4; cursor: default; }
/* 음성 읽기 단추(앱 book_audio). 읽는 동안 "1.3x"처럼 속도가 보여도 폭이 그대로이게 */
.tts-btn { flex: none; min-width: 44px; padding: 4px 4px; font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.tts-btn[hidden] { display: none; }
/* 절을 고르면 ▶가 '고른 절부터 듣기'임을 보이게 강조색으로 */
.tts-btn.from-verse { color: var(--accent); border-color: var(--accent); }
/* 음성 읽기 줄. 바 안의 한 줄(늘 다른 것들 뒤 order). 바가 아래면(wrap-reverse) 책·장 줄 위에, 위면 아래에 온다 */
.tts-bar { flex: 1 1 100%; order: 9; display: flex; justify-content: center; gap: 12px; }
.tts-bar[hidden] { display: none; }
.tts-bar svg { display: block; width: 24px; height: 24px; margin: auto; }
/* 지금 읽는 절 */
#verses li.tts-now { background: color-mix(in srgb, var(--accent) 14%, transparent); border-radius: 4px; }

/* ---- 본문 ---- */
/* 여러 단 대조 보기는 넓게. 한 칸이 너무 넓어지지 않게 역본 수(--nver, app.js) × 글자 34자쯤까지만 */
main.wide { max-width: calc(var(--nver, 2) * var(--verse-size) * 34 + 80px); }
/* 넓은 화면에서는 오른쪽 이동 버튼 자리를 비운다(폰은 칸이 좁아져서 앱처럼 겹치게 둔다) */
@media (min-width: 600px) {
  main.wide { padding-right: 48px; }
  .nav-left main.wide { padding-right: 16px; padding-left: 48px; } /* 이동 버튼을 왼쪽에 둘 때 */
}
main { flex: 1 0 auto; width: 100%; max-width: 760px; margin: 0 auto; padding: 8px 16px 24px; color: var(--page-fg); }
/* 아래쪽 동작 바(#selBar)가 마지막 절을 가리지 않게 */
html:not(.bar-top) main { padding-bottom: calc(24px + var(--sel-h, 0px) + var(--memo-h, 0px)); }
.bar-top main { padding-bottom: calc(24px + var(--memo-h, 0px)); }
#status { color: var(--muted); font-size: 0.9rem; margin: 8px 0; }
#status.error { color: var(--error); }
#emptyBox { margin: 8px 0; }
#status { word-break: keep-all; }

/* 한글은 낱말 가운데서 줄을 바꾸지 않게. 너무 긴 낱말만 아무 데서나 */
#verses { list-style: none; padding: 0; margin: 0; font-size: var(--verse-size); word-break: keep-all; overflow-wrap: anywhere; }
/* 절 번호 칸과 본문 칸을 나눈다(앱처럼). 본문이 여러 줄이어도 절 번호 밑으로 들어가지 않는다.
   번호 칸은 세 자리(시 119:176)가 들어가는 고정 폭이라 절마다 본문 시작 위치가 같다 */
#verses li {
  display: grid;
  grid-template-columns: 1.6em minmax(0, 1fr); /* minmax: 긴 낱말이 칸을 넓히지 않게 */
  column-gap: 0.4em;
  align-items: baseline;
  padding: 0.25em 0;
}
#verses .num { color: var(--page-muted); font-size: 0.7em; text-align: right; }
/* 절을 누르면 고른다(app.js 절 고르기). manipulation: 두 번 눌러 확대를 꺼서 누를 때 늦지 않게(두 손가락 확대는 된다) */
#verses li { cursor: pointer; -webkit-tap-highlight-color: transparent; }
#verses { touch-action: manipulation; }
#verses li.selected { background: color-mix(in srgb, var(--accent) 22%, transparent); border-radius: 4px; }
#verses .missing { color: var(--page-muted); }
/* 형광펜(app.js paintHighlights). 본문, 나의형광펜목록, 설정 창 견본에 같은 모양.
   모양은 뿌리의 클래스(app.js applyView: hl-bg·hl-underline·hl-color·hl-bold, 앱 HighlightStyle), 고른 색은 --hl-bg·--hl-fg.
   색을 고르지 않았으면 노랑을 바탕색(--hl-base)에 섞어 밝은·어두운·고른 배경 어디서나 글자가 읽히게
   (어두운 배경이면 앱 기본 형광펜 색 rgb(51,51,0)과 비슷한 어두운 노랑). 글자·밑줄 색은 앱 기본 rgb(235,200,61)이
   밝은 배경에서 잘 안 보여서 금색을 글자색(--hl-ink)에 섞는다. 여러 줄이면 줄마다 둥글게 */
#verses, .color-sample { --hl-base: var(--page-bg); --hl-ink: var(--page-fg); }
.hl-list { --hl-base: var(--bg); --hl-ink: var(--fg); }
.hl-bg :is(#verses .text.hl, .hl-list .htext, .hl-sample) {
  background: var(--hl-bg, color-mix(in srgb, #e6c200 38%, var(--hl-base)));
  border-radius: 2px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.hl-underline :is(#verses .text.hl, .hl-list .htext, .hl-sample) {
  text-decoration: underline;
  text-decoration-color: var(--hl-fg, color-mix(in srgb, #d4a800 70%, var(--hl-ink)));
  text-decoration-thickness: 0.1em;
  text-underline-offset: 0.18em;
}
.hl-color :is(#verses .text.hl, .hl-list .htext, .hl-sample) {
  color: var(--hl-fg, color-mix(in srgb, #d4a800 70%, var(--hl-ink)));
}
.hl-bold :is(#verses .text.hl, .hl-list .htext, .hl-sample) { font-weight: 700; }


/* ---- 책·장 고르기 ---- */
dialog {
  width: min(720px, calc(100vw - 16px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--fg);
}
dialog[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: rgb(0 0 0 / 0.45); }
.picker-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
}
.picker-head h2 { flex: 1; margin: 0; font-size: 1.05rem; text-align: center; }
.picker-head .link { border: 0; background: none; color: var(--accent); }
#pickerBody { overflow-y: auto; padding: 8px 12px 16px; }
#pickerBody h3 { font-size: 0.9rem; color: var(--muted); margin: 8px 0 6px; }

.grid { display: grid; gap: 6px; }
.grid.books { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); }
.grid.chapters { grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); }
/* 폰 폭에서 책 이름이 세 칸에 들어가게. "데살로니가전서"처럼 긴 이름은 두 줄로 */
.grid button { padding: 4px 2px; font-size: 0.9rem; line-height: 1.3; word-break: keep-all; overflow-wrap: anywhere; }
/* 가장 긴 낱말이 안 들어가는 책 이름(프랑스어 Thessaloniciens 등)은 글자를 줄인다. app.js fitLongBookNames */
.grid button.long { font-size: 0.74rem; }
.grid button.current { border-color: var(--accent); background: var(--accent-bg); font-weight: 600; }
/* 읽은 장(고른 역본 모두). 지금 장이면 테두리로 함께 보인다 */
.grid button.read { background: var(--read); color: #fff; }
.grid button.read.current { border: 2px solid var(--accent); }

/* ---- 성경읽기통계 ---- */
.stats-head { display: flex; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.stats-head select { flex: 1; min-width: 0; }
#statsAll {
  flex: none; min-width: 52px; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 6px; font-weight: 600; font-size: 0.9rem;
}
ul.stats { list-style: none; margin: 0; padding: 0 0 8px; }
.stat {
  display: block; width: 100%; min-height: 0; padding: 10px 16px;
  border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: none; text-align: left;
}
.stat-top { display: flex; align-items: baseline; gap: 8px; }
.stat-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat.summary .stat-name { font-weight: 600; }
.stat-value { flex: none; font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.stat-bar { display: block; height: 6px; margin-top: 6px; border-radius: 5px; background: var(--line); overflow: hidden; }
.stat.summary .stat-bar { height: 10px; }
.stat-bar span { display: block; height: 100%; border-radius: 5px; background: var(--reading); }
.stat-bar span.done { background: var(--read); }

/* ---- 나의형광펜목록, 책갈피(같은 목록 꼴) ---- */
#hlCount, #bmCount, #mlCount { font-weight: normal; font-size: 0.85rem; color: var(--muted); }
#hlBox .empty, #bmBox .empty, #mlBox .empty {
  margin: 24px 16px; color: var(--muted); white-space: pre-line; text-align: center;
  word-break: keep-all; overflow-wrap: anywhere; /* 한국어가 낱말 가운데서 끊기지 않게 */
}
#hlBox .empty[hidden], #bmBox .empty[hidden], #mlBox .empty[hidden] { display: none; }
/* 나의메모목록: 검색 칸이 넓게, 정렬은 글자만큼 */
#mlBox .stats-head select { flex: 0 1 auto; }
.ml-search { flex: 1 1 8em; min-width: 0; position: relative; display: flex; }
.ml-search input {
  flex: 1; min-width: 0; min-height: 40px; padding: 4px 2.2em 4px 8px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: inherit; font: inherit;
}
/* 검색할 때마다 창 높이가 바뀌면 입력하는 동안 창이 들썩이므로 높이를 고정한다 */
#mlBox[open] { height: min(720px, calc(100dvh - 32px)); }
#mlBox .ml-list { flex: 1; }
.ml-search .icon { position: absolute; right: 0; top: 0; bottom: 0; border: 0; background: none; color: var(--muted); }
.ml-search .icon[hidden] { display: none; }
/* 메모는 3줄까지(앱 MEMO_MAX_LINES). 줄바꿈은 그대로 보인다 */
.ml-list .mtext {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden;
  white-space: pre-line;
}
.ml-list .more { border-bottom: 0; }
.ml-list .more button { flex: 1; margin: 8px 4px 0; }
/* 책갈피 창 아래 줄은 알릴 것이 있을 때만 */
#bmBox .picker-foot:has(> .foot-status[hidden]) { display: none; }
.bm-list .go { padding: 12px 4px; }
.bm-list .sref { font-size: 1em; } /* 본문 없이 참조만 있는 줄이라 크게 */
.bm-list .del { margin-top: 8px; }
ul.hl-list { list-style: none; margin: 0; padding: 0 0 8px; word-break: keep-all; overflow-wrap: anywhere; }
.hl-list li { display: flex; align-items: flex-start; border-bottom: 1px solid var(--line); }
.hl-list .go {
  flex: 1; min-width: 0; display: block; padding: 8px 4px;
  border: 0; border-radius: 0; background: none; text-align: left; line-height: 1.6;
}
.hl-list .go:hover { background: var(--bar); }
.hl-list .sref { display: block; color: var(--accent); font-weight: 600; font-size: 0.85em; }
.hl-list .del { flex: none; margin: 6px 0 0 4px; border: 0; background: none; color: var(--muted); }

/* ---- 대조 보기 ----
   앱의 2단 보기(VerseList)는 역본을 둘씩 한 줄에 놓는다(1·2, 3·4 …). 1단(VerseListOneColumn)은 위아래로.
   절과 절 사이에 줄을 그어 어느 칸이 같은 절인지 보이게 한다 */
#verses.compare li { display: block; padding: 0.45em 0; border-bottom: 1px solid var(--line); }
#verses.compare .cell {
  display: grid;
  grid-template-columns: 1.6em minmax(0, 1fr); /* 단일 보기의 절 줄과 같은 번호 칸 */
  column-gap: 0.4em;
  align-items: baseline;
  min-width: 0;
}
#verses.compare .cells { display: grid; gap: 0.3em 0.9em; min-width: 0; }
/* 여러 단(1단으로 보기를 끈 상태): 화면 폭에 맞춰 자동. 한 칸은 글자 18자쯤(18em) 이상이라 넓으면 여러 역본이
   한 줄에 서고, 좁아지면 남는 역본이 다음 줄로 밀린다. 폰처럼 좁아도 앱의 2단처럼 최소 둘씩(50%).
   auto-fit이라 역본이 적으면 빈 칸 없이 늘어난다. em이라 글자를 키우면 한 줄에 서는 역본이 줄어든다 */
#verses.compare.two .cells { grid-template-columns: repeat(auto-fit, minmax(min(calc(50% - 0.45em), 18em), 1fr)); }
#verses.compare .vname { color: var(--accent); font-size: 0.65em; margin-right: 0.2em; }
/* 역본명은 앱처럼 기본은 숨김(앱 "여백 및 역본명 제거" 기본 켜짐). 본문화면설정의 "역본명 보이기"로 html.show-vname */
html:not(.show-vname) #verses.compare .vname { display: none; }
/* 2단은 칸이 좁지만 한글을 낱말 중간에서 끊으면(word-break: normal) 더 읽기 어려웠다. keep-all 그대로 둔다 */

/* ---- 역본 고르기 ---- */
#verBody, .scroll { overflow-y: auto; padding: 4px 12px 8px; }
#verBody h3, .scroll h3 { font-size: 0.9rem; color: var(--muted); margin: 12px 0 4px; }
.more-link { margin: 12px 0 4px; }
button.link { border: 0; background: none; color: var(--accent); padding: 4px 0; text-align: left; }
.hint { font-size: 0.85rem; color: var(--muted); margin: 6px 0; }
.hint.error { color: var(--error); }

/* ---- 도움말 ---- 글이 길어 본문처럼 줄 간격을 넉넉히. 기기별 설치 방법은 details로 접는다 */
.help { line-height: 1.55; font-size: 0.95rem; padding-bottom: 16px; }
.help h3 { color: var(--fg); font-size: 1rem; margin: 18px 0 6px; }
.help h3:first-child { margin-top: 8px; }
.help h4 { font-size: 0.9rem; margin: 12px 0 4px; }
.help p { margin: 6px 0; }
.help ul, .help ol { margin: 6px 0; padding-left: 1.4em; }
.help li { margin: 3px 0; }
.help a { color: var(--accent); }
/* 도움말 탭. 폰 폭(360px)에서 세 칸이 한 줄에 들어가게 칸을 똑같이 나눈다 */
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tabs:empty { display: none; }
/* 탭마다 내용 길이가 달라 창 크기가 바뀌지 않게 도움말 창은 높이를 채운다 */
#helpBox { height: calc(100dvh - 32px); }
.tabs button {
  flex: 1; min-width: 0; padding: 10px 4px; border: 0; border-bottom: 3px solid transparent;
  background: none; color: var(--muted); font: inherit; font-size: 0.9rem; cursor: pointer;
}
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.help details { border: 1px solid var(--line); border-radius: 8px; margin: 8px 0; padding: 0 12px; }
.help details[open] { padding-bottom: 8px; }
.help summary { cursor: pointer; font-weight: 600; padding: 10px 0; }
.help .note { border-left: 3px solid var(--accent); background: var(--accent-bg); padding: 8px 10px; border-radius: 4px; }
/* 꼭 알아야 할 경고(설치 탭의 브라우저 데이터 지우기). 안내(.note)와 구별되게 오류색. 어두운 화면에서도 배경이 튀지 않게 섞는다 */
.help .warn { border-left: 3px solid var(--error); background: color-mix(in srgb, var(--error) 10%, var(--bg)); padding: 4px 10px; border-radius: 4px; margin: 10px 0; }
.help .warn p:first-child { color: var(--error); }
.help code { font-size: 0.9em; }
.ver-list { list-style: none; margin: 0; padding: 0; }
.ver-list li {
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid var(--line);
}
.ver-list label {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  cursor: pointer;
  line-height: 1.3;
}
.ver-list input { width: 20px; height: 20px; flex: none; margin: 0; }
.ver-list .pad { width: 20px; flex: none; } /* 체크 상자가 없는 줄도 이름 위치를 맞춘다 */
.ver-list .order { min-width: 1.2em; color: var(--accent); font-weight: 600; text-align: center; }
.ver-list .name { overflow-wrap: anywhere; }
.badge {
  flex: none;
  font-size: 0.75rem;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 6px;
}
.ver-list .del, .ver-list .edit { min-width: 40px; min-height: 36px; border: 0; background: none; }
.picker-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
}
.picker-foot .spacer { flex: 1; }
.foot-status { flex: 1 1 100%; margin: 0; font-size: 0.85rem; color: var(--muted); overflow-wrap: anywhere; }
.foot-status.error { color: var(--error); }
.foot-status[hidden] { display: none; }
/* 폰 폭에서 확인 버튼만 둘째 줄로 밀리지 않게 체크 상자는 한 줄을 다 쓴다 */
.picker-foot .check { flex: 1 1 100%; }
.picker-foot .check[hidden] { display: none; }
.check { display: flex; align-items: center; gap: 6px; font-size: 0.9rem; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 0; }
button.primary { background: var(--accent); color: var(--bg); border-color: var(--accent); }

/* ---- 성경 파일 수동 넣기 ---- */
.import { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.import button { flex: 1 1 auto; min-height: 40px; }
#importNote { white-space: pre-line; color: var(--fg); }
#importNote.error { color: var(--error); }
/* 값을 주지 않은 progress는 브라우저가 계속 움직이는 바로 그린다. 단계별 진행률은 알 수 없어서 이렇게 둔다 */
#importProgress { display: block; width: 100%; height: 6px; margin-top: 12px; accent-color: var(--accent); }
#importProgress[hidden] { display: none; }
#dropOverlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgb(0 0 0 / 0.45);
  pointer-events: none; /* drop 이벤트는 밑의 문서가 받는다 */
}
#dropOverlay[hidden] { display: none; }
#dropOverlay p {
  margin: 0;
  padding: 24px;
  border: 3px dashed var(--accent);
  border-radius: 12px;
  background: var(--bg);
  color: var(--fg);
  text-align: center;
}
#backupNote { white-space: pre-line; }
/* 한글이 낱말 가운데서 끊기지 않게(긴 파일 이름은 anywhere로 끊는다) */
#updateText, #backupBody, #backupNote { word-break: keep-all; overflow-wrap: anywhere; }
.backup-notice { margin: 14px 0 4px; padding: 4px 12px; border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: 6px; font-size: 0.85rem; line-height: 1.5; }
#backupBody .backup-notice h3 { margin: 6px 0; color: var(--fg); }
.backup-notice p { margin: 0 0 8px; }
.backup-last { font-weight: 600; }
/* ---- 데이터 복구 ---- */
.restore-modes { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.restore-mode { display: flex; align-items: flex-start; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line);
  cursor: pointer; font-size: 0.9rem; line-height: 1.4; }
.restore-mode input { flex: none; width: 18px; height: 18px; margin: 2px 0 0; }
.restore-mode b { display: block; font-size: 1rem; }
#restoreResultText { white-space: pre-line; }
#syncAskText { white-space: pre-line; overflow-wrap: anywhere; } /* 역본 이름 목록이 길 수 있다 */
#conflictBox[open] { display: flex; flex-direction: column; max-height: calc(100dvh - 32px); }
.conflict-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; margin-bottom: 10px; }
#conflictBox .conflict-ref { margin: 0 0 4px; font-weight: 700; font-size: 1.05rem; }
.conflict-body h3 { margin: 12px 0 4px; font-size: 0.9rem; color: var(--muted); }
#conflictBox .conflict-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; user-select: text; }
#conflictRestRow { margin-bottom: 10px; }
#conflictRestRow[hidden] { display: none; }
/* 앱처럼 [이 기기] [백업] [둘 다] 순서로 같은 너비(다른 언어에서 글이 길어도 밖으로 밀리지 않게) */
.conflict-btns { display: flex; gap: 8px; }
.conflict-btns button { flex: 1 1 0; min-width: 0; min-height: 40px; }
#importBox.dropping { outline: 3px dashed var(--accent); outline-offset: -3px; }

/* ---- 메뉴 ----
   ☰ 아래 오른쪽에 붙는 작은 목록(앱의 옵션 메뉴). 모달로 열어 바깥을 누르면 닫힌다 */
/* ☰ 옆에 붙인다. 바가 아래면 ☰ 위로, 위면 ☰ 아래로(☰는 어느 쪽이든 바 끝 줄에 있다) */
dialog.menu {
  position: fixed;
  inset: auto 8px 52px auto;
  margin: 0;
  width: max-content;
  min-width: 180px;
  max-width: calc(100vw - 16px);
  /* 바(52px) 반대쪽에 8px 남긴다. 브라우저 기본 max-height(화면 - 약 38px)로는 항목이 많을 때(장 전체 복사·전송을
     더한 뒤 16개) 낮은 폰에서 메뉴 위쪽이 화면 밖으로 나갔다 */
  max-height: calc(100dvh - 60px);
  overflow-y: auto;
  padding: 4px 0;
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.25);
}
.bar-top dialog.menu { inset: 52px 8px auto auto; }
dialog.menu::backdrop { background: transparent; }
dialog.menu button {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 8px 16px;
  border: 0;
  border-radius: 0;
  background: none;
  text-align: left;
}
dialog.menu button:hover, dialog.menu button:focus-visible { background: var(--bar); }

/* ---- 이동 버튼(기본 오른쪽 아래, 앱은 오른쪽 가운데) ----
   앱처럼 본문 위에 떠 있고 본문 글자색을 흐리게(앱은 알파 100/255) 칠한다. 본문을 가리지 않게 단추 사이만 누를 수 있다 */
.side-nav {
  position: fixed;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--page-fg);
  opacity: 0.4;
  pointer-events: none;
}
.side-nav[hidden] { display: none; }
/* 위치(본문화면설정). 아래쪽이면 책·장 바(아래일 때) 바로 위에 띄운다. 바는 폭에 따라 한 줄/두 줄이라
   높이를 app.js가 재서 --bar-h에 넣는다. 바가 위쪽이면 화면 맨 아래에서 조금 띄운다 */
.side-nav[data-pos^="left"] { right: auto; left: 2px; }
.side-nav[data-pos$="bottom"] {
  top: auto;
  bottom: calc(var(--bar-h, 0px) + var(--sel-h, 0px) + var(--memo-h, 0px) + 8px); /* 절을 고르면 동작 바 위로 */
  transform: none;
}
.bar-top .side-nav[data-pos$="bottom"] { bottom: calc(var(--memo-h, 0px) + 8px); }
.side-nav button {
  pointer-events: auto;
  width: 40px;
  height: 40px;
  min-height: 0;
  padding: 2px;
  border: 0;
  border-radius: 8px;
  background: transparent;
}
.side-nav button:active { background: color-mix(in srgb, var(--page-fg) 25%, transparent); }
.side-nav button.off { display: none; } /* 설정에서 고르지 않은 쌍 */
.side-nav button.none { visibility: hidden; } /* 갈 곳이 없을 때(창세기 1장의 이전 장 등). 자리는 지킨다 */
.side-nav svg { display: block; width: 36px; height: 36px; }

#toast {
  position: fixed;
  left: 50%;
  bottom: max(120px, calc(var(--bar-h, 0px) + var(--sel-h, 0px) + var(--memo-h, 0px) + 16px));
  transform: translateX(-50%);
  z-index: 6;
  max-width: calc(100% - 32px);
  padding: 8px 14px;
  border-radius: 18px;
  background: rgb(40 40 40 / 0.92);
  color: #fff;
  font-size: 0.9rem;
  text-align: center;
  word-break: keep-all;
}
#toast[hidden] { display: none; }

/* ---- 고른 절 동작 바 ----
   책·장 바 바로 옆(바가 아래면 바 위, 위면 바 아래)에 붙는 띠. 바와 같은 색 */
#selBar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--bar-h, 0px) + var(--memo-h, 0px));
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: var(--bar);
  border-top: 1px solid var(--line);
}
.bar-top #selBar { top: var(--bar-h, 0px); bottom: auto; border-top: 0; border-bottom: 1px solid var(--line); }
#selBar[hidden] { display: none; }
#selBar button[hidden] { display: none; }
#selCount { flex: 1; min-width: 1.2em; /* 숫자 하나는 늘 보이게(넘치면 app.js가 숫자만 남긴다) */ font-size: 0.9rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* 단추가 넘치면(대조 보기에서 칠하기·지우기가 함께 나오는 등) ✕가 화면 밖으로 밀리지 않게 단추 글을 … 로 줄인다 */
#selBar button { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#selBar #selClear { flex: none; min-width: 44px; } /* .icon의 min-width를 위 min-width: 0이 덮지 않게 */
/* 폰 폭에서 형광펜·지우기·복사·공유·✕가 함께 나오면 "2절 선택"이 22px로 줄어 안 보였다(360px). 단추를 조금 좁힌다 */
@media (max-width: 400px) {
  #selBar { gap: 4px; padding: 6px; }
  #selBar button { padding: 4px 6px; }
}

/* ---- 메모 ----
   본문의 메모 글(app.js paintMemos). 앱처럼 본문보다 작고(앱 memosize 0.8) 흐린 색(앱 기본 #AAAAAA).
   고른 글자색·배경색에 맞추려고 흐린 글자(--page-muted)를 쓴다. 줄바꿈은 쓴 그대로 */
#verses .memo {
  font-size: 0.8em;
  color: var(--page-muted);
  white-space: pre-wrap;
  margin-top: 0.15em;
}
#verses li > .memo { grid-column: 2; } /* 단일 보기: 본문 칸 밑에 */
/* 메모를 숨겼을 때 본문 앞의 ★(누르면 입력판) */
#verses .memo-star {
  min-height: 0;
  padding: 0 0.1em;
  border: 0;
  background: none;
  color: var(--page-muted);
  font: inherit;
  cursor: pointer;
}

/* 입력판(앱 MemoPanel). 책·장 바 바로 위(바가 위면 화면 맨 아래)에 떠 있다.
   키보드가 화면을 덮는 아이폰은 덮인 만큼(--kb) 올리고, 그때는 아래쪽 바가 키보드에 덮이므로 키보드에 붙인다 */
#memoPanel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: var(--bar-h, 0px);
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 8px;
  background: var(--bar);
  border-top: 1px solid var(--line);
}
.bar-top #memoPanel { bottom: var(--kb, 0px); }
.kb-open #memoPanel { bottom: var(--kb, 0px); }
#memoPanel[hidden] { display: none; }
#memoPanel > * { width: 100%; max-width: 760px; }
#memoTitle { font-size: 0.9rem; font-weight: 600; }
/* 16px 밑이면 아이폰이 눌렀을 때 화면을 확대해 버린다. 높이는 본문이 보일 자리를 남기게(앱: 세로 폰 5줄쯤) */
#memoText {
  display: block;
  font: inherit;
  font-size: 16px;
  line-height: 1.4;
  min-height: calc(3 * 1.4em + 12px);
  max-height: min(calc(6 * 1.4em + 12px), 30dvh);
  padding: 6px 8px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
}
.memo-btns { display: flex; align-items: center; gap: 8px; }
.memo-btns .spacer { flex: 1; }
.memo-btns button[hidden] { display: none; }

/* 묻는 작은 창(저장 / 저장 안 함 / 취소) */
dialog.ask { width: min(360px, calc(100vw - 32px)); padding: 16px; }
dialog.ask p { margin: 0 0 14px; }
.ask-btns { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

/* ---- 본문화면설정 ---- */
.settings { padding-bottom: 16px; }
.setting {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 4px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  line-height: 1.35;
}
.setting[hidden] { display: none; } /* 음성 읽기가 없는 브라우저에서 TTS 설정을 숨긴다 */
.setting input[type="checkbox"] { width: 20px; height: 20px; flex: none; margin: 0; }
.setting small { display: block; font-size: 0.8rem; color: var(--muted); }
.setting.color { justify-content: space-between; }
.setting input[type="color"] {
  width: 56px;
  height: 36px;
  flex: none;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  cursor: pointer;
}
.presets { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 8px; }
.presets button { flex: 1 1 0; min-width: 0; padding: 4px 2px; font-size: 0.9rem; } /* 폰 폭에서도 넷이 한 줄 */
.presets button.current { outline: 2px solid var(--accent); outline-offset: 1px; }
.color-sample {
  margin: 8px 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--page-bg);
  color: var(--page-fg);
  font-size: var(--verse-size);
  word-break: keep-all; /* 본문과 같게 낱말 가운데서 줄을 바꾸지 않는다 */
}
#colorReset, #hlReset { width: 100%; }
.setting-hint { margin: 8px 0 2px; }
.setting-hint small { display: block; font-size: 0.8rem; color: var(--muted); }
.hl-need { display: block; color: var(--error); font-size: 0.85rem; }
.hl-need[hidden] { display: none; } /* 위 display가 hidden 속성을 덮어 늘 보였다 */
/* 글자 크기 − 18 + */
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper output { min-width: 2em; text-align: center; font-variant-numeric: tabular-nums; }
/* 고르기 상자는 문구가 길어("화면 + 장 + 최근목록 이동 버튼") 이름 밑에 한 줄을 다 쓴다 */
.setting.stack { flex-direction: column; align-items: stretch; gap: 6px; padding: 8px 0; }
.setting.stack select { width: 100%; }

/* ---- 검색 ---- */
.search-form { padding: 8px 12px 4px; display: grid; gap: 6px; }
.search-row { display: flex; flex-wrap: wrap; gap: 6px; }
.search-row input {
  flex: 1 1 140px;
  min-width: 0;
  min-height: 40px;
  padding: 4px 8px;
  font: inherit;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
}
/* 범위 상자는 이름이 길다("바울서신전체(로마서-빌레몬서)"). 폰 폭에서 줄어들게 */
.search-row select { flex: 1 1 140px; min-width: 0; }
.search-row select[hidden] { display: none; }
.search-row button { flex: 0 0 auto; }
#searchBody { overflow-y: auto; padding: 0 12px 12px; }
.search-status { display: flex; align-items: center; gap: 8px; }
#searchStatus { flex: 1; margin: 6px 0; font-size: 0.9rem; color: var(--muted); }
#searchStatus.error { color: var(--error); }
#searchResults { list-style: none; margin: 0; padding: 0; word-break: keep-all; overflow-wrap: anywhere; }
#searchResults li { border-bottom: 1px solid var(--line); }
#searchResults button {
  display: block;
  width: 100%;
  padding: 8px 4px;
  border: 0;
  border-radius: 0;
  background: none;
  text-align: left;
  line-height: 1.6;
}
#searchResults button:hover { background: var(--bar); }
#searchResults .sref { color: var(--accent); font-weight: 600; font-size: 0.9em; white-space: nowrap; }
mark { background: #ffe066; color: #222; border-radius: 2px; }
@media (prefers-color-scheme: dark) {
  mark { background: #8a6d00; color: #fff; }
}
#searchMore { display: block; width: 100%; margin-top: 8px; }
#searchMore[hidden] { display: none; }

/* 검색 결과에서 온 절을 잠깐 칠한다 */
#verses li.flash { animation: flash 2s ease-out; }
@keyframes flash {
  from { background: var(--accent-bg); }
  to { background: transparent; }
}

/* 이전/다음 장으로 넘기면 새 장이 그쪽에서 짧게 들어온다(앱 slide_left_in/slide_right_in).
   앱처럼 화면 폭 전체가 아니라 조금만 움직인다. 글이 길어 화면 전체를 옮기면 눈이 따라가기 힘들다.
   들어오는 동안 옆으로 삐져나와 가로 스크롤이 생기지 않게 main에서 자른다(clip은 스크롤 칸을 만들지 않는다) */
main { overflow-x: clip; }
#verses.slide-next { animation: slide-next 0.2s ease-out; }
#verses.slide-prev { animation: slide-prev 0.2s ease-out; }
@keyframes slide-next { from { transform: translateX(48px); opacity: 0.3; } }
@keyframes slide-prev { from { transform: translateX(-48px); opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) {
  #verses.slide-next, #verses.slide-prev { animation: none; }
}

/* ---- 새 버전 알림 (js/pwa.js) ---- */
/* 바와 겹치지 않게 바 반대쪽에 띄운다 */
#updateBar {
  position: fixed;
  left: 50%;
  top: 16px;
  transform: translateX(-50%);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 8px 8px 8px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bar);
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.2);
}
#updateBar[hidden] { display: none; }
.bar-top #updateBar { top: auto; bottom: 16px; }
#updateLater { flex: none; }
#updateBtn { flex: none; }
#updateBtn { background: var(--accent); color: var(--bg); border-color: var(--accent); }
/* 자동 동기화 띠: 새 버전 알림과 같은 모양, 같은 자리. 둘 다 보이면 비킨다 */
#syncBand {
  position: fixed; left: 50%; top: 16px; transform: translateX(-50%); z-index: 5;
  display: flex; align-items: center; gap: 12px; width: max-content; max-width: calc(100% - 32px);
  padding: 8px 8px 8px 16px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bar); box-shadow: 0 2px 8px rgb(0 0 0 / 0.2);
}
#syncBand[hidden] { display: none; }
#updateBar:not([hidden]) ~ #syncBand { top: 76px; }
.bar-top #syncBand { top: auto; bottom: 16px; }
.bar-top #updateBar:not([hidden]) ~ #syncBand { top: auto; bottom: 76px; }
#syncBandBtn { flex: none; background: var(--accent); color: var(--bg); border-color: var(--accent); }

/* ---- 메모책 ----
   제목 단추(입력판·나의메모목록): 메모책이 하나뿐이면 꺼 두는데, 흐리지 않게 그냥 글자처럼 보인다 */
.book-pick {
  min-height: 0; padding: 0; border: 0; border-radius: 0; background: none;
  font-weight: inherit; text-align: left; overflow-wrap: anywhere;
}
.book-pick:disabled { opacity: 1; }
.book-pick:not(:disabled) { color: var(--accent); }
#memoTitle.book-pick { min-height: 28px; font-size: 0.9rem; font-weight: 600; }
#mlTitle.book-pick { font-size: inherit; text-align: center; }
dialog.ask .ask-title { margin: 0 0 10px; font-size: 1.05rem; }
.ask-btns .spacer { flex: 1; }
/* 구글 드라이브 동기화 창. 기록(자세히)은 긴 줄을 접어서 가로 스크롤 없이 */
#syncBody { word-break: keep-all; overflow-wrap: anywhere; }
#syncStatus { white-space: pre-line; }
#syncDetails { margin: 8px 0; }
#syncDetails summary { cursor: pointer; font-size: 0.85rem; color: var(--muted); }
#syncLog { max-height: 40dvh; overflow-y: auto; margin: 6px 0 0; padding: 8px; font-size: 0.75rem;
  white-space: pre-wrap; overflow-wrap: anywhere; word-break: normal; user-select: text; border: 1px solid var(--line); border-radius: 6px; }
#syncLog:empty { display: none; }
#syncFiles[hidden] { display: none; }
#syncFiles h3 { margin: 14px 0 4px; font-size: 0.95rem; }
.sync-files { list-style: none; margin: 0; padding: 0; }
.sync-files li { display: flex; align-items: center; gap: 8px; padding: 2px 0; border-bottom: 1px solid var(--line); font-size: 0.9rem; }
.sync-files li label { flex: 1; display: flex; align-items: center; gap: 8px; min-height: 40px; cursor: pointer; }
.sync-files li span { flex: 1; overflow-wrap: anywhere; }
.mb-pick { display: flex; flex-direction: column; max-height: 50dvh; overflow-y: auto; margin-bottom: 12px; }
.mb-pick[hidden] { display: none; } /* 목소리 창: 이 언어의 목소리가 없을 때 */
.mb-pick .check { min-height: 44px; font-size: 1rem; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
#mbName { width: 100%; box-sizing: border-box; margin-bottom: 14px; padding: 6px 8px; font: inherit; font-size: 16px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg); }
.mb-list .go { padding: 10px 4px; }
.mb-list .mname { display: block; font-weight: 600; }
.mb-list .msum { display: block; font-size: 0.85em; color: var(--muted); }
.mb-list .add { color: var(--accent); }
.mb-list .icon { flex: none; margin: 6px 0 0 2px; min-width: 36px; border: 0; background: none; color: var(--muted); }
.mb-list .icon:disabled { visibility: hidden; }
.setting.nav { width: 100%; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: none;
  padding: 4px 0; text-align: left; }
#mbBox .picker-foot:has(> .foot-status[hidden]) { display: none; } /* 알릴 것이 있을 때만(책갈피 창과 같다) */

/* ---- 메모 입력 방식 ----
   아이콘은 앱 ic_memo_*_on/off를 그대로 옮긴 SVG(memoOptionIcon). 켜짐은 굵은 선, 꺼짐은 가는 선에 조금 흐리게
   (선 굵기만으로는 작은 화면에서 구별이 약했다. 앱과 같은 이유) */
.memo-head { display: flex; align-items: center; gap: 2px; }
.memo-head #memoTitle { flex: 1; min-width: 0; }
.memo-opt { flex: none; min-width: 32px; min-height: 32px; padding: 4px; border: 0; background: none; color: var(--fg); }
.opt-icon { width: 18px; height: 18px; display: block; flex: none; }
.opt-icon.off { opacity: 0.6; }
.mb-opts { display: flex; flex-direction: column; margin: -6px 0 12px; }
.mb-opts .check { min-height: 40px; justify-content: flex-start; }
.mb-opts .check:has(input:disabled) { opacity: 0.45; cursor: default; }

/* ---- 일본어·중국어 줄바꿈 ----
   한국어가 낱말 가운데서 끊기지 않게 여러 곳에 keep-all을 두었는데, 일본어·중국어는 띄어쓰기가 없어
   keep-all이면 쉼표에서만 줄이 바뀌고 "。iPhone"처럼 문장 부호가 줄 앞에 온다. 화면 언어(html lang)와
   본문 역본 언어(#verses·.cell의 lang)가 일본어·중국어면 보통 규칙으로. 위의 id 선택자보다 앞서려고 !important */
:lang(ja), :lang(zh) { word-break: normal !important; }
