/* Finipage
   중립 회색 도구 화면. 브랜드 색은 두 곳에만 쓴다.
     먹색   #17191E — 주 동작 버튼(저장 등). 로고 글자 색
     오렌지 #FF5A0A — 캔버스의 선택·호버 표시와 현재 상태 표시. 로고 마크 색
   그 밖의 강조는 굵기와 명도로 만든다. 그림자는 떠 있는 것(메뉴·툴바·대화상자)에만. */

:root {
  --bg: #FFFFFF;
  --bg-sub: #F7F7F8;
  --canvas: #ECECEE;
  --line: #E4E4E7;
  --line-strong: #D4D4D8;
  --hover: #F1F1F3;
  --press: #E7E7EA;
  --text: #18181B;
  --text-2: #52525B;
  --text-3: #6E6E76;
  --navy: #17191E;
  --navy-hover: #2D3138;
  --accent: #FF5A0A;
  --accent-soft: rgba(255,90,10,0.10);
  --accent-ink: #C2410C;
  --danger: #C4321F;
  --shadow-pop: 0 1px 2px rgba(0,0,0,0.06), 0 8px 24px rgba(0,0,0,0.12);
  --font: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Malgun Gothic', sans-serif;
  --mono: 'SFMono-Regular', ui-monospace, Consolas, 'D2Coding', monospace;
  --r: 5px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: var(--font);
  font-size: 12px;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'tnum';
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
[hidden] { display: none !important; }
svg.ic { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

/* ============ 배치 ============ */
#app {
  display: grid;
  grid-template-rows: 44px 1fr 24px;
  grid-template-columns: 232px minmax(0, 1fr) 264px;
  grid-template-areas:
    "topbar topbar topbar"
    "sidebar canvas inspector"
    "statusbar statusbar statusbar";
  height: 100vh;
  height: 100dvh;
}
#app.no-doc {
  grid-template-rows: 44px 1fr;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "topbar" "canvas";
}
#app.no-doc #sidebar, #app.no-doc #inspector, #app.no-doc #statusbar, #app.no-doc .doc-only { display: none !important; }

/* ============ 상단 바 ============ */
#topbar {
  grid-area: topbar;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 8px 0 12px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.tb-left, .tb-right { display: flex; align-items: center; gap: 2px; }
.tb-right { justify-content: flex-end; }
.tb-center { display: flex; align-items: center; gap: 2px; min-width: 0; }
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; letter-spacing: -0.01em;
  margin-right: 6px;
}
.brand .mark { width: 24px; height: 24px; margin-right: -4px; }
.brand .wordmark { font-family: 'Outfit', var(--font); font-weight: 700; font-size: 17px; letter-spacing: -.02em; line-height: 1; }
.tb-sep { width: 1px; height: 18px; background: var(--line); margin: 0 6px; }

.tb-btn, .tb-icon {
  height: 28px;
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: var(--r);
  color: var(--text-2);
  font-weight: 500;
  white-space: nowrap;
}
.tb-btn { padding: 0 9px; }
.tb-icon { width: 28px; justify-content: center; }
.tb-btn:hover:not(:disabled), .tb-icon:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.tb-btn:active:not(:disabled), .tb-icon:active:not(:disabled) { background: var(--press); }
.tb-btn:disabled, .tb-icon:disabled { color: var(--text-3); opacity: 0.55; }
.tb-btn.primary { background: var(--navy); color: #fff; padding: 0 14px; margin-left: 4px; }
.tb-btn.primary:hover:not(:disabled) { background: var(--navy-hover); color: #fff; }
.tb-btn.primary:disabled { background: var(--line-strong); color: #fff; opacity: 1; }
#btn-folder { color: #9A5B00; }
#btn-folder:hover { background: #FFF4E0; color: #7A4700; }
#btn-folder.linked { color: var(--text-2); }

.filename {
  display: inline-flex; align-items: center; gap: 6px;
  max-width: 360px;
  font-size: 12.5px; font-weight: 500;
  padding: 0 4px;
}
#filename-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filename .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); display: none; flex-shrink: 0; }
.filename.dirty .dot { display: inline-block; }

.seg { display: inline-flex; background: var(--bg-sub); border: 1px solid var(--line); border-radius: 6px; padding: 1px; }
.seg button { width: 28px; height: 24px; border-radius: 4px; display: inline-flex; align-items: center; justify-content: center; color: var(--text-3); }
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--bg); color: var(--text); box-shadow: 0 0 0 1px var(--line), 0 1px 1px rgba(0,0,0,0.04); }

/* 메뉴 */
.menu-wrap { position: relative; }
.menu {
  position: absolute; top: calc(100% + 6px); right: 0;
  width: 260px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-pop);
  padding: 4px;
  z-index: 10000;
}
.menu-item {
  width: 100%;
  display: flex; align-items: flex-start; gap: 8px;
  text-align: left;
  padding: 7px 8px;
  border-radius: var(--r);
}
.menu-item:hover { background: var(--hover); }
.mi-body { display: block; font-weight: 500; }
.menu-item .desc { display: block; font-weight: 400; color: var(--text-3); margin-top: 2px; line-height: 1.45; }
.menu-item .check {
  width: 14px; height: 14px; margin-top: 1px; border-radius: 3px;
  border: 1px solid var(--line-strong); flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.menu-item[aria-checked="true"] .check { background: var(--navy); border-color: var(--navy); }
.menu-item[aria-checked="true"] .check::after {
  content: ''; width: 4px; height: 8px; border: solid #fff; border-width: 0 1.5px 1.5px 0;
  transform: translateY(-1px) rotate(45deg);
}
.menu-sep { height: 1px; background: var(--line); margin: 4px 0; }
.menu-foot { color: var(--text-3); padding: 6px 8px 4px; font-size: 11px; }

/* ============ 왼쪽 패널 ============ */
#sidebar {
  grid-area: sidebar;
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  min-height: 0;
  background: var(--bg);
}
.pane { border-bottom: 1px solid var(--line); padding: 10px 8px 10px; }
.pane-fill { flex: 1; min-height: 0; display: flex; flex-direction: column; border-bottom: none; padding-bottom: 0; }
.pane-title { font-size: 11px; font-weight: 600; color: var(--text-2); padding: 0 6px 8px; }

.insert-list { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; }
.insert-item {
  display: flex; align-items: center; gap: 8px;
  height: 28px; padding: 0 6px;
  border-radius: var(--r);
  color: var(--text);
  text-align: left;
}
.insert-item svg.ic { color: var(--text-3); }
.insert-item:hover { background: var(--hover); }
.insert-item:hover svg.ic { color: var(--text); }

/* 레이어 트리 */
.layers { flex: 1; overflow: auto; padding-bottom: 12px; margin: 0 -8px; }
.ly-row {
  display: flex; align-items: center; gap: 4px;
  height: 24px;
  padding-right: 8px;
  cursor: default;
  white-space: nowrap;
  color: var(--text-2);
  border-left: 2px solid transparent;
}
.ly-row:hover { background: var(--hover); }
.ly-row.selected { background: var(--accent-soft); color: var(--text); border-left-color: var(--accent); }
.ly-caret {
  width: 16px; height: 16px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-3); border-radius: 3px;
}
.ly-caret svg.ic { width: 12px; height: 12px; transition: transform 0.12s; }
.ly-caret.open svg.ic { transform: rotate(90deg); }
.ly-caret.leaf { visibility: hidden; }
.ly-caret:hover { background: var(--press); color: var(--text); }
.ly-icon svg.ic { width: 14px; height: 14px; color: var(--text-3); }
.ly-tag { font-family: var(--mono); font-size: 11px; color: var(--text); }
.ly-meta { font-size: 11px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.ly-more { font-size: 11px; color: var(--text-3); padding: 4px 0 4px 40px; }

/* ============ 캔버스 ============ */
#canvas { grid-area: canvas; position: relative; background: var(--canvas); overflow: hidden; isolation: isolate; } /* 선택 표시가 서랍·시트 위로 올라오지 않게 */
#app.no-doc #canvas { background: var(--bg-sub); }

#iframe-wrap {
  position: absolute; inset: 0;
  display: flex;
  justify-content: safe center;
  background: #fff;
}
#editor-iframe { width: 100%; height: 100%; border: none; display: block; background: #fff; flex-shrink: 0; }
#iframe-wrap.vp-tablet, #iframe-wrap.vp-mobile { background: var(--canvas); overflow-x: auto; padding: 0 24px; }
#iframe-wrap.vp-tablet #editor-iframe { width: 768px; box-shadow: 0 0 0 1px var(--line-strong); }
#iframe-wrap.vp-mobile #editor-iframe { width: 390px; box-shadow: 0 0 0 1px var(--line-strong); }

/* 선택·호버 */
#hover-box {
  position: absolute; z-index: 9996;
  border: 1px solid var(--accent);
  pointer-events: none; display: none;
}
#hover-box.visible { display: block; }
#selection-box {
  position: absolute; z-index: 9997;
  border: 1.5px solid var(--accent);
  pointer-events: none; display: none;
}
#selection-box.visible { display: block; }
body.shift-down #selection-box.visible { pointer-events: auto; cursor: move; background: var(--accent-soft); }
.sel-label {
  position: absolute; left: -1.5px; bottom: 100%;
  background: var(--accent); color: #fff;
  font-family: var(--mono); font-size: 10px; line-height: 16px;
  padding: 0 5px;
  border-radius: 3px 3px 0 0;
  white-space: nowrap;
  pointer-events: none;
}
#selection-box.label-inside .sel-label { bottom: auto; top: 0; border-radius: 0 0 3px 0; }
#selection-box .rh {
  position: absolute; width: 8px; height: 8px;
  background: #fff; border: 1.5px solid var(--accent); border-radius: 1px;
  pointer-events: auto;
}
#selection-box .rh:hover { background: var(--accent); }
#selection-box .rh-nw { top: -5px; left: -5px; cursor: nwse-resize; }
#selection-box .rh-n  { top: -5px; left: 50%; margin-left: -4px; cursor: ns-resize; }
#selection-box .rh-ne { top: -5px; right: -5px; cursor: nesw-resize; }
#selection-box .rh-e  { top: 50%; right: -5px; margin-top: -4px; cursor: ew-resize; }
#selection-box .rh-se { bottom: -5px; right: -5px; cursor: nwse-resize; }
#selection-box .rh-s  { bottom: -5px; left: 50%; margin-left: -4px; cursor: ns-resize; }
#selection-box .rh-sw { bottom: -5px; left: -5px; cursor: nesw-resize; }
#selection-box .rh-w  { top: 50%; left: -5px; margin-top: -4px; cursor: ew-resize; }
#selection-box.editing .rh { display: none; }
#selection-box.editing { border-style: dashed; }

#drop-indicator {
  position: absolute; z-index: 9998;
  background: var(--accent); border-radius: 1px;
  display: none; pointer-events: none;
}

#floating-toolbar {
  position: absolute; z-index: 9999;
  display: none; gap: 1px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow-pop);
  padding: 2px;
}
#floating-toolbar.visible { display: flex; }
#floating-toolbar button {
  width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 4px; color: var(--text-2);
}
#floating-toolbar button:hover { background: var(--hover); color: var(--text); }
#floating-toolbar button.grip { cursor: grab; }
#floating-toolbar button.grip:active { cursor: grabbing; }
#floating-toolbar button.danger:hover { color: var(--danger); background: #FDEDEA; }
#floating-toolbar .ft-sep { width: 1px; background: var(--line); margin: 4px 1px; }

#resize-indicator {
  position: fixed; z-index: 10003;
  background: var(--text); color: #fff;
  font-family: var(--mono); font-size: 11px;
  padding: 3px 6px; border-radius: 4px;
  display: none; pointer-events: none;
}
#resize-indicator.visible { display: block; }

/* ============ 첫 화면 ============ */
#welcome { position: absolute; inset: 0; overflow-y: auto; }
.wl-inner { max-width: 600px; padding: 18vh 0 48px 12vw; }
#welcome h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; margin-bottom: 6px; }
.wl-sub { font-size: 13px; color: var(--text-2); margin-bottom: 20px; }
.wl-actions { display: flex; gap: 8px; margin-bottom: 36px; }
.recent { margin-bottom: 28px; }
.recent h2 { font-size: 11px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.recent ul { list-style: none; border-top: 1px solid var(--line); }
.recent li { border-bottom: 1px solid var(--line); }
.recent-item {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 4px;
  text-align: left;
}
.recent-item:hover { background: var(--hover); }
.recent-item svg.ic { color: var(--text-3); }
.recent-name { font-size: 13px; font-weight: 500; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-time { color: var(--text-3); white-space: nowrap; }
.wl-link { color: var(--text-2); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-strong); }
.wl-link:hover { color: var(--text); text-decoration-color: currentColor; }

/* 파일을 끌고 들어올 때 */
#drop-zone {
  position: fixed; inset: 0; z-index: 10004;
  background: rgba(24,24,27,0.18);
  display: none; align-items: center; justify-content: center;
  pointer-events: none;
}
#drop-zone.dragover { display: flex; }
.dz-box {
  background: var(--bg); border: 1.5px solid var(--accent);
  border-radius: 8px; padding: 18px 28px;
  font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow-pop);
}

/* ============ 공통 버튼 · 입력 ============ */
.btn {
  height: 30px; padding: 0 12px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  background: var(--bg);
  font-weight: 500;
  white-space: nowrap;
}
.btn:hover { background: var(--hover); }
.btn:active { background: var(--press); }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-hover); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.block { width: 100%; }
#welcome .btn { height: 34px; padding: 0 16px; font-size: 13px; }

.icon-btn {
  width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 4px; color: var(--text-2);
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.danger:hover { color: var(--danger); background: #FDEDEA; }
.icon-group { display: inline-flex; }

.inp {
  width: 100%; min-width: 0;
  height: 26px;
  padding: 0 7px;
  background: var(--bg-sub);
  border: 1px solid transparent;
  border-radius: 4px;
  outline: none;
  font-size: 12px;
}
.inp:hover { border-color: var(--line); }
.inp:focus { background: var(--bg); border-color: var(--accent); }
.inp.invalid { border-color: var(--danger); background: #FDEDEA; }
.inp.mono, .inp.num { font-family: var(--mono); font-size: 11.5px; }
.inp::placeholder { color: var(--text-3); }
textarea.inp { height: auto; padding: 5px 7px; resize: vertical; line-height: 1.45; font-family: var(--font); }
select.inp { padding-right: 20px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%238E8E96' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 7px center; }

/* ============ 오른쪽 패널 ============ */
#inspector {
  grid-area: inspector;
  border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
  min-height: 0;
  background: var(--bg);
}
.insp-head {
  display: flex; align-items: center; gap: 6px;
  height: 40px; padding: 0 8px 0 14px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.insp-name { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 6px; }
.insp-tag { font-weight: 600; font-size: 12.5px; }
.insp-cls { font-family: var(--mono); font-size: 11px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.insp-actions { display: flex; align-items: center; gap: 0; }
.insp-body { flex: 1; overflow-y: auto; }

.sec { padding: 12px 14px 14px; border-bottom: 1px solid var(--line); }
.sec h3 { font-size: 11px; font-weight: 600; color: var(--text-2); margin-bottom: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 6px; }
.field { display: flex; align-items: center; position: relative; }
.field .fl {
  position: absolute; left: 7px; top: 50%; transform: translateY(-50%);
  font-size: 11px; color: var(--text-3); pointer-events: none;
}
.field .inp { padding-left: 42px; }
.field.wide { margin-bottom: 6px; }
.field.wide .inp { padding-left: 42px; }
.field-stack { display: block; margin-bottom: 8px; }
.field-stack > span { display: block; font-size: 11px; color: var(--text-3); margin-bottom: 4px; }
.field-stack:last-child { margin-bottom: 0; }

.row-tools { display: flex; gap: 6px; }
.seg-sm { display: inline-flex; flex: 1; background: var(--bg-sub); border-radius: 4px; padding: 1px; }
.seg-sm button {
  flex: 1; height: 24px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 3px; color: var(--text-2); font-size: 12px;
}
.seg-sm button:hover { color: var(--text); }
.seg-sm button.active { background: var(--bg); color: var(--text); box-shadow: 0 0 0 1px var(--line), 0 1px 1px rgba(0,0,0,0.04); }
.seg-sm svg.ic { width: 14px; height: 14px; }

.color-row { display: grid; grid-template-columns: 42px 26px 1fr; align-items: center; gap: 6px; margin-bottom: 6px; }
.color-row:last-child { margin-bottom: 0; }
.color-row .fl { font-size: 11px; color: var(--text-3); }
.chip {
  width: 26px; height: 26px; border-radius: 4px;
  border: 1px solid var(--line-strong);
  background:
    linear-gradient(var(--c, transparent), var(--c, transparent)),
    repeating-conic-gradient(#e4e4e7 0% 25%, #fff 0% 50%) 50% / 8px 8px;
}
.chip:hover { border-color: var(--text-3); }
.chip.open { outline: 2px solid var(--accent); outline-offset: 1px; }

/* 여백: 바깥/안쪽 상자 */
.box-edit {
  position: relative;
  border: 1px dashed var(--line-strong);
  border-radius: 4px;
  padding: 26px 44px;
  margin-bottom: 8px;
  background: var(--bg-sub);
}
.be-inner {
  position: relative;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  padding: 26px 44px;
  background: var(--bg);
}
.be-core { height: 14px; border-radius: 2px; background: var(--hover); border: 1px solid var(--line); }
.be-label { position: absolute; top: 3px; left: 6px; font-size: 10px; color: var(--text-3); }
.box-edit .inp.num {
  position: absolute; width: 40px; height: 20px;
  padding: 0 2px; text-align: center; font-size: 11px;
  background: transparent;
}
.box-edit .inp.num:hover { background: var(--bg); border-color: var(--line); }
.box-edit .inp.num:focus { background: var(--bg); }
.be-t { top: 3px; left: 50%; transform: translateX(-50%); }
.be-b { bottom: 3px; left: 50%; transform: translateX(-50%); }
.be-l { left: 2px; top: 50%; transform: translateY(-50%); }
.be-r { right: 2px; top: 50%; transform: translateY(-50%); }

.link-btn { display: inline-flex; align-items: center; gap: 5px; color: var(--text-2); margin-top: 4px; }
.link-btn:hover { color: var(--text); }
.link-btn svg.ic { width: 14px; height: 14px; }
.check-row { display: flex; align-items: center; gap: 6px; margin-top: 8px; color: var(--text-2); }
.check-row input { accent-color: var(--navy); }
#link-href { margin-bottom: 0; }
#image-panel .btn { margin-bottom: 10px; }

/* 색 고르기 */
.popover {
  position: fixed; z-index: 10005;
  width: 216px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-pop);
  padding: 10px;
}
.pal-label { font-size: 11px; color: var(--text-3); margin-bottom: 6px; }
.pal-label + .swatches { margin-bottom: 10px; }
.swatches { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.swatch {
  aspect-ratio: 1; border-radius: 3px;
  background: var(--c);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.12);
}
.swatch:hover { transform: scale(1.12); }
.pal-foot { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 8px; margin-top: 2px; }
.pal-custom { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); cursor: pointer; }
.pal-custom input { width: 20px; height: 20px; border: none; padding: 0; background: none; cursor: pointer; }
.pal-none { color: var(--text-2); padding: 2px 4px; border-radius: 3px; }
.pal-none:hover { background: var(--hover); color: var(--text); }

/* ============ 상태 바 ============ */
#statusbar {
  grid-area: statusbar;
  display: flex; align-items: center; gap: 12px;
  padding: 0 8px 0 10px;
  border-top: 1px solid var(--line);
  background: var(--bg);
  font-size: 11px;
  color: var(--text-3);
  min-width: 0;
}
#breadcrumb { flex: 1; min-width: 0; display: flex; align-items: center; overflow: hidden; white-space: nowrap; }
#breadcrumb .bc-item {
  font-family: var(--mono); font-size: 11px;
  padding: 1px 4px; border-radius: 3px;
  color: var(--text-2);
}
#breadcrumb .bc-item:hover { background: var(--hover); color: var(--text); }
#breadcrumb .bc-item.current { color: var(--text); font-weight: 600; }
#breadcrumb .bc-sep { color: var(--line-strong); padding: 0 1px; }
.sb-right { display: flex; gap: 12px; white-space: nowrap; }
#sel-size { font-family: var(--mono); }
#status.error { color: var(--danger); }

/* ============ 알림 ============ */
#toast {
  position: fixed; bottom: 36px; left: 50%;
  transform: translate(-50%, 12px);
  opacity: 0; pointer-events: none;
  background: var(--text); color: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12.5px;
  max-width: min(600px, 90vw);
  display: flex; align-items: center; gap: 14px;
  z-index: 10001;
  transition: opacity 0.16s, transform 0.16s;
}
#toast.visible { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast.error { background: var(--danger); }
#toast.warn::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: #F5B83D; flex-shrink: 0; }
#toast button { color: #FFB088; font-weight: 600; padding: 2px 0; white-space: nowrap; }
#toast.error button { color: #fff; text-decoration: underline; }
#toast button:hover { text-decoration: underline; }

/* ============ 대화상자 ============ */
.overlay {
  position: fixed; inset: 0; z-index: 10002;
  background: rgba(24,24,27,0.32);
  display: none; align-items: center; justify-content: center;
  padding: 24px;
}
.overlay.visible { display: flex; }
.dialog {
  background: var(--bg);
  border-radius: 10px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.2);
  width: 100%; max-width: 560px; max-height: 86vh;
  overflow-y: auto;
  padding: 18px 20px 20px;
}
.dlg-head { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.dlg-head h2 { font-size: 15px; font-weight: 600; margin-right: auto; }
.dialog .msg { font-size: 13px; line-height: 1.6; color: var(--text); }
.dialog .msg small { display: block; color: var(--text-2); font-size: 12px; margin-top: 4px; }
.dialog .msg b { font-weight: 600; }
.dialog .btn-row { display: flex; gap: 6px; justify-content: flex-end; margin-top: 18px; }
#confirm-dialog { max-width: 400px; }

#help-dialog { max-width: 780px; }
.help-cols { display: grid; grid-template-columns: 1fr 1.25fr; gap: 28px; }
.help-cols h3 { font-size: 11px; font-weight: 600; color: var(--text-2); margin: 0 0 8px; }
.help-cols h3:not(:first-child) { margin-top: 18px; }
.keys { display: grid; grid-template-columns: auto 1fr; column-gap: 14px; row-gap: 7px; align-items: baseline; }
.keys dt { white-space: nowrap; color: var(--text-2); }
.keys dd { color: var(--text); }
kbd {
  display: inline-block; min-width: 18px;
  padding: 0 4px;
  font-family: var(--font); font-size: 11px; line-height: 17px; text-align: center;
  background: var(--bg-sub);
  border: 1px solid var(--line-strong); border-bottom-width: 2px;
  border-radius: 4px;
  color: var(--text);
}
.tips { list-style: none; }
.tips li { position: relative; padding-left: 12px; margin-bottom: 8px; line-height: 1.55; color: var(--text); }
.tips li::before { content: ''; position: absolute; left: 0; top: 0.62em; width: 4px; height: 1px; background: var(--text-3); }
code { font-family: var(--mono); font-size: 11px; background: var(--bg-sub); padding: 0 3px; border-radius: 3px; }

#source-dialog { max-width: 920px; display: flex; flex-direction: column; }
.source-meta { font-family: var(--mono); font-size: 11px; color: var(--text-3); }
#source-code {
  width: 100%; min-height: 320px; height: 62vh;
  background: var(--bg-sub);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  font-family: var(--mono); font-size: 11.5px; line-height: 1.55;
  color: var(--text);
  resize: none; white-space: pre; overflow: auto; tab-size: 2; outline: none;
}

/* ============ 반응형 ============
   1280↑  세 칸 (삽입·레이어 | 캔버스 | 속성)
   1024↑  세 칸, 패널 폭을 줄임
   768↑   캔버스 전체 폭 + 양쪽 패널은 옆에서 나오는 서랍
   768↓   캔버스 전체 폭 + 패널은 아래에서 올라오는 시트, 상단 바는 꼭 필요한 것만 */
.narrow-only, .phone-only { display: none !important; }
.drawer-head {
  align-items: center; justify-content: space-between;
  height: 40px; padding: 0 8px 0 14px;
  border-bottom: 1px solid var(--line);
  font-weight: 600; font-size: 12.5px;
  flex-shrink: 0;
}
#scrim { position: fixed; inset: 0; z-index: 9000; background: rgba(24,24,27,0.24); }

@media (max-width: 1279px) {
  #app { grid-template-columns: 208px minmax(0, 1fr) 248px; }
  #btn-download { display: none; }
  .brand .wordmark { display: none; }
}

@media (max-width: 1023px) {
  .narrow-only { display: inline-flex !important; }
  .drawer-head.narrow-only { display: flex !important; }
  #app, #app.no-doc {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 44px 1fr 24px;
    grid-template-areas: "topbar" "canvas" "statusbar";
  }
  #app.no-doc { grid-template-rows: 44px 1fr; grid-template-areas: "topbar" "canvas"; }
  #sidebar, #inspector {
    position: fixed; top: 44px; bottom: 0; z-index: 9001;
    width: min(300px, 86vw);
    box-shadow: var(--shadow-pop);
    transition: transform 0.2s ease;
    border: none;
  }
  #sidebar { left: 0; transform: translateX(-102%); }
  #inspector { right: 0; transform: translateX(102%); }
  body.show-left #sidebar, body.show-right #inspector { transform: none; }
  .wl-inner { padding: 12vh 32px 48px 8vw; }
}

@media (max-width: 767px) {
  .hide-phone { display: none !important; }
  .phone-only { display: block !important; }
  .menu-sep.phone-only { display: block !important; }
  .menu-item.phone-only { display: flex !important; }
  .menu-item.phone-only.unavail { display: none !important; }
  /* 파일을 연 뒤에는 편집에 쓰는 버튼만 상단에 남기고, 열기·닫기·폴더 연결은 ⋯ 메뉴로 */
  #app:not(.no-doc) .brand, #app:not(.no-doc) #btn-open, #app:not(.no-doc) #btn-new, #app:not(.no-doc) #btn-folder { display: none !important; }
  #app.no-doc .menu-item.doc-menu { display: none !important; }
  #app, #app.no-doc { grid-template-rows: 48px 1fr; grid-template-areas: "topbar" "canvas"; }
  #statusbar { display: none !important; }
  #topbar { display: flex; gap: 2px; padding: 0 6px; }
  .tb-left { flex-shrink: 0; }
  .tb-center { flex: 1; min-width: 0; justify-content: center; }
  .filename { max-width: 100%; min-width: 0; }
  .tb-right { flex-shrink: 0; }
  #btn-open { width: 32px; padding: 0; justify-content: center; font-size: 0; gap: 0; }
  #btn-folder { font-size: 0; gap: 0; padding: 0 8px; }
  .tb-btn.primary { padding: 0 12px; }
  .brand { margin-right: 2px; }
  /* 시트: 아래에서 올라온다. 캔버스 윗부분은 보인 채로 */
  #sidebar, #inspector {
    top: auto; left: 0; right: 0; bottom: 0;
    width: auto; height: min(58vh, 520px);
    border-radius: 12px 12px 0 0;
    transform: translateY(102%);
  }
  #sidebar::before, #inspector::before {
    content: ''; position: absolute; top: 6px; left: 50%; margin-left: -18px;
    width: 36px; height: 4px; border-radius: 2px; background: var(--line-strong);
  }
  .drawer-head, .insp-head { padding-top: 6px; height: 46px; }
  body.show-left #sidebar, body.show-right #inspector { transform: none; }
  .insert-list { grid-template-columns: 1fr 1fr 1fr; }
  .wl-inner { padding: 10vh 24px 40px; }
  .wl-actions { flex-wrap: wrap; }
  #toast { bottom: 20px; max-width: calc(100vw - 24px); }
  .help-cols { grid-template-columns: 1fr; gap: 8px; }
  .dialog { padding: 16px; max-height: 90vh; }
  .overlay { padding: 12px; align-items: flex-end; }
  #source-code { height: 60vh; }
}

/* 손가락 조작: 누를 곳을 키운다. iOS 는 16px 보다 작은 입력칸에 초점이 가면 화면을 확대해 버린다 */
@media (pointer: coarse) {
  .tb-btn, .tb-icon { height: 36px; }
  .tb-icon { width: 36px; }
  .seg button { width: 34px; height: 30px; }
  .insert-item { height: 40px; }
  .ly-row { height: 36px; }
  .icon-btn { width: 36px; height: 36px; }
  .inp, select.inp { height: 36px; font-size: 16px; }
  .inp.mono, .inp.num { font-size: 16px; }
  .field .inp { padding-left: 46px; }
  .seg-sm button { height: 34px; }
  .chip { width: 36px; height: 36px; }
  .color-row { grid-template-columns: 42px 36px 1fr; }
  .box-edit { padding: 34px 52px; }
  .be-inner { padding: 34px 52px; }
  .box-edit .inp.num { width: 48px; height: 28px; font-size: 16px; }
  .menu-item { padding: 11px 10px; }
  .recent-item { padding: 13px 4px; }
  #floating-toolbar button { width: 38px; height: 38px; }
  #floating-toolbar button svg.ic { width: 18px; height: 18px; }
  #selection-box .rh { width: 14px; height: 14px; border-radius: 3px; }
  #selection-box .rh::after { content: ''; position: absolute; inset: -10px; } /* 보이지 않는 넓은 손잡이 */
  #selection-box .rh-nw { top: -8px; left: -8px; }
  #selection-box .rh-n  { top: -8px; margin-left: -7px; }
  #selection-box .rh-ne { top: -8px; right: -8px; }
  #selection-box .rh-e  { right: -8px; margin-top: -7px; }
  #selection-box .rh-se { bottom: -8px; right: -8px; }
  #selection-box .rh-s  { bottom: -8px; margin-left: -7px; }
  #selection-box .rh-sw { bottom: -8px; left: -8px; }
  #selection-box .rh-w  { left: -8px; margin-top: -7px; }
  .swatches { gap: 6px; }
}
#selection-box .rh, #floating-toolbar .grip { touch-action: none; }

/* 스크롤바 */
.layers::-webkit-scrollbar, .insp-body::-webkit-scrollbar, .dialog::-webkit-scrollbar, #source-code::-webkit-scrollbar { width: 10px; height: 10px; }
.layers::-webkit-scrollbar-thumb, .insp-body::-webkit-scrollbar-thumb, .dialog::-webkit-scrollbar-thumb, #source-code::-webkit-scrollbar-thumb {
  background: #D4D4D8; border-radius: 10px; border: 3px solid transparent; background-clip: content-box;
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ============ Pro · 게시 창 ============ */
#pro-dialog, #publish-dialog { max-width: 520px; }
.dialog .lead { font-size: 13.5px; color: var(--text); margin-bottom: 14px; line-height: 1.6; }
.muted { color: var(--text-2); }
.small { font-size: 11.5px; line-height: 1.55; margin-top: 8px; }
.err { color: var(--danger); font-size: 12px; margin-top: 8px; line-height: 1.5; }
.badge { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 10px; background: var(--hover); color: var(--text-2); font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge.ok { background: rgba(255,90,10,0.12); color: var(--accent-ink); }
.badge.bad { background: #FDEDEA; color: var(--danger); }

.benefits { list-style: none; margin: 4px 0 16px; border-top: 1px solid var(--line); }
.benefits li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--line); }
.benefits svg.ic { color: var(--accent); margin-top: 1px; }
.benefits small { display: block; color: var(--text-3); font-size: 11.5px; margin-top: 1px; }
.price-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 4px; }
.plan-btn {
  display: flex; flex-direction: column; gap: 2px;
  padding: 11px 14px; border: 1px solid var(--line-strong); border-radius: 8px;
  color: var(--text); text-decoration: none;
}
.plan-btn:hover { border-color: var(--navy); }
.plan-btn b { font-size: 14px; }
.plan-btn span { font-size: 11.5px; color: var(--text-3); }
.plan-btn.best { border-color: var(--navy); box-shadow: inset 0 0 0 1px var(--navy); }
.key-row { display: flex; gap: 6px; margin-top: 12px; }
.key-row .inp { flex: 1; height: 30px; }
.pro-status { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.link-btn.trial { margin-top: 14px; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-strong); }
.link-btn.inline { display: inline; margin: 0; color: var(--navy); text-decoration: underline; text-underline-offset: 2px; font-size: inherit; }
.btn-row.left { justify-content: flex-start; flex-wrap: wrap; margin-top: 12px; }
.btn.ghost-danger { color: var(--danger); border-color: var(--line-strong); }
.btn.ghost-danger:hover { background: #FDEDEA; border-color: #F3B6AC; }
a.btn { text-decoration: none; color: var(--text); }
a.btn svg.ic { width: 14px; height: 14px; }

.notice { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 6px; margin-bottom: 10px; font-size: 12px; line-height: 1.5; }
.notice.warn { background: #FFF6E5; color: #6B4A00; }
.notice.bad { background: #FDEDEA; color: #8A2414; }
.notice span { flex: 1; }
.notice .btn { height: 26px; flex-shrink: 0; }

.site-list { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-bottom: 6px; }
.site-row { display: flex; align-items: flex-start; gap: 10px; padding: 10px 8px 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.site-row:last-child { border-bottom: none; }
.site-row:hover { background: var(--bg-sub); }
.site-row.disabled { cursor: default; opacity: 0.6; }
.site-row input[type="radio"] { margin-top: 3px; accent-color: var(--navy); }
.site-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.site-main b { font-weight: 600; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-main small { color: var(--text-3); font-size: 11.5px; }
.site-row .icon-btn { flex-shrink: 0; }
.slug-field { display: flex; align-items: center; gap: 4px; margin-top: 4px; }
.slug-field .inp { flex: 1; max-width: 220px; }
.slug-field span { font-family: var(--mono); font-size: 11.5px; color: var(--text-3); white-space: nowrap; }
.hint.ok { color: #15803D; }
.hint.bad { color: var(--danger); }

.pub-result { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: 8px; background: rgba(255,90,10,0.07); }
.pub-result svg.ic { width: 20px; height: 20px; color: var(--accent); margin-top: 1px; }
.pub-result b { display: block; font-size: 13.5px; margin-bottom: 3px; }
.pub-result a { color: var(--navy); font-family: var(--mono); font-size: 12px; word-break: break-all; }
.pub-domain { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 14px; }
.pub-domain h3 { font-size: 11px; font-weight: 600; color: var(--text-2); margin-bottom: 8px; }
.pub-domain p { margin-bottom: 8px; line-height: 1.55; }
.pub-domain a { color: var(--navy); }
.dom-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.dns { width: 100%; border-collapse: collapse; margin: 4px 0 8px; font-size: 12px; }
.dns th { text-align: left; font-weight: 600; font-size: 11px; color: var(--text-3); padding: 6px 8px; border-bottom: 1px solid var(--line); }
.dns td { padding: 8px; border-bottom: 1px solid var(--line); word-break: break-all; }
.mono { font-family: var(--mono); }
@media (max-width: 767px) {
  .price-row { grid-template-columns: 1fr; }
  .slug-field { flex-wrap: wrap; }
  .slug-field .inp { max-width: none; }
}

/* ============ 계정 ============ */
a.brand { color: inherit; text-decoration: none; }
a.tb-btn { text-decoration: none; }
.tb-icon.avatar span {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--navy); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
}
.acct-head { padding: 8px 8px 6px; display: flex; flex-direction: column; gap: 2px; }
.acct-head b { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-head span { font-size: 11px; color: var(--text-3); }
a.menu-item { color: inherit; text-decoration: none; }
.menu-item.danger .mi-body { color: var(--danger); }
.login-need { padding: 4px 0 2px; }
.login-need p { line-height: 1.6; margin-bottom: 10px; }

/* ============ 언어 탭 ============ */
.lang-tabs { display: inline-flex; background: var(--bg-sub); border: 1px solid var(--line); border-radius: 6px; padding: 1px; }
.lang-tabs button { height: 24px; padding: 0 10px; border-radius: 4px; font-size: 11.5px; color: var(--text-2); }
.lang-tabs button:hover { color: var(--text); }
.lang-tabs button.on { background: var(--bg); color: var(--text); font-weight: 600; box-shadow: 0 0 0 1px var(--line), 0 1px 1px rgba(0,0,0,0.04); }
.menu-lang { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 8px; font-size: 12px; color: var(--text-2); }
.wl-foot { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }

/* ---------- 광고 자리 (편집 화면 바깥 틀에만) ---------- */
.ad-box { flex: none; }
.ad-label { display: block; font-size: 10px; color: var(--text-3); margin-bottom: 4px; }
.ad-box:has(ins[data-ad-status="unfilled"]) { display: none; }
/* 왼쪽 패널: 넓고 높은 화면에서만 — 레이어 목록 공간을 먼저 지킨다 */
.ad-side { border-top: 1px solid var(--line); padding: 10px 8px; }
@media (max-width: 1279px), (max-height: 799px) { .ad-side { display: none !important; } }

/* ---------- 레이어 끌어서 순서 바꾸기 ---------- */
#layers { position: relative; }
#ly-drop { position: absolute; right: 4px; height: 2px; background: var(--accent); border-radius: 1px; pointer-events: none; display: none; z-index: 2; }
#ly-drop.bad { background: #D9534F; }
body.ly-dragging, body.ly-dragging .ly-row { cursor: grabbing; user-select: none; }
.ly-row.dragging { opacity: .45; }
