/* RaceAI – Polished Dark Theme */

:root {
    /* Core palette */
    --color-dark: #0a0a0a;
    --color-darker: #141414;
    --color-blue: #0077CC;
    --color-purple: #7300ff;
    --color-white: #ffffff;
    --color-gray: #cccccc;
    --color-gray-dark: #666666;
    --color-border: #333333;
    --color-hover: #1a1a1a;
    --color-bolt-glow: #3953a6;

    /* Semantic aliases */
    --color-bg: var(--color-dark);
    --color-bg-secondary: var(--color-darker);
    --color-bg-tertiary: var(--color-hover);
    --color-surface: #1e1e1e;
    --color-surface-hover: #252525;
    --color-text: var(--color-white);
    --color-text-secondary: var(--color-gray);
    --color-text-muted: var(--color-gray-dark);
    --color-primary: var(--color-purple);
    --color-primary-hover: #5c00cc;
    --color-primary-light: rgba(115, 0, 255, 0.12);
    --color-accent: var(--color-blue);
    --color-success: #22c55e;
    --color-warning: #eab308;
    --color-error: #ef4444;

    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 12px;
    --spacing-lg: 16px;
    --spacing-xl: 24px;
    --spacing-2xl: 32px;

    /* Radii */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,.4);
    --shadow-lg: 0 8px 24px rgba(0,0,0,.5);
    --glow-send: 0 0 20px rgba(57,83,166,.55);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-size-xs: 11px;
    --font-size-sm: 13px;
    --font-size-md: 14px;
    --font-size-lg: 16px;
    --font-size-xl: 18px;

    /* Layout */
    --sidebar-width: 280px;
    --header-height: 56px;
}

/* Light mode overrides */
body.light-mode {
    --color-bg: #ffffff;
    --color-bg-secondary: #f8f9fa;
    --color-bg-tertiary: #f0f2f5;
    --color-surface: #ffffff;
    --color-surface-hover: #f5f5f5;
    --color-border: #e0e0e0;
    --color-text: #1a1a1a;
    --color-text-secondary: #555555;
    --color-text-muted: #999999;
}

/* ───── Reset ───── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }

body {
    font-family: var(--font-family);
    font-size: var(--font-size-md);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ───── App Layout ───── */
.app {
    display: flex;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    width: 100%;
}

/* ───── Sidebar ───── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--color-bg-secondary);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: transform var(--transition-normal);
    overflow-y: auto;
    max-height: 100dvh;
}

.sidebar-header {
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-header h2 {
    font-size: var(--font-size-xl);
    font-weight: 700;
    background: linear-gradient(135deg, var(--color-blue), var(--color-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-section {
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    background: rgba(255,255,255,.02);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    margin: var(--spacing-sm) var(--spacing-sm) 0;
}

.sidebar-section h3 {
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--color-text-muted);
    margin-bottom: var(--spacing-sm);
}

.sidebar-footer {
    margin-top: auto;
    padding: var(--spacing-md) var(--spacing-lg);
    padding-bottom: calc(var(--spacing-md) + env(safe-area-inset-bottom));
    border-top: 1px solid var(--color-border);
}

/* ── Profiles ── */
.profiles-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.profile-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast);
    border: none;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    width: 100%;
}

.profile-item:hover { background: var(--color-hover); }
.profile-item.active { background: var(--color-primary-light); border-left: 3px solid var(--color-primary); }

.profile-item .avatar,
.profile-item img {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    object-fit: cover;
    flex-shrink: 0;
}

.profile-item .profile-info { flex: 1; min-width: 0; }
.profile-item .profile-name { font-weight: 600; font-size: var(--font-size-sm); }
.profile-item .profile-status { font-size: var(--font-size-xs); color: var(--color-text-muted); }

/* ── Conversation History ── */
.conversation-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    max-height: 300px;
    overflow-y: auto;
    padding-right: var(--spacing-xs);
}

.conversation-list::-webkit-scrollbar { width: 5px; }
.conversation-list::-webkit-scrollbar-track { background: transparent; }
.conversation-list::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: var(--radius-full); }

.conversation-item-wrapper {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    position: relative;
}
.conversation-item-wrapper .conversation-item { flex: 1; }

.conversation-item {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: left;
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

.conversation-item:hover { background: var(--color-hover); border-color: var(--color-border); }
.conversation-item.active { background: var(--color-primary-light); border-color: var(--color-primary); }

.conversation-item .conv-avatar {
    width: 32px; height: 32px;
    border-radius: var(--radius-full);
    overflow: hidden; flex-shrink: 0;
}
.conversation-item .conv-avatar img { width: 100%; height: 100%; object-fit: cover; }

.conversation-item .conv-info {
    flex: 1; min-width: 0;
    display: flex; flex-direction: column; gap: 2px;
}
.conversation-item .conv-header { display: flex; align-items: center; gap: var(--spacing-sm); }
.conversation-item .conv-name {
    font-weight: 600; font-size: var(--font-size-sm); margin: 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1;
}
.conversation-item .msg-count {
    min-width: 20px; height: 20px; padding: 0 5px;
    background: var(--color-accent);
    color: white; border-radius: var(--radius-full);
    font-size: 10px; font-weight: 700;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.conversation-item .conv-preview {
    font-size: var(--font-size-xs); color: var(--color-text-muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conversation-item .conv-time { font-size: var(--font-size-xs); color: var(--color-text-muted); }

.conv-delete-btn {
    width: 28px; height: 28px; padding: 0;
    background: transparent; border: none; border-radius: var(--radius-md);
    color: var(--color-text-muted); cursor: pointer;
    transition: all var(--transition-fast); flex-shrink: 0; opacity: 0;
    display: flex; align-items: center; justify-content: center;
}
.conv-delete-btn:hover { background: rgba(239,68,68,.15); color: var(--color-error); }
.conversation-item-wrapper:hover .conv-delete-btn { opacity: 1; }

.conversation-list .empty-state {
    padding: var(--spacing-lg);
    text-align: center; color: var(--color-text-muted); font-size: var(--font-size-sm);
}

/* ── Connection Status ── */
.connection-status {
    display: flex; align-items: center; gap: var(--spacing-sm);
    font-size: var(--font-size-sm); color: var(--color-text-secondary);
}
.status-dot {
    width: 8px; height: 8px; border-radius: var(--radius-full);
    background: var(--color-warning); animation: pulse 2s infinite;
}
.status-dot.connected { background: var(--color-success); }
.status-dot.disconnected { background: var(--color-error); animation: none; }

@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.5} }

/* ── Settings ── */
.setting-item { display: flex; align-items: center; justify-content: space-between; padding: var(--spacing-xs) 0; }

.toggle {
    width: 44px; height: 24px;
    background: var(--color-border); border: none; border-radius: var(--radius-full);
    cursor: pointer; position: relative; transition: background var(--transition-fast); padding: 0; flex-shrink: 0;
}
.toggle:hover { background: var(--color-surface-hover); }
.toggle.active { background: var(--color-primary); }
.toggle-slider {
    position: absolute; top: 2px; left: 2px;
    width: 20px; height: 20px; background: white; border-radius: var(--radius-full);
    transition: transform var(--transition-fast); box-shadow: var(--shadow-sm);
}
.toggle.active .toggle-slider { transform: translateX(20px); }


/* ───── Chat Container ───── */
.chat-container {
    flex: 1;
    display: flex; flex-direction: column;
    background: var(--color-bg);
    overflow: hidden; min-height: 0; position: relative;
}

/* ── Chat Header ── */
.chat-header {
    min-height: var(--header-height);
    padding: 0 var(--spacing-lg);
    border-bottom: 1px solid var(--color-border);
    display: flex; align-items: center; gap: var(--spacing-lg); justify-content: space-between;
    background: var(--color-bg-secondary);
    flex-shrink: 0;
}

.header-profile { display: flex; align-items: center; gap: var(--spacing-md); flex: 1; min-width: 0; }
.header-profile .avatar {
    width: 36px; height: 36px; border-radius: var(--radius-full);
    object-fit: cover; border: 2px solid var(--color-border);
}
.header-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.header-info h1 { font-size: var(--font-size-lg); font-weight: 600; margin: 0; line-height: 1.2; }

.header-meta {
    display: flex; align-items: center; gap: var(--spacing-sm); flex-wrap: wrap;
    font-size: var(--font-size-xs); color: var(--color-text-secondary);
}
.status-indicator { font-size: var(--font-size-xs); color: var(--color-success); }
.status-indicator.active::before { content: '● '; }
.model-name { color: var(--color-text-muted); }
.header-actions { display: flex; gap: var(--spacing-sm); }

/* ── Buttons ── */
.btn-icon {
    width: 34px; height: 34px; border: none; background: transparent;
    color: var(--color-text-secondary); border-radius: var(--radius-md);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all var(--transition-fast);
}
.btn-icon:hover { background: var(--color-hover); color: var(--color-text); }

.btn-primary {
    display: flex; align-items: center; justify-content: center; gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-lg);
    background: var(--color-primary); color: white; border: none;
    border-radius: var(--radius-md); font-size: var(--font-size-sm); font-weight: 500;
    cursor: pointer; transition: all var(--transition-fast);
}
.btn-primary:hover { background: var(--color-primary-hover); transform: translateY(-1px); }

.btn-primary.full-width,
.btn-secondary.full-width,
.btn-panel.full-width { width: 100%; }

.btn-secondary {
    display: flex; align-items: center; gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--color-primary); color: white; border: none;
    border-radius: var(--radius-md); font-size: var(--font-size-sm); font-weight: 500;
    cursor: pointer; transition: all var(--transition-fast);
}
.btn-secondary:hover { background: var(--color-primary-hover); transform: translateY(-1px); }
.btn-secondary.ghost {
    background: transparent; color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
}
.btn-secondary.ghost:hover { background: var(--color-primary-light); }

.btn-panel {
    display: flex; align-items: center; justify-content: center; gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md); border: 1px solid var(--color-border);
    background: transparent; color: var(--color-text); font-size: var(--font-size-sm); font-weight: 500;
    cursor: pointer; transition: border-color var(--transition-fast), background var(--transition-fast);
}
.btn-panel:hover { border-color: var(--color-accent); background: rgba(0,119,204,.08); }

.mobile-menu { display: none; }


/* ───── Messages ───── */
.messages-container {
    flex: 1; overflow-y: auto;
    padding: var(--spacing-md) var(--spacing-lg);
    display: flex; flex-direction: column; gap: var(--spacing-sm);
    padding-bottom: var(--spacing-lg); min-height: 0;
}
.messages-container::-webkit-scrollbar { width: 5px; }
.messages-container::-webkit-scrollbar-track { background: transparent; }
.messages-container::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 3px; }

/* Welcome */
.welcome-message {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center; color: var(--color-text-secondary);
}
.welcome-icon { font-size: 48px; margin-bottom: var(--spacing-lg); }
.welcome-message h2 { font-size: var(--font-size-xl); font-weight: 600; color: var(--color-text); margin-bottom: var(--spacing-sm); }
.welcome-message p { font-size: var(--font-size-md); }

/* Message bubbles */
.message {
    display: flex; gap: var(--spacing-sm);
    max-width: 80%; animation: msgIn .25s ease;
}

@keyframes msgIn { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }

.message.user { margin-left: auto; flex-direction: row-reverse; }

.message .avatar {
    width: 30px; height: 30px; border-radius: var(--radius-full);
    object-fit: cover; flex-shrink: 0;
}
.message-content { display: flex; flex-direction: column; gap: 2px; }

.message-bubble {
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-lg); font-size: var(--font-size-md);
    line-height: 1.55; word-wrap: break-word;
    white-space: pre-wrap;
}

.message.ai .message-bubble {
    background: var(--color-surface); color: var(--color-text);
    border-bottom-left-radius: var(--radius-sm);
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
}

.message.user .message-bubble {
    background: linear-gradient(135deg, var(--color-blue), var(--color-bolt-glow));
    color: white; border-bottom-right-radius: var(--radius-sm);
    box-shadow: 0 2px 12px rgba(0,119,204,.3);
}

.message-time { font-size: var(--font-size-xs); color: var(--color-text-muted); }

/* Streaming cursor */
.message-bubble .streaming-cursor {
    display: inline-block; width: 2px; height: 1em; background: var(--color-text);
    margin-left: 2px; vertical-align: text-bottom;
    animation: blink .7s steps(2) infinite;
}
@keyframes blink { 0%{opacity:1} 100%{opacity:0} }


/* ── Typing Indicator ── */
.typing-indicator {
    display: none; padding: 0 var(--spacing-lg); margin-bottom: var(--spacing-sm);
}
.typing-indicator.visible {
    display: flex; gap: var(--spacing-sm); align-items: flex-end;
    animation: msgIn .25s ease;
}
.typing-indicator .avatar { width: 30px; height: 30px; border-radius: var(--radius-full); object-fit: cover; }
.typing-bubble {
    display: flex; gap: 4px;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--color-surface); border-radius: var(--radius-lg); border-bottom-left-radius: var(--radius-sm);
}
.typing-bubble span {
    width: 7px; height: 7px; background: var(--color-text-muted);
    border-radius: var(--radius-full); animation: typing 1.4s infinite;
}
.typing-bubble span:nth-child(2) { animation-delay: .2s; }
.typing-bubble span:nth-child(3) { animation-delay: .4s; }

@keyframes typing { 0%,60%,100%{transform:translateY(0);opacity:.4} 30%{transform:translateY(-4px);opacity:1} }


/* ───── Chat Input ───── */
.chat-input {
    padding: var(--spacing-sm) var(--spacing-lg);
    padding-bottom: calc(var(--spacing-sm) + max(env(safe-area-inset-bottom), 6px));
    background: var(--color-bg-secondary);
    border-top: 1px solid var(--color-border);
    flex-shrink: 0; position: relative; z-index: 50;
}

.input-wrapper {
    display: flex; align-items: flex-end; gap: var(--spacing-sm);
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xs) var(--spacing-sm);
    transition: border-color var(--transition-fast);
}
.input-wrapper:focus-within { border-color: var(--color-accent); box-shadow: 0 0 0 2px rgba(0,119,204,.15); }

.input-wrapper textarea {
    flex: 1; background: transparent; border: none;
    color: var(--color-text); font-family: inherit; font-size: var(--font-size-md);
    line-height: 1.5; resize: none; max-height: 120px; outline: none;
    padding: var(--spacing-xs) var(--spacing-sm);
}
.input-wrapper textarea::placeholder { color: var(--color-text-muted); }

.btn-send {
    width: 42px; height: 42px;
    background: linear-gradient(145deg, var(--color-blue), var(--color-bolt-glow));
    border: none; border-radius: var(--radius-full); color: white;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    flex-shrink: 0; position: relative; overflow: hidden;
}
.btn-send::after {
    content: ''; position: absolute; inset: 6px; border-radius: inherit;
    border: 1px solid rgba(255,255,255,.25); opacity: 0; transition: opacity var(--transition-fast);
}
.btn-send:hover:not(:disabled) { transform: scale(1.06); box-shadow: var(--glow-send); }
.btn-send:hover::after { opacity: 1; }
.btn-send:disabled { opacity: .35; cursor: not-allowed; box-shadow: none; }
.btn-send svg { width: 18px; height: 18px; }

.input-footer { display: flex; justify-content: flex-end; padding-top: 2px; }
.char-count { font-size: var(--font-size-xs); color: var(--color-text-muted); }


/* ───── Toasts ───── */
.toast-container {
    position: fixed; bottom: var(--spacing-xl); right: var(--spacing-xl);
    display: flex; flex-direction: column; gap: var(--spacing-sm); z-index: 1000;
}
.toast {
    padding: var(--spacing-sm) var(--spacing-lg);
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
    animation: toastIn .3s ease; display: flex; align-items: center; gap: var(--spacing-sm);
    font-size: var(--font-size-sm);
}
.toast.success { border-left: 3px solid var(--color-success); }
.toast.error { border-left: 3px solid var(--color-error); }
.toast.warning { border-left: 3px solid var(--color-warning); }
.toast.info { border-left: 3px solid var(--color-accent); }

@keyframes toastIn { from{opacity:0;transform:translateX(100%)} to{opacity:1;transform:translateX(0)} }


/* ───── Confirm Modal ───── */
.confirm-modal {
    position: fixed; inset: 0; background: rgba(0,0,0,.6);
    display: flex; align-items: center; justify-content: center; z-index: 2000;
    animation: fadeIn .2s ease;
}
@keyframes fadeIn { from{opacity:0} to{opacity:1} }

.confirm-dialog {
    background: var(--color-bg-secondary); border: 1px solid var(--color-border);
    border-radius: var(--radius-lg); padding: var(--spacing-xl);
    max-width: 380px; width: 90%; box-shadow: var(--shadow-lg);
    animation: slideUp .25s ease;
}
@keyframes slideUp { from{opacity:0;transform:translateY(16px)} to{opacity:1;transform:translateY(0)} }

.confirm-dialog h3 { font-size: var(--font-size-lg); font-weight: 600; margin-bottom: var(--spacing-md); }
.confirm-dialog p { font-size: var(--font-size-md); color: var(--color-text-secondary); margin-bottom: var(--spacing-xl); line-height: 1.5; }
.confirm-actions { display: flex; gap: var(--spacing-md); justify-content: flex-end; }

.btn-confirm-cancel,
.btn-confirm-ok {
    padding: var(--spacing-sm) var(--spacing-lg); border: none; border-radius: var(--radius-md);
    font-size: var(--font-size-sm); font-weight: 500; cursor: pointer; transition: all var(--transition-fast);
}
.btn-confirm-cancel { background: var(--color-border); color: var(--color-text-secondary); }
.btn-confirm-cancel:hover { background: var(--color-surface-hover); color: var(--color-text); }
.btn-confirm-ok { background: var(--color-error); color: white; }
.btn-confirm-ok:hover { background: #dc2626; transform: translateY(-1px); }


/* ───── Skeleton Loaders ───── */
.skeleton {
    background: linear-gradient(90deg, var(--color-surface) 0%, var(--color-surface-hover) 50%, var(--color-surface) 100%);
    background-size: 200% 100%;
    animation: skeleton-load 1.5s infinite;
    border-radius: var(--radius-md);
}

@keyframes skeleton-load {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-profile {
    display: flex; align-items: center; gap: var(--spacing-md);
    padding: var(--spacing-sm) var(--spacing-md);
    margin-bottom: var(--spacing-xs);
}
.skeleton-profile .avatar { width: 36px; height: 36px; border-radius: var(--radius-full); }
.skeleton-profile .info { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.skeleton-profile .name { width: 70%; height: 14px; }
.skeleton-profile .status { width: 50%; height: 12px; }

/* ───── Copy Button (on message hover) ───── */
.message-copy-btn {
    display: none; position: absolute; top: 4px; right: 4px;
    width: 28px; height: 28px; padding: 0; border: none;
    background: rgba(0,119,204,.15); color: var(--color-accent);
    border-radius: var(--radius-md); cursor: pointer;
    transition: all var(--transition-fast); font-size: 12px;
}
.message:hover .message-copy-btn { display: flex; align-items: center; justify-content: center; }
.message-copy-btn:hover { background: var(--color-accent); color: white; }

.message {
    position: relative;
}

/* ───── Search Box ───── */
.conversation-search {
    padding: var(--spacing-sm) var(--spacing-lg);
    display: flex;
}
.search-input {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
    font-family: inherit;
    font-size: var(--font-size-sm);
    outline: none;
    transition: border-color var(--transition-fast);
}
.search-input:focus { border-color: var(--color-accent); }
.search-input::placeholder { color: var(--color-text-muted); }

/* Time group separator */
.conversation-time-group {
    display: flex; flex-direction: column; gap: var(--spacing-xs);
}
.conversation-time-label {
    font-size: var(--font-size-xs); font-weight: 600; text-transform: uppercase;
    color: var(--color-text-muted); padding: var(--spacing-sm) var(--spacing-lg) var(--spacing-xs);
    border-bottom: 1px solid var(--color-border); margin-top: var(--spacing-sm);
}
.conversation-time-label:first-child { margin-top: 0; }


/* ───── Mobile ───── */
@media (max-width: 768px) {
    .sidebar {
        position: fixed; left: 0; top: 0; height: 100%; z-index: 100;
        transform: translateX(-100%); overflow-y: auto;
    }
    .sidebar.open { transform: translateX(0); }
    .mobile-menu { display: flex; }
    #close-sidebar { display: flex; }
    .chat-header { padding: 0 var(--spacing-md); }
    .messages-container { padding: var(--spacing-sm) var(--spacing-md); }
    .message { max-width: 88%; }
    .chat-input { padding: var(--spacing-xs) var(--spacing-md); padding-bottom: calc(var(--spacing-xs) + max(env(safe-area-inset-bottom), 6px)); }
    .header-actions .btn-secondary span { display: none; }
}
@media (min-width: 769px) { #close-sidebar { display: none; } }
