/**
 * Podbbang AI Studio - Stylesheet
 */

:root {
    --bg-primary: #fafafa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f0f0f0;
    --bg-hover: #e8e8e8;
    --text-primary: #1a1a2e;
    --text-secondary: #4a4a6a;
    --text-muted: #8888a0;
    --border-color: #e0e0e8;
    --accent-primary: #1fa1eb;
    --accent-secondary: #0d8bd9;
    --accent-gradient: linear-gradient(135deg, #1fa1eb 0%, #0d8bd9 100%);
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
    --shadow-xl: 0 16px 48px rgba(0,0,0,0.16);
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --kakao-bg: #fee500;
    --kakao-text: #000000;
}

[data-theme="dark"] {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a28;
    --bg-hover: #252538;
    --text-primary: #f0f0f8;
    --text-secondary: #a0a0b8;
    --text-muted: #606078;
    --border-color: #2a2a3a;
    --accent-primary: #1fa1eb;
    --accent-secondary: #4db8f0;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
    --shadow-xl: 0 16px 48px rgba(0,0,0,0.5);
}

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

body {
    font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    line-height: 1.6;
    overflow: hidden;
}

html {
    height: 100vh;
    overflow: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(31, 161, 235, 0.12), transparent),
        radial-gradient(ellipse 60% 40% at 100% 100%, rgba(31, 161, 235, 0.08), transparent);
    pointer-events: none;
    z-index: -1;
}

/* ========== Header ========== */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 100;
    backdrop-filter: blur(12px);
}

[data-theme="dark"] .header { background: rgba(18, 18, 26, 0.9); }
[data-theme="light"] .header { background: rgba(255, 255, 255, 0.9); }

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.logo-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-icon svg { width: 100%; height: 100%; }

.logo-text {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.logo-text span { color: var(--accent-primary); }

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* 온라인 사용자 수 */
.online-users {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border-radius: 20px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: default;
}

.online-dot {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4); }
    50% { opacity: 0.8; box-shadow: 0 0 0 4px rgba(34, 197, 94, 0); }
}

.online-count {
    font-weight: 500;
    color: var(--text-primary);
}

.header-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--bg-tertiary);
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: var(--text-secondary);
    font-size: 18px;
}

.header-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon { 
    display: none;
    width: 20px;
    height: 20px;
}

.theme-toggle .icon-sun svg,
.theme-toggle .icon-moon svg {
    width: 100%;
    height: 100%;
    stroke: var(--text-primary);
}

[data-theme="dark"] .theme-toggle .icon-sun { display: flex; }
[data-theme="light"] .theme-toggle .icon-moon { display: flex; }

/* ========== User Menu ========== */
.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px 6px 6px;
    background: var(--bg-tertiary);
    border-radius: 24px;
    cursor: pointer;
    transition: all 0.2s;
}

.user-menu:hover { background: var(--bg-hover); }

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: 600;
    overflow: hidden;
}

.user-avatar img { width: 100%; height: 100%; object-fit: cover; }

.user-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

/* ========== Main Container ========== */
.main-container {
    min-height: 100vh;
    padding-top: 64px;
    display: flex;
    flex-direction: column;
}

/* ========== Login & Status Pages ========== */
.login-page, .status-page {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
}

.login-hero { max-width: 480px; margin-bottom: 48px; }

.login-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 8px 32px rgba(31, 161, 235, 0.4));
}

.login-icon svg { width: 100%; height: 100%; }

.login-title {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 12px;
}

.login-title span { color: var(--accent-primary); }

.login-desc {
    font-size: 16px;
    color: var(--text-secondary);
    line-height: 1.7;
}

.kakao-btn {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 16px 32px;
    background: var(--kakao-bg);
    color: var(--kakao-text);
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow-md);
}

.kakao-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.kakao-btn svg { width: 24px; height: 24px; }

.status-icon {
    width: 72px;
    height: 72px;
    margin-bottom: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
}

.status-icon.pending { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.status-icon.blocked { background: rgba(239, 68, 68, 0.15); color: var(--error); }
.status-icon.insufficient { background: rgba(31, 161, 235, 0.15); color: var(--accent-primary); }

.status-title { font-size: 24px; font-weight: 700; margin-bottom: 12px; }
.status-message { font-size: 15px; color: var(--text-secondary); max-width: 400px; margin-bottom: 32px; line-height: 1.7; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.btn-secondary { background: var(--bg-tertiary); color: var(--text-primary); }
.btn-secondary:hover { background: var(--bg-hover); }

/* ========== Chat Interface ========== */
.chat-page {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    padding: 0;
    overflow: hidden;
    min-height: 0;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Chat Message Styles */
.chat-message {
    display: flex;
    gap: 12px;
    max-width: 100%;
}

.chat-message.user-message {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.message-avatar.user-avatar {
    background: linear-gradient(135deg, var(--accent-primary), #0066cc);
}

.message-avatar.ai-avatar {
    background: transparent;
}

.message-avatar.ai-avatar svg {
    width: 20px;
    height: 20px;
    fill: white;
}

.avatar-text {
    color: white;
    font-size: 14px;
    font-weight: 600;
}

.message-content {
    flex: 1;
    max-width: 80%;
    min-width: 0;
}

.chat-message.user-message .message-content {
    text-align: right;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.chat-message.user-message .message-header {
    justify-content: flex-end;
}

.message-author {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.model-badge {
    font-size: 11px;
    padding: 2px 8px;
    background: var(--bg-tertiary);
    border-radius: 10px;
    color: var(--text-secondary);
}

.message-text {
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-primary);
    padding: 12px 16px;
    border-radius: 16px;
    word-wrap: break-word;
}

.chat-message.user-message .message-text {
    background: linear-gradient(135deg, var(--accent-primary), #0066cc);
    color: white;
    border-radius: 16px 16px 4px 16px;
    display: inline-block;
}

.chat-message.ai-message .message-text {
    background: var(--bg-secondary);
    border-radius: 16px 16px 16px 4px;
}

.message-text.ai-response {
    white-space: pre-wrap;
}

.welcome-message {
    text-align: left;
    padding: 20px;
}

.welcome-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 20px;
    filter: drop-shadow(0 0 40px rgba(31, 161, 235, 0.4));
}

.welcome-icon svg { width: 100%; height: 100%; }
.welcome-message h2 { font-size: 24px; font-weight: 600; margin-bottom: 8px; }
.welcome-message p { font-size: 15px; color: var(--text-secondary); }

/* ========== Messages ========== */
.message {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    animation: fadeIn 0.3s ease;
}

/* 사용자 메시지 - 카카오톡 스타일 오른쪽 정렬 */
.message.user {
    flex-direction: row-reverse;
    justify-content: flex-start;
}

.message.user .message-content {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.message.user .message-role {
    text-align: right;
}

.message.user .message-text {
    background: linear-gradient(135deg, #FEE500, #F0D900);
    color: #3C1E1E;
    border-radius: 16px 4px 16px 16px;
    max-width: 80%;
    text-align: left;
    display: inline-block;
}

[data-theme="dark"] .message.user .message-text {
    background: linear-gradient(135deg, #FEE500, #E6D000);
    color: #3C1E1E;
}

.message.user .user-attached-images {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

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

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
    font-weight: 600;
    overflow: hidden;
}

.message-avatar.user {
    background: linear-gradient(135deg, var(--accent-primary), #0066cc);
    color: white;
    font-weight: 600;
}

/* 사용자 아바타 이미지 스타일 */
.message-avatar.user .user-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* 프로필 이미지가 있을 때 배경색 제거 */
.message-avatar.user:has(.user-avatar-img) {
    background: transparent;
}

.message-avatar.ai {
    background: transparent;
}

.message-avatar.ai svg { width: 100%; height: 100%; }

/* 모델 아바타 이미지 스타일 */
.message-avatar.ai .model-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

/* 다크모드에서 검정 로고 반전 */
[data-theme="dark"] .message-avatar.ai .model-avatar-img.dark-invert,
[data-theme="dark"] .model-icon img.dark-invert,
[data-theme="dark"] .selected-model-logo.dark-invert {
    filter: invert(1);
}

.message-content { flex: 1; min-width: 0; }
.message-role { font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 6px; }
.message-text { font-size: 15px; line-height: 1.7; color: var(--text-primary); background: var(--bg-secondary); padding: 12px 16px; border-radius: 12px; }

/* 메시지 헤더 (이름 + 삭제 버튼) */
.message-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.message.user .message-header {
    flex-direction: row-reverse;
}

.message-delete-btn {
    opacity: 0;
    padding: 4px;
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s;
}

.message:hover .message-delete-btn {
    opacity: 1;
}

.message-delete-btn:hover {
    background: var(--error);
    color: white;
}

/* 사용자 첨부 이미지 스타일 */
.user-attached-images {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.user-attached-images .attached-image-preview {
    max-width: 200px;
    max-height: 200px;
    border-radius: 12px;
    object-fit: cover;
    cursor: pointer;
    transition: transform 0.2s;
}

.user-attached-images .attached-image-preview:hover {
    transform: scale(1.02);
}

/* 첨부 이미지 다운로드 링크 */
.attached-image-link {
    position: relative;
    display: inline-block;
}

.attached-image-link .download-icon {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.2s;
}

.attached-image-link:hover .download-icon {
    opacity: 1;
}

@media (max-width: 768px) {
    .user-attached-images .attached-image-preview {
        max-width: 150px;
        max-height: 150px;
    }
    
    .attached-image-link .download-icon {
        opacity: 1;
        width: 24px;
        height: 24px;
        font-size: 12px;
    }
}

.message-image {
    max-width: 100%;
    border-radius: 12px;
    margin-top: 8px;
    cursor: pointer;
    transition: transform 0.2s;
    box-shadow: var(--shadow-md);
}

.message-image:hover { transform: scale(1.02); }

.message-video {
    max-width: 100%;
    border-radius: 12px;
    margin-top: 8px;
    box-shadow: var(--shadow-md);
}

.model-badge {
    display: inline-block;
    padding: 2px 8px;
    background: var(--accent-primary);
    color: white;
    font-size: 10px;
    font-weight: 600;
    border-radius: 4px;
    margin-left: 8px;
    vertical-align: middle;
}

.chat-response {
    background: var(--bg-tertiary);
    padding: 16px;
    border-radius: 12px;
    margin-top: 8px;
}

/* ========== 마크다운 스타일 ========== */

/* 코드 블록 */
.chat-response .code-block {
    background: #1e1e1e;
    border-radius: 8px;
    margin: 12px 0;
    overflow: hidden;
}

/* 코드 헤더 (언어명, 복사 버튼) */
.chat-response .code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #2d2d2d;
    border-bottom: 1px solid #404040;
}

.chat-response .code-lang {
    font-size: 12px;
    color: #888;
    text-transform: uppercase;
    font-weight: 500;
}

.chat-response .copy-code-btn {
    font-size: 12px;
    padding: 4px 10px;
    background: transparent;
    border: 1px solid #555;
    border-radius: 4px;
    color: #aaa;
    cursor: pointer;
    transition: all 0.2s;
}

.chat-response .copy-code-btn:hover {
    background: #404040;
    color: #fff;
}

.chat-response .copy-code-btn.copied {
    background: #22c55e;
    border-color: #22c55e;
    color: #fff;
}

/* 코드 본문 (줄번호 + 코드) */
.chat-response .code-body {
    display: flex;
    overflow-x: auto;
}

/* 줄번호 */
.chat-response .line-numbers {
    display: flex;
    flex-direction: column;
    padding: 12px 0;
    background: #252525;
    border-right: 1px solid #404040;
    user-select: none;
    flex-shrink: 0;
}

.chat-response .line-numbers .line-num {
    padding: 0 12px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    line-height: 1.5;
    color: #6b7280;
    text-align: right;
    min-width: 32px;
}

/* 코드 영역 */
.chat-response .code-body pre {
    margin: 0;
    padding: 0;
    background: transparent;
    flex: 1;
    overflow-x: auto;
}

.chat-response .code-body code {
    display: block;
    padding: 12px 16px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 13px;
    line-height: 1.5;
    background: transparent;
    white-space: pre;
}

/* 인라인 코드 */
.chat-response .inline-code {
    background: var(--bg-hover);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.9em;
    color: #e06c75;
}

[data-theme="light"] .chat-response .inline-code {
    background: #f3f4f6;
    color: #e01e5a;
}

/* 테이블 */
.chat-response .table-wrapper {
    overflow-x: auto;
    margin: 12px 0;
}

.chat-response .markdown-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.chat-response .markdown-table th,
.chat-response .markdown-table td {
    border: 1px solid var(--border-color);
    padding: 10px 14px;
    text-align: left;
}

.chat-response .markdown-table th {
    background: var(--bg-secondary);
    font-weight: 600;
}

.chat-response .markdown-table tr:nth-child(even) {
    background: var(--bg-secondary);
}

/* 목록 */
.chat-response ul,
.chat-response ol {
    margin: 8px 0;
    padding-left: 24px;
}

.chat-response li {
    margin: 4px 0;
    line-height: 1.6;
}

.chat-response li > ul,
.chat-response li > ol {
    margin: 4px 0;
}

/* 인용문 */
.chat-response blockquote {
    border-left: 4px solid var(--accent-primary);
    margin: 12px 0;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border-radius: 0 8px 8px 0;
    color: var(--text-secondary);
}

.chat-response blockquote p {
    margin: 0;
}

/* 제목 */
.chat-response h1,
.chat-response h2,
.chat-response h3,
.chat-response h4,
.chat-response h5,
.chat-response h6 {
    margin: 16px 0 8px 0;
    font-weight: 600;
    line-height: 1.4;
}

.chat-response h1 { font-size: 1.5em; }
.chat-response h2 { font-size: 1.35em; }
.chat-response h3 { font-size: 1.2em; }
.chat-response h4 { font-size: 1.1em; }

/* 수평선 */
.chat-response hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 16px 0;
}

/* 링크 */
.chat-response a {
    color: var(--accent-primary);
    text-decoration: none;
}

.chat-response a:hover {
    text-decoration: underline;
}

/* 강조 */
.chat-response strong {
    font-weight: 600;
}

.chat-response em {
    font-style: italic;
}

/* 이미지 */
.chat-response img {
    max-width: 100%;
    border-radius: 8px;
    margin: 8px 0;
}

/* ========== LaTeX 수식 스타일 ========== */

.chat-response .math-block {
    overflow-x: auto;
    padding: 16px;
    margin: 12px 0;
    background: var(--bg-secondary);
    border-radius: 8px;
    text-align: center;
}

.chat-response .math-inline {
    padding: 0 2px;
}

.chat-response .math-error {
    color: #ef4444;
    font-family: monospace;
}

/* KaTeX 스타일 조정 */
.chat-response .katex {
    font-size: 1.1em;
}

.chat-response .katex-display {
    margin: 0;
    overflow-x: auto;
    overflow-y: hidden;
}

/* 다크모드 KaTeX */
[data-theme="dark"] .chat-response .katex {
    color: var(--text-primary);
}

/* 기존 코드 스타일 (호환성) */
.chat-response pre {
    background: var(--bg-primary);
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
}

.chat-response code {
    font-family: 'JetBrains Mono', 'Fira Code', 'Monaco', 'Consolas', monospace;
    font-size: 13px;
}

.chat-response pre code {
    background: none;
    padding: 0;
}

.chat-response code:not(pre code):not(.inline-code):not(.hljs) {
    background: var(--bg-hover);
    padding: 2px 6px;
    border-radius: 4px;
}

/* ========== Sound Player ========== */
.sound-player {
    margin-top: 8px;
}

.sound-player .message-audio {
    width: 100%;
    max-width: 400px;
    border-radius: 8px;
    margin-bottom: 8px;
}

.sound-info {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
    align-items: center;
}

.sound-info span {
    display: flex;
    align-items: center;
}

.sound-info .cost-icon {
    width: 12px;
    height: 12px;
    margin-right: 4px;
    opacity: 0.8;
}

.sound-info .badge-free {
    background: var(--success);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
}

/* ========== Video Processing ========== */
.video-processing {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    margin-top: 8px;
}

/* 동영상 완료 시 레이아웃 */
.video-processing:has(video) {
    display: block;
    padding: 0;
    background: transparent;
}

.video-processing .message-video {
    width: 100%;
    max-width: 640px;
    border-radius: 12px;
    margin-bottom: 8px;
}

.video-processing .video-info {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
    align-items: center;
}

.video-processing .video-info span {
    display: flex;
    align-items: center;
}

.video-processing .message-actions {
    display: flex;
    gap: 8px;
}

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

.processing-status {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.processing-time {
    font-size: 12px;
    color: var(--text-muted);
}

/* 동영상 생성 상태 UI */
.video-status-container {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    width: 100%;
}

.video-status-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.video-status-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.video-elapsed-time {
    font-size: 12px;
    color: var(--text-muted);
}

.video-progress-bar {
    width: 100%;
    max-width: 300px;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
}

.video-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary, #00d4ff));
    border-radius: 3px;
    transition: width 0.5s ease;
}

.video-info {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 8px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    align-items: center;
}

.video-info .cost-icon,
.video-processing .video-info .cost-icon {
    width: 12px;
    height: 12px;
    margin-right: 4px;
    opacity: 0.8;
    vertical-align: middle;
}

.english-prompt {
    background: var(--surface-secondary);
    border-left: 3px solid var(--accent-primary);
    padding: 8px 12px;
    margin-bottom: 12px;
    border-radius: 0 6px 6px 0;
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.english-prompt .prompt-label {
    font-weight: 600;
    color: var(--accent-primary);
}

/* 변환된 프롬프트 박스 (이미지 전 표시) */
.translated-prompt-box {
    background: linear-gradient(135deg, var(--surface-secondary) 0%, var(--surface-tertiary) 100%);
    border: 1px solid var(--border-color);
    border-left: 4px solid #4CAF50;
    border-radius: 0 8px 8px 0;
    padding: 12px 16px;
    margin-top: 8px;
}

.translated-prompt-label {
    font-size: 11px;
    font-weight: 600;
    color: #4CAF50;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.translated-prompt-text {
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.6;
    font-style: italic;
}

.message-meta {
    display: flex;
    gap: 16px;
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-muted);
}

.message-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.action-btn {
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.action-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* ========== Cost Info ========== */
.cost-info {
    margin-top: 12px;
    padding: 10px 14px;
    background: linear-gradient(135deg, rgba(31, 161, 235, 0.08), rgba(16, 185, 129, 0.08));
    border: 1px solid rgba(31, 161, 235, 0.2);
    border-radius: 10px;
    font-size: 12px;
}

.cost-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
}

.cost-row:not(:last-child) {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.cost-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.cost-value {
    color: var(--text-primary);
    font-family: 'Fira Code', monospace;
    font-size: 11px;
}

.cost-row.web-search-cost .cost-label {
    color: #10b981;
}

.cost-row.web-search-cost .cost-value {
    color: #10b981;
}

.cost-row.topic-total {
    margin-top: 4px;
    padding-top: 8px;
    border-top: 1px dashed rgba(31, 161, 235, 0.3);
}

.cost-row.topic-total .cost-label {
    color: var(--accent-primary);
}

.cost-row.topic-total .cost-value {
    color: var(--accent-primary);
    font-weight: 600;
}

/* Mini cost info (한 줄 표시) */
.message-cost-mini {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 8px;
    font-family: 'Fira Code', monospace;
    display: flex;
    align-items: center;
    gap: 2px;
    flex-wrap: wrap;
}

.message-cost-mini .cost-icon {
    width: 12px;
    height: 12px;
    margin-right: 2px;
    margin-left: 8px;
    opacity: 0.8;
}

.message-cost-mini .cost-icon:first-child {
    margin-left: 0;
}

/* 무료 표시 포인트 색상 */
.cost-free {
    color: #10b981;
    font-weight: 600;
}

/* 라이트 모드에서 더 진하게 */
[data-theme="light"] .message-cost-mini {
    color: #555;
}

[data-theme="light"] .cost-free {
    color: #059669;
}

/* 탭 잠금 (대화 중 다른 탭 숨김) */
.input-tab.tab-locked {
    display: none;
}

/* ========== Loading ========== */
.loading-status {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.loading-timer {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-family: 'SF Mono', Monaco, monospace;
}

.loading-dots {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background: var(--accent-primary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* ========== Input Tabs ========== */
.input-tabs-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 0 0 12px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 12px;
    position: relative;
    z-index: 100;
}

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

.model-selector-right {
    flex-shrink: 0;
}

.model-selector-right .model-dropdown {
    position: relative;
}

.model-selector-right .model-select-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.selected-model-logo {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    object-fit: cover;
}

.model-selector-right .model-select-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
}

.model-selector-right .model-options {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    left: auto;
    min-width: 240px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.2s;
    z-index: 9999;
    text-align: left;
}

.model-selector-right .model-dropdown.open .model-options {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.model-selector-right .coming-soon-badge {
    padding: 8px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

.input-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-radius: 10px;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.input-tab:hover {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.input-tab.active {
    background: var(--accent-primary);
    color: white;
}

.input-tab .tab-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.input-tab .tab-label {
    font-family: inherit;
}

/* ========== Model Selector ========== */
.model-selector {
    margin-bottom: 12px;
}

.model-dropdown {
    position: relative;
}

.model-select-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.model-select-btn:hover {
    border-color: var(--accent-primary);
    background: var(--bg-hover);
}

.model-select-btn .model-arrow {
    font-size: 10px;
    color: var(--text-muted);
    transition: transform 0.2s;
}

.model-dropdown.open .model-arrow {
    transform: rotate(180deg);
}

.model-options {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    left: auto;
    min-width: 240px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.2s ease;
    overflow: hidden;
    max-height: 300px;
    overflow-y: auto;
}

.model-dropdown.open .model-options {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.model-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.15s;
}

.model-option:hover {
    background: var(--bg-hover);
}

.model-option.active {
    background: rgba(31, 161, 235, 0.1);
}

.model-option .model-icon {
    font-size: 20px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border-radius: 8px;
}

.model-option .model-icon img {
    width: 20px;
    height: 20px;
    object-fit: contain;
    border-radius: 4px;
}

.model-option .model-icon-img {
    width: 32px;
    height: 32px;
    object-fit: contain;
    border-radius: 8px;
}

/* 다크모드에서 검정색 로고 반전 (ChatGPT, Grok) */
[data-theme="dark"] .model-option .model-icon.chatgpt-icon img,
[data-theme="dark"] .model-option .model-icon.grok-icon img {
    filter: invert(1);
}

.model-option .model-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.model-option .model-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.model-option .model-desc {
    font-size: 12px;
    color: var(--text-muted);
}

.model-option .model-desc.badge-pro::after {
    content: 'PRO';
    display: inline-block;
    margin-left: 6px;
    padding: 2px 6px;
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    color: #000;
    font-size: 9px;
    font-weight: 700;
    border-radius: 4px;
    vertical-align: middle;
}

.badge-free {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 8px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    border-radius: 4px;
    vertical-align: middle;
}

/* ========== Coming Soon Badge ========== */
.model-coming-soon {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background: var(--bg-tertiary);
    border: 2px dashed var(--border-color);
    border-radius: 12px;
}

.coming-soon-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
}

.coming-soon-icon {
    font-size: 32px;
    animation: pulse 2s infinite;
}

.coming-soon-text {
    font-size: 14px;
    font-weight: 500;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ========== Input Area ========== */
.input-area {
    padding: 16px 24px 24px;
    background: transparent;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
    width: 100%;
    box-sizing: border-box;
    overflow: visible;
}

.input-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 12px 16px;
    transition: all 0.2s;
}

/* 입력 영역 (textarea + buttons) */
.input-wrapper .input-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

/* 이미지 미리보기 컨테이너 */
.image-preview-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.image-preview-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.image-preview-item {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid var(--border-color);
    background: var(--bg-tertiary);
}

.image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-preview-item .remove-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    line-height: 1;
    transition: background 0.2s;
}

.image-preview-item .remove-btn:hover {
    background: rgba(239, 68, 68, 0.9);
}

.image-preview-item.uploading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Hailuo-02 프레임 선택 라디오 버튼 */
.image-preview-item.with-frame-selector {
    width: auto;
    min-width: 80px;
    height: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 6px;
}

.image-preview-item.with-frame-selector img {
    width: 80px;
    height: 80px;
    border-radius: 6px;
}

.frame-selector {
    display: flex;
    gap: 4px;
    justify-content: center;
}

.frame-radio {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 3px 6px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 10px;
    color: var(--text-muted);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    transition: all 0.2s;
}

.frame-radio input[type="radio"] {
    display: none;
}

.frame-radio.active,
.frame-radio:has(input:checked) {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.frame-radio:hover:not(.active) {
    background: var(--bg-tertiary);
    border-color: var(--accent-primary);
}

.frame-radio span {
    font-weight: 500;
}

/* 드래그 오버 스타일 */
.input-wrapper.drag-over {
    border-color: var(--accent-primary);
    background: rgba(31, 161, 235, 0.1);
}

.input-wrapper:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(31, 161, 235, 0.1);
}

.input-wrapper.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.model-unavailable-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    z-index: 10;
    backdrop-filter: blur(2px);
}

.unavailable-icon {
    font-size: 20px;
}

.unavailable-text {
    font-size: 15px;
    font-weight: 600;
    color: white;
}

.prompt-input {
    flex: 1;
    border: none;
    background: none;
    font-size: 15px;
    color: var(--text-primary);
    resize: none;
    outline: none;
    min-height: 24px;
    max-height: 150px;
    font-family: inherit;
    line-height: 1.5;
}

.prompt-input::placeholder { color: var(--text-muted); }

/* 상단 액션 버튼들 (첨부, 웹검색, 추론 등) */
.input-actions-top {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 8px;
    flex-wrap: wrap;
}

.input-actions {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.web-search-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--bg-tertiary);
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s;
    color: var(--text-secondary);
}

.web-search-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.web-search-btn.active {
    background: linear-gradient(135deg, #10b981, #059669);
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.4);
    color: #fff;
}

/* 번역 버튼 */
.translate-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--bg-tertiary);
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s;
    color: var(--text-secondary);
}

.translate-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.translate-btn.active {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    box-shadow: 0 0 12px rgba(139, 92, 246, 0.4);
    color: #fff;
}

/* 첨부파일 버튼 */
.attach-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--bg-tertiary);
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: var(--text-secondary);
}

.attach-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.attach-btn.has-images {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.4);
}

.attach-btn svg {
    stroke: currentColor;
}

/* Grok 검색 버튼 */
.grok-search-btn {
    height: 40px;
    padding: 0 12px;
    border: none;
    background: var(--bg-tertiary);
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 14px;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.grok-search-btn:hover {
    background: var(--bg-hover);
}

.grok-search-btn.active.x {
    background: linear-gradient(135deg, #1d9bf0, #0c7abf);
    color: white;
    box-shadow: 0 0 12px rgba(29, 155, 240, 0.4);
}

.grok-search-btn.active.web {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.4);
}

.grok-search-btn .grok-search-icon {
    font-size: 14px;
}

.grok-search-btn .grok-search-text {
    font-size: 12px;
    font-weight: 500;
}

/* Grok 추론 버튼 */
.grok-reasoning-btn {
    height: 40px;
    padding: 0 12px;
    border: none;
    background: var(--bg-tertiary);
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 14px;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.grok-reasoning-btn:hover {
    background: var(--bg-hover);
    color: #f97316;
}

.grok-reasoning-btn.active {
    background: linear-gradient(135deg, #f97316, #ea580c);
    color: white;
    box-shadow: 0 0 12px rgba(249, 115, 22, 0.4);
}

.grok-reasoning-btn svg {
    width: 16px;
    height: 16px;
}

.grok-reasoning-btn span {
    font-size: 12px;
    font-weight: 500;
}

.settings-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--bg-tertiary);
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 18px;
    transition: all 0.2s;
}

.settings-btn:hover {
    background: var(--bg-hover);
    color: var(--accent-primary);
}

.settings-btn.active {
    background: var(--accent-primary);
    color: white;
}

.send-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--accent-gradient);
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: all 0.2s;
}

.send-btn:hover { transform: scale(1.05); }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.send-btn .spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ========== Settings Info ========== */
.settings-info {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 0 0;
    font-size: 12px;
    color: var(--text-muted);
    width: 100%;
    box-sizing: border-box;
}

.settings-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: var(--bg-tertiary);
    border-radius: 6px;
}

.prompt-counter {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

.prompt-counter.warning {
    color: #f59e0b;
}

.prompt-counter.danger {
    color: #ef4444;
}

/* ========== Toggle Switch ========== */
.toggle-setting {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
}

.toggle-switch {
    position: relative;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    transition: 0.3s;
    border-radius: 26px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 2px;
    bottom: 2px;
    background-color: var(--text-muted);
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(22px);
    background-color: white;
}

.toggle-description {
    font-size: 13px;
    color: var(--text-secondary);
}

.setting-hint {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ========== Modal ========== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

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

.modal {
    background: var(--bg-secondary);
    border-radius: 20px;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

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

.modal-title {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg-tertiary);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 18px;
    transition: all 0.2s;
}

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

.modal-body { padding: 24px; }

.setting-group { margin-bottom: 24px; }
.setting-group:last-child { margin-bottom: 0; }

.setting-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.setting-select {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.setting-select:hover {
    border-color: var(--primary);
}

.setting-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(75, 123, 236, 0.1);
}

.setting-select option {
    padding: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* 설정 슬라이더 */
.setting-slider {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-tertiary);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    margin: 8px 0;
}

.setting-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    border: 3px solid var(--primary);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    transition: all 0.15s;
}

.setting-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(75, 123, 236, 0.5);
    border-color: var(--primary-hover);
}

.setting-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    border: 3px solid var(--primary);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.setting-value {
    float: right;
    font-weight: 600;
    color: var(--primary);
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* 음성 성별 탭 */
.voice-gender-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.voice-gender-tab {
    flex: 1;
    padding: 10px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.voice-gender-tab:hover {
    border-color: var(--primary);
    color: var(--text-primary);
}

.voice-gender-tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.size-presets {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.size-preset {
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.size-preset:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.size-preset.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.size-preset.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.number-presets {
    grid-template-columns: repeat(4, 1fr);
}

.setting-info {
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: 10px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.setting-info p {
    margin: 4px 0;
}

.setting-info strong {
    color: var(--text-primary);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s;
}

.checkbox-label:hover {
    background: var(--bg-hover);
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-primary);
}

.setting-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.setting-input-group { display: flex; flex-direction: column; gap: 6px; }
.setting-input-label { font-size: 12px; color: var(--text-muted); }

.setting-input {
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
    width: 100%;
}

.setting-input:focus { border-color: var(--accent-primary); }

/* ========== Server Status ========== */
.server-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-radius: 10px;
    font-size: 13px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

.status-dot.online {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.status-dot.offline { background: var(--error); }

/* ========== Lightbox ========== */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.lightbox.active { display: flex; }

.lightbox img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    border: none;
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
    color: white;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.2s;
}

.lightbox-close:hover { background: rgba(255,255,255,0.2); }

/* ========== Dropdown ========== */
.dropdown { position: relative; }

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    min-width: 180px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s;
    z-index: 1000;
    overflow: hidden;
}

.dropdown.active .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    font-size: 14px;
    color: var(--text-primary);
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s;
}

.dropdown-item:hover { background: var(--bg-hover); }
.dropdown-item.danger { color: var(--error); }
.dropdown-divider { height: 1px; background: var(--border-color); margin: 4px 0; }

/* 드롭다운 헤더 (프로필 정보) */
.dropdown-header {
    padding: 12px 16px;
}

.dropdown-user-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.dropdown-user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.dropdown-user-email {
    font-size: 12px;
    color: var(--text-muted);
}

/* 드롭다운 통계 */
.dropdown-stats {
    padding: 8px 16px;
}

.dropdown-stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 13px;
}

.dropdown-stat-item .stat-label {
    color: var(--text-muted);
}

.dropdown-stat-item .stat-value {
    color: var(--text-primary);
    font-weight: 500;
}

/* ========== Tablet (1000px 이하) - 탭 아이콘만 표시 ========== */
@media (max-width: 1000px) {
    .input-tab .tab-label { display: none; }
    .input-tab .tab-icon { font-size: 18px; }
    .input-tab { padding: 10px 14px; }
}

/* ========== Mobile ========== */
@media (max-width: 640px) {
    html {
        zoom: 0.8; /* 모바일 전체 화면 20% 축소 */
    }
    .header { padding: 0 16px; }
    .logo-text { display: none; }
    .user-name { display: none; }
    .chat-messages { padding: 16px; }
    .input-area { padding: 12px 16px 16px; }
    .welcome-message { padding: 16px; }
    .welcome-message h2 { font-size: 20px; }
    .size-presets { grid-template-columns: repeat(2, 1fr); }
    
    .input-tabs {
        gap: 2px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    .input-tabs::-webkit-scrollbar { display: none; }
    
    .input-tab {
        padding: 8px 12px;
        font-size: 13px;
        flex-shrink: 0;
    }
    
    .model-select-btn {
        padding: 10px 14px;
        font-size: 13px;
    }
}

/* ========== Scrollbar ========== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ========== App Container with Sidebar ========== */
.app-container {
    display: flex;
    height: calc(100vh - 64px);  /* 헤더 높이 제외 */
    overflow: hidden;
}

/* ========== PC Sidebar ========== */
.sidebar {
    width: 280px;
    height: 100%;  /* app-container 높이에 맞춤 */
    max-height: 100%;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
    transition: transform 0.3s ease, width 0.3s ease;
}

.sidebar-header {
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.sidebar-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.new-chat-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--accent-gradient);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}

.new-chat-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(31, 161, 235, 0.3);
}

.new-chat-btn svg {
    flex-shrink: 0;
}

.sidebar-search {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.search-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(31, 161, 235, 0.1);
}

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

.sidebar-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 8px 0;
}

.topic-section {
    padding: 0 8px;
    margin-bottom: 16px;
}

.topic-section:empty,
.topic-section .topic-list:empty {
    display: none;
}

.topic-section-title {
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.topic-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.topic-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
    position: relative;
    group: topic;
}

.topic-item:hover {
    background: var(--bg-hover);
}

.topic-item.active {
    background: var(--bg-tertiary);
}

.topic-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--accent-primary);
    border-radius: 0 3px 3px 0;
}

.topic-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.topic-icon svg {
    width: 16px;
    height: 16px;
    stroke: var(--text-secondary);
    fill: none;
}

/* 선택/호버 시 아이콘 색상 */
.topic-item.active .topic-icon svg,
.topic-item:hover .topic-icon svg {
    stroke: var(--accent-primary);
}

/* 라이트 모드에서 선택된 토픽 아이콘 강조 */
[data-theme="light"] .topic-item.active .topic-icon svg {
    stroke: #1fa1eb;
    stroke-width: 2.5;
}

/* 다크 모드에서 선택된 토픽 아이콘 */
[data-theme="dark"] .topic-item.active .topic-icon svg {
    stroke: #4db8f0;
}

.topic-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.topic-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topic-date {
    font-size: 11px;
    color: var(--text-muted);
}

.topic-actions {
    display: none;
    gap: 4px;
}

.topic-item:hover .topic-actions {
    display: flex;
}

.topic-action-btn {
    padding: 4px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.topic-action-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.topic-action-btn.delete:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

.sidebar-footer {
    padding: 10px 12px;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
    background: var(--bg-secondary);
}

/* 월간 사용량 패널 */
.usage-panel {
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 8px 10px;
    margin-bottom: 8px;
}

.usage-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.usage-title {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}

.usage-title svg {
    color: var(--text-primary);
}

.usage-value {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
}

/* $ 기호는 프로그래스바 색상에 맞춤 */
.usage-dollar {
    color: #10b981;
}

.usage-dollar.warning {
    color: #f59e0b;
}

.usage-dollar.danger {
    color: #ef4444;
}

.usage-progress-container {
    height: 4px;
    background: var(--bg-secondary);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 4px;
}

.usage-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #10b981, #34d399);
    border-radius: 2px;
    transition: width 0.5s ease;
}

/* 사용량이 70% 이상일 때 */
.usage-progress-bar.warning {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

/* 사용량이 95% 이상일 때 */
.usage-progress-bar.danger {
    background: linear-gradient(90deg, #ef4444, #f87171);
}

.usage-details {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: var(--text-muted);
}

.usage-limit {
    opacity: 0.7;
}

.usage-percent {
    font-weight: 600;
}

/* 프로필 래퍼 */
.user-profile-wrapper {
    position: relative;
}

.profile-arrow {
    margin-left: auto;
    opacity: 0.5;
    transition: transform 0.2s;
}

.user-info-mini:hover .profile-arrow {
    opacity: 1;
}

.user-profile-wrapper.active .profile-arrow {
    transform: rotate(180deg);
}

/* 프로필 팝업 */
.profile-popup {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 8px;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.2s ease;
    z-index: 100;
}

.profile-popup.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.profile-popup-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 10px;
}

.popup-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.popup-user-info {
    flex: 1;
    min-width: 0;
}

.popup-user-name {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.popup-user-email {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-popup-stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.popup-stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.popup-stat-label {
    font-size: 11px;
    color: var(--text-muted);
}

.popup-stat-value {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}

.user-info-mini {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 8px;
    transition: background 0.15s;
    cursor: pointer;
}

.user-info-mini:hover {
    background: var(--bg-hover);
}

.user-avatar-mini {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg-tertiary);
    flex-shrink: 0;
}

.user-name-mini {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ========== Mobile Topbar ========== */
.mobile-topbar {
    display: none;
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    height: 48px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    z-index: 90;
}

.mobile-menu-btn,
.mobile-new-chat {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.15s;
}

.mobile-menu-btn:hover,
.mobile-new-chat:hover {
    background: var(--bg-hover);
}

.mobile-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    max-width: calc(100% - 100px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Mobile Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 199;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* ========== Chat Page in Sidebar Layout ========== */
.app-container .chat-page {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100%;  /* app-container 높이에 맞춤 */
    padding-top: 0;
}

.app-container .chat-messages {
    padding-top: 24px;
}

/* ========== Mobile Responsive ========== */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 300px;
        height: 100vh;
        z-index: 200;
        transform: translateX(-100%);
        padding-top: 64px;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .mobile-topbar {
        display: flex;
    }

    /* main-container에 이미 padding-top: 64px가 있으므로, 모바일 탑바 48px만 추가 */
    .app-container {
        padding-top: 48px; /* 모바일 탑바 높이만 추가 */
        height: calc(100dvh - 64px); /* dvh 사용 - 모바일 브라우저 대응 */
        height: calc(100vh - 64px); /* fallback for older browsers */
    }
    
    /* dvh 지원 브라우저용 */
    @supports (height: 100dvh) {
        .app-container {
            height: calc(100dvh - 64px);
        }
    }

    .app-container .chat-page {
        height: 100%; /* app-container 높이에 맞춤 */
        padding-bottom: 0;
    }
    
    /* 모바일 입력창 - 화면 하단 고정 */
    .input-area {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 100;
        background: var(--bg-primary);
        padding: 12px 16px;
        padding-bottom: max(16px, env(safe-area-inset-bottom, 16px));
        border-top: 1px solid var(--border-color);
    }
    
    /* 채팅 메시지 영역 - 입력창 높이만큼 하단 여백 */
    .app-container .chat-messages {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        padding-bottom: 240px; /* 입력 영역 높이 + 여유 공간 (탭, 아이콘, 입력창, 모델선택 포함) */
    }
    
    /* 입력 영역 하단 여백 확보 */
    .input-wrapper {
        margin-bottom: 4px;
    }
    
    /* 전송 버튼이 항상 보이도록 */
    .input-row {
        min-height: 44px;
    }
    
    /* settings-info 여백 */
    .settings-info {
        padding-bottom: 4px;
    }
}

/* ========== Empty State ========== */
.empty-topics {
    padding: 24px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.empty-topics-icon {
    font-size: 32px;
    margin-bottom: 8px;
    opacity: 0.5;
}

/* ========== Topic Edit Mode ========== */
.topic-item.editing .topic-title {
    background: var(--bg-primary);
    border: 1px solid var(--accent-primary);
    border-radius: 4px;
    padding: 2px 6px;
    outline: none;
}

/* ========== Context Menu ========== */
.context-menu {
    position: fixed;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    padding: 4px;
    min-width: 160px;
    z-index: 1000;
    display: none;
}

.context-menu.active {
    display: block;
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    font-size: 13px;
    color: var(--text-primary);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
}

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

.context-menu-item.danger {
    color: var(--error);
}

.context-menu-item.danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* ========== Toast Messages ========== */
.toast-message {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 12px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 9999;
    opacity: 0;
    transition: all 0.3s ease;
    min-width: 280px;
    justify-content: center;
}

.toast-message.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast-message.toast-warning {
    border-color: #f59e0b;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), var(--bg-secondary));
}

.toast-icon {
    font-size: 18px;
}

.toast-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

/* ========== Pending Videos Notification ========== */
.pending-videos-notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 380px;
    max-width: calc(100vw - 40px);
    background: var(--bg-secondary);
    border: 1px solid var(--accent-primary);
    border-radius: 16px;
    box-shadow: var(--shadow-lg), 0 0 20px rgba(31, 161, 235, 0.2);
    z-index: 1000;
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.pending-videos-notification.hiding {
    animation: slideOutRight 0.3s ease forwards;
}

@keyframes slideOutRight {
    to {
        opacity: 0;
        transform: translateX(100px);
    }
}

.notification-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    color: var(--text-primary);
}

.notification-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s;
}

.notification-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.pending-videos-list {
    max-height: 300px;
    overflow-y: auto;
}

.pending-video-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    gap: 12px;
}

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

.pending-video-info {
    flex: 1;
    min-width: 0;
}

.pending-video-prompt {
    display: block;
    font-size: 13px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.pending-video-meta {
    font-size: 11px;
    color: var(--text-muted);
}

.pending-video-actions {
    flex-shrink: 0;
}

.btn-resume {
    padding: 6px 12px;
    font-size: 12px;
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-resume:hover {
    background: var(--accent-hover);
    transform: scale(1.02);
}

.notification-actions {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
}

.btn-resume-all {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    background: linear-gradient(135deg, var(--accent-primary), #0ea5e9);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-resume-all:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(31, 161, 235, 0.3);
}

/* ========== Image Editor Modal ========== */
.image-editor-modal {
    max-width: 90vw;
    max-height: 90vh;
    width: 900px;
}

.image-editor-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 0;
    max-height: calc(90vh - 140px);
    overflow: hidden;
}

.editor-toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    flex-wrap: wrap;
}

.tool-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tool-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-primary);
}

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

.tool-btn.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.tool-btn svg {
    stroke: currentColor;
}

.draw-options, .crop-options {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-left: 16px;
    border-left: 1px solid var(--border-color);
}

.apply-crop-btn {
    width: auto !important;
    padding: 8px 16px !important;
    font-size: 14px;
    font-weight: 500;
    background: var(--accent-primary) !important;
    color: white !important;
    border: none !important;
}

.apply-crop-btn:hover {
    background: var(--accent-secondary) !important;
}

.draw-options input[type="color"] {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    padding: 2px;
}

.draw-options select {
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
}

.editor-canvas-container {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border-radius: 8px;
    overflow: hidden;
    min-height: 400px;
}

#editorCanvas, #drawCanvas {
    position: absolute;
    max-width: 100%;
    max-height: 100%;
}

#drawCanvas {
    pointer-events: none;
}

#drawCanvas.active {
    pointer-events: auto;
    cursor: crosshair;
}

.crop-overlay {
    position: absolute;
    pointer-events: auto;
    overflow: hidden;
}

.crop-box {
    position: absolute;
    border: 2px dashed var(--accent-primary);
    background: transparent;
    cursor: move;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.6);
    z-index: 10;
}

.crop-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--accent-primary);
    border: 2px solid white;
    border-radius: 50%;
}

.crop-handle.nw { top: -6px; left: -6px; cursor: nw-resize; }
.crop-handle.ne { top: -6px; right: -6px; cursor: ne-resize; }
.crop-handle.sw { bottom: -6px; left: -6px; cursor: sw-resize; }
.crop-handle.se { bottom: -6px; right: -6px; cursor: se-resize; }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
}

.modal-footer .btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-footer .btn-secondary {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.modal-footer .btn-secondary:hover {
    background: var(--bg-hover);
}

.modal-footer .btn-primary {
    background: var(--accent-primary);
    border: none;
    color: white;
}

.modal-footer .btn-primary:hover {
    background: var(--accent-secondary);
}

@media (max-width: 768px) {
    .image-editor-modal {
        max-width: 100vw;
        max-height: 100vh;
        width: 100%;
        height: 100%;
        border-radius: 0;
    }
    
    .editor-toolbar {
        padding: 8px;
        gap: 8px;
    }
    
    .tool-btn {
        width: 36px;
        height: 36px;
    }
    
    .editor-canvas-container {
        min-height: 300px;
    }
}

/* Pending Message Styles */
.pending-message .message-content {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.1) 0%, rgba(245, 158, 11, 0.05) 100%);
    border: 1px dashed var(--warning);
    border-radius: 12px;
    padding: 16px;
}

.pending-info {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.pending-icon {
    font-size: 32px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.pending-text p {
    margin: 0 0 8px 0;
}

.pending-text p:last-child {
    margin-bottom: 0;
}

.pending-prompt {
    color: var(--text-secondary);
    font-style: italic;
    background: var(--bg-tertiary);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.9em;
    word-break: break-word;
}

.pending-time {
    font-size: 0.85em;
    color: var(--text-muted);
}

.pending-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.pending-retry-btn {
    background: var(--accent-primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background 0.2s;
}

.pending-retry-btn:hover {
    background: var(--accent-secondary);
}

.pending-cancel-btn {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.2s;
}

.pending-cancel-btn:hover {
    background: var(--bg-hover);
    color: var(--error);
    border-color: var(--error);
}

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

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Profile Setup Form */
.profile-setup {
    max-width: 400px;
    margin: 0 auto;
    padding-top: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: auto;
}

.profile-logo {
    width: 80px;
    height: 80px;
    margin-bottom: 16px;
}

.profile-logo svg {
    width: 100%;
    height: 100%;
}

.profile-ip {
    display: inline-block;
    padding: 6px 14px;
    margin-top: 20px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.profile-ip.internal {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.3);
    color: var(--success);
    font-weight: 500;
}

.profile-form {
    width: 100%;
    max-width: 320px;
    margin-top: 24px;
}

.profile-form .form-group {
    margin-bottom: 20px;
    text-align: left;
}

.profile-form label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
}

.profile-form label .required {
    color: var(--error);
}

.profile-form input,
.profile-form select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.profile-form input:focus,
.profile-form select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(31, 161, 235, 0.2);
}

.profile-form input::placeholder {
    color: var(--text-muted);
}

.profile-form select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238888a0' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
}

.profile-submit {
    width: 100%;
    padding: 14px 24px;
    margin-top: 8px;
    font-size: 1rem;
    font-weight: 600;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border: none;
    color: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.profile-submit:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.profile-submit:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.profile-notice {
    margin-bottom: 20px;
    padding: 12px;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--warning);
    text-align: center;
    line-height: 1.5;
}

.profile-setup .btn-logout {
    width: 100%;
    max-width: 320px;
    padding: 14px 24px;
    margin-top: 12px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 8px;
}

/* ========== 모델 정보 카드 ========== */
.model-info-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 32px 20px;
    text-align: left;
}

.model-info-card {
    max-width: 540px;
    width: 100%;
    padding: 0;
    text-align: left;
}

.model-info-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
}

.model-info-logo {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: 10px;
}

[data-theme="dark"] .model-info-logo.dark-invert {
    filter: invert(1);
}

.model-info-title h2 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.model-info-badge {
    display: inline-block;
    padding: 3px 8px;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 500;
    border-radius: 4px;
}

.model-info-badge.free {
    background: rgba(16, 185, 129, 0.12);
    color: var(--success);
}

.model-info-desc {
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--text-secondary);
    margin-bottom: 28px;
}

.model-info-section {
    margin-bottom: 24px;
}

.model-info-section:last-child {
    margin-bottom: 0;
}

.model-info-section h3 {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 10px;
    text-align: left;
}

.model-info-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.model-info-section li {
    position: relative;
    padding-left: 16px;
    margin-bottom: 8px;
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text-secondary);
}

.model-info-section li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 8px;
    width: 4px;
    height: 4px;
    background: var(--accent-primary);
    border-radius: 50%;
}

.model-info-section li strong {
    color: var(--text-primary);
    font-weight: 500;
}

.model-specs {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.spec-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border-radius: 6px;
}

.spec-item.disabled {
    opacity: 0.4;
}

.spec-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.spec-value {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
}

.model-specs.pricing .spec-value {
    color: var(--accent-primary);
}

.use-cases {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.use-case-tag {
    padding: 5px 10px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 4px;
}

/* 모바일 대응 */
@media (max-width: 600px) {
    .model-info-container {
        padding-bottom: 280px; /* 입력창이 가리지 않도록 여백 추가 */
    }
    
    .model-info-card {
        padding: 20px 0;
    }
    
    .model-specs {
        grid-template-columns: 1fr;
    }
    
    .model-info-title h2 {
        font-size: 1.2rem;
    }
}

