:root {
  --bg: #fbfaf7;
  --panel: #ffffff;
  --text: #1f2421;
  --muted: #6b736e;
  --line: #e3e1da;
  --accent: #2f4a3c;
  --accent-text: #ffffff;
  --sel: #e9efe9;
  --hl-y: #fff1a8;
  --hl-g: #cdeccd;
  --hl-b: #cfe3fb;
  --hl-p: #fbd3e0;
  --font: 18px;
  color-scheme: light;
}
:root[data-theme="sepia"] {
  --bg: #f4ecd8;
  --panel: #fbf5e6;
  --text: #3b2f20;
  --muted: #7a6a55;
  --line: #e0d4b8;
  --accent: #6b4a2b;
  --sel: #eadfc4;
}
:root[data-theme="dark"] {
  --bg: #15181a;
  --panel: #1e2224;
  --text: #e6e4de;
  --muted: #9aa19c;
  --line: #2e3336;
  --accent: #8fc3a6;
  --accent-text: #10201a;
  --sel: #26302b;
  --hl-y: #5c5216;
  --hl-g: #24492c;
  --hl-b: #1f3f63;
  --hl-p: #5c2a3d;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  display: flex;
  flex-direction: column;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
  border: 0;
  background: none;
  padding: 0;
}

.top {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.where {
  font-weight: 700;
  font-size: 17px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--sel);
}
.where::after {
  content: " ▾";
  color: var(--muted);
}
.heading {
  flex: 1;
  font-weight: 700;
  font-size: 17px;
}
.icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  font-size: 18px;
  color: var(--muted);
}

main {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  outline: none;
}
.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 16px 32px;
}

/* 읽기 */
.chapter-title {
  font-size: 22px;
  margin: 8px 0 16px;
}
.section {
  font-size: calc(var(--font) * 0.95);
  font-weight: 700;
  color: var(--accent);
  margin: 22px 0 8px;
}
.verse {
  font-size: var(--font);
  line-height: 1.85;
  margin: 0;
  padding: 3px 6px;
  border-radius: 6px;
  word-break: keep-all;
  overflow-wrap: anywhere;
  cursor: pointer;
}
.verse .n {
  font-size: 0.65em;
  color: var(--muted);
  vertical-align: 0.45em;
  margin-right: 6px;
  font-variant-numeric: tabular-nums;
}
.verse.sel {
  background: var(--sel);
  box-shadow: inset 3px 0 0 var(--accent);
}
.verse.target {
  animation: flash 1.6s ease-out;
}
@keyframes flash {
  from {
    background: var(--sel);
  }
}
.verse[data-hl="y"] .t {
  background: var(--hl-y);
}
.verse[data-hl="g"] .t {
  background: var(--hl-g);
}
.verse[data-hl="b"] .t {
  background: var(--hl-b);
}
.verse[data-hl="p"] .t {
  background: var(--hl-p);
}
.verse .t {
  border-radius: 3px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
.verse .bm {
  color: var(--accent);
  margin-right: 4px;
}
.fn {
  font-size: 0.7em;
  vertical-align: 0.4em;
  color: var(--accent);
  padding: 0 3px;
  font-weight: 700;
}
.fn-text,
.memo {
  font-size: calc(var(--font) * 0.82);
  line-height: 1.6;
  color: var(--muted);
  margin: 2px 6px 6px 24px;
  padding: 6px 10px;
  border-left: 2px solid var(--line);
}
.memo {
  color: var(--text);
  border-left-color: var(--accent);
  white-space: pre-wrap;
}
.pager {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 28px;
}
.pager button,
.ghost,
.primary {
  padding: 11px 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
}
.primary {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
  font-weight: 700;
}
.source {
  margin-top: 20px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}
a {
  color: var(--accent);
}

/* 선택한 절에 대한 동작 */
.actions {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  overflow-x: auto;
}
.actions[hidden] {
  display: none;
}
.actions > button {
  flex: none;
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  font-size: 14px;
}
.colors {
  display: flex;
  gap: 6px;
  flex: none;
}
.colors button {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}
.hl-y {
  background: var(--hl-y);
}
.hl-g {
  background: var(--hl-g);
}
.hl-b {
  background: var(--hl-b);
}
.hl-p {
  background: var(--hl-p);
}

/* 아래 메뉴 */
.tabs {
  flex: none;
  display: flex;
  background: var(--panel);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  flex: 1;
  padding: 13px 0;
  font-size: 14px;
  color: var(--muted);
}
.tabs button[aria-current="page"] {
  color: var(--accent);
  font-weight: 700;
  box-shadow: inset 0 2px 0 var(--accent);
}

/* 목록, 카드 */
.list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.list > li {
  border-bottom: 1px solid var(--line);
}
.item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 4px;
  line-height: 1.6;
}
.item .ref {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
}
.item mark {
  background: var(--hl-y);
  color: inherit;
  border-radius: 2px;
}
.item .sub {
  display: block;
  font-size: 13px;
  color: var(--muted);
  white-space: pre-wrap;
}
.row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.row.end {
  justify-content: flex-end;
  margin-top: 12px;
}
.searchbox {
  display: flex;
  gap: 8px;
}
.searchbox input {
  flex: 1;
  min-width: 0;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  font-size: 16px;
}
.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--panel);
}
.seg button,
.seg output {
  padding: 9px 14px;
  font-size: 14px;
}
.seg button + button,
.seg output + button,
.seg button + output {
  border-left: 1px solid var(--line);
}
.seg button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-text);
}
.hint {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}
.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 12px;
  line-height: 1.7;
}
.bar {
  height: 8px;
  border-radius: 4px;
  background: var(--line);
  overflow: hidden;
  margin: 10px 0;
}
.bar > i {
  display: block;
  height: 100%;
  background: var(--accent);
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  margin: 12px 0;
}
.card h3 {
  margin: 0 0 8px;
  font-size: 16px;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  font-size: 14px;
}
.chip.done {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}
.gospel h3 {
  color: var(--accent);
}
.gospel .verse {
  cursor: default;
}

/* 아래에서 올라오는 창 */
dialog.sheet {
  border: 0;
  padding: 0;
  margin: auto auto 0;
  width: 100%;
  max-width: 720px;
  max-height: 86vh;
  border-radius: 16px 16px 0 0;
  background: var(--panel);
  color: var(--text);
}
dialog.sheet::backdrop {
  background: rgba(0, 0, 0, 0.45);
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 10px 10px 16px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--panel);
}
.sheet-body {
  padding: 14px 16px calc(18px + env(safe-area-inset-bottom));
  overflow-y: auto;
}
.sheet-body textarea {
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  font-size: 16px;
  line-height: 1.6;
}
.field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 8px;
}
.grid.nums {
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
}
.grid button {
  padding: 11px 4px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--bg);
  font-size: 14px;
}
.grid button[aria-current="true"] {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}
.group-title {
  font-size: 13px;
  color: var(--muted);
  margin: 14px 0 8px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(120px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 10;
  max-width: 90vw;
}
.toast[hidden] {
  display: none;
}

/* 책 고르기의 구약·신약 머리 */
.testament {
  margin: 18px 0 0;
  font-size: 16px;
  color: var(--accent);
}
.testament:first-child {
  margin-top: 0;
}

/* 지도 */
dialog.sheet.tall {
  height: 92vh;
  max-height: 92vh;
}
dialog.sheet.tall[open] {
  display: flex;
  flex-direction: column;
}
dialog.sheet.tall .sheet-body {
  flex: 1;
}
.map-canvas {
  height: 44vh;
  min-height: 240px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--muted);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 12px;
  font-size: 14px;
  overflow: hidden;
}
.map-canvas.leaflet-container {
  display: block;
  padding: 0;
  font: inherit;
}
.pin {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 13px;
  font-weight: 700;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}
.pin.unsure {
  opacity: 0.6;
  border-style: dashed;
}
.item .pin {
  width: 22px;
  height: 22px;
  font-size: 12px;
  box-shadow: none;
  border: 0;
  vertical-align: -5px;
}
#map-steps {
  padding: 0;
}
#map-steps > li {
  padding-bottom: 10px;
}
.small {
  padding: 6px 10px;
  font-size: 13px;
}
.tabs button {
  white-space: nowrap;
}
