/* 노드 실습형 강좌 — 화면 · 노드 편집기 스타일 (노드 · 연결선 · 포트 규칙은 노드 빌더 원본과 같음) */
:root {
  --bg: #f1f4f9; --pane: #ffffff; --card: #ffffff; --card2: #f6f8fc; --line: #dfe4ec; --fg: #1d2433; --muted: #6b7587;
  --accent: #4f46e5; --accent-soft: #eceefe; --accent2: #0f9d8a; --ok: #1f9d55; --ok-soft: #e3f6ec; --warn: #c98a00; --warn-soft: #fff6d9;
  --danger: #d64541; --danger-soft: #fdeaea; --code-bg: #f6f8fb; --shadow: 0 1px 2px rgba(20,30,50,.06), 0 6px 18px rgba(20,30,50,.08);
  --grid: #dde3ec; --canvas: #eef1f6; --node-bg: #ffffff; --node-line: #d5dbe6; --sel: #4f46e5;
  --term-bg: #0f1419; --term-fg: #d7dde8; --term-muted: #7d8799; --term-err: #ff7b72; --term-ok: #7ee787; --term-sys: #79c0ff;
  --k-text: #5b8def; --k-llm: #d97706; --k-tool: #0f9d8a; --k-memory: #d9488b; --k-agent: #7c3aed; --k-task: #2563eb; --k-mcp: #0891b2; --k-resource: #65a30d; --k-prompt: #c026d3; --k-skill: #4338ca; --k-promptver: #0d9488;
  --mono: 'JetBrains Mono', 'D2Coding', Consolas, 'Courier New', monospace;
  --sans: 'Pretendard Variable', Pretendard, -apple-system, 'Segoe UI', 'Malgun Gothic', sans-serif;
  --nav-w: 270px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0e1116; --pane: #151a21; --card: #1a2029; --card2: #1f2631; --line: #2a323e; --fg: #e3e8f0; --muted: #8d97a8;
  --accent-soft: #23284a; --ok: #4cc983; --ok-soft: #132e20; --warn: #f2c14e; --warn-soft: #33290f;
  --danger: #ff6b61; --danger-soft: #3a1a18; --code-bg: #11161d; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
  --grid: #1c222b; --canvas: #12161c; --node-bg: #1a2029; --node-line: #2e3744; --sel: #a5b4fc;
  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; display: flex; flex-direction: column; overflow: hidden; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
code, kbd, pre { font-family: var(--mono); }
code { background: var(--code-bg); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; font-size: .88em; }
.muted { color: var(--muted); } .spacer { flex: 1; } .pad { padding: 14px; } .err { color: var(--danger); }
[hidden] { display: none !important; }
.teacher-only { display: none !important; }
.is-teacher .teacher-only { display: revert !important; }
.btn { border: 1px solid var(--line); background: var(--card); color: var(--fg); border-radius: 8px; padding: 5px 12px; cursor: pointer; font-weight: 600; font-size: 13px; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.small { padding: 2px 9px; font-size: 12px; }
.btn.danger { color: var(--danger); }

/* ---------------- 상단 · 목차 */
#top { display: flex; align-items: center; gap: 10px; padding: 8px 16px; background: var(--pane); border-bottom: 1px solid var(--line); flex: none; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--fg); }
.brand .logo { font-size: 24px; }
.brand b { display: block; font-size: 16px; line-height: 1.2; } .brand small { color: var(--muted); font-size: 12px; }
.role { font-size: 12px; font-weight: 700; color: var(--accent); }
#wrap { flex: 1; display: flex; min-height: 0; }
#nav { width: var(--nav-w); flex: none; overflow-y: auto; background: var(--pane); border-right: 1px solid var(--line); padding: 10px 8px; font-size: 14px; }
#nav a { display: flex; align-items: center; gap: 6px; text-decoration: none; color: var(--fg); padding: 6px 8px; border-radius: 8px; }
#nav a:hover { background: var(--card2); }
#nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.nav-home { margin-bottom: 6px; }
.nav-ct .no { font-family: var(--mono); font-size: 12px; color: var(--muted); width: 22px; }
.nav-ct .t { flex: 1; } .nav-ct .pg { font-size: 11px; color: var(--muted); } .nav-ct .pg.full { color: var(--ok); font-weight: 700; }
.nav-sec { padding-left: 36px !important; font-size: 13px; color: var(--muted) !important; }
.nav-sec.on { color: var(--accent) !important; }
#main { flex: 1; overflow-y: auto; min-width: 0; }
#content { max-width: 1180px; margin: 0 auto; padding: 24px 32px 80px; }
h1 { font-size: 26px; margin: 4px 0 10px; } h2 { font-size: 19px; margin: 28px 0 10px; } h3 { font-size: 16px; margin: 20px 0 8px; }
.crumb { font-size: 13px; color: var(--muted); } .crumb a { color: var(--muted); }
.lead { color: var(--muted); font-size: 16px; }

/* ---------------- 처음 화면 */
.hero { display: flex; gap: 20px; align-items: center; background: var(--pane); border: 1px solid var(--line); border-radius: 16px; padding: 22px 26px; }
.hero-ic { font-size: 54px; }
.hero h1 { margin: 0; } .hero .sub { color: var(--muted); margin: 2px 0 8px; }
.prog { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.prog .bar { width: 240px; height: 8px; background: var(--card2); border-radius: 8px; overflow: hidden; }
.prog .bar i { display: block; height: 100%; background: var(--ok); }
.chgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.chcard, .seccard { display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: var(--fg); background: var(--pane); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.chcard:hover, .seccard:hover { border-color: var(--accent); }
.chcard .no, .seccard .no { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.chcard .ic { font-size: 26px; } .chcard small, .seccard small { color: var(--muted); font-size: 12.5px; }
.seclist { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.seccard .st { color: var(--ok); font-size: 12px; font-weight: 700; }
.howto { border-collapse: collapse; font-size: 14px; } .howto td { border: 1px solid var(--line); padding: 6px 10px; vertical-align: top; } .howto td:first-child { font-weight: 700; white-space: nowrap; background: var(--card2); }
.goals { background: var(--accent-soft); border-radius: 10px; padding: 10px 16px; margin: 10px 0 16px; }
.goals ul { margin: 4px 0 0; padding-left: 20px; }

/* ---------------- 본문 */
.doc { font-size: 15.5px; }
.doc img, .doc svg { max-width: 100%; }
.doc pre { background: var(--code-bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; overflow: auto; font-size: 13px; }
.doc pre code { border: 0; background: none; padding: 0; }
.doc table { border-collapse: collapse; margin: 8px 0; } .doc th, .doc td { border: 1px solid var(--line); padding: 6px 10px; } .doc th { background: var(--card2); }
.callout { border-left: 4px solid var(--accent); background: var(--accent-soft); padding: 8px 14px; border-radius: 8px; margin: 12px 0; }
.callout.tip { border-color: var(--ok); background: var(--ok-soft); } .callout.warn { border-color: var(--warn); background: var(--warn-soft); }
.tnote { border: 1px dashed var(--accent); border-radius: 10px; padding: 10px 14px; margin: 14px 0; background: var(--card2); }
.labcard { border: 1px solid var(--line); border-radius: 14px; background: var(--pane); margin: 18px 0; overflow: hidden; }
.labcard.open { border-color: var(--accent); }
.lab-h { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.lab-h .tag { font-size: 12px; font-weight: 700; color: #fff; background: var(--accent2); border-radius: 6px; padding: 1px 8px; }
.lab-h .st { color: var(--ok); font-size: 12.5px; font-weight: 700; }
.lab-goal { padding: 8px 16px; font-size: 14.5px; }
.labcard.open .lab-goal { display: none; }
.quiz .q { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin: 10px 0; background: var(--pane); }
.quiz .opts { display: flex; flex-direction: column; gap: 4px; margin: 6px 0; }
.quiz .short { border: 1px solid var(--line); border-radius: 7px; padding: 4px 8px; margin: 6px 6px 6px 0; background: var(--card2); }
.quiz .res { margin-left: 8px; font-weight: 700; } .quiz .res.ok { color: var(--ok); } .quiz .res.bad { color: var(--danger); }
.quiz .explain { margin-top: 6px; color: var(--muted); font-size: 14px; } .tans { margin-top: 4px; font-size: 13px; color: var(--accent); }
.donebar { margin: 20px 0; text-align: center; }
.pager { display: flex; justify-content: space-between; margin-top: 30px; padding-top: 14px; border-top: 1px solid var(--line); font-weight: 600; }
.pager a { text-decoration: none; }

/* ---------------- 실습 창 */
.nl { display: flex; flex-direction: column; height: 600px; background: var(--pane); font-size: 13px; line-height: 1.5; }
.nl.full { position: fixed; inset: 0; z-index: 80; height: auto; }
.nl-bar { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.nl-title { font-size: 14px; }
.nl-auto { display: flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--muted); }
.nl-goal { display: none; padding: 6px 12px; border-bottom: 1px solid var(--line); font-size: 13.5px; max-height: 90px; overflow: auto; background: var(--card2); }
.nl.full .nl-goal { display: block; }
.nl-main { flex: 1; display: flex; min-height: 0; }
.nl-pal { width: 210px; flex: none; border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.nl-pal input { margin: 8px; padding: 5px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--card2); }
#nlPal { flex: 1; overflow: auto; padding: 0 8px 8px; }
.pcat { margin-top: 6px; }
.pcat-h { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--muted); padding: 4px; }
.pcat-h i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.pitem { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; margin: 4px 0; background: var(--card); cursor: grab; border-left-width: 4px; }
.pitem:hover { border-color: var(--accent); background: var(--accent-soft); }
.pitem .pi { font-size: 16px; width: 20px; text-align: center; }
.pitem b { font-size: 12.5px; display: block; } .pitem small { color: var(--muted); font-size: 11px; display: block; line-height: 1.25; }
.nl-center { flex: 1; position: relative; min-width: 0; background: var(--canvas); }
.nl-side { width: 300px; flex: none; border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.nl-side .tabs { display: flex; gap: 2px; padding: 4px 6px; border-bottom: 1px solid var(--line); }
.nl-side .tabs button { border: 0; background: transparent; padding: 4px 10px; border-radius: 6px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 12.5px; }
.nl-side .tabs button.on { background: var(--accent-soft); color: var(--accent); }
.nl-tab { display: none; flex: 1; min-height: 0; overflow: auto; flex-direction: column; }
.nl-tab.on { display: flex; }
#nlProps { padding: 10px 12px; }
.nl-checks { padding: 10px 12px; }
.nl-verdict { font-weight: 700; padding: 8px 10px; border-radius: 8px; margin-bottom: 8px; }
.nl-verdict.ok { background: var(--ok-soft); color: var(--ok); } .nl-verdict.bad { background: var(--warn-soft); color: var(--warn); }
.nl-cl { list-style: none; padding: 0; margin: 0; } .nl-cl li { padding: 4px 0; border-bottom: 1px dashed var(--line); }
.nl-cl li.ok { color: var(--ok); } .nl-cl li.bad { color: var(--danger); }
@media (max-width: 1000px) { .nl { height: 720px; } .nl-main { flex-wrap: wrap; } .nl-pal { width: 100%; height: 130px; border-right: 0; border-bottom: 1px solid var(--line); } .nl-center { min-height: 360px; flex-basis: 60%; } .nl-side { width: 100%; height: 220px; border-left: 0; border-top: 1px solid var(--line); } }

/* 캔버스 · 노드 (원본 노드 빌더와 같은 규칙) */
#canvas { position: absolute; inset: 0; overflow: hidden; cursor: default; background-image: radial-gradient(var(--grid) 1.2px, transparent 1.2px); background-size: 22px 22px; }
#canvas.panning { cursor: grabbing; }
#canvas .world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
#canvas svg.wires { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: visible; pointer-events: none; }
.wire { fill: none; stroke-width: 2.4; pointer-events: stroke; cursor: pointer; opacity: .9; }
.wire.sel { stroke-width: 3.6; filter: drop-shadow(0 0 3px var(--sel)); }
.wire.back { stroke-dasharray: 7 5; }
.wire.flow { stroke-dasharray: 6 6; animation: flow .6s linear infinite; }
.wire-hit { fill: none; stroke: transparent; stroke-width: 14; pointer-events: stroke; cursor: pointer; }
.wire.temp { stroke-dasharray: 5 4; pointer-events: none; }
@keyframes flow { to { stroke-dashoffset: -12; } }
.canvas-tools { position: absolute; right: 10px; top: 8px; display: flex; gap: 2px; align-items: center; background: var(--pane); border: 1px solid var(--line); border-radius: 8px; padding: 3px; box-shadow: var(--shadow); z-index: 2; }
.canvas-tools button { border: 0; background: transparent; width: 26px; height: 24px; border-radius: 6px; cursor: pointer; font-size: 14px; }
.canvas-tools button:hover { background: var(--accent-soft); }
#zoomLbl { font-size: 12px; width: 40px; text-align: center; color: var(--muted); }
.emptyhint { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.eh-box { background: var(--pane); border: 1px dashed var(--line); border-radius: 14px; padding: 16px 22px; text-align: center; color: var(--muted); max-width: 440px; }
.eh-box p { margin: 6px 0 0; font-size: 12.5px; }
.node { position: absolute; width: 200px; background: var(--node-bg); border: 1.5px solid var(--node-line); border-radius: 10px; box-shadow: var(--shadow); user-select: none; font-size: 12.5px; line-height: 1.45; --c: var(--accent); }
.node.sel { border-color: var(--sel); box-shadow: 0 0 0 3px color-mix(in srgb, var(--sel) 28%, transparent), var(--shadow); }
.node.running { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }
.node.done .nhead::after { content: '✔'; color: var(--ok); margin-left: auto; font-size: 12px; }
.node.err { border-color: var(--danger); } .node.err .nhead::after { content: '✖'; color: var(--danger); margin-left: auto; }
.node.skip { opacity: .5; } .node.skip .nhead::after { content: '⏭'; margin-left: auto; font-size: 11px; }
.nhead { display: flex; align-items: center; gap: 6px; padding: 5px 10px; border-bottom: 1px solid var(--node-line); border-radius: 9px 9px 0 0; cursor: grab; background: color-mix(in srgb, var(--c) 12%, var(--node-bg)); border-left: 5px solid var(--c); }
.nhead .nicon { font-size: 15px; }
.nhead .ntitle { font-weight: 700; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nhead .ntype { color: var(--muted); font-size: 10.5px; margin-left: auto; white-space: nowrap; }
.node.done .nhead .ntype, .node.err .nhead .ntype, .node.skip .nhead .ntype { display: none; }
.nbody { padding: 5px 0 7px; }
.nports { display: flex; justify-content: space-between; gap: 6px; }
.ncol { display: flex; flex-direction: column; gap: 3px; min-width: 0; } .ncol.out { align-items: flex-end; }
.port { display: flex; align-items: center; gap: 6px; padding: 2px 8px; position: relative; color: var(--muted); font-size: 11.5px; white-space: nowrap; cursor: crosshair; }
.port.out { flex-direction: row-reverse; }
.port i { width: 12px; height: 12px; border-radius: 50%; background: var(--pk); border: 2px solid var(--node-bg); box-shadow: 0 0 0 1.5px var(--pk); display: inline-block; flex: none; }
.port.in i { margin-left: -14px; } .port.out i { margin-right: -14px; }
.port.req span::after { content: '*'; color: var(--danger); }
.port:hover i { transform: scale(1.3); }
.port.multi i { border-radius: 3px; }
.nsum { padding: 4px 10px 0; color: var(--muted); font-size: 11px; line-height: 1.35; max-height: 54px; overflow: hidden; white-space: pre-wrap; word-break: break-all; }
.nsum b { color: var(--fg); font-weight: 600; }
.node.t-note, .node.t-core\.note { background: #fff8c5; border-color: #e6d36a; --c: #d4a017; }
:root[data-theme="dark"] .node.t-note, :root[data-theme="dark"] .node.t-core\.note { background: #3b3417; border-color: #6e5e1e; }
.node.t-core\.note .nsum { max-height: none; color: var(--fg); font-size: 12px; }
.ctxmenu { background: var(--card); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 4px; z-index: 120; min-width: 140px; }
.ctxmenu button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 6px 10px; border-radius: 6px; cursor: pointer; }
.ctxmenu button:hover { background: var(--accent-soft); }

/* 속성 · 결과 · 로그 */
.ph { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.ph .pi { font-size: 20px; }
.ph input.plabel { flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--card2); border-radius: 7px; padding: 4px 8px; font-weight: 700; }
.ph .ptype { font-size: 11px; color: var(--muted); }
.pdesc { font-size: 12px; color: var(--muted); margin-bottom: 10px; padding: 8px 10px; background: var(--card2); border-radius: 8px; }
.fld { margin-bottom: 10px; }
.fld label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 3px; }
.fld input[type=text], .fld input[type=number], .fld select, .fld textarea { width: 100%; border: 1px solid var(--line); background: var(--card2); border-radius: 7px; padding: 5px 8px; }
.fld textarea { resize: vertical; } .fld textarea.code { font-family: var(--mono); font-size: 12px; white-space: pre; }
.fld .help { font-size: 11px; color: var(--muted); margin-top: 3px; }
.fld .chk { display: flex; align-items: center; gap: 6px; font-weight: 500; color: var(--fg); }
.routes .rt { display: flex; gap: 4px; margin-bottom: 4px; } .routes .rt input { flex: 1; min-width: 0; } .routes .rt input.lab { flex: 0 0 80px; }
.pfoot { margin-top: 12px; display: flex; gap: 6px; }
.results { padding: 8px; flex: none; max-height: 60%; overflow: auto; }
.rcard { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; background: var(--card); }
.rcard h4 { margin: 0; padding: 5px 10px; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.rcard pre { margin: 0; padding: 8px 10px; white-space: pre-wrap; word-break: break-word; font-size: 13px; font-family: var(--sans); }
.rcard pre.json { font-family: var(--mono); font-size: 12px; }
.rcard .chips { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px 10px; } .rcard .chips span { background: var(--card2); border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; font-family: var(--mono); font-size: 12px; }
.lamp { display: flex; align-items: center; gap: 8px; padding: 8px 10px; font-weight: 700; }
.lamp i { width: 18px; height: 18px; border-radius: 50%; background: #9aa3b2; box-shadow: inset 0 -2px 4px rgba(0,0,0,.25); }
.lamp.on i { background: #facc15; box-shadow: 0 0 12px #facc15, inset 0 -2px 4px rgba(0,0,0,.15); }
svg.chart { width: 100%; height: 150px; padding: 6px; } svg.chart rect { fill: var(--accent); } svg.chart text { font-size: 10px; fill: var(--muted); }
.log { flex: 1; min-height: 80px; overflow: auto; background: var(--term-bg); color: var(--term-fg); font-family: var(--mono); font-size: 11.5px; line-height: 1.5; padding: 6px 10px; white-space: pre-wrap; word-break: break-word; }
.log .ln { display: block; } .log .n-start { color: var(--term-sys); } .log .n-skip { color: var(--term-muted); } .log .n-end { color: var(--term-ok); } .log .n-err { color: var(--term-err); } .log .n-sys { color: var(--term-muted); font-style: italic; } .log .n-loop { color: #f2c14e; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
#toast div { background: #1d2433; color: #fff; padding: 8px 16px; border-radius: 20px; font-size: 13px; box-shadow: var(--shadow); }
#toast div.ok { background: var(--ok); } #toast div.warn { background: var(--warn); } #toast div.err { background: var(--danger); }

@media (max-width: 860px) {
  #wrap { flex-direction: column; } #nav { width: 100%; max-height: 34vh; border-right: 0; border-bottom: 1px solid var(--line); }
  #content { padding: 16px; }
}
