:root,
[data-bs-theme="light"] {
    --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;
    --bg-app: #ffffff;
    --bg-sidebar: #f7f7f8;
    --bg-input: #ffffff;
    --bg-composer: #ffffff;
    --bg-message-user: #f4f4f4;
    --bg-message-assistant: transparent;
    --border-subtle: rgba(0, 0, 0, 0.1);
    --text-primary: #0d0d0d;
    --text-secondary: #5d5d5d;
    --accent: #10a37f;
    --accent-hover: #0d8c6d;
    --hover-bg: rgba(0, 0, 0, 0.06);
    --hover-bg-strong: rgba(0, 0, 0, 0.1);
    --focus-border: rgba(0, 0, 0, 0.2);
    --code-bg: rgba(0, 0, 0, 0.06);
    --pre-bg: #f4f4f4;
    --send-bg: #0d0d0d;
    --send-color: #ffffff;
    --send-hover-bg: #2d2d2d;
    --composer-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08), 0 2px 12px rgba(0, 0, 0, 0.06);
}

[data-bs-theme="dark"] {
    --bg-app: #212121;
    --bg-sidebar: #171717;
    --bg-input: #2f2f2f;
    --bg-composer: #303030;
    --bg-message-user: #303030;
    --bg-message-assistant: transparent;
    --border-subtle: rgba(255, 255, 255, 0.1);
    --text-primary: #f5f5f5;
    --text-secondary: #999999;
    --accent: #10a37f;
    --accent-hover: #0d8c6d;
    --hover-bg: rgba(255, 255, 255, 0.08);
    --hover-bg-strong: rgba(255, 255, 255, 0.12);
    --focus-border: rgba(255, 255, 255, 0.2);
    --code-bg: rgba(0, 0, 0, 0.3);
    --pre-bg: #1a1a1a;
    --send-bg: #ececec;
    --send-color: #212121;
    --send-hover-bg: #ffffff;
    --composer-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
}

*,
*::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;
    height: 100%;
    overflow: hidden;
}

html {
    height: 100%;
    overflow: hidden;
}

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

.app-shell {
    background: var(--bg-app);
    height: 100vh;
    height: 100dvh;
    position: relative;
}

@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;
}

.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(29, 29, 31, 0.14);
    border-top-color: #1d1d1f;
}

.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 chat layout */
.guest-mode .message-row.user {
    background: transparent;
}

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

.guest-mode .message-row.user .message-avatar,
.guest-mode .message-row.assistant .message-avatar {
    display: none;
}

.guest-mode .message-row.user .message-content {
    background: var(--bg-message-user);
    border-radius: 1.25rem;
    padding: 0.625rem 1rem;
}

.guest-mode .message-row.user .message-body {
    align-items: flex-end;
    max-width: min(85%, 32rem);
}

.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(--hover-bg-strong);
}

.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;
}

.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: 11rem;
}

.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-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    width: 100%;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    text-align: left;
    padding: 0.5rem 0.625rem;
    border-radius: 0.5rem;
    font-size: 0.8125rem;
    transition: background 0.15s, color 0.15s;
}

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

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

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

.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-view {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.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;
}

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

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

.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;
}

.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.5rem, 3.5vw, 2rem);
    font-weight: 600;
    line-height: 1.2;
}

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

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

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

.message-row.user {
    background: var(--bg-message-user);
}

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

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

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

.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 > :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 code {
    background: var(--code-bg);
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.875em;
}

.message-content pre {
    background: var(--pre-bg);
    border: 1px solid var(--border-subtle);
    border-radius: 0.5rem;
    padding: 1rem;
    padding-top: 2.25rem;
    overflow-x: auto;
    margin: 0.75rem 0;
    white-space: pre-wrap;
}

.code-block-wrap {
    position: relative;
    margin: 0.75rem 0;
}

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

.code-copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    z-index: 1;
    width: 1.75rem;
    height: 1.75rem;
    border: none;
    border-radius: 0.5rem;
    background: rgba(0, 0, 0, 0.45);
    color: #f5f5f5;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}

[data-bs-theme="light"] .code-copy-btn {
    background: rgba(255, 255, 255, 0.92);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
}

.code-block-wrap:hover .code-copy-btn,
.code-block-wrap:focus-within .code-copy-btn,
.code-copy-btn.is-success {
    opacity: 1;
}

.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;
    }
}

.message-content pre code {
    background: none;
    padding: 0;
}

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

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

.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-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);
}

.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: 17.5rem;
    max-width: min(20rem, 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;
    opacity: 0.72;
    cursor: default;
    pointer-events: none;
}

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

.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-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.75rem 1.25rem max(1.25rem, env(safe-area-inset-bottom));
    background: var(--bg-app);
    overflow: visible;
    position: relative;
    z-index: 2;
}

.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.15s, box-shadow 0.15s;
    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: #171717;
    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: #171717;
    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: var(--focus-border);
}

.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(--send-bg);
    color: var(--send-color);
}

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

.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-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-inner {
        flex-wrap: wrap;
        padding: 0.875rem;
    }

    .composer-guest-cta-copy {
        flex: 1 1 calc(100% - 3rem);
    }

    .composer-guest-cta-btn {
        width: 100%;
        margin-top: 0.25rem;
        padding-top: 0.625rem;
        padding-bottom: 0.625rem;
    }
}

/* ── 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(16, 163, 127, 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(16, 163, 127, 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: 0.72rem;
    font-size: 0.95rem;
}

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

.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(16, 163, 127, 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(16, 163, 127, 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: var(--text-primary);
    color: var(--bg-app);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.auth-continue-btn-light:hover {
    filter: brightness(1.08);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}

[data-bs-theme="dark"] .auth-continue-btn-light {
    background: #fff;
    color: #171717;
}

[data-bs-theme="dark"] .auth-continue-btn-light:hover {
    background: #f3f3f3;
    filter: none;
}

.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, #12b886 0%, var(--accent) 48%, #0e966f 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(16, 163, 127, 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-sidebar);
    border-color: var(--border-subtle);
}

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

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

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

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

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

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

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

    .chat-input-area {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
}

/* ── 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: #212121;
    color: #ececec;
    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: #212121;
}

.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: #ececec;
}

.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: #ececec;
    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: #171717;
    border: 1px solid #fff;
}

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

.rusty-ide-download-secondary {
    background: transparent;
    color: #ececec;
    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;
    }
}
