/* 다운 규약 문서 — 디자인 토큰은 :root 에, 다크 모드는 prefers-color-scheme 로 바꾼다. */
:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-2: #eef2ef;
  --text: #17201c;
  --muted: #5b6862;
  --line: #dbe2dd;
  --brand: #0f5c4d;
  --brand-ink: #ffffff;
  --brand-soft: #e1efe9;
  --accent: #c9822b;
  --link: #0d6b59;
  --code-bg: #eef2ef;
  --pub: #2f7d4f;   --pub-bg: #e3f3e8;
  --par: #8a5a12;   --par-bg: #fbefd9;
  --int: #9b2d3a;   --int-bg: #f8e1e4;
  --shadow: 0 1px 2px rgba(16, 32, 26, 0.06), 0 4px 16px rgba(16, 32, 26, 0.05);
  --radius: 10px;
  --wrap: 1180px;
  --font: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  --mono: "D2Coding", "JetBrains Mono", Consolas, ui-monospace, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1412; --surface: #161d1a; --surface-2: #1d2622; --text: #e6ece9; --muted: #9aa8a1; --line: #2a3530;
    --brand: #3fae93; --brand-ink: #06120e; --brand-soft: #173029; --link: #6fd0b6; --code-bg: #1d2622;
    --pub: #7fd39c; --pub-bg: #17301f; --par: #e9b860; --par-bg: #33280f; --int: #f08f9b; --int-bg: #3a1a1f;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1412; --surface: #161d1a; --surface-2: #1d2622; --text: #e6ece9; --muted: #9aa8a1; --line: #2a3530;
  --brand: #3fae93; --brand-ink: #06120e; --brand-soft: #173029; --link: #6fd0b6; --code-bg: #1d2622;
  --pub: #7fd39c; --pub-bg: #17301f; --par: #e9b860; --par-bg: #33280f; --int: #f08f9b; --int-bg: #3a1a1f;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4); color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16px; line-height: 1.7; overflow-x: hidden; word-break: keep-all; overflow-wrap: anywhere; }
a { color: var(--link); text-underline-offset: 3px; }
code, pre { font-family: var(--mono); font-size: 0.9em; }
img { max-width: 100%; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--brand); color: var(--brand-ink); padding: 8px 12px; border-radius: 6px; z-index: 10; }
.skip:focus { left: 16px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 16px; }
.section { padding: 28px 16px; }
.narrow { max-width: 760px; }

/* ---------- 상단 ---------- */
.top { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top-inner { max-width: var(--wrap); margin: 0 auto; padding: 0 16px; min-height: 60px; display: flex; align-items: center; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 17px; white-space: nowrap; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-weight: 800; }
.top-nav { margin-left: auto; display: flex; align-items: center; gap: 4px 6px; flex-wrap: wrap; justify-content: flex-end; }
.top-nav > a { color: var(--muted); text-decoration: none; padding: 8px 10px; border-radius: 8px; font-size: 15px; min-height: 40px; display: inline-flex; align-items: center; }
.top-nav > a:hover, .top-nav > a[aria-current="page"] { color: var(--text); background: var(--surface-2); }
.top-search input { width: 180px; min-height: 40px; }
.who { display: inline-flex; align-items: center; gap: 6px; margin: 0; min-width: 0; }
.who-name { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; color: var(--muted); }
.menu-btn { display: none; margin-left: auto; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; padding: 11px 10px; flex-direction: column; justify-content: space-between; }
.menu-btn span { display: block; height: 2px; background: var(--text); border-radius: 2px; }

input[type="search"], input[type="password"], input[type="text"] {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; min-width: 0;
}
input:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px var(--brand-soft); }
.btn { font: inherit; font-size: 15px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 16px; border-radius: 8px; border: 1px solid transparent; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn-primary { background: var(--brand); color: var(--brand-ink); font-weight: 600; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); }

/* ---------- 홈 ---------- */
.hero { background: linear-gradient(160deg, var(--brand-soft), transparent 70%); border-bottom: 1px solid var(--line); }
.hero .wrap { padding-top: 48px; padding-bottom: 40px; }
.eyebrow { margin: 0 0 6px; color: var(--brand); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; font-size: 13px; }
.hero h1 { margin: 0 0 12px; font-size: clamp(28px, 4.4vw, 44px); line-height: 1.25; letter-spacing: -0.02em; }
.lead { color: var(--muted); font-size: 17px; max-width: 70ch; margin: 0 0 18px; }
.hero-search { display: flex; gap: 8px; max-width: 620px; flex-wrap: wrap; }
.hero-search input { flex: 1 1 240px; min-height: 48px; font-size: 17px; }
.hero-search .btn { min-height: 48px; padding: 0 22px; }
.viewer-note { color: var(--muted); font-size: 14px; margin-top: 14px; }
.section-title { font-size: 20px; margin: 0 0 14px; }
.cards { display: flex; flex-wrap: wrap; gap: 14px; }
.card { flex: 1 1 220px; min-width: 0; display: flex; flex-direction: column; gap: 4px; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); text-decoration: none; color: var(--text); transition: border-color 0.15s, transform 0.15s; }
.card:hover { border-color: var(--brand); transform: translateY(-1px); }
.card-title { font-weight: 700; font-size: 17px; }
.card-sum { color: var(--muted); font-size: 14px; flex: 1; }
.card-count { color: var(--brand); font-weight: 700; font-size: 14px; }
.card-lock { color: var(--par); font-weight: 600; font-size: 13.5px; }
.ways { display: flex; flex-wrap: wrap; gap: 14px; }
.way { flex: 1 1 260px; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.way h3 { margin: 0 0 6px; font-size: 16px; }
.way p { margin: 0; color: var(--muted); font-size: 15px; }

/* ---------- 목록·표 ---------- */
.page-title { font-size: clamp(24px, 3.4vw, 32px); line-height: 1.3; margin: 0 0 8px; letter-spacing: -0.01em; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 16px; }
.tabs a { text-decoration: none; color: var(--muted); border: 1px solid var(--line); background: var(--surface); padding: 6px 14px; border-radius: 999px; min-height: 40px; display: inline-flex; align-items: center; font-size: 15px; }
.tabs a[aria-current="page"] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
thead th { background: var(--surface-2); font-size: 14px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.doc-table { min-width: 560px; }
.doc-table th button { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; min-height: 28px; }
.doc-table th button:focus-visible { outline: 2px solid var(--accent); }
.sort-ind::after { content: "↕"; opacity: 0.35; font-size: 12px; }
th[aria-sort="ascending"] .sort-ind::after { content: "▲"; opacity: 1; color: var(--brand); }
th[aria-sort="descending"] .sort-ind::after { content: "▼"; opacity: 1; color: var(--brand); }
.col-title a { font-weight: 600; text-decoration: none; }
.col-title a:hover { text-decoration: underline; }
.col-title .sub { display: block; color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.col-ver, .col-date { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--muted); }
.col-cat, .col-vis { white-space: nowrap; }
.empty { color: var(--muted); padding: 24px; text-align: center; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }

.badge { display: inline-block; font-size: 12px; font-weight: 700; line-height: 1; padding: 5px 8px; border-radius: 999px; vertical-align: middle; white-space: nowrap; }
.badge-public { color: var(--pub); background: var(--pub-bg); }
.badge-partner { color: var(--par); background: var(--par-bg); }
.badge-internal { color: var(--int); background: var(--int-bg); }

/* ---------- 문서 ---------- */
.doc-layout { display: flex; gap: 32px; align-items: flex-start; padding-top: 24px; padding-bottom: 48px; }
.doc-side { flex: 0 0 230px; position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow: auto; }
.doc { flex: 1 1 auto; min-width: 0; }
.side-h { font-size: 13px; font-weight: 700; color: var(--muted); margin: 0 0 6px; text-transform: uppercase; letter-spacing: 0.04em; }
.side-list ul { list-style: none; margin: 0; padding: 0; }
.side-list a { display: block; padding: 6px 10px; border-radius: 6px; color: var(--muted); text-decoration: none; font-size: 14.5px; line-height: 1.45; }
.side-list a:hover { background: var(--surface-2); color: var(--text); }
.side-list a[aria-current="page"] { background: var(--brand-soft); color: var(--text); font-weight: 600; }
.crumbs { font-size: 14px; color: var(--muted); margin: 0 0 6px; }
.crumbs a { color: var(--muted); }
.meta { display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 0 0 12px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); font-size: 14px; }
.meta div { display: flex; gap: 6px; align-items: center; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; font-weight: 600; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.tag { font-size: 13px; color: var(--muted); background: var(--surface-2); padding: 2px 8px; border-radius: 6px; }
.toc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 16px; margin: 0 0 20px; font-size: 14.5px; }
.toc summary { cursor: pointer; font-weight: 600; min-height: 32px; display: flex; align-items: center; }
.toc ol { margin: 6px 0 4px; padding-left: 18px; }
.toc ul { margin: 2px 0; padding-left: 18px; list-style: circle; }
.toc a { color: var(--muted); text-decoration: none; }
.toc a:hover { color: var(--link); text-decoration: underline; }

.prose { font-size: 16.5px; }
.prose h2 { font-size: 23px; margin: 36px 0 12px; padding-top: 8px; border-top: 1px solid var(--line); line-height: 1.35; scroll-margin-top: 80px; }
.prose h3 { font-size: 18.5px; margin: 28px 0 8px; scroll-margin-top: 80px; }
.prose h4 { font-size: 16.5px; margin: 22px 0 6px; }
.prose .anchor { float: left; margin-left: -1.1em; width: 1em; color: var(--muted); text-decoration: none; opacity: 0; }
.prose :is(h2, h3, h4):hover .anchor { opacity: 0.6; }
.prose p, .prose ul, .prose ol { margin: 0 0 14px; }
.prose li + li { margin-top: 4px; }
.prose :not(pre) > code { background: var(--code-bg); padding: 1px 6px; border-radius: 5px; font-size: 0.88em; }
.prose pre { background: var(--code-bg); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; overflow-x: auto; line-height: 1.55; font-size: 14px; }
.prose blockquote { margin: 0 0 14px; padding: 8px 16px; border-left: 4px solid var(--brand); background: var(--brand-soft); border-radius: 0 8px 8px 0; color: var(--text); }
.prose blockquote p:last-child { margin-bottom: 0; }
.prose .table-wrap { margin: 0 0 16px; }
.prose table { min-width: 480px; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 28px 0; }

/* ---------- 검색·로그인 ---------- */
.hits { list-style: none; padding: 0; margin: 16px 0 0; display: flex; flex-direction: column; gap: 10px; }
.hits li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.hits a { font-weight: 700; font-size: 17px; text-decoration: none; }
.hits p { margin: 6px 0 0; color: var(--muted); font-size: 14.5px; }
.hit-cat { margin-left: 8px; color: var(--muted); font-size: 13px; }
.login { display: flex; flex-direction: column; gap: 8px; max-width: 460px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.login label { font-weight: 600; font-size: 15px; }
.login input { min-height: 46px; font-family: var(--mono); }
.login .btn { margin-top: 6px; min-height: 46px; }
.alert { background: var(--int-bg); color: var(--int); border-radius: 8px; padding: 10px 14px; font-weight: 600; }
.hint { color: var(--muted); font-size: 14px; }

/* ---------- 하단 ---------- */
.foot { border-top: 1px solid var(--line); margin-top: 32px; }
.foot-inner { max-width: var(--wrap); margin: 0 auto; padding: 18px 16px 28px; display: flex; flex-wrap: wrap; gap: 8px 16px; justify-content: space-between; color: var(--muted); font-size: 14px; }
.foot-links { display: inline-flex; gap: 14px; }
.foot a { color: var(--muted); }

/* ---------- 반응형 ---------- */
@media (max-width: 960px) {
  /* 세로 배치에서 flex-start 면 본문 폭이 긴 코드블록만큼 늘어난다 — 폭을 화면에 묶는다 */
  .doc-layout { flex-direction: column; gap: 16px; align-items: stretch; }
  .doc { width: 100%; }
  .doc-side { position: static; flex: none; width: 100%; max-height: none; order: 2; border-top: 1px solid var(--line); padding-top: 16px; }
  .top-search input { width: 140px; }
}
@media (max-width: 768px) {
  .menu-btn { display: inline-flex; }
  .top-inner { flex-wrap: wrap; }
  .top-nav { display: none; width: 100%; flex-direction: column; align-items: stretch; padding: 4px 0 12px; gap: 4px; }
  .top-nav.open { display: flex; }
  .top-nav > a { min-height: 44px; }
  .top-search input { width: 100%; min-height: 44px; }
  .who { justify-content: space-between; }
  .who-name { max-width: none; flex: 1; }
  .hero .wrap { padding-top: 32px; padding-bottom: 28px; }
  .lead { font-size: 16px; }
  .prose { font-size: 16px; }
  .prose h2 { font-size: 20px; }
  .prose .anchor { display: none; }
}
/* 좁은 화면: 문서 표를 카드처럼 쌓는다 — 머리글은 정렬 버튼 줄로 남긴다 */
@media (max-width: 640px) {
  .doc-table, .doc-table thead, .doc-table tbody { display: block; min-width: 0; }
  .doc-table thead tr { display: flex; flex-wrap: wrap; gap: 4px 6px; padding: 8px 10px; }
  .doc-table thead th { display: block; border: 0; padding: 0; background: none; }
  .doc-table thead th button { padding: 6px 10px; min-height: 36px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
  .doc-table thead { background: var(--surface-2); border-bottom: 1px solid var(--line); }
  .doc-table tbody tr { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .doc-table tbody tr:last-child { border-bottom: 0; }
  .doc-table tbody td { display: block; border: 0; padding: 0; font-size: 14px; }
  .doc-table td.col-title { flex: 0 0 100%; font-size: 15.5px; }
  .doc-table td.col-ver::before { content: "v"; }
}
@media (max-width: 500px) {
  .section { padding: 20px 16px; }
  .meta { gap: 6px 14px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
