/* ======================================================
   Sagittarius — Style System
   Google Sans inspired, clean modern UI
   ====================================================== */

@import url('https://fonts.googleapis.com/css2?family=Google+Sans:wght@400;500;700&family=Google+Sans+Text:wght@400;500&family=Roboto+Mono:wght@400;500&display=swap');

/* ─────────── CSS Variables ─────────── */
:root {
    /* Radii */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-xl: 26px;
    --radius-pill: 9999px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.2s ease;
    --transition-slow: 0.3s ease;

    /* Layout */
    --sidebar-width: 280px;
    --topbar-height: 56px;
    --input-max-width: 820px;
}

/* Light Theme Variables */
:root, [data-theme="light"] {
    --bg-primary: #f0f4f9;
    --bg-surface: #ffffff;
    --bg-surface-dim: #f8fafd;
    --bg-overlay: rgba(0, 0, 0, 0.45);
    --sidebar-bg: #f0f4f9;
    --sidebar-hover: #e1e5ea;
    --sidebar-active: #d3e3fd;
    --border-color: #dee1e5;
    --border-focus: #1a73e8;

    --text-primary: #1f1f1f;
    --text-secondary: #444746;
    --text-tertiary: #717375;
    --text-link: #0b57d0;
    --text-on-primary: #ffffff;

    --accent-blue: #0b57d0;
    --accent-blue-hover: #0842a0;
    --accent-blue-light: #d3e3fd;
    --accent-blue-surface: #e8f0fe;
    --danger: #b3261e;
    --danger-hover: #8c1d18;
    --success: #146c2e;

    --shadow-sm: 0 1px 2px rgba(60,64,67,.3), 0 1px 3px 1px rgba(60,64,67,.15);
    --shadow-md: 0 4px 8px 3px rgba(60,64,67,.15), 0 1px 3px rgba(60,64,67,.3);
    --shadow-lg: 0 12px 24px 0 rgba(0,0,0,.15), 0 4px 8px 0 rgba(0,0,0,.3);
    --shadow-input: 0 1px 2px rgba(60,64,67,.3), 0 2px 6px 2px rgba(60,64,67,.15);

    --gemini-grad: linear-gradient(135deg, #4285F4 0%, #9B72CB 33%, #D96570 66%, #D96570 100%);
}

/* Dark Theme Variables */
[data-theme="dark"] {
    --bg-primary: #131314;
    --bg-surface: #1e1f20;
    --bg-surface-dim: #28292a;
    --bg-overlay: rgba(0, 0, 0, 0.7);
    --sidebar-bg: #1e1f20;
    --sidebar-hover: #333537;
    --sidebar-active: #004a77;
    --border-color: #444746;
    --border-focus: #a8c7fa;

    --text-primary: #e3e3e3;
    --text-secondary: #c4c7c5;
    --text-tertiary: #8e918f;
    --text-link: #a8c7fa;
    --text-on-primary: #041e49;

    --accent-blue: #a8c7fa;
    --accent-blue-hover: #d2e3fc;
    --accent-blue-light: #004a77;
    --accent-blue-surface: #003355;
    --danger: #f2b8b5;
    --danger-hover: #f9dedc;
    --success: #6dd58c;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
    --shadow-lg: 0 12px 32px rgba(0,0,0,0.6);
    --shadow-input: 0 2px 8px rgba(0,0,0,0.4);

    --gemini-grad: linear-gradient(135deg, #7baaf7 0%, #c091e6 33%, #ec929b 66%, #ec929b 100%);
}

/* ─────────── Reset & Base ─────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    font-family: 'Google Sans Text', 'Google Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-primary);
    overflow: hidden;
    transition: background-color var(--transition-base), color var(--transition-base);
}

a {
    color: var(--text-link);
    text-decoration: none;
}
a:hover { text-decoration: underline; }

button {
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
    outline: none;
}

textarea {
    font-family: inherit;
    resize: none;
    border: none;
    outline: none;
    background: transparent;
}

input {
    font-family: inherit;
    border: none;
    outline: none;
}

/* ─────────── Layout Shell ─────────── */
body {
    display: flex;
}

/* ─────────── Sidebar ─────────── */
.sidebar {
    display: flex;
    flex-direction: column;
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    transition: width var(--transition-slow), min-width var(--transition-slow), opacity var(--transition-slow);
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
    z-index: 100;
}

.sidebar.collapsed {
    width: 0;
    min-width: 0;
    opacity: 0;
    pointer-events: none;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 12px;
    height: var(--topbar-height);
    flex-shrink: 0;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 0;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.sidebar-content::-webkit-scrollbar { width: 4px; }
.sidebar-content::-webkit-scrollbar-track { background: transparent; }
.sidebar-content::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 2px; }

.sidebar-footer {
    flex-shrink: 0;
    padding: 8px;
    border-top: 1px solid var(--border-color);
}

.sidebar-footer-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: background var(--transition-fast), color var(--transition-fast);
    white-space: nowrap;
}
.sidebar-footer-btn:hover {
    background: var(--sidebar-hover);
    color: var(--text-primary);
}

/* Chat History */
.history-section { padding: 4px 8px; }
.history-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-tertiary);
    padding: 8px 8px 4px;
}

.empty-history {
    padding: 16px 8px;
    text-align: center;
}
.empty-history p {
    color: var(--text-tertiary);
    font-size: 13px;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
    color: var(--text-secondary);
    margin: 1px 0;
    white-space: nowrap;
    overflow: hidden;
    position: relative;
}
.chat-item:hover { background: var(--sidebar-hover); }
.chat-item.active { background: var(--sidebar-active); color: var(--text-primary); }

.chat-item-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 13.5px;
}

.chat-item-delete {
    opacity: 0;
    flex-shrink: 0;
    padding: 2px;
    border-radius: 4px;
    color: var(--text-tertiary);
    transition: opacity var(--transition-fast), color var(--transition-fast);
}
.chat-item:hover .chat-item-delete { opacity: 1; }
.chat-item-delete:hover { color: var(--danger); }

/* ─────────── Main Wrapper ─────────── */
.main-wrapper {
    display: flex;
    flex-direction: column;
    flex: 1;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

/* ─────────── Topbar ─────────── */
.topbar {
    display: flex;
    align-items: center;
    height: var(--topbar-height);
    padding: 0 16px;
    background: var(--bg-primary);
    border-bottom: 1px solid transparent;
    flex-shrink: 0;
    position: relative;
    z-index: 50;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 4px;
}

.topbar-menu-btn {
    display: none;
}

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

.logo-text {
    font-family: 'Google Sans', sans-serif;
    font-size: 20px;
    font-weight: 400;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

/* ─────────── Icon Buttons ─────────── */
.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-pill);
    color: var(--text-secondary);
    transition: background var(--transition-fast), color var(--transition-fast);
    flex-shrink: 0;
}
.icon-btn:hover {
    background: var(--sidebar-hover);
    color: var(--text-primary);
}

/* ─────────── Chat Area ─────────── */
.chat-area {
    flex: 1;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* ─────────── Welcome Screen ─────────── */
.welcome-screen {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: fadeIn 0.4s ease;
}

.welcome-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    max-width: 700px;
    width: 100%;
    text-align: center;
}

.gemini-icon {
    width: 60px;
    height: 60px;
    animation: sparkle 3s ease-in-out infinite;
}

.gemini-icon svg {
    width: 100%;
    height: 100%;
}

@keyframes sparkle {
    0%, 100% { transform: scale(1) rotate(0deg); filter: drop-shadow(0 0 8px rgba(66, 133, 244, 0.3)); }
    50% { transform: scale(1.05) rotate(5deg); filter: drop-shadow(0 0 16px rgba(155, 114, 203, 0.5)); }
}

.welcome-title {
    font-family: 'Google Sans', sans-serif;
    font-size: clamp(24px, 4vw, 36px);
    font-weight: 400;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.suggestion-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-pill);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-sm);
}
.chip:hover {
    background: var(--bg-surface-dim);
    border-color: #c1c7cd;
    color: var(--text-primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}
.chip svg { color: var(--text-tertiary); }

/* ─────────── Messages ─────────── */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px 24px 8px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.messages-container::-webkit-scrollbar { width: 6px; }
.messages-container::-webkit-scrollbar-track { background: transparent; }
.messages-container::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }

.messages {
    max-width: var(--input-max-width);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Message */
.message {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px 0;
    animation: slideUp 0.25s ease;
}

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

.message-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-pill);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 13px;
    font-weight: 700;
}

.message-avatar.user {
    background: var(--accent-blue);
    color: white;
}

.message-avatar.assistant {
    background: transparent;
    border: none;
}

.message-avatar.assistant svg {
    width: 28px;
    height: 28px;
}

.message-role {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.message-content {
    padding: 0 0 0 42px;
    color: var(--text-primary);
    line-height: 1.7;
    font-size: 15px;
}

/* User messages */
.message.user .message-content {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
    display: inline-block;
    max-width: 85%;
    margin-left: auto;
    border: 1px solid var(--border-color);
}

.message.user {
    align-items: flex-end;
}

.message.user .message-header {
    flex-direction: row-reverse;
}

/* Assistant messages — layout only; markdown styles below */

.message-content h1, .message-content h2, .message-content h3 {
    margin: 12px 0 6px;
    font-family: 'Google Sans', sans-serif;
}

.message-content h1 { font-size: 20px; }
.message-content h2 { font-size: 17px; }
.message-content h3 { font-size: 15px; }

.message-content p { margin: 6px 0; }
.message-content ul, .message-content ol { padding-left: 24px; margin: 8px 0; }
.message-content li { margin: 4px 0; }

.message-content pre {
    background: #1e1e2e;
    color: #cdd6f4;
    border-radius: var(--radius-md);
    padding: 16px;
    overflow-x: auto;
    margin: 12px 0;
    font-size: 13px;
}

.message-content code:not(pre code) {
    background: var(--accent-blue-surface);
    color: var(--accent-blue);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Roboto Mono', monospace;
    font-size: 13px;
}

.message-content pre code {
    background: none;
    color: inherit;
    padding: 0;
    font-family: 'Roboto Mono', monospace;
}

.message-content blockquote {
    border-left: 3px solid var(--accent-blue);
    padding-left: 16px;
    color: var(--text-secondary);
    margin: 8px 0;
}

.message-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 12px 0;
    font-size: 13px;
}

.message-content th, .message-content td {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    text-align: left;
}

.message-content th {
    background: var(--bg-surface-dim);
    font-weight: 600;
}

/* Streaming cursor */
.streaming-cursor::after {
    content: "▋";
    animation: blink 0.7s infinite;
    color: var(--accent-blue);
    font-size: 14px;
}

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

/* Message actions */
.message-actions {
    display: flex;
    gap: 4px;
    padding: 0 0 0 42px;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

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

.msg-action-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: var(--radius-pill);
    color: var(--text-tertiary);
    font-size: 12px;
    transition: background var(--transition-fast), color var(--transition-fast);
}
.msg-action-btn:hover {
    background: var(--sidebar-hover);
    color: var(--text-secondary);
}

/* Error messages */
.message-error {
    background: #fce8e6;
    border: 1px solid #f5c6c2;
    border-radius: var(--radius-md);
    padding: 12px 16px;
    color: var(--danger);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0;
}

/* ─────────── Input Area ─────────── */
.input-area-wrapper {
    flex-shrink: 0;
    padding: 8px 24px 16px;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.input-container {
    width: 100%;
    max-width: var(--input-max-width);
}

.input-box {
    background: var(--bg-surface);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 14px 16px 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

.input-box:focus-within {
    border-color: #c1c7cd;
    box-shadow: var(--shadow-input);
}

.message-input {
    width: 100%;
    font-size: 15px;
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 24px;
    max-height: 200px;
    overflow-y: auto;
    scrollbar-width: thin;
}

.message-input::placeholder { color: var(--text-tertiary); }

.input-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-pill);
    color: var(--text-tertiary);
    transition: background var(--transition-fast), color var(--transition-fast);
}
.action-btn:hover {
    background: var(--bg-primary);
    color: var(--text-secondary);
}

.model-selector-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: var(--radius-pill);
    background: var(--bg-surface-dim);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition-fast);
    max-width: 220px;
    overflow: hidden;
}

.model-selector-btn:hover {
    background: var(--bg-primary);
    border-color: #c1c7cd;
    color: var(--text-primary);
}

#selectedModelName {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 160px;
}

.send-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-pill);
    background: var(--accent-blue);
    color: white;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
    background: var(--accent-blue-hover);
    transform: scale(1.05);
}

.send-btn:disabled {
    background: var(--border-color);
    color: var(--text-tertiary);
    cursor: not-allowed;
}

.disclaimer {
    font-size: 12px;
    color: var(--text-tertiary);
    text-align: center;
}

/* ─────────── Model Dropdown ─────────── */
.model-dropdown {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    width: 420px;
    max-width: calc(100vw - 48px);
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 500;
    overflow: hidden;
    animation: dropIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes dropIn {
    from { opacity: 0; transform: translateX(-50%) translateY(12px) scale(0.96); }
    to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

.model-dropdown-header {
    padding: 16px 16px 12px;
    border-bottom: 1px solid var(--border-color);
}

.model-dropdown-header h3 {
    font-family: 'Google Sans', sans-serif;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.model-search-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-pill);
    padding: 7px 12px;
    color: var(--text-tertiary);
}

.model-search-input {
    flex: 1;
    background: transparent;
    font-size: 14px;
    color: var(--text-primary);
}
.model-search-input::placeholder { color: var(--text-tertiary); }

.model-list {
    max-height: 340px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
    padding: 8px;
}

.model-list::-webkit-scrollbar { width: 4px; }
.model-list::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 2px; }

.model-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 32px;
    color: var(--text-tertiary);
    font-size: 14px;
}

.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.model-provider-group { margin-bottom: 4px; }

.model-provider-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
    padding: 8px 10px 4px;
}

.model-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
}
.model-option:hover { background: var(--bg-primary); }
.model-option.selected { background: var(--accent-blue-light); }

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

.model-option-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.model-option-meta {
    font-size: 12px;
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
}

.model-check {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    color: var(--accent-blue);
    opacity: 0;
}

.model-option.selected .model-check { opacity: 1; }

.model-free-badge {
    font-size: 10px;
    font-weight: 600;
    background: #e6f4ea;
    color: var(--success);
    padding: 1px 6px;
    border-radius: var(--radius-pill);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ─────────── Modals ─────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    z-index: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: fadeIn 0.2s ease;
    backdrop-filter: blur(4px);
}

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

.modal {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 480px;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.25s cubic-bezier(0.34, 1.2, 0.64, 1);
}

.confirm-modal { max-width: 360px; }

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

.modal-header h2 {
    font-family: 'Google Sans', sans-serif;
    font-size: 18px;
    font-weight: 500;
    color: var(--text-primary);
}

.modal-body {
    padding: 20px 24px;
}

.modal-body p {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 24px 20px;
}

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

.settings-section:last-child { margin-bottom: 0; }

.settings-section h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    font-family: 'Google Sans', sans-serif;
}

.settings-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 14px;
    line-height: 1.6;
}

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

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

.text-input {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-surface);
    transition: border-color var(--transition-fast);
}

.text-input:focus {
    border-color: var(--border-focus);
    outline: none;
}

.api-key-input-wrap {
    position: relative;
    display: flex;
}

.api-key-input-wrap .text-input {
    padding-right: 42px;
}

.toggle-visibility-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    display: flex;
    padding: 4px;
    border-radius: 4px;
    transition: color var(--transition-fast);
}

.toggle-visibility-btn:hover { color: var(--text-secondary); }

.api-key-status {
    margin-top: 8px;
    font-size: 13px;
    min-height: 18px;
}

.api-key-status.success { color: var(--success); }
.api-key-status.error { color: var(--danger); }

/* Buttons */
.btn-primary {
    padding: 9px 20px;
    background: var(--accent-blue);
    color: white;
    border-radius: var(--radius-pill);
    font-size: 14px;
    font-weight: 500;
    transition: background var(--transition-fast), transform var(--transition-fast);
}
.btn-primary:hover { background: var(--accent-blue-hover); }
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
    padding: 9px 20px;
    background: transparent;
    color: var(--accent-blue);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-pill);
    font-size: 14px;
    font-weight: 500;
    transition: background var(--transition-fast);
}
.btn-secondary:hover { background: var(--accent-blue-light); }

.btn-danger {
    padding: 9px 20px;
    background: var(--danger);
    color: white;
    border-radius: var(--radius-pill);
    font-size: 14px;
    font-weight: 500;
    transition: background var(--transition-fast);
}
.btn-danger:hover { background: var(--danger-hover); }

/* ─────────── Thinking / Streaming ─────────── */
.thinking-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    color: var(--text-tertiary);
    font-size: 14px;
    animation: fadeIn 0.3s ease;
}

.thinking-dots {
    display: flex;
    gap: 4px;
}

.thinking-dot {
    width: 6px;
    height: 6px;
    background: var(--accent-blue);
    border-radius: 50%;
    animation: bounce 1.2s ease-in-out infinite;
}

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

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

/* ─────────── Responsive ─────────── */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 200;
        box-shadow: var(--shadow-lg);
    }

    .sidebar.collapsed {
        transform: translateX(-100%);
        width: var(--sidebar-width);
        min-width: var(--sidebar-width);
        opacity: 0;
        pointer-events: none;
    }

    .topbar-menu-btn { display: flex; }

    .input-area-wrapper { padding: 8px 12px 12px; }

    .messages-container { padding: 16px 12px 8px; }

    .model-dropdown { bottom: 80px; }
}

/* ─────────── Code block header ─────────── */
.code-block-wrap {
    position: relative;
    margin: 12px 0;
}

.code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #181825;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    padding: 8px 14px;
}

.code-lang {
    font-size: 12px;
    color: #a6adc8;
    font-family: 'Roboto Mono', monospace;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.copy-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #a6adc8;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background var(--transition-fast), color var(--transition-fast);
}
.copy-btn:hover { background: rgba(255,255,255,0.1); color: #cdd6f4; }
.copy-btn svg { width: 14px; height: 14px; }

.code-block-wrap pre {
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    margin: 0 !important;
}
