/* 웹폰트 */
@font-face {
    font-family: 'HCRBatang';
    src: local('함초롬바탕'), local('함초롬바탕 LVT'), local('HCR Batang LVT'), local('HCRBatang'),
         url('https://webcdn.mediclassics.kr/fonts/HCRBatang/HCRBatang.woff2') format('woff2'),
         url('https://webcdn.mediclassics.kr/fonts/HCRBatang/HCRBatang.woff') format('woff');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'HCRDotum';
    src: local('함초롬돋움'), local('함초롬돋움 LVT'), local('HCR Dotum LVT'), local('HCRDotum'),
         url('https://webcdn.mediclassics.kr/fonts/HCRDotum/HCRDotum.woff2') format('woff2'),
         url('https://webcdn.mediclassics.kr/fonts/HCRDotum/HCRDotum.woff') format('woff');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'HanaMin';
    src: local('HanaMinA'), local('花園明朝A'),
         url('https://webcdn.mediclassics.kr/fonts/HanaMin/HanaMinA.woff2') format('woff2'),
         url('https://webcdn.mediclassics.kr/fonts/HanaMin/HanaMinA.woff') format('woff');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'HanaMin';
    src: local('HanaMinB'), local('花園明朝B'),
         url('https://webcdn.mediclassics.kr/fonts/HanaMin/HanaMinB.woff2') format('woff2'),
         url('https://webcdn.mediclassics.kr/fonts/HanaMin/HanaMinB.woff') format('woff');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
    unicode-range: U+20000-2FFFF;
}

:root {
    --font-family-myungjo: 'HCRBatang', 'HanaMin', serif;
    --font-family-gothic: 'HCRDotum', 'HanaMin', sans-serif;
}

/* 페이지 스크롤 제거, 뷰포트 꽉 채우기 */
html, body {
    height: 100%;
    overflow: hidden;
}

body {
    display: flex;
    flex-direction: column;
    padding: 12px 20px 0;
}

/* 주석 (각주) */
.footnote-ref {
    color: #c0392b;
    font-size: 0.7em;
    vertical-align: super;
    cursor: pointer;
    text-decoration: none;
    font-weight: bold;
    margin: 0 1px;
}

.footnote-ref:hover {
    text-decoration: underline;
}

.footnotes {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #ddd;
    font-size: 0.85em;
    color: #555;
}

.footnote-item {
    display: flex;
    gap: 6px;
    margin-bottom: 4px;
    line-height: 1.6;
    padding: 2px 4px;
    border-radius: 4px;
    background-color: #f5f0e8;
    transition: background-color 0.15s, border-color 0.15s;
    border: 1px solid transparent;
}

.footnote-item:hover {
    border-color: #c9b99a;
}

.footnote-num {
    color: #c0392b;
    font-weight: bold;
    cursor: pointer;
    flex-shrink: 0;
}

.footnote-num:hover {
    text-decoration: none;
}

.footnote-text {
    flex: 1;
}

.fn-highlight {
    animation: fnFlash 3s ease-out forwards;
}

.footnote-ref.fn-highlight {
    animation: fnRefFlash 3s ease-out forwards;
    border-radius: 3px;
}

@keyframes fnFlash {
    0% { background: rgba(255, 140, 0, 0.4); }
    70% { background: rgba(255, 140, 0, 0.3); }
    100% { background: transparent; }
}

@keyframes fnRefFlash {
    0% { box-shadow: 0 0 0 5px rgba(255, 140, 0, 0.5); }
    70% { box-shadow: 0 0 0 4px rgba(255, 140, 0, 0.4); }
    100% { box-shadow: none; }
}

/* 인쇄 */
@media print {
    html, body {
        height: auto !important;
        overflow: visible !important;
        padding: 0 !important;
        margin: 0 !important;
        background: white !important;
    }
    .page-header, .left-panel, .resize-handle,
    .legend-sidebar, .right-panel > .panel-header,
    .home-button, .lang-toggle, .footer,
    .tag-popover, .toast, .cursor-ring,
    .cloud-auth-area, .saved-panel,
    #bmc-wbtn, .bmc-btn-container {
        display: none !important;
    }
    .main-area, .right-panel {
        display: block !important;
        width: 100% !important;
        height: auto !important;
        padding: 0 !important;
        margin: 0 !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        overflow: visible !important;
        flex: none !important;
    }
    #outputArea {
        width: 100% !important;
        height: auto !important;
        overflow: visible !important;
        padding: 20px !important;
        max-height: none !important;
    }
}

/* 푸터 여백 최소화 */
.footer {
    margin-top: 0 !important;
    padding: 6px 20px !important;
    flex-shrink: 0;
}

.page-header {
    text-align: center;
    flex-shrink: 0;
    padding-bottom: 10px;
}

/* ─── 클라우드 인증 영역 (우측 상단 고정) ─── */

.cloud-auth-area {
    position: fixed;
    top: 16px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 900;
}

.text-size-label {
    font-size: 0.7rem;
    color: #aaa;
    margin-left: 4px;
}

.cloud-login-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    border: 1px solid #ddd;
    border-radius: 20px;
    background: #fff;
    cursor: pointer;
    font-size: 0.8rem;
    color: #555;
    transition: background 0.15s, box-shadow 0.15s;
}

.cloud-login-btn:hover {
    background: #f8f8f8;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.cloud-user-area {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: #555;
}

.cloud-user-photo {
    width: 22px;
    height: 22px;
    border-radius: 50%;
}

.cloud-user-name {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cloud-logout-btn {
    display: inline-flex;
    align-items: center;
    padding: 4px;
    border: none;
    background: none;
    cursor: pointer;
    color: #999;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}

.cloud-logout-btn:hover {
    color: #e74c3c;
    background: #fef0f0;
}

.cloud-saved-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    border: 1px solid #d5c8f0;
    border-radius: 20px;
    background: #f8f4ff;
    cursor: pointer;
    font-size: 0.8rem;
    color: #7c5cbf;
    transition: background 0.15s, box-shadow 0.15s;
}

.cloud-saved-btn:hover {
    background: #efe8ff;
    box-shadow: 0 1px 4px rgba(124,92,191,0.15);
}

/* 저장 목록 패널 */

.saved-panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 400px;
    max-height: 420px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    z-index: 1000;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.saved-panel.open {
    display: flex;
}

.saved-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid #eee;
    font-size: 0.85rem;
    font-weight: 600;
    color: #444;
}

.saved-panel-close {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 1rem;
    color: #999;
    padding: 2px 6px;
    border-radius: 4px;
}

.saved-panel-close:hover {
    background: #f0f0f0;
    color: #333;
}

.saved-list-body {
    flex: 1;
    overflow-y: auto;
    padding: 6px;
}

.saved-loading,
.saved-empty {
    padding: 20px;
    text-align: center;
    color: #aaa;
    font-size: 0.8rem;
}

.saved-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    transition: background 0.12s;
}

.saved-item:hover {
    background: #f8f5ff;
}

.saved-item-info {
    flex: 1;
    min-width: 0;
    cursor: pointer;
}

.saved-item-title {
    font-size: 0.82rem;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.saved-item-date {
    font-size: 0.7rem;
    color: #aaa;
    margin-top: 2px;
}

.saved-item-pin {
    flex-shrink: 0;
    border: none;
    background: none;
    cursor: pointer;
    color: #ccc;
    fill: none;
    padding: 4px;
    border-radius: 4px;
    transition: color 0.15s, fill 0.15s, background 0.15s;
}

.saved-item-pin:hover {
    color: #f0a030;
    background: #fef8ee;
}

.saved-item-pin.pinned {
    color: #e8930c;
    fill: #e8930c;
}

.saved-item-pin.pinned:hover {
    color: #c07808;
    fill: #c07808;
    background: #fef3e0;
}

.saved-item-delete {
    flex-shrink: 0;
    border: none;
    background: none;
    cursor: pointer;
    color: #ccc;
    padding: 4px;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}

.saved-item-delete:hover {
    color: #e74c3c;
    background: #fef0f0;
}

.page-header h1 {
    font-size: 1.6rem;
    margin-bottom: 4px;
}

.page-header .subtitle {
    margin-bottom: 10px;
    font-size: 0.85rem;
}

/* 메인 영역: 남는 높이 전부 사용 */
.main-area {
    flex: 1;
    display: flex;
    gap: 16px;
    min-height: 0;
    padding-bottom: 4px;
}

/* 리사이즈 핸들 */
.resize-handle {
    width: 6px;
    cursor: col-resize;
    background: transparent;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    border-radius: 3px;
}

.resize-handle:hover,
.resize-handle.dragging {
    background: rgba(102, 126, 234, 0.2);
}

.resize-handle::after {
    content: '';
    width: 2px;
    height: 32px;
    background: #ccc;
    border-radius: 1px;
    transition: background 0.15s;
}

.resize-handle:hover::after,
.resize-handle.dragging::after {
    background: #667eea;
}

/* 왼쪽 패널 */
.left-panel {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 12px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.12);
    overflow: hidden;
}

.left-panel .panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
    position: relative;
}

.left-panel .panel-title {
    font-size: 1rem;
    font-weight: 600;
    color: #333;
}

.left-panel .panel-actions {
    display: flex;
    gap: 6px;
    margin-left: auto;
}

.left-panel textarea {
    flex: 1;
    width: 100%;
    height: auto !important;
    border: none;
    border-radius: 0;
    padding: 16px;
    font-family: var(--font-family-myungjo);
    font-size: 0.9rem;
    line-height: 2.4;
    color: #666;
    resize: none;
    outline: none;
}

/* 오른쪽 출력 패널 */
.right-panel {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 12px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.12);
    overflow: hidden;
}

.right-panel .panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
    position: relative;
}

.right-panel .panel-title {
    font-size: 1rem;
    font-weight: 600;
    color: #333;
}

.right-panel .panel-actions {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

.zoom-bar-inline {
    display: flex;
    align-items: center;
    gap: 4px;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.zoom-btn {
    width: 28px;
    height: 28px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #f8f8f8;
    color: #555;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    line-height: 1;
}

.zoom-btn:hover {
    background: #eee;
    border-color: #bbb;
}

.zoom-label {
    font-size: 0.72rem;
    color: #888;
    min-width: 32px;
    text-align: center;
    line-height: 28px;
}

.output-area {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    line-height: 1.8;
    background: white;
    font-family: var(--font-family-myungjo);
}

.output-area:empty::before {
    content: attr(data-placeholder);
    color: #bbb;
    font-style: italic;
}

/* 기호 스타일 (CSS 변수 기반) */
.output-area {
    --bracket-color: #666666;
    --bracket-bg: #f5f5f5;
    --bracket-size: 65%;
    --paren-color: #0d47a1;
    --paren-bg: transparent;
    --paren-underline: wavy;
    --paren-underline-color: #7398ce;
    --circle-color: #e65100;
    --missing-color: #c62828;
    --missing-bg: #ffebee;
    --illegible-color: #b71c1c;
    --illegible-bg: #ffcdd2;
    --decomp-color: #4a148c;
    --decomp-bg: #f3e5f5;
    --asterisk-color: #333333;
    --asterisk-bg: transparent;
    --caret-color: #333333;
    --caret-bg: #f8e3e3;
    --colon-color: #333333;
    --colon-bg: #edc4c4;
    --semicolon-color: #333333;
    --semicolon-bg: #90d987;
}

.sym-bracket {
    color: var(--bracket-color);
    background: var(--bracket-bg);
    font-size: var(--bracket-size);
    border-radius: 2px;
}

.sym-paren {
    color: var(--paren-color);
    background: var(--paren-bg);
    text-decoration: underline var(--paren-underline) var(--paren-underline-color);
    text-underline-offset: 3px;
    padding: 0 1px;
    border-radius: 2px;
}

/* 대괄호 안의 소괄호: 크기는 상속, 색상은 유지 */
.sym-bracket .sym-paren {
    font-size: inherit;
}

.sym-circle { color: var(--circle-color); }
.sym-missing { color: var(--missing-color); background: var(--missing-bg); padding: 0 2px; border-radius: 2px; }
.sym-illegible { color: var(--illegible-color); background: var(--illegible-bg); padding: 0 2px; border-radius: 2px; }
.sym-decomp { color: var(--decomp-color); background: var(--decomp-bg); padding: 0 2px; border-radius: 2px; }
.sym-asterisk { color: var(--asterisk-color); background: var(--asterisk-bg); padding: 0 1px; border-radius: 2px; }
.sym-caret { color: var(--caret-color); background: var(--caret-bg); padding: 0 1px; border-radius: 2px; }
.sym-colon { color: var(--colon-color); background: var(--colon-bg); padding: 0 1px; border-radius: 2px; }
.sym-semicolon { color: var(--semicolon-color); background: var(--semicolon-bg); padding: 0 1px; border-radius: 2px; }

/* 보이기/감추기 토글 */
.output-area.hide-bracket .sym-bracket { display: none; }
.output-area.hide-paren .sym-paren { display: none; }
.output-area.hide-footnote .footnote-ref,
.output-area.hide-footnote .footnotes { display: none; }
.output-area.hide-non-hanja .non-hanja { display: none; }

/* 쌍 기호 에러 버튼 */
.pair-error-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #ccc;
    cursor: default;
    padding: 5px 10px;
    border: none;
    border-radius: 6px;
    background: #f0f0f0;
    font-size: 0.78rem;
    font-weight: 500;
    transition: all 0.2s;
}

.pair-error-btn.has-errors {
    color: white;
    background: #c0392b;
    cursor: pointer;
    animation: pairBlink 1.2s ease-in-out infinite;
}

.pair-error-btn.has-errors:hover {
    animation: none;
    background: #e74c3c;
}

@keyframes pairBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* 쌍 기호 에러 모달 */
.pair-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 20000;
    display: none;
    align-items: center;
    justify-content: center;
}

.pair-overlay.show {
    display: flex;
}

.pair-modal {
    background: white;
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 560px;
    max-width: 90vw;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pair-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}

.pair-modal-header h2 {
    font-size: 1.15rem;
    font-weight: 600;
    color: #c0392b;
}

.pair-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 20px 16px;
}

.pair-error-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    margin-bottom: 6px;
    background: #fdecea;
    border-left: 3px solid #c0392b;
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.15s;
}

.pair-error-item:hover {
    background: #f9d6d2;
}

.pair-error-char {
    font-weight: 700;
    font-size: 1.1rem;
    font-family: var(--font-family-myungjo);
    color: #c0392b;
    min-width: 24px;
    text-align: center;
}

.pair-error-desc {
    color: #555;
}

.pair-error-pos {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.8rem;
    color: #888;
    white-space: nowrap;
}

/* 인라인 태그 밑줄 */
.inline-tag[data-underline="true"] {
    text-decoration: underline var(--inline-underline-style, solid) var(--inline-underline-color, currentColor);
    text-underline-offset: 3px;
}

/* 범례 사이드바 */
.legend-sidebar {
    width: 140px;
    flex-shrink: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-left: 10px;
}

.legend-title {
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
    box-sizing: border-box;
    width: 100%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.legend-settings-btn {
    cursor: pointer;
    color: #999;
    display: inline-flex;
    align-items: center;
    transition: color 0.15s;
}

.legend-settings-btn:hover {
    color: #333;
}

/* 설정 모달 */
.settings-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 20000;
    display: none;
    align-items: center;
    justify-content: center;
}

.settings-overlay.show {
    display: flex;
}

.settings-modal {
    background: white;
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 1014px;
    max-width: 92vw;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-size: 1.05rem;
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
    cursor: grab;
    user-select: none;
}

.settings-header.dragging {
    cursor: grabbing;
}

.settings-header h2 {
    font-size: 1.3rem;
    font-weight: 600;
    color: #333;
    text-align: left;
}

.settings-header-actions {
    display: flex;
    gap: 6px;
}

.settings-body {
    flex: 1;
    overflow-y: auto;
    padding: 0 20px 12px;
}

.settings-table tr.settings-inactive td {
    opacity: 0.2;
}

.settings-table tr.settings-inactive td.category-cell {
    opacity: 1;
}

.settings-table .category-cell {
    background: #f8f8fc;
    font-weight: 600;
    font-size: 0.85rem;
    color: #667eea;
    text-align: center !important;
    vertical-align: middle;
    padding: 8px 6px;
    border-right: 1px solid #e8eaf6;
    border-top: 2px solid #d0d4f0;
    white-space: nowrap;
}

.settings-table .category-first-row td {
    border-top: 2px solid #d0d4f0;
}

.settings-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

.settings-table th {
    text-align: center;
    padding: 8px 8px 6px;
    color: #888;
    font-weight: 500;
    white-space: nowrap;
    position: sticky;
    top: 0;
    background: white;
    z-index: 1;
    box-shadow: 0 1px 0 #eee;
}

.settings-table td {
    padding: 6px 8px;
    border-bottom: 1px solid #f5f5f5;
    text-align: center;
    vertical-align: middle;
}

.settings-table td:first-child,
.settings-table td:nth-child(2) {
    text-align: center;
    font-weight: 500;
    color: #333;
    white-space: nowrap;
}

.settings-table input[type="color"] {
    width: 32px;
    height: 26px;
    border: 1px solid #ddd;
    border-radius: 3px;
    cursor: pointer;
    padding: 0;
}

.settings-table input[type="number"] {
    width: 54px;
    padding: 3px 5px;
    border: 1px solid #ddd;
    border-radius: 3px;
    text-align: center;
    font-size: 0.9rem;
}

.settings-table select {
    padding: 3px 5px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 0.88rem;
}

.settings-table .color-cell,
.settings-table .toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
}

.settings-table .color-clear {
    width: 22px;
    height: 22px;
    border: 1px solid #ddd;
    border-radius: 3px;
    background: #f8f8f8;
    color: #bbb;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.settings-table .color-clear:hover {
    color: #666;
}

.legend-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 8px;
    background: #f0f0f0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.15s;
    background: white;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border: 1px solid #e0e0e0;
}

.legend-item:hover {
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    border-color: #bbb;
}

.legend-item.active {
    background: #eef;
    border-color: #667eea;
    box-shadow: 0 2px 6px rgba(102,126,234,0.3);
}

.legend-item.dimmed {
    opacity: 0.45;
}

.toggle-btn {
    margin-left: auto;
    cursor: pointer;
    display: flex;
    align-items: center;
    color: #888;
    flex-shrink: 0;
    padding: 2px;
    border-radius: 3px;
    transition: color 0.15s;
}

.toggle-btn:hover {
    color: #333;
}

.legend-swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    border: 1px solid #ccc;
    flex-shrink: 0;
}

/* 색상 사각형이 없는 항목(각주/표점)도 열 정렬 유지 */
.legend-swatch-placeholder {
    width: 12px;
    flex-shrink: 0;
}

.legend-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
    color: #444;
}

/* 토글 버튼이 없는 항목도 열 정렬 유지 */
.toggle-placeholder {
    width: 14px;
    flex-shrink: 0;
}

/* 태그 편집 팝오버 */
.tag-popover {
    position: fixed;
    z-index: 10000;
    background: white;
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
    padding: 14px;
    width: 220px;
    display: none;
}

.tag-popover.show {
    display: block;
}

.popover-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid #eee;
}

.popover-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.popover-row:last-child {
    margin-bottom: 0;
}

.popover-label {
    font-size: 0.78rem;
    color: #666;
    width: 50px;
    flex-shrink: 0;
}

.popover-row input[type="color"] {
    width: 30px;
    height: 26px;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    padding: 0;
}

.popover-row input[type="number"] {
    width: 50px;
    padding: 3px 5px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.8rem;
    text-align: center;
}

.popover-row .unit {
    color: #999;
    font-size: 0.75rem;
}

/* 버튼 크기 조정 */
.btn-sm {
    padding: 5px 10px;
    font-size: 0.78rem;
    border-radius: 6px;
}

.btn-convert-sm {
    padding: 5px 16px;
    font-size: 0.82rem;
    font-weight: 600;
    border-radius: 8px;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(240, 147, 251, 0.3);
}

.btn-convert-sm:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(240, 147, 251, 0.5);
}

.btn-convert-sm:disabled {
    background: #f0f0f0;
    color: #555;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-hwp-export {
    padding: 3px 6px;
    border-radius: 6px;
    border: 1px solid #c0d8f0;
    background: #f0f7ff;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
}

.btn-hwp-export:hover {
    background: #dceeff;
    border-color: #7ab3e0;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(61, 165, 245, 0.3);
}

.btn-hwp-export:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* textarea 강조 오버레이 */
.textarea-wrapper {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    overflow: hidden;
}

.textarea-wrapper textarea {
    flex: 1;
    min-height: 0;
}

.cursor-ring {
    position: absolute;
    width: 48px;
    height: 48px;
    background: rgba(255, 140, 0, 0.7);
    border-radius: 50%;
    pointer-events: none;
    transform: translate(-50%, -50%);
    animation: cursorPulse 3s ease-out forwards;
    z-index: 1;
}

@keyframes cursorPulse {
    0% { transform: translate(-50%, -50%) scale(2.5); opacity: 0; }
    10% { transform: translate(-50%, -50%) scale(1); opacity: 0.8; }
    20% { transform: translate(-50%, -50%) scale(1.4); opacity: 0.6; }
    30% { transform: translate(-50%, -50%) scale(1); opacity: 0.8; }
    70% { opacity: 0.7; }
    100% { opacity: 0; }
}

/* 반응형 */
@media (max-width: 900px) {
    .main-area {
        flex-direction: column;
    }

    .left-panel, .right-panel {
        flex: none;
        height: 45vh;
    }

    .legend-sidebar {
        width: 100px;
    }
}
