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

:root {
    --bg-main: #212121;
    --bg-sidebar: #171717;
    --bg-input: #2f2f2f;
    --text-primary: #ececec;
    --text-secondary: #b4b4b4;
    --text-muted: #8e8ea0;
    --border-light: rgba(255, 255, 255, 0.1);
    --border-hover: rgba(255, 255, 255, 0.2);
    --hover-bg: #2a2a2a;
    --accent: #10a37f;
    --accent-hover: #1a7f64;
    --error: #ef4444;
}

/* ===== Custom Scrollbar ===== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.3); }

body {
    font-family: 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ===== Login Overlay ===== */
.login-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-main);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.login-card {
    text-align: center;
    max-width: 380px;
    width: 90%;
    padding: 40px;
}

.login-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 24px;
    color: var(--text-primary);
}

.login-card h1 {
    font-size: 24px;
    font-weight: 500;
    margin-bottom: 12px;
}

.login-card > p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.login-form input {
    width: 100%;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--border-light);
    background: var(--bg-main);
    color: var(--text-primary);
    font-size: 16px;
    text-align: center;
    letter-spacing: 4px;
    outline: none;
    transition: border-color 0.2s;
}

.login-form input:focus { border-color: var(--accent); }

.login-form button {
    padding: 14px;
    border-radius: 8px;
    border: none;
    background: var(--accent);
    color: white;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.login-form button:hover { background: var(--accent-hover); }

.error { color: var(--error); font-size: 14px; margin-top: 16px; }

/* ===== App Layout ===== */
.app {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* ===== Sidebar ===== */
.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: margin-left 0.3s ease;
    overflow: hidden;
}

.sidebar.collapsed { margin-left: -260px; }

.sidebar-top { padding: 12px; }

.btn-new-chat {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border-light);
    background: transparent;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-new-chat:hover { background: var(--hover-bg); }

.btn-new-chat svg { width: 16px; height: 16px; }
.btn-new-chat .icon-edit { width: 16px; height: 16px; }

.sidebar-label {
    padding: 12px 12px 8px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
}

.sidebar-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.history-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
    position: relative;
    transition: background 0.2s;
    overflow: hidden;
    white-space: nowrap;
}

.history-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    mask-image: linear-gradient(to right, #000 80%, transparent 100%);
    -webkit-mask-image: linear-gradient(to right, #000 80%, transparent 100%);
}

.history-item:hover, .history-item.active { background: var(--hover-bg); }

/* Fix for the horrible delete button bug */
.history-item .delete-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--hover-bg);
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 4px;
    line-height: 0;
    box-shadow: -10px 0 10px 10px var(--hover-bg);
}

.history-item:hover .delete-btn { display: flex; }
.history-item .delete-btn:hover { color: var(--text-primary); }
.history-item .delete-btn svg { width: 16px; height: 16px; }

.sidebar-footer { padding: 12px; }

.btn-logout {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-logout:hover { background: var(--hover-bg); }
.btn-logout svg { width: 16px; height: 16px; }

/* ===== Main Chat Area ===== */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg-main);
    position: relative;
}

/* Topbar */
.topbar {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    gap: 12px;
    flex-shrink: 0;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 10;
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

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

.model-selector-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.model-selector-wrap select {
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    padding: 6px 28px 6px 12px;
    cursor: pointer;
    outline: none;
    border-radius: 8px;
    transition: background 0.2s, color 0.2s;
}

.model-selector-wrap select:hover { 
    color: var(--text-primary); 
    background: var(--hover-bg);
}
.model-selector-wrap select option { background: var(--bg-input); color: var(--text-primary); font-size: 14px;}

.select-chevron {
    position: absolute;
    right: 10px;
    pointer-events: none;
    color: var(--text-secondary);
}

/* Chat History */
.chat-area {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding-top: 60px; /* space for topbar */
}

.welcome {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
}

.welcome-logo {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: white;
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.welcome h1 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
}

.welcome-chips {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    max-width: 600px;
    width: 100%;
    padding: 0 24px;
}

.chip {
    padding: 14px;
    border-radius: 12px;
    border: 1px solid var(--border-light);
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    transition: background 0.2s;
}

.chip:hover { background: var(--hover-bg); }
.chip span { display: block; color: var(--text-primary); font-weight: 500; margin-bottom: 4px; }

/* Messages */
.msg-row {
    padding: 24px 0;
    display: flex;
    justify-content: center;
}

.msg-inner {
    max-width: 768px;
    width: 100%;
    padding: 0 24px;
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
    font-weight: 600;
}

.user-row .msg-avatar { background: #5436da; color: white; }
.assistant-row .msg-avatar { background: #10a37f; color: white; }

.msg-body {
    flex: 1;
    min-width: 0;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
    padding-top: 2px;
}

.msg-body p { margin-bottom: 16px; }
.msg-body p:last-child { margin-bottom: 0; }
.msg-body a { color: #8ab4f8; text-decoration: underline; }

.msg-body pre {
    background: #0d1117;
    border-radius: 8px;
    padding: 16px;
    margin: 16px 0;
    overflow-x: auto;
}

.msg-body code {
    font-family: 'Söhne Mono', Monaco, Consolas, monospace;
    font-size: 14px;
}

.msg-body p code {
    background: rgba(255,255,255,0.1);
    padding: 2px 4px;
    border-radius: 4px;
}

.msg-body ul, .msg-body ol { margin: 12px 0 12px 24px; }
.msg-body li { margin-bottom: 6px; }
.msg-body img { max-width: 100%; border-radius: 8px; margin: 12px 0; }

/* ===== Input Area ===== */
.input-dock {
    padding: 0 24px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
    background: linear-gradient(180deg, transparent, var(--bg-main) 30%);
}

.input-box {
    max-width: 768px;
    width: 100%;
    display: flex;
    align-items: flex-end;
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: 24px;
    padding: 10px 14px;
    box-shadow: 0 0 15px rgba(0,0,0,0.1);
    transition: border-color 0.2s;
}

.input-box:focus-within { border-color: var(--border-hover); }

#chat-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 16px;
    font-family: inherit;
    line-height: 1.5;
    resize: none;
    max-height: 200px;
    padding: 2px 8px;
    outline: none;
}

#chat-input::placeholder { color: var(--text-muted); }

.btn-send {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: var(--text-primary);
    color: var(--bg-main);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: opacity 0.2s;
}

.btn-send:disabled {
    background: var(--bg-input);
    color: var(--text-muted);
    cursor: not-allowed;
}

.btn-send:not(:disabled):hover { opacity: 0.8; }
.btn-send svg { width: 16px; height: 16px; }

.disclaimer {
    margin-top: 12px;
    font-size: 12px;
    color: var(--text-muted);
}

/* ===== Mobile Optimizations ===== */
.mobile-only { display: none !important; }
.sidebar-overlay { display: none; }

@media (max-width: 768px) {
    .desktop-only { display: none !important; }
    
    .mobile-sidebar-header { display: flex !important; }
    .mobile-topbar-title { display: block !important; }
    .mobile-topbar-actions { display: flex !important; }
    .mobile-fab { display: flex !important; }
    .btn-attach { display: block !important; }

    .sidebar { 
        position: fixed; 
        left: 0; 
        top: 0; 
        bottom: 0; 
        z-index: 60; 
        width: 85%;
        max-width: 340px;
        box-shadow: 4px 0 24px rgba(0,0,0,0.5);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        transform: translateX(0);
    }
    .sidebar.collapsed { 
        transform: translateX(-100%);
        box-shadow: none;
    }
    
    .sidebar-overlay {
        display: block;
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 55;
        opacity: 1;
        transition: opacity 0.3s;
        pointer-events: auto;
    }
    .sidebar-overlay.hidden {
        opacity: 0;
        pointer-events: none;
    }
    
    .topbar {
        justify-content: space-between;
        padding: 12px 16px;
    }
    
    .msg-inner { padding: 0 16px; gap: 12px; }
    
    .input-dock { 
        padding: 8px 16px 20px; 
        background: var(--bg-main);
    }
    
    .input-box {
        border-radius: 28px;
        padding: 6px 6px 6px 12px;
        background: #2f2f2f;
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
        align-items: center;
    }
    
    #chat-input {
        font-size: 16px; /* prevent iOS zoom */
        padding: 8px;
    }
    
    .btn-send {
        border-radius: 50%;
        width: 36px;
        height: 36px;
        background: var(--text-primary);
        color: var(--bg-main);
    }
    
    .welcome-chips { grid-template-columns: 1fr; }
}

/* ===== Visual Refresh v8 ===== */
:root {
    --bg-main: #181a1f;
    --bg-main-soft: #20232a;
    --bg-sidebar: #101115;
    --bg-elevated: #24272f;
    --bg-input: #282b33;
    --text-primary: #f3f4f6;
    --text-secondary: #c2c7d0;
    --text-muted: #858b98;
    --border-light: rgba(255, 255, 255, 0.09);
    --border-hover: rgba(255, 255, 255, 0.22);
    --hover-bg: rgba(255, 255, 255, 0.07);
    --accent: #18c29c;
    --accent-hover: #35d6b4;
    --accent-soft: rgba(24, 194, 156, 0.16);
    --shadow-soft: 0 18px 55px rgba(0, 0, 0, 0.28);
    --shadow-subtle: 0 10px 30px rgba(0, 0, 0, 0.18);
}

body {
    background:
        radial-gradient(circle at top left, rgba(24, 194, 156, 0.12), transparent 34vw),
        linear-gradient(135deg, #17191f 0%, #1f2026 48%, #17191f 100%);
}

.login-overlay {
    background:
        radial-gradient(circle at 50% 18%, rgba(24, 194, 156, 0.16), transparent 28%),
        linear-gradient(180deg, #1d2027 0%, #15161b 100%);
}

.login-card {
    padding: 42px 36px;
    background: rgba(32, 35, 42, 0.74);
    border: 1px solid var(--border-light);
    border-radius: 22px;
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(18px);
}

.login-icon {
    width: 56px;
    height: 56px;
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 18px;
    background: var(--accent-soft);
    box-shadow: inset 0 0 0 1px rgba(24, 194, 156, 0.18);
}

.login-form input {
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.035);
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.login-form input:focus {
    border-color: rgba(24, 194, 156, 0.72);
    background: rgba(255, 255, 255, 0.055);
    box-shadow: 0 0 0 4px rgba(24, 194, 156, 0.12);
}

.login-form button {
    border-radius: 14px;
    background: linear-gradient(135deg, var(--accent), #64e7c8);
    color: #06120f;
    box-shadow: 0 12px 28px rgba(24, 194, 156, 0.24);
    transition: transform 0.2s, box-shadow 0.2s, filter 0.2s;
}

.login-form button:hover {
    filter: brightness(1.04);
    transform: translateY(-1px);
    box-shadow: 0 16px 34px rgba(24, 194, 156, 0.3);
}

.sidebar {
    background: linear-gradient(180deg, #111217 0%, #0e0f13 100%);
    border-right: 1px solid rgba(255, 255, 255, 0.055);
}

.btn-new-chat-container {
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(255, 255, 255, 0.055);
}

.sidebar-btn-icon,
.btn-icon,
.btn-logout,
.history-item,
.chip,
.btn-send {
    transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.2s, box-shadow 0.2s, filter 0.2s;
}

.sidebar-btn-icon {
    width: 36px;
    height: 36px;
    justify-content: center;
    border-radius: 10px !important;
    color: var(--text-secondary) !important;
}

.sidebar-btn-icon:hover,
.btn-icon:hover {
    background: var(--hover-bg) !important;
    color: var(--text-primary) !important;
    transform: translateY(-1px);
}

.history-item:hover,
.history-item.active {
    background: var(--hover-bg);
    color: #fff;
}

.history-item.active {
    box-shadow: inset 3px 0 0 var(--accent);
}

.main {
    background:
        radial-gradient(circle at 72% 0%, rgba(24, 194, 156, 0.08), transparent 30vw),
        var(--bg-main);
}

.topbar {
    padding: 14px 18px;
}

.model-selector-wrap select {
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid transparent;
    border-radius: 12px;
}

.model-selector-wrap select:hover {
    border-color: var(--border-light);
}

.chat-area {
    padding-top: 68px;
}

.welcome {
    gap: 26px;
    padding: 0 18px;
}

.welcome-logo {
    width: 72px;
    height: 72px;
    border-radius: 24px;
    background: linear-gradient(135deg, rgba(24, 194, 156, 0.18), rgba(255, 255, 255, 0.08));
    color: var(--accent-hover);
    border: 1px solid rgba(24, 194, 156, 0.18);
    box-shadow: var(--shadow-subtle);
}

.welcome h1 {
    font-size: 30px;
    letter-spacing: 0;
}

.chip {
    min-height: 86px;
    padding: 16px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.035);
    line-height: 1.45;
}

.chip:hover {
    background: rgba(255, 255, 255, 0.065);
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-subtle);
}

.msg-row {
    padding: 18px 0;
}

.user-row {
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.026), transparent);
}

.msg-inner {
    gap: 14px;
}

.msg-avatar {
    width: 34px;
    height: 34px;
    border-radius: 12px;
}

.user-row .msg-avatar {
    background: linear-gradient(135deg, #7c5cff, #5f7cff);
    color: white;
}

.assistant-row .msg-avatar {
    background: linear-gradient(135deg, var(--accent), #6de5cb);
    color: #08110f;
}

.msg-body pre {
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
}

.msg-body img {
    border-radius: 16px;
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-subtle);
}

.input-box {
    background: rgba(40, 43, 51, 0.92);
    border-radius: 26px;
    padding: 12px 14px;
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(18px);
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.input-box:focus-within {
    border-color: rgba(24, 194, 156, 0.52);
    background: rgba(43, 47, 56, 0.96);
    box-shadow: 0 18px 52px rgba(0, 0, 0, 0.34), 0 0 0 4px rgba(24, 194, 156, 0.08);
}

.btn-send {
    border-radius: 11px;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: #06120f;
}

.btn-send:disabled {
    background: rgba(255, 255, 255, 0.07);
    color: var(--text-muted);
}

.btn-send:not(:disabled):hover {
    filter: brightness(1.06);
    transform: translateY(-1px);
}

@media (max-width: 768px) {
    .welcome h1 {
        font-size: 25px;
    }

    .welcome-logo {
        width: 62px;
        height: 62px;
        border-radius: 20px;
    }

    .chip {
        min-height: 74px;
    }

    .input-box {
        border-radius: 28px;
        padding: 7px 7px 7px 12px;
    }

    .mobile-fab {
        background: linear-gradient(135deg, var(--accent), var(--accent-hover)) !important;
        color: #06120f !important;
        box-shadow: 0 14px 34px rgba(24, 194, 156, 0.26) !important;
    }
}

/* ===== Light Background v9 ===== */
:root {
    --bg-main: #ffffff;
    --bg-main-soft: #f6f7f9;
    --bg-sidebar: #f4f5f7;
    --bg-elevated: #ffffff;
    --bg-input: #ffffff;
    --text-primary: #1f2328;
    --text-secondary: #4f5662;
    --text-muted: #8a929f;
    --border-light: rgba(17, 24, 39, 0.1);
    --border-hover: rgba(17, 24, 39, 0.18);
    --hover-bg: rgba(17, 24, 39, 0.06);
    --accent: #10a37f;
    --accent-hover: #0e8f70;
    --accent-soft: rgba(16, 163, 127, 0.12);
    --shadow-soft: 0 18px 55px rgba(17, 24, 39, 0.12);
    --shadow-subtle: 0 10px 30px rgba(17, 24, 39, 0.08);
}

body {
    background: #ffffff;
}

.login-overlay {
    background:
        radial-gradient(circle at 50% 12%, rgba(16, 163, 127, 0.12), transparent 26%),
        #ffffff;
}

.login-card {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(17, 24, 39, 0.1);
    box-shadow: var(--shadow-soft);
}

.login-form input {
    background: #ffffff;
    border-color: rgba(17, 24, 39, 0.12);
}

.login-form input:focus {
    background: #ffffff;
    border-color: rgba(16, 163, 127, 0.56);
}

.sidebar {
    background: linear-gradient(180deg, #f7f8fa 0%, #eef0f3 100%);
    border-right-color: rgba(17, 24, 39, 0.08);
}

.btn-new-chat-container {
    background: rgba(255, 255, 255, 0.72);
    border-color: rgba(17, 24, 39, 0.08);
}

.history-item .delete-btn {
    background: #eef0f3;
    box-shadow: -10px 0 10px 10px #eef0f3;
}

.main {
    background:
        radial-gradient(circle at 72% 0%, rgba(16, 163, 127, 0.07), transparent 28vw),
        #ffffff;
}

.model-selector-wrap select {
    background: rgba(17, 24, 39, 0.035);
}

.model-selector-wrap select option {
    background: #ffffff;
    color: var(--text-primary);
}

.welcome-logo {
    background: linear-gradient(135deg, rgba(16, 163, 127, 0.14), rgba(17, 24, 39, 0.04));
    color: var(--accent);
    border-color: rgba(16, 163, 127, 0.16);
}

.chip {
    background: #ffffff;
    border-color: rgba(17, 24, 39, 0.1);
}

.chip:hover {
    background: #f8fafb;
}

.user-row {
    background: linear-gradient(90deg, transparent, rgba(17, 24, 39, 0.026), transparent);
}

.assistant-row .msg-avatar {
    color: #ffffff;
}

.msg-body a {
    color: #2563eb;
}

.msg-body p code {
    background: rgba(17, 24, 39, 0.08);
}

.msg-body pre {
    background: #0f172a;
}

.input-dock {
    background: linear-gradient(180deg, transparent, #ffffff 30%);
}

.input-box {
    background: rgba(255, 255, 255, 0.94);
    border-color: rgba(17, 24, 39, 0.1);
    box-shadow: 0 18px 45px rgba(17, 24, 39, 0.12);
}

.input-box:focus-within {
    background: #ffffff;
    border-color: rgba(16, 163, 127, 0.42);
    box-shadow: 0 18px 52px rgba(17, 24, 39, 0.14), 0 0 0 4px rgba(16, 163, 127, 0.08);
}

.btn-send:disabled {
    background: rgba(17, 24, 39, 0.07);
}

@media (max-width: 768px) {
    .input-dock {
        background: #ffffff;
    }

    .input-box {
        background: #ffffff;
    }
}

/* ===== Chat Polish v10 ===== */
.chat-area {
    background:
        radial-gradient(circle at 78% 0%, rgba(16, 163, 127, 0.08), transparent 32vw),
        linear-gradient(180deg, #fbfcfd 0%, #ffffff 42%);
}

.msg-row {
    padding: 12px 22px;
    background: transparent;
}

.user-row {
    background: transparent;
}

.msg-inner {
    max-width: 880px;
    padding: 0;
    gap: 10px;
}

.user-row .msg-inner {
    flex-direction: row-reverse;
}

.msg-avatar {
    width: 38px;
    height: 38px;
    border-radius: 14px;
    margin-top: 2px;
    box-shadow: 0 8px 22px rgba(17, 24, 39, 0.12);
}

.msg-body {
    flex: initial;
    max-width: min(720px, calc(100vw - 190px));
    width: fit-content;
    padding: 14px 16px;
    border-radius: 18px;
    font-size: 16px;
    line-height: 1.72;
    word-break: break-word;
}

.user-row .msg-body {
    background: #2563eb;
    color: #ffffff;
    border-top-right-radius: 7px;
    box-shadow: 0 12px 28px rgba(37, 99, 235, 0.18);
}

.assistant-row .msg-body {
    background: #ffffff;
    color: var(--text-primary);
    border: 1px solid rgba(17, 24, 39, 0.08);
    border-top-left-radius: 7px;
    box-shadow: 0 12px 32px rgba(17, 24, 39, 0.08);
}

.msg-body p {
    margin-bottom: 10px;
}

.msg-body pre {
    margin: 12px 0;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.msg-body ul,
.msg-body ol {
    margin: 10px 0 10px 22px;
}

.reasoning-block {
    margin-bottom: 12px;
    padding: 10px 12px;
    background: #f6f8fa;
    border: 1px solid rgba(17, 24, 39, 0.08);
    border-radius: 14px;
    color: #5c6675;
    font-size: 13px;
    line-height: 1.6;
}

.reasoning-block summary {
    cursor: pointer;
    color: #4f5662;
    font-weight: 600;
    list-style: none;
}

.reasoning-block summary::-webkit-details-marker {
    display: none;
}

.reasoning-block summary::before {
    content: "+";
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin-right: 7px;
    border-radius: 999px;
    background: rgba(16, 163, 127, 0.12);
    color: var(--accent);
    font-weight: 700;
}

.reasoning-block[open] summary::before {
    content: "-";
}

.reasoning-content {
    margin-top: 8px;
    white-space: pre-wrap;
}

.answer-content:empty {
    display: none;
}

.loading-dots {
    color: var(--text-muted);
}

@media (max-width: 768px) {
    .msg-row {
        padding: 10px 12px;
    }

    .msg-inner {
        max-width: 100%;
        gap: 8px;
    }

    .msg-avatar {
        width: 34px;
        height: 34px;
        border-radius: 12px;
    }

    .msg-body {
        max-width: calc(100vw - 88px);
        padding: 12px 14px;
        font-size: 15px;
        line-height: 1.65;
        border-radius: 16px;
    }

    .user-row .msg-body {
        border-top-right-radius: 6px;
    }

    .assistant-row .msg-body {
        border-top-left-radius: 6px;
    }
}
