:root {
  --blue: #3182f6;
  --blue-soft: #e8f1fe;
  --orange: #e8710a;
  --orange-soft: #fff1e0;
  --purple: #6b4fd8;
  --purple-soft: #f0ecfd;
  --green: #03a55f;
  --green-soft: #e4f8ef;
  --red: #e0313e;
  --ink: #191f28;
  --ink2: #4e5968;
  --muted: #6b7684;
  --line: #e5e8eb;
  --bg: #fff;
  --soft: #f2f4f6;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  word-break: keep-all;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--blue); }
h1 { margin: 0 0 8px; font-size: 22px; line-height: 1.35; }
h2 { margin: 24px 0 8px; font-size: 18px; line-height: 1.4; }
h3 { margin: 0 0 6px; font-size: 16px; }
p { margin: 0 0 10px; }
ul { margin: 0 0 12px; padding-left: 20px; }

.page { max-width: 760px; margin: 0 auto; padding: 16px 16px calc(32px + env(safe-area-inset-bottom)); }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
.pad { padding: 32px 16px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 4px; padding: 8px 12px; background: rgba(255, 255, 255, 0.95); border-bottom: 1px solid var(--line); }
.top b { flex: 1; min-width: 0; font-size: 16px; }
.tab { min-height: 40px; padding: 0 10px; border: 0; border-radius: 10px; background: transparent; color: var(--ink2); font-size: 14px; font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; }
.tab.on { background: var(--blue-soft); color: var(--blue); }

.btn { min-height: 48px; padding: 0 18px; border: 0; border-radius: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.btn.primary { background: var(--blue); color: #fff; }
.btn.soft { background: var(--blue-soft); color: var(--blue); }
.btn.gray { background: var(--soft); color: var(--ink); }
.btn.green { background: var(--green); color: #fff; }
.btn.purple { background: var(--purple); color: #fff; }
.btn.small { min-height: 38px; padding: 0 12px; border-radius: 10px; font-size: 14px; }
.btn.full { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: default; }
.link { border: 0; background: none; padding: 0; color: var(--blue); font-weight: 600; }

.card { padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: #fff; margin-bottom: 12px; }
.label { display: block; margin-bottom: 4px; font-size: 14px; font-weight: 600; color: var(--ink2); }
input[type="text"], input[type="email"], input[inputmode], select, textarea { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid #c9ced4; border-radius: 10px; background: #fff; }
textarea { min-height: 130px; line-height: 1.6; resize: vertical; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 15px; }
.check input { margin-top: 5px; flex: none; width: 18px; height: 18px; }
.msg { padding: 10px 12px; border-radius: 10px; background: var(--blue-soft); color: #1b5dbe; font-size: 15px; }
.msg.err { background: #fdecee; color: var(--red); }

.pill { display: inline-flex; align-items: center; min-height: 24px; padding: 0 8px; border-radius: 999px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.pill.none { background: var(--soft); color: var(--muted); }
.pill.ok { background: var(--blue-soft); color: var(--blue); }
.pill.more { background: var(--orange-soft); color: var(--orange); }
.pill.adm { background: var(--purple-soft); color: var(--purple); }
.pill.fin { background: var(--green-soft); color: var(--green); }
.pill.warn { background: #fdecee; color: var(--red); }

/* 이미 검토된 편 — 테스트판 표시처럼 눈에 띄게 */
.band { padding: 12px 16px; border-radius: 12px; font-weight: 700; margin-bottom: 12px; line-height: 1.5; }
.band small { display: block; font-weight: 500; font-size: 14px; }
.band.orange { background: var(--orange); color: #fff; }
.band.green { background: var(--green); color: #fff; }
.band.red { background: var(--red); color: #fff; }
.band.purple { background: var(--purple-soft); color: var(--purple); }

.outbox { position: sticky; top: 57px; z-index: 4; padding: 8px 16px; background: #fff8e1; color: #7a5a00; font-size: 14px; font-weight: 600; border-bottom: 1px solid #f2e3b0; }

.bar { height: 8px; border-radius: 4px; background: var(--soft); overflow: hidden; display: flex; }
.bar i { display: block; height: 100%; }
.bar .b { background: var(--blue); }
.bar .g { background: var(--green); }

.book { display: flex; flex-direction: column; gap: 6px; width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; text-align: left; text-decoration: none; color: inherit; margin-bottom: 8px; }
.section { display: flex; align-items: center; gap: 8px; width: 100%; padding: 12px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; text-decoration: none; color: inherit; }
.section .t { flex: 1; min-width: 0; }
.section .t small { display: block; color: var(--muted); font-size: 14px; }
.section.seen { background: #fff9f2; }

.verses { font-size: 16px; }
.verses p { margin: 0 0 8px; }
.verses sup { color: var(--muted); font-size: 12px; margin-right: 3px; }
.verses .k { display: block; color: var(--muted); font-size: 14px; }
.item { white-space: pre-line; }

.actions { position: sticky; bottom: 0; display: flex; gap: 8px; padding: 10px 0 calc(10px + env(safe-area-inset-bottom)); background: #fff; }
.actions .btn { flex: 1; padding: 0 8px; }

.compare { display: grid; gap: 8px; margin: 8px 0; }
.compare > div { padding: 10px 12px; border-radius: 10px; white-space: pre-line; font-size: 15px; }
.compare .from { background: var(--soft); }
.compare .to { background: var(--blue-soft); }
.compare b { display: block; font-size: 13px; color: var(--muted); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 4px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; white-space: nowrap; }
details summary { cursor: pointer; font-weight: 600; min-height: 32px; }
.ns { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.ns a { padding: 2px 8px; border-radius: 8px; background: var(--soft); color: var(--ink2); font-size: 13px; text-decoration: none; }
.ns a.sug { background: var(--blue-soft); color: var(--blue); }

/* 칸으로 보기 */
.tabs { margin: 4px 0 4px; }
.chip { min-height: 42px; padding: 0 16px; border: 1px solid #c9ced4; border-radius: 21px; background: #fff; font-weight: 700; font-size: 15px; }
.chip small { font-weight: 600; opacity: 0.75; }
.chip.on { border-color: var(--blue); background: var(--blue); color: #fff; }
.group { margin: 14px 0 6px; color: var(--muted); font-size: 14px; font-weight: 700; }
.book-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 640px) { .book-grid { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); } }
.book-cell { display: flex; flex-direction: column; gap: 3px; min-height: 76px; padding: 9px 9px 10px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: inherit; text-decoration: none; }
.book-cell b { font-size: 15px; line-height: 1.3; letter-spacing: -0.03em; overflow-wrap: anywhere; }
.book-cell small { flex: 1; color: var(--muted); font-size: 13px; }
.book-cell .bar { height: 5px; }
.book-cell.some { background: #f4f8ff; border-color: #cfe0fb; }
.book-cell.all { background: var(--orange-soft); border-color: #f5cfa3; }
.book-cell.fin { background: var(--green-soft); border-color: #a7e3c7; }
.book-cell.fin small { color: var(--green); font-weight: 700; }
.book-cell.off { opacity: 0.55; }

.legend { margin: 14px 0 8px; font-size: 13px; color: var(--muted); }
.legend .link { font-size: 14px; }
.key { display: inline-block; width: 12px; height: 12px; margin: 0 2px 0 6px; border: 1px solid #c9ced4; border-radius: 3px; background: var(--soft); vertical-align: -1px; }
.key:first-child { margin-left: 0; }
.key.seen { background: var(--orange); border-color: var(--orange); }
.key.fin { background: var(--green); border-color: var(--green); }
.key.stale { background: var(--red); border-color: var(--red); }
.key.mine { background: #fff; border: 2px solid var(--ink); }
.key.adm { background: var(--purple); border-color: var(--purple); }

.num-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 6px; }
.num-cell { position: relative; display: flex; align-items: center; justify-content: center; min-height: 46px; border-radius: 10px; background: var(--soft); color: var(--ink2); font-size: 15px; font-weight: 700; text-decoration: none; }
.num-cell.seen { background: var(--orange); color: #fff; }
.num-cell.fin { background: var(--green); color: #fff; }
.num-cell.stale { background: var(--red); color: #fff; }
.num-cell.mine { box-shadow: 0 0 0 2px var(--ink); }
.num-cell.adm::after { content: ''; position: absolute; left: 6px; right: 6px; bottom: 4px; height: 3px; border-radius: 2px; background: var(--purple); }
.num-cell.seen.adm::after, .num-cell.fin.adm::after, .num-cell.stale.adm::after { background: #fff; }
.num-cell .dot { position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 1.5px #fff; }

.band.slim { padding: 8px 12px; margin-bottom: 8px; }
.band.slim small { display: inline; }

