:root {
  --bg: #05080b;
  --panel: #121920;
  --panel2: #0c1218;
  --line: #1e2a36;
  --text: #e8eef4;
  --muted: #a9b4bf;
  --mint: #12b886;
  --mint2: #63e6be;
  --red: #ff8787;
  --bar: 50px;
  --left: 46%;
  --guide: 56%;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", "Noto Sans KR", "Malgun Gothic", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  overflow: hidden;
}
body.read { overflow: auto; }
button { font: inherit; cursor: pointer; }

/* 상단 바 */
.bar {
  height: var(--bar);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel2);
}
.logo { font-weight: 800; letter-spacing: -.02em; color: var(--text); text-decoration: none; font-size: 17px; }
.logo span { color: var(--mint); }
.dots { display: flex; gap: 5px; list-style: none; margin: 0 auto; padding: 0; }
.dots a {
  display: grid; place-items: center;
  width: 24px; height: 24px; border-radius: 50%;
  font-size: 11px; color: var(--muted); text-decoration: none;
  border: 1px solid var(--line);
}
.dots .ok a { border-color: var(--mint); color: var(--mint); }
.dots .now a { background: var(--mint); border-color: var(--mint); color: #042; font-weight: 700; }
.dots a:hover { border-color: var(--mint2); }
.bar-link { color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 600; white-space: nowrap; }
.bar-link:hover { color: var(--mint2); }

/* 3구역 */
.work {
  display: grid;
  grid-template-columns: var(--left) 6px 1fr;
  height: calc(100vh - var(--bar));
}
.left {
  display: grid;
  grid-template-rows: var(--guide) 6px 1fr;
  min-height: 0;
  min-width: 0;
}
.v-handle, .h-handle { background: var(--line); position: relative; z-index: 2; touch-action: none; }
.v-handle { cursor: col-resize; }
.h-handle { cursor: row-resize; }
.v-handle::before, .h-handle::before { content: ""; position: absolute; inset: 0; }
.v-handle::before { left: -5px; right: -5px; }
.h-handle::before { top: -5px; bottom: -5px; }
.v-handle::after, .h-handle::after { content: ""; position: absolute; border-radius: 3px; background: #4b5a69; }
.v-handle::after { top: 50%; left: 1px; width: 4px; height: 40px; margin-top: -20px; }
.h-handle::after { left: 50%; top: 1px; height: 4px; width: 40px; margin-left: -20px; }
.v-handle:hover, .h-handle:hover, .v-handle.on, .h-handle.on { background: var(--mint); }
.v-handle:hover::after, .h-handle:hover::after, .v-handle.on::after, .h-handle.on::after { background: #042; }
body.dragging { user-select: none; cursor: inherit; }
body.dragging iframe { pointer-events: none; }

/* 가이드 글 */
.guide { overflow: auto; padding: 26px 30px 40px; min-height: 0; }
.read-main { max-width: 760px; margin: 0 auto; padding: 40px 24px 80px; }
.read-main .guide { padding: 0; overflow: visible; }
.step-no { margin: 0 0 4px; color: var(--mint); font-weight: 700; font-size: 13px; letter-spacing: .04em; }
.guide h1 { margin: 0 0 18px; font-size: 28px; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; }
.guide h2 { margin: 30px 0 10px; font-size: 18px; font-weight: 700; color: var(--mint2); }
.guide p { margin: 0 0 14px; }
.guide ul, .guide ol { margin: 0 0 14px; padding-left: 22px; }
.guide li { margin: 4px 0; }
.guide li::marker { color: var(--muted); }
.guide code { font-family: ui-monospace, "JetBrains Mono", Consolas, "D2Coding", monospace; font-size: .88em; background: var(--panel); border: 1px solid var(--line); padding: 1px 6px; border-radius: 5px; color: #d8e6f0; }
.guide strong { color: #fff; }
.guide table { border-collapse: collapse; width: 100%; margin: 0 0 16px; font-size: 14px; }
.guide th, .guide td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.guide th { background: var(--panel); color: var(--text); font-weight: 600; }
.guide table code { white-space: nowrap; }

.code { margin: 0 0 16px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #0d1117; }
.code-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 6px 14px; background: var(--panel); border-bottom: 1px solid var(--line); font-size: 12px; color: #c2ccd6; }
.code-head .file { font-family: ui-monospace, Consolas, monospace; }
.code-head .copy { background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 5px; padding: 2px 9px; font-size: 12px; }
.code-head .copy:hover { color: var(--text); border-color: var(--muted); }
.code-head .copy.ok { color: var(--mint2); border-color: var(--mint); }
.code pre { margin: 0; padding: 12px 14px; overflow: auto; font-size: 13px; line-height: 1.55; }
.code pre code { font-family: ui-monospace, "JetBrains Mono", Consolas, "D2Coding", monospace; background: none; border: 0; padding: 0; font-size: inherit; color: #eeffff; white-space: pre; }
.cm-jinja { color: #ffcb6b; }
.cm-jinja-tag { color: #c792ea; }

details.full { margin: 28px 0 0; border: 1px dashed var(--line); border-radius: 10px; padding: 0 14px; }
details.full summary { cursor: pointer; padding: 12px 0; color: var(--muted); font-weight: 600; }
details.full[open] summary { border-bottom: 1px solid var(--line); margin-bottom: 14px; }

.flow { display: grid; grid-template-columns: 1fr 1.3fr 1fr; align-items: center; gap: 10px; margin: 8px 0 22px; text-align: center; }
.flow .box { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 10px; }
.flow .box b { display: block; font-size: 17px; }
.flow .box span { font-size: 12px; color: var(--muted); }
.flow .arrow { display: grid; gap: 6px; font-size: 13px; color: var(--mint2); }
.layout-demo { display: grid; grid-template-columns: 1fr 1.2fr; grid-template-rows: 110px 110px; gap: 6px; margin: 8px 0 22px; font-weight: 700; text-align: center; }
.layout-demo > div { display: grid; place-content: center; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); }
.layout-demo small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }
.ld-preview { grid-row: 1 / 3; grid-column: 2; background: #fff !important; color: #212529; }
.ld-editor { background: #0d1117 !important; }

/* 게시판에 올리기 */
.submit { margin: 0 0 18px; padding: 18px 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.submit-form { display: grid; grid-template-columns: 1fr 1.6fr auto; gap: 10px; align-items: end; }
.submit-form label { display: grid; gap: 5px; font-size: 12.5px; color: var(--muted); font-weight: 600; min-width: 0; }
.submit-form input { width: 100%; padding: 9px 12px; font: inherit; font-size: 14px; color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; outline: none; }
.submit-form input:focus { border-color: var(--mint); }
.submit-form .btn { border: 0; padding: 10px 18px; white-space: nowrap; }
.submit-form .btn:disabled { opacity: .6; cursor: wait; }
.submit-result { margin: 12px 0 0 !important; font-size: 14px; color: var(--muted); }
.submit-result[hidden] { display: none; }
.submit-result.ok { color: var(--mint2); }
.submit-result.err { color: var(--red); }
.submit-result a { color: #fff; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
@media (max-width: 1500px) { .submit-form { grid-template-columns: 1fr 1fr; } .submit-form .btn { grid-column: 1 / -1; } }

.done-row { display: flex; justify-content: flex-end; gap: 10px; margin-top: 36px; padding-top: 20px; border-top: 1px solid var(--line); }
.btn { display: inline-block; padding: 10px 20px; border-radius: 8px; font-weight: 700; text-decoration: none; font-size: 14px; }
.btn.primary { background: var(--mint); color: #042; }
.btn.primary:hover { background: var(--mint2); }
.btn.ghost { border: 1px solid var(--line); color: var(--muted); }
.btn.ghost:hover { color: var(--text); border-color: var(--muted); }

/* 편집기 */
.editor { display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow: hidden; background: #212121; }
.tabbar { display: flex; align-items: stretch; background: var(--panel2); border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 2px; padding: 6px 0 0 8px; overflow-x: auto; flex: 1; min-width: 0; scrollbar-width: thin; }
.tab {
  display: flex; align-items: center; gap: 6px;
  background: none; border: 1px solid transparent; border-bottom: 0; color: #c2ccd6;
  padding: 6px 7px 6px 12px; border-radius: 7px 7px 0 0; font-size: 12.5px; font-family: ui-monospace, Consolas, monospace; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.on { background: #212121; color: var(--text); border-color: var(--line); }
.tab .dirty { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #ffcb6b; visibility: hidden; }
.tab.dirty .dirty { visibility: visible; }
.tab .x { display: grid; place-items: center; width: 17px; height: 17px; border-radius: 4px; font-size: 15px; line-height: 1; color: var(--muted); }
.tab .x:hover { background: #2c3a48; color: #fff; }
.tab-add { position: relative; display: flex; align-items: center; padding: 0 8px; border-left: 1px solid var(--line); }
#add-file { background: none; border: 1px solid var(--line); color: var(--text); border-radius: 6px; padding: 3px 9px; font-size: 12.5px; white-space: nowrap; }
#add-file:hover { border-color: var(--mint); color: var(--mint2); }
.file-menu { position: absolute; top: calc(100% + 2px); right: 8px; z-index: 5; min-width: 210px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 5px; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
.file-menu button { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; background: none; border: 0; color: var(--text); padding: 7px 10px; border-radius: 5px; font-size: 12.5px; font-family: ui-monospace, Consolas, monospace; }
.file-menu button:hover { background: #22303e; }
.file-menu button.open { color: var(--muted); }
.file-menu button.open::after { content: "열림"; margin-left: auto; font-size: 11px; font-family: inherit; }
.file-menu .dirty { width: 7px; height: 7px; border-radius: 50%; background: #ffcb6b; }
.cm-wrap { flex: 1; min-height: 0; position: relative; }
.cm-wrap.none .CodeMirror { visibility: hidden; }
.cm-wrap .empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 14px; }
.cm-wrap .empty[hidden] { display: none; }
.cm-s-material-darker .CodeMirror-linenumber { color: #6f7b87; }
.cm-s-material-darker .cm-comment { color: #8a96a2; }
.CodeMirror { height: 100%; font-family: ui-monospace, "JetBrains Mono", Consolas, "D2Coding", monospace; font-size: 13.5px; line-height: 1.5; }
.console[hidden] { display: none; }
.console { max-height: 45%; display: flex; flex-direction: column; border-top: 1px solid var(--line); background: #0d1117; }
.console-head { display: flex; justify-content: space-between; padding: 5px 12px; font-size: 12px; color: var(--muted); background: var(--panel2); }
.console-head button { background: none; border: 0; color: var(--text); font-size: 12px; }
.console pre { margin: 0; padding: 10px 14px; overflow: auto; font-size: 12px; line-height: 1.5; color: var(--red); white-space: pre-wrap; font-family: ui-monospace, Consolas, monospace; }
.editor-bar { display: flex; align-items: center; gap: 10px; padding: 7px 10px; background: var(--panel2); border-top: 1px solid var(--line); }
.status { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text); margin-right: auto; }
.status i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status.ok i { background: var(--mint); box-shadow: 0 0 8px var(--mint); }
.status.err i { background: #fa5252; box-shadow: 0 0 8px #fa5252; }
.status.busy i { background: #ffcb6b; animation: blink .8s infinite; }
@keyframes blink { 50% { opacity: .3; } }
.status b { font-weight: 600; }
#log-toggle { background: none; border: 1px solid var(--line); color: var(--text); border-radius: 6px; padding: 5px 10px; font-size: 12.5px; }
#log-toggle:hover { color: var(--text); }
.run { background: var(--mint); color: #042; border: 0; border-radius: 7px; padding: 7px 16px; font-weight: 700; font-size: 13.5px; }
.run:hover { background: var(--mint2); }
.run:disabled { opacity: .6; cursor: wait; }
.run kbd { font-family: inherit; font-size: 11px; font-weight: 500; opacity: .75; margin-left: 4px; }

/* 미리보기 */
.right { display: flex; flex-direction: column; min-width: 0; }
.addr { display: flex; align-items: center; gap: 6px; padding: 7px 10px; background: var(--panel2); border-bottom: 1px solid var(--line); }
.addr button, .addr a { background: none; border: 1px solid var(--line); color: var(--text); border-radius: 6px; width: 30px; height: 28px; display: grid; place-items: center; text-decoration: none; font-size: 14px; }
.addr button:hover, .addr a:hover { color: var(--text); border-color: var(--muted); }
.addr .host { font-size: 12.5px; color: var(--text); font-family: ui-monospace, Consolas, monospace; margin-left: 6px; }
.addr input { flex: 1; background: var(--panel); border: 1px solid var(--line); color: var(--text); border-radius: 6px; padding: 5px 10px; font-family: ui-monospace, Consolas, monospace; font-size: 13px; outline: none; }
.addr input:focus { border-color: var(--mint); }
iframe { flex: 1; border: 0; background: #fff; width: 100%; }
