:root {
  color-scheme: light dark; /* 시계·드롭다운 같은 기본 입력칸도 다크 모드를 따르게 */
  --bg: #f6f1e7;
  --paper: #fffdf8;
  --ink: #2b2620;
  --muted: #7a6f62;
  --line: #e4dccd;
  --accent: #8a5a2b;
  --accent-soft: #f1e4d2;
  --q-bg: #eef3ea;
  --q-line: #9db38c;
  --q-ink: #3f5a32;
  --sel: #fff1c7;
  --ok: #4f7a3a;
  --radius: 14px;
  --verse-size: 18px;
  --hero: #2f4373;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1916;
    --paper: #24211d;
    --ink: #ece5d8;
    --muted: #a89d8e;
    --line: #3a352e;
    --accent: #d9a86c;
    --accent-soft: #3a2f23;
    --q-bg: #24301f;
    --q-line: #6f8f5e;
    --q-ink: #c5dcb6;
    --sel: #4a3f1d;
    --ok: #8fc072;
    --hero: #34477a;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font-family: "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  font-size: 16px; line-height: 1.6;
  padding-bottom: calc(68px + env(safe-area-inset-bottom));
}
button, input, textarea, select { font: inherit; color: inherit; }

/* 상단바 */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.topbar-title { flex: 1; min-width: 0; }
.topbar h1 { font-size: 19px; margin: 0; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.subtitle { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.subtitle:empty { display: none; }
.top-actions { display: flex; gap: 4px; }
.icon-btn {
  border: 0; background: transparent; font-size: 28px; line-height: 1;
  width: 40px; height: 40px; border-radius: 10px; cursor: pointer;
}
.ver-select {
  width: auto; height: 34px; padding: 0 2px; font-size: 13px; font-weight: 700;
  border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--accent);
}
.icon-btn.small { font-size: 14px; font-weight: 700; border: 1px solid var(--line); width: 36px; height: 34px; padding: 0; white-space: nowrap; }

/* 하단 탭 */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--paper); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 10px; font-size: 12px; color: var(--muted); text-decoration: none;
}
.tabbar a .ti { font-size: 18px; line-height: 1.2; }
.tabbar a.active { color: var(--accent); font-weight: 700; }
body.no-tabs .tabbar { display: none; }
body.no-tabs { padding-bottom: env(safe-area-inset-bottom); }

main { max-width: 720px; margin: 0 auto; padding: 16px; }

/* 카드 */
.card {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
}
.card h2 { font-size: 17px; margin: 0 0 6px; }
.card h3 { font-size: 15px; margin: 0 0 4px; }
.hint { font-size: 13px; color: var(--muted); margin: 0 0 10px; }
.muted { color: var(--muted); }
.today-card { border-color: var(--accent); background: linear-gradient(180deg, var(--accent-soft), var(--paper) 70%); }
.today-card .big { font-size: 24px; font-weight: 800; margin: 2px 0; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .04em; color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--paper);
  border-radius: 12px; padding: 11px 16px; font-weight: 700; cursor: pointer; text-decoration: none; color: var(--ink);
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.block { display: flex; width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.btn-row .btn { flex: 1; }

/* 일정 목록 */
.week-label { font-size: 13px; font-weight: 700; color: var(--muted); margin: 18px 4px 6px; }
.day-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 8px; text-decoration: none; color: inherit;
}
.day-item .d { font-weight: 800; color: var(--accent); min-width: 34px; }
.day-item .t { flex: 1; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge.read { color: var(--accent); border-color: var(--accent); }
.badge.done { color: #fff; background: var(--ok); border-color: var(--ok); }
.stats { display: flex; gap: 8px; }
.stat { flex: 1; text-align: center; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 10px 4px; }
.stat b { display: block; font-size: 20px; }
.stat span { font-size: 12px; color: var(--muted); }
.stat b small { font-size: 14px; font-weight: 500; color: var(--muted); }

/* 본문 */
.reader { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 16px; }
.chapter-head { text-align: center; margin-bottom: 14px; }
.chapter-head .ch { font-size: 22px; font-weight: 800; }
.verse { margin: 0 0 10px; font-size: var(--verse-size); line-height: 1.85; padding: 2px 6px; border-radius: 8px; cursor: pointer; }
.verse sup { font-size: .62em; font-weight: 800; color: var(--accent); margin-right: 4px; vertical-align: .45em; }
.verse.selected { background: var(--sel); }
.verse.has-q sup::after { content: " ●"; color: var(--q-line); }

.qcard {
  margin: 4px 0 18px; padding: 14px; border-radius: 12px;
  background: var(--q-bg); border-left: 4px solid var(--q-line);
}
.qcard .qlabel { font-size: 12px; font-weight: 800; color: var(--q-ink); margin-bottom: 4px; }
.qcard .qtext { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.qcard.answered .qlabel::after { content: " · 작성함 ✓"; }

textarea, input[type=text], input[type=date], input[type=number], input[type=time], select {
  width: 100%; border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  border-radius: 10px; padding: 10px 12px; outline: none;
}
textarea { min-height: 76px; resize: vertical; line-height: 1.6; }
textarea:focus, input:focus, select:focus { border-color: var(--accent); }
.qcard textarea { background: var(--paper); }

.selbar {
  position: fixed; left: 12px; right: 12px; bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 20;
  max-width: 696px; margin: 0 auto;
  display: flex; gap: 8px; align-items: center;
  background: var(--ink); color: var(--bg); border-radius: 14px; padding: 10px 10px 10px 14px;
  box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
.selbar span { flex: 1; font-size: 14px; }
.selbar .btn { padding: 8px 12px; }

.end-box { margin-top: 18px; }

/* 저널 */
.jsec { margin-bottom: 14px; }
.jsec label.lbl { display: block; font-weight: 800; margin-bottom: 2px; }
.jsec .en { font-weight: 500; color: var(--muted); font-size: 13px; margin-left: 4px; }
.sublabel { font-size: 14px; font-weight: 700; margin: 10px 0 4px; }
.chips { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.chip {
  text-align: left; border: 1px solid var(--line); background: var(--paper);
  border-radius: 10px; padding: 8px 12px; font-size: 14px; cursor: pointer;
}
.chip.on { border-color: var(--accent); background: var(--accent-soft); font-weight: 700; }
.chips.collapsed .chip:not(.on) { display: none; }
.linkbtn { background: none; border: 0; color: var(--accent); font-weight: 700; padding: 4px 0; cursor: pointer; font-size: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.gratitude input { margin-bottom: 6px; }
.recap { font-size: 14px; }
.recap .rq { font-weight: 700; margin-top: 10px; }
.recap .ra { white-space: pre-wrap; color: var(--ink); }
.recap .ra.empty { color: var(--muted); font-style: italic; }
.saved { font-size: 12px; color: var(--ok); text-align: right; min-height: 18px; }

/* 성경 목록 */
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.book-grid a, .ch-grid a {
  display: block; text-align: center; padding: 10px 4px; border-radius: 10px;
  background: var(--paper); border: 1px solid var(--line); text-decoration: none; color: inherit; font-size: 14px;
}
.ch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 8px; }
.ch-grid a.has-plan { border-color: var(--accent); color: var(--accent); font-weight: 700; }
.section-title { font-size: 14px; font-weight: 800; color: var(--muted); margin: 6px 4px 8px; }
.pager { display: flex; justify-content: space-between; gap: 8px; margin-top: 14px; }

/* 지침 */
.guide ol, .guide ul { padding-left: 22px; margin: 6px 0; }
.guide li { margin-bottom: 4px; }
.guide .q12 li { font-size: 15px; }

/* 관리 */
.form-row { margin-bottom: 10px; }
.form-row label { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 3px; }
.q-preview li { font-size: 14px; margin-bottom: 4px; }
.danger { color: #b3412f; border-color: #b3412f; }

/* 질문 참고 · 함께 읽을 말씀 */
.qnote { font-size: 13px; color: var(--q-ink); background: var(--paper); border-radius: 8px; padding: 6px 10px; margin-bottom: 8px; }
.day-notes { margin-top: 18px; padding: 14px; border-radius: 12px; background: var(--accent-soft); }
.day-notes p { margin: 6px 0 0; font-size: 15px; }
.day-notes .qlabel { font-size: 12px; font-weight: 800; color: var(--accent); }

/* 메뉴 */
.menu-btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; color: var(--ink); font-size: 18px; }
.menu-hero { background: var(--hero); color: #fff; border-radius: 18px; padding: 22px 22px 20px; margin-bottom: 14px; display: flex; flex-direction: column; gap: 4px; }
.menu-hero b { font-size: 22px; }
.menu-hero span { font-size: 15px; opacity: .9; }
.menu-group { background: var(--paper); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; margin-bottom: 14px; }
.menu-item { display: flex; align-items: center; gap: 14px; padding: 16px 18px; text-decoration: none; color: inherit; }
.menu-item + .menu-item { border-top: 1px solid var(--line); }
.menu-item:active { background: var(--accent-soft); }
.menu-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; flex: none; }
.menu-icon.green { background: #e3efe4; } .menu-icon.blue { background: #e3e9f6; }
.menu-icon.sand { background: #f1ead9; } .menu-icon.rose { background: #f6e2df; }
.menu-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.menu-text b { font-size: 17px; }
.menu-text small { color: var(--muted); font-size: 14px; }
.menu-arrow { color: var(--muted); font-size: 22px; }
.doc h2 { font-size: 17px; margin: 0 0 8px; }
.doc ol, .doc ul { padding-left: 20px; margin: 0; }
.doc li { margin-bottom: 6px; }
.doc a:not(.btn) { color: var(--accent); }
.place { padding: 10px 0; display: flex; flex-direction: column; gap: 2px; }
.place + .place { border-top: 1px solid var(--line); }
.place.here b { color: var(--accent); }
.place small { color: var(--muted); }
.small-steps { margin-top: 12px !important; font-size: 14px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.switch-row span { display: flex; flex-direction: column; }
.switch-row small { color: var(--muted); font-size: 13px; }
.switch-row input { width: 24px; height: 24px; accent-color: var(--accent); }
.copy-row { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.copy-row span { flex: 1; min-width: 0; word-break: break-all; font-weight: 700; }
.info { white-space: pre-wrap; word-break: break-all; font-size: 12px; background: var(--bg); border-radius: 10px; padding: 10px; margin: 0 0 10px; }
.policy h3 { font-size: 15px; margin: 14px 0 4px; }
.policy p { margin: 0; }
.about-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; }
.about-row + .about-row { border-top: 1px solid var(--line); }
.about-row span { color: var(--muted); }

/* 홈 날짜 선택 */
.day-picker { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.day-picker label { font-size: 13px; font-weight: 800; color: var(--muted); white-space: nowrap; }
.day-picker select { flex: 1; min-width: 0; font-weight: 700; }
.today-card .linkbtn { margin-top: 8px; }

/* 구글 드라이브 상태 */
.drive-status {
  display: flex; flex-direction: column; gap: 2px; margin-bottom: 14px; padding: 10px 14px;
  border-radius: 12px; background: var(--paper); border: 1px solid var(--line); font-size: 14px; font-weight: 700;
}
.drive-status[hidden] { display: none; }
.drive-status small { font-weight: 500; color: var(--muted); font-size: 12px; }
.drive-status.ok span { color: var(--ok); }
.drive-status.error { border-color: #b3412f; color: #b3412f; cursor: pointer; }

/* 책 개요 */
.intro summary { font-weight: 800; cursor: pointer; color: var(--accent); }
.intro[open] summary { margin-bottom: 10px; }
.intro-row { display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px; font-size: 14px; }
.intro-row b { font-size: 12px; color: var(--muted); }

/* 지침/고백 기도 전환 */
.seg { display: flex; gap: 6px; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 4px; margin-bottom: 14px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 9px; border-radius: 9px; font-weight: 700; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--accent); color: #fff; }
.confess p { margin: 0 0 8px; font-size: 16px; line-height: 1.7; }

/* VIP 돌봄노트 */
.meets { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.meet { border: 1px solid var(--line); background: var(--paper); border-radius: 10px; padding: 10px 0; font-weight: 700; color: var(--muted); cursor: pointer; }
.meet.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.checks { display: flex; flex-direction: column; gap: 2px; }
.check { display: flex; align-items: center; gap: 10px; padding: 7px 4px; font-size: 15px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.check input:checked + span { color: var(--muted); text-decoration: line-through; }

.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 99px; font-size: 14px; z-index: 30;
  max-width: calc(100% - 32px);
}
.empty-state { text-align: center; padding: 30px 10px; color: var(--muted); }
.drive-status .drive-err { color: inherit; font-weight: 500; word-break: break-all; }

/* 질문 속 성경 구절 링크 + 주일설교 */
.qtext .ref { font: inherit; color: var(--accent); background: none; border: 0; padding: 0; border-bottom: 1px dashed var(--accent); cursor: pointer; }
.qrefs:empty { display: none; }
.qrefs { margin: 0 0 10px; display: flex; flex-direction: column; gap: 8px; }
.xref { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.xref-h { font-size: 13px; font-weight: 800; color: var(--accent); margin-bottom: 4px; }
.xref-h .muted { font-weight: 600; }
.xref p { margin: 0 0 4px; font-size: calc(var(--verse-size) - 2px); line-height: 1.7; }
.xref p sup { font-size: .62em; font-weight: 800; color: var(--accent); margin-right: 3px; }
.xref-s { font-size: 12px; font-weight: 800; color: var(--muted); margin: 6px 0 2px; }
.sermon { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; padding: 7px 2px; border-top: 1px solid var(--line); color: var(--ink); text-decoration: none; font-size: 14px; }
.sermon[hidden] { display: none; }
.sermon .play { color: #c4302b; font-size: 12px; }
.sermon .st { font-weight: 700; flex: 1 1 60%; }
.sermon .sm { font-size: 12px; color: var(--muted); }
.sermon .sm b { color: var(--accent); }
.sermon-more { margin-top: 6px; font-size: 13px; padding: 6px 10px; }
/* 설교가 많을 때 2열 작은 카드 */
.sermons.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 4px; }
.sermon.mini { display: flex; flex-direction: column; gap: 3px; padding: 8px 9px; border: 1px solid var(--line); border-radius: 10px; min-width: 0; font-size: 13px; }
.sermon.mini[hidden] { display: none; }
.sermon.mini .st { flex: none; font-size: 13px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sermon.mini .sm { font-size: 11.5px; }
.sermon-box .sub-h { font-size: 12.5px; font-weight: 700; color: var(--muted); margin: 10px 0 2px; }
.sermon-box summary { font-weight: 800; cursor: pointer; color: var(--accent); }
.sermon-box[open] summary { margin-bottom: 6px; }
.sermon-box .small { font-size: 12px; margin-bottom: 4px; }
.flash { animation: flash 1.4s ease; }
@keyframes flash { 0%, 40% { background: var(--sel); } 100% { background: transparent; } }

/* 새번역 각주 */
.fn-mark { font-size: .7em; color: var(--muted); vertical-align: .35em; margin: 0 1px; }
.fn { display: block; font-size: 12px; line-height: 1.5; color: var(--muted); margin-top: 2px; }
/* 쉬운성경 소제목 */
.vhead { display: block; font-size: 13px; font-weight: 700; color: var(--accent, var(--muted)); margin: 10px 0 2px; letter-spacing: -.01em; }
.verse:first-child .vhead:first-child, .xref p:first-child .vhead:first-child { margin-top: 0; }

/* 새 버전 알림 (홈 위) */
.update-banner { display: flex; flex-direction: column; gap: 4px; border: 1px solid var(--accent); }
.update-banner b { color: var(--accent); font-size: 16px; }
.update-banner small { color: var(--muted); font-size: 13px; line-height: 1.5; }
.update-banner .btn-row { margin-top: 6px; }

/* 마인드리셋 성경 읽기 (장 맨 앞) */
.rd-box { padding: 10px 12px; }
.rd-main { display: flex; gap: 10px; align-items: center; color: var(--ink); text-decoration: none; }
.rd-play { flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: #b3261e; color: #fff; font-size: 12px; }
.rd-body { display: flex; flex-direction: column; min-width: 0; }
.rd-body b { font-size: 15px; color: var(--accent); }
.rd-body small { font-size: 13px; color: var(--muted); }
.rd-others { margin-top: 8px; }
.rd-others summary { font-size: 13px; font-weight: 700; color: var(--muted); cursor: pointer; }
.rd-others[open] summary { margin-bottom: 4px; }
