/* CSS Variables & Theme Configuration */
:root {
    /* Color Palette - Dark Theme */
    --bg-primary: #000000;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #2a2a2a;
    --text-primary: #ffffff;
    --text-secondary: #e0e0e0;
    --text-muted: #a0a0a0;
    --accent-primary: #00d4ff;
    --accent-secondary: #0099cc;
    --file-attach-primary: #6b7280;
    --file-attach-secondary: #4b5563;
    --border-color: #333333;
    --shadow-color: rgba(255, 255, 255, 0.1);
    --input-bg: #1a1a1a;
    --card-bg: #1e1e1e;
    --hover-bg: #2a2a2a;
    
    /* Specialized Colors */
    --reasoning-bubble-bg: #1F1F1F;
    --reasoning-bubble-text: #E8EAED;
    --reasoning-bubble-border: #5F6368;
    --reasoning-bubble-strong-text: #8AB4F8;
    --history-area-bg: #161618;
    --code-bg: #2b2b2b;
    --code-header-bg: #3c3f41;
    --code-text-secondary: #bababa;
    --text-code-inline: #EB5757;
    
    /* Aborted Session Colors */
    --aborted-bg: #2a1a1a;
    --aborted-border: #cc6666;
    --aborted-text: #ffcccc;
    --aborted-icon: #ff6666;
    
    /* Spacing System */
    --space-xs: 0.25rem;    /* 4px */
    --space-sm: 0.5rem;     /* 8px */
    --space-md: 1rem;       /* 16px */
    --space-lg: 1.5rem;     /* 24px */
    --space-xl: 2rem;       /* 32px */
    --space-2xl: 3rem;      /* 48px */
    
    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 50%;
    
    /* Transitions */
    --transition-fast: all 0.15s ease;
    --transition-base: all 0.2s ease;
    --transition-slow: all 0.3s ease;
    
    /* Shadows */
    --shadow-sm: 0 1px 3px var(--shadow-color);
    --shadow-md: 0 4px 20px var(--shadow-color);
    --shadow-lg: 0 10px 40px var(--shadow-color);
    
    /* Z-index layers */
    --z-base: 1;
    --z-dropdown: 100;
    --z-modal: 1000;
    --z-tooltip: 10000;
}

[data-theme="light"] {
    /* Color Palette - Light Theme */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --text-primary: #1a202c;
    --text-secondary: #555555;
    --text-muted: #718096;
    --accent-primary: #007bff;
    --accent-secondary: #0056b3;
    --file-attach-primary: #6b7280;
    --file-attach-secondary: #4b5563;
    --border-color: #e2e8f0;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --input-bg: #ffffff;
    --card-bg: #ffffff;
    --hover-bg: #f7fafc;
    
    /* Specialized Colors */
    --reasoning-bubble-bg: #f5f5f5;
    --reasoning-bubble-text: #333333;
    --reasoning-bubble-border: #dddddd;
    --reasoning-bubble-strong-text: #000000;
    --history-area-bg: #f0f2f5;
    --code-bg: #f6f8fa;
    --code-header-bg: #f0f2f5;
    --code-text-secondary: #555555;
    --text-code-inline: #c7254e;
    
    /* Aborted Session Colors - Light Theme */
    --aborted-bg: #fff5f5;
    --aborted-border: #e53e3e;
    --aborted-text: #742a2a;
    --aborted-icon: #e53e3e;
}

/* 라이트 모드에서 텍스트 로고는 필터 적용 없이 그라디언트 색상 유지 */
[data-theme="light"] .logo {
    /* filter: invert(1); 제거 - 텍스트 그라디언트는 검색 버튼과 동일한 색상 사용 */
    text-shadow: none; /* 라이트 모드에서 글로우 효과 제거 */
}

/* Utility Classes */
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.flex-col { flex-direction: column; }
.flex-row { flex-direction: row; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-start { justify-content: flex-start; }
.justify-end { justify-content: flex-end; }

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.transition-fast { transition: var(--transition-fast); }
.transition-base { transition: var(--transition-base); }
.transition-slow { transition: var(--transition-slow); }

.rounded-sm { border-radius: var(--radius-sm); }
.rounded-md { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }
.rounded-full { border-radius: var(--radius-full); }

.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }

.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.gap-xl { gap: var(--space-xl); }

.p-xs { padding: var(--space-xs); }
.p-sm { padding: var(--space-sm); }
.p-md { padding: var(--space-md); }
.p-lg { padding: var(--space-lg); }
.p-xl { padding: var(--space-xl); }

.m-xs { margin: var(--space-xs); }
.m-sm { margin: var(--space-sm); }
.m-md { margin: var(--space-md); }
.m-lg { margin: var(--space-lg); }
.m-xl { margin: var(--space-xl); }

/* Base Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    min-height: 100vh;
    color: var(--text-primary);
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* 애니메이션 키프레임 */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes typing {
    from { width: 0; }
    to { width: 100%; }
}

@keyframes blink {
    50% { border-color: transparent; }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes streamingOrb {
    0% {
        top: 10%;
        opacity: 0.8;
        transform: translateY(-50%) scale(1);
    }
    25% {
        opacity: 1;
        transform: translateY(-50%) scale(1.4);
    }
    50% {
        top: 90%;
        opacity: 1;
        transform: translateY(-50%) scale(1);
    }
    75% {
        opacity: 1;
        transform: translateY(-50%) scale(1.4);
    }
    100% {
        top: 10%;
        opacity: 0.8;
        transform: translateY(-50%) scale(1);
    }
}

/* 기존 .reasoning-loading-placeholder 와 유사하게 final-generating-placeholder 스타일 정의 */
.final-generating-placeholder {
    color: var(--text-secondary);
    font-style: italic;
    padding: 1rem 0;
    text-align: center;
    width: 100%;
    margin-bottom: 1rem;
}

/* 시작 페이지 스타일 */
.start-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 240px); /* footer 공간 최적화 */
    padding: 2rem;
    position: relative;
    background: var(--bg-primary);
}

/* 로그인 폼 스타일 */
.login-form-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 1rem;
}

.login-form {
    background: var(--bg-primary);
    border-radius: 12px;
    padding: 2rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo {
    font-size: 2rem;
    font-weight: 900;
    background: linear-gradient(45deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
    letter-spacing: 1px;
}

.login-subtitle {
    font-size: 1.2rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-weight: 600;
}

.login-description {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.95rem;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.login-btn {
    width: 100%;
    padding: 12px 24px;
    background: linear-gradient(45deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.3);
}

.login-btn:active {
    transform: translateY(0);
}

.login-error {
    margin-top: 1rem;
    padding: 12px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    color: #ef4444;
    font-size: 0.9rem;
    text-align: center;
}

.login-footer {
    margin-top: 2rem;
    text-align: center;
}

.login-footer p {
    margin-bottom: 1rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.open-browser-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: transparent;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.open-browser-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.open-browser-btn svg {
    width: 16px;
    height: 16px;
}

/* 모바일 반응형 */
@media (max-width: 480px) {
    .login-form-container {
        padding: 0.5rem;
    }
    
    .login-form {
        padding: 1.5rem;
    }
    
    .login-logo {
        font-size: 1.8rem;
    }
    
    .login-subtitle {
        font-size: 1.1rem;
    }
    
    .login-description {
        font-size: 0.85rem;
    }
}

.logo {
    font-size: 3.5rem;
    font-weight: 900;
    background: linear-gradient(45deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 1rem;
    animation: fadeIn 1s ease-out;
    text-shadow: 0 0 30px var(--accent-primary);
    letter-spacing: 2px;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
}

.tagline {
    font-size: 1.3rem;
    color: var(--text-secondary);
    margin-bottom: 3rem;
    text-align: center;
    animation: fadeIn 1s ease-out 0.3s both;
    font-weight: 300;
    letter-spacing: 1px;
    text-transform: uppercase;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
}

.search-container {
    width: 100%;
    max-width: 900px;
    position: relative;
    animation: fadeIn 1s ease-out 0.6s both;
}

/* 이미지 미리보기 컨테이너 스타일 */
.image-preview-container {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 5;
    pointer-events: none;
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: nowrap;
    height: auto;
    /* 검색창 높이에 영향을 주지 않도록 absolute 위치 사용 */
    /* 수직 중앙 정렬을 위한 설정 */
}

.image-preview-container * {
    pointer-events: auto;
}

.image-preview-item {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    overflow: visible;
    transition: all 0.2s ease;
    background: var(--card-bg);
    flex-shrink: 0;
}

.image-preview-item:hover {
    border-color: var(--accent-primary);
    box-shadow: 0 2px 8px var(--shadow-color);
}

.image-preview-item img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
}

.image-delete-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #ef4444;
    color: white;
    border: 2px solid white;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    line-height: 1;
    z-index: 15;
    transition: var(--transition-base);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.image-delete-btn:hover {
    background: #dc2626;
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.search-box {
    width: 100%;
    padding: 1.5rem 120px 1.5rem 1.5rem; /* 버튼 크기 고정으로 패딩 복원 */
    border: 2px solid var(--border-color);
    border-radius: 50px;
    background: var(--input-bg);
    backdrop-filter: blur(10px);
    font-size: 1.1rem;
    color: var(--text-primary);
    outline: none;
    transition: var(--transition-slow);
    resize: none;
    overflow: hidden;
    min-height: 60px;
    max-height: 150px;
    line-height: 1.4;
    font-family: inherit;
}

.search-box::placeholder {
    color: var(--text-muted);
}

.search-box:focus {
    border-color: var(--accent-primary);
    background: var(--input-bg);
    transform: translateY(-2px);
    box-shadow: 0 10px 30px var(--shadow-color);
}

.search-btn {
    position: absolute;
    right: 8px;
    top: calc(50% - 2px); /* 패딩으로 인한 시각적 중심 보정 */
    transform: translateY(-50%);
    background: linear-gradient(45deg, var(--accent-primary), var(--accent-secondary));
    border: none;
    padding: 12px;
    border-radius: 40px;
    color: white;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition-slow);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
}

.search-btn:hover {
    transform: translateY(-50%) scale(1.05);
    box-shadow: 0 5px 15px var(--accent-primary);
}

.search-icon {
    width: 20px;
    height: 20px;
    stroke: white;
    transition: var(--transition-slow);
}

.search-btn:hover .search-icon {
    transform: scale(1.1);
}

/* 파일 첨부 버튼 스타일 */
.file-attach-btn {
    position: absolute;
    right: 64px; /* 검색 버튼 왼쪽에 위치 */
    top: calc(50% - 2px); /* 패딩으로 인한 시각적 중심 보정 */
    transform: translateY(-50%);
    background: linear-gradient(45deg, var(--file-attach-primary), var(--file-attach-secondary));
    border: none;
    padding: 12px;
    border-radius: 40px;
    color: white;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition-slow);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
}

.file-attach-btn:hover {
    transform: translateY(-50%) scale(1.05);
    box-shadow: 0 5px 15px var(--file-attach-primary);
}

.file-attach-icon {
    width: 20px;
    height: 20px;
    stroke: white;
    transition: all 0.3s ease;
}

.file-attach-btn:hover .file-attach-icon {
    transform: scale(1.1);
}

.examples {
    margin-top: 2rem;
    text-align: center;
    animation: fadeIn 1s ease-out 0.9s both;
}

.examples h3 {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-size: 1rem;
}

.example-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    justify-content: center;
}

.example-tag {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition-slow);
    font-size: 0.9rem;
}

.example-tag:hover {
    background: var(--hover-bg);
    transform: translateY(-2px);
    border-color: var(--accent-primary);
}

/* 검색 결과 페이지 스타일 */
.search-page {
    display: none;
    min-height: calc(100vh - 240px); /* footer 공간 최적화 */
    background: var(--bg-primary);
}

.header {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 2rem;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    box-shadow: 0 2px 10px var(--shadow-color);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-logo {
    font-size: 1.5rem;
    font-weight: 900;
    background: linear-gradient(45deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    cursor: pointer;
    letter-spacing: 1px;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
}

.header-search {
    flex-grow: 1;
    position: relative;
    display: flex;
    align-items: center; /* 자식 요소들을 수직 중앙 정렬 */
    gap: 0.5rem; /* 요소 간 간격 */
    min-height: 46px; /* 검색창 최소 높이 */
}

.header-search textarea {
    flex: 1 1 auto; /* 남은 공간 차지 */
    width: 100%;
    padding: 0.7rem 78px 0.7rem 1.5rem; /* 우측 버튼 공간 확보, 기본 좌측 패딩 */
    border: 2px solid var(--border-color);
    border-radius: 25px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    background: var(--input-bg);
    color: var(--text-primary);
    resize: none;
    overflow: hidden;
    min-height: 42px;
    max-height: 120px;
    line-height: 1.2;
    font-family: inherit;
    box-sizing: border-box;
    vertical-align: middle;
}

.header-search textarea::placeholder {
    color: var(--text-muted);
}

.header-search textarea:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.1);
}

/* 헤더 버튼 컨테이너 (데스크톱) */
.header-buttons {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* 헤더 검색창 스타일 - 중복 정의 제거 */

/* 헤더 검색창 이미지 미리보기 스타일 */
.header-search .image-preview-container {
    position: absolute;
    left: 12px;
    top: 8px; /* 고정 위치로 변경 */
    z-index: 5;
    pointer-events: none;
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: nowrap;
    height: auto;
}

.header-search .image-preview-container * {
    pointer-events: auto;
}

/* 헤더 검색창 버튼 스타일 - 시작페이지와 동일한 색톤 */
#headerSearchBtn {
    position: relative; /* 절대 위치 제거 */
    right: unset;
    top: unset;
    transform: none; /* Y 이동 제거 */
    flex: 0 0 30px; /* 고정 너비/높이 유지 */
    margin-left: 0.25rem; /* 버튼 사이 간격 */
    background: linear-gradient(45deg, var(--accent-primary), var(--accent-secondary));
    border: none;
    padding: 6px;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    transition: background 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    z-index: 10;
}

#headerSearchBtn:hover {
    box-shadow: 0 3px 10px var(--accent-primary);
}

#headerSearchBtn .search-icon {
    width: 16px;
    height: 16px;
    stroke: white;
    transition: all 0.3s ease;
}

#headerSearchBtn:hover .search-icon {
    transform: scale(1.1);
}

/* 헤더 파일 첨부 버튼 스타일 */
#headerFileAttachBtn {
    position: relative; /* 절대 위치 제거 */
    right: unset;
    top: unset;
    transform: none; /* Y 이동 제거 */
    flex: 0 0 30px; /* 고정 너비/높이 유지 */
    margin-left: 0.25rem; /* 버튼 사이 간격 */
    background: linear-gradient(45deg, var(--file-attach-primary), var(--file-attach-secondary));
    border: none;
    padding: 6px;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    transition: background 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    z-index: 10;
}

#headerFileAttachBtn:hover {
    box-shadow: 0 3px 10px var(--file-attach-primary);
}

#headerFileAttachBtn .file-attach-icon {
    width: 16px;
    height: 16px;
    stroke: white;
    transition: all 0.3s ease;
}

#headerFileAttachBtn:hover .file-attach-icon {
    transform: scale(1.1);
}

.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    padding-top: 6rem; /* 헤더 높이만큼 상단 패딩 추가 */
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 2rem;
    width: 100%;
    overflow: hidden;
    transition: grid-template-columns 0.3s ease-in-out;
}

.results-section {
    animation: fadeIn 0.8s ease-out;
    min-width: 0;
    overflow: hidden;
}

.ai-response {
    background: var(--card-bg);
    border-radius: 15px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 20px var(--shadow-color);
    border-left: 4px solid var(--accent-primary);
    position: relative;
    transition: var(--transition-slow);
    max-width: 100%;
    overflow: hidden;
    word-wrap: break-word;
}

.ai-response.streaming {
    border-left: 4px solid #00d4ff;
    position: relative;
}

.ai-response.streaming::before {
    content: '';
    position: absolute;
    left: -12px;
    top: 10%;
    width: 24px;
    height: 24px;
    background: radial-gradient(circle, #00d4ff 0%, rgba(0, 212, 255, 0.6) 50%, transparent 100%);
    border-radius: 50%;
    animation: streamingOrb 3s ease-in-out infinite;
    box-shadow: 0 0 25px rgba(0, 212, 255, 0.9);
    z-index: 10;
}

.ai-response h2 {
    font-size: 1.1em;
    font-weight: 400;
    color: var(--text-primary);
    margin-top: 0;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ai-response h2 .ai-icon {
    margin-right: 8px;
    font-size: 0.9em;
    padding: 3px 7px;
    border-radius: 4px;
    background-color: var(--accent-primary);
    color: white;
}

.ai-icon {
    width: 24px;
    height: 24px;
    background: linear-gradient(45deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.8rem;
    font-weight: bold;
    flex-shrink: 0;
}

.ai-response-text {
    line-height: 1.75;
    color: var(--text-secondary);
    font-size: 0.9rem; /* 기본 폰트 사이즈 설정 */
}

.ai-response-text h1,
.ai-response-text h2,
.ai-response-text h3,
.ai-response-text h4,
.ai-response-text h5,
.ai-response-text h6 {
    font-size: inherit;
    color: var(--text-primary);
    margin-top: 0.6em;
    margin-bottom: 0.1em;
    font-weight: 600;
    line-height: 1.4;
}

.ai-response-text h1 { font-size: 1.5rem; }
.ai-response-text h2 { font-size: 1.3rem; }
.ai-response-text h3 { font-size: 1.2rem; }
.ai-response-text h4 { font-size: 1.1rem; }

.ai-response-text p {
    margin: 0;
    padding: 0;
}

/* 연속된 p 태그 사이에만 작은 간격 추가 */
.ai-response-text p + p {
    margin-top: 0.5em;
}

/* 테이블의 첫 번째 자식일 때 margin-top 제거 */
.ai-response-text table:first-child {
    margin-top: 0;
}

.ai-response-text strong {
    font-weight: 600;
    color: var(--text-primary);
}

.ai-response-text em {
    font-style: italic;
    color: var(--text-secondary);
}

.ai-response-text a,
.ai-response-text a:visited {
    color: #007bff;
    text-decoration: underline;
    border-bottom: none;
    transition: color 0.2s ease, text-decoration 0.2s ease;
}

.ai-response-text a:hover,
.ai-response-text a:focus {
    color: #0056b3;
    text-decoration: none;
}

.ai-response-text ul,
.ai-response-text ol {
    margin-top: 0.3em;
    margin-bottom: 0.3em;
    padding-left: 2.5rem;
    color: var(--text-secondary);
}

.ai-response-text li {
    margin-top: 0;
    margin-bottom: 0;
    line-height: 1.6;
}

.ai-response-text li > p {
    margin-top: 0;
    margin-bottom: 0;
}

.ai-response-text ul li {
    list-style-type: disc;
}

.ai-response-text ol li {
    list-style-type: decimal;
}

.ai-response-text blockquote {
    border-left: 4px solid var(--accent-primary);
    background: var(--bg-tertiary);
    padding: 0.5em 1em;
    margin: 0.5em 0;
    font-style: italic;
    border-radius: 0 8px 8px 0;
    color: var(--text-secondary);
}

.ai-response-text table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.3em 0;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    background: var(--card-bg);
}

.ai-response-text th,
.ai-response-text td {
    border: 1px solid var(--border-color);
    padding: 0.75rem;
    text-align: left;
}

.ai-response-text th {
    background: var(--bg-tertiary);
    font-weight: 600;
    color: var(--text-primary);
}

.ai-response-text td {
    background: var(--card-bg);
    color: var(--text-secondary);
}

.ai-response-text tr:nth-child(even) td {
    background: var(--bg-tertiary);
}

.ai-response-text img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1rem 0;
    display: block;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    object-fit: contain;
}

.ai-response-text pre {
    max-width: 100%;
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.ai-response-text code {
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-all;
    max-width: 100%;
}

/* 테이블 중복 스타일 제거 - 기본 테이블 스타일만 사용 */
.ai-response-text a {
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-all;
    max-width: 100%;
}

.ai-response-text hr {
    border: none;
    height: 1px;
    background: var(--border-color);
    margin: 1em 0;
}

.message-copy-button {
    background: var(--hover-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.375rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.message-copy-button:hover {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 212, 255, 0.3);
}

.message-copy-button.success {
    background: #4CAF50;
    color: white;
    border-color: #4CAF50;
}

.message-copy-button .copy-icon {
    width: 16px;
    height: 16px;
    stroke-width: 2;
}

.ai-response-text .code-buttons {
    display: flex;
    gap: 0.5rem;
}

.ai-response-text .code-copy-btn,
.ai-response-text .code-download-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    background: var(--hover-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.ai-response-text .code-copy-btn:hover,
.ai-response-text .code-download-btn:hover {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 212, 255, 0.3);
}

.ai-response-text .code-copy-btn.success {
    background: #4CAF50;
    color: white;
    border-color: #4CAF50;
}

.ai-response-text .code-copy-btn svg,
.ai-response-text .code-download-btn svg {
    width: 16px;
    height: 16px;
    stroke-width: 2;
}

.ai-response-text .code-content {
    position: relative;
}

.ai-response-text .code-content pre code.hljs {
    background: transparent !important;
    padding: 0 !important;
    color: inherit;
    display: block;
    overflow-x: auto;
}

.ai-response-text pre.has-header {
    margin: 1.5rem 0;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 10px var(--shadow-color);
    overflow: hidden;
    background: var(--bg-secondary);
}

.ai-response-text pre.has-header code {
    background: var(--bg-secondary) !important;
    color: #FFFFFF !important;
    padding: 1rem;
    margin: 0;
    border-radius: 0;
    overflow-x: auto;
    font-family: 'Monaco', 'Menlo', 'Consolas', 'Liberation Mono', 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    border: none;
    box-shadow: none;
    display: block;
}

.theme-toggle {
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-primary);
}

.theme-toggle:hover {
    border-color: var(--accent-primary);
    transform: scale(1.1);
}

.theme-icon {
    width: 20px;
    height: 20px;
    transition: transform 0.3s ease;
}

.theme-toggle:hover .theme-icon {
    transform: rotate(180deg);
}

.start-theme-toggle {
    position: absolute;
    top: 2rem;
    right: 2rem;
    z-index: 100;
}



[data-theme="light"] .ai-response-text code:not(pre code) {
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    color: #4CAF50 !important;
}

.ai-response-text a {
    color: var(--accent-primary);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.3s ease;
}

.ai-response-text a:hover {
    color: var(--accent-secondary);
    border-bottom-color: var(--accent-primary);
}

.ai-response-text a.auto-link {
    color: var(--accent-primary);
    text-decoration: underline;
    text-decoration-style: dotted;
    font-weight: 500;
    word-break: break-all;
    transition: all 0.3s ease;
}

.ai-response-text a.auto-link:hover {
    color: var(--accent-secondary);
    text-decoration-style: solid;
    background: rgba(0, 212, 255, 0.1);
    padding: 0.1rem 0.2rem;
    border-radius: 4px;
}

.ai-response-text ul,
.ai-response-text ol {
    margin: 1rem 0;
    padding-left: 1.5rem;
    color: var(--text-secondary);
}

.ai-response-text li {
    margin: 0.5rem 0;
    line-height: 1.6;
}

.ai-response-text ul li {
    list-style-type: disc;
}

.ai-response-text ol li {
    list-style-type: decimal;
}

.ai-response-text blockquote {
    border-left: 4px solid var(--accent-primary);
    background: var(--bg-tertiary);
    padding: 1rem;
    margin: 1rem 0;
    font-style: italic;
    border-radius: 0 8px 8px 0;
    color: var(--text-secondary);
}

.ai-response-text table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.3rem 0;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    background: var(--card-bg);
}

.ai-response-text th,
.ai-response-text td {
    border: 1px solid var(--border-color);
    padding: 0.75rem;
    text-align: left;
}

.ai-response-text th {
    background: var(--bg-tertiary);
    font-weight: 600;
    color: var(--text-primary);
}

.ai-response-text td {
    background: var(--card-bg);
    color: var(--text-secondary);
}

.ai-response-text tr:nth-child(even) td {
    background: var(--bg-tertiary);
}

.ai-response-text img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1rem 0;
    display: block;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    object-fit: contain;
}

.ai-response-text pre {
    max-width: 100%;
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.ai-response-text code {
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-all;
    max-width: 100%;
}

/* 테이블 중복 스타일 제거 - 기본 테이블 스타일만 사용 */
.ai-response-text a {
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-all;
    max-width: 100%;
}

.ai-response-text hr {
    border: none;
    height: 1px;
    background: var(--border-color);
    margin: 1.5rem 0;
}

.message-copy-button {
    background: var(--hover-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.375rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.message-copy-button:hover {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 212, 255, 0.3);
}

.message-copy-button.success {
    background: #4CAF50;
    color: white;
    border-color: #4CAF50;
}

.message-copy-button .copy-icon {
    width: 16px;
    height: 16px;
    stroke-width: 2;
}

.ai-response-text .code-buttons {
    display: flex;
    gap: 0.5rem;
}

.ai-response-copy-button {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-response-copy-button svg {
    width: 20px;
    height: 20px;
}

.ai-response-copy-button:hover {
    color: var(--accent-primary);
}

.code-block-container {
    position: relative;
    margin: 1em 0;
    border-radius: 8px;
    overflow: hidden;
    background-color: var(--code-bg);
    border: 1px solid var(--border-color); /* 통일된 변수 사용 */
}

.code-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5em 1em;
    background-color: var(--code-header-bg);
    border-bottom: 1px solid var(--border-color); /* 통일된 변수 사용 */
}

.code-language {
    font-size: 0.85em;
    color: var(--code-text-secondary);
    text-transform: uppercase;
}

.code-buttons {
    display: flex;
    gap: 0.75em;
}

.code-copy-btn,
.code-download-btn {
    background: none;
    border: none;
    color: var(--code-text-secondary);
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.code-copy-btn:hover,
.code-download-btn:hover {
    opacity: 1;
}

.code-copy-btn.success {
    color: #4CAF50; /* Green check for success */
    opacity: 1;
}

/* Override highlight.js default styles slightly */
.code-block-container pre {
    margin: 0;
    padding: 0;
    background: transparent !important; /* Let container handle the background */
    overflow: hidden;
}

.code-block-container pre code.hljs {
    padding: 1em;
    border-radius: 0 0 8px 8px;
    overflow-x: auto;
    font-family: 'Fira Code', 'D2Coding', monospace;
    font-size: 0.9em;
    line-height: 1.6; /* 일관된 행간 적용 */
    letter-spacing: normal; /* 일관된 자간 적용 */
}

.inline-code {
    background: rgba(135,131,120,0.15);
    color: var(--text-code-inline); /* 변수 사용 */
    padding: 0.2em 0.4em;
    margin: 0 0.1em;
    font-size: 85%;
    border-radius: 3px;
    font-family: 'Fira Code', 'D2Coding', monospace;
}

/* 반응형 디자인 */
@media (max-width: 768px) {
    .main-content,
    .main-content.sidebar-hidden {
        grid-template-columns: 1fr;
        padding: 1rem;
        padding-top: 180px; /* 모바일에서 헤더 높이 증가로 인한 패딩 조정 */
        gap: 1rem;
    }
    .sidebar,
    .sidebar.hidden {
        width: 100%;
        min-width: 100%;
        max-width: 600px; /* 모바일에서 최대 너비 제한 */
        order: 2;
        opacity: 1;
        transform: translateX(0);
        padding: initial;
        margin: 0 auto; /* 좌우 중앙정렬 */
    }
    .sidebar-toggle-btn {
        display: flex;
        order: 3;
        position: static;
    }
    .results-section {
        order: 1;
        max-width: 100%;
        overflow-x: hidden;
    }
    .ai-response {
        padding: 1rem;
        margin-bottom: 1rem;
        max-width: 100%;
        overflow-x: hidden;
    }
    .ai-response-text {
        /* font-size는 기본값 0.9rem 사용 */
        max-width: 100%;
        overflow-x: hidden;
        word-break: break-word;
    }
    .ai-response-text img {
        max-width: 100%;
        height: auto;
    }
    .ai-response-text pre {
        font-size: 0.8rem;
        overflow-x: auto;
        max-width: 100%;
    }
    .ai-response-text code {
        font-size: 0.8rem;
        word-break: break-all;
    }
    .ai-response-text table {
        font-size: 0.8rem;
        overflow-x: auto;
        max-width: 100%;
    }
    .header-content {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    .header-logo {
        order: 1;
        text-align: center;
    }
    .header-search {
        order: 2;
        width: 100%;
    }
    /* 모바일에서 버튼들을 헤더 아래 한 줄에 배치 */
    .header-buttons {
        order: 3;
        display: flex;
        justify-content: center;
        gap: 1rem;
        width: 100%;
    }
    #clearHistoryBtn,
    .sidebar-toggle-btn,
    .theme-toggle,
    .feedback-reasoning-btn,
    .discussion-reasoning-btn {
        position: static;
        order: initial;
        flex-shrink: 0;
    }
    .start-theme-toggle {
        position: fixed;
        top: 2rem;
        right: 2rem;
        z-index: 1000;
    }
    .theme-icon {
        width: 18px;
        height: 18px;
    }
    .logo {
        font-size: 2.5rem;
    }
    .search-container {
        max-width: 100%;
    }
    /* 모바일에서 파일 첨부 버튼 크기 조정 */
    .file-attach-btn {
        right: 64px; /* 검색 버튼과의 간격 더 늘림 (56px -> 64px) */
        width: 48px; /* 고정 크기 유지 */
        height: 48px; /* 고정 크기 유지 */
        padding: 12px; /* 고정 패딩 유지 */
        flex-shrink: 0; /* 크기 변경 방지 */
    }
    .file-attach-icon {
        width: 20px; /* 고정 크기 유지 */
        height: 20px; /* 고정 크기 유지 */
    }
    /* 시작페이지 검색 버튼 크기 고정 */
    .search-btn {
        width: 48px; /* 고정 크기 유지 */
        height: 48px; /* 고정 크기 유지 */
        padding: 12px; /* 고정 패딩 유지 */
        flex-shrink: 0; /* 크기 변경 방지 */
    }
    .search-icon {
        width: 20px; /* 고정 크기 유지 */
        height: 20px; /* 고정 크기 유지 */
    }
    #headerFileAttachBtn {
        /* right 오프셋 제거하여 flex gap 기반 정렬 유지 */
        right: unset;
        flex: 0 0 26px; /* flex-basis를 width와 일치시켜 원형 유지 */
        width: 26px;
        height: 26px;
        padding: 5px;
        margin-left: 0.25rem; /* 버튼 간격 유지 */
    }
    #headerFileAttachBtn .file-attach-icon {
        width: 14px;
        height: 14px;
    }
    #headerSearchBtn {
        /* right 오프셋 제거하여 flex gap 기반 정렬 유지 */
        right: unset;
        flex: 0 0 26px; /* flex-basis를 width와 일치시켜 원형 유지 */
        width: 26px;
        height: 26px;
        padding: 5px;
    }
    #headerSearchBtn .search-icon {
        width: 14px;
        height: 14px;
    }
    /* 모바일에서 검색창 패딩 조정 */
    .search-box {
        padding: 1.5rem 120px 1.5rem 1.5rem; /* 버튼 크기 고정으로 패딩 복원 */
    }
    .header-search textarea {
        padding: 0.8rem 68px 0.8rem 1rem; /* 모바일에서 패딩 조정 */
    }
    .example-tags {
        gap: 0.5rem;
    }
    .ai-response, .sidebar-section {
        padding: 1rem;
    }
    
    /* 모바일에서 히스토리 카드 내부 콘텐츠 최적화 */
    .history-card {
        max-width: 100% !important;
        overflow: visible !important; /* 삭제 버튼이 잘리지 않도록 visible 유지 */
    }
    
    .history-card .history-question {
        font-size: 0.85rem !important;
        line-height: 1.3 !important;
        word-break: break-word !important;
        overflow-wrap: break-word !important;
        hyphens: auto !important;
        max-width: 100% !important;
        white-space: normal !important; /* nowrap 덮어쓰기 */
        overflow: hidden !important; /* 개별 요소 overflow 제어 */
        text-overflow: ellipsis !important;
    }
    
    .history-card .history-answer {
        font-size: 0.8rem !important;
        line-height: 1.3 !important;
        word-break: break-word !important;
        overflow-wrap: break-word !important;
        hyphens: auto !important;
        max-width: 100% !important;
        min-height: 4.5rem !important; /* 모바일에서 더 컴팩트하게 */
        overflow: hidden !important; /* 개별 요소 overflow 제어 */
        text-overflow: ellipsis !important;
    }
    
    .history-card-header {
        padding: 0.5rem 0.8rem !important;
        gap: 0.5rem !important;
    }
    
    .history-timestamp {
        font-size: 0.65rem !important;
        min-width: fit-content !important;
    }
    
    /* 모바일에서 삭제 버튼 크기 조정 */
    .history-card-delete-btn {
        width: 24px !important;
        height: 24px !important;
        font-size: 14px !important;
        line-height: 20px !important;
        top: -8px !important;
        right: -8px !important;
    }
    .message-copy-button {
        top: 0.5rem;
        right: 0.5rem;
        padding: 0.4rem;
    }
    .message-copy-button .copy-icon {
        width: 14px;
        height: 14px;
    }
    .ai-response-text .code-copy-btn,
    .ai-response-text .code-download-btn {
        width: 28px;
        height: 28px;
        padding: 0.3rem;
    }
    .ai-response-text .code-copy-btn svg,
    .ai-response-text .code-download-btn svg {
        width: 14px;
        height: 14px;
    }
    .ai-response-text .code-block-header {
        padding: 0.5rem 0.75rem;
        gap: 0.5rem;
    }
    .ai-response-text .code-language {
        font-size: 0.75rem;
    }
    .ai-response-text pre.has-header code {
        font-size: 0.8rem;
        padding: 0.75rem;
    }
    
    /* 모바일에서 이미지 미리보기 크기 조정 */
    .image-preview-item {
        width: 32px !important;
        height: 32px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    .image-delete-btn {
        width: 20px !important;
        height: 20px !important;
        font-size: 14px !important;
        top: -6px !important;
        right: -6px !important;
        border-width: 1px !important;
    }
    
    /* 모바일에서 검색창 패딩 조정 (이미지 미리보기 고려) */
    .search-box {
        padding-left: 1.5rem; /* 기본 패딩으로 재설정 */
    }
    
    .header-search textarea {
        padding-left: 1rem; /* 기본 패딩으로 재설정 */
    }
    
    /* Footer styles - moved from separate media query */
    .footer {
        padding: 1.5rem 0;
        margin-top: 2rem;
    }
    
    .footer-logo {
        height: 96px;
    }
    
    /* Artifact styles - moved from separate media query */
    .artifact-download-wrapper {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    
    .artifact-file-info {
        margin-right: 0;
        text-align: center;
    }
    
    .artifact-download-button {
        align-self: center;
    }
    
    .artifact-inaccessible-wrapper {
        padding: 1rem;
        text-align: center;
    }
    
    .artifact-inaccessible-wrapper > div:first-child {
        font-size: 0.9rem;
        margin-bottom: 0.5rem;
    }
}

/* 스트리밍 텍스트 애니메이션 */
.streaming-text {
    animation: fadeIn 0.3s ease-out;
}

/* 에러 메시지 스타일 */
.error-message {
    background: var(--bg-tertiary);
    color: var(--accent-primary);
    padding: 1rem;
    border-radius: 8px;
    margin: 1rem 0;
    border-left: 4px solid var(--accent-primary);
}

/* 정보 메시지 스타일 (크리틱 생성 불가 등) */
.info-message {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    padding: 1rem;
    border-radius: 8px;
    margin: 1rem 0;
    border-left: 4px solid var(--text-secondary);
    opacity: 0.8;
}

/* 재시도 버튼 스타일 */
.retry-button {
    background-color: var(--accent-primary);
    color: var(--text-primary);
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    margin-top: 10px;
    transition: background-color 0.3s;
    font-weight: 500;
}

.retry-button:hover {
    background-color: var(--accent-secondary);
    transform: translateY(-1px);
}

.retry-button:active {
    background-color: var(--accent-primary);
    transform: translateY(0);
}

/* 스타일 유지 */
.sidebar {
    animation: fadeIn 0.8s ease-out 0.3s both;
    position: relative;
    width: 300px;
    min-width: 300px;
    max-width: 300px;
    flex-shrink: 0;
    transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out, width 0.3s ease-in-out;
    opacity: 1;
    transform: translateX(0);
}

.sidebar-section {
    background: var(--card-bg);
    border-radius: 15px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 20px var(--shadow-color);
    border: 1.5px solid var(--border-color);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

/* 사이드바 섹션 호버 효과 */
.sidebar-section:hover {
    border-color: rgba(0, 212, 255, 0.3);
    box-shadow: 0 6px 24px var(--shadow-color);
}

/* 라이트 모드에서 사이드바 섹션 테두리 색상 */
[data-theme="light"] .sidebar-section {
    border-color: var(--border-color);
}

[data-theme="light"] .sidebar-section:hover {
    border-color: rgba(37, 99, 235, 0.3);
    box-shadow: 0 6px 24px rgba(37, 99, 235, 0.1);
}

/* 다크 모드에서 사이드바 섹션 테두리 색상 */
[data-theme="dark"] .sidebar-section {
    border-color: var(--border-color);
}

[data-theme="dark"] .sidebar-section:hover {
    border-color: rgba(0, 212, 255, 0.3);
    box-shadow: 0 6px 24px rgba(0, 212, 255, 0.15);
}

/* 오퍼레이션 섹션 특별 스타일 */
.sidebar-section.operation-section {
    padding: 1rem 1.5rem;
    border-color: rgba(0, 212, 255, 0.2);
}

.sidebar-section.operation-section:hover {
    border-color: rgba(0, 212, 255, 0.4);
    box-shadow: 0 8px 28px rgba(0, 212, 255, 0.2);
}

/* 라이트 모드에서 오퍼레이션 섹션 */
[data-theme="light"] .sidebar-section.operation-section {
    border-color: rgba(37, 99, 235, 0.2);
}

[data-theme="light"] .sidebar-section.operation-section:hover {
    border-color: rgba(37, 99, 235, 0.4);
    box-shadow: 0 8px 28px rgba(37, 99, 235, 0.15);
}

.sidebar-section h4 {
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.related-item,
.recommendation-item,
.deep-research-item,
.operation-item {
    padding: 0.5rem 0;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.3s ease;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

.related-item:last-child,
.recommendation-item:last-child,
.deep-research-item:last-child,
.operation-item:last-child {
    border-bottom: none;
}

.related-item:hover,
.recommendation-item:hover,
.deep-research-item:hover,
.operation-item:hover {
    color: var(--accent-primary);
}

/* 관련 질문 컨테이너 - 기본 상태로 복원 */
#relatedQuestions {
    /* 기본 상태 - 고정 높이 제거 */
}

/* 로딩 애니메이션 */
.loading {
    display: none;
    text-align: center;
    padding: 2rem;
    color: var(--accent-primary);
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--card-bg);
    border-radius: 15px;
    box-shadow: 0 10px 40px var(--shadow-color);
    z-index: 1000;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

/* 스타일 유지 */
.web-results {
    background: var(--card-bg);
    border-radius: 15px;
    padding: 1.5rem;
    box-shadow: 0 4px 20px var(--shadow-color);
}

.web-results h3 {
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.result-item {
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.result-item:last-child {
    border-bottom: none;
}

.result-item:hover {
    background: var(--hover-bg);
    margin: 0 -1rem;
    padding: 1rem;
    border-radius: 8px;
}

.result-title {
    color: var(--accent-primary);
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    text-decoration: none;
    transition: color 0.3s ease;
}

.result-title:hover {
    color: var(--accent-secondary);
}

.result-snippet {
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.result-url {
    color: var(--accent-secondary);
    font-size: 0.9rem;
}

/* 사이드바 토글 버튼 스타일 */
.sidebar-toggle-btn {
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-primary);
    padding: 0;
}

.sidebar-toggle-btn:hover {
    border-color: var(--accent-primary);
    transform: scale(1.1);
}

/* 쓰레드 모드 토글 버튼 스타일 (헤더 버튼들과 일관된 스타일) */
.thread-mode-btn {
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-primary);
    padding: 0;
}

.thread-mode-btn .thread-icon {
    width: 20px;
    height: 20px;
    stroke: var(--text-primary);
    transition: all 0.3s ease;
}

.thread-mode-btn:hover {
    border-color: var(--accent-primary);
    transform: scale(1.1);
}

.thread-mode-btn:hover .thread-icon {
    stroke: var(--accent-primary);
}

/* 쓰레드 모드 활성화 상태 */
.thread-mode-btn.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.3);
}

.thread-mode-btn.active .thread-icon {
    stroke: white;
}

.thread-mode-btn.active:hover {
    background: var(--accent-secondary);
    border-color: var(--accent-secondary);
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.4);
    transform: scale(1.1);
}

/* 피드백 추론 모드 버튼 */
.feedback-reasoning-btn {
    background: transparent;
    border: 2px solid var(--border-color);
    padding: 8px;
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.feedback-reasoning-btn .feedback-reasoning-icon {
    width: 20px;
    height: 20px;
    stroke: var(--text-secondary);
    transition: all 0.3s ease;
}

.feedback-reasoning-btn:hover {
    border-color: var(--accent-primary);
    background: rgba(0, 212, 255, 0.1);
}

.feedback-reasoning-btn:hover .feedback-reasoning-icon {
    stroke: var(--accent-primary);
    transform: scale(1.1);
}

/* 피드백 추론 모드 활성화 상태 */
.feedback-reasoning-btn.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.3);
}

.feedback-reasoning-btn.active .feedback-reasoning-icon {
    stroke: white;
}

.feedback-reasoning-btn.active:hover {
    background: var(--accent-secondary);
    border-color: var(--accent-secondary);
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.4);
    transform: scale(1.1);
}

/* 토론 추론 모드 버튼 */
.discussion-reasoning-btn {
    background: transparent;
    border: 2px solid var(--border-color);
    padding: 8px;
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.discussion-reasoning-btn .discussion-reasoning-icon {
    width: 20px;
    height: 20px;
    stroke: var(--text-secondary);
    transition: all 0.3s ease;
}

.discussion-reasoning-btn:hover {
    border-color: var(--accent-primary);
    background: rgba(0, 212, 255, 0.1);
}

.discussion-reasoning-btn:hover .discussion-reasoning-icon {
    stroke: var(--accent-primary);
    transform: scale(1.1);
}

/* 토론 추론 모드 활성화 상태 */
.discussion-reasoning-btn.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.3);
}

.discussion-reasoning-btn.active .discussion-reasoning-icon {
    stroke: white;
}

.discussion-reasoning-btn.active:hover {
    background: var(--accent-secondary);
    border-color: var(--accent-secondary);
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.4);
    transform: scale(1.1);
}

.sidebar-toggle-btn svg {
    transition: transform 0.3s ease;
}

/* 사이드바가 숨겨졌을 때 .main-content에 적용될 클래스 */
.main-content.sidebar-hidden {
    grid-template-columns: minmax(0, 1fr) 0px;
    gap: 0;
}

/* 사이드바 숨김 상태 - 완전히 숨기기 */
.sidebar.hidden {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    overflow: hidden !important;
    opacity: 0 !important;
    visibility: hidden !important;
    position: absolute !important;
    left: -9999px !important;
}

/* 채팅 히스토리 그리드 스타일 */
.chat-history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    padding: 1.5rem; /* ⭐️ 패딩을 주어 배경색이 보이도록 함 ⭐️ */
    margin-top: 1rem;
    border-top: 1px solid var(--border-color);
    background-color: var(--history-area-bg); /* ⭐️ 배경색 적용 ⭐️ */
    border-radius: 12px; /* ⭐️ 전체 영역에 부드러운 모서리 적용 (선택 사항) ⭐️ */
    box-shadow: 0 1px 3px rgba(0,0,0,0.1); /* ⭐️ 약간의 그림자 효과 (선택 사항) ⭐️ */
}

.history-card {
    background-color: var(--card-bg);
    border: 1.5px solid rgba(0, 212, 255, 0.3); /* 메인 액센트 색상의 연한 버전 */
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow-color);
    cursor: pointer;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out, border-color 0.2s ease-in-out;
    overflow: visible; /* 삭제 버튼을 위해 visible 유지 */
    display: flex;
    flex-direction: column;
    position: relative;
    word-wrap: break-word;
    isolation: isolate; /* 새로운 스태킹 컨텍스트 생성 */
}

.history-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 12px var(--shadow-color);
    border-color: rgba(0, 212, 255, 0.5); /* 호버 시 테두리 색상 더 진하게 */
}

/* 히스토리 카드 헤더 스타일 */
.history-card-header {
    background-color: transparent; /* 투명하게 변경하여 카드 테두리가 보이도록 */
    background-image: linear-gradient(to bottom, var(--bg-tertiary), var(--bg-tertiary));
    background-clip: padding-box;
    padding: 0.6rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    border-radius: 11px 11px 0 0; /* 카드보다 약간 작게 */
    position: relative;
    z-index: 1;
    margin: 1px 1px 0 1px; /* 테두리가 보이도록 약간의 마진 */
}

.history-card .history-question {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 0;
    margin-bottom: 0;
    order: 0;
    flex-grow: 1;
    margin-right: 0.5rem;
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.history-timestamp {
    font-size: 0.7em;
    color: var(--text-muted);
    background-color: transparent;
    padding: 0;
    border-radius: 0;
    white-space: nowrap;
    flex-shrink: 0;
}

.history-card .history-answer {
    font-size: 0.9rem; /* 실시간 답변창과 일치 */
    color: var(--text-secondary);
    line-height: 1.4;
    min-height: 5.4rem; /* 3줄 텍스트 + 상하 패딩을 위한 최소 높이 */
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box; 
    -webkit-line-clamp: 3; /* 3줄 표시 유지 */
    -webkit-box-orient: vertical;  
    padding: 0.8rem 1rem 1rem 1rem;
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    /* flex-grow: 1; /* 부모의 높이가 내용에 따라 결정되므로, 여기선 min-height로 제어 */
}

.history-card-delete-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 28px;
    height: 28px;
    background-color: var(--bg-tertiary);
    color: var(--text-muted);
    border: 1.5px solid var(--border-color);
    border-radius: 50%;
    font-size: 16px;
    font-weight: bold;
    line-height: 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 20;
    opacity: 0.9;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.history-card-delete-btn:hover {
    background-color: #ff4757;
    color: white;
    border-color: #ff3742;
    transform: scale(1.2) translate(4px, -4px);
    opacity: 1;
    box-shadow: 0 4px 16px rgba(255, 71, 87, 0.4);
}

/* 라이트 모드에서 히스토리 카드 테두리 색상 조정 */
[data-theme="light"] .history-card {
    border-color: rgba(37, 99, 235, 0.3); /* 라이트 모드에서는 파란색 계열 */
}

[data-theme="light"] .history-card:hover {
    border-color: rgba(37, 99, 235, 0.5);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.15);
}

/* 라이트 모드에서 삭제 버튼 스타일 개선 */
[data-theme="light"] .history-card-delete-btn {
    background-color: #ffffff;
    color: #666666;
    border-color: #e2e8f0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .history-card-delete-btn:hover {
    background-color: #ff4757;
    color: white;
    border-color: #ff3742;
    box-shadow: 0 4px 16px rgba(255, 71, 87, 0.3);
}

/* 다크 모드에서 히스토리 카드 테두리 색상 */
[data-theme="dark"] .history-card {
    border-color: rgba(0, 212, 255, 0.3); /* 다크 모드에서는 시안 계열 */
}

[data-theme="dark"] .history-card:hover {
    border-color: rgba(0, 212, 255, 0.5);
    box-shadow: 0 6px 16px rgba(0, 212, 255, 0.2);
}

/* 다크 모드에서 삭제 버튼 스타일 개선 */
[data-theme="dark"] .history-card-delete-btn {
    background-color: var(--bg-tertiary);
    color: var(--text-muted);
    border-color: var(--border-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .history-card-delete-btn:hover {
    background-color: #ff4757;
    color: white;
    border-color: #ff3742;
    box-shadow: 0 4px 16px rgba(255, 71, 87, 0.5);
}

/* 반응형에서 히스토리 카드 열 개수 조정 */
@media (max-width: 992px) { /* 3개에서 2개로 */
    .chat-history-grid {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
        gap: 1rem;
    }
}

@media (max-width: 576px) { /* 2개에서 1개로 */
    .chat-history-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    /* 매우 작은 화면에서 더 많은 상단 패딩 제공 */
    .main-content,
    .main-content.sidebar-hidden {
        padding-top: 200px !important; /* 작은 화면에서 헤더가 더 높아질 수 있음 */
    }
    
    /* 작은 화면에서 사이드바 너비 추가 조정 */
    .sidebar,
    .sidebar.hidden {
        max-width: 480px; /* 576px 이하에서 더 작은 최대 너비 */
    }
    
    /* 작은 화면에서 히스토리 카드 더 컴팩트하게 */
    .history-card .history-question {
        font-size: 0.8rem !important;
        line-height: 1.2 !important;
        white-space: normal !important;
    }
    
    .history-card .history-answer {
        font-size: 0.9rem !important; /* 실시간 답변창과 일치 */
        line-height: 1.2 !important;
        min-height: 4rem !important;
        -webkit-line-clamp: 4 !important; /* 작은 화면에서 4줄로 늘림 */
    }
    
    .history-card-header {
        padding: 0.4rem 0.6rem !important;
    }
    
    /* 576px 이하에서 삭제 버튼 더 작게 */
    .history-card-delete-btn {
        width: 22px !important;
        height: 22px !important;
        font-size: 12px !important;
        line-height: 18px !important;
        top: -6px !important;
        right: -6px !important;
    }
    
    /* 576px 이하에서 헤더 버튼 크기 조정 */
    #headerFileAttachBtn {
        flex: 0 0 24px;
        width: 24px;
        height: 24px;
        padding: 4px;
    }
    #headerFileAttachBtn .file-attach-icon {
        width: 12px;
        height: 12px;
    }
    #headerSearchBtn {
        flex: 0 0 24px;
        width: 24px;
        height: 24px;
        padding: 4px;
    }
    #headerSearchBtn .search-icon {
        width: 12px;
        height: 12px;
    }
}

/* 극소 화면(모바일 세로 모드)에서 추가 패딩 */
@media (max-width: 480px) {
    .main-content,
    .main-content.sidebar-hidden {
        padding-top: 220px !important; /* 극소 화면에서 최대 패딩 */
    }
    
    /* 극소 화면에서 사이드바 최대 너비 더 축소 */
    .sidebar,
    .sidebar.hidden {
        max-width: 100%; /* 극소 화면에서는 다시 전체 너비 사용 (좌우 패딩은 유지) */
        padding: 0 1rem; /* 좌우 여백 추가 */
    }
    
    /* 극소 화면에서 히스토리 카드 최적화 */
    .history-card {
        margin-bottom: 0.8rem !important;
    }
    
    .history-card .history-question {
        font-size: 0.75rem !important;
        line-height: 1.2 !important;
        padding-right: 0.3rem !important; /* 타임스탬프 공간 확보 */
        white-space: normal !important;
    }
    
    .history-card .history-answer {
        font-size: 0.9rem !important; /* 실시간 답변창과 일치 */
        line-height: 1.2 !important;
        min-height: 3.5rem !important;
        padding: 0.6rem 0.8rem 0.8rem 0.8rem !important;
        -webkit-line-clamp: 3 !important; /* 극소 화면에서 다시 3줄로 제한 */
    }
    
    .history-card-header {
        padding: 0.3rem 0.5rem !important;
        min-height: 2.2rem !important;
    }
    
    .history-timestamp {
        font-size: 0.6rem !important;
    }
    
    /* 480px 이하에서 삭제 버튼 가장 작게 */
    .history-card-delete-btn {
        width: 20px !important;
        height: 20px !important;
        font-size: 11px !important;
        line-height: 16px !important;
        top: -5px !important;
        right: -5px !important;
    }
    
    /* 480px 이하에서 헤더 버튼 가장 작게 */
    #headerFileAttachBtn {
        flex: 0 0 22px;
        width: 22px;
        height: 22px;
        padding: 3px;
    }
    #headerFileAttachBtn .file-attach-icon {
        width: 11px;
        height: 11px;
    }
    #headerSearchBtn {
        flex: 0 0 22px;
        width: 22px;
        height: 22px;
        padding: 3px;
    }
    #headerSearchBtn .search-icon {
        width: 11px;
        height: 11px;
    }
    
    /* 시작페이지 버튼 크기 및 간격 조정 */
    .file-attach-btn {
        right: 60px; /* 더 작은 화면에서 간격 조정 */
        width: 44px;
        height: 44px;
        padding: 10px;
    }
    .file-attach-icon {
        width: 18px;
        height: 18px;
    }
    .search-btn {
        width: 44px;
        height: 44px;
        padding: 10px;
    }
    .search-icon {
        width: 18px;
        height: 18px;
    }
    /* 검색창 패딩 조정 */
    .search-box {
        padding: 1.2rem 110px 1.2rem 1.2rem;
        font-size: 1rem;
    }
    
    /* 작은 화면에서 footer 로고 크기 조정 */
    .footer-logo {
        height: 80px;
    }
} 

/* 매우 작은 화면 (360px 이하) */
@media (max-width: 360px) {
    /* 시작페이지 버튼 더 작게 조정 */
    .file-attach-btn {
        right: 54px; /* 간격 더 줄임 */
        width: 40px;
        height: 40px;
        padding: 8px;
    }
    .file-attach-icon {
        width: 16px;
        height: 16px;
    }
    .search-btn {
        width: 40px;
        height: 40px;
        padding: 8px;
    }
    .search-icon {
        width: 16px;
        height: 16px;
    }
    /* 검색창 패딩 더 줄임 */
    .search-box {
        padding: 1rem 100px 1rem 1rem;
        font-size: 0.95rem;
        min-height: 50px;
    }
    
    /* 매우 작은 화면에서 footer 로고 크기 조정 */
    .footer-logo {
        height: 60px;
    }
} 

/* Styles for Reasoning Steps and Final Answer Bubbles */
.reasoning-steps-wrapper {
    display: flex;
    flex-direction: column;
    /* gap: 3rem; */ /* ⭐️ gap 속성 제거 또는 주석 처리 ⭐️ */
    margin-bottom: 1rem;
}

.reasoning-step-bubble {
    background-color: var(--reasoning-bubble-bg);
    color: var(--reasoning-bubble-text);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.9em;
    line-height: 1.5;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border: 1px solid var(--reasoning-bubble-border);
    margin-bottom: 1.5rem; /* ⭐️ !important 제거하고 값 1.5rem으로 조정 ⭐️ */
}

.reasoning-step-bubble strong {
    color: var(--reasoning-bubble-strong-text);
    font-weight: bold;
    margin-right: 0.25rem;
}

/* 라이트 모드일 때 명시적으로 재지정 */
[data-theme="light"] .reasoning-step-bubble {
    background-color: var(--reasoning-bubble-bg);
    color: var(--reasoning-bubble-text);
    border-color: var(--reasoning-bubble-border);
}

[data-theme="light"] .reasoning-step-bubble strong {
    color: var(--reasoning-bubble-strong-text);
}

.final-answer-wrapper {
    /* 최종 답변 컨테이너는 자체적으로 특별한 배경/테두리 없이,
       내부 MarkdownRenderer 결과가 기존 ai-response-text와 유사하게 보이도록 함.
       필요하다면 여기에 배경이나 패딩 추가 가능.
       예: background-color: var(--response-bg, var(--bg-secondary)); padding: 1rem; border-radius: 8px; 
    */
    font-size: 0.9rem; /* 실시간 답변창과 일치 */
    line-height: 1.6; /* ⭐️ 가독성을 위해 line-height도 적절히 조정 (기존 .ai-response-text 와 유사하게) ⭐️ */
    color: var(--text-secondary); /* ⭐️ 텍스트 색상도 AI 응답과 유사하게 설정 ⭐️ */
}

/* Typing indicator for final answer (if needed specifically here) */
.final-answer-wrapper.typing::after {
    content: '▋';
    animation: typing-cursor 0.5s infinite step-end;
    /* 스타일은 기존 .typing::after 와 동일하게 맞출 수 있음 */
    color: var(--text-primary);
    font-size: 1em; /* 현재 폰트 크기에 맞게 */
    margin-left: 0.2em;
    vertical-align: baseline;
}

/* Ensure aiResponseText children (wrappers) take full width */
#aiResponseText > div {
    width: 100%;
}

/* Styles for Tool Badges and enhanced reasoning bubbles */
.reasoning-step-bubble .bubble-tool-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.85em;
}

.reasoning-step-bubble .tool-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.5rem;
    background-color: var(--bg-tertiary);
    border-radius: 4px;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.reasoning-step-bubble .tool-icon {
    margin-right: 0.3rem;
    color: var(--accent-primary); /* 아이콘 색상 */
}

.reasoning-step-bubble .bubble-message-content {
    margin-top: 0.25rem;
    white-space: pre-wrap; /* JSON 문자열 등 pre-wrap으로 표시 */
    word-break: break-word;
}

/* tool_start 이벤트 버블에 대한 추가 스타일 (선택 사항) */
.tool-execution-bubble {
    background-color: var(--reasoning-bubble-bg);
}

.tool-execution-bubble small pre {
    background-color: var(--bg-secondary);
    padding: 0.5rem;
    border-radius: 4px;
    margin-top: 0.25rem;
    font-size: 0.9em;
    max-height: 100px; /* 입력이 너무 길 경우 스크롤 */
    overflow-y: auto;
}

.history-pagination-controls {
    display: flex; 
    justify-content: center; 
    align-items: center;
    padding: 1rem 0;
    margin-top: 1rem; 
    border-top: 1px solid var(--border-color);
}

.pagination-btn {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
    margin: 0 0.25rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
    font-size: 0.9em;
}

.pagination-btn:hover:not(:disabled) {
    background-color: var(--hover-bg);
    border-color: var(--accent-primary);
}

.pagination-btn.page-number:hover:not(.active-page):not(:disabled) {
    color: var(--accent-primary);
}

.pagination-btn.active-page {
    background-color: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
    cursor: default;
}

.pagination-btn.disabled-btn,
.pagination-btn:disabled { 
    opacity: 0.5;
    cursor: not-allowed;
    background-color: var(--bg-tertiary);
    border-color: var(--border-color);
}

.pagination-btn.prev-btn svg,
.pagination-btn.next-btn svg {
    vertical-align: middle;
}

/* 오퍼레이션 아이콘 컨테이너 */
.operation-icons {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin: 0;
    padding: 0;
}

/* 오퍼레이션 동그란 아이콘 버튼 */
.operation-icon-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.operation-icon-btn:hover {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 212, 255, 0.3);
}

.operation-icon-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0, 212, 255, 0.2);
}

/* 다크 테마에서 호버 효과 개선 */
[data-theme="dark"] .operation-icon-btn:hover {
    box-shadow: 0 4px 12px rgba(0, 212, 255, 0.4);
}

/* 라이트 테마에서 호버 효과 */
[data-theme="light"] .operation-icon-btn:hover {
    box-shadow: 0 4px 12px rgba(0, 212, 255, 0.25);
}

/* Abort Button Styles */
.operation-icon-btn.abort-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: transparent;
    color: #6b7280;
    border: 2px solid #6b7280;
    transition: all 0.3s ease;
    opacity: 0.5;
    cursor: not-allowed;
}

.operation-icon-btn.abort-btn.enabled {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: transparent;
    color: #ef4444;
    border: 2px solid #ef4444;
    opacity: 1;
    cursor: pointer;
}

.operation-icon-btn.abort-btn.enabled:hover {
    background: transparent;
    color: #dc2626;
    border-color: #dc2626;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.6), 0 0 40px rgba(239, 68, 68, 0.3);
    transform: translateY(-2px);
}

.operation-icon-btn.abort-btn.enabled:active {
    transform: translateY(0);
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.4), 0 0 30px rgba(239, 68, 68, 0.2);
}

/* Abort Button - Light Theme */
[data-theme="light"] .operation-icon-btn.abort-btn.enabled {
    background: transparent;
    color: #ef4444;
    border: 2px solid #ef4444;
}

[data-theme="light"] .operation-icon-btn.abort-btn.enabled:hover {
    background: transparent;
    color: #dc2626;
    border-color: #dc2626;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.6), 0 0 40px rgba(239, 68, 68, 0.3);
}

/* Abort Button - Dark Theme */
[data-theme="dark"] .operation-icon-btn.abort-btn.enabled {
    background: transparent;
    color: #ef4444;
    border: 2px solid #ef4444;
}

[data-theme="dark"] .operation-icon-btn.abort-btn.enabled:hover {
    background: transparent;
    color: #dc2626;
    border-color: #dc2626;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.6), 0 0 40px rgba(239, 68, 68, 0.3);
}



/* 쓰레드 모드 스타일 */
.thread-item {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 1.5rem;
    padding: 1.5rem;
    box-shadow: 0 2px 8px var(--shadow-color);
    animation: fadeInUp 0.3s ease-out;
}

.thread-question {
    color: var(--text-primary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 1.1rem;
}

.thread-question strong {
    color: var(--accent-primary);
}

.thread-answer {
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 0.9rem; /* 실시간 답변창과 일치 */
}

.thread-answer h1, 
.thread-answer h2, 
.thread-answer h3, 
.thread-answer h4, 
.thread-answer h5, 
.thread-answer h6 {
    color: var(--text-primary);
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

.thread-answer p {
    margin: 0;
    padding: 0;
}

/* 연속된 p 태그 사이에만 작은 간격 추가 */
.thread-answer p + p {
    margin-top: 0.5em;
}

.thread-answer ul, 
.thread-answer ol {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}

.thread-answer li {
    margin-bottom: 0.5rem;
}

.thread-answer code {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
}

.thread-answer pre {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 1rem;
}

.thread-answer blockquote {
    border-left: 4px solid var(--accent-primary);
    padding-left: 1rem;
    margin: 1rem 0;
    font-style: italic;
    color: var(--text-secondary);
}

/* 쓰레드 아이템 애니메이션 */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 컨텍스트 메뉴 스타일 */
.context-menu {
    position: fixed;
    z-index: 9999;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 8px 32px var(--shadow-color);
    padding: 0.5rem 0;
    min-width: 180px;
    backdrop-filter: blur(10px);
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.context-menu-item:hover {
    background: var(--hover-bg);
    color: var(--accent-primary);
}

.context-menu-item.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
    filter: grayscale(0.3);
}

.context-menu-item.disabled:hover {
    background: transparent;
    color: var(--text-secondary);
}

.context-menu-item svg {
    flex-shrink: 0;
    color: inherit;
}

/* 컨텍스트 메뉴 분리선 */
.context-menu-separator {
    height: 1px;
    background: var(--border-color);
    margin: 0.5rem 0;
}

/* 푸터 스타일 */
.footer {
    background: var(--bg-primary);
    padding: 2rem 0;
    margin-top: 3rem;
    width: 100%;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 2rem;
}

.footer-logo-link {
    display: inline-block;
    transition: all 0.3s ease;
    border-radius: 12px;
    padding: 1rem;
}

.footer-logo-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 212, 255, 0.15);
    background: var(--hover-bg);
}

.footer-logo {
    height: 120px;
    width: auto;
    transition: opacity 0.3s ease;
}

.footer-logo:hover {
    opacity: 0.8;
}

/* 모바일 반응형 */
/* Footer styles moved to main 768px media query above */

/* 비활성화된 UI 요소들 스타일 */
.disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
    user-select: none !important;
    transition: opacity 0.3s ease;
}

.related-item.disabled,
.recommendation-item.disabled,
.deep-research-item.disabled,
.operation-item.disabled,
.history-card.disabled,
.example-tag.disabled,
.tag-item.disabled,
.example-item.disabled {
    opacity: 0.4;
    pointer-events: none;
    filter: grayscale(0.3);
    transform: none !important;
}

.related-item.disabled:hover,
.recommendation-item.disabled:hover,
.deep-research-item.disabled:hover,
.operation-item.disabled:hover,
.history-card.disabled:hover,
.example-tag.disabled:hover,
.tag-item.disabled:hover,
.example-item.disabled:hover {
    color: inherit;
    background: inherit;
    transform: none;
    box-shadow: none;
}

/* 검색 중일 때 전역 커서 스타일 */
body.searching {
    cursor: wait !important;
}

body.searching * {
    cursor: wait !important;
}

/* 사이드바와 테마 토글은 항상 활성화 상태 유지 */
.sidebar-toggle-btn,
.theme-toggle,
#sidebarToggleBtn,
#themeToggle,
#startThemeToggle {
    cursor: pointer !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* 비활성화된 버튼들 스타일 */
button:disabled,
.pagination-btn:disabled,
#threadModeBtn:disabled,
#clearHistoryBtn:disabled,
#mainFileAttachBtn:disabled,
#headerFileAttachBtn:disabled,
.file-attach-btn:disabled,
.pdf-export-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
    filter: grayscale(0.2);
    transform: none !important;
}

/* 비활성화된 입력 필드들 스타일 */
input:disabled,
textarea:disabled,
#headerSearchBox:disabled,
#mainSearchBox:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background-color: var(--bg-tertiary);
    color: var(--text-muted);
}

/* 검색 중일 때만 적용되는 특별한 스타일 */
.searching .related-item,
.searching .recommendation-item,
.searching .deep-research-item,
.searching .operation-item,
.searching .history-card,
.searching .example-tag,
.searching .tag-item,
.searching .example-item {
    pointer-events: none !important;
    opacity: 0.4 !important;
    cursor: wait !important;
}

/* 검색 중에도 허용되는 요소들 */
.searching .sidebar-toggle-btn,
.searching .theme-toggle,
.searching #sidebarToggleBtn,
.searching #themeToggle,
.searching #startThemeToggle,
.searching .ai-response-copy-button,
.searching .podcast-button {
    pointer-events: auto !important;
    opacity: 1 !important;
    cursor: pointer !important;
}

/* 검색 중 히스토리 카드 삭제 버튼 비활성화 */
.searching .history-card-delete-btn {
    opacity: 0.3 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
    filter: grayscale(0.5);
    transform: none !important;
}

.searching .history-card-delete-btn:hover {
    background-color: var(--bg-tertiary) !important;
    color: var(--text-muted) !important;
    border-color: var(--border-color) !important;
    transform: none !important;
    box-shadow: none !important;
}

/* 검색 중 페이지네이션 버튼 비활성화 */
.searching .pagination-btn {
    opacity: 0.4 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
    filter: grayscale(0.3);
}

.searching .pagination-btn:hover {
    background-color: var(--card-bg) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
    transform: none !important;
}

/* 검색 중 히스토리 전체 삭제 버튼 비활성화 */
.searching #clearHistoryBtn {
    opacity: 0.4 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
    filter: grayscale(0.4);
    transform: none !important;
}

.searching #clearHistoryBtn:hover {
    background-color: var(--card-bg) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
    transform: none !important;
    box-shadow: none !important;
}

/* PDF 모달 스타일 */
.pdf-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-out;
}

.pdf-modal-content {
    background: var(--card-bg);
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    animation: fadeInUp 0.3s ease-out;
}

.pdf-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
}

.pdf-modal-header h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 600;
}

.pdf-modal-close {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    color: var(--text-muted);
}

.pdf-modal-close:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
    transform: scale(1.1);
}

.pdf-modal-body {
    padding: 2rem;
    text-align: center;
}

/* PDF 로딩 상태 */
.pdf-loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.pdf-loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.pdf-loading-state p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin: 0;
}

/* PDF 성공 상태 */
.pdf-success-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.pdf-success-icon {
    color: #22c55e;
    animation: pulse 2s infinite;
}

.pdf-success-state p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin: 0;
}

.pdf-download-btn {
    background: linear-gradient(45deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    text-decoration: none;
}

.pdf-download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0, 212, 255, 0.3);
}

/* PDF 에러 상태 */
.pdf-error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.pdf-error-icon {
    color: #ef4444;
}

.pdf-error-state p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin: 0;
}

.pdf-retry-btn {
    background: var(--hover-bg);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.pdf-retry-btn:hover {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
    transform: translateY(-2px);
}

/* PDF 버튼 스타일 - 복사 버튼과 동일하게 수정 */
.pdf-export-button {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pdf-export-button:hover {
    color: var(--accent-primary);
}

.pdf-export-button svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
}

@media (max-width: 576px) {
    .pdf-modal-content {
        width: 95%;
        margin: 1rem;
    }
    
    .pdf-modal-header {
        padding: 1rem 1.5rem;
    }
    
    .pdf-modal-body {
        padding: 1.5rem;
    }
    
    .pdf-modal-header h3 {
        font-size: 1.3rem;
    }
}

/* 아티팩트 컨테이너 스타일 */
.artifacts-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 1rem 0;
    padding: 0;
}

/* 개별 아티팩트 아이템 스타일 */
.artifact-item {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px var(--shadow-color);
    background: var(--card-bg);
    transition: all 0.3s ease;
}

.artifact-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px var(--shadow-color);
}

/* 이미지 아티팩트 스타일 */
.artifact-image-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    transition: all 0.3s ease;
}

.artifact-image-wrapper:hover {
    background: var(--hover-bg);
}

.artifact-image-wrapper img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    cursor: zoom-in;
    transition: transform 0.3s ease;
}

.artifact-image-wrapper img:hover {
    transform: scale(1.02);
}

.artifact-image-caption {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-align: center;
    font-style: italic;
}

/* 다운로드 가능한 파일 아티팩트 스타일 */
.artifact-download-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    transition: all 0.3s ease;
}

.artifact-download-wrapper:hover {
    background: var(--hover-bg);
    border-color: var(--accent-primary);
}

.artifact-file-info {
    flex-grow: 1;
    margin-right: 1rem;
}

.artifact-file-info > div:first-child {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    font-size: 1rem;
}

.artifact-file-info > div:last-child {
    font-size: 0.875rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.artifact-download-button {
    padding: 0.75rem;
    border: none;
    border-radius: 6px;
    background: var(--accent-primary);
    color: white;
    cursor: pointer;
    transition: var(--transition-slow);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
}

.artifact-download-button:hover {
    background: var(--accent-secondary);
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.artifact-download-button:active {
    transform: scale(0.95);
}

.artifact-download-button svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
}

/* 접근 불가능한 파일 메시지 스타일 */
.artifact-inaccessible-wrapper {
    display: flex;
    align-items: center;
    padding: 1rem;
    border: 1px solid var(--error-border, #fecaca);
    border-radius: 8px;
    background: var(--error-bg, #fef2f2);
    color: var(--error-text, #dc2626);
    animation: shake 0.5s ease-in-out;
}

.artifact-inaccessible-wrapper > div:first-child {
    margin-right: 0.75rem;
    flex-shrink: 0;
}

.artifact-inaccessible-wrapper > div:last-child {
    flex-grow: 1;
}

.artifact-inaccessible-wrapper > div:last-child > div:first-child {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.artifact-inaccessible-wrapper > div:last-child > div:last-child {
    font-size: 0.875rem;
    opacity: 0.9;
}

/* 경고 아이콘 애니메이션 */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-2px); }
    75% { transform: translateX(2px); }
}

/* HTML 아티팩트 스타일 */
.artifact-item[data-type="html"] {
    background: var(--code-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
}

.artifact-item[data-type="html"] * {
    color: var(--text-primary) !important;
}

/* 🔧 HTML 아티팩트 컨테이너 스타일 */
.artifact-html-content {
    position: relative;
    overflow: hidden;
}

/* HTML 아티팩트 내부의 이미지는 로딩 애니메이션 없이 처리 */
.artifact-html-content img,
[data-artifact-html="true"] img {
    display: inline-block !important;
    opacity: 1 !important;
    transition: none !important;
    /* 이미지 로딩 스피너 제거 */
    background: none !important;
    animation: none !important;
}

/* 다크/라이트 테마별 아티팩트 스타일 조정 */
[data-theme="light"] .artifact-image-wrapper,
[data-theme="light"] .artifact-download-wrapper {
    background: #f8fafc;
    border-color: #e2e8f0;
}

[data-theme="light"] .artifact-image-wrapper:hover,
[data-theme="light"] .artifact-download-wrapper:hover {
    background: #f1f5f9;
    border-color: #3b82f6;
}

[data-theme="light"] .artifact-inaccessible-wrapper {
    background: #fef2f2;
    border-color: #fecaca;
    color: #dc2626;
}

[data-theme="dark"] .artifact-image-wrapper,
[data-theme="dark"] .artifact-download-wrapper {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

[data-theme="dark"] .artifact-image-wrapper:hover,
[data-theme="dark"] .artifact-download-wrapper:hover {
    background: var(--hover-bg);
    border-color: var(--accent-primary);
}

[data-theme="dark"] .artifact-inaccessible-wrapper {
    background: #450a0a;
    border-color: #7f1d1d;
    color: #fca5a5;
}

/* Artifact styles moved to main 768px media query above */

/* 아티팩트 로딩 상태 */
.artifact-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: var(--text-secondary);
    font-style: italic;
}

.artifact-loading::before {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top: 2px solid var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 0.5rem;
}

/* 아티팩트 에러 상태 */
.artifact-error {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: var(--error-bg, #fef2f2);
    border: 1px solid var(--error-border, #fecaca);
    border-radius: 8px;
    color: var(--error-text, #dc2626);
    font-size: 0.9rem;
}

.artifact-error::before {
    content: '⚠️';
    margin-right: 0.5rem;
}

/* 파일 타입별 아이콘 스타일 */
.file-type-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    margin-right: 0.5rem;
}

.file-type-icon.pdf { background: #dc2626; color: white; }
.file-type-icon.doc { background: #2563eb; color: white; }
.file-type-icon.txt { background: #6b7280; color: white; }
.file-type-icon.json { background: #059669; color: white; }
.file-type-icon.xml { background: #ea580c; color: white; }
.file-type-icon.csv { background: #16a34a; color: white; }
.file-type-icon.default { background: var(--accent-primary); color: white; }

/* 이미지 로딩 관련 스타일 */
.image-container {
    position: relative;
    display: inline-block;
    max-width: 100%;
}

.image-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    min-height: 200px;
    gap: 1rem;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.image-loading p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0;
}

/* 이미지 에러 관련 스타일 제거됨 - 텍스트로 대체 */

.image-container img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    transition: opacity 0.3s ease;
}

/* 다크/라이트 테마별 이미지 로딩 스타일 */
[data-theme="light"] .image-loading {
    background: #f8fafc;
    border-color: #e2e8f0;
}

[data-theme="dark"] .image-loading {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
}

/* 헤더 검색창 버튼 그룹 */
.header-search-buttons {
    position: absolute;
    right: 6px;
    top: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* 이미지 미리보기 있을 때 좌측 패딩 증가 */
.header-search:has(.image-preview-container:not(:empty)) textarea {
    padding-left:78px;
    padding-right:78px; /* 우측은 유지 */
  }

/* ==============================
   📄 문서 첨부 미리보기 스타일
   ============================== */

/* 문서 미리보기 컨테이너 스타일 (위치는 JavaScript에서 인라인으로 설정) */
.document-preview-container {
    /* position, left, top, transform은 JavaScript에서 인라인으로 설정 */
}

.document-preview-container * {
    pointer-events: auto;
}

.document-preview-item {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    overflow: visible;
    transition: all 0.2s ease;
    background: var(--card-bg);
    flex-shrink: 0;
    height: 40px;
    padding: 0 12px;
    width: 120px; /* 고정 폭 (이미지 미리보기와 동일한 방식) */
    gap: 8px;
}

.document-preview-item:hover {
    border-color: var(--accent-primary);
    box-shadow: 0 2px 8px var(--shadow-color);
    transform: scale(1.05);
}

.document-preview-item .file-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.document-preview-item .file-name {
    font-size: 12px;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.document-delete-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #ef4444;
    color: white;
    border: 2px solid white;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    line-height: 1;
    z-index: 15;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.document-delete-btn:hover {
    background: #dc2626;
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* 헤더 검색창 문서 미리보기 스타일 (위치는 JavaScript에서 설정) */
.header-search .document-preview-container {
    /* position, left, top, transform은 JavaScript에서 인라인으로 설정 */
}

.header-search .document-preview-container * {
    pointer-events: auto;
}

/* 헤더 검색창 문서 미리보기 아이템 크기 조정 */
.header-search .document-preview-item {
    height: 36px; /* 이미지 미리보기와 유사한 크기 */
    width: 100px; /* 고정 폭 (이미지 미리보기와 동일한 방식) */
    padding: 0 10px;
}

.header-search .document-preview-item .file-icon {
    font-size: 16px;
}

.header-search .document-preview-item .file-name {
    font-size: 11px;
}

.header-search .document-delete-btn {
    width: 20px;
    height: 20px;
    font-size: 14px;
    top: -6px;
    right: -6px;
}

/* 모바일 반응형 문서 미리보기 스타일 */
@media (max-width: 768px) {
    .document-preview-item {
        width: 100px; /* 모바일에서도 고정 폭 */
        height: 36px;
        padding: 0 10px;
    }
    
    .document-preview-item .file-icon {
        font-size: 16px;
    }
    
    .document-preview-item .file-name {
        font-size: 11px;
    }
    
    .document-delete-btn {
        width: 20px;
        height: 20px;
        font-size: 14px;
        top: -6px;
        right: -6px;
    }
}

/* 문서 미리보기 패딩은 JavaScript에서 동적 계산하여 적용 */

/* 문서와 이미지 첨부 시 컨테이너 배치는 JavaScript에서 동적으로 처리 */

/* 다크/라이트 테마별 문서 미리보기 스타일 조정 */
[data-theme="light"] .document-preview-item {
    background: #f8fafc;
    border-color: #e2e8f0;
    color: #374151;
}

[data-theme="light"] .document-preview-item:hover {
    background: #f1f5f9;
    border-color: #3b82f6;
}

[data-theme="light"] .document-preview-item .file-name {
    color: #374151;
}

[data-theme="dark"] .document-preview-item {
    background: var(--card-bg);
    border-color: var(--border-color);
    color: var(--text-color);
}

[data-theme="dark"] .document-preview-item:hover {
    background: var(--hover-bg);
}

/* ⭐️ 중단된 세션 스타일 */
.aborted-response {
    background: var(--aborted-bg);
    border: 2px solid var(--aborted-border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin: var(--space-md) 0;
    text-align: center;
    animation: fadeInAborted 0.3s ease-in-out;
}

.aborted-message {
    color: var(--aborted-text);
    font-size: 16px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
}

.aborted-message::before {
    content: "⚠️";
    color: var(--aborted-icon);
    font-size: 20px;
}

@keyframes fadeInAborted {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 중단된 세션 메시지 호버 효과 */
.aborted-response:hover {
    border-color: var(--aborted-icon);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

/* 다크/라이트 테마별 중단된 세션 스타일 조정 */
[data-theme="light"] .aborted-response {
    background: var(--aborted-bg);
    border-color: var(--aborted-border);
    box-shadow: 0 2px 8px rgba(229, 62, 62, 0.1);
}

[data-theme="dark"] .aborted-response {
    background: var(--aborted-bg);
    border-color: var(--aborted-border);
    box-shadow: 0 2px 8px rgba(204, 102, 102, 0.2);
}

[data-theme="dark"] .document-preview-item .file-name {
    color: var(--text-color);
}