/* ── 몰라서 만들었다 — 본문 조판 ─────────────────────────── */

@page {
  size: A5;
  margin: 20mm 18mm 22mm;
  @bottom-center { content: counter(page); font-size: 8pt; color: #999; }
}

:root {
  --ink: #1B2A41;
  --text: #23272e;
  --sub: #6b7280;
  --line: #d8d4cb;
  --paper: #FDFCF9;
  --accent: #8a6d3b;
  --code-bg: #f5f3ee;
}

* { box-sizing: border-box; }

body {
  font-family: "NanumMyeongjo", "Apple SD Gothic Neo", "Noto Serif KR", serif;
  font-size: 10.5pt;
  line-height: 1.95;
  color: var(--text);
  background: var(--paper);
  max-width: 34em;
  margin: 0 auto;
  padding: 3.5em 1.6em 5em;
  word-break: keep-all;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ── 표제지 ─────────────────────────────────────────── */
.titlepage {
  text-align: center;
  padding: 6em 0 5em;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4em;
  page-break-after: always;
}
.titlepage .booktitle {
  font-family: "NanumGothic", sans-serif;
  font-size: 2.4em;
  font-weight: 800;
  letter-spacing: -.04em;
  line-height: 1.3;
  color: var(--ink);
  margin: 0 0 .8em;
}
.titlepage .subtitle {
  font-size: .95em;
  color: var(--sub);
  line-height: 1.7;
  margin: 0 auto 3em;
  max-width: 22em;
}
.titlepage .byline {
  font-size: .82em;
  color: var(--sub);
  letter-spacing: .08em;
}

/* ── 제목 ───────────────────────────────────────────── */
h1 {
  font-family: "NanumGothic", "Apple SD Gothic Neo", sans-serif;
  font-size: 1.05em;
  font-weight: 800;
  letter-spacing: .22em;
  color: var(--accent);
  text-align: center;
  margin: 5em 0 3.5em;
  padding: 1.4em 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  page-break-before: always;
  page-break-after: avoid;
}
h1:first-of-type { page-break-before: avoid; }

h2 {
  font-family: "NanumGothic", "Apple SD Gothic Neo", sans-serif;
  font-size: 1.42em;
  font-weight: 800;
  letter-spacing: -.035em;
  line-height: 1.45;
  color: var(--ink);
  margin: 3.4em 0 1.6em;
  page-break-after: avoid;
}
h2::after {
  content: "";
  display: block;
  width: 2.2em;
  height: 2px;
  background: var(--ink);
  margin-top: .55em;
}

h3 {
  font-family: "NanumGothic", "Apple SD Gothic Neo", sans-serif;
  font-size: 1.02em;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--ink);
  margin: 2.6em 0 .9em;
  page-break-after: avoid;
}

/* ── 본문 ───────────────────────────────────────────── */
p {
  margin: 0 0 1.3em;
  text-align: justify;
  text-justify: inter-character;
  orphans: 2;
  widows: 2;
}

strong { font-weight: 700; color: var(--ink); }
em { font-style: italic; color: var(--sub); }

/* ── 인용 (교훈 문장) ───────────────────────────────── */
blockquote {
  margin: 2.2em 0;
  padding: 1.3em 1.5em;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  font-family: "NanumGothic", sans-serif;
  font-size: .93em;
  line-height: 1.75;
  color: var(--ink);
  page-break-inside: avoid;
}
blockquote p { margin: 0; text-align: left; }
blockquote p + p { margin-top: .7em; }
blockquote strong { color: var(--accent); }

/* ── 코드/데이터 블록 ───────────────────────────────── */
pre {
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 1.1em 1.3em;
  font-family: "SF Mono", "D2Coding", Menlo, Consolas, monospace;
  font-size: .78em;
  line-height: 1.75;
  color: #3a3f47;
  overflow-x: auto;
  margin: 1.8em 0;
  page-break-inside: avoid;
}
code {
  font-family: "SF Mono", "D2Coding", Menlo, Consolas, monospace;
  font-size: .86em;
  background: var(--code-bg);
  padding: .12em .4em;
  border-radius: 2px;
  color: #4a3f2f;
}
pre code { background: none; padding: 0; font-size: 1em; color: inherit; }

/* ── 목록 ───────────────────────────────────────────── */
ul, ol { margin: 0 0 1.3em; padding-left: 1.4em; }
li { margin-bottom: .5em; }
li::marker { color: var(--sub); }

/* ── 구분선 ─────────────────────────────────────────── */
hr {
  border: 0;
  height: 1px;
  background: none;
  text-align: center;
  margin: 3em 0;
}
hr::before {
  content: "· · ·";
  color: var(--line);
  letter-spacing: .8em;
  font-size: .9em;
}

/* ── 목차 ───────────────────────────────────────────── */
#TOC, nav#TOC {
  page-break-after: always;
  margin: 0 0 4em;
  padding: 2em 0 2.5em;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-family: "NanumGothic", sans-serif;
}
#TOC::before {
  content: "차례";
  display: block;
  font-size: 1.1em;
  font-weight: 800;
  letter-spacing: .3em;
  color: var(--ink);
  text-align: center;
  margin-bottom: 1.8em;
}
#TOC ul { list-style: none; padding-left: 0; margin: 0; }
#TOC > ul > li { margin: 1.2em 0 .5em; }
#TOC > ul > li > a {
  font-weight: 800;
  font-size: .95em;
  color: var(--accent);
  letter-spacing: .05em;
}
#TOC ul ul { padding-left: .9em; margin-top: .35em; }
#TOC ul ul li { margin: .3em 0; }
#TOC ul ul a { font-size: .88em; color: var(--text); font-weight: 400; }
#TOC a { text-decoration: none; }
#TOC a:hover { text-decoration: underline; }

/* ── 화면(웹) 전용 ──────────────────────────────────── */
@media screen {
  body { max-width: 36em; padding: 4em 1.8em 6em; font-size: 11pt; }
  a { color: var(--accent); }
}

@media screen and (max-width: 600px) {
  body { font-size: 10.5pt; padding: 2.4em 1.2em 4em; line-height: 1.85; }
  .titlepage { padding: 3em 0 2.5em; }
  .titlepage .booktitle { font-size: 1.9em; }
  h2 { font-size: 1.28em; }
  pre { font-size: .72em; padding: .9em 1em; }
}

@media print {
  body { background: #fff; padding: 0; max-width: none; }
  a { color: inherit; text-decoration: none; }
}

/* ── 읽기 페이지 상단바 ─────────────────────────────── */
.readbar{
  position:sticky;top:0;z-index:50;
  display:flex;align-items:center;justify-content:space-between;gap:14px;
  margin:-4em -1.8em 3em;padding:.85em 1.8em;
  background:rgba(253,252,249,.92);backdrop-filter:saturate(180%) blur(12px);
  border-bottom:1px solid var(--line);
  font-family:"NanumGothic",-apple-system,sans-serif;font-size:.82em;
}
.readbar a{color:var(--accent);text-decoration:none}
.readbar a:hover{text-decoration:underline}
.readbar .rb-title{font-weight:800;color:var(--ink);letter-spacing:-.02em}
.readbar .rb-dl{color:var(--sub)}
@media screen and (max-width:600px){
  .readbar{margin:-2.4em -1.2em 2em;padding:.7em 1.2em;font-size:.76em}
  .readbar .rb-title{display:none}
}
