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

:root {
    --bg-app: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --bg-container: #ffffff;
    --bg-chat: #f9f9f9;
    --bg-bot: #e9ecef;
    --bg-input: #ffffff;
    --bg-attach: #f0f0f5;
    --bg-table: #ffffff;
    --bg-table-alt: #f7f8fc;
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-muted: #888888;
    --border: #e0e0e8;
    --border-soft: #f0f0f0;
    --code-bg: #f4f4f4;
}

[data-theme="dark"] {
    --bg-app: linear-gradient(135deg, #1a1c2e 0%, #2d1b3d 100%);
    --bg-container: #1e2030;
    --bg-chat: #15161f;
    --bg-bot: #2a2d40;
    --bg-input: #252838;
    --bg-attach: #1a1c2a;
    --bg-table: #252838;
    --bg-table-alt: #2a2d40;
    --text-primary: #e4e6f0;
    --text-secondary: #a8acc0;
    --text-muted: #6e7185;
    --border: #353849;
    --border-soft: #2a2d3e;
    --code-bg: #2a2d3e;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-app);
    height: 100vh;
    margin: 0;
    padding: 0;
    transition: background 0.3s;
}

.app-layout {
    display: flex;
    height: 100vh;
    width: 100%;
    background: var(--bg-app);
}

.sidebar {
    width: 260px;
    min-width: 260px;
    background: rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    transition: width 0.3s;
    overflow: hidden;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar.collapsed {
    width: 0;
    min-width: 0;
}

.sidebar-header {
    padding: 16px;
    display: flex;
    gap: 8px;
}

.new-chat-btn {
    flex: 1;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 10px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s;
}

.new-chat-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.clear-all-btn {
    flex: 1;
    padding: 10px 14px;
    background: rgba(220, 53, 69, 0.15);
    color: #dc3545;
    border: 1px solid rgba(220, 53, 69, 0.3);
    border-radius: 10px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s;
}

.clear-all-btn:hover {
    background: rgba(220, 53, 69, 0.25);
    border-color: rgba(220, 53, 69, 0.5);
}

.sidebar-toggle {
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: opacity 0.2s;
}

.sidebar-toggle:hover {
    opacity: 0.8;
}

.corpus-selector {
    padding: 10px 12px;
    border-top: 1px solid rgba(255,255,255,0.08);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    background: rgba(0,0,0,0.1);
}

.corpus-selector-label {
    font-size: 11px;
    color: rgba(255,255,255,0.7);
    font-weight: 600;
    margin-bottom: 6px;
    letter-spacing: 0.3px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.rag-files-list-btn {
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.75);
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 12px;
    cursor: pointer;
    line-height: 1.6;
    transition: background 0.15s;
}

.rag-files-list-btn:hover {
    background: rgba(255,255,255,0.25);
    color: white;
}

/* RAG 문서 목록 플로팅 패널 */
.rag-files-modal {
    position: fixed;
    top: 60px;
    left: 272px;
    z-index: 500;
    pointer-events: auto;
}

.rag-files-modal-content {
    background: var(--bg-container, #fff);
    border: 1px solid var(--border, #ddd);
    border-radius: 14px;
    width: 320px;
    max-width: 90vw;
    max-height: 60vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    overflow: hidden;
}

.rag-files-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border, #eee);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: move;
    user-select: none;
}

.rag-files-modal-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
    padding: 0 2px;
}

.rag-files-modal-close:hover { color: var(--text-primary); }

.sidebar.collapsed ~ * .rag-files-modal,
.sidebar.collapsed + .main-area .rag-files-modal {
    left: 12px;
}

.rag-files-list {
    overflow-y: auto;
    padding: 8px 0;
}

.rag-files-loading {
    padding: 20px;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
}

.rag-file-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 16px;
    font-size: 11.5px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-soft, #f0f0f0);
}

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

.rag-file-item.rag-file-downloadable {
    cursor: pointer;
    text-decoration: none;
    color: var(--text-primary);
}

.rag-file-item.rag-file-downloadable:hover {
    background: rgba(102, 126, 234, 0.08);
}

.rag-file-icon { flex-shrink: 0; display: flex; align-items: center; }

.rag-file-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rag-file-size {
    font-size: 10px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.corpus-buttons {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.corpus-btn {
    padding: 6px 10px;
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.85);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    text-align: left;
    transition: all 0.15s;
}

.corpus-btn:hover {
    background: rgba(255,255,255,0.18);
}

.corpus-btn.active {
    background: rgba(102, 126, 234, 0.5);
    border-color: rgba(170, 180, 245, 0.7);
    color: white;
    font-weight: 600;
}

.sidebar-sessions {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    font-size: 13px;
}

.session-group-label {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    padding: 12px 14px 6px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.session-item {
    padding: 10px 14px;
    margin: 0 8px;
    border-radius: 10px;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.85);
    font-size: 13px;
    transition: background 0.15s;
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.session-item:hover, .session-item.active {
    background: rgba(255, 255, 255, 0.15);
}

.session-item.has-unseen .session-title {
    font-weight: 700;
    color: #ffd54a;
}
.unseen-badge {
    display: inline-block;
    margin-left: 4px;
    font-size: 11px;
    animation: unseenPulse 1.6s ease-in-out infinite;
}
@keyframes unseenPulse {
    0%, 100% { opacity: 0.7; transform: scale(1); }
    50%      { opacity: 1;   transform: scale(1.15); }
}

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

.session-title {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.session-date {
    font-size: 11px;
    opacity: 0.6;
    margin-top: 2px;
}

.delete-session, .edit-session {
    display: none;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    opacity: 0.6;
    padding: 0 4px;
    font-size: 14px;
    line-height: 1;
    transition: opacity 0.2s;
}

.delete-session { font-size: 16px; }

.delete-session:hover, .edit-session:hover {
    opacity: 1;
}

.session-item:hover .delete-session,
.session-item:hover .edit-session {
    display: block;
}

/* 인라인 편집 input */
.session-title-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.35);
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: 4px;
    outline: none;
    box-sizing: border-box;
}
.session-title-input:focus {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.6);
}

.main-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    overflow: hidden;
}

.container {
    width: 100%;
    max-width: 900px;
    height: 95vh;
    background: var(--bg-container);
    border-radius: 2.5rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: background 0.3s, box-shadow 0.3s;
}

.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 18px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: none;
    gap: 16px;
}

.header-text {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1;
    min-width: 0;
}

.header-title {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.header-text h1 {
    margin-bottom: 2px;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.header-text p {
    font-size: 11px;
    opacity: 0.85;
    font-weight: 500;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

/* 헤더 KSNET 로고 — h1 안에 인라인, 텍스트와 같은 높이 */
.header-logo-ks {
    flex-shrink: 0;
    height: 1em;
    width: auto;
    object-fit: contain;
    display: block;
}

@media (max-width: 640px) {
    .header-logo-ks { display: none; }
}

.persona-toggle {
    display: flex;
    gap: 4px;
    background: rgba(255, 255, 255, 0.15);
    padding: 4px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.persona-btn {
    padding: 6px 12px;
    background: transparent;
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s;
    white-space: nowrap;
}

.persona-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.persona-btn.active {
    background: rgba(255, 255, 255, 0.25);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.clear-btn {
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 18px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

.clear-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

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

.icon-header-btn {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    cursor: pointer;
    font-size: 15px;
    transition: background 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.icon-header-btn:hover {
    background: rgba(255, 255, 255, 0.35);
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--bg-chat);
    transition: background 0.3s;
}

.messages {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    animation: slideIn 0.3s ease-in-out;
    margin-bottom: 8px;
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.message.user { justify-content: flex-end; }
.message.bot { justify-content: flex-start; }

.message-content {
    max-width: 85%;
    padding: 16px 22px;
    border-radius: 1.5rem;
    word-wrap: break-word;
    line-height: 1.65;
    position: relative;
}

.message.bot .message-content {
    max-width: 92%;
    position: relative;
}

.message.user .message-content {
    background: #667eea;
    color: white;
    border-bottom-right-radius: 6px;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    white-space: pre-wrap;
}

.message.bot .message-content {
    background: var(--bg-bot);
    color: var(--text-primary);
    border-bottom-left-radius: 6px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.message-content .attached-image {
    max-width: 200px;
    max-height: 200px;
    border-radius: 8px;
    margin-bottom: 6px;
    display: block;
}

.message-content .attached-file {
    background: rgba(0,0,0,0.05);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    margin-bottom: 6px;
    display: inline-block;
}

.message-actions {
    margin-top: 12px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding-top: 10px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.message-actions button {
    padding: 6px 12px;
    background: rgba(102, 126, 234, 0.1);
    color: #5568d3;
    border: 1px solid rgba(102, 126, 234, 0.2);
    border-radius: 8px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    transition: all 0.2s;
    white-space: nowrap;
}

.message-actions button:hover {
    background: rgba(102, 126, 234, 0.2);
    border-color: rgba(102, 126, 234, 0.4);
    transform: translateY(-1px);
}

[data-theme="dark"] .message-actions button {
    background: rgba(120, 145, 240, 0.15);
    color: #aab4f5;
    border-color: rgba(120, 145, 240, 0.3);
}

.mermaid-wrapper {
    position: relative;
    margin: 16px 0;
    padding: 16px;
    background: #f8f9ff;
    border-radius: 12px;
    border: 1px solid #e0e4f5;
    overflow-x: auto;
    text-align: center;
}

.mermaid-wrapper svg {
    max-width: 100%;
    height: auto;
    cursor: zoom-in;
}

[data-theme="dark"] .mermaid-wrapper {
    background: #1e2030;
    border-color: var(--border);
}

.mermaid-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.2s;
}

.mermaid-wrapper:hover .mermaid-actions {
    opacity: 1;
}

.mermaid-action-btn {
    padding: 5px 10px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #d0d4e8;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    color: #4a5568;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    transition: background 0.15s, transform 0.1s;
}

.mermaid-action-btn:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.mermaid-action-btn:active {
    transform: scale(0.96);
}

[data-theme="dark"] .mermaid-action-btn {
    background: rgba(40, 44, 64, 0.95);
    border-color: var(--border);
    color: #c0c8e0;
}

[data-theme="dark"] .mermaid-action-btn:hover {
    background: #8b9ff5;
    color: #1a1d2e;
    border-color: #8b9ff5;
}

/* Mermaid zoom modal */
.mermaid-zoom-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow: auto;
    cursor: zoom-out;
}

.mermaid-zoom-inner {
    background: white;
    padding: 24px;
    border-radius: 12px;
    max-width: 95vw;
    max-height: 95vh;
    overflow: auto;
    cursor: default;
    box-shadow: 0 10px 60px rgba(0,0,0,0.5);
}

.mermaid-zoom-inner svg {
    display: block;
    min-width: 800px;
}

.mermaid-zoom-close {
    position: fixed;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.95);
    font-size: 24px;
    cursor: pointer;
    color: #333;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.mermaid-zoom-close:hover {
    background: white;
    transform: scale(1.05);
}

@media (max-width: 768px) {
    .mermaid-actions {
        opacity: 1;
    }
    .mermaid-zoom-inner {
        padding: 12px;
    }
    .mermaid-zoom-inner svg {
        min-width: auto;
        width: 100%;
    }
}

.summary-box {
    margin-top: 12px;
    padding: 12px 14px;
    background: rgba(102, 126, 234, 0.08);
    border-left: 3px solid #667eea;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.6;
    animation: slideIn 0.3s ease-in-out;
}

[data-theme="dark"] .summary-box {
    background: rgba(120, 145, 240, 0.1);
    border-left-color: #8b9ff5;
}

.locked-notice {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: rgba(220, 53, 69, 0.08);
    border: 1px solid rgba(220, 53, 69, 0.3);
    border-radius: 10px;
    color: #c0392b;
    font-size: 13px;
    font-weight: 500;
}

[data-theme="dark"] .locked-notice {
    background: rgba(220, 53, 69, 0.15);
    color: #e57373;
}

.progress-text {
    color: var(--text-muted);
    font-size: 14px;
}

.progress-slow-hint {
    margin-top: 10px;
    padding: 8px 12px;
    background: rgba(240, 160, 64, 0.10);
    border-left: 3px solid #f0a040;
    border-radius: 6px;
    font-size: 12.5px;
    color: var(--text-muted);
    line-height: 1.5;
    animation: progressSlowHintIn 0.35s ease-out;
}

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

.progress-dots {
    display: inline-block;
    min-width: 18px;
    letter-spacing: 1px;
    color: #667eea;
    font-weight: 700;
}

.token-info {
    font-size: 11px;
    color: #888;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed #ccc;
}

.token-info-warn {
    color: #b07d00;
}

.token-info-danger {
    color: #b00020;
}

.token-warning {
    background: rgba(255, 193, 7, 0.15);
    border-left: 3px solid #ffc107;
    padding: 6px 10px;
    border-radius: 4px;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 12px;
}

.model-badge {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    background: rgba(102, 126, 234, 0.15);
    color: #5568d3;
    border: 1px solid rgba(102, 126, 234, 0.3);
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.2px;
}

[data-theme="dark"] .model-badge {
    background: rgba(120, 145, 240, 0.2);
    color: #aab4f5;
    border-color: rgba(120, 145, 240, 0.4);
}

.token-info-danger .token-warning {
    background: rgba(220, 53, 69, 0.15);
    border-left-color: #dc3545;
}

.sources-list {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dashed #ccc;
}

.sources-header {
    font-size: 11px;
    font-weight: 600;
    color: #888;
    margin-bottom: 6px;
}

.sources-links {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.source-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: 12px;
    color: #5568d3;
    background: rgba(102, 126, 234, 0.08);
    border: 1px solid rgba(102, 126, 234, 0.25);
    border-radius: 14px;
    text-decoration: none;
    transition: background 0.15s;
}

.source-link:hover {
    background: rgba(102, 126, 234, 0.18);
    text-decoration: none;
}

[data-theme="dark"] .sources-list {
    border-top-color: rgba(255,255,255,0.15);
}

[data-theme="dark"] .sources-header {
    color: rgba(255,255,255,0.45);
}

[data-theme="dark"] .source-link {
    color: #aab4f5;
    background: rgba(120, 145, 240, 0.12);
    border-color: rgba(120, 145, 240, 0.3);
}

[data-theme="dark"] .source-link:hover {
    background: rgba(120, 145, 240, 0.22);
}

.streaming-cursor {
    display: inline-block;
    width: 6px;
    height: 14px;
    background: #667eea;
    animation: blink 1s infinite;
    vertical-align: text-bottom;
    margin-left: 2px;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.message.bot .message-content h1,
.message.bot .message-content h2,
.message.bot .message-content h3,
.message.bot .message-content h4 {
    margin: 18px 0 8px 0;
    color: var(--text-primary);
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

[data-theme="dark"] .message.bot .message-content h1,
[data-theme="dark"] .message.bot .message-content h2,
[data-theme="dark"] .message.bot .message-content h3,
[data-theme="dark"] .message.bot .message-content h4,
[data-theme="dark"] .message.bot .message-content strong {
    color: #c8cdf0;
}

.message.bot .message-content h1 { font-size: 19px; }
.message.bot .message-content h2 { font-size: 17px; }
.message.bot .message-content h3 {
    font-size: 15px;
    border-bottom: none;
    padding-bottom: 0;
}
.message.bot .message-content h4 {
    font-size: 14px;
    border-bottom: none;
    padding-bottom: 0;
}

.message.bot .message-content > *:first-child { margin-top: 0; }

.message.bot .message-content p {
    margin: 10px 0;
    line-height: 1.65;
}

.message.bot .message-content ul,
.message.bot .message-content ol {
    margin: 10px 0;
    padding-left: 22px;
}

.message.bot .message-content li {
    margin: 5px 0;
    line-height: 1.6;
}

.message.bot .message-content hr {
    margin: 16px 0;
    border: none;
    border-top: 1px dashed #c0c4cc;
}

.message.bot .message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 14px 0;
    font-size: 13px;
    background: var(--bg-table);
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.message.bot .message-content th,
.message.bot .message-content td {
    border: 1px solid var(--border);
    padding: 8px 10px;
    text-align: left;
    vertical-align: top;
}

.message.bot .message-content th {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-weight: 600;
    font-size: 13px;
}

.message.bot .message-content tr:nth-child(even) td {
    background: var(--bg-table-alt);
}

.message.bot .message-content code {
    background: var(--code-bg);
    padding: 2px 5px;
    border-radius: 3px;
    font-size: 13px;
    font-family: 'Consolas', 'Monaco', monospace;
}

.message.bot .message-content pre {
    background: var(--code-bg);
    padding: 10px;
    padding-top: 36px;
    border-radius: 4px;
    overflow-x: auto;
    margin: 8px 0;
    position: relative;
}

.copy-btn {
    position: absolute;
    top: 6px;
    right: 8px;
    padding: 3px 10px;
    background: rgba(102, 126, 234, 0.12);
    color: #667eea;
    border: 1px solid rgba(102, 126, 234, 0.3);
    border-radius: 6px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    transition: all 0.2s;
    white-space: nowrap;
}

.copy-btn:hover {
    background: rgba(102, 126, 234, 0.25);
}

[data-theme="dark"] .copy-btn {
    background: rgba(120, 145, 240, 0.15);
    color: #aab4f5;
    border-color: rgba(120, 145, 240, 0.3);
}

.message.bot .message-content strong {
    color: #2c3e50;
    font-weight: 600;
}

.message.bot .message-content blockquote {
    border-left: 3px solid #667eea;
    padding-left: 10px;
    margin: 8px 0;
    color: #666;
}

[data-theme="dark"] .message.bot .message-content table {
    background: var(--bg-table);
}

[data-theme="dark"] .message.bot .message-content th {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

[data-theme="dark"] .message.bot .message-content td {
    color: var(--text-primary);
    border-color: var(--border);
}

[data-theme="dark"] .message.bot .message-content tr:nth-child(even) td {
    background: var(--bg-table-alt);
}

[data-theme="dark"] .message.bot .message-content strong {
    color: #e4e6f0;
}

[data-theme="dark"] .message.bot .message-content blockquote {
    color: var(--text-secondary);
    border-left-color: #667eea;
}

/* ===== Gemini-style Input ===== */
.gemini-input-area {
    padding: 12px 16px 16px;
    background: var(--bg-container);
    transition: background 0.3s;
}

.gemini-input-box {
    background: var(--bg-input);
    border: 1.5px solid var(--border);
    border-radius: 20px;
    transition: border-color 0.2s, box-shadow 0.2s;
    overflow: hidden;
}

.gemini-input-box:focus-within {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.12);
}

/* Attachment previews inside the box */
.attachment-preview {
    display: none;
    padding: 10px 14px 4px;
    gap: 8px;
    flex-wrap: wrap;
}

.attachment-preview.has-items { display: flex; }

.preview-item {
    position: relative;
    background: var(--bg-container);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 5px 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-primary);
}

.preview-item img {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 7px;
}

.preview-item .file-name {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.preview-item .remove-btn {
    cursor: pointer;
    color: #aaa;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    background: none;
    border: none;
    border-radius: 50%;
    line-height: 1;
    padding: 0;
}

.preview-item .remove-btn:hover {
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.1);
}

/* Textarea inside the box */
#messageInput {
    width: 100%;
    padding: 12px 16px 4px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    resize: none;
    overflow-y: auto;
    min-height: 44px;
    max-height: 160px;
    line-height: 1.6;
    font-family: inherit;
    box-sizing: border-box;
    display: block;
}

#messageInput::placeholder { color: var(--text-muted); }

/* Footer row: attach left, send right */
.gemini-input-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px 8px;
}

.gemini-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}

.gemini-icon-btn:hover {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

.gemini-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: #667eea;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, transform 0.1s;
    flex-shrink: 0;
}

.gemini-send-btn:hover:not(:disabled) {
    background: #5568d3;
}

.gemini-send-btn:active:not(:disabled) {
    transform: scale(0.93);
}

.gemini-send-btn.stopping {
    background: #e74c3c;
    animation: stopBtnPulse 1.4s ease-in-out infinite;
}
.gemini-send-btn.stopping:hover {
    background: #c0392b;
}
@keyframes stopBtnPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.45); }
    50%      { box-shadow: 0 0 0 6px rgba(231, 76, 60, 0); }
}

.aborted-notice {
    margin-top: 10px;
    padding: 6px 10px;
    background: rgba(231, 76, 60, 0.08);
    border-left: 3px solid #e74c3c;
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
}

.gemini-send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

[data-theme="dark"] .gemini-send-btn:disabled {
    background: #444;
}

[data-theme="dark"] .gemini-input-box {
    border-color: var(--border);
}

[data-theme="dark"] .preview-item {
    background: rgba(255,255,255,0.05);
}

.loading {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #667eea;
    animation: pulse 1.5s infinite;
    margin: 0 2px;
}

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

.progress-indicator {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: #667eea;
    font-weight: 600;
    animation: fadeIn 0.3s ease-in-out;
}

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(102, 126, 234, 0.2);
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.token-alert-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease-in-out;
}

.token-alert-modal {
    background: white;
    border-radius: 16px;
    padding: 32px;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .token-alert-modal {
    background: #1e2030;
    color: #e4e6f0;
}

.token-alert-modal h2 {
    margin: 0 0 16px 0;
    font-size: 18px;
    color: #dc3545;
}

.token-alert-modal p {
    margin: 0 0 24px 0;
    font-size: 14px;
    opacity: 0.85;
    line-height: 1.6;
}

.token-alert-modal button {
    padding: 10px 24px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
}

.token-alert-modal button:hover {
    background: #5568d3;
}

/* ===== Auth Pages ===== */
.auth-body {
    background: var(--bg-app);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
}

.auth-card {
    background: var(--bg-container);
    border-radius: 16px;
    padding: 32px 36px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    width: 100%;
    max-width: 420px;
}

.auth-header {
    text-align: center;
    margin-bottom: 24px;
}

.auth-header h1 {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 28px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}
.auth-logo-ks {
    height: 0.78em;
    width: auto;
    object-fit: contain;
    flex-shrink: 0;
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 13px;
}

.auth-form h2 {
    color: var(--text-primary);
    margin-bottom: 16px;
    font-size: 18px;
}

.auth-form label {
    display: block;
    margin-bottom: 14px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
}

.auth-form input {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    background: var(--bg-input);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s;
}

.auth-form input:focus {
    border-color: #667eea;
}

.auth-form button[type="submit"] {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    margin-top: 8px;
    transition: transform 0.1s;
}

.auth-form button[type="submit"]:hover {
    transform: translateY(-1px);
}

.auth-link {
    text-align: center;
    margin-top: 16px;
    color: var(--text-secondary);
    font-size: 13px;
}

.auth-link a {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
}

.auth-hint {
    text-align: center;
    margin-top: 12px;
    padding: 8px;
    background: rgba(102, 126, 234, 0.08);
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

.auth-error {
    background: rgba(220, 53, 69, 0.12);
    color: #dc3545;
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 13px;
    border: 1px solid rgba(220, 53, 69, 0.3);
}

.domain-notice {
    margin-top: 8px;
    padding: 8px 12px;
    background: rgba(102, 126, 234, 0.08);
    border-left: 3px solid #667eea;
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
}
.domain-notice strong {
    color: #667eea;
    font-weight: 700;
}

.auth-pending {
    background: rgba(240, 160, 64, 0.10);
    color: var(--text);
    padding: 18px 20px;
    border-radius: 10px;
    border-left: 4px solid #f0a040;
    font-size: 14px;
    line-height: 1.55;
}
.auth-pending h2 {
    font-size: 16px;
    color: #c87b1e;
}

/* 관리자 탭 — 가입 신청 대기 badge */
.pending-badge {
    display: inline-block;
    margin-left: 6px;
    min-width: 18px;
    padding: 0 6px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    background: #e74c3c;
    color: white;
    border-radius: 9px;
    font-size: 11px;
    font-weight: 700;
    vertical-align: middle;
}
.pending-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}
.pending-status-pending {
    background: rgba(240, 160, 64, 0.15);
    color: #c87b1e;
}
.pending-status-approved {
    background: rgba(40, 167, 69, 0.15);
    color: #2d8845;
}
.pending-status-rejected {
    background: rgba(220, 53, 69, 0.12);
    color: #c0392b;
}

/* ===== Board sidebar button ===== */
.board-sidebar-btn {
    display: block;
    margin: 0 12px 8px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.2s;
}

.board-sidebar-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* ===== Sidebar Footer (User Info) ===== */
.sidebar-footer {
    padding: 12px;
    border-top: 1px solid rgba(255,255,255,0.1);
    background: rgba(0,0,0,0.1);
}

.app-copyright {
    padding: 10px 12px 12px;
    border-top: 1px solid rgba(255,255,255,0.06);
    background: rgba(0,0,0,0.15);
    font-size: 10.5px;
    line-height: 1.45;
    letter-spacing: 0.01em;
    display: flex;
    align-items: center;
    gap: 10px;
}
.app-copyright-text {
    flex: 1;
    min-width: 0;
    text-align: left;
}
.app-copyright .power {
    color: #ffffff;
    font-weight: 500;
    display: block;
}
.app-copyright-logo {
    flex-shrink: 0;
    width: 56px;
    height: 56px;
    object-fit: contain;
    /* 흰 라운드 카드 — 어두운 사이드바와 대비 */
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.15);
}

/* 로그인 페이지에서는 카드 아래 그라데이션 배경 위에 배치 (로고 없이 텍스트만) */
.auth-body .app-copyright {
    border-top: none;
    background: transparent;
    margin-top: 18px;
    padding: 0;
    display: block;
    text-align: center;
}
.auth-body .app-copyright .power {
    color: rgba(255,255,255,0.85);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #aab4f5, #c7a3e8);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
}

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

.user-name {
    color: white;
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-dept {
    color: rgba(255,255,255,0.6);
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-actions {
    display: flex;
    gap: 4px;
}

.user-action-btn {
    flex: 1;
    padding: 6px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    color: white;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    font-size: 14px;
    transition: background 0.2s;
}

.user-action-btn:hover {
    background: rgba(255,255,255,0.2);
}

/* ===== Settings Modal ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-card {
    background: var(--bg-container);
    border-radius: 16px;
    width: 100%;
    max-width: 520px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

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

.modal-header h2 {
    color: var(--text-primary);
    font-size: 18px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
}

.modal-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
}

.modal-tab {
    flex: 1;
    padding: 12px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-weight: 600;
    border-bottom: 2px solid transparent;
}

.modal-tab.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

.modal-tab-content {
    display: none;
}

.modal-tab-content.active {
    display: block;
}

.modal-tab-content label {
    display: block;
    margin-bottom: 16px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
}

.modal-tab-content input,
.modal-tab-content textarea {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    background: var(--bg-input);
    color: var(--text-primary);
    outline: none;
    font-family: inherit;
    resize: vertical;
}

.modal-tab-content input:focus,
.modal-tab-content textarea:focus {
    border-color: #667eea;
}

.modal-save-btn {
    padding: 10px 24px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}

.modal-save-btn:hover {
    background: #5568d3;
}

.modal-msg {
    margin-top: 12px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    display: none;
}

.modal-msg.success {
    display: block;
    background: rgba(40, 167, 69, 0.12);
    color: #28a745;
}

.modal-msg.error {
    display: block;
    background: rgba(220, 53, 69, 0.12);
    color: #dc3545;
}

/* ===== Admin Page ===== */
.admin-page {
    background: var(--bg-app);
    min-height: 100vh;
    color: var(--text-primary);
}

.admin-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.admin-header h1 {
    font-size: 18px;
}

.admin-link {
    color: white;
    text-decoration: none;
    margin-left: 16px;
    padding: 6px 12px;
    background: rgba(255,255,255,0.15);
    border-radius: 6px;
    font-size: 13px;
}

.admin-link:hover {
    background: rgba(255,255,255,0.25);
}

.admin-tabs {
    display: flex;
    gap: 8px;
    padding: 16px 24px;
    background: var(--bg-container);
    border-bottom: 1px solid var(--border);
}

.admin-tab {
    padding: 8px 16px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    font-weight: 600;
}

.admin-tab.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.admin-content {
    padding: 0 24px 24px;
    background: var(--bg-container);
    min-height: calc(100vh - 130px);
}

.date-filter-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 14px 0 12px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

.dfb {
    padding: 5px 12px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--bg-container);
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.dfb:hover { background: rgba(102,126,234,0.08); color: #667eea; border-color: #667eea; }
.dfb.active { background: #667eea; color: white; border-color: #667eea; }

.dfb-sep { color: var(--border); font-size: 16px; margin: 0 2px; }

.dfb-date {
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 12px;
    background: var(--bg-input);
    color: var(--text-primary);
}

.dfb-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: 4px;
}

.admin-section {
    display: none;
}

.admin-section.active {
    display: block;
}

.admin-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 24px;
    border-radius: 12px;
}

.stat-label {
    font-size: 13px;
    opacity: 0.85;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.admin-table th,
.admin-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.admin-table th {
    background: var(--bg-table-alt);
    color: var(--text-secondary);
    font-weight: 600;
}

.admin-table tr:hover {
    background: var(--bg-table-alt);
}

.role-badge {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.role-badge.admin {
    background: rgba(220, 53, 69, 0.15);
    color: #dc3545;
}

.role-badge.user {
    background: rgba(102, 126, 234, 0.15);
    color: #667eea;
}

.admin-btn-small {
    padding: 4px 10px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
}

.conv-user-item,
.conv-item {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s;
}

.conv-user-item:hover,
.conv-item:hover {
    background: var(--bg-table-alt);
}

.admin-msg {
    margin-bottom: 12px;
    padding: 12px;
    border-radius: 8px;
    background: var(--bg-table-alt);
    border-left: 3px solid var(--border);
}

.admin-msg.user {
    border-left-color: #667eea;
}

.admin-msg.model {
    border-left-color: #28a745;
}

.admin-msg-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.admin-msg-body {
    font-size: 14px;
    line-height: 1.5;
}

/* ===== Menu toggle button (always visible) ===== */
.mobile-menu-btn {
    display: inline-flex;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}

.mobile-menu-btn:hover {
    background: rgba(255, 255, 255, 0.35);
}

/* Sidebar overlay backdrop (mobile only) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    animation: fadeIn 0.2s;
}

/* ===== Mobile Responsive ===== */
@media (max-width: 768px) {
    /* Sidebar becomes overlay drawer */
    .sidebar {
        position: fixed !important;
        top: 0;
        left: 0;
        height: 100% !important;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        width: 260px !important;
        min-width: 260px !important;
    }

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

    /* collapsed class ignored on mobile — use open/closed via transform */
    .sidebar.collapsed {
        width: 260px !important;
        min-width: 260px !important;
        transform: translateX(-100%);
    }

    /* Main area full-width */
    .main-area {
        padding: 0;
        width: 100vw;
    }

    .container {
        height: 100vh;
        border-radius: 0;
        max-width: 100%;
    }

    /* Header compact */
    .header {
        padding: 8px 10px;
        gap: 6px;
    }

    .header-text {
        gap: 8px;
        min-width: 0;        /* flex 자식이 줄어들 수 있게 */
        overflow: hidden;
    }

    .header-text h1 {
        font-size: 16px;
        margin-bottom: 0;
        gap: 6px;
        white-space: nowrap;  /* "AIWA MECA 3.1" 한 줄 유지 */
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .header-text h1 span {
        white-space: nowrap;
    }

    .header-text p {
        display: none;
    }

    .header-logo-ks {
        height: 14px !important;  /* 모바일에선 더 작게 */
    }

    .header-actions {
        gap: 4px;
        flex-shrink: 0;
    }

    .persona-toggle {
        padding: 2px;
    }

    .persona-btn {
        padding: 4px 7px;
        font-size: 11px;
        white-space: nowrap;
    }

    .clear-btn {
        padding: 5px 10px;
        font-size: 12px;
        white-space: nowrap;  /* "새 대화" 줄바꿈 방지 */
    }

    .icon-header-btn {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }

    /* 모바일에선 헤더의 "새 대화" 버튼 숨김 — 사이드바 "+ 새 대화"로 대체 가능 */
    .clear-btn {
        display: none !important;
    }

    /* 아주 좁은 화면(≤480px) — 로고 숨김 + 다운로드 아이콘 숨김 */
    @media (max-width: 480px) {
        .header-logo-ks { display: none !important; }
        .header-text h1 { font-size: 17px; }
        #exportBtn { display: none !important; }   /* 다운로드 버튼도 숨김 — 공간 확보 */
        .icon-header-btn { width: 28px; height: 28px; }
    }

    /* 극단적으로 좁은 화면(≤360px) — 추가 정리 */
    @media (max-width: 360px) {
        .header { padding: 6px 8px; gap: 4px; }
        .header-text h1 { font-size: 16px; }
        .persona-btn { padding: 3px 6px; font-size: 10px; }
    }

    /* Chat area */
    .chat-container {
        padding: 10px 8px;
    }

    .message-content {
        max-width: 90%;
        padding: 10px 14px;
        font-size: 14px;
    }

    /* Input area */
    .gemini-input-area {
        padding: 8px 8px 10px;
    }

    .gemini-input-box textarea {
        font-size: 15px;
    }

    /* RAG files modal — 모바일에선 좌우 8px 여백으로 가득 채우기 (우측 잘림 방지) */
    .rag-files-modal {
        left: 8px !important;
        right: 8px !important;
        top: auto !important;
        bottom: 80px;
    }
    .rag-files-modal-content {
        width: auto !important;
        max-width: 100% !important;
    }

    /* Settings modal full-width on mobile */
    .modal-card {
        max-width: 95vw;
        margin: 8px;
    }
}

/* ===== Board Page ===== */
.board-page {
    min-height: 100vh;
    background: var(--bg-app);
    display: flex;
    flex-direction: column;
}

.board-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.board-header h1 {
    flex: 1;
    font-size: 18px;
    font-weight: 700;
    text-align: center;
    margin: 0;
}

.board-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    font-size: 13px;
    padding: 6px 12px;
    background: rgba(255,255,255,0.15);
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.25);
    transition: background 0.2s;
    white-space: nowrap;
}

.board-back-btn:hover { background: rgba(255,255,255,0.25); }

.board-new-btn {
    padding: 8px 16px;
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.35);
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    transition: background 0.2s;
}

.board-new-btn:hover { background: rgba(255,255,255,0.35); }

.board-main {
    flex: 1;
    padding: 24px 16px;
    max-width: 780px;
    width: 100%;
    margin: 0 auto;
}

.board-card {
    background: var(--bg-container);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

.board-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.board-card-header h2 {
    font-size: 16px;
    color: var(--text-primary);
}

.board-cancel-btn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-muted);
}

.board-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    background: var(--bg-input);
    color: var(--text-primary);
    margin-bottom: 10px;
    outline: none;
    font-family: inherit;
}

.board-input:focus { border-color: #667eea; }

.board-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    background: var(--bg-input);
    color: var(--text-primary);
    outline: none;
    resize: vertical;
    font-family: inherit;
    line-height: 1.6;
}

.board-textarea:focus { border-color: #667eea; }

.board-form-actions {
    margin-top: 12px;
    display: flex;
    justify-content: flex-end;
}

.board-submit-btn {
    padding: 9px 22px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: background 0.2s;
}

.board-submit-btn:hover { background: #5568d3; }

.board-msg {
    margin-top: 8px;
    font-size: 13px;
    color: #dc3545;
    min-height: 18px;
}

.board-loading, .board-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.8;
}

/* Post list */
.post-list {
    background: var(--bg-container);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    overflow: hidden;
}

.post-item {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-soft);
    cursor: pointer;
    transition: background 0.15s;
}

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

.post-item:hover { background: var(--bg-table-alt); }

.post-item-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.post-item-meta {
    display: flex;
    gap: 10px;
    font-size: 12px;
    color: var(--text-muted);
    align-items: center;
}

.post-comment-count { color: #667eea; }

/* Post detail */
.post-full { margin-bottom: 24px; }

.post-full-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 8px;
}

.post-full-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.4;
}

.post-full-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.post-full-content {
    font-size: 14px;
    line-height: 1.8;
    color: var(--text-primary);
    white-space: pre-wrap;
    padding: 16px;
    background: var(--bg-chat);
    border-radius: 8px;
}

.board-delete-btn {
    padding: 5px 12px;
    background: rgba(220,53,69,0.1);
    color: #dc3545;
    border: 1px solid rgba(220,53,69,0.25);
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    white-space: nowrap;
    flex-shrink: 0;
}

.board-delete-btn:hover { background: rgba(220,53,69,0.2); }

.board-back-link {
    background: none;
    border: none;
    color: #667eea;
    cursor: pointer;
    font-size: 13px;
    padding: 0;
    margin-bottom: 16px;
    display: inline-block;
}

.board-back-link:hover { text-decoration: underline; }

/* Comments */
.comments-section { border-top: 1px solid var(--border); padding-top: 20px; margin-top: 8px; }

.comments-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.comment-item {
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 6px;
    border-bottom: none;
}

.comment-item:nth-child(odd) {
    background: rgba(102, 126, 234, 0.06);
}

.comment-item:nth-child(even) {
    background: rgba(118, 75, 162, 0.06);
}

[data-theme="dark"] .comment-item:nth-child(odd) {
    background: rgba(102, 126, 234, 0.1);
}

[data-theme="dark"] .comment-item:nth-child(even) {
    background: rgba(118, 75, 162, 0.1);
}

.comment-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.comment-meta strong { color: var(--text-secondary); }

.comment-content {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
}

.comment-delete-btn {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 11px;
    padding: 0;
}

.comment-delete-btn:hover { color: #dc3545; }

.comment-form { margin-top: 16px; }

.admin-badge {
    background: rgba(102,126,234,0.15);
    color: #667eea;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

/* Google reCAPTCHA v3 배지 숨김 (GCP gen-search-widget 로드 시 표시됨) */
.grecaptcha-badge {
    visibility: hidden !important;
}

/* ===== 공지 버튼 (채팅 상단) ===== */
.notice-btn {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 4px 8px;
    background: #fff7e6;
    color: #b8610a;
    border: 1px solid #ffd591;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, transform 0.05s;
    white-space: nowrap;
    line-height: 1.4;
}
.notice-btn:hover { background: #ffe7ba; }
.notice-btn:active { transform: scale(0.97); }
[data-theme="dark"] .notice-btn {
    background: #3a2a10;
    color: #ffd591;
    border-color: #6b4a1a;
}
[data-theme="dark"] .notice-btn:hover { background: #4a3618; }

/* ===== 공지 뱃지 (게시판 목록/상세) ===== */
.notice-badge {
    display: inline-block;
    padding: 2px 8px;
    margin-right: 6px;
    background: #fa8c16;
    color: #fff;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 700;
    vertical-align: middle;
}
.post-item-notice {
    background: linear-gradient(90deg, #fff7e6 0%, transparent 60%);
    border-left: 3px solid #fa8c16;
}
[data-theme="dark"] .post-item-notice {
    background: linear-gradient(90deg, rgba(250,140,22,0.12) 0%, transparent 60%);
}
.post-full-notice .post-full-title { color: #b8610a; }

/* ===== 글 상세 액션 버튼 (수정/삭제) ===== */
.post-full-actions {
    display: inline-flex;
    gap: 6px;
}
.board-edit-btn {
    background: #1677ff;
    color: #fff;
    border: none;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.board-edit-btn:hover { background: #0958d9; }
.board-broadcast-btn {
    background: #52c41a;
    color: #fff;
    border: none;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.board-broadcast-btn:hover { background: #389e0d; }

/* ===== 발송 결과 모달 ===== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-card {
    background: #fff;
    border-radius: 12px;
    padding: 24px 28px;
    max-width: 720px;
    width: 100%;
    max-height: 85vh;
    overflow: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
[data-theme="dark"] .modal-card { background: #1f2230; color: #e6e6e6; }
.modal-title { margin: 0 0 16px; font-size: 18px; }
.modal-section-title { margin: 18px 0 8px; font-size: 14px; color: #555; }
[data-theme="dark"] .modal-section-title { color: #aaa; }
.modal-loading { text-align: center; padding: 30px 0; }
.modal-spinner {
    width: 36px; height: 36px;
    border: 4px solid #e6e6e6;
    border-top-color: #1677ff;
    border-radius: 50%;
    margin: 0 auto 12px;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.modal-actions { margin-top: 18px; text-align: right; }
.modal-fatal {
    margin: 12px 0;
    padding: 10px 12px;
    background: #fff1f0;
    border: 1px solid #ffa39e;
    color: #cf1322;
    border-radius: 6px;
}
[data-theme="dark"] .modal-fatal {
    background: #2a1418;
    border-color: #5a2027;
    color: #ff7875;
}
.broadcast-summary {
    display: flex;
    gap: 14px;
    margin: 14px 0 6px;
}
.summary-item {
    flex: 1;
    background: #f7f9fc;
    border: 1px solid #e4e9f0;
    border-radius: 8px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.summary-success { background: #f6ffed; border-color: #b7eb8f; }
.summary-failed  { background: #fff2e8; border-color: #ffbb96; }
.summary-label { font-size: 12px; color: #888; }
.summary-value { font-size: 20px; font-weight: 700; }
[data-theme="dark"] .summary-item { background: #1a2030; border-color: #2a3550; }
[data-theme="dark"] .summary-success { background: #15301a; border-color: #356b3e; }
[data-theme="dark"] .summary-failed  { background: #3a1a10; border-color: #6b3a20; }
[data-theme="dark"] .summary-label { color: #aaa; }
.broadcast-result-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.broadcast-result-table th, .broadcast-result-table td {
    padding: 6px 10px;
    text-align: left;
    border-bottom: 1px solid #eaeaea;
}
.broadcast-result-table th {
    background: #fafafa;
    color: #555;
    font-weight: 600;
}
.modal-error-cell { color: #cf1322; word-break: break-word; }
[data-theme="dark"] .broadcast-result-table th { background: #20283a; color: #aaa; }
[data-theme="dark"] .broadcast-result-table th,
[data-theme="dark"] .broadcast-result-table td { border-bottom-color: #2a3344; }
[data-theme="dark"] .modal-error-cell { color: #ff7875; }
.board-cancel-btn-inline {
    background: #f0f0f0;
    color: #555;
    border: 1px solid #d9d9d9;
    padding: 8px 18px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    margin-left: 8px;
}
.board-cancel-btn-inline:hover { background: #e6e6e6; }
[data-theme="dark"] .board-cancel-btn-inline {
    background: #2a2a2a;
    color: #ccc;
    border-color: #444;
}

/* ===== 조회수 / 수정됨 표기 ===== */
.post-view-count {
    margin-left: 12px;
    color: #888;
    font-size: 13px;
}
.post-edited {
    color: #999;
    font-size: 12px;
    font-style: italic;
}

/* ===== 조회자 명단 (관리자) ===== */
.viewers-block {
    margin-top: 18px;
    padding: 10px 14px;
    background: #f7f9fc;
    border: 1px solid #e4e9f0;
    border-radius: 8px;
}
.viewers-block summary {
    cursor: pointer;
    font-weight: 600;
    color: #1677ff;
    user-select: none;
}
.viewers-block summary:hover { color: #0958d9; }
.viewers-table {
    width: 100%;
    margin-top: 10px;
    border-collapse: collapse;
    font-size: 13px;
}
.viewers-table th, .viewers-table td {
    padding: 6px 10px;
    text-align: left;
    border-bottom: 1px solid #eaeaea;
}
.viewers-table th {
    background: #fafafa;
    font-weight: 600;
    color: #555;
}
.viewers-table tbody tr:hover { background: #f5faff; }
[data-theme="dark"] .viewers-block {
    background: #1a2030;
    border-color: #2a3550;
}
[data-theme="dark"] .viewers-table th {
    background: #20283a;
    color: #aaa;
}
[data-theme="dark"] .viewers-table th,
[data-theme="dark"] .viewers-table td { border-bottom-color: #2a3344; }
[data-theme="dark"] .viewers-table tbody tr:hover { background: #1f2638; }

/* ===== 글쓰기 폼 공지 토글 ===== */
.board-notice-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 10px 0;
    padding: 10px 12px;
    background: #fff7e6;
    border: 1px solid #ffd591;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    color: #b8610a;
}
.board-notice-toggle input[type="checkbox"] { cursor: pointer; }
[data-theme="dark"] .board-notice-toggle {
    background: #3a2a10;
    color: #ffd591;
    border-color: #6b4a1a;
}

/* ===== 사용 안내 페이지 (/help) ===== */
.help-page-body {
    margin: 0;
    background: #f0f2f7;
    color: #2c2c34;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
    min-height: 100vh;
}
.help-page-container {
    max-width: 960px;
    margin: 0 auto;
    padding: 24px 16px 48px;
}
.help-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 22px 28px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border-radius: 14px 14px 0 0;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.25);
}
.help-page-title h1 {
    margin: 0 0 4px;
    font-size: 24px;
    font-weight: 700;
}
.help-page-subtitle {
    margin: 0;
    font-size: 13px;
    opacity: 0.85;
}
.help-page-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}
.help-page-btn {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.25);
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.15s;
    white-space: nowrap;
}
.help-page-btn:hover {
    background: rgba(255, 255, 255, 0.32);
}
.help-page-body-content {
    background: #fff;
    padding: 32px 40px;
    line-height: 1.75;
    font-size: 15px;
    color: #2c2c34;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
}
.help-page-body-content h2 {
    margin: 32px 0 14px;
    padding-bottom: 8px;
    border-bottom: 2px solid #667eea;
    font-size: 21px;
    color: #4a4a5a;
}
.help-page-body-content h2:first-child { margin-top: 0; }
.help-page-body-content h3 {
    margin: 22px 0 10px;
    font-size: 17px;
    color: #555;
}
.help-page-body-content p { margin: 10px 0; }
.help-page-body-content ul,
.help-page-body-content ol { margin: 10px 0; padding-left: 26px; }
.help-page-body-content li { margin: 5px 0; }
.help-page-body-content strong { color: #4a4a5a; }
.help-page-body-content code {
    background: #f2f2f7;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
    color: #c7254e;
}
.help-page-body-content blockquote {
    border-left: 4px solid #667eea;
    background: #f6f6fb;
    padding: 12px 16px;
    margin: 14px 0;
    color: #555;
    border-radius: 0 6px 6px 0;
}
.help-page-body-content blockquote p { margin: 5px 0; }
.help-page-body-content hr {
    border: none;
    border-top: 1px solid #e8e8ee;
    margin: 28px 0;
}
.help-page-body-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 14px 0;
    font-size: 14px;
}
.help-page-body-content th,
.help-page-body-content td {
    border: 1px solid #e0e0e8;
    padding: 10px 14px;
    text-align: left;
}
.help-page-body-content th {
    background: #f6f6fb;
    font-weight: 600;
}
.help-page-footer {
    background: #fff;
    padding: 18px 40px;
    border-top: 1px solid #eee;
    border-radius: 0 0 14px 14px;
    text-align: center;
    color: #888;
    font-size: 13px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
}
.help-page-footer p { margin: 0; }

/* "다음부터 띄우지 않기" 체크박스 영역 */
.help-page-dismiss {
    background: #fff8e1;
    border-top: 1px solid #f3e0a0;
    padding: 14px 24px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 14px;
}
.help-page-dismiss label {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    color: #5a4a10;
    font-weight: 600;
}
.help-page-dismiss input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #667eea;
}
.help-page-dismiss-hint {
    color: #8a7a3a;
    font-size: 13px;
}
[data-theme="dark"] .help-page-dismiss {
    background: #2a2410;
    border-top-color: #4a3a18;
}
[data-theme="dark"] .help-page-dismiss label {
    color: #ffdd99;
}
[data-theme="dark"] .help-page-dismiss-hint {
    color: #c0b070;
}
@media (max-width: 600px) {
    .help-page-dismiss {
        padding: 12px 16px;
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ===== Agent (Lab) 페이지 ===== */
.agent-page-body {
    margin: 0;
    background: #eef0f7;
    color: #2c2c34;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
    height: 100vh;
    overflow: hidden;
}
.agent-page-container {
    max-width: 1000px;
    margin: 0 auto;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: #fff;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.08);
}
.agent-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 24px;
    background: linear-gradient(135deg, #5b6ed8 0%, #8a5fb8 100%);
    color: #fff;
}
.agent-page-title h1 {
    margin: 0 0 4px;
    font-size: 21px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}
.agent-page-badge {
    display: inline-block;
    background: rgba(255, 255, 255, 0.22);
    border-radius: 6px;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
}
.agent-page-subtitle {
    margin: 0;
    font-size: 12px;
    opacity: 0.85;
}
.agent-page-actions { display: flex; gap: 8px; flex-shrink: 0; }
.agent-page-btn {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.25);
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.15s;
    white-space: nowrap;
}
.agent-page-btn:hover { background: rgba(255, 255, 255, 0.32); }

.agent-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 28px;
    background: #f7f8fc;
}
.agent-msg {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
}
.agent-msg-user { align-items: flex-end; }
.agent-msg-model { align-items: flex-start; }
.agent-msg-bubble {
    max-width: 78%;
    padding: 12px 16px;
    border-radius: 14px;
    line-height: 1.65;
    font-size: 14.5px;
    word-break: break-word;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.agent-msg-user .agent-msg-bubble {
    background: linear-gradient(135deg, #5b6ed8 0%, #8a5fb8 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.agent-msg-model .agent-msg-bubble {
    background: #fff;
    color: #2c2c34;
    border: 1px solid #e6e8f0;
    border-bottom-left-radius: 4px;
}
.agent-msg-model .agent-msg-bubble p { margin: 6px 0; }
.agent-msg-model .agent-msg-bubble p:first-child { margin-top: 0; }
.agent-msg-model .agent-msg-bubble p:last-child { margin-bottom: 0; }
.agent-msg-model .agent-msg-bubble ul,
.agent-msg-model .agent-msg-bubble ol { margin: 6px 0; padding-left: 22px; }
.agent-msg-model .agent-msg-bubble code {
    background: #f0f1f7;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 13px;
    color: #c7254e;
}
.agent-msg-model .agent-msg-bubble pre {
    background: #2a2a34;
    color: #e0e0e8;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
}
.agent-msg-model .agent-msg-bubble pre code { background: none; color: inherit; padding: 0; }
.agent-msg-model .agent-msg-bubble table {
    border-collapse: collapse;
    margin: 8px 0;
    width: 100%;
    font-size: 13px;
}
.agent-msg-model .agent-msg-bubble th,
.agent-msg-model .agent-msg-bubble td {
    border: 1px solid #d0d2dc;
    padding: 6px 10px;
    text-align: left;
}
.agent-msg-model .agent-msg-bubble th { background: #f0f1f7; }
.agent-progress {
    color: #8a8aa8;
    font-style: italic;
    font-size: 14px;
}

.agent-msg-sources {
    margin-top: 6px;
    max-width: 78%;
    background: #fff7e6;
    border: 1px solid #ffd591;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 13px;
    color: #6a4a10;
}
.agent-msg-sources strong { color: #b8610a; }
.agent-msg-sources ul { margin: 6px 0 0; padding-left: 20px; }
.agent-msg-sources li { margin: 2px 0; }

.agent-msg-usage {
    margin-top: 5px;
    font-size: 11px;
    color: #999;
}

.agent-input-area {
    display: flex;
    gap: 10px;
    padding: 16px 20px;
    background: #fff;
    border-top: 1px solid #e6e8f0;
}
.agent-input-area textarea {
    flex: 1;
    resize: none;
    border: 1px solid #d0d2dc;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
}
.agent-input-area textarea:focus { border-color: #5b6ed8; }
.agent-send-btn {
    background: linear-gradient(135deg, #5b6ed8 0%, #8a5fb8 100%);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 10px 22px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
}
.agent-send-btn:hover { opacity: 0.9; }
.agent-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

@media (max-width: 720px) {
    .agent-page-container { box-shadow: none; }
    .agent-page-header { padding: 14px 16px; flex-direction: column; align-items: flex-start; }
    .agent-page-title h1 { font-size: 18px; }
    .agent-messages { padding: 16px; }
    .agent-msg-bubble { max-width: 92%; }
    .agent-msg-sources { max-width: 92%; }
}

/* 도움말 본문 안의 버튼 아이콘 데모 */
.help-page-body-content .help-btn-demo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 14px 0;
    padding: 14px 18px;
    background: #f6f7fb;
    border: 1px dashed #c5cbe0;
    border-radius: 10px;
}
.help-page-body-content .help-btn-demo-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
    flex-shrink: 0;
}
.help-page-body-content .help-btn-demo-label {
    font-size: 14px;
    color: #555;
    font-weight: 500;
}
[data-theme="dark"] .help-page-body-content .help-btn-demo {
    background: #25252e;
    border-color: #444a5e;
}
[data-theme="dark"] .help-page-body-content .help-btn-demo-label {
    color: #c0c0c8;
}

/* 모바일 */
@media (max-width: 720px) {
    .help-page-container { padding: 12px 8px 32px; }
    .help-page-header {
        flex-direction: column;
        align-items: flex-start;
        padding: 18px 20px;
        border-radius: 12px 12px 0 0;
    }
    .help-page-title h1 { font-size: 20px; }
    .help-page-actions { width: 100%; justify-content: flex-end; }
    .help-page-body-content { padding: 22px 18px; }
    .help-page-footer { padding: 14px 20px; }
}

/* 인쇄 시 */
@media print {
    .help-page-actions { display: none; }
    .help-page-body { background: #fff; }
    .help-page-header { box-shadow: none; }
    .help-page-body-content,
    .help-page-footer { box-shadow: none; }
}

