/* --- [Core CSS Variables & Reset] --- */
:root {
    --bg-primary: #131314;
    /* Sidebar background */
    --bg-secondary: #0e0e10;
    /* Main background */
    --bg-tertiary: #1e1f20;
    /* Capsule input, bubble & search background */

    --text-main: #e3e3e3;
    --text-muted: #c4c7c5;
    --text-dark: #8e918f;

    --accent-indigo: #4b93ff;
    /* Gemini Blue Accent */
    --accent-indigo-hover: #1b73e8;
    --accent-cyan: #24b2b2;
    --accent-green: #34a853;
    --accent-red: #ea4335;
    --accent-yellow: #fbbc05;

    --discord-blurple: #5865F2;
    --discord-blurple-hover: #4752c4;

    --glass-bg: rgba(30, 31, 32, 0.8);
    --glass-border: rgba(255, 255, 255, 0.06);
    --glass-shadow: rgba(0, 0, 0, 0.5);

    --font-ui: 'Pretendard', -apple-system, BlinkMacSystemFont, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", system-ui, Roboto, sans-serif;
    --font-header: 'Pretendard', var(--font-ui);

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 9999px;

    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: var(--font-ui);
    -webkit-font-smoothing: antialiased;
}

html,
body {
    max-width: 100vw;
    overflow-x: hidden;
}

body {
    background-color: var(--bg-secondary);
    color: var(--text-main);
    height: 100vh;
    height: 100dvh;
    overflow-y: hidden;
}

/* --- [Hidden Utility Class] --- */
.hidden {
    display: none !important;
}

/* --- [App Layout] --- */
.app-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    height: 100vh;
    height: 100dvh;
    width: 100%;
}

/* --- [Glassmorphism Styles] --- */
.glassmorphism {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 8px 32px 0 var(--glass-shadow);
}

/* --- [Login Landing View] --- */
.login-layout {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    height: 100dvh;
    width: 100%;
    background-color: var(--bg-secondary);
}

.login-card {
    max-width: 420px;
    width: 90%;
    padding: 48px 36px;
    border-radius: 28px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    background-color: var(--bg-primary);
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.logo-area {
    margin-bottom: 8px;
}

.brand-logo-img {
    object-fit: contain;
    border-radius: 50%;
}

.brand-logo-img.login-logo {
    width: 64px;
    height: 64px;
}

.brand-logo-img.sidebar-logo {
    width: 24px;
    height: 24px;
}

.login-card h1 {
    font-family: var(--font-header);
    font-weight: 800;
    font-size: 28px;
    background: linear-gradient(135deg, #fff 40%, var(--text-muted) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-card p {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.6;
}

.btn-discord {
    background-color: var(--discord-blurple);
    color: white;
    font-size: 15px;
    font-weight: 600;
    border-radius: var(--radius-full);
    padding: 14px 28px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    transition: var(--transition-normal);
    box-shadow: 0 4px 14px rgba(88, 101, 242, 0.3);
}


.login-footer {
    font-size: 11px;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* --- [Sidebar Component] --- */
.sidebar {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background-color: var(--bg-primary);
    border-right: 1px solid var(--glass-border);
    padding: 20px 16px;
    z-index: 10;
    gap: 16px;
}

.sidebar-header {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-left: 8px;
}

.brand-logo {
    font-size: 24px;
    filter: drop-shadow(0 0 4px rgba(251, 188, 5, 0.3));
}

.brand h1 {
    font-family: var(--font-header);
    font-size: 20px;
    font-weight: 700;
    color: #fff;
}

/* Search Box */
.sidebar-search {
    position: relative;
    width: 100%;
}

.sidebar-search input {
    width: 100%;
    background-color: var(--bg-tertiary);
    border: none;
    border-radius: var(--radius-full);
    padding: 10px 16px 10px 42px;
    color: var(--text-main);
    font-size: 13.5px;
    outline: none;
    transition: box-shadow var(--transition-fast);
}

.sidebar-search input:focus {
    box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.15);
}

.sidebar-search .search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-dark);
    font-size: 14px;
    pointer-events: none;
}

/* Sidebar Action Buttons */
.sidebar-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    background-color: #1e1f20;
    border: 1px solid rgba(255, 255, 255, 0.04);
    color: var(--text-main);
    padding: 12px 18px;
    border-radius: var(--radius-full);
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color var(--transition-fast), border-color var(--transition-fast);
    width: 100%;
    text-align: left;
}

.action-btn:hover {
    background-color: #2b2c2d;
    border-color: rgba(255, 255, 255, 0.08);
}

.new-chat-btn i {
    color: var(--accent-indigo);
}

.library-btn i {
    color: var(--accent-yellow);
}

/* Sidebar Scrollable Menu */
.sidebar-menu {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
}

.sidebar-menu::-webkit-scrollbar {
    width: 4px;
}

.sidebar-menu::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-menu::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-full);
}

.menu-section h3 {
    font-family: var(--font-header);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-dark);
    margin-bottom: 10px;
    padding-left: 8px;
}

.thread-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.thread-item {
    font-size: 13.5px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: transparent;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: var(--transition-fast);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.thread-item:hover {
    background-color: #2b2c2d;
    color: var(--text-main);
}

.thread-item i {
    font-size: 13.5px;
    color: var(--text-dark);
}

.thread-item.active {
    background-color: #2e3b50;
    color: #e3e3e3;
    font-weight: 500;
}

/* Sidebar Footer area */
.sidebar-footer {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: auto;
}

.btn-danger-pill {
    background-color: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border-radius: var(--radius-full);
    padding: 10px 16px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background-color var(--transition-fast);
}

.btn-danger-pill:hover {
    background-color: rgba(239, 68, 68, 0.18);
}

/* Profile Card */
.profile-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 20px;
    background-color: #1e1f20;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.profile-card .avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    border: 2px solid var(--glass-border);
}

.profile-card .user-info {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 0;
}

.profile-card .name {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-main);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 130px;
}

.btn-logout {
    background: transparent;
    border: none;
    color: var(--text-dark);
    cursor: pointer;
    font-size: 14px;
    transition: var(--transition-fast);
}

.btn-logout:hover {
    color: var(--accent-red);
    transform: scale(1.1);
}

/* --- [Chat Container Components] --- */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    background-color: var(--bg-secondary);
    position: relative;
}

/* Top Glow Bar - Aero Aurora left-sweep */
.top-glow-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 200px;
    z-index: 12;
    opacity: 0;
    pointer-events: none;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-transform: translate3d(0, -100px, 0);
    transform: translate3d(0, -100px, 0);
    transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.top-glow-bar::before {
    content: "";
    position: absolute;
    top: -100px;
    left: -100px;
    right: -100px;
    bottom: 0;
    background: linear-gradient(90deg,
            rgba(202, 98, 39, 0.38) 0%,
            rgba(233, 185, 73, 0.32) 20%,
            rgba(73, 119, 74, 0.26) 40%,
            rgba(36, 120, 150, 0.22) 60%,
            rgba(202, 98, 39, 0.38) 80%,
            rgba(233, 185, 73, 0.32) 100%);
    background-size: 200% 100%;
    background-position: 0% 0%;
    background-repeat: repeat;
    -webkit-filter: blur(85px);
    filter: blur(85px);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    will-change: background-position;
}

.top-glow-bar.thinking {
    opacity: 1;
}

.top-glow-bar.thinking::before {
    animation: aero-aurora-flow 12s linear infinite;
}

@keyframes aero-aurora-flow {
    0% {
        background-position: 200% 0%;
    }

    100% {
        background-position: 0% 0%;
    }
}

.chat-header {
    position: absolute;
    top: 24px;
    left: 24px;
    right: 24px;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0;
    z-index: 10;
    background: transparent;
    border: none;
    box-shadow: none;
    pointer-events: none;
    box-sizing: border-box;
}

.chat-header > * {
    pointer-events: auto;
}

.header-info {
    background: rgba(30, 31, 32, 0.65);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 8px 18px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.header-info h2 {
    font-family: var(--font-header);
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.header-info p {
    font-size: 11.5px;
    color: var(--text-dark);
    margin: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.sync-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-dark);
    background: rgba(255, 255, 255, 0.02);
    padding: 4px 10px;
    border-radius: var(--radius-full);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.green {
    background-color: var(--accent-green);
    box-shadow: 0 0 8px var(--accent-green);
    animation: pulse 2s infinite;
}

.status-dot.red {
    background-color: var(--accent-red);
    box-shadow: 0 0 8px var(--accent-red);
}

/* --- [Chat Messages Area] --- */
.chat-messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 88px 24px 110px 24px;
    display: flex;
    flex-direction: column;
    gap: 28px;
    scroll-behavior: smooth;
}

/* Scrollbar Customization */
.chat-messages-area::-webkit-scrollbar {
    width: 6px;
}

.chat-messages-area::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages-area::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-full);
}

.chat-messages-area::-webkit-scrollbar-thumb:hover {
    background: var(--text-dark);
}

/* Welcome Overlay */
.welcome-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--text-muted);
}

.welcome-logo {
    margin-bottom: 20px;
}

.sparkle-logo {
    font-size: 44px;
    background: linear-gradient(135deg, #4b93ff, #ff8f6b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sparkle-logo-img {
    width: 64px;
    height: 64px;
    object-fit: contain;
}

.meta-avatar {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    object-fit: cover;
    vertical-align: middle;
    margin-right: 4px;
}

@keyframes spin-pulse {

    0%,
    100% {
        transform: scale(1) rotate(0deg);
    }

    50% {
        transform: scale(1.1) rotate(15deg);
    }
}

.welcome-greeting {
    font-family: var(--font-header);
    font-size: 44px;
    font-weight: 500;
    color: #fff;
    margin-bottom: 6px;
}

.welcome-prompt {
    font-family: var(--font-header);
    font-size: 44px;
    font-weight: 500;
    color: #444746;
    background: linear-gradient(90deg, #444746 0%, #888888 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 24px;
}

/* Message Bubble Styles */
.message-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 82%;
    animation: messageSlideIn var(--transition-normal);
}

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

.message-wrapper.assistant {
    align-self: flex-start;
    align-items: flex-start;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.assistant-header-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.assistant-content-row {
    display: flex;
    flex-direction: column;
    padding-left: 0;
    width: 100%;
    box-sizing: border-box;
}

.message-avatar-container {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

.message-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.message-content-wrapper {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.message-meta {
    display: none;
}

.message-bubble {
    line-height: 1.6;
    font-size: 14.5px;
    word-break: break-word;
}

.user .message-bubble {
    padding: 12px 20px;
    border-radius: 24px;
    background-color: var(--bg-tertiary);
    color: var(--text-main);
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.assistant .message-bubble {
    color: var(--text-main);
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin-top: 4px;
}

.message-stats {
    font-size: 11px;
    color: var(--text-dark);
    margin-top: 10px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.02);
    border-radius: 6px;
    font-family: var(--font-ui);
    letter-spacing: 0.1px;
}

/* Markdown Specific inside bubble */
.message-bubble p {
    margin-bottom: 12px;
}

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

.message-bubble ul,
.message-bubble ol {
    margin-left: 20px;
    margin-bottom: 12px;
}

.message-bubble li {
    margin-bottom: 4px;
}

.message-bubble code {
    background: rgba(255, 255, 255, 0.06);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 13px;
    color: #e5c07b;
}

.message-bubble pre {
    background: #1e1f20;
    padding: 16px;
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin: 14px 0;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.message-bubble pre code {
    background: none;
    padding: 0;
    font-size: 12.5px;
    color: #abb2bf;
}

/* --- [Generated Image] --- */
.generated-image {
    display: block;
    max-width: 320px;
    height: auto;
    border-radius: 12px;
    margin-top: 10px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

/* --- [Reasoning Accordion (ChatGPT Style)] --- */
.reasoning-container {
    margin-bottom: 12px;
    width: 100%;
    align-self: stretch;
    background: transparent;
    border: none;
}

.reasoning-header {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 0;
    cursor: pointer;
    user-select: none;
    color: #8e8e93;
    transition: color 0.15s ease;
}

.reasoning-header:hover {
    color: #c7c7cc;
    background: transparent;
}

.reasoning-title {
    font-size: 13px;
    font-weight: 500;
    color: inherit;
    display: flex;
    align-items: center;
    gap: 6px;
}

.reasoning-icon-arrow {
    font-size: 10px;
    color: inherit;
    transition: transform 0.2s ease;
}

/* Expanded state: rotate 180 degrees to point up */
.reasoning-header:not(.collapsed) .reasoning-icon-arrow {
    transform: rotate(180deg);
}

.reasoning-content {
    margin-left: 13px;
    padding: 8px 0 8px 16px;
    font-size: 13px;
    color: #94a3b8;
    line-height: 1.65;
    background: transparent;
    border-left: 2px solid rgba(255, 255, 255, 0.08);
    white-space: pre-wrap;
    overflow-wrap: break-word;
    word-break: break-word;
    overflow: hidden;
    max-height: 10000px; /* Large enough to avoid scrollbar, but still animatable */
    transition: max-height 0.3s cubic-bezier(0, 1, 0, 1), padding 0.2s ease, opacity 0.2s ease;
    opacity: 1;
}

.reasoning-container.collapsed .reasoning-content {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-left-color: transparent;
    opacity: 0;
}

/* --- [Tool Execution Status] --- */
.tool-status-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.tool-run-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(75, 147, 255, 0.06);
    border: 1px solid rgba(75, 147, 255, 0.12);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    color: #a5ccff;
    align-self: flex-start;
}

.tool-run-badge i {
    color: var(--accent-indigo);
}

/* --- [Capsule Chat Input Area] --- */
.chat-input-area {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    max-width: 760px;
    width: 90%;
    background: rgba(30, 31, 32, 0.65);
    /* Translucent background */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 32px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 6px 10px 6px 18px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    z-index: 10;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.chat-input-area:focus-within {
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1), 0 8px 32px rgba(0, 0, 0, 0.4);
}

.input-form {
    display: flex;
    align-items: center;
    gap: 12px;
}

#chat-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 14.5px;
    resize: none;
    outline: none;
    max-height: 200px;
    min-height: 28px;
    line-height: 1.5;
    padding: 10px 0;
    overflow-y: hidden;
}

#chat-input::-webkit-scrollbar {
    width: 6px;
}

#chat-input::-webkit-scrollbar-track {
    background: transparent;
}

#chat-input::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-full);
}

#chat-input::-webkit-scrollbar-thumb:hover {
    background: var(--text-dark);
}

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

.btn-input-action {
    background: transparent;
    border: none;
    color: var(--text-dark);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition-fast);
}

.btn-input-action:hover {
    color: var(--text-muted);
}

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

.model-badge-container {
    background: rgba(30, 31, 32, 0.65);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--radius-full);
    padding: 6px 14px;
    display: flex;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    height: 38px;
    box-sizing: border-box;
}

.badge-select {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 11.5px;
    font-weight: 600;
    outline: none;
    cursor: pointer;
}

.btn-send-msg {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background-color: #ff6b00;
    border: none;
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: background-color var(--transition-fast), transform var(--transition-fast);
}

.btn-send-msg:hover {
    background-color: #ff8526;
    transform: scale(1.04);
}

.btn-send-msg:disabled {
    background-color: #2d2f31;
    color: var(--text-dark);
    cursor: not-allowed;
    transform: none;
}

/* Loading Spinner */
.loading-spinner-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 16px;
    color: var(--text-dark);
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255, 255, 255, 0.04);
    border-radius: 50%;
    border-top-color: var(--accent-indigo);
    animation: spin 0.8s linear infinite;
}

/* --- [Memory Modal Styles] --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-card {
    width: 480px;
    max-width: 92%;
    border-radius: 28px;
    background-color: var(--bg-primary);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.modal-header h2 {
    font-family: var(--font-header);
    font-size: 18px;
    font-weight: 600;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-close-modal {
    background: transparent;
    border: none;
    color: var(--text-dark);
    font-size: 20px;
    cursor: pointer;
    transition: color var(--transition-fast);
}

.btn-close-modal:hover {
    color: var(--text-main);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    max-height: 420px;
}

.modal-desc {
    font-size: 13px;
    color: var(--text-dark);
    margin-bottom: 16px;
    line-height: 1.5;
}

.memory-list-container {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.memory-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: rgba(255, 255, 255, 0.02);
    padding: 12px 16px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.04);
    transition: background-color var(--transition-fast);
}

.memory-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.memory-text {
    font-size: 13.5px;
    color: var(--text-main);
    line-height: 1.5;
    padding-right: 12px;
    word-break: break-all;
}

.btn-delete-memory {
    background: transparent;
    border: none;
    color: var(--text-dark);
    cursor: pointer;
    font-size: 13px;
    transition: color var(--transition-fast), transform var(--transition-fast);
    padding: 4px;
}

.btn-delete-memory:hover {
    color: var(--accent-red);
    transform: scale(1.1);
}

.memory-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: var(--text-dark);
    padding: 36px 0;
    text-align: center;
}

.memory-empty-state i {
    font-size: 38px;
    color: rgba(255, 255, 255, 0.1);
}

.memory-empty-state p {
    font-size: 13.5px;
}

.btn-header-action {
    background: rgba(30, 31, 32, 0.65);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-dark);
    font-size: 16px;
    cursor: pointer;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    transition: all var(--transition-fast);
}

.btn-header-action:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--accent-red);
}

.tool-status-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.tool-run-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background-color: rgba(251, 188, 5, 0.1);
    color: var(--accent-yellow);
    padding: 6px 12px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid rgba(251, 188, 5, 0.15);
    animation: messageSlideIn 0.3s ease;
}

.tool-run-badge.success {
    background-color: rgba(52, 168, 83, 0.1);
    color: var(--accent-green);
    border-color: rgba(52, 168, 83, 0.15);
}

.tool-run-badge.fail {
    background-color: rgba(234, 67, 53, 0.1);
    color: var(--accent-red);
    border-color: rgba(234, 67, 53, 0.15);
}

.tool-run-badge i {
    font-size: 14px;
}

/* --- [Mobile Specific Components] --- */
.btn-mobile-nav {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 20px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: none;
    /* Hidden on desktop */
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: background-color var(--transition-fast);
}

.btn-mobile-nav:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 90;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal) ease;
}

.sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* --- [Keyframes Animations] --- */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        opacity: 0.5;
    }

    50% {
        transform: scale(1.05);
        opacity: 1;
    }

    100% {
        transform: scale(0.95);
        opacity: 0.5;
    }
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in {
    animation: messageSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}


/* --- [Responsive Adjustments] --- */
@media (max-width: 768px) {
    .top-glow-bar {
        height: 120px;
        -webkit-transform: translate3d(0, -60px, 0);
        transform: translate3d(0, -60px, 0);
    }

    .top-glow-bar::before {
        top: -60px;
        left: -60px;
        right: -60px;
        bottom: 0;
        -webkit-filter: blur(45px);
        filter: blur(45px);
    }

    .app-layout {
        grid-template-columns: 1fr;
        width: 100vw;
        max-width: 100%;
        overflow-x: hidden;
    }

    .chat-container {
        width: 100vw;
        max-width: 100%;
        overflow-x: hidden;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        transform: translateX(-100%);
        z-index: 100;
        transition: transform var(--transition-normal) cubic-bezier(0.4, 0, 0.2, 1), box-shadow var(--transition-normal) ease;
        box-shadow: none;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 20px 0 50px rgba(0, 0, 0, 0.5);
    }

    .chat-header {
        position: absolute;
        top: 16px;
        left: 16px;
        right: 16px;
        height: auto;
        padding: 0;
        z-index: 10;
        background: transparent;
        border: none;
        box-shadow: none;
        box-sizing: border-box;
        pointer-events: none;
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
        align-items: center;
        gap: 8px;
    }

    .chat-header > * {
        pointer-events: auto;
    }

    .btn-mobile-nav {
        order: 1;
        display: flex;
        background: rgba(30, 31, 32, 0.65);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border: 1px solid rgba(255, 255, 255, 0.08);
        color: var(--text-main);
        font-size: 18px;
        cursor: pointer;
        width: 40px;
        height: 40px;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
        transition: background-color var(--transition-fast), transform var(--transition-fast);
    }

    .header-actions {
        order: 2;
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .chat-header .header-info {
        order: 3;
        width: 100%;
        max-width: 100%;
        background: rgba(30, 31, 32, 0.65);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border: 1px solid rgba(255, 255, 255, 0.08);
        border-radius: 20px;
        padding: 8px 16px;
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
        display: flex;
        align-items: center;
        justify-content: center;
        height: 40px;
        box-sizing: border-box;
        margin-top: 4px;
    }

    .chat-header h2 {
        font-size: 14px;
        font-weight: 600;
        text-align: center;
        max-width: 90%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        margin: 0;
    }

    .model-badge-container {
        background: rgba(30, 31, 32, 0.65);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border: 1px solid rgba(255, 255, 255, 0.08);
        border-radius: 20px;
        height: 40px;
        padding: 0 10px;
        display: flex;
        align-items: center;
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
        box-sizing: border-box;
    }

    .btn-header-action {
        background: rgba(30, 31, 32, 0.65);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border: 1px solid rgba(255, 255, 255, 0.08);
        color: var(--text-dark);
        font-size: 15px;
        cursor: pointer;
        width: 40px;
        height: 40px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
        box-sizing: border-box;
    }

    .chat-header p {
        display: none;
        /* Hide subtitle on mobile for cleaner layout */
    }

    .chat-messages-area {
        padding: 120px 12px calc(90px + env(safe-area-inset-bottom)) 12px;
        gap: 20px;
        overflow-x: hidden;
    }

    .message-wrapper {
        max-width: 95%;
    }

    .chat-input-area {
        position: absolute;
        bottom: calc(16px + env(safe-area-inset-bottom));
        left: 50%;
        transform: translateX(-50%);
        width: 90%;
        max-width: 600px;
        margin: 0;
        border-radius: 28px;
        border: 1px solid rgba(255, 255, 255, 0.08);
        background: rgba(30, 31, 32, 0.65);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        padding: 6px 8px 6px 14px;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
        z-index: 10;
        transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    }

    .chat-input-area:focus-within {
        border-color: rgba(255, 255, 255, 0.2);
        box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1), 0 8px 32px rgba(0, 0, 0, 0.4);
    }

    .input-form {
        gap: 8px;
    }

    #chat-input {
        font-size: 15px;
        /* Prevents auto-zoom on iOS */
        padding: 8px 0;
    }

    .welcome-greeting {
        font-size: 26px;
    }

    .welcome-prompt {
        font-size: 26px;
    }

    .message-meta {
        font-size: 11px;
    }

    .message-bubble {
        padding: 10px 14px;
        font-size: 14px;
    }

    .modal-card {
        max-width: 95%;
        border-radius: 20px;
    }
}