/* LLM 위키 — 색인형 리디자인. 다크 기본, 단일 강조색(러스트). 디자인 전체가 이 파일 하나. */
@import url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable-dynamic-subset.min.css");
@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&display=swap");

/* 다크가 기본값 — 라이트는 [data-theme="light"]일 때만 */
:root {
  --bg: #101215;
  --panel: #14171b;
  --text: #e6e8ec;
  --strong: #f2f4f7;
  --muted: #8f959f;
  --faint: #6d737c;
  --line: #23262b;
  --line-2: #33373e;
  --accent: #e08055;
  --code-bg: #191c21;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, monospace;
}
:root[data-theme="light"] {
  --bg: #ffffff;
  --panel: #fafbfc;
  --text: #24272c;
  --strong: #14161a;
  --muted: #5f646c;
  --faint: #797f87;
  --line: #e4e6ea;
  --line-2: #d8dade;
  --accent: #b4441c;
  --code-bg: #f4f5f7;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard Variable", Pretendard, -apple-system, sans-serif;
  font-size: 16.5px;
  line-height: 1.8;
  word-break: keep-all;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ── 헤더: 사이트명 + 섹션 내비 + 검색 + 아이콘 토글 ─────── */
.site-header {
  display: flex; align-items: center; gap: 1.75rem;
  padding: 0 2rem; height: 52px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.site-name {
  color: var(--strong); font-weight: 700; font-size: 15px;
  letter-spacing: -0.01em; text-decoration: none;
}
.site-name:hover { text-decoration: none; }
.site-nav { display: flex; gap: 1.15rem; }
.site-nav a { color: var(--muted); font-size: 13.5px; text-decoration: none; }
.site-nav a:hover { color: var(--text); }
.site-nav a[aria-current="page"] { color: var(--accent); font-weight: 600; }

#theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; flex: 0 0 auto;
  background: var(--bg); border: 1px solid var(--line-2); border-radius: 5px;
  color: var(--text); cursor: pointer; padding: 0; font: inherit; font-size: 14px;
}
#theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
/* 다크에서는 라이트로 갈 수 있으니 해, 라이트에서는 달 */
#theme-toggle::before { content: "☀"; }
:root[data-theme="light"] #theme-toggle::before { content: "☾"; }

.header-search {
  position: relative; margin-left: auto; width: 200px;
  --pagefind-ui-scale: 0.62;
}
.header-search .pagefind-ui__drawer {
  position: absolute; top: 100%; right: 0; left: auto; width: 26rem; z-index: 40;
  max-height: 70vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line-2);
  border-radius: 8px; padding: 0 0.9rem;
}
@media (max-width: 720px) {
  .site-header { flex-wrap: wrap; height: auto; padding: 0.7rem 1.1rem; gap: 0.9rem; }
  .site-nav { order: 3; flex-basis: 100%; }
  .header-search { width: 100%; order: 4; margin-left: 0; }
}

/* ── 본문 ─────────────────────────────────────────────── */
main { max-width: 70rem; margin: 0 auto; padding: 2.25rem 2rem 5rem; }
.breadcrumb { color: var(--faint); font-size: 12.5px; margin-bottom: 0.85rem; }
.breadcrumb a { color: var(--accent); text-decoration: none; }
.breadcrumb span { color: var(--faint); }

article h1, main > h1 {
  font-size: 31px; line-height: 1.35; font-weight: 800;
  color: var(--strong); letter-spacing: -0.025em; margin: 0 0 0.5rem;
}
article > .meta:first-child {
  font-family: var(--mono); font-size: 12px; color: var(--faint);
  margin: 0 0 1.75rem;
}
article h2 {
  font-size: 22px; font-weight: 700; color: var(--strong);
  letter-spacing: -0.02em; margin: 2.75rem 0 0.85rem;
  padding-bottom: 0.4rem; border-bottom: 2px solid var(--strong);
  display: inline-block;
}
article h3 { font-size: 18px; font-weight: 700; color: var(--strong); margin: 2rem 0 0.4rem; }
/* 66ch는 "0" 글자 기준이라 한글로는 한 줄 33자밖에 안 됐다 — 80ch ≈ 한글 40자 */
article p, article li { max-width: 80ch; text-wrap: pretty; }
article p { margin: 0 0 1.15rem; }
article ul, article ol { padding-left: 1.15rem; }
article li { margin-bottom: 0.45rem; }
article strong { font-weight: 700; color: var(--strong); }

/* 첫 요약 구획을 눈에 띄게: 문서 첫 h2 + 바로 뒤 목록 */
article h2:first-of-type + ul, article h2:first-of-type + blockquote {
  background: var(--panel);
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
  padding: 1.15rem 1.35rem 1.15rem 2.35rem; margin: 0 0 2.25rem;
}
article h2:first-of-type + blockquote { padding-left: 1.35rem; color: var(--text); }

article blockquote {
  margin: 1.5rem 0; padding: 0 0 0 1.25rem;
  border-left: 2px solid var(--line-2); color: var(--muted);
}
article table { border-collapse: collapse; width: 100%; display: block; overflow-x: auto; font-size: 14.5px; margin-bottom: 1.75rem; }
article th, article td { border: 1px solid var(--line); padding: 0.5rem 0.75rem; text-align: left; }
article th { background: var(--panel); color: var(--strong); font-weight: 600; }
article code {
  font-family: var(--mono); font-size: 0.85em;
  background: var(--code-bg); padding: 0.12em 0.35em; border-radius: 4px;
}
article pre { background: var(--code-bg); padding: 1rem; border-radius: 6px; overflow-x: auto; border: 1px solid var(--line); }
article pre code { background: none; padding: 0; }
.meta { color: var(--faint); font-size: 12.5px; }
.dead-link { color: var(--faint); border-bottom: 1px dotted var(--faint); }

/* 흐름 도식 — 본문에 인라인 HTML로 <div class="flow">를 쓰면 카드 + 화살표로 렌더된다 */
.flow { display: flex; align-items: stretch; gap: 0.75rem; margin: 1.75rem 0; flex-wrap: wrap; }
.flow-step {
  flex: 1 1 12rem; padding: 1rem 1.1rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
}
.flow-step .tag {
  display: inline-block; font-family: var(--mono); font-size: 11.5px;
  color: var(--accent); letter-spacing: 0.02em; margin-bottom: 0.35rem;
}
.flow-step .name { display: block; font-weight: 700; color: var(--strong); font-size: 15.5px; line-height: 1.5; }
.flow-step .note { display: block; font-size: 13px; color: var(--muted); line-height: 1.6; margin-top: 0.15rem; }
.flow-arrow {
  align-self: center; font-family: var(--mono); font-size: 15px; color: var(--faint);
  user-select: none;
}
@media (max-width: 560px) {
  .flow { flex-direction: column; }
  .flow-arrow { align-self: flex-start; padding-left: 1.1rem; transform: rotate(90deg); }
}

/* 인용 칩 */
.cite {
  font-family: var(--mono); font-size: 11px; vertical-align: super; line-height: 0;
  color: var(--accent); padding: 0 0.15em; text-decoration: none;
}
.cite:hover { text-decoration: underline; }

/* ── 목차: 넓은 화면에서 왼쪽 고정 사이드바 ─────────────── */
.toc {
  margin: 1.5rem 0 2.25rem; padding: 1rem 1.1rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
}
.toc-title {
  margin: 0 0 0.6rem; font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.1em; color: var(--faint); font-weight: 500;
}
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc li { padding: 0; }
.toc a {
  display: block; font-size: 14px; line-height: 1.5;
  padding: 0.35rem 0.6rem; border-radius: 4px;
  color: var(--muted); text-decoration: none;
}
.toc li.toc-h3 a { padding-left: 1.4rem; font-size: 13.5px; color: var(--faint); }
.toc a:hover { color: var(--text); background: var(--bg); text-decoration: none; }
.toc a.active {
  color: var(--accent); font-weight: 600;
  background: var(--bg); border: 1px solid var(--line-2);
}
article h2, article h3 { scroll-margin-top: 4.5rem; }

@media (min-width: 1100px) {
  main.has-toc {
    max-width: 84rem;
    display: grid;
    grid-template-columns: 13.5rem minmax(0, 1fr);
    column-gap: 3rem;
    align-items: start;
  }
  main.has-toc > .breadcrumb,
  main.has-toc > h1,
  main.has-toc > article,
  main.has-toc > .backlinks { grid-column: 2; }
  main.has-toc > .toc {
    grid-column: 1; grid-row: 1 / span 4;
    position: sticky; top: 4.5rem;
    max-height: calc(100vh - 7rem); overflow-y: auto;
    margin: 0; padding: 0.25rem 0.5rem 0.25rem 0;
    background: none; border: 0; border-radius: 0;
  }
}

/* ── 태그 · 백링크 ───────────────────────────────────────── */
.tags {
  margin-top: 2.5rem; padding-top: 1.15rem; border-top: 1px solid var(--line);
  display: flex; flex-wrap: wrap; gap: 0.35rem;
}
.tag {
  font-family: var(--mono); font-size: 12px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 4px; padding: 0.15rem 0.5rem;
  text-decoration: none;
}
.tag:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }
.backlinks {
  margin-top: 2rem; padding: 1.1rem 1.25rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
}
.backlinks summary {
  font-size: 14px; color: var(--strong); font-weight: 600; cursor: pointer;
}
.backlinks ul {
  list-style: none; padding: 0; margin: 0.85rem 0 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 0.35rem 1.5rem;
}
.backlinks li { padding: 0; font-size: 14.5px; }

/* ── 홈 ──────────────────────────────────────────────────── */
.home { max-width: none; margin: 0; padding: 0; }
.home .hero {
  display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 3.5rem; align-items: start;
  max-width: 74rem; margin: 0 auto; padding: 3.5rem 2rem 2.4rem;
}
.home h1 {
  margin: 0 0 1.5rem; font-size: 44px; line-height: 1.2;
  font-weight: 800; color: var(--strong); letter-spacing: -0.035em;
}
.home #search { max-width: none; }
.home .stats { display: flex; flex-wrap: wrap; gap: 1.85rem; margin: 1.5rem 0 0; }
.home .stats span { font-size: 13px; color: var(--faint); white-space: nowrap; }
.home .stats strong { font-family: var(--mono); font-weight: 600; color: var(--text); }

.start {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 1.25rem 1.35rem;
}
.start h2 {
  margin: 0 0 0.9rem; font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.1em; color: var(--faint); font-weight: 500;
}
.start ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.9rem; counter-reset: start; }
.start li {
  counter-increment: start; line-height: 1.5;
  display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 0.75rem;
}
.start li::before {
  content: "0" counter(start);
  grid-column: 1; grid-row: 1 / span 2;
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  color: var(--accent); line-height: 1.7;
}
.start li a { grid-column: 2; grid-row: 1; display: block; font-size: 15.5px; font-weight: 600; color: var(--strong); text-decoration: none; }
.start li a:hover { color: var(--accent); }
.start .summary { grid-column: 2; grid-row: 2; display: block; font-size: 13.5px; color: var(--muted); line-height: 1.6; }

/* 카테고리 진입점: 본문 폭에 맞춘 4칸 띠 */
.entries {
  display: grid; grid-template-columns: repeat(4, 1fr);
  width: calc(100% - 4rem); max-width: 70rem; margin: 0 auto;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.entry {
  padding: 1.35rem 1.4rem; border-right: 1px solid var(--line);
  color: var(--text); text-decoration: none;
}
.entry:first-child { padding-left: 0; }
.entry:last-child { padding-right: 0; border-right: 0; }
.entry:hover { background: var(--panel); text-decoration: none; }
.entry .label { display: flex; align-items: baseline; gap: 0.5rem; margin-bottom: 0.3rem; }
.entry .name { font-size: 16px; font-weight: 700; color: var(--strong); }
.entry .count { font-family: var(--mono); font-size: 12px; color: var(--accent); }
.entry .note { display: block; font-size: 13.5px; line-height: 1.65; color: var(--muted); }
@media (max-width: 900px) {
  .home .hero { grid-template-columns: 1fr; gap: 2rem; padding: 2.25rem 1.25rem 1.75rem; }
  .home h1 { font-size: 34px; }
  .entries { grid-template-columns: repeat(2, 1fr); width: calc(100% - 2.5rem); }
  .entry:nth-child(2n) { border-right: 0; padding-right: 0; }
  .entry:nth-child(2n+1) { padding-left: 0; }
  .entry:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}

/* ── 목록: 최근 갱신 · 섹션 목록 · 태그 목록 ─────────────── */
.recent { max-width: 74rem; margin: 0 auto; padding: 2rem 2rem 4rem; }
.recent h2 { margin: 0 0 0.9rem; font-size: 17px; font-weight: 700; color: var(--strong); }
.recent .more { float: right; font-size: 13px; }
.recent ul, .listing { list-style: none; padding: 0; margin: 0; }
.recent li, .listing li { border-top: 1px solid var(--line); }
.recent li:last-child, .listing li:last-child { border-bottom: 1px solid var(--line); }
.recent li > a, .listing li > a {
  display: grid; grid-template-columns: minmax(0, 1fr) 5.5rem;
  gap: 0.15rem 1rem; padding: 0.75rem 0;
  color: var(--strong); text-decoration: none; font-size: 15.5px; font-weight: 600;
}
.recent li > a:hover, .listing li > a:hover { color: var(--accent); text-decoration: none; }
.recent .summary, .listing .summary {
  grid-column: 1; display: block; margin-top: 0.15rem;
  color: var(--muted); font-size: 13.5px; line-height: 1.6; font-weight: 400;
}
.recent .meta, .listing .meta {
  grid-column: 2; grid-row: 1; text-align: right;
  font-family: var(--mono); font-size: 12px; color: var(--faint);
}
.listing-head { margin-bottom: 1.25rem; }
.listing-head .meta { margin: 0.2rem 0 0; }

/* 태그 색인 */
.tag-index { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 2rem; }
.tag-index .count { color: var(--faint); font-size: 11px; }
.tag-single > summary { color: var(--muted); font-size: 13.5px; cursor: pointer; }
.tag-single .tag-index { margin-top: 1rem; }

/* ── Pagefind UI를 팔레트에 맞춤 ─────────────────────────── */
:root {
  --pagefind-ui-scale: 0.85;
  --pagefind-ui-primary: var(--accent);
  --pagefind-ui-text: var(--text);
  --pagefind-ui-background: var(--bg);
  --pagefind-ui-border: var(--line-2);
  --pagefind-ui-border-width: 1px;
  --pagefind-ui-border-radius: 6px;
  --pagefind-ui-font: "Pretendard Variable", Pretendard, sans-serif;
}
.pagefind-ui__search-input { font-size: 1rem !important; }
