/* 통독 · QT 읽기 화면(갓피아 꽉 채우기, 위아래 도구 막대)과 패널 */

/* ---------- 읽기 모드 (통독 · QT) ---------- */
body.full { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; overscroll-behavior-x: none; }
html:has(body.full) { overscroll-behavior-x: none; } /* 크롬의 좌우 스와이프 뒤로/앞으로 가기 끄기 */
body.full main { flex: 1; min-height: 0; width: 100%; max-width: none; margin: 0; padding: 0; display: block; }
body.full .footer { display: none; }
body.full .topbar { position: static; padding: 6px 12px; }
.rd { height: 100%; display: flex; flex-direction: column; }
.rd-top { background: var(--surface); border-bottom: 1px solid var(--line); padding: 8px 12px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.rd-row { display: flex; align-items: center; gap: 8px; }
.rd-title { flex: 1; min-width: 0; display: grid; gap: 1px; }
.rd.reading .rd-title { flex: none; }
.rd-title small { font-size: .74rem; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 5px; white-space: nowrap; overflow: hidden; }
.rd-title .dim { font-weight: 400; }
.rd-title b { font-size: 1.02rem; font-weight: 700; letter-spacing: -0.03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#r-view span { max-width: 130px; overflow: hidden; text-overflow: ellipsis; }

.steps { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
.steps-track { flex: 1; min-width: 0; display: flex; justify-content: center; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.steps-track::-webkit-scrollbar { display: none; }
.step-pill {
  flex: 1 0 auto; min-width: 44px; max-width: 160px; height: 34px; padding: 0 10px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
  font-weight: 700; font-size: .92rem; font-variant-numeric: tabular-nums; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 3px;
}
.step-pill .bk { font-size: .72rem; font-weight: 600; color: var(--muted); margin-right: 2px; }
.step-pill.done { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.step-pill.done .bk { color: inherit; }
.step-pill.active { border: 2px solid var(--accent); background: var(--surface); color: var(--accent); }
.step-pill.done.active { background: var(--accent-soft); }
.step-check {
  flex: none; height: 34px; padding: 0 12px; border-radius: 10px; border: 0; cursor: pointer; font: inherit; font-weight: 700; font-size: .88rem;
  background: var(--accent); color: #fff; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
}
.step-check svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.step-check.next { background: var(--accent); }
.steps-count { flex: none; font-size: .84rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.steps-count b { color: var(--accent); font-size: 1rem; }

/* 갓피아 웹의 상단 로고 막대(고정, 스크롤 후 60px)를 잘라내 본문이 위까지 차도록 함 */
.rd-clip { --crop: 60px; flex: 1; min-height: 0; position: relative; overflow: hidden; background: #fff; }
.rd-frame { position: absolute; left: 0; top: calc(-1 * var(--crop)); width: 100%; height: calc(100% + var(--crop)); border: 0; display: block; }

.rd-bottom {
  display: flex; align-items: center; gap: 8px; background: var(--surface); border-top: 1px solid var(--line);
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
}
.rd-bottom .icon-btn { width: 46px; height: 46px; }
.rd-main { flex: 1; min-width: 0; display: flex; gap: 4px; max-width: 520px; margin: 0 auto; }
.streak { flex: none; font-size: .86rem; color: var(--qt); background: var(--qt-soft); padding: 6px 10px; border-radius: 99px; white-space: nowrap; }
.dot-mark { position: absolute; top: 8px; right: 8px; width: 6px; height: 6px; border-radius: 50%; background: var(--qt); }

.rd.qt .btn.primary { background: var(--qt); color: #fff; }
.rd.qt .btn.soft { background: var(--qt-soft); color: var(--qt); }
.qt-title { position: relative; cursor: pointer; text-align: center; }
.qt-title small { justify-content: center; }
.qt-title b { display: inline-flex; align-items: center; justify-content: center; gap: 4px; }
.qt-title b svg { color: var(--muted); width: .95em; height: .95em; }
.qt-title input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; padding: 0; border: 0; }

/* ---------- 패널 ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgb(0 0 0 / .32); z-index: 30; }
.sheet {
  position: fixed; z-index: 31; top: 0; right: 0; bottom: 0; width: min(420px, 100%);
  background: var(--bg); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; box-shadow: -10px 0 40px rgb(0 0 0 / .18);
}
.sheet-grip { display: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px; background: var(--surface); border-bottom: 1px solid var(--line); }
.sheet-head h2 { margin: 0; }
.sheet-body { flex: 1; overflow-y: auto; padding: 14px; overscroll-behavior: contain; display: grid; gap: 12px; align-content: start; }
.label { font-size: .8rem; font-weight: 700; color: var(--muted); margin: 4px 0 0; letter-spacing: 0; }
.opts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.opt {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 12px;
  padding: 11px 10px; font-weight: 600; cursor: pointer; text-align: center;
}
.opt.big { display: grid; gap: 2px; padding: 14px 10px; }
.opt.big span { font-size: .76rem; color: var(--muted); font-weight: 500; }
.opt.on { border: 2px solid var(--accent); background: var(--accent-soft); color: var(--accent); }
.opt:disabled { opacity: .35; cursor: default; }
.tool-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: grid; gap: 8px; }
.tool-card .label { margin: 0; }
.table-sum { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; display: grid; gap: 8px; }
.table-sum p { margin: 0; font-size: .86rem; color: var(--muted); }
.table-sum b { color: var(--accent); }
.ttable { display: grid; gap: 6px; }
.trow {
  display: grid; grid-template-columns: 58px 1fr 40px; gap: 8px; align-items: center;
  width: 100%; text-align: left; padding: 10px 12px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
.t-day { font-weight: 700; font-size: .84rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.t-range { font-weight: 600; font-size: .92rem; min-width: 0; }
.t-range small { display: block; font-weight: 400; font-size: .74rem; color: var(--muted); }
.t-st { justify-self: end; font-size: .78rem; font-weight: 700; color: var(--accent); display: flex; }
.t-st svg { width: 20px; height: 20px; }
.trow.done { background: var(--accent-soft); border-color: transparent; }
.trow.done .t-range { color: var(--muted); }
.trow.current:not(.done) .t-st { color: var(--qt); }
.trow.current:not(.done) { border-color: var(--qt); }
.trow.viewing { box-shadow: inset 0 0 0 2px var(--accent); }

.toast {
  position: fixed; z-index: 40; left: 50%; bottom: 150px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; max-width: calc(100vw - 24px);
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 99px;
  font-weight: 600; font-size: .9rem; box-shadow: 0 6px 24px rgb(0 0 0 / .22); white-space: nowrap;
}
.toast-action {
  flex: none; border: 0; border-radius: 99px; padding: 5px 12px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: .84rem;
}
.rd.qt .toast-action, .rd.qt ~ .toast .toast-action { background: var(--qt); color: #fff; }

/* 갓피아 화면 위에 떠 있는 붙여넣기 버튼 (오른쪽 아래) */
.paste-fab {
  position: absolute; right: 12px; bottom: 12px; z-index: 5;
  display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid var(--line); border-radius: 99px; padding: 9px 14px; cursor: pointer;
  background: color-mix(in srgb, var(--surface) 92%, transparent); color: var(--ink);
  font-weight: 700; font-size: .86rem; box-shadow: 0 4px 16px rgb(0 0 0 / .18);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.paste-fab:active { transform: scale(.96); }
.rd.qt .paste-fab { color: var(--qt); }

.inline.between { justify-content: space-between; }
.hint { margin: 0; line-height: 1.5; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border: 0; cursor: pointer; font-family: inherit; }
.trow.late:not(.part) .t-st { color: var(--warn); }

/* 갓피아 모바일 레이아웃: 로고 막대(60px) 아래에 역본·권·장 버튼 줄(99px)이 sticky로 따라다님 → 함께 잘라냄 */
@media (max-width: 767px) {
  .rd.reading .rd-clip { --crop: 159px; }
}

@media (max-width: 560px) {
  .rd-top { padding: 6px 8px; gap: 6px; }
  .rd-row { gap: 6px; }
  .chip-btn { padding: 0 10px; font-size: .82rem; height: 36px; }
  .rd.reading .rd-title .dim { display: none; }
  .step-pill { min-width: 30px; height: 32px; padding: 0 5px; font-size: .86rem; flex: 0 0 auto; }
  .step-check { height: 32px; padding: 0 9px; font-size: .82rem; }
  .rd.reading .rd-title small { font-size: .7rem; }
  .steps-track { justify-content: flex-start; gap: 4px; }
  .rd-bottom { padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); gap: 6px; }
  .rd-bottom .icon-btn { width: 42px; height: 42px; }
  .sheet { top: auto; left: 0; width: 100%; height: 84dvh; border-left: 0; border-radius: 20px 20px 0 0; overflow: hidden; }
  .sheet-grip { display: block; width: 40px; height: 4px; border-radius: 4px; background: var(--line); position: absolute; top: 6px; left: 50%; transform: translateX(-50%); }
}

/* ---------- 오늘 분량 요약 ---------- */
.sum-head { display: grid; gap: 1px; }
.sum-head small { font-size: .74rem; color: var(--muted); font-weight: 600; }
.sum-head b { font-size: 1.05rem; letter-spacing: -0.03em; }
.sum-card { gap: 10px; }
.sum-people { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.sum-people li { display: inline-flex; flex-direction: column; gap: 1px; background: var(--accent-soft); border-radius: 12px; padding: 7px 11px; min-width: 0; }
.sum-people b { color: var(--accent); font-size: .92rem; }
.sum-people span { font-size: .76rem; color: var(--muted); }
.sum-story { margin: 0; line-height: 1.75; font-size: .96rem; }
.sum-songs { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.sum-songs li { display: grid; gap: 6px; justify-items: start; padding-top: 12px; border-top: 1px solid var(--line); }
.sum-songs li:first-child { padding-top: 0; border-top: 0; }
.sum-songs li div { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.sum-songs li span { font-size: .82rem; color: var(--muted); }
.sum-songs li p { margin: 0; font-size: .86rem; color: var(--muted); }
.sum-state { display: grid; justify-items: center; gap: 6px; text-align: center; padding: 28px 8px; }
.sum-state p { margin: 0; }
.sum-spin { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: sum-spin 0.9s linear infinite; }
@keyframes sum-spin { to { transform: rotate(360deg); } }

/* ---------- 메모 구절 고르기 ---------- */
.mp-panel { display: grid; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.mp-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: .84rem; color: var(--muted); }
.mp-bar b { color: var(--ink); }
.mp-bar-btns { display: inline-flex; }
.mp-panel .btn.text { padding: 6px 8px; }
.mp-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 56dvh; overflow-y: auto; overscroll-behavior: contain; }
.mp-item { position: relative; display: flex; align-items: flex-start; gap: 10px; padding: 9px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
.mp-item:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
/* 체크박스는 숨기고 상자 전체를 눌러 고름(선택되면 테두리·바탕 색과 ✓) */
.mp-item input, .vp-row input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; pointer-events: none; }
.mp-item:has(input:focus-visible), .vp-row:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.mp-item:has(input:checked)::after, .vp-row:has(input:checked)::after { content: "✓"; position: absolute; top: 6px; right: 9px; color: var(--accent); font-weight: 800; font-size: calc(.9rem * var(--fz, 1)); }
.mp-body { min-width: 0; flex: 1 1 0; padding-right: 14px; display: grid; gap: 3px; }
.mp-body b { font-size: calc(.9rem * var(--fz, 1)); line-height: 1.5; overflow-wrap: anywhere; }
.mp-body small { color: var(--muted); font-size: calc(.84rem * var(--fz, 1)); line-height: 1.6; white-space: pre-line; overflow-wrap: anywhere; word-break: keep-all; }
.mp-item.mp-note .mp-body b { font-weight: 500; }
.mp-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.mp-actions .btn.text { margin-left: auto; }

/* 인물 관계도 · 주요 지역 · 주석 링크 */
.rg { width: 100%; height: auto; display: block; }
.rg-wrap .rg { max-width: 460px; margin: 0 auto; } /* 꾹 누르기 전 미리보기는 PC에서도 글자가 커지지 않게 */
.rg-node rect { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1.5; }
.rg-node text { fill: var(--ink); font-size: 13px; font-weight: 700; }
.rg-node.hub rect { stroke-width: 2.8; filter: drop-shadow(0 0 4px var(--accent)); }
.rg-node.hub text { font-size: 14px; }
.rg-label { font-size: 11.5px; font-weight: 700; paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.rg-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin: 0; font-size: .76rem; color: var(--muted); }
.rg-legend span { display: inline-flex; align-items: center; gap: 5px; }
.rg-legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.rg-legend em { font-style: normal; flex-basis: 100%; }

/* 꾹 눌러서 여는 관계도 */
.rg-hint { margin: 0 0 4px; font-size: .8rem; font-weight: 600; color: var(--accent); }
.rg-hint::before { content: "👆 "; }
.rg-wrap { position: relative; border-radius: 12px; -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; touch-action: manipulation; cursor: pointer; }
.rg-wrap:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.rg-press { position: absolute; left: 10%; right: 10%; bottom: 2px; height: 4px; border-radius: 4px; background: var(--accent-soft); overflow: hidden; opacity: 0; transition: opacity .15s; pointer-events: none; }
.rg-press::after { content: ""; position: absolute; inset: 0; background: var(--accent); transform: scaleX(0); transform-origin: left; }
.rg-wrap.rg-pressing { background: var(--accent-soft); }
.rg-wrap.rg-pressing .rg-press { opacity: 1; }
.rg-wrap.rg-pressing .rg-press::after { transform: scaleX(1); transition: transform 1.5s linear; }

html.rg-open, html.rg-open body { overflow: hidden; }
.rg-modal { position: fixed; inset: 0; z-index: 200; background: var(--surface); display: flex; align-items: stretch; justify-content: center; }
.rg-sheet { width: 100%; max-width: none; height: 100dvh; background: var(--surface); border-radius: 0; display: flex; flex-direction: column; padding: calc(10px + env(safe-area-inset-top)) 14px calc(12px + env(safe-area-inset-bottom)); gap: 6px; }
.rg-top { display: flex; align-items: center; gap: 8px; }
.rg-top b { font-size: 1rem; }
.rg-zoom { margin-left: auto; display: inline-flex; gap: 4px; }
.rg-zoom button, .rg-close { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 10px; min-width: 36px; height: 34px; font-size: .9rem; font-weight: 700; cursor: pointer; padding: 0 8px; }
.rg-close { font-size: 1rem; }
.rg-tip { margin: 0; font-size: .78rem; color: var(--muted); }
.rg-live { flex: 1 1 auto; min-height: 0; height: 100%; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); touch-action: none; user-select: none; -webkit-user-select: none; }
.rg-live .rg-node { cursor: grab; }
.rg-live .rg-node:active { cursor: grabbing; }
.rg-live .rg-hit { fill: none; stroke: transparent; stroke-width: 18; cursor: pointer; }
.rg-live .rg-label { cursor: pointer; }
.rg-live .rg-edge, .rg-live .rg-node, .rg-live .rg-label { transition: opacity .2s; }
.rg-live.rg-dim .rg-edge:not(.on), .rg-live.rg-dim .rg-node:not(.on), .rg-live.rg-dim .rg-label:not(.on) { opacity: .2; }
.rg-live .rg-edge.on .rg-line { stroke-width: 3.5; }
.rg-live .rg-node.on rect { stroke-width: 2.5; }
.rg-detail { flex: 0 0 auto; max-height: 38%; overflow-y: auto; overscroll-behavior: contain; display: grid; gap: 6px; align-content: start; }
.rg-detail p { margin: 0; }
.rg-rel { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 6px; font-size: .95rem; }
.rg-rel em, .rg-rels em { font-style: normal; font-weight: 700; }
.rg-arrow { color: var(--muted); }
.rg-kind { font-size: .72rem; color: var(--muted); border: 1px solid var(--line); border-radius: 99px; padding: 1px 7px; }
.rg-notes { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.rg-notes li { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; display: grid; gap: 2px; }
.rg-notes small, .rg-src { color: var(--accent); font-weight: 700; font-size: .78rem; }
.rg-notes p { font-size: .9rem; line-height: 1.55; }
.rg-person { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; }
.rg-person span { font-size: .84rem; color: var(--muted); }
.rg-rels { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.rg-rels button { width: 100%; text-align: left; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 6px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 10px; padding: 7px 10px; font: inherit; font-size: .88rem; cursor: pointer; }
.sum-places { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.sum-places li { display: grid; gap: 1px; }
.sum-places b { font-size: .92rem; }
.sum-places span { font-size: .84rem; color: var(--muted); line-height: 1.45; }
.sum-links { display: grid; gap: 6px; }
.sum-links b { font-size: .84rem; }
.sum-links span { display: flex; flex-wrap: wrap; gap: 6px; }
.sum-chip { text-decoration: none; font-size: .82rem; font-weight: 600; padding: 5px 11px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); color: var(--accent); }

/* 요약 새로 만들기 버튼 */
.sum-headrow { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sum-refresh { flex: none; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 1rem; line-height: 1; cursor: pointer; padding: 0; }
.sum-refresh:active { transform: scale(.94); }
.sum-refresh.spin { animation: sum-spin 0.9s linear infinite; opacity: .6; cursor: default; }
.sum-detail { max-width: 320px; word-break: break-all; }

/* 미리 써 둔 장별 요약 */
.sum-ref { margin: 4px 0 -4px; font-size: .78rem; font-weight: 700; color: var(--accent); }
.sum-lines, .sum-events { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.sum-lines li { display: grid; gap: 2px; }
.sum-lines b { font-size: .8rem; color: var(--accent); }
.sum-lines span { font-size: .93rem; line-height: 1.6; }
.sum-events li { position: relative; display: grid; gap: 3px; padding-left: 16px; }
.sum-events li::before { content: ""; position: absolute; left: 2px; top: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.sum-events li:not(:last-child)::after { content: ""; position: absolute; left: 5px; top: 17px; bottom: -11px; width: 1px; background: var(--line); }
.sum-events div { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
.sum-events b { font-size: .94rem; }
.sum-events small { font-size: .74rem; color: var(--muted); font-weight: 600; }
.sum-events p { margin: 0; font-size: .88rem; line-height: 1.6; color: var(--ink); }
.sum-places p { margin: 2px 0 0; font-size: .86rem; line-height: 1.55; }
.sum-places p small { font-size: .72rem; font-weight: 700; color: var(--accent); margin-right: 6px; }
.ai-note { text-align: center; }
.sum-people b small { font-size: .7rem; font-weight: 600; color: var(--muted); margin-left: 5px; }

/* 구절 선택 패널 */
.vp-head { display: flex; align-items: center; justify-content: center; gap: 14px; }
.vp-list { display: grid; gap: 6px; }
.vp-row { position: relative; display: grid; grid-template-columns: auto 1fr; gap: 8px; align-items: start; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; }
.vp-row:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.vp-num { min-width: 1.6em; font-weight: 700; color: var(--accent); font-size: calc(.86rem * var(--fz, 1)); padding-top: 2px; }
.vp-txt { padding-right: 12px; font-weight: 400; font-size: calc(.92rem * var(--fz, 1)); line-height: 1.6; }
.vp-txt small { display: block; margin-top: 4px; font-size: calc(.84rem * var(--fz, 1)); color: var(--muted); }
.vp-txt small i { font-style: normal; font-weight: 700; margin-right: 4px; }
.vp-bar { position: sticky; bottom: -14px; display: flex; align-items: center; gap: 6px; padding: 10px 0 14px; margin-top: 8px; background: var(--bg); }
.vp-bar .vp-n { flex: 1; font-size: .86rem; color: var(--muted); }

/* 통독 화면: 탭(통독표·요약·구절·메모·도구·갓피아 원문)을 위에 늘 보여 주고, 패널은 본문 자리에 붙여 띄움 */
.rd-nav { display: flex; align-items: center; gap: 8px; }
.rd-seg { flex: none; }
.rd-seg button { padding: 6px 11px; font-size: .86rem; white-space: nowrap; }
.rd-chap { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center; gap: 2px; }
.rd-chap b { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .95rem; letter-spacing: -0.02em; }
.rd-chap .icon-btn { width: 32px; height: 32px; flex: none; }
.rd-tabs { display: flex; gap: 6px; padding: 8px 10px 0; overflow-x: auto; scrollbar-width: none; }
.rd-tabs::-webkit-scrollbar { display: none; }
.rd-tabs button { flex: none; padding: 7px 13px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font: inherit; font-size: .88rem; font-weight: 600; cursor: pointer; }
.rd-tabs button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.rd-clip .sheet { position: absolute; inset: 0; width: auto; height: auto; border: 0; border-radius: 0; box-shadow: none; z-index: 5; }
.rd-clip .sheet-grip, .rd-clip .sheet-backdrop { display: none; }
.rd-clip .sheet-head:has(.seg) { display: none; }
.rd-clip:has(.sheet:not([hidden])) .paste-fab { display: none; }
.vp-vers { display: flex; overflow-x: auto; gap: 6px; scrollbar-width: none; flex: none; }
.vp-vers .opt { flex: none; padding: 6px 11px; font-size: .8rem; }

/* 구절 패널이 화면 폭을 넘지 않게: 그리드 칸이 글 길이만큼 늘어나지 않도록 하고 긴 글은 줄바꿈 */
.sheet-body { grid-template-columns: minmax(0, 1fr); }
.vp { display: grid; gap: 12px; min-width: 0; }
.vp-list { min-width: 0; }
.vp-row { grid-template-columns: auto minmax(0, 1fr); min-width: 0; }
.vp-txt { min-width: 0; overflow-wrap: anywhere; word-break: keep-all; }

/* 글씨 크기 조절 (50%~200%) */
.vp-zoom, .mp-zoom { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.fz { display: inline-flex; align-items: center; gap: 4px; }
.fz b { min-width: 3.2em; text-align: center; font-size: .82rem; font-variant-numeric: tabular-nums; }
.fz-btn { display: inline-flex; align-items: baseline; gap: 1px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); font: inherit; font-size: .85rem; font-weight: 700; cursor: pointer; }
.fz-btn small { font-size: .7rem; }
.fz-btn:disabled { opacity: .4; cursor: default; }
.mp-item, .vp-row { overflow-wrap: anywhere; word-break: keep-all; }
.mp-body b { white-space: pre-line; }

/* 관계도 구절 풀이의 장·절 → 개역개정 원문 펼치기 */
.rg-src { justify-self: start; padding: 0; border: 0; background: none; text-align: left; cursor: pointer; }
.rg-src span { margin-left: 4px; color: var(--muted); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.rg-orig { border-left: 3px solid var(--accent-soft); padding: 2px 0 2px 8px; display: grid; gap: 4px; }
.rg-orig p { font-size: .86rem; line-height: 1.6; color: var(--ink); overflow-wrap: anywhere; word-break: keep-all; }
.rg-orig b { color: var(--accent); margin-right: 2px; }
.rg-orig > small { font-size: .72rem; }

/* ---------- QT: 앱이 직접 그리는 본문·묵상 ---------- */
.rd.qt .rd-clip { background: var(--bg); }
.qt-read { position: absolute; inset: 0; overflow-y: auto; padding: 16px 16px 84px; display: grid; gap: 14px; align-content: start; max-width: 720px; margin: 0 auto; overscroll-behavior: contain; }
.qt-head small { color: var(--qt); font-weight: 700; font-size: .84rem; }
.qt-head h2 { margin: 2px 0 0; font-size: 1.2rem; letter-spacing: -0.03em; }
.qt-passage { display: grid; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.qt-sec { display: grid; gap: 6px; }
.qt-sec h3 { margin: 0; font-size: .92rem; color: var(--qt); }
.qt-sec ol { margin: 0; padding-left: 1.3em; display: grid; gap: 6px; }
.qt-sec p, .qt-sec li { margin: 0; line-height: 1.7; font-size: .95rem; overflow-wrap: anywhere; word-break: keep-all; }
.qt-src { margin: 4px 0 0; }
.sheet-frame { position: relative; height: 100%; min-height: 70dvh; margin: -14px; overflow: hidden; background: #fff; }
.sheet-frame .rd-frame { --crop: 60px; }
#sheet-title h2 { display: flex; align-items: center; gap: 8px; }

/* 구절 두 역본 나란히 (QT 본문, 관계도 원문) */
.vpair { margin: 0; line-height: 1.7; font-size: .95rem; overflow-wrap: anywhere; word-break: keep-all; }
.vpair b { color: var(--accent); margin-right: 3px; font-size: .84em; }
.vpair small { display: block; margin-top: 2px; color: var(--muted); font-size: .88em; line-height: 1.6; }
.vpair small i { font-style: normal; font-weight: 700; margin-right: 4px; }
.vpair-src { color: var(--muted); font-size: .72rem; }
.rd.qt .vpair b { color: var(--qt); }

/* 통독 위 둘째 줄(토글 + ‹ 장 ›) 휴대폰 크기 */
@media (max-width: 560px) {
  .rd-nav { gap: 4px; }
  .rd-seg { padding: 2px; }
  .rd-seg button { padding: 6px 7px; font-size: .78rem; }
  .rd-chap { gap: 0; }
  .rd-chap b { font-size: .84rem; }
  .rd-chap .icon-btn { width: 24px; height: 30px; background: transparent; border: 0; font-size: 1.1rem; }
}

/* ‹ 장 이름 › : 화살표는 네모 칸, 장 이름을 누르면 권·장 고르기 */
.rd-chap { gap: 6px; }
.chap-arrow { flex: none; width: 38px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); font: inherit; font-size: 1.35rem; font-weight: 700; line-height: 1; cursor: pointer; display: grid; place-items: center; }
.chap-arrow:disabled { opacity: .35; cursor: default; }
.chap-name { min-width: 0; display: inline-flex; align-items: center; gap: 3px; border: 0; background: none; color: var(--ink); font: inherit; font-weight: 700; font-size: .95rem; letter-spacing: -0.02em; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 6px 2px; }
.chap-name svg { flex: none; width: 14px; height: 14px; fill: none; stroke: var(--muted); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.goto-books, .goto-chaps { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; }
.goto-chaps { grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); }
.goto-books button, .goto-chaps button { padding: 8px 4px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-size: .88rem; cursor: pointer; }
.goto-books button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.goto-chaps button.plan { border-color: var(--accent); }
.goto-chaps button.read { background: var(--accent-soft); color: var(--accent); }
.goto-chaps button.on { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.goto-chaps-wrap { display: grid; gap: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
@media (max-width: 560px) {
  .chap-arrow { width: 36px; height: 34px; }
  .chap-name { font-size: .86rem; }
  .goto-books { grid-template-columns: repeat(4, 1fr); }
}

/* 그날 분량 끝 축하 양 (3초) */
.cheer-pop { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgb(0 0 0 / .18); padding: 16px; animation: cheer-in .35s ease-out; }
.cheer-pop.bye { animation: cheer-out .35s ease-in forwards; }
.cheer-card { width: min(420px, 100%); background: var(--surface); border-radius: 22px; overflow: hidden; box-shadow: 0 12px 40px rgb(0 0 0 / .25); text-align: center; }
.cheer-card svg { display: block; aspect-ratio: 2 / 1; height: auto; }
.cheer-card svg g[filter] > g { transform-box: fill-box; }
.cheer-sub { margin: 10px 0 14px; font-weight: 700; }
.cheer-fallback { font-size: 2rem; margin: 30px 0 0; }
@keyframes cheer-in { from { opacity: 0; transform: scale(.85) translateY(20px); } to { opacity: 1; transform: none; } }
@keyframes cheer-out { to { opacity: 0; transform: scale(.9) translateY(-10px); } }

/* 읽음 스위치: 켜고 끄는 전원 스위치처럼 옆으로 미끄러짐 (안 읽음 = 꺼짐 "읽었어요", 읽음 = 켜짐 "더 읽을래요") */
.read-switch {
  flex: none; display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 2px 0 6px;
  border: 0; background: transparent; font: inherit; font-weight: 700; font-size: .86rem; color: var(--muted);
  cursor: pointer; white-space: nowrap; -webkit-tap-highlight-color: transparent;
}
.read-switch.on { color: var(--accent); }
.read-switch:disabled { opacity: 1; cursor: default; }
.rs-track { position: relative; flex: none; width: 48px; height: 28px; border-radius: 99px; background: color-mix(in srgb, var(--muted) 38%, var(--surface-2)); transition: background .17s; }
.rs-knob {
  position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgb(0 0 0 / .35); transition: transform .17s; display: grid; place-items: center;
}
.rs-knob::after { content: "✓"; font-size: 13px; font-weight: 800; line-height: 1; color: var(--accent); opacity: 0; transition: opacity .17s; }
.read-switch.on .rs-track { background: var(--accent); }
.read-switch.on .rs-knob { transform: translateX(20px); }
.read-switch.on .rs-knob::after { opacity: 1; }
.read-switch:focus-visible .rs-track { outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }
@media (max-width: 560px) {
  .read-switch { gap: 5px; font-size: .8rem; padding-left: 2px; }
  .rs-track { width: 44px; height: 26px; }
  .rs-knob { width: 20px; height: 20px; }
  .read-switch.on .rs-knob { transform: translateX(18px); }
}

/* QT 노트 세 칸 */
.qt-field { display: grid; gap: 4px; }
.qt-field b { font-size: .9rem; }
.qt-field small { color: var(--muted); font-size: .78rem; line-height: 1.4; }

/* 메모 고르기 칸이 화면 밖으로 밀리지 않게: 안쪽 칸이 모두 줄어들 수 있게 함 */
.mp, .mp-panel, .mp-list, .mp-list li { min-width: 0; max-width: 100%; }
.mp-item { min-width: 0; }

/* QT 질문 아래 내 답 칸 · 본문 절 고르기 */
.qt-sec ol li { display: grid; gap: 6px; }
.qt-q { font-weight: 600; }
.qt-ans { width: 100%; min-height: 4.6em; resize: vertical; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: var(--surface); color: var(--ink); font: inherit; font-size: .94rem; line-height: 1.6; }
.qt-ans:focus { outline: 2px solid color-mix(in srgb, var(--qt) 45%, transparent); outline-offset: 0; }
.qt-passage .vp-list { min-width: 0; }
.rd.qt .vp-row:has(input:checked) { border-color: var(--qt); background: var(--qt-soft); }
.rd.qt .vp-row:has(input:checked)::after { color: var(--qt); }
.rd.qt .vp-num { color: var(--qt); }
.rd.qt .vp-vers .opt.on { border-color: var(--qt); background: var(--qt-soft); color: var(--qt); }
.rd.qt .qp-fixed .btn.primary { background: var(--qt); color: #fff; }
.rd.qt .qp-fixed .btn.soft { background: var(--qt-soft); color: var(--qt); }
.qt-read { grid-template-columns: minmax(0, 1fr); }
#q-content, .qt-passage, .qp-body { min-width: 0; max-width: 100%; }
.qt-passage .vp-vers { max-width: 100%; }

/* QT 화면: 통독과 같은 위쪽 한 줄(날짜 이동 + 우상단 읽음 스위치), 절 선택 막대는 맨 아래에 고정 */
.q-check { flex: none; margin-left: auto; display: inline-flex; }
.rd.qt .read-switch.on { color: var(--qt); }
.rd.qt .read-switch.on .rs-track { background: var(--qt); }
.rd.qt .read-switch.on .rs-knob::after { color: var(--qt); }
.qp-fixed {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 8; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line);
  box-shadow: 0 -4px 14px rgb(0 0 0 / .08);
}
.qp-fixed .vp-n { flex: 1 1 auto; min-width: 5.5em; font-size: .86rem; color: var(--muted); white-space: nowrap; }
.qp-fixed .btn.text { padding: 6px 8px; }
.rd-clip:has(.sheet:not([hidden])) .qp-fixed { display: none; }
.rd.qt .qt-read { padding-bottom: 130px; }
.rd.qt .paste-fab { bottom: 84px; }
.qp-fixed { flex-wrap: nowrap; gap: 4px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
.qp-fixed .vp-n { min-width: 0; font-size: .8rem; overflow: hidden; text-overflow: ellipsis; }
.qp-fixed .btn { flex: none; padding: 6px 9px; font-size: .82rem; white-space: nowrap; }
.qp-fixed .btn.text { padding: 6px 6px; }

/* 관계도 자세히 보기: 인물 찾기 */
.rg-find { display: grid; gap: 6px; }
.rg-find-row { display: flex; gap: 6px; }
.rg-q { flex: 1; min-width: 0; height: 34px; border: 1px solid var(--line); border-radius: 10px; padding: 0 10px; font-size: .9rem; background: var(--surface); color: var(--ink); }
.rg-sort { height: 34px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 10px; padding: 0 10px; font-size: .82rem; font-weight: 700; cursor: pointer; white-space: nowrap; }
.rg-chips { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; max-width: 100%; background: var(--surface-2); border-radius: 12px; padding: 3px; }
.rg-chips::-webkit-scrollbar { display: none; }
.rg-chips button { flex: none; border: 0; background: transparent; color: var(--muted); border-radius: 9px; padding: 6px 11px; font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer; }
.rg-chips button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgb(0 0 0 / .1); }

/* 관계도 자세히 보기: 인물별 관계 묶음 · 쌍방 관계 구분 */
.rg-person { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.rg-nsort { margin-left: auto; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 10px; padding: 3px 9px; font-size: .78rem; font-weight: 700; cursor: pointer; }
.rg-rels { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.rg-grp.two { border: 1px solid var(--line); border-radius: 12px; padding: 4px; background: var(--surface-2); display: grid; gap: 0; }
.rg-grp.two .rg-grp-h { padding: 2px 8px 4px; color: var(--muted); font-size: .72rem; }
.rg-grp.two button + button { border-top: 1px dashed var(--line); border-radius: 0 0 10px 10px; }
.rg-dir + .rg-dir { margin-top: 10px; padding-top: 10px; border-top: 2px dashed var(--line); }
.rg-dir.cur .rg-rel { font-weight: 700; }
.rg-family { margin: 10px 0; padding: 9px 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.rg-family > b { display: block; margin-bottom: 6px; }
.rg-family-summary { margin: -1px 0 7px; color: var(--ink); font-size: .86rem; }
.rg-family-links { display: flex; flex-wrap: wrap; gap: 5px; }
.rg-family-links button { border: 1px solid var(--line); border-radius: 999px; padding: 5px 9px; background: var(--surface); color: var(--ink); font: inherit; cursor: pointer; }
.rg-family-links button span { color: var(--muted); font-size: .78rem; }
.rg-family > small { display: block; margin-top: 6px; color: var(--muted); }
.rg-mini-pop { position: relative; margin: 10px 0; padding: 12px 34px 12px 12px; border: 2px solid var(--accent); border-radius: 14px; background: var(--surface); box-shadow: 0 8px 24px rgb(0 0 0 / .16); }
.rg-mini-close { position: absolute; top: 7px; right: 8px; border: 0; background: transparent; color: var(--muted); font-size: 1rem; cursor: pointer; }
.rg-mini-pop p { margin: 5px 0 0; color: var(--muted); font-size: .82rem; line-height: 1.45; }
.rg-mini-pop > small { display: block; margin-top: 8px; color: var(--muted); }
.rg-mini-graph { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-top: 9px; }
.rg-mini-node, .rg-mini-edge { border-radius: 8px; padding: 4px 7px; background: var(--accent-soft); color: var(--ink); font-size: .78rem; }
.rg-mini-node.focus { font-weight: 800; outline: 2px solid var(--accent); }
.rg-mini-edge { display: inline-flex; align-items: center; gap: 5px; background: var(--surface-2); }
.rg-mini-edge em { color: var(--muted); font-style: normal; }

/* 탭 전환 슬라이드 */
@keyframes slide-in-r { from { transform: translateX(46px); opacity: .25; } to { transform: none; opacity: 1; } }
@keyframes slide-in-l { from { transform: translateX(-46px); opacity: .25; } to { transform: none; opacity: 1; } }
.sheet-body.slide-l { animation: slide-in-r .28s ease-out; }
.sheet-body.slide-r { animation: slide-in-l .28s ease-out; }
/* QT 탭 묶음이 가로로 늘어나지 않게 */
#q-tabs { justify-self: start; align-self: flex-start; width: max-content; max-width: 100%; }

/* 주요 등장 인물: 박스 없이 담백한 목록 (이름 내림차순) */
.sum-people { display: block; }
.sum-people li { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; background: none; border-radius: 0; padding: 8px 2px; border-bottom: 1px solid var(--line); }
.sum-people li:last-child { border-bottom: 0; }
.sum-people b { color: var(--ink); font-size: .95rem; font-weight: 700; }
.sum-people span { color: var(--muted); font-size: .84rem; text-align: right; }

/* 주요 등장 인물: 여러 열로 압축 (이름 · 역할을 한 칸에) */
.sum-people { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px 14px; }
.sum-people li { display: block; border-bottom: 0; padding: 2px 0; min-width: 0; }
.sum-people b { display: block; overflow-wrap: anywhere; }
.sum-people span { display: block; text-align: left; font-size: .78rem; line-height: 1.35; }

/* 주요 등장 인물: 찾기 칸 + 중요도 순 목록 */
.sum-find { width: 100%; box-sizing: border-box; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--ink); font: inherit; font-size: .9rem; padding: 6px 2px; outline: none; margin-bottom: 8px; }
.sum-find:focus { border-bottom-color: var(--accent); }
.sum-people li[hidden] { display: none; }
