/* ===================================================
   THEME SYSTEM — CSS CUSTOM PROPERTIES
   The default (:root) is identical to [data-theme="dark"]
   so the app starts in a proper dark mode.
   All themes override the same set of vars.
   =================================================== */

:root,
[data-theme="dark"] {
    --font-sans: 'Manrope', 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', Consolas, monospace;

    /* Workspace (right) */
    --bg-page: #101317;
    --bg-topbar: rgba(16, 20, 27, 0.82);
    --bg-message-user: #202733;
    --bg-message-assistant: #171c25;
    --bg-code: #0d1118;
    --bg-composer: rgba(12, 16, 23, 0.9);
    --bg-composer-shell: linear-gradient(180deg, #1b212d, #181f2a);
    --bg-empty-state: linear-gradient(145deg, #131a24, #171e2b);

    /* Sidebar (left) */
    --bg-sidebar: linear-gradient(180deg, #141a24, #11161f);
    --bg-sidebar-hover: #1b2331;
    --bg-sidebar-active: #1d2e4b;
    --sidebar-border: #2a3444;
    --sidebar-primary-bg: #1d2c43;
    --sidebar-primary-border: #3c4b63;
    --sidebar-primary-color: #dfe9ff;

    /* Shared */
    --border: #2a3444;
    --border-soft: #334055;
    --text-main: #e6ebf5;
    --text-muted: #8f9ab0;
    --text-subtle: #b6bfd1;
    --accent: #4c8dff;
    --accent-soft: #2f63bf;
    --danger: #e1645d;
    --success: #2abf84;
    --shadow: 0 14px 40px rgba(0, 0, 0, 0.35);

    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 24px;

    color-scheme: dark;
}

/* --------------- LIGHT --------------- */
[data-theme="light"] {
    --bg-page: #f0f2f5;
    --bg-topbar: rgba(245, 247, 250, 0.88);
    --bg-message-user: #e8ecf2;
    --bg-message-assistant: #ffffff;
    --bg-code: #f6f8fa;
    --bg-composer: rgba(240, 242, 245, 0.92);
    --bg-composer-shell: linear-gradient(180deg, #ffffff, #fafbfd);
    --bg-empty-state: linear-gradient(145deg, #ffffff, #f5f7fa);

    --bg-sidebar: linear-gradient(180deg, #e8ecf2, #dfe4ec);
    --bg-sidebar-hover: #d5dbe5;
    --bg-sidebar-active: #c8d3e5;
    --sidebar-border: #c8cdd8;
    --sidebar-primary-bg: #dce4f0;
    --sidebar-primary-border: #b8c4d8;
    --sidebar-primary-color: #2c3e5c;

    --border: #d0d5de;
    --border-soft: #bcc3d0;
    --text-main: #1a2233;
    --text-muted: #64748b;
    --text-subtle: #475569;
    --accent: #3b7cf5;
    --accent-soft: #2960c9;
    --shadow: 0 14px 40px rgba(0, 0, 0, 0.08);

    color-scheme: light;
}

/* --------------- ROSE (#f6dde6) --------------- */
[data-theme="rose"] {
    --bg-page: #f6dde6;
    --bg-topbar: rgba(246, 221, 230, 0.88);
    --bg-message-user: #eed0da;
    --bg-message-assistant: #fdf0f4;
    --bg-code: #f9e4ec;
    --bg-composer: rgba(246, 221, 230, 0.92);
    --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;
}

/* --------------- CHARCOAL (#212121) --------------- */
[data-theme="charcoal"] {
    --bg-page: #212121;
    --bg-topbar: rgba(33, 33, 33, 0.88);
    --bg-message-user: #2e2e2e;
    --bg-message-assistant: #292929;
    --bg-code: #1a1a1a;
    --bg-composer: rgba(28, 28, 28, 0.92);
    --bg-composer-shell: linear-gradient(180deg, #303030, #282828);
    --bg-empty-state: linear-gradient(145deg, #2a2a2a, #242424);

    --bg-sidebar: linear-gradient(180deg, #181818, #111111);
    --bg-sidebar-hover: #2a2a2a;
    --bg-sidebar-active: #353535;
    --sidebar-border: #3a3a3a;
    --sidebar-primary-bg: #333333;
    --sidebar-primary-border: #4a4a4a;
    --sidebar-primary-color: #e0e0e0;

    --border: #3a3a3a;
    --border-soft: #484848;
    --text-main: #e8e8e8;
    --text-muted: #999999;
    --text-subtle: #bbbbbb;
    --accent: #6ea8fe;
    --accent-soft: #4d85d6;
    --shadow: 0 14px 40px rgba(0, 0, 0, 0.45);

    color-scheme: dark;
}

/* --------------- DRACULA (#282a36) --------------- */
[data-theme="dracula"] {
    --bg-page: #282a36;
    --bg-topbar: rgba(40, 42, 54, 0.88);
    --bg-message-user: #343746;
    --bg-message-assistant: #2e3040;
    --bg-code: #21222c;
    --bg-composer: rgba(35, 37, 48, 0.92);
    --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;
}

/* --------------- CREAM (#f3eedc) --------------- */
[data-theme="cream"] {
    --bg-page: #f3eedc;
    --bg-topbar: rgba(243, 238, 220, 0.88);
    --bg-message-user: #e8e2cc;
    --bg-message-assistant: #faf7ee;
    --bg-code: #ece7d6;
    --bg-composer: rgba(243, 238, 220, 0.92);
    --bg-composer-shell: linear-gradient(180deg, #faf7ee, #f0ebd8);
    --bg-empty-state: linear-gradient(145deg, #faf7ee, #f0ead5);

    --bg-sidebar: linear-gradient(180deg, #c8b98a, #b5a576);
    --bg-sidebar-hover: #d6c99a;
    --bg-sidebar-active: #c4b785;
    --sidebar-border: #c2b48c;
    --sidebar-primary-bg: #d8cb9c;
    --sidebar-primary-border: #b0a272;
    --sidebar-primary-color: #3d3518;

    --border: #d4ccb0;
    --border-soft: #bfb793;
    --text-main: #33280f;
    --text-muted: #8a7b56;
    --text-subtle: #6e6040;
    --accent: #b38728;
    --accent-soft: #946e1c;
    --shadow: 0 14px 40px rgba(50, 30, 0, 0.12);

    color-scheme: light;
}

/* --------------- TEAL (#0d3640) --------------- */
[data-theme="teal"] {
    --bg-page: #0d3640;
    --bg-topbar: rgba(13, 54, 64, 0.88);
    --bg-message-user: #15444f;
    --bg-message-assistant: #0f3c48;
    --bg-code: #092a32;
    --bg-composer: rgba(10, 44, 52, 0.92);
    --bg-composer-shell: linear-gradient(180deg, #184c58, #10404c);
    --bg-empty-state: linear-gradient(145deg, #124450, #0e3840);

    --bg-sidebar: linear-gradient(180deg, #072228, #04181e);
    --bg-sidebar-hover: #164450;
    --bg-sidebar-active: #1e5463;
    --sidebar-border: #1a4855;
    --sidebar-primary-bg: #1d5060;
    --sidebar-primary-border: #2a7588;
    --sidebar-primary-color: #d8f5fc;

    --border: #1e5060;
    --border-soft: #286878;
    --text-main: #d8f0f5;
    --text-muted: #78b0c0;
    --text-subtle: #a0d0dd;
    --accent: #38d9b0;
    --accent-soft: #28a888;
    --shadow: 0 14px 40px rgba(0, 20, 30, 0.45);

    color-scheme: dark;
}

/* ===========================
   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;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

a {
    color: inherit;
    text-decoration: none;
}

#root,
.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: 280px 1fr;
}

/* ===========================
   SIDEBAR
   =========================== */

.sidebar {
    border-right: 1px solid var(--sidebar-border);
    background: var(--bg-sidebar);
    padding: 12px;
    display: flex;
    flex-direction: column;
    min-height: 0;
    transition: background 250ms ease;
}

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

#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 — expands within 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="light"] .settings-flyout,
[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 {
    flex: 0 0 auto;
    padding: 12px 0 4px;
    border-top: 1px solid var(--sidebar-border);
    margin-top: 8px;
}


.theme-picker {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.theme-picker-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

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

/* Auto theme swatch — half light / half dark */
.swatch-half-light {
    background: #f0f2f5;
    border-radius: 24px 0 0 24px;
}

.swatch-half-dark {
    background: #181c24;
    border-radius: 0 24px 24px 0;
}

/* ===========================
   WORKSPACE
   =========================== */

.workspace {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    height: 100%;
    transition: background 250ms ease;
}

.workspace .topbar {
    flex: 0 0 auto;
}

.workspace .message-scroller {
    flex: 1 1 auto;
    min-height: 0;
}

.workspace .composer-wrap {
    flex: 0 0 auto;
}

/* ===========================
   TRUE CENTERED STATE
   =========================== */

.workspace.is-empty .message-scroller {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.workspace.is-empty #message-list {
    display: none;
}

.centered-container {
    width: min(720px, 100%);
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.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;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    background: var(--bg-topbar);
    backdrop-filter: blur(10px);
}

.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: 200px;
    border: 1px solid var(--border-soft);
    background: var(--bg-code);
    border-radius: 999px;
    padding: 7px 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.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-y: auto;
    padding: 18px;
    min-height: 0;
}

#message-list {
    width: min(900px, 100%);
    margin: 0 auto;
    display: grid;
    gap: 14px;
}

/* ===========================
   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;
    margin-bottom: 10px;
}

.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;
    gap: 6px;
}

.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-content {
    color: var(--text-main);
    line-height: 1.7;
    font-size: 15px;
    overflow-wrap: break-word;
}

.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 first message)
   =========================== */

.composer-wrap {
    border-top: 1px solid var(--border);
    padding: 14px 16px 16px;
    background: var(--bg-composer);
    backdrop-filter: blur(10px);
    transition: background 250ms ease;
}

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

/* 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;
}

.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: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) {
    .sidebar {
        width: 260px;
    }

    .topbar {
        height: 50px;
        padding: 0 10px;
    }

    .message-scroller {
        padding: 10px;
    }

    .empty-state h2 {
        font-size: 24px;
    }

    .centered-textarea {
        font-size: 18px;
        min-height: 44px;
    }

    .centered-container {
        padding: 0 12px;
    }

    .user-pill {
        max-width: 100px;
        font-size: 12px;
        padding: 5px 8px;
    }

    .composer-wrap {
        padding: 8px;
    }

    .composer-shell {
        padding: 10px;
        border-radius: 20px;
    }

    #message-input {
        font-size: 15px;
        min-height: 38px;
    }

    .model-picker-label {
        max-width: 100px;
        font-size: 13px;
    }

    .model-picker-btn {
        height: 34px;
        gap: 4px;
        padding: 0 8px;
    }

    .icon-control {
        width: 34px;
        height: 34px;
    }

    .send-btn-circle {
        width: 36px;
        height: 36px;
    }

    .footnote {
        font-size: 10px;
    }

    .message {
        padding: 10px;
    }

    .context-menu {
        min-width: 160px;
    }

    .theme-swatch {
        width: 22px;
        height: 22px;
    }

    .share-icon-btn {
        width: 32px;
        height: 32px;
        border-radius: 8px;
    }

    .share-icons {
        gap: 5px;
    }

    .share-picker {
        padding-bottom: 10px;
        margin-bottom: 10px;
    }
}

/* ===========================
   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;
}

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