:root {
  --bg: #f5f7f5;
  --paper: #ffffff;
  --ink: #17201b;
  --muted: #5f6b65;
  --line: #dde5df;
  --teal: #0f766e;
  --blue: #2563eb;
  --amber: #b45309;
  --red: #b91c1c;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background: var(--bg);
  font-family: "Segoe UI", "Noto Sans KR", "Malgun Gothic", Arial, sans-serif;
  letter-spacing: 0;
}

a { color: inherit; }
.layout {
  display: grid;
  grid-template-columns: 306px minmax(0, 1fr);
  min-height: 100vh;
  transition: grid-template-columns .22s ease;
}

.toc {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 100vh;
  overflow-y: auto;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: #eef4f1;
}

.toc-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  margin: 0 0 14px;
  padding: 0 10px;
  border: 1px solid rgba(15, 23, 42, .14);
  border-radius: 6px;
  color: var(--teal);
  background: var(--paper);
  font: inherit;
  font-size: 12px;
  font-weight: 850;
  cursor: pointer;
}

.toc-toggle:hover {
  border-color: var(--teal);
}

.toc-toggle:focus-visible {
  outline: 3px solid rgba(20, 184, 166, .35);
  outline-offset: 3px;
}

.layout.toc-collapsed {
  grid-template-columns: 58px minmax(0, 1fr);
}

.layout.toc-collapsed .toc {
  padding: 16px 8px;
  overflow: hidden;
}

.layout.toc-collapsed .toc-title,
.layout.toc-collapsed .toc a {
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
}

.layout.toc-collapsed .toc-toggle {
  width: 42px;
  min-height: 42px;
  margin: 0 auto;
  padding: 0;
  writing-mode: vertical-rl;
}

.toc-title {
  margin: 0 0 16px;
  font-size: 16px;
  line-height: 1.35;
}

.toc-title span,
.toc-title em {
  display: block;
}

.toc-title span {
  color: var(--ink);
}

.toc-title em {
  margin-top: 4px;
  color: var(--teal);
  font-size: 13px;
  font-style: normal;
  font-weight: 700;
}

.toc a,
.toc .chapter {
  display: block;
  text-decoration: none;
  border-radius: 6px;
}

.toc .chapter {
  margin: 18px 0 7px;
  color: var(--ink);
  font-weight: 800;
  font-size: 13px;
}

.toc a {
  padding: 8px 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.42;
}

.toc a:hover { background: var(--paper); color: var(--teal); }

.toc .toc-section {
  padding-left: 18px;
  font-size: 12px;
}

.toc a.chapter {
  margin-top: 12px;
  color: var(--ink);
  font-weight: 800;
}

.page {
  width: min(1180px, 100%);
  padding: 42px 48px 80px;
}

.cover-page {
  display: grid;
  align-items: center;
  min-height: 100vh;
}

.cover-page .cover {
  border-bottom: 0;
}

.cover {
  position: relative;
  overflow: hidden;
  padding: 16px 0 34px;
  border-bottom: 1px solid var(--line);
}

.cover-grid {
  display: block;
  min-height: 520px;
}

.cover-copy {
  max-width: 860px;
}

.series {
  margin: 0 0 12px;
  color: var(--teal);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

h1 {
  max-width: 940px;
  margin: 0;
  font-size: clamp(46px, 7vw, 86px);
  line-height: 1;
}

.cover h1 {
  max-width: none;
  font-size: clamp(42px, 5.5vw, 68px);
  white-space: nowrap;
}

.subtitle {
  margin: 18px 0 0;
  color: var(--amber);
  font-size: clamp(26px, 3.8vw, 46px);
  font-weight: 800;
  line-height: 1.18;
}

.lead {
  max-width: 870px;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.72;
}

.author {
  margin: 28px 0 0;
  color: var(--ink);
  font-size: clamp(19px, 2.1vw, 24px);
  font-weight: 850;
}

.cover-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 30px;
}

.primary-action,
.secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 18px;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 800;
}

.primary-action {
  color: #ffffff;
  background: var(--teal);
}

.secondary-action {
  color: var(--ink);
  border: 1px solid var(--line);
  background: var(--paper);
}

.device-note {
  max-width: 620px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.6;
}

.support-qr {
  display: inline-flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(260px, 100%);
  margin: 26px 0 0;
}

.support-pay-link {
  display: inline-flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
}

.support-qr img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.support-pay-link span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--ink);
  border-radius: 8px;
  background: var(--ink);
  color: #ffffff;
  font-size: 14px;
  font-weight: 850;
  line-height: 1.35;
  text-align: center;
}

.support-pay-link:hover span,
.support-pay-link:focus-visible span {
  background: #111827;
}

.support-pay-link:focus-visible {
  outline: 3px solid rgba(20, 184, 166, .35);
  outline-offset: 4px;
}

.support-qr figcaption {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.55;
}

.rights-callout {
  display: block;
  max-width: 820px;
  margin-top: 28px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--teal);
  border-radius: 8px;
  background: rgba(255, 255, 255, .72);
}

.rights-callout p {
  margin: 0;
  color: var(--muted);
  line-height: 1.62;
}

.rights-callout strong {
  color: var(--ink);
}

.metric-strip,
.chapter-grid,
.source-grid,
.question-grid {
  display: grid;
  gap: 12px;
}

.metric-strip {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 28px;
}

.metric-card,
.chapter-card,
.panel,
.source-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.metric-card { min-height: 118px; padding: 16px; }
.metric-card span,
.metric-card em {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}
.metric-card strong {
  display: block;
  margin: 10px 0 8px;
  font-size: 28px;
}

.chapter-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 28px 0;
}

.chapter-card {
  padding: 20px;
  min-height: 176px;
  text-decoration: none;
}
.chapter-card:hover { border-color: var(--teal); }
.chapter-card span { color: var(--teal); font-weight: 800; }
.chapter-card h2 { margin: 10px 0; font-size: 22px; }
.chapter-card p { margin: 0; color: var(--muted); line-height: 1.65; }

.section {
  margin: 38px 0;
  padding-top: 8px;
}
.section h2 {
  margin: 0 0 10px;
  font-size: 30px;
}
.section > p {
  max-width: 900px;
  color: var(--muted);
  line-height: 1.75;
}

.panel {
  margin: 18px 0;
  padding: 22px;
}
.panel h3 { margin: 0 0 12px; }
.chart-box {
  height: 360px;
  min-height: 360px;
}
.map-box {
  min-height: 620px;
}

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, .62fr);
  gap: 16px;
  align-items: stretch;
}

.note-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.75;
}

.source-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.source-card {
  padding: 16px;
  min-height: 126px;
}
.source-card strong { display: block; margin-bottom: 8px; }
.source-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }

.narrative-flow {
  padding-bottom: 8px;
}

.flow-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.flow-steps article,
.thesis-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.flow-steps article {
  min-height: 188px;
  padding: 18px;
}

.flow-steps span {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  color: #ffffff;
  background: var(--teal);
  font-size: 13px;
  font-weight: 800;
}

.flow-steps h3 {
  margin: 14px 0 8px;
  font-size: 19px;
}

.flow-steps p {
  margin: 0;
  color: var(--muted);
  line-height: 1.62;
}

.thesis-box {
  margin-top: 14px;
  padding: 20px 22px;
  border-left: 4px solid var(--amber);
}

.thesis-box strong {
  display: block;
  margin-bottom: 8px;
  color: var(--amber);
}

.thesis-box p {
  margin: 0;
  max-width: 920px;
  line-height: 1.72;
}

.question-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 18px;
}

.question-card {
  min-height: 250px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.question-card h3 {
  margin: 0 0 10px;
  font-size: 18px;
}

.question-card ul {
  margin: 0;
  padding-left: 18px;
  color: var(--ink);
  line-height: 1.62;
}

.question-card li { margin: 6px 0; }

.question-card p {
  margin: 14px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.question-plan {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.plan-chapter {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  overflow: hidden;
}

.plan-chapter > header {
  padding: 20px 22px;
  background: #eef4f1;
  border-bottom: 1px solid var(--line);
}

.plan-chapter h3 {
  margin: 0 0 8px;
  font-size: 22px;
}

.plan-chapter > header p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.plan-section {
  padding: 20px 22px 22px;
  border-top: 1px solid var(--line);
}

.plan-section:first-of-type { border-top: none; }

.plan-section h4 {
  margin: 0 0 14px;
  color: var(--teal);
  font-size: 18px;
}

.plan-question-list {
  display: grid;
  gap: 12px;
}

.plan-question {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.plan-question h5 {
  margin: 0 0 12px;
  font-size: 16px;
  line-height: 1.45;
}

.plan-question dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

.plan-question dl div {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.plan-question dt {
  color: var(--amber);
  font-size: 12px;
  font-weight: 800;
}

.plan-question dd {
  margin: 0;
  color: var(--muted);
  line-height: 1.58;
}

.method {
  border-left: 4px solid var(--teal);
  background: #f8fbfa;
}

.footer-note {
  margin-top: 34px;
  color: var(--muted);
  font-size: 13px;
}

.book-toc ol {
  margin: 0;
  padding-left: 24px;
  line-height: 1.85;
}

.book-toc > ol > li {
  margin: 10px 0;
  font-weight: 800;
}

.book-toc ol ol {
  color: var(--muted);
  font-weight: 500;
}

.book-toc a {
  text-decoration: none;
}

.book-toc a:hover {
  color: var(--teal);
}

.feedback-form-box {
  max-width: 720px;
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .78);
}

.feedback-form-box summary {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  margin: 0;
  padding: 9px 13px;
  color: #ffffff;
  border-radius: 7px;
  background: var(--teal);
  font-size: 13px;
  font-weight: 850;
  cursor: pointer;
  list-style: none;
}

.feedback-form-box summary::-webkit-details-marker {
  display: none;
}

.feedback-form-box[open] summary {
  margin: 12px 12px 0;
}

.feedback-form-box form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 14px 16px 16px;
}

.feedback-form-box label {
  display: grid;
  gap: 6px;
}

.feedback-form-box label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.feedback-form-box input,
.feedback-form-box textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 11px;
  color: var(--ink);
  background: #ffffff;
  font: inherit;
  font-size: 14px;
}

.feedback-form-box textarea {
  min-height: 118px;
  resize: vertical;
}

.feedback-message-field,
.feedback-form-box button,
.feedback-form-box p {
  grid-column: 1 / -1;
}

.feedback-form-box button {
  justify-self: start;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--ink);
  border-radius: 7px;
  color: #ffffff;
  background: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 850;
  cursor: pointer;
}

.feedback-form-box button:hover {
  background: #111827;
}

.feedback-form-box p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.55;
}

.feedback-honey {
  position: absolute !important;
  left: -9999px !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
}

.page-turn-nav {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
  margin-top: 54px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.page-turn-link,
.page-turn-home {
  display: flex;
  min-height: 64px;
  border-radius: 8px;
  text-decoration: none;
}

.page-turn-link {
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: var(--paper);
}

.page-turn-link.next {
  text-align: right;
}

.page-turn-link span {
  color: var(--teal);
  font-size: 12px;
  font-weight: 850;
}

.page-turn-link strong {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.35;
}

.page-turn-link:hover {
  border-color: var(--teal);
}

.page-turn-link.disabled {
  color: var(--muted);
  background: transparent;
  opacity: .46;
}

.page-turn-home {
  align-items: center;
  justify-content: center;
  min-width: 158px;
  padding: 0 18px;
  border: 1px solid var(--ink);
  color: #ffffff;
  background: var(--ink);
  font-size: 14px;
  font-weight: 850;
}

.page-turn-home:hover {
  background: #111827;
}

@media (max-width: 900px) {
  .layout {
    display: block;
  }

  .layout.toc-collapsed {
    display: block;
  }

  .toc {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    gap: 6px;
    height: auto;
    max-width: 100vw;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
  }

  .toc-toggle {
    display: none;
  }

  .layout.toc-collapsed .toc {
    height: auto;
    max-width: 100vw;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px 12px;
  }

  .layout.toc-collapsed .toc-title,
  .layout.toc-collapsed .toc a {
    pointer-events: auto;
    opacity: 1;
    visibility: visible;
  }

  .toc-title {
    flex: 0 0 176px;
    margin: 0 4px 0 0;
    padding: 7px 8px 6px 0;
    border-right: 1px solid rgba(15, 23, 42, .1);
    font-size: 13px;
  }

  .toc-title em {
    font-size: 11px;
  }

  .toc a,
  .toc .chapter,
  .toc a.chapter,
  .toc .toc-section {
    flex: 0 0 auto;
    max-width: 220px;
    margin: 0;
    padding: 8px 10px !important;
    scroll-snap-align: start;
    white-space: nowrap;
  }

  .toc .chapter,
  .toc a.chapter {
    font-size: 12px;
  }

  .toc .toc-section {
    font-size: 12px !important;
  }

  .page {
    width: 100%;
    padding: 28px 18px 60px;
  }

  .cover-page {
    align-items: start;
    min-height: auto;
  }

  .cover-grid {
    min-height: 0;
  }

  .cover {
    padding-top: 8px;
  }

  h1 {
    font-size: clamp(36px, 11vw, 52px);
    line-height: 1.08;
  }

  .cover h1 {
    font-size: clamp(24px, 7.2vw, 42px);
    line-height: 1.08;
    white-space: nowrap;
  }

  .subtitle {
    font-size: clamp(22px, 7vw, 32px);
  }

  .lead {
    margin-top: 18px;
    font-size: 16px;
    line-height: 1.68;
  }

  .cover-actions a {
    flex: 1 1 150px;
  }

  .primary-action,
  .secondary-action {
    min-height: 44px;
    padding: 0 14px;
  }

  .rights-callout {
    margin-top: 24px;
    padding: 15px 16px;
  }

  .feedback-form-box form {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 16px;
  }

  .section h2 {
    font-size: 24px;
  }

  .chart-box {
    height: 320px;
    min-height: 320px;
  }

  .map-box {
    min-height: 420px;
  }

  .metric-strip,
  .chapter-grid,
  .source-grid,
  .question-grid,
  .flow-steps,
  .two-col { grid-template-columns: 1fr; }
  .plan-question dl div { grid-template-columns: 1fr; gap: 3px; }

  .page-turn-nav {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 36px;
    padding-top: 18px;
  }

  .page-turn-link,
  .page-turn-link.next {
    text-align: left;
  }

  .page-turn-home {
    min-width: 0;
    min-height: 48px;
  }
}
