* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Google Sans', 'Segoe UI', Arial, sans-serif;
}

:root {
    --bg-primary: #131314;
    --bg-secondary: #1e1f20;
    --bg-tertiary: #282a2c;
    --bg-hover: #2d2f31;
    --text-primary: #e3e3e3;
    --text-secondary: #9aa0a6;
    --text-muted: #6b7280;
    --accent-blue: #4285f4;
    --accent-purple: #9b72cb;
    --accent-pink: #d96570;
    --border-color: #3c4043;
}

body.light-mode {
    --bg-primary: #f8f9fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f3f4;
    --bg-hover: #e8eaed;
    --text-primary: #202124;
    --text-secondary: #5f6368;
    --text-muted: #80868b;
    --border-color: #dadce0;
}

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    height: 100vh;
    overflow: hidden;
    transition: background 0.3s, color 0.3s;
}

/* ── SIDEBAR ── */
.sidebar {
    width: 260px;
    min-width: 260px;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    padding: 8px;
    border-right: 1px solid var(--border-color);
    height: 100vh;
    transition: background 0.3s;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 4px 16px;
}

.menu-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    font-size: 22px;
    display: flex;
    align-items: center;
    transition: background 0.2s;
}
.menu-btn:hover { background: var(--bg-hover); }

.sidebar-logo {
    font-size: 1.2rem;
    font-weight: 600;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple), var(--accent-pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.new-chat-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-tertiary);
    border: none;
    color: var(--text-primary);
    padding: 10px 16px;
    border-radius: 24px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 16px;
    transition: background 0.2s;
    width: 100%;
}
.new-chat-btn:hover { background: var(--bg-hover); }

.sidebar-section-title {
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 4px 12px 8px;
    font-weight: 500;
}

.chat-history {
    list-style: none;
    flex: 1;
    overflow-y: auto;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-secondary);
    transition: background 0.2s;
}
.history-item:hover, .history-item.active {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.history-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-bottom {
    border-top: 1px solid var(--border-color);
    padding-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 10px 12px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: background 0.2s, color 0.2s;
    width: 100%;
    text-align: left;
}
.sidebar-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 4px;
    transition: background 0.2s;
}
.user-profile:hover { background: var(--bg-hover); }

.user-avatar {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: white;
    flex-shrink: 0;
}

/* ── MAIN CONTENT ── */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ── HEADER ── */
.header {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    overflow-y: auto;
}

body.hide-header .header { display: none; }

.gemini-logo-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin-bottom: 8px;
}

.gemini-star {
    animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

.welcome-title {
    font-size: 2.8rem;
    font-weight: 500;
    text-align: center;
}

.gradient-text {
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple), var(--accent-pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-subtitle {
    font-size: 1.4rem;
    color: var(--text-secondary);
    font-weight: 400;
    margin-bottom: 2.5rem;
    text-align: center;
}

/* ── SUGGESTION CARDS ── */
.suggestion-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    width: 100%;
    max-width: 860px;
}

.suggestion-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 16px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 130px;
    transition: background 0.2s, border-color 0.2s, transform 0.2s;
}

.suggestion-card:hover {
    background: var(--bg-tertiary);
    border-color: rgba(66,133,244,0.5);
    transform: translateY(-2px);
}

.card-text {
    font-size: 0.875rem;
    color: var(--text-primary);
    line-height: 1.4;
}

.card-icon {
    align-self: flex-end;
    width: 36px;
    height: 36px;
    background: var(--bg-tertiary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 12px;
    color: var(--text-secondary);
}
.suggestion-card:hover .card-icon {
    background: rgba(66,133,244,0.15);
    color: var(--accent-blue);
}

/* ── CHAT LIST ── */
.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 24px 0 0;
    display: none;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

body.hide-header .chat-list { display: block; }

.message {
    max-width: 780px;
    margin: 0 auto 24px;
    padding: 0 24px;
    animation: messageIn 0.3s ease;
}

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

.message.outgoing .message-content {
    display: flex;
    justify-content: flex-end;
}

.message.outgoing .text {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 12px 18px;
    border-radius: 20px 20px 4px 20px;
    max-width: 75%;
    font-size: 0.95rem;
    line-height: 1.6;
}

.message.incoming .message-content {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    padding: 6px;
}

.message.loading .avatar {
    animation: rotate 2s linear infinite;
}

@keyframes rotate {
    100% { transform: rotate(360deg); }
}

.message.incoming .text {
    color: var(--text-primary);
    font-size: 0.95rem;
    line-height: 1.7;
    flex: 1;
    padding-top: 4px;
}

.message.incoming .text.error { color: #f28b82; }
.message.loading .text { display: none; }

.loading-indicator {
    display: none;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    padding-top: 8px;
}

.message.loading .loading-indicator { display: flex; }

.loading-bar {
    height: 10px;
    border-radius: 5px;
    background: linear-gradient(90deg, var(--bg-tertiary), rgba(66,133,244,0.4), var(--bg-tertiary));
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}
.loading-bar:nth-child(1) { width: 100%; }
.loading-bar:nth-child(2) { width: 80%; animation-delay: 0.15s; }
.loading-bar:nth-child(3) { width: 55%; animation-delay: 0.3s; }

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

.message-actions {
    display: flex;
    gap: 4px;
    margin-top: 8px;
    margin-left: 46px;
    opacity: 0;
    transition: opacity 0.2s;
}
.message.incoming:hover .message-actions { opacity: 1; }

.action-icon {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    font-size: 18px;
    display: flex;
    align-items: center;
    transition: background 0.2s, color 0.2s;
}
.action-icon:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* ── INPUT AREA ── */
.input-area {
    padding: 16px 24px 20px;
    background: var(--bg-primary);
    transition: background 0.3s;
}

.input-container {
    max-width: 780px;
    margin: 0 auto;
}

.input-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 12px 12px 12px 20px;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-box:focus-within {
    border-color: rgba(66,133,244,0.5);
    box-shadow: 0 0 0 2px rgba(66,133,244,0.1);
}

.typing-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 0.95rem;
    line-height: 1.5;
    resize: none;
    max-height: 200px;
    overflow-y: auto;
    padding: 4px 0;
}

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

.send-btn {
    background: var(--accent-blue);
    border: none;
    color: white;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s;
    flex-shrink: 0;
}
.send-btn:hover {
    background: #3367d6;
    transform: scale(1.05);
}

.disclaimer {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 10px;
}

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
    .suggestion-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .sidebar { display: none; }
    .welcome-title { font-size: 2rem; }
    .welcome-subtitle { font-size: 1.1rem; }
    .suggestion-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .message { padding: 0 16px; }
    .input-area { padding: 12px 16px 16px; }
}

/* ── FIX: Material Symbols font fallback ── */
.material-symbols-rounded {
    font-family: 'Material Symbols Rounded', 'Material Icons', sans-serif;
    font-weight: normal;
    font-style: normal;
    font-size: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    text-transform: none;
    letter-spacing: normal;
    word-wrap: normal;
    white-space: nowrap;
    direction: ltr;
    -webkit-font-smoothing: antialiased;
}

/* ── FIX: Suggestion cards grid layout ── */
.suggestion-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.card-icon {
    width: 36px;
    height: 36px;
    background: var(--bg-tertiary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: flex-end;
    margin-top: 16px;
    flex-shrink: 0;
}

/* ── CHAT RESPONSE FORMATTING ── */
.message.incoming .text .resp-h1 {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 16px 0 8px;
}
.message.incoming .text .resp-h2 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 14px 0 6px;
}
.message.incoming .text .resp-h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 12px 0 6px;
}
.message.incoming .text .resp-ul {
    padding-left: 20px;
    margin: 6px 0;
    list-style: disc;
}
.message.incoming .text .resp-ul li {
    margin: 4px 0;
    line-height: 1.6;
    color: var(--text-primary);
}
.message.incoming .text .resp-pre {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 14px 16px;
    margin: 10px 0;
    overflow-x: auto;
    font-size: 0.875rem;
    line-height: 1.6;
}
.message.incoming .text .resp-pre code {
    background: none;
    padding: 0;
    font-family: 'Courier New', Courier, monospace;
    color: #80cbc4;
}
.message.incoming .text .resp-code {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.875rem;
    font-family: 'Courier New', Courier, monospace;
    color: #80cbc4;
}
.message.incoming .text .resp-hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 12px 0;
}
.message.incoming .text strong {
    font-weight: 600;
    color: var(--text-primary);
}
.message.incoming .text em {
    font-style: italic;
    color: var(--text-secondary);
}