/* math-ai-matrix 공용 토큰과 컴포넌트 (2026-10-07 개편, 정본: 이 파일)
   기준: APPLE_DESIGN.md (한국어 사이트에 맞춰 조정), SPEC.md 2절
   - 강조색은 Action Blue 하나. 링크·포커스용(--link)과 버튼 바탕용(--btn-bg)을 나눠
     어두운 면에서는 링크만 Sky Blue(#2997ff)로 바꾸고 버튼 바탕은 #0066cc를 유지한다.
   - 도메인 색은 .dot / .tag 안에서만 쓴다.
   - 그림자·장식 그라데이션 없음. 면 색이 바뀌는 것이 구분선이다. */

/* ---------- 1. 토큰 ---------- */
:root {
  color-scheme: light;

  /* 면 */
  --bg: #ffffff;            /* canvas */
  --bg-alt: #f5f5f7;        /* canvas-parchment */
  --tile: #272729;          /* surface-tile-1 */
  --tile-2: #2a2a2c;        /* surface-tile-2 */
  --nav-bg: #000000;        /* surface-black, 전역 메뉴 전용 */
  --nav-panel: #161617;

  /* 글자 */
  --ink: #1d1d1f;
  --ink-2: #6e6e73;         /* 보조 글자. #7a7a7a는 흰 바탕 4.3:1이라 한 단계 진하게 */
  --on-dark: #f5f5f7;
  --on-dark-2: #a1a1a6;

  /* 강조색 (하나) */
  --link: #0066cc;          /* primary: 링크·포커스 */
  --link-on-dark: #2997ff;  /* primary-on-dark: 어두운 면의 링크·포커스 */
  --focus: #0071e3;         /* primary-focus */
  --btn-bg: #0066cc;        /* 버튼 바탕은 두 테마 모두 이 값 */
  --btn-ink: #ffffff;

  /* 선과 카드 */
  --hairline: #d2d2d7;
  --card-on-bg: #f5f5f7;    /* 흰 면 위 카드 */
  --card-on-alt: #ffffff;   /* 회백 면 위 카드 */
  --card-on-tile: #1d1d1f;  /* 어두운 타일 위 카드: 타일보다 한 단계 어둡게(링크 대비 5.6:1) */
  --hairline-soft: #e8e8ed; /* 표 안쪽 같은 약한 선 */
  --link-bg: #e8f1fb;       /* 강조색의 옅은 바탕(빈칸·강조 표시) */

  /* 도메인 점 색 (product 페이지 대분류 12개, 기존 값 유지) */
  --c-pd-a: #2f6a7d; --c-pd-b: #6a5a2f; --c-pd-c: #7d2f4f; --c-pd-d: #3f7d2f;
  --c-pd-e: #a1327d; --c-pd-f: #2f4a7d; --c-pd-g: #7d5a2f; --c-pd-h: #4a2f7d;
  --c-pd-i: #2f7d5e; --c-pd-j: #a15332; --c-pd-k: #7d2f2f; --c-pd-l: #4f5d7d;
  /* 수학 도메인 점 색 (개념 뷰어) */
  --c-prob: #2f5a8f;

  /* 글꼴 */
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, system-ui,
    "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* 글자 크기 (APPLE_DESIGN typography를 한글에 맞춰 조정) */
  --fs-hero: clamp(34px, 6.2vw, 56px);
  --fs-display: clamp(28px, 4.4vw, 40px);
  --fs-lead: clamp(19px, 2.4vw, 24px);
  --fs-tagline: 21px;
  --fs-body: 17px;
  --fs-caption: 14px;
  --fs-fine: 12px;
  --fs-nav: 13px;

  /* 간격 */
  --sp-xxs: 4px; --sp-xs: 8px; --sp-sm: 12px; --sp-md: 17px; --sp-lg: 24px;
  --sp-xl: 32px; --sp-xxl: 48px; --sp-section: 80px;

  /* 모서리 */
  --r-sm: 8px; --r-md: 11px; --r-lg: 18px; --r-pill: 9999px;

  --nav-h: 48px;
  --wrap: 980px;
  --wrap-wide: 1200px;
}

/* 다크: 시스템 설정(사용자가 라이트를 고르지 않았을 때) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #000000; --bg-alt: #161617; --tile: #272729; --tile-2: #2a2a2c;
    --nav-panel: #1d1d1f;
    --ink: #f5f5f7; --ink-2: #a1a1a6;
    --link: #2997ff; --focus: #2997ff;
    --hairline: #424245; --hairline-soft: #2c2c2e; --link-bg: #0d2440;
    --card-on-bg: #1c1c1e; --card-on-alt: #232325; --card-on-tile: #1d1d1f;
    --c-pd-a: #7ec0d4; --c-pd-b: #c9b06e; --c-pd-c: #d47ea1; --c-pd-d: #8fc46e;
    --c-pd-e: #d98fc4; --c-pd-f: #7e9ad4; --c-pd-g: #d4ab6e; --c-pd-h: #9a7ed4;
    --c-pd-i: #7ed4ac; --c-pd-j: #d99a7e; --c-pd-k: #d47e7e; --c-pd-l: #9ab0d4;
    --c-prob: #7ea6d9;
  }
}
/* 다크: 토글로 고정 */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000; --bg-alt: #161617; --tile: #272729; --tile-2: #2a2a2c;
  --nav-panel: #1d1d1f;
  --ink: #f5f5f7; --ink-2: #a1a1a6;
  --link: #2997ff; --focus: #2997ff;
  --hairline: #424245; --hairline-soft: #2c2c2e; --link-bg: #0d2440;
  --card-on-bg: #1c1c1e; --card-on-alt: #232325; --card-on-tile: #1d1d1f;
  --c-pd-a: #7ec0d4; --c-pd-b: #c9b06e; --c-pd-c: #d47ea1; --c-pd-d: #8fc46e;
  --c-pd-e: #d98fc4; --c-pd-f: #7e9ad4; --c-pd-g: #d4ab6e; --c-pd-h: #9a7ed4;
  --c-pd-i: #7ed4ac; --c-pd-j: #d99a7e; --c-pd-k: #d47e7e; --c-pd-l: #9ab0d4;
  --c-prob: #7ea6d9;
}

/* ---------- 2. 바탕 ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: 1.47;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;          /* 한글은 어절 단위로 줄바꿈 */
  overflow-wrap: anywhere;       /* 긴 영문 이름이 칸을 넘지 않게 */
}
img, svg { max-width: 100%; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 4px; }
h1, h2, h3 { text-wrap: balance; margin: 0; }
p { margin: 0; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  background: var(--btn-bg); color: var(--btn-ink); padding: 10px 18px; border-radius: var(--r-pill);
  font-size: var(--fs-caption);
}
.skip-link:focus { top: 8px; }

/* ---------- 3. 섹션 타일 (full-bleed, 모서리 없음) ---------- */
.tile { padding: var(--sp-section) 0; background: var(--bg); color: var(--ink); --card-bg: var(--card-on-bg); }
.tile--alt { background: var(--bg-alt); --card-bg: var(--card-on-alt); }
.tile--dark, .tile--dark-2 {
  background: var(--tile); color: var(--on-dark);
  --ink: var(--on-dark); --ink-2: var(--on-dark-2);
  --link: var(--link-on-dark); --focus: var(--link-on-dark);
  --hairline: #48484a; --card-bg: var(--card-on-tile);
}
.tile--dark-2 { background: var(--tile-2); }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 22px; }
.wrap--wide { max-width: var(--wrap-wide); }
.center { text-align: center; }

/* ---------- 4. 글자 ---------- */
.t-hero { font-size: var(--fs-hero); font-weight: 700; line-height: 1.14; letter-spacing: -0.025em; }
.t-display { font-size: var(--fs-display); font-weight: 700; line-height: 1.2; letter-spacing: -0.02em; }
.t-lead { font-size: var(--fs-lead); font-weight: 400; line-height: 1.45; letter-spacing: -0.012em; color: var(--ink-2); }
.t-tagline { font-size: var(--fs-tagline); font-weight: 600; line-height: 1.33; letter-spacing: -0.012em; }
.t-caption { font-size: var(--fs-caption); line-height: 1.45; color: var(--ink-2); }
.t-fine { font-size: var(--fs-fine); line-height: 1.5; color: var(--ink-2); letter-spacing: 0; }
.kicker { font-size: var(--fs-caption); font-weight: 600; color: var(--ink-2); letter-spacing: 0; margin-bottom: var(--sp-xs); }
.prose { max-width: 680px; line-height: 1.7; }   /* 긴 한글 읽기는 1.47보다 넉넉하게 */
.prose p + p { margin-top: 1em; }
.prose h2 { font-size: var(--fs-tagline); font-weight: 700; line-height: 1.33; margin: 2em 0 0.6em; letter-spacing: -0.015em; }

/* ---------- 5. pill 버튼 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 11px 22px; border-radius: var(--r-pill);
  font: inherit; font-size: var(--fs-body); line-height: 1; letter-spacing: -0.01em;
  border: 1px solid transparent; cursor: pointer; text-decoration: none;
  transition: transform 0.12s ease;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(0.95); }
.btn--primary { background: var(--btn-bg); color: var(--btn-ink); }
.btn--ghost { background: transparent; color: var(--link); border-color: var(--link); }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--sp-sm); }
.center .btn-row { justify-content: center; }
@media (prefers-reduced-motion: reduce) { .btn { transition: none; } .btn:active { transform: none; } }

/* 작은 pill 링크 (점프 링크, 트랙 등) */
.pill {
  display: inline-flex; align-items: center; gap: 8px; min-height: 36px;
  padding: 7px 15px; border-radius: var(--r-pill);
  background: var(--card-bg); color: var(--ink); font-size: var(--fs-caption);
  border: 1px solid var(--hairline); text-decoration: none; transition: transform 0.12s ease;
}
.pill:hover { text-decoration: none; border-color: var(--ink-2); }
.pill:active { transform: scale(0.95); }
.pill-row { display: flex; flex-wrap: wrap; gap: var(--sp-xs); }

/* ---------- 6. 점과 태그 ---------- */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--dot, var(--ink-2)); }
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: var(--r-pill);
  font-size: var(--fs-fine); font-weight: 600; letter-spacing: 0; line-height: 1.4;
  color: var(--ink-2); border: 1px solid var(--hairline); white-space: nowrap;
}
.tag--link { color: var(--link); border-color: currentColor; }

/* ---------- 7. 카드 (18px, 그림자 없음) ---------- */
.card {
  display: block; background: var(--card-bg); color: var(--ink);
  border-radius: var(--r-lg); padding: var(--sp-lg);
  border: 1px solid transparent;
}
a.card { text-decoration: none; transition: transform 0.12s ease; }
a.card:hover { border-color: var(--hairline); text-decoration: none; }
a.card:hover .card__title { color: var(--link); }
a.card:active { transform: scale(0.98); }
.card__title { font-size: var(--fs-body); font-weight: 600; line-height: 1.35; letter-spacing: -0.012em; }
.card__desc { margin-top: 4px; font-size: var(--fs-caption); line-height: 1.5; color: var(--ink-2); }
.card__meta { margin-top: var(--sp-sm); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.card--muted { background: transparent; border: 1px dashed var(--hairline); }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); }
.grid--2 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }

/* ---------- 8. 그룹 경로 ---------- */
.crumbs ol { list-style: none; margin: 0 0 var(--sp-md); padding: 0; display: flex; flex-wrap: wrap; gap: 4px 8px; font-size: var(--fs-caption); color: var(--ink-2); }
.crumbs li { display: inline-flex; align-items: center; gap: 8px; }
.crumbs li + li::before { content: "›"; color: var(--ink-2); }
.crumbs a { color: var(--ink-2); }
.crumbs a:hover { color: var(--link); }
.crumbs [aria-current="page"] { color: var(--ink); font-weight: 600; }

/* ---------- 9. 전역 메뉴 (검은 띠) ---------- */
.gnav {
  position: sticky; top: 0; z-index: 50;
  background: var(--nav-bg); color: #f5f5f7;
  font-size: var(--fs-nav); letter-spacing: 0;
  --link: #2997ff; --focus: #2997ff;
}
.gnav__bar {
  max-width: var(--wrap-wide); margin: 0 auto; height: var(--nav-h);
  display: flex; align-items: center; gap: 4px; padding: 0 12px;
}
.gnav__brand {
  color: #f5f5f7; font-weight: 700; font-size: 15px; letter-spacing: -0.01em;
  padding: 8px 10px; margin-right: 8px; white-space: nowrap;
}
.gnav__brand:hover { text-decoration: none; color: #fff; }
.gnav__menu { flex: 1; min-width: 0; }
.gnav__groups { list-style: none; margin: 0; padding: 0; display: flex; justify-content: center; gap: 2px; }
.gnav__trigger {
  font: inherit; font-size: var(--fs-nav); color: #d2d2d7; background: none; border: 0;
  height: var(--nav-h); padding: 0 14px; cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
}
.gnav__trigger:hover, .gnav__trigger[aria-expanded="true"] { color: #fff; }
.gnav__trigger.is-current { color: #fff; font-weight: 600; }
.gnav__trigger.is-current::after { content: ""; width: 4px; height: 4px; border-radius: 50%; background: #f5f5f7; }
.gnav__chev { display: none; }
.gnav__tools { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.gnav__theme, .gnav__burger {
  font: inherit; font-size: var(--fs-nav); color: #d2d2d7; background: none; border: 0; cursor: pointer;
  min-height: 44px; min-width: 44px; padding: 0 10px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: var(--r-sm); transition: transform 0.12s ease;
}
.gnav__theme:hover, .gnav__burger:hover { color: #fff; }
.gnav__theme:active, .gnav__burger:active { transform: scale(0.95); }
.gnav__burger { display: none; }
.gnav__theme svg, .gnav__burger svg { width: 18px; height: 18px; }

/* 펼침 판: 데스크톱에서는 띠 아래 전체 폭 */
.gnav__panel {
  position: absolute; left: 0; right: 0; top: var(--nav-h);
  background: var(--nav-panel); color: #f5f5f7;
  border-top: 1px solid #2c2c2e;
}
.gnav:not(.gnav--ready) .gnav__panel { display: none; }
.gnav:not(.gnav--ready) .gnav__group:hover .gnav__panel,
.gnav:not(.gnav--ready) .gnav__group:focus-within .gnav__panel { display: block; } /* JS가 없을 때의 대비책 */
.gnav__panel-inner {
  max-width: var(--wrap); margin: 0 auto; padding: 32px 22px 40px;
  display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr); gap: 32px;
}
.gnav__lead { font-size: 24px; font-weight: 700; line-height: 1.3; letter-spacing: -0.02em; color: #f5f5f7; }
.gnav__lead-desc { margin-top: 8px; font-size: var(--fs-caption); line-height: 1.5; color: #a1a1a6; }
.gnav__col-title { font-size: 12px; color: #a1a1a6; margin-bottom: 10px; }
.gnav__list { list-style: none; margin: 0; padding: 0; }
.gnav__list a {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  color: #f5f5f7; font-size: 17px; font-weight: 600; line-height: 1.35; padding: 6px 0;
}
.gnav__list a:hover { color: #fff; text-decoration: underline; }
.gnav__list a[aria-current="page"] { color: #2997ff; }
.gnav__list .gnav__soon { font-size: 11px; font-weight: 600; color: #a1a1a6; border: 1px solid #48484a; border-radius: var(--r-pill); padding: 1px 8px; }
.gnav__more { display: inline-block; margin-top: 14px; font-size: var(--fs-caption); color: #2997ff; }
.gnav__empty { font-size: var(--fs-caption); color: #a1a1a6; }

/* 모바일: 접힌 메뉴 */
@media (max-width: 833px) {
  .gnav__burger { display: inline-flex; order: 3; }
  .gnav__tools { order: 2; }
  .gnav__menu {
    position: absolute; left: 0; right: 0; top: var(--nav-h);
    max-height: calc(100vh - var(--nav-h)); max-height: calc(100dvh - var(--nav-h)); overflow-y: auto;
    background: var(--nav-bg); padding: 8px 0 24px; border-top: 1px solid #2c2c2e;
  }
  .gnav--ready .gnav__menu:not(.is-open) { display: none; }
  .gnav:not(.gnav--ready) .gnav__menu { position: static; padding: 0; display: none; }
  .gnav__groups { flex-direction: column; gap: 0; max-width: var(--wrap); margin: 0 auto; }
  .gnav__trigger {
    width: 100%; justify-content: space-between; height: auto; min-height: 52px; padding: 0 22px;
    font-size: 21px; font-weight: 600; color: #f5f5f7; letter-spacing: -0.012em;
  }
  .gnav__trigger.is-current::after { display: none; }
  .gnav__chev { display: inline-block; width: 14px; height: 14px; transition: transform 0.2s ease; }
  .gnav__trigger[aria-expanded="true"] .gnav__chev { transform: rotate(180deg); }
  .gnav__panel { position: static; border-top: 0; background: transparent; }
  .gnav__panel-inner { grid-template-columns: 1fr; gap: 16px; padding: 4px 22px 18px 34px; }
  .gnav__lead { display: none; }
  .gnav__lead-desc { margin-top: 0; }
}
@media (prefers-reduced-motion: reduce) { .gnav__chev { transition: none; } }

/* ---------- 10. 푸터 ---------- */
.site-footer { background: var(--bg-alt); color: var(--ink-2); padding: 48px 0 64px; font-size: var(--fs-fine); line-height: 1.47; }
.site-footer__inner { max-width: var(--wrap-wide); margin: 0 auto; padding: 0 22px; }
@media (max-width: 419px) { .site-footer__inner { padding: 0 16px; } }
.site-footer__cols { display: grid; gap: 24px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr)); margin-bottom: 32px; }
.site-footer h2 { font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li a { color: var(--ink-2); font-size: 13px; line-height: 2.2; }
.site-footer li a:hover { color: var(--link); }
.site-footer__legal a { color: var(--ink-2); }
.site-footer__legal { border-top: 1px solid var(--hairline); padding-top: 16px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }

/* ---------- 11. 반응형 ---------- */
@media (max-width: 734px) {
  .tile { padding: 56px 0; }
}
@media (max-width: 419px) {
  .tile { padding: 48px 0; }
  .wrap { padding: 0 16px; }
  .card { padding: 20px; }
}

/* ---------- 12. 페이지 보조 메뉴 (반투명 띠, 전역 메뉴 아래에 붙음) ---------- */
:root { --subnav-bg: rgba(255, 255, 255, 0.78); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --subnav-bg: rgba(22, 22, 23, 0.78); } }
:root[data-theme="dark"] { --subnav-bg: rgba(22, 22, 23, 0.78); }
.subnav {
  position: sticky; top: var(--nav-h); z-index: 40;
  background: var(--subnav-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--hairline);
}
.subnav__inner { max-width: var(--wrap-wide); margin: 0 auto; padding: 0 22px; min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.subnav__title { font-size: 19px; font-weight: 700; letter-spacing: -0.015em; line-height: 1.25; color: var(--ink); min-width: 0; }
.subnav__links { display: flex; align-items: center; gap: 14px; font-size: var(--fs-caption); flex: none; }
.btn--sm { min-height: 32px; padding: 6px 14px; font-size: var(--fs-caption); }
@media (max-width: 560px) { .subnav__title { font-size: 16px; } .subnav__links .hide-sm { display: none; } }

/* ---------- 13. 기존 페이지 호환 ---------- */
/* 기존 페이지(개념 뷰어, 학습 트랙 장, 매트릭스 페이지)가 쓰던 색·글꼴 이름을 새 토큰에 잇는다.
   각 페이지 <style>에서 이 이름들의 값 선언은 지웠고, 여기서 한 번만 정한다.
   site.css 안에 두고, 페이지 <style>보다 먼저 읽히므로 덮어써야 하는 규칙은 html을 붙여 우선순위를 높인다. 도메인 색(--c-*)은 페이지에 그대로 남아 있다. */
:root {
  --paper: var(--bg);
  --surface: var(--bg-alt);
  --surface-2: var(--card-on-alt);
  --ink-dim: var(--ink-2);
  --ink-faint: var(--ink-2);
  --line: var(--hairline);
  --line-soft: var(--hairline-soft);
  --highlight: var(--link);
  --highlight-bg: var(--link-bg);
  --font-kr: var(--font);
}

/* 전역 메뉴 아래에서 제목으로 바로 건너뛸 때 띠에 가리지 않게 */
[id] { scroll-margin-top: calc(var(--nav-h) + 16px); }

/* 기존 페이지 상단의 그룹 경로 */
.page-crumbs { margin-bottom: 18px; }
.page-crumbs ol { margin-bottom: 0; }

/* 장·뷰어 상단: 그룹 경로와 돌아가기 링크 */
.topbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin: 0 0 18px; }
.topbar .crumbs ol { margin: 0; }

/* 문서가 여러 형식으로 보일 때 현재 페이지의 역할을 먼저 알려 준다. */
.content-role {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  margin: 0 0 18px; padding: 12px 14px; border: 1px solid var(--hairline-soft);
  border-radius: var(--r-md); background: var(--bg-alt); color: var(--ink-2);
}
.content-role__copy { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 0; font-size: 13.5px; line-height: 1.55; }
.content-role__badge {
  display: inline-flex; align-items: center; min-height: 26px; padding: 3px 9px;
  border-radius: var(--r-pill); background: var(--link-bg); color: var(--link); font-size: 12px; font-weight: 700;
}
.content-role__links { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px 12px; flex: none; }
.content-role__links a { color: var(--link); font-size: 13px; font-weight: 600; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.content-role__links .content-role__practice {
  display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 3px 10px;
  border: 1px solid var(--ink); border-radius: var(--r-pill); background: var(--ink); color: var(--bg);
  text-decoration: none;
}
.content-role__practice:hover { opacity: .78; }
.content-role__practice:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.content-role__github-mark { width: 17px; height: 17px; flex: none; }
.gnav__repo {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 10px;
  border-radius: var(--r-pill); color: var(--ink); font-size: 12.5px; font-weight: 700; text-decoration: none;
}
.gnav__repo:hover { background: var(--surface); text-decoration: none; }
.gnav__repo:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.gnav__repo svg { width: 19px; height: 19px; flex: none; }
@media (max-width: 680px) {
  .content-role { align-items: flex-start; flex-direction: column; }
  .content-role__links { justify-content: flex-start; }
  .gnav__repo span { display: none; }
  .gnav__repo { min-width: 44px; justify-content: center; padding: 0; }
}

/* 한글 라벨은 고정폭 글꼴 대신 본문 글꼴로(고정폭에 한글이 없어 글자 사이가 벌어진다). 코드·입력 칸은 그대로 고정폭. */
html .back-link,
html .domain-tag,
html .example-label,
html .eyebrow,
html .box-label,
html .def-term,
html .related-label,
html .step-num,
html .series-kicker,
html .proof-progress-label,
html .publication-status,
html .publication-version,
html .publication-date,
html .publication-journey,
html .publication-meta-row,
html .card-item .k,
html .reveal-btn,
html .attempt-hint,
html .check-label,
html main h2 .step {
  font-family: var(--font);
  letter-spacing: 0;
  text-transform: none;
}
html .back-link { font-size: var(--fs-caption); color: var(--ink-2); }

/* ---------- 14. 매트릭스 페이지 ---------- */
/* 매트릭스 페이지 공용 스타일. site.css 토큰만 쓴다.
   페이지 구조: main.mx-page > section.tile(page-hero | mx-block | page-meta) > .wrap
   도메인 색은 카드·칩의 작은 점(--chip-c)과 범례 점에만 쓴다. */

/* ---------- 머리말 ---------- */
.mx-page .page-hero { padding-top: 56px; padding-bottom: 56px; }
.mx-page .page-hero h1 {
  font-size: clamp(32px, 5.4vw, 48px); font-weight: 700; line-height: 1.16; letter-spacing: -0.025em;
  margin: 0 0 16px;
}
.mx-page .page-hero h1 em { font-style: normal; }
.mx-page .lede {
  max-width: 760px; margin: 0 0 20px;
  font-size: var(--fs-lead); line-height: 1.5; letter-spacing: -0.012em; color: var(--ink-2);
}
.mx-page .lede a, .mx-page .source-note a, .mx-page .hint a { color: var(--link); }
/* 트랙 장 페이지는 .mx-page가 없고 도입 문단 크기를 각 페이지의 인라인 style이 정하므로 선택자에 .mx-page를 붙이지 않는다.
   "짧은 답"으로 시작하는 장 도입은 훑는 독자와 검색 착지용 요약이라, 본문보다 작고 보조색으로 둔다.
   색은 --ink-2를 그대로 쓴다(더 옅게 하면 흰 바탕 4.5:1 아래로 내려간다). :has()를 모르는 브라우저는 예전 크기로 보인다. */
.lede:has(> strong:first-child) { font-size: 15px; line-height: 1.65; letter-spacing: 0; margin-bottom: 24px; }
.lede:has(> strong:first-child) > strong:first-child { font-weight: 600; margin-right: 4px; }
.mx-page .source-note {
  max-width: 760px; margin: 0 0 20px;
  font-size: var(--fs-caption); line-height: 1.6; color: var(--ink-2);
}
.mx-page .source-note strong { color: var(--ink); font-weight: 600; margin-right: 4px; }
.mx-page .legend { display: flex; flex-wrap: wrap; gap: var(--sp-xs); margin: 24px 0 16px; }
.mx-page .legend-item {
  display: inline-flex; align-items: center; gap: 8px; min-height: 34px;
  padding: 6px 14px; border-radius: var(--r-pill);
  background: var(--card-bg); border: 1px solid var(--hairline);
  font-size: var(--fs-caption); color: var(--ink);
}
.mx-page .legend-item .dot, .mx-page .group-title .dot, .mx-page .axis-item .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.mx-page .hint {
  display: block; margin: 8px 0 0; max-width: 760px;
  font-size: var(--fs-caption); line-height: 1.5; color: var(--ink-2);
}
.mx-page .hint svg { display: inline-block; vertical-align: -2px; margin-right: 6px; opacity: 0.8; }

/* ---------- 대분류 · 중분류 · 카드 ---------- */
.mx-page .group-title {
  display: flex; align-items: center; gap: 12px; margin: 0;
  font-size: clamp(24px, 3.2vw, 32px); font-weight: 700; letter-spacing: -0.02em; line-height: 1.25; color: var(--ink);
}
.mx-page .group-title .dot { width: 10px; height: 10px; }
.mx-page .group-desc { margin: 10px 0 0; max-width: 720px; color: var(--ink-2); font-size: var(--fs-body); line-height: 1.5; }
.mx-page .sub-block { margin-top: 32px; }
.mx-page .sub-title { margin: 0 0 12px; font-size: var(--fs-caption); font-weight: 600; color: var(--ink-2); letter-spacing: 0; }
.mx-page .chip-row { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); }
.mx-page .chip-card {
  display: block; position: relative;
  background: var(--card-bg); color: var(--ink);
  border: 1px solid transparent; border-radius: var(--r-lg);
  padding: 20px 22px 22px;
  text-decoration: none; transition: transform 0.12s ease;
}
.mx-page a.chip-card:hover { border-color: var(--hairline); text-decoration: none; }
.mx-page a.chip-card:hover .name { color: var(--link); }
.mx-page a.chip-card:active { transform: scale(0.98); }
.mx-page .chip-card .name {
  display: flex; align-items: baseline; gap: 8px; margin: 0;
  font-size: var(--fs-body); font-weight: 600; line-height: 1.35; letter-spacing: -0.012em;
}
.mx-page .chip-card .name::before {
  content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%;
  background: var(--chip-c, var(--ink-2)); transform: translateY(-1px);
}
.mx-page .chip-card .formula { margin: 6px 0 0; font-size: var(--fs-caption); line-height: 1.5; color: var(--ink-2); }
@media (prefers-reduced-motion: reduce) { .mx-page .chip-card { transition: none; } .mx-page a.chip-card:active { transform: none; } }

/* 옮긴 카드 안내 (product → marketing) */
.mx-page .moved-note {
  display: flex; flex-direction: column; justify-content: center; gap: 6px;
  border: 1px dashed var(--hairline); border-radius: var(--r-lg); padding: 20px 22px;
  font-size: var(--fs-caption); line-height: 1.5; color: var(--ink-2);
}
.mx-page .moved-note a { font-weight: 600; }

/* ---------- 표 매트릭스 (기초·심화·XAI) ---------- */
.mx-page .matrix-scroll {
  overflow: auto; max-height: 78vh;
  border: 1px solid var(--hairline); border-radius: var(--r-lg);
  background: var(--card-bg);
}
.mx-page table.matrix { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 1040px; }
.mx-page .matrix thead th {
  position: sticky; top: 0; z-index: 3;
  background: var(--card-bg); border-bottom: 1px solid var(--hairline);
  text-align: left; padding: 16px 18px; vertical-align: top;
}
.mx-page .matrix thead th.corner { left: 0; z-index: 4; width: 200px; }
.mx-page .col-title { margin: 0 0 4px; font-size: var(--fs-body); font-weight: 700; letter-spacing: -0.012em; }
.mx-page .col-sub { margin: 0; font-size: var(--fs-fine); color: var(--ink-2); line-height: 1.5; }
.mx-page .matrix tbody th {
  position: sticky; left: 0; z-index: 2; background: var(--card-bg);
  text-align: left; vertical-align: top; padding: 16px;
  width: 200px; border-bottom: 1px solid var(--hairline-soft); border-right: 1px solid var(--hairline);
}
.mx-page .row-eyebrow {
  display: inline-flex; align-items: center; gap: 6px; margin: 0 0 4px;
  font-size: var(--fs-fine); font-weight: 600; letter-spacing: 0;
}
.mx-page .row-eyebrow::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
/* 글자는 무채색으로, 도메인 색(인라인 color)은 점에만 남긴다 */
.mx-page .row-eyebrow { -webkit-text-fill-color: var(--ink-2); }
.mx-page .row-name { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -0.012em; color: var(--ink); }
.mx-page tr.group-start > th, .mx-page tr.group-start > td { border-top: 1px solid var(--hairline); }
.mx-page .matrix td {
  vertical-align: top; padding: 14px 16px; min-width: 230px;
  border-bottom: 1px solid var(--hairline-soft); border-right: 1px solid var(--hairline-soft);
}
.mx-page .matrix td:last-child, .mx-page .matrix th:last-child { border-right: none; }
.mx-page .cell { display: flex; flex-direction: column; gap: 10px; }
.mx-page .chip { display: block; padding: 4px 6px; margin: -4px -6px; border-radius: var(--r-sm); color: var(--ink); text-decoration: none; }
.mx-page .chip .name {
  display: flex; align-items: baseline; gap: 7px; margin: 0;
  font-size: var(--fs-caption); font-weight: 600; line-height: 1.4;
}
.mx-page .chip .name::before {
  content: ""; flex: none; width: 7px; height: 7px; border-radius: 50%;
  background: var(--chip-c, var(--ink-2)); transform: translateY(-1px);
}
.mx-page .chip .formula { margin: 2px 0 0 14px; font-size: var(--fs-fine); line-height: 1.5; color: var(--ink-2); }
.mx-page a.chip:hover { text-decoration: none; }
.mx-page a.chip:hover .name { color: var(--link); }
.mx-page .chip[data-tag] .name::after {
  content: "•"; color: var(--link); font-weight: 700;
}
.mx-page .chip.is-linked { background: var(--link-bg); outline: 1px solid var(--link); }

/* ---------- 읽는 페이지(예비수학·읽는 법)의 절 ---------- */
.mx-page .mx-block--section h2 {
  margin: 0 0 10px; font-size: clamp(24px, 3.2vw, 32px); font-weight: 700; line-height: 1.25; letter-spacing: -0.02em;
}
.mx-page .mx-block--section h2 .idx { display: block; margin-bottom: 6px; font-size: var(--fs-caption); font-weight: 600; color: var(--ink-2); letter-spacing: 0; }
.mx-page .section-lede { margin: 0 0 24px; max-width: 720px; color: var(--ink-2); font-size: var(--fs-body); line-height: 1.6; }
.mx-page .section-lede a { color: var(--link); }
.mx-page .detail-link { display: inline-block; margin-top: 10px; font-size: var(--fs-caption); font-weight: 600; color: var(--link); }
.mx-page .topic, .mx-page .axis-item, .mx-page .cross-card, .mx-page .course-toc {
  background: var(--card-bg); border: 0; border-radius: var(--r-lg);
}
.mx-page .topic, .mx-page .axis-item { padding: 22px 24px; margin: 0 0 16px; max-width: 860px; line-height: 1.6; }
.mx-page .topic .t-name, .mx-page .axis-item .axis-name { font-size: var(--fs-body); font-weight: 700; }
.mx-page .topic .t-tag, .mx-page .axis-item .axis-sub, .mx-page .course-toc-summary, .mx-page .course-part .chapter-no, .mx-page .topic .rank {
  font-family: var(--font); font-size: var(--fs-fine); color: var(--ink-2);
}
.mx-page .topic p, .mx-page .axis-item p, .mx-page .cross-card p { font-size: 15px; line-height: 1.65; color: var(--ink-2); }
.mx-page .topic .t-gap.full { background: var(--link-bg); color: var(--link); }
.mx-page .topic a, .mx-page .axis-item a, .mx-page .cross-card a { color: var(--link); }
.mx-page .cross-card { padding: 18px 20px; }
.mx-page .cross-card .cc-title .tag { border: 0; padding: 0; font-family: var(--font); font-size: var(--fs-fine); color: var(--ink-2); white-space: normal; }
.mx-page .course-toc { padding: 24px; margin: 0; }
.mx-page .course-toc h2 { font-size: var(--fs-tagline); }
.mx-page .course-part a { font-size: 14px; color: var(--ink); }
.mx-page .course-part a:hover { color: var(--link); }
.mx-page .ext-table th { font-family: var(--font); text-transform: none; letter-spacing: 0; font-size: var(--fs-fine); }
.mx-page .ext-table { font-size: var(--fs-caption); }
.mx-page .crosslink-note {
  margin-top: 24px; padding: 20px 22px; max-width: 760px;
  background: var(--card-bg); border-radius: var(--r-lg);
  font-size: var(--fs-caption); line-height: 1.6; color: var(--ink-2);
}
.mx-page .crosslink-note strong { color: var(--ink); }
.mx-page .crosslink-note a { color: var(--link); }

/* 예비수학 머리말의 시작 버튼과 숫자 */
.mx-page .hero-actions { display: flex; flex-wrap: wrap; gap: var(--sp-sm); margin: 8px 0 28px; }
.mx-page .hero-action {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px;
  padding: 11px 22px; border-radius: var(--r-pill); border: 1px solid var(--link);
  background: transparent; color: var(--link); font-size: var(--fs-body); text-decoration: none;
  transition: transform 0.12s ease;
}
.mx-page .hero-action.primary { background: var(--btn-bg); border-color: var(--btn-bg); color: var(--btn-ink); }
.mx-page .hero-action:hover { text-decoration: none; }
.mx-page .hero-action:active { transform: scale(0.95); }
.mx-page .stat-row { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); margin: 0; }
.mx-page .stat-card { background: var(--card-bg); border-radius: var(--r-lg); padding: 20px 22px; }
.mx-page .stat-card .num { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; color: var(--ink); }
.mx-page .stat-card .desc { margin-top: 4px; font-size: var(--fs-caption); line-height: 1.5; color: var(--ink-2); }

/* ---------- 페이지 끝 정보 ---------- */
.mx-page .page-meta { padding: 32px 0; }
.mx-page .page-meta__text { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; }
.mx-page .page-meta__text a { color: var(--link); }

@media (max-width: 734px) {
  .mx-page .page-hero { padding-top: 40px; padding-bottom: 40px; }
  .mx-page .topic, .mx-page .axis-item { padding: 20px; }
}

/* ---------- 새 형식 매트릭스 페이지(marketing) ---------- */
.mx-new .page-hero { padding-top: 56px; padding-bottom: 56px; }
.mx-new .page-hero .t-hero { font-size: clamp(32px, 5.4vw, 48px); }
.mx-new .page-lead { max-width: 720px; margin-top: 16px; }
.mx-new .source-note { max-width: 720px; margin-top: 20px; }
.mx-new .source-note strong { color: var(--ink); font-weight: 600; margin-right: 6px; }
.mx-new .move-note { max-width: 720px; margin-top: 12px; display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: baseline; }
.mx-new .hero-tags { display: flex; gap: 6px; margin-bottom: 14px; }
.mx-new .jump { margin-top: 28px; }
.mx-new .hint { margin-top: 18px; }

.mx-new .group-title {
  display: flex; align-items: center; gap: 12px;
  font-size: clamp(24px, 3.2vw, 32px); font-weight: 700; letter-spacing: -0.02em; line-height: 1.25;
}
.mx-new .group-title .dot { width: 10px; height: 10px; }
.mx-new .group-desc { margin-top: 10px; max-width: 680px; color: var(--ink-2); }
.mx-new .sub-title { margin: 36px 0 12px; font-size: var(--fs-caption); font-weight: 600; color: var(--ink-2); letter-spacing: 0; }
.mx-new .group-desc + .sub-title { margin-top: 28px; }
.mx-new .concept-card .card__title { font-size: var(--fs-body); }
.mx-new .tile { scroll-margin-top: calc(var(--nav-h) + 52px); }

/* 배치 노트 표 */
.mx-new .table-scroll { margin-top: 24px; overflow-x: auto; border-radius: var(--r-lg); background: var(--card-bg); }
.mx-new .move-table { width: 100%; min-width: 640px; border-collapse: collapse; font-size: var(--fs-caption); line-height: 1.45; }
.mx-new .move-table th, .mx-new .move-table td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--hairline); vertical-align: top; }
.mx-new .move-table thead th { color: var(--ink-2); font-weight: 600; }
.mx-new .move-table tbody th { font-weight: 600; }
.mx-new .move-table tr:last-child th, .mx-new .move-table tr:last-child td { border-bottom: 0; }
.mx-new .move-table code, .mx-new .notes code { font-family: var(--font-mono); font-size: 12px; color: var(--ink-2); overflow-wrap: anywhere; }
.mx-new .notes { margin: 24px 0 0; padding-left: 1.2em; color: var(--ink-2); font-size: var(--fs-caption); line-height: 1.6; max-width: 760px; }
.mx-new .notes li + li { margin-top: 6px; }

.mx-new .card__desc { overflow-wrap: anywhere; }

/* 학습 트랙 장: 이전 장·다음 장 (scripts/tidy-track-chapters.mjs가 넣음) */
.chapter-pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 48px 0 8px; }
.chapter-pager a { display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; border-radius: 14px; background: var(--card-on-bg); color: var(--ink); text-decoration: none; }
.chapter-pager a:hover, .chapter-pager a:focus-visible { background: var(--link-bg); }
.chapter-pager__next { text-align: right; }
.chapter-pager__tag { font-size: 13px; color: var(--ink-2); }
.chapter-pager__title { font-size: 16px; font-weight: 600; line-height: 1.4; color: var(--link); }
@media (max-width: 600px) { .chapter-pager { grid-template-columns: 1fr; } .chapter-pager__next { text-align: left; } }

/* 에세이 그림: 밝은 배경 그림이라 다크 모드에서는 조금 어둡게 눌러 눈부심을 줄인다 */
.essay-figure { margin: 28px 0 36px; }
.essay-figure img { display: block; width: 100%; height: auto; border-radius: var(--r-lg); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .essay-figure img { filter: brightness(0.86); } }
:root[data-theme="dark"] .essay-figure img { filter: brightness(0.86); }

/* 복사 막기(오너 결정 2026-10-11): 글·그림을 끌어 선택하거나 길게 눌러 저장하지 못하게 한다.
   입력칸(빈칸 답 적기)은 그대로 쓸 수 있어야 해서 되살린다. 실제 차단은 assets/protect.js와 함께 한다. */
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input, textarea, select, [contenteditable="true"] { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
img, svg, picture { -webkit-user-drag: none; user-drag: none; }

/* ---------- 학습 트랙 도식(.dg) ----------
   글로 그려야 하는 구조를 HTML로 그린다. 구역은 테두리 대신 면 색으로 나누고, 좁은 화면에서는 세로로 쌓는다. */
.dg { margin: 28px 0 32px; }
.dg figcaption { font-size: 13.5px; color: var(--ink-2); margin-top: 12px; line-height: 1.6; }
.dg-panel { background: var(--bg-alt); border-radius: var(--r-lg); padding: 20px; }
.dg-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dg-case { background: var(--bg-alt); border-radius: var(--r-lg); padding: 18px 18px 16px; display: flex; flex-direction: column; gap: 10px; }
.dg-title { font-size: 14px; font-weight: 700; margin: 0; color: var(--ink); }
.dg-node { background: var(--bg); border-radius: var(--r-md); padding: 10px 12px; font-size: 14px; font-weight: 700; line-height: 1.4; }
.dg-node small { display: block; font-weight: 400; font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }
.dg-node--accent { background: var(--link-bg); }
.dg-arrow { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); padding-left: 14px; line-height: 1.4; }
.dg-arrow::before { content: "↓"; font-size: 18px; color: var(--link); flex: none; }
.dg-arrow b { color: var(--ink); font-weight: 600; }
.dg-verdict { font-size: 13.5px; font-weight: 700; margin: 2px 0 0; }
.dg-verdict--bad { color: var(--fail, #a33a3a); }
.dg-verdict--good { color: var(--ok, #2f7a5c); }
.dg-split { display: grid; grid-template-columns: 1fr auto 1fr; gap: 0; align-items: stretch; }
.dg-zone { border-radius: var(--r-lg); padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.dg-zone--client { background: var(--bg-alt); }
.dg-zone--server { background: var(--link-bg); }
.dg-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.dg-chips li { background: var(--bg); border-radius: 8px; padding: 4px 9px; font-size: 13px; margin: 0; line-height: 1.45; }
.dg-total { font-size: 13px; color: var(--ink-2); margin: auto 0 0; font-variant-numeric: tabular-nums; }
.dg-total b { color: var(--ink); font-size: 15px; }
.dg-wall { display: flex; align-items: center; justify-content: center; width: 44px; position: relative; }
.dg-wall::before { content: ""; position: absolute; top: 8px; bottom: 8px; left: 50%; border-left: 2px dashed var(--ink-2); opacity: .5; }
.dg-wall span { position: relative; writing-mode: vertical-rl; background: var(--bg); color: var(--ink-2); font-size: 12px; padding: 8px 2px; }
.dg-steps { list-style: none; counter-reset: dg; margin: 14px 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.dg-steps li { counter-increment: dg; background: var(--bg-alt); border-radius: var(--r-md); padding: 12px 12px 12px 40px; position: relative; font-size: 13.5px; line-height: 1.55; margin: 0; }
.dg-steps li::before { content: counter(dg); position: absolute; left: 12px; top: 11px; width: 20px; height: 20px; border-radius: 50%; background: var(--link); color: var(--bg); font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.dg-pipe { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; }
.dg-pipe .dg-arrow { padding: 0; flex-direction: column; text-align: center; max-width: 120px; }
.dg-pipe .dg-arrow::before { content: "→"; }
.dg-branch { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
/* 상자 2·3개를 같은 폭으로 나란히(.dg-branch, .dg-branch--3). 세로 흐름(.dg-stack) 안에서는 위쪽 간격을 gap이 맡는다. */
.dg-branch > .dg-node { min-width: 0; }
.dg-branch--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dg-stack > .dg-branch { margin-top: 0; }
@media (max-width: 640px) {
  .dg-compare, .dg-branch, .dg-branch--3, .dg-steps { grid-template-columns: 1fr; }
  .dg-split, .dg-pipe { grid-template-columns: 1fr; }
  .dg-wall { width: auto; height: 40px; }
  .dg-wall::before { top: 50%; bottom: auto; left: 8px; right: 8px; border-left: 0; border-top: 2px dashed var(--ink-2); }
  .dg-wall span { writing-mode: horizontal-tb; padding: 2px 8px; }
  .dg-pipe .dg-arrow { max-width: none; flex-direction: row; text-align: left; padding-left: 14px; }
  .dg-pipe .dg-arrow::before { content: "↓"; }
}
/* 3열 비교(.dg-trio): .dg-case 세 개를 나란히, 좁은 화면에서는 세로로 */
.dg-trio { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 640px) { .dg-trio { grid-template-columns: 1fr; } }
/* 가로 막대(.dg-bars): 이름 · 막대 · 값 한 줄씩. 막대 길이는 <i style="width:..%">로 준다 */
.dg-bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.dg-bars li { display: grid; grid-template-columns: 4em 1fr 5.2em; gap: 10px; align-items: center; font-size: 13.5px; margin: 0; font-variant-numeric: tabular-nums; }
.dg-bars li > span:nth-child(2) { display: block; background: var(--bg); border-radius: 6px; height: 12px; overflow: hidden; }
.dg-bars i { display: block; height: 100%; border-radius: 6px; background: var(--link); }
.dg-bars li > span:last-child { text-align: right; color: var(--ink-2); }
.dg-bars-low i { opacity: .45; }
/* 계산 그림(.dg-svg): .dg-panel 안 인라인 SVG. viewBox 너비 약 300이라 휴대폰 폭에서 글자가 13px 이상으로 보인다 */
.dg-svg { display: block; width: 100%; max-width: 360px; height: auto; margin: 0 auto; color: var(--ink); font-family: inherit; overflow: visible; }
.dg-svg text { font-size: 13.5px; fill: currentColor; font-variant-numeric: tabular-nums; }
.dg-svg text.b { font-weight: 700; }
.dg-svg .f-ink { fill: currentColor; }
.dg-svg .f-link { fill: var(--link); }
.dg-svg text.f-muted, .dg-svg .f-muted { fill: var(--ink-2); }
.dg-svg text.f-link { fill: var(--link); }
.dg-svg .soft { fill-opacity: .3; }
.dg-svg .s-ink { stroke: currentColor; fill: none; stroke-width: 1.5; }
.dg-svg .s-link { stroke: var(--link); fill: none; stroke-width: 2.5; }
.dg-svg .s-muted { stroke: var(--ink-2); fill: none; stroke-width: 1.5; }
.dg-svg .dash { stroke-dasharray: 4 4; }

/* ---------- AI에게 바로 시키기(.prompt-kit) ----------
   장 맨 위의 복사용 프롬프트. 사이트 전체의 복사 막기에서 이 상자만 예외다(assets/protect.js). */
.prompt-kit { background: var(--bg-alt); border-radius: var(--r-lg); padding: 18px 18px 14px; margin: 8px 0 36px; }
.prompt-kit__title { font-size: 15px; font-weight: 700; margin: 0; color: var(--ink); }
.prompt-kit__desc { font-size: 13.5px; color: var(--ink-2); margin: 4px 0 12px; line-height: 1.6; }
.prompt { background: var(--bg); border-radius: var(--r-md); margin: 0 0 10px; overflow: hidden; }
.prompt__bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 10px 9px 14px; }
.prompt__title { font-size: 14px; font-weight: 600; line-height: 1.4; }
.prompt__copy { flex: none; font: inherit; font-size: 13px; font-weight: 600; padding: 5px 12px; border-radius: var(--r-pill); border: 0; background: var(--link); color: var(--bg); cursor: pointer; }
.prompt__copy:hover { filter: brightness(1.08); }
.prompt__copy.is-done { background: var(--ok, #2f7a5c); }
html .prompt__body { margin: 0; padding: 0 14px 14px; background: transparent; border: 0; border-radius: 0; font-family: var(--font-mono); font-size: 12.5px; line-height: 1.65; white-space: pre-wrap; word-break: keep-all; overflow-wrap: anywhere; max-height: 220px; overflow: auto; color: var(--ink-2); }
.prompt-kit, .prompt-kit * { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
.prompt__copy { -webkit-user-select: none; user-select: none; }

/* 가로 흐름(.dg-flow): 구조도처럼 상자 → 상자를 한 줄로, 좁은 화면에서는 세로로.
   상자 사이 <span class="dg-flow-to">짧은 설명</span>이 화살표가 된다(--back은 거꾸로 ←).
   .dg-stack은 .dg-panel 안 요소를 세로로 띄워 쌓고, .dg-lane은 줄 이름이다 */
.dg-stack { display: flex; flex-direction: column; gap: 10px; }
.dg-lane { font-size: 12.5px; font-weight: 700; color: var(--ink-2); margin: 0; }
.dg-flow { display: flex; align-items: stretch; gap: 6px; }
.dg-flow > .dg-node { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.dg-flow-to { flex: 0 0 auto; max-width: 92px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; font-size: 12.5px; color: var(--ink-2); line-height: 1.35; }
.dg-flow-to::before { content: "→"; font-size: 18px; color: var(--link); }
.dg-flow-to--back::before { content: "←"; }
.dg-flow-to b { color: var(--ink); font-weight: 600; }
@media (max-width: 640px) {
  .dg-flow { flex-direction: column; }
  .dg-flow-to { max-width: none; flex-direction: row; gap: 8px; padding-left: 14px; justify-content: flex-start; text-align: left; }
  .dg-flow-to::before { content: "↓"; }
  .dg-flow-to--back::before { content: "↑"; }
}

/* 모으기(.dg-fan + .dg-join): 위 상자 여러 개(--n개)가 선으로 모여 아래 상자 하나로 들어간다.
   .dg-node--fail은 실패한 단계, .dg-node--off는 실행되지 않은 단계 */
.dg-fan { --n: 2; display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 8px; }
.dg-fan > * { position: relative; }
.dg-fan > *::after { content: ""; position: absolute; left: 50%; top: 100%; height: 12px; border-left: 2px solid var(--link); }
.dg-join { --n: 2; position: relative; height: 24px; margin: 12px calc((100% - (var(--n) - 1) * 8px) / (2 * var(--n))) 2px; border-top: 2px solid var(--link); }
.dg-join::after { content: "↓"; position: absolute; left: 50%; top: -3px; transform: translateX(-50%); color: var(--link); font-size: 18px; line-height: 1; }
.dg-node--fail { background: color-mix(in srgb, var(--fail, #a33a3a) 16%, var(--bg)); }
.dg-node--off { opacity: .45; }

/* ---------- ML 개발자 꿀팁(.dev-tip) ---------- */
.dev-tip { background: var(--link-bg); border-radius: var(--r-lg); padding: 14px 18px; margin: 20px 0 24px; }
.dev-tip__title { font-size: 13px; font-weight: 700; color: var(--link); margin: 0 0 4px; letter-spacing: 0.02em; }
.dev-tip p { font-size: 15px; margin: 4px 0; line-height: 1.7; }

/* ---------- 이 트랙의 시나리오(.scenario) ---------- */
.scenario { background: var(--bg-alt); border-radius: var(--r-lg); padding: 14px 18px 12px; margin: 4px 0 22px; }
.scenario__label { font-size: 12.5px; font-weight: 700; color: var(--link); margin: 0; letter-spacing: 0.02em; }
.scenario__title { font-size: 16px; font-weight: 700; margin: 2px 0 0; line-height: 1.45; }
.scenario__desc { font-size: 13.5px; color: var(--ink-2); margin: 4px 0 0; line-height: 1.6; }
.scenario__steps { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 8px; padding: 0; }
.scenario__steps li { margin: 0; }
.scenario__steps a, .scenario__steps span { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; font-size: 12.5px; font-weight: 700; text-decoration: none; background: var(--bg); color: var(--ink-2); }
.scenario__steps li.is-done a { background: var(--link-bg); color: var(--link); }
.scenario__steps li.is-now span { background: var(--link); color: var(--bg); }
.scenario__steps a:hover { outline: 2px solid var(--link); outline-offset: 1px; }
.scenario__now { font-size: 14px; margin: 0; line-height: 1.55; color: var(--ink); }
.scenario__now b { color: var(--link); margin-right: 6px; font-weight: 700; }

/* comic: four cropped panels from one composite illustration */
.comic { margin:28px 0 32px; }
.comic .comic__panels { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; list-style:none; padding:0; margin:0; align-items:start; }
.comic .comic__panel { min-width:0; margin:0; }
.comic .comic__panel a { display:block; border-radius:var(--r-lg); overflow:hidden; }
.comic .comic__panel img { display:block; width:100%; height:auto; margin:0; }
.comic figcaption { margin-top:14px; color:var(--ink-2); }
.comic .comic__title { display:block; font-size:18px; line-height:1.5; color:var(--ink); }
/* 말풍선 대사는 그림 안에 이미 보이므로 화면에서는 숨기고 스크린 리더와 검색용으로만 남긴다 */
.comic .comic__dialogue { position:absolute; width:1px; height:1px; margin:-1px; padding:0; overflow:hidden; clip:rect(0 0 0 0); clip-path:inset(50%); white-space:nowrap; }
.comic .comic__credit { font-size:14px; margin:8px 0 0; }
/* PC는 맨 위 2×2로 네 컷을 한꺼번에, 모바일은 1컷만 위에 두고 2~4컷은 장 중간에 하나씩 끼워 넣는다 */
.comic-mid { display:none; }
@media(max-width:833px) {
  .comic .comic__panels { grid-template-columns:1fr; }
  .comic .comic__panel:nth-child(n+2) { display:none; }
  .comic-mid { display:block; margin:28px 0; }
  .comic-mid a { display:block; border-radius:var(--r-lg); overflow:hidden; }
  .comic-mid img { display:block; width:100%; height:auto; margin:0; }
  .comic-mid__no { display:block; font-size:12px; color:var(--ink-2); margin:0 0 6px; }
}

/* 쉬운 본문 아래에 자세한 근거를 접어 두는 토글 (트랙 공통) */
main details.deep { margin: 28px 0 24px; border-top: 1px dashed var(--line); padding-top: 14px; }
main details.deep > summary { cursor: pointer; font-weight: 700; color: var(--ink-dim); }
main details.deep[open] > summary { margin-bottom: 12px; }

/* 블록 식(KaTeX display)이 좁은 화면에서 넘치지 않고 가로로 밀리게 */
.eq .katex-display { margin: 0; overflow-x: auto; overflow-y: hidden; }

/* 사이트 검색: 헤더 버튼과 검색 창 */
.gnav__search {
  font: inherit; font-size: var(--fs-nav); color: #d2d2d7; background: none; border: 0; cursor: pointer;
  min-height: 44px; min-width: 44px; padding: 0 10px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: var(--r-sm);
}
.gnav__search:hover { color: #fff; }
.gnav__search svg { width: 18px; height: 18px; flex: none; }
.gnav__search kbd { font: inherit; font-size: 11px; line-height: 18px; color: #a1a1a6; border: 1px solid #48484a; border-radius: 5px; padding: 0 6px; }
@media (max-width: 833px) { .gnav__search span, .gnav__search kbd { display: none; } }
dialog.ms {
  width: min(680px, calc(100vw - 24px)); max-height: min(78vh, 720px); margin: 12vh auto auto; padding: 0;
  border: 1px solid var(--hairline); border-radius: var(--r-lg); background: var(--bg); color: var(--ink);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35); overflow: hidden; flex-direction: column;
}
dialog.ms[open] { display: flex; }
dialog.ms::backdrop { background: rgba(0, 0, 0, 0.5); }
.ms__form { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--hairline); margin: 0; }
.ms__icon { width: 20px; height: 20px; color: var(--ink-2); flex: none; }
.ms__input { flex: 1; min-width: 0; font: inherit; font-size: 17px; border: 0; background: none; color: var(--ink); outline: none; padding: 6px 0; }
.ms__input::-webkit-search-cancel-button { display: none; }
.ms__close { font: inherit; font-size: 12px; color: var(--ink-2); border: 1px solid var(--hairline); background: none; border-radius: 6px; padding: 2px 8px; min-height: 28px; cursor: pointer; }
.ms__close:focus-visible, .ms__chip:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.ms__status { margin: 0; padding: 10px 16px 6px; font-size: var(--fs-caption); line-height: 1.6; color: var(--ink-2); }
.ms__chip { font: inherit; font-size: 13px; color: var(--ink); background: var(--bg-alt); border: 1px solid var(--hairline); border-radius: var(--r-pill); padding: 3px 11px; margin: 2px 4px 2px 0; cursor: pointer; }
.ms__chip:hover { border-color: var(--link); color: var(--link); }
.ms__list { list-style: none; margin: 0; padding: 0 8px 8px; overflow-y: auto; flex: 1; min-height: 0; }
.ms__sec { padding: 12px 10px 4px; font-size: 12px; font-weight: 700; color: var(--ink-2); }
.ms__sec span { font-weight: 500; }
.ms__list li[role="option"] { display: block; padding: 9px 10px; border-radius: var(--r-sm); cursor: pointer; }
.ms__list li.is-active { background: var(--link-bg); }
.ms__title { display: block; font-weight: 600; font-size: 15px; line-height: 1.4; color: var(--ink); }
.ms__meta { display: block; margin-top: 2px; font-size: 13px; line-height: 1.45; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms__hint { margin: 0; padding: 8px 16px; border-top: 1px solid var(--hairline); font-size: 12px; color: var(--ink-2); }
@media (max-width: 600px) {
  dialog.ms { margin-top: 8px; width: calc(100vw - 16px); max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); }
  .ms__hint { display: none; }
}

/* 장 끝 "실제로 써 보기"의 영상. 닫힌 details 안의 iframe(loading=lazy)은 열기 전에는 불러오지 않는다(JS 없이 클릭해야 재생). */
details.video { margin: 20px 0; border: 1px solid var(--hairline); border-radius: 12px; overflow: hidden; }
details.video > summary { cursor: pointer; padding: 12px 16px; font-weight: 600; }
details.video iframe { display: block; width: 100%; aspect-ratio: 16 / 9; border: 0; }

/* 표 바로 뒤에 오는 글이 표 아랫선에 맞닿아 보이지 않게 한다(표 뒤 간격만, 본문 문단 간격은 그대로). */
.tbl + p, .tbl + ul, .tbl + ol { margin-top: 14px; }

/* 장 끝 "실제로 써 보기"의 안내형 글: 짧은 문단이 이어지므로 문단 사이에 여백을 두고, 굵은 단계 제목을 따로 띄운다. */
.steps p { margin: 12px 0 0; }
.steps p > strong:only-child { display: block; margin-top: 28px; }
.steps h3 { margin-bottom: 4px; }

/* 장 끝 "이 장과 이어서 볼 개념 카드": 접어 두고, 링크는 본문에 그대로 둔다. */
details.more-concepts { margin: 28px 0; border: 1px solid var(--hairline); border-radius: 12px; padding: 2px 16px; }
details.more-concepts > summary { cursor: pointer; padding: 12px 0; font-weight: 600; }
details.more-concepts ul { margin: 4px 0 14px; padding-left: 20px; }
details.more-concepts li { margin: 6px 0; line-height: 1.55; }

/* 매트릭스 표에서 해당하는 항목이 없는 칸 */
.cell-empty { color: var(--ink-2); font-size: 13px; }
