/* ===================================================================
   C++ 웹 실습 강좌 — 기본 스타일 (라이트 / 다크)
   =================================================================== */
:root {
  --bg: #f4f6f9;
  --pane: #ffffff;
  --card: #ffffff;
  --card2: #f7f9fc;
  --line: #e1e6ee;
  --fg: #1d2433;
  --muted: #6b7587;
  --accent: #0b5cad;        /* C++ 블루 */
  --accent-soft: #e5f0fb;
  --accent2: #00897b;       /* 청록 */
  --accent2-soft: #e0f4f1;
  --ok: #1f9d55;
  --ok-soft: #e3f6ec;
  --warn: #c98a00;
  --warn-soft: #fff6d9;
  --danger: #d64541;
  --danger-soft: #fdeaea;
  --more: #7b4fd1;
  --more-soft: #f1ebfd;
  --code-bg: #f6f8fb;
  --code-fg: #24292f;
  --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 4px 16px rgba(20, 30, 50, .06);
  --radius: 10px;
  --mono: 'JetBrains Mono', 'D2Coding', Consolas, 'Courier New', monospace;
  --sans: 'Pretendard Variable', Pretendard, -apple-system, 'Segoe UI', 'Malgun Gothic', sans-serif;
  /* 콘솔은 항상 어두운 터미널 */
  --term-bg: #0f1419;
  --term-fg: #d7dde8;
  --term-muted: #7d8799;
  --term-err: #ff7b72;
  --term-in: #7ee787;
  --term-sys: #79c0ff;
  /* 코드 토큰 */
  --tk-keyword: #cf222e;
  --tk-type: #8250df;
  --tk-string: #0a3069;
  --tk-number: #0550ae;
  --tk-comment: #6e7781;
  --tk-def: #953800;
  --tk-meta: #116329;
  --tk-op: #24292f;
  --nav-w: 290px;
  --out-w: 430px;
  --editor-h: 38%;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0e1116;
  --pane: #151a21;
  --card: #1a2029;
  --card2: #1f2631;
  --line: #2a323e;
  --fg: #e3e8f0;
  --muted: #8d97a8;
  --accent: #5aa9f5;
  --accent-soft: #13263b;
  --accent2: #4fc3b0;
  --accent2-soft: #10302c;
  --ok: #4cc983;
  --ok-soft: #132e20;
  --warn: #f2c14e;
  --warn-soft: #33290f;
  --danger: #ff6b61;
  --danger-soft: #3a1a18;
  --more: #b695ff;
  --more-soft: #271d3d;
  --code-bg: #11161d;
  --code-fg: #d6deeb;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  --tk-keyword: #ff7b72;
  --tk-type: #d2a8ff;
  --tk-string: #a5d6ff;
  --tk-number: #79c0ff;
  --tk-comment: #8b949e;
  --tk-def: #ffa657;
  --tk-meta: #7ee787;
  --tk-op: #d6deeb;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent2); }
code, kbd, pre { font-family: var(--mono); }
kbd { font-size: .82em; padding: 1px 6px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; background: var(--card2); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.spacer { flex: 1; }

/* ---------------------------------------------------------------- 버튼 */
.btn {
  display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid var(--line); background: var(--card); color: var(--fg);
  border-radius: 8px; padding: 6px 12px; cursor: pointer; font-weight: 600; font-size: 13.5px;
  white-space: nowrap; transition: background .12s, border-color .12s, color .12s;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.small { padding: 3px 9px; font-size: 12.5px; border-radius: 7px; }
.btn.ghost { background: transparent; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.07); }
.btn.blue { background: var(--accent2); border-color: var(--accent2); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.danger:not(:disabled) { border-color: var(--danger); }
.icon-btn {
  border: none; background: transparent; cursor: pointer; font-size: 18px; line-height: 1;
  width: 32px; height: 32px; border-radius: 8px; color: var(--muted);
}
.icon-btn:hover { background: var(--card2); color: var(--fg); }
.icon-btn.small { width: 24px; height: 24px; font-size: 13px; }

/* ---------------------------------------------------------------- 레이아웃 */
.layout {
  display: grid;
  grid-template-columns: var(--nav-w) 5px minmax(360px, 1fr) 5px var(--out-w);
  height: 100vh;
  overflow: hidden;
}
.layout.nav-collapsed { grid-template-columns: 0 0 minmax(360px, 1fr) 5px var(--out-w); }
.layout.nav-collapsed .nav { visibility: hidden; }
.pane { min-width: 0; min-height: 0; background: var(--pane); }
.gutter { cursor: col-resize; background: var(--line); opacity: .5; }
.gutter:hover, .gutter.drag { background: var(--accent); opacity: 1; }
.hgutter { height: 5px; cursor: row-resize; background: var(--line); opacity: .6; flex: none; }
.hgutter:hover, .hgutter.drag { background: var(--accent); opacity: 1; }

/* ---------------------------------------------------------------- 네비게이션 */
.nav { display: flex; flex-direction: column; border-right: 1px solid var(--line); overflow: hidden; }
.brand { display: flex; align-items: center; gap: 10px; padding: 14px 12px 10px 14px; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font-size: 13px; font-weight: 900; color: #fff; font-family: var(--mono); letter-spacing: -.5px;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); text-decoration: none; flex: none;
  box-shadow: 0 2px 8px rgba(11, 92, 173, .35);
}
.brand-text { flex: 1; min-width: 0; }
.brand-title { font-weight: 800; font-size: 16.5px; letter-spacing: -.01em; }
.brand-sub { font-size: 12px; color: var(--muted); }
.nav-open { display: none; }
.layout.nav-collapsed .nav-open { display: inline-block; }
.role-switch, .view-switch { display: flex; background: var(--card2); border: 1px solid var(--line); border-radius: 9px; padding: 3px; gap: 3px; }
.role-switch { margin: 2px 12px 10px; }
.role-switch button, .view-switch button {
  flex: 1; border: none; background: transparent; border-radius: 7px; padding: 5px 8px; cursor: pointer;
  font-weight: 700; font-size: 13px; color: var(--muted); white-space: nowrap;
}
.role-switch button.active, .view-switch button.active { background: var(--pane); color: var(--fg); box-shadow: var(--shadow); }
.role-switch button[data-role="teacher"].active { color: var(--accent2); }
.role-switch button[data-role="student"].active { color: var(--accent); }
.progress-wrap { padding: 0 14px 8px; }
.progress-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-weight: 600; }
.progress { height: 6px; background: var(--card2); border-radius: 6px; overflow: hidden; border: 1px solid var(--line); }
.progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), #f5b041); transition: width .3s; }
.nav-search {
  margin: 4px 12px 8px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card2); outline: none;
}
.nav-search:focus { border-color: var(--accent); }
.nav-tree { flex: 1; overflow-y: auto; padding: 2px 8px 16px; }
.nav-home {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 8px; cursor: pointer; font-weight: 700;
  color: var(--fg); text-decoration: none; font-size: 14px;
}
.nav-home:hover { background: var(--card2); }
.nav-home.active { background: var(--accent-soft); color: var(--accent); }
.nav-ch { margin-top: 2px; }
.nav-ch-head {
  display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 8px; cursor: pointer; user-select: none;
  font-weight: 700; font-size: 14px;
}
.nav-ch-head:hover { background: var(--card2); }
.nav-ch-head .no {
  font: 700 11.5px var(--mono); color: var(--accent); background: var(--accent-soft); border-radius: 6px; padding: 1px 6px; min-width: 38px; text-align: center;
}
.nav-ch-head .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-ch-head .caret { color: var(--muted); font-size: 11px; transition: transform .15s; }
.nav-ch.open .caret { transform: rotate(90deg); }
.nav-ch-head .pending { font-size: 11px; color: var(--muted); font-weight: 500; }
.nav-ch.active > .nav-ch-head { color: var(--accent); }
.nav-secs { display: none; padding: 2px 0 6px 18px; margin-left: 20px; border-left: 1px dashed var(--line); }
.nav-ch.open .nav-secs { display: block; }
.nav-sec {
  display: flex; gap: 6px; align-items: flex-start; padding: 5px 8px; border-radius: 7px; cursor: pointer; font-size: 13.5px;
  color: var(--fg); text-decoration: none; line-height: 1.45;
}
.nav-sec:hover { background: var(--card2); }
.nav-sec.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.nav-sec .chk { flex: none; width: 16px; color: var(--muted); font-size: 12px; margin-top: 1px; }
.nav-sec.done .chk { color: var(--ok); }
.nav-sec .hit { display: block; font-size: 11.5px; color: var(--muted); font-weight: 400; }
.nav-overview { font-size: 12.5px; color: var(--muted); }
.nav-foot { border-top: 1px solid var(--line); padding: 8px 10px; }
.server-badge {
  width: 100%; display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--card2);
  border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: 12.5px; font-weight: 600; text-align: left;
}
.server-badge .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--warn); flex: none; }
.server-badge.ok .dot { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.server-badge.bad .dot { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }

/* ---------------------------------------------------------------- 가운데 */
.center { display: flex; flex-direction: column; overflow: hidden; background: var(--bg); }
.topbar {
  display: flex; align-items: center; gap: 8px; padding: 7px 12px; border-bottom: 1px solid var(--line); background: var(--pane); flex: none; min-height: 46px;
}
.crumb { font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.crumb b { color: var(--fg); }
.view-switch button { flex: none; padding: 3px 10px; font-size: 12.5px; }
.doc-view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.content { flex: 1; overflow-y: auto; outline: none; scroll-behavior: smooth; }
.editor-pane { height: var(--editor-h); min-height: 44px; display: flex; flex-direction: column; background: var(--pane); flex: none; }
.editor-pane.folded { height: 42px !important; }
.editor-pane.folded .editor-host { display: none; }
.editor-bar { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-bottom: 1px solid var(--line); flex: none; flex-wrap: wrap; }
.editor-title { font-weight: 700; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.editor-host { flex: 1; min-height: 0; position: relative; }
.editor-host .CodeMirror { position: absolute; inset: 0; height: 100%; }
.editor-host textarea.fallback { position: absolute; inset: 0; width: 100%; height: 100%; border: none; resize: none; padding: 10px; background: var(--code-bg); font: 14px/1.6 var(--mono); }

/* ---------------------------------------------------------------- 문서(강좌 내용) */
.doc { max-width: 920px; margin: 0 auto; padding: 28px 34px 80px; }
.doc h1 { font-size: 30px; line-height: 1.3; margin: 6px 0 10px; letter-spacing: -.02em; }
.doc h2 { font-size: 22px; margin: 36px 0 12px; padding-bottom: 6px; border-bottom: 2px solid var(--line); letter-spacing: -.01em; }
.doc h3 { font-size: 18.5px; margin: 28px 0 8px; display: flex; align-items: center; gap: 8px; }
.doc h3::before { content: ''; width: 5px; height: 18px; border-radius: 3px; background: var(--accent); }
.doc p { margin: 8px 0; }
.doc ul, .doc ol { padding-left: 24px; margin: 8px 0; }
.doc li { margin: 3px 0; }
.doc li::marker { color: var(--accent); }
.doc :not(pre) > code { background: var(--card2); border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; font-size: .88em; color: var(--tk-def); }
.doc mark { background: var(--warn-soft); color: inherit; padding: 0 3px; border-radius: 3px; }
.doc table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: 14px; background: var(--card); border-radius: 8px; overflow: hidden; box-shadow: var(--shadow); }
.doc th, .doc td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; vertical-align: top; }
.doc th { background: var(--card2); font-weight: 700; }
.doc .table-wrap { overflow-x: auto; }
.doc .caption { font-size: 12.5px; color: var(--muted); text-align: center; margin-top: -4px; }
.doc pre { white-space: pre-wrap; }

.chapter-badge {
  display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 13px; color: var(--accent);
  background: var(--accent-soft); border-radius: 20px; padding: 3px 12px;
}
.lead { font-size: 16.5px; color: var(--muted); }
.meta-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 600; border: 1px solid var(--line); background: var(--card); border-radius: 20px; padding: 2px 10px; color: var(--muted); }
.goals {
  background: var(--card); border: 1px solid var(--line); border-left: 5px solid var(--accent2); border-radius: var(--radius); padding: 12px 18px; margin: 16px 0; box-shadow: var(--shadow);
}
.goals b { color: var(--accent2); }
.goals ul { margin: 6px 0 0; }
.flow { display: flex; gap: 0; margin: 10px 0; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); }
.flow div { padding: 5px 8px; font-size: 12.5px; background: var(--card2); border-right: 1px solid var(--line); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.flow div:last-child { border-right: none; }
.flow b { color: var(--accent2); }

/* 코드 블록 */
.code-block { margin: 16px 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--code-bg); box-shadow: var(--shadow); }
.code-head { display: flex; align-items: center; gap: 6px; padding: 7px 10px 7px 14px; background: var(--card); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.code-head .t { font-weight: 700; font-size: 14px; flex: 1; min-width: 200px; }
.code-head .t .tag { font: 600 11px var(--mono); color: var(--accent2); background: var(--accent2-soft); border-radius: 5px; padding: 1px 6px; margin-right: 6px; vertical-align: 1px; }
.code-block pre { margin: 0; padding: 12px 0; overflow-x: auto; font-size: 13.5px; line-height: 1.6; color: var(--code-fg); white-space: pre; }
.code-block pre .ln { display: block; padding: 0 16px 0 0; }
.code-block pre .ln::before { content: attr(data-n); display: inline-block; width: 42px; padding-right: 12px; margin-right: 4px; text-align: right; color: var(--muted); opacity: .6; user-select: none; }
.code-block pre .ln.file-mark { background: var(--accent2-soft); }
.code-desc { padding: 10px 16px; background: var(--card); border-top: 1px solid var(--line); font-size: 14px; }
.code-desc p:first-child { margin-top: 0; }
.code-desc p:last-child { margin-bottom: 0; }
.stdin-hint { font-size: 12.5px; color: var(--muted); padding: 6px 16px; background: var(--card); border-top: 1px dashed var(--line); }
.stdin-hint code { color: var(--accent2) !important; }
.expect { border-top: 1px solid var(--line); }
.expect summary { cursor: pointer; padding: 6px 14px; font-size: 12.5px; font-weight: 600; color: var(--muted); background: var(--card); list-style: none; }
.expect summary::-webkit-details-marker { display: none; }
.expect summary::before { content: '▸ '; }
.expect[open] summary::before { content: '▾ '; }
.expect pre.term { margin: 0; background: var(--term-bg); color: var(--term-fg); padding: 10px 16px; font-size: 13px; white-space: pre-wrap; }

/* 콜아웃 */
.callout { border-radius: var(--radius); padding: 12px 16px 12px 16px; margin: 16px 0; border: 1px solid var(--line); border-left-width: 5px; background: var(--card); }
.callout .ct { font-weight: 800; margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }
.callout > div > p:first-child { margin-top: 0; }
.callout > div > p:last-child { margin-bottom: 0; }
.callout.tip { border-left-color: var(--ok); background: var(--ok-soft); }
.callout.tip .ct { color: var(--ok); }
.callout.warn { border-left-color: var(--danger); background: var(--danger-soft); }
.callout.warn .ct { color: var(--danger); }
.callout.info { border-left-color: var(--accent2); background: var(--accent2-soft); }
.callout.info .ct { color: var(--accent2); }
.callout.more { border-left-color: var(--more); background: var(--more-soft); }
.callout.more .ct { color: var(--more); }

/* 그림 */
.figure { margin: 18px 0; padding: 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
.figure svg { width: 100%; height: auto; display: block; font-family: var(--sans); }
.figure svg text:not([fill]) { fill: var(--fg); }
.figure .caption { margin: 8px 0 0; }

/* 실습 · 퀴즈 */
.practice { margin: 16px 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); overflow: hidden; }
.practice-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--accent-soft); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.practice-head b { flex: 1; min-width: 180px; font-size: 15px; }
.level { font-size: 12px; font-weight: 700; color: var(--accent); letter-spacing: 1px; }
.practice-body { padding: 10px 16px 14px; }
.practice-body details { margin-top: 8px; }
.practice-body details summary { cursor: pointer; font-weight: 700; font-size: 13.5px; color: var(--accent2); }
.practice-body .actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.solution { margin-top: 10px; border: 1px dashed var(--accent2); border-radius: 8px; overflow: hidden; }
.solution .code-block { margin: 0; border: none; border-radius: 0; box-shadow: none; }
.teacher-badge { font-size: 11.5px; font-weight: 700; color: #fff; background: var(--accent2); border-radius: 5px; padding: 1px 7px; }

.quiz { margin: 14px 0; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); }
.quiz .qn { font-weight: 800; color: var(--accent2); margin-right: 4px; }
.quiz .q { font-weight: 600; }
.quiz .q pre { background: var(--code-bg); padding: 10px 14px; border-radius: 8px; border: 1px solid var(--line); font-size: 13px; overflow-x: auto; white-space: pre; }
.quiz .opts { display: grid; gap: 6px; margin-top: 10px; }
.quiz .opt {
  text-align: left; border: 1px solid var(--line); background: var(--card2); border-radius: 8px; padding: 7px 12px; cursor: pointer; display: flex; gap: 8px;
}
.quiz .opt:hover { border-color: var(--accent2); }
.quiz .opt .n { font-weight: 800; color: var(--muted); }
.quiz .opt.right { border-color: var(--ok); background: var(--ok-soft); }
.quiz .opt.right .n { color: var(--ok); }
.quiz .opt.wrong { border-color: var(--danger); background: var(--danger-soft); }
.quiz .explain { margin-top: 8px; font-size: 14px; padding: 8px 12px; border-radius: 8px; background: var(--accent2-soft); }

.section-end { margin-top: 36px; padding: 18px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; box-shadow: var(--shadow); }
.section-end .done-btn.done { background: var(--ok); border-color: var(--ok); color: #fff; }

/* 홈 / 챕터 개요 */
.hero {
  border-radius: 16px; padding: 30px 32px; margin-bottom: 20px; color: #fff; position: relative; overflow: hidden;
  background: radial-gradient(circle at 85% 20%, rgba(255, 255, 255, .18), transparent 40%), linear-gradient(135deg, #003b73 0%, #0b5cad 50%, #00897b 100%);
}
.hero h1 { margin: 0 0 6px; font-size: 32px; }
.hero p { margin: 4px 0; opacity: .95; }
.hero .hero-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.hero .btn { background: rgba(255, 255, 255, .95); color: #1d2433; border-color: transparent; }
.hero .btn.outline { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .7); }
.hero .cup { position: absolute; right: 26px; bottom: -22px; font-size: 120px; font-weight: 900; font-family: var(--mono); opacity: .2; }
.nav-group { margin: 14px 10px 4px; font-size: 12px; font-weight: 800; letter-spacing: .04em; color: var(--muted); text-transform: uppercase; border-top: 1px solid var(--line); padding-top: 10px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin: 14px 0; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; cursor: pointer; text-decoration: none; color: inherit;
  box-shadow: var(--shadow); transition: transform .12s, border-color .12s; display: flex; flex-direction: column; gap: 4px;
}
.card:hover { transform: translateY(-2px); border-color: var(--accent); }
.card .ci { font-size: 24px; }
.card .cn { font: 700 12px var(--mono); color: var(--accent); }
.card .ct { font-weight: 800; font-size: 16px; }
.card .cs { font-size: 13px; color: var(--muted); }
.card .cp { height: 4px; background: var(--card2); border-radius: 4px; overflow: hidden; margin-top: 6px; }
.card .cp i { display: block; height: 100%; background: var(--ok); }
.card.disabled { opacity: .55; cursor: default; }
.steps { counter-reset: step; list-style: none; padding: 0 !important; }
.steps li { counter-increment: step; position: relative; padding-left: 38px; margin: 10px 0; }
.steps li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 800; display: grid; place-items: center; font-size: 13px; }
.sec-list { display: grid; gap: 8px; }
.sec-item { display: flex; gap: 12px; align-items: center; padding: 10px 14px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; cursor: pointer; text-decoration: none; color: inherit; }
.sec-item:hover { border-color: var(--accent); }
.sec-item .sn { font: 700 13px var(--mono); color: var(--accent2); background: var(--accent2-soft); border-radius: 6px; padding: 2px 8px; }
.sec-item .st { flex: 1; font-weight: 700; }
.sec-item .sm { font-size: 12.5px; color: var(--muted); }

/* ---------------------------------------------------------------- 오른쪽: 콘솔 */
.output { display: flex; flex-direction: column; border-left: 1px solid var(--line); background: var(--term-bg); }
.console-panel { display: flex; flex-direction: column; height: 100%; min-height: 0; background: var(--term-bg); color: var(--term-fg); --c-font: 14px; }
.console-head { display: flex; align-items: center; gap: 10px; padding: 9px 12px; background: #161b22; border-bottom: 1px solid #262c36; }
.console-dots { display: flex; gap: 6px; }
.console-dots i { width: 11px; height: 11px; border-radius: 50%; background: #ff5f57; display: block; }
.console-dots i:nth-child(2) { background: #febc2e; }
.console-dots i:nth-child(3) { background: #28c840; }
.console-title { font-weight: 700; font-size: 13.5px; color: #e6edf3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.console-title .muted { color: var(--term-muted); font-weight: 500; }
.run-state { font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 20px; background: #262c36; color: var(--term-muted); white-space: nowrap; }
.run-state.compiling { background: #3b2e0e; color: #f2c14e; }
.run-state.running { background: #0f3a22; color: #4cc983; }
.run-state.error { background: #3d1614; color: #ff7b72; }
.run-state.done { background: #13283f; color: #79c0ff; }
.console-tools { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-bottom: 1px solid #262c36; background: #12171e; flex-wrap: wrap; }
.console-tools .btn { background: transparent; color: #c9d1d9; border-color: #30363d; }
.console-tools .btn:hover:not(:disabled) { border-color: #58a6ff; }
.console-tools .btn.danger:not(:disabled) { color: #ff7b72; border-color: #ff7b72; }
.fs-only { display: none !important; }
.console {
  flex: 1; overflow: auto; padding: 12px 14px; font: var(--c-font)/1.55 var(--mono); white-space: pre-wrap; word-break: break-all; outline: none;
}
.console .o { color: var(--term-fg); }
.console .e { color: var(--term-err); }
.console .i { color: var(--term-in); }
.console .s { color: var(--term-sys); }
.console .m { color: var(--term-muted); }
.console .hint { display: block; white-space: normal; margin: 6px 0 10px; padding: 8px 10px; border-radius: 6px; background: #1b2330; border-left: 3px solid #f2c14e; font-family: var(--sans); font-size: 13px; color: #e6edf3; }
.console .hint b { color: #f2c14e; }
.console .diag { display: block; white-space: pre-wrap; margin: 6px 0; }
.console .diag .loc { color: #79c0ff; cursor: pointer; text-decoration: underline dotted; }
.console .run-sep { display: block; color: var(--term-muted); border-top: 1px dashed #30363d; margin: 10px 0 6px; padding-top: 6px; font-size: 12px; font-family: var(--sans); }
.console-welcome { font-family: var(--sans); white-space: normal; color: var(--term-muted); text-align: center; padding: 40px 16px; }
.console-welcome .cw-icon { font: 700 34px var(--mono); color: #4cc983; margin-bottom: 8px; }
.console-welcome b { color: #e6edf3; }
.console-welcome code { color: #79c0ff; }
.console-welcome kbd { background: #1b2330; border-color: #30363d; color: #e6edf3; }
.stdin-form { display: flex; align-items: center; gap: 6px; padding: 7px 10px; border-top: 1px solid #262c36; background: #12171e; }
.stdin-form .prompt { color: #4cc983; font-size: 15px; }
.stdin-form input {
  flex: 1; min-width: 0; background: #0b0f14; border: 1px solid #30363d; border-radius: 6px; padding: 6px 9px; color: #7ee787; font-family: var(--mono); font-size: 14px; outline: none;
}
.stdin-form input:focus { border-color: #4cc983; box-shadow: 0 0 0 2px rgba(76, 201, 131, .2); }
.stdin-form input:disabled { opacity: .5; }
.stdin-form.waiting input { border-color: #f2c14e; animation: pulseBorder 1.2s infinite; }
@keyframes pulseBorder { 50% { box-shadow: 0 0 0 3px rgba(242, 193, 78, .25); } }
.stdin-form .btn { background: transparent; color: #c9d1d9; border-color: #30363d; }
.console-status { display: flex; gap: 8px; padding: 4px 12px; font-size: 12px; color: var(--term-muted); background: #161b22; border-top: 1px solid #262c36; }

/* ---------------------------------------------------------------- 모달 · 토스트 */
.modal { position: fixed; inset: 0; background: rgba(8, 12, 18, .55); display: grid; place-items: center; z-index: 1000; padding: 20px; }
.modal-card { width: min(760px, 100%); max-height: 86vh; display: flex; flex-direction: column; background: var(--pane); border-radius: 14px; border: 1px solid var(--line); box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.modal-head { display: flex; align-items: center; padding: 12px 14px 10px 18px; border-bottom: 1px solid var(--line); font-size: 16px; }
.modal-body { padding: 16px 18px; overflow: auto; }
.modal-body pre { background: var(--code-bg); border: 1px solid var(--line); padding: 10px 14px; border-radius: 8px; overflow: auto; font-size: 13px; }
.modal-body input[type=text] { width: 100%; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card2); }
.file-list { display: grid; gap: 4px; margin: 10px 0; }
.file-row { display: flex; gap: 10px; align-items: center; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; background: var(--card); }
.file-row:hover { border-color: var(--accent); }
.file-row .fn { flex: 1; font-family: var(--mono); font-size: 13.5px; }
.file-row .fs { font-size: 12px; color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); background: #1d2433; color: #fff; padding: 9px 18px; border-radius: 10px; font-weight: 600; z-index: 2000; box-shadow: 0 8px 24px rgba(0, 0, 0, .3); }

/* ---------------------------------------------------------------- CodeMirror 테마 (라이트/다크 공용) */
.CodeMirror { font-family: var(--mono); font-size: var(--ed-font, 14.5px); line-height: 1.6; background: var(--code-bg); color: var(--code-fg); height: 100%; }
.CodeMirror-gutters { background: var(--code-bg); border-right: 1px solid var(--line); }
.CodeMirror-linenumber { color: var(--muted); opacity: .7; padding: 0 8px 0 4px; }
.CodeMirror-cursor { border-left: 2px solid var(--accent); }
.CodeMirror-activeline-background { background: rgba(127, 140, 160, .09); }
.CodeMirror-selected, .CodeMirror-focused .CodeMirror-selected { background: rgba(47, 111, 179, .22) !important; }
.CodeMirror-matchingbracket { color: var(--ok) !important; font-weight: 700; text-decoration: underline; }
.CodeMirror .err-line { background: rgba(214, 69, 65, .14); }
.CodeMirror .err-gutter { color: var(--danger); font-weight: 800; padding-left: 3px; cursor: help; }
.cm-keyword { color: var(--tk-keyword); font-weight: 600; }
.cm-type, .cm-variable-3 { color: var(--tk-type); }
.cm-string, .cm-string-2 { color: var(--tk-string); }
.cm-number, .cm-atom { color: var(--tk-number); }
.cm-comment { color: var(--tk-comment); font-style: italic; }
.cm-def { color: var(--tk-def); }
.cm-meta { color: var(--tk-meta); }
.cm-builtin { color: var(--tk-type); }
.cm-operator { color: var(--tk-op); }
.cm-variable, .cm-variable-2, .cm-property { color: var(--code-fg); }
.cm-file-mark { color: var(--accent2); font-weight: 700; font-style: normal; }

/* ---------------------------------------------------------------- 반응형 */
@media (max-width: 1100px) {
  :root { --nav-w: 250px; --out-w: 360px; }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: auto; height: auto; overflow: visible; }
  .layout .gutter { display: none; }
  .nav { max-height: 60vh; border-right: none; border-bottom: 1px solid var(--line); }
  .layout.nav-collapsed { grid-template-columns: 1fr; }
  .layout.nav-collapsed .nav { display: none; }
  .center { height: auto; overflow: visible; }
  .content { overflow: visible; }
  .editor-pane { height: 420px; }
  .output { height: 70vh; }
  .doc { padding: 20px 16px 60px; }
  .nav-close { display: inline-block; }
}
