.aeriz-wysiwyg {
  --aw-bg: #ffffff;
  --aw-fg: #1a1a1a;
  --aw-fg-muted: #6b7280;
  --aw-border: #e5e7eb;
  --aw-toolbar-bg: #f9fafb;
  --aw-toolbar-fg: #374151;
  --aw-btn-hover-bg: #e5e7eb;
  --aw-btn-active-bg: #dbeafe;
  --aw-btn-active-fg: #1d4ed8;
  --aw-primary: #03c75a;
  --aw-primary-fg: #ffffff;
  --aw-primary-hover: #02b150;
  --aw-divider: #e5e7eb;
  --aw-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --aw-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --aw-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --aw-radius: 6px;
  --aw-radius-sm: 4px;
  --aw-font: -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Pretendard',
    'Noto Sans KR', 'Malgun Gothic', sans-serif;
  --aw-font-mono: 'SF Mono', Menlo, Monaco, Consolas, 'D2Coding', monospace;

  /* ─── 모션 ──────────────────────────────────────────────────────────
     블록 UI 의 전환은 전부 이 토큰들을 쓴다. 값이 한 군데 모여 있어야
     "누르면 즉각, 사라질 땐 느긋하게" 같은 규칙이 화면 전체에서 일관된다.
     · fast — 눌림/색 변화처럼 손끝에 바로 붙어야 하는 것
     · base — 나타남/사라짐
     · slow — 위치 이동처럼 눈으로 따라가는 것
     · ease-out : 등장(감속). ease-spring : 살짝 튕기며 자리잡는 등장. */
  --aw-dur-fast: 90ms;
  --aw-dur-base: 160ms;
  --aw-dur-slow: 240ms;
  --aw-ease-out: cubic-bezier(0.22, 0.85, 0.3, 1);
  --aw-ease-spring: cubic-bezier(0.2, 1.3, 0.4, 1);

  --aw-toolbar-height: 44px;
  --aw-z-toolbar: 10;
  --aw-z-popover: 100;
  --aw-z-dialog: 1000;
}

.aeriz-wysiwyg[data-theme='dark'] {
  --aw-bg: #0a0e14;
  --aw-fg: #e7eef5;
  --aw-fg-muted: #6a7a8a;
  --aw-border: rgba(100, 200, 255, 0.12);
  --aw-toolbar-bg: #0d1320;
  --aw-toolbar-fg: #cfd6dd;
  --aw-btn-hover-bg: rgba(100, 200, 255, 0.06);
  --aw-btn-active-bg: rgba(100, 200, 255, 0.14);
  --aw-btn-active-fg: #64c8ff;
  --aw-primary: #64c8ff;
  --aw-primary-fg: #050810;
  --aw-primary-hover: #8ad6ff;
  --aw-divider: rgba(100, 200, 255, 0.12);
}
.aeriz-wysiwyg {
  font-family: var(--aw-font);
  background-color: var(--aw-bg);
  color: var(--aw-fg);
  border: 1px solid var(--aw-border);
  border-radius: var(--aw-radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  /* 부모가 명시적 높이를 주면 그 높이를 채우고 내부 컨텐츠가 스크롤되며,
     부모가 auto 면 min-height 가 floor 로 작용한다. */
  height: 100%;
  min-height: 320px;
  box-shadow: var(--aw-shadow-sm);
}

.aeriz-wysiwyg *,
.aeriz-wysiwyg *::before,
.aeriz-wysiwyg *::after {
  box-sizing: border-box;
}

.aw-content-wrap {
  flex: 1;
  /* flex 자식이 기본 min-content 크기 이상으로 줄어들 수 있게 함 — 이게 없으면
     overflow-y:auto 가 부모를 밀어내 스크롤이 발생하지 않는다. */
  min-height: 0;
  overflow-y: auto;
  background-color: var(--aw-bg);
  position: relative; /* 드래그 핸들 / 드롭 인디케이터 절대 위치 기준 */
}

/* ─── 뷰어 모드 ─────────────────────────────────────────────────────
   AerizViewer 는 컨텐츠 길이만큼 자연스럽게 늘어난다 (스크롤 / 고정 높이 X).
   에디터 기본 규칙을 viewer 클래스가 좁게 덮어쓴다. */
.aeriz-wysiwyg-viewer {
  height: auto;
  min-height: 0;
}
.aeriz-wysiwyg-viewer .aw-content-wrap {
  flex: 0 0 auto;
  overflow: visible;
  min-height: 0;
}
.aeriz-wysiwyg-viewer .aw-content {
  min-height: 0;
}

/* ─── 드래그 핸들 오버레이 ───────────────────────────────────────────── */

.aw-block-handles {
  position: absolute;
  top: 0;
  left: 0;
  width: 20px;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

/* 블록별 컨트롤 그룹 — 드래그 핸들 + 단락 추가 버튼을 세로로 묶는다.
   지금 다루는 블록(포인터가 올라간 블록 / 캐럿이 있는 블록) 것만 드러난다.
   본문 어디에나 마우스만 올리면 모든 블록의 핸들이 한꺼번에 떠오르던
   예전 동작은, 글이 길어질수록 왼쪽에 점 기둥을 세워 놓는 꼴이었다. */
.aw-block-controls {
  position: absolute;
  left: 3px;
  display: flex;
  flex-direction: column;
  gap: 0;
  pointer-events: none;
  opacity: 0;
  /* 살짝 왼쪽에서 밀려 들어온다 — 나타남에 방향이 생기면 어느 블록에
     붙은 컨트롤인지가 눈으로 더 빨리 읽힌다. */
  transform: translateX(-3px);
  transition:
    opacity var(--aw-dur-base) var(--aw-ease-out),
    transform var(--aw-dur-base) var(--aw-ease-out);
}
/* 캐럿이 있는 블록 — 은은하게 상주. 포인터가 올라오면 완전히 또렷하게. */
.aw-block-controls.is-active {
  opacity: 0.5;
  transform: none;
}
.aw-block-controls.is-hovered,
.aw-block-controls:hover,
.aw-block-controls:focus-within {
  opacity: 1;
  transform: none;
}

/* 높이는 AerizEditor.positionHandle 의 HANDLE_HEIGHT 와 짝을 이룬다 —
   한쪽만 바꾸면 짧은 블록(hr) 위에서 핸들의 수직 정렬이 어긋난다. */
.aw-block-handle,
.aw-block-add {
  width: 14px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
  color: var(--aw-fg-muted);
  pointer-events: auto;
  user-select: none;
  appearance: none;
  padding: 0;
  cursor: pointer;
  transition:
    color var(--aw-dur-fast) var(--aw-ease-out),
    background-color var(--aw-dur-fast) var(--aw-ease-out),
    border-color var(--aw-dur-fast) var(--aw-ease-out),
    transform var(--aw-dur-fast) var(--aw-ease-out);
}
.aw-block-handle { cursor: grab; }

.aw-block-handle svg,
.aw-block-add svg {
  width: 10px;
  height: 11px;
}

.aw-block-handle:hover,
.aw-block-add:hover {
  color: var(--aw-btn-active-fg, var(--aw-primary));
  background-color: var(--aw-btn-hover-bg);
  border-color: var(--aw-border);
}
/* 눌린 순간 살짝 눌러앉는다 — 클릭이 먹었다는 신호가 색보다 빠르다. */
.aw-block-handle:active,
.aw-block-add:active {
  transform: scale(0.88);
}
/* 키보드 사용자에게도 같은 위치를 알려 준다. */
.aw-block-handle:focus-visible,
.aw-block-add:focus-visible {
  outline: 2px solid var(--aw-primary);
  outline-offset: 1px;
  color: var(--aw-primary);
}
/* 추가 버튼의 '+' 는 hover 시 1/4 바퀴 돌아 "여기서 새로 시작한다" 는
   느낌을 준다. 회전은 8px 아이콘에서도 확실히 읽히는 몇 안 되는 변화다. */
.aw-block-add svg {
  transition: transform var(--aw-dur-base) var(--aw-ease-spring);
}
.aw-block-add:hover svg {
  transform: rotate(90deg);
}

.aw-block-handle.is-dragging {
  cursor: grabbing;
  color: var(--aw-primary);
  background-color: var(--aw-btn-active-bg);
  border-color: var(--aw-primary);
  transform: scale(1.05);
}

/* 끌고 있는 블록 자신 — 자리만 남기고 물러난다. */
.is-block-dragging {
  opacity: 0.35;
  filter: saturate(0.6);
  transition:
    opacity var(--aw-dur-base) var(--aw-ease-out),
    filter var(--aw-dur-base) var(--aw-ease-out);
}

/* ─── 드롭 위치 인디케이터 ─────────────────────────────────────────────
   선 왼쪽 끝에 점을 하나 찍는다. 얇은 선만 있으면 어느 쪽 여백에 걸린
   건지 애매한데, 점이 있으면 "여기서부터" 가 분명해진다. */

.aw-block-drop-indicator {
  position: absolute;
  left: 28px;
  right: 28px;
  height: 2px;
  background: var(--aw-primary);
  border-radius: 1px;
  pointer-events: none;
  z-index: 3;
  transform: translateY(-1px);
  box-shadow: 0 0 6px color-mix(in srgb, var(--aw-primary) 70%, transparent);
  animation: aw-drop-in var(--aw-dur-base) var(--aw-ease-out);
}
.aw-block-drop-indicator::before {
  content: '';
  position: absolute;
  left: -3px;
  top: 50%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--aw-primary);
  transform: translateY(-50%);
}
@keyframes aw-drop-in {
  from {
    opacity: 0;
    transform: translateY(-1px) scaleX(0.94);
  }
  to {
    opacity: 1;
    transform: translateY(-1px) scaleX(1);
  }
}

/* ─── Status Bar ─────────────────────────────────────────────────────
   에디터 하단의 메타 정보 표시(활성 블록 / 블록 수 / 글자 수). 뷰어에는
   불필요하므로 .aeriz-wysiwyg-viewer 안에서는 숨긴다. */

.aw-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 12px;
  border-top: 1px solid var(--aw-border);
  background-color: var(--aw-toolbar-bg);
  color: var(--aw-fg-muted);
  font-family: var(--aw-font-mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.aw-status-left,
.aw-status-right {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.aw-status-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.aw-status-item::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--aw-primary);
  opacity: 0.55;
  flex-shrink: 0;
}

/* status bar 안의 작은 아이콘 액션 버튼 (undo/redo 등) */
.aw-status-action {
  appearance: none;
  cursor: pointer;
  background: transparent;
  border: 1px solid transparent;
  color: var(--aw-fg-muted);
  padding: 0;
  width: 22px;
  height: 22px;
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.12s, background-color 0.12s, border-color 0.12s;
}
.aw-status-action svg {
  width: 13px;
  height: 13px;
}
.aw-status-action:hover {
  color: var(--aw-btn-active-fg, var(--aw-primary));
  background-color: var(--aw-btn-hover-bg);
  border-color: var(--aw-border);
}
.aw-status-action:active {
  background-color: var(--aw-btn-active-bg);
}

.aeriz-wysiwyg-viewer .aw-status-bar {
  display: none;
}

/* ─── 블록 포커스 인디케이터 + 라벨 태그 ─────────────────────────────── */

/* 활성 블록 표시는 **레일(왼쪽 세로선) + 옅은 바탕** 두 겹이다.
   레일은 색이 아니라 길이로 자란다 — `box-shadow` 를 켜고 끄면 선이 툭
   나타나는데, 세로로 자라 올라오면 "이 블록이 지금 잡혔다" 가 동작으로
   읽힌다. 레일은 별도 pseudo 로 그려서 블록 자신의 배경(코드 블록 ·
   인용구) 과 겹치지 않는다. 어떤 태그에도 레이아웃 영향을 주지 않도록
   position:absolute 만 쓰고 블록의 박스 크기는 건드리지 않는다. */
.aw-content > [data-block-id] {
  position: relative;
  transition: background-color var(--aw-dur-base) var(--aw-ease-out);
}

.aw-content > [data-block-id]::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 0;
  width: 3px;
  height: 100%;
  border-radius: 2px;
  background: var(--aw-primary);
  opacity: 0;
  transform: scaleY(0.25);
  transform-origin: center;
  pointer-events: none;
  transition:
    opacity var(--aw-dur-base) var(--aw-ease-out),
    transform var(--aw-dur-base) var(--aw-ease-spring);
}

.aw-content > [data-block-focused] {
  background-color: color-mix(in srgb, var(--aw-primary) 7%, transparent);
  border-radius: 3px;
}

.aw-content > [data-block-focused]::before {
  opacity: 1;
  transform: scaleY(1);
}

/* 포인터가 올라간 블록 — 아직 잡은 건 아니므로 레일 없이 바탕만 살짝.
   활성 블록의 강조를 덮지 않도록 :not() 으로 비켜 준다. */
.aw-content > [data-block-id]:hover:not([data-block-focused]) {
  background-color: color-mix(in srgb, var(--aw-fg) 3%, transparent);
}

/* 표는 pseudo 요소가 익명 테이블 박스로 감싸여 위치가 어긋난다. 레일 대신
   테두리 강조로 같은 뜻을 전한다. */
.aw-content > table::before {
  display: none;
}
.aw-content > table[data-block-focused] {
  outline: 1px solid color-mix(in srgb, var(--aw-primary) 55%, transparent);
  outline-offset: 3px;
}

/* 유형이 막 바뀐 블록 — 한 번만 반짝. AerizEditor 가 애니메이션이 끝나면
   속성을 지운다. */
.aw-content > [data-block-flash] {
  animation: aw-block-flash 520ms var(--aw-ease-out);
}
@keyframes aw-block-flash {
  0% {
    background-color: color-mix(in srgb, var(--aw-primary) 26%, transparent);
  }
  100% {
    background-color: transparent;
  }
}

/* 캐럿이 놓인 빈 본문 블록 — 무엇을 하면 되는지 한 줄로 알려 준다.
   문서 전체가 비었을 때 뜨는 에디터 placeholder 와 겹치지 않도록, 블록이
   둘 이상일 때만(`:has(> :nth-child(2))`) 나타난다. */
.aw-content:has(> :nth-child(2))
  > p[data-block-focused]:has(> br:only-child)::after {
  content: var(--aw-empty-hint, '');
  position: absolute;
  left: 0;
  top: 0;
  color: var(--aw-fg-muted);
  opacity: 0;
  pointer-events: none;
  user-select: none;
  font-size: 0.95em;
  animation: aw-hint-in var(--aw-dur-slow) var(--aw-ease-out) 120ms forwards;
}
@keyframes aw-hint-in {
  from {
    opacity: 0;
    transform: translateX(-2px);
  }
  to {
    opacity: 0.45;
    transform: none;
  }
}

/* 구분선은 높이가 사실상 0 이라 레일이 안 보인다 — 최소 길이를 주고
   세로 가운데에 건다 (핸들의 HANDLE_HEIGHT 정렬과 같은 규칙). */
.aw-content > hr::before {
  height: 14px;
  top: 50%;
  margin-top: -7px;
}

/* 읽기 전용 뷰어에는 편집 상태 표시가 의미 없다. */
.aeriz-wysiwyg-viewer .aw-content > [data-block-id]::before {
  display: none;
}
.aeriz-wysiwyg-viewer .aw-content > [data-block-id]:hover {
  background-color: transparent;
}

/* ─── 인터랙티브 블록 라벨 pill ───────────────────────────────────────
   활성 블록 위에 떠 있는 작은 버튼. 정적 ::before pseudo 라벨을 대체하며
   클릭 시 블록 유형 드롭다운을 열어 마이크로 인터랙션으로 유형 변경. */
.aw-block-label-pill {
  position: absolute;
  z-index: 4;
  appearance: none;
  font-family: var(--aw-font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--aw-primary);
  background: var(--aw-bg);
  padding: 2px 5px 2px 4px;
  border: 1px solid color-mix(in srgb, var(--aw-primary) 45%, transparent);
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  line-height: 1;
  white-space: nowrap;
  transition:
    transform var(--aw-dur-fast) var(--aw-ease-out),
    background-color var(--aw-dur-fast) var(--aw-ease-out),
    color var(--aw-dur-fast) var(--aw-ease-out),
    border-color var(--aw-dur-fast) var(--aw-ease-out),
    box-shadow var(--aw-dur-base) var(--aw-ease-out);
}

/* 유형 기호 — 라벨을 읽기 전에 눈이 먼저 잡는 부분이라 한 칸 더 진하게. */
.aw-block-label-pill .aw-pill-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 13px;
  height: 13px;
  padding: 0 2px;
  border-radius: 3px;
  background: color-mix(in srgb, var(--aw-primary) 16%, transparent);
  font-size: 9px;
  letter-spacing: 0;
  transition: background-color var(--aw-dur-fast) var(--aw-ease-out);
}

.aw-block-label-pill::after {
  content: '▾';
  font-size: 9px;
  opacity: 0.55;
  transition:
    opacity var(--aw-dur-fast) var(--aw-ease-out),
    transform var(--aw-dur-base) var(--aw-ease-out);
}
.aw-block-label-pill:hover {
  background: var(--aw-primary);
  color: var(--aw-primary-fg);
  border-color: var(--aw-primary);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px color-mix(in srgb, var(--aw-primary) 32%, transparent);
}
.aw-block-label-pill:hover .aw-pill-glyph {
  background: color-mix(in srgb, var(--aw-primary-fg) 22%, transparent);
}
.aw-block-label-pill:hover::after {
  opacity: 1;
  transform: translateY(1px);
}
.aw-block-label-pill:active {
  transform: translateY(0) scale(0.97);
  box-shadow: none;
}
.aw-block-label-pill:focus-visible {
  outline: 2px solid var(--aw-primary);
  outline-offset: 2px;
}

/* 다른 블록으로 캐럿이 옮겨갈 때만 재생된다 (AerizEditor 가 클래스를 다시
   붙인다). 같은 블록에서 타이핑하는 동안에는 미동도 없어야 한다. */
.aw-block-label-pill.is-entering {
  animation: aw-pill-in var(--aw-dur-slow) var(--aw-ease-spring);
}
/* pill 에서 연 블록 유형 메뉴가 떠 있는 동안 */
.aw-block-label-pill.is-popover-open {
  background: var(--aw-primary);
  color: var(--aw-primary-fg);
  border-color: var(--aw-primary);
}
.aw-block-label-pill.is-popover-open::after {
  transform: rotate(180deg);
  opacity: 1;
}
@keyframes aw-pill-in {
  from {
    opacity: 0;
    transform: translateY(3px) scale(0.92);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.aw-content {
  outline: none;
  /* 위쪽 여백은 라벨 pill(약 15px) + 여유가 들어갈 만큼 둔다 — 문서 첫
     블록에서도 pill 이 글자를 덮지 않아야 한다. */
  padding: 28px 28px 24px;
  min-height: 240px;
  font-size: 15px;
  line-height: 1.7;
  color: var(--aw-fg);
  word-break: break-word;
}

.aw-content:empty::before,
.aw-content[data-placeholder]:has(p:only-child > br:only-child)::before {
  content: attr(data-placeholder);
  color: var(--aw-fg-muted);
  pointer-events: none;
  position: absolute;
}

.aw-content > p {
  margin: 0 0 0.8em 0;
}
.aw-content > p:last-child {
  margin-bottom: 0;
}

/* 정렬 클래스 — getHTML({ styles: 'class' }) 출력이 style="text-align:…" 대신
   사용한다. style 속성을 제거하는 서버 sanitizer 를 통과해도 정렬이 남는다.
   에디터 자체는 계속 인라인 style 로 정렬하므로 편집 중 동작에는 영향이 없다. */
.aw-content .aw-align-left {
  text-align: left;
}
.aw-content .aw-align-center {
  text-align: center;
}
.aw-content .aw-align-right {
  text-align: right;
}
.aw-content .aw-align-justify {
  text-align: justify;
}

.aw-content h1,
.aw-content h2,
.aw-content h3 {
  font-weight: 700;
  margin: 0.6em 0 0.4em;
  padding-bottom: 0.25em;
  border-bottom: 1px solid var(--aw-border);
}
.aw-content h1 { font-size: 1.875rem; line-height: 1.3; }
.aw-content h2 { font-size: 1.5rem;   line-height: 1.35; }
.aw-content h3 { font-size: 1.25rem;  line-height: 1.4; }

.aw-content blockquote {
  margin: 1em 0;
  padding: 0.5em 1em;
  border-left: 4px solid var(--aw-primary);
  background-color: color-mix(in srgb, var(--aw-primary) 8%, transparent);
  color: var(--aw-fg);
  font-style: italic;
}

.aw-content pre {
  position: relative;
  background-color: color-mix(in srgb, var(--aw-fg) 6%, var(--aw-bg));
  border: 1px solid var(--aw-border);
  border-radius: var(--aw-radius-sm);
  padding: 12px 16px;
  font-family: var(--aw-font-mono);
  font-size: 13px;
  line-height: 1.6;
  overflow-x: auto;
  margin: 1em 0;
}

/* 코드 블록 우상단의 언어 라벨 — `<code data-language="javascript">` 의
 * data-language 가 있을 때만 표시. attr() 로 자동 동기화돼 별도 JS 갱신
 * 불필요. 사용자가 드롭다운으로 언어 변경 시 CSS 가 즉시 반영. */
.aw-content > pre > code[data-language]:not([data-language=""])::before {
  content: attr(data-language);
  position: absolute;
  top: 6px;
  right: 10px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--aw-fg-muted);
  background: color-mix(in srgb, var(--aw-fg) 10%, transparent);
  padding: 2px 8px;
  border-radius: 4px;
  pointer-events: none;
  user-select: none;
}

.aw-content code {
  font-family: var(--aw-font-mono);
  font-size: 0.9em;
  background-color: color-mix(in srgb, var(--aw-fg) 8%, transparent);
  padding: 0.15em 0.4em;
  border-radius: 3px;
}
.aw-content pre code {
  background: transparent;
  padding: 0;
}

/* ─── Syntax highlight 토큰 색 (자체 highlight.ts 출력) ──────────── */
.aw-content pre code .hl-keyword { color: #c678dd; font-weight: 600; }
.aw-content pre code .hl-string  { color: #98c379; }
.aw-content pre code .hl-number  { color: #d19a66; }
.aw-content pre code .hl-comment { color: var(--aw-fg-muted); font-style: italic; }
.aw-content pre code .hl-fn      { color: #61afef; }
.aw-content pre code .hl-builtin { color: #56b6c2; }
.aw-content pre code .hl-tag     { color: #e06c75; }
.aw-content pre code .hl-attr    { color: #d19a66; }
.aw-content pre code .hl-prop    { color: #61afef; }
.aw-content pre code .hl-punct   { color: var(--aw-fg-muted); }

/* light 테마 보정 */
.aeriz-wysiwyg[data-theme='light'] .aw-content pre code .hl-keyword { color: #a626a4; }
.aeriz-wysiwyg[data-theme='light'] .aw-content pre code .hl-string  { color: #50a14f; }
.aeriz-wysiwyg[data-theme='light'] .aw-content pre code .hl-number  { color: #986801; }
.aeriz-wysiwyg[data-theme='light'] .aw-content pre code .hl-fn      { color: #4078f2; }
.aeriz-wysiwyg[data-theme='light'] .aw-content pre code .hl-builtin { color: #0184bc; }
.aeriz-wysiwyg[data-theme='light'] .aw-content pre code .hl-tag     { color: #e45649; }
.aeriz-wysiwyg[data-theme='light'] .aw-content pre code .hl-prop    { color: #4078f2; }

.aw-content ul,
.aw-content ol {
  margin: 0.6em 0;
  padding-left: 1.6em;
}

.aw-content li {
  margin: 0.2em 0;
}

/* ─── 체크리스트 ─────────────────────────────────────────────────────
   체크박스는 `<input>` 이 아니라 `<li>` 의 ::before 다. contentEditable 안의
   폼 요소는 캐럿이 들어가고 서버 sanitizer 가 지우는데, ::before 는 둘 다
   해당이 없다. 완료 여부는 `data-checked` 한 글자로 남는다. */
.aw-content ul.aw-task-list {
  list-style: none;
  padding-left: 1.9em;
}
.aw-content ul.aw-task-list > li {
  position: relative;
}
.aw-content ul.aw-task-list > li::before {
  content: '';
  position: absolute;
  left: -1.5em;
  top: 0.28em;
  width: 15px;
  height: 15px;
  border: 1.5px solid var(--aw-fg-muted);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  box-sizing: border-box;
  transition:
    background-color var(--aw-dur-fast) var(--aw-ease-out),
    border-color var(--aw-dur-fast) var(--aw-ease-out),
    transform var(--aw-dur-base) var(--aw-ease-spring);
}
.aw-content ul.aw-task-list > li:hover::before {
  border-color: var(--aw-primary);
  transform: scale(1.1);
}
/* 체크 표시는 두 번째 pseudo 로 그린다 — 네모와 따로 움직여야 "찍히는"
   느낌이 난다. 회전한 ㄴ 자 두 획이 체크 모양이다. */
.aw-content ul.aw-task-list > li::after {
  content: '';
  position: absolute;
  left: -1.16em;
  top: 0.42em;
  width: 4px;
  height: 8px;
  border: solid var(--aw-primary-fg);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) scale(0.4);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity var(--aw-dur-fast) var(--aw-ease-out),
    transform var(--aw-dur-base) var(--aw-ease-spring);
}
.aw-content ul.aw-task-list > li[data-checked='true']::before {
  background: var(--aw-primary);
  border-color: var(--aw-primary);
}
.aw-content ul.aw-task-list > li[data-checked='true']::after {
  opacity: 1;
  transform: rotate(45deg) scale(1);
}
/* 완료한 항목은 한 걸음 물러난다. 지우지는 않는다 — 무엇을 끝냈는지도
   목록의 일부다. */
.aw-content ul.aw-task-list > li[data-checked='true'] {
  color: var(--aw-fg-muted);
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, var(--aw-fg-muted) 60%, transparent);
}

.aw-content a {
  color: var(--aw-primary);
  text-decoration: underline;
}

.aw-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--aw-radius-sm);
  margin: 0.5em 0;
}

.aw-content hr {
  border: none;
  border-top: 1px solid var(--aw-border);
  margin: 1.5em 0;
}

/* ─── 유튜브 임베드 (16:9 반응형 컨테이너) ──────────────────── */
.aw-content > div.aw-youtube-embed {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  margin: 1em 0;
  border-radius: 8px;
  /* overflow: hidden; */
  background: #000;
  border: 1px solid var(--aw-border);
}
.aw-content > div.aw-youtube-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* ─── 파일 첨부 (다운로드 카드) ──────────────────── */
.aw-content > a.aw-file-attachment {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 1em 0;
  padding: 10px 14px;
  border: 1px solid var(--aw-border);
  border-radius: 8px;
  background: var(--aw-bg);
  color: var(--aw-fg);
  text-decoration: none;
  transition: background-color 0.08s, border-color 0.08s;
  cursor: pointer;
  user-select: none;
}
.aw-content > a.aw-file-attachment:hover {
  background: color-mix(in srgb, var(--aw-fg) 5%, var(--aw-bg));
  border-color: color-mix(in srgb, var(--aw-primary) 40%, var(--aw-border));
}
.aw-content > a.aw-file-attachment .aw-file-icon {
  flex: 0 0 auto;
  display: inline-flex;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: color-mix(in srgb, var(--aw-primary) 12%, transparent);
  color: var(--aw-primary);
}
.aw-content > a.aw-file-attachment .aw-file-icon svg {
  width: 20px;
  height: 20px;
}
.aw-content > a.aw-file-attachment .aw-file-meta {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.aw-content > a.aw-file-attachment .aw-file-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--aw-fg);
  word-break: break-all;
  line-height: 1.3;
}
.aw-content > a.aw-file-attachment .aw-file-info {
  font-size: 0.75rem;
  color: var(--aw-fg-muted);
  font-family: var(--aw-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
  letter-spacing: 0.02em;
}
.aw-content > a.aw-file-attachment .aw-file-action {
  flex: 0 0 auto;
  display: inline-flex;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  color: var(--aw-fg-muted);
}
.aw-content > a.aw-file-attachment .aw-file-action svg {
  width: 18px;
  height: 18px;
}
.aw-content > a.aw-file-attachment:hover .aw-file-action {
  color: var(--aw-primary);
}

/* ─── 링크 카드 (Open Graph 스타일 미리보기) ──────────────────── */
.aw-content > a.aw-link-card {
  display: flex;
  align-items: stretch;
  gap: 14px;
  text-decoration: none;
  margin: 1em 0;
  padding: 0;
  border: 1px solid var(--aw-border);
  border-radius: 8px;
  background-color: color-mix(in srgb, var(--aw-primary) 5%, var(--aw-bg));
  color: var(--aw-fg);
  overflow: hidden;
  transition: border-color 0.12s, background-color 0.12s;
}
.aw-content > a.aw-link-card:hover {
  border-color: var(--aw-primary);
  background-color: color-mix(in srgb, var(--aw-primary) 9%, var(--aw-bg));
}

/* 좌측 og:image 썸네일 — 있을 때만. */
.aw-content > a.aw-link-card > .aw-link-card-image {
  flex: 0 0 auto;
  width: 120px;
  height: auto;
  object-fit: cover;
  align-self: stretch;
  background: color-mix(in srgb, var(--aw-fg) 5%, var(--aw-bg));
}

/* 우측 본문 — title / desc / url 행. */
.aw-content > a.aw-link-card > .aw-link-card-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
}
.aw-content > a.aw-link-card .aw-link-card-title {
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.3;
  color: var(--aw-fg);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.aw-content > a.aw-link-card .aw-link-card-desc {
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--aw-fg-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.aw-content > a.aw-link-card .aw-link-card-url {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  font-size: 0.78rem;
  color: var(--aw-primary);
  font-family: var(--aw-font-mono);
  word-break: break-all;
}
.aw-content > a.aw-link-card .aw-link-card-favicon {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  border-radius: 2px;
  background: transparent;
}
.aw-content > a.aw-link-card .aw-link-card-url-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.aw-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 1em 0;
}
.aw-content table td,
.aw-content table th {
  border: 1px solid var(--aw-border);
  padding: 8px 12px;
  vertical-align: top;
  min-width: 40px;
  /* td/th 의 inline background-color 가 overflow 자식에 가려지지 않도록 */
  background-clip: padding-box;
}
.aw-content table th {
  background-color: color-mix(in srgb, var(--aw-fg) 5%, var(--aw-bg));
  font-weight: 600;
}

.aw-content table td,
.aw-content table th {
  transition: background-color var(--aw-dur-fast) var(--aw-ease-out);
}

/* 커스텀 드래그-셀렉션으로 마킹된 표 셀 — 다중 선택 시각 강조. */
.aw-content table td.aw-cell-selected,
.aw-content table th.aw-cell-selected {
  outline: 2px solid var(--aw-primary);
  outline-offset: -2px;
  background-color: color-mix(in srgb, var(--aw-primary) 18%, transparent) !important;
}
.aeriz-wysiwyg-viewer .aw-cell-selected {
  outline: none;
  background-color: revert !important;
}

/* ─── 리사이즈 핸들 + 정렬 컨트롤 (이미지·유튜브) ──────────────────── */
.aw-content > figure,
.aw-content > div.aw-youtube-embed {
  position: relative;
  /* 인라인 width 가 본문보다 커도 넘치지 않게 막는다. 드래그 리사이즈는
     JS 에서 본문 폭으로 상한을 두지만, 외부에서 들어온 값(HTML 가져오기,
     예전에 더 넓은 화면에서 저장된 스냅샷)까지 막아 주는 건 이 규칙이다.
     이게 없으면 본문이 가로로 넓어지면서 에디터 전체가 늘어난다. */
  max-width: 100%;
}

/* figure 의 좌우 여백을 0 으로 명시한다.
   브라우저 UA 기본값은 `figure { margin: 1em 40px }` 인데, getHTML() 이
   베이크하는 portable 스타일은 `margin: 1em 0` 이다. 그대로 두면 에디터에서는
   80px 좁게 보이고 내보낸 HTML 에서는 넓게 보이는 WYSIWYG 불일치가 생긴다. */
.aw-content > figure {
  margin: 1em 0;
}

/* ─── 이미지 캡션 ────────────────────────────────────────────────────
   그림에 딸린 설명. 본문보다 한 단계 작고 흐리게 — 그림을 읽고 나서 눈이
   내려오는 자리다. 그림 정렬(가운데/오른쪽) 을 따라가도록 figure 의
   text-align 을 그대로 상속받는다. */
.aw-content > figure > figcaption {
  margin-top: 0.5em;
  font-size: 0.85em;
  line-height: 1.5;
  color: var(--aw-fg-muted);
  outline: none;
}
/* 비어 있는 동안만 안내를 띄운다. 캡션은 캐럿이 떠나면 사라지므로, 이
   안내가 보이는 시간은 "지금 쓰면 된다" 는 순간뿐이다. */
.aw-content > figure > figcaption:empty::before {
  content: var(--aw-caption-hint, '');
  color: var(--aw-fg-muted);
  opacity: 0.5;
  pointer-events: none;
}
.aeriz-wysiwyg-viewer .aw-content > figure > figcaption:empty {
  display: none;
}

/* 좌상단 정렬 컨트롤 — 좌/중/우 3 버튼. hover 시 위에서 내려오며 fade-in. */
.aw-block-align-controls {
  position: absolute;
  top: 6px;
  left: 6px;
  display: flex;
  gap: 1px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  border-radius: 6px;
  padding: 2px;
  z-index: 11;
  opacity: 0;
  transform: translateY(-4px);
  transition:
    opacity var(--aw-dur-base) var(--aw-ease-out),
    transform var(--aw-dur-base) var(--aw-ease-out);
  user-select: none;
}
.aw-content > figure:hover .aw-block-align-controls,
.aw-content > div.aw-youtube-embed:hover .aw-block-align-controls,
.aw-content > figure:focus-within .aw-block-align-controls,
.aw-resizing .aw-block-align-controls {
  opacity: 1;
  transform: none;
}
/* 정렬 버튼과 캡션 버튼 사이 구분선 — 하는 일이 다르다는 표시. */
.aw-block-ctl-divider {
  width: 1px;
  align-self: stretch;
  margin: 2px 2px;
  background: rgba(255, 255, 255, 0.25);
}

.aw-block-align-btn,
.aw-block-caption-btn {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  border-radius: 4px;
  padding: 0;
  transition:
    background-color var(--aw-dur-fast) var(--aw-ease-out),
    transform var(--aw-dur-fast) var(--aw-ease-out);
}
.aw-block-align-btn:hover,
.aw-block-caption-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}
.aw-block-align-btn:active,
.aw-block-caption-btn:active {
  transform: scale(0.9);
}
.aw-block-align-btn:focus-visible,
.aw-block-caption-btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: -2px;
}
.aw-block-align-btn svg,
.aw-block-caption-btn svg {
  width: 14px;
  height: 14px;
}
.aw-resize-handle {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 14px;
  height: 14px;
  background: var(--aw-primary);
  border: 2px solid var(--aw-bg);
  border-radius: 4px;
  cursor: nwse-resize;
  z-index: 10;
  user-select: none;
  opacity: 0;
  transform: scale(0.7);
  transition:
    opacity var(--aw-dur-base) var(--aw-ease-out),
    transform var(--aw-dur-base) var(--aw-ease-spring),
    box-shadow var(--aw-dur-base) var(--aw-ease-out);
}
/* 실제로 잡히는 면적은 보이는 것보다 넓다 — 14px 짜리 점을 정확히 겨냥해야
   하면 리사이즈가 스트레스가 된다. */
.aw-resize-handle::before {
  content: '';
  position: absolute;
  inset: -7px;
}
.aw-content > figure:hover .aw-resize-handle,
.aw-content > div.aw-youtube-embed:hover .aw-resize-handle,
.aw-resizing .aw-resize-handle {
  opacity: 1;
  transform: none;
}
.aw-resize-handle:hover {
  transform: scale(1.18);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--aw-primary) 22%, transparent);
}
/* 크기를 조절하는 동안은 그 블록만 또렷하게 남기고 나머지 UI 는 조용해진다. */
.aw-resizing .aw-resize-handle {
  transform: scale(1.18);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--aw-primary) 28%, transparent);
}
.aw-resizing {
  outline: 1px solid color-mix(in srgb, var(--aw-primary) 60%, transparent);
  outline-offset: 2px;
}

/* 유튜브 임베드는 iframe 안에 자체 워터마크/컨트롤이 있어 코너에 핸들을 두면
 * 클릭이 충돌한다. embed 안쪽 우하단에 약간 들여서 배치 — YouTube 자체 UI
 * 영역과 약간 떨어진 위치. */
.aw-content > div.aw-youtube-embed > .aw-resize-handle {
  right: 0px;
  bottom: -15px;
}
.aw-resizing {
  user-select: none;
}

/* 뷰어(읽기 전용) 모드에서는 편집용 컨트롤(리사이즈 핸들 / 정렬 컨트롤) 을
 * 모두 숨긴다. AerizViewer.root 의 className 'aeriz-wysiwyg-viewer' 를 타겟. */
.aeriz-wysiwyg-viewer .aw-resize-handle,
.aeriz-wysiwyg-viewer .aw-block-align-controls {
  display: none !important;
}

/* ─── 모션 민감 사용자 ───────────────────────────────────────────────
   움직임은 전부 걷어내되 **상태는 그대로 보이게** 한다. transition 만 0 으로
   만들면 애니메이션으로 나타나던 요소가 영영 안 보이는 사고가 나므로,
   등장 애니메이션은 끝 상태를 직접 지정한다. */
@media (prefers-reduced-motion: reduce) {
  .aeriz-wysiwyg *,
  .aeriz-wysiwyg *::before,
  .aeriz-wysiwyg *::after {
    transition-duration: 1ms !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
  }
  .aw-content > [data-block-focused]::before {
    transform: none;
  }
  .aw-block-add:hover svg,
  .aw-block-label-pill:hover,
  .aw-block-handle:active,
  .aw-block-add:active,
  .aw-block-align-btn:active {
    transform: none;
  }
}
.aw-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  padding: 6px 8px;
  background-color: var(--aw-toolbar-bg);
  border-bottom: 1px solid var(--aw-border);
  color: var(--aw-toolbar-fg);
  z-index: var(--aw-z-toolbar);
}

.aw-toolbar-sticky {
  position: sticky;
  top: 0;
}

.aw-toolbar-group {
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 0 4px;
  border-right: 1px solid var(--aw-divider);
}

.aw-toolbar-group:last-child {
  border-right: none;
}

.aw-toolbar-group:empty {
  display: none;
}

.aw-toolbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  min-width: 32px;
  padding: 0 6px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--aw-radius-sm);
  cursor: pointer;
  color: var(--aw-toolbar-fg);
  position: relative;
  transition:
    background-color var(--aw-dur-fast) var(--aw-ease-out),
    color var(--aw-dur-fast) var(--aw-ease-out),
    border-color var(--aw-dur-fast) var(--aw-ease-out),
    transform var(--aw-dur-fast) var(--aw-ease-out);
}

.aw-toolbar-btn:hover:not(:disabled) {
  background-color: var(--aw-btn-hover-bg);
}

/* 누르는 순간의 반응 — 색보다 먼저 손끝에 닿는 신호. */
.aw-toolbar-btn:active:not(:disabled) {
  transform: scale(0.94);
}

.aw-toolbar-btn:focus-visible {
  outline: 2px solid var(--aw-primary);
  outline-offset: -1px;
}

.aw-toolbar-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.aw-toolbar-btn-active {
  background-color: var(--aw-btn-active-bg);
  color: var(--aw-btn-active-fg);
}

.aw-toolbar-btn-active:hover:not(:disabled) {
  background-color: var(--aw-btn-active-bg);
}

/* 켜진 항목 아래 2px 밑줄이 가운데에서 좌우로 펼쳐진다. 배경색만 바뀌면
   어두운 테마에서 on/off 차이가 잘 안 읽힌다. */
.aw-toolbar-btn::after {
  content: '';
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 3px;
  height: 2px;
  border-radius: 1px;
  background: currentColor;
  transform: scaleX(0);
  opacity: 0;
  transition:
    transform var(--aw-dur-base) var(--aw-ease-out),
    opacity var(--aw-dur-base) var(--aw-ease-out);
}
.aw-toolbar-btn-active::after {
  transform: scaleX(1);
  opacity: 0.8;
}

/* 이 버튼에서 열린 드롭다운이 떠 있는 동안 — 셰브론이 뒤집혀 "다시 누르면
   닫힌다" 를 알린다. */
.aw-toolbar-btn.is-popover-open {
  background-color: var(--aw-btn-active-bg);
  color: var(--aw-btn-active-fg);
}
.aw-toolbar-btn .aw-toolbar-btn-chevron {
  transition: transform var(--aw-dur-base) var(--aw-ease-out), opacity var(--aw-dur-fast);
}
.aw-toolbar-btn.is-popover-open .aw-toolbar-btn-chevron {
  transform: rotate(180deg);
  opacity: 1;
}

.aw-toolbar-btn-icon {
  display: inline-flex;
  width: 18px;
  height: 18px;
}

.aw-toolbar-btn-icon svg {
  width: 100%;
  height: 100%;
}

.aw-toolbar-btn-chevron {
  display: inline-flex;
  width: 12px;
  height: 12px;
  margin-left: 2px;
  opacity: 0.7;
}

.aw-toolbar-btn-chevron svg {
  width: 100%;
  height: 100%;
}
/*
 * Dialog / popover 는 .aeriz-wysiwyg 의 자식이 아닌 document.body 에 attach
 * 되므로 에디터의 CSS 변수를 직접 받지 못한다. 대신 자기 자신에
 * data-theme 속성을 받아 아래의 변수 토큰을 분기한다. 호출자(에디터)는
 * dialog/popover 를 열 때 자신의 theme 을 전달한다.
 */

.aw-dialog-overlay,
.aw-popover {
  --d-bg: #ffffff;
  --d-fg: #1a1a1a;
  --d-fg-muted: #6b7280;
  --d-border: #e5e7eb;
  --d-border-strong: #d1d5db;
  --d-input-bg: #ffffff;
  --d-input-fg: #1a1a1a;
  --d-footer-bg: #f9fafb;
  --d-hover-bg: #f3f4f6;
  --d-primary: #64c8ff;
  --d-primary-hover: #38bdf8;
  --d-primary-soft: rgba(100, 200, 255, 0.18);
  --d-on-primary: #050810;
  --d-overlay: rgba(0, 0, 0, 0.45);
  --d-mono: ui-monospace, SFMono-Regular, 'JetBrains Mono', Menlo, Consolas, monospace;
  /* 다이얼로그/팝오버는 body 에 붙어 에디터 토큰을 상속받지 못한다.
     같은 값을 여기에도 둔다 — 두 표면의 모션이 어긋나면 한 제품처럼 안 느껴진다.
     (tokens.css 의 --aw-dur-* / --aw-ease-* 와 값이 같아야 한다.) */
  --aw-dur-fast: 90ms;
  --aw-dur-base: 160ms;
  --aw-dur-slow: 240ms;
  --aw-ease-out: cubic-bezier(0.22, 0.85, 0.3, 1);
  --aw-ease-spring: cubic-bezier(0.2, 1.3, 0.4, 1);
}

.aw-dialog-overlay[data-theme='dark'],
.aw-popover[data-theme='dark'] {
  --d-bg: #0a0e14;
  --d-fg: #e7eef5;
  --d-fg-muted: #76849b;
  --d-border: rgba(100, 200, 255, 0.16);
  --d-border-strong: rgba(100, 200, 255, 0.30);
  --d-input-bg: #0d1320;
  --d-input-fg: #e7eef5;
  --d-footer-bg: #05080d;
  --d-hover-bg: rgba(100, 200, 255, 0.10);
  --d-primary: #64c8ff;
  --d-primary-hover: #8ad6ff;
  --d-primary-soft: rgba(100, 200, 255, 0.22);
  --d-on-primary: #050810;
  --d-overlay: rgba(0, 0, 0, 0.65);
}

.aw-dialog-overlay {
  position: fixed;
  inset: 0;
  background-color: var(--d-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--aw-z-dialog, 1000);
  font-family: -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Pretendard',
    'Noto Sans KR', 'Malgun Gothic', sans-serif;
  animation: aw-fade-in 0.12s ease;
}

@keyframes aw-fade-in { from { opacity: 0; } to { opacity: 1; } }

.aw-dialog {
  background: var(--d-bg);
  color: var(--d-fg);
  border-radius: 8px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.45);
  width: 480px;
  max-width: 95vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: aw-slide-up 0.18s ease;
  border: 1px solid var(--d-border);
}

@keyframes aw-slide-up {
  from { transform: translateY(8px); opacity: 0; }
  to   { transform: translateY(0);   opacity: 1; }
}

.aw-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--d-border);
}

.aw-dialog-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--d-fg);
}

.aw-dialog-close {
  background: transparent;
  border: none;
  cursor: pointer;
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 4px;
  color: var(--d-fg-muted);
  transition: background-color 0.12s, color 0.12s;
}
.aw-dialog-close:hover { background-color: var(--d-hover-bg); color: var(--d-fg); }
.aw-dialog-close svg { width: 18px; height: 18px; }

.aw-dialog-body {
  padding: 20px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px;
}

.aw-dialog-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--d-border);
  display: flex; justify-content: flex-end; gap: 8px;
  background-color: var(--d-footer-bg);
}

.aw-field { display: flex; flex-direction: column; gap: 6px; }
.aw-field-label { font-size: 13px; font-weight: 600; color: var(--d-fg); }

.aw-input {
  width: 100%;
  padding: 8px 12px;
  font-size: 14px;
  font-family: inherit;
  border: 1px solid var(--d-border-strong);
  border-radius: 6px;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
  color: var(--d-input-fg);
  background-color: var(--d-input-bg);
}
.aw-input:focus {
  border-color: var(--d-primary);
  box-shadow: 0 0 0 3px var(--d-primary-soft);
}

.aw-textarea {
  resize: vertical;
  min-height: 120px;
  font-family: var(--d-mono);
  font-size: 12px;
  line-height: 1.5;
}

.aw-checkbox {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 14px;
  color: var(--d-fg);
  cursor: pointer; user-select: none;
}
.aw-checkbox input { width: 16px; height: 16px; accent-color: var(--d-primary); }

.aw-btn {
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  transition: background-color 0.12s, border-color 0.12s, color 0.12s;
}
.aw-btn-primary { background-color: var(--d-primary); color: var(--d-on-primary); }
.aw-btn-primary:hover { background-color: var(--d-primary-hover); }
.aw-btn-ghost {
  background-color: transparent;
  color: var(--d-fg);
  border-color: var(--d-border-strong);
}
.aw-btn-ghost:hover { background-color: var(--d-hover-bg); }

.aw-tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--d-border);
  margin: -4px -4px 8px;
}
.aw-tab {
  padding: 8px 14px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 14px;
  font-family: inherit;
  font-weight: 500;
  color: var(--d-fg-muted);
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s;
}
.aw-tab:hover { color: var(--d-fg); }
.aw-tab-active { color: var(--d-primary); border-bottom-color: var(--d-primary); }
.aw-tab-disabled,
.aw-tab[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
  text-decoration: line-through;
  color: var(--d-fg-muted);
}
.aw-tab-disabled:hover,
.aw-tab[disabled]:hover { color: var(--d-fg-muted); }

.aw-dialog-hint {
  font-size: 12px;
  color: var(--d-fg-muted);
  margin-top: -4px;
}

.aw-pane-notice {
  padding: 24px 16px;
  text-align: center;
  font-size: 13px;
  color: var(--d-fg-muted);
  background-color: var(--d-input-bg);
  border: 1px dashed var(--d-border-strong);
  border-radius: 8px;
}

.aw-pane { display: flex; flex-direction: column; gap: 12px; }

.aw-dropzone {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 10px;
  padding: 32px 20px;
  border: 2px dashed var(--d-border-strong);
  border-radius: 8px;
  cursor: pointer;
  text-align: center;
  color: var(--d-fg-muted);
  transition: border-color 0.12s, background-color 0.12s, color 0.12s;
  background-color: var(--d-input-bg);
}
.aw-dropzone:hover {
  border-color: var(--d-primary);
  background-color: var(--d-hover-bg);
  color: var(--d-primary);
}
.aw-dropzone svg { width: 36px; height: 36px; }
.aw-dropzone-text { font-size: 13px; line-height: 1.5; }
.aw-dropzone-loading { opacity: 0.6; pointer-events: none; }

.aw-preview {
  width: 100%; height: 160px;
  border-radius: 6px;
  background-size: cover; background-position: center;
  border: 1px solid var(--d-border);
}

.aw-table-grid {
  display: grid;
  grid-template-columns: repeat(10, 22px);
  grid-template-rows: repeat(10, 22px);
  gap: 2px;
  padding: 8px;
  background-color: var(--d-footer-bg);
  border-radius: 6px;
  width: max-content;
  margin: 0 auto;
}
.aw-table-cell {
  background-color: var(--d-input-bg);
  border: 1px solid var(--d-border-strong);
  border-radius: 2px;
  cursor: pointer;
  transition: background-color 0.08s;
}
.aw-table-cell-active {
  background-color: var(--d-primary-soft);
  border-color: var(--d-primary);
}
.aw-table-status {
  text-align: center;
  font-size: 13px;
  color: var(--d-fg-muted);
  margin-top: 4px;
}

/* ─── Popovers ──────────────────────────────────────────────── */

.aw-popover {
  background: var(--d-bg);
  color: var(--d-fg);
  border: 1px solid var(--d-border);
  border-radius: 8px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.35);
  padding: 8px;
  z-index: var(--aw-z-popover, 100);
  animation: aw-fade-in 0.1s ease;
  min-width: 160px;
  font-family: -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Pretendard',
    'Noto Sans KR', 'Malgun Gothic', sans-serif;
}

.aw-color-popover {
  /* 8 swatch × 22 + 7 gap × 4 + 8 padding × 2 = 220px 컨텐츠에 맞게 */
  width: max-content;
  min-width: 220px;
}

.aw-color-grid {
  display: grid;
  grid-template-columns: repeat(8, 22px);
  gap: 4px;
  justify-content: start;
}

.aw-color-swatch {
  width: 22px; height: 22px;
  border-radius: 4px;
  border: 1px solid var(--d-border);
  cursor: pointer;
  padding: 0;
  transition:
    transform var(--aw-dur-base, 160ms) var(--aw-ease-spring, ease),
    box-shadow var(--aw-dur-fast, 90ms) ease;
}
/* 색은 손톱만 한 사각형이라, 확대만으로는 어느 칸에 있는지 확신이 안 선다.
   같은 색 링을 한 겹 둘러 커서가 놓인 칸을 못 박아 준다. */
.aw-color-swatch:hover {
  transform: scale(1.18);
  box-shadow: 0 0 0 2px var(--d-bg), 0 0 0 3px var(--d-primary);
}
.aw-color-swatch:active { transform: scale(1.02); }
.aw-color-swatch:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--d-bg), 0 0 0 3px var(--d-primary);
}

.aw-color-section {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--d-fg-muted);
  font-weight: 700;
  padding: 6px 2px 4px;
}
.aw-color-section + .aw-color-grid { margin-bottom: 4px; }

.aw-popover-action {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  color: var(--d-fg);
  font-family: inherit;
  margin-top: 4px;
  position: relative;
}
.aw-popover-action:hover { background-color: var(--d-hover-bg); }

.aw-popover-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 4px 8px;
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  color: var(--d-fg);
  font-family: inherit;
  font-size: 12.5px;
  transition:
    background-color var(--aw-dur-fast, 90ms) ease,
    color var(--aw-dur-fast, 90ms) ease;
}
.aw-popover-item:hover { background-color: var(--d-hover-bg); }
.aw-popover-item:active { background-color: var(--d-primary-soft); }
.aw-popover-item:focus-visible {
  outline: 2px solid var(--d-primary);
  outline-offset: -2px;
}

.aw-popover-item-glyph {
  display: inline-flex;
  width: 18px; height: 18px;
  align-items: center; justify-content: center;
  flex-shrink: 0;
  border-radius: 3px;
  background: var(--d-hover-bg);
  color: var(--d-fg-muted);
  font-family: var(--d-mono);
  font-size: 10px;
  font-weight: 700;
  transition:
    background-color var(--aw-dur-fast, 90ms) ease,
    color var(--aw-dur-fast, 90ms) ease,
    transform var(--aw-dur-base, 160ms) var(--aw-ease-spring, ease);
}
/* 항목을 훑을 때 기호만 살짝 커진다 — 행 전체가 움직이면 목록이 출렁이지만,
   18px 짜리 기호 하나는 커서를 따라오는 느낌만 남기고 레이아웃을 흔들지 않는다. */
.aw-popover-item:hover .aw-popover-item-glyph {
  background: var(--d-primary-soft);
  color: var(--d-primary);
  transform: scale(1.12);
}
.aw-popover-item-glyph svg { width: 11px; height: 11px; }

.aw-popover-item-label { flex: 1; min-width: 0; }

.aw-popover-item-icon {
  display: inline-flex;
  width: auto;
  padding: 8px;
  align-items: center; justify-content: center;
  gap: 0;
}
.aw-popover-item-icon svg { width: 18px; height: 18px; }

.aw-popover-divider {
  height: 1px;
  background: var(--d-border);
  margin: 4px 6px;
}

/* 블록 유형 드롭다운 — 항목이 많아 세로로 길어지지 않도록 2 컬럼 그리드.
 * 섹션 구분 divider 는 grid-column 으로 두 컬럼을 모두 가로지른다. */
.aw-block-type-popover {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  column-gap: 2px;
  min-width: 320px;
}
.aw-block-type-popover .aw-popover-divider {
  grid-column: 1 / -1;
}

/* 글꼴 드롭다운 — 라벨(작게) + '가A' 미리보기(글꼴 자체) 두 영역. */
.aw-font-family-popover {
  min-width: 180px;
  max-height: 360px;
  overflow-y: auto;
}
.aw-font-family-item {
  padding: 4px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.aw-font-family-name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 11px;
  line-height: 1.4;
  color: var(--d-fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.aw-font-family-preview {
  flex: 0 0 auto;
  font-size: 13px;
  line-height: 1.4;
  color: var(--d-fg-muted);
  letter-spacing: 0.05em;
}

/* 표 편집 드롭다운 — 행/열 추가·삭제 텍스트 항목 */
.aw-table-menu-popover {
  min-width: 160px;
}
.aw-table-menu-item {
  font-size: 12px;
  padding: 6px 10px;
}

/* 글자 크기 드롭다운 — 한 줄당 px 라벨이 그 크기로 렌더되는 컴팩트 리스트 */
.aw-font-size-popover {
  min-width: 80px;
  max-height: 320px;
  overflow-y: auto;
}
.aw-font-size-item {
  padding: 2px 10px;
  justify-content: space-between;
}
.aw-font-size-label {
  font-size: 11px;
  color: var(--d-fg);
  font-family: var(--d-mono);
  letter-spacing: 0.02em;
}

.aw-popover-item-active {
  background-color: color-mix(in srgb, var(--d-primary) 14%, transparent);
  color: var(--d-primary);
}
.aw-popover-item-active::after {
  content: '✓';
  margin-left: auto;
  font-size: 11px;
}

.aw-align-popover {
  display: flex;
  gap: 2px;
  min-width: auto;
}

/* 표 삽입 드롭다운 — 호버에 따라 동적으로 늘어나는 셀 그리드 */
.aw-table-popover {
  padding: 10px;
  min-width: auto;
}
.aw-table-picker-grid {
  display: grid;
  gap: 2px;
  margin-bottom: 6px;
}
.aw-table-picker-grid .aw-table-cell {
  width: 18px;
  height: 18px;
  background-color: var(--d-input-bg);
  border: 1px solid var(--d-border-strong);
  border-radius: 2px;
  cursor: pointer;
  transition: background-color 0.06s, border-color 0.06s;
}
/* 선택된 칸은 살짝 안으로 눌러 담긴다 — 몇 칸이 잡혔는지 숫자를 읽지 않고도
   면적으로 먼저 보인다. */
.aw-table-picker-grid .aw-table-cell.aw-table-cell-active {
  background-color: var(--d-primary-soft);
  border-color: var(--d-primary);
  transform: scale(0.9);
}
.aw-table-picker-grid .aw-table-cell {
  transition:
    background-color var(--aw-dur-fast, 90ms) ease,
    border-color var(--aw-dur-fast, 90ms) ease,
    transform var(--aw-dur-fast, 90ms) var(--aw-ease-out, ease);
}
.aw-table-popover .aw-table-status {
  text-align: center;
  font-size: 12px;
  color: var(--d-fg-muted);
  font-family: var(--d-mono);
  margin: 0;
}

.aw-coming-soon-popover .aw-popover-section {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--d-fg-muted);
  padding: 4px 8px;
  font-weight: 700;
}
.aw-coming-soon-popover .aw-popover-empty {
  padding: 10px 8px;
  font-size: 13px;
  color: var(--d-fg-muted);
}
