/* 위키 보기 / 편집 — main.css 변수·테마 스크롤바 참조 */

:root {
    --wiki-prose-size: 13px;
    --wiki-prose-line: 1.65;
    --wiki-prose-p-margin-bottom: 0.75em;
    --wiki-prose-heading-margin: 1em 0 0.5em;
    --wiki-prose-list-margin: 0.5em 0 0.75em 1.25em;
    --wiki-prose-padding: 1.5rem 1.25rem;
    /* 링크 앞 아이콘 — Layer_45(24×24) 두 path, 세로 반전은 g transform. 마스크용 fill 검정. 푸터 Icons8 출처 */
    --wiki-link-icon-mask: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20preserveAspectRatio%3D%22xMidYMid%20meet%22%3E%3Cg%20transform%3D%22translate(0%2024)%20scale(1%20-1)%22%3E%3Cpath%20fill%3D%22black%22%20d%3D%22M14.12988%2C15.50342l-1.41406-1.415%2C1.42383-1.42285a2.02108%2C2.02108%2C0%2C0%2C0%2C0-2.855L9.87012%2C5.541a2.06778%2C2.06778%2C0%2C0%2C0-2.85547%2C0L5.59082%2C6.96436a2.02108%2C2.02108%2C0%2C0%2C0%2C0%2C2.855L4.17676%2C11.2334a4.02212%2C4.02212%2C0%2C0%2C1%2C0-5.68311L5.60059%2C4.127a4.01858%2C4.01858%2C0%2C0%2C1%2C5.68359%2C0l4.26953%2C4.26953a4.02449%2C4.02449%2C0%2C0%2C1%2C0%2C5.68359Z%22%2F%3E%3Cpath%20fill%3D%22black%22%20d%3D%22M15.55762%2C20.94971a3.99349%2C3.99349%2C0%2C0%2C1-2.8418-1.17725L8.44629%2C15.50293a4.02449%2C4.02449%2C0%2C0%2C1%2C0-5.68359L9.87012%2C8.396l1.41406%2C1.415L9.86035%2C11.23389a2.02108%2C2.02108%2C0%2C0%2C0%2C0%2C2.855l4.26953%2C4.26953a2.06778%2C2.06778%2C0%2C0%2C0%2C2.85547%2C0l1.42383-1.42334a2.02108%2C2.02108%2C0%2C0%2C0%2C0-2.855L19.82324%2C12.666a4.02449%2C4.02449%2C0%2C0%2C1%2C0%2C5.68359l-1.42383%2C1.42334A3.9917%2C3.9917%2C0%2C0%2C1%2C15.55762%2C20.94971Z%22%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E");
}

.wiki-page {
    flex: 1;
    width: 100%;
    max-width: 1200px;
    max-height: 900px;
    margin: 0 auto;
    padding: 2rem 1.25rem 3rem;
    z-index: 1;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    min-height: 0;
}

.wiki-content-meta-row {
    display: grid;
    grid-template-columns: 2fr 8fr;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    margin-bottom: 0.55rem;
    flex-shrink: 0;
}

.wiki-content-meta-toc {
    min-width: 0;
}

.wiki-content-meta-main {
    grid-column: 2;
    min-width: 0;
    width: 100%;
    display: flex;
    align-items: baseline;
    justify-content: flex-start;
    gap: 0.75rem;
}

.wiki-header-lead {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    gap: 0.65rem;
    min-width: 0;
    flex: 0 1 auto;
}

.wiki-header-title {
    font-family: var(--font-header);
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
    color: var(--text);
}

.wiki-header-date {
    margin: 0;
    font-family: var(--font-main);
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.92);
    text-align: left;
}

.wiki-header-actions {
    flex-shrink: 0;
    margin-left: auto;
}

.wiki-header-actions .wiki-edit-link[hidden] {
    display: none !important;
}

/* 목차(좌) + 본문(우) */
.wiki-content-row {
    display: grid;
    grid-template-columns: 2fr 8fr;
    align-items: stretch;
    gap: 0.75rem;
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    box-sizing: border-box;
}

.wiki-btn {
    display: flex;
    font-family: var(--font-main);
    font-size: 0.95rem;
    padding: 0.5rem 1rem;
    cursor: pointer;
    color: var(--text);
    background: var(--card-bg);
    border: 2px solid var(--border);
    text-decoration: none;
    transition: border-color 0.2s ease, color 0.2s ease;
}

.wiki-btn:hover {
    border-color: var(--secondary);
    color: var(--secondary);
}

/* main.css .btn-primary / .btn-secondary 와 동일 (wiki-btn 가 덮어쓰지 않도록) */
.wiki-btn.btn-primary {
    background: var(--secondary);
    color: #fff;
    border: 2px solid var(--secondary);
}

.wiki-btn.btn-primary:hover {
    filter: brightness(1.05);
    border-color: var(--secondary);
    color: #fff;
}

.wiki-btn.btn-secondary {
    background: #fff;
    color: var(--fgb-dark);
    border: 2px solid var(--secondary);
}

.wiki-btn.btn-secondary:hover {
    color: var(--secondary);
    border-color: var(--secondary);
}

.wiki-header-actions .wiki-edit-link:hover {
    color: var(--fgb-dark);
    border-color: var(--fgb-dark);
}

.wiki-body {
    grid-column: 2;
    min-width: 0;
    width: 100%;
    height: 100%;
    min-height: 0;
    max-height: 600px;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
    font-family: var(--font-main);
    font-size: var(--wiki-prose-size);
    line-height: var(--wiki-prose-line);
    color: var(--fgb-dark);
    background: white;
    border: 2px solid var(--border);
    border-radius: 6px;
    padding: var(--wiki-prose-padding);
    box-sizing: border-box;
}

.wiki-body h1[id],
.wiki-body h2[id],
.wiki-body h3[id] {
    scroll-margin-top: 0.5rem;
}

.wiki-body blockquote {
    margin: 0.75em 0;
    padding: 0.65em 0 0.65em 1rem;
    border-left: 3px solid rgba(8, 24, 73, 0.25);
    background: rgba(8, 24, 73, 0.04);
}

.wiki-body blockquote p {
    margin: 0;
}

/* 본문 타이포 — 보기·Quill·TipTap 공통 */
.wiki-body p,
#editor .ql-editor p,
#editor .ProseMirror p {
    margin: 0 0 var(--wiki-prose-p-margin-bottom);
}

/* 에디터 엔터로 생긴 빈 단락이 뷰어에서 높이 0으로 사라지지 않게 */
.wiki-body p:empty,
article.wiki-body.ql-editor p:empty,
.wiki-body p:has(> br:only-child),
article.wiki-body.ql-editor p:has(> br:only-child) {
    min-height: calc(var(--wiki-prose-size) * var(--wiki-prose-line));
}

.wiki-body h1,
.wiki-body h2,
.wiki-body h3,
#editor .ql-editor h1,
#editor .ql-editor h2,
#editor .ql-editor h3,
#editor .ProseMirror h1,
#editor .ProseMirror h2,
#editor .ProseMirror h3 {
    font-family: var(--font-header);
    margin: var(--wiki-prose-heading-margin);
    font-weight: 600;
}

.wiki-body ul,
.wiki-body ol,
#editor .ql-editor ul,
#editor .ql-editor ol,
#editor .ProseMirror ul,
#editor .ProseMirror ol {
    margin: var(--wiki-prose-list-margin);
    /* 보기(Quill HTML)와 동일 — quill.snow의 ol 1.5em·ul 0 대신 통일 */
    padding-left: 1.25em;
}

/* TipTap li — Quill `.ql-editor li`(padding-left 1.5em)와 동일해 보기·편집 depth 일치 */
#editor .ProseMirror li {
    padding-left: 1.5em;
    position: relative;
}

/* TipTap에 로드된 Quill HTML — li.ql-indent N (quill.snow와 동일 수치) */
#editor .ProseMirror li.ql-indent-1:not(.ql-direction-rtl) {
    padding-left: 4.5em;
}
#editor .ProseMirror li.ql-indent-2:not(.ql-direction-rtl) {
    padding-left: 7.5em;
}
#editor .ProseMirror li.ql-indent-3:not(.ql-direction-rtl) {
    padding-left: 10.5em;
}
#editor .ProseMirror li.ql-indent-4:not(.ql-direction-rtl) {
    padding-left: 13.5em;
}
#editor .ProseMirror li.ql-indent-5:not(.ql-direction-rtl) {
    padding-left: 16.5em;
}
#editor .ProseMirror li.ql-indent-6:not(.ql-direction-rtl) {
    padding-left: 19.5em;
}
#editor .ProseMirror li.ql-indent-7:not(.ql-direction-rtl) {
    padding-left: 22.5em;
}
#editor .ProseMirror li.ql-indent-8:not(.ql-direction-rtl) {
    padding-left: 25.5em;
}
#editor .ProseMirror li.ql-indent-9:not(.ql-direction-rtl) {
    padding-left: 28.5em;
}

#editor .ql-editor blockquote,
#editor .ProseMirror blockquote {
    margin: 0.75em 0;
    padding: 0.65em 0 0.65em 1rem;
    border-left: 3px solid rgba(8, 24, 73, 0.25);
    background: rgba(8, 24, 73, 0.04);
}

#editor .ql-editor blockquote p,
#editor .ProseMirror blockquote p {
    margin: 0;
}

.wiki-body a {
    color: var(--secondary);
    word-break: break-word;
}

/* 링크 앞 연결 아이콘 — 본문·편집기 공통 (글자 링크만; 이미지 전용 링크는 제외) */
.wiki-body a[href]::before,
#editor .tiptap a[href]::before,
#editor .ProseMirror a[href]::before,
#editor .ql-editor a[href]::before {
    content: '';
    display: inline-block;
    width: 0.88em;
    height: 0.88em;
    margin-right: 0.3em;
    vertical-align: -0.12em;
    background-color: currentColor;
    opacity: 0.92;
    -webkit-mask-image: var(--wiki-link-icon-mask);
    mask-image: var(--wiki-link-icon-mask);
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
}

.wiki-body a[href]:has(> img:only-child)::before,
#editor .tiptap a[href]:has(> img:only-child)::before,
#editor .ProseMirror a[href]:has(> img:only-child)::before,
#editor .ql-editor a[href]:has(> img:only-child)::before {
    content: none;
    display: none;
}

/* 링크 호버 URL 툴팁 — JS(initLinkTooltip)가 생성한 .wiki-link-tip 의 스타일 */
.wiki-link-tip {
    position: fixed;
    z-index: 9999;
    max-width: 320px;
    padding: 4px 9px;
    background: rgba(24, 24, 28, 0.93);
    color: #e8e8ec;
    font-size: 11px;
    font-family: ui-monospace, 'SFMono-Regular', Consolas, monospace;
    font-weight: 400;
    line-height: 1.5;
    word-break: break-all;
    border-radius: 5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.28);
    pointer-events: none;
    white-space: pre-wrap;
}

.wiki-body img {
    max-width: 100%;
    height: auto;
}

/*
 * 보기 전용: 본문에 .ql-editor + quill.snow.css — Quill이 저장하는 ol/li[data-list]·ql-indent·.ql-ui 마커와 동일하게 표시.
 * 편집 화면과 달리 예전에 snow.css 가 없어 숫자 목록만 보이던 문제 해결.
 */
article.wiki-body.ql-editor {
    box-sizing: border-box;
    height: auto;
    min-height: 0;
    max-height: 600px;
    overflow: auto;
    outline: none;
    counter-reset: list-0 list-1 list-2 list-3 list-4 list-5 list-6 list-7 list-8 list-9;
    font-family: var(--font-main);
    font-size: var(--wiki-prose-size);
    line-height: var(--wiki-prose-line);
    color: var(--fgb-dark);
    background: #fff;
    padding: var(--wiki-prose-padding);
    white-space: normal;
    word-wrap: break-word;
    tab-size: 4;
}

article.wiki-body.ql-editor > * {
    cursor: auto;
}

/* Quill 기본은 p·제목 margin 0 — 위키 단락·제목 간격 유지 */
article.wiki-body.ql-editor p {
    margin: 0 0 var(--wiki-prose-p-margin-bottom);
}

article.wiki-body.ql-editor h1,
article.wiki-body.ql-editor h2,
article.wiki-body.ql-editor h3 {
    font-family: var(--font-header);
    margin: var(--wiki-prose-heading-margin);
    font-weight: 600;
}

article.wiki-body.ql-editor blockquote {
    margin: 0.75em 0;
    padding: 0.65em 0 0.65em 1rem;
    border-left: 3px solid rgba(8, 24, 73, 0.25);
    background: rgba(8, 24, 73, 0.04);
}

article.wiki-body.ql-editor blockquote p {
    margin: 0;
}

article.wiki-body.ql-editor ul {
    list-style-type: disc !important;
}

article.wiki-body.ql-editor ol {
    list-style-type: decimal !important;
}

article.wiki-body.ql-editor li {
    display: list-item !important;
    list-style-position: outside !important;
    list-style-image: none !important;
}

article.wiki-body.ql-editor ul > li {
    list-style-type: disc !important;
}

article.wiki-body.ql-editor ol > li {
    list-style-type: decimal !important;
}

/* .ql-ui 없이 저장된 구간 호환(숫자만 나오는 경우) */
article.wiki-body.ql-editor ol > li[data-list='bullet'] {
    list-style-type: disc;
}

article.wiki-body.ql-editor ol > li[data-list='ordered'] {
    list-style-type: decimal;
}

article.wiki-body.ql-editor li > .ql-ui {
    display: none;
}

#editor .ql-editor img,
#editor .ProseMirror img {
    max-width: 100%;
    height: auto;
    cursor: default;
}

/* 목록 항목 안 이미지: 불릿·번호와의 상하 정렬만 맞춤(들여쓰기·depth 규칙은 그대로) */
.wiki-body li img,
.wiki-body li a > img,
#editor .ProseMirror li img,
#editor .ProseMirror li a > img,
#editor .ql-editor li img,
#editor .ql-editor li a > img {
    vertical-align: middle;
}

.wiki-toc-empty-hint {
    margin: 0.35rem 0 0;
    font-size: 0.8rem;
    color: rgba(8, 24, 73, 0.55);
    line-height: 1.35;
}

/* 자동 목차 — wiki-body 좌측, 가로 2 : 본문 8 */
#wikiTocNav.wiki-toc {
    box-sizing: border-box;
    grid-column: 1;
    min-width: 0;
    height: auto;
    min-height: 96px;
    max-height: 300px;
    align-self: stretch;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 1rem 0.8rem 1rem 1rem;
    background: rgba(255, 255, 255, 0.3);
    border: none;
    border-radius: 0;
    color: var(--fgb-dark);
}

.wiki-toc-title {
    margin: 0 0 0.45em;
    padding-bottom: 0.35em;
    border-bottom: 2px solid var(--fgb-dark);
    font-size: 1.2rem;
    line-height: 1.3;
    word-break: keep-all;
}

.wiki-toc-list {
    margin: 0;
    padding-left: 1rem;
    font-size: 0.9rem;
    line-height: 1.35;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.wiki-toc-list li {
    margin: 0.28em 0;
}

.wiki-toc-list a {
    display: block;
    white-space: normal;
    overflow-wrap: anywhere;
    color: var(--fgb-dark);
    text-decoration: none;
}

.wiki-toc-list a:hover {
    color: var(--fgb-dark);
    text-decoration: underline;
}

/* h2 목차 — h1 항목보다 한 단계 안쪽 */
.wiki-toc-h2 {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 0.35em;
    list-style: none;
    margin-left: 0.85rem;
    padding-left: 0;
}

.wiki-toc-h2::before {
    content: '•';
    flex: 0 0 auto;
    line-height: 1.35;
    font-size: 0.85em;
    color: var(--fgb-dark);
    margin-top: 0.08em;
}

.wiki-toc-h2 > a {
    flex: 1;
    min-width: 0;
}

/* h3 목차 — h2보다 한 단계 더 안쪽 */
.wiki-toc-depth2 {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 0.35em;
    list-style: none;
    margin-left: 1.85rem;
    padding-left: 0;
}

.wiki-toc-depth2::before {
    content: '◦';
    flex: 0 0 auto;
    line-height: 1.35;
    font-size: 0.85em;
    color: var(--fgb-dark);
    margin-top: 0.08em;
}

.wiki-toc-depth2 > a {
    flex: 1;
    min-width: 0;
}

.wiki-empty {
    opacity: 0.75;
    font-style: italic;
}


.wiki-edit-content-row > .wiki-edit-toc-detail-col {
    grid-column: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    gap: 0.5rem;
    align-self: stretch;
}

.wiki-edit-content-row > .wiki-edit-col--editor {
    grid-column: 2;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.wiki-page.wiki-edit-page #wikiTocNav.wiki-toc {
    height: auto;
    max-height: min(40vh, 300px);
    min-height: 96px;
    flex: 1 1 auto;
}

/* 목차 아래 — 표·색 상세 패널만 */
.wiki-toolbar-expand-area {
    margin-top: 0.15rem;
    border: 2px solid var(--border);
    background: #fafbfd;
    border-radius: 6px;
    padding: 0.5rem 0.55rem 0.55rem;
    max-height: min(52vh, 440px);
    overflow-x: hidden;
    overflow-y: auto;
    box-sizing: border-box;
}

.wiki-toolbar-panel {
    margin: 0;
    padding: 0;
}

.wiki-toolbar-panel-title {
    margin: 0 0 0.5rem;
    font-family: var(--font-header);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--fgb-dark);
    text-align: left;
}

.wiki-toolbar-panel-actions {
    margin-top: 0.65rem;
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.65rem;
}

@media (max-width: 640px) {
    .wiki-content-meta-row {
        grid-template-columns: 1fr;
    }

    .wiki-content-meta-toc {
        display: none;
    }

    .wiki-content-meta-main {
        grid-column: 1;
        width: 100%;
    }

    .wiki-content-row {
        grid-template-columns: 1fr;
    }

    #wikiTocNav.wiki-toc {
        grid-column: 1;
        width: 100%;
        max-height: 10rem;
    }

    .wiki-body {
        grid-column: 1;
        width: 100%;
    }

    .wiki-edit-content-row > .wiki-edit-toc-detail-col {
        grid-column: 1;
        width: 100%;
    }

    .wiki-edit-content-row .wiki-edit-col--editor {
        grid-column: 1;
        width: 100%;
    }

    .wiki-toc-list {
        font-size: 0.75rem;
    }

    .wiki-toc-title {
        font-size: 0.82rem;
    }
}

/* 편집 페이지 — wiki-page 대비 상단 여백만 줄임 (툴바 행 공간 확보) */
.wiki-edit-main {
    padding-top: 1rem;
}

.wiki-edit-workspace {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 0.75rem;
    width: 100%;
    flex: 1;
    min-height: 0;
    box-sizing: border-box;
}

.wiki-edit-col--editor {
    flex: 1 1 0%;
    min-width: 0;
    overflow-x: hidden;
    box-sizing: border-box;
}

.wiki-edit-col--diff {
    flex: 0 0 min(380px, 38vw);
    min-width: 260px;
    max-width: 100%;
    box-sizing: border-box;
}

.wiki-edit-sheet {
    width: 100%;
    height: 100%;
    min-height: 0;
    box-sizing: border-box;
}

.wiki-diff-panel {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    height: 100%;
    min-height: 0;
    box-sizing: border-box;
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: 6px;
    padding: 0.85rem 1rem 1rem;
    color: var(--text);
}

.wiki-diff-panel-head {
    flex-shrink: 0;
}

.wiki-diff-panel-title {
    margin: 0 0 0.35rem;
    font-size: 1rem;
    font-family: var(--font-header);
    font-weight: 600;
    color: var(--text);
}

.wiki-diff-panel-sub {
    margin: 0;
    font-size: 0.78rem;
    line-height: 1.45;
    color: rgba(255, 255, 255, 0.88);
}

.wiki-diff-conflict-banner {
    flex-shrink: 0;
    padding: 0.65rem 0.75rem;
    border-radius: 4px;
    background: rgba(220, 80, 60, 0.18);
    border: 1px solid rgba(255, 160, 140, 0.45);
}

.wiki-diff-conflict-banner[hidden] {
    display: none !important;
}

.wiki-diff-conflict-text {
    margin: 0 0 0.55rem;
    font-size: 0.8rem;
    line-height: 1.45;
    color: var(--text);
}

.wiki-diff-apply-btn {
    width: 100%;
    box-sizing: border-box;
    font-size: 0.82rem;
    padding: 0.45rem 0.65rem;
}

.wiki-diff-body {
    flex: 1 1 auto;
    min-height: 200px;
    max-height: 600px;
    overflow: auto;
    box-sizing: border-box;
    padding: 0.65rem 0.75rem;
    font-family: var(--font-main);
    font-size: 0.78rem;
    line-height: 1.55;
    color: var(--fgb-dark);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 4px;
    white-space: pre-wrap;
    word-break: break-word;
}

.wiki-diff-body--empty {
    color: rgba(8, 24, 73, 0.45);
    font-style: italic;
}

.wiki-diff-add {
    background: rgba(46, 160, 67, 0.28);
    border-radius: 2px;
    padding: 0.05em 0.1em;
}

.wiki-diff-del {
    background: rgba(220, 53, 69, 0.28);
    text-decoration: line-through;
    text-decoration-color: rgba(120, 20, 30, 0.85);
    border-radius: 2px;
    padding: 0.05em 0.1em;
}

@media (max-width: 900px) {
    .wiki-edit-col--diff {
        flex: 1 1 auto;
        width: 100%;
        min-width: 0;
    }

    .wiki-diff-body {
        max-height: 320px;
    }
}

/* Quill 툴바 + 저장/취소 한 줄 — 흰 배경, 에디터와 맞닿음 */
.wiki-edit-toolbar-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    box-sizing: border-box;
    background: #fff;
    border: 2px solid var(--border);
    border-bottom: 1px solid var(--fgb-dark);
    padding: 0.4rem 0.65rem 0.4rem 0.5rem;
    border-radius: 6px 6px 0 0;
    position: relative;
    z-index: 20;
}

/* min-width:0 + flex:1 이면 툴바가 가로로 0에 가깝게 눌려 아이콘이 안 보임 */
.wiki-edit-quill-toolbar-wrap {
    flex: 1 1 auto;
    min-width: min-content;
    overflow: visible;
    -webkit-overflow-scrolling: touch;
}

/* TipTap toolbar — 1행(본문) + 2행(표) */
.wiki-tiptap-toolbar-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
    width: 100%;
}

.wiki-tiptap-toolbar {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.wiki-tiptap-toolbar--table {
    padding-top: 0.25rem;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    width: 100%;
    box-sizing: border-box;
}

.wiki-tiptap-toolbar button {
    appearance: none;
    border: 1px solid #c8d0de;
    background: #fff;
    color: var(--fgb-dark);
    border-radius: 4px;
    min-width: 2rem;
    height: 1.9rem;
    padding: 0 0.45rem;
    font-size: 0.82rem;
    line-height: 1;
    cursor: pointer;
}

.wiki-tiptap-toolbar button:hover {
    border-color: var(--fgb-dark);
    color: var(--fgb-dark);
}

.wiki-tiptap-toolbar button.is-active {
    border-color: var(--fgb-dark);
    background: rgba(0, 0, 0, 0.06);
    color: var(--fgb-dark);
}

.wiki-tiptap-toolbar .wiki-tiptap-mark-italic {
    font-style: italic;
}

.wiki-tiptap-toolbar .wiki-tiptap-mark-strike {
    text-decoration: line-through;
}

/* 링크 편집 — 목차 하단 패널 (표시 텍스트 + URL) */
.wiki-link-edit-fields {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.wiki-link-edit-label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    width: 100%;
    text-align: left;
}

.wiki-link-edit-label-text {
    font-family: var(--font-main);
    font-size: 0.82rem;
    color: var(--fgb-dark);
}

.wiki-link-edit-input {
    width: 100%;
    box-sizing: border-box;
    font-family: var(--font-main);
    font-size: 0.95rem;
    padding: 0.45rem 0.55rem;
    color: var(--fgb-dark);
}

.wiki-table-insert-header-label {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
}

.wiki-table-insert-header-label .wiki-link-edit-label-text {
    margin: 0;
}

/* 글자색 / 셀 배경색 — 버튼 + 스와치(1rem) + 라벨 */
.wiki-tiptap-toolbar .wiki-tiptap-color-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    appearance: none;
    border: 1px solid #c8d0de;
    background: #fff;
    color: var(--fgb-dark);
    border-radius: 4px;
    min-height: 1.9rem;
    padding: 0.2rem 0.45rem 0.2rem 0.35rem;
    font-size: inherit;
    line-height: 1;
    cursor: pointer;
    box-sizing: border-box;
}

.wiki-tiptap-toolbar .wiki-tiptap-color-btn:hover {
    border-color: var(--fgb-dark);
}

.wiki-tiptap-toolbar .wiki-tiptap-color-swatch {
    width: 1rem;
    height: 1rem;
    border: 1px solid #c8d0de;
    border-radius: 4px;
    flex-shrink: 0;
    box-sizing: border-box;
    pointer-events: none;
}

.wiki-tiptap-toolbar .wiki-tiptap-color-label {
    font-size: 0.82rem;
    font-family: var(--font-main);
    white-space: nowrap;
    pointer-events: none;
}

/* 글자색·셀 배경색 모달 */
.wiki-color-pick-body {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    text-align: left;
}

.wiki-color-pick-palette-block {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.wiki-color-pick-block-title {
    font-family: var(--font-main);
    font-size: 0.82rem;
    color: var(--fgb-dark);
}

.wiki-color-pick-preset {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
}

.wiki-color-pick-preset-swatch {
    width: 1.25rem;
    height: 1.25rem;
    padding: 0;
    border: 1px solid #c8d0de;
    border-radius: 3px;
    cursor: pointer;
    box-sizing: border-box;
    flex-shrink: 0;
}

.wiki-color-pick-preset-swatch:hover {
    border-color: var(--fgb-dark);
}

.wiki-color-pick-native-label {
    margin: 0;
}

.wiki-color-pick-input {
    width: 100%;
    max-width: 100%;
    height: 2.25rem;
    padding: 0;
    border: 1px solid #c8d0de;
    border-radius: 4px;
    cursor: pointer;
    box-sizing: border-box;
    background: #fff;
}

.wiki-color-pick-recent-block {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.wiki-color-pick-recent-title {
    font-family: var(--font-main);
    font-size: 0.82rem;
    color: var(--fgb-dark);
}

.wiki-color-pick-recent {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    min-height: 1.75rem;
}

.wiki-color-pick-recent-swatch {
    width: 1.5rem;
    height: 1.5rem;
    padding: 0;
    border: 1px solid #c8d0de;
    border-radius: 4px;
    cursor: pointer;
    box-sizing: border-box;
    flex-shrink: 0;
}

.wiki-color-pick-recent-swatch:hover {
    border-color: var(--fgb-dark);
}

.wiki-color-pick-recent-empty {
    margin: 0;
    font-family: var(--font-main);
    font-size: 0.8rem;
    color: rgba(8, 24, 73, 0.55);
}

/* TipTap 표 — 편집·보기 공통 */
#editor .tiptap table,
#editor .ProseMirror table,
.wiki-body table {
    border-collapse: collapse;
    table-layout: auto;
    width: 100%;
    margin: 0.5em 0;
    font-size: inherit;
}

#editor .tiptap th,
#editor .tiptap td,
#editor .ProseMirror th,
#editor .ProseMirror td,
.wiki-body th,
.wiki-body td {
    border: 1px solid rgba(8, 24, 73, 0.35);
    padding: 0.5em;
    vertical-align: middle;
}

#editor .tiptap th,
#editor .ProseMirror th,
.wiki-body th {
    background: rgba(8, 24, 73, 0.06);
    font-weight: 600;
}

/* 셀 안 단락·목록 여백 제거 — 수직 중앙정렬이 패딩과 어긋나지 않도록 */
#editor .tiptap td p,       #editor .tiptap th p,
#editor .ProseMirror td p,  #editor .ProseMirror th p,
.wiki-body td p,             .wiki-body th p,
article.wiki-body.ql-editor td p,
article.wiki-body.ql-editor th p {
    margin-bottom: 0;
}

#editor .tiptap td ul,      #editor .tiptap td ol,
#editor .tiptap th ul,      #editor .tiptap th ol,
#editor .ProseMirror td ul, #editor .ProseMirror td ol,
#editor .ProseMirror th ul, #editor .ProseMirror th ol,
.wiki-body td ul,            .wiki-body td ol,
.wiki-body th ul,            .wiki-body th ol,
article.wiki-body.ql-editor td ul,
article.wiki-body.ql-editor td ol,
article.wiki-body.ql-editor th ul,
article.wiki-body.ql-editor th ol {
    margin-top: 0;
    margin-bottom: 0;
}

/* TipTap / ProseMirror — 표 열 너비 수동 조절(드래그 핸들) */
#editor .ProseMirror .tableWrapper {
    position: relative;
    overflow-x: hidden;
    overflow-y: visible;
    max-width: 100%;
}

/* 표가 에디터 영역을 벗어나지 못하도록 외부 래퍼 제한
   wiki-table-wrap 은 contentDOM — overflow 변경 시 Chrome IME 이중입력 재발 가능성 있으므로 제외 */
#editor .ProseMirror .wiki-table-outer-wrap {
    max-width: 100%;
}

/* column-resize-handle 가 각 셀 우측 경계 기준으로 위치하도록
   td/th 를 containing block 으로 지정 */
#editor .ProseMirror td,
#editor .ProseMirror th {
    position: relative;
}

#editor .ProseMirror .tableWrapper table {
    table-layout: fixed;
    max-width: 100%;
}

/* 보기 페이지 — 편집기와 동일하게 fixed 레이아웃 적용 (열 너비 일치) */
.wiki-body .wiki-table-wrap table,
article.wiki-body.ql-editor .wiki-table-wrap table {
    table-layout: fixed;
}

#editor .ProseMirror .column-resize-handle {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 4px;
    background: transparent;
    pointer-events: none;
}

/* 드래그 중(resize-cursor 상태)일 때만 핸들을 표시 */
#editor .ProseMirror.resize-cursor .column-resize-handle {
    background: rgba(59, 130, 246, 0.45);
}

#editor .ProseMirror.resize-cursor {
    cursor: col-resize;
}

/* 표 행 높이(에디터에서 드래그로 rowHeight 저장) */
#editor .ProseMirror td[data-wiki-row-height],
#editor .ProseMirror th[data-wiki-row-height] {
    box-sizing: border-box;
}

.wiki-body td[data-wiki-row-height],
.wiki-body th[data-wiki-row-height] {
    box-sizing: border-box;
}

/* 표 전체 너비(저장 시 inline style 병행 — 없으면 기본 100%) */
.wiki-body table[data-wiki-table-width],
#editor .ProseMirror table[data-wiki-table-width] {
    box-sizing: border-box;
}

/* 보기 전용(Quill snow.css가 table/td를 덮어씀) — 에디터 표와 동일 스타일로 강제 */
article.wiki-body.ql-editor table {
    border-collapse: collapse;
    table-layout: auto;
    width: 100%;
    margin: 0.5em 0;
    font-size: inherit;
}

article.wiki-body.ql-editor th,
article.wiki-body.ql-editor td {
    border: 1px solid rgba(8, 24, 73, 0.35);
    padding: 0.5em;
    vertical-align: middle;
}

article.wiki-body.ql-editor th {
    background: rgba(8, 24, 73, 0.06);
    font-weight: 600;
}

#editor .tiptap a,
#editor .ProseMirror a {
    color: var(--secondary);
    text-decoration: underline;
    cursor: pointer;
}

.wiki-edit-actions {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.5rem;
    flex-shrink: 0;
    margin-left: auto;
    align-items: center;
}

.wiki-connection-status {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    margin-right: 0.5rem;
}

.wiki-connection-status.status-connected {
    background: rgba(72, 187, 120, 0.2);
    color: #48bb78;
}

.wiki-connection-status.status-connecting {
    background: rgba(237, 137, 54, 0.2);
    color: #ed8936;
}

.wiki-connection-status.status-disconnected,
.wiki-connection-status.status-error {
    background: rgba(245, 101, 101, 0.2);
    color: #f56565;
}

#editor {
    height: 600px;
    min-height: 600px;
    max-height: 600px;
    background: white;
    border: 2px solid var(--border);
    border-top: none;
    border-radius: 0 0 6px 6px;
    color: var(--text);
    overflow: hidden;
    position: relative;
    z-index: 1;
}

.wiki-editor-loading,
.wiki-editor-error {
    box-sizing: border-box;
    min-height: 600px;
    padding: 1rem 1.1rem;
    color: var(--text);
    font-family: var(--font-main);
}

.wiki-editor-loading {
    margin: 0;
}

.wiki-editor-error {
    font-size: 0.9rem;
    line-height: 1.5;
}

.wiki-editor-error pre.wiki-editor-error-detail {
    margin-top: 0.75rem;
    padding: 0.65rem;
    font-size: 0.75rem;
    white-space: pre-wrap;
    word-break: break-all;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border);
    border-radius: 4px;
}

/* TipTap / ProseMirror */
#editor .tiptap,
#editor .ProseMirror {
    outline: none;
    height: 600px;
    min-height: 600px;
    max-height: 600px;
    box-sizing: border-box;
    overflow-x: hidden;
    overflow-y: auto;
    padding: var(--wiki-prose-padding);
    font-family: var(--font-main);
    font-size: var(--wiki-prose-size);
    line-height: var(--wiki-prose-line);
    color: var(--fgb-dark);
    caret-color: var(--fgb-dark);
}

/* Gapcursor — 이미지 등 atom 노드 인접 위치의 커서
   기본값은 border-top:1px solid black 가로선이라 거의 안 보임.
   세로 텍스트 커서처럼 보이도록 재정의. */
@keyframes ProseMirror-cursor-blink {
    to { visibility: hidden; }
}

#editor .ProseMirror-gapcursor {
    display: none;
    pointer-events: none;
    position: absolute;
}

#editor .ProseMirror.ProseMirror-focused .ProseMirror-gapcursor {
    display: block;
}

#editor .ProseMirror-gapcursor::after {
    content: '';
    display: block;
    position: absolute;
    top: 0;
    width: 2px;
    height: 1.4em;
    background: #000;
    border: none;
    border-radius: 1px;
    animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
}

/* TipTap collaboration cursor */
#editor .collaboration-cursor__caret {
    position: relative;
    margin-left: -1px;
    margin-right: -1px;
    border-left: 2px solid currentColor;
    border-right: 0;
    pointer-events: none;
    word-break: normal;
}

#editor .collaboration-cursor__label {
    position: absolute;
    top: -1.4em;
    left: -1px;
    font-size: 0.68rem;
    line-height: 1;
    font-weight: 600;
    color: #fff;
    background: currentColor;
    border-radius: 3px 3px 3px 0;
    padding: 0.12rem 0.3rem;
    white-space: nowrap;
    user-select: none;
}

/* Quill — 툴바는 #wikiQuillToolbar 로 분리됨
   body color(#fff)가 currentColor로 SVG에 상속되면 흰 배경에서 아이콘이 사라짐 */
#wikiQuillToolbar.ql-toolbar,
#wikiQuillToolbar {
    color: var(--fgb-dark) !important;
}

#wikiQuillToolbar.ql-toolbar,
#wikiQuillToolbar .ql-toolbar {
    border: none !important;
    background: #fff !important;
    padding-left: 0;
    max-width: 100%;
}

#wikiQuillToolbar .ql-stroke {
    stroke: var(--fgb-dark) !important;
}

#wikiQuillToolbar .ql-fill {
    fill: var(--fgb-dark) !important;
}

#wikiQuillToolbar .ql-picker-label {
    color: var(--fgb-dark) !important;
}

#wikiQuillToolbar .ql-picker {
    position: relative;
    z-index: 1;
}

#wikiQuillToolbar .ql-picker.ql-expanded {
    z-index: 50;
}

#wikiQuillToolbar .ql-picker-options {
    color: var(--fgb-dark);
    z-index: 51;
}

#wikiQuillToolbar .ql-picker-item {
    color: var(--fgb-dark) !important;
}

#wikiQuillToolbar button:hover .ql-stroke,
#wikiQuillToolbar button.ql-active .ql-stroke {
    stroke: var(--fgb-dark) !important;
}

#wikiQuillToolbar button:hover .ql-fill,
#wikiQuillToolbar button.ql-active .ql-fill {
    fill: var(--fgb-dark) !important;
}

#editor .ql-container.ql-snow {
    border-color: var(--border) !important;
    font-family: var(--font-main);
    font-size: var(--wiki-prose-size);
    color: var(--fgb-dark);
    max-height: 600px;
    box-sizing: border-box;
}

#editor .ql-editor {
    min-height: 240px;
    max-height: 600px;
    box-sizing: border-box;
    overflow-y: auto;
    color: var(--fgb-dark);
    background: #fff;
    font-size: var(--wiki-prose-size);
    line-height: var(--wiki-prose-line);
    padding: var(--wiki-prose-padding);
    font-family: var(--font-main);
}

#editor .ql-editor a,
#editor .ProseMirror a {
    color: var(--secondary);
}

/* tableContainer 노드의 렌더 결과 — 표와 document root 사이 블록 래퍼 */
.wiki-table-wrap {
    display: block;
    width: 100%;
}

/* 편집기 내 tableContainer NodeView 외부 래퍼 */
.wiki-table-outer-wrap {
    display: block;
    width: 100%;
    max-width: 100%;
    position: relative;
    overflow-x: hidden;
    box-sizing: border-box;
    margin: 0.5em 0;
}

/* 이미지 리사이즈 래퍼
   line-height: 0 을 쓰면 래퍼 인접 캐럿 높이가 0이 되어 안 보이므로 제거.
   하단 여백은 vertical-align: bottom 으로 처리. */
.wiki-img-resize-wrapper {
    position: relative;
    display: inline-block;
    max-width: 100%;
    vertical-align: bottom;
}

/* 이미지 우하단 리사이즈 핸들 */
.wiki-img-resize-handle {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 14px;
    height: 14px;
    background: rgba(59, 130, 246, 0.85);
    border: 2px solid #fff;
    border-radius: 2px;
    cursor: se-resize;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 5;
    box-sizing: border-box;
}

.wiki-img-resize-wrapper:hover .wiki-img-resize-handle,
.wiki-img-resize-selected .wiki-img-resize-handle {
    opacity: 1;
}

/* 이미지 선택 시 테두리 강조 */
.wiki-img-resize-wrapper.wiki-img-resize-selected img {
    outline: 2px solid rgba(59, 130, 246, 0.7);
    outline-offset: 1px;
}

/* 글자 크기 컨트롤 그룹 */
.wiki-tiptap-font-size-wrap {
    display: inline-flex;
    align-items: center;
    gap: 0;
    border: 1px solid #c8d0de;
    border-radius: 4px;
    overflow: visible;
    background: #fff;
    height: 1.9rem;
    box-sizing: border-box;
    flex-shrink: 0;
}

.wiki-tiptap-font-step-btn {
    appearance: none;
    border: none;
    border-radius: 0;
    background: transparent;
    color: var(--fgb-dark);
    width: 1.3rem;
    height: 100%;
    padding: 0;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wiki-tiptap-font-step-btn:hover {
    background: rgba(0, 0, 0, 0.06);
}

.wiki-tiptap-font-size-wrap .wiki-tiptap-font-step-btn:first-child {
    border-right: 1px solid #c8d0de;
    border-radius: 3px 0 0 3px;
}

.wiki-tiptap-font-size-wrap .wiki-tiptap-font-step-btn:last-child {
    border-left: 1px solid #c8d0de;
    border-radius: 0 3px 3px 0;
}

.wiki-tiptap-font-size-select {
    appearance: none;
    -webkit-appearance: none;
    border: none;
    background: transparent;
    color: var(--fgb-dark);
    font-size: 0.8rem;
    font-family: var(--font-main);
    height: 100%;
    padding: 0 0.3rem;
    cursor: pointer;
    text-align: center;
    min-width: 3.2rem;
    outline: none;
}

/* H1/H2 커서 위치일 때 글자 크기 컨트롤 비활성화 */
.wiki-tiptap-font-size-wrap.wiki-tiptap-font-size-disabled {
    opacity: 0.4;
    pointer-events: none;
    cursor: not-allowed;
}

/* 저장 확인 — 랜딩 모달과 동일 계열, 버튼 두 개 가로 */
.wiki-save-confirm-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    justify-content: center;
    width: 100%;
}
