        :root { 
            --ui-bg: #1a1d21; 
            --ui-nav: #12151a; 
            --ui-panel: #1e2228; 
            --ui-hover: #282d35; 
            --ui-border: #2d333b; 
            --ui-text: #e6edf3; 
            --ui-dim: #8b949e; 
            --ui-accent: #00C853; 
            --ui-warning: #FF9800;
            --ui-error: #f85149;
            --ui-info: #58a6ff;
        }

        /* ===== 사용자 템플릿 영역 ===== */
        .user-templates-section {
            max-height: 200px;
            overflow-y: auto;
            margin: 10px 0;
            padding-right: 5px;
        }

        .user-templates-section::-webkit-scrollbar {
            width: 4px;
        }

        .user-templates-section::-webkit-scrollbar-thumb {
            background: var(--ui-border);
            border-radius: 2px;
        }

        .user-templates-section::-webkit-scrollbar-thumb:hover {
            background: var(--ui-dim);
        }

        .template-divider {
            height: 1px;
            background: var(--ui-border);
            margin: 10px 0;
            position: relative;
        }

        .template-divider::after {
            content: '사용자 템플릿';
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            background: var(--ui-nav);
            padding: 0 8px;
            font-size: 9px;
            color: var(--ui-dim);
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        /* 사용자 템플릿 아이템 */
        .user-template-item {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 10px 12px;
            background: var(--ui-panel);
            border: 1px solid var(--ui-border);
            border-radius: 6px;
            cursor: pointer;
            transition: all 0.15s;
            position: relative;
            margin-bottom: 4px;
        }

        .user-template-item:hover {
            background: var(--ui-hover);
            border-color: var(--ui-dim);
        }

        .user-template-item.selected {
            border-color: var(--ui-accent);
            background: rgba(0, 200, 83, 0.1);
        }

        .user-template-item .label {
            flex: 1;
            font-size: 13px;
            font-weight: 500;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .user-template-item .delete-btn {
            width: 20px;
            height: 20px;
            border: none;
            background: transparent;
            color: var(--ui-dim);
            font-size: 14px;
            cursor: pointer;
            border-radius: 4px;
            display: flex;
            align-items: center;
            justify-content: center;
            opacity: 0;
            transition: all 0.15s;
        }

        .user-template-item:hover .delete-btn {
            opacity: 1;
        }

        .user-template-item .delete-btn:hover {
            background: var(--ui-error);
            color: white;
        }

        /* 템플릿 추가 모달 */
        .template-modal {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.75);
            align-items: center;
            justify-content: center;
            z-index: 2000;
        }

        .template-modal.active {
            display: flex;
        }

        .template-modal-content {
            background: var(--ui-panel);
            border: 1px solid var(--ui-border);
            border-radius: 12px;
            padding: 24px;
            width: 420px;
            box-shadow: 0 15px 50px rgba(0,0,0,0.5);
        }

        .template-modal-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
        }

        .template-modal-title {
            font-size: 16px;
            font-weight: 700;
            color: var(--ui-accent);
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .template-modal-close {
            width: 28px;
            height: 28px;
            border: none;
            background: transparent;
            color: var(--ui-dim);
            font-size: 18px;
            cursor: pointer;
            border-radius: 6px;
        }

        .template-modal-close:hover {
            background: var(--ui-hover);
            color: var(--ui-text);
        }

        .template-input-group {
            margin-bottom: 16px;
        }

        .template-input-label {
            font-size: 12px;
            font-weight: 600;
            color: var(--ui-dim);
            margin-bottom: 8px;
            display: block;
        }

        .template-name-input {
            width: 100%;
            padding: 10px 12px;
            border: 1px solid var(--ui-border);
            border-radius: 6px;
            background: var(--ui-bg);
            color: var(--ui-text);
            font-size: 13px;
        }

        .template-name-input:focus {
            outline: none;
            border-color: var(--ui-accent);
        }

        .template-dropzone {
            border: 2px dashed var(--ui-border);
            border-radius: 8px;
            padding: 30px;
            text-align: center;
            cursor: pointer;
            transition: all 0.2s;
        }

        .template-dropzone:hover,
        .template-dropzone.dragover {
            border-color: var(--ui-accent);
            background: rgba(0, 200, 83, 0.05);
        }

        .template-dropzone-icon {
            font-size: 36px;
            margin-bottom: 10px;
        }

        .template-dropzone-text {
            font-size: 13px;
            color: var(--ui-text);
            margin-bottom: 5px;
        }

        .template-dropzone-hint {
            font-size: 11px;
            color: var(--ui-dim);
        }

        .template-dropzone-file {
            display: none;
            align-items: center;
            gap: 10px;
            padding: 10px;
            background: var(--ui-bg);
            border-radius: 6px;
            margin-top: 10px;
        }

        .template-dropzone-file.show {
            display: flex;
        }

        .template-dropzone-file .filename {
            flex: 1;
            font-size: 12px;
            color: var(--ui-accent);
        }

        .template-dropzone-file .remove {
            color: var(--ui-dim);
            cursor: pointer;
        }

        .template-dropzone-file .remove:hover {
            color: var(--ui-error);
        }

        .template-submit-btn {
            width: 100%;
            padding: 12px;
            border: none;
            border-radius: 8px;
            background: linear-gradient(135deg, var(--ui-accent), #00a844);
            color: #003300;
            font-size: 14px;
            font-weight: 700;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            margin-top: 20px;
            transition: all 0.2s;
        }

        .template-submit-btn:hover:not(:disabled) {
            transform: translateY(-1px);
            box-shadow: 0 4px 15px rgba(0, 200, 83, 0.3);
        }

        .template-submit-btn:disabled {
            background: var(--ui-border);
            color: var(--ui-dim);
            cursor: not-allowed;
        }

        .template-submit-btn .spinner {
            display: none;
            width: 16px;
            height: 16px;
            border: 2px solid transparent;
            border-top-color: currentColor;
            border-radius: 50%;
            animation: spin 0.8s linear infinite;
        }

        /* 템플릿 리스트 */
        .template-list {
            display: flex;
            flex-direction: column;
            gap: 4px;
            margin-bottom: 10px;
        }

        .template-item {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 10px 12px;
            background: var(--ui-panel);
            border: 1px solid var(--ui-border);
            border-radius: 6px;
            cursor: pointer;
            transition: all 0.15s;
        }

        .template-item:hover {
            background: var(--ui-hover);
            border-color: var(--ui-dim);
        }

        .template-item.selected {
            border-color: var(--ui-accent);
            background: rgba(0, 200, 83, 0.1);
        }

        .template-item input[type="radio"] {
            accent-color: var(--ui-accent);
        }

        .template-item .label {
            flex: 1;
            font-size: 13px;
            font-weight: 500;
        }

        .template-item .delete-btn {
            opacity: 0;
            background: transparent;
            border: none;
            color: var(--ui-dim);
            cursor: pointer;
            font-size: 14px;
        }

        .template-item:hover .delete-btn {
            opacity: 1;
        }

        .template-item .delete-btn:hover {
            color: var(--ui-error);
        }

        /* 템플릿 요소 체크박스 */
        .template-elements {
            margin-top: 12px;
            padding: 12px;
            background: var(--ui-bg);
            border: 1px solid var(--ui-border);
            border-radius: 6px;
        }

        .elements-title {
            font-size: 10px;
            font-weight: 600;
            color: var(--ui-dim);
            margin-bottom: 8px;
            text-transform: uppercase;
        }

        .elements-list {
            display: flex;
            flex-direction: column;
            gap: 6px;
        }

        .element-checkbox {
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 12px;
            color: var(--ui-text);
            cursor: pointer;
        }

        .element-checkbox input[type="checkbox"] {
            accent-color: var(--ui-accent);
        }

        .element-checkbox .element-icon {
            font-size: 14px;
        }

        /* 사용자 템플릿 프리뷰 */
        .user-template-preview {
            display: none;
            position: fixed;
            width: 280px;
            background: var(--ui-panel);
            border: 1px solid var(--ui-border);
            border-radius: 12px;
            padding: 15px;
            box-shadow: 0 10px 40px rgba(0,0,0,0.5);
            z-index: 1000;
            pointer-events: none;
        }

        .user-template-preview::after {
            content: '';
            position: absolute;
            right: -8px;
            top: 50%;
            transform: translateY(-50%);
            border: 8px solid transparent;
            border-left-color: var(--ui-panel);
        }

        .user-template-preview.show {
            display: block;
        }

        .preview-analyzed-features {
            margin-top: 12px;
        }

        .preview-analyzed-feature {
            font-size: 11px;
            color: var(--ui-accent);
            padding: 3px 0;
            display: flex;
            align-items: center;
            gap: 6px;
        }

        .preview-analyzed-feature::before {
            content: '✓';
        }        
        
        * { margin: 0; padding: 0; box-sizing: border-box; }
        
        body { 
            font-family: 'Noto Sans KR', sans-serif; 
            background: var(--ui-bg); 
            color: var(--ui-text); 
            height: 100vh; 
            display: flex; 
            flex-direction: column; 
            overflow: hidden; 
        }
        
        /* ===== 상단 툴바 ===== */
        .toolbar {
            height: 50px;
            background: var(--ui-panel);
            border-bottom: 1px solid var(--ui-border);
            display: flex;
            align-items: center;
            padding: 0 15px;
            gap: 8px;
        }
        
        .toolbar-logo {
            display: flex;
            align-items: center;
            gap: 8px;
            font-weight: 900;
            color: var(--ui-accent);
            font-size: 18px;
        }
        
        .toolbar-spacer { flex: 1; }
        
        .toolbar-divider {
            width: 1px;
            height: 24px;
            background: var(--ui-border);
            margin: 0 8px;
        }
        
        .toolbar-btn {
            padding: 7px 14px;
            border-radius: 5px;
            border: 1px solid var(--ui-border);
            background: var(--ui-hover);
            color: var(--ui-text);
            font-size: 12px;
            font-weight: 500;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 6px;
            transition: all 0.15s;
        }
        
        .toolbar-btn:hover {
            background: var(--ui-panel);
            border-color: var(--ui-dim);
        }
        
        .toolbar-btn:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }
        
        .toolbar-btn.active {
            background: rgba(0, 200, 83, 0.2);
            border-color: var(--ui-accent);
            color: var(--ui-accent);
        }
        
        .zoom-select {
            padding: 6px 10px;
            border-radius: 5px;
            border: 1px solid var(--ui-border);
            background: var(--ui-hover);
            color: var(--ui-text);
            font-size: 12px;
            cursor: pointer;
        }
        
        /* ===== 메인 컨테이너 ===== */
        .app {
            display: flex;
            flex: 1;
            overflow: hidden;
        }
        
        /* ===== 좌측 사이드바 ===== */
        .sidebar {
            width: 280px;
            background: var(--ui-nav);
            border-right: 1px solid var(--ui-border);
            display: flex;
            flex-direction: column;
        }
        
        .sidebar-header {
            padding: 15px;
            border-bottom: 1px solid var(--ui-border);
            background: var(--ui-panel);
        }
        
        .sidebar-title {
            font-size: 11px;
            font-weight: 700;
            color: var(--ui-dim);
            text-transform: uppercase;
            letter-spacing: 0.5px;
            margin-bottom: 10px;
        }
        
        .sidebar-btn {
            width: 100%;
            padding: 10px 12px;
            border-radius: 6px;
            border: 1px solid var(--ui-border);
            background: var(--ui-hover);
            color: var(--ui-text);
            font-size: 13px;
            font-weight: 500;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 10px;
            transition: all 0.15s;
            text-align: left;
            margin-bottom: 8px;
        }
        
        .sidebar-btn:hover {
            background: var(--ui-panel);
            border-color: var(--ui-dim);
        }
        
        .sidebar-btn .icon { font-size: 16px; }
        
        .sidebar-content {
            flex: 1;
            overflow-y: auto;
            padding: 15px;
            display: flex;
            flex-direction: column;
            gap: 15px;
        }

        .section-title {
            font-size: 11px;
            font-weight: 700;
            color: var(--ui-dim);
            text-transform: uppercase;
            letter-spacing: 0.5px;
            margin-bottom: 8px;
        }

        /* 참고 파일 확인 */
        .file-check-box {
            background: var(--ui-panel);
            border: 1px solid var(--ui-border);
            border-radius: 8px;
            padding: 12px;
        }
        
        .file-check-row {
            display: flex;
            justify-content: space-between;
            align-items: center;
            font-size: 12px;
            padding: 5px 0;
        }
        
        .file-check-label { color: var(--ui-dim); }
        
        .file-check-value { font-weight: 600; }
        .file-check-value.ok { color: var(--ui-accent); }
        .file-check-value.warn { color: var(--ui-warning); cursor: pointer; }
        .file-check-value.warn:hover { text-decoration: underline; }
        
        .file-path {
            font-size: 11px;
            color: var(--ui-info);
            word-break: break-all;
            padding: 6px 0;
            border-bottom: 1px solid var(--ui-border);
            margin-bottom: 5px;
        }
        
        .file-path.empty { color: var(--ui-dim); font-style: italic; }
        
        /* 미확인 파일 펼침 */
        .unknown-files {
            background: var(--ui-bg);
            border: 1px solid var(--ui-border);
            border-radius: 6px;
            margin-top: 8px;
            padding: 10px;
            display: none;
        }
        
        .unknown-files.show { display: block; }
        
        .unknown-file-item {
            font-size: 11px;
            color: var(--ui-warning);
            padding: 3px 0;
        }
        
        .open-folder-btn {
            margin-top: 8px;
            padding: 6px 10px;
            border-radius: 4px;
            border: 1px solid var(--ui-border);
            background: var(--ui-hover);
            color: var(--ui-dim);
            font-size: 11px;
            cursor: pointer;
            width: 100%;
        }
        
        .open-folder-btn:hover {
            border-color: var(--ui-accent);
            color: var(--ui-accent);
        }

        /* 작성 방식 선택 (가로 탭) */
        .write-mode-box {
            background: var(--ui-panel);
            border: 1px solid var(--ui-border);
            border-radius: 8px;
            padding: 10px;
        }

        .write-mode-tabs {
            display: flex;
            gap: 4px;
        }

        .write-mode-tab {
            flex: 1;
            padding: 10px 8px;
            border: 1px solid var(--ui-border);
            border-radius: 6px;
            background: transparent;
            cursor: pointer;
            transition: all 0.15s;
            text-align: center;
        }

        .write-mode-tab:hover {
            background: var(--ui-hover);
            border-color: var(--ui-dim);
        }

        .write-mode-tab.selected {
            background: rgba(0, 200, 83, 0.15);
            border-color: var(--ui-accent);
        }

        .write-mode-tab input[type="radio"] {
            display: none;
        }

        .write-mode-icon {
            font-size: 16px;
            margin-bottom: 4px;
        }

        .write-mode-label {
            font-size: 11px;
            font-weight: 600;
            color: var(--ui-text);
        }

        .write-mode-tab.selected .write-mode-label {
            color: var(--ui-accent);
        }

        .write-mode-notice {
            margin-top: 8px;
            padding: 6px 8px;
            background: rgba(255, 152, 0, 0.1);
            border-radius: 4px;
            font-size: 10px;
            color: var(--ui-warning);
            display: flex;
            align-items: center;
            gap: 5px;
        }

        /* 진행 상태 */
        .step-list {
            display: flex;
            flex-direction: column;
            gap: 2px;
        }
        
        .step-item {
            font-size: 11px;
            color: var(--ui-dim);
            padding: 6px 8px;
            display: flex;
            align-items: center;
            gap: 8px;
            border-radius: 4px;
            transition: all 0.15s;
        }
        
        .step-item .status {
            width: 16px;
            text-align: center;
            font-size: 12px;
        }
        
        .step-item.pending { color: #555; }
        .step-item.running { 
            color: var(--ui-info); 
            background: rgba(88, 166, 255, 0.1);
        }
        .step-item.running .status { animation: pulse 1s infinite; }
        .step-item.done { color: var(--ui-accent); }
        .step-item.error { color: var(--ui-error); }
        
        .step-divider {
            height: 1px;
            background: var(--ui-border);
            margin: 6px 0;
        }
        
        @keyframes pulse {
            0%, 100% { opacity: 1; }
            50% { opacity: 0.4; }
        }
        
        /* 좌측 생성 버튼 */
        .sidebar-generate-btn {
            width: 100%;
            padding: 14px;
            border-radius: 8px;
            border: none;
            background: linear-gradient(135deg, var(--ui-accent), #00a844);
            color: #003300;
            font-size: 14px;
            font-weight: 700;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            transition: all 0.2s;
        }
        
        .sidebar-generate-btn:hover:not(:disabled) {
            transform: translateY(-1px);
            box-shadow: 0 4px 15px rgba(0, 200, 83, 0.3);
        }
        
        .sidebar-generate-btn:disabled {
            background: var(--ui-border);
            color: var(--ui-dim);
            cursor: not-allowed;
            transform: none;
            box-shadow: none;
        }

        /* ===== 가운데 뷰어 ===== */
        .main {
            flex: 1;
            display: flex;
            flex-direction: column;
            min-width: 0;
            position: relative;
        }
        
        /* 서식 바 */
        .format-bar {
            height: 44px;
            background: #252a30;
            border-bottom: 1px solid var(--ui-border);
            display: none;
            align-items: center;
            padding: 0 12px;
            gap: 4px;
        }
        .format-bar.active { display: flex; }
        
        .format-btn { 
            width: 32px; height: 32px; border-radius: 4px; border: none; 
            background: transparent; color: var(--ui-text); cursor: pointer; 
            font-size: 14px; display: flex; align-items: center; justify-content: center; 
            transition: all 0.15s;
        }
        .format-btn:hover { background: var(--ui-hover); }
        .format-btn.active { background: rgba(0, 200, 83, 0.3); color: var(--ui-accent); }
        
        .format-select { 
            padding: 4px 8px; border-radius: 4px; border: 1px solid var(--ui-border); 
            background: var(--ui-hover); color: var(--ui-text); font-size: 12px; 
            cursor: pointer; min-width: 80px; 
        }
        .format-divider { width: 1px; height: 24px; background: var(--ui-border); margin: 0 6px; }
        
        .viewer {
            flex: 1;
            background: #525659;
            overflow: auto;
            display: flex;
            justify-content: center;
            padding: 30px;
        }
        
        .a4-wrapper {
            transform-origin: top center;
        }
        
        .a4-preview {
            width: 210mm;
            min-height: 297mm;
            background: white;
            box-shadow: 0 0 20px rgba(0,0,0,0.3);
            color: #333;
            position: relative;
        }
        
        .preview-iframe {
            width: 100%;
            min-height: 297mm;
            border: none;
            background: white;
            display: none;
        }
        
        .preview-iframe.active {
            display: block;
        }
        
        .placeholder {
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            height: 297mm;
            color: #888;
            text-align: center;
            padding: 40px;
        }
        
        .placeholder .icon {
            font-size: 72px;
            margin-bottom: 25px;
            opacity: 0.4;
        }
        
        .placeholder .text {
            font-size: 18px;
            color: #666;
            margin-bottom: 10px;
        }
        
        .placeholder .sub-text {
            font-size: 14px;
            color: #999;
        }

        /* 하단 피드백 바 */
        .feedback-bar {
            background: var(--ui-panel);
            border-top: 1px solid var(--ui-border);
            padding: 12px 20px;
            display: none;
            align-items: center;
            gap: 12px;
        }

        /* 목차 확인 액션바 */
        .toc-action-bar {
            background: var(--ui-panel);
            border-top: 1px solid var(--ui-border);
            padding: 12px 20px;
            display: none;
            align-items: center;
            justify-content: flex-end;
            gap: 12px;
        }
        .toc-action-bar.show { display: flex; }

        .toc-action-btn {
            padding: 10px 24px;
            border-radius: 6px;
            border: none;
            font-size: 13px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.15s;
        }
        .toc-action-btn.primary {
            background: var(--ui-accent);
            color: #003300;
        }
        .toc-action-btn.primary:hover {
            background: #00e676;
        }
        .toc-action-btn.secondary {
            background: var(--ui-hover);
            color: var(--ui-text);
            border: 1px solid var(--ui-border);
        }
        .toc-action-btn.secondary:hover {
            border-color: var(--ui-accent);
            color: var(--ui-accent);
        }        

        .feedback-bar.show { display: flex; }
        
        .feedback-input {
            flex: 1;
            padding: 10px 14px;
            border-radius: 6px;
            border: 1px solid var(--ui-border);
            background: var(--ui-bg);
            color: var(--ui-text);
            font-size: 13px;
        }
        .feedback-input:focus {
            outline: none;
            border-color: var(--ui-accent);
        }
        
        .feedback-btn {
            padding: 10px 20px;
            border-radius: 6px;
            border: none;
            font-size: 13px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.15s;
        }
        .feedback-btn.primary {
            background: var(--ui-accent);
            color: #003300;
        }
        .feedback-btn.primary:hover {
            background: #00e676;
        }
        .feedback-btn.secondary {
            background: var(--ui-hover);
            color: var(--ui-text);
            border: 1px solid var(--ui-border);
        }

        /* ===== 우측 패널 ===== */
        .right-panel {
            width: 280px;
            background: var(--ui-nav);
            border-left: 1px solid var(--ui-border);
            display: flex;
            flex-direction: column;
        }
        
        .panel-header {
            padding: 15px;
            border-bottom: 1px solid var(--ui-border);
            background: var(--ui-panel);
        }
        
        .panel-title {
            font-size: 11px;
            font-weight: 700;
            color: var(--ui-dim);
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }
        
        .panel-body {
            flex: 1;
            overflow-y: auto;
            padding: 15px;
        }
        
        /* 문서 유형 선택 - 심플 리스트 */
        .doc-type-list {
            display: flex;
            flex-direction: column;
            gap: 4px;
            margin-bottom: 10px;
        }
        
        .doc-type-item {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 10px 12px;
            background: var(--ui-panel);
            border: 1px solid var(--ui-border);
            border-radius: 6px;
            cursor: pointer;
            transition: all 0.15s;
            position: relative;
        }
        
        .doc-type-item:hover:not(.disabled) {
            background: var(--ui-hover);
            border-color: var(--ui-dim);
        }
        
        .doc-type-item.selected {
            border-color: var(--ui-accent);
            background: rgba(0, 200, 83, 0.1);
        }
        
        .doc-type-item.disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }
        
        .doc-type-item input[type="radio"] {
            accent-color: var(--ui-accent);
        }
        
        .doc-type-item .label {
            flex: 1;
            font-size: 13px;
            font-weight: 500;
        }
        
        .doc-type-item .badge {
            font-size: 9px;
            padding: 2px 6px;
            border-radius: 4px;
            background: var(--ui-warning);
            color: #000;
            font-weight: 600;
        }

        .doc-type-item .delete-btn {
            width: 20px;
            height: 20px;
            border: none;
            background: transparent;
            color: var(--ui-dim);
            font-size: 14px;
            cursor: pointer;
            border-radius: 4px;
            display: flex;
            align-items: center;
            justify-content: center;
            opacity: 0;
            transition: all 0.15s;
        }

        .doc-type-item:hover .delete-btn {
            opacity: 1;
        }

        .doc-type-item .delete-btn:hover {
            background: var(--ui-error);
            color: white;
        }
        
        /* 플로팅 프리뷰 팝업 - fixed로 변경 */
        .doc-type-preview {
            display: none;
            position: fixed;
            width: 280px;
            background: var(--ui-panel);
            border: 1px solid var(--ui-border);
            border-radius: 12px;
            padding: 15px;
            box-shadow: 0 10px 40px rgba(0,0,0,0.5);
            z-index: 1000;
            pointer-events: none;
        }
        
        .doc-type-preview::after {
            content: '';
            position: absolute;
            right: -8px;
            top: 50%;
            transform: translateY(-50%);
            border: 8px solid transparent;
            border-left-color: var(--ui-panel);
        }
        
        .doc-type-preview.show {
            display: block;
        }
        
        /* 프리뷰 썸네일 */
        .preview-thumbnail {
            width: 100%;
            height: 120px;
            background: #ffffff;
            border-radius: 8px;
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 8px;
            margin-bottom: 12px;
            border: 1px solid var(--ui-border);
            overflow: hidden;
            padding: 10px;
        }
        
        /* 기획서 프리뷰 - 2페이지 */
        .preview-thumbnail.briefing .page {
            width: 45px;
            height: 64px;
            border: 1px solid #ccc;
            border-radius: 2px;
            padding: 3px;
            background: white;
            box-shadow: 0 1px 3px rgba(0,0,0,0.1);
        }
        .preview-thumbnail.briefing .page-header {
            height: 4px;
            background: #1a365d;
            margin-bottom: 3px;
            border-radius: 1px;
        }
        .preview-thumbnail.briefing .page-title {
            height: 5px;
            background: #1a365d;
            margin-bottom: 3px;
            border-radius: 1px;
        }
        .preview-thumbnail.briefing .page-divider {
            height: 2px;
            background: linear-gradient(90deg, #1a365d, #2c5282);
            margin-bottom: 3px;
        }
        .preview-thumbnail.briefing .page-lead {
            height: 8px;
            background: #f7fafc;
            border-left: 2px solid #1a365d;
            margin-bottom: 3px;
        }
        .preview-thumbnail.briefing .page-body {
            height: 4px;
            background: #e2e8f0;
            margin-bottom: 2px;
            border-radius: 1px;
        }
        .preview-thumbnail.briefing .page-bottom {
            height: 6px;
            background: linear-gradient(90deg, #1a365d 22%, #f0f0f0 22%);
            margin-top: auto;
            border-radius: 1px;
        }
        .preview-thumbnail.briefing .page-attach {
            font-size: 4px;
            color: #666;
            text-align: center;
            margin-bottom: 2px;
        }
        
        /* 보고서 프리뷰 */
        .preview-thumbnail.report {
            flex-direction: column;
            justify-content: flex-start;
            padding: 15px;
        }
        .preview-thumbnail.report .line {
            width: 100%;
            height: 3px;
            background: #ddd;
            margin-bottom: 4px;
            border-radius: 1px;
        }
        .preview-thumbnail.report .line.h1 {
            background: #333;
            height: 5px;
            width: 50%;
            margin-bottom: 8px;
        }
        .preview-thumbnail.report .line.h2 {
            background: #555;
            height: 4px;
            width: 40%;
            margin-top: 6px;
            margin-bottom: 6px;
        }
        .preview-thumbnail.report .line.body {
            background: #ccc;
            width: 95%;
        }
        
        /* PPT 프리뷰 */
        .preview-thumbnail.ppt {
            background: #2d3748;
            flex-direction: row;
            gap: 6px;
            padding: 15px;
        }
        .preview-thumbnail.ppt .slide {
            width: 55px;
            height: 40px;
            background: #1a365d;
            border-radius: 3px;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            padding: 4px;
        }
        .preview-thumbnail.ppt .slide-title {
            font-size: 5px;
            color: white;
            font-weight: bold;
            margin-bottom: 3px;
        }
        .preview-thumbnail.ppt .slide-body {
            width: 80%;
            height: 2px;
            background: rgba(255,255,255,0.3);
            margin-bottom: 2px;
        }

        /* custom 프리뷰 */
        .preview-thumbnail.custom {
            flex-direction: column;
            justify-content: flex-start;
            padding: 15px;
        }
        .preview-thumbnail.custom .line {
            width: 100%;
            height: 3px;
            background: #ddd;
            margin-bottom: 4px;
            border-radius: 1px;
        }
        .preview-thumbnail.custom .line.h1 {
            background: #1a365d;
            height: 5px;
            width: 60%;
            margin-bottom: 8px;
        }
        .preview-thumbnail.custom .line.h2 {
            background: #2c5282;
            height: 4px;
            width: 45%;
            margin-top: 6px;
            margin-bottom: 6px;
        }
        .preview-thumbnail.custom .line.body {
            background: #cbd5e0;
            width: 90%;
        }
        
        /* 프리뷰 정보 */
        .preview-title {
            font-size: 14px;
            font-weight: 700;
            color: var(--ui-text);
            margin-bottom: 4px;
        }
        
        .preview-desc {
            font-size: 11px;
            color: var(--ui-dim);
            margin-bottom: 12px;
        }
        
        .preview-features {
            display: flex;
            flex-direction: column;
            gap: 5px;
        }
        
        .preview-feature {
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 11px;
            color: var(--ui-dim);
        }
        
        .preview-feature .icon {
            font-size: 12px;
        }
        
        /* 템플릿 추가 버튼 */
        .add-template-btn {
            width: 100%;
            padding: 12px;
            border-radius: 8px;
            border: 1px dashed var(--ui-border);
            background: transparent;
            color: var(--ui-dim);
            font-size: 13px;
            cursor: pointer;
            transition: all 0.15s;
            margin-top: 10px;
        }
        
        .add-template-btn:hover {
            border-color: var(--ui-accent);
            color: var(--ui-accent);
            background: rgba(0, 200, 83, 0.05);
        }
        
        /* 옵션 섹션 */
        .option-section {
            margin-bottom: 20px;
        }
        
        .option-title {
            font-size: 11px;
            font-weight: 700;
            color: var(--ui-dim);
            margin-bottom: 10px;
        }
        
        .option-group {
            display: flex;
            flex-direction: column;
            gap: 6px;
        }
        
        .option-item {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 8px 12px;
            background: var(--ui-panel);
            border: 1px solid var(--ui-border);
            border-radius: 6px;
            cursor: pointer;
            transition: all 0.15s;
        }
        
        .option-item:hover {
            background: var(--ui-hover);
        }
        
        .option-item.selected {
            border-color: var(--ui-accent);
            background: rgba(0, 200, 83, 0.1);
        }
        
        .option-item input[type="radio"],
        .option-item input[type="checkbox"] {
            accent-color: var(--ui-accent);
        }
        
        .option-item label {
            font-size: 12px;
            cursor: pointer;
            flex: 1;
        }

        /* 페이지 수 입력 필드 */
        .page-input {
            width: 45px;
            padding: 4px 6px;
            border: 1px solid var(--ui-border);
            border-radius: 4px;
            background: var(--ui-bg);
            color: var(--ui-text);
            font-size: 12px;
            text-align: center;
            margin-left: 4px;
        }

        .page-input:focus {
            outline: none;
            border-color: var(--ui-accent);
        }

        .page-input:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }

        .page-input-suffix {
            font-size: 12px;
            color: var(--ui-dim);
            margin-left: 2px;
        }

        /* 스피너 숨기기 (Chrome) */
        .page-input::-webkit-inner-spin-button,
        .page-input::-webkit-outer-spin-button {
            -webkit-appearance: none;
            margin: 0;
        }
        
        /* 요청사항 */
        .request-textarea {
            width: 100%;
            height: 100px;
            padding: 12px;
            border-radius: 6px;
            border: 1px solid var(--ui-border);
            background: var(--ui-panel);
            color: var(--ui-text);
            font-size: 12px;
            resize: vertical;
            font-family: inherit;
        }
        .request-textarea:focus {
            outline: none;
            border-color: var(--ui-accent);
        }
        .request-textarea::placeholder {
            color: var(--ui-dim);
        }
        
        /* 생성 버튼 */
        .generate-btn {
            width: 100%;
            padding: 14px;
            border-radius: 8px;
            border: none;
            background: linear-gradient(135deg, var(--ui-accent), #00a844);
            color: #003300;
            font-size: 14px;
            font-weight: 700;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            transition: all 0.2s;
            margin-top: 20px;
        }
        
        .generate-btn:hover:not(:disabled) {
            transform: translateY(-1px);
            box-shadow: 0 4px 15px rgba(0, 200, 83, 0.3);
        }
        
        .generate-btn:disabled {
            background: var(--ui-border);
            color: var(--ui-dim);
            cursor: not-allowed;
            transform: none;
            box-shadow: none;
        }

        /* ===== 상태바 ===== */
        .status-bar {
            height: 28px;
            background: var(--ui-nav);
            border-top: 1px solid var(--ui-border);
            padding: 0 15px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            font-size: 11px;
            color: var(--ui-dim);
        }
        
        .status-left {
            display: flex;
            align-items: center;
            gap: 10px;
        }
        
        .status-dot {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background: #555;
        }
        
        .status-dot.connected {
            background: var(--ui-accent);
            box-shadow: 0 0 8px var(--ui-accent);
        }

        /* ===== 모달 ===== */
        .modal-overlay {
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.75);
            display: none;
            align-items: center;
            justify-content: center;
            z-index: 1000;
        }
        
        .modal-overlay.active { display: flex; }
        
        .modal {
            background: var(--ui-panel);
            border: 1px solid var(--ui-border);
            border-radius: 12px;
            padding: 20px;
            min-width: 450px;
            max-width: 550px;
            box-shadow: 0 15px 50px rgba(0,0,0,0.5);
        }
        
        .modal-header {
            font-size: 16px;
            font-weight: 700;
            color: var(--ui-accent);
            margin-bottom: 20px;
            display: flex;
            align-items: center;
            gap: 10px;
        }
        
        .modal-body { margin-bottom: 20px; }
        
        .modal-textarea {
            width: 100%;
            height: 220px;
            padding: 12px 14px;
            border-radius: 6px;
            border: 1px solid var(--ui-border);
            background: var(--ui-bg);
            color: var(--ui-text);
            font-size: 12px;
            font-family: 'Consolas', 'Monaco', monospace;
            resize: vertical;
        }
        
        .modal-textarea:focus {
            outline: none;
            border-color: var(--ui-accent);
        }
        
        .modal-footer {
            display: flex;
            justify-content: flex-end;
            gap: 10px;
        }
        
        .modal-btn {
            padding: 10px 20px;
            border-radius: 6px;
            border: 1px solid var(--ui-border);
            background: var(--ui-hover);
            color: var(--ui-text);
            font-size: 13px;
            cursor: pointer;
            transition: all 0.15s;
        }
        
        .modal-btn:hover { background: var(--ui-panel); }
        
        .modal-btn.primary {
            background: var(--ui-accent);
            border-color: var(--ui-accent);
            color: #003300;
            font-weight: 700;
        }
        
        .modal-btn.primary:hover { background: #00e676; }

        /* 스크롤바 */
        ::-webkit-scrollbar { width: 8px; height: 8px; }
        ::-webkit-scrollbar-track { background: var(--ui-bg); }
        ::-webkit-scrollbar-thumb { background: #444; border-radius: 4px; }
        ::-webkit-scrollbar-thumb:hover { background: #555; }

        /* 로딩 스피너 */
        .loading-spinner {
            border: 2px solid transparent;
            border-top: 2px solid currentColor;
            border-radius: 50%;
            width: 16px;
            height: 16px;
            animation: spin 0.8s linear infinite;
        }
        @keyframes spin {
            to { transform: rotate(360deg); }
        }

        /* AI 수정 플로팅 박스 */
        .ai-edit-popup {
            display: none;
            position: fixed;
            top: 80px;
            right: 300px;
            width: 320px;
            background: var(--ui-panel);
            border: 1px solid var(--ui-accent);
            border-radius: 12px;
            padding: 15px;
            box-shadow: 0 10px 40px rgba(0, 200, 83, 0.2);
            z-index: 500;
        }

        .ai-edit-popup.show { display: block; }

        .ai-edit-header {
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 14px;
            font-weight: 700;
            color: var(--ui-accent);
            margin-bottom: 12px;
        }

        .ai-edit-selected {
            font-size: 11px;
            color: var(--ui-dim);
            margin-bottom: 8px;
        }

        .ai-edit-selected-text {
            background: var(--ui-bg);
            border: 1px solid var(--ui-border);
            border-radius: 6px;
            padding: 8px;
            font-size: 12px;
            color: var(--ui-text);
            max-height: 80px;
            overflow-y: auto;
            margin-bottom: 12px;
        }

        .ai-edit-input {
            width: 100%;
            padding: 10px;
            border-radius: 6px;
            border: 1px solid var(--ui-border);
            background: var(--ui-bg);
            color: var(--ui-text);
            font-size: 12px;
            margin-bottom: 12px;
            resize: none;
        }

        .ai-edit-btn {
            width: 100%;
            padding: 10px;
            border-radius: 6px;
            border: none;
            background: var(--ui-accent);
            color: #003300;
            font-size: 13px;
            font-weight: 700;
            cursor: pointer;
        }

        .ai-edit-close {
            position: absolute;
            top: 10px;
            right: 10px;
            background: none;
            border: none;
            color: var(--ui-dim);
            cursor: pointer;
            font-size: 16px;
        }

        /* 문서 유형별 옵션 컨테이너 */
        #docTypeOptionsContainer {
            margin-bottom: 20px;
        }

        /* 사용자 문서 유형 구분선 */
        .doc-type-divider {
            height: 1px;
            background: var(--ui-border);
            margin: 10px 0;
            position: relative;
        }

        .doc-type-divider::after {
            content: '사용자 추가';
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            background: var(--ui-nav);
            padding: 0 8px;
            font-size: 9px;
            color: var(--ui-dim);
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        /* 로딩 상태 */
        .doc-type-list.loading {
            min-height: 100px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .doc-type-list.loading::after {
            content: '로딩 중...';
            color: var(--ui-dim);
            font-size: 12px;
        }

        .analysis-progress {
            padding: 20px 0;
        }

        .analysis-step {
            display: flex;
            align-items: center;
            padding: 8px 12px;
            margin-bottom: 4px;
            border-radius: 6px;
            background: var(--ui-bg);
        }

        .analysis-step.running {
            background: var(--accent-light);
        }

        .analysis-step.done {
            opacity: 0.7;
        }

        .analysis-step .step-icon {
            width: 24px;
            text-align: center;
        }

        .analysis-step .step-name {
            flex: 1;
            margin-left: 8px;
        }

        .analysis-step .step-status {
            font-size: 12px;
            color: var(--ui-text-muted);
        }

        .progress-bar-container {
            height: 8px;
            background: var(--ui-border);
            border-radius: 4px;
            margin-top: 16px;
            overflow: hidden;
        }

        .progress-bar {
            height: 100%;
            background: var(--accent-primary);
            transition: width 0.3s ease;
        }

        /* 분석 결과 UI */
        .analysis-result h4 {
            margin-bottom: 16px;
        }

        .result-summary {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 12px;
            margin-bottom: 20px;
        }

        .summary-item {
            padding: 12px;
            background: var(--ui-bg);
            border-radius: 6px;
            text-align: center;
        }

        .toc-list {
            list-style: none;
            padding: 0;
        }

        .toc-list li {
            padding: 6px 12px;
            border-left: 2px solid var(--ui-border);
            margin-bottom: 2px;
        }

        .toc-level-2 { padding-left: 28px; }
        .toc-level-3 { padding-left: 44px; }
        .step-icon.spinning {
            display: inline-block;
            animation: spin 1s linear infinite;
        }

        .analysis-step .step-status {
            font-size: 10px;
            color: var(--ui-dim);
            margin-left: auto;
            max-width: 150px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }