:root {
  --bg: #ffffff; --panel: #f6f7f9; --line: #e3e6eb; --fg: #1d2129; --dim: #555d6b; --mute: #8a92a0;
  --accent: #0f9e8a; --accent-soft: #e3f6f2; --purple: #7c6cf0; --purple-soft: #efedfd;
  --warn: #b7791f; --warn-soft: #fdf3e1; --danger: #c0392b; --danger-soft: #fdecea;
  --code-bg: #f4f5f7; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.05);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171c; --panel: #191d24; --line: #2c333e; --fg: #e6e9ee; --dim: #aab2bf; --mute: #7d8695;
    --accent: #18b6a0; --accent-soft: #123a35; --purple: #9d90ff; --purple-soft: #2a2645;
    --warn: #e0a84a; --warn-soft: #3a2f1a; --danger: #ef7468; --danger-soft: #3d1f1d; --code-bg: #1d222a; --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #14171c; --panel: #191d24; --line: #2c333e; --fg: #e6e9ee; --dim: #aab2bf; --mute: #7d8695;
  --accent: #18b6a0; --accent-soft: #123a35; --purple: #9d90ff; --purple-soft: #2a2645;
  --warn: #e0a84a; --warn-soft: #3a2f1a; --danger: #ef7468; --danger-soft: #3d1f1d; --code-bg: #1d222a; --shadow: none;
}
* { box-sizing: border-box; }
html { scroll-padding-top: 76px; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16.5px/1.75 "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif; word-break: keep-all; overflow-wrap: anywhere; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* header */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 18px; height: 60px; padding: 0 20px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--fg); font-weight: 700; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand em { font-style: normal; font-weight: 500; color: var(--mute); margin-left: 4px; }
.menu-btn { display: none; border: 1px solid var(--line); background: var(--panel); color: var(--fg); border-radius: 8px; width: 38px; height: 34px; font-size: 18px; cursor: pointer; }
.search { position: relative; flex: 1; max-width: 460px; margin-left: auto; }
.search input { width: 100%; height: 38px; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--fg); font: inherit; font-size: 14.5px; }
.search input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.results { position: absolute; top: 44px; left: 0; right: 0; max-height: 70vh; overflow: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.18); padding: 6px; }
.results a { display: block; padding: 9px 12px; border-radius: 8px; color: var(--fg); font-size: 14.5px; line-height: 1.5; }
.results a:hover, .results a.sel { background: var(--accent-soft); text-decoration: none; }
.results small { display: block; color: var(--mute); font-size: 12.5px; }
.results mark { background: none; color: var(--accent); font-weight: 700; }
.results .none { padding: 10px 12px; color: var(--mute); font-size: 14px; }
.links { display: flex; align-items: center; gap: 16px; font-size: 14.5px; white-space: nowrap; }
.links a { color: var(--dim); }
#theme { border: 1px solid var(--line); background: var(--panel); color: var(--fg); border-radius: 8px; width: 34px; height: 34px; cursor: pointer; font-size: 16px; }

/* layout */
.wrap { display: grid; grid-template-columns: 280px minmax(0, 1fr) 230px; max-width: 1480px; margin: 0 auto; }
.side { position: sticky; top: 60px; height: calc(100vh - 60px); overflow: auto; padding: 22px 14px 40px 20px; border-right: 1px solid var(--line); font-size: 14.5px; }
.nav-part { margin: 18px 0 6px 8px; font-size: 12px; font-weight: 700; letter-spacing: .06em; color: var(--mute); text-transform: uppercase; }
.nav-part:first-child { margin-top: 0; }
.side ul { list-style: none; margin: 0; padding: 0; }
.side a { display: flex; gap: 9px; padding: 6px 10px; border-radius: 8px; color: var(--dim); line-height: 1.45; }
.side a:hover { background: var(--panel); text-decoration: none; color: var(--fg); }
.side a.on { background: var(--accent-soft); color: var(--fg); font-weight: 600; }
.side .n { flex: none; width: 20px; color: var(--mute); font-variant-numeric: tabular-nums; font-size: 13px; padding-top: 1px; }
.doc { min-width: 0; padding: 36px 56px 60px; }
.toc { position: sticky; top: 60px; height: calc(100vh - 60px); overflow: auto; padding: 36px 18px 40px 6px; font-size: 13.5px; }
.toc-head { font-size: 12px; font-weight: 700; letter-spacing: .06em; color: var(--mute); margin-bottom: 8px; }
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc ul ul { padding-left: 12px; }
.toc a { display: block; padding: 3px 0 3px 10px; color: var(--mute); border-left: 2px solid transparent; line-height: 1.5; }
.toc a.on { color: var(--accent); border-left-color: var(--accent); }

/* content */
.crumb { font-size: 13.5px; color: var(--accent); font-weight: 600; letter-spacing: .02em; }
.crumb .chap:not(:empty)::before { content: " · 제"; color: var(--mute); font-weight: 500; }
.crumb .chap:not(:empty)::after { content: "장"; color: var(--mute); font-weight: 500; }
.doc h1 { margin: 6px 0 18px; font-size: 2.15rem; line-height: 1.3; letter-spacing: -.02em; }
article { max-width: 820px; }
article > blockquote:first-child { margin: 0 0 30px; padding: 16px 20px; border: 0; border-radius: 12px; background: var(--panel); color: var(--dim); font-size: 1.04rem; }
article > blockquote:first-child p { margin: 0; }
article h2 { margin: 2.4em 0 .6em; padding-top: .4em; font-size: 1.5rem; letter-spacing: -.01em; border-top: 1px solid var(--line); }
article h3 { margin: 1.8em 0 .5em; font-size: 1.18rem; }
article h2 .anchor, article h3 .anchor { margin-left: 8px; color: var(--mute); opacity: 0; font-weight: 400; }
article h2:hover .anchor, article h3:hover .anchor { opacity: 1; }
article p, article li { color: var(--fg); }
article ul, article ol { padding-left: 1.4em; }
article li { margin: .25em 0; }
article strong { font-weight: 700; }
article code { font: 14px/1.5 "SF Mono", Menlo, Consolas, monospace; background: var(--code-bg); padding: .12em .38em; border-radius: 5px; }
article pre, article .hl { border-radius: 12px; }
article .hl pre, article pre { margin: 0; padding: 16px 18px; overflow: auto; background: var(--code-bg); border: 1px solid var(--line); border-radius: 12px; font: 14px/1.6 "SF Mono", Menlo, Consolas, monospace; }
article .hl, article pre { margin: 1em 0 1.3em; }
article pre code { background: none; padding: 0; }
.hl { background: none !important; }
article table { width: 100%; border-collapse: collapse; margin: 1em 0 1.4em; font-size: 15px; display: block; overflow-x: auto; }
article th, article td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
article th { background: var(--panel); font-weight: 600; white-space: nowrap; }
article td code { white-space: nowrap; }
figure { margin: 1.4em 0 1.8em; }
figure img { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); background: var(--panel); }
figcaption { margin-top: 10px; font-size: 14px; color: var(--mute); line-height: 1.55; }
article hr { border: 0; border-top: 1px solid var(--line); margin: 2.4em 0; }

/* callouts: !!! note / tip / warning / exercise / answer */
.admonition { margin: 1.3em 0; padding: 14px 18px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); }
.admonition > p { margin: .4em 0; }
.admonition-title { font-weight: 700; font-size: .95rem; margin-top: 0 !important; }
.admonition.tip { background: var(--accent-soft); border-color: transparent; }
.admonition.tip .admonition-title { color: var(--accent); }
.admonition.note { background: var(--purple-soft); border-color: transparent; }
.admonition.note .admonition-title { color: var(--purple); }
.admonition.warning { background: var(--warn-soft); border-color: transparent; }
.admonition.warning .admonition-title { color: var(--warn); }
.admonition.exercise { border: 2px dashed var(--accent); background: transparent; }
.admonition.exercise .admonition-title { color: var(--accent); }
.admonition.exercise .admonition-title::before { content: "✍︎ "; }
details.answer { margin: -.4em 0 1.4em; padding: 10px 16px; border: 1px solid var(--line); border-radius: 10px; }
details.answer summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin: 1.2em 0 1.6em; }
.cards a { display: block; padding: 16px 18px; border: 1px solid var(--line); border-radius: 12px; color: var(--fg); background: var(--bg); box-shadow: var(--shadow); }
.cards a:hover { border-color: var(--accent); text-decoration: none; }
.cards b { display: block; margin-bottom: 4px; }
.cards span { font-size: 14px; color: var(--mute); line-height: 1.5; display: block; }
.steps { counter-reset: s; list-style: none; padding-left: 0 !important; }
.steps > li { position: relative; padding-left: 40px; margin: .8em 0; }
.steps > li::before { counter-increment: s; content: counter(s); position: absolute; left: 0; top: .1em; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 13.5px; font-weight: 700; display: grid; place-items: center; }
.video { position: relative; aspect-ratio: 16/9; margin: 1.2em 0 1.6em; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; max-width: 820px; margin: 56px 0 0; }
.pager a { display: block; padding: 14px 18px; border: 1px solid var(--line); border-radius: 12px; color: var(--fg); font-weight: 600; }
.pager a:hover { border-color: var(--accent); text-decoration: none; }
.pager span { display: block; font-size: 12.5px; color: var(--mute); font-weight: 500; }
.pager .next { text-align: right; }
.foot { max-width: 820px; margin-top: 40px; padding-top: 18px; border-top: 1px solid var(--line); font-size: 13px; color: var(--mute); }

@media (max-width: 1200px) { .wrap { grid-template-columns: 260px minmax(0, 1fr); } .toc { display: none; } }
@media (max-width: 860px) {
  .wrap { grid-template-columns: minmax(0, 1fr); }
  .menu-btn { display: block; }
  .side { position: fixed; top: 60px; left: 0; bottom: 0; width: min(320px, 86vw); height: auto; background: var(--bg); z-index: 30; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0,0,0,.25); }
  body.nav-open .side { transform: none; }
  .doc { padding: 24px 16px 48px; }
  .doc h1 { font-size: 1.7rem; }
  .links a { display: none; }
  .brand em { display: none; }
  .search { max-width: none; }
  .pager { grid-template-columns: 1fr; }
}
@media (max-width: 520px) { .brand span { display: none; } .top { gap: 10px; padding: 0 12px; } }
