/* allkit-editor 테마 토큰.
   :root 에 두어 body 에 붙는 플로팅 UI(다이얼로그·메뉴·팝오버)도 같은 값을 받는다.
   소비자는 .cde-editor 스코프에서 변수를 덮어 브랜드에 맞출 수 있다. */
:root {
  --cde-bg: #ffffff;
  --cde-surface: #f7f8fa;
  --cde-border: #d6d9df;
  --cde-fg: #1a1d23;
  --cde-fg-muted: #5c6470;
  /* 비활성 글자도 3:1 이상(버튼 문구는 4.5:1)이어야 한다. opacity로 흐리지 않고 색으로 표시한다. */
  --cde-fg-disabled: #5f6773;
  --cde-accent: #2563eb;
  --cde-accent-fg: #ffffff;
  --cde-accent-soft: #e8effd;
  --cde-danger: #b42318;
  --cde-danger-soft: #fdeceb;
  --cde-warn: #b45309;
  --cde-warn-soft: #fdf1e2;
  --cde-focus: #2563eb;
  --cde-shadow: 0 8px 24px rgba(15, 23, 42, 0.16);
  --cde-radius: 8px;
  --cde-control-h: 24px;
  /* 툴바 안 독립 조작 요소 사이 간격(조밀 변형) */
  --cde-gap-control: 3px;
  --cde-font: -apple-system, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  --cde-mono: Consolas, "Courier New", monospace;
}

/* 다크 테마: 에디터 루트와 테마를 전파받은 플로팅 UI 모두에 적용된다. */
.cde-theme-dark {
  --cde-bg: #17191d;
  --cde-surface: #212429;
  --cde-border: #34383f;
  --cde-fg: #e6e8ec;
  --cde-fg-muted: #a3abb8;
  --cde-fg-disabled: #9aa3b1;
  --cde-accent: #5b8cff;
  --cde-accent-fg: #0d1117;
  --cde-accent-soft: #24314d;
  --cde-danger: #ff7a70;
  --cde-danger-soft: #3a2320;
  --cde-warn: #f5a25c;
  --cde-warn-soft: #3d2c1a;
  --cde-focus: #5b8cff;
  --cde-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* 호스트 페이지의 전역 규칙(img{display:block} 등)이 HTML hidden 속성을 덮어
   숨겨야 할 이미지·입력이 보이던 문제(2026-11-27 감사 img-broken). 플로팅 UI는 body에 붙으므로 함께 막는다. */
.cde-editor [hidden],
.cde-dialog [hidden],
.cde-context-menu[hidden],
.cde-tip[hidden],
.cde-tb-drop[hidden],
.cde-tb-more[hidden],
.cde-tb-more-panel[hidden],
.cde-tb-row[hidden],
.cde-find-panel[hidden],
.cde-image-slot[hidden] {
  display: none !important;
}

/* body 에 붙는 플로팅 UI(다이얼로그·메뉴·툴팁)도 호스트의 전역 box-sizing 에서 지킨다. */
.cde-dialog,
.cde-dialog *,
.cde-dialog *::before,
.cde-dialog *::after,
.cde-context-menu,
.cde-context-menu *,
.cde-tip,
.cde-find-panel,
.cde-find-panel *,
.cde-tb-more-panel,
.cde-tb-more-panel *,
.cde-tb-more-panel *::before,
.cde-tb-more-panel *::after {
  box-sizing: border-box;
}

/* 호스트 페이지의 전역 box-sizing·표시 규칙이 툴바 배치를 깨지 않게 편집기 안에서 고정한다. */
.cde-editor,
.cde-editor *,
.cde-editor *::before,
.cde-editor *::after {
  box-sizing: border-box;
}

.cde-editor {
  display: flex;
  flex-direction: column;
  font-family: var(--cde-font);
  color: var(--cde-fg);
  background: var(--cde-bg);
  border: 1px solid var(--cde-border);
  border-radius: 14px;
  overflow: hidden;
  line-height: 1.65;
  font-size: 14px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 12px 36px rgba(15, 23, 42, 0.08);
}

/* ── 툴바 ──
   좁은 화면에서도 잘리지 않게 묶음 단위로 다음 줄로 흐른다(가로 스크롤 없음).
   호스트 CSS가 display/flex 를 덮어도 배치가 유지되도록 핵심 속성만 !important 로 고정한다. */
.cde-toolbar {
  position: relative;
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: wrap !important;
  align-items: center;
  gap: 0 2px;
  padding: 2px 4px;
  background: var(--cde-surface);
  border-bottom: 1px solid var(--cde-border);
  overflow: visible;
  min-width: 0;
}

/* ── 고정 툴바(AKR-20261120-10) ──
   page 스크롤에 붙는다. 편집기 자체의 overflow:hidden 은 sticky 의 스크롤 컨테이너가
   되므로 sticky 를 켤 때는 clip(지원 시) 또는 visible 로 바꾼다. 부모에 overflow:hidden 이
   있으면 부모가 스크롤 컨테이너가 되어 고정되지 않는다(문서에 제약을 적는다). */
.cde-editor.cde-toolbar-sticky {
  overflow: visible;
}

@supports (overflow: clip) {
  .cde-editor.cde-toolbar-sticky {
    overflow: clip;
  }
}

.cde-editor.cde-toolbar-sticky .cde-toolbar {
  position: sticky !important;
  top: var(--cde-toolbar-sticky-top, 0px);
  z-index: 30;
}

/* 전체 화면에서는 호스트 헤더 오프셋을 무시하고 화면 맨 위에 붙인다. */
.cde-editor.cde-toolbar-sticky:fullscreen .cde-toolbar {
  top: 0;
}

/* 인쇄 미리보기·인쇄에서는 툴바를 고정하지 않는다(모달/인쇄물과 겹침 방지). */
@media print {
  .cde-editor.cde-toolbar-sticky .cde-toolbar {
    position: static !important;
  }
}

/* ── 행 분리(벤치마킹): 삽입 계열 / 서식 계열 / 유틸. 밀도(1·2·3줄·전체)에 따라 행 수가 달라진다 ── */
.cde-tb-row {
  display: flex !important;
  flex: 1 1 100%;
  flex-wrap: wrap !important;
  align-items: center;
  justify-content: flex-start;
  gap: 1px;
  min-width: 0;
  max-width: 100%;
}

/* 서식 행 안에서 문단 서식 줄을 분리한다. */
.cde-tb-break {
  display: none;
}

/* 툴바 끝단(밀도 선택·갤러리·고지): 마지막 행 오른쪽에 붙고 좁으면 다음 줄로 흐른다. */
.cde-tb-end {
  display: inline-flex !important;
  flex: 0 1 auto;
  flex-wrap: wrap !important;
  align-items: center;
  gap: 4px;
  margin-left: 0;
  padding: 0 1px;
  min-width: 0;
  max-width: 100%;
}

/* ── 더보기: 넘치는 묶음을 실제 DOM 노드째 담는 팝오버/모바일 하단 시트 ── */
.cde-tb-more {
  flex: none;
}

.cde-tb-more-panel {
  position: fixed;
  top: var(--cde-more-top, 8px);
  left: var(--cde-more-left, 8px);
  right: auto;
  z-index: 95;
  display: none;
  flex-direction: column;
  width: min(520px, calc(100vw - 24px));
  max-height: min(70vh, 560px);
  padding: 8px;
  border: 1px solid var(--cde-border);
  border-radius: 12px;
  background: var(--cde-bg);
  box-shadow: var(--cde-shadow);
}

.cde-tb-more-panel.open {
  display: flex;
}

.cde-tb-more-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 4px 8px;
  border-bottom: 1px solid var(--cde-border);
}

.cde-tb-more-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--cde-fg);
}

.cde-tb-more-close {
  flex: none;
}

.cde-tb-more-body {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding-top: 8px;
  overflow: auto;
  overscroll-behavior: contain;
}

.cde-tb-more-body .cde-tb-group {
  width: 100%;
  justify-content: flex-start;
  border-color: var(--cde-border);
  background: var(--cde-surface);
}

/* 더보기 안에서는 밀도와 무관하게 항목 이름을 보여 준다(발견성). */
.cde-tb-more-panel .cde-btn-label {
  display: inline;
}

/* 현재 서식 상태 표시 라벨(벤치마킹 #6) */
.cde-status-label {
  margin-left: auto;
  padding: 0 4px;
  font-size: 11px;
  color: var(--cde-fg-muted);
  white-space: nowrap;
}

/* 각 묶음을 둥근 세그먼트로 그려 그룹이 시각적으로 구분된다.
   묶음은 기본적으로 한 줄을 유지하되(응집), 화면이 좁으면 묶음 안에서도 줄바꿈한다. */
.cde-tb-group {
  display: inline-flex !important;
  flex: 0 1 auto;
  /* 묶음이 한 행 폭보다 넓어지면(좁은 화면) 묶음 안에서 줄바꿈해 가로 넘침을 막는다. */
  flex-wrap: wrap !important;
  align-items: center;
  gap: 1px;
  padding: 1px;
  min-width: 0;
  max-width: 100%;
  border: 1px solid rgba(15, 23, 42, 0.05);
  border-radius: 5px;
  background: rgba(15, 23, 42, 0.03);
}

.cde-theme-dark .cde-tb-group {
  border-color: rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.04);
}

/* ── 툴바 아이콘 툴팁(JS가 body에 부착, 네이티브 title 지연 대체) ── */
.cde-tip {
  position: fixed;
  z-index: 9999;
  max-width: 280px;
  padding: 5px 9px;
  border-radius: 6px;
  background: #101418;
  color: #f3f5f8;
  font-size: 12px;
  line-height: 1.45;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.28);
}

/* ── 버튼: 아이콘·문구는 가로·세로 정중앙. 컨트롤 높이는 전부 --cde-control-h ── */
.cde-btn {
  display: inline-flex !important;
  flex: none;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: auto !important;
  height: var(--cde-control-h) !important;
  min-height: var(--cde-control-h);
  max-width: 100%;
  padding: 0 4px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--cde-fg);
  font: inherit;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  overflow-wrap: break-word;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease, transform 0.06s ease;
}

.cde-btn:hover {
  background: var(--cde-accent-soft);
}

.cde-btn:active {
  transform: translateY(1px);
}

.cde-btn.cde-active {
  background: linear-gradient(135deg, var(--cde-accent), #4f46e5);
  border-color: transparent;
  color: var(--cde-accent-fg);
  box-shadow: 0 1px 4px rgba(37, 99, 235, 0.35);
}

.cde-btn:disabled {
  color: var(--cde-fg-disabled);
  cursor: default;
  background: transparent;
}

.cde-btn:focus-visible,
.cde-select:focus-visible,
.cde-menu-item:focus-visible,
.cde-find-input:focus-visible,
.cde-find-replace:focus-visible,
.cde-dialog input:focus-visible {
  outline: 2px solid var(--cde-focus);
  outline-offset: 1px;
}

.cde-btn svg {
  flex: none;
  width: 18px;
  height: 18px;
}

/* 아이콘 전용 버튼은 같은 크기 정사각형으로 통일(호스트의 `button{width:100%}` 보다 우선). */
.cde-btn-icon-only {
  width: var(--cde-control-h) !important;
  padding: 0;
}

.cde-btn-label {
  display: inline;
}

/* 문구가 비어 있는 span은 렌더하지 않는다(아이콘 가운데 정렬 유지) */
.cde-btn-label:empty {
  display: none;
}

/* 1·2·3줄 밀도: 문구·상태 라벨을 숨겨 아이콘 중심으로 깔끔하게 유지한다. */
.cde-toolbar[data-density="line1"] .cde-btn-label,
.cde-toolbar[data-density="line2"] .cde-btn-label,
.cde-toolbar[data-density="line3"] .cde-btn-label,
.cde-toolbar[data-density="line1"] .cde-status-label,
.cde-toolbar[data-density="line2"] .cde-status-label,
.cde-toolbar[data-density="line3"] .cde-status-label {
  display: none;
}

/* 밀도 선택은 짧은 이름만 담으므로 폭을 줄인다. */
.cde-density-select {
  width: 88px !important;
  font-size: 12px;
}

/* 기능별 색 포인트: 아이콘에만 색을 주어 그룹이 시각적으로 구분된다. */
.cde-btn-tone-blue svg {
  color: var(--cde-accent);
}

.cde-btn-tone-blue:hover {
  background: var(--cde-accent-soft);
}

.cde-btn-tone-orange svg {
  color: var(--cde-warn);
}

.cde-btn-tone-red svg {
  color: var(--cde-danger);
}

.cde-btn-tone-orange:hover {
  background: var(--cde-warn-soft);
}

.cde-btn-tone-red:hover {
  background: var(--cde-danger-soft);
}

/* 활성 버튼은 배경이 채워지므로 아이콘·문구를 전경색으로 강제한다(tone 색이 새어 아이콘이 배경과 같은 색이 되지 않도록). */
.cde-btn.cde-active svg,
.cde-btn.cde-active .cde-btn-label {
  color: var(--cde-accent-fg);
}

.cde-btn.cde-active:hover {
  background: linear-gradient(135deg, var(--cde-accent), #4f46e5);
}

/* 인쇄는 유일한 '출력' 동작 — 강조 버튼으로 눈에 띄게 한다. */
.cde-btn-print {
  background: linear-gradient(135deg, var(--cde-accent), #4f46e5);
  border-color: transparent;
  color: var(--cde-accent-fg);
  box-shadow: 0 1px 4px rgba(37, 99, 235, 0.3);
}

.cde-btn-print:hover {
  background: linear-gradient(135deg, var(--cde-accent), #4f46e5);
  filter: brightness(1.06);
}

/* 서식 갤러리 버튼은 툴바 끝의 작은 진입점으로 조용하게 둔다. */
.cde-catalog-btn {
  padding: 0 12px;
  border: none;
  background: linear-gradient(135deg, #7c5cff 0%, #22c58b 100%);
  font-size: 12.5px;
  font-weight: 700;
  color: #ffffff;
  box-shadow: 0 1px 5px rgba(124, 92, 255, 0.35);
}

.cde-catalog-btn:hover {
  background: linear-gradient(135deg, #8b6dff 0%, #2fd79e 100%);
  color: #ffffff;
  filter: brightness(1.05);
}

/* ── select: 좌측 정렬, 버튼과 같은 높이 ──
   호스트의 `select { width: 100% }` 같은 전역 규칙이 툴바를 세로로 무너뜨리지 않게
   폭을 클래스로 고정한다(좁은 화면에서는 max-width: 100% 로 줄어든다). */
select.cde-select {
  display: inline-block !important;
  flex: 0 0 auto;
  width: auto;
  min-width: 0;
  max-width: 100%;
  height: var(--cde-control-h) !important;
  min-height: var(--cde-control-h);
  padding: 0 4px;
  border: 1px solid var(--cde-border);
  border-radius: 4px;
  background: var(--cde-bg);
  color: var(--cde-fg);
  font: inherit;
  font-size: 12px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.cde-select-xs { width: 70px !important; }
.cde-select-sm { width: 92px !important; }
.cde-select-md { width: 112px !important; }
.cde-select-lg { width: 136px !important; }

/* 호스트 테마의 전역 select 배경 규칙([data-theme] select)보다 우선해 에디터 토큰을 유지한다. */
.cde-theme-dark select.cde-select,
.cde-theme-light select.cde-select {
  background: var(--cde-bg);
  color: var(--cde-fg);
  border-color: var(--cde-border);
}

/* ── 목록 분할 버튼: 본 버튼 + 스타일 드롭다운 화살표 ── */
.cde-tb-split {
  display: inline-flex !important;
  flex: none;
  align-items: center;
  position: relative;
  gap: 4px;
  max-width: 100%;
}

.cde-tb-caret {
  width: 24px !important;
  padding: 0;
  border-radius: 4px;
}

.cde-tb-caret svg {
  width: 12px;
  height: 12px;
  opacity: 0.65;
}

.cde-tb-drop {
  display: none;
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  z-index: 80;
  min-width: 168px;
  flex-direction: column;
  padding: 4px;
  border: 1px solid var(--cde-border);
  border-radius: 9px;
  background: var(--cde-bg);
  box-shadow: var(--cde-shadow);
}

.cde-tb-drop.open {
  display: flex;
}

/* 아래 공간이 없는 더보기 패널·좁은 화면에서는 위로 펼친다. */
.cde-tb-drop.cde-tb-drop-up {
  top: auto;
  bottom: calc(100% + 5px);
}

.cde-tb-drop-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--cde-fg);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
}

.cde-tb-drop-item:hover {
  background: var(--cde-accent-soft);
}

/* ── 표 모달 ── */
.cde-table-dialog .cde-table-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.cde-menu-ico {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
}

.cde-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 6px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--cde-fg);
  font: inherit;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
}

.cde-menu-item:hover:not(:disabled) {
  background: var(--cde-accent-soft);
}

.cde-menu-item:disabled {
  color: var(--cde-fg-disabled);
  cursor: default;
}

.cde-menu-item-danger {
  color: var(--cde-danger);
}

.cde-menu-item-danger:hover:not(:disabled) {
  background: var(--cde-danger-soft);
}

/* ── 우클릭 컨텍스트 메뉴 ── */
.cde-context-menu {
  position: fixed;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  min-width: 200px;
  padding: 4px;
  background: var(--cde-bg);
  border: 1px solid var(--cde-border);
  border-radius: var(--cde-radius);
  box-shadow: var(--cde-shadow);
}

.cde-context-menu[hidden] {
  display: none;
}

.cde-context-sep {
  height: 1px;
  margin: 4px 6px;
  background: var(--cde-border);
}

/* ── 색상 모달 ── */
.cde-color-dialog {
  width: min(360px, calc(100vw - 32px));
}

.cde-color-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cde-color-row label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--cde-fg-muted);
  min-width: 120px;
}

.cde-color-row input[type="color"] {
  width: var(--cde-control-h);
  height: var(--cde-control-h);
  padding: 2px;
  border: 1px solid var(--cde-border);
  border-radius: 6px;
  background: var(--cde-bg);
  cursor: pointer;
}

/* ── 찾기 패널 ── */
.cde-find-panel {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 8px;
  background: var(--cde-surface);
  border-bottom: 1px solid var(--cde-border);
}

.cde-find-panel[hidden] {
  display: none;
}

.cde-find-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.cde-find-input,
.cde-find-replace {
  flex: 1 1 140px;
  height: var(--cde-control-h);
  min-height: var(--cde-control-h);
  padding: 0 8px;
  border: 1px solid var(--cde-border);
  border-radius: 6px;
  background: var(--cde-bg);
  color: var(--cde-fg);
  font: inherit;
  font-size: 13.5px;
}

.cde-find-count {
  font-size: 12.5px;
  color: var(--cde-fg-muted);
  min-width: 48px;
  text-align: center;
}

.cde-find-none .cde-find-count {
  color: var(--cde-danger);
}

.cde-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--cde-fg-muted);
  cursor: pointer;
}

.cde-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--cde-accent);
  cursor: pointer;
}

/* ── 본문 ── */
.cde-content {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 200px;
}

.cde-content .cde-editable {
  flex: 1 1 auto;
  padding: 20px 24px;
  outline: none;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: keep-all;
  /* 캔버스 안 색은 에디터 토큰으로 고정한다(호스트 전역 p 색 상속 차단). */
  color: var(--cde-fg);
  background: var(--cde-bg);
}

/* ── 눈금선·들여쓰기 안내선(보기 메뉴) ── */
.cde-gridlines .cde-editable {
  background-origin: content-box;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent calc(1.6em - 1px),
    rgba(100, 116, 139, 0.14) calc(1.6em - 1px),
    rgba(100, 116, 139, 0.14) 1.6em
  );
}

.cde-indent-guides .cde-editable {
  background-origin: content-box;
  background-image: repeating-linear-gradient(
    to right,
    transparent 0,
    transparent calc(1.5em - 1px),
    rgba(100, 116, 139, 0.16) calc(1.5em - 1px),
    rgba(100, 116, 139, 0.16) 1.5em
  );
}

.cde-gridlines.cde-indent-guides .cde-editable {
  background-image: repeating-linear-gradient(
      to right,
      transparent 0,
      transparent calc(1.5em - 1px),
      rgba(100, 116, 139, 0.16) calc(1.5em - 1px),
      rgba(100, 116, 139, 0.16) 1.5em
    ),
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent calc(1.6em - 1px),
      rgba(100, 116, 139, 0.14) calc(1.6em - 1px),
      rgba(100, 116, 139, 0.14) 1.6em
    );
}

/* 갤러리 서식을 끌어 올 때 삽입 위치 표시선 */
.cde-drop-line {
  position: fixed;
  z-index: 120;
  display: none;
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, #2563eb, #7c3aed);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.18);
  pointer-events: none;
}

/* 블록 드래그 가능 표시(위·아래로 끌어 옮기기) */
.cde-editable [draggable="true"]:hover {
  cursor: grab;
}
.cde-editable [draggable="true"]:active {
  cursor: grabbing;
}

.cde-editable > :first-child {
  margin-top: 0;
}

.cde-editable p {
  margin: 0.4em 0;
  color: inherit; /* 호스트 사이트의 전역 p 색이 본문에 새지 않게 한다. */
}

.cde-editable h1,
.cde-editable h2,
.cde-editable h3,
.cde-editable h4,
.cde-editable h5,
.cde-editable h6 {
  margin: 0.9em 0 0.4em;
  line-height: 1.3;
}

.cde-editable h1 { font-size: 1.9em; }
.cde-editable h2 { font-size: 1.55em; }
.cde-editable h3 { font-size: 1.3em; }
.cde-editable h4 { font-size: 1.12em; }

.cde-editable blockquote {
  margin: 0.6em 0;
  padding: 0.2em 1em;
  border-left: 3px solid var(--cde-border);
  color: var(--cde-fg-muted);
}

.cde-editable pre {
  background: var(--cde-surface);
  border: 1px solid var(--cde-border);
  border-radius: 6px;
  padding: 0.7em 0.9em;
  font-family: var(--cde-mono);
  font-size: 0.9em;
  overflow-x: auto;
}

.cde-editable code {
  font-family: var(--cde-mono);
  font-size: 0.92em;
  background: var(--cde-surface);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.cde-editable pre code {
  background: none;
  padding: 0;
}

.cde-editable ul,
.cde-editable ol {
  margin: 0.4em 0;
  padding-left: 1.7em;
}

/* ── 개요 번호(다단계 목록): ol[style*="outline"] — CSS 카운터로 1, 1.1, 1.1.1 표기 ── */
.cde-editable ol[style*="outline"],
.cde-editable ol[style*="outline"] ol {
  list-style: none;
  counter-reset: cde-olc;
  padding-left: 2em;
}
.cde-editable ol[style*="outline"] li {
  counter-increment: cde-olc;
  position: relative;
}
.cde-editable ol[style*="outline"] li::before {
  content: counters(cde-olc, ".") ". ";
  position: absolute;
  right: 100%;
  margin-right: 0.35em;
  white-space: nowrap;
  font-weight: 600;
  color: var(--cde-accent, #2563eb);
}

.cde-editable a {
  color: var(--cde-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.cde-editable hr {
  border: 0;
  border-top: 1px solid var(--cde-border);
  margin: 1em 0;
}

.cde-editable img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}

/* ── 표 ── */
.cde-editable table {
  border-collapse: collapse;
  table-layout: fixed;
  width: 100%;
  margin: 0.6em 0;
  overflow: hidden;
}

.cde-editable th,
.cde-editable td {
  border: 1px solid var(--cde-border);
  padding: 6px 10px;
  vertical-align: top;
  position: relative;
}

.cde-editable th {
  background: var(--cde-surface);
  font-weight: 600;
  text-align: left;
}

.cde-editable .selectedCell:after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--cde-accent-soft);
  pointer-events: none;
}

/* 열 크기 조절 손잡이 */
.column-resize-handle {
  position: absolute;
  right: -2px;
  top: 0;
  bottom: -2px;
  width: 4px;
  background: var(--cde-accent);
  pointer-events: none;
}

.resize-cursor {
  cursor: col-resize;
}

/* gap cursor(표 앞뒤) */
.ProseMirror-gapcursor {
  display: none;
  pointer-events: none;
  position: absolute;
}

.ProseMirror-gapcursor:after {
  content: "";
  display: block;
  position: absolute;
  top: -2px;
  width: 20px;
  border-top: 1px solid var(--cde-fg);
  animation: cde-blink 1.1s steps(2, start) infinite;
}

@keyframes cde-blink {
  to { visibility: hidden; }
}

/* 선택 영역 */
.cde-editable ::selection {
  background: var(--cde-accent-soft);
}

.cde-editable .ProseMirror-selectednode {
  outline: 2px solid var(--cde-accent);
  border-radius: 4px;
}

/* ── placeholder ── */
.cde-editable[data-placeholder]::before {
  content: attr(data-placeholder);
  color: var(--cde-fg-muted);
  pointer-events: none;
  float: left;
  height: 0;
  overflow: visible;
}

/* ── 찾기 강조 ── */
.cde-find-match {
  background: var(--cde-accent-soft);
  border-radius: 2px;
}

.cde-find-current {
  background: var(--cde-accent);
  color: var(--cde-accent-fg);
  border-radius: 2px;
}

/* ── 상태바 ── */
.cde-statusbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 5px 14px;
  border-top: 1px solid var(--cde-border);
  background: var(--cde-surface);
  font-size: 12.5px;
  color: var(--cde-fg-muted);
}

/* 글자 수 한도: N / 한도 + 도달 시 경고색 */
.cde-status-chars.is-limit {
  color: var(--cde-warn);
  font-weight: 600;
}

/* ── 다이얼로그 ── */
.cde-dialog {
  border: 1px solid var(--cde-border);
  border-radius: 16px;
  background: var(--cde-bg);
  color: var(--cde-fg);
  padding: 0;
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.22);
}

.cde-dialog::backdrop {
  background: rgba(10, 12, 18, 0.5);
  backdrop-filter: blur(3px);
}

.cde-html-dialog {
  width: min(720px, calc(100vw - 24px));
}

.cde-html-source {
  width: 100%;
  min-height: 300px;
  max-height: 55vh;
  padding: 10px;
  border: 1px solid var(--cde-border);
  border-radius: 6px;
  background: var(--cde-bg);
  color: var(--cde-fg);
  font-family: var(--cde-mono);
  font-size: 12.5px;
  line-height: 1.5;
  resize: vertical;
  white-space: pre;
  overflow: auto;
}

.cde-dialog-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  margin: 0;
}

.cde-dialog-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 16px;
  line-height: 1.3;
}

.cde-dialog-title svg {
  flex: none;
  color: var(--cde-fg-muted);
}

.cde-dialog-close {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--cde-fg-muted);
  font: inherit;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}

.cde-dialog-close:hover {
  background: var(--cde-hover, rgba(0, 0, 0, 0.06));
  color: var(--cde-fg);
}

.cde-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--cde-fg-muted);
}

.cde-field input,
.cde-field select,
.cde-field textarea {
  box-sizing: border-box;
  width: 100%;
  border: 1px solid var(--cde-border);
  border-radius: 6px;
  background: var(--cde-bg);
  color: var(--cde-fg);
  font: inherit;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.cde-field input,
.cde-field select {
  height: var(--cde-control-h);
  min-height: var(--cde-control-h);
  padding: 0 10px;
}

.cde-field textarea {
  min-height: 84px;
  padding: 8px 10px;
  resize: vertical;
}

.cde-field select {
  appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
  cursor: pointer;
}

.cde-field input[type="color"] {
  padding: 2px 6px;
  cursor: pointer;
}

.cde-field input[type="number"] {
  padding-right: 6px;
}

.cde-field :is(input, select, textarea):focus-visible {
  outline: none;
  border-color: var(--cde-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--cde-accent) 18%, transparent);
}

.cde-field :is(input, select, textarea):disabled {
  color: var(--cde-fg-disabled);
  background: var(--cde-surface);
  cursor: not-allowed;
}

/* ── 문서 기능 다이얼로그 보강 ── */
.cde-doc-dialog .cde-dialog-body {
  overflow-y: auto;
  max-height: min(78vh, 680px);
}

.cde-margin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.cde-field-fill-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: start;
}

.cde-field-fill-grid .cde-field {
  min-width: 0;
}

.cde-signature-pad {
  display: block;
  box-sizing: border-box;
  width: 100%;
  max-width: 480px;
  border: 1.5px dashed var(--cde-border);
  border-radius: 10px;
  background: var(--cde-surface);
  touch-action: none;
}

.cde-image-preview:not([hidden]) {
  display: block;
  max-width: 100%;
  padding: 4px;
}

.cde-dialog-error {
  margin: 0;
  font-size: 13px;
  color: var(--cde-danger);
}

.cde-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 2px;
}

.cde-spacer {
  flex: 1 1 auto;
}

.cde-btn-primary {
  background: linear-gradient(135deg, var(--cde-accent), #4f46e5);
  color: var(--cde-accent-fg);
  border-color: transparent;
  box-shadow: 0 1px 4px rgba(37, 99, 235, 0.3);
}

.cde-btn-primary:hover {
  background: linear-gradient(135deg, var(--cde-accent), #4f46e5);
  filter: brightness(1.06);
}

.cde-btn-secondary {
  border-color: var(--cde-border);
  background: var(--cde-surface);
}

.cde-btn-danger {
  background: var(--cde-danger);
  border-color: transparent;
  color: #ffffff;
}

.cde-btn-danger:hover {
  background: var(--cde-danger);
  filter: brightness(1.08);
}

.cde-theme-dark .cde-btn-danger {
  color: #17191d;
}

.cde-image-preview {
  max-height: 160px;
  object-fit: contain;
  border: 1px solid var(--cde-border);
  border-radius: 6px;
  background: var(--cde-surface);
}

/* ── 인쇄 미리보기 ── */
/* header / 스크롤되는 preview / footer 구조: 모달 외곽에 이중 스크롤이 생기지 않는다. */
.cde-dialog-print {
  width: min(880px, calc(100vw - 32px));
  height: min(720px, calc(100vh - 48px));
  overflow: hidden;
}

.cde-dialog-print .cde-dialog-body {
  height: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.cde-dialog-print .cde-print-preview {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
}

.cde-print-error {
  margin: 0 0 8px;
  color: var(--cde-danger);
  font-size: 12px;
}

.cde-print-preview {
  overflow: auto;
  max-height: min(70vh, 620px);
  padding: 20px;
  border: 1px solid var(--cde-border);
  border-radius: 8px;
  background: var(--cde-surface);
}

.cde-print-sheet {
  box-sizing: border-box;
  width: max-content;
  max-width: 100%;
  margin: 0 auto;
}

.cde-print-preview-frame {
  display: block;
  width: 100%;
  border: 0;
  background: #fff;
}

.cde-print-pages {
  align-self: center;
  color: var(--cde-fg-muted);
  font-size: 12px;
}

.cde-print-margin-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: var(--cde-control-h);
  color: var(--cde-fg-muted);
  font-size: 12px;
}

/* ── 전체 화면 ── */
.cde-editor:fullscreen {
  border: 0;
  border-radius: 0;
  background: var(--cde-bg);
}

.cde-editor:fullscreen .cde-content {
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
}

/* ── 좁은 화면: 묶음 안에서도 줄바꿈해 가로 넘침을 막는다 ── */
@media (max-width: 760px) {
  .cde-tb-group {
    flex-wrap: wrap !important;
  }
}

/* ── 좁은 화면(터치): 44px 조작 영역을 보장하고 문구는 숨긴다 ── */
@media (max-width: 600px) {
  .cde-toolbar {
    gap: 2px 4px;
    padding: 3px 4px;
  }
  .cde-tb-group {
    gap: 1px;
    padding: 1px;
  }
  .cde-btn {
    height: 44px !important;
    min-height: 44px;
    min-width: 44px;
    padding: 0 8px;
    font-size: 12px;
  }
  .cde-btn-icon-only {
    width: 44px !important;
  }
  select.cde-select {
    height: 44px !important;
    min-height: 44px;
    font-size: 12px;
  }
  /* 툴바 밖의 조작 요소(찾기 입력·드롭다운·메뉴)도 같은 터치 기준을 따른다. */
  .cde-find-input,
  .cde-find-replace {
    height: 44px;
    min-height: 44px;
  }
  .cde-tb-caret {
    width: 44px !important;
    height: 44px !important;
  }
  .cde-menubar-item {
    min-width: 44px;
    min-height: 44px;
    padding-block: 0;
  }
  .cde-tb-drop-item,
  .cde-menu-item {
    min-height: 44px;
  }
  .cde-btn-label {
    display: none;
  }
  .cde-status-label {
    display: none;
  }
  /* 더보기는 모바일에서 하단 시트로 열어 엄지로 닿게 한다. */
  .cde-tb-more-panel {
    position: fixed;
    inset: auto 0 0 0;
    width: 100%;
    max-height: 82dvh;
    padding: 10px 10px calc(12px + env(safe-area-inset-bottom));
    border-radius: 14px 14px 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
  }
  .cde-tb-more-head {
    padding-bottom: 10px;
  }
  .cde-tb-more-body {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .cde-tb-more-panel .cde-btn-label {
    display: none;
  }
}

/* ── 위첨자/아래첨자 ── */
.cde-editable sup {
  vertical-align: super;
  font-size: 0.75em;
  line-height: 1;
}
.cde-editable sub {
  vertical-align: sub;
  font-size: 0.75em;
  line-height: 1;
}

/* ── 안내 토스트 ── */
.cde-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(12px);
  max-width: min(90vw, 480px);
  padding: 10px 16px;
  border-radius: 8px;
  background: rgba(30, 30, 30, 0.92);
  color: #fff;
  font-size: 13px;
  line-height: 1.5;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 2147483000;
}
.cde-toast-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── 인쇄 가드: 편집기 본문은 어떤 경우에도 직접 인쇄되지 않는다 ──
   인쇄는 미리보기 모달 → 서버 PDF 저장으로 수행된다(window.print 미사용). */
@media print {
  .cde-editor {
    display: none !important;
  }
  body.cde-print-blocked > *:not(.cde-print-notice) {
    visibility: hidden;
  }
  .cde-print-notice {
    display: block !important;
  }
}
.cde-print-notice {
  display: none;
}

/* ══ 윤컴즈 이식 보기·삽입 기능 ══ */

/* ── 책갈피 앵커 ── */
.cde-editable a[data-bookmark] {
  display: inline-block;
  width: 0.9em;
  height: 1em;
  vertical-align: -0.12em;
  background: var(--cde-accent, #4f7cff);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 78%, 0 100%);
  border-radius: 1px;
}
.cde-editable a[data-bookmark][data-bookmark]:not([data-bookmark=""]) {
  width: auto;
  min-width: 1.1em;
  padding: 0 4px;
  color: #fff;
  font-size: 0.72em;
  line-height: 1.5em;
  vertical-align: 0.06em;
  text-decoration: none;
  clip-path: none;
  border-radius: 4px;
}
.cde-editable a[data-bookmark]::before {
  content: attr(data-bookmark);
}

/* ── 동영상 ── */
.cde-editable div[data-node="video"] {
  margin: 0.6em 0;
}
.cde-editable div[data-node="video"] video {
  display: block;
  width: 100%;
  max-width: 640px;
  border-radius: 6px;
  background: #000;
}

/* ── 눈금자(가로) ── */
.cde-ruler {
  height: 18px;
  overflow: hidden;
  background: var(--cde-surface);
  border-bottom: 1px solid var(--cde-border);
  flex: 0 0 auto;
  position: relative;
}
.cde-ruler-scale {
  height: 18px;
  min-width: 2000px;
  background-image: repeating-linear-gradient(
    to right,
    var(--cde-border) 0 1px,
    transparent 1px 40px
  );
  background-size: 400px 18px;
  position: relative;
}
/* 여백 영역 음영(가로 눈금자 위). */
.cde-ruler-margin {
  position: absolute;
  top: 0;
  height: 18px;
  background: rgba(148, 163, 184, 0.22);
  pointer-events: none;
}
.cde-ruler-margin-l {
  left: 18px;
  border-right: 1px dashed var(--cde-border);
}
.cde-ruler-margin-r {
  right: 0;
  border-left: 1px dashed var(--cde-border);
}
/* 세로 눈금자(왼쪽). */
.cde-editor.cde-ruler-v-on .cde-content {
  position: relative;
}
.cde-editor.cde-ruler-v-on .cde-editable {
  padding-left: 44px;
}
.cde-ruler-v {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 18px;
  background-image: repeating-linear-gradient(
    to bottom,
    var(--cde-border) 0 1px,
    transparent 1px 40px
  );
  background-size: 18px 400px;
  border-right: 1px solid var(--cde-border);
  pointer-events: none;
}

/* ── 워터마크 ── */
.cde-editor.cde-has-watermark .cde-content {
  position: relative;
}
.cde-editor.cde-has-watermark .cde-content::after {
  content: attr(data-wm-text);
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: rgba(120, 120, 120, var(--cde-wm-opacity, 0.12));
  white-space: pre;
  pointer-events: none;
  z-index: 1;
}
.cde-editor.cde-has-watermark .cde-editable {
  position: relative;
  z-index: 2;
}
.cde-editor.cde-has-watermark .cde-content[data-wm-repeat="1"]::after {
  content: none;
}
.cde-editor.cde-has-watermark .cde-content[data-wm-rotate="1"]::after {
  transform: translate(-50%, -50%) rotate(-30deg);
}
.cde-editor.cde-has-watermark .cde-content[data-wm-position="top-left"]::after,
.cde-editor.cde-has-watermark .cde-content[data-wm-position="top-right"]::after,
.cde-editor.cde-has-watermark .cde-content[data-wm-position="bottom-left"]::after,
.cde-editor.cde-has-watermark .cde-content[data-wm-position="bottom-right"]::after {
  font-size: 20px;
  top: auto;
  left: auto;
  bottom: 12px;
  transform: none;
}
.cde-editor.cde-has-watermark .cde-content[data-wm-position="top-left"]::after { left: 16px; bottom: auto; top: 12px; }
.cde-editor.cde-has-watermark .cde-content[data-wm-position="top-right"]::after { right: 16px; bottom: auto; top: 12px; }
.cde-editor.cde-has-watermark .cde-content[data-wm-position="bottom-left"]::after { left: 16px; }
.cde-editor.cde-has-watermark .cde-content[data-wm-position="bottom-right"]::after { right: 16px; }

/* ── 배경 그림 ── */
.cde-editor.cde-has-bg-image .cde-content {
  background-size: cover;
  background-position: center;
}
.cde-editor.cde-has-bg-image .cde-editable {
  background: rgba(255, 255, 255, 0.82);
}

/* ── 반응형 미리보기 폭 ── */
.cde-editor.cde-preview-tablet .cde-content {
  max-width: 768px;
  margin: 0 auto;
}
.cde-editor.cde-preview-mobile .cde-content {
  max-width: 375px;
  margin: 0 auto;
}

/* ── 상단 메뉴바 ── */
.cde-menubar {
  display: flex;
  gap: 2px;
  padding: 2px 8px;
  border-bottom: 1px solid var(--cde-border);
  background: var(--cde-bg);
  position: relative;
  flex-wrap: wrap;
}
.cde-menubar-item {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: none;
  background: transparent;
  color: var(--cde-fg);
  font: inherit;
  font-size: 12px;
  padding: 3px 6px;
  border-radius: 5px;
  cursor: pointer;
}
.cde-menubar-item:hover,
.cde-menubar-item.open {
  background: var(--cde-hover, rgba(0, 0, 0, 0.06));
}
.cde-menubar-popup {
  position: absolute;
  z-index: 60;
  min-width: 170px;
  background: var(--cde-bg);
  border: 1px solid var(--cde-border);
  border-radius: 8px;
  box-shadow: var(--cde-shadow);
  padding: 4px;
  display: flex;
  flex-direction: column;
}
.cde-menubar-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--cde-fg);
  font: inherit;
  font-size: 12px;
  padding: 5px 8px;
  border-radius: 5px;
  cursor: pointer;
  position: relative;
  white-space: nowrap;
}
.cde-menubar-option svg {
  flex: none;
  opacity: 0.8;
}
.cde-menubar-option:hover {
  background: var(--cde-hover, rgba(0, 0, 0, 0.06));
}
.cde-menubar-option.danger {
  color: var(--cde-danger, #dc2626);
}
.cde-menubar-option.has-sub::after {
  content: "\203A";
  position: absolute;
  right: 8px;
}
.cde-menubar-sub {
  position: absolute;
  left: calc(100% - 2px);
  top: -1px;
}

/* ── 글꼴·글자 크기·색·레이아웃 선택 다이얼로그 ── */
.cde-pick-dialog {
  width: min(560px, calc(100vw - 32px));
}
.cde-pick-group h4 {
  margin: 10px 0 6px;
  font-size: 12px;
  color: var(--cde-fg-muted, #64748b);
}
.cde-pick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
  gap: 4px;
  max-height: 320px;
  overflow: auto;
}
.cde-pick {
  border: 1px solid var(--cde-border);
  background: var(--cde-bg);
  color: var(--cde-fg);
  border-radius: 6px;
  min-height: 32px;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 4px;
}
.cde-pick:hover {
  background: var(--cde-hover, rgba(0, 0, 0, 0.06));
  border-color: var(--cde-accent, #2563eb);
}
.cde-layout-grid {
  grid-template-columns: repeat(3, 1fr);
}
.cde-layout-pick {
  min-height: 60px;
}

/* ── 문서 템플릿 카드 ── */
.cde-dialog-hint {
  margin: 2px 0 8px;
  font-size: 12px;
  color: var(--cde-fg-muted, #64748b);
}
.cde-template-grid {
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}
.cde-template-pick {
  flex-direction: column;
  gap: 4px;
  min-height: 120px;
  padding: 8px;
}
.cde-template-mini {
  width: 64px;
  height: 48px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  opacity: 0.85;
}
.cde-template-name {
  font-size: 13.5px;
  font-weight: 600;
}
.cde-template-desc {
  font-size: 11.5px;
  color: var(--cde-fg-muted, #64748b);
  line-height: 1.35;
}

/* ── 도형 삽입 다이얼로그 ── */
.cde-shape-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 6px;
  margin-bottom: 8px;
}
.cde-shape-pick {
  flex-direction: column;
  gap: 3px;
  min-height: 52px;
  font-size: 11.5px;
}
.cde-shape-pick.cde-active {
  border-color: var(--cde-accent, #2563eb);
  background: var(--cde-accent-soft, rgba(37, 99, 235, 0.12));
}
.cde-shape-mini {
  width: 34px;
  height: 22px;
}
.cde-shape-options {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
}
.cde-shape-preview {
  width: 100%;
  height: auto;
  border: 1px solid var(--cde-border);
  border-radius: 8px;
  margin: 10px 0;
  background: #ffffff;
}

/* ── 단축키 도움말 표 ── */
.cde-hotkey-table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 13px;
}
.cde-hotkey-table td {
  border-bottom: 1px solid var(--cde-border);
  padding: 5px 8px;
}
.cde-hotkey-table kbd {
  background: var(--cde-hover, rgba(0, 0, 0, 0.06));
  border: 1px solid var(--cde-border);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: inherit;
  font-size: 12px;
}
.cde-privacy-result {
  max-height: 320px;
  overflow: auto;
}
.cde-privacy-preview {
  color: var(--cde-fg-muted, #64748b);
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 820px 이하: 입력 글자는 16px 이상으로 둬 iOS 자동 확대를 막는다(툴바 select 는 예외). */
@media (max-width: 820px) {
  .cde-btn {
    font-size: 12px;
  }
  .cde-find-input,
  .cde-find-replace,
  .cde-field :is(input, select, textarea) {
    font-size: 16px;
  }
}
/* ── 서식 갤러리(올킷 자체 서식) ── */
.cde-gallery-dialog {
  width: min(1100px, 96vw);
  max-height: 90vh;
  padding: 0;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 18px;
  background: var(--cde-bg, #ffffff);
  color: var(--cde-fg, #1f2937);
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);
  overflow: hidden;
}
.cde-gallery-dialog::backdrop {
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
}
.cde-gallery {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  max-height: 90vh;
}

/* ── 헤더: 브랜드 그라데이션 + 흰 제목 + 검색 ── */
.cde-gallery-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: linear-gradient(120deg, #2563eb, #4f46e5 60%, #7c3aed);
}
.cde-gallery-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: #ffffff;
  white-space: nowrap;
}
.cde-gallery-head .cde-btn-icon-only {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.14);
}
.cde-gallery-head .cde-btn-icon-only:hover {
  background: rgba(255, 255, 255, 0.26);
}
.cde-gallery-search {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: #64748b;
  box-shadow: 0 1px 6px rgba(15, 23, 42, 0.12);
}
.cde-gallery-search:focus-within {
  border-color: #ffffff;
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.25);
}
.cde-gallery-search input {
  flex: 1;
  min-width: 0;
  height: 34px;
  border: 0;
  background: transparent;
  color: #1f2937;
  font: inherit;
  outline: none;
}

/* ── 탭: 칩 형태, 항상 보이게 붙인다 ── */
.cde-gallery-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.07);
  background: var(--cde-surface, #f8fafc);
  overflow-x: auto;
  scrollbar-width: thin;
}
.cde-gallery-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  min-height: 32px;
  padding: 0 13px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 999px;
  background: var(--cde-bg, #ffffff);
  color: var(--cde-fg-muted, #4b5563);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.12s ease, background 0.12s ease, color 0.12s ease, transform 0.08s ease;
}
.cde-gallery-tab:hover {
  border-color: rgba(37, 99, 235, 0.45);
  transform: translateY(-1px);
}
.cde-gallery-tab.cde-active {
  border-color: transparent;
  background: linear-gradient(120deg, #2563eb, #4f46e5);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}
.cde-gallery-count {
  padding: 0 7px;
  border-radius: 999px;
  background: rgba(100, 116, 139, 0.15);
  font-size: 10.5px;
  line-height: 17px;
  font-weight: 700;
}
.cde-gallery-tab.cde-active .cde-gallery-count {
  background: rgba(255, 255, 255, 0.22);
}

/* ── 본문 ── */
.cde-gallery-body {
  overflow-y: auto;
  padding: 16px 18px 22px;
  background: var(--cde-surface, #f8fafc);
}
.cde-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(252px, 1fr));
  gap: 16px;
}

/* ── 카드: 떠오르는 효과 + 미리보기 ── */
.cde-gallery-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 14px;
  background: var(--cde-bg, #ffffff);
  cursor: grab;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: border-color 0.14s ease, box-shadow 0.14s ease, transform 0.14s ease;
}
.cde-gallery-card.cde-dragging {
  opacity: 0.45;
  cursor: grabbing;
}
.cde-gallery-card:hover {
  border-color: rgba(37, 99, 235, 0.5);
  box-shadow: 0 10px 28px rgba(37, 99, 235, 0.16);
  transform: translateY(-3px);
}
.cde-gallery-card.cde-picked {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2), 0 10px 28px rgba(37, 99, 235, 0.16);
}
/* 미리보기는 실제 서식 그대로 축소 — 개별 요소 글자 크기 대신 배율로 줄인다. */
.cde-gallery-preview {
  position: relative;
  height: 160px;
  overflow: hidden;
  border: 1px solid rgba(15, 23, 42, 0.06);
  border-radius: 10px;
  background: #ffffff;
  padding: 12px 14px;
  pointer-events: none;
  user-select: none;
}
.cde-theme-dark .cde-gallery-preview {
  background: #ffffff;
  color: #1f2937;
}
.cde-gallery-preview > * {
  pointer-events: none;
  transform-origin: top left;
  transition: transform 0.25s ease;
}
.cde-gallery-card:hover .cde-gallery-preview > * {
  transform: scale(1.035);
}
.cde-gallery-preview * {
  max-width: 100% !important;
}
.cde-gallery-preview img {
  max-height: 100px;
  object-fit: cover;
}
.cde-gallery-card-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 800;
  color: var(--cde-fg, #111827);
}
.cde-gallery-card-icon {
  display: inline-flex;
  color: #2563eb;
}
.cde-theme-dark .cde-gallery-card-icon {
  color: var(--cde-accent, #5b8cff);
}
.cde-gallery-card-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cde-gallery-star {
  border: 0;
  background: transparent;
  color: #d1d5db;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.1s ease, color 0.1s ease;
}
.cde-gallery-star:hover {
  transform: scale(1.2);
}
.cde-gallery-star.cde-active {
  color: #f59e0b;
}
.cde-gallery-card-hint {
  margin: 0;
  color: var(--cde-fg-muted, #6b7280);
  font-size: 11.5px;
  line-height: 1.5;
}
.cde-gallery-insert {
  margin-top: auto;
  width: 100%;
  min-height: 32px;
  padding: 0 12px;
  font-size: 12.5px;
  font-weight: 700;
  justify-content: center;
}
.cde-gallery-empty {
  margin: 48px 0;
  text-align: center;
  color: var(--cde-fg-muted, #6b7280);
  font-size: 13px;
}

/* ── 바닥 ── */
.cde-gallery-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  background: var(--cde-bg, #ffffff);
}
.cde-gallery-hint {
  flex: 1;
  color: var(--cde-fg-muted, #6b7280);
  font-size: 11.5px;
}
.cde-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

@media (max-width: 640px) {
  .cde-gallery-dialog {
    width: 100vw;
    max-height: 100vh;
    border-radius: 0;
  }
  .cde-gallery-head {
    flex-wrap: wrap;
  }
  .cde-gallery-search {
    order: 3;
    flex-basis: 100%;
  }
  .cde-gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }
}
