/* =========================================================================
   study-web — SaaS 리디자인 스타일
   레이아웃: [아이콘 레일] [접이식 사이드바] [본문]
   프레임워크 없음. CSS 변수로 라이트/다크. 기능 클래스 선택자는 보존.
   ========================================================================= */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Newsreader:opsz,wght@6..72,400;6..72,500;6..72,600&display=swap');

:root {
  /* 기본 테마 = 세이지 (전체 표면·브랜드까지 은은한 녹조) */
  --bg: #fafcfb;
  --bg-elev: #ffffff;
  --bg-soft: #eef3f0;
  --bg-rail: #f4f8f5;
  --text: #1b1c1e;
  --text-soft: #5b5e63;
  --text-dim: #9a9da3;
  --border: #e7ece9;
  --border-strong: #dbe2dd;
  --brand: #34403a;            /* 세이지 그래파이트 (활성·버튼·링크) */
  --brand-2: #4a564f;
  --brand-soft: #e6efe9;       /* 활성 배경 — 은은한 녹조 */
  --brand-text: #34403a;
  --on-brand: #ffffff;         /* brand 배경 위 글자색 */
  --accent: #4f6f64;           /* 절제된 딥 세이지 그린 포인트 */
  --accent-tint: #eaf0ed;      /* 펼친 섹션 헤더 배경 */
  --ok: #3f7d54;
  --warn: #9a6a2e;
  --err: #b04a45;
  --code-bg: #1b1d1f;
  --code-text: #e7e6e2;
  --shadow-sm: 0 1px 2px rgba(28,28,30,.04);
  --shadow: 0 1px 2px rgba(28,28,30,.05), 0 1px 1px rgba(28,28,30,.03);
  --shadow-md: 0 8px 24px rgba(28,28,30,.07);
  --shadow-lg: 0 24px 60px rgba(28,28,30,.16);
  --radius: 10px;
  --radius-lg: 16px;
  --rail-w: 76px;
  --sidebar-w: 274px;
  --maxw: 1120px;
  --mono: "SFMono-Regular", ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard",
          "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
  --serif: "Newsreader", "Apple SD Gothic Neo", Georgia, "Noto Serif KR", serif;
}

html[data-theme="dark"] {
  /* 기본 테마 = 세이지 (다크, 은은한 녹조) */
  --bg: #0c0e0d;
  --bg-elev: #151716;
  --bg-soft: #1b1e1c;
  --bg-rail: #0f1110;
  --text: #ecebe7;
  --text-soft: #a8a8a2;
  --text-dim: #71726d;
  --border: #262a27;
  --border-strong: #333830;
  --brand: #bdc9c2;            /* 밝은 세이지 그래파이트(다크 활성·링크) */
  --brand-2: #9eaaa3;
  --brand-soft: #1d231f;       /* 활성 배경 — 은은한 녹조 */
  --brand-text: #cad6cf;
  --on-brand: #141816;         /* 밝은 brand 배경 위 어두운 글자 */
  --accent: #8fb3a4;           /* 세이지 그린 포인트(다크) */
  --accent-tint: #20272a;      /* 펼친 섹션 헤더 배경(다크) */
  --code-bg: #0a0b0b;
  --code-text: #e7e6e2;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow: 0 1px 3px rgba(0,0,0,.45);
  --shadow-md: 0 8px 24px rgba(0,0,0,.5);
  --shadow-lg: 0 20px 56px rgba(0,0,0,.62);
}

/* ── 색상 테마 — 표면·브랜드·액센트까지 한 색조로, 채도는 아주 낮게 ── */
/* 기본(sage)은 :root 사용. 나머지는 data-accent 로 전체 토큰을 덮어씀. */

/* 슬레이트 (청회) */
html[data-accent="slate"] {
  --bg: #fafbfc; --bg-soft: #eef1f4; --bg-rail: #f4f6f9;
  --border: #e6eaef; --border-strong: #dae0e7;
  --brand: #353d49; --brand-2: #4b535f; --brand-soft: #e6ebf1; --brand-text: #353d49;
  --accent: #566a82; --accent-tint: #e9edf2;
}
/* 클레이 (흙빛) */
html[data-accent="clay"] {
  --bg: #fdfbfa; --bg-soft: #f3efeb; --bg-rail: #f9f6f3;
  --border: #ece5e0; --border-strong: #e2dad1;
  --brand: #43382f; --brand-2: #594c41; --brand-soft: #efe7e0; --brand-text: #43382f;
  --accent: #9a6650; --accent-tint: #f1eae6;
}
/* 플럼 (보랏빛 회색) */
html[data-accent="plum"] {
  --bg: #fcfbfc; --bg-soft: #f1eef3; --bg-rail: #f7f5f9;
  --border: #eae6ec; --border-strong: #e0dae4;
  --brand: #3c3540; --brand-2: #524956; --brand-soft: #ece6f0; --brand-text: #3c3540;
  --accent: #6f5d7e; --accent-tint: #eeebf1;
}
/* 그래파이트 (중립) */
html[data-accent="graphite"] {
  --bg: #fbfbfa; --bg-soft: #f4f4f2; --bg-rail: #f9f9f7;
  --border: #eceae6; --border-strong: #e0ded9;
  --brand: #2f3437; --brand-2: #474c50; --brand-soft: #f0efeb; --brand-text: #2f3437;
  --accent: #5b6166; --accent-tint: #eceded;
}

/* 다크 모드 — 밝고 부드러운 변형 */
html[data-theme="dark"][data-accent="slate"] {
  --bg: #0c0d0f; --bg-soft: #1b1d20; --bg-rail: #0f1012;
  --border: #25272b; --border-strong: #323640;
  --brand: #b6c0cc; --brand-2: #97a2af; --brand-soft: #1c2027; --brand-text: #c3cdd9;
  --accent: #93a7c0; --accent-tint: #1d2530;
}
html[data-theme="dark"][data-accent="clay"] {
  --bg: #0f0d0c; --bg-soft: #201c1a; --bg-rail: #120f0e;
  --border: #2b2724; --border-strong: #3a342e;
  --brand: #ccc0b6; --brand-2: #afa297; --brand-soft: #241e1a; --brand-text: #d9cdc3;
  --accent: #c79784; --accent-tint: #2b231f;
}
html[data-theme="dark"][data-accent="plum"] {
  --bg: #0e0c0f; --bg-soft: #1e1b20; --bg-rail: #110f12;
  --border: #292630; --border-strong: #373240;
  --brand: #c4bacb; --brand-2: #a597af; --brand-soft: #221d27; --brand-text: #d1c8d9;
  --accent: #b0a0bf; --accent-tint: #261f2b;
}
html[data-theme="dark"][data-accent="graphite"] {
  --bg: #0d0e0e; --bg-soft: #1d1e1e; --bg-rail: #101111;
  --border: #272826; --border-strong: #34352f;
  --brand: #c9c9c2; --brand-2: #a9a9a2; --brand-soft: #232422; --brand-text: #d6d6cf;
  --accent: #a9aeb2; --accent-tint: #232527;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 84px; }
body {
  margin: 0; font-family: var(--sans); background: var(--bg); color: var(--text);
  line-height: 1.7; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: var(--brand-text); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: color-mix(in srgb, var(--brand) 26%, transparent); }

/* ===================== 레이아웃 ===================== */
.layout { display: flex; min-height: 100vh; }

/* ----- 아이콘 레일 ----- */
.cat-rail {
  width: var(--rail-w); flex-shrink: 0; background: var(--bg-rail);
  border-right: 1px solid var(--border); position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 14px 8px; overflow-y: auto; z-index: 40;
}
.cat-rail::-webkit-scrollbar { width: 0; }
.rail-logo {
  width: 40px; height: 40px; border-radius: 11px; margin-bottom: 10px;
  display: grid; place-items: center; color: var(--on-brand);
  font-family: var(--serif); font-size: 20px; font-weight: 600;
  background: var(--brand); box-shadow: none;
}
.rail-logo:hover { text-decoration: none; }
.search-trigger svg { width: 15px; height: 15px; stroke: currentColor; }
.search-bar .search-ic svg { width: 17px; height: 17px; stroke: var(--text-dim); }
.rail-logo:hover { text-decoration: none; filter: brightness(1.05); }
.rail-btn {
  width: 100%; max-width: 60px; border-radius: 12px; padding: 9px 2px 7px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--text-soft); position: relative; transition: background .12s, color .12s;
}
.rail-btn:hover { background: var(--bg-soft); color: var(--text); text-decoration: none; }
.rail-btn .rail-ic { line-height: 0; }
.rail-btn .rail-ic svg { width: 20px; height: 20px; display: block; stroke: currentColor; }
.rail-btn .rail-lb { font-size: 10px; font-weight: 600; letter-spacing: -.2px; }
.rail-btn.active { background: var(--brand-soft); color: var(--brand-text); }
.rail-btn.active::before {
  content: ""; position: absolute; left: -8px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 22px; border-radius: 0 3px 3px 0; background: var(--brand);
}

/* ----- 사이드바 ----- */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: var(--bg-elev);
  border-right: 1px solid var(--border); position: sticky; top: 0; height: 100vh;
  overflow-y: auto; padding: 16px 12px 48px;
}
.sb-head {
  display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 15px;
  letter-spacing: -.2px; padding: 8px 10px 14px; color: var(--text);
}
.sb-head .sb-ic { font-size: 17px; }
.sb-section { margin-bottom: 4px; }
.sb-sectitle {
  width: 100%; display: flex; align-items: center; gap: 9px; cursor: pointer;
  background: none; border: none; color: var(--text); font-family: inherit;
  font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  padding: 10px 10px; text-align: left; border-radius: 8px; transition: color .15s, background .15s;
}
.sb-sectitle:hover { background: var(--bg-soft); }
/* 박스형 펼침/접힘 인디케이터 */
.sb-sectitle .chev {
  display: inline-grid; place-items: center; width: 20px; height: 20px; flex-shrink: 0;
  font-size: 12px; font-weight: 800; line-height: 1; border-radius: 6px;
  border: 1px solid var(--line); color: var(--text-dim);
  transition: transform .2s, color .15s, background .15s, border-color .15s;
}
/* 펼침 상태: 제목 진하게 + 인디케이터 채움(▾ 아래) */
.sb-section:not(.collapsed) > .sb-sectitle { color: var(--text); }
.sb-section:not(.collapsed) > .sb-sectitle .chev {
  color: var(--on-brand); background: var(--accent); border-color: var(--accent);
}
/* 접힘 상태: 제목 흐리게 + 인디케이터 외곽선만(▸ 오른쪽) */
.sb-section.collapsed > .sb-sectitle { color: var(--text-dim); }
.sb-section.collapsed > .sb-sectitle .chev { transform: rotate(-90deg); }
.sb-section.collapsed .sb-list { display: none; }
/* 단일 페이지 토픽(챕터 없음) — 사이드바 루트의 평면 링크 */
.sb-toplink { margin: 1px 0; }
.sb-list { display: flex; flex-direction: column; gap: 1px; }
.navlink {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px;
  color: var(--text-soft); font-size: 14px; font-weight: 500; line-height: 1.35;
}
.navlink:hover { background: var(--bg-soft); color: var(--text); text-decoration: none; }
.navlink .num {
  flex-shrink: 0; font-size: 11px; font-weight: 700; min-width: 22px; height: 22px; padding: 0 4px;
  border-radius: 6px; display: grid; place-items: center; background: var(--bg-soft); color: var(--text-dim);
}
.navlink.active { background: var(--brand-soft); color: var(--brand-text); font-weight: 700; }
.navlink.active .num { background: var(--brand); color: var(--on-brand); }

/* ----- 콘텐츠 / 탑바 ----- */
.content { flex: 1; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 0 26px; height: 56px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-elev) 82%, transparent);
  backdrop-filter: saturate(180%) blur(10px); position: sticky; top: 0; z-index: 30;
}
.topbar .crumb { color: var(--text-dim); font-size: 13.5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .crumb b { color: var(--text); font-weight: 700; }
.topbar .actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.icon-btn {
  border: 1px solid var(--border-strong); background: var(--bg-elev); color: var(--text-soft);
  width: 34px; height: 34px; border-radius: 9px; cursor: pointer; display: grid; place-items: center; font-size: 15px;
}
.icon-btn:hover { color: var(--text); border-color: var(--brand); }
.icon-btn svg { width: 17px; height: 17px; stroke: currentColor; }
.hamburger { display: none; }

/* 색상 테마 선택 팝오버 */
.accent-wrap { position: relative; display: inline-flex; }
.accent-btn.accent-btn { color: var(--accent); }
.accent-pop {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 60;
  min-width: 176px; padding: 7px; border-radius: 12px;
  background: var(--bg-elev); border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-md);
  opacity: 0; visibility: hidden; transform: translateY(-4px);
  transition: opacity .14s, transform .14s, visibility .14s;
}
.accent-wrap.open .accent-pop { opacity: 1; visibility: visible; transform: translateY(0); }
.accent-pop-title {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-dim); padding: 4px 8px 6px;
}
.accent-opt {
  width: 100%; display: flex; align-items: center; gap: 10px; cursor: pointer;
  background: none; border: none; font-family: inherit; font-size: 13.5px; color: var(--text-soft);
  padding: 7px 8px; border-radius: 8px; text-align: left;
}
.accent-opt:hover { background: var(--bg-soft); color: var(--text); }
.accent-opt.on { color: var(--text); font-weight: 600; }
.accent-swatch {
  width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0;
  box-shadow: 0 0 0 1px var(--border) inset;
}
.accent-opt.on .accent-swatch { box-shadow: 0 0 0 2px var(--bg-elev) inset, 0 0 0 3.5px var(--accent); }

.article { max-width: var(--maxw); margin: 0 auto; padding: 38px 34px 96px; }
/* 검색·앵커 이동 시 sticky 헤더에 가리지 않도록 여백 */
.article h1, .article h2, .article h3, .article h4, .article .pat, .ex { scroll-margin-top: 84px; }
.article > p, .article > ul, .article > ol, .article > h1, .article > h2, .article > h3,
.article > h4, .article > .lead, .article > .callout, .article > .analogy, .article > .steps,
.article > .hero { max-width: 820px; }
.article > .codeblock, .article > .playground, .article > table, .article > .cards,
.article > .diagram, .article > .apisim { max-width: 100%; }

/* ===================== 타이포 ===================== */
.article h1 { font-family: var(--serif); font-size: 37px; font-weight: 560; letter-spacing: -.012em; margin: 6px 0 10px; line-height: 1.16; }
.article .lead { font-size: 18px; line-height: 1.68; margin: 0 0 34px; color: var(--text-soft); font-weight: 400; }
.article h2 {
  font-family: var(--serif); font-size: 26px; font-weight: 540; margin: 52px 0 14px; padding-top: 22px;
  border-top: 1px solid var(--border); letter-spacing: -.01em; line-height: 1.25;
}
.article h3 { font-size: 17.5px; font-weight: 650; margin: 32px 0 10px; letter-spacing: -.01em; }
.article h4 { font-size: 14px; font-weight: 650; margin: 22px 0 8px; color: var(--text-soft); letter-spacing: .01em; }
.article p { margin: 13px 0; }
.article ul, .article ol { padding-left: 22px; margin: 13px 0; }
.article li { margin: 6px 0; }
.article strong { font-weight: 700; }
.article hr { border: none; border-top: 1px solid var(--border); margin: 34px 0; }
.article code:not([class]) {
  font-family: var(--mono); font-size: .86em; background: var(--bg-soft); color: var(--brand-text);
  padding: 2px 6px; border-radius: 6px; border: 1px solid var(--border);
}

/* ===================== 카드 / 콜아웃 ===================== */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 16px; margin: 26px 0; }
.card {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 20px; box-shadow: var(--shadow-sm); display: block; color: inherit;
  transition: transform .14s, border-color .14s, box-shadow .14s;
}
a.card:hover { text-decoration: none; transform: translateY(-3px); border-color: var(--brand); box-shadow: var(--shadow-md); }
.card .card-num { font-size: 11.5px; font-weight: 800; color: var(--brand-text); letter-spacing: .02em; text-transform: uppercase; }
.card h3 { margin: 8px 0 6px; font-size: 17px; letter-spacing: -.2px; }
.card p { margin: 0; color: var(--text-soft); font-size: 13.5px; }

.callout {
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  background: var(--bg-elev); border-radius: 12px; padding: 14px 16px; margin: 18px 0; box-shadow: var(--shadow-sm);
}
.callout .callout-title { font-weight: 700; margin-bottom: 4px; }
.callout.tip { border-left-color: var(--ok); }
.callout.warn { border-left-color: var(--warn); }
.callout.danger { border-left-color: var(--err); }
.callout.note { border-left-color: var(--brand); }
.callout p:first-child { margin-top: 0; } .callout p:last-child { margin-bottom: 0; }

.usage {
  border: 1px solid var(--border); border-left: 3px solid var(--brand);
  background: var(--bg-elev); border-radius: 12px; padding: 14px 16px; margin: 18px 0; box-shadow: var(--shadow-sm);
}
.usage .usage-title { font-weight: 700; font-size: 13px; color: var(--brand-text); letter-spacing: .02em; margin-bottom: 5px; }
.usage ul { margin: 6px 0 0; padding-left: 20px; } .usage li { margin: 5px 0; } .usage li b { color: var(--text); }

.analogy {
  background: linear-gradient(180deg, var(--brand-soft), transparent);
  border: 1px solid var(--border); border-radius: 12px; padding: 13px 16px; margin: 15px 0; font-size: 14.5px;
}
.analogy::before { content: "비유"; display: inline-block; font-weight: 800; color: var(--brand-text); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; margin-right: 8px; }

/* 표 */
.article table { width: 100%; border-collapse: collapse; margin: 18px 0; font-size: 14px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.article th, .article td { border-bottom: 1px solid var(--border); padding: 10px 13px; text-align: left; vertical-align: top; }
.article th { background: var(--bg-soft); font-weight: 700; }
.article tbody tr:last-child td { border-bottom: none; }
.article tbody tr:hover td { background: color-mix(in srgb, var(--brand) 4%, transparent); }

/* ===================== 코드블록 ===================== */
.codeblock { position: relative; margin: 18px 0; }
.codeblock pre {
  margin: 0; background: var(--code-bg); color: var(--code-text); border: 1px solid var(--border-strong);
  border-radius: 12px; padding: 18px 20px; overflow-x: auto; font-family: var(--mono); font-size: 13.5px; line-height: 1.7;
}
.codeblock .cb-tools { position: absolute; top: 9px; right: 9px; display: flex; gap: 6px; opacity: .55; transition: opacity .12s; }
.codeblock:hover .cb-tools { opacity: 1; }
.codeblock .copy-btn, .codeblock .expand-btn {
  background: rgba(255,255,255,.08); color: #cbd5e1; border: 1px solid rgba(255,255,255,.14);
  border-radius: 7px; font-size: 12px; padding: 4px 9px; cursor: pointer;
}
.codeblock .copy-btn:hover, .codeblock .expand-btn:hover { background: rgba(255,255,255,.18); color: #fff; }
.tok-key { color: #c792ea; } .tok-str { color: #c3e88d; } .tok-com { color: #6b7a8d; font-style: italic; }
.tok-num { color: #f78c6c; } .tok-fn { color: #82aaff; } .tok-tag { color: #f07178; }

/* ===================== 용어 (?) 툴팁/모달 ===================== */
.term { border-bottom: 1.5px dotted var(--accent); cursor: help; font-weight: 600; white-space: nowrap; }
.term .q {
  font-size: .62em; font-weight: 800; color: var(--on-brand); background: var(--accent); border-radius: 50%;
  padding: 0 .34em; margin-left: 2px; vertical-align: top; position: relative; top: -.1em; cursor: pointer;
}
.term:hover { background: var(--brand-soft); }
#tooltip {
  position: fixed; z-index: 100; max-width: 300px; background: var(--text); color: var(--bg-elev);
  padding: 9px 12px; border-radius: 9px; font-size: 13px; line-height: 1.5; box-shadow: var(--shadow-lg);
  pointer-events: none; opacity: 0; transform: translateY(4px); transition: opacity .12s, transform .12s;
}
#tooltip.show { opacity: 1; transform: translateY(0); }
#tooltip .tt-term { font-weight: 800; display: block; margin-bottom: 2px; }
#tooltip .tt-more { display: block; margin-top: 5px; font-size: 11.5px; opacity: .8; }
.modal-overlay { position: fixed; inset: 0; background: rgba(10,12,18,.55); display: none; align-items: center; justify-content: center; z-index: 120; padding: 20px; backdrop-filter: blur(2px); }
.modal-overlay.show { display: flex; }
.modal { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 16px; max-width: 540px; width: 100%; max-height: 84vh; overflow-y: auto; box-shadow: var(--shadow-lg); padding: 24px 26px; }
.modal .modal-kicker { font-size: 12px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .06em; }
.modal h3 { margin: 4px 0 12px; font-size: 22px; }
.modal .modal-body { color: var(--text-soft); } .modal .modal-body p { margin: 10px 0; }
.modal .modal-example { margin-top: 14px; }
.modal .modal-related { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 13.5px; }
.modal .modal-related .chip { display: inline-block; background: var(--brand-soft); color: var(--brand-text); border-radius: 999px; padding: 3px 11px; margin: 3px 4px 0 0; font-size: 13px; cursor: pointer; font-weight: 600; }
.modal .modal-close { float: right; border: none; background: var(--bg-soft); color: var(--text-soft); width: 32px; height: 32px; border-radius: 8px; cursor: pointer; font-size: 18px; }
.modal .modal-close:hover { color: var(--text); }

/* ===================== 라이브 플레이그라운드 ===================== */
.playground { border: 1px solid var(--border-strong); border-radius: 14px; overflow: hidden; margin: 18px 0; background: var(--bg-elev); box-shadow: var(--shadow-sm); }
.pg-head { display: flex; align-items: center; justify-content: space-between; padding: 9px 13px; background: var(--bg-soft); border-bottom: 1px solid var(--border); }
.pg-variant { display: inline-flex; background: var(--bg-elev); border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; margin-right: 10px; }
.pg-variant .pg-vbtn { border: none; background: transparent; color: var(--text-soft); font-family: inherit; font-size: 12px; font-weight: 700; padding: 4px 11px; cursor: pointer; }
.pg-variant .pg-vbtn.active { background: var(--brand); color: var(--on-brand); }
.pg-head .pg-title { font-size: 13px; font-weight: 700; color: var(--text-soft); display: flex; gap: 7px; align-items: center; }
.pg-actions { display: flex; gap: 7px; }
.pg-btn { border: 1px solid var(--border-strong); background: var(--bg-elev); color: var(--text); border-radius: 8px; padding: 5px 12px; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.pg-btn:hover { border-color: var(--brand); }
.pg-btn.run { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.pg-btn.run:hover { filter: brightness(1.07); }
.pg-body { display: grid; grid-template-columns: 1.15fr 1fr; min-height: 300px; }
.pg-body.stacked { grid-template-columns: 1fr; }
.pg-editor { border-right: 1px solid var(--border); position: relative; }
.pg-body.stacked .pg-editor { border-right: none; border-bottom: 1px solid var(--border); }
.pg-editor textarea { width: 100%; height: 100%; min-height: 300px; border: none; resize: vertical; font-family: var(--mono); font-size: 14px; line-height: 1.7; padding: 16px 18px; background: var(--code-bg); color: var(--code-text); tab-size: 2; outline: none; display: block; }
.pg-result { display: flex; flex-direction: column; background: var(--bg-elev); }
.pg-result .pg-preview { flex: 1; }
.pg-result iframe { width: 100%; height: 100%; min-height: 240px; border: none; background: var(--bg-elev); }
.pg-console { font-family: var(--mono); font-size: 12px; padding: 8px 12px; background: #1a1f29; color: #9aa6b6; border-top: 1px solid #2a3543; max-height: 120px; overflow-y: auto; white-space: pre-wrap; display: none; }
.pg-console.show { display: block; } .pg-console.error { color: #fca5a5; }
.codemirror-wrap .CodeMirror { height: auto; min-height: 220px; font-family: var(--mono); font-size: 13px; }

/* 코드 "크게 보기" 버튼/팝업 */
.big-overlay { position: fixed; inset: 0; background: rgba(10,12,18,.62); z-index: 200; display: none; align-items: center; justify-content: center; padding: 24px; backdrop-filter: blur(2px); }
.big-overlay.show { display: flex; }
.big-modal { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 16px; width: min(1400px, 96vw); height: 92vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); overflow: hidden; }
.big-modal-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 15px; border-bottom: 1px solid var(--border); background: var(--bg-soft); }
.big-modal-bar .big-title { font-weight: 700; font-size: 14px; color: var(--text-soft); }
.big-modal-close { border: 1px solid var(--border-strong); background: var(--bg-elev); color: var(--text); border-radius: 8px; padding: 6px 14px; font-size: 13px; font-weight: 600; cursor: pointer; }
.big-modal-close:hover { border-color: var(--brand); }
.big-modal-host { flex: 1; min-height: 0; display: flex; padding: 15px; overflow: auto; }
.big-modal-host .playground { flex: 1; margin: 0; }
.big-modal-host > pre { flex: 1; margin: 0; background: var(--code-bg); color: var(--code-text); border-radius: 12px; padding: 20px 22px; overflow: auto; font-family: var(--mono); font-size: 15px; line-height: 1.75; }
.playground.pg-expanded .pg-body { min-height: 74vh; }
.playground.pg-expanded .pg-editor textarea, .playground.pg-expanded .pg-result iframe { min-height: 74vh; }

/* ===================== 단계 다이어그램 (viz.js) ===================== */
.diagram { border: 1px solid var(--border-strong); border-radius: 14px; background: var(--bg-elev); box-shadow: var(--shadow-sm); margin: 18px 0; overflow: hidden; }
.diagram .viz-stage { padding: 24px 20px; min-height: 240px; }
.diagram .viz-step { display: none; }
.diagram .viz-step.active { display: block; animation: vizfade .25s ease; }
@keyframes vizfade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.viz-caption { font-size: 14.5px; color: var(--text-soft); margin: 0 0 16px; min-height: 44px; }
.viz-caption b { color: var(--text); }
.viz-controls { display: flex; align-items: center; gap: 10px; padding: 11px 15px; border-top: 1px solid var(--border); background: var(--bg-soft); }
.viz-controls .viz-btn { border: 1px solid var(--border-strong); background: var(--bg-elev); color: var(--text); border-radius: 8px; padding: 6px 14px; font-size: 13px; font-weight: 600; cursor: pointer; }
.viz-controls .viz-btn:hover:not(:disabled) { border-color: var(--brand); }
.viz-controls .viz-btn:disabled { opacity: .4; cursor: default; }
.viz-controls .viz-btn.primary { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.viz-controls .viz-pos { font-size: 13px; color: var(--text-dim); margin-left: auto; }
.viz-dots { display: flex; gap: 6px; }
.viz-dots .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); }
.viz-dots .dot.on { background: var(--brand); }
.viz-row { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; }
.viz-col { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.viz-node { border: 2px solid var(--border-strong); border-radius: 10px; background: var(--bg-soft); padding: 10px 14px; font-family: var(--mono); font-size: 13px; font-weight: 600; min-width: 76px; text-align: center; transition: all .3s; }
.viz-node .viz-tag { display: block; font-size: 10.5px; color: var(--text-dim); font-family: var(--sans); font-weight: 600; }
.viz-node.is-changed { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 16%, var(--bg-elev)); color: var(--text); }
.viz-node.is-same { opacity: .5; }
.viz-node.is-active { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-text); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 16%, transparent); }
.viz-node.is-applied { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 16%, var(--bg-elev)); }
.viz-arrow { font-size: 22px; color: var(--text-dim); }
.viz-label-col { font-size: 12px; font-weight: 700; color: var(--text-dim); width: 64px; text-align: right; }
.viz-box { border: 1.5px solid var(--border-strong); border-radius: 10px; padding: 10px 14px; background: var(--bg-soft); font-size: 13.5px; min-width: 110px; text-align: center; transition: all .3s; }
.viz-box.is-active { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-text); }
.viz-box.is-cache { border-color: var(--accent); }
.viz-box.is-stale { border-style: dashed; opacity: .6; }
.viz-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-soft); margin-top: 16px; justify-content: center; }
.viz-legend span { display: inline-flex; align-items: center; gap: 6px; }
.viz-legend i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; border: 2px solid; }
.viz-legend i.changed { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 16%, transparent); }
.viz-legend i.active { border-color: var(--brand); background: var(--brand-soft); }
.viz-legend i.applied { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 16%, transparent); }

/* ===================== API 시뮬레이터 (apisim.js) ===================== */
.apisim { border: 1px solid var(--border-strong); border-radius: 14px; background: var(--bg-elev); box-shadow: var(--shadow-sm); margin: 18px 0; overflow: hidden; }
.apisim-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 11px 15px; background: var(--bg-soft); border-bottom: 1px solid var(--border); }
.apisim-method { font-family: var(--mono); font-weight: 800; font-size: 12px; color: #fff; border-radius: 6px; padding: 3px 8px; letter-spacing: .03em; }
.apisim-method.get { background: #16a34a; } .apisim-method.post { background: var(--brand); color: var(--on-brand); }
.apisim-method.put { background: #d97706; } .apisim-method.delete { background: #dc2626; }
.apisim-url { font-family: var(--mono); font-size: 13.5px; color: var(--text); }
.apisim-send { margin-left: auto; border: 1px solid var(--brand); background: var(--brand); color: var(--on-brand); border-radius: 8px; padding: 6px 14px; font-size: 12.5px; font-weight: 700; cursor: pointer; }
.apisim-send:hover { filter: brightness(1.07); } .apisim-send:disabled { opacity: .6; cursor: default; }
.apisim-body { display: grid; grid-template-columns: 1fr 1fr; }
.apisim-pane { padding: 12px 15px; min-width: 0; }
.apisim-pane + .apisim-pane { border-left: 1px solid var(--border); }
.apisim-pane .apisim-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); margin-bottom: 6px; }
.apisim-pane pre { margin: 0; background: var(--code-bg); color: var(--code-text); border-radius: 8px; padding: 12px 14px; overflow-x: auto; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; min-height: 60px; }
.apisim-status { font-family: var(--mono); font-size: 12px; font-weight: 700; margin-bottom: 6px; }
.apisim-status.ok { color: var(--ok); } .apisim-status.err { color: var(--err); } .apisim-status.wait { color: var(--text-dim); }
.apisim-note { padding: 9px 15px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-soft); background: var(--bg-soft); }

/* ===================== 전체 검색 (⌘K) ===================== */
.search-trigger {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border-strong);
  background: var(--bg-elev); color: var(--text-soft); border-radius: 9px; padding: 6px 10px;
  font-family: inherit; font-size: 13px; cursor: pointer;
}
.search-trigger:hover { border-color: var(--brand); color: var(--text); }
.search-trigger .kbd { font-size: 11px; font-weight: 700; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; color: var(--text-dim); }
@media (max-width: 600px) { .search-trigger span { display: none; } }

.search-overlay {
  position: fixed; inset: 0; background: rgba(10, 12, 18, .5); z-index: 150; display: none;
  justify-content: center; align-items: flex-start; padding: 64px 16px 16px; backdrop-filter: blur(3px);
}
.search-overlay.show { display: flex; }
.search-box { width: 100%; max-width: 680px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); overflow: hidden; display: flex; flex-direction: column; max-height: 78vh; }
.search-bar { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.search-bar .search-ic { font-size: 16px; }
.search-input { flex: 1; border: none; outline: none; background: none; color: var(--text); font-family: inherit; font-size: 16px; }
.search-close { border: 1px solid var(--border-strong); background: var(--bg-soft); color: var(--text-dim); border-radius: 6px; font-size: 11px; padding: 3px 8px; cursor: pointer; }
.search-results { overflow-y: auto; padding: 8px; }
.search-hint, .search-count { padding: 14px 12px; color: var(--text-dim); font-size: 13px; }
.search-count { padding: 8px 12px 4px; font-weight: 700; }
.sr-group { margin-bottom: 8px; }
.sr-gtitle { font-size: 11.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--brand-text); padding: 8px 12px 4px; }
.sr-gtitle span { color: var(--text-dim); font-weight: 600; }
.sr-item { display: block; padding: 9px 12px; border-radius: 9px; color: inherit; }
.sr-item:hover { background: var(--bg-soft); text-decoration: none; }
.sr-head { font-size: 14px; }
.sr-head b { font-weight: 700; }
.sr-head .sr-sec { color: var(--text-soft); font-weight: 500; }
.sr-snip { font-size: 12.5px; color: var(--text-soft); margin-top: 2px; line-height: 1.5; max-height: 3.2em; overflow: hidden; }
.sr-more { font-size: 12px; color: var(--text-dim); padding: 2px 12px 6px; }
.search-results mark { background: color-mix(in srgb, var(--brand) 30%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; font-weight: 700; }

/* ===================== 영어 사전 모달 (dict.js) ===================== */
.dict-trigger {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border-strong);
  background: var(--bg-elev); color: var(--text-soft); border-radius: 9px; padding: 6px 10px;
  font-family: inherit; font-size: 13px; cursor: pointer;
}
.dict-trigger:hover { border-color: var(--brand); color: var(--text); }
.dict-trigger svg { width: 15px; height: 15px; stroke: currentColor; }
.dict-trigger .kbd { font-size: 11px; font-weight: 700; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; color: var(--text-dim); }
@media (max-width: 600px) { .dict-trigger span:not(.kbd) { display: none; } .dict-trigger .kbd { display: none; } }

/* 본문 단어 선택 시 뜨는 사전 칩 */
.dict-pop {
  position: absolute; z-index: 200; transform: translateX(-50%); display: none;
  align-items: center; gap: 5px; padding: 5px 11px; font-family: inherit; font-size: 12.5px; font-weight: 700;
  color: var(--on-brand); background: var(--brand); border: none; border-radius: 8px; cursor: pointer;
  box-shadow: var(--shadow-md, 0 4px 14px rgba(0,0,0,.22)); white-space: nowrap;
}
.dict-pop.show { display: inline-flex; }
.dict-pop svg { width: 14px; height: 14px; stroke: currentColor; }
.dict-pop::after { content: ""; position: absolute; bottom: -5px; left: 50%; transform: translateX(-50%); border: 5px solid transparent; border-top-color: var(--brand); border-bottom: 0; }

.dict-overlay {
  position: fixed; inset: 0; background: rgba(10, 12, 18, .5); z-index: 150; display: none;
  justify-content: center; align-items: flex-start; padding: 64px 16px 16px; backdrop-filter: blur(3px);
}
.dict-overlay.show { display: flex; }
.dict-box { width: 100%; max-width: 640px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); overflow: hidden; display: flex; flex-direction: column; max-height: 82vh; }
.dict-bar { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.dict-bar-ic svg { width: 18px; height: 18px; stroke: var(--text-dim); }
.dict-input { flex: 1; border: none; outline: none; background: none; color: var(--text); font-family: inherit; font-size: 16px; }
.dict-close { border: 1px solid var(--border-strong); background: var(--bg-soft); color: var(--text-dim); border-radius: 6px; font-size: 11px; padding: 3px 8px; cursor: pointer; }
.dict-body { overflow-y: auto; padding: 14px 16px 18px; }
.dict-recent { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.dict-recent-lb { font-size: 11.5px; color: var(--text-dim); font-weight: 600; margin-right: 2px; }
.dict-chip { border: 1px solid var(--border-strong); background: var(--bg); color: var(--text-soft); border-radius: 999px; padding: 3px 10px; font-size: 12.5px; font-weight: 600; cursor: pointer; font-family: inherit; }
.dict-chip:hover { color: var(--text); border-color: var(--brand); }
.dict-chip.clear { color: var(--text-dim); }
.dict-status { font-size: 13px; color: var(--text-dim); margin: 2px 0; min-height: 2px; }
.dict-status.loading { color: var(--brand); }
.dict-status.error { color: #d4503b; font-weight: 600; }

.dict-card { padding-top: 4px; }
.dict-top { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px 11px; }
.dict-word { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -.01em; }
.dict-ipa { font-size: 15.5px; color: var(--text-soft); font-family: "Times New Roman", serif; }
.dict-play { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border: 1px solid var(--border-strong); background: var(--bg); color: var(--brand); border-radius: 8px; cursor: pointer; }
.dict-play svg { width: 17px; height: 17px; }
.dict-play:hover { border-color: var(--brand); }
.dict-play.playing { background: var(--brand); color: var(--on-brand); }
.dict-ko { display: flex; align-items: baseline; gap: 9px; margin: 13px 0 6px; padding: 11px 14px; background: var(--bg); border-radius: 11px; }
.dict-ko-lb { flex: none; font-size: 11.5px; font-weight: 700; color: var(--on-brand); background: var(--brand); padding: 2px 9px; border-radius: 6px; }
.dict-ko-val { font-size: 18.5px; font-weight: 700; color: var(--text); line-height: 1.4; }
.dict-mean { margin-top: 15px; }
.dict-pos { display: inline-block; font-size: 12.5px; font-weight: 700; color: var(--brand); margin-bottom: 7px; }
.dict-defs { margin: 0; padding-left: 19px; }
.dict-defs li { margin: 9px 0; line-height: 1.5; }
.dict-def-ko { display: block; font-size: 15px; font-weight: 600; color: var(--text); }
.dict-def-en { display: block; font-size: 13px; color: var(--text-dim); margin-top: 1px; }
.dict-ex-en { display: block; font-size: 13.5px; color: var(--text-soft); margin-top: 4px; }
.dict-ex-ko { display: block; font-size: 13px; color: var(--text-dim); }
.dict-syn { margin-top: 8px; font-size: 13px; }
.dict-syn-lb { font-weight: 700; color: var(--text-soft); margin-right: 6px; }
.dict-syn-val { color: var(--text-soft); }
.dict-note { margin-top: 12px; padding: 11px 13px; background: var(--bg); border-radius: 10px; font-size: 13.5px; color: var(--text-soft); }
.dict-src { margin-top: 15px; padding-top: 11px; border-top: 1px solid var(--border); font-size: 11px; color: var(--text-dim); }

/* 사전 모달의 단어장 저장 별 */
.dict-star { margin-left: auto; border: none; background: none; cursor: pointer; font-size: 22px; line-height: 1; color: var(--text-dim); padding: 0 2px; }
.dict-star.on { color: #f5a623; }
.dict-star:hover { color: #f5a623; }

/* ===================== 단어장 (vocab.js) ===================== */
.vocab-trigger {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border-strong);
  background: var(--bg-elev); color: var(--text-soft); border-radius: 9px; padding: 6px 10px;
  font-family: inherit; font-size: 13px; cursor: pointer;
}
.vocab-trigger:hover { border-color: var(--brand); color: var(--text); }
.vocab-trigger svg { width: 15px; height: 15px; stroke: currentColor; }
.vocab-badge { font-size: 11px; font-weight: 800; background: var(--brand); color: var(--on-brand); border-radius: 999px; padding: 1px 6px; min-width: 16px; text-align: center; }
@media (max-width: 600px) { .vocab-trigger span:not(.vocab-badge) { display: none; } }

/* 예문 카드의 단어장 별 */
.ex-star { position: absolute; top: 9px; right: 42px; border: none; background: none; cursor: pointer; font-size: 17px; line-height: 1; color: var(--text-dim); padding: 2px; z-index: 2; }
.ex-star.on { color: #f5a623; }
.ex-star:hover { color: #f5a623; }

.vocab-overlay { position: fixed; inset: 0; background: rgba(10, 12, 18, .5); z-index: 150; display: none; justify-content: center; align-items: flex-start; padding: 56px 16px 16px; backdrop-filter: blur(3px); }
.vocab-overlay.show { display: flex; }
.vocab-box { width: 100%; max-width: 620px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); overflow: hidden; display: flex; flex-direction: column; max-height: 84vh; }
.vocab-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.vocab-title { font-size: 16px; font-weight: 800; }
.vocab-cnt { color: var(--text-dim); font-weight: 700; font-size: 14px; }
.vocab-head-actions { display: flex; gap: 8px; }
.vocab-review-btn { border: 1px solid var(--brand); background: var(--brand); color: var(--on-brand); border-radius: 9px; font-size: 13px; font-weight: 700; padding: 6px 14px; cursor: pointer; font-family: inherit; }
.vocab-review-btn:hover { filter: brightness(1.05); }
.vocab-close { border: 1px solid var(--border-strong); background: var(--bg-soft); color: var(--text-dim); border-radius: 6px; font-size: 11px; padding: 3px 9px; cursor: pointer; }
.vocab-body { overflow-y: auto; padding: 14px 16px 18px; }
.vocab-empty { color: var(--text-soft); font-size: 14px; line-height: 1.6; padding: 24px 8px; text-align: center; }
.vocab-hint { font-size: 12.5px; color: var(--text-dim); margin-bottom: 10px; }
.vocab-card { position: relative; border: 1px solid var(--border); border-radius: 11px; background: var(--bg); padding: 12px 14px; margin-bottom: 9px; display: flex; align-items: center; gap: 10px; cursor: pointer; }
.vocab-card-main { flex: 1; min-width: 0; }
.vocab-en { font-size: 16px; font-weight: 700; color: var(--text); }
.vocab-ko { font-size: 14px; color: var(--text-soft); margin-top: 2px; }
.vocab-note { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.vocab-card.hide-ko .vocab-ko, .vocab-card.hide-ko .vocab-note { filter: blur(5px); opacity: .55; }
.vocab-tools { display: flex; gap: 6px; flex: none; }
.vocab-play { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border: 1px solid var(--border-strong); background: var(--bg-elev); color: var(--brand); border-radius: 8px; cursor: pointer; }
.vocab-play svg { width: 16px; height: 16px; }
.vocab-play.playing { background: var(--brand); color: var(--on-brand); }
.vocab-del { width: 30px; height: 30px; border: 1px solid var(--border-strong); background: var(--bg-elev); color: var(--text-dim); border-radius: 8px; cursor: pointer; font-size: 13px; }
.vocab-del:hover { color: #d4503b; border-color: #d4503b; }

/* 복습(플래시카드) */
.vocab-body.review { display: flex; flex-direction: column; align-items: stretch; }
.rv-prog { font-size: 13px; color: var(--text-dim); font-weight: 600; text-align: center; }
.rv-bar { height: 5px; background: var(--bg); border-radius: 999px; margin: 8px 0 16px; overflow: hidden; }
.rv-fill { height: 100%; background: var(--brand); border-radius: 999px; transition: width .25s; }
.rv-card { border: 1px solid var(--border); border-radius: 14px; background: var(--bg); padding: 30px 20px; text-align: center; min-height: 150px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; cursor: pointer; }
.rv-en { font-size: 26px; font-weight: 800; }
.rv-play { width: 38px; height: 38px; border: 1px solid var(--border-strong); background: var(--bg-elev); color: var(--brand); border-radius: 10px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.rv-play svg { width: 19px; height: 19px; }
.rv-play.playing { background: var(--brand); color: var(--on-brand); }
.rv-ko, .rv-note { display: none; }
.rv-card.revealed .rv-ko { display: block; font-size: 18px; font-weight: 700; color: var(--brand); }
.rv-card.revealed .rv-note { display: block; font-size: 13px; color: var(--text-dim); }
.rv-reveal { border: 1px solid var(--border-strong); background: var(--bg-elev); color: var(--text-soft); border-radius: 9px; font-size: 13.5px; font-weight: 600; padding: 8px 18px; cursor: pointer; font-family: inherit; }
.rv-ans { display: flex; gap: 10px; margin-top: 16px; }
.rv-ans button { flex: 1; border-radius: 10px; font-size: 14.5px; font-weight: 700; padding: 12px; cursor: pointer; font-family: inherit; border: 1px solid var(--border-strong); }
.rv-no { background: var(--bg-elev); color: var(--text-soft); }
.rv-no:hover { border-color: #d4503b; color: #d4503b; }
.rv-yes { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.rv-quit { margin-top: 14px; align-self: center; border: none; background: none; color: var(--text-dim); font-size: 12.5px; cursor: pointer; text-decoration: underline; font-family: inherit; }
.rv-done-emoji { font-size: 44px; text-align: center; margin-top: 20px; }
.rv-done { font-size: 18px; font-weight: 800; text-align: center; margin-top: 8px; }
.rv-done-actions { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 20px; }

/* ===================== 모의 터미널 (termsim.js) ===================== */
.termsim { border: 1px solid var(--border-strong); border-radius: 12px; overflow: hidden; margin: 18px 0; box-shadow: var(--shadow-sm); background: #0b0f17; }
.ts-bar { display: flex; align-items: center; gap: 7px; padding: 8px 12px; background: #1a1f2b; border-bottom: 1px solid #2a3142; }
.ts-dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.ts-dot.r { background: #ff5f56; } .ts-dot.y { background: #ffbd2e; } .ts-dot.g { background: #27c93f; }
.ts-name { color: #8b94a7; font-size: 12px; margin-left: 6px; }
.ts-run { margin-left: auto; border: 1px solid #3a4254; background: #2a3142; color: #e6e8ee; border-radius: 7px; padding: 4px 12px; font-size: 12px; font-weight: 700; cursor: pointer; }
.ts-run:hover:not(:disabled) { background: #353d50; }
.ts-run:disabled { opacity: .55; cursor: default; }
.ts-body { padding: 12px 14px; font-family: var(--mono); font-size: 13px; line-height: 1.65; color: #e6e8ee; min-height: 40px; }
.ts-line .ts-prompt { color: #27c93f; font-weight: 700; }
.ts-line .ts-cmd { color: #e6e8ee; }
.ts-output { margin: 6px 0 0; white-space: pre-wrap; color: #aeb6c6; font-family: var(--mono); font-size: 13px; background: none; border: none; padding: 0; }
.ts-output.running::after { content: "실행 중…"; color: #6b7080; }

/* ===================== PLC 태그 모니터 (plcsim) ===================== */
.plcsim { border: 1px solid var(--border-strong); border-radius: 14px; background: var(--bg-elev); box-shadow: var(--shadow-sm); margin: 18px 0; overflow: hidden; }
.plc-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 11px 15px; background: var(--bg-soft); border-bottom: 1px solid var(--border); }
.plc-led { width: 10px; height: 10px; border-radius: 50%; background: var(--text-dim); flex-shrink: 0; transition: background .2s, box-shadow .2s; }
.plc-led.on { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 28%, transparent); }
.plc-device { font-weight: 700; font-size: 14px; color: var(--text); }
.plc-proto { font-size: 11px; font-weight: 700; letter-spacing: .03em; color: var(--accent); border: 1px solid var(--border-strong); border-radius: 999px; padding: 2px 9px; }
.plc-scan { font-size: 12px; color: var(--text-dim); font-family: var(--mono); }
.plc-run { margin-left: auto; border: 1px solid var(--brand); background: var(--brand); color: var(--on-brand); border-radius: 8px; padding: 5px 14px; font-size: 12.5px; font-weight: 700; cursor: pointer; font-family: inherit; }
.plc-run:hover { opacity: .9; }
.plc-table { width: 100%; border-collapse: collapse; margin: 0; font-size: 13px; }
.plc-table thead th { text-align: left; padding: 8px 14px; background: var(--bg); color: var(--text-dim); font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--border); }
.plc-table td { padding: 8px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.plc-table tbody tr:last-child td { border-bottom: none; }
.plc-addr, .plc-type { font-family: var(--mono); color: var(--text-soft); font-size: 12px; }
.plc-name { font-weight: 600; color: var(--text); }
.plc-val { font-family: var(--mono); font-weight: 700; color: var(--text); white-space: nowrap; }
.plc-valh { width: 1%; }
.plc-desc { color: var(--text-dim); font-size: 12.5px; }
.plc-w { font-size: 10px; font-weight: 700; color: var(--accent); border: 1px solid var(--accent); border-radius: 4px; padding: 0 5px; margin-left: 5px; vertical-align: middle; }
.plc-val.changed { animation: plc-flash 0.6s ease; }
@keyframes plc-flash { 0% { background: color-mix(in srgb, var(--accent) 32%, transparent); } 100% { background: transparent; } }
.plc-write { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 15px; background: var(--bg-soft); border-top: 1px solid var(--border); }
.plc-write-lb { font-size: 12px; font-weight: 700; color: var(--text-soft); }
.plc-wsel, .plc-winput { font: inherit; font-size: 13px; padding: 5px 9px; border: 1px solid var(--border-strong); border-radius: 7px; background: var(--bg-elev); color: var(--text); }
.plc-winput { width: 92px; }
.plc-wbtn { font: inherit; font-size: 12.5px; font-weight: 700; padding: 5px 13px; border: 1px solid var(--brand); background: var(--brand); color: var(--on-brand); border-radius: 7px; cursor: pointer; }
.plc-wmsg { font-size: 12px; color: var(--ok); font-weight: 600; }

/* ===================== 디자인 전/후 비교 (beforeafter) ===================== */
.beforeafter { border: 1px solid var(--border-strong); border-radius: 14px; background: var(--bg-elev); box-shadow: var(--shadow-sm); margin: 18px 0; overflow: hidden; }
.ba-head { padding: 10px 15px; background: var(--bg-soft); border-bottom: 1px solid var(--border); }
.ba-ttl { font-weight: 700; font-size: 13.5px; color: var(--text); }
.ba-grid { display: grid; grid-template-columns: 1fr 1fr; }
.ba-pane { min-width: 0; }
.ba-pane:first-child { border-right: 1px solid var(--border); }
.ba-label { font-size: 11px; font-weight: 700; letter-spacing: .03em; padding: 7px 12px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 6px; }
.ba-label::before { content: ""; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.ba-label.is-before { color: var(--text-dim); background: var(--bg); }
.ba-label.is-before::before { background: var(--text-dim); }
.ba-label.is-after { color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--bg-elev)); }
.ba-label.is-after::before { background: var(--accent); }
.ba-frame { width: 100%; border: 0; display: block; background: #fff; min-height: 80px; }
@media (max-width: 640px) {
  .ba-grid { grid-template-columns: 1fr; }
  .ba-pane:first-child { border-right: 0; border-bottom: 1px solid var(--border); }
}

/* ===================== 레일 하단 설정 버튼 ===================== */
.rail-settings {
  margin-top: auto; width: 100%; max-width: 60px; border: none; background: none; cursor: pointer;
  border-radius: 12px; padding: 9px 2px 7px; font-family: inherit; outline: none; appearance: none; -webkit-appearance: none;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--text-soft); transition: background .12s, color .12s;
}
.rail-settings:hover { background: var(--bg-soft); color: var(--text); }
.rail-settings:focus { outline: none; }
.rail-settings:focus-visible { background: var(--bg-soft); color: var(--text); }
.rail-settings .rail-ic { line-height: 0; }
.rail-settings .rail-ic svg { width: 20px; height: 20px; display: block; stroke: currentColor; }
.rail-settings .rail-lb { font-size: 10px; font-weight: 600; letter-spacing: -.2px; }

/* ===================== 설정 패널 ===================== */
.settings-overlay {
  position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center;
  background: rgba(20,22,26,.42); backdrop-filter: blur(2px);
  opacity: 0; visibility: hidden; transition: opacity .15s, visibility .15s;
}
.settings-overlay.show { opacity: 1; visibility: visible; }
.settings-box {
  width: min(440px, 92vw); max-height: 86vh; overflow-y: auto;
  background: var(--bg-elev); border: 1px solid var(--border-strong); border-radius: 16px;
  box-shadow: var(--shadow-lg); transform: translateY(6px); transition: transform .15s;
}
.settings-overlay.show .settings-box { transform: translateY(0); }
.set-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.set-head span { font-family: var(--serif); font-size: 18px; font-weight: 600; color: var(--text); }
.set-close { border: none; background: none; color: var(--text-dim); font-size: 17px; cursor: pointer; line-height: 1; padding: 4px; border-radius: 7px; }
.set-close:hover { color: var(--text); background: var(--bg-soft); }
.set-body { padding: 10px 18px 20px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.set-row:last-child { border-bottom: none; }
.set-label { font-size: 14px; font-weight: 600; color: var(--text); flex-shrink: 0; }
.set-sub { margin: 16px 0 2px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); }
.set-hint { margin: 6px 0 2px; font-size: 12px; line-height: 1.55; color: var(--text-soft); background: var(--bg); border-radius: 9px; padding: 9px 11px; }
.set-hint b { color: var(--text); }
.set-seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 9px; overflow: hidden; background: var(--bg); }
.set-seg-btn { border: none; background: none; padding: 6px 13px; font-size: 13px; font-weight: 600; color: var(--text-soft); cursor: pointer; font-family: inherit; }
.set-seg-btn + .set-seg-btn { border-left: 1px solid var(--border); }
.set-seg-btn:hover { color: var(--text); }
.set-seg-btn.on { background: var(--brand); color: var(--on-brand); }
.set-swatches { display: flex; gap: 8px; }
.set-swatch { width: 24px; height: 24px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; box-shadow: 0 0 0 1px var(--border) inset; }
.set-swatch.on { box-shadow: 0 0 0 2px var(--bg-elev) inset, 0 0 0 4px var(--accent); }
.set-select { font-family: inherit; font-size: 13px; padding: 6px 9px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--bg-elev); color: var(--text); max-width: 220px; }
.set-preview { margin-top: 14px; width: 100%; border: 1px solid var(--accent); background: var(--accent-tint); color: var(--accent); border-radius: 9px; padding: 9px; font-size: 13px; font-weight: 700; cursor: pointer; font-family: inherit; }
.set-preview:hover { filter: brightness(.97); }

/* 글자 크기 — large */
html[data-fontscale="large"] .article { font-size: 17.5px; }
html[data-fontscale="large"] .ex .en { font-size: 18px; }
html[data-fontscale="large"] .ex .ko { font-size: 15.5px; }

/* ===================== 모드 토글 (개발 ⇄ 영어) ===================== */
.mode-toggle {
  display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border-strong);
  background: var(--bg-elev); color: var(--text-soft); font-size: 12.5px; font-weight: 700;
  text-decoration: none; transition: border-color .14s, color .14s, background .14s;
}
.mode-toggle:hover { color: var(--text); border-color: var(--brand); text-decoration: none; }
.mode-toggle svg { width: 15px; height: 15px; stroke: var(--accent); }

/* ===================== 패턴 페이지 페이징 (patterns.js) ===================== */
.pat-block { scroll-margin-top: 70px; }
.pat-pager { display: flex; align-items: center; justify-content: center; gap: 5px; margin: 18px 0; flex-wrap: wrap; }
.pat-pager.top { margin: 6px 0 22px; }
.pat-pg {
  min-width: 34px; height: 34px; padding: 0 8px; border: 1px solid var(--border-strong); background: var(--bg-elev);
  color: var(--text-soft); border-radius: 9px; font-size: 13.5px; font-weight: 700; cursor: pointer; font-family: inherit;
}
.pat-pg:hover:not([disabled]):not(.on) { color: var(--text); border-color: var(--brand); }
.pat-pg.on { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.pat-pg.arrow { font-size: 16px; }
.pat-pg[disabled] { opacity: .4; cursor: default; }

/* ===================== 패턴 회화 제목 ===================== */
.pat {
  margin: 30px 0 6px; padding: 10px 0 10px 14px; border-left: 4px solid var(--accent);
  font-size: 21px; font-weight: 700; color: var(--text); line-height: 1.35;
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
}
.pat .pat-ko { font-size: 15px; font-weight: 700; color: var(--accent); }
.article > .pat + p, .pat + p { margin-top: 4px; color: var(--text-soft); }
/* 패턴의 공식(작은 회색) */
.pat-form { display: block; margin: 2px 0 0 14px; font-size: 13.5px; color: var(--text-dim); font-family: "SFMono-Regular", ui-monospace, Menlo, monospace; }
/* 상황·어조·느낌 노트 (예문 위) */
.pat-tone { margin: 8px 0 10px; padding: 10px 14px; background: var(--bg-elev); border-left: 3px solid var(--accent); border-radius: 8px; font-size: 14px; color: var(--text-soft); line-height: 1.65; }
.pat-tone b { color: var(--text); }
.pat-tone .lbl { display: inline-block; font-size: 11.5px; font-weight: 800; color: var(--accent); margin-right: 6px; }

/* ===================== 영어 예문 카드 (examples) ===================== */
.exlist { border: 1px solid var(--border-strong); border-radius: 14px; background: var(--bg-elev); box-shadow: var(--shadow-sm); margin: 18px 0; overflow: hidden; }
.exl-head { display: flex; align-items: center; gap: 10px; padding: 10px 15px; background: var(--bg-soft); border-bottom: 1px solid var(--border); }
.exl-title { font-weight: 700; font-size: 13px; color: var(--text); }
.exl-all { border: 1px solid var(--border-strong); background: var(--bg-elev); color: var(--text-soft); border-radius: 8px; padding: 4px 11px; font-size: 12px; font-weight: 700; cursor: pointer; font-family: inherit; }
.exl-all:hover { color: var(--text); border-color: var(--brand); }
.exl-speed { margin-left: auto; border: 1px solid var(--accent); background: var(--accent-tint); color: var(--accent); border-radius: 8px; padding: 4px 11px; font-size: 12px; font-weight: 700; cursor: pointer; font-family: inherit; }
.exl-speed:hover { filter: brightness(0.97); }
.exl-head { gap: 8px; }
.ex { position: relative; display: block; padding: 13px 52px 13px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.ex:last-child { border-bottom: none; }
.ex:hover { background: var(--bg-soft); }
.ex .en { display: block; font-size: 16px; font-weight: 600; color: var(--text); line-height: 1.5; letter-spacing: -.005em; }
.ex .ko { display: block; margin-top: 5px; font-size: 14px; color: var(--text-soft); line-height: 1.55; }
.ex .note { display: block; margin-top: 6px; font-size: 12.5px; color: var(--text-dim); }
/* 실제 발음 표기 (연음·축약 등) — 항상 보임 */
.ex .say { display: block; margin-top: 4px; font-size: 13px; color: var(--accent); font-weight: 600; }
.ex .say::before { content: "발음 "; font-size: 10.5px; font-weight: 800; background: var(--accent); color: var(--on-brand, #fff); border-radius: 4px; padding: 1px 5px; margin-right: 6px; vertical-align: middle; }
html[data-fontscale="large"] .ex .say { font-size: 14.5px; }
.ex.hide-ko .ko { display: none; }
.ex.hide-ko .note { display: none; }
.ex .ex-reveal { display: none; margin-top: 6px; font-size: 12px; font-weight: 700; color: var(--accent); }
.ex.hide-ko .ex-reveal { display: inline-block; }
.ex.hide-ko:hover .ex-reveal::after { content: " ▾"; }
.ex-play {
  position: absolute; top: 11px; right: 12px; width: 32px; height: 32px; border-radius: 9px;
  border: 1px solid var(--border-strong); background: var(--bg); color: var(--accent);
  display: grid; place-items: center; cursor: pointer; padding: 0;
}
.ex-play:hover { border-color: var(--accent); background: var(--accent-tint); }
.ex-play.playing { background: var(--accent); color: var(--on-brand); border-color: var(--accent); }

/* ===================== 페이저 / 스텝 ===================== */
.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 52px; }
.pager a { flex: 1; border: 1px solid var(--border); border-radius: 12px; padding: 14px 18px; background: var(--bg-elev); color: inherit; box-shadow: var(--shadow-sm); transition: border-color .12s, transform .12s; }
.pager a:hover { border-color: var(--brand); text-decoration: none; transform: translateY(-2px); }
.pager a.next { text-align: right; }
.pager .pager-label { font-size: 12px; color: var(--text-dim); }
.pager .pager-title { font-weight: 700; color: var(--brand-text); }
.steps { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.step { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 999px; padding: 5px 13px; font-size: 13px; font-weight: 600; }
.step b { color: var(--brand-text); }

/* ===================== 히어로 / 랜딩 ===================== */
.hero { text-align: center; padding: 76px 20px 22px; }
.hero h1 { font-family: var(--serif); font-size: 52px; font-weight: 560; margin: 16px 0; letter-spacing: -.018em; line-height: 1.08; }
.hero h1 .grad { color: var(--accent); }
.hero p { font-size: 18px; color: var(--text-soft); max-width: 660px; margin: 10px auto; }
.hero .badge { display: inline-block; background: var(--brand-soft); color: var(--brand-text); border-radius: 999px; padding: 6px 15px; font-size: 13px; font-weight: 700; }
.section-label { font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--text-dim); margin: 40px 0 2px; }

/* 연습장 전체화면 */
.pg-full { max-width: 1180px; margin: 0 auto; padding: 24px 24px 60px; }
.pg-full .playground { min-height: 70vh; }
.pg-full .pg-body { min-height: 66vh; }
.pg-full .pg-editor textarea, .pg-full .pg-result iframe { min-height: 66vh; }
.preset-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.preset-bar select { padding: 8px 12px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--bg-elev); color: var(--text); font-size: 14px; }

/* ===================== 반응형 ===================== */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 55; display: none; }
.scrim.show { display: block; }
@media (max-width: 1000px) {
  .cat-rail, .sidebar {
    position: fixed; top: 0; height: 100vh; z-index: 60; transform: translateX(-100%); transition: transform .22s; box-shadow: var(--shadow-lg);
  }
  .cat-rail { left: 0; }
  /* 사이드바는 레일 폭만큼 오른쪽에서 시작하므로, 닫을 때 그만큼 더 밀어 완전히 숨김 */
  .sidebar { left: var(--rail-w); transform: translateX(calc(-100% - var(--rail-w))); }
  .cat-rail.open, .sidebar.open { transform: translateX(0); }
  .hamburger { display: grid; }
}
@media (max-width: 600px) {
  .article { padding: 26px 18px 84px; }
  .article h1 { font-size: 26px; }
  .hero h1 { font-size: 31px; }
  .pg-body { grid-template-columns: 1fr; }
  .apisim-body { grid-template-columns: 1fr; }
  .apisim-pane + .apisim-pane { border-left: none; border-top: 1px solid var(--border); }
}
