:root {
    --bg-dark: #131314; 
    --sidebar-bg: #1e1f20;
    --text-main: #e3e3e3;
    --accent: #333537;
    --user-bubble: #2f2f2f;
    --gemini-blue: #4285f4;
    --text-muted: #9aa0a6;
    --input-bg: #1e1f20;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body, html { 
    height: 100%; width: 100%; 
    font-family: 'Outfit', sans-serif; 
    background: var(--bg-dark); color: var(--text-main); 
    overflow: hidden; 
}

/* HEADER */
.header {
    position: fixed; top: 0; left: 0; right: 0; height: 64px;
    background: var(--bg-dark); display: flex; align-items: center; justify-content: space-between;
    padding: 0 16px; z-index: 5000;
}

.header-left, .header-right { display: flex; align-items: center; gap: 4px; }

.header-btn { 
    background: transparent; border: none; color: #fff; cursor: pointer;
    width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.header-btn:hover { background: var(--accent); border-radius: 50%; }

.app-title-container {
    font-weight: 500; font-size: 18px; margin-left: 8px;
    background: linear-gradient(90deg, #4285f4, #9b72cb, #d96570);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    display: flex; align-items: center; gap: 8px;
}

/* SIDEBAR */
.sidebar { 
    position: fixed; left: -280px; top: 0; bottom: 0; width: 280px; 
    background: var(--sidebar-bg); transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1); z-index: 6000; 
    padding-top: 20px; box-shadow: 10px 0 30px rgba(0,0,0,0.5);
}
.sidebar.open { left: 0; }

.new-chat-sidebar { 
    margin: 12px 16px; padding: 14px 20px; border-radius: 12px; background: #1a1c1e; 
    color: #fff; border: 1px solid #444746; cursor: pointer; display: flex; align-items: center; gap: 12px; font-size: 14px;
}

.history-container { height: calc(100% - 120px); overflow-y: auto; padding: 0 12px; margin-top: 10px; }
.history-item { 
    padding: 12px 16px; border-radius: 24px; cursor: pointer; color: #c4c7c5; 
    font-size: 14px; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.history-item:hover { background: rgba(255,255,255,0.05); }
.history-item.active-session { background: rgba(66, 133, 244, 0.15); color: #fff; font-weight: 500; }

.overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 5500; display: none;
}
.sidebar.open ~ .overlay { display: block; }

/* MAIN CONTENT */
.main-content { flex: 1; display: flex; flex-direction: column; width: 100%; height: 100vh; position: relative; align-items: center; }

.chat-window { 
    flex: 1; overflow-y: auto; overflow-x: hidden;
    padding: 80px 16px 280px 16px;
    display: flex; flex-direction: column; gap: 32px;
    width: 100%; max-width: 800px;
}

/* MESSAGES */
.msg-wrapper { display: flex; width: 100%; margin-bottom: 8px; }
.msg-wrapper.user { justify-content: flex-end; }
.msg-wrapper.ai { 
    flex-direction: column; 
    gap: 4px;
    align-items: flex-start;
    justify-content: flex-start;
}

.ai-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    background-image: url('https://www.gstatic.com/lamda/images/gemini_sparkle_v002_d473530437e2925461dcf.svg');
    background-size: contain;
    background-repeat: no-repeat;
    margin-bottom: 4px;
}

.user .bubble { 
    background: #2f2f2f; 
    color: #ececec; 
    padding: 12px 20px; 
    border-radius: 22px 22px 4px 22px;
    max-width: 85%;
    font-size: 15px;
    line-height: 1.5;
    box-shadow: none;
    border: none;
}

.ai .bubble { 
    color: #e3e3e3;
    font-size: 15px;
    line-height: 1.6;
    padding: 0;
    background: transparent;
    max-width: 100%;
    width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* INPUT AREA */
.input-container {
    padding: 12px 16px calc(24px + env(safe-area-inset-bottom, 0px)) 16px;
    background: var(--bg-dark);
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: fixed;
    bottom: 0;
    left: 0;
    z-index: 2000;
}

.input-wrapper {
    background-color: #1e1f20;
    border-radius: 28px;
    padding: 12px 16px;
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border: 1px solid rgba(255,255,255,0.05);
    transition: 0.2s;
    position: relative;
}

.input-wrapper:focus-within {
    background-color: #202124;
    border-color: rgba(255,255,255,0.1);
}

textarea {
    width: 100%;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 16px;
    line-height: 1.5;
    resize: none;
    padding: 4px 0;
    outline: none;
    max-height: 200px;
    min-height: 24px;
    font-family: inherit;
}

textarea::placeholder {
    color: #8e918f;
}

.input-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.input-actions-left, .input-actions-right {
    display: flex;
    align-items: center;
    gap: 16px;
    color: #c4c7c5;
}

.action-icon {
    font-size: 18px;
    cursor: pointer;
    transition: 0.2s;
    color: #c4c7c5;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.action-icon:hover { 
    color: #fff; 
    background: rgba(255,255,255,0.05);
}

.action-icon.recording {
    color: #ff5f56;
    animation: recordPulse 1.5s infinite;
}

@keyframes recordPulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.7; }
    100% { transform: scale(1); opacity: 1; }
}

.model-pill {
    background-color: #131314;
    border: 1px solid #333537;
    border-radius: 20px;
    padding: 4px 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #e3e3e3;
    cursor: pointer;
}

.upload-options, .model-dropdown {
    display: none;
    position: absolute;
    bottom: calc(100% + 12px);
    background: #1e1f20;
    border: 1px solid #333537;
    border-radius: 16px;
    z-index: 3000;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    overflow: hidden;
}

.upload-options { left: 16px; min-width: 180px; }
.model-dropdown { right: 16px; min-width: 220px; max-height: 400px; overflow-y: auto; }

.upload-option, .model-option {
    padding: 14px 18px;
    cursor: pointer;
    color: #e3e3e3;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: 0.2s;
}

.upload-option:hover, .model-option:hover { background: rgba(255,255,255,0.05); }

.model-option { border-bottom: 1px solid rgba(255,255,255,0.05); }
.model-option:last-child { border-bottom: none; }
.model-option i { width: 20px; text-align: center; color: var(--gemini-blue); }
.model-info { display: flex; flex-direction: column; }
.model-name { font-size: 14px; font-weight: 500; }
.model-desc { font-size: 11px; color: var(--text-muted); }

/* THINKING UI */
.toggle-container { width: 100%; margin-bottom: 2px; }
.toggle-header { display: inline-flex; align-items: center; gap: 12px; color: var(--text-muted); font-size: 14px; cursor: pointer; padding: 2px 0; }
.toggle-header:hover { color: #fff; }
.toggle-content { display: none; border-left: 1px solid #333537; margin: 4px 0 12px 10px; padding-left: 12px; color: var(--text-muted); font-size: 13px; font-style: italic; }
.toggle-content.show { display: block; }

.thinking-dots { display: flex; gap: 4px; align-items: center; }
.thinking-dot { width: 4px; height: 4px; background-color: var(--gemini-blue); border-radius: 50%; animation: thinkingPulse 1.4s infinite ease-in-out both; }
.thinking-dot:nth-child(1) { animation-delay: -0.32s; }
.thinking-dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes thinkingPulse { 0%, 80%, 100% { transform: scale(0); opacity: 0.3; } 40% { transform: scale(1); opacity: 1; } }

/* WELCOME SCREEN */
.welcome-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    max-width: 900px;
    margin: 0 auto;
    padding: 40px 16px 60px 16px;
    width: 100%;
    animation: welcomeFadeIn 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes welcomeFadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.welcome-header h1.gradient-text { 
    background: linear-gradient(90deg, #4285f4, #9b72cb, #d96570, #4285f4);
    background-size: 200% auto;
    -webkit-background-clip: text; 
    -webkit-text-fill-color: transparent; 
    animation: gradientShift 4s linear infinite;
}

@keyframes gradientShift {
    0% { background-position: 0% center; }
    100% { background-position: 200% center; }
}

.welcome-header p { 
    color: var(--text-muted); 
    font-size: 18px; 
    line-height: 1.6; 
    max-width: 700px; 
    margin: 0 auto; 
    opacity: 0.9;
}

.quick-actions { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); 
    gap: 16px; 
    margin-top: 50px; 
    width: 100%; 
}

.action-card { 
    background: #1e1f20; 
    border: 1px solid #333537; 
    padding: 24px; 
    border-radius: 24px; 
    cursor: pointer; 
    text-align: left; 
    transition: all 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.action-card:hover { 
    transform: translateY(-8px); 
    background: #282a2d; 
    border-color: rgba(255,255,255,0.15);
    box-shadow: 0 15px 30px rgba(0,0,0,0.3); 
}

.action-card i { font-size: 24px; margin-bottom: 20px; }
.action-card h3 { font-size: 16px; margin-bottom: 8px; color: #fff; font-weight: 600; }
.action-card p { font-size: 12px; color: var(--text-muted); line-height: 1.5; margin: 0; }

@media (max-width: 768px) {
    .welcome-header h1 { font-size: 32px; }
    .quick-actions { grid-template-columns: repeat(2, 1fr); }
    .action-card { padding: 16px; }
    .action-card i { margin-bottom: 12px; }
}

@media (max-width: 480px) {
    .quick-actions { grid-template-columns: 1fr; }
}

/* CODE BLOCK (CARBON STYLE) */
.code-block { margin: 20px 0; border-radius: 12px; overflow: hidden; background: #0e0e0e; border: 1px solid rgba(255,255,255,0.1); position: relative; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.code-header { background: #1e1f20; padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(255,255,255,0.05); }
.code-dots { display: flex; gap: 6px; }
.code-dot { width: 10px; height: 10px; border-radius: 50%; }
.dot-red { background: #ff5f56; } .dot-yellow { background: #ffbd2e; } .dot-green { background: #27c93f; }
.code-lang { color: var(--text-muted); font-size: 11px; font-family: monospace; text-transform: uppercase; }
.copy-btn { background: rgba(255,255,255,0.05); color: #fff; border: 1px solid rgba(255,255,255,0.1); border-radius: 6px; padding: 4px 8px; font-size: 11px; cursor: pointer; }
.bubble pre { margin: 0 !important; padding: 20px !important; font-size: 14px !important; background: transparent !important; }

/* TABLES */
.bubble table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    overflow: hidden;
    font-size: 0.9rem;
}

.bubble th {
    background: rgba(66, 133, 244, 0.1);
    color: var(--gemini-blue);
    text-align: left;
    padding: 12px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

.bubble td {
    padding: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: #e3e3e3;
}

.bubble tr:last-child td { border-bottom: none; }

.disclaimer-text { color: var(--text-muted); font-size: 11px; text-align: center; width: 100%; margin-top: 8px; opacity: 0.7; }

@media (max-width: 768px) {
    .welcome-header h1 { font-size: 36px; }
    .quick-actions { grid-template-columns: 1fr; }
    .chat-window { padding: 70px 16px 250px 16px; }
}