/*
 * SSemForm Studio — 셸 스타일.
 *
 * <설계 전제>
 * Form.io 빌더는 Bootstrap 을 전제한다(formio.full.min.css 가 그 일부를 들고 온다).
 * 우리 셸은 자체 CSS 라 섞이면 헤더·버튼이 Bootstrap 규칙에 끌려간다.
 * 그래서 셸은 우리 클래스만 쓰고, 빌더가 건드리는 범위는 formio-theme.css 로 분리했다.
 *
 * 색은 works-studio 다크 팔레트를 따른다 — 같은 조직의 제품으로 보이게.
 */

:root {
  /* 표면 — 어두운 쪽에서 밝은 쪽으로 4단계. 이 이상 늘리면 위계가 흐려진다. */
  --bg:        #0c0e14;
  --surface:   #12151e;
  --surface-2: #171b26;
  --surface-3: #1e2331;
  --line:      #252b3a;
  --line-soft: #1c2130;

  --text:      #e8ebf4;
  --text-2:    #a9b1c6;
  --text-dim:  #737d94;

  --accent:      #4a90ff;
  --accent-hi:   #6aa5ff;
  --accent-ink:  #ffffff;
  --accent-soft: rgba(74, 144, 255, 0.12);

  --ok:     #3ecf8e;
  --ok-soft: rgba(62, 207, 142, 0.12);
  --warn:   #f5a623;
  --warn-soft: rgba(245, 166, 35, 0.12);
  --danger: #ff6b6b;
  --danger-soft: rgba(255, 107, 107, 0.12);

  --r-sm: 6px;
  --r:    9px;
  --r-lg: 14px;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-2: 0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-3: 0 18px 50px rgba(0, 0, 0, 0.55);

  --sidebar-w: 264px;

  --font: -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Pretendard',
    'Malgun Gothic', 'Noto Sans KR', 'Segoe UI', sans-serif;
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body.is-locked { overflow: hidden; }

button, input, select, textarea { font-family: inherit; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2b3244; border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #3a4356; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ══════════════════════════════════════════════════════════════════════════
 *  셸 — 좌측 고정 사이드바 + 본문
 * ══════════════════════════════════════════════════════════════════════════ */

#app { height: 100%; }

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  height: 100%;
  transition: grid-template-columns 0.16s ease;
}
.shell.is-collapsed { grid-template-columns: 0 minmax(0, 1fr); }
.shell.is-collapsed .sidebar { opacity: 0; pointer-events: none; }

/* ── 사이드바 ─────────────────────────────────────────────── */

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  overflow: hidden;
  transition: opacity 0.12s ease;
}

.side-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 14px 12px;
  text-decoration: none; color: inherit;
}
.brand-mark {
  width: 30px; height: 30px; flex: none;
  display: grid; place-items: center;
  border-radius: 9px;
  background: linear-gradient(140deg, var(--accent), #7b5cff);
  color: #fff; font-weight: 700; font-size: 12px; letter-spacing: -0.02em;
  box-shadow: 0 2px 10px rgba(74, 144, 255, 0.35);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-name { font-weight: 650; font-size: 14px; letter-spacing: -0.01em; }
.brand-sub { font-size: 10.5px; color: var(--text-dim); }
.side-collapse {
  margin-left: auto; flex: none;
  background: none; border: 0; color: var(--text-dim);
  cursor: pointer; padding: 4px 6px; border-radius: var(--r-sm); font-size: 14px;
}
.side-collapse:hover { background: var(--surface-3); color: var(--text); }

.side-cta { padding: 0 12px 12px; }
.side-scroll { flex: 1; overflow-y: auto; padding: 0 8px 12px; min-height: 0; }

.side-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 8px 6px;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.07em;
  color: var(--text-dim); text-transform: uppercase;
}

/* 나열 항목 — 그룹 트리와 보기 전환이 같은 모양을 쓴다(둘 다 "무엇을 볼지" 고르는 것이라). */
.nav-row { display: flex; align-items: center; gap: 2px; }
.nav-item {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 9px;
  background: none; border: 0; color: var(--text-2);
  padding: 7px 10px; border-radius: var(--r-sm); cursor: pointer;
  font-size: 13px; text-align: left;
}
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.is-active { background: var(--accent-soft); color: var(--accent-hi); font-weight: 600; }
.nav-item .ico { flex: none; width: 16px; text-align: center; opacity: 0.85; font-size: 13px; }
.nav-item .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-count {
  flex: none; font-size: 11px; color: var(--text-dim);
  background: var(--surface-3); border-radius: 999px; padding: 1px 7px; min-width: 22px; text-align: center;
}
.nav-item.is-active .nav-count { background: rgba(74, 144, 255, 0.2); color: var(--accent-hi); }

.icon-btn {
  background: none; border: 0; color: var(--text-dim);
  cursor: pointer; padding: 5px 7px; border-radius: var(--r-sm);
  font-size: 13px; line-height: 1;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.subtle { opacity: 0; transition: opacity 0.12s; }
.nav-row:hover .icon-btn.subtle, .icon-btn.subtle:focus-visible { opacity: 1; }

.tag-box { display: flex; flex-wrap: wrap; gap: 5px; padding: 4px 8px 0; }

/* 사이드바 바닥 — 상태를 항상 보이게 둔다(§ 인증이 꺼진 채 운영에 나가는 것을 막는 가장 싼 방법). */
.side-foot { border-top: 1px solid var(--line); padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 7px; }
.side-status { display: flex; flex-wrap: wrap; gap: 5px; }
.side-meta { font-size: 10.5px; color: var(--text-dim); display: flex; justify-content: space-between; }

/* ── 본문 ─────────────────────────────────────────────────── */

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }

.page-head {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 24px 14px;
  border-bottom: 1px solid var(--line-soft);
}
.page-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.page-title h1 { margin: 0; font-size: 19px; font-weight: 650; letter-spacing: -0.02em; }
.page-title .sub { color: var(--text-dim); font-size: 12.5px; }
.page-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.page-body { flex: 1; overflow-y: auto; min-height: 0; }
.page-pad { padding: 18px 24px 40px; }

/* ══════════════════════════════════════════════════════════════════════════
 *  기본 요소
 * ══════════════════════════════════════════════════════════════════════════ */

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface-3);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 7px 13px;
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.btn:hover { background: #232838; border-color: #333b50; }
.btn:active { transform: translateY(0.5px); }

.btn-primary {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600;
  box-shadow: 0 1px 8px rgba(74, 144, 255, 0.25);
}
.btn-primary:hover { background: var(--accent-hi); border-color: var(--accent-hi); }

.btn-danger { background: var(--danger); border-color: var(--danger); color: #2a0b0b; font-weight: 600; }
.btn-danger:hover { filter: brightness(1.06); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); border-color: transparent; }

.btn-block { width: 100%; justify-content: center; }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn[disabled] { opacity: 0.4; cursor: not-allowed; }
.btn[disabled]:hover { background: var(--surface-3); border-color: var(--line); }

.input {
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--r-sm);
  padding: 8px 11px;
  font-size: 13px;
  width: 100%;
  transition: border-color 0.12s, background 0.12s;
}
.input::placeholder { color: var(--text-dim); }
.input:hover { border-color: #303851; }
.input:focus { outline: none; border-color: var(--accent); background: var(--surface-3); }
select.input { cursor: pointer; }

/* 검색 — 아이콘을 왼쪽에 붙인다. */
.search-wrap { position: relative; flex: 1; max-width: 420px; }
.search-wrap .ico {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--text-dim); font-size: 13px; pointer-events: none;
}
.search-wrap .input { padding-left: 32px; }

/* 스위치 — 브라우저 기본 체크박스는 다크에서 흰 사각형으로 튄다. */
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 12.5px; color: var(--text-2); user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 34px; height: 19px; flex: none;
  background: var(--surface-3); border: 1px solid var(--line);
  border-radius: 999px; position: relative; transition: background 0.15s, border-color 0.15s;
}
.switch .track::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--text-dim); transition: transform 0.15s, background 0.15s;
}
.switch input:checked + .track { background: var(--accent-soft); border-color: var(--accent); }
.switch input:checked + .track::after { transform: translateX(15px); background: var(--accent); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--surface-3); border: 1px solid var(--line); color: var(--text-2);
  border-radius: 999px; padding: 3px 10px; font-size: 11.5px; cursor: pointer;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.chip:hover { border-color: #39415a; color: var(--text); }
.chip.is-active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.chip.is-unused { opacity: 0.4; }
.chip .n { font-size: 10.5px; opacity: 0.7; }
.chip.is-static { cursor: default; }
.chip.is-static:hover { border-color: var(--line); color: var(--text-2); }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2.5px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600; border: 1px solid transparent;
  white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge-published { background: var(--ok-soft); color: #5fe0a8; border-color: rgba(62, 207, 142, 0.28); }
.badge-draft { background: var(--surface-3); color: var(--text-2); border-color: var(--line); }
.badge-deprecated { background: var(--warn-soft); color: #ffc369; border-color: rgba(245, 166, 35, 0.28); }
.badge-ok { background: var(--ok-soft); color: #5fe0a8; border-color: rgba(62, 207, 142, 0.28); }
.badge-warn { background: var(--warn-soft); color: #ffc369; border-color: rgba(245, 166, 35, 0.28); }
.badge-error { background: var(--danger-soft); color: #ff9c9c; border-color: rgba(255, 107, 107, 0.3); }

.muted { color: var(--text-dim); }
.dim { color: var(--text-2); }
.small { font-size: 11.5px; }
.strong { font-weight: 600; }
.mono { font-family: var(--mono); font-size: 12px; }
.spacer { flex: 1; }
.row { display: flex; gap: 8px; align-items: center; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.wrap { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }

/* ══════════════════════════════════════════════════════════════════════════
 *  목록 화면
 * ══════════════════════════════════════════════════════════════════════════ */

.stats {
  display: grid; gap: 12px; margin-bottom: 18px;
  /* 넓은 화면에서 카드가 늘어지면 숫자 하나에 빈 상자가 붙은 꼴이 된다 — 상한을 준다. */
  grid-template-columns: repeat(auto-fit, minmax(148px, 210px));
}
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 13px 16px;
}
.stat-label { font-size: 11.5px; color: var(--text-dim); margin-bottom: 5px; }
.stat-value { font-size: 23px; font-weight: 650; letter-spacing: -0.03em; line-height: 1.1; }
.stat-value.is-ok { color: #5fe0a8; }
.stat-value.is-warn { color: #ffc369; }
.stat-value.is-dim { color: var(--text-dim); }

.toolbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 14px;
}

.active-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; align-items: center; }

/* 행을 표 대신 카드로 둔다 — 폼 하나가 이름·키·상태·태그·사용처를 함께 이고 있어
   표의 칸에 넣으면 어느 칸도 다 못 읽는다(스크린샷에서 실제로 그랬다). */
.form-list { display: flex; flex-direction: column; gap: 8px; }

.form-row {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 13px 16px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, transform 0.12s;
}
.form-row:hover { border-color: #333c54; background: var(--surface-2); }
.form-row:focus-visible { border-color: var(--accent); }
.form-row.is-archived { opacity: 0.55; }

.form-icon {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--surface-3); border: 1px solid var(--line);
  font-size: 16px;
}
.form-row:hover .form-icon { border-color: #39415a; }

.form-main { min-width: 0; flex: 1; }
.form-name-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.form-name { font-weight: 600; font-size: 14px; letter-spacing: -0.01em; }
.form-key {
  font-family: var(--mono); font-size: 11.5px; color: var(--text-dim);
  background: var(--surface-3); border-radius: 4px; padding: 1px 6px;
}
.form-desc { color: var(--text-dim); font-size: 12.5px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.form-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 7px; font-size: 11.5px; color: var(--text-dim); }
.form-meta .sep { opacity: 0.4; }

.form-side { flex: none; display: flex; align-items: center; gap: 18px; }
.form-usage { text-align: right; min-width: 62px; }
.form-usage .n { font-size: 15px; font-weight: 600; }
.form-usage .n.is-zero { color: var(--text-dim); font-weight: 400; }
.form-usage .cap { font-size: 10.5px; color: var(--text-dim); }
.form-go { color: var(--text-dim); font-size: 15px; }
.form-row:hover .form-go { color: var(--accent-hi); }

.list-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; color: var(--text-dim); font-size: 12px; }

/* ── 비어 있음 · 오류 · 로딩 ────────────────────────────── */

.empty {
  padding: 54px 28px; text-align: center;
  border: 1px dashed var(--line); border-radius: var(--r-lg);
  background: rgba(255, 255, 255, 0.012);
}
.empty .ico { font-size: 30px; opacity: 0.5; margin-bottom: 12px; }
.empty h3 { margin: 0 0 6px; font-size: 15px; font-weight: 600; }
.empty p { margin: 0 0 16px; color: var(--text-dim); font-size: 13px; }

.error-box {
  padding: 16px 18px; border-radius: var(--r);
  border: 1px solid rgba(255, 107, 107, 0.4); background: var(--danger-soft);
  color: #ffcfcf; line-height: 1.7;
}
.error-box code { font-family: var(--mono); font-size: 12px; color: #ffb4b4; }

.skeleton { display: flex; flex-direction: column; gap: 8px; }
.skeleton-row {
  height: 68px; border-radius: var(--r);
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 37%, var(--surface) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease infinite;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* ══════════════════════════════════════════════════════════════════════════
 *  상세 화면
 * ══════════════════════════════════════════════════════════════════════════ */

.detail { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .detail { grid-template-columns: minmax(0, 1fr); } }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); overflow: hidden;
}
.card + .card { margin-top: 16px; }
.card-head {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; border-bottom: 1px solid var(--line-soft);
}
.card-head h3 { margin: 0; font-size: 13px; font-weight: 650; letter-spacing: -0.01em; }
.card-head .ico { opacity: 0.7; }
.card-head .count { color: var(--text-dim); font-size: 12px; font-weight: 400; }
.card-body { padding: 14px 16px; }
.card-body.is-flush { padding: 0; }
.card-danger { border-color: rgba(255, 107, 107, 0.3); }
.card-danger .card-head { border-bottom-color: rgba(255, 107, 107, 0.2); }
.card-danger .card-head h3 { color: #ff9c9c; }

.kv { display: grid; grid-template-columns: minmax(78px, auto) minmax(0, 1fr); gap: 11px 18px; margin: 0; font-size: 13px; }
.kv dt { color: var(--text-dim); font-size: 12px; }
.kv dd { margin: 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-width: 0; }

/* 버전 이력 — 표 대신 행. 상태와 메모가 같은 무게로 읽혀야 한다. */
.ver-list { display: flex; flex-direction: column; }
.ver-row {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px; border-bottom: 1px solid var(--line-soft);
}
.ver-row:last-child { border-bottom: 0; }
.ver-row:hover { background: var(--surface-2); }
.ver-num { font-weight: 650; font-size: 13.5px; min-width: 34px; flex: none; }
.ver-main { flex: 1; min-width: 0; }
.ver-note { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ver-meta { font-size: 11.5px; color: var(--text-dim); margin-top: 3px; display: flex; gap: 9px; flex-wrap: wrap; }
.ver-meta .sep { opacity: 0.4; }
.ver-actions { flex: none; display: flex; gap: 5px; opacity: 0.55; transition: opacity 0.12s; }
.ver-row:hover .ver-actions { opacity: 1; }

.usage-row { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--line-soft); }
.usage-row:last-child { border-bottom: 0; }
.usage-row .sys { font-weight: 600; font-size: 12.5px; min-width: 84px; flex: none; }

.notice {
  display: flex; align-items: flex-start; gap: 9px;
  padding: 11px 15px; border-radius: var(--r);
  background: var(--warn-soft); border: 1px solid rgba(245, 166, 35, 0.28);
  color: #ffc369; font-size: 12.5px; line-height: 1.6;
}
.notice .ico { flex: none; }

/* ══════════════════════════════════════════════════════════════════════════
 *  빌더 화면
 * ══════════════════════════════════════════════════════════════════════════ */

.builder-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--schema-w, 380px);
  gap: 1px; background: var(--line);
  flex: 1; min-height: 0;
}
.builder-layout.is-schema-hidden { grid-template-columns: minmax(0, 1fr); }

.pane { background: var(--bg); display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.pane-head {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 14px; border-bottom: 1px solid var(--line-soft);
  background: var(--surface);
}
.pane-head h2 { margin: 0; font-size: 12px; font-weight: 650; letter-spacing: 0.02em; }
.hint { color: var(--text-dim); font-size: 11px; }

#formio-builder-root { flex: 1; overflow: auto; padding: 14px; }
.pane-side { background: var(--surface); }

.json {
  margin: 0; flex: 1; overflow: auto;
  padding: 12px 14px;
  font-family: var(--mono); font-size: 11.5px; line-height: 1.6;
  color: #b9c6e8; white-space: pre; tab-size: 2;
}

/* ══════════════════════════════════════════════════════════════════════════
 *  모달
 *
 *  🔴 배경 클릭으로 닫히지 않는다. ESC 또는 닫기/취소를 눌러야 한다.
 *     빌더·메타 편집은 입력이 길어서, 캔버스를 겨누다 빗나간 클릭 한 번에
 *     작성 중인 내용이 사라지면 안 된다(사용자 지시 2026-08-16).
 * ══════════════════════════════════════════════════════════════════════════ */

.backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(5, 7, 12, 0.72);
  backdrop-filter: blur(3px);
  display: grid; place-items: center;
  padding: 28px;
  animation: fade 0.14s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: min(1080px, 100%); max-height: 100%;
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); overflow: hidden;
  box-shadow: var(--shadow-3);
  animation: pop 0.16s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.985); } to { opacity: 1; transform: none; } }

.modal-sm { width: min(540px, 100%); }
.modal-head {
  display: flex; align-items: center; gap: 10px;
  padding: 15px 18px; border-bottom: 1px solid var(--line-soft);
}
.modal-head h2 { margin: 0; font-size: 14.5px; font-weight: 650; letter-spacing: -0.01em; }
.modal-head .btn { margin-left: auto; }
.modal-form { padding: 18px; overflow-y: auto; }
.modal-foot {
  padding: 13px 18px; border-top: 1px solid var(--line-soft);
  display: flex; justify-content: flex-end; gap: 8px;
  background: var(--surface-2);
}
.modal-body { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1px; background: var(--line); overflow: hidden; min-height: 0; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12px; color: var(--text-2); font-weight: 500; }
.field-hint { font-size: 11px; color: var(--text-dim); line-height: 1.5; }

/* 미리보기 — 빌더는 다크(저작 도구)지만 미리보기는 밝은 "종이"다.
   최종 사용자가 보게 될 화면을 흉내 내는 자리라, 도구의 색을 입히면 오히려 거짓말이 된다. */
.preview-frame { background: #f4f5f8; padding: 22px; overflow: auto; min-height: 320px; }
#formio-preview-root {
  background: #fff; color: #1b1f2a;
  border-radius: 10px; padding: 22px;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.12);
  max-width: 640px; margin: 0 auto;
}
.submitted { background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.submitted-head { padding: 11px 14px; border-bottom: 1px solid var(--line-soft); color: var(--text-dim); font-size: 11px; }

/* ══════════════════════════════════════════════════════════════════════════
 *  토스트
 * ══════════════════════════════════════════════════════════════════════════ */

.toast-host { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 9px; }
.toast {
  display: flex; align-items: flex-start; gap: 9px;
  padding: 11px 15px; border-radius: var(--r); font-size: 13px;
  background: var(--surface-3); border: 1px solid var(--line); color: var(--text);
  box-shadow: var(--shadow-2); max-width: 420px;
  animation: slide 0.18s cubic-bezier(0.2, 0.9, 0.3, 1.05);
}
@keyframes slide { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
.toast .ico { flex: none; }
.toast-ok { border-color: rgba(62, 207, 142, 0.4); }
.toast-ok .ico { color: #5fe0a8; }
.toast-error { border-color: rgba(255, 107, 107, 0.45); }
.toast-error .ico { color: #ff9c9c; }
.toast-info .ico { color: var(--accent-hi); }

/* 최초 부팅 실패 — 앱이 뜨기 전이라 셸 클래스를 못 쓴다. */
.fatal {
  margin: 28px; padding: 18px; border-radius: var(--r);
  border: 1px solid var(--danger); background: var(--danger-soft);
  color: #ffd9d9; line-height: 1.7;
}

/* ── 언어 선택기 ─────────────────────────────────────────── */

.side-status-host { display: flex; flex-direction: column; gap: 7px; }
.lang-select { font-size: 12px; padding: 6px 9px; }

/* ── RTL (아랍어) ────────────────────────────────────────────
 * `dir=rtl` 은 브라우저가 대부분 알아서 뒤집는다. 방향이 **의미**인 것만 되돌린다.
 */
[dir='rtl'] .form-go { transform: scaleX(-1); }      /* › 는 "다음"이라 방향이 뜻이다 */
[dir='rtl'] .side-collapse { transform: scaleX(-1); }
[dir='rtl'] .page-actions { margin-left: 0; margin-right: auto; }
[dir='rtl'] .modal-head .btn { margin-left: 0; margin-right: auto; }
[dir='rtl'] .form-usage { text-align: left; }
/* 🔴 빌더 캔버스는 LTR 로 고정한다.
 *    Form.io 의 드래그 좌표계·핸들 위치가 LTR 전제라 뒤집으면 컴포넌트가 엉뚱한 곳에 떨어진다.
 *    라벨 텍스트 자체는 브라우저 BiDi 가 문자 단위로 처리하므로 아랍어도 정상 표시된다.
 *    (SSemWorks 에디터가 캔버스를 ltr 로 고정한 것과 같은 이유 — 방향이 의미의 일부다.) */
[dir='rtl'] #formio-builder-root { direction: ltr; }

/* ══════════════════════════════════════════════════════════════════════════
 *  그룹 관리 (드래그앤드롭)
 *
 *  놓는 자리를 **두 가지로 분명히** 구분한다 — 항목 위(하위로 들어감)는 테두리,
 *  항목 사이(형제로 끼어듦)는 굵은 선. 어디에 떨어질지 모른 채 손을 떼면
 *  되돌리는 비용이 크다.
 * ══════════════════════════════════════════════════════════════════════════ */

.gtree { display: flex; flex-direction: column; }

.gitem {
  display: flex; align-items: center; gap: 11px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 11px 14px;
  cursor: grab; user-select: none;
  transition: border-color 0.12s, background 0.12s, box-shadow 0.12s;
}
.gitem:hover { border-color: #333c54; background: var(--surface-2); }
.gitem:active { cursor: grabbing; }
.gitem.is-dragging { opacity: 0.4; }
/* 항목 위에 놓기 = 하위로 들어감 */
.gitem.is-over {
  border-color: var(--accent); background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.ghandle { color: var(--text-dim); font-size: 15px; letter-spacing: -2px; flex: none; }
.gname { font-weight: 600; font-size: 13.5px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gcount { color: var(--text-dim); font-size: 11.5px; flex: none; }
.gactions { display: flex; gap: 5px; flex: none; opacity: 0; transition: opacity 0.12s; }
.gitem:hover .gactions, .gitem:focus-within .gactions { opacity: 1; }

/* 항목 사이에 놓기 = 형제로 끼어듦 */
.gdrop { height: 10px; border-radius: 3px; margin: 1px 0; transition: background 0.1s, height 0.1s; }
.gdrop.is-over { background: var(--accent); height: 4px; margin: 4px 0; }
.gdrop.is-root {
  height: auto; padding: 12px 14px; margin-bottom: 8px;
  border: 1.5px dashed var(--line); border-radius: var(--r);
  color: var(--text-dim); font-size: 12px; text-align: center;
}
.gdrop.is-root.is-over { background: var(--accent-soft); border-color: var(--accent); border-style: dashed; color: var(--accent-hi); }

/* ── 사이드바 펼치기 손잡이 ──────────────────────────────────
 * 🔴 접기 버튼이 사이드바 **안에만** 있으면, 접는 순간 되돌릴 길이 화면에서 사라진다.
 *    (실제로 그렇게 만들어 사용자가 갇혔다 — 2026-08-16)
 *    그래서 셸에 하나 더 두고, 접혔을 때만 보인다.
 */
.shell-expand {
  position: fixed; top: 14px; inset-inline-start: 12px; z-index: 40;
  width: 30px; height: 30px; padding: 0;
  display: none; place-items: center;
  background: var(--surface-3); color: var(--text-2);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  cursor: pointer; font-size: 14px; line-height: 1;
  box-shadow: var(--shadow-1);
}
.shell.is-collapsed .shell-expand { display: grid; }
.shell-expand:hover { background: #232838; color: var(--text); border-color: #333b50; }
[dir='rtl'] .shell-expand { transform: scaleX(-1); }
/* 손잡이가 페이지 제목을 가리지 않게 본문 머리를 밀어 준다. */
.shell.is-collapsed .page-head { padding-inline-start: 54px; }

/* ══════════════════════════════════════════════════════════════════════════
 *  AI 어시스턴트 패널
 *
 *  빌더 오른쪽에 도킹한다(SSemWorks 에디터와 같은 자리). 기본은 닫힘 —
 *  캔버스 폭이 곧 작업 편의라 늘 열어 두면 방해가 된다.
 * ══════════════════════════════════════════════════════════════════════════ */

.builder-layout.is-ai-open { grid-template-columns: minmax(0, 1fr) var(--schema-w, 380px) 340px; }
.builder-layout.is-ai-open.is-schema-hidden { grid-template-columns: minmax(0, 1fr) 340px; }
.ai-panel { display: none; }
.builder-layout.is-ai-open .ai-panel {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--surface); border-inline-start: 1px solid var(--line);
}

.ai-head {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px; border-bottom: 1px solid var(--line-soft);
}
.ai-head h2 { margin: 0; font-size: 12px; font-weight: 650; }

.ai-config { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--line-soft); }
.ai-config .input { font-size: 12px; padding: 6px 9px; }

.ai-log { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.ai-intro { color: var(--text-dim); font-size: 12.5px; line-height: 1.65; }
.ai-examples { display: flex; flex-direction: column; gap: 6px; }
.ai-example {
  text-align: start; background: var(--surface-2); border: 1px solid var(--line);
  color: var(--text-2); border-radius: var(--r-sm); padding: 9px 11px;
  font-size: 12.5px; cursor: pointer; line-height: 1.5;
}
.ai-example:hover { border-color: var(--accent); color: var(--text); }

.ai-msg {
  border-radius: var(--r); padding: 9px 12px; font-size: 12.5px; line-height: 1.65;
  white-space: pre-wrap; word-break: break-word;
}
.ai-msg.is-user { background: var(--accent-soft); border: 1px solid rgba(74,144,255,0.28); align-self: flex-end; max-width: 92%; }
.ai-msg.is-assistant { background: var(--surface-2); border: 1px solid var(--line); }
.ai-msg.is-pending { color: var(--text-dim); font-style: italic; }

/* 제안 카드 — 무엇이 들어오는지 보여 준 뒤에 누르게 한다. */
.ai-proposal {
  border: 1px solid var(--accent); border-radius: var(--r);
  background: rgba(74,144,255,0.06); padding: 11px 12px;
  display: flex; flex-direction: column; gap: 9px;
}
.ai-proposal-head { display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; }
.ai-fields { display: flex; flex-wrap: wrap; gap: 5px; }
.ai-warn {
  background: var(--warn-soft); border: 1px solid rgba(245,166,35,0.28);
  color: #ffc369; border-radius: var(--r-sm); padding: 8px 10px; line-height: 1.6;
}
.ai-actions { display: flex; gap: 6px; }
.ai-actions .btn { flex: 1; justify-content: center; }

.ai-compose { border-top: 1px solid var(--line-soft); padding: 10px 12px; }
.ai-compose-row { display: flex; gap: 6px; align-items: flex-end; }
.ai-input { resize: none; font-size: 12.5px; }
.ai-send { flex: none; width: 36px; height: 36px; padding: 0; justify-content: center; }
.ai-hint { color: var(--text-dim); font-size: 10.5px; margin-top: 6px; }
