:root {
  --paper: #F7F4EC;
  --ink: #1F1D1A;
  --muted: #6B665C;
  --faint: #8A8478;
  --line: #D9D3C5;
  --red: #9A3B2E;
  --serif: 'Nanum Myeongjo', 'AppleMyungjo', 'Batang', serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  word-break: keep-all;
  overflow-wrap: break-word;
}

.book {
  max-width: 480px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(40px + env(safe-area-inset-top)) 32px calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}
@media (max-width: 359px) { .book { padding-left: 24px; padding-right: 24px; } }

.bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.nav { min-height: 48px; margin-top: 16px; }

.page {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 32px 0;
  outline: none;
}
.page.enter { animation: fade 0.35s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .page.enter { animation: none; } }

.stack { display: flex; flex-direction: column; gap: 28px; }
.stack.tight { gap: 16px; }
.center { align-items: center; text-align: center; }

/* 문장 스타일: content JSON의 lines[][0] 키와 1:1 대응 */
.l { margin: 0; white-space: pre-line; font-size: 19px; line-height: 1.9; }
.l-muted { color: var(--muted); }
.l-bold { font-weight: 700; }
.l-big { font-size: 34px; line-height: 1.5; font-weight: 800; }
.l-big2 { font-size: 26px; line-height: 1.6; font-weight: 800; }
.l-big3 { font-size: 22px; line-height: 1.7; font-weight: 800; }
.l-hero { font-size: 30px; line-height: 1.6; font-weight: 800; }
.l-answer { font-size: 22px; line-height: 1.7; font-weight: 700; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.l-red { font-weight: 700; color: var(--red); }
.l-redsoft { font-size: 17px; color: var(--red); }
.l-small { font-size: 16px; line-height: 1.8; }
.l-src { font-size: 13px; line-height: 1.6; color: var(--muted); }
.l-qmuted { font-size: 17px; line-height: 1.6; color: var(--muted); }
.l-smallmuted { font-size: 15px; line-height: 1.8; color: var(--muted); }
.l-rule { width: 32px; height: 1px; margin: 8px 0; background: var(--ink); }

@media (max-width: 359px) {
  .l { font-size: 17px; }
  .l-big { font-size: 30px; }
  .l-hero { font-size: 26px; }
  .l-big2 { font-size: 23px; }
  .l-big3, .l-answer { font-size: 20px; }
}

button { font-family: inherit; color: inherit; -webkit-appearance: none; appearance: none; }
.link {
  min-height: 44px;
  padding: 0 4px;
  background: none;
  border: none;
  font-size: 15px;
  cursor: pointer;
}
.link.underline { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 8px; }
.link.strong { font-size: 16px; font-weight: 700; }
.link.muted { color: var(--muted); font-size: 14px; }
.link:active { color: var(--red); }
@media (hover: hover) { .link:hover { color: var(--red); } }
.link:focus-visible, .opt:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

/* 입력 */
.input-q { font-size: 30px; font-weight: 800; line-height: 1.5; margin: 0; white-space: pre-line; }
.input-sub { font-size: 16px; color: var(--muted); margin: 0; }
.field { display: flex; flex-direction: column; gap: 8px; margin-top: 40px; }
.field label { font-size: 13px; color: var(--muted); }
.field input {
  font-family: inherit;
  font-size: 19px; /* 16px 이상: iOS 자동 확대 방지 */
  color: var(--ink);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--ink);
  border-radius: 0;
  padding: 10px 0;
  outline: none;
}
.field input:focus { border-bottom-color: var(--red); }
.field input::placeholder { color: var(--faint); }
.input-note { margin: 8px 0 0; font-size: 12px; line-height: 1.6; color: var(--faint); white-space: pre-line; }

/* 선택지 */
.opts { display: flex; flex-direction: column; }
.opt {
  display: flex;
  gap: 16px;
  align-items: baseline;
  min-height: 56px;
  padding: 14px 0;
  background: none;
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  font-size: 16px;
  line-height: 1.6;
  text-align: left;
  cursor: pointer;
}
.opt:active { background: rgba(154, 59, 46, 0.06); }
.num { font-size: 13px; color: var(--muted); flex-shrink: 0; }
.hint { font-size: 13px; color: var(--muted); text-align: center; margin: 0; }

/* 결과 첨삭 */
.mark { display: flex; gap: 16px; align-items: baseline; }
.mark-wrong { font-size: 17px; line-height: 1.7; color: var(--muted); text-decoration: line-through; text-decoration-color: var(--red); }
.mark-right {
  font-size: 17px; line-height: 1.9; font-weight: 700;
  text-decoration: underline; text-decoration-color: var(--red);
  text-decoration-thickness: 2px; text-underline-offset: 6px;
}

/* 저장 지점 / 안내 화면 */
.step { font-size: 13px; color: var(--muted); letter-spacing: 0.2em; margin: 0; }
.title { font-size: 28px; font-weight: 800; line-height: 1.6; margin: 0; white-space: pre-line; }
.msg { font-size: 17px; line-height: 1.9; color: var(--muted); margin: 0; white-space: pre-line; }
.actions { display: flex; flex-direction: column; gap: 8px; align-items: center; margin-top: 24px; }

/* 위기 안내 */
.contacts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.contacts a {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  min-height: 56px; padding: 14px 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink); text-decoration: none; font-size: 16px;
}
.contacts strong { font-size: 22px; color: var(--red); }
.contacts small { display: block; font-size: 13px; color: var(--muted); }

.noscript { padding: 32px; text-align: center; }

/* 세로가 짧은 화면(iPhone SE 1세대 등): 여백을 줄여 스크롤 없이 한 장에 담기 */
@media (max-height: 640px) {
  .book { padding-top: calc(20px + env(safe-area-inset-top)); padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .page { padding: 16px 0; }
  .nav { margin-top: 4px; }
  .stack { gap: 20px; }
  .opt { min-height: 48px; padding: 10px 0; }
}

/* 처음 화면: 편 안쪽처럼 한 장에 질문 하나 */
.page.home { justify-content: flex-start; padding: 8px 0 16px; }
.home-wrap { flex: 1; display: flex; flex-direction: column; gap: 20px; }
.home-main { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 24px 0; }
.hero { display: flex; flex-direction: column; gap: 12px; color: var(--ink); text-decoration: none; }
.hero:focus-visible { outline: 2px solid var(--red); outline-offset: 6px; }
.hero-label { margin: 0; font-size: 14px; font-weight: 700; color: var(--red); }
.hero-q { margin: 0; font-size: 28px; line-height: 1.55; font-weight: 800; white-space: pre-line; }
.hero-meta { margin: 0; font-size: 15px; color: var(--muted); }
.hero-cta {
  align-self: flex-start; margin-top: 16px; font-size: 17px; font-weight: 700;
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 8px;
}
.hero:active .hero-cta { color: var(--red); }
@media (hover: hover) { .hero:hover .hero-cta { color: var(--red); } }
@media (max-height: 640px) { .hero-q { font-size: 24px; } .home-main { padding: 8px 0; } }
.home-more, .home-back {
  align-self: flex-start; min-height: 44px; display: inline-flex; align-items: center;
  font-size: 15px; color: var(--muted); text-decoration: underline;
  text-decoration-thickness: 1px; text-underline-offset: 6px;
}
.home-more:active, .home-back:active { color: var(--red); }
@media (hover: hover) { .home-more:hover, .home-back:hover { color: var(--red); } }
.home-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 16px; margin-top: -8px; }
.home-note { margin: 0; font-size: 12px; line-height: 1.6; color: var(--faint); }

/* 입문 코스·전체 지도: 접었다 펴는 섹션 */
.map { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.sec { display: flex; flex-direction: column; }
.sec > summary {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  min-height: 48px; padding: 12px 0;
  border-bottom: 1px solid var(--line);
  list-style: none; cursor: pointer;
}
.sec > summary::-webkit-details-marker { display: none; }
.sec > summary::before { content: '▸'; font-size: 12px; color: var(--muted); margin-right: -4px; }
.sec[open] > summary::before { content: '▾'; }
.sec > summary:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.sec-title { flex: 1; font-size: 17px; font-weight: 700; }
.sec-meta { font-size: 13px; color: var(--muted); white-space: nowrap; }
.sec-sub { margin: 10px 0 2px; font-size: 14px; line-height: 1.6; color: var(--muted); white-space: pre-line; }
.course > summary { border-top: 1px solid var(--line); }
.course .sec-title { flex: 0 0 auto; }
.dots { flex: 1; display: flex; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; border: 1px solid var(--muted); }
.dot.on { background: var(--red); border-color: var(--red); }
.ep {
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink); text-decoration: none;
}
a.ep:active { background: rgba(154, 59, 46, 0.06); }
@media (hover: hover) { a.ep:hover .ep-title { color: var(--red); } }
a.ep:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.ep-head { display: flex; gap: 12px; align-items: baseline; }
.ep-title { font-size: 18px; font-weight: 800; line-height: 1.4; }
.ep-q { margin: 0 0 0 28px; font-size: 15px; line-height: 1.5; }
.ep.is-done .ep-q { color: var(--muted); }
.ep-status { margin: 2px 0 0 28px; font-size: 13px; line-height: 1.5; font-weight: 700; color: var(--red); }
.ep-status.done { font-weight: 400; color: var(--muted); }
.ep.soon .ep-title, .ep.soon .ep-q { color: var(--faint); }
.ep.soon .ep-status { color: var(--faint); font-weight: 400; }

/* 내 답 */
.answers { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.ans { display: flex; flex-direction: column; gap: 6px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.ans-head { font-size: 13px; line-height: 1.5; color: var(--muted); text-decoration: none; }
.ans-head:active { color: var(--red); }
@media (hover: hover) { .ans-head:hover { color: var(--red); } }
.ans-text { margin: 0; font-size: 20px; line-height: 1.6; font-weight: 700; white-space: pre-line; }
.ans-wipe { align-self: center; margin-top: 16px; }
