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

:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --primary-light: #eff6ff;
    --secondary: #8b5cf6;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg-main: #f8fafc;
    --bg-sidebar: #ffffff;
    --bg-input: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --bubble-user: #eff6ff;
    --bubble-user-border: #bfdbfe;
    --bubble-ai: #ffffff;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 30px;
}

:root[data-theme="dark"] {
    --primary: #60a5fa;
    --primary-dark: #93c5fd;
    --primary-light: rgba(96, 165, 250, 0.15);
    --bg-main: #0b1120;
    --bg-sidebar: #111827;
    --bg-input: #1f2937;
    --text-primary: #e5e7eb;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border: #334155;
    --border-light: #1f2937;
    --bubble-user: rgba(59, 130, 246, 0.2);
    --bubble-user-border: rgba(96, 165, 250, 0.45);
    --bubble-ai: #111827;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --primary: #60a5fa;
        --primary-dark: #93c5fd;
        --primary-light: rgba(96, 165, 250, 0.15);
        --bg-main: #0b1120;
        --bg-sidebar: #111827;
        --bg-input: #1f2937;
        --text-primary: #e5e7eb;
        --text-secondary: #cbd5e1;
        --text-muted: #94a3b8;
        --border: #334155;
        --border-light: #1f2937;
        --bubble-user: rgba(59, 130, 246, 0.2);
        --bubble-user-border: rgba(96, 165, 250, 0.45);
        --bubble-ai: #111827;
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
        --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.45);
        --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    }
}

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

.app {
    display: flex;
    height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: 300px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 16px 12px 12px;
    transition: transform 0.3s;
    overflow: hidden;
    gap: 2px;
}

.sidebar.closed {
    transform: translateX(-100%);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding: 0 4px;
}

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

.logo-image {
    width: 86px;
    height: 56px;
    object-fit: contain;
    border-radius: 12px;
}

.logo-text {
    display: none;
}

.menu-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
}

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

/* User Section */
.user-section {
    margin-bottom: 12px;
    position: relative;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: var(--bg-input);
    border-radius: 16px;
    border: 1px solid var(--border);
}

.user-profile.hidden {
    display: none !important;
}

.user-avatar-img {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary-light);
}

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

.user-info span:first-child {
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-info span:last-child {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-menu-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
}

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

.user-menu-dropdown {
    position: absolute;
    right: 0;
    top: auto;
    bottom: calc(100% + 8px);
    background: #2f3238;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    min-width: 210px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
    padding: 8px;
    z-index: 1200;
}

.user-menu-item {
    width: 100%;
    border: none;
    background: transparent;
    color: #fff;
    font-size: 15px;
    border-radius: 10px;
    padding: 11px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    text-align: left;
}

.user-menu-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.user-menu-item.danger {
    color: #ffd6d6;
}

/* New Chat Button */
.new-chat-btn {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.new-chat-btn:hover {
    background: #e2e8f0;
    border-color: var(--primary);
}

.new-chat-btn i {
    color: var(--primary);
}

/* History Label */
.history-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 10px;
    padding-left: 6px;
}

/* Conversation List */
.conversation-list {
    list-style: none;
    flex: 1;
    min-height: 120px;
    min-height: 0;
    overflow-y: auto;
    margin-bottom: 12px;
    padding-right: 2px;
}

.conversation-list::-webkit-scrollbar {
    width: 5px;
}

.conversation-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 999px;
}

.conversation-list::-webkit-scrollbar-thumb:hover {
    background: #cbd5e1;
}

.conv-item {
    padding: 10px 10px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 13px;
}
.history-group {
    list-style: none;
    font-size: 11px;
    color: var(--text-muted);
    padding: 10px 8px 4px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.conv-item i {
    color: var(--text-secondary);
    font-size: 14px;
    width: 18px;
}

.conv-item.active {
    background: var(--primary-light);
    color: var(--primary);
}

.conv-item.active i {
    color: var(--primary);
}

.conv-item:hover:not(.active) {
    background: var(--bg-input);
}

.conv-title {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.delete-conv {
    opacity: 0;
    color: var(--text-secondary);
    padding: 3px;
}

.conv-item:hover .delete-conv {
    opacity: 0.6;
}

.delete-conv:hover {
    opacity: 1;
    color: var(--danger);
    background: #fee2e2;
}

/* Sidebar Footer */
.sidebar-bottom {
    margin-top: auto;
    position: sticky;
    bottom: 0;
    background: var(--bg-sidebar);
    padding-top: 8px;
}

.sidebar-footer {
    padding-top: 12px;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
}

.sidebar-auth-links {
    margin-top: 0;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-auth-link {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 9px 11px;
    font-size: 13px;
    color: var(--text-primary);
    text-decoration: none;
    background: var(--bg-input);
}

.sidebar-auth-link.cta {
    justify-content: center;
    font-weight: 600;
}

.sidebar-auth-link:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.scroll-bottom-btn {
    position: absolute;
    right: 18px;
    bottom: 102px;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background: rgba(35, 37, 43, 0.92);
    color: #fff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 25px;
    z-index: 35;
}

.scroll-bottom-btn:hover {
    transform: translateY(-1px);
}

.sidebar-auth-note {
    font-size: 11px;
    color: var(--text-muted);
    padding: 0 2px;
}

/* ===== MENU DROPDOWN ===== */
.menu-dropdown {
    position: fixed;
    top: 60px;
    left: 310px;
    background: var(--bg-sidebar);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    padding: 6px;
    min-width: 200px;
    z-index: 1000;
    display: none;
}

.menu-dropdown.show {
    display: block;
}

.menu-item {
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    border-radius: 8px;
    font-size: 13px;
}

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

.menu-divider {
    height: 1px;
    background: var(--border);
    margin: 6px 0;
}

/* ===== MAIN CHAT ===== */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg-main);
    position: relative;
}

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

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

.hamburger-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 16px;
}

.hamburger-btn:hover {
    background: var(--bg-input);
}

.chat-info {
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-info h2 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.time-badge {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    color: var(--text-secondary);
    background: var(--bg-input);
    padding: 3px 8px;
    border-radius: 16px;
    border: 1px solid var(--border);
}

.time-badge i {
    color: var(--primary);
    font-size: 10px;
}

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

.model-indicator {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    font-weight: 500;
    color: var(--primary);
    background: var(--primary-light);
    padding: 3px 8px;
    border-radius: 16px;
    border: 1px solid var(--bubble-user-border);
}

.model-indicator img {
    width: 13px;
    height: 13px;
    object-fit: contain;
}

/* ===== TAMBAHAN: HEADER NEW CHAT BUTTON ===== */
.header-new-chat-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 16px;
    transition: all 0.15s;
}

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

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.empty-state {
    text-align: center;
    padding: 40px 16px;
    color: var(--text-secondary);
    max-width: 450px;
    margin: 0 auto;
}

.empty-icon {
    width: 108px;
    height: 108px;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.empty-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.empty-state h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.empty-state p {
    font-size: 13px;
    margin-bottom: 20px;
}

.suggestions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
}

.suggestion-btn {
    padding: 8px 12px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all 0.15s;
}

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

.suggestion-btn i {
    color: var(--primary);
}

/* Messages */
.message {
    display: flex;
    gap: 6px;
    max-width: 90%;
    animation: slideIn 0.2s ease;
}

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

.message.user {
    flex-direction: row-reverse;
    align-self: flex-end;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
    background: #e2e8f0;
    color: var(--text-secondary);
}

.message.user .message-avatar {
    background: #dbeafe;
    color: var(--primary);
}

.message.assistant .message-avatar {
    background: transparent;
    color: white;
    animation: ai-avatar-breath 2.2s ease-in-out infinite;
}

.message.assistant .message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 8px;
}

.message-content-wrapper {
    position: relative;
    flex: 1;
    min-width: 0;
}

.message-content {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    padding: 8px 12px;
    border-radius: 14px;
    background: var(--bubble-ai);
    border: 1px solid var(--border);
    line-height: 1.4;
    font-size: 13px;
    word-break: break-word;
    box-shadow: var(--shadow-sm);
}

.message.assistant .message-content {
    background: linear-gradient(180deg, color-mix(in srgb, var(--bubble-ai) 92%, var(--primary-light) 8%), var(--bubble-ai));
}

.message-content strong {
    font-weight: 700;
}

.message-content em {
    font-style: italic;
}

.message-content code {
    padding: 2px 5px;
    border-radius: 6px;
    background: rgba(15, 23, 42, 0.08);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
}

.message-content a {
    color: var(--primary-dark);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.message-citations-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
    margin-bottom: 3px;
}

.source-chip,
.inline-source-ref {
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-secondary);
    border-radius: 999px;
    padding: 3px 9px;
    font-size: 11px;
    cursor: pointer;
}

.source-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.source-inline-label {
    display: inline-flex;
    align-items: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-left: 4px;
}

.source-chip img {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex: 0 0 auto;
}

.source-chip:hover,
.inline-source-ref:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.inline-source-ref {
    display: inline-flex;
    margin: 0 2px;
}

.message.user .message-content {
    background: var(--bubble-user);
    border-color: var(--bubble-user-border);
}

.message.error .message-content {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

.message-image {
    max-width: 180px;
    border-radius: 10px;
    margin-top: 8px;
    overflow: hidden;
}

.message-image img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 10px;
}

/* Message Actions */
.message-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-top: 5px;
    padding-top: 2px;
    opacity: 1;
    transition: opacity 0.15s;
}

.message.pending .message-actions {
    opacity: 0.45;
    pointer-events: none;
}

.message:hover .message-actions {
    opacity: 1;
}

.action-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    font-size: 11px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    transition: all 0.15s;
}

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

.action-btn.liked {
    color: var(--success);
}

.action-btn.liked i {
    color: var(--success);
}

.action-btn.disliked {
    color: var(--danger);
}

.action-btn.disliked i {
    color: var(--danger);
}

.action-btn.copied {
    color: var(--success);
}

.action-btn i {
    font-size: 11px;
}

.feedback-indicator {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 9px;
    color: var(--text-muted);
    margin-left: 4px;
}

.search-indicator {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 9px;
    color: var(--success);
    margin-left: 4px;
}

/* ===== IMAGE DRAFT ===== */
.image-draft-container {
    padding: 8px 12px 0;
    background: transparent;
    flex-shrink: 0;
}

.image-draft {
    display: inline-flex;
    align-items: flex-start;
    gap: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 6px 10px 6px 6px;
    max-width: 260px;
    position: relative;
}

.image-draft-preview {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
}

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

.image-draft-info {
    flex: 1;
    min-width: 0;
}

.image-draft-name {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.image-draft-size {
    font-size: 9px;
    color: var(--text-muted);
}

.image-draft-remove {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--danger);
    color: white;
    border: 2px solid var(--bg-sidebar);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 10px;
    transition: all 0.15s;
    box-shadow: var(--shadow-sm);
}

.image-draft-remove:hover {
    background: #dc2626;
    transform: scale(1.1);
}

/* Thinking Indicator */
.thinking-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 0;
    color: var(--text-secondary);
    font-size: 12px;
}

.thinking-indicator i {
    color: var(--primary);
    animation: pulse 1.5s infinite;
}

.thinking-indicator span {
    animation: fadeText 1.5s infinite;
}

.thinking-dots {
    display: inline-flex;
    align-items: flex-end;
    gap: 4px;
    height: 14px;
}

.thinking-dots span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--primary);
    animation: thinkingUpDown 0.9s ease-in-out infinite;
}

.thinking-dots span:nth-child(2) { animation-delay: 0.18s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.36s; }

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

@keyframes fadeText {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

@keyframes thinkingUpDown {
    0%, 100% { transform: translateY(2px); opacity: 0.55; }
    50% { transform: translateY(-3px); opacity: 1; }
}

@keyframes ai-avatar-breath {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.06); }
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 3px;
    padding: 4px 0;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background: #94a3b8;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

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

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

.loading-dots {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 4px 0;
}

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

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

/* Typing Cursor */
.typing-cursor {
    display: inline-block;
    width: 2px;
    height: 1.2em;
    background-color: var(--primary);
    margin-left: 3px;
    vertical-align: middle;
    animation: blink 1s infinite;
}

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

/* Chat Input */
.chat-input-area {
    padding: 8px 12px 10px;
    background: var(--bg-sidebar);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    position: relative;
}

.composer-toolbar {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    align-items: center;
}

.hidden {
    display: none !important;
}

.model-select {
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 12px;
    padding: 8px 12px;
    min-width: 128px;
    max-width: 170px;
    height: 34px;
}
.model-select-btn {
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 12px;
    padding: 8px 12px;
    min-width: 128px;
    max-width: 170px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.tools-btn {
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 12px;
    padding: 8px 12px;
    cursor: pointer;
    display: inline-flex;
    gap: 6px;
    align-items: center;
    height: 34px;
    padding: 8px 10px;
}


.model-select-panel {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 10px;
    min-width: 230px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 10px;
    box-shadow: var(--shadow-lg);
    z-index: 40;
}
.model-group-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    margin: 6px 4px;
}
.panel-model-item {
    width: 100%;
    text-align: left;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-primary);
    border-radius: 10px;
    padding: 9px 10px;
    margin-bottom: 6px;
    cursor: pointer;
}
.model-panel-note {
    color: var(--text-muted);
    font-size: 11px;
    display: block;
    margin: 4px 4px 0;
}

.tools-menu {
    position: absolute;
    left: 16px;
    width: min(280px, calc(100% - 32px));
    bottom: calc(100% + 8px);
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    padding: 8px;
    z-index: 30;
}
.tools-menu-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 2px 8px 6px;
}

.tool-item {
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: 10px;
    padding: 8px;
    color: var(--text-primary);
}

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

.tool-item span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.search-input-container {
    position: relative;
}

.input-container {
    background: var(--bg-input);
    border-radius: 24px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 8px 8px 8px 10px;
    transition: all 0.2s;
}
.input-container.stacked {
    flex-direction: column;
    align-items: stretch;
}

.input-container:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    background: var(--bg-sidebar);
}

.attach-btn {
    width: 32px;
    height: 32px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 16px;
    transition: all 0.15s;
    flex-shrink: 0;
}

.attach-btn:hover {
    background: #e2e8f0;
    color: var(--primary);
}

#messageInput {
    flex: 1;
    background: transparent;
    border: none;
    padding: 8px 4px;
    font-size: 13px;
    resize: none;
    outline: none;
    font-family: inherit;
    max-height: 80px;
    color: var(--text-primary);
}

#messageInput::placeholder {
    color: var(--text-muted);
    font-size: 12px;
}

.send-btn {
    min-width: 32px;
    padding: 0 10px;
    height: 32px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    border: none;
    color: white;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.15s;
    flex-shrink: 0;
    gap: 8px;
    font-weight: 600;
}

.send-btn:hover {
    background: var(--primary-dark);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.send-btn.stop {
    background: var(--danger);
}

.send-btn.stop i {
    font-size: 12px;
}

.sources-btn.has-sources {
    color: var(--primary);
}

.sources-btn {
    margin-left: 10px;
}

.sources-btn.is-empty {
    opacity: 0.45;
}

.sources-sheet {
    position: fixed;
    inset: 0;
    z-index: 1500;
}

.sources-sheet-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
}

.sources-sheet-panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 72vh;
    background: #08090c;
    color: #fff;
    border-radius: 20px 20px 0 0;
    padding: 10px 14px 16px;
    overflow: auto;
}

.sources-sheet-handle {
    width: 56px;
    height: 5px;
    border-radius: 999px;
    margin: 0 auto 12px;
    background: rgba(255, 255, 255, 0.25);
}

.sources-sheet-header {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 10px;
}

.source-item {
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.source-item a {
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    display: block;
    margin-bottom: 5px;
}

.source-item p {
    color: rgba(255, 255, 255, 0.74);
    font-size: 14px;
    }

/* TAMBAHAN: Feature Hint */
.feature-hint {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 6px;
    font-size: 10px;
    color: var(--text-muted);
}

.hint-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.hint-item i {
    color: var(--primary);
    font-size: 10px;
}

/* Search Suggestions */
.search-suggestions {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    z-index: 20;
    max-height: 250px;
    overflow-y: auto;
}

.suggestions-header {
    padding: 8px 12px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 6px;
}

.suggestion-item {
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: background 0.1s;
    color: var(--text-primary);
    font-size: 12px;
}

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

.suggestion-item i {
    color: var(--text-secondary);
    width: 16px;
    font-size: 12px;
}

.hidden {
    display: none !important;
}

/* ===== TAMBAHAN: SETTINGS MODAL ===== */
.settings-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-modal.hidden {
    display: none !important;
}

.settings-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.settings-container {
    position: relative;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    background: var(--bg-sidebar);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

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

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

.settings-close-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 16px;
    transition: all 0.15s;
}

.settings-close-btn:hover {
    background: var(--bg-input);
}

.settings-tabs {
    display: flex;
    padding: 8px 16px 0;
    border-bottom: 1px solid var(--border);
    gap: 4px;
}

.settings-tab {
    padding: 10px 20px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px 8px 0 0;
    transition: all 0.15s;
}

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

.settings-tab.active {
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
}

.settings-content {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.settings-content.hidden {
    display: none !important;
}

.settings-section {
    margin-bottom: 24px;
}

.settings-section h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.settings-model-options {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.settings-model-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, transform 0.15s;
    text-align: left;
}

.settings-model-btn:hover {
    border-color: #cbd5e1;
    transform: translateY(-1px);
}

.settings-model-btn.active {
    border-color: var(--primary);
    background: var(--primary-light);
}

.settings-model-btn i {
    width: 24px;
    text-align: center;
    color: var(--primary);
    font-size: 18px;
    flex-shrink: 0;
}

.model-logo {
    width: 24px;
    height: 24px;
    object-fit: contain;
    flex-shrink: 0;
}

.settings-model-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

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

.settings-model-desc {
    color: var(--text-secondary);
    font-size: 11px;
}

.feature-settings {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.feature-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-input);
    padding: 12px;
}

.feature-toggle-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.feature-toggle-info span {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.feature-toggle-info small {
    font-size: 11px;
    color: var(--text-secondary);
}

.feature-toggle input[type="checkbox"] {
    width: 40px;
    height: 22px;
    accent-color: var(--primary);
    cursor: pointer;
}

.theme-options {
    display: flex;
    gap: 12px;
}

.theme-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.15s;
}

.theme-btn i {
    font-size: 16px;
}

.theme-btn.active {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
}

.language-select {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    outline: none;
}

.language-select:focus {
    border-color: var(--primary);
}

.profile-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input {
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
}

.form-group input:focus {
    border-color: var(--primary);
}

.form-group input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.save-profile-btn {
    padding: 12px 20px;
    background: var(--primary);
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.save-profile-btn:hover {
    background: var(--primary-dark);
}

.danger-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    background: transparent;
    border: 1px solid var(--danger);
    border-radius: 12px;
    color: var(--danger);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.15s;
    margin-bottom: 12px;
}

.danger-btn:hover {
    background: transparent;
}

/* ===== MOBILE ===== */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        z-index: 100;
        box-shadow: var(--shadow-lg);
        max-width: 260px;
    }
    
    .sidebar.closed {
        transform: translateX(-100%);
    }
    
    .main {
        margin-left: 0;
        width: 100%;
    }
    
    .chat-header {
        padding: 6px 10px;
    }
    
    .header-left {
        gap: 6px;
    }
    
    .hamburger-btn {
        width: 28px;
        height: 28px;
    }
    
    .chat-info {
        gap: 4px;
    }
    
    .chat-info h2 {
        font-size: 14px;
        max-width: 100px;
    }
    
    .time-badge {
        padding: 2px 6px;
        font-size: 9px;
    }
    
    .time-badge i {
        font-size: 9px;
    }
    
    .time-badge span {
        display: none;
    }
    
    .model-indicator {
        padding: 2px 6px;
        font-size: 9px;
    }
    
    .model-indicator span {
        display: none;
    }
    
    .model-indicator i {
        margin: 0;
    }
    
    .header-new-chat-btn {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }
    
    .chat-messages {
        padding: 10px;
        gap: 10px;
    }
    
    .message {
        max-width: 95%;
        gap: 5px;
    }
    
    .message-avatar {
        width: 32px;
        height: 32px;
        font-size: 11px;
    }
    
    .message-content {
        padding: 7px 10px;
        font-size: 12px;
    }
    
    .message-image {
        max-width: 150px;
    }
    
    .empty-state {
        padding: 30px 12px;
    }
    
    .empty-icon {
        width: 84px;
        height: 84px;
    }
    
    .empty-state h3 {
        font-size: 18px;
    }
    
    .empty-state p {
        font-size: 12px;
    }
    
    .suggestions {
        flex-direction: column;
        align-items: stretch;
        gap: 5px;
    }
    
    .suggestion-btn {
        justify-content: center;
        padding: 8px 10px;
    }
    
    .message-actions {
        opacity: 1;
        flex-wrap: wrap;
        margin-top: 3px;
    }
    
    .action-btn {
        padding: 3px 5px;
    }
    
    .action-btn span {
        display: none;
    }
    
    .action-btn i {
        font-size: 11px;
    }
    
    .image-draft-container {
        padding: 6px 10px 0;
    }
    
    .image-draft {
        max-width: 100%;
        padding: 5px 8px 5px 5px;
    }
    
    .image-draft-preview {
        width: 38px;
        height: 38px;
    }
    
    .chat-input-area {
        padding: 6px 10px 8px;
        padding-bottom: max(8px, env(safe-area-inset-bottom));
    }

    .model-select,
    .tools-btn {
        font-size: 11px;
        padding: 7px 10px;
    }
    .model-select {
        min-width: 108px;
        max-width: 140px;
    }
    
    .input-container {
        padding: 6px 6px 6px 8px;
    }
    
    .attach-btn {
        width: 28px;
        height: 28px;
    }
    
    #messageInput {
        padding: 6px 3px;
        font-size: 13px;
    }
    
    .send-btn.wide {
        width: 100%;
        height: 38px;
    }
    
    .menu-dropdown {
        left: 10px;
        right: 10px;
        min-width: auto;
        max-width: 240px;
    }
    
    .settings-container {
        width: 95%;
        max-height: 85vh;
    }
    
    .settings-tab {
        padding: 8px 16px;
        font-size: 13px;
    }
    
    .theme-options {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .chat-info h2 {
        max-width: 70px;
        font-size: 13px;
    }
    
    .time-badge i {
        margin: 0;
    }
}

/* Safe Area untuk iPhone */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .chat-input-area {
        padding-bottom: max(8px, env(safe-area-inset-bottom));
    }
    
    .sidebar {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* ===== FIX KHUSUS MOBILE ===== */
@media (max-width: 768px) {
    body {
        position: fixed;
        width: 100%;
        height: 100vh;
        height: 100dvh;
    }
    
    .app {
        height: 100vh;
        height: 100dvh;
    }
    
    .sidebar {
        width: 85%;
        max-width: 280px;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }
    
    .main {
        width: 100%;
        margin-left: 0 !important;
    }
    
    .chat-header {
        padding: 5px 8px;
    }
    
    .chat-messages {
        padding: 8px;
    }
    
    .chat-input-area {
        padding: 5px 8px 8px;
    }
    
    .input-container {
        margin-bottom: 0;
    }
}

/* Fix untuk iOS Safari */
@supports (-webkit-touch-callout: none) {
    .chat-messages {
        -webkit-overflow-scrolling: touch;
    }
    
    #messageInput {
        font-size: 16px;
    }
}

.quota-badge {
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    background: var(--bg-input);
}

.quota-badge.premium {
    color: #7c3aed;
    border-color: #c4b5fd;
    background: #f5f3ff;
}

.source-logo-stack {
    display: inline-flex;
    margin-right: 2px;
}

.source-logo-stack img {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1px solid var(--bg-sidebar);
    margin-right: -5px;
}

.source-item a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.source-item a img {
    width: 16px;
    height: 16px;
    border-radius: 50%;
}


.profile-premium-badge{display:inline-flex;align-items:center;width:max-content;margin-top:4px;padding:2px 8px;border-radius:999px;background:rgba(124,58,237,.15);color:#a78bfa;font-size:10px;font-weight:600;text-transform:uppercase;letter-spacing:.4px;}
.header-right .quota-badge{display:none!important;}
.model-indicator{gap:6px;}
.model-indicator i{display:none;}
.model-indicator img{width:14px;height:14px;border-radius:50%;}
.composer-toolbar{display:flex;align-items:center;justify-content:space-between;gap:8px;flex-wrap:nowrap;}
.model-select-btn{display:inline-flex;align-items:center;gap:7px;}
.model-select-btn img{width:14px;height:14px;border-radius:50%;}
.tools-btn{margin-right:auto;}
.attach-btn,.send-btn{align-self:center;}
.send-btn{margin-left:0;}
.send-btn #sendBtnText{display:none;}
.model-select-panel{min-width:320px;max-width:min(92vw,360px);padding:10px 10px 0;border-radius:18px;background:#20232b;border-color:rgba(255,255,255,.08);}
.model-group-title{font-size:12px;letter-spacing:.08em;color:rgba(255,255,255,.5);margin:6px 6px 8px;}
.panel-model-item{display:flex;align-items:center;justify-content:space-between;background:rgba(255,255,255,.04);border:1px solid transparent;color:#e5e7eb;border-radius:11px;padding:10px;}
.panel-model-item.locked{opacity:.72;cursor:not-allowed;}
.panel-model-item.locked i{color:#9ca3af;}
.premium-title{display:flex;align-items:center;gap:8px;}
.upgrade-badge{font-size:10px;padding:2px 7px;border-radius:999px;background:rgba(245,158,11,.2);color:#fbbf24;}
.model-panel-note{display:flex;gap:7px;align-items:center;background:rgba(0,0,0,.24);padding:12px 10px;margin:10px -10px 0;border-radius:0 0 18px 18px;border-top:1px solid rgba(255,255,255,.06);font-size:12px;}
@media (max-width:768px){.composer-toolbar{gap:6px}.tools-btn{padding:8px 10px}.model-select-btn{min-width:120px}.model-select-panel{left:0;right:0;min-width:100%;}}


.user-profile{align-items:flex-start;padding:10px 12px;gap:10px;}
.user-info{display:flex;flex-direction:column;min-width:0;gap:2px;}
.user-info #userEmail{font-size:11px;line-height:1.3;}
.profile-premium-badge{margin-top:6px;}
.model-select-panel{min-width:260px;max-width:280px;padding:8px;border-radius:14px;}
.model-panel-note{margin:8px 0 0;border-radius:10px;padding:8px 9px;font-size:11px;}
.limit-notice{position:sticky;top:8px;z-index:9;max-width:540px;margin:8px auto 10px;background:#2b2d33;border:1px solid rgba(255,255,255,.1);border-radius:16px;padding:12px 14px;display:flex;flex-direction:column;gap:10px;}
.limit-notice.hidden{display:none!important;}
.limit-notice-text{font-size:14px;line-height:1.45;color:#eceff4;padding-right:24px;}
.limit-notice-close{position:absolute;right:10px;top:8px;background:transparent;border:none;color:#c7cad1;cursor:pointer;}
.limit-notice-cta{border:none;background:#1e2740;color:#cdd8ff;border-radius:999px;padding:10px 14px;font-weight:600;cursor:pointer;align-self:stretch;}


.panel-model-item span small{display:block;font-size:10px;color:#9ca3af;margin-top:2px;}
.code-block{margin:10px 0;border:1px solid rgba(255,255,255,.12);border-radius:10px;overflow:hidden;background:#1e1e1e;}
.code-header{display:flex;justify-content:space-between;align-items:center;background:#2a2d2e;padding:7px 10px;border-bottom:1px solid rgba(255,255,255,.08);}
.code-language{font-size:11px;text-transform:lowercase;color:#d1d5db;font-family:'Fira Code','Courier New',monospace;}
.code-copy-btn{background:#3b3f41;color:#e5e7eb;border:1px solid rgba(255,255,255,.2);border-radius:6px;padding:3px 8px;font-size:11px;cursor:pointer;}
.code-block pre{margin:0;padding:12px;overflow:auto;max-width:100%;}
.code-block code{display:block;color:#d4d4d4;background:transparent!important;font-family:'Fira Code','Courier New',monospace;font-size:12px;line-height:1.5;white-space:pre;min-width:max-content;}
.code-block pre::-webkit-scrollbar{height:10px;width:10px;}
.code-block pre::-webkit-scrollbar-thumb{background:#4b5563;border-radius:999px;}


* { -webkit-tap-highlight-color: transparent; }
button:focus, button:focus-visible, .action-btn:focus, .panel-model-item:focus { outline: none !important; box-shadow: none !important; }
.profile-premium-badge.is-free{background:rgba(148,163,184,.18);color:#cbd5e1;}
