/* Custom Global Layout Overrides for High End SPA Aesthetic */
.custom-scrollbar::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}
.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #1e2538;
    border-radius: 99px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: #3b82f6;
}

/* Markdown Styling Core Injector inside Response Bubble */
.markdown-body p {
    margin-bottom: 0.75rem;
    line-height: 1.6;
}
.markdown-body p:last-child {
    margin-bottom: 0;
}
.markdown-body ul, .markdown-body ol {
    margin-bottom: 0.75rem;
    padding-left: 1.25rem;
}
.markdown-body ul { list-style-type: disc; }
.markdown-body ol { list-style-type: decimal; }
.markdown-body li {
    margin-bottom: 0.25rem;
}
.markdown-body code {
    background-color: #1a1f36;
    padding: 0.15rem 0.35rem;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.85em;
    color: #f43f5e;
}
.markdown-body pre {
    background-color: #0f111a !important;
    padding: 1rem;
    border-radius: 12px;
    margin: 0.75rem 0;
    border: 1px solid #1e2538;
    overflow-x: auto;
}
.markdown-body pre code {
    background-color: transparent !important;
    padding: 0;
    color: inherit;
    font-size: 0.9rem;
}

/* Keyframe Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}
.animate-fade-in {
    animation: fadeIn 0.25s ease-out forwards;
}

/* Responsive hardening: keep the original dark enterprise layout, but prevent mobile click/overflow bugs. */
html,

.brand-home-link {
    cursor: pointer;
}

.brand-home-link:hover,
.brand-home-link:focus-visible {
    background: rgba(255, 255, 255, 0.05);
    outline: none;
}

.brand-home-link:active {
    transform: scale(0.985);
}

body {
    width: 100%;
    min-width: 0;
    height: 100%;
    min-height: 100dvh;
    overscroll-behavior: none;
}

body {
    touch-action: manipulation;
}

button,
[data-chat-id],
a,
textarea {
    -webkit-tap-highlight-color: transparent;
}

button:disabled {
    cursor: not-allowed;
}

#sidebar {
    will-change: transform;
}

#sidebar-overlay:not(.hidden) {
    display: block;
}

#chat-messages-container {
    scroll-padding-bottom: 8rem;
}

.chat-bubble-row {
    min-width: 0;
}

.markdown-body {
    min-width: 0;
    word-break: break-word;
}

.markdown-body table {
    display: block;
    width: max-content;
    max-width: 100%;
    overflow-x: auto;
    border-collapse: collapse;
}

.markdown-body blockquote {
    border-left: 3px solid #3b82f6;
    padding-left: 0.85rem;
    color: #cbd5e1;
    margin: 0.75rem 0;
}

.markdown-body a {
    color: #60a5fa;
    text-decoration: underline;
    text-underline-offset: 3px;
}

@media (max-width: 767px) {
    body.sidebar-is-open {
        overflow: hidden;
    }

    #chat-messages-container {
        padding-left: 0.875rem;
        padding-right: 0.875rem;
        padding-bottom: 9.5rem;
    }

    header {
        min-height: 4rem;
    }

    #current-chat-title {
        max-width: 42vw;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* Chat composer + bubble action hardening */
#chat-composer-shell {
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
}

#chat-input-form {
    max-height: 15rem;
}

#user-input {
    line-height: 1.5rem;
    overflow-y: auto;
}

.bubble-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.4rem;
    flex-wrap: wrap;
}

.bubble-action-btn,
.code-copy-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    background: rgba(15, 23, 42, 0.55);
    color: #94a3b8;
    font-size: 0.68rem;
    line-height: 1;
    padding: 0.45rem 0.65rem;
    transition: 160ms ease;
}

.bubble-action-btn:hover,
.code-copy-btn:hover {
    border-color: rgba(96, 165, 250, 0.35);
    color: #dbeafe;
    background: rgba(59, 130, 246, 0.12);
}

.user-bubble-group,
.assistant-bubble-group {
    min-width: 0;
}

.assistant-bubble-group > .markdown-body {
    overflow-wrap: anywhere;
}

.code-card {
    margin: 0.85rem 0;
    overflow: hidden;
    border: 1px solid #1e2538;
    border-radius: 0.95rem;
    background: #0b1020;
    max-width: 100%;
}

.code-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    border-bottom: 1px solid #1e2538;
    background: rgba(15, 23, 42, 0.75);
    padding: 0.55rem 0.7rem;
    color: #94a3b8;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.code-card-body {
    max-width: 100%;
    overflow-x: auto;
}

.markdown-body .code-card pre {
    margin: 0;
    border: 0;
    border-radius: 0;
    background-color: #0f111a !important;
}

.markdown-body .code-card pre code {
    white-space: pre;
}

@media (max-width: 767px) {
    main {
        min-width: 0;
    }

    #chat-composer-shell {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    #chat-input-form {
        border-radius: 1rem;
    }

    #submit-btn {
        width: 2.55rem;
        height: 2.55rem;
        flex: 0 0 2.55rem;
    }

    .bubble-action-btn,
    .code-copy-btn {
        padding: 0.42rem 0.58rem;
    }
}

/* Final mobile composer hardening + contextual user bubble actions */
* {
    box-sizing: border-box;
}

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

body {
    width: 100%;
    min-height: 100svh;
}

body > .flex,
main {
    max-width: 100%;
}

#chat-composer-shell {
    position: relative;
    width: 100%;
    max-width: 100%;
    flex: 0 0 auto;
}

#chat-input-form {
    width: 100%;
    max-width: min(48rem, calc(100vw - 1.5rem));
    min-width: 0;
    overflow: hidden;
}

#user-input {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.user-bubble-actions {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-3px);
    max-height: 0;
    margin-top: 0;
    overflow: hidden;
    transition: opacity 160ms ease, visibility 160ms ease, transform 160ms ease, max-height 160ms ease, margin-top 160ms ease;
}

.user-bubble-group:hover .user-bubble-actions,
.user-bubble-group:focus-within .user-bubble-actions,
.user-bubble-actions.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
    max-height: 3rem;
    margin-top: 0.4rem;
}

@media (max-width: 767px) {
    body,
    body > .flex {
        min-height: 100svh;
        height: 100svh;
        width: 100%;
    }

    main {
        width: 100%;
        min-width: 0;
        overflow: hidden;
    }

    #chat-composer-shell {
        padding: 0.625rem 0.625rem max(0.625rem, env(safe-area-inset-bottom));
    }

    #chat-input-form {
        max-width: 100%;
        gap: 0.5rem;
        padding: 0.5rem;
        border-radius: 1rem;
    }

    #user-input {
        padding-left: 0.65rem;
        padding-right: 0.25rem;
        font-size: 16px;
        max-height: 8.5rem;
    }

    #chat-messages-container {
        padding-bottom: 1rem;
    }

    .user-bubble-group {
        max-width: min(92%, calc(100vw - 1.75rem));
    }
}

/* Stable mobile app viewport: prevent header/composer jumping after send/focus changes. */
:root {
    --app-viewport-height: 100dvh;
}

#app-shell {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: var(--app-viewport-height);
    max-height: var(--app-viewport-height);
    overflow: hidden;
}

main > header {
    flex: 0 0 4rem;
    min-height: 4rem;
    transform: translateZ(0);
    will-change: auto;
}

#chat-messages-container {
    flex: 1 1 auto;
    min-height: 0;
    overflow-anchor: none;
    overscroll-behavior: contain;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
    contain: layout paint;
}

#chat-composer-shell {
    flex: 0 0 auto;
    transform: translateZ(0);
    will-change: auto;
}

/* Copy feedback must not resize buttons. Text stays "Salin" / "Salin kode", only the icon changes. */
.bubble-action-btn {
    min-width: 4.65rem;
    white-space: nowrap;
}

.code-copy-btn {
    min-width: 6.75rem;
    white-space: nowrap;
}

.bubble-action-btn.is-copied,
.code-copy-btn.is-copied {
    border-color: rgba(34, 197, 94, 0.35);
    color: #bbf7d0;
    background: rgba(34, 197, 94, 0.1);
}

@media (max-width: 767px) {
    html,
    body {
        height: var(--app-viewport-height);
        min-height: var(--app-viewport-height);
    }

    body > .flex,
    #app-shell {
        height: var(--app-viewport-height);
        min-height: var(--app-viewport-height);
    }

    main > header {
        flex-basis: 4rem;
    }

    #chat-messages-container {
        padding-bottom: 0.875rem;
    }
}

/* Assistant thinking state before the first streamed token arrives. */
.thinking-loader {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    color: #cbd5e1;
    font-size: 0.82rem;
    line-height: 1.5;
    white-space: nowrap;
}

.thinking-dots {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.thinking-dots i {
    width: 0.32rem;
    height: 0.32rem;
    border-radius: 999px;
    background: #60a5fa;
    opacity: 0.42;
    animation: thinkingDotPulse 1s ease-in-out infinite;
}

.thinking-dots i:nth-child(2) {
    animation-delay: 0.16s;
}

.thinking-dots i:nth-child(3) {
    animation-delay: 0.32s;
}



/* Stronger thinking-state contrast for both themes. */
.thinking-loader {
    color: var(--wutty-text-soft) !important;
    font-weight: 650;
}

html[data-resolved-theme="light"] .thinking-loader {
    color: #111827 !important;
}

html[data-resolved-theme="light"] .thinking-dots i {
    background: #2563eb !important;
    opacity: 0.78;
}

@keyframes thinkingDotPulse {
    0%, 80%, 100% {
        transform: translateY(0);
        opacity: 0.35;
    }
    40% {
        transform: translateY(-0.16rem);
        opacity: 1;
    }
}

.bubble-action-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.assistant-retry-btn {
    min-width: 4.55rem;
}

/* Production composer polish: readable default input, Android Chrome safe viewport, no clipped placeholder. */
#chat-composer-shell {
    background: linear-gradient(to top, #090b11 78%, rgba(9, 11, 17, 0.92) 93%, rgba(9, 11, 17, 0));
    padding-top: 0.65rem;
}

#chat-input-form {
    align-items: center;
    min-height: 3.65rem;
    padding: 0.5rem;
    border-radius: 1.15rem;
    background: linear-gradient(180deg, rgba(18, 22, 36, 0.98), rgba(15, 19, 32, 0.98));
    box-shadow: 0 18px 46px rgba(0, 0, 0, 0.30), inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

#user-input {
    display: block;
    min-height: 2.45rem;
    height: 2.45rem;
    max-height: 8.75rem;
    padding: 0.48rem 0.55rem 0.48rem 0.75rem;
    line-height: 1.45rem;
    font-size: 0.94rem;
    color: rgba(248, 250, 252, 0.96);
    caret-color: #60a5fa;
    scrollbar-gutter: stable;
    -webkit-text-fill-color: rgba(248, 250, 252, 0.96);
}

#user-input::placeholder {
    color: rgba(203, 213, 225, 0.68);
    opacity: 1;
    white-space: nowrap;
    -webkit-text-fill-color: rgba(203, 213, 225, 0.68);
}

#user-input:focus::placeholder {
    color: rgba(203, 213, 225, 0.50);
    -webkit-text-fill-color: rgba(203, 213, 225, 0.50);
}

#submit-btn {
    width: 2.55rem;
    height: 2.55rem;
    flex: 0 0 2.55rem;
    border-radius: 0.9rem;
}

#composer-helper-text {
    line-height: 1.15;
    padding-bottom: 0.02rem;
    margin-top: 0.45rem;
}

.chat-scroll-controls {
    position: absolute;
    right: clamp(0.7rem, 2vw, 1.15rem);
    bottom: calc(5.7rem + env(safe-area-inset-bottom));
    z-index: 12;
    display: flex;
    flex-direction: column;
    gap: 0.42rem;
    pointer-events: none;
}

.chat-scroll-btn {
    width: 2.28rem;
    height: 2.28rem;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    background: linear-gradient(180deg, rgba(20, 25, 42, 0.84), rgba(12, 16, 28, 0.78));
    color: rgba(226, 232, 240, 0.82);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.30), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    opacity: 0;
    transform: translateX(10px) scale(0.94);
    pointer-events: none;
    transition: opacity 180ms ease, transform 180ms ease, border-color 180ms ease, background 180ms ease, color 180ms ease, box-shadow 180ms ease;
}

.chat-scroll-btn i {
    font-size: 0.82rem;
}

.chat-scroll-btn.is-visible {
    opacity: 1;
    transform: translateX(0) scale(1);
    pointer-events: auto;
}

.chat-scroll-btn:hover,
.chat-scroll-btn:focus-visible {
    color: #ffffff;
    border-color: rgba(96, 165, 250, 0.46);
    background: linear-gradient(180deg, rgba(37, 99, 235, 0.42), rgba(29, 78, 216, 0.30));
    box-shadow: 0 16px 38px rgba(37, 99, 235, 0.18), 0 14px 34px rgba(0, 0, 0, 0.28);
    outline: none;
}

.chat-scroll-btn:active {
    transform: translateX(0) scale(0.95);
}

@media (max-width: 767px) {
    #app-shell {
        height: var(--app-viewport-height);
        max-height: var(--app-viewport-height);
    }

    #chat-composer-shell {
        padding: 0.62rem 0.78rem max(0.68rem, env(safe-area-inset-bottom));
    }

    #chat-input-form {
        max-width: 100%;
        min-height: 3.55rem;
        padding: 0.48rem;
        border-radius: 1.1rem;
    }

    #user-input {
        min-height: 2.35rem;
        height: 2.35rem;
        max-height: 8.4rem;
        padding: 0.42rem 0.45rem 0.42rem 0.72rem;
        line-height: 1.48rem;
        font-size: 16px;
    }

    #submit-btn {
        width: 2.48rem;
        height: 2.48rem;
        flex-basis: 2.48rem;
        border-radius: 0.88rem;
    }

    .chat-scroll-controls {
        right: 0.72rem;
        bottom: calc(5.72rem + env(safe-area-inset-bottom));
        gap: 0.4rem;
    }

    .chat-scroll-btn {
        width: 2.18rem;
        height: 2.18rem;
    }
}

@media (max-width: 380px) {
    #chat-composer-shell {
        padding-left: 0.65rem;
        padding-right: 0.65rem;
    }

    #user-input {
        padding-left: 0.75rem;
    }

    #submit-btn {
        width: 2.36rem;
        height: 2.36rem;
        flex-basis: 2.36rem;
    }
}

/* Chat room action menus: navbar + sidebar kebab modal. */
.nav-kebab-btn,
.chat-kebab-btn {
    width: 2.35rem;
    height: 2.35rem;
    border-radius: 0.85rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    border: 1px solid transparent;
    background: transparent;
    transition: 160ms ease;
}

.nav-kebab-btn:hover,
.nav-kebab-btn:focus-visible,
.chat-kebab-btn:hover,
.chat-kebab-btn:focus-visible {
    color: #e2e8f0;
    border-color: rgba(148, 163, 184, 0.16);
    background: rgba(255, 255, 255, 0.055);
    outline: none;
}

.chat-history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.72rem 0.66rem 0.72rem 0.78rem;
    border-radius: 0.9rem;
    cursor: pointer;
    color: #94a3b8;
    border: 1px solid transparent;
    transition: 160ms ease;
}

.chat-history-item:hover {
    color: #e5e7eb;
    background: rgba(18, 22, 36, 0.92);
}

.chat-history-item.is-active {
    color: #ffffff;
    background: rgba(37, 99, 235, 0.10);
    border-color: rgba(59, 130, 246, 0.20);
}

.chat-history-main {
    display: flex;
    align-items: center;
    gap: 0.62rem;
    min-width: 0;
    flex: 1;
}

.chat-kebab-btn {
    width: 2rem;
    height: 2rem;
    flex: 0 0 2rem;
    opacity: 1;
    position: relative;
    z-index: 2;
}

@media (min-width: 768px) {
    .chat-kebab-btn {
        opacity: 0;
        transform: translateX(3px);
    }

    .chat-history-item:hover .chat-kebab-btn,
    .chat-history-item:focus-within .chat-kebab-btn,
    .chat-history-item.is-active .chat-kebab-btn {
        opacity: 1;
        transform: translateX(0);
    }
}

.chat-action-modal {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0.85rem;
    background: rgba(0, 0, 0, 0.62);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.chat-action-sheet {
    width: 100%;
    max-width: 26rem;
    overflow: hidden;
    border-radius: 1.35rem;
    border: 1px solid rgba(148, 163, 184, 0.16);
    background: linear-gradient(180deg, rgba(18, 22, 36, 0.98), rgba(10, 14, 25, 0.98));
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.chat-action-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.chat-action-kicker {
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #60a5fa;
    font-weight: 700;
}

.chat-action-title {
    margin-top: 0.15rem;
    color: #f8fafc;
    font-size: 0.92rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-action-close {
    width: 2.1rem;
    height: 2.1rem;
    border-radius: 0.8rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    transition: 160ms ease;
}

.chat-action-close:hover,
.chat-action-close:focus-visible {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.06);
    outline: none;
}

.chat-action-list {
    padding: 0.45rem;
}

.chat-action-item {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    border-radius: 1rem;
    padding: 0.85rem 0.9rem;
    color: #dbe4f0;
    text-align: left;
    transition: 150ms ease;
}

.chat-action-item span {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    font-size: 0.84rem;
    font-weight: 650;
}

.chat-action-item span i {
    width: 1rem;
    color: #93c5fd;
}

.chat-action-item small {
    color: #64748b;
    font-size: 0.68rem;
    white-space: nowrap;
}

.chat-action-item:hover,
.chat-action-item:focus-visible {
    background: rgba(59, 130, 246, 0.10);
    color: #ffffff;
    outline: none;
}

.chat-action-item.is-danger {
    color: #fecaca;
}

.chat-action-item.is-danger span i {
    color: #f87171;
}

.chat-action-item.is-danger:hover,
.chat-action-item.is-danger:focus-visible {
    background: rgba(239, 68, 68, 0.10);
}

.chat-name-input {
    width: 100%;
    min-height: 2.85rem;
    border-radius: 0.95rem;
    border: 1px solid rgba(148, 163, 184, 0.18);
    background: rgba(8, 12, 22, 0.90);
    color: #f8fafc;
    padding: 0.75rem 0.9rem;
    font-size: 0.92rem;
    outline: none;
    transition: 160ms ease;
}

.chat-name-input:focus {
    border-color: rgba(96, 165, 250, 0.55);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

@media (min-width: 640px) {
    .chat-action-modal {
        align-items: center;
    }
}

@media (max-width: 767px) {
    .nav-kebab-btn {
        width: 2.25rem;
        height: 2.25rem;
    }

    .chat-action-modal {
        padding: 0.75rem 0.75rem max(0.75rem, env(safe-area-inset-bottom));
    }

    .chat-action-sheet {
        max-width: 100%;
        border-radius: 1.18rem;
    }
}

/* Scroll memory + dynamic composer-safe floating controls. */
:root {
    --composer-height: 5.8rem;
    --keyboard-safe-bottom: env(safe-area-inset-bottom);
}

.chat-scroll-controls {
    bottom: calc(var(--composer-height, 5.8rem) + 0.9rem + var(--keyboard-safe-bottom));
    transition: opacity 160ms ease, right 180ms ease, transform 180ms ease;
}

.chat-scroll-controls.is-composer-expanded {
    bottom: calc(var(--composer-height, 7.8rem) + 0.75rem + var(--keyboard-safe-bottom));
}

#chat-messages-container {
    scroll-behavior: smooth;
}

@media (max-width: 767px) {
    #chat-composer-shell {
        position: relative;
        z-index: 14;
    }

    .chat-scroll-controls,
    .chat-scroll-controls.is-composer-expanded {
        right: 0.72rem;
        bottom: calc(var(--composer-height, 5.7rem) + 0.7rem + var(--keyboard-safe-bottom));
    }

    .chat-scroll-controls.is-composer-expanded {
        transform: none;
    }

    #chat-messages-container {
        padding-bottom: 0.9rem;
    }
}

@supports (height: 100dvh) {
    #app-shell {
        min-height: var(--app-viewport-height);
    }
}

/* Header-centered toast: forced to the real visual center of the header/nav.
   Important: generic fadeIn used by other UI changes transform, so toast uses its own animation. */
@keyframes toastHeaderCenterIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-8px) scale(0.97); }
    to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

.app-toast {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 4.65rem);
    left: 50%;
    right: auto;
    bottom: auto;
    transform: translateX(-50%);
    z-index: 70;
    width: fit-content;
    max-width: min(calc(100vw - 1rem), 520px);
    min-height: 2.35rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    padding: 0.55rem 0.86rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(12, 18, 32, 0.96);
    color: #f8fafc;
    box-shadow: 0 18px 46px rgba(0, 0, 0, 0.42);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    pointer-events: none;
    text-align: center;
    animation: toastHeaderCenterIn 0.2s ease-out forwards !important;
}

.app-toast-error {
    border-color: rgba(248, 113, 113, 0.42);
    background: rgba(69, 10, 10, 0.96);
    color: #fee2e2;
}

.app-toast-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.35rem;
    height: 1.35rem;
    flex: 0 0 1.35rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.11);
    font-size: 0.68rem;
}

.app-toast-text {
    min-width: 0;
    max-width: 100%;
    overflow: visible;
    text-overflow: unset;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: normal;
    font-size: 0.76rem;
    line-height: 1.18rem;
    font-weight: 800;
    letter-spacing: -0.012em;
}

@media (max-width: 767px) {
    .app-toast {
        top: calc(env(safe-area-inset-top, 0px) + 4.4rem);
        left: 50%;
        width: auto;
        min-width: 0;
        max-width: calc(100vw - 0.75rem);
        min-height: 2.25rem;
        gap: 0.42rem;
        padding: 0.48rem 0.62rem;
        border-radius: 1rem;
    }

    .app-toast-icon {
        width: 1.14rem;
        height: 1.14rem;
        flex-basis: 1.14rem;
        font-size: 0.58rem;
    }

    .app-toast-text {
        font-size: clamp(0.68rem, 3.2vw, 0.76rem);
        line-height: 1.02rem;
        max-width: calc(100vw - 3.4rem);
        display: block;
        overflow: visible;
        -webkit-line-clamp: unset;
        -webkit-box-orient: unset;
    }
}

@media (max-width: 360px) {
    .app-toast {
        max-width: calc(100vw - 0.45rem);
        padding-left: 0.48rem;
        padding-right: 0.48rem;
    }

    .app-toast-text {
        font-size: 0.64rem;
        line-height: 0.94rem;
        max-width: calc(100vw - 3rem);
    }
}

/* Assistant learning feedback controls: like/dislike + correction flow */
.learning-action-btn {
    min-width: 4.35rem;
}

.learning-action-btn[data-assistant-feedback="dislike"] {
    min-width: 5.4rem;
}

.learning-action-btn.is-active {
    border-color: rgba(96, 165, 250, 0.48);
    color: #dbeafe;
    background: rgba(59, 130, 246, 0.16);
}

.learning-action-btn[data-assistant-feedback="dislike"].is-active {
    border-color: rgba(251, 146, 60, 0.48);
    color: #fed7aa;
    background: rgba(249, 115, 22, 0.14);
}

.learning-action-btn.is-loading {
    opacity: 0.68;
    cursor: wait;
}

.correction-sheet textarea::placeholder {
    color: rgba(148, 163, 184, 0.72);
}

@media (max-width: 520px) {
    .assistant-bubble-group .bubble-actions {
        gap: 0.32rem;
        margin-top: 0.5rem;
    }

    .assistant-bubble-group .bubble-action-btn {
        min-width: auto;
        flex: 0 1 auto;
        padding: 0.42rem 0.55rem;
        font-size: 0.64rem;
    }

    .assistant-bubble-group .learning-action-btn[data-assistant-feedback="dislike"] {
        min-width: auto;
    }
}

@media (max-width: 360px) {
    .assistant-bubble-group .bubble-action-btn {
        gap: 0.26rem;
        padding-inline: 0.48rem;
        font-size: 0.61rem;
    }

    .assistant-bubble-group .bubble-action-btn i {
        font-size: 0.68rem;
    }
}

/* Vision upload composer: modern responsive image input without disturbing old chat controls */
.composer-input-row {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    width: 100%;
    min-width: 0;
}

.composer-plus-btn {
    width: 2.5rem;
    height: 2.5rem;
    flex: 0 0 2.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.9rem;
    border: 1px solid rgba(148, 163, 184, 0.16);
    background: rgba(15, 23, 42, 0.76);
    color: #cbd5e1;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
    transition: 180ms ease;
}

.composer-plus-btn:hover,
.composer-plus-btn:focus-visible {
    border-color: rgba(96, 165, 250, 0.4);
    background: rgba(59, 130, 246, 0.14);
    color: #eff6ff;
    outline: none;
}

.composer-plus-btn:active {
    transform: scale(0.96);
}

.image-preview-tray {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    overflow-x: auto;
    padding: 0.1rem 0.15rem 0.2rem;
    max-width: 100%;
}

.image-preview-tray.hidden {
    display: none;
}

.composer-image-preview {
    position: relative;
    width: 4.25rem;
    height: 4.25rem;
    flex: 0 0 4.25rem;
    overflow: hidden;
    border-radius: 1rem;
    border: 1px solid rgba(148, 163, 184, 0.2);
    background: #0b1020;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.24);
}

.composer-image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.composer-image-preview button {
    position: absolute;
    top: 0.28rem;
    right: 0.28rem;
    width: 1.35rem;
    height: 1.35rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(2, 6, 23, 0.82);
    color: #f8fafc;
    font-size: 0.68rem;
    backdrop-filter: blur(10px);
}

.message-image-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.45rem;
    margin-bottom: 0.65rem;
    max-width: min(21rem, 76vw);
}

.message-image-grid.single {
    grid-template-columns: minmax(0, 1fr);
    max-width: min(18rem, 72vw);
}

.message-image-link {
    display: block;
    overflow: hidden;
    border-radius: 0.9rem;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(15, 23, 42, 0.38);
}

.message-image-link img {
    display: block;
    width: 100%;
    height: 8rem;
    object-fit: cover;
}

.message-image-grid.single .message-image-link img {
    height: auto;
    max-height: 16rem;
}

.modal-is-open {
    overflow: hidden;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.68);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.modal-backdrop.hidden {
    display: none;
}

.modal-card {
    width: min(100%, 30rem);
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 1.45rem;
    background: linear-gradient(180deg, rgba(18, 22, 36, 0.98), rgba(9, 11, 17, 0.98));
    color: #f8fafc;
    box-shadow: 0 28px 90px rgba(0, 0, 0, 0.48);
}

.modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1rem 0.8rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.modal-head h3 {
    font-size: 0.95rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.modal-eyebrow {
    margin-bottom: 0.18rem;
    color: #60a5fa;
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.modal-close-btn {
    width: 2rem;
    height: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 2rem;
    border-radius: 0.8rem;
    color: #94a3b8;
    transition: 160ms ease;
}

.modal-close-btn:hover {
    background: rgba(255, 255, 255, 0.07);
    color: #fff;
}

.upload-drop-zone {
    margin: 1rem;
    padding: 1.25rem;
    border: 1px dashed rgba(96, 165, 250, 0.35);
    border-radius: 1.25rem;
    background: radial-gradient(circle at top, rgba(59, 130, 246, 0.13), transparent 58%), rgba(15, 23, 42, 0.48);
    text-align: center;
    cursor: pointer;
    transition: 180ms ease;
}

.upload-drop-zone:hover {
    border-color: rgba(147, 197, 253, 0.58);
    background-color: rgba(30, 41, 59, 0.52);
}

.upload-drop-icon {
    width: 3.1rem;
    height: 3.1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.7rem;
    border-radius: 1.1rem;
    background: rgba(59, 130, 246, 0.14);
    color: #93c5fd;
    font-size: 1.25rem;
}

.upload-drop-title {
    font-size: 0.9rem;
    font-weight: 800;
}

.upload-drop-desc {
    max-width: 20rem;
    margin: 0.35rem auto 0.9rem;
    color: #94a3b8;
    font-size: 0.74rem;
    line-height: 1.15rem;
}

.upload-select-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    min-height: 2.35rem;
    padding: 0 0.9rem;
    border-radius: 999px;
    background: #2563eb;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 800;
    box-shadow: 0 14px 35px rgba(37, 99, 235, 0.25);
}

@media (min-width: 640px) {
    .modal-backdrop {
        align-items: center;
    }
}

@media (max-width: 520px) {
    #chat-input-form {
        border-radius: 1.15rem;
    }

    .composer-input-row {
        gap: 0.42rem;
    }

    .composer-plus-btn,
    #submit-btn {
        width: 2.35rem;
        height: 2.35rem;
        flex-basis: 2.35rem;
        border-radius: 0.82rem;
    }

    .composer-image-preview {
        width: 3.85rem;
        height: 3.85rem;
        flex-basis: 3.85rem;
    }

    .message-image-link img {
        height: 6.8rem;
    }

    .modal-backdrop {
        padding: 0.75rem;
        padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
    }
}

.auth-account-btn {
    min-height: 2.35rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    border: 1px solid rgba(59, 130, 246, 0.18);
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.10), rgba(15, 23, 42, 0.78));
    color: #dbeafe;
    border-radius: 999px;
    padding: 0.52rem 0.72rem;
    font-size: 0.72rem;
    font-weight: 700;
    max-width: 12rem;
    transition: transform .18s ease, border-color .18s ease, background .18s ease;
}

.auth-account-btn span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.auth-account-btn:hover,
.auth-account-btn.is-logged-in {
    border-color: rgba(96, 165, 250, 0.45);
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.28), rgba(15, 23, 42, 0.92));
    transform: translateY(-1px);
}

.auth-sheet {
    width: min(94vw, 30rem);
    max-height: min(92vh, 44rem);
    overflow: hidden auto;
    border: 1px solid var(--brand-border, #1e2538);
    border-radius: 1.4rem;
    background: radial-gradient(circle at top left, rgba(59, 130, 246, 0.16), transparent 38%), #121624;
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.48);
}

.auth-body {
    padding: 1rem;
}

.auth-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
    padding: 0.28rem;
    border: 1px solid rgba(148, 163, 184, 0.12);
    border-radius: 1rem;
    background: rgba(2, 6, 23, 0.35);
    margin-bottom: 0.85rem;
}

.auth-tabs button {
    border: 0;
    border-radius: 0.78rem;
    color: #94a3b8;
    padding: 0.7rem;
    font-size: 0.78rem;
    font-weight: 800;
    transition: background .18s ease, color .18s ease;
}

.auth-tabs button.is-active {
    color: #fff;
    background: linear-gradient(135deg, #2563eb, #4f46e5);
    box-shadow: 0 12px 24px rgba(37, 99, 235, 0.20);
}

.auth-form {
    display: grid;
    gap: 0.72rem;
}

.auth-form label {
    display: grid;
    gap: 0.35rem;
    color: #cbd5e1;
    font-size: 0.72rem;
    font-weight: 800;
}

.auth-form input:not([type="checkbox"]) {
    width: 100%;
    border: 1px solid rgba(148, 163, 184, 0.16);
    outline: none;
    border-radius: 0.95rem;
    background: rgba(2, 6, 23, 0.55);
    color: #f8fafc;
    padding: 0.82rem 0.9rem;
    font-size: 0.86rem;
}

.auth-form input:focus {
    border-color: rgba(59, 130, 246, 0.72);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.10);
}

.auth-check {
    display: flex !important;
    grid-template-columns: none !important;
    align-items: flex-start;
    gap: 0.55rem !important;
    color: #94a3b8 !important;
    font-weight: 600 !important;
    line-height: 1.35;
}

.auth-check input {
    margin-top: 0.12rem;
    accent-color: #2563eb;
}

.auth-submit-btn,
.auth-danger-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    border: 0;
    border-radius: 1rem;
    padding: 0.86rem 1rem;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 900;
    background: linear-gradient(135deg, #2563eb, #4f46e5);
    box-shadow: 0 16px 32px rgba(37, 99, 235, 0.22);
}

.auth-submit-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.auth-danger-btn {
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.95), rgba(127, 29, 29, 0.95));
    box-shadow: 0 16px 32px rgba(220, 38, 38, 0.16);
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #64748b;
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .06em;
    margin: 0.85rem 0;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    height: 1px;
    flex: 1;
    background: rgba(148, 163, 184, 0.14);
}

.google-signin-slot {
    min-height: 2.75rem;
    display: flex;
    justify-content: center;
    overflow: hidden;
}


.google-oauth-redirect-btn {
    width: min(100%, 22.5rem);
    min-height: 2.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    background: rgba(15, 23, 42, 0.88);
    color: #f8fafc;
    font-size: 0.86rem;
    font-weight: 800;
    text-decoration: none;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.google-oauth-redirect-btn:hover {
    transform: translateY(-1px);
    border-color: rgba(96, 165, 250, 0.58);
    background: rgba(30, 41, 59, 0.96);
}

html[data-theme="light"] .google-oauth-redirect-btn,
html.theme-light .google-oauth-redirect-btn {
    background: #ffffff;
    color: #111827;
    border-color: rgba(15, 23, 42, 0.14);
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.10);
}

html[data-theme="light"] .google-oauth-redirect-btn:hover,
html.theme-light .google-oauth-redirect-btn:hover {
    background: #f8fafc;
    border-color: rgba(37, 99, 235, 0.35);
}

.auth-note {
    margin-top: 0.85rem;
    color: #94a3b8;
    font-size: 0.74rem;
    line-height: 1.55;
}

.auth-profile-card {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    border: 1px solid rgba(148, 163, 184, 0.14);
    background: rgba(2, 6, 23, 0.36);
    border-radius: 1.05rem;
    padding: 0.9rem;
}

.auth-profile-card strong,
.auth-profile-card span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.auth-profile-card strong {
    color: #f8fafc;
    font-size: 0.9rem;
}

.auth-profile-card span {
    color: #94a3b8;
    font-size: 0.74rem;
    margin-top: 0.12rem;
}

.auth-avatar {
    width: 2.6rem;
    height: 2.6rem;
    border-radius: 0.9rem;
    flex: 0 0 auto;
    overflow: hidden;
    display: grid;
    place-items: center;
    color: #bfdbfe;
    background: linear-gradient(135deg, rgba(37, 99, 235, .35), rgba(15, 23, 42, .85));
    border: 1px solid rgba(96, 165, 250, 0.24);
}

.auth-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.auth-initial {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    border-radius: inherit;
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: #e0f2fe;
    background: radial-gradient(circle at 30% 18%, rgba(255,255,255,.22), transparent 34%), linear-gradient(135deg, rgba(37,99,235,.88), rgba(14,165,233,.46));
    box-shadow: inset 0 1px 0 rgba(255,255,255,.18);
}

.auth-account-btn .auth-initial,
.auth-account-btn img {
    width: 1.15rem;
    height: 1.15rem;
    flex: 0 0 1.15rem;
    border-radius: 999px;
    object-fit: cover;
}

.auth-account-btn .auth-initial {
    font-size: .62rem;
}

@media (max-width: 520px) {
    .auth-account-btn {
        width: 2.35rem;
        padding: 0;
        border-radius: 0.85rem;
    }

    .auth-account-btn span {
        display: none !important;
    }

    .auth-sheet {
        width: 100%;
        border-radius: 1.2rem 1.2rem 0 0;
    }
}

/* Brand assets from server-side config (.env URL/path support) */
.brand-logo-box {
    isolation: isolate;
    background: transparent !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

.brand-logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    background: transparent !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

.welcome-hero-image {
    display: block;
    background: transparent !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

.welcome-hero-image.is-logo {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    object-position: center center;
    padding: 0;
}

.welcome-logo-stack {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
}

.welcome-theme-logo {
    position: absolute;
    inset: 0;
    margin: auto;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 160ms ease, visibility 160ms ease;
}

.welcome-theme-logo[hidden] {
    display: none !important;
}

.welcome-theme-logo.is-active-theme-logo,
html[data-resolved-theme="dark"] .welcome-hero-image-dark,
html[data-resolved-theme="light"] .welcome-hero-image-light {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

html[data-resolved-theme="dark"] .welcome-hero-image-light,
html[data-resolved-theme="light"] .welcome-hero-image-dark {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.welcome-hero-logo {
    position: relative;
    display: grid;
    place-items: center;
    margin-inline: auto;
    background: transparent !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

/* Theme engine + AI avatar from runtime config. Dark theme remains the default baseline. */
:root {
    --wutty-bg: #090b11;
    --wutty-bg-soft: #0d101b;
    --wutty-surface: #121624;
    --wutty-surface-2: #0f1320;
    --wutty-border: #1e2538;
    --wutty-text: #f8fafc;
    --wutty-text-soft: #cbd5e1;
    --wutty-text-muted: #94a3b8;
    --wutty-text-faint: #64748b;
    --wutty-accent: #3b82f6;
    --wutty-accent-soft: rgba(59, 130, 246, 0.13);
    --wutty-danger: #f87171;
    --wutty-shadow: rgba(0, 0, 0, 0.42);
    --wutty-composer-gradient: linear-gradient(to top, #090b11 78%, rgba(9, 11, 17, 0.92) 93%, rgba(9, 11, 17, 0));
    --wutty-card-gradient: linear-gradient(180deg, rgba(18, 22, 36, 0.98), rgba(15, 19, 32, 0.98));
}

html[data-resolved-theme="light"] {
    --wutty-bg: #f5f7fb;
    --wutty-bg-soft: #eef2f8;
    --wutty-surface: #ffffff;
    --wutty-surface-2: #f8fafc;
    --wutty-border: #dfe5ef;
    --wutty-text: #0f172a;
    --wutty-text-soft: #334155;
    --wutty-text-muted: #475569;
    --wutty-text-faint: #64748b;
    --wutty-accent: #2563eb;
    --wutty-accent-soft: rgba(37, 99, 235, 0.10);
    --wutty-danger: #dc2626;
    --wutty-shadow: rgba(15, 23, 42, 0.12);
    --wutty-composer-gradient: linear-gradient(to top, #f5f7fb 78%, rgba(245, 247, 251, 0.94) 93%, rgba(245, 247, 251, 0));
    --wutty-card-gradient: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.98));
}

body,
.bg-brand-bg,
main.bg-brand-bg {
    background-color: var(--wutty-bg) !important;
    color: var(--wutty-text) !important;
}

.bg-brand-surface,
#chat-input-form,
.assistant-bubble-group .markdown-body {
    background-color: var(--wutty-surface) !important;
}

.border-brand-border,
#chat-input-form,
.assistant-bubble-group .markdown-body,
.code-card,
.code-card-head {
    border-color: var(--wutty-border) !important;
}

.text-gray-100,
.text-gray-200,
.text-white,
.markdown-body,
.chat-action-title,
.auth-profile-card strong,
.upload-drop-title,
.modal-head h3 {
    color: var(--wutty-text) !important;
}

.text-gray-300,
.text-gray-400,
.text-gray-500,
.auth-note,
.upload-drop-desc,
.chat-action-item small,
.auth-form label,
.auth-profile-card span {
    color: var(--wutty-text-muted) !important;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--wutty-border) 88%, var(--wutty-accent));
}

main > header {
    background: color-mix(in srgb, var(--wutty-bg) 86%, transparent) !important;
    border-color: var(--wutty-border) !important;
}

#sidebar {
    background: var(--wutty-bg) !important;
    border-color: var(--wutty-border) !important;
}

#sidebar .border-b,
#sidebar .border-t,
header.border-b {
    border-color: var(--wutty-border) !important;
}

#sidebar .bg-[#0d101b] {
    background: var(--wutty-bg-soft) !important;
}

.brand-home-link:hover,
.brand-home-link:focus-visible,
.nav-kebab-btn:hover,
.nav-kebab-btn:focus-visible,
.chat-kebab-btn:hover,
.chat-kebab-btn:focus-visible,
.chat-action-close:hover,
.chat-action-close:focus-visible {
    background: color-mix(in srgb, var(--wutty-accent) 10%, transparent) !important;
    color: var(--wutty-text) !important;
}

#chat-composer-shell {
    background: var(--wutty-composer-gradient) !important;
}

#chat-input-form,
.modal-card,
.chat-action-sheet,
.auth-sheet {
    background: var(--wutty-card-gradient) !important;
    border-color: var(--wutty-border) !important;
    box-shadow: 0 26px 70px var(--wutty-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.06) !important;
}

#user-input,
.chat-name-input,
.auth-form input:not([type="checkbox"]) {
    color: var(--wutty-text) !important;
    background: transparent !important;
    -webkit-text-fill-color: var(--wutty-text) !important;
}

.chat-name-input,
.auth-form input:not([type="checkbox"]) {
    background: color-mix(in srgb, var(--wutty-surface-2) 86%, transparent) !important;
    border-color: color-mix(in srgb, var(--wutty-border) 86%, var(--wutty-accent)) !important;
}

#user-input::placeholder,
.chat-name-input::placeholder,
.auth-form input::placeholder {
    color: var(--wutty-text-muted) !important;
    -webkit-text-fill-color: var(--wutty-text-muted) !important;
}

.bubble-action-btn,
.code-copy-btn,
.composer-plus-btn,
.chat-scroll-btn,
.auth-account-btn,
.chat-history-item {
    border-color: color-mix(in srgb, var(--wutty-border) 75%, transparent) !important;
    background: color-mix(in srgb, var(--wutty-surface) 82%, transparent) !important;
    color: var(--wutty-text-muted) !important;
}

.bubble-action-btn:hover,
.code-copy-btn:hover,
.composer-plus-btn:hover,
.chat-scroll-btn:hover,
.auth-account-btn:hover,
.auth-account-btn.is-logged-in,
.chat-history-item:hover,
.chat-history-item.is-active {
    border-color: color-mix(in srgb, var(--wutty-accent) 48%, var(--wutty-border)) !important;
    background: var(--wutty-accent-soft) !important;
    color: var(--wutty-text) !important;
}

.chat-action-head,
.modal-head,
.code-card-head {
    border-color: color-mix(in srgb, var(--wutty-border) 86%, transparent) !important;
    background: color-mix(in srgb, var(--wutty-surface-2) 70%, transparent) !important;
}

.chat-action-item {
    color: var(--wutty-text-soft) !important;
}

.chat-action-item:hover,
.chat-action-item:focus-visible {
    background: var(--wutty-accent-soft) !important;
    color: var(--wutty-text) !important;
}

.chat-action-item.is-danger {
    color: color-mix(in srgb, var(--wutty-danger) 82%, var(--wutty-text)) !important;
}

.markdown-body code {
    background-color: color-mix(in srgb, var(--wutty-surface-2) 88%, var(--wutty-accent)) !important;
}

.markdown-body pre,
.markdown-body .code-card pre,
.code-card,
.composer-image-preview {
    background: color-mix(in srgb, var(--wutty-surface-2) 90%, #020617) !important;
    border-color: var(--wutty-border) !important;
}

.modal-backdrop,
.chat-action-modal {
    background: rgba(2, 6, 23, 0.58) !important;
}

.upload-drop-zone {
    background: radial-gradient(circle at top, color-mix(in srgb, var(--wutty-accent) 16%, transparent), transparent 58%), color-mix(in srgb, var(--wutty-surface-2) 76%, transparent) !important;
    border-color: color-mix(in srgb, var(--wutty-accent) 40%, var(--wutty-border)) !important;
}

.app-toast {
    background: color-mix(in srgb, var(--wutty-surface) 94%, transparent) !important;
    color: var(--wutty-text) !important;
    border-color: color-mix(in srgb, var(--wutty-border) 75%, transparent) !important;
}

/* Theme switcher inside menu sheets */
.theme-switcher {
    padding: 0.85rem 0.9rem 0.45rem;
    border-bottom: 1px solid color-mix(in srgb, var(--wutty-border) 82%, transparent);
}

.theme-switcher-label {
    margin-bottom: 0.55rem;
    color: var(--wutty-text-muted);
    font-size: 0.68rem;
    font-weight: 850;
    letter-spacing: 0.075em;
    text-transform: uppercase;
}

.theme-switcher-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.45rem;
}

.theme-choice-btn {
    min-width: 0;
    display: grid;
    place-items: center;
    gap: 0.2rem;
    min-height: 4.25rem;
    border-radius: 1rem;
    border: 1px solid color-mix(in srgb, var(--wutty-border) 86%, transparent);
    background: color-mix(in srgb, var(--wutty-surface-2) 84%, transparent);
    color: var(--wutty-text-muted);
    padding: 0.52rem 0.35rem;
    transition: 160ms ease;
}

.theme-choice-btn i {
    color: var(--wutty-accent);
    font-size: 0.92rem;
}

.theme-choice-btn span {
    color: var(--wutty-text-soft);
    font-size: 0.74rem;
    font-weight: 850;
}

.theme-choice-btn small {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--wutty-text-faint);
    font-size: 0.59rem;
}

.theme-choice-btn:hover,
.theme-choice-btn:focus-visible,
.theme-choice-btn.is-active {
    border-color: color-mix(in srgb, var(--wutty-accent) 56%, var(--wutty-border));
    background: var(--wutty-accent-soft);
    color: var(--wutty-text);
    outline: none;
}

.theme-choice-btn.is-active {
    box-shadow: 0 12px 28px color-mix(in srgb, var(--wutty-accent) 16%, transparent);
}

/* Adaptive AI avatar. One image path works in both modes, robot icon remains fallback. */
.ai-avatar {
    position: relative;
    overflow: visible;
    isolation: isolate;
    background: transparent !important;
    border: 0 !important;
    color: #60a5fa !important;
    box-shadow: none !important;
}

.ai-avatar::before {
    content: none;
}

.ai-avatar-ring {
    position: absolute;
    inset: -3px;
    z-index: 0;
    display: none;
    border-radius: 0.85rem;
    background: conic-gradient(from 0deg, #38bdf8, #8b5cf6, #22c55e, #38bdf8);
    opacity: 0;
    pointer-events: none;
    animation: aiAvatarRingSpin 1.15s linear infinite;
    filter: drop-shadow(0 0 9px rgba(56, 189, 248, 0.24));
}

.ai-avatar.is-loading.is-ring-typing .ai-avatar-ring {
    display: block;
    opacity: 0.92;
}

.ai-avatar-img,
.ai-avatar-theme-stack,
.ai-avatar-fallback-icon {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
}

.ai-avatar-theme-stack {
    position: absolute;
    inset: 0;
    display: block;
}

.ai-avatar-theme-image {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    padding: 0;
    border-radius: inherit;
    filter: brightness(1.25) contrast(1.06) saturate(1.05);
}

.ai-avatar.is-ring-typing .ai-avatar-img,
.ai-avatar.is-ring-typing .ai-avatar-theme-image,
.ai-avatar.is-ring-typing .ai-avatar-fallback-icon {
    animation: none !important;
}

.ai-avatar-fallback-icon {
    display: none !important;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    color: #60a5fa;
}

.ai-avatar:not(.has-avatar-error) > .fa-robot:not(.ai-avatar-fallback-icon) {
    position: relative;
    z-index: 2;
}

.ai-avatar.has-avatar-error .ai-avatar-img,
.ai-avatar.has-avatar-error .ai-avatar-theme-image {
    display: none !important;
}

.ai-avatar.has-avatar-error .ai-avatar-fallback-icon {
    display: inline-flex !important;
}

html[data-resolved-theme="light"] .ai-avatar {
    background: transparent !important;
    border-color: transparent !important;
    color: #1d4ed8 !important;
    box-shadow: none !important;
}

html[data-resolved-theme="light"] .ai-avatar-ring {
    filter: drop-shadow(0 0 8px rgba(37, 99, 235, 0.16));
}

html[data-resolved-theme="light"] .ai-avatar-img,
html[data-resolved-theme="light"] .ai-avatar-theme-image {
    filter: brightness(0.95) contrast(1.12) saturate(1.06) drop-shadow(0 1px 1px rgba(15, 23, 42, 0.10));
}

html[data-resolved-theme="light"] .ai-avatar-fallback-icon,
html[data-resolved-theme="light"] .ai-avatar:not(.has-avatar-error) > .fa-robot:not(.ai-avatar-fallback-icon) {
    color: #2563eb;
}

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

html[data-resolved-theme="light"] .bg-gradient-to-r.from-white,
html[data-resolved-theme="light"] .bg-gradient-to-r.from-white.via-gray-200.to-gray-500 {
    background-image: linear-gradient(to right, #0f172a, #2563eb, #64748b) !important;
}

html[data-resolved-theme="light"] .from-brand-bg,
html[data-resolved-theme="light"] .via-brand-bg\/95 {
    --tw-gradient-from: var(--wutty-bg) var(--tw-gradient-from-position) !important;
    --tw-gradient-to: rgba(245, 247, 251, 0) var(--tw-gradient-to-position) !important;
    --tw-gradient-stops: var(--tw-gradient-from), rgba(245, 247, 251, .95) var(--tw-gradient-via-position), var(--tw-gradient-to) !important;
}

html[data-resolved-theme="light"] .app-toast-error {
    background: rgba(254, 242, 242, 0.96) !important;
    color: #7f1d1d !important;
    border-color: rgba(220, 38, 38, 0.26) !important;
}

html[data-resolved-theme="light"] .auth-tabs {
    background: #eef2f8 !important;
    border-color: #dfe5ef !important;
}

html[data-resolved-theme="light"] .auth-tabs button {
    color: #64748b !important;
}

html[data-resolved-theme="light"] .auth-tabs button.is-active {
    color: #ffffff !important;
}

@media (max-width: 420px) {
    .theme-choice-btn small {
        display: none;
    }

    .theme-choice-btn {
        min-height: 3.45rem;
    }
}

/* Composer stability + stop generation control (production hardening). */
#chat-composer-shell {
    flex: 0 0 auto !important;
    position: relative !important;
    inset: auto !important;
    width: 100% !important;
    max-height: min(36vh, 17rem);
    contain: layout paint;
}

#chat-input-form {
    width: min(100%, 48rem);
    margin-left: auto;
    margin-right: auto;
    flex: 0 0 auto;
    align-items: stretch;
}

.composer-input-row {
    width: 100%;
    min-height: 2.55rem;
    align-items: flex-end;
}

#user-input {
    flex: 1 1 auto;
    min-width: 0;
    height: 2.45rem;
    min-height: 2.45rem;
    max-height: 9rem;
    overflow-x: hidden;
    overflow-y: hidden;
    resize: none !important;
}

.composer-stop-btn {
    width: 2.55rem;
    height: 2.55rem;
    flex: 0 0 2.55rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.9rem;
    border: 1px solid color-mix(in srgb, #f97316 48%, var(--wutty-border));
    background: linear-gradient(135deg, rgba(249, 115, 22, 0.92), rgba(239, 68, 68, 0.90));
    color: #fff;
    box-shadow: 0 14px 32px rgba(239, 68, 68, 0.22);
    transition: transform 160ms ease, opacity 160ms ease, filter 160ms ease;
}

.composer-stop-btn:hover,
.composer-stop-btn:focus-visible {
    filter: brightness(1.06);
    transform: translateY(-1px);
    outline: none;
}

.composer-stop-btn:active {
    transform: scale(0.95);
}

.composer-stop-btn.hidden {
    display: none !important;
}

.composer-stop-btn:disabled {
    opacity: 0.55;
    pointer-events: none;
}

@media (min-width: 768px) {
    #app-shell {
        height: 100dvh !important;
        min-height: 100dvh !important;
        max-height: 100dvh !important;
    }

    #chat-composer-shell {
        padding-bottom: clamp(0.9rem, 1.7vh, 1.5rem) !important;
    }
}

@media (max-width: 767px) {
    #chat-composer-shell {
        max-height: min(42vh, 16rem);
        padding-bottom: max(0.68rem, env(safe-area-inset-bottom)) !important;
    }

    .keyboard-open #chat-composer-shell {
        padding-bottom: max(0.62rem, env(safe-area-inset-bottom)) !important;
    }

    .composer-input-row {
        min-height: 2.48rem;
    }

    #user-input {
        height: 2.35rem;
        min-height: 2.35rem;
        max-height: 8.4rem;
    }

    .composer-stop-btn {
        width: 2.48rem;
        height: 2.48rem;
        flex-basis: 2.48rem;
        border-radius: 0.88rem;
    }
}

/* Light theme contrast hardening: keep dark UI untouched, fix unreadable text/background pairs. */
html[data-resolved-theme="light"] #sidebar,
html[data-resolved-theme="light"] #sidebar *:not(.text-white):not(.text-blue-400):not(.text-red-300),
html[data-resolved-theme="light"] .chat-history-item,
html[data-resolved-theme="light"] .chat-history-item * {
    color: var(--wutty-text) !important;
}

html[data-resolved-theme="light"] #sidebar .text-gray-400,
html[data-resolved-theme="light"] #sidebar .text-gray-500,
html[data-resolved-theme="light"] #sidebar .opacity-50,
html[data-resolved-theme="light"] #chat-history-list .text-gray-500 {
    color: #334155 !important;
    opacity: 1 !important;
}

html[data-resolved-theme="light"] #sidebar .border-t.bg-\[\#0d101b\],
html[data-resolved-theme="light"] #sidebar > .border-t,
html[data-resolved-theme="light"] #sidebar-footer {
    background: linear-gradient(180deg, #ffffff, #f1f5f9) !important;
    border-color: #d9e2ef !important;
    color: #0f172a !important;
}

html[data-resolved-theme="light"] #sidebar [data-action="delete-all-chats"] {
    background: #fff1f2 !important;
    border-color: #fecdd3 !important;
    color: #9f1239 !important;
}

html[data-resolved-theme="light"] #sidebar [data-action="delete-all-chats"] i,
html[data-resolved-theme="light"] #sidebar [data-action="delete-all-chats"] span {
    color: #9f1239 !important;
}

html[data-resolved-theme="light"] #sidebar button:not([data-action="new-chat"]):not([data-action="delete-all-chats"]),
html[data-resolved-theme="light"] #sidebar .brand-home-link {
    color: #0f172a !important;
}

html[data-resolved-theme="light"] .stopped-empty-message {
    color: #334155 !important;
}

html[data-resolved-theme="dark"] .stopped-empty-message {
    color: #94a3b8 !important;
}

html[data-resolved-theme="light"] .markdown-body,
html[data-resolved-theme="light"] .assistant-bubble-group .markdown-body {
    color: #0f172a !important;
}

html[data-resolved-theme="light"] .markdown-body p,
html[data-resolved-theme="light"] .markdown-body li,
html[data-resolved-theme="light"] .markdown-body strong,
html[data-resolved-theme="light"] .markdown-body em,
html[data-resolved-theme="light"] .markdown-body blockquote,
html[data-resolved-theme="light"] .markdown-body table,
html[data-resolved-theme="light"] .markdown-body td,
html[data-resolved-theme="light"] .markdown-body th {
    color: #0f172a !important;
}

html[data-resolved-theme="light"] .markdown-body code:not(pre code) {
    background: #eef4ff !important;
    border: 1px solid #c7d7fe !important;
    color: #be123c !important;
}

html[data-resolved-theme="light"] .code-card {
    background: #ffffff !important;
    border-color: #d9e2ef !important;
    box-shadow: 0 16px 42px rgba(15, 23, 42, 0.08) !important;
}

html[data-resolved-theme="light"] .code-card-head {
    background: linear-gradient(180deg, #f8fafc, #eef2f7) !important;
    border-color: #d9e2ef !important;
    color: #0f172a !important;
}

html[data-resolved-theme="light"] .code-card-head span {
    color: #1e293b !important;
}

html[data-resolved-theme="light"] .markdown-body pre,
html[data-resolved-theme="light"] .markdown-body .code-card pre,
html[data-resolved-theme="light"] .code-card-body,
html[data-resolved-theme="light"] .hljs {
    background: #f8fafc !important;
    color: #0f172a !important;
}

html[data-resolved-theme="light"] .markdown-body pre code,
html[data-resolved-theme="light"] .markdown-body .code-card pre code,
html[data-resolved-theme="light"] pre code.hljs {
    background: transparent !important;
    color: #334155;
    -webkit-text-fill-color: initial;
}

html[data-resolved-theme="light"] .markdown-body pre code span,
html[data-resolved-theme="light"] pre code.hljs span {
    -webkit-text-fill-color: currentColor !important;
}

html[data-resolved-theme="light"] .hljs-keyword,
html[data-resolved-theme="light"] .hljs-selector-tag,
html[data-resolved-theme="light"] .hljs-built_in,
html[data-resolved-theme="light"] .hljs-name,
html[data-resolved-theme="light"] .hljs-tag {
    color: #7c3aed !important;
}

html[data-resolved-theme="light"] .hljs-string,
html[data-resolved-theme="light"] .hljs-title,
html[data-resolved-theme="light"] .hljs-section,
html[data-resolved-theme="light"] .hljs-attribute,
html[data-resolved-theme="light"] .hljs-literal,
html[data-resolved-theme="light"] .hljs-template-tag,
html[data-resolved-theme="light"] .hljs-template-variable,
html[data-resolved-theme="light"] .hljs-type,
html[data-resolved-theme="light"] .hljs-addition {
    color: #047857 !important;
}

html[data-resolved-theme="light"] .hljs-comment,
html[data-resolved-theme="light"] .hljs-quote,
html[data-resolved-theme="light"] .hljs-meta {
    color: #64748b !important;
}

html[data-resolved-theme="light"] .hljs-number,
html[data-resolved-theme="light"] .hljs-regexp,
html[data-resolved-theme="light"] .hljs-variable,
html[data-resolved-theme="light"] .hljs-symbol,
html[data-resolved-theme="light"] .hljs-bullet,
html[data-resolved-theme="light"] .hljs-link,
html[data-resolved-theme="light"] .hljs-deletion {
    color: #dc2626 !important;
}

html[data-resolved-theme="light"] #edit-message-modal .bg-brand-surface,
html[data-resolved-theme="light"] #correction-feedback-modal .bg-brand-surface,
html[data-resolved-theme="light"] .correction-sheet {
    background: #ffffff !important;
    color: #0f172a !important;
    border-color: #d9e2ef !important;
}

html[data-resolved-theme="light"] #edit-message-modal h3,
html[data-resolved-theme="light"] #correction-feedback-modal h3,
html[data-resolved-theme="light"] #edit-message-modal p,
html[data-resolved-theme="light"] #correction-feedback-modal p,
html[data-resolved-theme="light"] #edit-message-modal .text-gray-400,
html[data-resolved-theme="light"] #correction-feedback-modal .text-gray-400 {
    color: #334155 !important;
}

html[data-resolved-theme="light"] #edit-message-input,
html[data-resolved-theme="light"] #correction-feedback-input,
html[data-resolved-theme="light"] .correction-sheet textarea {
    background: #f8fafc !important;
    border-color: #cbd5e1 !important;
    color: #0f172a !important;
    -webkit-text-fill-color: #0f172a !important;
}

html[data-resolved-theme="light"] #edit-message-input::placeholder,
html[data-resolved-theme="light"] #correction-feedback-input::placeholder,
html[data-resolved-theme="light"] .correction-sheet textarea::placeholder {
    color: #64748b !important;
    -webkit-text-fill-color: #64748b !important;
}

html[data-resolved-theme="light"] #correction-feedback-modal .bg-blue-500\/5,
html[data-resolved-theme="light"] .correction-sheet .bg-blue-500\/5 {
    background: #eff6ff !important;
    border-color: #bfdbfe !important;
    color: #1e3a8a !important;
}

html[data-resolved-theme="light"] #edit-message-modal [data-close-edit-modal],
html[data-resolved-theme="light"] #correction-feedback-modal [data-close-correction-modal] {
    color: #334155 !important;
    background: #ffffff !important;
}

html[data-resolved-theme="light"] #edit-message-modal [data-close-edit-modal]:hover,
html[data-resolved-theme="light"] #correction-feedback-modal [data-close-correction-modal]:hover {
    color: #0f172a !important;
    background: #f1f5f9 !important;
}

.code-card-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.composer-file-preview {
    position: relative;
    min-width: 13rem;
    max-width: 17rem;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 1rem;
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.94), rgba(2, 6, 23, 0.88));
    padding: 0.65rem 2.15rem 0.65rem 0.7rem;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
}

.composer-file-icon {
    width: 2.35rem;
    height: 2.35rem;
    flex: 0 0 2.35rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.85rem;
    background: rgba(59, 130, 246, 0.13);
    color: #93c5fd;
}

.composer-file-meta {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.12rem;
}

.composer-file-meta strong,
.message-file-pill span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.composer-file-meta strong {
    max-width: 10rem;
    color: #e5e7eb;
    font-size: 0.74rem;
    line-height: 1rem;
}

.composer-file-meta span {
    color: #94a3b8;
    font-size: 0.66rem;
    line-height: 0.9rem;
}

.composer-file-preview button {
    position: absolute;
    top: 0.45rem;
    right: 0.45rem;
    width: 1.35rem;
    height: 1.35rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(2, 6, 23, 0.82);
    color: #f8fafc;
    font-size: 0.68rem;
}


.composer-file-preview.is-uploading {
    min-width: min(17rem, calc(100vw - 2rem));
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.96), rgba(15, 23, 42, 0.92));
    border-color: rgba(96, 165, 250, 0.34);
}

.composer-file-preview.is-uploading .composer-file-icon {
    animation: uploadPulse 1.15s ease-in-out infinite;
}

.composer-upload-progress {
    width: 100%;
    height: 0.38rem;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.18);
    margin-top: 0.28rem;
}

.composer-upload-progress span {
    display: block;
    height: 100%;
    width: 1%;
    border-radius: inherit;
    background: linear-gradient(90deg, #60a5fa, #a78bfa);
    transition: width 160ms ease;
}

@keyframes uploadPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(0.94); opacity: 0.72; }
}

@media (max-width: 640px) {
    .composer-file-preview,
    .composer-file-preview.is-uploading {
        min-width: min(15.5rem, calc(100vw - 2.5rem));
        max-width: calc(100vw - 2.5rem);
    }

    .composer-file-meta strong {
        max-width: 9.5rem;
    }
}

html[data-resolved-theme="light"] .composer-file-preview.is-uploading {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(239, 246, 255, 0.96));
    border-color: rgba(37, 99, 235, 0.28);
}

html[data-resolved-theme="light"] .composer-upload-progress {
    background: rgba(148, 163, 184, 0.24);
}

.message-file-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-bottom: 0.55rem;
}

.message-file-pill {
    min-width: 0;
    max-width: 100%;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.25);
    color: #e0f2fe;
    padding: 0.38rem 0.62rem;
    font-size: 0.72rem;
    text-decoration: none;
}

.upload-choice-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem;
    padding: 1rem;
}

.upload-choice-card {
    width: 100%;
    margin: 0;
    appearance: none;
    color: inherit;
}

.upload-mini-link {
    margin: 0 1rem 1rem;
    width: calc(100% - 2rem);
    min-height: 2.35rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 0.95rem;
    background: rgba(15, 23, 42, 0.55);
    color: #cbd5e1;
    font-size: 0.74rem;
    transition: 180ms ease;
}

.upload-mini-link:hover {
    border-color: rgba(96, 165, 250, 0.45);
    color: #fff;
    background: rgba(30, 41, 59, 0.72);
}

@media (max-width: 640px) {
    .upload-choice-grid {
        grid-template-columns: 1fr;
        gap: 0.7rem;
    }

    .composer-file-preview {
        min-width: 11.5rem;
        max-width: 14.5rem;
    }
}

/* Sidebar workspace navigation refresh */
#sidebar {
    flex: 0 0 18rem;
    width: 18rem;
    max-width: min(86vw, 20rem);
    transition: transform 260ms cubic-bezier(.22, 1, .36, 1), margin-left 260ms cubic-bezier(.22, 1, .36, 1), box-shadow 260ms ease;
    box-shadow: 18px 0 42px rgba(2, 6, 23, 0.08);
}

.sidebar-close-btn {
    width: 2.35rem;
    height: 2.35rem;
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    border: 1px solid color-mix(in srgb, var(--wutty-border) 78%, transparent);
    background: color-mix(in srgb, var(--wutty-surface-2) 76%, transparent);
}

.sidebar-primary-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.5rem;
}

.sidebar-search-trigger {
    min-width: 2.8rem;
    height: 2.65rem;
    padding: 0 0.82rem;
    border-radius: 0.8rem;
    border: 1px solid color-mix(in srgb, var(--wutty-border) 82%, transparent);
    background: color-mix(in srgb, var(--wutty-surface-2) 80%, transparent);
    color: var(--wutty-text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    font-size: 0.72rem;
    font-weight: 800;
    transition: 160ms ease;
}

.sidebar-search-trigger:hover,
.sidebar-search-trigger:focus-visible,
.sidebar-search-trigger.is-active {
    outline: none;
    color: var(--wutty-text);
    border-color: color-mix(in srgb, var(--wutty-accent) 52%, var(--wutty-border));
    background: var(--wutty-accent-soft);
}

.sidebar-search-trigger span {
    display: none;
}

.sidebar-search-panel {
    position: relative;
    animation: sidebarSearchReveal 180ms ease both;
}

.sidebar-search-panel > i {
    position: absolute;
    left: 0.86rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--wutty-text-faint);
    font-size: 0.75rem;
    pointer-events: none;
}

#sidebar-chat-search-input {
    width: 100%;
    height: 2.65rem;
    border-radius: 0.85rem;
    border: 1px solid color-mix(in srgb, var(--wutty-border) 85%, transparent);
    background: color-mix(in srgb, var(--wutty-surface-2) 82%, transparent);
    color: var(--wutty-text);
    padding: 0 2.45rem 0 2.25rem;
    font-size: 0.76rem;
    outline: none;
    transition: 160ms ease;
}

#sidebar-chat-search-input:focus {
    border-color: color-mix(in srgb, var(--wutty-accent) 58%, var(--wutty-border));
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--wutty-accent) 12%, transparent);
}

#sidebar-chat-search-input::placeholder {
    color: var(--wutty-text-faint);
}

#sidebar-chat-search-input::-webkit-search-cancel-button {
    appearance: none;
}

.sidebar-search-clear {
    position: absolute;
    right: 0.48rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1.75rem;
    height: 1.75rem;
    display: grid;
    place-items: center;
    border-radius: 0.55rem;
    color: var(--wutty-text-muted);
    transition: 140ms ease;
}

.sidebar-search-clear:hover {
    color: var(--wutty-text);
    background: color-mix(in srgb, var(--wutty-accent) 12%, transparent);
}

.sidebar-search-empty {
    min-height: 8rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    padding: 1.25rem;
    color: var(--wutty-text-faint);
    font-size: 0.72rem;
    line-height: 1.5;
    text-align: center;
}

.sidebar-search-empty i {
    font-size: 1.1rem;
    color: var(--wutty-accent);
}

.sidebar-footer {
    padding: 0.7rem;
    color: var(--wutty-text-muted);
}

.sidebar-settings-btn {
    width: 100%;
    min-height: 3.65rem;
    display: flex;
    align-items: center;
    gap: 0.72rem;
    padding: 0.62rem 0.68rem;
    border: 1px solid transparent;
    border-radius: 0.95rem;
    transition: 160ms ease;
}

.sidebar-settings-btn:hover,
.sidebar-settings-btn:focus-visible {
    outline: none;
    border-color: color-mix(in srgb, var(--wutty-border) 82%, transparent);
    background: color-mix(in srgb, var(--wutty-accent) 9%, transparent);
}

.sidebar-settings-icon {
    width: 2.15rem;
    height: 2.15rem;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 0.72rem;
    color: var(--wutty-accent);
    background: var(--wutty-accent-soft);
    border: 1px solid color-mix(in srgb, var(--wutty-accent) 24%, var(--wutty-border));
}

.sidebar-settings-btn strong,
.sidebar-settings-btn small {
    display: block;
}

.sidebar-settings-btn strong {
    color: var(--wutty-text-soft);
    font-size: 0.76rem;
    font-weight: 850;
}

.sidebar-settings-btn small {
    margin-top: 0.08rem;
    color: var(--wutty-text-faint);
    font-size: 0.62rem;
}

.sidebar-settings-chevron {
    color: var(--wutty-text-faint);
    font-size: 0.68rem;
}

.sidebar-status-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.7rem;
    padding: 0.55rem 0.72rem 0.1rem;
    font-size: 0.65rem;
}

.sidebar-open-brand {
    position: relative;
    width: 2.45rem;
    height: 2.45rem;
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    overflow: hidden;
    border-radius: 0.8rem;
    border: 1px solid color-mix(in srgb, var(--wutty-border) 82%, transparent);
    background: color-mix(in srgb, var(--wutty-surface) 86%, transparent);
    box-shadow: 0 8px 24px var(--wutty-shadow);
    transition: 170ms ease;
}

.sidebar-open-brand-logo,
.sidebar-open-hover-icon {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    transition: opacity 150ms ease, transform 180ms ease;
}

.theme-logo-stack {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
}

.theme-logo-image {
    display: block;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 160ms ease, visibility 160ms ease, transform 160ms ease;
}

.theme-logo-image[hidden] {
    display: none !important;
}

html[data-resolved-theme="dark"] .theme-logo-image[data-theme-logo="dark"],
html[data-resolved-theme="light"] .theme-logo-image[data-theme-logo="light"] {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

html[data-resolved-theme="dark"] .theme-logo-image[data-theme-logo="light"],
html[data-resolved-theme="light"] .theme-logo-image[data-theme-logo="dark"] {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.theme-logo-image:not([data-theme-logo]) {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.sidebar-open-brand-logo img,
.sidebar-open-brand-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: transparent !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

.sidebar-open-brand-logo i {
    color: var(--wutty-accent);
}

.sidebar-open-hover-icon {
    opacity: 0;
    transform: scale(0.72) rotate(-8deg);
    color: var(--wutty-text);
    background: color-mix(in srgb, var(--wutty-surface-2) 95%, transparent);
}

.sidebar-open-brand:hover,
.sidebar-open-brand:focus-visible {
    outline: none;
    border-color: color-mix(in srgb, var(--wutty-accent) 54%, var(--wutty-border));
    transform: translateY(-1px);
}

.sidebar-open-brand:hover .sidebar-open-brand-logo,
.sidebar-open-brand:focus-visible .sidebar-open-brand-logo {
    opacity: 0;
    transform: scale(1.14);
}

.sidebar-open-brand:hover .sidebar-open-hover-icon,
.sidebar-open-brand:focus-visible .sidebar-open-hover-icon {
    opacity: 1;
    transform: scale(1) rotate(0);
}

.settings-sheet {
    width: min(92vw, 31rem);
}

.settings-modal-body {
    padding: 0.35rem 0.8rem 0.9rem;
}

.settings-modal-body .theme-switcher {
    border-bottom: 0;
    padding: 0.85rem 0.15rem 0.65rem;
}

.settings-info-card {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    margin: 0.35rem 0.15rem 0;
    padding: 0.8rem;
    border-radius: 0.9rem;
    border: 1px solid color-mix(in srgb, var(--wutty-border) 82%, transparent);
    background: color-mix(in srgb, var(--wutty-surface-2) 68%, transparent);
}

.settings-info-card > span {
    width: 2rem;
    height: 2rem;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 0.65rem;
    color: var(--wutty-accent);
    background: var(--wutty-accent-soft);
}

.settings-info-card strong,
.settings-info-card small {
    display: block;
}

.settings-info-card strong {
    color: var(--wutty-text-soft);
    font-size: 0.73rem;
}

.settings-info-card small {
    margin-top: 0.12rem;
    color: var(--wutty-text-faint);
    font-size: 0.64rem;
    line-height: 1.4;
}

@keyframes sidebarSearchReveal {
    from { opacity: 0; transform: translateY(-0.3rem); }
    to { opacity: 1; transform: translateY(0); }
}

@media (min-width: 768px) {
    body.sidebar-collapsed #sidebar {
        margin-left: -18rem;
        box-shadow: none;
        pointer-events: none;
    }

    body:not(.sidebar-collapsed) .sidebar-open-brand {
        display: none;
    }
}

@media (max-width: 767px) {
    #sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(86vw, 20rem);
        max-width: min(86vw, 20rem);
        flex-basis: auto;
        box-shadow: none;
    }

    .sidebar-open-brand {
        width: 2.35rem;
        height: 2.35rem;
    }

    .sidebar-search-trigger span {
        display: none;
    }

    .sidebar-status-row {
        padding-bottom: max(0.2rem, env(safe-area-inset-bottom));
    }
}

@media (max-width: 390px) {
    .sidebar-primary-actions {
        grid-template-columns: minmax(0, 1fr) 2.65rem;
    }

    .sidebar-search-trigger {
        padding-inline: 0;
    }

    .settings-modal-body .theme-switcher-grid {
        grid-template-columns: 1fr;
    }

    .settings-modal-body .theme-choice-btn {
        min-height: 3.6rem;
        grid-template-columns: auto 1fr;
        justify-items: start;
        padding-inline: 0.85rem;
    }

    .settings-modal-body .theme-choice-btn small {
        grid-column: 2;
    }
}

/* Precise sidebar controls: desktop panel glyph + compact mobile menu. */
.sidebar-panel-icon {
    position: relative;
    width: 1.28rem;
    height: 1.05rem;
    display: inline-block;
    flex: 0 0 auto;
    border: 0.12rem solid currentColor;
    border-radius: 0.28rem;
    box-sizing: border-box;
}

.sidebar-panel-icon::before {
    content: "";
    position: absolute;
    top: -0.12rem;
    bottom: -0.12rem;
    left: 0.34rem;
    width: 0.12rem;
    background: currentColor;
}

.sidebar-panel-icon > span {
    position: absolute;
    left: 0.08rem;
    top: 50%;
    width: 0.13rem;
    height: 0.13rem;
    border-radius: 999px;
    background: currentColor;
    transform: translateY(-50%);
}

.sidebar-mobile-menu-icon {
    display: none;
    width: 1.18rem;
    height: 0.9rem;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 0.28rem;
}

.sidebar-mobile-menu-icon span {
    display: block;
    width: 1.05rem;
    height: 0.13rem;
    border-radius: 999px;
    background: currentColor;
}

@media (max-width: 767px) {
    .sidebar-open-brand-logo,
    .sidebar-open-hover-icon {
        display: none;
    }

    .sidebar-mobile-menu-icon {
        display: inline-flex;
        color: var(--wutty-text);
    }

    .sidebar-open-brand:hover .sidebar-mobile-menu-icon,
    .sidebar-open-brand:focus-visible .sidebar-mobile-menu-icon {
        transform: scale(1.04);
    }
}

/* Clean, responsive empty workspace hero. */
.welcome-screen-clean {
    width: min(100%, 46rem);
    gap: clamp(1.25rem, 3vw, 1.8rem);
    min-height: min(32rem, 100%);
}

.welcome-screen-clean .welcome-hero-logo {
    width: clamp(7.5rem, 20vw, 10.5rem);
    height: clamp(7.5rem, 20vw, 10.5rem);
    border-radius: 0;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    overflow: visible !important;
}

.welcome-screen-clean .welcome-hero-logo > i {
    font-size: clamp(1.85rem, 5vw, 2.45rem);
}

.welcome-copy {
    display: grid;
    justify-items: center;
    gap: clamp(0.65rem, 2vw, 0.9rem);
}

.welcome-brand-title {
    font-size: clamp(1.85rem, 6vw, 3rem);
    line-height: 1.08;
    font-weight: 750;
    letter-spacing: -0.045em;
}

.welcome-question {
    max-width: 34rem;
    font-size: clamp(1.05rem, 3.4vw, 1.4rem);
    line-height: 1.45;
    font-weight: 500;
    letter-spacing: -0.018em;
    text-wrap: balance;
}

html[data-resolved-theme="light"] .welcome-brand-title {
    background-image: linear-gradient(90deg, #0f172a, #334155, #64748b) !important;
}

html[data-resolved-theme="dark"] .welcome-brand-title {
    background-image: linear-gradient(90deg, #ffffff 0%, #dbeafe 34%, #93c5fd 68%, #c4b5fd 100%) !important;
    filter: drop-shadow(0 8px 24px rgba(96, 165, 250, 0.14));
    -webkit-text-fill-color: transparent;
}

@media (max-height: 650px) {
    .welcome-screen-clean {
        min-height: 100%;
        gap: 1rem;
        padding-top: 1.5rem;
        padding-bottom: 1.5rem;
    }

    .welcome-screen-clean .welcome-hero-logo {
        width: min(8rem, 52vw);
        height: min(8rem, 52vw);
        border-radius: 0;
        overflow: visible !important;
    }
}

/* Share Chat Modal */
.share-chat-sheet {
    width: min(94vw, 560px);
}

.share-chat-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.share-chat-card {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 14px;
    border: 1px solid rgba(96, 165, 250, 0.18);
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.12), rgba(168, 85, 247, 0.08));
}

.share-chat-icon {
    width: 38px;
    height: 38px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #bfdbfe;
    background: rgba(96, 165, 250, 0.14);
    border: 1px solid rgba(96, 165, 250, 0.22);
}

.share-chat-card strong {
    display: block;
    font-size: 14px;
    color: #f8fafc;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.share-chat-card small {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    line-height: 1.5;
    color: #94a3b8;
}

.share-link-box {
    display: flex;
    gap: 8px;
    padding: 8px;
    border-radius: 16px;
    background: rgba(2, 6, 23, 0.38);
    border: 1px solid rgba(148, 163, 184, 0.14);
}

.share-link-box input {
    min-width: 0;
    flex: 1;
    border: 0;
    outline: 0;
    color: #dbeafe;
    background: transparent;
    font-size: 12px;
}

.share-link-box button,
.share-native-btn,
.share-social-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.share-link-box button {
    padding: 9px 12px;
    border-radius: 12px;
    color: #ffffff;
    background: linear-gradient(135deg, #2563eb, #4f46e5);
    font-size: 12px;
    font-weight: 700;
}

.share-social-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.share-social-btn {
    min-height: 46px;
    border-radius: 15px;
    color: #e5e7eb;
    background: rgba(15, 23, 42, 0.62);
    border: 1px solid rgba(148, 163, 184, 0.16);
    font-size: 12px;
    font-weight: 700;
}

.share-native-btn {
    width: 100%;
    min-height: 46px;
    border-radius: 15px;
    color: #bfdbfe;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(96, 165, 250, 0.2);
    font-size: 13px;
    font-weight: 800;
}

.share-link-box button:hover,
.share-social-btn:hover,
.share-native-btn:hover,
.share-link-box button:focus-visible,
.share-social-btn:focus-visible,
.share-native-btn:focus-visible {
    transform: translateY(-1px);
    outline: none;
}

.share-social-btn:hover,
.share-social-btn:focus-visible,
.share-native-btn:hover,
.share-native-btn:focus-visible {
    background: rgba(59, 130, 246, 0.14);
    border-color: rgba(96, 165, 250, 0.32);
}

.chat-action-item:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

html[data-resolved-theme="light"] .share-chat-card {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(124, 58, 237, 0.06));
}

html[data-resolved-theme="light"] .share-chat-card strong {
    color: #0f172a;
}

html[data-resolved-theme="light"] .share-link-box {
    background: rgba(248, 250, 252, 0.84);
    border-color: rgba(15, 23, 42, 0.1);
}

html[data-resolved-theme="light"] .share-link-box input {
    color: #1e293b;
}

html[data-resolved-theme="light"] .share-social-btn,
html[data-resolved-theme="light"] .share-native-btn {
    color: #1e293b;
    background: rgba(248, 250, 252, 0.82);
    border-color: rgba(15, 23, 42, 0.1);
}

@media (max-width: 520px) {
    .share-social-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .share-link-box {
        flex-direction: column;
    }

    .share-link-box button {
        width: 100%;
    }
}

/* Modern AI model selector */
.nav-model-wrap {
    min-width: 0;
    max-width: min(54vw, 520px);
    position: relative;
    z-index: 30;
}

.model-selector-btn {
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    position: relative;
    z-index: 31;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: min(420px, 52vw);
    max-width: 100%;
    min-height: 44px;
    padding: 8px 10px 8px 14px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.86), rgba(17, 24, 39, 0.62));
    color: #e5e7eb;
    box-shadow: 0 16px 42px rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.04);
    transition: border-color .18s ease, transform .18s ease, background .18s ease, box-shadow .18s ease;
}

.model-selector-btn:hover,
.model-selector-btn:focus-visible,
.model-selector-btn[aria-expanded="true"] {
    border-color: rgba(96, 165, 250, 0.45);
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.92), rgba(15, 23, 42, 0.82));
    box-shadow: 0 18px 50px rgba(37, 99, 235, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.06);
    outline: none;
}

.model-selector-btn:active {
    transform: scale(0.985);
}

.model-selector-main {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
    flex: 1;
}

.model-selector-name {
    max-width: 100%;
    font-size: 13px;
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.01em;
    color: #f8fafc;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.model-selector-desc {
    max-width: 100%;
    margin-top: 2px;
    font-size: 10.5px;
    line-height: 1.2;
    color: #94a3b8;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.model-selector-badge {
    flex: 0 0 auto;
    border-radius: 999px;
    border: 1px solid rgba(96, 165, 250, 0.3);
    background: rgba(59, 130, 246, 0.12);
    color: #bfdbfe;
    padding: 5px 8px;
    font-size: 9.5px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.model-selector-chevron {
    flex: 0 0 auto;
    font-size: 10px;
    color: #94a3b8;
    transition: transform .18s ease;
}

.model-selector-btn[aria-expanded="true"] .model-selector-chevron {
    transform: rotate(180deg);
}

.model-selector-menu {
    position: fixed;
    z-index: 9999;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 24px;
    background: rgba(8, 13, 26, 0.94);
    backdrop-filter: blur(22px);
    box-shadow: 0 28px 90px rgba(0, 0, 0, 0.46), 0 0 0 1px rgba(255, 255, 255, 0.03) inset;
    overflow: hidden;
    color: #e5e7eb;
    isolation: isolate;
}

.model-selector-head {
    padding: 15px 16px 12px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
    background: radial-gradient(circle at 12% 0%, rgba(59, 130, 246, 0.16), transparent 34%);
}

.model-selector-head strong {
    display: block;
    font-size: 13px;
    color: #f8fafc;
}

.model-selector-head small {
    display: block;
    margin-top: 3px;
    font-size: 11px;
    color: #94a3b8;
}

.model-selector-list {
    max-height: min(68vh, 560px);
    overflow-y: auto;
    padding: 8px;
}

.model-option {
    width: 100%;
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) auto 18px;
    align-items: center;
    gap: 10px;
    padding: 11px 10px;
    border: 1px solid transparent;
    border-radius: 18px;
    color: inherit;
    text-align: left;
    transition: background .16s ease, border-color .16s ease, transform .16s ease;
}

.model-option:hover,
.model-option:focus-visible,
.model-option.is-active {
    background: rgba(59, 130, 246, 0.10);
    border-color: rgba(96, 165, 250, 0.26);
    outline: none;
}

.model-option:active {
    transform: scale(0.99);
}

.model-option-rank {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: rgba(148, 163, 184, 0.10);
    color: #cbd5e1;
    font-size: 11px;
    font-weight: 900;
}

.model-option-copy {
    min-width: 0;
}

.model-option-copy strong,
.model-option-copy small,
.model-option-copy code,
.model-option-engine {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.model-option-copy strong {
    font-size: 12px;
    color: #f8fafc;
}

.model-option-copy small {
    margin-top: 3px;
    font-size: 10.5px;
    color: #9ca3af;
}

.model-option-engine {
    display: block;
    margin-top: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 9.5px;
    font-weight: 750;
    letter-spacing: .055em;
    text-transform: uppercase;
    color: #93c5fd;
}

.model-option-badge {
    border-radius: 999px;
    padding: 5px 7px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    background: rgba(255, 255, 255, 0.04);
    color: #cbd5e1;
    font-size: 9px;
    font-weight: 900;
    white-space: nowrap;
}

.model-option-check {
    opacity: 0;
    color: #60a5fa;
    font-size: 12px;
}

.model-option.is-active .model-option-check {
    opacity: 1;
}

html[data-resolved-theme="light"] .model-selector-btn {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(248, 250, 252, 0.84));
    color: #0f172a;
    border-color: rgba(15, 23, 42, 0.1);
    box-shadow: 0 16px 38px rgba(15, 23, 42, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

html[data-resolved-theme="light"] .model-selector-name,
html[data-resolved-theme="light"] .model-option-copy strong,
html[data-resolved-theme="light"] .model-selector-head strong {
    color: #0f172a;
}

html[data-resolved-theme="light"] .model-selector-desc,
html[data-resolved-theme="light"] .model-selector-head small,
html[data-resolved-theme="light"] .model-option-copy small {
    color: #64748b;
}

html[data-resolved-theme="light"] .model-selector-menu {
    background: rgba(255, 255, 255, 0.96);
    color: #0f172a;
    border-color: rgba(15, 23, 42, 0.10);
    box-shadow: 0 28px 80px rgba(15, 23, 42, 0.18), 0 0 0 1px rgba(255, 255, 255, 0.8) inset;
}

html[data-resolved-theme="light"] .model-option:hover,
html[data-resolved-theme="light"] .model-option:focus-visible,
html[data-resolved-theme="light"] .model-option.is-active {
    background: rgba(37, 99, 235, 0.08);
    border-color: rgba(37, 99, 235, 0.20);
}

html[data-resolved-theme="light"] .model-option-rank,
html[data-resolved-theme="light"] .model-option-badge {
    background: rgba(15, 23, 42, 0.045);
    color: #475569;
}

@media (max-width: 720px) {
    .nav-model-wrap {
        flex: 1 1 auto;
        max-width: calc(100vw - 142px);
    }
    .model-selector-btn {
        min-width: 0;
        width: 100%;
        min-height: 42px;
        padding: 8px 9px 8px 11px;
        border-radius: 15px;
    }
    .model-selector-desc {
        display: none;
    }
    .model-selector-name {
        font-size: 12px;
    }
    .model-selector-badge {
        display: none;
    }
    .model-selector-menu {
        left: 10px !important;
        right: 10px !important;
        width: calc(100vw - 20px) !important;
        border-radius: 22px;
    }
    .model-selector-list {
        max-height: min(66vh, 520px);
    }
    .model-option {
        grid-template-columns: 26px minmax(0, 1fr) 16px;
        gap: 8px;
        padding: 11px 9px;
    }
    .model-option-badge {
        display: none;
    }
}

@media (max-width: 380px) {
    .nav-model-wrap {
        max-width: calc(100vw - 126px);
    }
    .model-selector-name {
        font-size: 11.5px;
    }
    .model-option-engine {
        font-size: 8.5px;
    }
}


/* Mobile viewport and floating navigation hardening. */
@media (max-width: 767px) {
    html, body {
        width: 100%;
        overflow: hidden;
        overscroll-behavior: none;
    }

    #app-shell {
        top: var(--visual-viewport-offset-top, 0px);
        bottom: auto;
        transform: translateZ(0);
    }

    #chat-messages-container {
        scroll-behavior: auto;
        overscroll-behavior-y: contain;
    }

    .chat-scroll-controls,
    .chat-scroll-controls.is-composer-expanded {
        bottom: calc(var(--composer-height, 5.7rem) + 0.72rem);
        transform: translateZ(0);
        will-change: opacity, transform;
    }

    .chat-scroll-btn {
        -webkit-tap-highlight-color: transparent;
    }
}


/* Rich assistant content: consistent enterprise typography in both themes. */
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
    margin: 1.05em 0 0.55em;
    color: #f8fafc;
    font-weight: 800;
    line-height: 1.25;
    letter-spacing: -0.025em;
}
.markdown-body h1 { font-size: 1.42rem; }
.markdown-body h2 { font-size: 1.23rem; }
.markdown-body h3 { font-size: 1.08rem; }
.markdown-body hr {
    border: 0;
    height: 1px;
    margin: 1.15rem 0;
    background: linear-gradient(90deg, transparent, rgba(148,163,184,.38), transparent);
}
.markdown-body table th {
    background: rgba(96,165,250,.10);
    font-weight: 800;
}
.markdown-body kbd {
    display: inline-flex;
    align-items: center;
    min-height: 1.45rem;
    padding: 0.08rem 0.42rem;
    border: 1px solid rgba(148,163,184,.30);
    border-bottom-width: 2px;
    border-radius: 0.42rem;
    background: rgba(15,23,42,.74);
    font-family: ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;
    font-size: .82em;
}
.markdown-body .katex-display {
    max-width: 100%;
    margin: 1rem 0;
    padding: .85rem 1rem;
    overflow-x: auto;
    overflow-y: hidden;
    border: 1px solid rgba(148,163,184,.18);
    border-radius: 1rem;
    background: rgba(15,23,42,.62);
}
.markdown-body .katex { font-size: 1.04em; }

html[data-resolved-theme="light"] .markdown-body h1,
html[data-resolved-theme="light"] .markdown-body h2,
html[data-resolved-theme="light"] .markdown-body h3,
html[data-resolved-theme="light"] .markdown-body h4 { color: #0f172a !important; }
html[data-resolved-theme="light"] .markdown-body table th { background: #eef4ff !important; }
html[data-resolved-theme="light"] .markdown-body kbd {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #0f172a;
}
html[data-resolved-theme="light"] .markdown-body .katex,
html[data-resolved-theme="light"] .markdown-body .katex * { color: #0f172a !important; }
html[data-resolved-theme="light"] .markdown-body .katex-display {
    background: #f8fafc;
    border-color: #d9e2ef;
}

/* Complete light syntax palette. Do not force a generic color on token spans. */
html[data-resolved-theme="light"] .hljs-attr,
html[data-resolved-theme="light"] .hljs-property,
html[data-resolved-theme="light"] .hljs-selector-class,
html[data-resolved-theme="light"] .hljs-selector-id { color: #1d4ed8 !important; }
html[data-resolved-theme="light"] .hljs-function,
html[data-resolved-theme="light"] .hljs-title.function_,
html[data-resolved-theme="light"] .hljs-title.class_ { color: #7c3aed !important; }
html[data-resolved-theme="light"] .hljs-params,
html[data-resolved-theme="light"] .hljs-punctuation { color: #334155 !important; }
html[data-resolved-theme="light"] .hljs-doctag,
html[data-resolved-theme="light"] .hljs-formula { color: #b45309 !important; }

/* Orion formatter and cancellable upload hardening */
html[data-resolved-theme="light"] .hljs-subst { color:#334155 !important; }
html[data-resolved-theme="light"] .hljs-operator,
html[data-resolved-theme="light"] .hljs-punctuation { color:#475569 !important; }
html[data-resolved-theme="light"] .hljs-selector-attr,
html[data-resolved-theme="light"] .hljs-selector-pseudo { color:#0369a1 !important; }
html[data-resolved-theme="light"] .hljs-variable.language_,
html[data-resolved-theme="light"] .hljs-template-variable { color:#be123c !important; }
.composer-file-preview.is-uploading button[data-cancel-upload] { opacity:.9; transition:transform .16s ease,background .16s ease; }
.composer-file-preview.is-uploading button[data-cancel-upload]:hover { transform:scale(1.08); background:rgba(239,68,68,.9); }
.markdown-body .katex-display > .katex { min-width:max-content; }
.markdown-body .katex-error { color:#f87171 !important; font-family:ui-monospace,SFMono-Regular,Menlo,monospace; }


/* Production fallback avatar: modern icon + name initial, shared by header and account modal. */
.auth-name-placeholder {
    position: relative;
    display: inline-grid;
    place-items: center;
    isolation: isolate;
    overflow: hidden;
    background: linear-gradient(145deg, rgba(59,130,246,.98), rgba(124,58,237,.92));
    border: 1px solid rgba(255,255,255,.24);
    box-shadow: 0 8px 22px rgba(37,99,235,.2), inset 0 1px 0 rgba(255,255,255,.22);
}
.auth-name-placeholder i { font-size: 52%; opacity: .92; transform: translateY(-8%); }
.auth-name-placeholder b {
    position: absolute; right: 2px; bottom: 1px; z-index: 2;
    min-width: 12px; height: 12px; padding: 0 2px; border-radius: 999px;
    display: grid; place-items: center; font-size: 7px; line-height: 1; font-weight: 900;
    color: #172554; background: #fff; border: 1px solid rgba(219,234,254,.95);
}
.auth-name-placeholder.auth-initial-compact b { min-width: 10px; height: 10px; font-size: 6px; }
html[data-resolved-theme="light"] .auth-name-placeholder { box-shadow: 0 8px 20px rgba(37,99,235,.18), inset 0 1px 0 rgba(255,255,255,.35); }

/* Final rich-response formatter: assistant Markdown only; user bubbles stay plain text. */
.assistant-bubble-group .markdown-body {
    overflow-wrap: anywhere;
    word-break: normal;
    line-height: 1.72;
}
.assistant-bubble-group .markdown-body > :first-child { margin-top: 0 !important; }
.assistant-bubble-group .markdown-body > :last-child { margin-bottom: 0 !important; }
.assistant-bubble-group .markdown-body h5,
.assistant-bubble-group .markdown-body h6 {
    margin: 1em 0 .5em;
    color: #f1f5f9;
    font-weight: 800;
    line-height: 1.3;
}
.assistant-bubble-group .markdown-body h5 { font-size: .98rem; }
.assistant-bubble-group .markdown-body h6 { font-size: .9rem; color: #cbd5e1; }
.assistant-bubble-group .markdown-body ul,
.assistant-bubble-group .markdown-body ol { padding-left: 1.45rem; }
.assistant-bubble-group .markdown-body li + li { margin-top: .32rem; }
.assistant-bubble-group .markdown-body li > ul,
.assistant-bubble-group .markdown-body li > ol { margin-top: .35rem; margin-bottom: .35rem; }
.assistant-bubble-group .markdown-body li::marker { color: #93c5fd; font-weight: 700; }
.assistant-bubble-group .markdown-body input[type="checkbox"] {
    width: 1rem; height: 1rem; margin: 0 .45rem 0 0; accent-color: #3b82f6; vertical-align: -.12rem;
}
.assistant-bubble-group .markdown-body strong { color: #f8fafc; font-weight: 800; }
.assistant-bubble-group .markdown-body del { color: #94a3b8; text-decoration-thickness: 1.5px; }
.assistant-bubble-group .markdown-body mark {
    padding: .08em .3em; border-radius: .35rem; background: rgba(250,204,21,.2); color: #fef3c7;
}
.assistant-bubble-group .markdown-body sup,
.assistant-bubble-group .markdown-body sub { font-size: .76em; line-height: 0; }
.assistant-bubble-group .markdown-body img {
    display: block; max-width: 100%; height: auto; margin: .9rem 0; border-radius: 1rem;
    border: 1px solid rgba(148,163,184,.2); box-shadow: 0 14px 34px rgba(2,6,23,.24);
}
.assistant-bubble-group .markdown-body table {
    width: 100%; min-width: 34rem; border-spacing: 0; border-collapse: separate;
    border: 1px solid rgba(148,163,184,.2); border-radius: .9rem;
}
.assistant-bubble-group .markdown-body th,
.assistant-bubble-group .markdown-body td {
    min-width: 7rem; padding: .68rem .78rem; text-align: left; vertical-align: top;
    border-right: 1px solid rgba(148,163,184,.15); border-bottom: 1px solid rgba(148,163,184,.15);
}
.assistant-bubble-group .markdown-body tr > :last-child { border-right: 0; }
.assistant-bubble-group .markdown-body tbody tr:last-child > * { border-bottom: 0; }
.assistant-bubble-group .markdown-body details {
    margin: .85rem 0; padding: .75rem .85rem; border: 1px solid rgba(148,163,184,.18);
    border-radius: .8rem; background: rgba(15,23,42,.42);
}
.assistant-bubble-group .markdown-body summary { cursor: pointer; font-weight: 800; color: #dbeafe; }
.assistant-bubble-group .markdown-body .code-card { max-width: 100%; }
.assistant-bubble-group .markdown-body pre,
.assistant-bubble-group .markdown-body .code-card-body { tab-size: 4; }
.assistant-bubble-group .markdown-body pre code {
    display: block; min-width: max-content; white-space: pre; word-break: normal; overflow-wrap: normal;
    font-variant-ligatures: none;
}
.assistant-bubble-group .markdown-body .katex-display { scrollbar-width: thin; }

html[data-resolved-theme="light"] .assistant-bubble-group .markdown-body h5,
html[data-resolved-theme="light"] .assistant-bubble-group .markdown-body h6,
html[data-resolved-theme="light"] .assistant-bubble-group .markdown-body strong { color: #0f172a !important; }
html[data-resolved-theme="light"] .assistant-bubble-group .markdown-body del { color: #64748b; }
html[data-resolved-theme="light"] .assistant-bubble-group .markdown-body mark { background: #fef3c7; color: #78350f; }
html[data-resolved-theme="light"] .assistant-bubble-group .markdown-body details { background: #f8fafc; border-color: #dbe4f0; }
html[data-resolved-theme="light"] .assistant-bubble-group .markdown-body summary { color: #1e3a8a; }

/* Reliable responsive profile image fallback for header/nav and account modal. */
.auth-avatar-shell {
    position: relative;
    display: inline-grid;
    place-items: center;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    border-radius: inherit;
    flex: 0 0 auto;
}
.auth-avatar-shell > .auth-initial,
.auth-avatar-shell > .auth-avatar-image {
    grid-area: 1 / 1;
    width: 100%;
    height: 100%;
    border-radius: inherit;
}
.auth-avatar-shell > .auth-avatar-image {
    position: relative;
    z-index: 2;
    display: block;
    object-fit: cover;
    background: #0f172a;
}
.auth-account-btn .auth-avatar-shell {
    width: 1.15rem;
    height: 1.15rem;
    flex-basis: 1.15rem;
    border-radius: 999px;
}
.auth-avatar .auth-avatar-shell { width: 100%; height: 100%; border-radius: inherit; }

@media (max-width: 520px) {
    .auth-account-btn .auth-avatar-shell { width: 1.22rem; height: 1.22rem; flex-basis: 1.22rem; }
    .assistant-bubble-group .markdown-body table { min-width: 30rem; }
    .assistant-bubble-group .markdown-body th,
    .assistant-bubble-group .markdown-body td { padding: .58rem .65rem; font-size: .78rem; }
}

/* ====================================
   BRAND LOGO GLOW EFFECT (Dark Theme)
   ==================================== */

@keyframes logoGlowPulse {
    0% {
        filter: drop-shadow(0 0 20px rgba(59, 130, 246, 0.4)) 
                drop-shadow(0 0 40px rgba(147, 197, 253, 0.2));
    }
    50% {
        filter: drop-shadow(0 0 30px rgba(59, 130, 246, 0.6)) 
                drop-shadow(0 0 60px rgba(147, 197, 253, 0.3))
                drop-shadow(0 0 80px rgba(139, 92, 246, 0.2));
    }
    100% {
        filter: drop-shadow(0 0 20px rgba(59, 130, 246, 0.4)) 
                drop-shadow(0 0 40px rgba(147, 197, 253, 0.2));
    }
}

/* Enhanced glow effect for welcome logo in dark theme */
html[data-resolved-theme="dark"] .welcome-hero-image.is-logo {
    filter: drop-shadow(0 0 20px rgba(59, 130, 246, 0.5)) 
            drop-shadow(0 0 40px rgba(96, 165, 250, 0.3))
            drop-shadow(0 0 60px rgba(139, 92, 246, 0.15));
    animation: logoGlowPulse 3s ease-in-out infinite;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* Light theme: no glow effect */
html[data-resolved-theme="light"] .welcome-hero-image.is-logo {
    filter: none;
}

/* Parent container subtle backdrop enhancement for dark theme */
html[data-resolved-theme="dark"] .welcome-logo-stack {
    position: relative;
}

/* Additional layer styling for enhanced depth */
html[data-resolved-theme="dark"] .welcome-hero-image-dark {
    filter: drop-shadow(0 0 20px rgba(59, 130, 246, 0.5)) 
            drop-shadow(0 0 40px rgba(96, 165, 250, 0.3))
            drop-shadow(0 0 60px rgba(139, 92, 246, 0.15));
    animation: logoGlowPulse 3s ease-in-out infinite;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* Ensure light theme logo has no glow */
html[data-resolved-theme="light"] .welcome-hero-image-light {
    filter: none;
    animation: none;
}

