/* ============================================
   Memeee Chat — chat.css
   ============================================ */

/* ── Nav active link ── */
.nav-link-active {
    color: var(--accent) !important;
    font-weight: 600;
}

.nav-user-name {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ── Login Screen ── */
.login-screen {
    min-height: calc(100vh - 64px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-6) var(--space-4);
    background: var(--bg-primary);
}

.login-card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: var(--space-10) var(--space-8);
    width: 100%;
    max-width: 400px;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.login-logo {
    margin-bottom: var(--space-2);
    line-height: 1;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    margin-bottom: var(--space-6);
    margin-top: var(--space-2);
}

.login-form {
    text-align: left;
}

.form-group {
    margin-bottom: var(--space-4);
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.form-input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.9375rem;
    font-family: var(--font-mono);
    transition: border-color var(--transition-fast);
    box-sizing: border-box;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.btn-full {
    width: 100%;
}

.login-error {
    background: var(--red-light);
    color: var(--red);
    border: 1px solid var(--red);
    border-radius: var(--radius);
    padding: var(--space-3) var(--space-4);
    font-size: 0.875rem;
    margin-bottom: var(--space-4);
}

.btn-spinner {
    display: inline-flex;
    align-items: center;
    margin-left: var(--space-2);
}

.spin {
    animation: spin 0.8s linear infinite;
}

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

/* ── Chat App Layout ── */
.chat-app {
    display: flex;
    height: calc(100vh - 64px);
    overflow: hidden;
    background: var(--bg-primary);
    position: relative;
}

/* ── Sidebar ── */
.chat-sidebar {
    width: 260px;
    min-width: 260px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform var(--transition-slow);
}

.sidebar-header {
    padding: var(--space-4);
    border-bottom: 1px solid var(--border);
}

.sidebar-conversations {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-2) var(--space-2);
}

/* Support both class names: conversation-item (legacy) and conv-item (JS) */
.conversation-item, .conv-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-3);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background var(--transition-fast);
    border-bottom: 1px solid var(--border-light);
}

.conversation-item:last-child, .conv-item:last-child {
    border-bottom: none;
}

.conversation-item:hover, .conv-item:hover {
    background: var(--bg-tertiary);
}

.conversation-item.active, .conv-item.active {
    background: var(--accent-light);
    color: var(--accent);
}

.conversation-title, .conv-title {
    flex: 1;
    font-size: 0.8125rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
    line-height: 1.4;
}

.conversation-item.active .conversation-title,
.conv-item.active .conv-title {
    color: var(--accent);
    font-weight: 500;
}

.conversation-delete {
    opacity: 0;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 2px;
    border-radius: var(--radius-sm);
    transition: opacity var(--transition-fast), color var(--transition-fast);
    display: flex;
    align-items: center;
}

.conversation-item:hover .conversation-delete,
.conv-item:hover .conversation-delete {
    opacity: 1;
}

.conversation-delete:hover {
    color: var(--red);
}

.sidebar-divider {
    height: 1px;
    background: var(--border);
    margin: 0 var(--space-3);
}

.sidebar-info {
    padding: var(--space-4);
    font-size: 0.8125rem;
    overflow-y: auto;
    max-height: 40vh;
}

.info-section-title {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: var(--space-2);
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-1);
    gap: var(--space-2);
}

.info-label {
    color: var(--text-muted);
    font-size: 0.75rem;
    flex-shrink: 0;
}

.info-value {
    color: var(--text-primary);
    font-size: 0.75rem;
    font-weight: 500;
    text-align: right;
    word-break: break-all;
}

.context-bar-wrap {
    margin-top: var(--space-1);
}

.context-bar-track {
    background: var(--border);
    border-radius: var(--radius-full);
    height: 6px;
    overflow: hidden;
    margin-bottom: 4px;
}

.context-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: var(--radius-full);
    transition: width 0.4s ease;
}

.context-bar-fill.warn {
    background: var(--yellow);
}

.context-bar-fill.danger {
    background: var(--red);
}

.context-bar-label {
    font-size: 0.6875rem;
    color: var(--text-muted);
}

/* ── Main Chat ── */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* ── Top Bar ── */
.chat-topbar {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border);
    background: var(--bg-primary);
    min-height: 56px;
}

.sidebar-toggle-btn {
    flex-shrink: 0;
}

.model-selector-wrap {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.model-label {
    font-size: 0.8125rem;
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
}

.model-select {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.875rem;
    padding: var(--space-2) var(--space-3);
    cursor: pointer;
    font-family: var(--font-sans);
    transition: border-color var(--transition-fast);
}

.model-select:focus {
    outline: none;
    border-color: var(--accent);
}

.topbar-spacer {
    flex: 1;
}

.btn-ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

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

.btn-xs {
    padding: 2px 6px;
    font-size: 0.75rem;
}

/* ── System Prompt ── */
.system-prompt-area {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: var(--space-3) var(--space-4);
}

.system-prompt-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

.system-prompt-input {
    width: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: var(--font-sans);
    padding: var(--space-3);
    resize: vertical;
    min-height: 60px;
    max-height: 200px;
    box-sizing: border-box;
    transition: border-color var(--transition-fast);
}

.system-prompt-input:focus {
    outline: none;
    border-color: var(--accent);
}

/* ── Compact Banner ── */
.compact-banner {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    background: var(--yellow-light);
    color: var(--yellow);
    border-bottom: 1px solid var(--yellow);
    padding: var(--space-2) var(--space-4);
    font-size: 0.875rem;
    font-weight: 500;
}

/* ── Messages ── */
.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4) var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    scroll-behavior: smooth;
}

.messages-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
    gap: var(--space-3);
}

.messages-empty h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0;
}

.messages-empty p {
    font-size: 0.9375rem;
    margin: 0;
}

.empty-icon {
    color: var(--border);
}

/* ── Message Bubble ── */
.message-row {
    display: flex;
    gap: var(--space-3);
    max-width: 100%;
}

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

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 2px;
}

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

.message-row.assistant .message-avatar {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.message-content-wrap {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    max-width: calc(100% - 48px);
}

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

.message-row.assistant .message-content-wrap {
    align-items: flex-start;
}

.message-bubble {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-lg);
    font-size: 0.9375rem;
    line-height: 1.7;
    word-break: break-word;
    max-width: 680px;
    overflow-wrap: anywhere;
}

.message-row.user .message-bubble {
    background: var(--accent);
    color: white;
    border-bottom-right-radius: var(--radius-sm);
}

.message-row.assistant .message-bubble {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-bottom-left-radius: var(--radius-sm);
}

.message-meta {
    font-size: 0.6875rem;
    color: var(--text-muted);
    display: flex;
    gap: var(--space-3);
}

/* ── Markdown Styles in Bubbles ── */
.message-bubble h1,
.message-bubble h2,
.message-bubble h3,
.message-bubble h4 {
    margin: var(--space-3) 0 var(--space-2);
    font-weight: 700;
    line-height: 1.3;
    color: inherit;
}

.message-bubble h3 { font-size: 1.0625rem; }
.message-bubble h4 { font-size: 0.9375rem; }

.message-bubble p {
    margin: 0 0 var(--space-2);
}

.message-bubble p:last-child {
    margin-bottom: 0;
}

.message-bubble ul,
.message-bubble ol {
    margin: var(--space-2) 0;
    padding-left: var(--space-5);
}

.message-bubble li {
    margin-bottom: var(--space-1);
}

.message-bubble code {
    background: rgba(0,0,0,0.12);
    padding: 1px 5px;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.875em;
}

.message-row.user .message-bubble code {
    background: rgba(255,255,255,0.2);
}

.message-bubble pre {
    background: var(--bg-code);
    border-radius: var(--radius);
    padding: var(--space-4);
    overflow-x: auto;
    margin: var(--space-2) 0;
    position: relative;
}

.message-bubble pre code {
    background: none;
    padding: 0;
    color: #E5E7EB;
    font-size: 0.875rem;
    font-family: var(--font-mono);
}

.code-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255,255,255,0.06);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius) var(--radius) 0 0;
    font-size: 0.75rem;
    color: #9CA3AF;
    font-family: var(--font-mono);
}

.code-copy-btn {
    background: none;
    border: 1px solid rgba(255,255,255,0.15);
    color: #9CA3AF;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.6875rem;
    transition: all var(--transition-fast);
}

.code-copy-btn:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.code-wrap {
    background: var(--bg-code);
    border-radius: var(--radius);
    margin: var(--space-2) 0;
    overflow: hidden;
}

.code-wrap pre {
    margin: 0;
    border-radius: 0;
}

.message-bubble blockquote {
    border-left: 3px solid var(--accent);
    padding-left: var(--space-4);
    margin: var(--space-2) 0;
    color: var(--text-secondary);
    font-style: italic;
}

.message-row.user .message-bubble blockquote {
    border-left-color: rgba(255,255,255,0.5);
    color: rgba(255,255,255,0.8);
}

.message-bubble a {
    color: var(--link);
    text-decoration: underline;
}

.message-row.user .message-bubble a {
    color: rgba(255,255,255,0.9);
}

.message-bubble strong { font-weight: 700; }
.message-bubble em { font-style: italic; }

/* ── Typing Indicator ── */
.typing-indicator {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: var(--space-3) var(--space-4);
}

.typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: typing-bounce 1.4s infinite ease-in-out;
}

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

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

/* ── Input Area ── */
.input-area {
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid var(--border);
    background: var(--bg-primary);
}

.token-bar {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: 0.6875rem;
    color: var(--text-muted);
    margin-bottom: var(--space-2);
    flex-wrap: wrap;
}

.token-stat {
    display: flex;
    align-items: center;
    gap: 3px;
}

.token-divider {
    color: var(--border);
}

.input-row {
    display: flex;
    gap: var(--space-2);
    align-items: flex-end;
}

.message-input {
    flex: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: 0.9375rem;
    font-family: var(--font-sans);
    padding: var(--space-3) var(--space-4);
    resize: none;
    max-height: 200px;
    line-height: 1.5;
    transition: border-color var(--transition-fast);
    box-sizing: border-box;
}

.message-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

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

.send-btn, .stop-btn {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-full);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.send-btn {
    background: var(--accent);
    color: white;
}

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

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

.stop-btn {
    background: var(--red-light);
    color: var(--red);
}

.stop-btn:hover {
    background: var(--red);
    color: white;
}

/* ── Mobile Overlay ── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 99;
    border: none;
    cursor: pointer;
}

/* ── Scrollbar ── */
.messages-area::-webkit-scrollbar,
.sidebar-conversations::-webkit-scrollbar,
.sidebar-info::-webkit-scrollbar {
    width: 5px;
}
.messages-area::-webkit-scrollbar-thumb,
.sidebar-conversations::-webkit-scrollbar-thumb,
.sidebar-info::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: var(--radius-full);
}

/* ══════════════════════════════════════════════════════════
   MOBILE RESPONSIVE — Unified (≤768px)
   ══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    /* ── Prevent white gap below ── */
    html, body {
        background: var(--bg-primary);
        height: 100dvh;
        max-height: 100dvh;
        overflow: hidden;
        margin: 0;
        padding: 0;
    }
    
    /* Login screen: let it scroll if needed */
    .login-screen {
        overflow-y: auto;
        height: calc(100dvh - 64px);
    }

    /* ── App Layout: fill exact viewport ── */
    .chat-app {
        height: calc(100dvh - 64px);
        max-height: calc(100dvh - 64px);
        overflow: hidden;
    }

    /* ── Chat main: flex column, fill available ── */
    .chat-main {
        display: flex;
        flex-direction: column;
        height: 100%;
        overflow: hidden;
    }

    /* ── Navbar ── */
    .nav {
        padding: 0 var(--space-3);
    }
    .nav-links {
        display: none; /* use hamburger menu instead */
    }
    .nav-mobile-toggle {
        display: flex !important;
    }

    /* ── Sidebar: off-canvas drawer ── */
    .chat-sidebar {
        position: fixed;
        left: 0;
        top: 64px;
        bottom: 0;
        z-index: 100;
        transform: translateX(-100%);
        width: min(85vw, 320px);
        min-width: unset;
        transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
        will-change: transform;
    }
    .chat-sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,0.25);
    }
    .sidebar-overlay.visible {
        display: block;
    }

    /* Sidebar info: show but compact */
    .sidebar-info {
        max-height: 30vh;
        padding: var(--space-3);
    }
    .info-section-title { font-size: 0.625rem; }
    .info-row { margin-bottom: 0; }
    .info-label, .info-value { font-size: 0.6875rem; }

    /* Sidebar buttons: full width, tappable */
    .sidebar-header-actions {
        gap: var(--space-2);
    }
    .sidebar-header-actions .btn {
        min-height: 40px;
    }

    /* ── Topbar: compact, single line ── */
    .chat-topbar {
        padding: var(--space-2) var(--space-3);
        gap: var(--space-2);
        min-height: 44px;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .model-label { display: none; }
    .model-selector-wrap { flex: 1; min-width: 0; }
    .model-select {
        width: 100%;
        font-size: 0.8125rem;
        padding: var(--space-2);
    }
    .topbar-spacer { display: none; }

    /* Topbar buttons: icon only, no text labels */
    .chat-topbar .btn-ghost span,
    #systemPromptToggle span,
    #paramsToggle span,
    #compareBtn span,
    #toolsToggle span {
        display: none !important;
    }
    #systemPromptToggle,
    #paramsToggle,
    #compareBtn,
    #toolsToggle {
        padding: var(--space-2);
        min-width: 36px;
        min-height: 36px;
        font-size: 1.1rem;
    }

    /* Model selector: shorter, don't overflow */
    .model-select {
        width: 100%;
        max-width: 120px;
        font-size: 0.75rem;
        padding: var(--space-1) var(--space-2);
        text-overflow: ellipsis;
    }

    /* ── Messages ── */
    .messages-area {
        padding: var(--space-3);
        gap: var(--space-3);
    }
    .message-row { gap: var(--space-2); }
    .message-avatar { width: 28px; height: 28px; font-size: 0.65rem; }
    .message-content-wrap { max-width: calc(100% - 36px); }
    .message-bubble {
        max-width: 100%;
        padding: var(--space-3);
        font-size: 0.9rem;
        line-height: 1.55;
    }
    .message-meta { font-size: 0.625rem; gap: var(--space-2); }

    /* Code blocks: horizontal scroll, smaller text */
    .message-bubble pre { padding: var(--space-3); }
    .message-bubble pre code { font-size: 0.8rem; }
    .code-block-header { font-size: 0.6875rem; padding: var(--space-1) var(--space-2); }

    /* ── Input Area: bottom of flex, no gap ── */
    .input-area {
        position: relative;
        flex-shrink: 0;
        z-index: 20;
        background: var(--bg-primary);
        padding: var(--space-2) var(--space-3);
        padding-bottom: max(var(--space-3), env(safe-area-inset-bottom));
        border-top: 1px solid var(--border);
    }
    .message-input {
        font-size: 16px; /* prevent iOS zoom */
        min-height: 40px;
        max-height: 100px;
    }
    /* Messages fill available space */
    .messages-area {
        flex: 1;
        overflow-y: auto;
        padding-bottom: var(--space-3);
    }

    /* Input buttons: tappable size */
    .input-area .btn-icon {
        min-width: 36px;
        min-height: 36px;
    }
    .send-btn {
        min-width: 40px;
        min-height: 40px;
    }

    /* Token bar below input */
    .token-bar {
        font-size: 0.625rem;
        gap: var(--space-2);
        overflow-x: auto;
        flex-wrap: nowrap;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    /* Cost estimator */
    .cost-estimator {
        font-size: 0.6875rem;
        padding: var(--space-1) 0;
    }

    /* ── System Prompt ── */
    .system-prompt-area {
        padding: var(--space-2) var(--space-3);
    }
    .system-prompt-input {
        font-size: 0.875rem;
        min-height: 50px;
    }

    /* ── Parameters Panel ── */
    .params-grid {
        grid-template-columns: 1fr !important;
        gap: var(--space-3);
    }
    .params-panel {
        padding: var(--space-3);
    }

    /* ── Compare Mode: stack vertical ── */
    .compare-mode .chat-main {
        grid-template-columns: 1fr !important;
    }
    .compare-col:not(:first-of-type) {
        border-top: 1px solid var(--border);
        max-height: 40vh;
    }

    /* ── Tool Blocks ── */
    .tool-block { padding: var(--space-2) var(--space-3); }
    .tool-block-header { font-size: 0.8125rem; }
    .tool-block-content { font-size: 0.75rem; }

    /* ── Context Visualizer ── */
    .context-bar-track { height: 8px; } /* slightly bigger for touch */

    /* ── Search ── */
    .search-input { font-size: 0.875rem; }

    /* ── Modals: bottom sheet ── */
    .modal-backdrop {
        align-items: flex-end;
    }
    .modal-box {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        max-height: 85vh;
        overflow-y: auto;
        animation: slideUp 0.25s ease;
    }
    @keyframes slideUp {
        from { transform: translateY(100%); opacity: 0; }
        to { transform: translateY(0); opacity: 1; }
    }

    /* ── Templates grid ── */
    .templates-grid {
        grid-template-columns: 1fr;
    }

    /* ── Image preview strip ── */
    .image-preview-strip {
        max-height: 60px;
    }
    .image-preview-strip img {
        max-height: 50px;
    }
}

/* ── Very small screens (≤ 380px, e.g. iPhone SE) ── */
@media (max-width: 380px) {
    .chat-topbar {
        gap: 4px;
        padding: var(--space-1) var(--space-2);
    }
    .model-select { font-size: 0.75rem; }
    #systemPromptToggle,
    #paramsToggle,
    #compareBtn,
    #toolsToggle {
        min-width: 32px;
        min-height: 32px;
        font-size: 1rem;
    }
    .message-bubble { font-size: 0.85rem; }
    .sidebar-header-actions .btn { font-size: 0.8125rem; }
}

/* ── Standard small screens (≤ 480px) ── */
@media (max-width: 480px) {
    .message-input {
        font-size: 16px; /* prevent iOS zoom */
    }
}

/* ── Landscape mobile ── */
@media (max-width: 768px) and (orientation: landscape) {
    .chat-app {
        height: 100dvh;
    }
    .chat-sidebar {
        top: 0;
        height: 100dvh;
    }
    /* Hide navbar in landscape to maximize chat space */
    .site-header {
        display: none;
    }
    .messages-area {
        padding-bottom: var(--space-6);
    }
}

/* ── Desktop: hide sidebar toggle ── */
@media (min-width: 769px) {
    .sidebar-toggle-btn {
        display: none;
    }
    .nav-mobile-toggle {
        display: none !important;
    }
}

/* ── Summary Message ── */
.message-row.summary .message-bubble {
    background: var(--purple-light);
    border-color: var(--purple);
    color: var(--text-primary);
    font-style: italic;
}

.summary-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--purple);
    background: var(--purple-light);
    border: 1px solid var(--purple);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    margin-bottom: var(--space-2);
}

/* ══════════════════════════════════════════════════════════
   FEATURE 1: Code block enhancements (marked + hljs)
   ══════════════════════════════════════════════════════════ */
.code-wrap { margin: 8px 0; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); background: var(--bg-tertiary); }
.code-block-header { display: flex; align-items: center; justify-content: space-between; padding: 4px 12px; background: var(--bg-secondary); border-bottom: 1px solid var(--border); font-size: 0.75rem; color: var(--text-secondary); font-family: monospace; }
.code-copy-btn { background: none; border: 1px solid var(--border); border-radius: 4px; padding: 2px 8px; font-size: 0.6875rem; color: var(--text-secondary); cursor: pointer; transition: all 0.15s; }
.code-copy-btn:hover { background: var(--primary); color: white; border-color: var(--primary); }
.code-wrap pre { margin: 0; padding: 12px; overflow-x: auto; font-size: 0.8125rem; line-height: 1.6; }
.code-wrap pre code { font-family: 'SFMono-Regular','Cascadia Code','Fira Code',monospace; background: none!important; padding: 0!important; }
.code-wrap pre code.hljs { background: transparent!important; padding: 0!important; }
.message-bubble code:not(.hljs) { background: var(--bg-tertiary); padding: 2px 6px; border-radius: 4px; font-size: 0.85em; font-family: 'SFMono-Regular',monospace; border: 1px solid var(--border); }
.message-bubble h3,.message-bubble h4,.message-bubble h5,.message-bubble h6 { margin: 12px 0 4px 0; font-weight: 600; }
.message-bubble ul,.message-bubble ol { margin: 4px 0; padding-left: 1.5em; }
.message-bubble li { margin-bottom: 4px; }
.message-bubble blockquote { border-left: 3px solid var(--primary); margin: 8px 0; padding: 8px 12px; color: var(--text-secondary); background: var(--bg-secondary); border-radius: 0 4px 4px 0; }
.message-bubble table { border-collapse: collapse; margin: 8px 0; width: 100%; font-size: 0.875rem; display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.message-bubble th,.message-bubble td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; white-space: nowrap; }
.message-bubble th { background: var(--bg-secondary); font-weight: 600; }
.message-bubble tbody tr:hover { background: var(--bg-tertiary); }
.message-bubble hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }
.message-bubble a { color: var(--primary); text-decoration: underline; }
.message-bubble p { margin: 4px 0; }
.message-bubble p:first-child { margin-top: 0; }
.message-bubble p:last-child { margin-bottom: 0; }

/* ══════════════════════════════════════════════════════════
   FEATURE 2: Export Menu
   ══════════════════════════════════════════════════════════ */
.conv-actions { display: none; gap: 2px; align-items: center; }
.conv-item:hover .conv-actions,
.conversation-item:hover .conv-actions { display: flex; }
.conv-action-btn { background: none; border: none; color: var(--text-secondary); cursor: pointer; width: 22px; height: 22px; border-radius: 4px; display: flex; align-items: center; justify-content: center; font-size: 0.875rem; transition: all 0.15s; }
.conv-action-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.conv-action-delete:hover { color: var(--red); }
.export-menu { position: absolute; right: 0; top: 100%; background: var(--bg-primary); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 100; min-width: 140px; overflow: hidden; }
.export-menu button { display: block; width: 100%; padding: 8px 12px; text-align: left; background: none; border: none; color: var(--text-primary); font-size: 0.8125rem; cursor: pointer; }
.export-menu button:hover { background: var(--bg-secondary); }
.conv-item, .conversation-item { position: relative; }

/* ══════════════════════════════════════════════════════════
   FEATURE 3: File Upload & Preview
   ══════════════════════════════════════════════════════════ */
.attach-btn { background: none; border: none; font-size: 1.25rem; cursor: pointer; padding: 6px 8px; border-radius: var(--radius); flex-shrink: 0; }
.attach-btn:hover { background: var(--bg-tertiary); }
.file-preview-area { display: flex; gap: 8px; flex-wrap: wrap; padding: 8px 16px; border-top: 1px solid var(--border); background: var(--bg-secondary); }
.file-preview-item { display: flex; align-items: center; gap: 6px; padding: 4px 8px; background: var(--bg-primary); border: 1px solid var(--border); border-radius: var(--radius); font-size: 0.75rem; max-width: 200px; }
.file-preview-thumb { width: 32px; height: 32px; object-fit: cover; border-radius: 4px; }
.file-preview-icon { font-size: 1.25rem; }
.file-preview-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-primary); flex: 1; }
.file-preview-remove { background: none; border: none; color: var(--text-secondary); cursor: pointer; font-size: 1rem; line-height: 1; padding: 0 2px; flex-shrink: 0; }
.file-preview-remove:hover { color: var(--red); }
.drag-over { border: 2px dashed var(--primary)!important; background: rgba(37,99,235,0.05)!important; }
.msg-attachments { margin-top: 6px; display: flex; gap: 4px; flex-wrap: wrap; }
.msg-attach-badge { font-size: 0.6875rem; padding: 2px 6px; background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: 4px; color: var(--text-secondary); }

/* ══════════════════════════════════════════════════════════
   FEATURE 4: Search
   ══════════════════════════════════════════════════════════ */
.sidebar-header-actions { display: flex; gap: 6px; align-items: center; }
.search-area { margin-top: 8px; }
.search-input-wrap { position: relative; display: flex; align-items: center; }
.search-input { width: 100%; padding: 6px 28px 6px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-primary); color: var(--text-primary); font-size: 0.8125rem; outline: none; }
.search-input:focus { border-color: var(--primary); }
.search-clear-btn { position: absolute; right: 6px; background: none; border: none; color: var(--text-secondary); cursor: pointer; font-size: 1rem; }
.search-clear-btn:hover { color: var(--text-primary); }
.search-results-count { font-size: 0.6875rem; color: var(--text-secondary); margin-top: 4px; padding-left: 4px; }

/* ══════════════════════════════════════════════════════════
   FEATURE 6: Shortcuts Modal
   ══════════════════════════════════════════════════════════ */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-box { background: var(--bg-primary); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 420px; margin: 16px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 12px; border-bottom: 1px solid var(--border); }
.modal-title { font-size: 1rem; font-weight: 600; margin: 0; color: var(--text-primary); }
.modal-body { padding: 16px 20px 20px; }
.shortcuts-table { width: 100%; border-collapse: collapse; }
.shortcuts-table td { padding: 6px 0; font-size: 0.875rem; color: var(--text-primary); border: none; }
.shortcuts-table td:first-child { white-space: nowrap; padding-right: 16px; text-align: right; width: 50%; }
.shortcuts-table td:last-child { color: var(--text-secondary); }
kbd { display: inline-block; padding: 2px 6px; font-size: 0.75rem; font-family: monospace; background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: 4px; box-shadow: 0 1px 0 var(--border); color: var(--text-primary); min-width: 20px; text-align: center; }

/* ── Feature 8: Prompt Library ── */
.prompt-library-modal { max-width: 600px; }
.prompt-list { display: flex; flex-direction: column; gap: 10px; max-height: 400px; overflow-y: auto; padding-right: 4px; }
.prompt-item { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; background: var(--bg-secondary); transition: border-color 0.15s; }
.prompt-item:hover { border-color: var(--accent); }
.prompt-item-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.prompt-item-name { font-weight: 600; font-size: 0.9375rem; color: var(--text-primary); flex: 1; }
.prompt-badge { font-size: 0.6875rem; padding: 2px 8px; background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.prompt-item-actions { display: flex; gap: 6px; flex-shrink: 0; }
.prompt-item-preview { font-size: 0.8125rem; color: var(--text-secondary); line-height: 1.5; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.btn-xs { padding: 3px 10px; font-size: 0.75rem; border-radius: var(--radius-sm); border: 1px solid var(--border); cursor: pointer; background: var(--bg-secondary); color: var(--text-primary); transition: background 0.15s; }
.btn-xs.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-xs.btn-primary:hover { opacity: 0.9; }
.btn-xs.btn-ghost { background: transparent; border-color: transparent; }
.btn-xs.btn-ghost:hover { background: var(--bg-tertiary); }

/* ── Feature 9: Share Dialog ── */
#shareDialog .modal-box { max-width: 440px; }

/* ── Feature 12: Fork Button ── */
.fork-btn { display: none; margin-top: 6px; padding: 3px 10px; font-size: 0.75rem; background: transparent; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; color: var(--text-muted); transition: all 0.15s; }
.fork-btn:hover { background: var(--bg-secondary); border-color: var(--accent); color: var(--accent); }
.message-row.assistant:hover .fork-btn { display: inline-flex; align-items: center; gap: 4px; }
.conv-title[data-fork]::before { content: '⑂ '; font-size: 0.75em; color: var(--text-muted); }

/* ══════════════════════════════════════════════════════════
   FEATURE 13: Parameters Panel
   ══════════════════════════════════════════════════════════ */
.params-panel {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: var(--space-3) var(--space-4);
    display: none;
}
.params-panel.open { display: block; }
.params-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-4);
}
.param-item { display: flex; flex-direction: column; gap: 4px; }
.param-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.param-value-badge {
    font-size: 0.6875rem;
    font-weight: 700;
    color: var(--accent);
    background: var(--accent-light);
    border-radius: 4px;
    padding: 1px 6px;
    min-width: 36px;
    text-align: center;
}
.param-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 5px;
    border-radius: var(--radius-full);
    background: var(--border);
    outline: none;
    cursor: pointer;
    accent-color: var(--accent);
}
.param-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 0 0 2px var(--bg-primary);
    border: 2px solid var(--accent);
    transition: transform 0.1s;
}
.param-slider:hover::-webkit-slider-thumb { transform: scale(1.2); }
.param-hint { font-size: 0.625rem; color: var(--text-muted); text-align: center; margin-top: 2px; }

@media (max-width: 600px) {
    .params-grid { grid-template-columns: 1fr; }
}

/* ══════════════════════════════════════════════════════════
   FEATURE 14: Token Cost Estimator
   ══════════════════════════════════════════════════════════ */
.cost-estimator {
    font-size: 0.6875rem;
    color: var(--text-muted);
    padding: 2px 4px 4px;
    text-align: right;
    min-height: 16px;
    transition: color 0.2s;
}
.cost-estimator.warn { color: var(--yellow); }

/* ══════════════════════════════════════════════════════════
   FEATURE 15: Context Window Visualizer
   ══════════════════════════════════════════════════════════ */
.ctx-stacked-bar {
    display: flex;
    height: 10px;
    border-radius: var(--radius-full);
    overflow: visible;
    position: relative;
    background: var(--border);
    margin-bottom: 4px;
    border-radius: 6px;
    overflow: hidden;
}
.ctx-segment {
    height: 100%;
    min-width: 0;
    transition: width 0.4s ease;
    position: relative;
    cursor: pointer;
}
.ctx-segment:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 130%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-code);
    color: #E5E7EB;
    font-size: 0.6875rem;
    padding: 4px 8px;
    border-radius: 6px;
    white-space: nowrap;
    z-index: 50;
    pointer-events: none;
    box-shadow: var(--shadow-lg);
}
.ctx-seg-system  { background: #7C3AED; }
.ctx-seg-user    { background: #2563EB; }
.ctx-seg-asst    { background: #059669; }
.ctx-seg-avail   { background: var(--border); }
.ctx-bar-text { font-size: 0.6875rem; color: var(--text-muted); margin-top: 2px; }

/* ══════════════════════════════════════════════════════════
   FEATURE 16: Model Comparison Mode
   ══════════════════════════════════════════════════════════ */
.compare-mode .chat-main {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto auto auto 1fr auto;
    overflow: hidden;
}
/* Topbar spans both columns */
.compare-mode .chat-topbar { grid-column: 1 / -1; }
.compare-mode .system-prompt-area { grid-column: 1 / -1; }
.compare-mode .compact-banner { grid-column: 1 / -1; }
.compare-mode .params-panel { grid-column: 1 / -1; }
/* two compare columns */
.compare-col {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-right: 1px solid var(--border);
    min-width: 0;
}
.compare-col:last-child { border-right: none; }
.compare-col-header {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    font-size: 0.8125rem;
    font-weight: 600;
}
.compare-col-header .model-select { font-size: 0.8125rem; flex: 1; }
.compare-messages { flex: 1; overflow-y: auto; padding: var(--space-3); display: flex; flex-direction: column; gap: var(--space-3); }
/* Single input spans both cols */
.compare-input-row { grid-column: 1 / -1; }
.compare-mode-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    background: #7C3AED22;
    border: 1px solid #7C3AED55;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    color: #7C3AED;
}
[data-theme="dark"] .compare-mode-badge { color: #A78BFA; background: #7C3AED33; border-color: #7C3AED66; }
.compare-cost-bar {
    font-size: 0.6875rem;
    color: var(--text-muted);
    padding: 4px var(--space-3);
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    min-height: 22px;
}

/* ══════════════════════════════════════════════════════════
   FEATURE 17: Image Upload (enhanced)
   ══════════════════════════════════════════════════════════ */
.img-upload-btn {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 6px 7px;
    border-radius: var(--radius);
    flex-shrink: 0;
    color: var(--text-secondary);
    transition: background 0.15s, color 0.15s;
    display: flex;
    align-items: center;
}
.img-upload-btn:hover { background: var(--bg-tertiary); color: var(--accent); }
.img-preview-strip {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 8px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}
.img-preview-thumb-wrap {
    position: relative;
    display: inline-flex;
}
.img-preview-thumb-wrap img {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.img-preview-remove {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--red);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.img-paste-hint {
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-align: right;
    padding: 0 4px 2px;
}

/* ══════════════════════════════════════════════════════════
   PHASE 4B: MCP Tool Blocks
   ══════════════════════════════════════════════════════════ */
.tool-block {
    margin: 8px 0;
    border-left: 3px solid var(--accent, #1E40AF);
    padding: 8px 12px;
    border-radius: 0 var(--radius) var(--radius) 0;
    background: var(--bg-secondary);
    font-size: 0.875rem;
}
.tool-block-header {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    color: var(--text-primary);
    user-select: none;
}
.tool-block-header:hover { color: var(--accent, #1E40AF); }
.tool-block-arrow {
    font-size: 0.7em;
    transition: transform 0.2s;
    margin-left: auto;
}
.tool-block.collapsed .tool-block-arrow { transform: rotate(-90deg); }
.tool-block-content {
    margin-top: 8px;
    font-family: monospace;
    font-size: 0.82em;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--text-secondary);
    max-height: 300px;
    overflow-y: auto;
}
.tool-block.collapsed .tool-block-content { display: none; }
.tool-result-block {
    margin: 4px 0 8px 0;
    border-left: 3px solid var(--green, #16a34a);
    padding: 6px 12px;
    border-radius: 0 var(--radius) var(--radius) 0;
    background: color-mix(in srgb, var(--bg-secondary) 95%, var(--green, #16a34a) 5%);
    font-size: 0.8rem;
}
.tool-result-header {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
}
.tool-result-content {
    font-family: monospace;
    font-size: 0.8em;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--text-secondary);
    max-height: 200px;
    overflow-y: auto;
}
.tool-result-block.collapsed .tool-result-content { display: none; }
/* Tools toggle button */
#toolsToggle.active {
    background: var(--accent, #1E40AF);
    color: white;
}
#toolsToggle.active:hover {
    background: color-mix(in srgb, var(--accent, #1E40AF) 85%, black 15%);
}
.tools-indicator {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
    margin-right: 4px;
    vertical-align: middle;
}

/* ══════════════════════════════════════════════════════════
   PHASE 4B: Cloud Sync Icons & Templates Modal
   ══════════════════════════════════════════════════════════ */
.conv-cloud-icon {
    color: var(--text-muted);
    font-size: 0.7rem;
    margin-left: 4px;
    opacity: 0.7;
}
.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
    margin-top: 12px;
}
.template-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
    background: var(--bg-secondary);
}
.template-card:hover {
    border-color: var(--accent, #1E40AF);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, #1E40AF) 15%, transparent 85%);
}
.template-icon { font-size: 1.75rem; margin-bottom: 8px; }
.template-name { font-weight: 600; font-size: 0.9rem; margin-bottom: 4px; }
.template-desc { font-size: 0.78rem; color: var(--text-muted); }

/* ── (Mobile responsive rules consolidated above) ── */

/* ══════════════════════════════════════════════════════════
   FIGMA INTEGRATION STYLES
   ══════════════════════════════════════════════════════════ */
:root {
    --figma-accent: #A259FF;
}
.figma-settings {
    border-top: 1px solid var(--border);
    padding-top: var(--space-2);
}
.figma-settings .info-section-title {
    color: var(--figma-accent);
    font-size: 0.78rem;
    font-weight: 600;
}
.figma-settings input:focus {
    border-color: var(--figma-accent);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--figma-accent) 20%, transparent 80%);
}
/* Figma tool result accent */
.tool-block[data-tool^="figma_"] {
    border-left-color: var(--figma-accent) !important;
}
.tool-result-block.figma-result {
    border-left: 3px solid var(--figma-accent);
    background: color-mix(in srgb, var(--bg-secondary) 95%, var(--figma-accent) 5%);
}
/* Figma URL detection hint */
.figma-url-hint {
    font-size: 0.75rem;
    color: var(--figma-accent);
    padding: 4px 8px;
    margin-top: 4px;
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--figma-accent) 8%, transparent 92%);
    display: flex;
    align-items: center;
    gap: 4px;
    animation: figmaHintFade 0.3s ease;
}
@keyframes figmaHintFade {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}


/* === Enhanced Message Bubble Spacing === */
.message-bubble {
    transition: box-shadow var(--transition-fast);
}

.message-bubble:hover {
    box-shadow: var(--shadow-sm);
}

/* === Conversation List Item Hover === */
.conv-item {
    transition: all var(--transition-fast);
}

.conv-item:hover {
    background: var(--bg-tertiary);
    transform: translateX(2px);
}

/* === Loading Skeleton for Messages === */
.msg-skeleton {
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.msg-skeleton-line {
    height: 12px;
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-secondary) 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: var(--radius-sm);
}

.msg-skeleton-line:nth-child(1) { width: 80%; }
.msg-skeleton-line:nth-child(2) { width: 60%; }
.msg-skeleton-line:nth-child(3) { width: 70%; }

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

/* === Empty State Enhancement === */
.empty-chat-state {
    transition: opacity var(--transition-slow);
}

/* === Conversation Item Active Accent Border === */
.conv-item.active,
.conversation-item.active {
    border-left: 3px solid var(--accent);
    padding-left: calc(var(--space-3) - 3px);
}

/* === Message Row Hover === */
.msg-row {
    transition: background var(--transition-fast);
}

.msg-row:hover {
    background: var(--bg-secondary);
}

/* === Skeleton Avatar === */
.msg-skeleton-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-secondary) 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    flex-shrink: 0;
}

/* === Input Area Mobile Fix (iOS zoom prevention) === */
@media (max-width: 768px) {
    .input-row {
        padding: var(--space-2) var(--space-3);
    }

    .input-row textarea {
        font-size: 16px;
    }
}
