.chat-page {
    overflow: hidden;
    height: 100vh;
}

.chat-app {
    display: flex;
    height: 100vh;
    width: 100%;
}

.sidebar {
    width: 280px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-subtle);
}

.btn-new-chat {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: linear-gradient(135deg, var(--purple-600), var(--purple-800));
    color: white;
    border: none;
    border-radius: 12px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 4px 16px rgba(147, 51, 234, 0.3);
}

.btn-new-chat:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(147, 51, 234, 0.5);
}

.plus {
    font-size: 20px;
    line-height: 1;
    font-weight: 400;
}

.sidebar-history {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 14px;
    transition: all 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.history-item.active {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-medium);
}

.history-item-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-empty {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    padding: 40px 20px;
    line-height: 1.6;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--text-muted);
    font-size: 13px;
    background: transparent;
    border: 1px solid transparent;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    width: 100%;
    text-align: left;
}

.sidebar-link:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-subtle);
}

.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    position: relative;
    min-width: 0;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-subtle);
    background: rgba(10, 8, 18, 0.8);
    backdrop-filter: blur(20px);
    z-index: 10;
}

.menu-toggle {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
}

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

.chat-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 16px;
    flex: 1;
}

.chat-status {
    font-size: 12px;
    color: var(--accent-green);
    font-weight: 500;
    margin-left: 8px;
}

.chat-controls {
    display: flex;
    gap: 8px;
}

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

.icon-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-medium);
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 32px 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    scroll-behavior: smooth;
}

.welcome {
    max-width: 720px;
    margin: auto;
    text-align: center;
    padding: 40px 20px;
    animation: fadeInUp 0.6s ease;
}

.welcome-logo {
    width: 72px;
    height: 72px;
    margin: 0 auto 24px;
    border-radius: 24px;
    background: linear-gradient(135deg, var(--purple-500), var(--accent-pink));
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--glow-md);
    animation: float 4s ease-in-out infinite;
}

.welcome-dot {
    width: 24px;
    height: 24px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
}

.welcome-title {
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 12px;
}

.welcome-subtitle {
    color: var(--text-secondary);
    font-size: 16px;
    margin-bottom: 40px;
    line-height: 1.6;
}

.suggestions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.suggestion {
    padding: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    transition: all 0.25s ease;
    line-height: 1.5;
}

.suggestion:hover {
    background: var(--bg-hover);
    border-color: var(--border-strong);
    color: var(--text-primary);
    transform: translateY(-2px);
    box-shadow: var(--glow-sm);
}

.msg {
    display: flex;
    gap: 14px;
    max-width: 780px;
    width: 100%;
    margin: 0 auto;
    animation: fadeInUp 0.4s ease;
}

.msg-avatar {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 18px;
}

.msg-user .msg-avatar {
    background: linear-gradient(135deg, var(--purple-600), var(--purple-800));
    color: white;
    font-weight: 700;
    font-size: 14px;
}

.msg-ai .msg-avatar {
    background: linear-gradient(135deg, var(--purple-500), var(--accent-pink));
    box-shadow: var(--glow-sm);
    color: white;
}

.msg-body {
    flex: 1;
    min-width: 0;
}

.msg-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.msg-text {
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-primary);
    word-wrap: break-word;
    white-space: pre-wrap;
}

.msg-text code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--border-subtle);
}

.msg-text pre {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 16px;
    margin: 12px 0;
    overflow-x: auto;
}

.msg-text pre code {
    background: transparent;
    border: none;
    padding: 0;
}

.typing {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.typing span {
    width: 6px;
    height: 6px;
    background: var(--purple-400);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

.status-line {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    color: var(--purple-300);
    font-size: 14px;
    font-style: italic;
}

.status-line::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--purple-400);
    box-shadow: 0 0 8px var(--purple-400);
    animation: pulse 1.4s ease-in-out infinite;
    flex-shrink: 0;
}

.file-card-wrap {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 12px;
    max-width: 460px;
}

.file-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.1), rgba(236, 72, 153, 0.06));
    border: 1px solid var(--border-medium);
    border-radius: 16px;
    text-decoration: none;
    color: inherit;
    transition: all 0.25s ease;
    cursor: pointer;
}

.file-card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--glow-sm);
    transform: translateY(-2px);
}

.file-card-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--purple-600), var(--purple-800));
    border-radius: 12px;
    font-size: 20px;
    flex-shrink: 0;
    color: white;
}

.file-card-info {
    flex: 1;
    min-width: 0;
}

.file-card-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-card-meta {
    font-size: 12px;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

.file-card-download {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: linear-gradient(135deg, var(--purple-500), var(--purple-700));
    color: white;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.file-card:hover .file-card-download {
    box-shadow: var(--glow-sm);
}

.file-card-note {
    font-size: 11px;
    color: #f9e2af;
    opacity: 0.75;
    padding-left: 4px;
    line-height: 1.4;
}

.user-file-chip {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    padding: 8px 12px;
    background: rgba(168, 85, 247, 0.12);
    border: 1px solid var(--border-medium);
    border-radius: 12px;
    font-size: 13px;
    color: var(--text-primary);
    max-width: 100%;
}

.user-file-chip-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.user-file-chip-name {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.user-file-chip-size {
    color: var(--text-muted);
    font-size: 11px;
    flex-shrink: 0;
}

.user-files-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
}

.composer {
    padding: 12px 24px 20px;
    background: linear-gradient(to top, var(--bg-primary) 60%, transparent);
    border-top: 1px solid var(--border-subtle);
}

.composer-privacy {
    max-width: 780px;
    margin: 0 auto 10px;
    padding: 8px 14px;
    background: rgba(249, 226, 175, 0.06);
    border: 1px solid rgba(249, 226, 175, 0.18);
    border-radius: 10px;
    font-size: 12px;
    color: #f9e2af;
    text-align: center;
    line-height: 1.5;
}

.composer-privacy strong {
    color: #f9e2af;
    font-weight: 700;
}

.composer-files {
    max-width: 780px;
    margin: 0 auto 8px;
    display: none;
    flex-direction: column;
    gap: 6px;
    max-height: 260px;
    overflow-y: auto;
    animation: fadeInUp 0.25s ease;
}

.composer-files.visible {
    display: flex;
}

.composer-files-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 6px;
    font-size: 11px;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: 0.05em;
}

.pending-file {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: rgba(168, 85, 247, 0.1);
    border: 1px solid var(--border-medium);
    border-radius: 12px;
    transition: all 0.2s ease;
}

.pending-file:hover {
    border-color: var(--border-strong);
}

.pending-file-icon {
    font-size: 20px;
    flex-shrink: 0;
}

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

.pending-file-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 2px;
}

.pending-file-size {
    font-size: 11px;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

.pending-file-remove {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    font-family: inherit;
    padding: 0;
    line-height: 1;
}

.pending-file-remove:hover {
    background: rgba(243, 139, 168, 0.15);
    color: #f38ba8;
    border-color: rgba(243, 139, 168, 0.3);
}

.composer-inner {
    max-width: 780px;
    margin: 0 auto;
    display: flex;
    gap: 6px;
    align-items: flex-end;
    background: var(--bg-card);
    border: 1px solid var(--border-medium);
    border-radius: 20px;
    padding: 8px;
    transition: all 0.25s ease;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.composer-inner:focus-within {
    border-color: var(--border-strong);
    box-shadow: var(--glow-sm);
}

.composer-attach {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--text-muted);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.composer-attach:hover {
    background: var(--bg-hover);
    color: var(--purple-300);
}

.composer-attach.active {
    color: var(--accent-pink);
}

.composer-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 15px;
    line-height: 1.5;
    resize: none;
    max-height: 200px;
    padding: 10px 8px;
    min-width: 0;
}

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

.composer-send {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--purple-500), var(--purple-700));
    color: white;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.25s ease;
    flex-shrink: 0;
}

.composer-send:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: var(--glow-sm);
}

.composer-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.composer-hint {
    max-width: 780px;
    margin: 10px auto 0;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
}

.kbd {
    display: inline-block;
    padding: 1px 6px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--text-secondary);
}

.consent-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 8, 18, 0.85);
    backdrop-filter: blur(10px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeInUp 0.4s ease;
}

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

.consent-box {
    max-width: 560px;
    width: 100%;
    padding: 40px;
    background: var(--bg-card);
    border: 1px solid var(--border-medium);
    border-radius: 24px;
    box-shadow: var(--glow-md), 0 30px 80px rgba(0, 0, 0, 0.5);
}

.consent-title {
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 20px;
    text-align: center;
    background: linear-gradient(135deg, var(--purple-300), var(--accent-pink));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.consent-text {
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.7;
    margin-bottom: 16px;
    text-align: center;
}

.consent-text strong {
    color: var(--accent-pink);
}

.consent-note {
    padding: 14px 18px;
    background: rgba(249, 226, 175, 0.08);
    border: 1px solid rgba(249, 226, 175, 0.22);
    border-radius: 12px;
    font-size: 13px;
    color: #f9e2af;
    line-height: 1.6;
    margin-bottom: 28px;
    text-align: left;
}

.consent-note strong {
    color: #f9e2af;
    font-weight: 700;
}

.consent-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.consent-actions .btn {
    flex: 1;
    padding: 14px 20px;
}

.consent-link {
    display: block;
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 1px dotted var(--text-muted);
    transition: color 0.2s ease;
}

.consent-link:hover {
    color: var(--purple-300);
    border-bottom-color: var(--purple-300);
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 100;
        transform: translateX(-100%);
        box-shadow: 20px 0 60px rgba(0, 0, 0, 0.5);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .menu-toggle {
        display: flex;
    }
    .messages {
        padding: 20px 16px;
    }
    .composer {
        padding: 10px 16px 16px;
    }
    .suggestions {
        grid-template-columns: 1fr;
    }
    .consent-box {
        padding: 28px 24px;
    }
    .consent-actions {
        flex-direction: column;
    }
    .file-card-wrap {
        max-width: 100%;
    }
}