:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --paper: #fbfcfd;
  --paper-strong: #ffffff;
  --ink: #17202a;
  --muted: #5b6674;
  --line: #d8dee7;
  --line-strong: #aeb8c5;
  --accent: #176b63;
  --accent-dark: #0f4d47;
  --accent-soft: #e7f1ef;
  --goal: #e6f2ef;
  --steps: #f5e6dd;
  --surface: #eef0f7;
  --reference: #f3eedb;
  --map: #edf3f8;
  --warn: #9a5a14;
  --wine: #8a3f51;
  --blue: #395f8f;
  --code-bg: #17202a;
  --code-ink: #ecf4ee;
  --shadow: 0 20px 52px rgba(33, 45, 59, 0.1);
  --shadow-soft: 0 14px 36px rgba(33, 45, 59, 0.06);
  --radius: 8px;
  font-family: "SUIT Variable", "Pretendard Variable", "Apple SD Gothic Neo", "Noto Sans KR", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.72;
}

a {
  color: var(--accent-dark);
  text-decoration-color: rgba(15, 107, 92, 0.35);
  text-underline-offset: 0.18em;
}

button,
input {
  font: inherit;
}

.progress {
  position: fixed;
  inset: 0 0 auto;
  z-index: 30;
  height: 4px;
  background: rgba(23, 107, 99, 0.12);
}

.progress span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: 12px 28px;
  border-bottom: 1px solid rgba(216, 222, 231, 0.92);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 750;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  min-width: 34px;
  height: 34px;
  padding: 0 9px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 850;
  letter-spacing: 0.02em;
}

.top-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.top-actions a,
.top-actions button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper-strong);
  color: var(--ink);
  cursor: pointer;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
}

.shell {
  display: grid;
  grid-template-columns: minmax(0, 940px) minmax(220px, 280px);
  gap: 36px;
  width: min(1320px, calc(100% - 40px));
  margin: 0 auto;
  padding: 24px 0 96px;
}

.toc {
  position: sticky;
  top: 88px;
  align-self: start;
  max-height: calc(100vh - 112px);
  overflow: auto;
}

.page,
.toc-group {
  display: grid;
  gap: 16px;
}

.toc a {
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
}

.content {
  min-width: 0;
}

.page-hero {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(260px, 0.9fr);
  gap: 24px;
  min-height: clamp(260px, 34vw, 390px);
  align-items: center;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-strong);
  box-shadow: var(--shadow);
}

.page-hero__visual {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.page-hero__content {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 14px;
  max-width: 760px;
}

.page-hero__meta {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.page-badge {
  display: inline-grid;
  place-items: center;
  min-width: 42px;
  height: 42px;
  padding: 0 12px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 850;
  letter-spacing: 0.04em;
}

.page-hero__orb {
  display: none;
}

.page-hero__grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(23, 107, 99, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 107, 99, 0.05) 1px, transparent 1px);
  background-size: 26px 26px, 26px 26px;
  mask-image: linear-gradient(90deg, rgba(0, 0, 0, 0.18), rgba(0, 0, 0, 0.04));
}

.page-hero__poster {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefa;
}

.page-kicker {
  margin: 0;
  color: var(--accent-dark);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.page-hero h1 {
  margin: 0;
  font-size: clamp(38px, 5vw, 58px);
  line-height: 1.08;
  letter-spacing: 0;
}

.page-subtitle {
  margin: 12px 0 0;
  color: var(--ink);
  font-size: clamp(18px, 2.2vw, 24px);
  font-weight: 700;
}

.page-plain {
  margin: 0;
  color: var(--accent-dark);
  font-size: 18px;
  font-weight: 800;
}

.page-description {
  max-width: 760px;
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 18px;
}

.page-summary {
  width: min(100%, 520px);
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  box-shadow: 0 12px 30px rgba(60, 46, 26, 0.08);
}

.page-summary strong {
  display: block;
  margin-bottom: 6px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.page-summary p {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.hub-section {
  display: grid;
  gap: 12px;
}

.hub-band {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-radius: 8px;
  font-size: 21px;
  font-weight: 800;
}

.hub-band h2 {
  margin: 0;
  font-size: inherit;
  font-weight: inherit;
}

.hub-band--goal {
  background: var(--goal);
}

.hub-band--steps {
  background: var(--steps);
}

.hub-band--surface {
  background: var(--surface);
}

.hub-band--reference {
  background: var(--reference);
}

.hub-band--map {
  background: var(--map);
}

.hub-callout,
.resource-list,
.doc-section,
.reader-map {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-strong);
  box-shadow: var(--shadow-soft);
}

.reader-map {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  background: var(--line);
}

.reader-card {
  display: grid;
  gap: 8px;
  min-height: 156px;
  padding: 18px;
  background: var(--paper-strong);
  color: var(--ink);
  text-decoration: none;
}

.reader-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 780;
}

.reader-card strong {
  font-size: 20px;
  line-height: 1.25;
}

.reader-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.reader-card--start strong {
  color: var(--accent-dark);
}

.reader-card--work strong {
  color: var(--wine);
}

.reader-card--close strong {
  color: var(--blue);
}

.hub-callout {
  padding: 20px 22px;
}

.hub-callout > p:first-child {
  margin-top: 0;
}

.goal-list {
  margin: 16px 0 0;
  padding-left: 1.35em;
}

.goal-list li + li {
  margin-top: 8px;
}

.evidence-note > p:first-child {
  max-width: 760px;
}

.evidence-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.evidence-list li {
  display: grid;
  gap: 6px;
  min-height: 126px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.evidence-list strong {
  color: var(--accent-dark);
  font-size: 17px;
}

.evidence-list span {
  color: var(--muted);
  line-height: 1.55;
}

.hub-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.hub-card,
.resource-card {
  color: var(--ink);
  text-decoration: none;
}

.hub-card {
  display: grid;
  gap: 8px;
  min-height: 164px;
  padding: 18px 18px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-strong);
  box-shadow: var(--shadow-soft);
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.hub-card:hover,
.resource-card:hover,
.top-actions a:hover,
.top-actions button:hover {
  border-color: var(--line-strong);
  box-shadow: 0 16px 34px rgba(60, 46, 26, 0.1);
  transform: translateY(-1px);
}

.hub-card__index,
.hub-card__icon {
  color: var(--accent-dark);
  font-weight: 850;
}

.hub-card__index {
  font-size: 13px;
  letter-spacing: 0.08em;
}

.hub-card__icon {
  font-size: 22px;
}

.hub-card strong {
  font-size: 22px;
  line-height: 1.24;
}

.hub-card span:last-child {
  color: var(--muted);
}

.hub-grid--compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.hub-card--compact {
  min-height: 0;
}

.resource-list {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.resource-card {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
}

.resource-card__icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: #eef4f3;
  font-size: 22px;
}

.resource-card__body {
  display: grid;
  gap: 4px;
}

.resource-card__body span {
  color: var(--muted);
}

.doc-section {
  margin-top: 6px;
}

.doc-header {
  padding: 36px 36px 18px;
  border-bottom: 1px solid var(--line);
}

.doc-kicker {
  color: var(--accent-dark);
  font-size: 14px;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.doc-header h2 {
  margin: 8px 0 8px;
  font-size: clamp(30px, 4vw, 42px);
  line-height: 1.14;
  letter-spacing: 0;
}

.doc-header p {
  max-width: 680px;
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 17px;
}

.source-link {
  display: inline-flex;
  margin-top: 4px;
  font-size: 14px;
  font-weight: 750;
}

.prose {
  padding: 20px 36px 48px;
  font-size: 17px;
}

.prose h2,
.prose h3,
.prose h4,
.prose h5,
.prose h6 {
  scroll-margin-top: 92px;
  letter-spacing: 0;
}

.prose h2 {
  margin: 46px 0 14px;
  padding: 12px 16px;
  border-radius: 8px;
  background: #eef4f3;
  font-size: 30px;
  line-height: 1.22;
}

.prose h3 {
  margin: 32px 0 10px;
  font-size: 23px;
  line-height: 1.28;
}

.prose h4 {
  margin: 26px 0 8px;
  font-size: 19px;
}

.prose p,
.prose ul,
.prose ol,
.prose blockquote,
.table-wrap,
.code-block,
.diagram-card {
  margin: 14px 0;
}

.prose p,
.prose li {
  overflow-wrap: anywhere;
}

.prose ul,
.prose ol {
  padding-left: 1.45em;
}

.prose li + li {
  margin-top: 6px;
}

.prose blockquote {
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 12px 18px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 560px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #eef4f3;
  font-weight: 850;
}

tr:last-child td {
  border-bottom: 0;
}

.code-block,
.diagram-source-toggle pre {
  overflow-x: auto;
  border-radius: var(--radius);
  background: var(--code-bg);
  color: var(--code-ink);
  padding: 16px;
}

.code-block {
  position: relative;
}

.code-block::before {
  content: attr(data-language);
  display: block;
  margin-bottom: 8px;
  color: #9fc9bd;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.92em;
}

p code,
li code,
td code {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f2f5f8;
  overflow-wrap: anywhere;
  padding: 0.08em 0.32em;
}

.diagram-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
  padding: 14px;
}

.diagram-render {
  display: grid;
  place-items: center;
  min-height: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #eef4f3 100%);
  padding: 12px;
}

.diagram-render svg {
  max-width: 100%;
  height: auto;
}

.diagram-source-toggle {
  margin-top: 12px;
}

.diagram-source-toggle summary {
  cursor: pointer;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
}

.diagram-error {
  margin: 0;
  color: var(--warn);
  font-size: 14px;
  font-weight: 700;
}

.private-ref {
  border-radius: 5px;
  background: #f7e6cf;
  color: var(--warn);
  padding: 0.08em 0.32em;
}

.toc {
  padding-left: 4px;
}

.toc-group {
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
}

.toc-group strong {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--muted);
}

.toc a {
  display: block;
  padding: 5px 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.toc a.is-active,
.toc a:hover {
  background: rgba(23, 107, 99, 0.1);
  color: var(--accent-dark);
}

.toc-level-3 {
  margin-left: 12px;
}

@media (max-width: 1180px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .toc {
    display: none;
  }
}

@media (max-width: 820px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 12px 18px;
  }

  .shell {
    width: min(100% - 28px, 760px);
    padding-top: 16px;
  }

  .page-hero {
    grid-template-columns: 1fr;
    min-height: 220px;
    padding: 22px 20px;
    border-radius: 8px;
  }

  .page-hero__meta {
    gap: 10px;
  }

  .page-badge {
    min-width: 38px;
    height: 38px;
    border-radius: 8px;
    font-size: 13px;
  }

  .page-hero h1 {
    font-size: 36px;
  }

  .page-description {
    font-size: 16px;
  }

  .page-summary p {
    font-size: 16px;
  }

  .hub-grid,
  .hub-grid--compact,
  .evidence-list,
  .reader-map {
    grid-template-columns: 1fr;
  }

  .doc-header,
  .prose {
    padding-left: 22px;
    padding-right: 22px;
  }

  .doc-header h2 {
    font-size: 30px;
  }

  .prose {
    font-size: 16px;
  }

  .prose h2 {
    font-size: 25px;
  }

  table {
    min-width: 0;
    table-layout: fixed;
  }

  th,
  td {
    overflow-wrap: anywhere;
  }

  .code-block code,
  .diagram-source-toggle code {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }
}

@media print {
  body {
    background: #fff;
  }

  .topbar,
  .toc,
  .progress,
  .source-link {
    display: none !important;
  }

  .shell {
    display: block;
    width: 100%;
    padding: 0;
  }

  .page-hero,
  .hub-section,
  .doc-section {
    box-shadow: none;
    border: 0;
    break-inside: avoid;
  }
}
