/* ===================================================
   THEME SYSTEM - CSS CUSTOM PROPERTIES
   The default (:root) follows the system color scheme.
   All named themes override the same set of vars.
   =================================================== */

:root {
    --font-sans: 'Manrope', 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', Consolas, monospace;

    /* Workspace (right) - defaults to Cream (light mode) */
    --bg-page: #faf8f3;
    --bg-topbar: #faf8f3;
    --bg-message-user: #f0ede5;
    --bg-message-assistant: #ffffff;
    --bg-code: #f3f0e8;
    --bg-composer: #faf8f3;
    --bg-composer-shell: linear-gradient(180deg, #ffffff, #f5f2ea);
    --bg-empty-state: linear-gradient(145deg, #ffffff, #f5f2ea);

    /* Sidebar (left) */
    --bg-sidebar: linear-gradient(180deg, #e8e2d4, #ddd6c4);
    --bg-sidebar-hover: #ece7d9;
    --bg-sidebar-active: #dfd8c6;
    --sidebar-border: #d4cbb8;
    --sidebar-primary-bg: #e8e1cf;
    --sidebar-primary-border: #c4b99e;
    --sidebar-primary-color: #3a3225;

    /* Shared */
    --border: #e4ded0;
    --border-soft: #cfc8b6;
    --text-main: #2c2516;
    --text-muted: #8a7e66;
    --text-subtle: #6b6050;
    --accent: #b08430;
    --accent-soft: #956e22;
    --danger: #e1645d;
    --success: #2abf84;
    --shadow: 0 12px 36px rgba(40, 30, 10, 0.08);

    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 24px;

    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-page: #1a1d22;
        --bg-topbar: #1a1d22;
        --bg-message-user: #22262c;
        --bg-message-assistant: #1e2128;
        --bg-code: #141619;
        --bg-composer: #1a1d22;
        --bg-composer-shell: linear-gradient(180deg, #252830, #212121);
        --bg-empty-state: linear-gradient(145deg, #22262c, #1a1d22);

        --bg-sidebar: linear-gradient(180deg, #1e1e1e, #181818);
        --bg-sidebar-hover: #262626;
        --bg-sidebar-active: #2e2e2e;
        --sidebar-border: #2c2c2c;
        --sidebar-primary-bg: #2a2a2a;
        --sidebar-primary-border: #3a3e46;
        --sidebar-primary-color: #f0e6ec;

        --border: #2e3138;
        --border-soft: #3a3e46;
        --text-main: #e8e4ea;
        --text-muted: #9b95a0;
        --text-subtle: #c4bec8;
        --accent: #93517e;
        --accent-soft: #7a4068;
        --shadow: 0 16px 40px rgba(0, 0, 0, 0.45);

        color-scheme: dark;
    }
}

/* --------------- CREAM (default light mode) --------------- */
[data-theme="cream"] {
    --bg-page: #faf8f3;
    --bg-topbar: #faf8f3;
    --bg-message-user: #f0ede5;
    --bg-message-assistant: #ffffff;
    --bg-code: #f3f0e8;
    --bg-composer: #faf8f3;
    --bg-composer-shell: linear-gradient(180deg, #ffffff, #f5f2ea);
    --bg-empty-state: linear-gradient(145deg, #ffffff, #f5f2ea);

    --bg-sidebar: linear-gradient(180deg, #e8e2d4, #ddd6c4);
    --bg-sidebar-hover: #ece7d9;
    --bg-sidebar-active: #dfd8c6;
    --sidebar-border: #d4cbb8;
    --sidebar-primary-bg: #e8e1cf;
    --sidebar-primary-border: #c4b99e;
    --sidebar-primary-color: #3a3225;

    --border: #e4ded0;
    --border-soft: #cfc8b6;
    --text-main: #2c2516;
    --text-muted: #8a7e66;
    --text-subtle: #6b6050;
    --accent: #b08430;
    --accent-soft: #956e22;
    --shadow: 0 12px 36px rgba(40, 30, 10, 0.08);

    color-scheme: light;
}

/* --------------- ROSE (#f6dde6) --------------- */
[data-theme="rose"] {
    --bg-page: #f6dde6;
    --bg-topbar: #f6dde6;
    --bg-message-user: #eed0da;
    --bg-message-assistant: #fdf0f4;
    --bg-code: #f9e4ec;
    --bg-composer: #f6dde6;
    --bg-composer-shell: linear-gradient(180deg, #fdf0f4, #f9e4ec);
    --bg-empty-state: linear-gradient(145deg, #fdf0f4, #f6dde6);

    --bg-sidebar: linear-gradient(180deg, #dba9bb, #c8899f);
    --bg-sidebar-hover: #e0b3c4;
    --bg-sidebar-active: #d49ab0;
    --sidebar-border: #c99aac;
    --sidebar-primary-bg: #e5b8c9;
    --sidebar-primary-border: #c28ea2;
    --sidebar-primary-color: #5a2040;

    --border: #dbbfc8;
    --border-soft: #c8a0ae;
    --text-main: #3d1228;
    --text-muted: #8c5668;
    --text-subtle: #6e3a50;
    --accent: #d4577a;
    --accent-soft: #b53e60;
    --shadow: 0 14px 40px rgba(100, 20, 50, 0.12);

    color-scheme: light;
}

/* --------------- DUSK (default dark mode) --------------- */
[data-theme="dusk"] {
    --bg-page: #1a1d22;
    --bg-topbar: #1a1d22;
    --bg-message-user: #22262c;
    --bg-message-assistant: #1e2128;
    --bg-code: #141619;
    --bg-composer: #1a1d22;
    --bg-composer-shell: linear-gradient(180deg, #252830, #212121);
    --bg-empty-state: linear-gradient(145deg, #22262c, #1a1d22);

    --bg-sidebar: linear-gradient(180deg, #1e1e1e, #181818);
    --bg-sidebar-hover: #262626;
    --bg-sidebar-active: #2e2e2e;
    --sidebar-border: #2c2c2c;
    --sidebar-primary-bg: #2a2a2a;
    --sidebar-primary-border: #3a3e46;
    --sidebar-primary-color: #f0e6ec;

    --border: #2e3138;
    --border-soft: #3a3e46;
    --text-main: #e8e4ea;
    --text-muted: #9b95a0;
    --text-subtle: #c4bec8;
    --accent: #93517e;
    --accent-soft: #7a4068;
    --shadow: 0 16px 40px rgba(0, 0, 0, 0.45);

    color-scheme: dark;
}

/* --------------- CHARCOAL (#212121) --------------- */
[data-theme="dark"],
[data-theme="charcoal"] {
    --bg-page: #101316;
    --bg-topbar: #101316;
    --bg-message-user: #171d24;
    --bg-message-assistant: #12171c;
    --bg-code: #0b0f13;
    --bg-composer: #101316;
    --bg-composer-shell: linear-gradient(180deg, #171d23, #12171c);
    --bg-empty-state: linear-gradient(145deg, #141a20, #101419);

    --bg-sidebar: linear-gradient(180deg, #1a222a, #162028);
    --bg-sidebar-hover: #202a33;
    --bg-sidebar-active: #25313c;
    --sidebar-border: #2a333c;
    --sidebar-primary-bg: #24303b;
    --sidebar-primary-border: #3d4b58;
    --sidebar-primary-color: #e6edf6;

    --border: #27313a;
    --border-soft: #313d49;
    --text-main: #e7edf4;
    --text-muted: #92a0ae;
    --text-subtle: #c0cad5;
    --accent: #7da2cf;
    --accent-soft: #5d82ae;
    --shadow: 0 16px 40px rgba(0, 0, 0, 0.42);

    color-scheme: dark;
}

/* --------------- DRACULA (#282a36) --------------- */
[data-theme="dracula"] {
    --bg-page: #282a36;
    --bg-topbar: #282a36;
    --bg-message-user: #343746;
    --bg-message-assistant: #2e3040;
    --bg-code: #21222c;
    --bg-composer: #282a36;
    --bg-composer-shell: linear-gradient(180deg, #3a3d50, #30334a);
    --bg-empty-state: linear-gradient(145deg, #30334a, #292b38);

    --bg-sidebar: linear-gradient(180deg, #1e1f2b, #191a24);
    --bg-sidebar-hover: #3a3d50;
    --bg-sidebar-active: #44475a;
    --sidebar-border: #44475a;
    --sidebar-primary-bg: #44475a;
    --sidebar-primary-border: #6272a4;
    --sidebar-primary-color: #f8f8f2;

    --border: #44475a;
    --border-soft: #565a72;
    --text-main: #f8f8f2;
    --text-muted: #6272a4;
    --text-subtle: #bfc9e0;
    --accent: #bd93f9;
    --accent-soft: #9b6bd8;
    --shadow: 0 14px 40px rgba(0, 0, 0, 0.4);

    color-scheme: dark;
}

/* --------------- AURORA / LIGHT / TEAL (legacy alias) --------------- */
[data-theme="light"],
[data-theme="teal"],
[data-theme="aurora"] {
    --bg-page: #132132;
    --bg-topbar: #132132;
    --bg-message-user: #203650;
    --bg-message-assistant: #17293e;
    --bg-code: #0e1a28;
    --bg-composer: #132132;
    --bg-composer-shell: linear-gradient(180deg, #213a55, #172c45);
    --bg-empty-state: linear-gradient(145deg, #223b55, #173047);

    --bg-sidebar: linear-gradient(90deg, #435f57 0%, #24415e 100%);
    --bg-sidebar-hover: #35526c;
    --bg-sidebar-active: #436985;
    --sidebar-border: #506975;
    --sidebar-primary-bg: #2f536a;
    --sidebar-primary-border: #62859d;
    --sidebar-primary-color: #edf7ff;

    --border: #31485d;
    --border-soft: #47627a;
    --text-main: #edf3fb;
    --text-muted: #9eb3c7;
    --text-subtle: #c7d7e8;
    --accent: #86c0ff;
    --accent-soft: #5d91cb;
    --shadow: 0 16px 42px rgba(0, 16, 30, 0.42);

    color-scheme: dark;
}

/* ===========================
   AD UNITS
   =========================== */

.ad-side {
    position: fixed;
    top: 50%;
    width: 300px;
    height: 600px;
    transform: translateY(-50%);
    z-index: 6;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    overflow: hidden;
    transition: opacity 180ms ease, transform 180ms ease;
}

.ad-side-left {
    left: 16px;
}

.ad-side-right {
    right: 16px;
}

.ad-side.is-collapsed {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-50%) scale(0.98);
}

.ad-middle-slot {
    width: 100%;
    flex: 0 0 auto;
    overflow-anchor: none;
    contain: layout paint;
}

.ad-middle-empty-slot,
.ad-middle-thread-slot {
    position: absolute;
    left: 0;
    right: 0;
    width: 100%;
    margin: 0;
    overflow: hidden;
    pointer-events: none;
    opacity: 0;
}

.ad-middle-empty-slot {
    width: min(720px, 100%);
    margin-inline: auto;
}

.ad-middle-empty-slot.is-filled,
.ad-middle-thread-slot.is-filled {
    position: static;
    opacity: 1;
}

.ad-middle-thread-slot .adsbygoogle,
.ad-middle-thread-slot iframe {
    pointer-events: none !important;
}

.ad-unit-frame {
    border: 0;
    border-radius: var(--radius-lg);
    background: transparent;
    box-shadow: none;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 180ms ease;
}

.ad-unit-frame.is-filled {
    opacity: 1;
}

.ad-unit-frame-side {
    width: 300px;
    height: 600px;
}

.ad-unit-frame-middle {
    width: 100%;
    min-height: 112px;
}

.ad-middle-empty-slot.is-filled {
    margin-top: 18px;
}

.ad-unit-frame .adsbygoogle {
    width: 100%;
}

.ad-side .adsbygoogle {
    width: 300px;
    height: 600px;
}

@media (max-width: 1800px) {
    .ad-side {
        display: none !important;
    }
}

@media (max-width: 760px) {
    .ad-middle-empty-slot.is-filled {
        margin-top: 16px;
    }

    .ad-middle-thread-slot {
        width: 100%;
    }
}

/* ===========================
   GLOBAL RESET
   =========================== */

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
}

body {
    font-family: var(--font-sans);
    color: var(--text-main);
    background: var(--bg-page);
    transition: background 250ms ease, color 200ms ease;
    overflow: hidden;
    position: relative;
}

body.page-shell {
    overflow-x: hidden;
    overflow-y: auto;
    height: auto;
    min-height: 100%;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

a {
    color: inherit;
    text-decoration: none;
}

#root {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.screen {
    width: 100%;
    height: 100%;
}

.is-hidden,
.native-hidden {
    display: none !important;
}

/* ===========================
   AUTH MODAL
   =========================== */

.auth-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 200ms ease;
}

.auth-modal.is-hidden {
    display: none !important;
}

.auth-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(8px);
}

.auth-modal-body {
    position: relative;
    z-index: 1;
    width: min(460px, calc(100% - 32px));
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    background: var(--bg-page);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
    padding: 32px 28px;
    animation: slideUp 250ms ease;
}

.auth-modal-close {
    position: absolute;
    top: 14px;
    right: 16px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background 120ms ease;
}

.auth-modal-close:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-main);
}

.auth-brand-mini {
    position: relative;
    text-align: center;
    margin-bottom: 24px;
}

.auth-brand-mini h2 {
    margin: 0 0 6px;
    font-size: 26px;
    letter-spacing: -0.03em;
}

.auth-brand-mini p {
    margin: 0;
    color: var(--text-muted);
    font-size: 14px;
}

.orb-mini {
    position: absolute;
    width: 120px;
    height: 120px;
    right: 50%;
    top: -60px;
    transform: translateX(50%);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(76, 141, 255, 0.2), transparent 72%);
    pointer-events: none;
}

.auth-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    background: var(--bg-page);
    padding: 20px;
}

.auth-modal-body .auth-card {
    border: none;
    background: transparent;
    padding: 0;
}

.auth-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}

.tab {
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-sidebar-hover);
    color: var(--text-muted);
    padding: 9px 12px;
    cursor: pointer;
    font-weight: 600;
    transition: all 120ms ease;
}

.tab.is-active {
    border-color: var(--accent-soft);
    background: var(--bg-sidebar-active);
    color: var(--text-main);
}

.auth-error {
    color: var(--danger);
    font-size: 14px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 180ms ease;
}

.auth-error.is-visible {
    max-height: 80px;
    margin-bottom: 8px;
}

.auth-form {
    display: grid;
    gap: 8px;
}

.auth-form label {
    font-size: 13px;
    color: var(--text-muted);
}

.auth-form input {
    border: 1px solid var(--border);
    background: var(--bg-code);
    border-radius: var(--radius-sm);
    padding: 11px 12px;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}

.auth-form input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(76, 141, 255, 0.15);
}

.primary-btn {
    margin-top: 10px;
    border: none;
    border-radius: var(--radius-sm);
    background: linear-gradient(120deg, var(--accent-soft), var(--accent));
    color: #fff;
    padding: 11px 14px;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 120ms ease;
}

.primary-btn:hover {
    opacity: 0.9;
}

.text-link {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 13px;
    cursor: pointer;
    padding: 0;
    margin-top: 4px;
    text-align: left;
}

.text-link:hover {
    text-decoration: underline;
}

.auth-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0 0 4px 0;
    line-height: 1.4;
}

.auth-form select {
    border: 1px solid var(--border);
    background: var(--bg-code);
    color: var(--text-main);
    border-radius: var(--radius-sm);
    padding: 11px 12px;
    transition: border-color 120ms ease, box-shadow 120ms ease;
    font-size: inherit;
    font-family: inherit;
    appearance: auto;
}

.auth-form select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(76, 141, 255, 0.15);
}

.danger-link {
    color: #dc4545 !important;
    cursor: pointer;
}

.danger-link:hover {
    background: rgba(220, 69, 69, 0.1) !important;
}

.auth-divider {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 10px;
    color: var(--text-muted);
    margin: 14px 0;
    font-size: 13px;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    height: 1px;
    background: var(--border);
}

.oauth-group {
    display: grid;
    gap: 10px;
}

.oauth-btn {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-code);
    text-align: center;
    padding: 10px 12px;
    font-weight: 600;
    transition: all 120ms ease;
}

.oauth-btn:hover {
    background: var(--bg-sidebar-hover);
    border-color: var(--border-soft);
}

.oauth-btn.is-disabled {
    opacity: 0.45;
    pointer-events: auto;
}

/* ===========================
   CHAT SCREEN LAYOUT
   =========================== */

.chat-screen {
    display: grid;
    grid-template-columns: minmax(260px, 280px) minmax(0, 1fr);
    height: 100dvh;
    max-height: 100dvh;
    min-height: 0;
    overflow: hidden;
}

/* ===========================
   SIDEBAR
   =========================== */

.sidebar {
    border-right: 1px solid var(--sidebar-border);
    background: var(--bg-sidebar);
    padding: 12px;
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    height: 100dvh;
    max-height: 100dvh;
    min-height: 0;
    overflow: hidden;
    transition: background 250ms ease;
    z-index: 8;
    position: relative;
}

.sidebar-header {
    margin-bottom: 8px;
}

.sidebar-primary {
    width: 100%;
    border: 1px solid var(--sidebar-primary-border);
    border-radius: var(--radius-sm);
    background: var(--sidebar-primary-bg);
    color: var(--sidebar-primary-color);
    padding: 10px 12px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background 120ms ease;
}

.sidebar-primary:hover {
    opacity: 0.9;
}

/* --- Search --- */
.sidebar-search {
    position: relative;
    margin-bottom: 8px;
}

.sidebar-search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.sidebar-search-input {
    width: 100%;
    border: 1px solid var(--sidebar-border);
    background: rgba(0, 0, 0, 0.15);
    border-radius: var(--radius-sm);
    padding: 8px 10px 8px 32px;
    font-size: 13px;
    color: var(--text-main);
    transition: border-color 120ms ease;
}

.sidebar-search-input::placeholder {
    color: var(--text-muted);
}

.sidebar-search-input:focus {
    outline: none;
    border-color: var(--accent);
}

/* --- Conversation List --- */
.conversation-nav {
    min-height: 0;
    overflow-y: auto;
    padding-bottom: 12px;
    scrollbar-gutter: stable;
}

#conversation-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 4px;
}

.conversation-row {
    display: flex;
    align-items: center;
    position: relative;
    min-width: 0;
}

.conversation-item {
    flex: 1;
    min-width: 0;
    border: 1px solid transparent;
    background: transparent;
    border-radius: 9px;
    padding: 9px 32px 9px 10px;
    text-align: left;
    color: var(--text-subtle);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all 120ms ease;
}

.conversation-item:hover {
    border-color: var(--border-soft);
    background: var(--bg-sidebar-hover);
}

.conversation-item.is-active {
    border-color: var(--accent-soft);
    background: var(--bg-sidebar-active);
    color: var(--text-main);
}

/* Kebab/three-dot button */
.conversation-kebab {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: 6px;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: all 120ms ease;
}

.conversation-row:hover .conversation-kebab,
.conversation-kebab.is-open {
    opacity: 1;
}

.conversation-kebab:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-main);
}

/* --- Context Menu --- */
.context-menu {
    position: fixed;
    z-index: 50;
    min-width: 180px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-page);
    box-shadow: var(--shadow);
    padding: 4px;
    animation: fadeIn 120ms ease;
}

.context-menu.is-hidden {
    display: none !important;
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    border: none;
    background: transparent;
    border-radius: 7px;
    padding: 8px 10px;
    font-size: 13px;
    color: var(--text-subtle);
    cursor: pointer;
    transition: all 100ms ease;
}

.context-menu-item:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-main);
}

.context-menu-item.danger {
    color: var(--danger);
}

.context-menu-item.danger:hover {
    background: rgba(225, 100, 93, 0.12);
}

.context-menu-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 6px;
}

/* --- Settings Section --- */
.settings-section {
    position: relative;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--sidebar-border);
}

.settings-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    border-radius: 10px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 150ms ease;
}

.settings-btn:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-main);
}

.settings-btn svg {
    flex-shrink: 0;
}

.settings-menu {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--bg-sidebar);
    border: 1px solid var(--sidebar-border);
    border-radius: 12px;
    padding: 6px;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.18);
    z-index: 100;
    animation: settingsSlideUp 150ms ease;
}

@keyframes settingsSlideUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.settings-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-main);
    text-decoration: none;
    transition: all 120ms ease;
}

.settings-menu-item:hover {
    background: var(--bg-sidebar-hover);
}

.settings-menu-item svg {
    flex-shrink: 0;
    color: var(--text-muted);
}

.settings-menu-divider {
    height: 1px;
    background: var(--sidebar-border);
    margin: 4px 8px;
}

/* Submenu row (Theme / Help) */
.settings-menu-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-main);
    cursor: pointer;
    transition: all 120ms ease;
    position: relative;
}

.settings-menu-row:hover {
    background: var(--bg-sidebar-hover);
}

.settings-menu-row .settings-menu-label {
    flex: 1;
}

.submenu-chevron {
    margin-left: auto;
    flex-shrink: 0;
    color: var(--text-muted);
    transition: transform 200ms ease;
}

/* Flyout panel (inline dropdown that expands within the menu) */
.settings-flyout {
    display: none;
    width: 100%;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    padding: 4px;
    margin-top: 4px;
    animation: flyoutIn 120ms ease;
}

[data-theme="rose"] .settings-flyout,
[data-theme="cream"] .settings-flyout {
    background: rgba(0, 0, 0, 0.05);
}

@keyframes flyoutIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.settings-flyout-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-main);
    text-decoration: none;
    background: transparent;
    border: none;
    font-family: inherit;
    cursor: pointer;
    width: 100%;
    text-align: left;
    transition: all 120ms ease;
    white-space: normal;
    word-break: break-word;
}

.settings-flyout-item:hover {
    background: var(--bg-sidebar-hover);
}

.settings-flyout-item.is-active {
    color: var(--accent);
    font-weight: 600;
}

.settings-flyout-item svg {
    flex-shrink: 0;
    color: var(--text-muted);
}

.settings-flyout-divider {
    height: 1px;
    background: var(--sidebar-border);
    margin: 4px 8px;
}

/* Language picker (settings menu + topbar) */

/* Current language value shown next to label */
.settings-menu-value {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 400;
    margin-right: 4px;
}

/* Scrollable language flyout */
.lang-flyout {
    max-height: 260px;
    overflow-y: auto;
    scrollbar-width: thin;
}

/* Topbar language selector (next to Sign in) */
.topbar-lang-selector {
    position: relative;
    display: inline-flex;
}

.lang-trigger {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
}

.topbar-lang-menu {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 200;
    min-width: 180px;
    max-height: 320px;
    overflow-y: auto;
    background: var(--bg-sidebar-hover);
    border: 1px solid var(--sidebar-border);
    border-radius: var(--radius-sm);
    padding: 4px;
    box-shadow: var(--shadow);
    scrollbar-width: thin;
}

.topbar-lang-item {
    display: block;
    padding: 7px 12px;
    font-size: 13px;
    color: var(--text-main);
    text-decoration: none;
    border-radius: 6px;
    white-space: nowrap;
    transition: background 100ms;
}

.topbar-lang-item:hover {
    background: var(--bg-sidebar-active);
}

.topbar-lang-item.is-active {
    color: var(--accent);
    font-weight: 600;
}

/* RTL support */
[dir="rtl"] .sidebar {
    border-right: none;
    border-left: 1px solid var(--sidebar-border);
}

[dir="rtl"] .submenu-chevron {
    margin-left: 0;
    margin-right: auto;
    transform: scaleX(-1);
}

[dir="rtl"] .settings-menu-value {
    margin-left: 4px;
    margin-right: auto;
}

[dir="rtl"] .topbar-lang-menu {
    right: auto;
    left: 0;
}

/* Documentation link at bottom of settings menu */
.settings-menu-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-main);
    text-decoration: none;
    transition: all 120ms ease;
}

.settings-menu-link:hover {
    background: var(--bg-sidebar-hover);
}

.settings-menu-link svg {
    flex-shrink: 0;
    color: var(--text-muted);
}

/* --- Share Picker --- */
.share-picker {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding-bottom: 14px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--sidebar-border);
}

.share-picker-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.share-icons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.share-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: none;
    background: var(--bg-sidebar-hover);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 180ms ease;
    position: relative;
}

.share-icon-btn:hover {
    background: var(--bg-sidebar-active);
    color: var(--text-main);
    transform: scale(1.1);
}

.share-icon-btn:active {
    transform: scale(0.95);
}

.share-icon-btn svg {
    pointer-events: none;
}

.share-icon-btn.is-copied {
    color: var(--success);
}

/* --- Theme Picker --- */
.sidebar-footer {
    padding: 12px 0 4px;
    border-top: 1px solid var(--sidebar-border);
    background: var(--bg-sidebar);
}


.theme-picker {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.theme-picker-label {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--sidebar-border);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-muted);
    flex-shrink: 0;
}

.theme-picker-label svg {
    width: 15px;
    height: 15px;
}

.theme-swatches {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.theme-swatch {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid transparent;
    padding: 0;
    cursor: pointer;
    overflow: hidden;
    display: flex;
    transition: border-color 120ms ease, transform 120ms ease;
    position: relative;
}

.theme-swatch:hover {
    transform: scale(1.15);
}

.theme-swatch.is-active {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent);
}

.theme-swatch span {
    flex: 1;
    display: block;
    width: 100%;
    height: 100%;
}

/* ===========================
   WORKSPACE
   =========================== */

.workspace {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    height: 100dvh;
    max-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-gutter: stable both-edges;
    scroll-padding-bottom: 220px;
    transition: background 250ms ease;
}

.mobile-composer-fab {
    display: none;
}

.workspace .topbar {
    flex: 0 0 auto;
    position: sticky;
    top: 0;
    z-index: 14;
}

.workspace .message-scroller {
    flex: 1 0 auto;
    min-height: 0;
    padding-bottom: 24px;
    overflow: visible;
}

.workspace .composer-wrap {
    flex: 0 0 auto;
    min-height: 0;
    position: sticky;
    bottom: 0;
}

/* ===========================
   TRUE CENTERED STATE
   =========================== */

.workspace.is-empty .message-scroller {
    display: block;
}

.workspace.is-empty #message-list {
    display: none;
}

.centered-container {
    width: min(720px, 100%);
    min-height: 100%;
    margin: 0 auto;
    padding: clamp(28px, 8vh, 72px) 20px 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.workspace:not(.is-empty) .centered-container {
    display: none;
}

.workspace.is-empty .empty-state {
    border: none;
    background: transparent;
    text-align: center;
    margin-bottom: 24px;
}

.empty-state h2 {
    margin: 0;
    font-size: 34px;
    letter-spacing: -0.03em;
}

.empty-state p {
    margin: 8px 0 0;
    color: var(--text-muted);
}

.centered-composer {
    width: 100%;
}

.centered-composer .composer-shell {
    width: 100%;
}

.centered-textarea {
    width: 100%;
    border: none;
    background: transparent;
    color: var(--text-main);
    font-size: 22px;
    line-height: 1.5;
    min-height: 52px;
    max-height: 200px;
    resize: none;
    padding: 2px 2px 8px;
}

.centered-textarea::placeholder {
    color: var(--text-muted);
}

.centered-textarea:focus {
    outline: none;
}

/* ===========================
   TOPBAR
   =========================== */

.topbar {
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    background: var(--bg-topbar);
    backdrop-filter: blur(10px);
    position: relative;
    z-index: 10;
}

.topbar-left,
.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border-soft);
    background: var(--bg-code);
    color: var(--text-subtle);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
}

.user-pill {
    max-width: 240px;
    border: 1px solid var(--border-soft);
    background: var(--bg-code);
    border-radius: 999px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-pill-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px 6px 8px;
    cursor: pointer;
}

.user-pill-text {
    display: inline-block;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-pill-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(255,133,82,0.18), rgba(127,90,240,0.22));
    color: var(--text-main);
    flex: 0 0 auto;
}

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

.user-pill-avatar span {
    font-size: 13px;
    font-weight: 700;
}

.user-menu-shell {
    position: relative;
}

.user-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 210px;
    padding: 8px;
    border-radius: 16px;
    border: 1px solid var(--border-soft);
    background: var(--bg-message-assistant);
    box-shadow: var(--shadow);
    z-index: 30;
}

.user-menu-link {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    color: var(--text-main);
    text-decoration: none;
    border: none;
    background: transparent;
    cursor: pointer;
}

.user-menu-link:hover {
    background: var(--bg-code);
}

.user-menu-link-main {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.user-menu-link-main svg {
    flex: 0 0 auto;
    opacity: 0.82;
}

.user-menu-button {
    font: inherit;
}

.ghost-btn {
    border: 1px solid var(--border-soft);
    background: var(--bg-code);
    border-radius: 9px;
    padding: 8px 11px;
    color: var(--text-subtle);
    cursor: pointer;
    transition: all 120ms ease;
}

.ghost-btn:hover {
    border-color: var(--accent);
}

/* ===========================
   MESSAGE AREA
   =========================== */

.message-scroller {
    overflow: visible;
    padding: 18px;
    min-height: 0;
}

#message-list {
    width: min(900px, 100%);
    margin: 0 auto;
    display: grid;
    gap: 14px;
    min-width: 0;
    position: relative;
}

/* ===========================
   MESSAGES
   =========================== */

.message {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    transition: background 250ms ease;
}

.message.user {
    background: var(--bg-message-user);
}

.message.assistant {
    background: var(--bg-message-assistant);
}

.message.system {
    border: none;
    padding: 0;
    background: transparent;
}

.message-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 10px;
}

.message-head>* {
    min-width: 0;
}

.message-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.message-label .model-icon {
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.message-label .model-icon img {
    width: 16px;
    height: 16px;
}

.message-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    min-width: 0;
}

.message-action-btn {
    border: 1px solid var(--border-soft);
    background: var(--bg-message-user);
    color: var(--text-subtle);
    border-radius: 8px;
    padding: 5px 8px;
    font-size: 12px;
    cursor: pointer;
    transition: all 120ms ease;
}

.message-action-btn:hover {
    border-color: var(--accent);
}

.message-stream-status {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border: 1px solid var(--border-soft);
    background: linear-gradient(135deg, rgba(52, 120, 246, 0.12), rgba(52, 199, 156, 0.08));
    color: var(--text-main);
    border-radius: 999px;
    min-width: 120px;
    justify-content: flex-end;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
    max-width: 100%;
}

.message-stream-status.is-active {
    display: inline-flex;
}

.message-stream-pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 0 rgba(52, 120, 246, 0.36);
    animation: thinkingPulse 1.8s infinite;
}

.message-stream-label {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.03em;
}

.message-stream-timer {
    min-width: 38px;
    text-align: right;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-subtle);
}

.message-content {
    color: var(--text-main);
    line-height: 1.7;
    font-size: 15px;
    overflow-wrap: break-word;
}

.assistant-answer,
.reasoning-panel,
.reasoning-body,
.search-citations,
.citation-link,
.code-toolbar,
.user-attachments,
.user-attachment-chip {
    min-width: 0;
    max-width: 100%;
}

.assistant-answer,
.reasoning-body {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.assistant-answer.is-streaming {
    white-space: pre-wrap;
}

.message-content a,
.assistant-answer a,
.reasoning-body a {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.assistant-answer>:first-child,
.reasoning-body>:first-child {
    margin-top: 0;
}

.assistant-answer>:last-child,
.reasoning-body>:last-child {
    margin-bottom: 0;
}

.generated-image-card {
    width: min(100%, 520px);
    margin: 12px 0 0;
}

.generated-image-media {
    position: relative;
}

.generated-image-card a {
    display: grid;
    place-items: center;
    aspect-ratio: 1 / 1;
    border: 1px solid var(--border-soft);
    background: var(--bg-message-user);
    overflow: hidden;
}

.generated-image-card img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
}

.generated-image-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
    display: flex;
    gap: 8px;
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    transition: opacity .16s ease, transform .16s ease;
}

.generated-image-download-btn,
.generated-image-edit-btn,
.generated-image-delete-btn {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, .62);
    background: rgba(18, 23, 28, .72);
    color: #fff;
    box-shadow: 0 10px 24px rgba(0, 0, 0, .24);
    transition: opacity .16s ease, transform .16s ease, background .16s ease;
    cursor: pointer;
}

.generated-image-media:hover .generated-image-actions,
.generated-image-media:focus-within .generated-image-actions {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.generated-image-download-btn:hover,
.generated-image-download-btn:focus-visible,
.generated-image-edit-btn:hover,
.generated-image-edit-btn:focus-visible,
.generated-image-delete-btn:hover,
.generated-image-delete-btn:focus-visible {
    background: rgba(18, 23, 28, .9);
    outline: none;
}

.generated-image-delete-btn:hover,
.generated-image-delete-btn:focus-visible {
    background: rgba(173, 37, 37, .9);
}

.generated-image-card figcaption {
    margin-top: 8px;
    color: var(--text-subtle);
    font-size: 13px;
    line-height: 1.5;
}

.generated-file-list {
    width: min(100%, 620px);
    margin: 12px 0 0;
    display: grid;
    gap: 8px;
}

.generated-file-card {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) 40px;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border: 1px solid var(--border-soft);
    background: var(--bg-message-user);
}

.generated-file-icon {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border-soft);
    background: var(--bg-code);
    color: var(--text-strong);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0;
}

.generated-file-info {
    min-width: 0;
}

.generated-file-title {
    color: var(--text-strong);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.generated-file-meta {
    margin-top: 3px;
    color: var(--text-subtle);
    font-size: 12px;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.generated-file-download {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border-soft);
    background: var(--bg-panel);
    color: var(--text-strong);
    cursor: pointer;
    transition: border-color .16s ease, color .16s ease, background .16s ease;
}

.generated-file-download:hover,
.generated-file-download:focus-visible {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--bg-code);
    outline: none;
}

.thinking-card {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    margin-bottom: 12px;
    border: 1px solid var(--border-soft);
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(52, 120, 246, 0.12), rgba(120, 190, 255, 0.06) 46%, rgba(52, 199, 156, 0.08));
    overflow: hidden;
}

.thinking-card.is-image-generation {
    transform: perspective(720px) rotateX(1deg) translateZ(0);
    border-color: rgba(160, 108, 182, 0.30);
    background:
        radial-gradient(circle at 18% 16%, rgba(177, 87, 151, 0.30), transparent 34%),
        radial-gradient(circle at 78% 22%, rgba(110, 168, 254, 0.22), transparent 38%),
        linear-gradient(135deg, rgba(177, 87, 151, 0.22) 0%, rgba(90, 99, 167, 0.20) 50%, rgba(70, 107, 171, 0.24) 100%),
        linear-gradient(180deg, rgba(19, 26, 36, 0.96), rgba(11, 16, 24, 0.98));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 16px 34px rgba(34, 24, 56, 0.26);
    animation: imageThinkingLift 2.8s ease-in-out infinite;
}

.thinking-card.is-image-generation::after {
    background: linear-gradient(110deg, transparent 0%, rgba(255, 255, 255, 0.10) 46%, transparent 72%);
}

.thinking-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(110deg, transparent 0%, rgba(255, 255, 255, 0.18) 46%, transparent 72%);
    transform: translateX(-100%);
    animation: thinkingSweep 2.8s linear infinite;
}

.thinking-copy {
    position: relative;
    z-index: 1;
    min-width: 0;
}

.thinking-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
}

.thinking-card.is-image-generation .thinking-title {
    color: #f5f8ff;
}

.thinking-hint {
    margin-top: 4px;
    font-size: 13px;
    color: var(--text-subtle);
}

.thinking-card.is-image-generation .thinking-hint {
    color: #cbd8ea;
}

.thinking-card-timer {
    margin-top: 8px;
    display: inline-flex;
    align-items: center;
    width: fit-content;
    border: 1px solid rgba(52, 120, 246, 0.22);
    border-radius: 999px;
    padding: 3px 8px;
    color: var(--accent);
    background: rgba(255, 255, 255, 0.52);
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 700;
}

.thinking-card.is-image-generation .thinking-card-timer {
    border-color: rgba(110, 168, 254, 0.28);
    color: #e7f0ff;
    background: rgba(110, 168, 254, 0.14);
}

.thinking-bars {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: flex-end;
    gap: 4px;
    height: 22px;
    flex-shrink: 0;
}

.thinking-bars span {
    width: 4px;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(180deg, var(--accent), rgba(52, 199, 156, 0.92));
    transform-origin: center bottom;
    animation: thinkingBars 1.1s ease-in-out infinite;
}

.thinking-card.is-image-generation .thinking-bars span {
    background: linear-gradient(180deg, #8ec5ff, rgba(52, 199, 156, 0.92));
}

.thinking-bars span:nth-child(2) {
    animation-delay: 0.14s;
}

.thinking-bars span:nth-child(3) {
    animation-delay: 0.28s;
}

.thinking-bars span:nth-child(4) {
    animation-delay: 0.42s;
}

.reasoning-panel {
    border: 1px solid rgba(160, 108, 182, 0.24);
    background:
        radial-gradient(circle at 18% 16%, rgba(177, 87, 151, 0.32), transparent 34%),
        radial-gradient(circle at 78% 22%, rgba(160, 108, 182, 0.22), transparent 38%),
        linear-gradient(135deg, rgba(177, 87, 151, 0.22) 0%, rgba(160, 108, 182, 0.18) 36%, rgba(90, 99, 167, 0.2) 70%, rgba(70, 107, 171, 0.22) 100%),
        linear-gradient(180deg, rgba(19, 26, 36, 0.96), rgba(11, 16, 24, 0.98));
    border-radius: 14px;
    padding: 12px 14px;
    margin-bottom: 14px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 14px 30px rgba(58, 49, 92, 0.2);
}

.reasoning-panel.is-live {
    border-color: rgba(128, 123, 196, 0.34);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 16px 34px rgba(88, 99, 171, 0.24);
}

.reasoning-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.reasoning-title {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #9ec0ff;
}

.reasoning-badge {
    border: 1px solid rgba(110, 168, 254, 0.22);
    border-radius: 999px;
    background: rgba(110, 168, 254, 0.12);
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 700;
    color: #dce8fb;
}

.reasoning-panel.is-live .reasoning-badge {
    color: #f2f7ff;
    border-color: rgba(110, 168, 254, 0.34);
    background: rgba(110, 168, 254, 0.16);
}

.reasoning-body {
    color: #d6e2f2;
    font-size: 13px;
    line-height: 1.78;
    font-family: var(--font-mono);
}

.reasoning-body :not(pre)>code {
    background: rgba(148, 163, 184, 0.12);
    border-color: rgba(148, 163, 184, 0.18);
    color: #eff6ff;
}

.reasoning-body pre {
    background: rgba(7, 11, 19, 0.86);
    border-color: rgba(110, 168, 254, 0.12);
}

.reasoning-body pre code {
    color: inherit;
}

.reasoning-body blockquote {
    color: #9fb2cc;
    border-left-color: rgba(110, 168, 254, 0.24);
    background: rgba(148, 163, 184, 0.08);
    padding: 10px 12px;
    border-radius: 8px;
}

.reasoning-body strong {
    color: #f4f8ff;
}

.reasoning-body a {
    color: #9fc5ff;
}

.reasoning-body.is-streaming {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.message.assistant.is-thinking .message-action-btn {
    display: none;
}

.message.assistant.is-thinking .message-stream-status {
    min-width: 0;
}

.message-content p {
    margin: 0 0 10px;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4 {
    margin: 16px 0 8px;
}

.message-content ul,
.message-content ol {
    margin: 8px 0;
    padding-left: 22px;
}

.message-content blockquote {
    margin: 10px 0;
    border-left: 4px solid var(--accent-soft);
    padding-left: 12px;
    color: var(--text-subtle);
}

.message-content :not(pre)>code {
    border: 1px solid var(--border-soft);
    background: var(--bg-code);
    border-radius: 6px;
    padding: 1px 6px;
    font-family: var(--font-mono);
    font-size: 0.88em;
}

.message-content pre {
    border: 1px solid var(--border);
    background: var(--bg-code);
    border-radius: 10px;
    padding: 14px;
    overflow-x: auto;
    margin: 10px 0;
}

.message-content pre code {
    font-family: var(--font-mono);
    font-size: 13px;
}

.code-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 1px solid var(--border);
    border-bottom: none;
    background: var(--bg-message-user);
    color: var(--text-subtle);
    border-radius: 10px 10px 0 0;
    padding: 6px 10px;
    font-family: var(--font-mono);
    font-size: 12px;
}

.code-toolbar button {
    border: 1px solid var(--border-soft);
    background: transparent;
    color: var(--text-main);
    border-radius: 6px;
    padding: 2px 8px;
    cursor: pointer;
}

.code-toolbar+pre {
    margin-top: 0 !important;
    border-top-left-radius: 0 !important;
    border-top-right-radius: 0 !important;
}

.typing {
    display: flex;
    align-items: center;
    gap: 6px;
}

.typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: bounce 1.4s infinite ease-in-out;
}

.typing span:nth-child(2) {
    animation-delay: 0.16s;
}

.typing span:nth-child(3) {
    animation-delay: 0.32s;
}

.system-line {
    border: 1px solid var(--border-soft);
    background: var(--bg-message-user);
    color: var(--text-subtle);
    border-radius: 10px;
    padding: 8px 11px;
    font-size: 14px;
}

.system-line.error {
    border-color: var(--danger);
    color: var(--danger);
}

/* Context cleared divider */
.context-cleared-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
}

.context-cleared-divider::before,
.context-cleared-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-soft);
}

.context-cleared-text {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    letter-spacing: 0.02em;
}

/* Speak button icon */
.speak-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 7px;
}

.speak-btn svg {
    flex-shrink: 0;
    pointer-events: none;
}

.speak-btn.is-speaking {
    border-color: var(--accent);
    color: var(--accent);
}

.user-attachments {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.user-attachment-chip {
    border: 1px solid var(--border-soft);
    border-radius: 999px;
    padding: 4px 9px;
    font-size: 12px;
    color: var(--text-subtle);
    background: var(--bg-code);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.user-attachment-thumb {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    object-fit: cover;
    border: 1px solid var(--border-soft);
}

.user-attachment-dot {
    border: 1px solid var(--border-soft);
    border-radius: 6px;
    padding: 1px 4px;
    font-size: 10px;
    font-weight: 700;
}

/* ===========================
   SEARCH CITATIONS
   =========================== */

.search-citations {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border-soft);
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.citations-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    width: 100%;
    margin-bottom: 2px;
}

.citation-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 1px solid var(--border-soft);
    border-radius: 999px;
    background: var(--bg-code);
    color: var(--text-subtle);
    padding: 4px 10px 4px 6px;
    font-size: 12px;
    text-decoration: none;
    transition: all 140ms ease;
    max-width: 260px;
}

.citation-link:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--bg-sidebar-hover);
}

.citation-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    flex-shrink: 0;
}

.citation-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===========================
   COMPOSER (BOTTOM; shown after the first message)
   =========================== */

.composer-wrap {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px 16px 16px;
    background: var(--bg-composer);
    backdrop-filter: blur(10px);
    transition: background 250ms ease;
    position: relative;
    z-index: 12;
    flex-shrink: 0;
}

.composer-shell {
    width: min(900px, 100%);
    margin: 0 auto;
    border: 1px solid var(--border);
    border-radius: 26px;
    background: var(--bg-composer-shell);
    padding: 14px;
    box-shadow: var(--shadow);
    transition: border-color 250ms ease, box-shadow 250ms ease;
}

.composer-shell.is-dragover {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(76, 141, 255, 0.2), var(--shadow);
}

#message-input {
    width: 100%;
    border: none;
    background: transparent;
    color: var(--text-main);
    font-size: 16px;
    line-height: 1.5;
    min-height: 44px;
    max-height: 240px;
    resize: none;
    padding: 2px 2px 8px;
}

#message-input::placeholder {
    color: var(--text-muted);
}

#message-input:focus {
    outline: none;
}

.attachment-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.attachment-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--border-soft);
    border-radius: 999px;
    background: var(--bg-code);
    color: var(--text-main);
    padding: 5px 10px;
    font-size: 12px;
    max-width: 280px;
}

.attachment-thumb {
    width: 20px;
    height: 20px;
    border-radius: 5px;
    object-fit: cover;
    border: 1px solid var(--border-soft);
}

.attachment-doc-badge {
    border: 1px solid var(--border-soft);
    border-radius: 6px;
    background: var(--bg-message-user);
    padding: 1px 6px;
    font-size: 10px;
    font-weight: 700;
}

.attachment-name {
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.attachment-pill button {
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    line-height: 1;
    font-size: 14px;
}

.attachment-pill button:hover {
    color: var(--text-main);
}

.composer-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.composer-left,
.composer-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Icon buttons */
.control-btn {
    border: 1px solid var(--border);
    background: var(--bg-code);
    color: var(--text-subtle);
    border-radius: 999px;
    padding: 9px 12px;
    font-size: 14px;
    cursor: pointer;
    transition: all 120ms ease;
}

.control-btn:hover {
    border-color: var(--accent);
}

.control-btn.is-active {
    border-color: var(--accent);
    background: var(--bg-sidebar-active);
    color: var(--text-main);
}

.icon-control {
    width: 38px;
    height: 38px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.icon-control svg {
    flex-shrink: 0;
}

/* Mic recording */
.control-btn.is-recording {
    border-color: var(--danger);
    background: rgba(225, 100, 93, 0.15);
    color: var(--danger);
    animation: pulse-recording 1.5s infinite;
}

@keyframes pulse-recording {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(225, 100, 93, 0.4);
    }

    50% {
        box-shadow: 0 0 0 8px rgba(225, 100, 93, 0);
    }
}

@keyframes thinkingPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(52, 120, 246, 0.36);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(52, 120, 246, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(52, 120, 246, 0);
    }
}

@keyframes thinkingBars {
    0%,
    100% {
        transform: scaleY(0.38);
        opacity: 0.45;
    }

    50% {
        transform: scaleY(1);
        opacity: 1;
    }
}

@keyframes thinkingSweep {
    from {
        transform: translateX(-100%);
    }

    to {
        transform: translateX(100%);
    }
}

@keyframes imageThinkingLift {
    0%,
    100% {
        transform: perspective(720px) rotateX(1deg) translateY(0);
    }

    50% {
        transform: perspective(720px) rotateX(1.8deg) translateY(-2px);
    }
}

/* Model Picker */
.model-picker {
    position: relative;
}

.model-picker-btn {
    border: 1px solid var(--border);
    background: var(--bg-code);
    color: var(--text-main);
    border-radius: 999px;
    height: 38px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 120ms ease;
}

.model-picker-btn:hover {
    border-color: var(--accent);
}

.model-picker-icon {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.model-picker-icon img,
.model-picker-icon svg {
    width: 18px;
    height: 18px;
}

.model-picker-label {
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.model-picker-caret {
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
}

.model-menu {
    position: absolute;
    left: 0;
    bottom: 46px;
    min-width: 250px;
    max-height: 280px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-page);
    box-shadow: var(--shadow);
    padding: 6px;
    z-index: 30;
    display: none;
}

.model-menu.is-open {
    display: grid;
    gap: 2px;
}

.reasoning-picker {
    position: relative;
}

.reasoning-picker-btn {
    border: 1px solid var(--border);
    background: var(--bg-code);
    color: var(--text-main);
    border-radius: 999px;
    height: 38px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 120ms ease;
}

.reasoning-picker-btn:hover {
    border-color: var(--accent);
}

.reasoning-picker-icon {
    width: 20px;
    height: 20px;
    min-width: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
}

.reasoning-option .reasoning-picker-icon {
    color: inherit;
}

.reasoning-signal {
    width: 22px;
    height: 14px;
    display: inline-flex;
    align-items: flex-end;
    gap: 2px;
}

.reasoning-signal-bar {
    width: 3px;
    border-radius: 999px;
    background: var(--border-soft);
    opacity: 0.5;
}

.reasoning-signal-bar:nth-child(1) {
    height: 3px;
}

.reasoning-signal-bar:nth-child(2) {
    height: 5px;
}

.reasoning-signal-bar:nth-child(3) {
    height: 8px;
}

.reasoning-signal-bar:nth-child(4) {
    height: 11px;
}

.reasoning-signal-bar:nth-child(5) {
    height: 14px;
}

.reasoning-signal-bar.is-active {
    background: currentColor;
    opacity: 1;
}

.reasoning-picker-label {
    max-width: 88px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reasoning-menu {
    position: absolute;
    left: 0;
    bottom: 46px;
    min-width: 170px;
    max-height: 280px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-page);
    box-shadow: var(--shadow);
    padding: 6px;
    z-index: 30;
    display: none;
}

.reasoning-menu.is-open {
    display: grid;
    gap: 2px;
}

.reasoning-option {
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--text-subtle);
    text-align: left;
    padding: 7px 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 120ms ease;
}

.reasoning-option-hint {
    margin-left: auto;
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

.reasoning-option:hover {
    background: var(--bg-sidebar-hover);
    border-color: var(--border-soft);
}

.reasoning-option:disabled,
.reasoning-option.is-disabled {
    cursor: not-allowed;
    opacity: 0.58;
}

.reasoning-option:disabled:hover,
.reasoning-option.is-disabled:hover {
    background: transparent;
    border-color: transparent;
}

.reasoning-option.is-selected {
    background: var(--bg-sidebar-active);
    border-color: var(--accent);
    color: var(--text-main);
}

.reasoning-option.is-selected .reasoning-option-hint {
    color: var(--text-subtle);
}

.reasoning-option-check {
    margin-left: auto;
    display: inline-flex;
    color: var(--accent);
    opacity: 0;
}

.reasoning-option.is-selected .reasoning-option-check {
    opacity: 1;
}

.image-size-menu {
    min-width: 240px;
}

.image-size-picker-icon {
    color: var(--accent);
}

.image-size-preview {
    width: 20px;
    height: 16px;
    border: 2px solid currentColor;
    border-radius: 4px;
    display: inline-block;
    box-shadow: inset 0 0 0 2px var(--bg-page);
}

.image-size-preview.is-square {
    width: 17px;
    height: 17px;
}

.image-size-preview.is-landscape {
    width: 22px;
    height: 13px;
}

.image-size-preview.is-portrait {
    width: 13px;
    height: 22px;
}

.image-size-option-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
    flex: 1;
}

.image-size-option-title {
    color: var(--text-main);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.image-size-option-size {
    color: var(--text-muted);
    font-size: 11px;
    white-space: nowrap;
}

.image-size-option .image-size-price {
    margin-left: 8px;
    font-weight: 600;
    color: var(--text-subtle);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    min-width: 58px;
}

.image-size-lock-label {
    color: var(--accent);
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    text-transform: uppercase;
}

.image-size-picker-label {
    max-width: 92px;
}

.model-option {
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--text-subtle);
    text-align: left;
    padding: 7px 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 120ms ease;
}

.model-option-label {
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.model-group-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 8px 4px 6px;
    padding: 0 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-muted);
    pointer-events: none;
}

.model-group-divider::before,
.model-group-divider::after {
    content: '';
    flex: 1 1 auto;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-soft), transparent);
}

.model-group-divider[data-family="openai"] {
    color: #20a37f;
}

.model-group-divider[data-family="openai"]::before,
.model-group-divider[data-family="openai"]::after {
    background: linear-gradient(90deg, transparent, rgba(32, 163, 127, 0.42), transparent);
}

.model-group-divider[data-family="anthropic"] {
    color: #c97c3d;
}

.model-group-divider[data-family="anthropic"]::before,
.model-group-divider[data-family="anthropic"]::after {
    background: linear-gradient(90deg, transparent, rgba(201, 124, 61, 0.38), transparent);
}

.model-group-divider[data-family="gemini"] {
    color: #5b7cff;
}

.model-group-divider[data-family="gemini"]::before,
.model-group-divider[data-family="gemini"]::after {
    background: linear-gradient(90deg, transparent, rgba(91, 124, 255, 0.38), transparent);
}

.model-group-divider[data-family="deepseek"] {
    color: #0fa38a;
}

.model-group-divider[data-family="deepseek"]::before,
.model-group-divider[data-family="deepseek"]::after {
    background: linear-gradient(90deg, transparent, rgba(15, 163, 138, 0.4), transparent);
}

.model-group-divider[data-family="xai"] {
    color: #d04d8d;
}

.model-group-divider[data-family="xai"]::before,
.model-group-divider[data-family="xai"]::after {
    background: linear-gradient(90deg, transparent, rgba(208, 77, 141, 0.4), transparent);
}

.model-option:hover {
    background: var(--bg-sidebar-hover);
    border-color: var(--border-soft);
}

.model-option.is-selected {
    background: var(--bg-sidebar-active);
    border-color: var(--accent-soft);
}

.model-option img,
.model-option svg {
    width: 16px;
    height: 16px;
}

/* Send Button */
.send-btn-circle {
    border: none;
    border-radius: 999px;
    background: linear-gradient(120deg, var(--accent-soft), var(--accent));
    color: #fff;
    width: 40px;
    height: 40px;
    padding: 0;
    cursor: pointer;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 150ms ease;
}

.send-btn-circle:hover {
    transform: scale(1.05);
}

.send-btn-circle.is-streaming {
    background: linear-gradient(120deg, #a63b37, #dc5f56);
}

.send-btn-circle .is-hidden {
    display: none;
}

.footnote {
    width: min(900px, 100%);
    margin: 8px auto 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
}

.backdrop {
    display: none;
}

/* ===========================
   VOICE RECORDER MODAL
   =========================== */

.voice-modal {
    position: fixed;
    inset: 0;
    z-index: 110;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 180ms ease;
}

.voice-modal.is-hidden {
    display: none !important;
}

.voice-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(12px);
}

.voice-modal-body {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 48px 40px 40px;
    animation: slideUp 250ms ease;
}

/* Pulsing ring container */
.voice-modal-ring {
    position: relative;
    width: 140px;
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.voice-modal-ring-pulse {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--accent);
    opacity: 0;
    animation: voicePulse 2.4s infinite ease-out;
}

.voice-modal-ring-pulse.delay-1 {
    animation-delay: 0.8s;
}

.voice-modal-ring-pulse.delay-2 {
    animation-delay: 1.6s;
}

@keyframes voicePulse {
    0% {
        transform: scale(0.6);
        opacity: 0.7;
    }

    100% {
        transform: scale(1.3);
        opacity: 0;
    }
}

.voice-modal-mic-circle {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-soft), var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 6px 30px rgba(76, 141, 255, 0.35);
    animation: micGlow 1.5s infinite alternate ease-in-out;
}

@keyframes micGlow {
    0% {
        box-shadow: 0 6px 30px rgba(76, 141, 255, 0.25);
        transform: scale(1);
    }

    100% {
        box-shadow: 0 6px 40px rgba(76, 141, 255, 0.5);
        transform: scale(1.04);
    }
}

.voice-timer {
    font-size: 40px;
    font-weight: 700;
    color: #fff;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.04em;
}

.voice-hint {
    margin: 0;
    color: rgba(255, 255, 255, 0.6);
    font-size: 14px;
}

.voice-modal-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 8px;
}

.voice-action-btn {
    border: none;
    border-radius: 999px;
    padding: 12px 28px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 150ms ease;
}

.voice-cancel {
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.voice-cancel:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.voice-stop {
    background: linear-gradient(120deg, #dc4545, #e66060);
    color: #fff;
}

.voice-stop:hover {
    transform: scale(1.04);
}

/* ===========================
   ANIMATIONS
   =========================== */

@keyframes bounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.35;
    }

    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(24px) scale(0.97);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ===========================
   RESPONSIVE - TABLET
   =========================== */

@media (max-width: 1040px) {
    .chat-screen {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 280px;
        transform: translateX(-105%);
        transition: transform 220ms ease, background 250ms ease;
        z-index: 25;
        overflow-y: auto;
    }

    .sidebar.is-open {
        transform: translateX(0);
    }

    .icon-btn {
        display: inline-flex;
    }

    .backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 20;
        opacity: 0;
        pointer-events: none;
        background: rgba(0, 0, 0, 0.45);
        transition: opacity 170ms ease;
    }

    .backdrop.is-visible {
        opacity: 1;
        pointer-events: auto;
    }
}

/* ===========================
   RESPONSIVE - MOBILE
   =========================== */

@media (max-width: 760px) {
    .workspace.has-mobile-collapsed-composer {
        scroll-padding-bottom: calc(112px + env(safe-area-inset-bottom));
    }

    .workspace.has-mobile-collapsed-composer .message-scroller {
        padding-bottom: calc(96px + env(safe-area-inset-bottom));
    }

    .sidebar {
        width: 260px;
    }

    .topbar {
        height: 50px;
        padding:
            0
            max(12px, env(safe-area-inset-right))
            0
            max(12px, env(safe-area-inset-left));
    }

    .topbar-right {
        gap: 6px;
    }

    .ghost-btn {
        padding: 6px 8px;
        font-size: 12px;
    }

    .workspace {
        scroll-padding-bottom: calc(172px + env(safe-area-inset-bottom));
    }

    .message-scroller {
        padding:
            12px
            max(12px, env(safe-area-inset-right))
            16px
            max(12px, env(safe-area-inset-left));
    }

    .empty-state h2 {
        font-size: 24px;
    }

    .centered-textarea {
        font-size: 18px;
        min-height: 44px;
    }

    .centered-container {
        padding:
            24px
            max(14px, env(safe-area-inset-right))
            32px
            max(14px, env(safe-area-inset-left));
    }

    .user-pill {
        max-width: min(42vw, 148px);
        font-size: 12px;
        padding: 5px 8px;
    }

    .composer-wrap {
        padding:
            10px
            max(12px, env(safe-area-inset-right))
            8px
            max(12px, env(safe-area-inset-left));
        padding-bottom: max(8px, env(safe-area-inset-bottom));
        overflow: visible;
        z-index: 40;
    }

    .composer-wrap.is-mobile-collapsed {
        display: none;
    }

    

    .composer-controls {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: end;
        column-gap: 8px;
        row-gap: 8px;
    }

    .composer-left {
        min-width: 0;
        flex-wrap: wrap;
        gap: 6px;
        /* Keep mobile picker popovers clickable instead of clipping them inside the toolbar row. */
        overflow: visible;
    }

    .composer-right {
        min-width: 0;
        flex-shrink: 0;
        gap: 6px;
        justify-self: end;
        margin-left: auto;
    }

    .model-picker,
    .reasoning-picker {
        min-width: 0;
        max-width: 100%;
    }

    .model-picker-btn,
    .reasoning-picker-btn {
        max-width: 100%;
    }

    .model-menu {
        position: fixed;
        left: 12px;
        right: 12px;
        bottom: max(12px, calc(12px + env(safe-area-inset-bottom)));
        min-width: 0;
        width: auto;
        max-width: none;
        max-height: min(52vh, 320px);
        border-radius: 18px;
        padding: 10px;
        z-index: 60;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }

    .reasoning-menu {
        position: fixed;
        left: 12px;
        right: 12px;
        bottom: max(12px, calc(12px + env(safe-area-inset-bottom)));
        min-width: 0;
        width: auto;
        max-width: none;
        max-height: min(52vh, 320px);
        border-radius: 18px;
        padding: 10px;
        z-index: 60;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }

    .model-option,
    .reasoning-option {
        min-height: 42px;
    }

    .model-group-divider {
        margin: 10px 4px 8px;
    }

    .reasoning-picker-label {
        max-width: 68px;
        font-size: 12px;
    }


    #message-input {
        font-size: 15px;
        min-height: 38px;
    }

    .model-picker-label {
        max-width: 72px;
        font-size: 12px;
    }

    .model-picker-btn {
        height: 34px;
        gap: 4px;
        padding: 0 8px;
    }

    .icon-control {
        width: 34px;
        height: 34px;
        flex-shrink: 0;
    }

    .send-btn-circle {
        width: 38px;
        height: 38px;
        flex-shrink: 0;
    }

    .footnote {
        font-size: 10px;
    }

    .message {
        padding: 10px;
    }

    .context-menu {
        min-width: 160px;
    }

    .theme-swatch {
        width: 22px;
        height: 22px;
    }

    .mobile-composer-fab {
        position: fixed;
        right: max(12px, env(safe-area-inset-right));
        bottom: calc(14px + env(safe-area-inset-bottom));
        z-index: 15;
        display: inline-flex;
        align-items: center;
        gap: 12px;
        width: min(calc(100vw - 24px - env(safe-area-inset-left) - env(safe-area-inset-right)), 228px);
        min-height: 58px;
        padding: 12px 14px;
        border: 1px solid rgba(160, 108, 182, 0.26);
        border-radius: 18px;
        background:
            radial-gradient(circle at 18% 16%, rgba(177, 87, 151, 0.30), transparent 34%),
            radial-gradient(circle at 78% 22%, rgba(160, 108, 182, 0.22), transparent 38%),
            linear-gradient(135deg, rgba(177, 87, 151, 0.24) 0%, rgba(160, 108, 182, 0.18) 38%, rgba(90, 99, 167, 0.20) 72%, rgba(70, 107, 171, 0.22) 100%),
            linear-gradient(180deg, rgba(19, 26, 36, 0.96), rgba(11, 16, 24, 0.98));
        color: #f5f8ff;
        box-shadow: 0 18px 34px rgba(34, 24, 56, 0.32);
        backdrop-filter: blur(16px);
        cursor: pointer;
        text-align: left;
    }

    .mobile-composer-fab:focus-visible {
        outline: 2px solid var(--accent);
        outline-offset: 2px;
    }

    .mobile-composer-fab-orb {
        width: 10px;
        height: 10px;
        border-radius: 50%;
        flex-shrink: 0;
        background: linear-gradient(180deg, #8ec5ff, #6ea8fe);
        box-shadow: 0 0 0 0 rgba(110, 168, 254, 0.34);
    }

    .mobile-composer-fab-copy {
        display: grid;
        gap: 2px;
        min-width: 0;
        flex: 1 1 auto;
    }

    .mobile-composer-fab-badge {
        font-size: 10px;
        font-weight: 700;
        letter-spacing: 0.10em;
        text-transform: uppercase;
        color: #b8d2ff;
    }

    .mobile-composer-fab-label {
        font-size: 13px;
        font-weight: 700;
        color: #f5f8ff;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .mobile-composer-fab-bars {
        display: inline-flex;
        align-items: flex-end;
        gap: 3px;
        height: 18px;
        flex-shrink: 0;
    }

    .mobile-composer-fab-bars span {
        width: 3px;
        height: 100%;
        border-radius: 999px;
        background: linear-gradient(180deg, #8ec5ff, rgba(52, 199, 156, 0.92));
        transform-origin: center bottom;
        animation: thinkingBars 1.15s ease-in-out infinite;
    }

    .mobile-composer-fab-bars span:nth-child(2) {
        animation-delay: 0.14s;
    }

    .mobile-composer-fab-bars span:nth-child(3) {
        animation-delay: 0.28s;
    }

    .mobile-composer-fab:not(.is-streaming) .mobile-composer-fab-bars span {
        animation-duration: 1.8s;
        opacity: 0.7;
    }

    .mobile-composer-fab.is-streaming .mobile-composer-fab-orb {
        animation: thinkingPulse 1.8s infinite;
    }

    .share-icon-btn {
        width: 32px;
        height: 32px;
        border-radius: 8px;
    }

    .share-icons {
        gap: 5px;
    }

    .share-picker {
        padding-bottom: 10px;
        margin-bottom: 10px;
    }
}

@media (min-width: 761px) {
    .mobile-composer-fab {
        display: none !important;
    }
}

/* ===========================
   RESPONSIVE - TINY PHONE HEIGHTS
   =========================== */

@media (max-height: 600px) {
    .topbar {
        height: 44px;
    }

    .sidebar-header {
        margin-bottom: 4px;
    }

    .sidebar-search {
        margin-bottom: 4px;
    }

    .sidebar-footer {
        padding-top: 4px;
        margin-top: 4px;
    }

    .share-picker {
        padding-bottom: 6px;
        margin-bottom: 6px;
    }
}

/* reCAPTCHA: hide floating badge (inline attribution in register form) */
.grecaptcha-badge {
    visibility: hidden !important;
    width: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
    pointer-events: none !important;
    opacity: 0 !important;
    z-index: -1 !important;
}

.recaptcha-notice {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
    margin: 8px 0 0;
    line-height: 1.4;
}

.recaptcha-notice a {
    color: var(--accent);
    text-decoration: none;
}

.recaptcha-notice a:hover {
    text-decoration: underline;
}




.usage-summary-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 10px;
}

.usage-summary-row .settings-menu-label {
    white-space: nowrap;
}

.settings-menu-footnote {
    padding: 0 12px 8px 38px;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-muted);
    word-break: break-word;
}

[dir="rtl"] .settings-menu-footnote {
    padding-left: 12px;
    padding-right: 38px;
}

.account-usage-card {
    display: grid;
    gap: 14px;
    padding: 16px;
    border-radius: 18px;
    background:
        radial-gradient(circle at top right, rgba(255,133,82,0.14), transparent 44%),
        linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.015)),
        var(--bg-sidebar-hover);
    border: 1px solid rgba(255,255,255,0.08);
}

.account-usage-card-head,
.account-usage-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.account-usage-kicker {
    margin: 0;
    font-size: 11px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.account-usage-card-head h3 {
    margin: 4px 0 0;
    font-size: 20px;
}

.settings-menu-inline-link {
    color: var(--accent);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
}

.account-usage-body {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 16px;
    align-items: center;
}

.account-usage-ring-wrap {
    position: relative;
    width: 120px;
    height: 120px;
}

.account-usage-ring {
    width: 120px;
    height: 120px;
    transform: rotate(-90deg);
}

.account-usage-ring-track,
.account-usage-ring-progress {
    fill: none;
    stroke-width: 10;
}

.account-usage-ring-track {
    stroke: rgba(255,255,255,0.08);
}

.account-usage-ring-progress {
    stroke: url(#homeQuotaGradient);
    stroke-linecap: round;
    stroke-dasharray: 263.89;
    stroke-dashoffset: 263.89;
    transition: stroke-dashoffset 260ms ease;
}

.account-usage-center {
    position: absolute;
    inset: 0;
    display: grid;
    place-content: center;
    gap: 4px;
    text-align: center;
}

.account-usage-center strong {
    font-size: 20px;
    letter-spacing: -0.03em;
}

.account-usage-center span {
    font-size: 12px;
    color: var(--text-muted);
}

.account-usage-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.account-usage-stats div {
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.05);
}

.account-usage-stats span {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

.account-usage-stats strong {
    font-size: 14px;
}

.message-meta {
    margin-top: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.message-meta-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(255,255,255,0.06);
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1;
}

.message-meta-chip strong {
    color: var(--text-main);
    font-weight: 700;
}

@media (max-width: 760px) {
    .account-usage-body {
        grid-template-columns: 1fr;
    }

    .account-usage-ring-wrap {
        margin: 0 auto;
    }
}
