/* =========================================================
   ARIA 접근성 가이드 — 공통 스타일
   - 색 대비 WCAG AA 이상 (본문 4.5:1, 큰 글자·UI 3:1)
   - 라이트/다크 테마, 보기 설정(글자 크기·간격·정렬·고대비), 인쇄
   - 크기는 rem 기준이라 글자 크기 설정에 따라 함께 커짐
   - prefers-reduced-motion 존중
   ========================================================= */

:root {
  --bg: #f8f9fc;
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --surface-3: #e7eaf3;
  --text: #161b2e;
  --text-2: #3d4560;
  --muted: #5a627a;
  --border: #d8dce8;
  --border-strong: #b9bfd1;
  --accent: #4338ca;
  --accent-hover: #3730a3;
  --accent-soft: #eef0ff;
  --accent-text: #ffffff;
  --good: #11743d;
  --good-soft: #e6f6ec;
  --bad: #b42318;
  --bad-soft: #fdecea;
  --warn: #8a5300;
  --warn-soft: #fff4dc;
  --info: #0b5cad;
  --info-soft: #e7f1fd;
  --state: #9d174d;
  --state-soft: #fdecf4;
  --prop: #0f5f73;
  --prop-soft: #e3f4f8;
  --code-bg: #12162a;
  --code-text: #e6e8f2;
  --code-border: #262c47;
  --tk-tag: #8fb3ff;
  --tk-attr: #f2c78b;
  --tk-aria: #ff9bd0;
  --tk-val: #a6e3a1;
  --tk-com: #8a91ad;
  --tk-kw: #c9a2ff;
  --tk-str: #a6e3a1;
  --focus: #4338ca;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 48, .06), 0 4px 18px rgba(16, 24, 48, .06);
  --topbar-h: 4rem;
  --sidebar-w: 17.5rem;
  --toc-w: 13.75rem;
  --content-w: 51.25rem;
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "맑은 고딕", system-ui, sans-serif;
  --mono: "D2Coding", "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1020; --surface: #151a2e; --surface-2: #1b2139; --surface-3: #242b47;
    --text: #e9ecf6; --text-2: #c3c8db; --muted: #9aa1ba; --border: #2b3252; --border-strong: #414a70;
    --accent: #a5b0ff; --accent-hover: #c3caff; --accent-soft: #232a52; --accent-text: #0d1020;
    --good: #6fdc9b; --good-soft: #10291c; --bad: #ff8f86; --bad-soft: #33161a; --warn: #f5c66b; --warn-soft: #2f2410;
    --info: #8cc4ff; --info-soft: #11243d; --state: #ff9ccc; --state-soft: #35172a; --prop: #7fd6ea; --prop-soft: #0f2a32;
    --code-bg: #0a0d1a; --code-border: #252b46; --focus: #a5b0ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 22px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1020; --surface: #151a2e; --surface-2: #1b2139; --surface-3: #242b47;
  --text: #e9ecf6; --text-2: #c3c8db; --muted: #9aa1ba; --border: #2b3252; --border-strong: #414a70;
  --accent: #a5b0ff; --accent-hover: #c3caff; --accent-soft: #232a52; --accent-text: #0d1020;
  --good: #6fdc9b; --good-soft: #10291c; --bad: #ff8f86; --bad-soft: #33161a; --warn: #f5c66b; --warn-soft: #2f2410;
  --info: #8cc4ff; --info-soft: #11243d; --state: #ff9ccc; --state-soft: #35172a; --prop: #7fd6ea; --prop-soft: #0f2a32;
  --code-bg: #0a0d1a; --code-border: #252b46; --focus: #a5b0ff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 22px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

/* ---------- 기본 ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar-h) + 16px); }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 1.03rem; line-height: 1.75; letter-spacing: -0.005em;
  word-break: keep-all; overflow-wrap: anywhere;
}
img, svg { max-width: 100%; }
a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--accent-hover); text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
code, kbd, pre { font-family: var(--mono); }
:not(pre) > code { font-size: .88em; background: var(--surface-2); border: 1px solid var(--border); padding: .08em .38em; border-radius: 6px; color: var(--text); }
kbd { display: inline-block; font-size: .82em; padding: .1em .45em; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 6px; background: var(--surface); color: var(--text); line-height: 1.4; }
h1, h2, h3, h4 { line-height: 1.35; letter-spacing: -0.02em; color: var(--text); }
h2 { font-size: 1.5rem; margin: 2.6rem 0 .9rem; }
h3 { font-size: 1.15rem; margin: 1.8rem 0 .6rem; }
h4 { font-size: 1.02rem; margin: 1.4rem 0 .5rem; }
p, ul, ol, dl { margin: 0 0 1rem; }
hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { text-align: left; vertical-align: top; padding: .6rem .75rem; border-bottom: 1px solid var(--border); }
thead th { background: var(--surface-2); font-weight: 700; font-size: .88rem; color: var(--text-2); }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); margin: 0 0 1.2rem; }
.table-wrap table { margin: 0; }
.table-wrap tr:last-child > * { border-bottom: 0; }
caption { text-align: left; padding: .6rem .75rem; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.sr-only, .visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: 12px; top: -100px; z-index: 1000; background: var(--accent); color: var(--accent-text); padding: .7rem 1.1rem; border-radius: var(--radius-sm); font-weight: 700; text-decoration: none; }
.skip-link:focus { top: 12px; }

/* ---------- 상단 바 ---------- */
.topbar { position: sticky; top: 0; z-index: 50; min-height: var(--topbar-h); background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--border); }
.topbar-inner { min-height: var(--topbar-h); display: flex; align-items: center; gap: 12px; padding: 0 20px; max-width: 1560px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 800; font-size: 1.06rem; letter-spacing: -0.02em; white-space: nowrap; }
.brand:hover { color: var(--text); }
.brand-mark { display: block; width: 32px; height: 32px; border-radius: 9px; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--text-2); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.nav-toggle { display: none; }
.top-actions { display: flex; gap: 4px; margin-left: auto; }

/* 검색 (combobox) */
.search { position: relative; flex: 1 1 auto; max-width: 520px; margin-left: 24px; }
.search input { width: 100%; height: 42px; padding: 0 14px 0 40px; border-radius: 11px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; font-size: .95rem; }
.search input::placeholder { color: var(--muted); }
.search input:focus { outline: 3px solid var(--focus); outline-offset: 1px; background: var(--surface); }
.search-icon { position: absolute; left: 13px; top: 12px; color: var(--muted); pointer-events: none; }
.search-kbd { position: absolute; right: 10px; top: 10px; font-size: .75rem; color: var(--muted); }
.search-list { position: absolute; top: calc(100% + 6px); left: 0; right: 0; margin: 0; padding: 6px; list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); max-height: min(70vh, 520px); overflow-y: auto; z-index: 60; }
.search-list li { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; padding: 8px 10px; border-radius: 9px; cursor: pointer; line-height: 1.45; }
.search-list li[aria-selected="true"], .search-list li:hover { background: var(--accent-soft); }
.search-list .s-kind { grid-row: span 2; align-self: start; font-size: .72rem; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: var(--surface-3); color: var(--text-2); white-space: nowrap; margin-top: 2px; }
.search-list .s-title { font-weight: 700; color: var(--text); }
.search-list .s-sum { font-size: .84rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-list .s-empty { display: block; color: var(--muted); cursor: default; }
.search-list mark { background: transparent; color: var(--accent); font-weight: 800; }

/* ---------- 레이아웃 ---------- */
.layout { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); max-width: 1560px; margin: 0 auto; }
.sidebar { position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); overflow-y: auto; padding: 20px 14px 40px 20px; border-right: 1px solid var(--border); font-size: .93rem; overscroll-behavior: contain; }
.main { display: grid; grid-template-columns: minmax(0, 1fr); gap: 40px; padding: 28px 40px 80px; min-width: 0; }
.main:focus { outline: none; }
.layout.has-toc .main { grid-template-columns: minmax(0, var(--content-w)) var(--toc-w); justify-content: center; }
.content { min-width: 0; max-width: var(--content-w); width: 100%; margin: 0 auto; }
.page-home .content, .page-index .content, .page-cheatsheet .content, .page-tool .content { max-width: 68.75rem; }

/* 사이드바 */
.nav-group { margin: 0 0 6px; }
.nav-group-title { list-style: none; cursor: pointer; font-size: .78rem; font-weight: 800; letter-spacing: .04em; color: var(--muted); padding: 8px 8px 6px; border-radius: 8px; display: flex; align-items: center; justify-content: space-between; }
.nav-group-title::-webkit-details-marker { display: none; }
.nav-group-title::after { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform .15s; margin-right: 4px; }
.nav-group[open] > .nav-group-title::after { transform: rotate(45deg); }
.nav-group-title:hover { color: var(--text); background: var(--surface-2); }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar a { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; border-radius: 8px; color: var(--text-2); text-decoration: none; line-height: 1.45; }
.sidebar a:hover { background: var(--surface-2); color: var(--text); }
.sidebar a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.sidebar a code { background: none; border: 0; padding: 0; font-size: .86rem; color: inherit; }
.sidebar .count, .count { font-size: .74rem; font-weight: 700; color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: 1px 8px; }
.nav-sub { margin: 4px 0 8px 10px !important; padding-left: 8px !important; border-left: 1px solid var(--border); }
.nav-sub-title { display: block; font-size: .74rem; font-weight: 700; color: var(--muted); padding: 8px 10px 2px; }
.nav-sub a { padding: 3px 10px; font-size: .88rem; }

/* 목차 */
.toc { position: sticky; top: calc(var(--topbar-h) + 28px); align-self: start; max-height: calc(100vh - var(--topbar-h) - 56px); overflow-y: auto; font-size: .87rem; border-left: 1px solid var(--border); padding-left: 16px; }
.toc-title { font-weight: 800; font-size: .78rem; color: var(--muted); letter-spacing: .04em; margin-bottom: .5rem; }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc a { display: block; padding: 4px 0; color: var(--muted); text-decoration: none; line-height: 1.45; }
.toc a:hover, .toc a[aria-current="true"] { color: var(--accent); }
.toc a[aria-current="true"] { font-weight: 700; }

/* 브레드크럼 */
.breadcrumb ol { list-style: none; display: flex; flex-wrap: wrap; gap: 4px; padding: 0; margin: 0 0 18px; font-size: .86rem; }
.breadcrumb li + li::before { content: "/"; color: var(--border-strong); margin-right: 6px; }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); text-decoration: underline; }
.breadcrumb a[aria-current="page"] { color: var(--text); font-weight: 600; }

/* ---------- 문서 머리 ---------- */
.page-head { margin-bottom: 28px; padding-bottom: 22px; border-bottom: 1px solid var(--border); }
.page-head h1 { font-size: clamp(1.8rem, 3.6vw, 2.5rem); margin: 0 0 10px; }
.title-code code { background: none; border: 0; padding: 0; font-size: 1em; color: var(--text); letter-spacing: -0.03em; }
.title-en { margin: -4px 0 10px; color: var(--muted); font-size: 1.02rem; }
.eyebrow { margin: 0 0 8px; font-size: .84rem; font-weight: 700; color: var(--accent); letter-spacing: .01em; }
.lead { font-size: 1.12rem; color: var(--text-2); margin: 0 0 12px; }
.head-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.crit-num { font-family: var(--mono); font-weight: 700; color: var(--accent); margin-right: .2em; }

/* 배지·태그·칩 */
.badge, .tag { display: inline-flex; align-items: center; gap: 4px; font-size: .76rem; font-weight: 700; line-height: 1.5; padding: 2px 9px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.badge--basic { background: var(--good-soft); color: var(--good); }
.badge--intermediate { background: var(--info-soft); color: var(--info); }
.badge--advanced { background: var(--state-soft); color: var(--state); }
.badge--deprecated { background: var(--bad-soft); color: var(--bad); }
.badge--default { background: var(--accent-soft); color: var(--accent); }
.badge--native { background: var(--warn-soft); color: var(--warn); }
.badge--new { background: linear-gradient(135deg, #4f46e5, #9333ea); color: #fff; }
.badge--lv-A { background: var(--good-soft); color: var(--good); }
.badge--lv-AA { background: var(--info-soft); color: var(--info); }
.badge--lv-AAA { background: var(--state-soft); color: var(--state); }
.tag--state { background: var(--state-soft); color: var(--state); }
.tag--property { background: var(--prop-soft); color: var(--prop); }
.tag--native { background: var(--warn-soft); color: var(--warn); }
.tag code { background: none; border: 0; padding: 0; color: inherit; font-size: .95em; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 1rem; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); text-decoration: none; color: var(--text); font-size: .9rem; line-height: 1.4; }
.chip code { background: none; border: 0; padding: 0; font-size: .92em; }
a.chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.chip--muted { color: var(--muted); border-style: dashed; }
.chip-std { font-size: .74rem; font-weight: 800; color: var(--accent); }
.sub-label { display: block; font-size: .82rem; font-weight: 700; color: var(--muted); margin: 14px 0 6px; }

/* ---------- 본문 요소 ---------- */
.article > *:first-child { margin-top: 0; }
.doc-section { margin-top: 2.6rem; }
.doc-section > h2:first-child { margin-top: 0; }
.facts h2, .facts > h2 { font-size: 1rem; margin: 0 0 10px; color: var(--muted); }
.facts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin: 0; }
.facts-grid > div { background: var(--surface); padding: 12px 16px; }
.facts-grid dt { font-size: .78rem; font-weight: 700; color: var(--muted); margin-bottom: 2px; }
.facts-grid dd { margin: 0; font-weight: 600; }
.example { margin: 0 0 1.6rem; }
.example h3 { margin-top: 0; }
.example-note { color: var(--muted); font-size: .93rem; }
.check-list { list-style: none; padding: 0; }
.check-list li { position: relative; padding: 6px 0 6px 30px; border-bottom: 1px dashed var(--border); }
.check-list li::before { content: ""; position: absolute; left: 2px; top: 11px; width: 16px; height: 16px; border: 2px solid var(--accent); border-radius: 4px; }
.check-list li:last-child { border-bottom: 0; }
.article ul:not([class]), .article ol:not([class]) { padding-left: 1.3rem; }
.article li { margin: .25rem 0; }
blockquote { margin: 0 0 1rem; padding: .6rem 1rem; border-left: 4px solid var(--accent); background: var(--surface-2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* 코드 블록 */
.code { margin: 0 0 1.2rem; border-radius: var(--radius); overflow: hidden; background: var(--code-bg); border: 1px solid var(--code-border); }
.code-head { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 14px; background: rgba(255, 255, 255, .04); border-bottom: 1px solid var(--code-border); font-size: .78rem; color: #b7bdd6; }
.code-label { font-weight: 700; flex: 1; }
.code-badge { font-weight: 800; padding: 1px 8px; border-radius: 999px; font-size: .72rem; }
.code-badge.good { background: #143d27; color: #7ee2a8; }
.code-badge.bad { background: #4a1a1d; color: #ffa39b; }
.code--good { border-color: #1e6a42; }
.code--bad { border-color: #7a2a2a; }
.copy-btn { font: inherit; font-size: .76rem; font-weight: 700; padding: 3px 10px; border-radius: 7px; border: 1px solid #3a4266; background: transparent; color: #d4d8ea; cursor: pointer; }
.copy-btn:hover { background: #262d4d; }
.code pre { margin: 0; padding: 14px 16px; overflow-x: auto; font-size: .86rem; line-height: 1.65; color: var(--code-text); tab-size: 2; }
.code pre code { background: none; border: 0; padding: 0; color: inherit; font-size: inherit; }
.tk-tag { color: var(--tk-tag); } .tk-attr { color: var(--tk-attr); } .tk-aria { color: var(--tk-aria); font-weight: 600; }
.tk-val { color: var(--tk-val); } .tk-com { color: var(--tk-com); font-style: italic; } .tk-kw { color: var(--tk-kw); } .tk-str { color: var(--tk-str); }
.compare { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; margin-bottom: 1.2rem; }
.compare .code { margin: 0; }

/* 안내 상자 */
.callout { margin: 0 0 1.2rem; padding: 14px 18px; border-radius: var(--radius); border: 1px solid var(--border); border-left-width: 4px; background: var(--surface); }
.callout > :last-child { margin-bottom: 0; }
.callout-title { font-weight: 800; margin: 0 0 6px; }
.callout--tip { border-left-color: var(--good); background: var(--good-soft); }
.callout--warn { border-left-color: var(--warn); background: var(--warn-soft); }
.callout--note { border-left-color: var(--info); background: var(--info-soft); }
.callout--danger { border-left-color: var(--bad); background: var(--bad-soft); }

/* 권장/비권장 */
.dodont { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.dodont-col { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; background: var(--surface); }
.dodont-col h3 { margin: 0 0 8px; font-size: 1rem; }
.dodont-col ul { margin: 0; padding-left: 1.1rem; }
.dodont-col--do { border-top: 4px solid var(--good); }
.dodont-col--do h3 { color: var(--good); }
.dodont-col--dont { border-top: 4px solid var(--bad); }
.dodont-col--dont h3 { color: var(--bad); }

/* 화면낭독기 표 */
.sr-caption { font-size: .9rem; }
.sr-caption .muted { font-weight: 400; font-size: .84rem; }
.sr-out { font-family: var(--mono); font-size: .88rem; background: var(--surface-2); padding: 2px 8px; border-radius: 6px; quotes: "“" "”"; }
.kbd-table th { white-space: nowrap; width: 1%; }
.values-table th[scope="row"] { white-space: nowrap; width: 1%; }

/* 데모 */
.demo { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); margin: 0 0 1.4rem; overflow: hidden; }
.demo-stage { padding: 24px; background-image: radial-gradient(var(--border) 1px, transparent 1px); background-size: 16px 16px; background-color: var(--surface); }
.demo-stage > :last-child { margin-bottom: 0; }
.demo-inspect { border-top: 1px solid var(--border); background: var(--code-bg); }
.demo-inspect-title { margin: 0; padding: 8px 14px; font-size: .78rem; font-weight: 700; color: #b7bdd6; border-bottom: 1px solid var(--code-border); }
.demo-inspect-title .muted { color: #8a91ad; font-weight: 400; }
.demo-inspect pre { margin: 0; padding: 12px 14px; color: var(--code-text); font-size: .84rem; overflow: auto; max-height: 320px; white-space: pre-wrap; overflow-wrap: anywhere; }
.demo-inspect code { background: none; border: 0; padding: 0; color: inherit; }
.demo-inspect .changed { background: rgba(255, 155, 208, .22); border-radius: 3px; }
.demo-btn { font: inherit; font-weight: 700; padding: .55rem 1rem; border-radius: 10px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-text); cursor: pointer; min-height: 44px; }
.demo-btn:hover { background: var(--accent-hover); }
.demo-btn--ghost, .demo-btn[aria-pressed="false"] { background: var(--surface); color: var(--accent); }
.demo-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }
.demo-btn[aria-disabled="true"], .demo-btn:disabled { opacity: .55; cursor: not-allowed; }
.demo-panel { margin-top: 12px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.demo-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.demo-field { display: grid; gap: 6px; margin-bottom: 14px; }
.demo-field label { font-weight: 700; font-size: .93rem; }
.demo-field input[type="checkbox"], .demo-field input[type="radio"] { justify-self: start; width: auto; }
.demo-input { font: inherit; padding: .55rem .8rem; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); min-height: 44px; }
.demo-input[aria-invalid="true"] { border-color: var(--bad); box-shadow: 0 0 0 1px var(--bad); }
.demo-list { list-style: none; margin: 0; padding: 6px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.demo-list > li { padding: 8px 10px; border-radius: 7px; cursor: pointer; }
.demo-list > li[aria-selected="true"], .demo-list > li.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.demo-msg { margin-top: 10px; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--info-soft); color: var(--info); min-height: 1em; }
/* 라이브 리전은 비어 있어도 렌더링돼 있어야 알림이 읽힘 — display:none 금지 */
.demo-msg:empty { padding: 0; margin: 0; background: transparent; min-height: 0; }
.demo-error { color: var(--bad); font-weight: 600; font-size: .92rem; margin: 2px 0 0; }

/* 이전/다음 */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 56px; }
.pager-link { display: grid; gap: 2px; padding: 14px 18px; border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; background: var(--surface); }
.pager-link:hover { border-color: var(--accent); }
.pager-next { text-align: right; grid-column: 2; }
.pager-dir { font-size: .8rem; color: var(--muted); font-weight: 700; }
.pager-title { font-weight: 700; color: var(--text); }

/* ---------- 목록 페이지 (카드) ---------- */
.filter { position: sticky; top: var(--topbar-h); z-index: 5; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); padding: 14px 0; margin-bottom: 8px; border-bottom: 1px solid var(--border); display: grid; gap: 10px; }
.filter-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.filter-label { font-size: .84rem; font-weight: 700; color: var(--muted); min-width: 74px; }
.filter-input { flex: 1 1 260px; max-width: 420px; height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { font: inherit; font-size: .86rem; font-weight: 600; padding: 5px 13px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer; min-height: 34px; }
.seg button:hover { border-color: var(--accent); color: var(--accent); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.filter-count { margin: 0; font-size: .86rem; color: var(--muted); }
.filter-empty { padding: 30px; text-align: center; color: var(--muted); }
.cat-section { margin-top: 2rem; }
.cat-section > h2 { margin: 0 0 4px; display: flex; align-items: center; gap: 10px; }
.card-grid { list-style: none; padding: 0; margin: 16px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.card-grid--wide { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.ref-card { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); transition: border-color .15s, box-shadow .15s, transform .15s; }
.ref-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
@media (prefers-reduced-motion: no-preference) { .ref-card:hover { transform: translateY(-1px); } }
.ref-card-link { text-decoration: none; color: var(--text); }
.ref-card-link::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.ref-card-link:focus-visible { outline: none; }
.ref-card:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.ref-card-name { background: none !important; border: 0 !important; padding: 0 !important; font-size: 1.02rem !important; font-weight: 700; color: var(--accent) !important; }
.ref-card-title { font-weight: 800; font-size: 1.08rem; }
.ref-card-sum { margin: 0; font-size: .92rem; color: var(--text-2); line-height: 1.6; }
.ref-card-meta { margin: auto 0 0; display: flex; flex-wrap: wrap; gap: 6px; padding-top: 4px; }
[hidden] { display: none !important; }

/* 지침 목록 */
.std-principle { margin-top: 2rem; }
.std-principle-title { font-size: 1.3rem; margin: 0 0 4px; padding-bottom: 8px; border-bottom: 2px solid var(--accent); }
.std-guideline { margin: 1.4rem 0 0; }
.std-guideline h4 { margin: 0 0 6px; font-size: 1.05rem; }
.crit-list { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 8px; }
.crit-list li { padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.crit-list li > a { text-decoration: none; font-weight: 700; color: var(--text); }
.crit-list li > a:hover .crit-title { color: var(--accent); text-decoration: underline; }
.crit-sum { flex-basis: 100%; margin: 0; font-size: .9rem; color: var(--muted); }
.map-table td, .map-table th { vertical-align: middle; }
.map-table .chip { font-size: .82rem; padding: 3px 10px; margin: 2px 0; }

/* ---------- 홈 ---------- */
.hero { padding: 36px 0 26px; }
.hero h1 { font-size: clamp(2.1rem, 5vw, 3.4rem); line-height: 1.18; margin: 8px 0 18px; letter-spacing: -0.035em; }
.grad { background: linear-gradient(120deg, #4f46e5, #9333ea 55%, #db2777); -webkit-background-clip: text; background-clip: text; color: transparent; }
:root[data-theme="dark"] .grad { background-image: linear-gradient(120deg, #a5b0ff, #d8b4fe 55%, #f9a8d4); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .grad { background-image: linear-gradient(120deg, #a5b0ff, #d8b4fe 55%, #f9a8d4); } }
.hero .lead { max-width: 720px; font-size: 1.16rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 24px 0 30px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; padding: 0 20px; border-radius: 12px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn--primary:hover { background: var(--accent-hover); color: var(--accent-text); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin: 0; max-width: 820px; }
.stats > div { padding: 14px 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.stats dt { font-size: .82rem; color: var(--muted); font-weight: 700; }
.stats dd { margin: 0; font-size: 1.9rem; font-weight: 800; letter-spacing: -0.03em; }
.home-section { margin-top: 3.2rem; }
.home-section > h2 { margin: 0 0 16px; }
.path { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; counter-reset: none; }
.path a { position: relative; display: grid; gap: 4px; padding: 18px 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); text-decoration: none; height: 100%; }
.path a:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.path-step { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); font-weight: 800; margin-bottom: 6px; }
.path-title { font-weight: 800; color: var(--text); font-size: 1.05rem; }
.path-desc { color: var(--muted); font-size: .92rem; }
.feature-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.feature-grid a { display: grid; gap: 6px; padding: 22px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); text-decoration: none; color: var(--text); height: 100%; }
.feature-grid a:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.feature-icon { font-size: 1.6rem; }
.feature-title { font-weight: 800; font-size: 1.12rem; }
.feature-desc { color: var(--text-2); font-size: .94rem; }
.weekly-card { padding: 26px 28px; border-radius: 18px; background: linear-gradient(135deg, var(--accent-soft), var(--surface)); border: 1px solid var(--border); }
.weekly-kind { margin: 0; font-weight: 700; color: var(--accent); font-size: .9rem; }
.weekly-name { margin: 4px 0 6px; font-size: 1.8rem; font-weight: 800; }
.weekly-name a { text-decoration: none; }
.weekly-name code { background: none; border: 0; padding: 0; font-size: 1em; color: var(--text); }
.weekly-sum { font-size: 1.05rem; margin: 0 0 8px; }
.weekly-meta { margin: 0; font-size: .86rem; }
.cat-tiles { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.cat-tiles a { display: grid; gap: 6px; padding: 18px 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); text-decoration: none; color: var(--text); height: 100%; }
.cat-tiles a:hover { border-color: var(--accent); }
.cat-tile-title { font-weight: 800; display: flex; gap: 8px; align-items: center; }
.cat-tile-desc { font-size: .9rem; color: var(--muted); }
.cat-tile-ex { display: flex; flex-wrap: wrap; gap: 4px; }
.rule-list { padding-left: 1.4rem; display: grid; gap: 10px; }
.rule-list li span { display: block; color: var(--muted); font-size: .94rem; }
.more { font-weight: 700; text-decoration: none; }
.news-mini { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.news-mini li { padding: 14px 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.news-mini a { font-weight: 700; }

/* 소식 */
.news-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.news-item { padding: 18px 22px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.news-meta { margin: 0 0 4px; display: flex; gap: 8px; align-items: center; font-size: .86rem; color: var(--muted); }
.news-title { font-size: 1.1rem; margin: 0 0 6px; }
.news-item > p:last-child { margin-bottom: 0; }

/* 한눈에 보기 */
.cs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.cs-block { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; background: var(--surface); break-inside: avoid; }
.cs-block h3 { margin: 0 0 8px; font-size: 1rem; color: var(--accent); }
.cs-block dl { margin: 0; }
.cs-block dl > div { padding: 6px 0; border-bottom: 1px dashed var(--border); }
.cs-block dl > div:last-child { border-bottom: 0; }
.cs-block dt { font-weight: 700; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cs-block dt a { text-decoration: none; }
.cs-block dd { margin: 0; font-size: .88rem; color: var(--text-2); line-height: 1.55; }
.cs-values { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.cs-values code { font-size: .78rem !important; }

/* 용어집 */
.glossary { display: grid; gap: 0; margin: 0; }
.glossary-item { padding: 14px 0; border-bottom: 1px solid var(--border); }
.glossary-item:target { background: var(--accent-soft); border-radius: var(--radius-sm); padding-left: 12px; padding-right: 12px; }
.glossary dt { font-weight: 800; font-size: 1.05rem; }
.glossary dt .muted { font-weight: 500; font-size: .9rem; margin-left: 6px; }
.glossary dd { margin: 4px 0 0; color: var(--text-2); }

/* 참고 링크 */
.ref-links { padding-left: 1.2rem; }

/* ---------- 실습실 / 튜터 (도구 페이지) ---------- */
.tool-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.panel { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.panel-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.panel-head h2, .panel-head h3 { margin: 0; font-size: .98rem; flex: 1; }
.panel-body { padding: 14px; flex: 1; min-height: 0; }
.editor { width: 100%; min-height: 380px; height: 100%; resize: vertical; border: 0; padding: 14px 16px; font-family: var(--mono); font-size: .88rem; line-height: 1.65; background: var(--code-bg); color: var(--code-text); tab-size: 2; }
.editor:focus { outline: 3px solid var(--focus); outline-offset: -3px; }
.preview-frame { width: 100%; min-height: 380px; height: 100%; border: 0; background: #fff; }
.btn-sm { font: inherit; font-size: .86rem; font-weight: 700; padding: 6px 12px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer; min-height: 36px; }
.btn-sm:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-sm--primary:hover { background: var(--accent-hover); color: var(--accent-text); }
.btn-sm[disabled] { opacity: .5; cursor: not-allowed; }
.select { font: inherit; font-size: .9rem; padding: 6px 10px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); min-height: 36px; max-width: 100%; }
.issues { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.issue { padding: 10px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); border-left-width: 4px; background: var(--surface); font-size: .93rem; }
.issue--error { border-left-color: var(--bad); }
.issue--warn { border-left-color: var(--warn); }
.issue--ok { border-left-color: var(--good); background: var(--good-soft); }
.issue-head { font-weight: 700; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.issue-sev { font-size: .72rem; font-weight: 800; padding: 1px 8px; border-radius: 999px; }
.issue--error .issue-sev { background: var(--bad-soft); color: var(--bad); }
.issue--warn .issue-sev { background: var(--warn-soft); color: var(--warn); }
.issue p { margin: 4px 0 0; color: var(--text-2); }
.issue code { font-size: .84em; }
.ax-tree { font-family: var(--mono); font-size: .84rem; line-height: 1.7; margin: 0; padding: 0; list-style: none; }
.ax-tree ul { list-style: none; margin: 0; padding-left: 18px; border-left: 1px dashed var(--border); }
.ax-role { color: var(--state); font-weight: 700; }
.ax-name { color: var(--text); }
.ax-state { color: var(--prop); }
.mission-box { padding: 14px 18px; border-radius: var(--radius); border: 1px solid var(--accent); background: var(--accent-soft); margin-bottom: 16px; }
.mission-box h2 { margin: 0 0 4px; font-size: 1.05rem; }
.mission-box p { margin: 0; }
.mission-result { margin-top: 10px; }
.tabbar { display: flex; gap: 4px; padding: 6px 8px 0; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.tabbar [role="tab"] { font: inherit; font-size: .88rem; font-weight: 700; padding: 8px 14px; border: 1px solid transparent; border-bottom: 0; border-radius: 9px 9px 0 0; background: transparent; color: var(--muted); cursor: pointer; }
.tabbar [role="tab"][aria-selected="true"] { background: var(--surface); color: var(--accent); border-color: var(--border); margin-bottom: -1px; }

/* 챗봇 */
.chat { display: grid; grid-template-rows: minmax(0, 1fr) auto; height: calc(100vh - var(--topbar-h) - 220px); min-height: 520px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.chat-log { overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.msg { max-width: 88%; padding: 12px 16px; border-radius: 16px; line-height: 1.7; }
.msg > :last-child { margin-bottom: 0; }
.msg--user { align-self: flex-end; background: var(--accent); color: var(--accent-text); border-bottom-right-radius: 4px; white-space: pre-wrap; }
.msg--bot { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg--bot pre { background: var(--code-bg); color: var(--code-text); padding: 12px 14px; border-radius: 10px; overflow-x: auto; font-size: .85rem; }
.msg--bot pre code { background: none; border: 0; padding: 0; color: inherit; }
.msg--bot h3, .msg--bot h4 { margin: .8rem 0 .4rem; font-size: 1rem; }
.msg--error { align-self: flex-start; background: var(--bad-soft); color: var(--bad); border: 1px solid var(--bad); }
.msg-who { display: block; font-size: .76rem; font-weight: 800; margin-bottom: 4px; opacity: .8; }
.chat-form { border-top: 1px solid var(--border); padding: 12px; display: grid; gap: 8px; background: var(--surface); }
.chat-input { width: 100%; min-height: 70px; max-height: 260px; resize: vertical; padding: 10px 12px; border-radius: 11px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; }
.chat-input.is-code { font-family: var(--mono); font-size: .88rem; }
.chat-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.chat-suggest { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.typing { display: inline-flex; gap: 4px; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
@media (prefers-reduced-motion: no-preference) {
  .typing span { animation: blink 1.2s infinite both; }
  .typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
  @keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }
}

/* ---------- 푸터 ---------- */
.footer { border-top: 1px solid var(--border); background: var(--surface); }
.footer-inner { max-width: 1560px; margin: 0 auto; padding: 28px 40px; font-size: .9rem; }
.footer-inner p { margin: 0 0 4px; }

/* ---------- 반응형 ---------- */
/* 홈: 질문 입력창 + 대표 메뉴만 */
@media (min-width: 961px) {
  .page-home .sidebar { display: none; }
  .page-home .layout { grid-template-columns: minmax(0, 1fr); }
}
.page-home .content { max-width: 55rem; }
.home-hero { padding: 48px 0 8px; text-align: center; }
.home-hero h1 { font-size: clamp(2rem, 5vw, 3rem); letter-spacing: -0.035em; margin: 0 0 10px; }
.home-hero .lead { margin: 0 auto 24px; color: var(--text-2); }
.home-ask { display: flex; gap: 8px; align-items: stretch; padding: 8px; border: 1px solid var(--border-strong); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); text-align: left; }
.home-ask:focus-within { border-color: var(--accent); }
.home-ask textarea { flex: 1; min-height: 52px; max-height: 220px; resize: vertical; border: 0; padding: 12px 14px; background: transparent; color: var(--text); font: inherit; font-size: 1.05rem; }
.home-ask textarea:focus { outline: none; }
.home-ask .btn { align-self: flex-end; }
#home-ask-help { margin: 10px 0 0; }
.home-answer { margin-top: 18px; padding: 18px 22px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); text-align: left; display: grid; gap: 14px; }
.home-answer .msg-who { display: block; font-size: .8rem; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.home-answer .msg--user { color: var(--text-2); }
.home-answer .msg--error { color: var(--danger, #b91c1c); }
.home-menu { margin: 40px 0 24px; }
.home-menu ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.home-menu a { display: grid; gap: 6px; height: 100%; padding: 28px 26px; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); color: var(--text); text-decoration: none; }
.home-menu a:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.home-menu-icon { font-size: 2rem; }
.home-menu-title { font-size: 1.3rem; font-weight: 800; }
.home-menu-desc { color: var(--text-2); font-size: .95rem; }
@media (max-width: 600px) {
  .home-hero { padding-top: 24px; }
  .home-menu ul { grid-template-columns: minmax(0, 1fr); }
  .home-ask { flex-wrap: wrap; }
  .home-ask textarea { flex-basis: 100%; }
  .home-ask .btn { flex: 1; }
}

@media (max-width: 1240px) {
  .layout.has-toc .main { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 960px) {
  :root { --topbar-h: 3.75rem; }
  .nav-toggle { display: inline-grid; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 40; top: var(--topbar-h); left: 0; width: min(320px, 88vw); background: var(--surface); box-shadow: var(--shadow); transform: translateX(-105%); visibility: hidden; transition: transform .2s, visibility .2s; }
  .sidebar.is-open { transform: none; visibility: visible; }
  .main { padding: 20px 16px 60px; }
  .footer-inner { padding: 24px 16px; }
  .search { margin-left: 0; }
  .search-kbd { display: none; }
  .tool-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
  body { font-size: 1rem; }
  .brand-text { display: none; }
  .topbar-inner { padding: 0 10px; gap: 6px; }
  .pager { grid-template-columns: 1fr; }
  .pager-next { grid-column: 1; }
  .filter { position: static; }
  .msg { max-width: 100%; }
  .demo-stage { padding: 16px; }
}


/* ---------- 인쇄 ---------- */
@media print {
  .topbar, .sidebar, .toc, .footer, .pager, .copy-btn, .skip-link, .filter, .hero-actions, button { display: none !important; }
  .layout, .main, .layout.has-toc .main { display: block; padding: 0; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .code, .demo-inspect { background: #f5f5f5 !important; }
  .code pre { color: #000; white-space: pre-wrap; }
  a { color: #000; }
}

/* ---------- 고대비 모드 ---------- */
@media (forced-colors: active) {
  .badge, .tag, .chip, .seg button, .demo-btn { border: 1px solid CanvasText; }
  .seg button[aria-pressed="true"], .demo-btn[aria-pressed="true"] { outline: 3px solid Highlight; }
}

/* 카드 안 태그는 줄바꿈 허용 (좁은 화면 가로 넘침 방지) */
.ref-card-meta .tag { white-space: normal; overflow-wrap: anywhere; }

/* 네이티브 그룹·검색 요소 */
search { display: block; }
.filter-fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.filter-fieldset > legend { float: left; padding: 0; margin: 0 10px 0 0; line-height: 34px; }
.filter-fieldset > legend + * { clear: none; }
.chip-std { white-space: nowrap; }
.map-table th[scope="row"] { min-width: 230px; }
.map-table td { min-width: 220px; }
.map-table .chip { display: flex; width: fit-content; }

/* ---------- 보기 설정 패널 ---------- */
.view-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-size: .9rem; font-weight: 700; cursor: pointer; }
.view-btn:hover { border-color: var(--accent); color: var(--accent); }
.view-btn[aria-expanded="true"] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.view-panel { position: absolute; right: 16px; top: calc(100% + 6px); z-index: 70; width: min(30rem, calc(100vw - 32px)); max-height: calc(100vh - var(--topbar-h) - 24px); overflow-y: auto; padding: 18px 20px; background: var(--surface); color: var(--text); border: 2px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow); }
.view-panel-title { font-size: 1.15rem; margin: 0 0 10px; }
.view-field { border: 0; margin: 0 0 14px; padding: 0; min-width: 0; }
.view-field legend { font-weight: 800; padding: 0; margin-bottom: 6px; }
.view-opts { display: flex; flex-wrap: wrap; gap: 6px; }
.view-opt { position: relative; }
.view-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.view-opt span { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border: 2px solid var(--border-strong); border-radius: 10px; background: var(--surface); font-weight: 700; cursor: pointer; }
.view-opt input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.view-opt input:checked + span::before { content: "✓ "; white-space: pre; }
.view-opt input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.view-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.view-hint { margin: 10px 0 0; }
@media (max-width: 600px) { .view-btn-text { display: none; } .view-btn { width: 40px; padding: 0; justify-content: center; } .view-panel { right: 8px; } }

/* 글자 크기: rem 기준이므로 루트 크기만 바꿈 */
html[data-fs="115"] { font-size: 115%; }
html[data-fs="130"] { font-size: 130%; }
html[data-fs="150"] { font-size: 150%; }
html[data-fs="175"] { font-size: 175%; }
html[data-fs="200"] { font-size: 200%; }
/* 150% 이상이면 화면이 넓어도 사이드바·목차를 접고 본문 한 단으로 (가로 스크롤 방지) */
html[data-fs="150"] .nav-toggle, html[data-fs="175"] .nav-toggle, html[data-fs="200"] .nav-toggle { display: inline-grid; }
html[data-fs="150"] .layout, html[data-fs="175"] .layout, html[data-fs="200"] .layout,
html[data-fs="150"] .layout.has-toc .main, html[data-fs="175"] .layout.has-toc .main, html[data-fs="200"] .layout.has-toc .main { grid-template-columns: minmax(0, 1fr); }
html[data-fs="150"] .toc, html[data-fs="175"] .toc, html[data-fs="200"] .toc { display: none; }
html[data-fs="150"] .sidebar, html[data-fs="175"] .sidebar, html[data-fs="200"] .sidebar { position: fixed; z-index: 40; top: var(--topbar-h); left: 0; width: min(24rem, 92vw); background: var(--surface); box-shadow: var(--shadow); transform: translateX(-105%); visibility: hidden; transition: transform .2s, visibility .2s; }
html[data-fs="150"] .sidebar.is-open, html[data-fs="175"] .sidebar.is-open, html[data-fs="200"] .sidebar.is-open { transform: none; visibility: visible; }
html[data-fs="150"] .main, html[data-fs="175"] .main, html[data-fs="200"] .main { padding: 20px 16px 60px; }
html[data-fs="175"] .brand-text, html[data-fs="200"] .brand-text { display: none; }
html[data-fs="175"] .search, html[data-fs="200"] .search { margin-left: 0; }

/* 줄 간격·글자 간격 (WCAG 1.4.12 텍스트 간격 기준 이상) */
html[data-lh="wide"] body { line-height: 2; letter-spacing: .04em; word-spacing: .12em; }
html[data-lh="wider"] body { line-height: 2.3; letter-spacing: .08em; word-spacing: .2em; }
html[data-lh="wide"] p, html[data-lh="wide"] li { margin-bottom: 1.4em; }
html[data-lh="wider"] p, html[data-lh="wider"] li { margin-bottom: 1.8em; }

/* 정렬: 확대해서 읽을 때 줄 시작을 찾기 쉽게 모두 왼쪽 정렬 */
html[data-align="left"] body * { text-align: left !important; }
html[data-align="left"] .home-hero .lead { margin-left: 0; }

/* ---------- 큰 버튼 ---------- */
.btn--lg { min-height: 52px; padding: 0 24px; font-size: 1.05rem; }

/* ---------- AI 퀴즈 ---------- */
.quiz-setup, .quiz-play, .quiz-summary { margin: 0 0 2.6rem; }
.quiz-field { border: 0; margin: 0 0 1.4rem; padding: 0; min-width: 0; }
.quiz-field > legend { font-weight: 800; font-size: 1.08rem; padding: 0; margin-bottom: 8px; }
.quiz-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(12rem, 100%), 1fr)); gap: 8px; }
.quiz-choice { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border: 2px solid var(--border); border-radius: 12px; background: var(--surface); cursor: pointer; }
.quiz-choice:hover { border-color: var(--accent); }
.quiz-choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.quiz-choice--wide { grid-column: 1 / -1; }
.quiz-choice input { width: 1.25rem; height: 1.25rem; margin: .2em 0 0; flex: none; accent-color: var(--accent); }
.quiz-choice span { display: grid; gap: 2px; }
.quiz-choice span strong { font-size: 1.02rem; }
.quiz-start, .quiz-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 1rem; }
.quiz-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.quiz-progress { margin: 0; font-weight: 800; font-size: 1.05rem; }
.quiz-loading { padding: 28px; border: 2px dashed var(--border-strong); border-radius: var(--radius); font-size: 1.05rem; }
.quiz-card { padding: 24px 26px; border: 2px solid var(--border-strong); border-radius: 16px; background: var(--surface); }
.quiz-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 10px; }
.quiz-note { font-size: .9rem; color: var(--warn); font-weight: 700; }
.quiz-question { font-size: 1.4rem; line-height: 1.5; margin: 0 0 16px; }
.quiz-question:focus { outline: none; }
.quiz-question:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }
.quiz-code { margin: 0 0 16px; padding: 16px 18px; background: var(--code-bg); color: var(--code-text); border: 1px solid var(--code-border); border-radius: 12px; overflow-x: auto; font-size: 1rem; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.quiz-options { border: 0; margin: 0; padding: 0; min-width: 0; }
.quiz-options > div { display: grid; gap: 10px; }
.quiz-option { display: flex; align-items: flex-start; flex-wrap: wrap; gap: 12px; padding: 14px 16px; border: 2px solid var(--border-strong); border-radius: 12px; background: var(--surface); cursor: pointer; font-size: 1.08rem; line-height: 1.55; }
.quiz-option:hover { border-color: var(--accent); }
.quiz-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.quiz-option input { width: 1.35rem; height: 1.35rem; margin: .15em 0 0; flex: none; accent-color: var(--accent); }
.quiz-option-num { flex: none; display: inline-grid; place-items: center; min-width: 1.8rem; height: 1.8rem; border-radius: 8px; background: var(--surface-3); font-weight: 800; }
.quiz-option-text { flex: 1 1 12rem; min-width: 0; }
.quiz-options:disabled .quiz-option { cursor: default; }
.quiz-option.is-answer, .quiz-option.is-answer:has(input:checked) { border-color: var(--good); background: var(--good-soft); border-width: 3px; box-shadow: none; }
.quiz-option.is-wrong, .quiz-option.is-wrong:has(input:checked) { border-color: var(--bad); background: var(--bad-soft); border-style: dashed; border-width: 3px; box-shadow: none; }
.quiz-options:disabled .quiz-option:hover { border-color: var(--border-strong); }
.quiz-options:disabled .quiz-option.is-answer:hover { border-color: var(--good); }
.quiz-options:disabled .quiz-option.is-wrong:hover { border-color: var(--bad); }
.quiz-option-tag { flex-basis: 100%; font-weight: 800; font-size: .95rem; }
.quiz-option.is-answer .quiz-option-tag { color: var(--good); }
.quiz-option.is-wrong .quiz-option-tag { color: var(--bad); }
.quiz-feedback { margin-top: 16px; padding: 20px 24px; border-radius: 16px; border: 2px solid var(--border-strong); background: var(--surface); }
.quiz-feedback.is-ok { border-color: var(--good); }
.quiz-feedback.is-bad { border-color: var(--bad); }
.quiz-feedback h3 { margin: 0 0 10px; font-size: 1.3rem; }
.quiz-feedback.is-ok h3 { color: var(--good); }
.quiz-feedback.is-bad h3 { color: var(--bad); }
.quiz-feedback h3:focus { outline: none; }
.quiz-feedback h3:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }
#quiz-explain p { font-size: 1.05rem; }
.quiz-ask { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.quiz-ask h4 { margin: 0 0 10px; }
.quiz-ask-log { display: grid; gap: 12px; margin-bottom: 12px; }
.quiz-ask-log:empty { display: none; }
.quiz-ask .chat-suggest { margin: 10px 0 0; }
.quiz-score { font-size: 1.3rem; }
.quiz-bar { display: inline-block; vertical-align: middle; width: 6rem; height: .7rem; border: 1px solid var(--border-strong); border-radius: 99px; overflow: hidden; background: var(--surface-2); }
.quiz-bar span { display: block; height: 100%; background: var(--accent); }
.quiz-weak { color: var(--bad); }
.quiz-wrong-list { padding-left: 1.2rem; }
.quiz-wrong-list li { margin-bottom: .8rem; }
.quiz-record { margin-top: 3rem; padding-top: 1.6rem; border-top: 1px solid var(--border); }
@media (max-width: 600px) {
  .quiz-card, .quiz-feedback { padding: 16px; }
  .quiz-question { font-size: 1.2rem; }
  .quiz-actions .btn, .quiz-start .btn { flex: 1 1 100%; }
}

/* ---------- 고대비 모드 (보기 설정 또는 운영체제의 대비 높이기 설정) ---------- */
:root[data-contrast="high-dark"] {
  --bg: #000; --surface: #000; --surface-2: #111; --surface-3: #222;
  --text: #fff; --text-2: #fff; --muted: #e8e8e8;
  --border: #fff; --border-strong: #fff;
  --accent: #ffe14d; --accent-hover: #fff3a6; --accent-soft: #2a2500; --accent-text: #000;
  --good: #7dff8a; --good-soft: #002a06; --bad: #ff9a9a; --bad-soft: #2e0000; --warn: #ffd27a; --warn-soft: #2a1d00;
  --info: #9fd0ff; --info-soft: #001a33; --state: #ffa6d2; --state-soft: #2a0016; --prop: #8ff0ff; --prop-soft: #002a30;
  --code-bg: #000; --code-text: #fff; --code-border: #fff;
  --focus: #ffe14d; --shadow: none;
  color-scheme: dark;
}
:root[data-contrast="high-light"] {
  --bg: #fff; --surface: #fff; --surface-2: #f2f2f2; --surface-3: #e0e0e0;
  --text: #000; --text-2: #000; --muted: #1f1f1f;
  --border: #000; --border-strong: #000;
  --accent: #0000b8; --accent-hover: #00006e; --accent-soft: #e6e6ff; --accent-text: #fff;
  --good: #005c12; --good-soft: #e3f5e6; --bad: #a30000; --bad-soft: #ffe5e5; --warn: #6b3d00; --warn-soft: #fff1d6;
  --info: #003f7d; --info-soft: #e5f0ff; --state: #7a003c; --state-soft: #ffe8f3; --prop: #004652; --prop-soft: #e2f6f9;
  --code-bg: #000; --code-text: #fff; --code-border: #000;
  --focus: #c00000; --shadow: none;
  color-scheme: light;
}
:root[data-contrast^="high"] a { text-decoration: underline; text-decoration-thickness: 2px; }
:root[data-contrast^="high"] :focus-visible { outline-width: 4px; outline-offset: 3px; }
:root[data-contrast^="high"] .btn, :root[data-contrast^="high"] .btn-sm, :root[data-contrast^="high"] .icon-btn,
:root[data-contrast^="high"] input, :root[data-contrast^="high"] textarea, :root[data-contrast^="high"] select { border: 2px solid var(--border-strong); }
:root[data-contrast^="high"] .grad { background: none; color: var(--text); }
:root[data-contrast^="high"] .topbar { background: var(--surface); backdrop-filter: none; border-bottom: 2px solid var(--border); }
:root[data-contrast^="high"] .tag, :root[data-contrast^="high"] .chip, :root[data-contrast^="high"] .badge { border: 1px solid var(--border); }
:root[data-contrast^="high"] ::placeholder { color: var(--muted); opacity: 1; }
:root[data-contrast^="high"] .home-ask textarea { border: 0; }
:root[data-contrast^="high"] .home-menu a { text-decoration: none; border-width: 2px; }
:root[data-contrast^="high"] .home-menu a:hover .home-menu-title, :root[data-contrast^="high"] .home-menu a:focus-visible .home-menu-title { text-decoration: underline; }
