/* Tiptap Editor 전용 스타일 */
/* 한글 글꼴(바탕/굴림/돋움/궁서 등) @font-face는 main.css에서 사이트 전역으로 로드됨 */

/* 본문/표 테두리 색 상수 (추후 #000000 등으로 변경 시 일괄 적용) */
:root {
    --tiptap-ink: #111827;
}

/* 뷰어(안내문/서식 본문)는 .ProseMirror.prose-viewer 로 동일 스타일 적용. 편집기는 .ProseMirror 단독. */

/* 에디터 컨테이너 */
.tiptap-editor-container {
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    overflow: hidden;
    background-color: white;
    position: relative;
}

/* 에디터 본문 (공백 보존: 문단 앞·뒤 공백이 무시되지 않도록 스타일시트에서만 지정) */
.ProseMirror {
    min-height: 400px;
    max-height: 600px;
    overflow-y: auto !important;
    padding: 1rem;
    border: none !important;
    border-radius: 0 !important;
    outline: none !important;
    font-family: 바탕 !important;
    font-size: 15pt !important;
    line-height: 1.6 !important;
    background-color: white !important;
    color: var(--tiptap-ink) !important;
    white-space: pre-wrap !important;
}

.ProseMirror:focus {
    outline: none !important;
    box-shadow: none !important;
}

/* 뷰어 전용: 편집기 컨테이너 스타일 제거(편집기와 동일한 본문 스타일만 적용) */
.prose-viewer.ProseMirror {
    min-height: 0 !important;
    max-height: none !important;
    padding: 0 !important;
    overflow: visible !important;
    /* 문단 앞·뒤 공백이 무시되지 않도록 (모듈화: 스타일시트에서만 지정, 인라인/style 태그 사용 금지) */
    white-space: pre-wrap !important;
}

.ProseMirror p.is-editor-empty:first-child::before {
    content: attr(data-placeholder);
    float: left;
    color: #9ca3af;
    pointer-events: none;
    height: 0;
}

.ProseMirror img {
    max-width: 100%;
    height: auto;
    border-radius: 0;
    margin: 1rem 0;
}

/* 개체(그림·표) 선택 핸들: 상하좌우 작은 사각형 표시 */
.tiptap-node-with-handles {
    position: relative;
    display: inline-block;
}
.tiptap-node-with-handles.tiptap-table-wrapper {
    display: block;
}
.tiptap-node-with-handles .handle {
    display: none;
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: #2563eb;
    border: 1px solid #fff;
    box-sizing: border-box;
    pointer-events: none;
}
.tiptap-node-with-handles.ProseMirror-selectednode .handle,
.tiptap-node-with-handles.tiptap-table-node-selected .handle {
    display: block;
    pointer-events: auto;
    cursor: nwse-resize;
}
/* 표 선택 모드: 블록 선택 없이 핸들만 표시, 드래그 이동용 커서(move). 핸들 클릭 = 보안속성 대상 등 동일 이벤트 */
.tiptap-editor-container.tiptap-table-select-mode .tiptap-table-wrapper .handle {
    display: block !important;
    pointer-events: auto !important;
    cursor: move;
}
.tiptap-editor-container.tiptap-table-select-mode .tiptap-table-wrapper .handle-top,
.tiptap-editor-container.tiptap-table-select-mode .tiptap-table-wrapper .handle-bottom,
.tiptap-editor-container.tiptap-table-select-mode .tiptap-table-wrapper .handle-left,
.tiptap-editor-container.tiptap-table-select-mode .tiptap-table-wrapper .handle-right,
.tiptap-editor-container.tiptap-table-select-mode .tiptap-table-wrapper .handle-topleft,
.tiptap-editor-container.tiptap-table-select-mode .tiptap-table-wrapper .handle-topright,
.tiptap-editor-container.tiptap-table-select-mode .tiptap-table-wrapper .handle-bottomright,
.tiptap-editor-container.tiptap-table-select-mode .tiptap-table-wrapper .handle-bottomleft {
    cursor: move;
}
.tiptap-node-with-handles.tiptap-table-node-selected .handle-top,
.tiptap-node-with-handles.tiptap-table-node-selected .handle-bottom,
.tiptap-node-with-handles.tiptap-table-node-selected .handle-left,
.tiptap-node-with-handles.tiptap-table-node-selected .handle-right,
.tiptap-node-with-handles.tiptap-table-node-selected .handle-topleft,
.tiptap-node-with-handles.tiptap-table-node-selected .handle-topright,
.tiptap-node-with-handles.tiptap-table-node-selected .handle-bottomright,
.tiptap-node-with-handles.tiptap-table-node-selected .handle-bottomleft {
    cursor: move;
}
.tiptap-node-with-handles.ProseMirror-selectednode .handle-top,
.tiptap-node-with-handles.ProseMirror-selectednode .handle-bottom,
.tiptap-node-with-handles.tiptap-table-node-selected .handle-top,
.tiptap-node-with-handles.tiptap-table-node-selected .handle-bottom {
    cursor: ns-resize;
}
.tiptap-node-with-handles.ProseMirror-selectednode .handle-left,
.tiptap-node-with-handles.ProseMirror-selectednode .handle-right,
.tiptap-node-with-handles.tiptap-table-node-selected .handle-left,
.tiptap-node-with-handles.tiptap-table-node-selected .handle-right {
    cursor: ew-resize;
}
.tiptap-node-with-handles.ProseMirror-selectednode .handle-topleft,
.tiptap-node-with-handles.tiptap-table-node-selected .handle-topleft { cursor: nwse-resize; }
.tiptap-node-with-handles.ProseMirror-selectednode .handle-topright,
.tiptap-node-with-handles.tiptap-table-node-selected .handle-topright { cursor: nesw-resize; }
.tiptap-node-with-handles.ProseMirror-selectednode .handle-bottomleft,
.tiptap-node-with-handles.tiptap-table-node-selected .handle-bottomleft { cursor: nesw-resize; }
.tiptap-node-with-handles.ProseMirror-selectednode .handle-bottomright,
.tiptap-node-with-handles.tiptap-table-node-selected .handle-bottomright { cursor: nwse-resize; }
/* 변(상하좌우) 핸들 */
.tiptap-node-with-handles .handle-top {
    top: -5px;
    left: 50%;
    transform: translateX(-50%);
}
.tiptap-node-with-handles .handle-right {
    top: 50%;
    right: -5px;
    transform: translateY(-50%);
}
.tiptap-node-with-handles .handle-bottom {
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
}
.tiptap-node-with-handles .handle-left {
    top: 50%;
    left: -5px;
    transform: translateY(-50%);
}
/* 모서리 핸들 */
.tiptap-node-with-handles .handle-topleft {
    top: -5px;
    left: -5px;
}
.tiptap-node-with-handles .handle-topright {
    top: -5px;
    right: -5px;
}
.tiptap-node-with-handles .handle-bottomright {
    bottom: -5px;
    right: -5px;
}
.tiptap-node-with-handles .handle-bottomleft {
    bottom: -5px;
    left: -5px;
}
.tiptap-image-wrapper {
    display: inline-block;
}
.tiptap-image-wrapper img {
    display: block;
    margin: 0;
}
.tiptap-table-wrapper table {
    margin: 0;
    border-collapse: collapse;
    min-width: 100%;
}
/* 표 자체(노드) 선택 시: 블록/아웃라인 없이 핸들만 표시, 셀·내용은 그대로 보이게 */
.tiptap-table-wrapper.ProseMirror-selectednode,
.tiptap-table-wrapper.tiptap-table-node-selected {
    background: transparent !important;
    outline: none !important;
    box-shadow: none !important;
}
.tiptap-table-wrapper.ProseMirror-selectednode table,
.tiptap-table-wrapper.tiptap-table-node-selected table {
    background: transparent !important;
}

/* 표 드래그 중 ghost 미리보기 (텍스트/그림 드래그처럼 보이게) */
.tiptap-table-drag-ghost {
    position: fixed !important;
    z-index: 10000;
    opacity: 0.92;
    max-width: min(420px, 90vw);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    border-radius: 2px;
    transform: translate(-50%, -50%);
    margin-left: 0;
    margin-top: 0;
}
.tiptap-table-drag-ghost table {
    margin: 0 !important;
}

/* 보안 등급 라벨(왼쪽 상단 바깥) — 텍스트·그림·표 공통 */
.ProseMirror .security-mark::before,
.ProseMirror span[data-security-grade]:not(.security-masked)::before,
.prose-viewer .security-mark::before,
.prose-viewer span[data-security-grade]:not(.security-masked)::before,
.tiptap-image-wrapper[data-security-grade]::before,
.tiptap-table-wrapper[data-security-grade]::before {
    content: attr(data-security-grade-name);
    position: absolute !important;
    top: 0 !important;
    left: -1px !important;
    transform: translateY(-100%) !important;
    font-family: auto !important;
    letter-spacing: normal !important;
    text-decoration: none !important;
    line-height: 1.2 !important;
    padding: 2px !important;
    background: var(--security-grade-color, #6b7280) !important;
    color: #fff !important;
    border-radius: 0 !important;
    white-space: nowrap !important;
    max-width: 140px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    pointer-events: none !important;
}
.ProseMirror .security-mark::before,
.ProseMirror span[data-security-grade]:not(.security-masked)::before,
.prose-viewer .security-mark::before,
.prose-viewer span[data-security-grade]:not(.security-masked)::before {
    font-size: 9px !important;
}
.tiptap-image-wrapper[data-security-grade]::before,
.tiptap-table-wrapper[data-security-grade]::before {
    z-index: 2 !important;
    font-size: 10px !important;
}
.tiptap-image-wrapper[data-security-grade],
.tiptap-table-wrapper[data-security-grade] {
    position: relative !important;
}
/* 보안등급 부여된 표 래퍼: 상하 마진 1rem. 하위 table은 margin 0 (.ProseMirror table 우선 방지) */
.tiptap-table-wrapper[data-security-grade] {
    margin: 1rem 0 !important;
}
.tiptap-table-wrapper[data-security-grade] table,
.ProseMirror .tiptap-table-wrapper[data-security-grade] table,
.prose-viewer .tiptap-table-wrapper[data-security-grade] table {
    margin: 0 !important;
}
/* 이미지/표 보안 테두리 — JS는 --security-grade-color만 설정 */
.tiptap-image-wrapper[data-security-grade-color] {
    border: 1px solid var(--security-grade-color) !important;
}
.tiptap-table-wrapper[data-security-grade-color] {
    border: 1px solid var(--security-grade-color) !important;
}
.prose-viewer .tiptap-image-wrapper[data-security-grade-color] {
    border: 1px solid var(--security-grade-color) !important;
}
.prose-viewer .tiptap-table-wrapper[data-security-grade-color] {
    border: 1px solid var(--security-grade-color) !important;
}

.ProseMirror h1 {
    font-family: 맑은 고딕 !important;
    font-size: 20pt !important;
    font-weight: 700 !important;
    text-align: center;
    text-decoration: underline !important;
    margin-top: 0;
    margin-bottom: 0;
}
/* 사용자가 정렬/굵게/밑줄을 바꾼 경우 우선 */
.ProseMirror h1[data-no-bold] {
    font-weight: 400 !important;
}
.ProseMirror h1[data-no-underline] {
    text-decoration: none !important;
}
/* 제목 1 기본이 중앙이라 TextAlign이 left 스타일을 안 넣을 때 사용 */
.ProseMirror h1[data-align="left"] {
    text-align: left;
}

.ProseMirror h2 {
    font-family: 맑은 고딕 !important;
    font-size: 16pt !important;
    font-weight: 700 !important;
    margin-top: 30pt;
    margin-bottom: 0;
    padding-left: 1.85rem !important;
    position: relative !important;
}

.ProseMirror h2::before {
    content: '□' !important;
    position: absolute !important;
    left: 0 !important;
}

.ProseMirror h3 {
    font-family: 돋움 !important;
    font-size: 15pt !important;
    font-weight: 700 !important;
    margin-top: 0;
    margin-bottom: 0;
}

.ProseMirror p {
    margin-top: 0;
    margin-bottom: 0;
}

/* 본문 2 스타일 */
.ProseMirror p[data-style="paragraph-2"] {
    font-family: 바탕 !important;
    font-size: 15pt !important;
    font-weight: 400 !important;
    margin-top: 15pt;
    margin-bottom: 0;
    padding-left: 1.25rem !important;
    position: relative !important;
}

.ProseMirror p[data-style="paragraph-2"]::before {
    content: 'o' !important;
    position: absolute !important;
    left: 0 !important;
}

/* 본문 3 스타일 */
.ProseMirror p[data-style="paragraph-3"] {
    font-family: 바탕 !important;
    font-size: 15pt !important;
    font-weight: 400 !important;
    margin-top: 15pt;
    margin-bottom: 0;
    padding-left: 2.4rem !important;
    position: relative !important;
}

.ProseMirror p[data-style="paragraph-3"]::before {
    content: '-' !important;
    position: absolute !important;
    left: 1.25rem !important;
}

/* 보필 1 스타일 */
.ProseMirror p[data-style="paragraph-bofil-1"] {
    font-family: 굴림 !important;
    font-size: 12pt !important;
    font-weight: 400 !important;
    margin-top: 5pt;
    margin-bottom: 0;
    padding-left: 2.1rem !important;
    position: relative !important;
}

.ProseMirror p[data-style="paragraph-bofil-1"]::before {
    content: '*' !important;
    position: absolute !important;
    left: 1.25rem !important;
}

/* 보필 2 스타일 */
.ProseMirror p[data-style="paragraph-bofil-2"] {
    font-family: 굴림 !important;
    font-size: 12pt !important;
    font-weight: 400 !important;
    margin-top: 5pt;
    margin-bottom: 0;
    padding-left: 3.35rem !important;
    position: relative !important;
}

.ProseMirror p[data-style="paragraph-bofil-2"]::before {
    content: '*' !important;
    position: absolute !important;
    left: 2.5rem !important;
}

/* 보필 3 스타일 */
.ProseMirror p[data-style="paragraph-bofil-3"] {
    font-family: 궁서 !important;
    font-size: 12pt !important;
    font-weight: 400 !important;
    margin-top: 5pt !important;
    margin-bottom: 0 !important;
    padding-left: 2.1rem !important;
    position: relative !important;
}

.ProseMirror p[data-style="paragraph-bofil-3"]::before {
    content: '*' !important;
    position: absolute !important;
    left: 1.25rem !important;
}

/* 보필 4 스타일 */
.ProseMirror p[data-style="paragraph-bofil-4"] {
    font-family: 궁서 !important;
    font-size: 12pt !important;
    font-weight: 400 !important;
    margin-top: 5pt;
    margin-bottom: 0;
    padding-left: 3.35rem !important;
    position: relative !important;
}

.ProseMirror p[data-style="paragraph-bofil-4"]::before {
    content: '*' !important;
    position: absolute !important;
    left: 2.5rem !important;
}

.ProseMirror ul {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    padding-left: 2rem !important;
    list-style-type: disc !important;
    list-style-position: outside !important;
    list-style: disc outside !important;
}

.ProseMirror ol {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    padding-left: 2rem !important;
    list-style-type: decimal !important;
    list-style-position: outside !important;
    list-style: decimal outside !important;
}

.ProseMirror li {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    display: list-item !important;
    list-style-position: outside !important;
    padding-left: 0.5rem !important;
}

.ProseMirror a {
    color: var(--accent, #A85143);
    text-decoration: underline;
}

.ProseMirror a:hover {
    color: var(--accent-700, #8E4136);
}

.ProseMirror blockquote {
    border-left: 4px solid #d1d5db;
    padding-left: 1rem;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    color: #6b7280;
    font-style: italic;
}

/* 글상자(text edging) — 편집기 내 */
.ProseMirror .tiptap-text-edging {
    display: inline-block !important;
    width: max-content !important;
    max-width: 100% !important;
    padding: 0.25rem 0.5rem !important;
    border: 1px solid var(--tiptap-ink) !important;
    margin: 0.25rem 0 !important;
    box-sizing: border-box !important;
}

/* 표 스타일 */
.ProseMirror table {
    border-collapse: collapse !important;
    margin: 1rem 0 !important;
    width: 100% !important;
    table-layout: auto !important;
}

.ProseMirror table td,
.ProseMirror table th {
    min-width: 1em !important;
    border: 1px solid var(--tiptap-ink) !important;
    padding: 0.5rem !important;
    vertical-align: top !important;
    box-sizing: border-box !important;
    position: relative !important;
}

.ProseMirror table th {
    font-weight: 400 !important;
    text-align: left !important;
    background-color: #f3f4f6 !important;
}

.ProseMirror table th p {
    font-family: 굴림 !important;
    font-size: 12pt !important;
    letter-spacing: 0 !important;
    font-weight: 400 !important;
    margin: 0 !important;
}

.ProseMirror table td p {
    font-family: 굴림 !important;
    font-size: 11pt !important;
    letter-spacing: -0.083em !important;
    font-weight: 400 !important;
    margin: 0 !important;
}

/* 셀 블록 선택: 셀 선택/드래그 시 연한 배경(블록) 표시 */
.ProseMirror table .selectedCell {
    position: relative !important;
}
.ProseMirror table .selectedCell:after {
    position: absolute !important;
    content: "" !important;
    left: 0 !important;
    right: 0 !important;
    top: 0 !important;
    bottom: 0 !important;
    background: var(--accent-50, rgba(249, 239, 235, 0.25)) !important;
    pointer-events: none !important;
    z-index: 0 !important;
}
.ProseMirror table .selectedCell > * {
    position: relative !important;
    z-index: 1 !important;
}

.ProseMirror table .column-resize-handle {
    position: absolute !important;
    right: -2px !important;
    top: 0 !important;
    bottom: -2px !important;
    width: 4px !important;
    background-color: var(--accent, #A85143) !important;
    pointer-events: none !important;
}

/* 표 메뉴 래퍼 (마지막 tiptap-toolbar-row 아래) */
.tiptap-table-menu-wrapper {
    width: 100% !important;
    padding: 0.5rem 0 0 0 !important;
    background-color: #f9fafb !important;
    border-top: 1px solid #d1d5db !important;
}

/* 표 삽입 모달 */
.tiptap-table-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background-color: rgba(0, 0, 0, 0.5) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 1000 !important;
}

.tiptap-table-modal-content {
    background-color: white !important;
    padding: 1.5rem !important;
    border-radius: 0.5rem !important;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05) !important;
    min-width: 300px !important;
    max-width: 400px !important;
}

/* 툴바 */
.tiptap-toolbar {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.5rem !important;
    padding: 0.75rem !important;
    border: none !important;
    border-bottom: 1px solid #d1d5db !important;
    border-radius: 0 !important;
    background-color: #f9fafb !important;
    margin: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

.tiptap-toolbar-row {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 0.35rem !important;
    width: 100% !important;
}

.tiptap-toolbar button {
    padding: 0.375rem 0.5rem !important;
    border: 1px solid #d1d5db !important;
    background-color: white !important;
    border-radius: 0.375rem !important;
    cursor: pointer !important;
    font-size: 0.75rem !important;
    font-weight: 500 !important;
    transition: all 0.2s !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 2rem !important;
    height: 2rem !important;
    color: #374151 !important;
    white-space: nowrap !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    font-family: inherit !important;
    gap: 0.25rem !important;
}

.tiptap-toolbar button svg {
    width: 14px !important;
    height: 14px !important;
    flex-shrink: 0 !important;
}

.tiptap-toolbar button .button-text {
    font-size: 0.75rem !important;
}

.tiptap-toolbar button:hover {
    background-color: #f3f4f6 !important;
    border-color: #9ca3af !important;
}

.tiptap-toolbar button.is-active {
    background-color: var(--accent, #A85143) !important;
    color: white !important;
    border-color: var(--accent, #A85143) !important;
}

.tiptap-toolbar button:active {
    transform: scale(0.98);
}

.tiptap-toolbar .toolbar-divider {
    width: 1px !important;
    background-color: #d1d5db !important;
    margin: 0 0.15rem !important;
    height: 1.5rem !important;
    align-self: center !important;
    flex-shrink: 0 !important;
}

.tiptap-toolbar-select {
    padding: 0.375rem 0.5rem !important;
    border: 1px solid #d1d5db !important;
    background-color: white !important;
    border-radius: 0.375rem !important;
    font-size: 0.75rem !important;
    font-weight: 500 !important;
    color: #374151 !important;
    min-width: 2rem !important;
    height: 2rem !important;
    cursor: pointer !important;
    margin: 0 !important;
    box-sizing: border-box !important;
}

.tiptap-toolbar-select:hover {
    background-color: #f3f4f6 !important;
    border-color: #9ca3af !important;
}

.tiptap-toolbar-select:focus {
    outline: none !important;
    border-color: var(--accent, #A85143) !important;
    box-shadow: 0 0 0 2px var(--accent-50, rgba(168, 81, 67, 0.1)) !important;
}

/* 색상 선택기 스타일 */
.tiptap-color-picker-wrapper {
    position: relative !important;
    display: inline-block !important;
}

.tiptap-color-button {
    padding: 0.375rem 0.5rem !important;
    border: 1px solid #d1d5db !important;
    background-color: white !important;
    border-radius: 0.375rem !important;
    cursor: pointer !important;
    font-size: 0.75rem !important;
    font-weight: 500 !important;
    transition: all 0.2s !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 2rem !important;
    height: 2rem !important;
    color: #374151 !important;
    white-space: nowrap !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    font-family: inherit !important;
    gap: 0.25rem !important;
}

.tiptap-color-button:hover {
    background-color: #f3f4f6 !important;
    border-color: #9ca3af !important;
}

.tiptap-color-button.is-active {
    background-color: var(--accent, #A85143) !important;
    color: white !important;
    border-color: var(--accent, #A85143) !important;
}

.tiptap-color-dropdown {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    margin-top: 0.25rem !important;
    background-color: white !important;
    border: 1px solid #d1d5db !important;
    border-radius: 0.375rem !important;
    padding: 0.5rem !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06) !important;
    z-index: 1000 !important;
    min-width: 120px !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
}

.tiptap-color-item {
    display: flex !important;
    align-items: center !important;
    padding: 0.375rem 0.5rem !important;
    cursor: pointer !important;
    border-radius: 0.25rem !important;
    margin-bottom: 0.25rem !important;
    transition: background-color 0.15s !important;
}

.tiptap-color-item:last-child {
    margin-bottom: 0 !important;
}

.tiptap-color-item:hover {
    background-color: #f3f4f6 !important;
}

.tiptap-color-item.active {
    background-color: var(--accent-50, #F9EFEB) !important;
    border: 1px solid var(--accent, #A85143) !important;
}

.tiptap-color-item .color-box {
    width: 20px !important;
    height: 20px !important;
    border-radius: 0.25rem !important;
    border: 1px solid #d1d5db !important;
    margin-right: 0.5rem !important;
    flex-shrink: 0 !important;
}

.tiptap-color-item .color-label {
    font-size: 0.75rem !important;
    color: #374151 !important;
}

/* 보안속성 드롭다운 (컬러 드롭다운과 구별) */
.tiptap-security-picker-wrapper {
    position: relative !important;
    display: inline-block !important;
}

.tiptap-security-button {
    padding: 0.375rem 0.5rem !important;
    border: 1px solid #d1d5db !important;
    background-color: white !important;
    border-radius: 0.375rem !important;
    cursor: pointer !important;
    font-size: 0.75rem !important;
    font-weight: 500 !important;
    transition: all 0.2s !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 2rem !important;
    height: 2rem !important;
    color: #374151 !important;
    white-space: nowrap !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    font-family: inherit !important;
    gap: 0.25rem !important;
}

.tiptap-security-button:hover {
    background-color: #f3f4f6 !important;
    border-color: #9ca3af !important;
}

.tiptap-security-button.is-active {
    background-color: #E5E7EB !important;
    color: #1F2937 !important;
    border-color: #6B7280 !important;
}

.tiptap-security-info-button {
    padding: 0.375rem 0.5rem !important;
    border: 1px solid #d1d5db !important;
    background-color: white !important;
    border-radius: 0.375rem !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 2rem !important;
    height: 2rem !important;
    color: #374151 !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    gap: 0.25rem !important;
}
.tiptap-security-info-button:hover {
    background-color: #f3f4f6 !important;
    border-color: #9ca3af !important;
}
.tiptap-security-info-button .tiptap-security-info-label {
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 80px;
}

.tiptap-security-count-link:hover {
    color: #1d4ed8 !important;
}

.tiptap-security-dropdown {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    margin-top: 0.25rem !important;
    background-color: white !important;
    border: 1px solid #d1d5db !important;
    border-radius: 0.375rem !important;
    padding: 0.5rem !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06) !important;
    z-index: 1000 !important;
    min-width: 140px !important;
    max-height: 280px !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
}

.tiptap-security-item {
    display: flex !important;
    align-items: center !important;
    padding: 0.375rem 0.5rem !important;
    cursor: pointer !important;
    border-radius: 0.25rem !important;
    margin-bottom: 0.25rem !important;
    transition: background-color 0.15s !important;
    white-space: nowrap !important;
}

.tiptap-security-item:last-child {
    margin-bottom: 0 !important;
}

.tiptap-security-item:hover {
    background-color: #f3f4f6 !important;
}

.tiptap-security-item.active {
    background-color: #E5E7EB !important;
    border: 1px solid #6B7280 !important;
}

.tiptap-security-item .security-grade-chip {
    width: 16px !important;
    height: 16px !important;
    border-radius: 0.2rem !important;
    border: 1px solid #d1d5db !important;
    margin-right: 0.5rem !important;
    flex-shrink: 0 !important;
}

.tiptap-security-item .security-item-label {
    font-size: 0.75rem !important;
    color: #374151 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

/* 편집기·렌더링(뷰어) 공통: 보안 마크 — 드림위버 스타일(테두리 + 왼쪽 상단 바깥 라벨). 라운딩 없음. security-masked는 제외 */
.ProseMirror .security-mark,
.ProseMirror span[data-security-grade]:not(.security-masked),
.prose-viewer .security-mark,
.prose-viewer span[data-security-grade]:not(.security-masked) {
    position: relative !important;
    padding: 2px !important;
    margin: -2px !important;
    border-radius: 0 !important;
}
/* 등급 색상이 있으면 배경·테두리는 CSS 변수로 통일 (인라인은 --security-grade-color만 설정) */
.ProseMirror .security-mark[data-security-grade-color],
.ProseMirror span[data-security-grade][data-security-grade-color]:not(.security-masked),
.prose-viewer .security-mark[data-security-grade-color],
.prose-viewer span[data-security-grade][data-security-grade-color]:not(.security-masked) {
    background-color: color-mix(in srgb, var(--security-grade-color) 20%, transparent) !important;
    border: 1px solid var(--security-grade-color) !important;
}
/* 등급명 없으면 "보안" 표시 */
.ProseMirror .security-mark:not([data-security-grade-name])::before,
.ProseMirror span[data-security-grade]:not([data-security-grade-name]):not(.security-masked)::before,
.prose-viewer .security-mark:not([data-security-grade-name])::before,
.prose-viewer span[data-security-grade]:not([data-security-grade-name]):not(.security-masked)::before {
    content: '보안';
}

/* 접근 권한 없음 마스킹 (서버/클라이언트 마스킹 공통) */
.ProseMirror .security-masked,
.prose-viewer .security-masked {
    display: inline-block;
    margin: -2px 2px !important;
    background: repeating-linear-gradient(
        45deg,
        #f3f4f6,
        #f3f4f6 4px,
        #e5e7eb 4px,
        #e5e7eb 8px
    );
    color: #6b7280;
    padding: 2px;
    border-radius: 4px;
    font-size: 80%;
    font-weight: 500;
    cursor: not-allowed;
    user-select: none;
}
.ProseMirror .security-masked::before,
.prose-viewer .security-masked::before {
    content: '🔒';
}
.ProseMirror .security-masked[data-security-grade-color],
.prose-viewer .security-masked[data-security-grade-color] {
    border-left: 3px solid var(--mask-color, #9ca3af);
}

/* 특수문자/이모지 선택기 스타일 */
.tiptap-char-item,
.tiptap-emoji-item {
    padding: 0.5rem !important;
    border: 1px solid #d1d5db !important;
    border-radius: 0.25rem !important;
    background-color: white !important;
    cursor: pointer !important;
    transition: all 0.15s !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.tiptap-char-item {
    font-size: 1rem !important;
}

.tiptap-emoji-item {
    font-size: 1.25rem !important;
}

.tiptap-char-item:hover,
.tiptap-emoji-item:hover {
    background-color: #f3f4f6 !important;
    border-color: #9ca3af !important;
    transform: scale(1.1) !important;
}

/* 모바일 친화적 스타일 */
@media (max-width: 640px) {
    /* 외부 컨테이너 패딩 조정 (편집기 콘텐츠 표시 영역) */
    /* 뷰어(prose-viewer) 또는 편집기 콘텐츠를 포함하는 컨테이너 */
    div.bg-white.border.border-gray-200.rounded-lg.p-6 {
        padding: 1rem !important; /* p-4 = 1rem */
    }
    
    /* 뷰어(안내문/서식 본문) 모바일 zoom */
    .prose-viewer {
        zoom: 0.8;
    }
    
    .tiptap-toolbar {
        padding: 0.5rem !important;
        gap: 0.375rem !important;
    }
    
    .tiptap-toolbar button {
        padding: 0.375rem !important;
        min-width: 1.75rem !important;
        height: 1.75rem !important;
    }
    
    .tiptap-toolbar button .button-text {
        display: none !important;
    }
    
    .tiptap-toolbar-select {
        padding: 0.375rem !important;
        min-width: 1.75rem !important;
        height: 1.75rem !important;
        font-size: 0.7rem !important;
    }
    
    .ProseMirror {
        min-height: 300px;
        padding: 0.75rem;
    }
}
