/* 우리집 성경 — 노년층을 위한 큰 글씨·높은 대비·큰 버튼 */
:root {
  --read: 26px;
  --bg: #fffdf8; --fg: #1a1a1a; --sub: #4a4a4a; --line: #d9d3c7;
  --card: #ffffff; --btn: #f1ece2; --btn-fg: #1a1a1a;
  --accent: #1e4fb8; --accent-fg: #ffffff; --accent-soft: #e3ebfb;
  --mark: #fff0a8; --speak: #d9f2dc; --vn: #b0461f;
  --chg: #7b1fa2; --chg-bg: #f3e3f7;
  --hint: #c2410c; --hint-bg: #ffedd5;
  --tab-h: 76px;
  --radius: 14px;
}
[data-theme="paper"] {
  --bg: #f3ead7; --fg: #2f2416; --sub: #5a4a33; --line: #d6c7a6;
  --card: #fbf5e8; --btn: #e8dcc2; --btn-fg: #2f2416;
  --accent: #7a3e12; --accent-fg: #fff; --accent-soft: #f1e1c8;
  --mark: #f8e08a; --speak: #dcebc9; --vn: #9a3412;
  --chg: #6a1b9a; --chg-bg: #ead6ee;
  --hint: #b23c07; --hint-bg: #f8dcc0;
}
[data-theme="dark"] {
  --bg: #141414; --fg: #f2f2f2; --sub: #c2c2c2; --line: #3a3a3a;
  --card: #1f1f1f; --btn: #2b2b2b; --btn-fg: #f2f2f2;
  --accent: #8fb4ff; --accent-fg: #0d1a33; --accent-soft: #23314d;
  --mark: #5c4d00; --speak: #1f4426; --vn: #ffb38a;
  --chg: #f0b8ff; --chg-bg: #3d2447;
  --hint: #ffa94d; --hint-bg: #4a2a12;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font-family: "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", "맑은 고딕", sans-serif;
  line-height: 1.6; word-break: keep-all; overflow-wrap: anywhere;
  touch-action: manipulation;
}
[data-font="serif"] .reading, [data-font="serif"] .preview {
  font-family: "Noto Serif KR", "Nanum Myeongjo", "나눔명조", "AppleMyungjo", "Batang", "바탕", serif;
}
button, input, a.btn, label.btn { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 4px solid var(--accent); outline-offset: 2px; }
small { font-size: .8em; color: var(--sub); font-weight: normal; }

.view {
  max-width: 760px; margin: 0 auto;
  padding: 0 16px calc(var(--tab-h) + 28px + env(safe-area-inset-bottom));
  min-height: 100vh;
}
.loading { text-align: center; padding-top: 40vh; font-size: 1.3rem; }

/* ----- 위쪽 제목줄 ----- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  margin: 0 -16px; padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--bg); border-bottom: 2px solid var(--line);
  min-height: 68px;
}
.topbar h1 { flex: 1; margin: 0; font-size: 1.45rem; line-height: 1.3; outline: none; min-width: 0; }
.title-btn {
  border: 0; background: none; padding: 6px 4px; font-weight: 700; font-size: 1.45rem;
  cursor: pointer; text-align: left; min-height: 52px;
}

/* ----- 버튼 공통: 손가락으로 누르기 쉬운 최소 56px ----- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 56px; padding: 8px 16px;
  background: var(--btn); color: var(--btn-fg);
  border: 2px solid var(--line); border-radius: var(--radius);
  text-decoration: none; font-weight: 600; cursor: pointer;
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.btn:active { transform: scale(.97); filter: brightness(.93); }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn.big { width: 100%; min-height: 64px; font-size: 1.15rem; margin-top: 12px; }
.btn.quiet { background: transparent; }
.btn.back { min-height: 52px; padding: 6px 12px; white-space: nowrap; flex: none; }
.btn.back span { font-size: 1.6em; line-height: 1; margin-top: -4px; }

.tools {
  position: relative;
  display: flex; gap: 8px; padding: 8px 0; margin-bottom: 4px;
  background: var(--bg);
}
.tools .btn { flex: 1; min-height: 52px; padding: 6px 8px; font-size: .95rem; white-space: nowrap; }
.tools .btn.on { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.ga { font-weight: 800; }
.ga.s { font-size: .8em; } .ga.l { font-size: 1.3em; }

.hint { color: var(--sub); font-size: 1.05rem; margin: 18px 0 10px; display: block; }
.note {
  background: var(--card); border: 2px dashed var(--line); border-radius: var(--radius);
  padding: 18px; margin: 18px 0; font-size: 1.05rem; text-align: center;
}
.note .btn { margin-top: 8px; }

/* ----- 카드 ----- */
.card {
  display: block; background: var(--card); color: var(--fg); text-decoration: none;
  border: 2px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; margin: 12px 0;
}
.card.continue {
  position: relative; margin-top: 16px; padding-right: 48px;
  background: var(--accent); color: var(--accent-fg); border-color: var(--accent);
}
.card.continue .cap { display: block; font-size: .95rem; opacity: .9; }
.card.continue b { font-size: 1.4rem; }
.card.continue .arrow { position: absolute; right: 18px; top: 50%; transform: translateY(-50%); font-size: 2.2rem; }
.card.result b { display: block; font-size: 1.1rem; color: var(--accent); margin-bottom: 4px; }
.card.result span { display: block; font-size: 1.05rem; line-height: 1.7; }
mark { background: var(--mark); color: inherit; padding: 0 2px; border-radius: 3px; }

/* ----- 구약/신약 고르기 ----- */
.seg { display: flex; margin: 16px 0 8px; border: 2px solid var(--accent); border-radius: var(--radius); overflow: hidden; }
.seg button {
  flex: 1; min-height: 60px; border: 0; background: var(--card); font-size: 1.2rem; font-weight: 700; cursor: pointer;
}
.seg button + button { border-left: 2px solid var(--accent); }
.seg button.on { background: var(--accent); color: var(--accent-fg); }
.seg button.on small { color: inherit; opacity: .85; }
.seg.small button { min-height: 52px; font-size: 1rem; }

/* ----- 책·장 단추 격자 ----- */
.grid { display: grid; gap: 10px; margin: 12px 0; }
.grid.books { grid-template-columns: repeat(2, 1fr); }
.btn.book { min-height: 64px; font-size: 1.15rem; }
.grid.chapters { grid-template-columns: repeat(5, 1fr); }
.btn.ch { min-height: 60px; padding: 0; font-size: 1.25rem; }
.btn.ch.here { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
@media (min-width: 560px) {
  .grid.books { grid-template-columns: repeat(3, 1fr); }
  .grid.chapters { grid-template-columns: repeat(8, 1fr); }
}

/* ----- 본문 ----- */
.reading { font-size: var(--read); line-height: 1.85; }
.verse {
  margin: 0; padding: 10px 10px 10px 8px; border-radius: 10px; cursor: pointer;
  border-left: 6px solid transparent; transition: background .2s;
}
.verse + .verse { margin-top: 2px; }
.vn { font-size: .62em; font-weight: 800; color: var(--vn); margin-right: .45em; vertical-align: .25em; }
.verse.marked { border-left-color: #e0a800; background: color-mix(in srgb, var(--mark) 45%, transparent); }
.verse.focus { background: var(--accent-soft); }
.verse.sel { background: var(--accent-soft); outline: 3px solid var(--accent); }
.verse.speaking { background: var(--speak); }
.verse.edited .vn::after { content: " ✎"; color: var(--accent); }
.input.area { min-height: 7em; font-size: var(--read); line-height: 1.6; resize: vertical; }
.btn[disabled] { opacity: .45; cursor: default; }
.card.result .small-note { margin-top: 6px; font-size: .9rem; }
ins.chg {
  text-decoration: underline 3px; text-underline-offset: .2em;
  color: var(--chg); background: var(--chg-bg); font-weight: 700; border-radius: 4px; padding: 0 2px;
}
del.chg { color: var(--chg); text-decoration-thickness: 2px; }
mark.hint {
  background: var(--hint-bg); color: var(--hint); font-weight: 700; padding: 0 2px; border-radius: 4px;
  text-decoration: underline wavy var(--hint); text-decoration-thickness: 2px; text-underline-offset: .25em;
}
.verse.todo { border-left-color: var(--hint); }
.btn.ch.todo { position: relative; }
.btn.ch.todo::after {
  content: ""; position: absolute; top: 6px; right: 6px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--hint);
}
.hint-status { font-weight: 700; color: var(--hint); margin: 4px 0 8px; }
.legend { margin: 8px 0 4px; font-size: 1rem; color: var(--sub); }
.tap-hint { text-align: center; color: var(--sub); font-size: .95rem; margin: 20px 0 0; }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 24px 0 8px; }
.pager .btn { min-height: 68px; font-size: 1.15rem; }

/* ----- 찬송가 ----- */
.keypad-wrap { text-align: center; }
.pad-display {
  display: flex; justify-content: center; align-items: baseline; gap: 8px;
  background: var(--card); border: 3px solid var(--accent); border-radius: var(--radius);
  padding: 6px 16px; font-weight: 800;
}
.pad-num { font-size: 3rem; min-width: 3ch; text-align: right; letter-spacing: .05em; }
.pad-unit { font-size: 1.5rem; color: var(--sub); }
.pad-preview { min-height: 1.8em; font-size: 1.2rem; font-weight: 700; color: var(--accent); margin: 8px 0; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 420px; margin: 0 auto; }
.btn.key { min-height: 68px; font-size: 1.8rem; font-weight: 700; }
.btn.key.fn { font-size: 1.05rem; }
.btn.key.go { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-size: 1.3rem; }
.title-search { margin-top: 26px; border-top: 2px solid var(--line); }
.count { color: var(--sub); margin: 12px 0 0; }

.hymn-title { font-size: 1.2em; line-height: 1.4; margin: 12px 0 8px; }
.hymn-title span { color: var(--accent); }
.stanza { margin: 14px 0; padding: 12px 16px; background: var(--card); border-radius: var(--radius); border: 2px solid var(--line); }
.stanza.refrain { background: var(--accent-soft); border-color: transparent; margin-left: 16px; }
.sn { margin: 0 0 4px; font-size: .65em; font-weight: 800; color: var(--vn); }
.lyric { margin: 0; white-space: pre-line; }

/* ----- 찾기 ----- */
.search-row { display: flex; gap: 8px; }
.input {
  width: 100%; min-height: 64px; padding: 10px 16px; font-size: 1.25rem;
  background: var(--card); color: var(--fg);
  border: 3px solid var(--line); border-radius: var(--radius);
}
.input:focus { border-color: var(--accent); outline: none; }
.btn.mic { min-width: 64px; font-size: 1.6rem; }
.examples { margin-top: 20px; }
.chip {
  display: inline-block; margin: 0 8px 10px 0; padding: 10px 16px; min-height: 52px;
  background: var(--card); border: 2px solid var(--line); border-radius: 999px; font-size: 1.05rem; cursor: pointer;
}

/* ----- 책갈피 ----- */
.sec { font-size: 1.25rem; margin: 26px 0 4px; }
.mark-row { display: flex; gap: 8px; align-items: stretch; }
.mark-row .card { flex: 1; min-width: 0; }
.btn.del { margin: 12px 0; flex: none; padding: 6px 12px; font-size: .95rem; }

/* ----- 설정 ----- */
.set { background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin: 18px 0; }
.set h2 { margin: 0 0 12px; font-size: 1.2rem; }
.set p { margin: 6px 0; font-size: 1.05rem; }
.preview { background: var(--bg); border-radius: 10px; padding: 12px; margin: 0 0 4px !important; font-size: var(--read) !important; }
.size-row { display: flex; align-items: center; gap: 10px; }
.size-row .btn { flex: 1; margin-top: 8px; }
.level { font-size: 1.2rem; font-weight: 800; min-width: 4ch; text-align: center; margin-top: 8px; }
.opts { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.btn.opt { min-height: 60px; }
.btn.opt.on { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn.opt.on::before { content: "✓ "; }
.sw { display: inline-block; width: 22px; height: 22px; border-radius: 50%; border: 2px solid #888; }
.sw.light { background: #fffdf8; } .sw.paper { background: #f3ead7; } .sw.dark { background: #141414; }
.btn.file { cursor: pointer; }
.small-note { color: var(--sub); font-size: .95rem !important; }
code { background: var(--btn); padding: 1px 6px; border-radius: 6px; }

/* ----- 아래 탭 ----- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--card); border-top: 2px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 12px rgba(0,0,0,.08);
}
.tabbar button {
  min-height: var(--tab-h); border: 0; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 16px; font-weight: 700; color: var(--sub);
  -webkit-tap-highlight-color: transparent;
}
.tabbar .ic { font-size: 26px; line-height: 1.1; filter: grayscale(1); opacity: .75; }
.tabbar button.on { color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 4px 0 var(--accent); }
.tabbar button.on .ic { filter: none; opacity: 1; }

/* ----- 아래에서 올라오는 메뉴 ----- */
.sheet {
  position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.45);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet[hidden] { display: none; }
.sheet-body {
  width: 100%; max-width: 760px; max-height: 85vh; overflow-y: auto;
  background: var(--bg); border-radius: 22px 22px 0 0;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  transform: translateY(30px); opacity: 0; transition: transform .2s, opacity .2s;
}
.sheet.show .sheet-body { transform: none; opacity: 1; }
.sheet-ref { font-weight: 800; font-size: 1.2rem; margin: 0 0 6px; color: var(--accent); }
.sheet-text { font-size: 1.1rem; margin: 0 0 8px; line-height: 1.7; }
.sheet .btn.big { margin-top: 10px; }
.grid.chapters.in-sheet { margin-top: 8px; }

/* ----- 알림 ----- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + 20px + env(safe-area-inset-bottom)); z-index: 30;
  transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  max-width: 90vw; padding: 14px 22px; border-radius: 999px;
  background: #222; color: #fff; font-size: 1.1rem; font-weight: 600; text-align: center;
  transition: opacity .2s, transform .2s; box-shadow: 0 4px 16px rgba(0,0,0,.25);
}
.toast.show { opacity: 1; transform: translateX(-50%); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
