/* ═══════════════════════════════════════════════════════════
   2418 TEXT_DIFF — kit-ide 변형 (평면 · 무채 + diff 2색)
   출발점: 2801_DesignKit/kit-ide (파일 탭 · 라인넘버 거터 · 모노 라벨)
   변형: 다크 네이비 → 라이트 페이퍼 기본, 그라디언트·블러·글로우·다색 제거,
        액센트는 잉크 1색, 색은 추가(녹)/삭제(적) 두 가지만 채도 낮게.
═══════════════════════════════════════════════════════════ */
:root {
  --bg: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #f0f0ec;
  --surface-3: #e8e8e3;
  --border: #e1e1dc;
  --border-2: #cdcdc6;
  --text: #1f2328;
  --text-2: #50565e;
  --text-3: #868b93;
  --ink: #1f2328;
  --ink-fg: #ffffff;
  --del-bg: #fcebea;
  --del-hl: #f3bfbc;
  --del-fg: #b3261e;
  --ins-bg: #e8f5eb;
  --ins-hl: #b5dfc0;
  --ins-fg: #1b6e36;
  --skip: #a3a8af;
  --cur: #1f2328;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "D2Coding", "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", "Hiragino Sans", "Microsoft YaHei", Roboto, sans-serif;
  --r: 6px;
  --hdr: 50px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #121417;
  --surface: #181b1f;
  --surface-2: #1e2226;
  --surface-3: #262b30;
  --border: #2a2f35;
  --border-2: #3a4047;
  --text: #e2e4e7;
  --text-2: #a9afb7;
  --text-3: #737a83;
  --ink: #e2e4e7;
  --ink-fg: #121417;
  --del-bg: #3a1f20;
  --del-hl: #6e2f2d;
  --del-fg: #ff9b93;
  --ins-bg: #183221;
  --ins-hl: #25583a;
  --ins-fg: #7fd495;
  --skip: #5f666e;
  --cur: #e2e4e7;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
svg.i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ─── 헤더 (에디터 메뉴바) ─── */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1440px; margin: 0 auto; height: var(--hdr);
  padding: 0 16px; display: flex; align-items: center; gap: 12px;
}
.brand {
  display: inline-flex; align-items: center; gap: 9px; text-decoration: none;
  font-family: var(--mono); font-weight: 700; font-size: 15px; letter-spacing: -0.02em; white-space: nowrap;
}
.brand-badge {
  width: 28px; height: 28px; border-radius: 5px; background: var(--ink); color: var(--ink-fg);
  display: inline-flex; align-items: center; justify-content: center; font-size: 15px; line-height: 1;
}
.brand small { font-weight: 500; color: var(--text-3); font-size: 12px; }
.nav { display: flex; align-items: stretch; gap: 2px; margin-left: 8px; height: 100%; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  display: inline-flex; align-items: center; padding: 0 12px; text-decoration: none;
  font-family: var(--mono); font-size: 13px; color: var(--text-2); white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.nav a:hover { color: var(--text); }
.nav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--ink); }
.hdr-tools { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.lang-select {
  height: 30px; border: 1px solid var(--border); background: var(--surface); border-radius: var(--r);
  padding: 0 6px; font-size: 13px; max-width: 120px;
}
.icon-btn {
  width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); background: var(--surface); border-radius: var(--r); cursor: pointer; color: var(--text-2);
}
.icon-btn:hover { color: var(--text); border-color: var(--border-2); }
@media (max-width: 720px) {
  .header-inner { flex-wrap: wrap; height: auto; padding: 8px 12px 0; row-gap: 4px; }
  .brand small { display: none; }
  .nav { order: 3; width: 100%; margin: 0 -12px; padding: 0 6px; height: 38px; border-top: 1px solid var(--border); }
  .nav a { padding: 0 9px; font-size: 12.5px; }
}

/* ─── 메인 ─── */
main { flex: 1; width: 100%; }
.wrap { max-width: 1440px; margin: 0 auto; padding: 14px 16px 40px; }
.page { max-width: 820px; padding-top: 22px; }

/* ─── 에디터(입력 두 칸) ─── */
.panes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 860px) { .panes { grid-template-columns: 1fr; } }
.pane {
  position: relative; border: 1px solid var(--border); border-radius: var(--r);
  background: var(--surface); display: flex; flex-direction: column; min-width: 0;
}
.pane.drag { border-color: var(--ink); border-style: dashed; }
.pane-tab {
  display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 6px 0 0;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
  border-radius: var(--r) var(--r) 0 0; font-family: var(--mono); font-size: 12.5px;
}
.tab-file {
  display: inline-flex; align-items: center; gap: 7px; height: 100%; padding: 0 12px;
  background: var(--surface); border-right: 1px solid var(--border); min-width: 0; max-width: 60%;
  border-radius: var(--r) 0 0 0; box-shadow: inset 0 2px 0 var(--mark);
}
.pane[data-side="a"] { --mark: var(--del-fg); }
.pane[data-side="b"] { --mark: var(--ins-fg); }
.tab-sign { color: var(--mark); font-weight: 700; }
.tab-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.tab-meta { color: var(--text-3); white-space: nowrap; }
.tab-actions { margin-left: auto; display: flex; gap: 2px; }
.tbtn {
  height: 26px; min-width: 26px; padding: 0 6px; display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  border: 0; background: transparent; border-radius: 4px; cursor: pointer; color: var(--text-2); font-size: 12px;
}
.tbtn:hover { background: var(--surface-3); color: var(--text); }
.tbtn input { display: none; }
.pane-body { position: relative; display: flex; min-height: 0; }
.gutter {
  flex: none; width: 46px; padding: 10px 8px 10px 0; margin: 0; text-align: right; overflow: hidden;
  font-family: var(--mono); font-size: 13px; line-height: 20px; color: var(--text-3);
  background: var(--surface); border-right: 1px solid var(--border); user-select: none; white-space: pre;
  border-radius: 0 0 0 var(--r);
}
.pane textarea {
  flex: 1; min-width: 0; border: 0; outline: none; resize: vertical; background: transparent;
  padding: 10px 12px; font-family: var(--mono); font-size: 13px; line-height: 20px; tab-size: 4;
  white-space: pre; overflow: auto; height: clamp(200px, 36vh, 480px); min-height: 140px;
}
.pane textarea::placeholder { color: var(--text-3); white-space: pre-wrap; }
.pane:focus-within { border-color: var(--border-2); }
.drop-hint {
  position: absolute; inset: 36px 0 0 0; display: none; align-items: center; justify-content: center;
  background: var(--surface); font-family: var(--mono); font-size: 13px; color: var(--text-2);
  border-radius: 0 0 var(--r) var(--r);
}
.pane.drag .drop-hint { display: flex; }

/* ─── 옵션·실행 바 ─── */
.toolbar {
  margin-top: 10px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface);
  font-size: 13px;
}
.toolbar .grp { display: inline-flex; align-items: center; gap: 6px; }
.toolbar .lbl { font-family: var(--mono); font-size: 12px; color: var(--text-3); }
.toolbar select {
  height: 30px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); padding: 0 6px; font-size: 13px;
}
.chk { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; white-space: nowrap; color: var(--text-2); }
.chk input { accent-color: var(--ink); width: 15px; height: 15px; margin: 0; }
.chk:hover { color: var(--text); }
.toolbar .sep { width: 1px; align-self: stretch; background: var(--border); }
.toolbar .end { margin-left: auto; display: inline-flex; gap: 6px; flex-wrap: wrap; }
.btn {
  height: 32px; padding: 0 12px; display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border-2); background: var(--surface); border-radius: var(--r); cursor: pointer; font-size: 13px; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--ink); color: var(--ink-fg); border-color: var(--ink); font-weight: 600; }
.btn.primary:hover { opacity: .9; }
.btn kbd { font-family: var(--mono); font-size: 10.5px; opacity: .7; }
.btn:disabled { opacity: .45; cursor: default; }
@media (max-width: 720px) {
  .toolbar .sep { display: none; }
  .toolbar .end { margin-left: 0; width: 100%; }
  .toolbar .end .btn.primary { flex: 1; justify-content: center; }
  .btn kbd { display: none; }
}

/* ─── 결과 ─── */
.result { margin-top: 14px; }
.res-bar {
  position: sticky; top: var(--hdr); z-index: 20;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r) var(--r) 0 0;
}
@media (max-width: 720px) { .res-bar { position: static; } }
.stats { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-family: var(--mono); font-size: 13px; }
.st em { font-style: normal; color: var(--text-3); font-family: var(--sans); font-size: 12px; }
.st-add { color: var(--ins-fg); font-weight: 700; }
.st-del { color: var(--del-fg); font-weight: 700; }
.st-mod { color: var(--text); font-weight: 700; }
.st-sim b { font-weight: 700; }
.st-ms { color: var(--text-3); font-size: 12px; }
.st-same { font-family: var(--sans); font-weight: 600; }
.res-ctrl { margin-left: auto; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--border-2); border-radius: var(--r); overflow: hidden; }
.seg button {
  height: 30px; padding: 0 10px; border: 0; background: var(--surface); cursor: pointer; font-size: 12.5px; color: var(--text-2);
  display: inline-flex; align-items: center; gap: 5px;
}
.seg button + button { border-left: 1px solid var(--border-2); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--ink-fg); }
.nav-count { font-family: var(--mono); font-size: 12px; color: var(--text-2); min-width: 64px; text-align: center; }
.res-msg { font-size: 13px; color: var(--text-2); padding: 6px 10px; border-left: 1px solid var(--border); border-right: 1px solid var(--border); background: var(--surface); }
.res-msg:empty { display: none; }
.result.busy .diff-view { opacity: .5; }
.diff-view {
  border: 1px solid var(--border); border-top: 0; border-radius: 0 0 var(--r) var(--r);
  background: var(--surface); overflow-x: auto;
}
.diff-view.empty { min-height: 40px; }

.dt { width: 100%; border-collapse: collapse; table-layout: fixed; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; }
.dt .c-ln { width: 50px; }
.dt .c-sg { width: 20px; }
.dt td { padding: 0 8px; vertical-align: top; }
.dt td.cd { white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; tab-size: 4; }
.dt td.ln { color: var(--text-3); text-align: right; user-select: none; font-size: 11.5px; padding-top: 1px; background: var(--surface); }
.dt.split td.ln + td.cd { border-right: 1px solid var(--border); }
.dt.split td.cd:last-child { border-right: 0; }
.dt td.sg { user-select: none; text-align: center; padding: 0; }
.dt td.del { background: var(--del-bg); }
.dt td.ins { background: var(--ins-bg); }
.dt td.ln.del, .dt td.sg.del { color: var(--del-fg); }
.dt td.ln.ins, .dt td.sg.ins { color: var(--ins-fg); }
.dt td.nil { background: var(--surface-2); }
.dt td.skip { color: var(--skip); }
.dt td.del .hl { background: var(--del-hl); border-radius: 2px; }
.dt td.ins .hl { background: var(--ins-hl); border-radius: 2px; }
.dt .cr, .dt .noeol { color: var(--text-3); font-size: 10px; margin-left: 2px; }
.dt tr[data-blk] td { border-top: 1px solid transparent; }
.dt tr.cur td:first-child { box-shadow: inset 3px 0 0 var(--cur); }
.dt tr.fold td { padding: 0; background: var(--surface-2); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.dt tr.fold button {
  width: 100%; border: 0; background: transparent; cursor: pointer; padding: 3px 10px; text-align: left;
  font-family: var(--mono); font-size: 12px; color: var(--text-2);
}
.dt tr.fold button:hover { color: var(--text); background: var(--surface-3); }

/* ─── 광고 (architecture §4 — 래퍼 border-radius·overflow 금지) ─── */
.ad-grid { display: flex; flex-direction: column; align-items: center; gap: 14px; width: 100%; max-width: 672px; margin: 22px auto 0; }
.ad-grid[data-ad-layout="mixed"] { max-width: 780px; }
.ad-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; width: 100%; }
.ad-cell { max-width: 100%; }
.ad-row.ad-mo { display: none; }
.ad-row.ad-pc { display: flex; }
.ad-row.ad-any { display: flex; }
@media (max-width: 719px) {
  .ad-row.ad-pc { display: none; }
  .ad-row.ad-mo { display: flex; }
}

/* ─── 콘텐츠 페이지 ─── */
.crumb { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-family: var(--mono); font-size: 12px; color: var(--text-3); margin-bottom: 14px; }
.crumb a { text-decoration: none; color: var(--text-2); }
.crumb a:hover { color: var(--text); text-decoration: underline; }
.page-head { margin-bottom: 22px; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.eyebrow { font-family: var(--mono); font-size: 12px; color: var(--text-3); letter-spacing: .02em; }
.page-head h1 { font-size: clamp(24px, 3.4vw, 32px); line-height: 1.3; margin: 6px 0 8px; letter-spacing: -0.02em; }
.page-head p { margin: 0; color: var(--text-2); }
.meta-line { margin-top: 10px !important; font-family: var(--mono); font-size: 12px; color: var(--text-3) !important; }
.prose { font-size: 16px; line-height: 1.8; }
.prose h2 { font-size: 21px; line-height: 1.4; margin: 38px 0 12px; letter-spacing: -0.01em; }
.prose h2::before { content: "## "; font-family: var(--mono); color: var(--text-3); font-weight: 500; }
.prose h3 { font-size: 17px; margin: 26px 0 8px; }
.prose p { margin: 0 0 14px; }
.prose ul, .prose ol { margin: 0 0 16px; padding-left: 1.4em; }
.prose li { margin: 4px 0; }
.prose blockquote { margin: 16px 0; padding: 10px 14px; border-left: 3px solid var(--ink); background: var(--surface-2); border-radius: 0 var(--r) var(--r) 0; }
.prose blockquote p:last-child { margin: 0; }
.prose code { font-family: var(--mono); font-size: .88em; background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; }
.prose pre { margin: 0 0 18px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); overflow-x: auto; font-family: var(--mono); font-size: 13px; line-height: 1.6; }
.prose pre code { background: none; border: 0; padding: 0; font-size: inherit; }
.prose pre .dl-add { display: block; background: var(--ins-bg); color: var(--ins-fg); margin: 0 -14px; padding: 0 14px; }
.prose pre .dl-del { display: block; background: var(--del-bg); color: var(--del-fg); margin: 0 -14px; padding: 0 14px; }
.prose pre .dl-hunk { display: block; color: var(--text-3); }
.prose pre .dl-meta { display: block; color: var(--text-2); font-weight: 600; }
.prose a { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--border-2); }
.prose a:hover { text-decoration-color: var(--text); }
.tbl-wrap { overflow-x: auto; margin: 0 0 18px; }
.prose table { border-collapse: collapse; width: 100%; font-size: 14px; line-height: 1.55; }
.prose th, .prose td { border: 1px solid var(--border); padding: 7px 10px; text-align: left; vertical-align: top; }
.prose th { background: var(--surface-2); font-weight: 600; }
.feature-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; margin: 0 0 12px; }
.feature { border: 1px solid var(--border); border-radius: var(--r); padding: 12px 14px; background: var(--surface); }
.feature h3 { margin: 0 0 4px; font-size: 15px; }
.feature p { margin: 0; font-size: 14px; color: var(--text-2); line-height: 1.6; }
.faq-item { border-top: 1px solid var(--border); padding: 14px 0; }
.faq-item h3 { margin: 0 0 6px; font-size: 16px; }
.faq-item p { margin: 0; color: var(--text-2); }
.sources { font-size: 14px; color: var(--text-2); }
.sources h2 { font-size: 16px; }
.cta {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: var(--r);
  background: var(--ink); color: var(--ink-fg) !important; text-decoration: none !important; font-weight: 600; font-size: 14px;
}
.card-list { display: grid; gap: 10px; }
.card {
  display: block; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface);
  text-decoration: none;
}
.card:hover { border-color: var(--border-2); }
.card .no { font-family: var(--mono); font-size: 12px; color: var(--text-3); }
.card h2, .card h3 { margin: 2px 0 4px; font-size: 17px; }
.card p { margin: 0; font-size: 14px; color: var(--text-2); }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 28px; }
.pager a { padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r); text-decoration: none; font-size: 13px; color: var(--text-3); background: var(--surface); }
.pager a b { display: block; color: var(--text); font-size: 14.5px; margin-top: 2px; font-weight: 600; }
.pager a.next { text-align: right; }
.pager a:hover { border-color: var(--border-2); }
@media (max-width: 560px) { .pager { grid-template-columns: 1fr; } .pager a.next { text-align: left; } }
.notfound { text-align: center; padding: 60px 0; }
.notfound .code { font-family: var(--mono); font-size: 56px; font-weight: 700; color: var(--text-3); }

/* ─── 푸터 ─── */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); margin-top: 20px; }
.footer-inner { max-width: 1440px; margin: 0 auto; padding: 18px 16px 26px; display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: center; font-size: 13px; color: var(--text-3); }
.footer-links { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.footer-links a { text-decoration: none; color: var(--text-2); }
.footer-links a:hover { color: var(--text); text-decoration: underline; }
.footer-base { margin-left: auto; font-family: var(--mono); font-size: 12px; }

/* ─── 토스트 ─── */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--ink-fg); padding: 8px 14px; border-radius: var(--r); font-size: 13px; transition: all .18s ease; z-index: 60;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ─── RTL ─── */
[dir="rtl"] .brand, [dir="rtl"] .nav a { direction: rtl; }
[dir="rtl"] .hdr-tools { margin-left: 0; margin-right: auto; }
[dir="rtl"] .nav { margin-left: 0; margin-right: 8px; }
[dir="rtl"] .toolbar .end, [dir="rtl"] .res-ctrl, [dir="rtl"] .footer-base { margin-left: 0; margin-right: auto; }
[dir="rtl"] .tab-actions { margin-left: 0; margin-right: auto; }
[dir="rtl"] .prose ul, [dir="rtl"] .prose ol { padding-left: 0; padding-right: 1.4em; }
[dir="rtl"] .prose blockquote { border-left: 0; border-right: 3px solid var(--ink); border-radius: var(--r) 0 0 var(--r); }
[dir="rtl"] .pager a.next { text-align: left; }
/* 에디터·diff 본문은 코드처럼 항상 LTR 로 둔다(텍스트 자체의 방향은 브라우저가 처리) */
[dir="rtl"] .pane-body, [dir="rtl"] .diff-view, [dir="rtl"] .prose pre { direction: ltr; }
[dir="rtl"] .pane textarea { direction: auto; unicode-bidi: plaintext; }
.prose pre .dl-ctx { display: block; }
.prose code, .prose pre, .dt, .pane textarea, .gutter { font-variant-ligatures: none; }
[dir="rtl"] .panes { direction: ltr; }
[dir="rtl"] .pane-tab { direction: rtl; }
.dt td.cd { unicode-bidi: plaintext; }
