/* ============================================================
   Quiet-luxury design system
   Warm-neutral ramp + signature copper accent (on-brand "Rusty").
   Shared, theme-agnostic tokens live here.
   ============================================================ */
:root {
    --sidebar-width: 16.5rem;
    --sidebar-rail-width: 3.25rem;
    --font-sans: "Figtree", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Monaco, Consolas, monospace;

    /* Signature copper — the one accent, used sparingly */
    --copper-400: #d79466;
    --copper-500: #c97f4e;
    --copper-600: #b56a3c;

    /* Radius scale */
    --radius-xs: 6px;
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --radius-pill: 999px;

    /* Motion — calm, precise */
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
    --dur-fast: 120ms;
    --dur: 200ms;
    --dur-slow: 340ms;
}

:root,
[data-bs-theme="light"] {
    --bg-app: #faf9f7;
    --bg-sidebar: #f2f0ec;
    --bg-elevated: #ffffff;
    --bg-input: #ffffff;
    --bg-composer: #ffffff;
    --bg-message-user: #efece7;
    --bg-message-assistant: transparent;
    --border-subtle: rgba(35, 30, 24, 0.10);
    --border-strong: rgba(35, 30, 24, 0.16);
    --text-primary: #1b1815;
    --text-secondary: #6a655d;
    --text-tertiary: #938d83;
    --accent: var(--copper-600);
    --accent-hover: var(--copper-500);
    --accent-contrast: #ffffff;
    --accent-soft: rgba(181, 106, 60, 0.12);
    --accent-ring: rgba(181, 106, 60, 0.35);
    --hover-bg: rgba(35, 30, 24, 0.05);
    --hover-bg-strong: rgba(35, 30, 24, 0.09);
    --focus-border: var(--accent-ring);
    --code-bg: rgba(35, 30, 24, 0.06);
    --pre-bg: #f4f1ec;
    --send-bg: #1b1815;
    --send-color: #faf9f7;
    --send-hover-bg: #322c26;
    --shadow-sm: 0 1px 2px rgba(24, 20, 16, 0.06);
    --shadow-md: 0 4px 16px rgba(24, 20, 16, 0.08);
    --shadow-lg: 0 12px 40px rgba(24, 20, 16, 0.12);
    --composer-shadow: 0 0 0 1px var(--border-subtle), 0 2px 12px rgba(24, 20, 16, 0.06);
}

[data-bs-theme="dark"] {
    --bg-app: #17150f;
    --bg-sidebar: #100e0a;
    --bg-elevated: #201d17;
    --bg-input: #201d17;
    --bg-composer: #211e18;
    --bg-message-user: #262219;
    --bg-message-assistant: transparent;
    --border-subtle: rgba(240, 232, 218, 0.09);
    --border-strong: rgba(240, 232, 218, 0.16);
    --text-primary: #f3efe7;
    --text-secondary: #a8a196;
    --text-tertiary: #7c756a;
    --accent: var(--copper-500);
    --accent-hover: var(--copper-400);
    --accent-contrast: #17150f;
    --accent-soft: rgba(201, 127, 78, 0.16);
    --accent-ring: rgba(201, 127, 78, 0.40);
    --hover-bg: rgba(240, 232, 218, 0.06);
    --hover-bg-strong: rgba(240, 232, 218, 0.10);
    --focus-border: var(--accent-ring);
    --code-bg: rgba(0, 0, 0, 0.32);
    --pre-bg: #141109;
    --send-bg: #f3efe7;
    --send-color: #17150f;
    --send-hover-bg: #ffffff;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 6px 22px rgba(0, 0, 0, 0.44);
    --shadow-lg: 0 18px 50px rgba(0, 0, 0, 0.55);
    --composer-shadow: 0 0 0 1px var(--border-subtle), 0 8px 30px rgba(0, 0, 0, 0.38);
}

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

html,
body {
    height: 100%;
    margin: 0;
}

body.app-body {
    background: var(--bg-app);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    letter-spacing: normal;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    position: fixed;
    inset: 0;
    top: var(--app-offset-top, 0px);
    width: 100%;
    height: var(--app-height, 100%);
    max-height: var(--app-height, 100%);
    overflow: hidden;
    overscroll-behavior: none;
}


html {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    /* 100dvh tracks the keyboard natively on modern iOS/Android (paired with
       interactive-widget=resizes-content). JS only overrides this while a modal
       is open, to keep the login sheet from being crushed by the keyboard. */
    --app-height: 100dvh;
    --app-offset-top: 0px;
}

@supports not (height: 100dvh) {
    html {
        --app-height: 100svh;
    }
}

@supports not (height: 100svh) {
    html {
        --app-height: 100vh;
    }
}

button,
input,
textarea,
select,
.app-shell {
    font-family: inherit;
}

.app-shell {
    background: var(--bg-app);
    position: relative;
    width: 100%;
    height: 100%;
    max-height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
}

@media (min-width: 768px) {
    html.sidebar-collapsed-init .app-shell:not(.sidebar-drawer-open) .sidebar {
        width: var(--sidebar-rail-width);
        min-width: var(--sidebar-rail-width);
        max-width: var(--sidebar-rail-width);
    }

    html.sidebar-collapsed-init .app-shell:not(.sidebar-drawer-open) .sidebar-panel {
        display: none !important;
    }

    html.sidebar-collapsed-init .app-shell:not(.sidebar-drawer-open) .sidebar-rail {
        display: flex !important;
    }
}

/* Guest vs logged-in panels */
.guest-only {
    display: none !important;
}

.guest-mode .guest-only {
    display: revert !important;
}

.guest-mode .guest-header-auth {
    display: flex !important;
    align-items: center;
    gap: 0.375rem;
    flex-shrink: 0;
}

.guest-mode .sidebar-nav-item.guest-only,
.guest-mode .sidebar-nav-list .guest-only.sidebar-nav-item {
    display: flex !important;
}

.guest-mode .sidebar-rail .guest-only {
    display: inline-flex !important;
}

.guest-mode .guest-cta-title,
.guest-mode .guest-cta-text {
    display: block !important;
}

.guest-mode .sidebar-guest-footer.guest-only {
    display: block !important;
    flex-shrink: 0;
}

.user-only {
    /* visible by default; flex children keep their layout */
}

.guest-mode .user-only {
    display: none !important;
}

.sidebar-rail-bottom .dropup.user-only {
    display: flex;
    justify-content: center;
}

.sidebar-nav-divider {
    height: 1px;
    margin: 0.375rem 0.75rem;
    background: var(--border-subtle);
    flex-shrink: 0;
}

.sidebar-guest-footer {
    flex-shrink: 0;
    margin-top: auto;
    padding: 1rem 1rem 1.125rem;
    border-top: 1px solid var(--border-subtle);
}

.guest-cta-title {
    margin: 0 0 0.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.35;
    color: var(--text-primary);
}

.guest-cta-text {
    margin: 0 0 0.875rem;
    font-size: 0.8125rem;
    font-weight: 400;
    line-height: 1.45;
    color: var(--text-secondary);
}

.guest-auth-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.9375rem;
    font-weight: 500;
    line-height: 1.4;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
    transition: color 0.15s ease, opacity 0.15s ease;
}

.guest-auth-link:hover {
    color: var(--accent);
}

.guest-auth-link--emphasis {
    font-size: 1rem;
    font-weight: 600;
}

.guest-mode .guest-header-auth .guest-auth-link {
    text-decoration: none;
    padding: 0.375rem 0.625rem;
    border-radius: 0.5rem;
}

.guest-mode .guest-header-auth .guest-auth-link:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
    text-decoration: none;
}

.sidebar-guest-footer .guest-auth-link,
.sidebar-footer.guest-only .guest-auth-link {
    width: 100%;
    justify-content: flex-start;
    text-align: left;
}

.composer-guest-cta .guest-auth-link {
    flex-shrink: 0;
    white-space: nowrap;
    text-decoration: none;
    border-radius: 999px;
    background: var(--text-primary);
    color: var(--bg-app);
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1;
    padding: 0.5625rem 1rem;
    transition: opacity 0.15s ease, transform 0.12s ease;
}

.composer-guest-cta .guest-auth-link:hover {
    color: var(--bg-app);
    opacity: 0.92;
}

.composer-guest-cta .guest-auth-link:active {
    transform: scale(0.98);
}

.btn-guest-login {
    background: var(--bg-input);
    border: none;
    color: var(--text-primary);
    border-radius: 999px;
    padding: 0.5625rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25;
    transition: background 0.15s ease;
}

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

.guest-cta-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.btn-guest-signup {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    border-radius: 999px;
    padding: 0.5625rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25;
    transition: background 0.15s ease;
}

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

.auth-continue-btn.is-loading,
.auth-continue-btn:disabled {
    opacity: 0.92;
    pointer-events: none;
    cursor: wait;
}

.auth-btn-spinner {
    display: none;
    width: 1.125rem;
    height: 1.125rem;
    border-radius: 999px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #ffffff;
    animation: thinkingSpin 0.75s linear infinite;
    flex-shrink: 0;
}

.auth-continue-btn-light .auth-btn-spinner {
    border-color: rgba(255, 255, 255, 0.35);
    border-top-color: #ffffff;
}

.auth-continue-btn.is-loading .auth-btn-spinner {
    display: inline-block;
    position: absolute;
    left: 50%;
    top: 50%;
    margin: -0.5625rem 0 0 -0.5625rem;
}

.auth-continue-btn.is-loading .auth-btn-label,
.auth-continue-btn.is-loading .auth-continue-arrow {
    opacity: 0;
}

.auth-text-btn.is-loading,
.auth-text-btn:disabled,
.auth-forgot-link.is-loading,
.auth-forgot-link:disabled,
.auth-oauth-btn.is-loading,
.auth-oauth-btn:disabled {
    opacity: 0.72;
    pointer-events: none;
    cursor: wait;
}

.auth-text-btn .auth-btn-spinner--inline,
.auth-forgot-link .auth-btn-spinner--inline {
    display: none;
    width: 0.875rem;
    height: 0.875rem;
    border-color: rgba(29, 29, 31, 0.14);
    border-top-color: var(--accent);
}

.auth-btn-spinner--oauth {
    display: none;
    position: absolute;
    left: 50%;
    top: 50%;
    z-index: 3;
    margin: -0.5625rem 0 0 -0.5625rem;
    border-color: rgba(29, 29, 31, 0.14);
    border-top-color: #1d1d1f;
}

[data-bs-theme="dark"] .auth-btn-spinner--oauth {
    border-color: rgba(255, 255, 255, 0.2);
    border-top-color: #f5f5f7;
}

.auth-text-btn.is-loading .auth-btn-spinner--inline,
.auth-forgot-link.is-loading .auth-btn-spinner--inline {
    display: inline-block;
}

.auth-oauth-btn.is-loading .auth-btn-spinner--oauth {
    display: inline-block;
}

.auth-text-btn.is-loading .auth-btn-label,
.auth-forgot-link.is-loading .auth-btn-label {
    opacity: 0.45;
}

.auth-oauth-btn.is-loading .auth-oauth-label,
.auth-oauth-btn.is-loading .auth-oauth-icon {
    opacity: 0;
}

.auth-forgot-link {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--accent);
    font-size: 0.8125rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
}

.guest-mode .sidebar-bottom {
    display: none !important;
}

.guest-mode .sidebar-panel {
    flex: 1 1 auto;
    min-height: 100%;
    height: 100%;
}

.guest-mode .sidebar-offcanvas .sidebar-footer.guest-only {
    margin-top: auto;
}

.guest-mode .sidebar-top {
    padding-bottom: 0.25rem;
}

/* Guest header: Log in link only */
.guest-mode .chat-header {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
}

.guest-mode .chat-title {
    display: none;
}

.guest-mode .chat-header-start:empty {
    display: none;
}

.guest-mode .chat-header-actions > .btn-theme-toggle {
    display: none !important;
}

.btn-auth-header-solid {
    background: var(--text-primary);
    color: var(--bg-sidebar);
    border: none;
    border-radius: 999px;
    padding: 0.4375rem 0.9375rem;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25;
    transition: opacity 0.15s ease;
}

.btn-auth-header-solid:hover {
    opacity: 0.88;
    color: var(--bg-sidebar);
}

.btn-auth-header-outline {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    border-radius: 999px;
    padding: 0.4375rem 0.9375rem;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25;
    transition: background 0.15s ease;
}

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

@media (max-width: 767px) {
    .guest-mode .chat-header {
        justify-content: space-between;
    }

    .guest-mode .chat-header-start:empty {
        display: none;
    }

    .guest-mode .chat-header-start:not(:empty) {
        display: flex;
    }

    .btn-auth-header-solid,
    .btn-auth-header-outline {
        padding: 0.375rem 0.75rem;
        font-size: 0.8125rem;
        white-space: nowrap;
        flex-shrink: 0;
    }

    .chat-header-actions {
        gap: 0.25rem;
        flex-shrink: 0;
    }

    .guest-mode .guest-header-auth {
        gap: 0.375rem;
    }
}

/* Guest: hide assistant avatar too (user avatars hidden globally below) */
.guest-mode .message-row.assistant .message-avatar {
    display: none;
}

.guest-mode:not(.guest-show-welcome) #welcomeScreen {
    display: none !important;
}

.guest-mode.guest-show-welcome #welcomeScreen {
    display: flex !important;
}

.sidebar-nav-list {
    display: flex;
    flex-direction: column;
    gap: 0.0625rem;
    padding: 0.125rem 0;
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    width: 100%;
    border: none;
    background: transparent;
    color: var(--text-primary);
    text-align: left;
    padding: 0.5rem 0.75rem;
    border-radius: 0.625rem;
    font-size: 0.875rem;
    font-weight: 400;
    line-height: 1.25rem;
    transition: background 0.15s ease;
    cursor: pointer;
}

.sidebar-nav-item span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-nav-item:hover {
    background: var(--hover-bg);
}

.sidebar-nav-item.active {
    background: var(--accent-soft);
    color: var(--text-primary);
}

.sidebar-nav-item.active .sidebar-icon {
    color: var(--accent);
}

.sidebar-nav-item:active {
    background: var(--hover-bg-strong);
}

.sidebar-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.125rem;
    height: 1.125rem;
    flex-shrink: 0;
    color: var(--text-primary);
    opacity: 1;
}

.sidebar-icon svg {
    width: 1.125rem;
    height: 1.125rem;
    display: block;
}

.sidebar-nav-item .sidebar-icon svg {
    width: 1.0625rem;
    height: 1.0625rem;
}

.sidebar-rail-btn .sidebar-icon {
    width: 1.375rem;
    height: 1.375rem;
    opacity: 1;
}

.sidebar-rail-btn .sidebar-icon svg {
    width: 1.1875rem;
    height: 1.1875rem;
}

.btn-sidebar-toggle .sidebar-icon svg {
    width: 1.0625rem;
    height: 1.0625rem;
}

.sidebar-search .sidebar-icon {
    opacity: 0.55;
    color: var(--text-secondary);
}

.sidebar-search .sidebar-icon svg {
    width: 1rem;
    height: 1rem;
}

.btn-sidebar-toggle {
    opacity: 0.65;
    color: var(--text-secondary);
}

.btn-sidebar-toggle:hover {
    opacity: 1;
    color: var(--text-primary);
    background: var(--hover-bg);
}

/* ── Sidebar ─────────────────────────────────────────────── */

.sidebar,
.sidebar-offcanvas {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-subtle);
}

[data-bs-theme="dark"] .sidebar,
[data-bs-theme="dark"] .sidebar-offcanvas {
    border-right-color: rgba(255, 255, 255, 0.06);
}

.sidebar {
    min-height: 0;
    height: 100%;
    flex-shrink: 0;
    transition: width 0.28s ease, min-width 0.28s ease, box-shadow 0.28s ease;
    z-index: 1;
    overflow: hidden;
}

.sidebar-panel {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
}

.sidebar-rail {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    height: 100%;
    padding: 0.625rem 0;
    flex-shrink: 0;
}

.sidebar-rail-top,
.sidebar-rail-bottom {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.125rem;
    width: 100%;
}

.sidebar-rail-btn {
    width: 2.25rem;
    height: 2.25rem;
    border: none;
    background: transparent;
    color: var(--text-primary);
    border-radius: 0.625rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s ease;
}

.sidebar-rail-btn i {
    font-size: 1.125rem;
    line-height: 1;
}

.sidebar-rail-btn:hover {
    background: var(--hover-bg);
}

.sidebar-rail-btn.active {
    background: var(--hover-bg-strong);
}

.sidebar-rail-avatar {
    padding: 0;
}

.sidebar-rail-avatar .user-avatar-btn {
    width: 1.75rem;
    height: 1.75rem;
    font-size: 0.625rem;
}

/* Collapsed: narrow icon rail (ChatGPT-style) */
.app-shell.sidebar-collapsed:not(.sidebar-drawer-open) .sidebar {
    width: var(--sidebar-rail-width);
    min-width: var(--sidebar-rail-width);
    max-width: var(--sidebar-rail-width);
    opacity: 1;
    pointer-events: auto;
    border-right: 1px solid var(--border-subtle);
}

.app-shell.sidebar-collapsed:not(.sidebar-drawer-open) .sidebar-panel {
    display: none !important;
}

.app-shell.sidebar-collapsed:not(.sidebar-drawer-open) .sidebar-rail {
    display: flex !important;
}

/* Collapsed rail: the account dropup must escape the narrow column
   instead of being clipped, and paint above the composer (z:20). */
.app-shell.sidebar-collapsed:not(.sidebar-drawer-open) .sidebar {
    overflow: visible;
    position: relative;
    z-index: 40;
}

.sidebar-rail-bottom .user-menu {
    min-width: 12rem;
    margin-left: 0.375rem;
    margin-bottom: 0.5rem;
    z-index: 1200;
}

.app-shell.sidebar-drawer-open .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    max-width: var(--sidebar-width);
    opacity: 1;
    pointer-events: auto;
    z-index: 1050;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.35);
}

.app-shell.sidebar-drawer-open .sidebar-panel {
    display: flex !important;
}

.app-shell.sidebar-drawer-open .sidebar-rail {
    display: none !important;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1040;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

@media (min-width: 768px) {
    .app-shell.sidebar-drawer-open .sidebar-backdrop:not([hidden]) {
        display: block;
        opacity: 1;
        pointer-events: auto;
    }
}

/* ── Search gate popover (guest) ─────────────────────────── */

.search-gate-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1055;
    background: transparent;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.22s ease;
}

.search-gate-backdrop:not([hidden]) {
    pointer-events: auto;
}

.search-gate-backdrop.is-visible {
    opacity: 1;
    background: rgba(0, 0, 0, 0.42);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.search-gate-popover {
    position: fixed;
    z-index: 1060;
    width: min(20rem, calc(100vw - 2rem));
    overflow: hidden;
    border-radius: 1.125rem;
    border: 1px solid var(--border-subtle);
    background: var(--bg-app);
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.04),
        0 24px 64px rgba(0, 0, 0, 0.38);
    opacity: 0;
    transform: translateY(8px) scale(0.98);
    transition:
        opacity 0.24s ease,
        transform 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-bs-theme="light"] .search-gate-popover {
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.06),
        0 24px 64px rgba(0, 0, 0, 0.16);
}

.search-gate-popover:not([hidden]) {
    display: block;
}

.search-gate-popover.is-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.search-gate-popover.search-gate-popover--centered {
    transform: translate(-50%, -50%) translateY(8px) scale(0.98);
}

.search-gate-popover.search-gate-popover--centered.is-visible {
    transform: translate(-50%, -50%) scale(1);
}

.search-gate-close {
    position: absolute;
    top: 0.625rem;
    right: 0.625rem;
    z-index: 2;
    width: 1.75rem;
    height: 1.75rem;
    border: none;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.28);
    color: rgba(255, 255, 255, 0.92);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 0.8125rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.search-gate-close:hover {
    background: rgba(0, 0, 0, 0.42);
    color: #fff;
}

.search-gate-hero {
    position: relative;
    height: 4.75rem;
    overflow: hidden;
    background:
        radial-gradient(ellipse 80% 70% at 20% 100%, rgba(255, 255, 255, 0.1) 0%, transparent 55%),
        radial-gradient(ellipse 60% 55% at 85% 10%, rgba(255, 255, 255, 0.07) 0%, transparent 50%),
        linear-gradient(165deg, #a3a3a3 0%, #737373 28%, #525252 55%, #262626 100%);
}

.search-gate-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
    background-size: 20px 20px;
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.5) 0%, transparent 90%);
    pointer-events: none;
}

.search-gate-hero-icon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.92);
}

.search-gate-hero-icon .sidebar-icon {
    width: 1.75rem;
    height: 1.75rem;
    opacity: 1;
}

.search-gate-hero-icon .sidebar-icon svg {
    width: 1.625rem;
    height: 1.625rem;
    stroke-width: 1.5;
}

.search-gate-content {
    padding: 1.125rem 1.25rem 1.25rem;
}

.search-gate-title {
    margin: 0 0 0.375rem;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
}

.search-gate-text {
    margin: 0 0 1.125rem;
    font-size: 0.875rem;
    font-weight: 400;
    line-height: 1.5;
    color: var(--text-secondary);
}

.search-gate-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.search-gate-btn-solid {
    width: 100%;
    padding: 0.625rem 1rem;
    border: none;
    border-radius: 999px;
    background: var(--text-primary);
    color: var(--bg-app);
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25;
    transition: opacity 0.15s ease;
}

.search-gate-btn-solid:hover {
    opacity: 0.9;
    color: var(--bg-app);
}

.search-gate-btn-ghost {
    width: 100%;
    padding: 0.625rem 1rem;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25;
    transition: color 0.15s ease, background 0.15s ease;
}

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

@media (prefers-reduced-motion: reduce) {
    .search-gate-popover,
    .search-gate-backdrop {
        transition: none;
    }
}

.btn-dock-sidebar:not([hidden]) {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    background: var(--hover-bg);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    margin-bottom: 0.5rem;
}

.sidebar-top {
    flex-shrink: 0;
    padding: 0.75rem 0.625rem 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.375rem;
    min-height: 2rem;
    padding: 0 0.125rem;
    margin-bottom: 0.125rem;
}

.sidebar-logo {
    display: block;
    padding: 0.125rem 0.25rem;
    text-decoration: none;
    line-height: 0;
}

.sidebar-logo-img .rusty-logo {
    max-height: 1.25rem;
    max-width: 5rem;
}

.sidebar-search {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.625rem;
    border-radius: 0.5rem;
    background: var(--hover-bg);
    color: var(--text-secondary);
}

.sidebar-search-input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.8125rem;
    outline: none;
    padding: 0;
}

.sidebar-search-input::placeholder {
    color: var(--text-secondary);
}

.sidebar-conversations {
    min-height: 0;
    overflow-y: auto;
    padding: 0.25rem 0.5rem;
}

.sidebar-bottom {
    flex-shrink: 0;
    padding: 0.625rem 0.625rem 0.75rem;
    border-top: 1px solid var(--border-subtle);
}

.sidebar-user-btn {
    width: 100%;
    border: none;
    background: transparent;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.375rem;
    border-radius: 0.5rem;
    text-align: left;
    transition: background 0.15s;
}

.sidebar-user-btn:hover {
    background: var(--hover-bg);
}

.sidebar-user-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.875rem;
}

.user-avatar-btn {
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 0.6875rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.user-menu {
    min-width: 13rem;
}

.user-menu-header {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.4375rem 0.5rem 0.5rem;
}

.user-menu-avatar {
    width: 2rem;
    height: 2rem;
    flex-shrink: 0;
    font-size: 0.6875rem;
}

.user-menu-identity {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.25;
}

.user-menu-name {
    font-size: 0.875rem;
    font-weight: 550;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-menu-email {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-menu .dropdown-divider {
    margin: 0.125rem 0.25rem 0.3125rem;
    border-color: var(--border-subtle);
}

.user-menu .dropdown-item {
    display: flex;
    align-items: center;
    font-size: 0.9rem;
    font-weight: 450;
    letter-spacing: -0.003em;
    padding: 0.5625rem 0.5625rem;
}

.user-menu .dropdown-item i {
    width: 1.25rem;
    font-size: 1.05rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--text-secondary);
}

.user-menu .dropdown-item:hover i,
.user-menu .dropdown-item:focus-visible i {
    color: var(--text-primary);
}

.offcanvas-header {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
    align-items: center;
}

.sidebar-footer {
    flex-shrink: 0;
    padding: 0.75rem;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.sidebar-footer.guest-only {
    border-top: 1px solid var(--border-subtle);
    padding: 1rem;
    gap: 0;
}

.sidebar-footer-actions {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.sidebar-footer-actions .btn-auth {
    flex: 1;
    min-width: 0;
}

.btn-new-chat {
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    border-radius: 0.625rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.625rem;
    transition: background 0.15s;
}

.btn-new-chat i {
    font-size: 1rem;
    opacity: 0.85;
}

.btn-new-chat:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
    border-color: var(--border-subtle);
}

.conversation-row {
    display: flex;
    align-items: center;
    gap: 0.125rem;
    width: 100%;
    border-radius: 0.5rem;
    transition: background 0.15s;
}

.conversation-row:hover,
.conversation-row:focus-within {
    background: var(--hover-bg);
}

.conversation-row.active {
    background: var(--hover-bg-strong);
}

.conversation-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    text-align: left;
    padding: 0.5rem 0.375rem 0.5rem 0.625rem;
    border-radius: 0.5rem;
    font-size: 0.8125rem;
    transition: color 0.15s;
}

.conversation-row:hover .conversation-item,
.conversation-row:focus-within .conversation-item,
.conversation-row.active .conversation-item {
    color: var(--text-primary);
}

.conversation-item .conv-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.conversation-menu {
    flex-shrink: 0;
    margin-right: 0.15rem;
}

.conversation-menu-btn,
.project-action-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.65rem;
    height: 1.65rem;
    border: none;
    border-radius: 0.375rem;
    background: transparent;
    color: var(--text-secondary);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s, color 0.15s, background 0.15s;
}

.conversation-row:hover .conversation-menu-btn,
.conversation-row:focus-within .conversation-menu-btn,
.conversation-row.active .conversation-menu-btn,
.project-row:hover .project-action-btn,
.project-row:focus-within .project-action-btn,
.conversation-menu.show .conversation-menu-btn,
.project-row .dropdown.show .project-action-btn {
    opacity: 1;
    pointer-events: auto;
}

.conversation-menu-btn:hover,
.conversation-menu-btn:focus-visible,
.project-action-btn:hover,
.project-action-btn:focus-visible {
    color: var(--text-primary);
    background: var(--hover-bg-strong);
}

@media (hover: none) {
    .conversation-menu-btn,
    .project-action-btn {
        opacity: 0.85;
        pointer-events: auto;
    }
}

.conversation-menu-dropdown {
    min-width: 11.5rem;
    max-height: 16rem;
    overflow-y: auto;
}

.conversation-row--nested .conversation-item {
    padding-left: 1.35rem;
}

.projects-block {
    margin-bottom: 0.25rem;
}

.project-section {
    margin-bottom: 0.15rem;
}

.project-row {
    display: flex;
    align-items: center;
    gap: 0.1rem;
    border-radius: 0.5rem;
    transition: background 0.15s;
}

.project-row:hover,
.project-row:focus-within,
.project-section.is-active-project > .project-row {
    background: var(--hover-bg);
}

.project-toggle {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    color: var(--text-primary);
    text-align: left;
    padding: 0.45rem 0.35rem 0.45rem 0.45rem;
    border-radius: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 500;
}

.project-chevron {
    font-size: 0.7rem;
    opacity: 0.7;
    flex-shrink: 0;
}

.project-folder-icon {
    font-size: 0.9rem;
    opacity: 0.85;
    flex-shrink: 0;
    color: var(--text-secondary);
}

.project-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.project-count {
    flex-shrink: 0;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 1rem;
    text-align: right;
}

.project-chats {
    padding-bottom: 0.15rem;
}

.project-empty-hint {
    margin: 0;
    padding: 0.25rem 0.5rem 0.5rem 1.75rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.conv-group-label {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-secondary);
    padding: 0.75rem 0.625rem 0.375rem;
    margin: 0;
}

.conv-group-label:first-child {
    padding-top: 0.25rem;
}

.sidebar-offcanvas .conversation-item i {
    flex-shrink: 0;
    opacity: 0.7;
}

.user-badge {
    color: var(--text-secondary);
    font-size: 0.8125rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-auth {
    border: 1px solid var(--border-subtle);
    background: transparent;
    color: var(--text-primary);
    border-radius: 0.5rem;
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
}

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

/* ── Main chat area ──────────────────────────────────────── */

.chat-main {
    background: var(--bg-app);
    min-width: 0;
    min-height: 0;
}

.chat-header {
    flex-shrink: 0;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.5rem;
    min-height: 3rem;
    padding: 0 0.75rem;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-app);
}

[data-bs-theme="dark"] .chat-header {
    border-bottom-color: rgba(255, 255, 255, 0.06);
}

@media (min-width: 768px) {
    .chat-header {
        grid-template-columns: auto 1fr auto;
        padding: 0 1.25rem;
    }

    .chat-header-start {
        display: flex;
        align-items: center;
        gap: 0.375rem;
        min-width: 0;
    }

    .guest-mode .chat-header-start:empty {
        display: none;
    }
}

.chat-header-start {
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

.chat-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.25;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

@media (min-width: 768px) {
    .chat-title {
        text-align: left;
        font-size: 1.0625rem;
    }
}

.chat-header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.125rem;
    flex-shrink: 0;
    min-width: 0;
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-primary);
    width: 2.25rem;
    height: 2.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    padding: 0;
    flex-shrink: 0;
}

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

.chat-main {
    background: var(--bg-app);
    min-width: 0;
    min-height: 0;
    flex: 1 1 auto;
    overflow: hidden;
}

.chat-workspace {
    position: relative;
    width: 100%;
    min-height: 0;
}

.chat-view {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    min-width: 0;
}

/* Document editor covers the main area (same screen, never side-by-side). */
.chat-workspace.doc-editor-open .chat-view {
    display: none !important;
}

/* ── Document editor panel (articles, letters, long-form) ─ */

.doc-editor-panel {
    display: none;
    flex-direction: column;
    position: absolute;
    inset: 0;
    width: 100%;
    min-width: 0;
    min-height: 0;
    background: var(--bg-app);
    z-index: 8;
}

.chat-workspace.doc-editor-open .doc-editor-panel {
    display: flex !important;
    animation: docEditorIn 0.22s ease;
}

@keyframes docEditorIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.doc-editor-status {
    flex-shrink: 0;
    padding: 0.45rem 1rem;
    max-width: 48rem;
    width: 100%;
    margin: 0 auto;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-subtle);
}

.doc-editor-status:not(.d-none)::before {
    content: '';
    display: inline-block;
    width: 0.45rem;
    height: 0.45rem;
    margin-right: 0.45rem;
    border-radius: 50%;
    background: var(--accent, #3b82f6);
    vertical-align: middle;
    animation: docStatusPulse 1.1s ease-in-out infinite;
}

@keyframes docStatusPulse {
    0%, 100% { opacity: 0.35; }
    50% { opacity: 1; }
}

.doc-editor-streaming-hint {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    margin: 0;
}

.doc-editor-waiting {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    padding-top: 0.5rem;
}

.doc-editor-pulse {
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    border: 2px solid var(--border-subtle);
    border-top-color: var(--accent, #3b82f6);
    animation: docSpin 0.7s linear infinite;
}

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

.doc-editor-stream-text {
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
}

.doc-stream-caret {
    display: inline-block;
    width: 0.55rem;
    height: 1.1em;
    margin-left: 1px;
    vertical-align: text-bottom;
    background: var(--text-primary);
    animation: docCaretBlink 0.9s steps(1) infinite;
}

@keyframes docCaretBlink {
    50% { opacity: 0; }
}

.doc-editor-preview.is-streaming-doc {
    scroll-behavior: auto;
}

.doc-editor-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
    max-width: 48rem;
    width: 100%;
    margin: 0 auto;
}

.doc-editor-heading {
    min-width: 0;
    flex: 1;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.doc-editor-back {
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.doc-editor-heading-text {
    min-width: 0;
    flex: 1;
}

.doc-editor-kicker {
    display: block;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.doc-editor-title {
    margin: 0;
    font-size: 1.0625rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.doc-editor-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
}

.doc-editor-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border: none;
    border-radius: 0.5rem;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1;
    padding: 0.45rem 0.55rem;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.doc-editor-btn:hover,
.doc-editor-btn[aria-pressed="true"] {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.doc-editor-btn-close {
    padding: 0.45rem;
}

.doc-editor-btn span {
    display: none;
}

@media (min-width: 720px) {
    .doc-editor-btn span {
        display: inline;
    }
}

.doc-editor-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.doc-editor-preview {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 1.25rem 1.35rem 2rem;
    max-width: 48rem;
    width: 100%;
    margin: 0 auto;
    -webkit-overflow-scrolling: touch;
}

.doc-editor-preview h1 {
    font-size: 1.5rem;
    margin-top: 0;
}

.doc-editor-preview h2 {
    font-size: 1.2rem;
}

.doc-editor-textarea {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    max-width: 48rem;
    margin: 0 auto;
    border: none;
    resize: none;
    outline: none;
    padding: 1.25rem 1.35rem 2rem;
    background: var(--bg-app);
    color: var(--text-primary);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.875rem;
    line-height: 1.55;
}

.chat-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.chat-messages.is-streaming {
    scroll-behavior: auto;
}

.guest-mode.guest-show-welcome .chat-messages {
    display: flex;
    flex-direction: column;
}

/* ── Welcome screen ──────────────────────────────────────── */

.welcome-screen {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1.5rem 2rem;
    min-height: min(100%, 32rem);
}

.welcome-inner {
    width: 100%;
    max-width: 42rem;
    text-align: center;
    margin: 0 auto;
}

.welcome-logo {
    margin-bottom: 1.5rem;
    line-height: 0;
}

/* ── Rusty logo (theme-aware) ────────────────────────────── */

.rusty-logo-wrap {
    display: inline-block;
    line-height: 0;
}

.rusty-logo {
    display: block;
    width: auto;
    object-fit: contain;
}

.rusty-logo-dark {
    display: none;
}

.rusty-logo-red {
    display: none;
}

[data-bs-theme="dark"] .rusty-logo-light {
    display: none;
}

[data-bs-theme="dark"] .rusty-logo-dark {
    display: block;
}

body.is-rustyred-mode .rusty-logo-light,
body.is-rustyred-mode .rusty-logo-dark {
    display: none !important;
}

body.is-rustyred-mode .rusty-logo-red {
    display: block !important;
}

.sidebar-logo-img .rusty-logo-wrap {
    display: inline-block;
}

.offcanvas-brand {
    flex: 1;
    min-width: 0;
}

.offcanvas-brand-logo .rusty-logo {
    max-height: 2.25rem;
    max-width: 10rem;
}

.welcome-logo-img .rusty-logo {
    max-height: 5.5rem;
    max-width: min(14rem, 70vw);
    margin: 0 auto;
}

body.is-rustyred-mode .welcome-logo-img .rusty-logo-red {
    max-height: min(16.5rem, 42vh);
    max-width: min(22rem, 88vw);
}

body.is-rustyred-mode .welcome-logo {
    margin-bottom: 1.75rem;
}

body.is-rustyred-mode .welcome-heading {
    letter-spacing: -0.02em;
    color: #fb7185;
    font-size: clamp(1.35rem, 3.2vw, 1.85rem);
}

body.is-rustyred-mode .welcome-subtext {
    color: rgba(252, 165, 165, 0.82);
}

/* ── RustyRed mode theme + transition + ambient fire ───── */

body.is-rustyred-mode {
    --bg-app: #120306;
    --bg-sidebar: #0a0204;
    --bg-input: #2a0a12;
    --bg-composer: #2a0a12;
    --bg-message-user: #3a1018;
    --border-subtle: rgba(225, 29, 72, 0.28);
    --accent: #e11d48;
    --text-primary: #ffe4e6;
    --text-secondary: #fda4af;
    --hover-bg: rgba(225, 29, 72, 0.12);
}

body.is-rustyred-mode .app-shell,
body.is-rustyred-mode .chat-main,
body.is-rustyred-mode .chat-view {
    background: #120306 !important;
}

body.is-rustyred-mode .chat-header {
    border-bottom: none !important;
    box-shadow: none !important;
    background: #120306 !important;
}

body.is-rustyred-mode .chat-messages {
    position: relative;
    z-index: 1;
    background: transparent !important;
}

body.is-rustyred-mode .chat-input-area {
    position: relative;
    z-index: 2;
    border-top: none !important;
    box-shadow: none !important;
    background: #120306 !important;
}

body.is-rustyred-mode .chat-composer {
    border: 1px solid rgba(225, 29, 72, 0.55) !important;
    box-shadow: 0 0 0 1px rgba(127, 29, 29, 0.5), 0 0 40px rgba(225, 29, 72, 0.25);
    background: rgba(40, 8, 14, 0.95) !important;
}

body.is-rustyred-mode .composer-mode-trigger.is-rustyred,
body.is-rustyred-mode .composer-mode-trigger.is-rustyred .composer-mode-trigger-label {
    color: #fb7185 !important;
    text-shadow: 0 0 14px rgba(225, 29, 72, 0.7);
}

body.is-rustyred-mode .btn-send {
    background: #e11d48 !important;
    border-color: #be123c !important;
    color: #fff !important;
    box-shadow: 0 0 18px rgba(225, 29, 72, 0.55);
}

body.is-rustyred-mode .btn-send:hover:not(:disabled) {
    background: #fb7185 !important;
}

body.is-rustyred-mode .message-row.assistant .message-bubble {
    border: 1px solid rgba(225, 29, 72, 0.25);
    background: rgba(40, 8, 14, 0.55);
}

body.is-rustyred-mode .sidebar,
body.is-rustyred-mode .sidebar-offcanvas,
body.is-rustyred-mode .sidebar-panel,
body.is-rustyred-mode .sidebar-rail {
    border: none !important;
    border-right: none !important;
    background: #120306 !important;
    box-shadow: none !important;
}

body.is-rustyred-mode .sidebar-nav-item,
body.is-rustyred-mode .sidebar-rail-btn {
    color: #fda4af;
}

body.is-rustyred-mode .sidebar-nav-item:hover,
body.is-rustyred-mode .sidebar-rail-btn:hover {
    background: rgba(225, 29, 72, 0.14);
    color: #fecaca;
}

body.is-rustyred-mode .sidebar-nav-item.active,
body.is-rustyred-mode .sidebar-rail-btn.active {
    background: rgba(225, 29, 72, 0.2);
    color: #fb7185;
}

body.is-rustyred-mode .sidebar-search,
body.is-rustyred-mode .sidebar-search-input {
    background: rgba(40, 8, 14, 0.85) !important;
    border-color: rgba(225, 29, 72, 0.25) !important;
    color: #ffe4e6;
}

body.is-rustyred-mode .sidebar-guest-footer,
body.is-rustyred-mode .sidebar-nav-divider,
body.is-rustyred-mode .sidebar-top,
body.is-rustyred-mode .sidebar-conversations,
body.is-rustyred-mode .sidebar-footer {
    border: none !important;
    border-color: transparent !important;
}

body.is-rustyred-mode .input-hint {
    color: rgba(252, 165, 165, 0.55);
}

body.is-rustyred-mode .welcome-inner {
    position: relative;
    z-index: 2;
}

body.rustyred-transition-lock {
    overflow: hidden !important;
}

body.rustyred-transition-lock .app-shell {
    pointer-events: none;
    user-select: none;
}

.rustyred-transition {
    position: fixed;
    inset: 0;
    z-index: 2147483000;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(ellipse at center, rgba(127, 29, 29, 0.7), transparent 50%),
        linear-gradient(180deg, #2a060a 0%, #050001 45%, #3b0a10 100%);
    overflow: hidden;
    opacity: 1;
    visibility: visible;
}

.rustyred-transition.d-none {
    display: none !important;
}

.rustyred-transition.is-leaving {
    animation: rustyred-fade-out 0.8s ease forwards;
}

.rustyred-transition-embers {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at 20% 110%, rgba(239, 68, 68, 0.55), transparent 42%),
        radial-gradient(circle at 80% 120%, rgba(251, 146, 60, 0.4), transparent 45%),
        radial-gradient(circle at 50% 100%, rgba(225, 29, 72, 0.55), transparent 55%);
    animation: rustyred-ember-pulse 1.8s ease-in-out infinite;
}

.rustyred-transition-flames {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 45%;
    pointer-events: none;
    background:
        radial-gradient(ellipse 40% 80% at 20% 100%, rgba(251, 146, 60, 0.65), transparent 70%),
        radial-gradient(ellipse 50% 100% at 50% 110%, rgba(225, 29, 72, 0.8), transparent 70%),
        radial-gradient(ellipse 40% 80% at 80% 100%, rgba(185, 28, 28, 0.7), transparent 70%);
    filter: blur(8px);
    animation: rustyred-flames 1.2s ease-in-out infinite alternate;
}

.rustyred-transition-inner {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 2rem;
    max-width: 30rem;
}

.rustyred-transition-logo {
    width: min(16rem, 58vw);
    height: auto;
    display: block;
    margin: 0 auto 1.25rem;
    filter: drop-shadow(0 0 36px rgba(225, 29, 72, 0.85));
    animation: rustyred-logo-pulse 1.6s ease-in-out infinite;
}

.rustyred-transition-kicker {
    margin: 0 0 0.5rem;
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.32em;
    color: #fb7185;
    text-shadow: 0 0 18px rgba(225, 29, 72, 0.9);
}

.rustyred-transition-title {
    margin: 0 0 0.5rem;
    font-size: clamp(1.5rem, 4.5vw, 2.1rem);
    font-weight: 800;
    color: #fecaca;
    text-shadow: 0 0 24px rgba(225, 29, 72, 0.55);
}

.rustyred-transition-sub {
    margin: 0 0 1rem;
    font-size: 1rem;
    color: rgba(252, 165, 165, 0.9);
}

.rustyred-transition-count {
    margin: 0 0 1.25rem;
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1;
    color: #e11d48;
    text-shadow: 0 0 20px rgba(225, 29, 72, 0.9);
    font-variant-numeric: tabular-nums;
}

.rustyred-transition-bar {
    height: 4px;
    width: min(18rem, 72vw);
    margin: 0 auto;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    overflow: hidden;
}

.rustyred-transition-bar-fill {
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, #7f1d1d, #e11d48, #fb923c, #e11d48);
    box-shadow: 0 0 16px rgba(225, 29, 72, 0.95);
}

.rustyred-transition.is-active .rustyred-transition-bar-fill {
    animation: rustyred-bar-fill 10s linear forwards;
}

@keyframes rustyred-bar-fill {
    from { width: 0; }
    to { width: 100%; }
}

@keyframes rustyred-logo-pulse {
    0%, 100% { transform: scale(1); filter: drop-shadow(0 0 28px rgba(225, 29, 72, 0.7)); }
    50% { transform: scale(1.06); filter: drop-shadow(0 0 48px rgba(251, 113, 133, 1)); }
}

@keyframes rustyred-ember-pulse {
    0%, 100% { opacity: 0.8; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.08); }
}

@keyframes rustyred-flames {
    from { transform: translateY(8%) scaleY(0.92); opacity: 0.75; }
    to { transform: translateY(0) scaleY(1.05); opacity: 1; }
}

@keyframes rustyred-fade-out {
    to { opacity: 0; visibility: hidden; }
}

.chat-view {
    position: relative;
}

.rustyred-ambient {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.rustyred-ambient.d-none {
    display: none !important;
}

.rustyred-ambient-fire {
    position: absolute;
    left: -10%;
    right: -10%;
    bottom: -8%;
    height: 42%;
    background:
        radial-gradient(ellipse 35% 90% at 15% 100%, rgba(251, 146, 60, 0.55), transparent 70%),
        radial-gradient(ellipse 55% 110% at 50% 115%, rgba(225, 29, 72, 0.7), transparent 68%),
        radial-gradient(ellipse 35% 90% at 85% 100%, rgba(153, 27, 27, 0.6), transparent 70%);
    filter: blur(18px);
    animation: rustyred-flames 1.6s ease-in-out infinite alternate;
    opacity: 0.9;
}

.rustyred-ambient-fire--hot {
    height: 28%;
    filter: blur(10px);
    opacity: 0.75;
    animation-duration: 1.1s;
    animation-direction: alternate-reverse;
    mix-blend-mode: screen;
}

.rustyred-fire-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0.9;
}

.rustyred-ambient-vignette {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at center, transparent 30%, rgba(0, 0, 0, 0.55) 100%),
        linear-gradient(180deg, rgba(80, 0, 10, 0.25) 0%, transparent 35%, rgba(80, 0, 10, 0.35) 100%);
}

.rustyred-ambient-cracks {
    position: absolute;
    inset: 0;
    opacity: 0.35;
    background:
        repeating-linear-gradient(
            115deg,
            transparent 0 18px,
            rgba(225, 29, 72, 0.04) 18px 19px
        ),
        repeating-linear-gradient(
            -20deg,
            transparent 0 26px,
            rgba(251, 113, 133, 0.03) 26px 27px
        );
    mix-blend-mode: screen;
    animation: rustyred-ember-pulse 3.5s ease-in-out infinite;
}

.rustyred-watermark {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    /* Only behind real conversation turns — not the "Name your sin." welcome. */
    opacity: 0;
    visibility: hidden;
}

body.is-rustyred-mode:not(.has-chat-welcome) .rustyred-watermark {
    opacity: 1;
    visibility: visible;
}

.rustyred-watermark-logo {
    width: min(48vw, 300px);
    max-width: 300px;
    height: auto;
    opacity: 0.11;
    user-select: none;
    -webkit-user-drag: none;
    filter: drop-shadow(0 0 28px rgba(225, 29, 72, 0.35));
    transform-origin: center center;
    animation: rustyred-watermark-expand 5.2s ease-in-out infinite;
}

@keyframes rustyred-watermark-expand {
    0%,
    100% {
        transform: scale(0.86);
        opacity: 0.07;
    }
    50% {
        transform: scale(1.14);
        opacity: 0.16;
    }
}

@media (max-width: 575.98px) {
    .rustyred-watermark-logo {
        width: min(58vw, 220px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .rustyred-watermark-logo {
        animation: none;
        transform: scale(1);
        opacity: 0.1;
    }
}

.message-avatar-rusty {
    background: transparent !important;
    overflow: hidden;
    padding: 0.125rem;
}

.message-avatar-rusty .rusty-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.welcome-heading {
    margin: 0 0 0.75rem;
    font-size: clamp(1.6rem, 3.6vw, 2.15rem);
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: -0.021em;
}

.welcome-subtext {
    margin: 0 0 1.75rem;
    color: var(--text-secondary);
    font-size: 1.0625rem;
    font-weight: 400;
    line-height: 1.5;
    letter-spacing: -0.006em;
}

/* ── Messages ────────────────────────────────────────────── */

.message-row {
    padding: 1rem 0;
}

.message-row.user {
    background: transparent;
}

.message-inner {
    max-width: 48rem;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    gap: 0.875rem;
}

.message-row.user .message-inner {
    justify-content: flex-end;
}

.message-body {
    flex: 1;
    min-width: 0;
}

.message-row.user .message-body {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    flex: 0 1 auto;
    max-width: min(85%, 36rem);
}

.message-row.user .message-avatar {
    display: none;
}

.message-row.user .message-content {
    background: var(--bg-message-user);
    border-radius: 1.25rem;
    padding: 0.7rem 1.05rem;
    width: fit-content;
    max-width: 100%;
}

.message-content {
    min-width: 0;
    line-height: 1.7;
    font-size: 1rem;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: normal;
}

.message-attachments {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    margin-bottom: 0.65rem;
}

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

.message-attachment-images {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.message-attachment-image {
    display: block;
    max-width: min(100%, 22rem);
    border-radius: 0.75rem;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.06);
    line-height: 0;
}

.message-attachment-image img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 20rem;
    object-fit: contain;
    background: rgba(0, 0, 0, 0.04);
}

.message-row.user .message-attachment-image {
    background: rgba(255, 255, 255, 0.12);
}

.message-attachment-doc {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    max-width: 100%;
    padding: 0.45rem 0.7rem;
    border-radius: 0.65rem;
    background: rgba(0, 0, 0, 0.06);
    font-size: 0.875rem;
}

.message-row.user .message-attachment-doc {
    background: rgba(255, 255, 255, 0.12);
}

.message-attachment-doc-icon {
    display: inline-flex;
    flex-shrink: 0;
}

.message-attachment-doc-icon svg {
    width: 1.1rem;
    height: 1.1rem;
}

.message-attachment-doc-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-avatar {
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.875rem;
}

.message-row.user .message-avatar {
    background: #5436da;
    color: #fff;
}

.message-row.assistant .message-avatar {
    background: var(--accent);
    color: #fff;
}

.message-content.is-document-card {
    max-width: 28rem;
}

.doc-message-card {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem 1rem;
    border: 1px solid var(--border-subtle);
    border-radius: 1rem;
    background: var(--bg-sidebar);
}

.doc-message-card-icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--hover-bg);
    color: var(--text-primary);
    font-size: 1.125rem;
}

.doc-message-card-copy {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
    flex: 1;
}

.doc-message-card-kicker {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.doc-message-card-title {
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.doc-message-card-hint {
    font-size: 0.75rem;
    line-height: 1.35;
    color: var(--text-secondary);
}

.doc-message-card-btn {
    flex-shrink: 0;
    border: none;
    border-radius: 999px;
    background: var(--text-primary);
    color: var(--bg-app);
    font-size: 0.8125rem;
    font-weight: 600;
    padding: 0.5rem 0.875rem;
    cursor: pointer;
}

.doc-message-card-btn:hover:not(:disabled) {
    opacity: 0.92;
}

.doc-message-card-btn:disabled {
    opacity: 0.65;
    cursor: default;
}

.doc-editor-btn-stop {
    color: #f87171 !important;
}

.message-content > :first-child {
    margin-top: 0;
}

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

.message-content p {
    margin: 0 0 0.875rem;
}

.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4 {
    margin: 1.25rem 0 0.625rem;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -0.02em;
}

.message-content h1 { font-size: 1.375rem; }
.message-content h2 { font-size: 1.25rem; }
.message-content h3 { font-size: 1.125rem; }
.message-content h4 { font-size: 1.0625rem; }

.message-content ul,
.message-content ol {
    margin: 0 0 0.875rem;
    padding-left: 1.375rem;
}

.message-content li {
    margin: 0.25rem 0;
}

.message-content li > ul,
.message-content li > ol {
    margin-bottom: 0.25rem;
}

.message-content hr {
    border: none;
    border-top: 1px solid var(--border-subtle);
    margin: 1rem 0;
}

.message-content strong {
    font-weight: 600;
    color: var(--text-primary);
}

.message-content blockquote {
    margin: 0 0 0.875rem;
    padding: 0.125rem 0 0.125rem 0.875rem;
    border-left: 3px solid var(--border-subtle);
    color: var(--text-secondary);
}

.message-content .katex-display {
    margin: 0.75rem 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0.125rem 0;
}

.message-content .katex {
    font-size: 1.05em;
}

.message-content a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 0.14em;
    text-decoration-thickness: 1px;
    overflow-wrap: anywhere;
}

.message-content a:hover {
    color: var(--accent-hover);
}

.message-content code {
    font-family: var(--font-mono);
    background: var(--code-bg);
    padding: 0.125rem 0.375rem;
    border-radius: 0.3rem;
    font-size: 0.875em;
    overflow-wrap: anywhere;
}

.message-content pre {
    background: var(--pre-bg);
    border: none;
    border-radius: 0;
    padding: 0.9rem 1rem;
    overflow-x: auto;
    margin: 0;
    white-space: pre;
    -webkit-overflow-scrolling: touch;
}

.message-content pre code {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    line-height: 1.55;
    background: none;
    padding: 0;
    border-radius: 0;
    overflow-wrap: normal;
    word-break: normal;
}

.table-scroll {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    margin: 0.85rem 0;
    border: 1px solid var(--border-subtle);
    border-radius: 0.65rem;
    -webkit-overflow-scrolling: touch;
}

.message-content table {
    width: 100%;
    min-width: 28rem;
    border-collapse: collapse;
    font-size: 0.9rem;
    line-height: 1.45;
    margin: 0;
}

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

.message-content th {
    font-weight: 600;
    background: var(--hover-bg);
    white-space: nowrap;
}

.message-content tr:last-child td {
    border-bottom: none;
}

.code-block-wrap {
    position: relative;
    margin: 0.85rem 0;
    border: 1px solid var(--border-subtle);
    border-radius: 0.75rem;
    overflow: hidden;
    background: var(--pre-bg);
}

.code-block-wrap pre {
    margin: 0;
}

.code-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.4rem 0.65rem 0.4rem 0.85rem;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--hover-bg);
}

.code-block-lang {
    min-width: 0;
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.code-block-toolbar {
    position: static;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    opacity: 1;
    flex-shrink: 0;
}

.code-copy-btn,
.code-preview-btn {
    border: 1px solid transparent;
    border-radius: 0.45rem;
    background: transparent;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    padding: 0;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.code-copy-btn:hover,
.code-preview-btn:hover {
    background: var(--hover-bg-strong);
    color: var(--text-primary);
}

.code-copy-btn {
    width: 1.75rem;
    height: 1.75rem;
}

.code-preview-btn {
    height: 1.75rem;
    padding: 0 0.55rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.code-preview-btn span {
    line-height: 1;
}


.code-html-preview {
    margin-top: 0.5rem;
    border: 1px solid var(--border-subtle);
    border-radius: 0.75rem;
    overflow: hidden;
    background: #fff;
}

.code-html-preview-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.45rem 0.65rem;
    background: var(--bg-app);
    border-bottom: 1px solid var(--border-subtle);
}

.code-html-preview-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
}

.code-html-preview-open {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.35rem;
    border-radius: 0.375rem;
    cursor: pointer;
}

.code-html-preview-open:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.code-html-preview-frame {
    display: block;
    width: 100%;
    height: min(70vh, 34rem);
    border: 0;
    background: #fff;
}

.message-actions {
    display: flex;
    align-items: center;
    gap: 0.125rem;
    margin-top: 0.375rem;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.message-row:hover .message-actions,
.message-row:focus-within .message-actions,
.message-action-btn.is-success {
    opacity: 1;
}

.message-row.is-streaming .message-actions {
    display: none;
}

.message-row.user .message-actions {
    justify-content: flex-end;
}

.message-action-btn {
    width: 1.75rem;
    height: 1.75rem;
    border: none;
    border-radius: 0.5rem;
    background: transparent;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 0.9375rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

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

.message-action-btn.is-success,
.code-copy-btn.is-success {
    color: var(--accent);
    opacity: 1;
}

@media (hover: none) {
    .message-actions {
        opacity: 1;
    }

    .code-copy-btn {
        opacity: 0.88;
    }
}

.typing-cursor::after {
    content: '▋';
    animation: blink 1s step-end infinite;
    color: var(--accent);
    margin-left: 2px;
}

@keyframes blink {
    50% { opacity: 0; }
}

.message-content.is-thinking {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.message-stream-body {
    min-height: 0;
}

.message-stream-body:empty {
    min-height: 1.25rem;
}

.message-thinking {
    margin: 0;
    padding: 0.25rem 0 0.5rem;
    color: var(--text-secondary);
}

.message-thinking .thinking-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.375rem;
}

.thinking-spinner {
    width: 0.875rem;
    height: 0.875rem;
    border-radius: 999px;
    border: 2px solid var(--border-subtle);
    border-top-color: var(--accent);
    animation: thinkingSpin 0.85s linear infinite;
    flex-shrink: 0;
}

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

.message-thinking .thinking-label {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-primary);
}

.message-thinking .thinking-elapsed {
    margin-left: auto;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.message-content.is-thinking .typing-cursor::after {
    display: none;
}

.message-content.is-thinking .message-thinking {
    margin-bottom: 0;
}

.message-thinking .thinking-hint {
    display: block;
    font-size: 0.8125rem;
    line-height: 1.45;
}

.message-searching {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    padding: 0.25rem 0 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9375rem;
    font-weight: 500;
}

.message-searching .bi {
    color: var(--accent);
}

.message-generating-image {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    padding: 0.25rem 0 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9375rem;
    font-weight: 500;
}

.message-content img {
    display: block;
    max-width: min(100%, 32rem);
    width: auto;
    height: auto;
    margin: 0.75rem 0;
    border-radius: 0.875rem;
    border: 1px solid var(--border-subtle);
    background: var(--bg-sidebar);
}

.message-content em {
    font-style: italic;
}

.thought-duration {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    margin: 0 0 0.625rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.thought-duration i {
    font-size: 0.8125rem;
    opacity: 0.85;
}

@media (prefers-reduced-motion: reduce) {
    .thinking-spinner {
        animation: none;
        border-top-color: var(--border-subtle);
    }
}

/* ── Composer mode menu (Grok-style) ───────────────────────── */

.composer-row {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    width: 100%;
}

.composer-leading {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.composer-trailing {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    flex-shrink: 0;
}

.composer-mode-trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1;
    padding: 0.5rem 0.375rem;
    border-radius: 0.625rem;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease, color 0.15s ease;
}

.composer-mode-trigger:hover:not(:disabled),
.composer-mode-trigger[aria-expanded="true"] {
    background: var(--hover-bg);
}

.composer-mode-trigger:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.composer-mode-chevron {
    font-size: 0.75rem;
    color: var(--text-secondary);
    transition: transform 0.15s ease;
}

.composer-mode-trigger[aria-expanded="true"] .composer-mode-chevron {
    transform: rotate(180deg);
}

.composer-mode-menu {
    min-width: 19rem;
    max-width: min(22rem, calc(100vw - 2rem));
    padding: 0.375rem;
    border: 1px solid var(--border-subtle);
    border-radius: 1rem;
    background: var(--bg-composer);
    inset: auto 0 calc(100% + 0.5rem) auto !important;
    transform: none !important;
    margin: 0 !important;
    z-index: 1080;
}

.composer-mode-list {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.composer-mode-pro-section {
    margin-top: 0.125rem;
}

.composer-mode-pro-gate {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.5rem 0.625rem;
}

.composer-mode-pro-gate-main {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
    flex: 1;
}

.composer-mode-pro-icon {
    color: var(--text-primary);
}

.composer-mode-signin-btn {
    flex-shrink: 0;
    padding: 0.4375rem 1rem;
    border: none;
    border-radius: 999px;
    background: var(--text-primary);
    color: var(--bg-app);
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    transition: opacity 0.15s ease, transform 0.12s ease;
}

.composer-mode-signin-btn:hover {
    opacity: 0.92;
}

.composer-mode-signin-btn:active {
    transform: scale(0.98);
}

.composer-mode-super-section {
    margin-top: 0.125rem;
}

.composer-mode-super-gate {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.5rem 0.625rem;
}

.composer-mode-super-gate.is-locked {
    opacity: 0.78;
}

.composer-mode-super-gate.is-locked:not(:has(.composer-mode-signin-btn:not(.d-none))) {
    pointer-events: none;
    cursor: default;
}

.composer-mode-super-icon {
    color: var(--accent);
}

.composer-mode-option--pro .composer-mode-option-icon,
.composer-mode-pro-icon {
    color: var(--text-primary);
}

.composer-mode-pro-gate.is-locked {
    opacity: 0.78;
}

.composer-mode-option--super .composer-mode-option-icon {
    color: var(--accent);
}

.composer-mode-red-section {
    margin-top: 0.125rem;
}

.composer-mode-red-gate {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
    box-sizing: border-box;
    padding: 0.75rem;
    border-radius: 0.75rem;
    background: transparent;
    border: none;
}

.composer-mode-red-gate .composer-mode-pro-gate-main {
    flex: 1 1 auto;
    min-width: 0;
}

.composer-mode-red-gate.is-locked {
    opacity: 0.92;
}

.composer-mode-red-gate.is-locked:not(:has(.composer-mode-signin-btn:not(.d-none))) {
    pointer-events: none;
    cursor: default;
}

.composer-mode-red-icon {
    color: #e11d48;
    filter: none;
}

.composer-mode-red-title {
    color: #fb7185 !important;
    font-weight: 600;
    letter-spacing: 0;
    text-shadow: none;
}

.composer-mode-red-hint {
    color: var(--text-secondary) !important;
}

.composer-mode-soon-badge {
    flex-shrink: 0;
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--border-subtle);
    border-radius: 999px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
}

.composer-mode-soon-badge.composer-mode-red-badge {
    flex: 0 0 auto;
    align-self: center;
    margin-left: auto;
    border-color: rgba(225, 29, 72, 0.35);
    background: rgba(225, 29, 72, 0.1);
    color: #fda4af;
    font-weight: 600;
    letter-spacing: 0;
}

.composer-mode-signin-btn--red {
    background: #e11d48;
    color: #fff;
}

.composer-mode-signin-btn--red:hover {
    opacity: 0.92;
    background: #e11d48;
}

.composer-mode-option--red {
    background: transparent;
    border: none;
}

.composer-mode-option--red:hover:not(:disabled) {
    background: var(--hover-bg);
}

.composer-mode-option--red .composer-mode-option-icon {
    color: #e11d48;
    filter: none;
}

.composer-mode-option--red.active {
    border: none;
    box-shadow: none;
    background: var(--hover-bg);
}

.composer-mode-trigger.is-rustyred,
.composer-mode-trigger.is-rustyred .composer-mode-trigger-label {
    color: #fb7185;
}

.composer-mode-trigger.is-rustyred .composer-mode-chevron {
    color: #fb7185;
}

.composer-attach-menu {
    min-width: 13.5rem;
    padding: 0.375rem;
    border: 1px solid var(--border-subtle);
    border-radius: 0.875rem;
    background: var(--bg-app);
    inset: auto auto calc(100% + 0.5rem) 0 !important;
    transform: none !important;
    margin: 0 !important;
    z-index: 1080;
}

.composer-mode-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    border: none;
    border-radius: 0.75rem;
    background: transparent;
    color: var(--text-primary);
    text-align: left;
    padding: 0.75rem;
    cursor: pointer;
    transition: background 0.15s ease;
}

.composer-mode-option:hover:not(:disabled) {
    background: var(--hover-bg);
}


.composer-mode-option:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.composer-mode-option-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    flex-shrink: 0;
    color: var(--text-secondary);
    font-size: 1rem;
}

.composer-mode-option-body {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    min-width: 0;
    flex: 1;
}

.composer-mode-option-title {
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.2;
}

.composer-mode-option-hint {
    font-size: 0.8125rem;
    line-height: 1.35;
    color: var(--text-secondary);
}

.composer-mode-check {
    flex-shrink: 0;
    font-size: 1rem;
    opacity: 0;
    color: var(--text-primary);
    transition: opacity 0.15s ease;
}

.composer-mode-option.active .composer-mode-check {
    opacity: 1;
}

.composer-attach {
    position: relative;
    flex-shrink: 0;
}

/* ── Input composer ──────────────────────────────────────── */

.chat-input-area {
    flex-shrink: 0;
    padding: 0.625rem 1.25rem max(0.875rem, env(safe-area-inset-bottom));
    background: linear-gradient(to top, var(--bg-app) 72%, color-mix(in srgb, var(--bg-app) 78%, transparent));
    overflow: visible;
    position: relative;
    z-index: 20;
}

.input-wrapper {
    width: 100%;
    max-width: 48rem;
    margin: 0 auto;
    overflow: visible;
}

.guest-mode.guest-show-welcome .chat-input-area {
    padding-top: 0.5rem;
}

#chatForm {
    margin: 0;
}

.chat-composer {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background: var(--bg-composer);
    border: 1px solid var(--border-subtle);
    border-radius: 1.75rem;
    padding: 0.5rem 0.625rem 0.5rem 0.5rem;
    box-shadow: var(--composer-shadow);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
    overflow: visible;
}

.composer-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.composer-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.125rem;
    height: 1.125rem;
    flex-shrink: 0;
    color: inherit;
    pointer-events: none;
}

.composer-icon svg {
    display: block;
    width: 100%;
    height: 100%;
}

.composer-attach-option .composer-icon {
    width: 1.0625rem;
    height: 1.0625rem;
    color: var(--text-secondary);
}

.btn-composer-add {
    width: 2rem;
    height: 2rem;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: var(--text-primary);
    opacity: 0.72;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
    transition: background 0.18s ease, color 0.18s ease, opacity 0.18s ease, transform 0.12s ease;
}

.btn-composer-add .composer-icon {
    width: 1.1875rem;
    height: 1.1875rem;
}

.btn-composer-add:hover:not(:disabled),
.btn-composer-add[aria-expanded="true"] {
    background: var(--hover-bg);
    opacity: 1;
    transform: none;
}

.btn-composer-add:active:not(:disabled) {
    transform: scale(0.96);
}

.btn-composer-add:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.composer-attach-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-radius: 0.5625rem;
    font-size: 0.875rem;
    padding: 0.625rem 0.75rem;
}

.composer-attach-option:hover .composer-icon {
    color: var(--text-primary);
}

.composer-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    padding: 0.125rem 0.375rem 0;
}

.composer-attachment-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    max-width: 100%;
    padding: 0.375rem 0.5rem 0.375rem 0.375rem;
    border: 1px solid var(--border-subtle);
    border-radius: 0.75rem;
    background: var(--bg-sidebar);
}

.composer-attachment-thumb {
    width: 2rem;
    height: 2rem;
    border-radius: 0.4375rem;
    object-fit: cover;
    flex-shrink: 0;
}

.composer-attachment-file-icon {
    width: 2rem;
    height: 2rem;
    border-radius: 0.4375rem;
    background: var(--hover-bg);
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.composer-attachment-file-icon svg {
    width: 1rem;
    height: 1rem;
    display: block;
}

.composer-attachment-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.25;
}

.composer-attachment-name {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 10rem;
}

.composer-attachment-size {
    font-size: 0.6875rem;
    color: var(--text-secondary);
}

.composer-attachment-remove {
    width: 1.375rem;
    height: 1.375rem;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.composer-attachment-remove .composer-icon {
    width: 0.6875rem;
    height: 0.6875rem;
}

.composer-attachment-remove:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.composer-actions {
    display: none;
}

@media (max-width: 479.98px) {
    .composer-mode-trigger-label {
        max-width: 4.5rem;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .composer-mode-menu {
        min-width: min(17.5rem, calc(100vw - 2rem));
    }
}

.btn-voice-typing,
.btn-voice-mode {
    width: 2rem;
    height: 2rem;
    border: none;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
    transition: background 0.18s ease, color 0.18s ease, transform 0.12s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.btn-voice-typing {
    background: transparent;
    color: var(--text-primary);
    opacity: 0.72;
}

.btn-voice-typing .composer-icon {
    width: 1.125rem;
    height: 1.125rem;
}

.btn-voice-typing:hover:not(:disabled) {
    background: var(--hover-bg);
    opacity: 1;
    transform: none;
}

.btn-voice-typing.is-listening {
    color: #ef4444;
    opacity: 1;
    background: rgba(239, 68, 68, 0.12);
    animation: voiceMicPulse 1.4s ease-in-out infinite;
}

.btn-voice-typing.is-listening .composer-icon svg {
    filter: drop-shadow(0 0 4px rgba(239, 68, 68, 0.35));
}

.btn-voice-mode {
    width: 2.125rem;
    height: 2.125rem;
    background: #ffffff;
    color: #201d17;
    box-shadow: none;
}

.btn-voice-mode .composer-icon {
    width: 1.125rem;
    height: 1.125rem;
}

[data-bs-theme="light"] .btn-voice-mode {
    background: var(--text-primary);
    color: var(--bg-app);
}

.btn-voice-mode:hover:not(:disabled) {
    background: #f3f3f3;
    color: #201d17;
    transform: none;
    box-shadow: none;
}

[data-bs-theme="light"] .btn-voice-mode:hover:not(:disabled) {
    background: var(--send-hover-bg);
    color: var(--bg-app);
}

.btn-voice-mode:active:not(:disabled) {
    transform: scale(0.96);
}

.composer-icon-voice-wave .voice-bar {
    transform-box: fill-box;
    transform-origin: center bottom;
}

.btn-voice-mode:hover:not(:disabled) .composer-icon-voice-wave .voice-bar {
    animation: composerVoiceBar 1.1s ease-in-out infinite;
}

.composer-icon-voice-wave .voice-bar:nth-child(1) { animation-delay: 0s; }
.composer-icon-voice-wave .voice-bar:nth-child(2) { animation-delay: 0.15s; }
.composer-icon-voice-wave .voice-bar:nth-child(3) { animation-delay: 0.08s; }

@keyframes composerVoiceBar {
    0%, 100% {
        transform: scaleY(0.55);
        opacity: 0.75;
    }
    50% {
        transform: scaleY(1);
        opacity: 1;
    }
}

@keyframes voiceMicPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.25); }
    50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

@media (prefers-reduced-motion: reduce) {
    .composer-icon-voice-wave .voice-bar,
    .btn-voice-typing.is-listening {
        animation: none;
    }

    .btn-composer-add,
    .btn-voice-typing,
    .btn-voice-mode,
    .btn-send,
    .btn-stop {
        transition: none;
    }
}

.chat-composer:focus-within {
    border-color: color-mix(in srgb, var(--accent) 55%, var(--border-strong));
    box-shadow:
        var(--composer-shadow),
        0 0 0 3px var(--accent-ring);
}

.chat-textarea {
    width: 100%;
    min-width: 0;
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 0.625rem 0.25rem;
    resize: none;
    max-height: 200px;
    line-height: 1.5;
    font-size: 1rem;
    font-weight: 400;
    field-sizing: content;
    outline: none;
    box-shadow: none;
}

.chat-textarea::placeholder {
    color: var(--text-secondary);
}

.chat-textarea:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-send,
.btn-stop {
    width: 2.25rem;
    height: 2.25rem;
    border: none;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
    transition: background 0.18s ease, color 0.18s ease, transform 0.12s ease, opacity 0.18s ease;
}

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

.btn-send:not(:disabled) {
    background: var(--accent);
    color: var(--accent-contrast);
    box-shadow: 0 1px 8px var(--accent-soft);
}

.btn-send:not(:disabled):hover {
    background: var(--accent-hover);
}

.btn-send:disabled {
    opacity: 1;
    cursor: default;
}

.btn-stop {
    background: var(--send-bg);
    color: var(--send-color);
}

.btn-send .composer-icon,
.btn-stop .composer-icon {
    width: 1rem;
    height: 1rem;
}

.btn-send:active:not(:disabled),
.btn-stop:active:not(:disabled) {
    transform: scale(0.96);
}

.input-hint {
    margin: 0.625rem 0 0;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-secondary);
    line-height: 1.45;
}

.composer-guest-cta {
    margin-top: 0.75rem;
}

.composer-guest-cta.is-pro-nudge .composer-guest-cta-inner {
    border-color: color-mix(in srgb, var(--accent, #c97f4e) 45%, var(--border-subtle));
    background: color-mix(in srgb, var(--accent, #c97f4e) 10%, var(--bg-sidebar));
}

.guest-pro-upgrade {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
    margin-top: 0.75rem;
    padding: 0.7rem 0.85rem;
    border-radius: 0.85rem;
    border: 1px solid color-mix(in srgb, var(--accent, #c97f4e) 40%, var(--border-subtle));
    background: color-mix(in srgb, var(--accent, #c97f4e) 9%, var(--bg-sidebar));
}

.guest-pro-upgrade-copy {
    flex: 1;
    min-width: 12rem;
    font-size: 0.8125rem;
    line-height: 1.4;
    color: var(--text-secondary);
}

.guest-pro-upgrade-copy strong {
    color: var(--text-primary);
    font-weight: 600;
}

.guest-pro-upgrade-btn {
    flex-shrink: 0;
    border: none;
    border-radius: 999px;
    background: var(--text-primary);
    color: var(--bg-app);
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1;
    padding: 0.55rem 0.95rem;
    cursor: pointer;
}

.guest-pro-upgrade-btn:hover {
    opacity: 0.92;
}

.composer-guest-cta-inner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-radius: 1rem;
    background: var(--bg-sidebar);
    border: 1px solid var(--border-subtle);
}

.composer-guest-cta-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    flex-shrink: 0;
    border-radius: 0.625rem;
    background: var(--hover-bg);
    color: var(--text-primary);
    font-size: 1rem;
}

.composer-guest-cta-copy {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    min-width: 0;
    flex: 1;
}

.composer-guest-cta-title {
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.25;
    color: var(--text-primary);
}

.composer-guest-cta-hint {
    font-size: 0.75rem;
    line-height: 1.4;
    color: var(--text-secondary);
}

.composer-guest-cta-btn {
    flex-shrink: 0;
    border: none;
    border-radius: 999px;
    background: var(--text-primary);
    color: var(--bg-app);
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1;
    padding: 0.5625rem 1rem;
    cursor: pointer;
    transition: opacity 0.15s ease, transform 0.12s ease;
    white-space: nowrap;
}

.composer-guest-cta-btn:hover {
    opacity: 0.92;
}

.composer-guest-cta-btn:active {
    transform: scale(0.98);
}

@media (max-width: 575.98px) {
    .composer-guest-cta {
        margin-top: 0.5rem;
    }

    .composer-guest-cta-inner {
        gap: 0.625rem;
        padding: 0.625rem 0.75rem;
    }

    .composer-guest-cta-icon {
        width: 1.875rem;
        height: 1.875rem;
        font-size: 0.875rem;
    }

    .composer-guest-cta-hint {
        display: none;
    }

    .composer-guest-cta .guest-auth-link {
        padding: 0.5rem 0.875rem;
    }
}

/* ── Modals & dropdowns ──────────────────────────────────── */

/* ── Auth gate modal (Rusty split-panel) ─────────────────── */

body:has(#authModal.show) .modal-backdrop {
    background: rgba(8, 7, 6, 0.68);
    backdrop-filter: blur(14px) saturate(1.2);
    -webkit-backdrop-filter: blur(14px) saturate(1.2);
}

.auth-dialog {
    max-width: min(42rem, calc(100vw - 1.25rem));
    margin: 0.75rem auto;
}

.auth-modal-root .modal-content.auth-gate-modal {
    overflow: hidden;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border-subtle);
    border-radius: 1.375rem;
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.04),
        0 32px 64px -12px rgba(0, 0, 0, 0.35),
        0 48px 120px -24px rgba(0, 0, 0, 0.25);
}

.auth-modal-root.show .auth-gate-modal {
    animation: authModalEnter 0.42s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes authModalEnter {
    from {
        opacity: 0;
        transform: scale(0.97) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.auth-gate-layout {
    display: grid;
    grid-template-columns: 1fr;
}

@media (min-width: 640px) {
    .auth-gate-layout {
        grid-template-columns: minmax(13rem, 38%) 1fr;
        min-height: 27rem;
    }
}

@media (max-width: 639px) {
    .auth-gate-hero {
        padding: 1.25rem 1.375rem;
    }

    .auth-gate-hero-inner {
        gap: 0.5rem;
    }

    .auth-gate-logo .rusty-logo-light {
        max-height: 2rem;
    }

    .auth-gate-hero-tagline {
        font-size: 0.75rem;
    }
}

.auth-gate-hero {
    position: relative;
    overflow: hidden;
    padding: 2rem 1.625rem;
    color: #fff;
    background:
        radial-gradient(ellipse 80% 60% at 15% 100%, rgba(255, 255, 255, 0.1) 0%, transparent 55%),
        radial-gradient(ellipse 65% 55% at 90% 8%, rgba(255, 255, 255, 0.07) 0%, transparent 50%),
        linear-gradient(165deg, #a3a3a3 0%, #737373 24%, #525252 52%, #262626 100%);
}

.auth-gate-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
    background-size: 24px 24px;
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.45) 0%, transparent 85%);
    pointer-events: none;
}

.auth-gate-hero-inner {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: 1.125rem;
}

.auth-gate-logo .rusty-logo-light {
    display: block !important;
    max-height: 2.625rem;
    max-width: 9rem;
    filter: brightness(0) invert(1);
    opacity: 0.96;
}

.auth-gate-logo .rusty-logo-dark {
    display: none !important;
}

.auth-gate-hero-tagline {
    margin: 0;
    font-size: 0.8125rem;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.84);
    max-width: 15rem;
    letter-spacing: -0.01em;
}

.auth-gate-perks {
    list-style: none;
    margin: auto 0 0;
    padding: 0;
    display: none;
    flex-direction: column;
    gap: 0.5rem;
}

@media (min-width: 640px) {
    .auth-gate-perks {
        display: flex;
    }
}

.auth-gate-perks li {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.88);
    letter-spacing: -0.01em;
}

.auth-perk-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.625rem;
    height: 1.625rem;
    border-radius: 0.4375rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.12);
    flex-shrink: 0;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.75);
}

.auth-gate-body {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    max-height: calc(100dvh - 2rem);
    overflow-y: auto;
    padding: 1.875rem 1.625rem 1.5rem;
    background: var(--bg-app);
    color: var(--text-primary);
}

@media (min-width: 640px) {
    .auth-gate-body {
        padding: 2.125rem 2rem 1.75rem;
    }
}

.auth-gate-close {
    position: absolute;
    top: 0.875rem;
    right: 0.875rem;
    z-index: 2;
    width: 2rem;
    height: 2rem;
    border: none;
    border-radius: 0.5rem;
    background: transparent;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    transition: color 0.18s ease, background 0.18s ease;
}

.auth-gate-close:hover {
    color: var(--text-primary);
    background: var(--hover-bg);
}

.auth-mode-toggle {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    margin-bottom: 1.375rem;
    padding: 0.1875rem;
    border-radius: 0.6875rem;
    background: var(--bg-sidebar);
    border: 1px solid var(--border-subtle);
}

.auth-mode-toggle::before {
    content: '';
    position: absolute;
    top: 0.1875rem;
    bottom: 0.1875rem;
    left: 0.1875rem;
    width: calc(50% - 0.1875rem);
    border-radius: 0.5rem;
    background: var(--bg-app);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 2px 8px rgba(0, 0, 0, 0.04);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}

.auth-mode-toggle:has([data-auth-mode="signup"].active)::before {
    transform: translateX(100%);
}

[data-bs-theme="dark"] .auth-mode-toggle::before {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.auth-mode-btn {
    position: relative;
    z-index: 1;
    padding: 0.5625rem 0.75rem;
    border: none;
    border-radius: 0.5rem;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.2s ease;
}

.auth-mode-btn:hover {
    color: var(--text-primary);
}

.auth-mode-btn.active {
    color: var(--text-primary);
}

.auth-gate-title {
    margin: 0 0 0.375rem;
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1.25;
    color: var(--text-primary);
}

#authStepWelcome {
    text-align: center;
}

#authStepWelcome .auth-gate-title,
#authStepWelcome .auth-gate-subtitle {
    text-align: center;
}

#authStepWelcome .auth-gate-subtitle {
    max-width: 18rem;
    margin-left: auto;
    margin-right: auto;
}

.auth-gate-subtitle {
    margin: 0 0 1.375rem;
    font-size: 0.875rem;
    line-height: 1.55;
    color: var(--text-secondary);
}

.auth-email-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    margin: 0 0 1.25rem;
    padding: 0.375rem 0.75rem;
    border-radius: 999px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border-subtle);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    word-break: break-all;
    max-width: 100%;
}

.auth-email-badge::before {
    content: '';
    width: 0.375rem;
    height: 0.375rem;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
}

.auth-social-row {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0;
}

.auth-oauth-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    width: 100%;
    padding: 0.6875rem 1rem;
    border: 1px solid var(--border-subtle);
    border-radius: 999px;
    background: var(--bg-app);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    letter-spacing: -0.01em;
    cursor: pointer;
    transition:
        border-color 0.18s ease,
        background 0.18s ease,
        box-shadow 0.18s ease,
        transform 0.12s ease;
}

.auth-oauth-btn.is-disabled,
.auth-oauth-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.auth-oauth-label {
    position: relative;
    z-index: 1;
    pointer-events: none;
}

.auth-oauth-btn--google .auth-oauth-icon,
.auth-oauth-btn--apple .auth-oauth-icon {
    position: relative;
    z-index: 1;
    pointer-events: none;
}

.auth-oauth-host {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    align-items: stretch;
    justify-content: stretch;
    overflow: hidden;
    border-radius: inherit;
    opacity: 0.011;
}

.auth-oauth-host > div,
.auth-oauth-host iframe {
    width: 100% !important;
    min-height: 100% !important;
    margin: 0 !important;
}

.auth-oauth-btn.is-loading .auth-oauth-host {
    pointer-events: none;
}

.auth-oauth-btn:hover {
    border-color: var(--focus-border);
    background: var(--bg-sidebar);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.auth-oauth-btn:active {
    transform: scale(0.99);
}

[data-bs-theme="dark"] .auth-oauth-btn:hover {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}

.auth-oauth-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.125rem;
    height: 1.125rem;
    flex-shrink: 0;
    font-size: 1.0625rem;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    margin: 1.125rem 0;
    color: var(--text-secondary);
    font-size: 0.6875rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-subtle) 20%, var(--border-subtle) 80%, transparent);
}

.auth-divider span {
    padding: 0 0.125rem;
    opacity: 0.7;
}

.auth-field-label {
    display: block;
    margin-bottom: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.auth-email-form,
.auth-credentials-form,
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.auth-form .auth-gate-input {
    margin-bottom: 0.75rem;
}

.auth-field-optional {
    font-weight: 400;
    color: var(--text-secondary);
}

.auth-field-hint {
    margin: -0.375rem 0 0.75rem;
    font-size: 0.75rem;
    line-height: 1.45;
    color: var(--text-secondary);
}

.auth-gate-input {
    width: 100%;
    padding: 0.8125rem 0.9375rem;
    border: 1px solid var(--border-subtle);
    border-radius: 0.6875rem;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.9375rem;
    letter-spacing: -0.01em;
    outline: none;
    transition:
        border-color 0.18s ease,
        box-shadow 0.18s ease,
        background 0.18s ease;
}

.auth-gate-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.75;
}

.auth-gate-input:hover {
    border-color: var(--focus-border);
}

.auth-gate-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(201, 127, 78, 0.16);
    background: var(--bg-app);
}

.auth-gate-input-pill {
    border-radius: 999px;
    margin-bottom: 0.75rem;
    text-align: left;
}

.auth-verify-subtitle strong {
    color: var(--text-primary);
    font-weight: 600;
}

.auth-floating-field {
    position: relative;
    margin-bottom: 0.75rem;
}

.auth-floating-field label {
    position: absolute;
    top: -0.5rem;
    left: 0.75rem;
    padding: 0 0.35rem;
    font-size: 0.75rem;
    line-height: 1;
    color: var(--accent);
    background: var(--bg-app);
    pointer-events: none;
}

.auth-code-input {
    font-size: 1.125rem;
    letter-spacing: 0.28em;
    text-align: left;
    padding-top: 1rem;
    padding-bottom: 0.75rem;
}

.auth-text-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    margin: 0.25rem 0 0.5rem;
    padding: 0.5rem;
    border: 0;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.9375rem;
    text-align: center;
    cursor: pointer;
}

.auth-text-btn:hover {
    text-decoration: underline;
}

.auth-text-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    text-decoration: none;
}

.auth-password-alt-btn {
    width: 100%;
    justify-content: center;
}

.auth-legal-links {
    margin-top: 1.25rem;
    text-align: center;
}

.auth-legal-links a {
    color: var(--text-secondary);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.auth-legal-links span {
    margin: 0 0.5rem;
    color: var(--text-secondary);
    opacity: 0.6;
}

.auth-country-field {
    position: relative;
    margin-bottom: 0.75rem;
}

/* Premium floating-label fields (signup / credentials) */
.auth-credentials-form {
    gap: 0;
}

.auth-float-field {
    position: relative;
    margin-bottom: 0.875rem;
}

.auth-float-input {
    width: 100%;
    min-height: 3.25rem;
    padding: 1.35rem 0.875rem 0.5rem;
    border: 1px solid var(--border-subtle);
    border-radius: 0.75rem;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.9375rem;
    letter-spacing: -0.01em;
    outline: none;
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        background 0.2s ease;
}

.auth-float-input:hover {
    border-color: var(--focus-border);
}

.auth-float-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(201, 127, 78, 0.14);
    background: var(--bg-app);
}

.auth-float-field label {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 0.9375rem;
    font-weight: 400;
    line-height: 1;
    pointer-events: none;
    transition:
        top 0.18s ease,
        transform 0.18s ease,
        font-size 0.18s ease,
        color 0.18s ease;
}

.auth-float-field.is-filled label,
.auth-float-input:focus + label,
.auth-float-select:focus + label {
    top: 0.65rem;
    transform: translateY(0);
    font-size: 0.6875rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.auth-float-input:focus + label,
.auth-float-select:focus + label {
    color: var(--accent);
}

.auth-float-field--select .auth-float-select {
    padding-right: 2rem;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23888' d='M1.41 0 6 4.58 10.59 0 12 1.41l-6 6-6-6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.875rem center;
    background-size: 12px 8px;
}

.auth-field-group {
    margin-bottom: 0.875rem;
}

.auth-field-group-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    padding: 0 0.125rem;
}

.auth-field-group-label {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.auth-field-group-head .bi {
    font-size: 0.875rem;
    color: var(--text-secondary);
    opacity: 0.75;
}

.auth-dob-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 0.75fr) minmax(0, 0.95fr);
    gap: 0.5rem;
}

.auth-dob-grid .auth-float-field {
    margin-bottom: 0;
}

.auth-dob-grid .auth-float-input {
    min-height: 3rem;
    padding-top: 1.25rem;
}

.auth-float-field--country .auth-country-flag {
    position: absolute;
    left: 0.875rem;
    top: 1.35rem;
    transform: none;
    font-size: 1.125rem;
    line-height: 1;
    pointer-events: none;
    z-index: 2;
}

.auth-country-picker.is-filled .auth-country-flag,
.auth-country-picker:focus-within .auth-country-flag,
.auth-country-picker.is-open .auth-country-flag {
    top: 1.5rem;
    font-size: 1.05rem;
}

.auth-country-picker label {
    left: 2.65rem;
    z-index: 3;
}

.auth-country-picker.is-filled label,
.auth-country-picker.is-open label {
    left: 0.875rem;
}

.auth-country-picker.is-filled label,
.auth-country-picker.is-open label {
    top: 0.65rem;
    transform: translateY(0);
    font-size: 0.6875rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.auth-country-picker.is-open label {
    color: var(--accent);
}

.auth-country-trigger {
    position: relative;
    width: 100%;
    min-height: 3.25rem;
    padding: 1.35rem 2.25rem 0.5rem 2.65rem;
    border: 1px solid var(--border-subtle);
    border-radius: 0.75rem;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.9375rem;
    letter-spacing: -0.01em;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    outline: none;
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        background 0.2s ease;
}

.auth-country-trigger:hover {
    border-color: var(--focus-border);
}

.auth-country-picker.is-open .auth-country-trigger,
.auth-country-trigger:focus-visible {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(201, 127, 78, 0.14);
    background: var(--bg-app);
}

.auth-country-value {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.auth-country-chevron {
    position: absolute;
    right: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    color: var(--text-secondary);
    pointer-events: none;
    transition: transform 0.2s ease;
}

.auth-country-picker.is-open .auth-country-chevron {
    transform: translateY(-50%) rotate(180deg);
}

.auth-country-dropdown {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 0.35rem);
    z-index: 40;
    border: 1px solid var(--border-subtle);
    border-radius: 0.875rem;
    background: var(--bg-app);
    box-shadow:
        0 16px 48px rgba(0, 0, 0, 0.16),
        0 0 0 1px rgba(255, 255, 255, 0.03);
    overflow: hidden;
}

.auth-country-search-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 0.875rem;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-input);
}

.auth-country-search-wrap .bi-search {
    flex-shrink: 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.auth-country-search {
    flex: 1;
    min-width: 0;
    border: 0;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.875rem;
    outline: none;
}

.auth-country-search::placeholder {
    color: var(--text-secondary);
    opacity: 0.75;
}

.auth-country-list-wrap {
    max-height: 15rem;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.auth-country-list {
    list-style: none;
    margin: 0;
    padding: 0.375rem 0;
}

.auth-country-option {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 0;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.875rem;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease;
}

.auth-country-option:hover,
.auth-country-option.is-highlighted {
    background: var(--hover-bg);
}

.auth-country-option.is-selected {
    background: rgba(201, 127, 78, 0.12);
    color: var(--accent);
}

.auth-country-option-flag {
    flex-shrink: 0;
    font-size: 1.125rem;
    line-height: 1;
}

.auth-country-option-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.auth-country-empty {
    margin: 0;
    padding: 1.25rem 0.875rem;
    font-size: 0.8125rem;
    text-align: center;
    color: var(--text-secondary);
}

.auth-country-detected-hint {
    margin: -0.5rem 0 0.75rem;
    padding: 0 0.125rem;
    font-size: 0.75rem;
    line-height: 1.4;
    color: var(--text-secondary);
}

.auth-country-detected-hint strong {
    color: var(--accent);
    font-weight: 500;
}

.auth-float-field--country .auth-country-select {
    padding-left: 2.65rem;
}

.auth-float-field--password .auth-float-input {
    padding-right: 2.75rem;
}

.auth-password-toggle {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 0;
    border-radius: 0.5rem;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease;
}

.auth-password-toggle:hover {
    color: var(--text-primary);
    background: var(--hover-bg);
}

.auth-forgot-row {
    display: flex;
    justify-content: flex-end;
    margin: -0.25rem 0 0.75rem;
    padding: 0 0.125rem;
}

.auth-forgot-link:hover {
    text-decoration: underline;
}

.auth-birth-year-hint {
    margin: -0.5rem 0 0.75rem;
    padding: 0 0.125rem;
    font-size: 0.75rem;
    line-height: 1.4;
    color: var(--text-secondary);
}

.auth-birth-year-hint.is-valid {
    color: var(--accent);
}

.auth-birth-year-hint.is-error {
    color: #ef4444;
}

[data-bs-theme="dark"] .auth-birth-year-hint.is-error {
    color: #f87171;
}

.auth-float-field--birth-year .auth-float-input {
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.04em;
}

.auth-float-hint {
    margin: -0.375rem 0 0.875rem;
    padding: 0 0.125rem;
    font-size: 0.75rem;
    line-height: 1.4;
    color: var(--text-secondary);
}

.auth-signup-fields {
    margin-bottom: 0.125rem;
}

#authStepCredentials .auth-email-badge {
    margin-bottom: 1rem;
}

.auth-continue-btn-light {
    background: linear-gradient(180deg, var(--copper-400) 0%, var(--copper-600) 100%);
    color: #fff;
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.auth-continue-btn-light:hover {
    filter: brightness(1.06);
    box-shadow:
        0 4px 14px rgba(201, 127, 78, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

.auth-continue-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    margin-top: 0.25rem;
    padding: 0.8125rem 1rem;
    border: none;
    border-radius: 0.6875rem;
    background: linear-gradient(180deg, var(--copper-400) 0%, var(--copper-600) 100%);
    color: #fff;
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    cursor: pointer;
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.12);
    transition:
        filter 0.18s ease,
        transform 0.12s ease,
        box-shadow 0.18s ease;
}

.auth-continue-btn:hover {
    filter: brightness(1.06);
    box-shadow:
        0 4px 14px rgba(201, 127, 78, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

.auth-continue-btn:active {
    transform: scale(0.985);
    filter: brightness(0.98);
}

.auth-continue-arrow {
    font-size: 0.875rem;
    opacity: 0.9;
    transition: transform 0.18s ease;
}

.auth-continue-btn:hover .auth-continue-arrow {
    transform: translateX(2px);
}

.auth-legal {
    margin: 1.125rem 0 0;
    font-size: 0.6875rem;
    line-height: 1.55;
    color: var(--text-secondary);
}

.auth-legal a {
    color: var(--text-primary);
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-color: var(--border-subtle);
    transition: text-decoration-color 0.15s ease;
}

.auth-legal a:hover {
    text-decoration-color: var(--accent);
}

.auth-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    margin-bottom: 1.125rem;
    padding: 0.375rem 0.625rem 0.375rem 0.375rem;
    margin-left: -0.375rem;
    border: none;
    border-radius: 0.5rem;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.18s ease, background 0.18s ease;
}

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

.auth-switch-mode {
    display: block;
    width: 100%;
    margin-top: 0.875rem;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--accent);
    font-size: 0.8125rem;
    font-weight: 500;
    text-align: center;
    cursor: pointer;
    transition: opacity 0.15s ease;
}

.auth-switch-mode:hover {
    text-decoration: underline;
}

.auth-gate-error {
    margin: 0 0 0.75rem;
    padding: 0.625rem 0.875rem;
    border-radius: 0.5625rem;
    font-size: 0.8125rem;
    background: rgba(220, 53, 69, 0.08);
    border: 1px solid rgba(220, 53, 69, 0.22);
    color: #dc3545;
}

[data-bs-theme="dark"] .auth-gate-error {
    color: #ffb4b4;
}

@media (prefers-reduced-motion: reduce) {
    .auth-modal-root.show .auth-gate-modal,
    .auth-mode-toggle::before,
    .auth-continue-btn,
    .auth-continue-arrow,
    .auth-oauth-btn {
        animation: none;
        transition: none;
    }
}

.auth-modal-content {
    background: var(--bg-sidebar);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
}

.form-control {
    background: var(--bg-input);
    border-color: var(--border-subtle);
    color: var(--text-primary);
}

.form-control:focus {
    background: var(--bg-input);
    border-color: var(--focus-border);
    color: var(--text-primary);
    box-shadow: none;
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.dropdown-menu {
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 0.3125rem;
}

.dropdown-item {
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.625rem;
    font-size: 0.875rem;
    transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}

.dropdown-item:hover,
.dropdown-item:focus-visible {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.dropdown-item:active {
    background: var(--accent-soft);
    color: var(--text-primary);
}

.dropdown-item.text-danger:hover,
.dropdown-item.text-danger:focus-visible {
    background: color-mix(in srgb, #e5484d 14%, transparent);
}

.dropdown-item:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

/* ── Mobile ──────────────────────────────────────────────── */

@media (max-width: 767.98px) {
    .message-row {
        padding: 0.75rem 0;
    }

    .message-inner {
        padding: 0 0.875rem;
        gap: 0.65rem;
    }

    .message-row.assistant .message-avatar {
        display: none;
    }

    .message-row.user .message-body {
        max-width: 92%;
    }

    .message-row.user .message-content {
        padding: 0.6rem 0.9rem;
        font-size: 0.975rem;
    }

    .message-content {
        font-size: 0.975rem;
        line-height: 1.65;
    }

    .welcome-screen {
        padding: 2rem 1rem 1.5rem;
        align-items: center;
        justify-content: center;
        flex: 1 1 auto;
        min-height: 0;
    }

    .welcome-heading {
        font-size: 1.375rem;
    }

    .welcome-subtext {
        margin-bottom: 1.25rem;
    }

    .chat-input-area {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
        padding-top: 0.5rem;
        padding-bottom: max(0.5rem, env(safe-area-inset-bottom, 0px));
        flex-shrink: 0;
        background: linear-gradient(to top, var(--bg-app) 78%, color-mix(in srgb, var(--bg-app) 70%, transparent));
    }

    .chat-composer {
        border-radius: 1.5rem;
    }

    .chat-textarea {
        font-size: 16px; /* prevent iOS zoom-on-focus */
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }

    .chat-header {
        min-height: 2.75rem;
        padding-left: 0.5rem;
        padding-right: 0.5rem;
        backdrop-filter: saturate(1.2) blur(10px);
        background: color-mix(in srgb, var(--bg-app) 88%, transparent);
    }

    .welcome-heading {
        font-size: 1.5rem;
        letter-spacing: -0.03em;
    }

    .message-row {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .chat-view {
        flex: 1 1 auto;
        min-height: 0;
    }

    /* Welcome already has header “Log in” — hide the bulky card that gets clipped. */
    .guest-mode.guest-show-welcome .composer-guest-cta,
    .guest-mode.guest-show-welcome .input-hint {
        display: none !important;
    }

    .guest-mode:not(.guest-show-welcome) .input-hint {
        display: none;
    }
}

/* ── RustyIDE modal (Codex-style) ─────────────────────────── */

body:has(#rustyIdeModal.show) .modal-backdrop {
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(6px);
}

.rusty-ide-dialog {
    max-width: min(42rem, calc(100vw - 2rem));
    margin: 1rem auto;
}

.rusty-ide-modal {
    position: relative;
    overflow: hidden;
    border-radius: 1.5rem;
    background: #201d17;
    color: #f3efe7;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
}

.rusty-ide-hero {
    position: relative;
    padding: 2.75rem 1.5rem 2.25rem;
    background:
        radial-gradient(ellipse 120% 80% at 50% 0%, rgba(255, 255, 255, 0.45) 0%, transparent 55%),
        linear-gradient(165deg, #93c5fd 0%, #bfdbfe 38%, #dbeafe 62%, #a5c9f5 100%);
}

.rusty-ide-close {
    position: absolute;
    top: 0.875rem;
    right: 0.875rem;
    z-index: 2;
    width: 2rem;
    height: 2rem;
    border: none;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.55);
    color: #1f2937;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease;
}

.rusty-ide-close:hover {
    background: rgba(255, 255, 255, 0.85);
    transform: scale(1.04);
}

.rusty-ide-close i {
    font-size: 0.875rem;
    line-height: 1;
}

.rusty-ide-demo-card {
    max-width: 26rem;
    margin: 0 auto;
    padding: 1rem 1.125rem 0.875rem;
    border-radius: 1.125rem;
    background: rgba(255, 255, 255, 0.96);
    box-shadow:
        0 1px 2px rgba(15, 23, 42, 0.06),
        0 12px 32px rgba(15, 23, 42, 0.14);
}

.rusty-ide-demo-text {
    margin: 0 0 0.875rem;
    font-size: 0.875rem;
    line-height: 1.6;
    color: #374151;
}

.rusty-ide-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.4375rem;
    border-radius: 0.4375rem;
    font-size: 0.75rem;
    font-weight: 600;
    vertical-align: baseline;
    white-space: nowrap;
}

.rusty-ide-badge i {
    font-size: 0.75rem;
    line-height: 1;
}

.rusty-ide-badge-github {
    background: #f3f4f6;
    color: #111827;
}

.rusty-ide-badge-rusty {
    background: #d1fae5;
    color: #065f46;
}

.rusty-ide-badge-chat {
    background: #dbeafe;
    color: #1e40af;
}

.rusty-ide-demo-preview {
    border-radius: 0.625rem;
    overflow: hidden;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
}

.rusty-ide-demo-bar {
    display: flex;
    gap: 0.3125rem;
    padding: 0.4375rem 0.5rem;
    background: #eef2f7;
    border-bottom: 1px solid #e5e7eb;
}

.rusty-ide-demo-bar span {
    width: 0.4375rem;
    height: 0.4375rem;
    border-radius: 999px;
    background: #cbd5e1;
}

.rusty-ide-demo-bar span:first-child {
    background: #fca5a5;
}

.rusty-ide-demo-bar span:nth-child(2) {
    background: #fcd34d;
}

.rusty-ide-demo-bar span:nth-child(3) {
    background: #86efac;
}

.rusty-ide-demo-code {
    padding: 0.625rem 0.75rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.6875rem;
    line-height: 1.5;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rusty-ide-demo-code span + span {
    margin-left: 0.375rem;
}

.rusty-ide-code-accent {
    color: #059669;
    font-weight: 600;
}

.rusty-ide-body {
    padding: 1.625rem 1.5rem 1.5rem;
    text-align: center;
    background: #201d17;
}

.rusty-ide-brand {
    display: flex;
    justify-content: center;
    margin-bottom: 0.875rem;
}

.rusty-ide-brand .sidebar-icon {
    width: 2.5rem;
    height: 2.5rem;
    opacity: 1;
    color: #f3efe7;
}

.rusty-ide-brand .sidebar-icon svg {
    width: 2rem;
    height: 2rem;
    stroke-width: 1.35;
}

.rusty-ide-title {
    margin: 0 0 0.625rem;
    font-size: 1.3125rem;
    font-weight: 600;
    line-height: 1.35;
    letter-spacing: -0.015em;
    color: #fff;
}

.rusty-ide-desc {
    margin: 0 auto 1.125rem;
    max-width: 32rem;
    font-size: 0.875rem;
    line-height: 1.6;
    color: #9b9b9b;
}

.rusty-ide-learn-more {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.125rem;
    padding: 0.4375rem 1.125rem;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 999px;
    color: #f3efe7;
    font-size: 0.8125rem;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.rusty-ide-learn-more:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.28);
    color: #fff;
}

.rusty-ide-platform-hint {
    margin: 0 0 0.75rem;
    font-size: 0.75rem;
    color: #6b7280;
    letter-spacing: 0.01em;
}

.rusty-ide-downloads {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

.rusty-ide-download-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4375rem;
    min-width: 0;
    flex: 1 1 calc(50% - 0.25rem);
    max-width: calc(50% - 0.25rem);
    padding: 0.6875rem 0.875rem;
    border-radius: 999px;
    font-size: 0.8125rem;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s ease, opacity 0.15s ease, border-color 0.15s ease;
}

.rusty-ide-download-btn i {
    font-size: 0.9375rem;
    line-height: 1;
    flex-shrink: 0;
}

.rusty-ide-download-primary {
    background: #fff;
    color: #201d17;
    border: 1px solid #fff;
}

.rusty-ide-download-primary:hover {
    background: #f3f4f6;
    color: #201d17;
}

.rusty-ide-download-secondary {
    background: transparent;
    color: #f3efe7;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.rusty-ide-download-secondary:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.32);
    color: #fff;
}

.rusty-ide-downloads.is-single {
    max-width: 16rem;
    margin: 0 auto;
}

.rusty-ide-downloads.is-single .rusty-ide-download-btn {
    flex: 1 1 100%;
    max-width: 100%;
}

.rusty-ide-downloads.is-quad .rusty-ide-download-btn {
    flex: 1 1 calc(50% - 0.25rem);
    max-width: calc(50% - 0.25rem);
    font-size: 0.75rem;
    padding: 0.5625rem 0.625rem;
}

.rusty-ide-downloads.is-quad .rusty-ide-download-btn span {
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 575.98px) {
    .rusty-ide-hero {
        padding: 2.25rem 1.125rem 1.75rem;
    }

    .rusty-ide-body {
        padding: 1.375rem 1.125rem 1.25rem;
    }

    .rusty-ide-title {
        font-size: 1.1875rem;
    }

    .rusty-ide-download-btn {
        flex: 1 1 100%;
        max-width: 100%;
    }
}

/* ── Tools page (Apps-style) ──────────────────────────────── */

.tools-view {
    background: var(--bg-app);
    min-height: 0;
}

.tools-page {
    max-width: 56rem;
    margin: 0 auto;
    padding: 1.5rem 1.5rem 2.5rem;
}

.tools-header {
    margin-bottom: 1.5rem;
}

.tools-header-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.tools-title {
    margin: 0 0 0.375rem;
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.tools-subtitle {
    margin: 0;
    font-size: 0.9375rem;
    color: var(--text-secondary);
}

.tools-search-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 12rem;
    padding: 0.5rem 0.875rem;
    border-radius: 999px;
    background: var(--hover-bg);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
}

.tools-search-wrap i {
    font-size: 0.875rem;
    flex-shrink: 0;
}

.tools-search-input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.875rem;
    outline: none;
    padding: 0;
}

.tools-search-input::placeholder {
    color: var(--text-secondary);
}

.tools-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tools-filter {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 999px;
    padding: 0.4375rem 0.875rem;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.tools-filter:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.tools-filter.active {
    background: var(--hover-bg-strong);
    color: var(--text-primary);
}

.tools-group {
    margin-bottom: 2.25rem;
}

.tools-group-head {
    margin-bottom: 0.875rem;
}

.tools-group-title {
    margin: 0 0 0.25rem;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
}

.tools-group-subtitle {
    margin: 0;
    font-size: 0.8125rem;
    line-height: 1.45;
    color: var(--text-secondary);
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.25rem;
}

.tool-card {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    width: 100%;
    border: none;
    background: transparent;
    color: var(--text-primary);
    text-align: left;
    padding: 0.75rem 0.875rem;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: background 0.15s ease;
}

.tool-card:hover {
    background: var(--hover-bg);
}

.tool-card-icon {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--tool-color) 18%, transparent);
    color: var(--tool-color);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.125rem;
}

.tool-card-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.tool-card-name {
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.3;
}

.tool-card-desc {
    font-size: 0.8125rem;
    line-height: 1.4;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tool-card-chevron {
    color: var(--text-secondary);
    opacity: 0.45;
    flex-shrink: 0;
    font-size: 0.875rem;
}

.tool-detail-dialog {
    max-width: min(28rem, calc(100vw - 2rem));
}

.tool-detail-modal {
    background: var(--bg-sidebar);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    border-radius: 1rem;
}

.tool-detail-head {
    display: flex;
    align-items: flex-start;
    gap: 0.875rem;
}

.tool-detail-icon {
    width: 3rem;
    height: 3rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--tool-color) 18%, transparent);
    color: var(--tool-color);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.25rem;
}

.tool-detail-name {
    margin: 0 0 0.25rem;
    font-size: 1.125rem;
    font-weight: 600;
}

.tool-detail-desc {
    margin: 0;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text-secondary);
}

.tool-detail-features-label {
    margin: 0 0 0.625rem;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.tool-detail-features {
    margin: 0 0 1.25rem;
    padding-left: 1.125rem;
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--text-primary);
}

.tool-detail-features li + li {
    margin-top: 0.25rem;
}

.tool-detail-open-btn {
    background: var(--text-primary);
    color: var(--bg-app);
    border: none;
    border-radius: 999px;
    padding: 0.6875rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.tool-detail-open-btn:hover {
    opacity: 0.9;
    color: var(--bg-app);
}

@media (max-width: 767.98px) {
    .tools-page {
        padding: 1rem 1rem 2rem;
    }

    .tools-header-top {
        flex-direction: column;
        align-items: stretch;
    }

    .tools-search-wrap {
        width: 100%;
    }

    .tools-grid {
        grid-template-columns: 1fr;
    }

    .tools-title {
        font-size: 1.5rem;
    }
}

/* ── Confirm modal (delete chat / project) ───────────────── */
.confirm-dialog {
    width: min(100% - 2rem, 420px);
    margin-left: auto;
    margin-right: auto;
}

.confirm-modal-content {
    position: relative;
    background: var(--bg-sidebar, #1a1a1a);
    color: var(--text-primary, #f2f2f2);
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.1));
    border-radius: 18px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
    overflow: hidden;
}

.confirm-modal-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    z-index: 2;
    width: 2rem;
    height: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--text-secondary, #a1a1a1);
    padding: 0;
}

.confirm-modal-close:hover,
.confirm-modal-close:focus-visible {
    background: var(--hover-bg, rgba(255, 255, 255, 0.08));
    color: var(--text-primary, #f2f2f2);
    outline: none;
}

.confirm-modal-body {
    padding: 1.75rem 1.5rem 1.5rem;
    text-align: center;
}

.confirm-modal-icon {
    width: 3.25rem;
    height: 3.25rem;
    margin: 0 auto 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: rgba(220, 53, 69, 0.14);
    color: #ff6b7a;
    font-size: 1.35rem;
}

.confirm-modal-icon.is-warning {
    background: rgba(255, 193, 7, 0.14);
    color: #ffc107;
}

.confirm-modal-title {
    margin: 0 0 0.5rem;
    font-size: 1.2rem;
    font-weight: 650;
    letter-spacing: -0.02em;
    color: var(--text-primary, #f2f2f2);
    padding-inline: 1.5rem;
}

.confirm-modal-message {
    margin: 0 auto 1.35rem;
    max-width: 28ch;
    font-size: 0.95rem;
    line-height: 1.45;
    color: var(--text-secondary, #a1a1a1);
}

.confirm-modal-actions {
    display: flex;
    gap: 0.65rem;
    justify-content: stretch;
}

.confirm-modal-actions .btn {
    flex: 1 1 0;
    min-height: 2.75rem;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.95rem;
}

.confirm-modal-cancel {
    background: var(--hover-bg, rgba(255, 255, 255, 0.08));
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.12));
    color: var(--text-primary, #f2f2f2);
}

.confirm-modal-cancel:hover,
.confirm-modal-cancel:focus-visible {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--border-subtle, rgba(255, 255, 255, 0.18));
    color: var(--text-primary, #f2f2f2);
}

.confirm-modal-confirm {
    background: #d32f2f;
    border: 1px solid #d32f2f;
    color: #fff;
}

.confirm-modal-confirm:hover,
.confirm-modal-confirm:focus-visible {
    background: #b71c1c;
    border-color: #b71c1c;
    color: #fff;
}

.confirm-modal-confirm.is-primary {
    background: var(--accent, #0d6efd);
    border-color: var(--accent, #0d6efd);
}

.confirm-modal-confirm.is-primary:hover,
.confirm-modal-confirm.is-primary:focus-visible {
    background: var(--accent-hover, #0b5ed7);
    border-color: var(--accent-hover, #0b5ed7);
}

@media (max-width: 575.98px) {
    .confirm-dialog {
        width: min(100% - 1.25rem, 420px);
        margin: 0.75rem auto;
    }

    .confirm-modal-body {
        padding: 1.5rem 1.15rem 1.15rem;
    }

    .confirm-modal-title {
        font-size: 1.1rem;
        padding-inline: 1.25rem;
    }

    .confirm-modal-message {
        font-size: 0.9rem;
        margin-bottom: 1.15rem;
    }

    .confirm-modal-actions {
        flex-direction: column-reverse;
        gap: 0.55rem;
    }

    .confirm-modal-actions .btn {
        width: 100%;
        min-height: 2.9rem;
    }
}


/* ── Viewport / keyboard polish (iOS + desktop) ───────────── */

@media (min-width: 768px) {
    .chat-input-area {
        padding-top: 0.75rem;
        padding-bottom: 1.5rem;
    }

    .chat-composer {
        border-radius: 1.85rem;
    }

    .chat-composer:focus-within {
        transform: translateY(-1px);
    }

    .input-wrapper {
        max-width: 48rem;
    }

    .chat-messages {
        scroll-padding-bottom: 1.5rem;
    }
}

@media (max-width: 767.98px) {
    .chat-messages {
        scroll-padding-bottom: 1rem;
        -webkit-overflow-scrolling: touch;
    }

    /* Keep composer fully visible above the soft keyboard. */
    .chat-input-area {
        padding-bottom: max(0.5rem, env(safe-area-inset-bottom, 0px));
    }

    .chat-composer,
    .chat-composer:focus-within,
    body.keyboard-open .chat-composer {
        transform: none !important;
        transition: border-color 0.2s ease, box-shadow 0.2s ease !important;
    }

    body.app-body {
        /* Avoid animating height/top — that shakes Ask anything on keyboard open. */
        transition: none !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    body.app-body,
    .chat-composer {
        transition: none !important;
    }
}


/* ── Auth modal + mobile keyboard (no auto jump) ─────────── */

@media (max-width: 767.98px) {
    /* Top-align; do not clip/overlay the form — that blocks Continue taps. */
    .auth-modal-root.modal {
        padding: max(0.5rem, env(safe-area-inset-top, 0px)) 0.5rem 0.5rem;
        align-items: flex-start !important;
        justify-content: flex-start !important;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    .auth-modal-root .modal-dialog.auth-dialog,
    .auth-modal-root .modal-dialog-centered.auth-dialog {
        display: block;
        min-height: 0 !important;
        height: auto !important;
        margin: 0.5rem auto;
        max-width: min(42rem, calc(100vw - 1rem));
        transform: none !important;
        pointer-events: auto;
        position: relative;
        z-index: 1;
    }

    .auth-modal-root.show .modal-dialog {
        transform: none !important;
    }

    .auth-modal-root .modal-content.auth-gate-modal {
        max-height: none;
        overflow: visible;
        display: block;
        pointer-events: auto;
    }

    .auth-gate-layout {
        min-height: 0;
        overflow: visible;
        pointer-events: auto;
    }

    .auth-gate-body {
        max-height: none;
        overflow: visible;
        padding-bottom: max(1rem, env(safe-area-inset-bottom, 0px));
        pointer-events: auto;
        position: relative;
        z-index: 2;
    }

    .auth-gate-body .auth-float-input,
    .auth-gate-body .auth-gate-input,
    .auth-gate-body input,
    .auth-gate-body textarea {
        scroll-margin: 0;
        font-size: 16px; /* prevent iOS zoom */
    }

    /* Keep Google iframe clipped to its button — it must not steal Continue taps. */
    .auth-social-row {
        position: relative;
        z-index: 1;
        isolation: isolate;
    }

    .auth-oauth-btn--google {
        overflow: hidden;
        isolation: isolate;
    }

    #authEmailForm,
    #authEmailSubmit,
    #authVerifySubmit,
    #authCredentialsSubmit {
        position: relative;
        z-index: 5;
        pointer-events: auto !important;
    }
}

body.modal-open {
    --app-offset-top: 0px;
}

body.modal-open.app-body {
    top: 0 !important;
}


/* Silent stream recovery — keep the calm typing affordance, no status copy */
.message-row.is-stream-recovering .message-content.typing-cursor::after,
.message-content.is-stream-recovering.typing-cursor::after {
    opacity: 0.7;
}
