/* index.css - REPLIX UI Core Styles */

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg-dark: #0b1120;
    --card-dark: rgba(30, 41, 59, 0.5);
    --text-main: #f8fafc;
    --text-dim: #94a3b8;
    --accent: #6366f1;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --secondary-accent-gradient: linear-gradient(135deg, #a78bfa 0%, #f472b6 100%);
    --hero-gradient: linear-gradient(135deg, #ffffff 0%, #cbd5e1 60%, #94a3b8 100%);
    --border: rgba(255, 255, 255, 0.08);
    --error: #f87171;
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.15);
    --msg-user: #312e81;
    --glow: rgba(99, 102, 241, 0.15);
    --input-bg: rgba(15, 23, 42, 0.6);
    --input-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.5);
    --card-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    --bg-gradient-top: rgba(2, 6, 23, 0);
    --bg-gradient-bottom: rgba(2, 6, 23, 0.6);

    --nav-bg: rgba(10, 15, 30, 0.85);
    --nav-text: #94a3b8;
    --nav-active-bg: rgba(99, 102, 241, 0.18);
    --nav-active-text: #a5b4fc;
    --nav-logo: #f8fafc;
    --nav-border: rgba(255, 255, 255, 0.08);

    /* Layout Tokens */
    --chat-max-width: 640px;
    --h-gap: 1rem;
    --v-gap: 1rem;
    --composer-gap: 1.25rem;
    --nav-height-mobile: 4.5rem;
}

replix-nav {
    display: contents;
}

/* Modal Styles */
.modal-body label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
    color: var(--text-main);
    opacity: 0.9;
    text-align: left;
}

.modal-body input,
.modal-body textarea {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    color: var(--text-main);
    font-family: inherit;
    transition: all 0.2s;
    margin-bottom: 1.25rem;
}

.modal-body input:focus,
.modal-body textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--glow);
}

.modal-body .hint {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-top: -1rem;
    margin-bottom: 1.25rem;
    display: block;
}

.btn-modal-submit {
    background: var(--accent-gradient);
    color: white;
    border: none;
    border-radius: 0.75rem;
    padding: 0.85rem;
    font-weight: 700;
    width: 100%;
    cursor: pointer;
    transition: 0.2s;
}

.btn-modal-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px var(--glow);
}

.btn-modal-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

body {
    font-family: 'Outfit', 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--body-bg, #020617);
    background-image:
        radial-gradient(circle at 100% 0%, var(--bg-glow-1, rgba(99, 102, 241, 0.08)) 0%, transparent 40%),
        radial-gradient(circle at 10% 20%, var(--bg-glow-2, rgba(99, 102, 241, 0.1)) 0%, transparent 45%),
        radial-gradient(circle at 90% 80%, var(--bg-glow-3, rgba(16, 185, 129, 0.08)) 0%, transparent 45%),
        radial-gradient(circle at 50% 10%, var(--bg-glow-4, rgba(139, 92, 246, 0.06)) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, var(--bg-glow-5, rgba(244, 114, 182, 0.04)) 0%, transparent 40%),
        linear-gradient(180deg, var(--bg-gradient-top) 0%, var(--bg-gradient-bottom) 100%);
    background-attachment: fixed;
    color: var(--text-main);
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: row;
    line-height: 1.6;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    animation: pageFadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
}

body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    opacity: var(--bg-noise-opacity, 0.02);
    pointer-events: none;
    z-index: 1;
    mix-blend-mode: overlay;
}

@keyframes pageFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

@media (max-width: 600px) {
    :root {
        --h-gap: 1rem;
    }

    .page-body {
        padding-top: var(--nav-height-mobile);
    }

    ::-webkit-scrollbar {
        display: none;
    }
}

/* ── Page body wrapper ── */
.page-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
    min-height: 0;
}

.page-body {
    display: flex;
    flex-direction: row;
    flex: 1;
    overflow: hidden;
    height: 100dvh;
}

.hero-main-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    /* Centered! */
    width: 100%;
    max-width: var(--chat-max-width);
    /* 640px */
    margin: 0 auto;
    position: relative;
}

main.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: relative;
    background: transparent;
    padding: 0 var(--h-gap);
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    width: 100%;
    scroll-behavior: smooth;
    padding-top: 0;

    /* Feathered edge at the bottom of the scrollable area */
    -webkit-mask-image: linear-gradient(to bottom, black calc(100% - 20px), transparent 100%);
    mask-image: linear-gradient(to bottom, black calc(100% - 20px), transparent 100%);
}

@media (max-width: 600px) {
    .chat-history {
        padding-top: 0rem;
    }

    .chat-history-inner {
        padding-top: 0.5rem;
    }
}

.chat-history-inner {
    max-width: var(--chat-max-width);
    width: 100%;
    margin: 0 auto;
    padding: 0 0 0 0;
    display: flex;
    flex-direction: column;
    gap: var(--v-gap);
    min-height: 100%;
    position: relative;
}

.chat-history-inner::before {
    content: '';
    margin-top: auto;
    flex-shrink: 0;
}

.chat-container.empty-state .chat-history-inner {
    justify-content: flex-end;
    /* Dock everything to the bottom (above composer) */
    max-width: 1400px;
    padding-bottom: 0.25rem;
}

@media (max-width: 600px) {
    .chat-container.empty-state .chat-history-inner {
        padding-bottom: 0;
        justify-content: flex-end;
    }
}

.chat-container.empty-state .chat-history-inner::before {
    content: none;
}

/* Empty State */
/* Empty State */
.empty-state-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 100%;
    padding: 0rem 1.5rem;
    animation: fadeIn 0.8s ease;
}

@media (max-width: 600px) {
    .empty-state-hero {
        padding: 0.15rem 0rem;
        /* Ultra minimal padding for mobile */
    }
}

.ai-avatar {
    width: 110px;
    height: 110px;
    background: var(--nav-active-bg, rgba(255, 255, 255, 0.03));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1.5px solid var(--border, rgba(255, 255, 255, 0.15));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3.2rem;
    box-shadow: var(--card-shadow);
    animation: float 6s infinite ease-in-out;
    color: var(--text-main);
    text-transform: uppercase;
    font-weight: 800;
    position: relative;
    z-index: 2;
    line-height: 1;
    flex-shrink: 0;
}

/* Artistic glow effect */
.ai-avatar::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: var(--accent-gradient);
    border-radius: 50%;
    filter: blur(25px);
    opacity: var(--avatar-glow-opacity, 0.4);
    z-index: -1;
    animation: pulse 4s infinite alternate ease-in-out;
}

@keyframes float {

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

    50% {
        transform: translateY(-15px) rotate(2deg);
    }
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 0.3;
    }

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

@media (max-width: 600px) {
    .ai-avatar {
        width: 70px;
        height: 70px;
        font-size: 2.2rem;
        border: 1px solid rgba(255, 255, 255, 0.3);
    }
}

.empty-state-hero h2 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0;
    letter-spacing: -0.03em;
    background: var(--hero-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.empty-state-hero p {
    color: var(--text-dim);
    font-size: 1.05rem;
    max-width: 520px;
    line-height: 1.6;
    font-weight: 400;
    transition: all 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.hero-main-group {
    display: flex;
    align-items: center;
    justify-content: center;
    /* Centered */
    gap: 2rem;
    text-align: center;
    /* Centered */
    width: 100%;
}

.hero-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    /* Centered */
    text-align: center;
    /* Centered */
    gap: 0rem;
}

@media (max-width: 768px) {
    .hero-main-group {
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        text-align: left;
        gap: 1.25rem;
        padding: 0 1rem;
    }

    .hero-text {
        align-items: flex-start;
        text-align: left;
        gap: 0.2rem;
        width: 100%;
    }

    .empty-state-hero h1 {
        font-size: 1.6rem;
        margin-bottom: 0.25rem;
    }

    .empty-state-hero p {
        font-size: 0.88rem;
        line-height: 1.4;
        margin-bottom: 0.5rem;
    }
}

@media (max-width: 600px) {
    .empty-state-hero h1 {
        font-size: 1.4rem;
        margin-bottom: 0;
        /* Gap 1 reduced */
    }

    .empty-state-hero p {
        font-size: 0.82rem;
        line-height: 1.25;
        margin-bottom: 0.25rem;
        /* Gap 2 reduced */
    }
}

/* Product panel styles moved to product_panel.css */

/* ── Web Components Overrides ── */
replix-product-panel {
    display: contents;
}

/* Messages */
.message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    min-width: 60px;
    animation: messageIn 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.98);
    }

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

.message.user {
    align-self: flex-end;
    background: var(--msg-user-bg, linear-gradient(135deg, rgba(6, 78, 59, 0.98) 0%, rgba(16, 185, 129, 0.92) 100%));
    color: white;
    padding: 0.9rem 1.35rem;
    border-radius: 1.5rem 1.5rem 0.25rem 1.5rem;
    box-shadow: 0 10px 25px -5px rgba(6, 78, 59, 0.4);
    border: 1px solid rgba(110, 231, 183, 0.15);
}

.message.bot {
    align-self: flex-start;
    background: var(--msg-bot-bg, linear-gradient(165deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.01) 100%), rgba(15, 23, 42, 0.75));
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    color: var(--text-main);
    padding: 1rem 1.4rem;
    border-radius: 1.5rem 1.5rem 1.5rem 0.25rem;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border);
    position: relative;
}

.message-content {
    font-size: 1rem;
    line-height: 1.6;
    word-break: break-word;
}

.message-content p {
    margin-bottom: 1rem;
}

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

.message-content ul,
.message-content ol {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}

.message-content li {
    margin-bottom: 0.5rem;
}

.message-content code {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.2rem 0.4rem;
    border-radius: 0.4rem;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.9em;
}

.message-content pre {
    background: rgba(0, 0, 0, 0.3);
    padding: 1rem;
    border-radius: 1rem;
    margin-bottom: 1rem;
    overflow-x: auto;
    border: 1px solid var(--border);
}

.message-content pre code {
    background: none;
    padding: 0;
    border-radius: 0;
    display: block;
}

.message-content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 0.75rem;
    overflow: hidden;
}

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

.message-content th {
    background: rgba(255, 255, 255, 0.05);
    font-weight: 600;
}

.message-content blockquote {
    border-left: 4px solid var(--accent);
    padding-left: 1rem;
    margin-left: 0;
    margin-bottom: 1rem;
    color: var(--text-dim);
    font-style: italic;
}

.message-content h1,
.message-content h2,
.message-content h3 {
    margin: 1.5rem 0 1rem 0;
    font-weight: 700;
    line-height: 1.3;
    color: inherit;
}

.message-content strong {
    color: inherit;
    font-weight: 700;
}

.sponsor-msg {
    margin-top: 1.25rem;
    margin-bottom: 1rem;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.02) 100%);
    border-radius: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-left: 4px solid #fbbf24;
    font-size: 0.9rem;
    color: #f8fafc;
    line-height: 1.6;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(8px);
}

.sponsor-msg strong {
    color: #fbbf24;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.sponsor-msg a {
    color: #6ee7b7;
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px dashed rgba(110, 231, 183, 0.5);
    transition: all 0.2s;
}

.sponsor-msg a:hover {
    color: #34d399;
    border-bottom-style: solid;
    border-bottom-color: #34d399;
}

.sponsor-tags-wrap {
    margin-top: 0.6rem;
    display: flex;
    justify-content: flex-start;
}

.sponsor-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0;
}

.sponsor-tag {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.65rem;
    border-radius: 0.6rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.45);
    font-size: 0.7rem;
    line-height: 1;
    font-weight: 300;
    letter-spacing: 0.01em;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.sponsor-tag:hover {
    border-color: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.7);
    background: rgba(255, 255, 255, 0.05);
}

@media (max-width: 600px) {
    .sponsor-msg {
        padding: 0.9rem 1rem;
        font-size: 0.85rem;
    }

    .sponsor-tags-wrap {
        margin-top: 0.5rem;
    }

    .sponsor-tags {
        gap: 0.28rem;
    }

    .sponsor-tag {
        font-size: 0.65rem;
        padding: 0.22rem 0.48rem;
    }
}

.katex-display {
    margin: 1rem 0;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 0.75rem;
    overflow-x: auto;
}

.message.bot {
    position: relative;
}

.copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-dim);
    width: 2rem;
    height: 2rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s;
    z-index: 5;
}

.message.bot:hover .copy-btn {
    opacity: 1;
}

.copy-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.copy-btn.copied {
    color: var(--success);
    border-color: var(--success);
}

.meta {
    margin-top: 0.85rem;
    font-size: 0.72rem;
    color: var(--text-dim);
    display: flex;
    gap: 0rem 0.4rem;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: wrap;
    width: 100%;
}

.meta-main,
.training-tip {
    display: contents;
}

/* The Unified Chip Style */
.meta-main>span,
.training-tip>a,
.sponsor-add-btn {
    background: rgba(255, 255, 255, 0.03) !important;
    border-radius: 0.6rem !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    height: 26px !important;
    padding: 0 0.65rem !important;
    box-sizing: border-box !important;
    color: rgba(255, 255, 255, 0.45) !important;
    font-size: 0.7rem !important;
    font-weight: 300 !important;
    border: 1px solid rgba(255, 255, 255, 0.06) !important;
    text-decoration: none !important;
    transition: all 0.2s ease !important;
    white-space: nowrap !important;
    margin: 0.2rem 0 !important;
    cursor: default;
}

.training-tip>a,
.sponsor-add-btn {
    cursor: pointer !important;
}

.meta-main>span {
    cursor: default;
}

.training-tip>a:hover,
.sponsor-add-btn:hover {
    border-color: rgba(255, 255, 255, 0.12) !important;
    color: rgba(255, 255, 255, 0.7) !important;
    background: rgba(255, 255, 255, 0.05) !important;
    transform: translateY(-1px);
}

/* Ensure text inside links doesn't interfere */
.training-tip>a span,
.sponsor-add-btn span {
    background: none !important;
    padding: 0 !important;
    border: none !important;
    height: auto !important;
    line-height: inherit !important;
    font-size: inherit !important;
    font-weight: inherit !important;
    display: inline !important;
    color: inherit !important;
}

.meta .training-tip {
    display: contents;
}

/* Input Area */
.input-area {
    width: 100%;
    padding: 1.5rem 0 1.5rem;
    /* Reduced from var(--composer-gap) */
    position: relative;
    z-index: 100;
    flex-shrink: 0;
}

.input-wrapper {
    max-width: var(--chat-max-width);
    margin: 0 auto;
    background: var(--input-bg, rgba(15, 23, 42, 0.6));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 1.5rem;
    padding: 0.6rem;
    box-shadow: var(--input-shadow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 10;
}

.input-wrapper::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: inherit;
    background: none;
    opacity: 0;
}

.input-wrapper>* {
    position: relative;
    z-index: 1;
}

.query-composer {
    display: flex;
    flex-direction: column;
    gap: 0rem;
    width: 100%;
}

.query-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.9rem;
    min-height: 2.5rem;
}

.query-hint {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    color: rgba(226, 232, 240, 0.72);
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.01em;
}

.query-hint .hint-dot {
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 999px;
    background: linear-gradient(135deg, #60a5fa 0%, #a78bfa 100%);
    box-shadow: 0 0 0 6px rgba(99, 102, 241, 0.12);
}

.query-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

.server-status {
    width: 100%;
    max-width: var(--chat-max-width);
    margin: 0 auto 0.75rem;
    padding: 0.8rem 1rem;
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(12, 18, 34, 0.82);
    color: var(--text-dim);
    font-size: 0.9rem;
    line-height: 1.4;
    display: none;
    align-items: center;
    gap: 0.65rem;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
}

.server-status.active {
    display: flex;
}

.server-status .status-dot {
    width: 0.65rem;
    height: 0.65rem;
    border-radius: 999px;
    background: var(--accent);
    box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.45);
    animation: statusPulse 1.4s infinite;
    flex-shrink: 0;
}

.server-status.ready {
    color: #d1fae5;
    background: rgba(6, 95, 70, 0.24);
    border-color: rgba(16, 185, 129, 0.22);
}

.server-status.ready .status-dot {
    background: var(--success);
    animation: none;
    box-shadow: none;
}

.server-status.warming {
    color: #cbd5e1;
}

@keyframes statusPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.42);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(99, 102, 241, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0);
    }
}

.context-badge {
    position: absolute;
    top: -2.5rem;
    left: 0;
    background: rgba(99, 102, 241, 0.2);
    border: 1px solid var(--accent);
    color: #a5b4fc;
    padding: 0.25rem 0.75rem;
    border-radius: 2rem;
    font-size: 0.75rem;
    display: none;
    align-items: center;
    gap: 0.5rem;
    animation: fadeIn 0.3s ease;
}

.context-badge.active {
    display: flex;
}

.context-badge button {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
}

.context-badge button:hover {
    color: var(--error);
}

.btn-attach {
    background: transparent;
    color: var(--text-dim);
    border: 1px solid transparent;
    border-radius: 0.9rem;
    width: 2.75rem;
    height: 2.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    opacity: 0.7;
    flex-shrink: 0;
}

.btn-attach:hover {
    background: var(--nav-active-bg);
    color: var(--accent);
    opacity: 1;
}

.btn-attach svg {
    width: 18px;
    height: 18px;
}

.input-wrapper:focus-within {
    box-shadow: var(--input-shadow-focus, 0 8px 18px rgba(0, 0, 0, 0.15));
    background: var(--input-bg-focus, var(--input-bg));
    border-color: var(--accent);
}

textarea {
    flex: 1;
    width: 100%;
    min-height: 52px;
    max-height: 200px;
    padding: 0.65rem 0.85rem;
    border-radius: 0.9rem;
    background: transparent;
    border: none;
    font-size: 1rem;
    color: var(--text-main);
    resize: vertical;
    outline: none;
    font-family: inherit;
    line-height: 1.5;
    overflow-y: auto;
    box-sizing: border-box;
    transition: all 0.18s;
}

.input-wrapper textarea {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 1.05rem;
    font-family: inherit;
    width: 100%;
    padding: 0.8rem 0.6rem;
    resize: none;
    outline: none;
    max-height: 200px;
    line-height: 1.6;
}

.input-wrapper textarea::placeholder {
    color: var(--text-dim);
    opacity: 0.5;
}

.model-selector {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0 0.75rem;
    height: 2.75rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
    margin-right: 0.25rem;
}

.model-selector:hover {
    background: var(--nav-active-bg);
    border-color: var(--border);
}

.model-selector .model-name {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-dim);
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.model-selector .chevron {
    opacity: 0.5;
    transition: transform 0.2s;
    color: var(--text-dim);
}

.model-selector.open .chevron {
    transform: rotate(180deg);
}

.model-dropdown {
    position: absolute;
    bottom: calc(100% + 0.6rem);
    left: 0;
    background: var(--nav-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 0.9rem;
    padding: 0.4rem;
    min-width: 180px;
    box-shadow: var(--card-shadow);
    display: none;
    flex-direction: column;
    gap: 0.2rem;
    z-index: 2000;
    animation: dropdownFadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes dropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.95);
    }

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

.model-dropdown.open {
    display: flex;
}

.model-item {
    padding: 0.6rem 0.8rem;
    border-radius: 0.6rem;
    font-size: 0.78rem;
    color: var(--text-dim);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 500;
}

.model-item:hover:not(.disabled) {
    background: var(--nav-active-bg);
    color: var(--nav-active-text);
}

.model-item.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

.model-item.active {
    background: var(--nav-active-bg);
    color: var(--nav-active-text);
    font-weight: 700;
    order: 10;
}

.model-item.active::after {
    content: '✓';
    font-size: 0.75rem;
    font-weight: 900;
}

@media (max-width: 600px) {
    .model-name {
        max-width: none;
    }
}

.record-btn {
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text-dim);
    width: 3.2rem;
    height: 3.2rem;
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--card-shadow);
    flex-shrink: 0;
}

.record-btn:hover {
    background: var(--nav-active-bg);
    color: var(--accent);
    transform: scale(1.05);
}

.ai-avatar {
    width: 110px;
    height: 110px;
    background: var(--nav-active-bg, rgba(255, 255, 255, 0.03));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1.5px solid var(--border, rgba(255, 255, 255, 0.15));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3.2rem;
    box-shadow: var(--card-shadow);
    animation: float 6s infinite ease-in-out;
    color: var(--text-main);
    text-transform: uppercase;
    font-weight: 800;
    position: relative;
    z-index: 2;
    line-height: 1;
    flex-shrink: 0;
}

/* Artistic glow effect */
.ai-avatar::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: var(--accent-gradient);
    border-radius: 50%;
    filter: blur(25px);
    opacity: var(--avatar-glow-opacity, 0.4);
    z-index: -1;
    animation: pulse 4s infinite alternate ease-in-out;
}

.btn-send {
    background: transparent;
    color: var(--text-dim);
    border: 1px solid transparent;
    border-radius: 0.9rem;
    width: 2.75rem;
    height: 2.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    flex-shrink: 0;
}

.btn-send:hover:not(:disabled) {
    background: var(--nav-active-bg);
    border-color: var(--border);
    color: var(--text-main);
    transform: translateY(-1px);
}

.btn-send.has-text {
    background: var(--accent-gradient);
    color: var(--nav-bg);
    border: none;
    box-shadow: var(--accent-shadow, 0 4px 12px rgba(139, 92, 246, 0.3));
}

.btn-send.has-text:hover {
    transform: translateY(-2px);
    box-shadow: var(--accent-shadow-hover, 0 6px 16px rgba(139, 92, 246, 0.45));
}

.btn-send:disabled {
    background: var(--input-bg, rgba(255, 255, 255, 0.05));
    color: var(--text-dim);
    opacity: 0.4;
    box-shadow: none;
    cursor: not-allowed;
}

.btn-send svg {
    width: 18px;
    height: 18px;
}

textarea::placeholder {
    color: var(--text-dim);
    white-space: pre-wrap;
    transition: color 0.2s ease;
}

textarea:focus::placeholder {
    color: transparent;
}

.placeholder-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 4rem;
    padding: 0.65rem 0.85rem;
    color: var(--text-dim);
    pointer-events: none;
    white-space: nowrap;
    font-size: 1rem;
    line-height: 1.5;
    transition: opacity 0.4s ease, transform 0.4s ease;
    z-index: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.query-composer:focus-within .placeholder-overlay {
    opacity: 0 !important;
    pointer-events: none;
}

@media (max-width: 400px) {
    .hide-on-small {
        display: none !important;
    }
}

@media (max-width: 600px) {
    .input-wrapper {
        width: 100%;
        padding: 0.85rem 0.85rem 0.8rem;
        gap: 0.7rem;
        border-radius: 1.35rem;
        align-items: stretch;
    }

    .input-wrapper textarea {
        font-size: 0.9rem;
        min-height: 52px;
        max-height: 180px;
    }

    textarea::placeholder {
        text-align: left;
    }

    .query-toolbar {
        align-items: flex-end;
        gap: 0.65rem;
    }

    .query-hint {
        font-size: 0.7rem;
    }

    .btn-attach {
        width: 2.55rem;
        height: 2.55rem;
    }

    .btn-attach svg {
        width: 15px;
        height: 15px;
    }

    .btn-send {
        width: 2.55rem !important;
        height: 2.55rem !important;
        border-radius: 0.9rem !important;
        margin-bottom: 0 !important;
    }

    .btn-send svg {
        width: 15px;
        height: 15px;
    }

    .empty-state-hero h2 {
        font-size: 1.8rem;
    }

    .empty-state-hero p {
        font-size: 1rem;
    }
}

.btn-send:hover:not(:disabled) {
    transform: scale(1.1) rotate(-5deg);
}

.btn-send:disabled {
    background: #334155;
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

/* Typing Anim */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--success);
    box-shadow: 0 4px 14px var(--success-glow);
    border-radius: 50%;
    animation: dotBounce 1.4s infinite ease-in-out;
    opacity: 0.95;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dotBounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

.training-tip {
    margin: 0;
    background: none;
    border: none;
    padding: 0;
    opacity: 1;
}

.meta-row {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 0.75rem;
    margin-top: 0.5rem;
    width: 100%;
}

.meta-row .training-tip {
    margin-top: 0;
    padding: 0.35rem 0.6rem;
    border-radius: 0.6rem;
    display: flex;
    align-items: center;
    min-height: 1.75rem;
    height: 100%;
    box-sizing: border-box;
    white-space: nowrap;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: #6ee7b7;
}

.meta-row .training-tip .mobile-text {
    display: none;
}

.meta-row .training-tip a {
    color: #6ee7b7;
    text-decoration: none;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 0.5rem;
    background: rgba(0, 0, 0, 0.25);
    transition: all 0.2s;
}

.meta-row .training-tip a:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    transform: translateY(-1px);
}

.model-info {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    font-size: 0.75rem;
    color: var(--text-dim);
    opacity: 0.8;
    font-weight: 500;
    letter-spacing: 0.02em;
}

@media (max-width: 600px) {
    .model-info {
        opacity: 0.9;
        margin-top: 0.8rem;
        font-size: 0.65rem;
    }

    .placeholder-overlay {
        font-size: 0.85rem;
        padding: 0.5rem 0.75rem;
    }

    .user-card-marquee {
        padding: 0.3rem 0.75rem 0.3rem 0.3rem;
        gap: 0.5rem;
    }

    .user-card-marquee .avatar-letter {
        width: 26px;
        height: 26px;
        font-size: 0.75rem;
    }

    .user-card-marquee .username {
        font-size: 0.72rem;
    }

    .user-card-marquee .user-profession {
        font-size: 0.55rem;
    }
}

.model-info .separator {
    opacity: 0.4;
}

.chat-data-actions {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.chat-data-btn {
    background: var(--accent-gradient);
    color: #fff;
    border: none;
    border-radius: 0.9rem;
    padding: 0.75rem 1rem;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
    box-shadow: 0 8px 20px rgba(139, 92, 246, 0.25);
}

.chat-data-btn:hover {
    transform: translateY(-1px);
}

.chat-data-btn.secondary {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    box-shadow: none;
}

.mobile-brand-tag {
    display: none;
}

@media (max-width: 600px) {
    .mobile-brand-tag {
        display: none;
    }

    .mobile-menu-btn {
        width: 2.2rem;
        height: 2.2rem;
    }

    .mobile-menu {
        top: 3.5rem;
    }

    .ai-avatar {
        width: 60px;
        height: 60px;
        font-size: 1.8rem;
        border-radius: 1.2rem;
        flex-shrink: 0;
    }

    .empty-state-hero h2 {
        font-size: 1.5rem;
    }

    .input-area {
        position: relative;
        padding: 1rem 0 calc(1rem + env(safe-area-inset-bottom, 0px));
        background: var(--bg-main);
        z-index: 1000;
        margin-top: 0;
    }

    /* Remove the pseudo-element as box-shadow is more reliable and dynamic */

    .empty-state-hero p {
        font-size: 0.82rem;
        max-width: 100%;
        line-height: 1.5;
        margin-bottom: 0.5rem;
    }

    .message.bot,
    .message.user {
        padding: 0.85rem 1.15rem;
    }

    .message-content {
        font-size: 0.9rem;
    }

    .meta-row {
        display: none;
    }

    .meta-row .training-tip {
        display: none;
    }

    .meta-row .training-tip .desktop-text {
        display: none;
    }

    .meta-row .training-tip .mobile-text {
        display: inline;
    }

    .meta-main>span,
    .training-tip>a,
    .sponsor-add-btn {
        height: 22px !important;
        font-size: 0.65rem !important;
    }

    .desktop-text {
        display: none;
    }

    .model-info {
        font-size: 0.7rem;
        margin-top: 0.5rem;
        flex-wrap: nowrap;
        white-space: nowrap;
    }

    .chat-data-actions {
        flex-direction: column;
        gap: 0.5rem;
    }

    .chat-data-btn {
        width: 100%;
    }

    /* Performance optimization for low-RAM mobile (2GB) */
    .overlay,
    .card,
    .blur-bg,
    .model-dropdown,
    .context-menu,
    .user-card-marquee,
    .sponsor-msg,
    .message.bot,
    .input-wrapper {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        background-color: var(--modal-bg) !important;
        /* Fallback to theme base */
        box-shadow: var(--modal-card-shadow) !important;
    }

    .placeholder-overlay,
    .model-selector .model-name {
        color: var(--text-dim) !important;
        opacity: 0.5;
    }

    .ai-avatar {
        background: var(--nav-bg);
        border: 1px solid var(--border) !important;
        box-shadow: var(--card-shadow);
    }

    .ai-avatar::before {
        display: none !important;
    }

    body.is-home .ai-avatar {
        display: none !important;
    }

    .card {
        transform: translateZ(0);
        /* Hardware acceleration */
        backface-visibility: hidden;
    }

    /* Performance: Very subtle edge fade for mobile */
    .user-marquee-container {
        mask-image: linear-gradient(to right, transparent, black 10%, black 90%, transparent) !important;
        -webkit-mask-image: linear-gradient(to right, transparent, black 10%, black 90%, transparent) !important;
    }

    /* Keep pseudo-elements hidden on mobile to avoid double layering */
    .user-marquee-container::before,
    .user-marquee-container::after {
        display: none !important;
    }

    .suggested-questions {
        margin-top: 1rem !important;
    }
}

body.is-home .ai-avatar {
    display: none !important;
}

@media (max-width: 350px) {
    .model-info {
        flex-direction: column;
        gap: 0.2rem;
        white-space: normal;
    }

    .model-info .separator {
        display: none;
    }
}

.input-wrapper textarea {
    resize: none;
}

.input-wrapper textarea::-webkit-resizer {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
}

/* User Marquee */
#user-marquee-root {
    width: 100%;
    display: none;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#user-marquee-root.active {
    display: flex;
    min-height: 80px;
    /* Cadangan ruang stabil */
}

.user-marquee-container {
    width: 100%;
    max-width: 800px;
    /* Increased slightly for desktop */
    margin: 0.5rem auto 0;
    overflow: hidden;
    position: relative;
    mask-image: linear-gradient(to right, transparent, black 10%, black 90%, transparent);
    -webkit-mask-image: linear-gradient(to right, transparent, black 10%, black 90%, transparent);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

@media (max-width: 600px) {
    .user-marquee-container {
        margin-top: 0;
        /* Gap 2 reduced */
        margin-bottom: 0;
    }
}

.user-marquee-container::before,
.user-marquee-container::after {
    content: "";
    position: absolute;
    top: 0;
    width: 60px;
    height: 100%;
    z-index: 2;
    pointer-events: none;
    display: none;
    /* Hidden by default, optimized for desktop with mask-image */
}

@media (max-width: 768px) {
    .user-marquee-container {
        mask-image: linear-gradient(to right, transparent, black 8%, black 92%, transparent);
        -webkit-mask-image: linear-gradient(to right, transparent, black 8%, black 92%, transparent);
    }
}

.user-marquee-container.show {
    opacity: 1;
    transform: translateY(0);
}

.user-marquee-track {
    display: flex;
    gap: 1.25rem;
    white-space: nowrap;
    animation: marquee-scroll 45s linear infinite;
    width: max-content;
    padding: 10px 0;
    will-change: transform;
}

@media (max-width: 600px) {
    .user-marquee-track {
        gap: 0.75rem;
    }
}

.user-marquee-container:hover .user-marquee-track {
    animation-play-state: paused;
}

@keyframes marquee-scroll {
    from {
        transform: translate3d(0, 0, 0);
    }

    to {
        transform: translate3d(-50%, 0, 0);
    }
}

.user-card-marquee {
    background: var(--card-dark);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.4rem 1rem 0.4rem 0.4rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: all 0.3s ease;
    text-decoration: none;
    box-shadow: var(--card-shadow);
}

.user-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    text-align: left;
    gap: 1px;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.user-card-marquee:hover {
    background: var(--nav-active-bg);
    border-color: var(--accent);
    transform: translateY(-2px);
}

.user-card-marquee .avatar-letter {
    width: 32px;
    height: 32px;
    background: var(--accent-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    line-height: 1;
    color: white;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.user-card-marquee .username {
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-card-marquee .user-profession {
    font-size: 0.65rem;
    color: var(--text-dim);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.suggested-questions {
    display: none;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 1rem;
    margin-top: 2rem;
    width: 100%;
}

.question-chip {
    background: var(--card-dark);
    border: 1px solid var(--border);
    padding: 0.75rem 1.25rem;
    border-radius: 3rem;
    font-size: 0.95rem;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    font-weight: 600;
    box-shadow: var(--card-shadow);
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    max-width: 640px;
    display: block;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    text-align: left;
}

@media (max-width: 600px) {
    .question-chip {
        padding: 0.65rem 1rem;
        font-size: 0.85rem;
    }
}

@media (max-width: 360px) {
    .question-chip {
        padding: 0.55rem 0.85rem;
        font-size: 0.75rem;
    }
}

.question-chip:hover {
    background: var(--nav-active-bg);
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--card-shadow);
    color: var(--accent);
}

.question-chip:active {
    transform: translateY(0);
}

/* Global Loader Styles */
.global-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: var(--modal-overlay);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.global-loader.active {
    opacity: 1;
    pointer-events: all;
}

.global-loader .spinner {
    width: 50px;
    height: 50px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-left-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    box-shadow: var(--accent-shadow);
}

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

/* Hero Illustration - Harmonized Flow */
.hero-illustration {
    display: none;
    width: 100%;
    max-width: 380px;
    /* Increased desktop size */
    margin: 0 auto 0rem;
    opacity: 0.9;
    filter: none;
    transition: all 0.5s ease;
}

body.is-home .hero-illustration {
    display: block;
}

.hero-illustration img {
    width: 100%;
    height: auto;
    filter: drop-shadow(0 20px 40px rgba(99, 102, 241, 0.4));
    -webkit-mask-image: radial-gradient(ellipse at center, black 40%, transparent 70%);
    mask-image: radial-gradient(ellipse at center, black 40%, transparent 70%);
    mix-blend-mode: screen;
}

@media (max-width: 600px) {
    .hero-illustration {
        max-width: 200px;
        /* Increased from 110px for better visibility */
        margin-bottom: 0.1rem;
    }
}