/* World Model 튜토리얼 공용 스타일 — 모든 장이 같은 모양을 쓰도록 여기만 고친다. */

:root {
  --bg: #fbfaf7;
  --bg-2: #f3f1ec;
  --surface: #ffffff;
  --line: #e2ded5;
  --line-soft: #ece9e2;
  --text: #1d1f23;
  --text-2: #4a4f57;
  --text-3: #7a808a;
  --accent: #2f6fdb;
  --accent-soft: #e8f0fc;
  --accent-line: #b8cff3;

  --note: #2f6fdb;
  --note-bg: #eef4fd;
  --tip: #1f8a5b;
  --tip-bg: #eaf6f0;
  --warn: #b7620c;
  --warn-bg: #fdf3e6;
  --key: #7b4fd1;
  --key-bg: #f3eefc;
  --quiz: #b03a6a;
  --quiz-bg: #fbeef3;

  --code-bg: #f6f5f1;
  --code-text: #24292f;
  --hl-keyword: #cf222e;
  --hl-string: #0a3069;
  --hl-number: #0550ae;
  --hl-comment: #6e7781;
  --hl-title: #8250df;
  --hl-builtin: #953800;
  --hl-attr: #116329;

  --fig-1: #2f6fdb;
  --fig-2: #1f8a5b;
  --fig-3: #b7620c;
  --fig-4: #7b4fd1;
  --fig-5: #b03a6a;

  --font-body: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo',
    'Noto Sans KR', 'Malgun Gothic', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --measure: 780px;
  --gutter: 16px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #14161a;
    --bg-2: #1a1d22;
    --surface: #1d2026;
    --line: #2e333b;
    --line-soft: #252930;
    --text: #e6e8eb;
    --text-2: #b4bac3;
    --text-3: #868d98;
    --accent: #7aa7f0;
    --accent-soft: #1e2a3d;
    --accent-line: #34507d;

    --note: #7aa7f0;
    --note-bg: #1a2433;
    --tip: #5cc795;
    --tip-bg: #172a22;
    --warn: #e8a35a;
    --warn-bg: #2e2416;
    --key: #b495f0;
    --key-bg: #251f35;
    --quiz: #e981ad;
    --quiz-bg: #321c27;

    --code-bg: #191c21;
    --code-text: #d7dce2;
    --hl-keyword: #ff7b72;
    --hl-string: #a5d6ff;
    --hl-number: #79c0ff;
    --hl-comment: #8b949e;
    --hl-title: #d2a8ff;
    --hl-builtin: #ffa657;
    --hl-attr: #7ee787;

    --fig-1: #7aa7f0;
    --fig-2: #5cc795;
    --fig-3: #e8a35a;
    --fig-4: #b495f0;
    --fig-5: #e981ad;
    color-scheme: dark;
  }
}

:root[data-theme='dark'] {
  --bg: #14161a;
  --bg-2: #1a1d22;
  --surface: #1d2026;
  --line: #2e333b;
  --line-soft: #252930;
  --text: #e6e8eb;
  --text-2: #b4bac3;
  --text-3: #868d98;
  --accent: #7aa7f0;
  --accent-soft: #1e2a3d;
  --accent-line: #34507d;

  --note: #7aa7f0;
  --note-bg: #1a2433;
  --tip: #5cc795;
  --tip-bg: #172a22;
  --warn: #e8a35a;
  --warn-bg: #2e2416;
  --key: #b495f0;
  --key-bg: #251f35;
  --quiz: #e981ad;
  --quiz-bg: #321c27;

  --code-bg: #191c21;
  --code-text: #d7dce2;
  --hl-keyword: #ff7b72;
  --hl-string: #a5d6ff;
  --hl-number: #79c0ff;
  --hl-comment: #8b949e;
  --hl-title: #d2a8ff;
  --hl-builtin: #ffa657;
  --hl-attr: #7ee787;

  --fig-1: #7aa7f0;
  --fig-2: #5cc795;
  --fig-3: #e8a35a;
  --fig-4: #b495f0;
  --fig-5: #e981ad;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 72px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.8;
  letter-spacing: -0.003em;
  word-break: keep-all;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-underline-offset: 3px;
}

::selection {
  background: var(--accent-soft);
}

/* ── 머리 막대 ─────────────────────────────────────────── */

.wm-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.wm-bar-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 10px var(--gutter);
  font-size: 14px;
}

.wm-bar a {
  color: var(--text-2);
  text-decoration: none;
}

.wm-bar a:hover {
  color: var(--accent);
}

.wm-bar .wm-home {
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.wm-bar .wm-where {
  flex: 1;
  min-width: 0;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wm-bar button {
  font: inherit;
  font-size: 13px;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 10px;
  cursor: pointer;
}

.wm-bar button:hover {
  color: var(--accent);
  border-color: var(--accent-line);
}

.wm-progress {
  position: absolute;
  left: 0;
  bottom: -1px;
  height: 2px;
  width: 0;
  background: var(--accent);
}

/* ── 배치: 본문 + 오른쪽 목차 ──────────────────────────── */

.wm-layout {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 48px;
}

@media (min-width: 1180px) {
  .wm-layout {
    grid-template-columns: minmax(0, 1fr) 260px;
  }
}

.wm-toc {
  display: none;
}

@media (min-width: 1180px) {
  .wm-toc {
    display: block;
    position: sticky;
    top: 64px;
    align-self: start;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    padding: 28px 0 40px;
    font-size: 13.5px;
    line-height: 1.5;
  }
}

.wm-toc .wm-toc-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-3);
  margin-bottom: 10px;
}

.wm-toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
}

.wm-toc li a {
  display: block;
  padding: 4px 0 4px 12px;
  border-left: 2px solid var(--line);
  color: var(--text-3);
  text-decoration: none;
}

.wm-toc li.lv3 a {
  padding-left: 24px;
  font-size: 12.5px;
}

.wm-toc li a:hover {
  color: var(--text);
}

.wm-toc li a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}

/* 좁은 화면의 접는 목차 */
.wm-toc-inline {
  margin: 24px 0 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  padding: 4px 16px;
  font-size: 15px;
}

.wm-toc-inline summary {
  cursor: pointer;
  font-weight: 700;
  padding: 8px 0;
}

.wm-toc-inline ol {
  margin: 0 0 12px;
  padding-left: 20px;
  line-height: 1.7;
}

.wm-toc-inline li.lv3 {
  margin-left: 16px;
  list-style: circle;
  font-size: 14px;
}

@media (min-width: 1180px) {
  .wm-toc-inline {
    display: none;
  }
}

/* ── 본문 ─────────────────────────────────────────────── */

main.wm-main {
  min-width: 0;
  max-width: var(--measure);
  width: 100%;
  margin: 0 auto;
  padding: 36px 0 80px;
}

.wm-kicker {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.04em;
}

h1 {
  font-size: clamp(30px, 5vw, 42px);
  line-height: 1.25;
  letter-spacing: -0.02em;
  margin: 8px 0 16px;
}

.wm-lead {
  font-size: 19px;
  color: var(--text-2);
  margin: 0 0 20px;
}

.wm-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 8px;
  font-size: 13px;
}

.wm-meta span {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 2px 10px;
  color: var(--text-2);
}

h2 {
  font-size: 27px;
  line-height: 1.35;
  letter-spacing: -0.015em;
  margin: 64px 0 16px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

h3 {
  font-size: 21px;
  line-height: 1.4;
  margin: 40px 0 12px;
}

h4 {
  font-size: 18px;
  margin: 28px 0 8px;
}

h2 .wm-num,
h3 .wm-num {
  color: var(--text-3);
  font-weight: 600;
  margin-right: 6px;
}

p {
  margin: 0 0 16px;
}

ul,
ol {
  padding-left: 24px;
  margin: 0 0 16px;
}

li {
  margin: 4px 0;
}

strong {
  font-weight: 700;
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 40px 0;
}

/* 인라인 코드 */
:not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  padding: 1px 5px;
  word-break: break-all;
}

kbd {
  font-family: var(--font-mono);
  font-size: 0.82em;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 6px;
  background: var(--surface);
}

/* 표 */
.wm-table {
  width: 100%;
  overflow-x: auto;
  margin: 0 0 20px;
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 15px;
  line-height: 1.6;
}

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

thead th {
  background: var(--bg-2);
  font-weight: 700;
}

/* ── 수식 ─────────────────────────────────────────────── */

.katex {
  font-size: 1.08em;
}

.katex-display {
  margin: 14px 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 0;
}

/* 단계별 풀이: 수식 한 줄 + 왜 그런지 */
.derive {
  margin: 20px 0 24px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  overflow: hidden;
}

.derive > .derive-title {
  font-weight: 700;
  font-size: 15px;
  padding: 10px 18px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
}

.derive > .derive-title::before {
  content: '✎ 풀이 · ';
  color: var(--accent);
}

.derive .step {
  padding: 10px 18px 12px;
  border-bottom: 1px dashed var(--line);
}

.derive .step:last-child {
  border-bottom: 0;
}

.derive .step .katex-display {
  margin: 4px 0;
}

.derive .why {
  font-size: 15px;
  color: var(--text-2);
  line-height: 1.7;
}

.derive .why::before {
  content: '↳ ';
  color: var(--accent);
  font-weight: 700;
}

.derive .step.result {
  background: var(--accent-soft);
}

/* ── 상자 ─────────────────────────────────────────────── */

.box {
  --c: var(--note);
  --cb: var(--note-bg);
  margin: 20px 0;
  padding: 14px 18px;
  border-left: 4px solid var(--c);
  border-radius: 0 12px 12px 0;
  background: var(--cb);
}

.box > :last-child {
  margin-bottom: 0;
}

.box > .box-title {
  display: block;
  font-weight: 700;
  color: var(--c);
  margin-bottom: 6px;
}

.box.note {
  --c: var(--note);
  --cb: var(--note-bg);
}

.box.tip {
  --c: var(--tip);
  --cb: var(--tip-bg);
}

.box.warn {
  --c: var(--warn);
  --cb: var(--warn-bg);
}

.box.key {
  --c: var(--key);
  --cb: var(--key-bg);
}

.box.quiz {
  --c: var(--quiz);
  --cb: var(--quiz-bg);
}

.box.quiz details {
  margin-top: 8px;
}

.box.quiz summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--c);
}

.box.quiz details > div {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed color-mix(in srgb, var(--c) 40%, transparent);
}

/* 이 장에서 배우는 것 */
.goals {
  margin: 20px 0 8px;
  padding: 16px 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.goals .box-title {
  font-weight: 700;
  margin-bottom: 6px;
  display: block;
}

.goals ul {
  margin: 0;
}

/* 비유 */
.analogy {
  margin: 20px 0;
  padding: 16px 20px;
  border-radius: 14px;
  background: var(--bg-2);
  font-size: 16px;
}

.analogy::before {
  content: '비유로 이해하기';
  display: block;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--text-3);
  margin-bottom: 4px;
}

/* ── 코드 ─────────────────────────────────────────────── */

.code {
  margin: 18px 0 22px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--code-bg);
  overflow: hidden;
}

.code-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px 14px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-3);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--code-bg) 70%, var(--bg-2));
}

.code-head .code-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.code-head a {
  color: var(--text-3);
}

.code-head button {
  font: inherit;
  font-size: 12px;
  color: var(--text-2);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 8px;
  cursor: pointer;
}

.code-head button:hover {
  color: var(--accent);
  border-color: var(--accent-line);
}

pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--code-text);
  tab-size: 4;
}

pre code {
  font-family: inherit;
  background: none;
  border: 0;
  padding: 0;
}

pre.loading {
  color: var(--text-3);
  font-style: italic;
}

.code.collapsed pre {
  max-height: 420px;
  overflow: auto;
}

/* highlight.js 토큰 색 (테마 토큰으로) */
.hljs-keyword,
.hljs-selector-tag,
.hljs-meta .hljs-keyword {
  color: var(--hl-keyword);
}

.hljs-string,
.hljs-regexp {
  color: var(--hl-string);
}

.hljs-number,
.hljs-literal {
  color: var(--hl-number);
}

.hljs-comment,
.hljs-quote {
  color: var(--hl-comment);
  font-style: italic;
}

.hljs-title,
.hljs-title.function_,
.hljs-title.class_ {
  color: var(--hl-title);
}

.hljs-built_in,
.hljs-type {
  color: var(--hl-builtin);
}

.hljs-attr,
.hljs-variable,
.hljs-params,
.hljs-meta {
  color: var(--hl-attr);
}

/* 실행 결과 */
.output {
  margin: -10px 0 22px;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 12px 12px;
  background: var(--surface);
}

.output::before {
  content: '실행 결과';
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-3);
  padding: 8px 16px 0;
}

.output pre {
  font-size: 12.5px;
  color: var(--text-2);
  padding-top: 4px;
}

/* ── 그림 ─────────────────────────────────────────────── */

figure {
  margin: 24px 0 28px;
}

figure img,
figure svg {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

figure img {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

figure.diagram svg {
  color: var(--text);
  font-family: var(--font-body);
}

figcaption {
  margin-top: 10px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-3);
  text-align: center;
}

figcaption b {
  color: var(--text-2);
}

/* SVG 도표에서 쓰는 공통 클래스 */
svg .f-line {
  stroke: currentColor;
  fill: none;
}

svg .f-box {
  fill: var(--surface);
  stroke: var(--line);
}

svg .f-text {
  fill: currentColor;
}

svg .f-muted {
  fill: var(--text-3);
}

svg .f-c1 {
  stroke: var(--fig-1);
}

svg .f-c2 {
  stroke: var(--fig-2);
}

svg .f-c3 {
  stroke: var(--fig-3);
}

svg .f-c4 {
  stroke: var(--fig-4);
}

svg .f-c5 {
  stroke: var(--fig-5);
}

svg .f-fill1 {
  fill: var(--fig-1);
}

svg .f-fill2 {
  fill: var(--fig-2);
}

svg .f-fill3 {
  fill: var(--fig-3);
}

svg .f-fill4 {
  fill: var(--fig-4);
}

svg .f-fill5 {
  fill: var(--fig-5);
}

/* ── 작은 상호작용 데모 ───────────────────────────────── */

.demo {
  margin: 22px 0 26px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.demo .demo-title {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 10px;
}

.demo .demo-title::before {
  content: '▶ 직접 해 보기 · ';
  color: var(--tip);
}

.demo label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  margin: 6px 0;
  flex-wrap: wrap;
}

.demo input[type='range'] {
  flex: 1;
  min-width: 140px;
  accent-color: var(--accent);
}

.demo output,
.demo .val {
  font-family: var(--font-mono);
  font-size: 13px;
  min-width: 56px;
  color: var(--text-2);
}

.demo canvas {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--bg);
}

.demo button {
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 12px;
  cursor: pointer;
}

/* ── 장 이동 ──────────────────────────────────────────── */

.wm-pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 64px;
}

.wm-pager a {
  display: block;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  text-decoration: none;
  color: var(--text);
  line-height: 1.45;
}

.wm-pager a:hover {
  border-color: var(--accent-line);
}

.wm-pager a small {
  display: block;
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 2px;
}

.wm-pager a.next {
  text-align: right;
  grid-column: 2;
}

/* 전체 장 목록 (시작 페이지 등) */
.wm-chapters {
  list-style: none;
  padding: 0;
  margin: 16px 0 24px;
  display: grid;
  gap: 8px;
}

.wm-chapters li {
  margin: 0;
}

.wm-chapters a {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 4px 12px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  text-decoration: none;
  color: var(--text);
}

.wm-chapters a:hover {
  border-color: var(--accent-line);
}

.wm-chapters .no {
  grid-row: span 2;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 18px;
  color: var(--accent);
}

.wm-chapters .t {
  font-weight: 700;
}

.wm-chapters .d {
  font-size: 14px;
  color: var(--text-3);
  line-height: 1.55;
}

.wm-chapters a.current {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* 용어 첫 등장 */
.term {
  font-weight: 700;
}

.term .en {
  font-weight: 400;
  color: var(--text-3);
  font-size: 0.9em;
  margin-left: 2px;
}

/* 용어 · 수식 설명 팝업 (glossary.js) */
.gl-term {
  cursor: help;
  text-decoration: underline dotted var(--accent-line);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
  border-radius: 3px;
  transition: background-color 0.12s;
}

.gl-term:hover,
.gl-term[aria-expanded='true'] {
  text-decoration-color: var(--accent);
  background: var(--accent-soft);
}

.gl-term:focus-visible,
.gl-math:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.gl-math {
  cursor: help;
  border-radius: 4px;
  transition: background-color 0.12s, box-shadow 0.12s;
}

.gl-math:hover,
.gl-math[aria-expanded='true'] {
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.gl-pop {
  position: absolute;
  z-index: 40;
  width: min(26rem, calc(100vw - 32px));
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.16), 0 2px 6px rgba(0, 0, 0, 0.08);
  font-size: 14.5px;
  line-height: 1.65;
  outline: none;
  animation: gl-in 0.14s ease-out;
}

.gl-pop[hidden] {
  display: none !important;
}

@keyframes gl-in {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }
}

@media (prefers-reduced-motion: reduce) {
  .gl-pop {
    animation: none;
  }
}

.gl-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
}

.gl-head {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.gl-back {
  align-self: flex-start;
  margin-left: -6px;
  padding: 2px 8px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--text-3);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}

.gl-back:hover {
  background: var(--bg-2);
  color: var(--text);
}

.gl-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.gl-pop h3.gl-title {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 17px;
  line-height: 1.35;
  font-weight: 700;
}

.gl-badge {
  flex-shrink: 0;
  padding: 1px 9px;
  border-radius: 999px;
  background: var(--bg-2);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.gl-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.gl-chip {
  padding: 1px 9px;
  border-radius: 999px;
  background: var(--bg-2);
  color: var(--text-3);
  font-size: 12px;
}

.gl-formula {
  overflow-x: auto;
  padding: 2px 10px;
  border-radius: 8px;
  background: var(--bg-2);
}

.gl-formula .katex-display {
  margin: 8px 0;
}

.gl-pop p {
  margin: 0;
}

.gl-summary {
  font-weight: 600;
}

.gl-sec {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.gl-pop h4 {
  margin: 0;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-3);
}

.gl-links {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.gl-link {
  color: var(--accent);
  text-decoration: none;
}

.gl-link:hover {
  text-decoration: underline;
}

.gl-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.gl-rel {
  padding: 1px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font: inherit;
  font-size: 12.5px;
  line-height: 1.7;
  cursor: pointer;
}

.gl-rel:hover {
  border-color: var(--accent-line);
  color: var(--accent);
}

.gl-rel-inline {
  padding: 0 8px;
  font-size: 12px;
  vertical-align: 1px;
}

.gl-syms {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 14px;
  margin: 0;
}

.gl-sym {
  display: contents;
}

.gl-syms dt {
  justify-self: center;
  font-size: 1.08em;
  white-space: nowrap;
}

.gl-syms dd {
  margin: 0;
  color: var(--text-2);
}

/* 작은 화면 */
@media (max-width: 640px) {
  body {
    font-size: 16px;
  }

  h2 {
    font-size: 23px;
  }

  h3 {
    font-size: 19px;
  }

  .wm-lead {
    font-size: 17px;
  }

  .derive .step {
    padding: 8px 12px 10px;
  }

  pre {
    font-size: 12.5px;
  }

  .wm-pager {
    grid-template-columns: 1fr;
  }

  .wm-pager a.next {
    grid-column: 1;
  }
}

/* 인쇄 (쪽 규칙은 Word 내보내기가 서식으로 오해하지 않도록 넣지 않는다) */
@media print {
  .wm-bar,
  .wm-toc,
  .wm-toc-inline,
  .wm-pager,
  .code-head button,
  .gl-pop {
    display: none !important;
  }

  .gl-term {
    text-decoration: none;
    background: none;
  }

  body {
    background: #fff;
    color: #000;
    font-size: 11pt;
  }

  main.wm-main {
    max-width: none;
    padding: 0;
  }

  .code.collapsed pre {
    max-height: none;
  }

  h2,
  h3 {
    break-after: avoid;
  }

  .derive,
  figure,
  .box {
    break-inside: avoid;
  }
}
