/* ======================================================================
   PIXEL AI 2.0 — COMPLETE APPLICATION STYLESHEET
   Identity: Premium, Minimal, Dark (#0A0A0A), Gold Accent (#D4AF37)
   ====================================================================== */

:root {
    /* -- Brand Palette -- */
    --bg: #0A0A0A;
    --surface: #111215;
    --surface-raised: #17181C;
    --surface-hover: #212328;
    --surface-active: #292B32;
    --gold: #D4AF37;
    --gold-light: #F3E5AB;
    --gold-glow: rgba(212, 175, 55, 0.25);
    --gold-subtle: rgba(212, 175, 55, 0.12);

    /* -- Text Colors -- */
    --text: #F5F5F7;
    --text-secondary: #A1A1A6;
    --text-muted: #6E6E73;
    --text-inverse: #0A0A0A;

    /* -- Borders -- */
    --border: rgba(255, 255, 255, 0.08);
    --border-gold: rgba(212, 175, 55, 0.28);
    --border-gold-strong: rgba(212, 175, 55, 0.65);

    /* -- Functional Colors -- */
    --danger: #FF5252;
    --danger-subtle: rgba(255, 82, 82, 0.12);
    --success: #46D160;
    --success-subtle: rgba(70, 209, 96, 0.12);

    /* -- Layout & Sizing -- */
    --sidebar-width: 270px;
    --topbar-height: 56px;
    --content-width: 920px;
    --app-viewport-height: 100vh;
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 9999px;

    /* -- Transitions & Shadows -- */
    --ease: 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.65);
    --shadow-gold: 0 0 20px rgba(212, 175, 55, 0.25);

    /* -- Z-Indices -- */
    --z-base: 1;
    --z-topbar: 40;
    --z-composer: 50;
    --z-dropdown: 90;
    --z-overlay: 100;
    --z-sidebar: 110;
    --z-modal: 200;
}

body.auth-pending .app {
    visibility: hidden;
}

@supports (height: 100dvh) {
    :root {
        --app-viewport-height: 100dvh;
    }
}

/* Light Mode Comprehensive Theme */
body.light-mode {
    --bg: #F8F9FA;
    --surface: #FFFFFF;
    --surface-raised: #F1F3F5;
    --surface-hover: #E9ECEF;
    --surface-active: #DEE2E6;
    --gold: #B8860B;
    --gold-light: #9B7008;
    --gold-glow: rgba(184, 134, 11, 0.18);
    --gold-subtle: rgba(184, 134, 11, 0.08);
    --text: #18191C;
    --text-secondary: #4A4D55;
    --text-muted: #747882;
    --text-inverse: #FFFFFF;
    --border: rgba(0, 0, 0, 0.08);
    --border-gold: rgba(184, 134, 11, 0.35);
    --border-gold-strong: rgba(184, 134, 11, 0.65);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.10);
    --shadow-gold: 0 0 20px rgba(184, 134, 11, 0.18);
}

/* Light Mode: Canvas & Structure */
body.light-mode {
    background-color: var(--bg);
    color: var(--text);
}

/* Light Mode: Sidebar */
body.light-mode .sidebar {
    background: #FFFFFF;
    border-right: 1px solid rgba(0, 0, 0, 0.08);
}

body.light-mode .sidebar-header {
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

body.light-mode .sidebar-search-box {
    background: #F1F3F5;
    border: 1px solid rgba(0, 0, 0, 0.08);
    color: #18191C;
}

body.light-mode .sidebar-search-box input {
    color: #18191C;
}

body.light-mode .sidebar-search-box input::placeholder {
    color: #868E96;
}

body.light-mode .sidebar-actions .new-chat-btn {
    background: #F1F3F5;
    color: #18191C;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

body.light-mode .sidebar-actions .new-chat-btn:hover {
    background: #E9ECEF;
    color: var(--gold);
    border-color: var(--border-gold);
}

body.light-mode .conversation-item {
    color: #4A4D55;
}

body.light-mode .conversation-item:hover {
    background: #F1F3F5;
    color: #18191C;
}

body.light-mode .conversation-item.active {
    background: rgba(184, 134, 11, 0.12);
    color: #B8860B;
    border: 1px solid rgba(184, 134, 11, 0.25);
    font-weight: 600;
}

body.light-mode .history-title {
    color: #868E96;
}

body.light-mode .sidebar-footer {
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    background: #FFFFFF;
}

body.light-mode .sidebar-footer-btn {
    color: #4A4D55;
}

body.light-mode .sidebar-footer-btn:hover {
    background: #F1F3F5;
    color: #18191C;
}

body.light-mode .profile-card {
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

body.light-mode .profile-button:hover {
    background: #F1F3F5;
}

body.light-mode .profile-avatar {
    background: rgba(184, 134, 11, 0.15);
    color: #B8860B;
}

body.light-mode .sidebar-more-menu {
    background: #FFFFFF;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

body.light-mode .sidebar-more-item {
    color: #4A4D55;
}

body.light-mode .sidebar-more-item:hover {
    background: #F1F3F5;
    color: #18191C;
}

/* Light Mode: Topbar & Navigation */
body.light-mode .topbar {
    background: rgba(255, 255, 255, 0.88);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

body.light-mode .topbar-btn {
    color: #4A4D55;
}

body.light-mode .topbar-btn:hover {
    background: #F1F3F5;
    color: #B8860B;
}

body.light-mode .top-model-pill {
    background: #F1F3F5;
    border: 1px solid rgba(0, 0, 0, 0.08);
    color: #18191C;
}

body.light-mode .top-model-pill:hover {
    background: #E9ECEF;
}

body.light-mode .current-chat-title {
    color: #18191C;
}

/* Light Mode: Chat & Messages */
body.light-mode .welcome-title {
    background: linear-gradient(135deg, #18191C 60%, #B8860B 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

body.light-mode .welcome-desc {
    color: #4A4D55;
}

body.light-mode .prompt-suggestion {
    background: #FFFFFF;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
    color: #18191C;
}

body.light-mode .prompt-suggestion:hover {
    background: #F8F9FA;
    border-color: var(--border-gold);
    transform: translateY(-2px);
}

body.light-mode .prompt-suggestion-icon {
    background: rgba(184, 134, 11, 0.1);
    color: #B8860B;
}

body.light-mode .message.ai .message-content {
    color: #18191C;
}

body.light-mode .message.ai .message-content p,
body.light-mode .message.ai .message-content li {
    color: #18191C;
}

body.light-mode .message.ai .message-content strong,
body.light-mode .message.ai .message-content h1,
body.light-mode .message.ai .message-content h2,
body.light-mode .message.ai .message-content h3,
body.light-mode .message.ai .message-content h4 {
    color: #0A0A0A;
}

body.light-mode .message.ai .message-content code:not(pre code) {
    background: #F1F3F5;
    color: #B8860B;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

body.light-mode .message.ai .message-content blockquote {
    border-left-color: #B8860B;
    background: rgba(184, 134, 11, 0.06);
    color: #4A4D55;
}

body.light-mode .message.ai .message-content table th {
    background: #F1F3F5;
    color: #18191C;
    border-color: rgba(0, 0, 0, 0.08);
}

body.light-mode .message.ai .message-content table td {
    border-color: rgba(0, 0, 0, 0.08);
    color: #18191C;
}

body.light-mode .message.user .bubble {
    background: #E9ECEF;
    border-color: rgba(0, 0, 0, 0.06);
    color: #18191C;
}

body.light-mode .message-action {
    color: #747882;
    border-color: rgba(0, 0, 0, 0.08);
    background: #FFFFFF;
}

body.light-mode .message-action:hover {
    background: #F1F3F5;
    color: #18191C;
    border-color: rgba(0, 0, 0, 0.15);
}

body.light-mode .user-action-btn {
    color: #747882;
}

body.light-mode .user-action-btn:hover {
    background: #DEE2E6;
    color: #18191C;
}

/* Light Mode: Composer */
body.light-mode .composer-box {
    background: #FFFFFF;
    border: 1px solid rgba(0, 0, 0, 0.12);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.06), 0 0 0 1px rgba(0, 0, 0, 0.04);
}

body.light-mode .composer-box:focus-within {
    border-color: rgba(184, 134, 11, 0.45);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08), 0 0 16px rgba(184, 134, 11, 0.12);
}

body.light-mode #promptInput {
    color: #18191C;
}

body.light-mode #promptInput::placeholder {
    color: #868E96;
}

body.light-mode .composer-btn {
    color: #4A4D55;
}

body.light-mode .composer-btn:hover {
    background: #F1F3F5;
    color: #18191C;
}

body.light-mode .model-button {
    background: #F1F3F5;
    border: 1px solid rgba(0, 0, 0, 0.08);
    color: #18191C;
}

body.light-mode .model-menu {
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.12);
    border-color: rgba(0, 0, 0, 0.1);
    color: #18191C;
}

/* Light Mode: Settings Dialog */
body.light-mode .settings-dialog {
    background: #FFFFFF;
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.15);
    color: #18191C;
}

body.light-mode .settings-dialog::backdrop {
    background: rgba(0, 0, 0, 0.4);
}

body.light-mode .dialog-header {
    background: #FFFFFF;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    color: #18191C;
}

body.light-mode .settings-nav {
    background: #F8F9FA;
    border-right: 1px solid rgba(0, 0, 0, 0.08);
}

body.light-mode .settings-tab {
    color: #4A4D55;
}

body.light-mode .settings-tab:hover {
    background: #E9ECEF;
    color: #18191C;
}

body.light-mode .settings-tab.active {
    background: #FFFFFF;
    color: #B8860B;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    font-weight: 600;
}

body.light-mode .settings-tab.active i {
    color: #B8860B;
}

body.light-mode .settings-section-header h3 {
    color: #18191C;
}

body.light-mode .settings-intro {
    color: #747882;
}

body.light-mode .settings-group-title {
    color: #868E96;
}

body.light-mode .setting-row {
    background: #FFFFFF;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

body.light-mode .setting-row:hover {
    background: #F8F9FA;
    border-color: rgba(0, 0, 0, 0.15);
}

body.light-mode .setting-row-select {
    background: #FFFFFF;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

body.light-mode .setting-icon-wrap {
    background: #F1F3F5;
    color: #4A4D55;
}

body.light-mode .setting-row:hover .setting-icon-wrap {
    background: rgba(184, 134, 11, 0.1);
    color: #B8860B;
}

body.light-mode .setting-info strong {
    color: #18191C;
}

body.light-mode .setting-info small {
    color: #747882;
}

body.light-mode .setting-row input[type="checkbox"] {
    background: rgba(0, 0, 0, 0.15);
}

body.light-mode .setting-row input[type="checkbox"]:checked {
    background: #B8860B;
}

body.light-mode .settings-select-inline,
body.light-mode .settings-input {
    background: #F1F3F5;
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: #18191C;
}

body.light-mode .shortcut-keys kbd {
    background: #E9ECEF;
    border-color: rgba(0, 0, 0, 0.1);
    color: #495057;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Light Mode: Code Blocks */
body.light-mode .code-block {
    background: #282C34;
    border-color: rgba(0, 0, 0, 0.12);
}

body.light-mode .code-header {
    background: #21252B;
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

body.light-mode .chat-context-menu {
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

/* ======================================================================
   BASE & RESET
   ====================================================================== */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Startup-only brand reveal */
.pixel-loader {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: grid;
    place-items: center;
    background: #0A0A0A;
    opacity: 1;
    visibility: visible;
    transition: opacity 420ms ease, visibility 420ms ease;
}
.pixel-loader--leaving {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.pixel-loader__content {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: min(280px, calc(100vw - 48px));
    transform: translateY(0);
}
.pixel-loader__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #F5F5F7;
    font-size: 25px;
    font-weight: 600;
    line-height: 1;
    opacity: 0;
    animation: pixel-loader-enter 680ms cubic-bezier(0.2, 0.7, 0.25, 1) 40ms forwards;
}
.pixel-loader__brand img {
    display: block;
    width: 38px;
    height: 38px;
    object-fit: contain;
}
.pixel-loader__line {
    position: relative;
    width: 88px;
    height: 1px;
    margin-top: 24px;
    overflow: hidden;
    background: rgba(212, 175, 55, 0.22);
    opacity: 0;
    animation: pixel-loader-line-in 420ms ease 180ms forwards;
}
.pixel-loader__line span {
    position: absolute;
    top: 0;
    left: 0;
    width: 8px;
    height: 1px;
    background: #D4AF37;
    animation: pixel-loader-travel 1.8s ease-in-out 220ms infinite;
}
.pixel-loader__status {
    margin-top: 14px;
    color: #85858B;
    font-size: 12px;
    font-weight: 400;
    opacity: 0;
    animation: pixel-loader-status-in 420ms ease 250ms forwards;
}
@keyframes pixel-loader-enter {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes pixel-loader-status-in {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes pixel-loader-line-in {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes pixel-loader-travel {
    0% { transform: translateX(0); opacity: 0.55; }
    50% { opacity: 1; }
    100% { transform: translateX(80px); opacity: 0.55; }
}
@media (prefers-reduced-motion: reduce) {
    .pixel-loader,
    .pixel-loader__brand,
    .pixel-loader__line,
    .pixel-loader__status {
        animation: none;
        transition: none;
        opacity: 1;
        transform: none;
    }
    .pixel-loader__line span {
        animation: none;
        left: calc(50% - 4px);
        opacity: 1;
    }
}

/* Subtle background grain texture */
body:not(.texture-disabled)::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image: url("../assets/texture.png");
    background-repeat: repeat;
    background-size: 180px;
    opacity: 0.035;
    pointer-events: none;
    z-index: 0;
}

/* Interactive subtle mouse glow */
.cursor-glow {
    position: fixed;
    width: 450px;
    height: 450px;
    margin-left: -225px;
    margin-top: -225px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(212, 175, 55, 0.04) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
    transition: transform 0.08s ease-out;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(212, 175, 55, 0.35);
}

/* Button & Input Resets */
button, input, textarea, select {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    border: none;
    outline: none;
    background: none;
}
button {
    cursor: pointer;
}

/* ======================================================================
   APPLICATION SHELL
   ====================================================================== */

.app {
    display: flex;
    width: 100%;
    height: var(--app-viewport-height, 100vh);
    position: relative;
    overflow: hidden;
    z-index: var(--z-base);
}

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

.sidebar {
    width: var(--sidebar-width);
    height: var(--app-viewport-height, 100vh);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    bottom: auto;
    left: 0;
    z-index: var(--z-sidebar);
    transform: translateX(-100%);
    transition: transform var(--ease);
}

.sidebar.expanded {
    transform: translateX(0);
}

.sidebar-header {
    height: var(--topbar-height);
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    cursor: pointer;
    text-decoration: none;
}
.sidebar-brand:focus-visible {
    outline: 2px solid var(--gold-bright, #f4e3a2);
    outline-offset: 5px;
    border-radius: 5px;
}

.sidebar-logo {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.sidebar-title-group {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.sidebar-title {
    font-weight: 700;
    font-size: 17px;
    letter-spacing: -0.02em;
    color: var(--text);
}

.sidebar-version {
    font-size: 10px;
    font-weight: 600;
    color: var(--gold);
    background: var(--gold-subtle);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid rgba(212, 175, 55, 0.2);
}

.sidebar-close-btn {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: background var(--ease), color var(--ease);
}
.sidebar-close-btn:hover {
    background: var(--surface-hover);
    color: var(--gold);
}

/* New Chat Button */
.new-chat-btn {
    margin: 14px 14px 10px;
    padding: 11px 14px;
    background: var(--surface-raised);
    border: 1px solid var(--border-gold);
    border-radius: var(--radius-md);
    color: var(--gold-light);
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all var(--ease);
}
.new-chat-btn:hover {
    background: var(--gold-subtle);
    border-color: var(--gold);
    color: #FFFFFF;
    box-shadow: 0 4px 16px rgba(212, 175, 55, 0.15);
    transform: translateY(-1px);
}
.new-chat-btn i {
    color: var(--gold);
    font-size: 13px;
}
.shortcut-key {
    margin-left: auto;
    font-size: 11px;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 5px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Sidebar Action Buttons Container (Creator on top, New Chat below) */
.sidebar-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 14px 8px;
}
.sidebar-actions .new-chat-btn {
    width: 100%;
    margin: 0;
    padding: 10px 14px;
    background: var(--surface-raised);
    border: 1px solid var(--border-gold);
    border-radius: var(--radius-md);
    color: var(--gold-light);
    font-size: 13.5px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: all var(--ease);
}
.sidebar-actions .new-chat-btn:hover {
    background: var(--gold-subtle);
    border-color: var(--gold);
    color: #FFFFFF;
    box-shadow: 0 4px 16px rgba(212, 175, 55, 0.15);
    transform: translateY(-1px);
}
.sidebar-actions .new-chat-btn i {
    color: var(--gold);
    font-size: 13px;
    width: 16px;
    text-align: center;
}
.sidebar-actions .creator-btn {
    background: var(--surface-raised);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}
.sidebar-actions .creator-btn:hover {
    background: var(--surface-hover);
    border-color: var(--border-gold);
    color: var(--gold-light);
    box-shadow: 0 4px 16px rgba(212, 175, 55, 0.1);
}
.sidebar-actions .creator-btn i {
    color: var(--gold);
}
.sidebar-actions .shortcut-key {
    margin-left: auto;
    font-size: 11px;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Rich Media Video Embeds */
.media-video-container {
    margin: 14px 0;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    max-width: 640px;
}
.media-video-frame {
    width: 100%;
    aspect-ratio: 16 / 9;
    display: block;
    border: none;
}
.media-video-meta {
    padding: 8px 12px;
    background: var(--surface);
    border-top: 1px solid var(--border);
}
.media-video-link {
    font-size: 13px;
    color: var(--gold-light);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}
.media-video-link:hover {
    color: #ffffff;
    text-decoration: underline;
}
.media-video-link i {
    color: #ff0000;
}

/* Sidebar Search Box */
.sidebar-search {
    padding: 0 14px 10px;
}
.sidebar-search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 7px 10px;
    transition: border-color var(--ease);
}
.sidebar-search-box:focus-within {
    border-color: var(--border-gold);
}
.sidebar-search-box i {
    font-size: 12px;
    color: var(--text-muted);
}
.sidebar-search-box input {
    width: 100%;
    font-size: 13px;
    color: var(--text);
}
.sidebar-search-box input::placeholder {
    color: var(--text-muted);
}

/* History Groupings */
.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 6px 10px;
}

.history-group {
    margin-bottom: 16px;
}

.history-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    padding: 6px 10px;
}

.conversation-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.conversation-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13.5px;
    cursor: pointer;
    transition: all var(--ease);
    position: relative;
}

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

.conversation-item.active {
    background: var(--surface-raised);
    color: var(--gold-light);
    border: 1px solid var(--border-gold);
    font-weight: 500;
}

.conversation-item.pinned .item-icon {
    color: var(--gold);
}

.item-icon {
    font-size: 13px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.chat-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pin-badge {
    font-size: 11px;
    color: var(--gold);
    margin-right: 4px;
}

.item-menu-btn {
    opacity: 0;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: opacity var(--ease), background var(--ease), color var(--ease);
}

.conversation-item:hover .item-menu-btn,
.conversation-item.active .item-menu-btn {
    opacity: 1;
}

.item-menu-btn:hover {
    background: var(--surface-active);
    color: var(--text);
}

/* Sidebar Footer / Profile */
.sidebar-footer {
    padding: 12px 14px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--surface);
}

.sidebar-footer-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    transition: all var(--ease);
}
.sidebar-footer > .sidebar-footer-btn[hidden] { display: none !important; }
.sidebar-footer-btn:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.sidebar-more-toggle {
    width: 100%;
    border: 0;
    background: transparent;
    text-align: left;
    cursor: pointer;
}

.sidebar-more-toggle:focus-visible,
.sidebar-more-item:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}

.sidebar-more-chevron {
    width: 12px;
    color: var(--text-muted);
    text-align: center;
    transition: transform var(--ease), color var(--ease);
}

.sidebar-more-section.is-open .sidebar-more-chevron {
    transform: rotate(90deg);
    color: var(--gold);
}

.sidebar-more-menu {
    display: grid;
    grid-template-rows: 0fr;
    margin-top: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
    transition: grid-template-rows var(--ease), margin-top var(--ease), opacity var(--ease);
}

.sidebar-more-section.is-open .sidebar-more-menu {
    grid-template-rows: 1fr;
    margin-top: 3px;
    opacity: 1;
    pointer-events: auto;
}

.sidebar-more-menu-inner {
    display: flex;
    min-height: 0;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}

.sidebar-more-item {
    display: flex;
    width: 100%;
    min-height: 32px;
    align-items: center;
    gap: 9px;
    padding: 6px 9px 6px 31px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    text-align: left;
    transition: background var(--ease), color var(--ease), opacity var(--ease);
}

.sidebar-more-item i {
    width: 14px;
    color: var(--text-muted);
    text-align: center;
}

.sidebar-more-item:not(:disabled) {
    cursor: pointer;
}

.sidebar-more-item:not(:disabled):hover {
    background: var(--surface-hover);
    color: var(--text);
}

.sidebar-more-item:not(:disabled):hover i {
    color: var(--gold);
}

.sidebar-more-item:disabled {
    cursor: not-allowed;
    opacity: .68;
}

.sidebar-more-item small {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 9px;
    white-space: nowrap;
}

.profile-card {
    border-top: 1px solid var(--border);
    padding-top: 8px;
}

.profile-button {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: var(--radius-md);
    background: var(--surface-raised);
    border: 1px solid var(--border);
    text-align: left;
    transition: all var(--ease);
}
.profile-button:hover {
    border-color: var(--border-gold);
    background: var(--surface-hover);
}

.profile-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--gold-subtle);
    border: 1px solid var(--border-gold);
    color: var(--gold);
    font-weight: 700;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.profile-details {
    flex: 1;
    overflow: hidden;
    line-height: 1.25;
}
.profile-details strong {
    display: block;
    font-size: 13px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.profile-details small {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-menu-icon {
    font-size: 12px;
    color: var(--text-muted);
    margin-right: 4px;
}

/* ======================================================================
   MAIN WORKSPACE & TOP NAVIGATION
   ====================================================================== */

.main {
    flex: 1;
    height: 100%;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    background: transparent;
}

.topbar {
    height: var(--topbar-height);
    padding: 0 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    background: rgba(10, 10, 10, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    z-index: var(--z-topbar);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    border: 1px solid transparent;
    transition: all var(--ease);
}
.topbar-btn:hover {
    background: var(--surface-raised);
    color: var(--gold);
    border-color: var(--border-gold);
}

.current-chat-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    background: transparent;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    max-width: 280px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all var(--ease);
}
.current-chat-title:hover {
    background: var(--surface-raised);
    color: var(--gold-light);
}

.topbar-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.top-model-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: var(--surface-raised);
    border: 1px solid var(--border-gold);
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 500;
    color: var(--gold-light);
    cursor: pointer;
    transition: all var(--ease);
}
.top-model-pill:hover {
    background: var(--surface-hover);
    border-color: var(--gold);
    box-shadow: 0 0 12px var(--gold-glow);
}

.pill-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--gold);
    box-shadow: 0 0 8px var(--gold);
}

.pill-chevron {
    font-size: 10px;
    color: var(--text-muted);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ======================================================================
   CHAT CONVERSATION CONTAINER
   ====================================================================== */

.chat-container {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    position: relative;
    padding: 24px 20px 160px;
    scroll-behavior: smooth;
    scrollbar-gutter: stable;
}
.chat-container::-webkit-scrollbar { width: 8px; }
.chat-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border: 2px solid transparent;
    border-radius: 8px;
    background-clip: padding-box;
}
.chat-container::-webkit-scrollbar-thumb:hover { background-color: rgba(212, 175, 55, 0.45); }

.chat-area {
    width: 100%;
    max-width: var(--content-width);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

/* ======================================================================
   EMPTY STATE (WELCOME SCREEN)
   ====================================================================== */

.welcome {
    width: 100%;
    max-width: 760px;
    min-height: 100%;
    margin: 0 auto;
    padding: 24px 0 150px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity var(--ease), transform var(--ease);
}

.welcome.hide {
    display: none;
}

.welcome-emblem {
    position: relative;
    width: 54px;
    height: 54px;
    margin-bottom: 18px;
}

.emblem-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    position: relative;
    z-index: 2;
}

.welcome-title {
    font-size: 34px;
    font-weight: 700;
    letter-spacing: 0;
    line-height: 1.15;
    color: var(--text);
    margin-bottom: 10px;
    background: linear-gradient(135deg, #FFFFFF 60%, var(--gold-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.welcome-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 28px;
}

/* Starter Prompt Cards Grid */
.starter-cards-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    width: 100%;
}

.starter-card {
    width: 100%;
    min-height: 94px;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    text-align: left;
    cursor: pointer;
    transition: background var(--ease), border-color var(--ease), transform var(--ease);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.starter-card:hover {
    background: var(--surface-hover);
    border-color: var(--border-gold);
    transform: translateY(-1px);
}
.starter-card:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 3px;
}

.starter-card-top {
    display: flex;
    align-items: center;
    gap: 10px;
}

.starter-card-top strong {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.starter-icon {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    background: var(--gold-subtle);
    color: var(--gold);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
}

.starter-text {
    font-size: 12.5px;
    color: var(--text-muted);
    line-height: 1.4;
}

/* ======================================================================
   CHAT MESSAGES
   ====================================================================== */

.message {
    display: flex;
    width: 100%;
    align-items: flex-start;
    animation: messageIn 0.25s var(--ease);
}

@keyframes messageIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* User Message */
.message.user {
    justify-content: flex-end;
}

.user-message-body {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    max-width: min(720px, 82%);
    gap: 4px;
}

.message.user .bubble {
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.09);
    color: #F0F0F2;
    padding: 12px 16px;
    border-radius: 16px 16px 5px 16px;
    font-size: 15px;
    line-height: 1.55;
    box-shadow: var(--shadow-sm);
    word-break: break-word;
}

.message.user:hover .bubble {
    border-color: rgba(212, 175, 55, 0.25);
}

.user-text {
    white-space: normal;
    overflow-wrap: anywhere;
}

.user-text > :first-child { margin-top: 0; }
.user-text > :last-child { margin-bottom: 0; }
.user-text p { margin: 0 0 0.7em; }
.user-text ul,
.user-text ol { margin: 0.5em 0 0.7em; padding-left: 1.35em; }
.user-text blockquote { margin: 0.7em 0; padding-left: 0.8em; border-left: 2px solid rgba(212, 175, 55, 0.5); }
.user-text a { color: #e7cd77; text-decoration: underline; }
.user-text .code-block { max-width: 100%; }
.user-text .code-body { max-width: 100%; overflow: auto; }
.user-text pre { max-width: 100%; overflow: auto; }
.user-text table { display: block; max-width: 100%; overflow: auto; }

/* User Uploaded Attachments Inside Chat Bubble */
.user-attachments-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

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

.user-img-wrapper {
    position: relative;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.12);
    cursor: pointer;
    transition: transform var(--ease), border-color var(--ease);
}

.user-img-wrapper:hover {
    transform: scale(1.02);
    border-color: var(--gold);
}

.user-img-thumb {
    width: 140px;
    height: 140px;
    object-fit: cover;
    display: block;
    border-radius: var(--radius-sm);
}

.user-docs-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
}

.user-doc-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}
.user-doc-chip i {
    color: var(--gold);
}

.user-message-actions {
    display: flex;
    gap: 4px;
    opacity: 0.65;
    transition: opacity var(--ease);
}

.message.user:hover .user-message-actions,
.message.user:focus-within .user-message-actions {
    opacity: 1;
}

.user-action-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 11px;
    transition: all var(--ease);
}
.user-action-btn:hover {
    background: var(--surface-raised);
    color: var(--gold);
}

/* Assistant Message */
.message.ai {
    justify-content: flex-start;
    gap: 12px;
}

.ai-avatar {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: var(--surface-raised);
    border: 1px solid var(--border-gold);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
}

.ai-avatar img {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.ai-message-body {
    flex: 1 1 0;
    min-width: 0;
    max-width: 820px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.message.ai .bubble {

    border-radius: 2px 8px 8px 2px;
    padding: 8px 18px;
    color: var(--text);
    font-size: 15.5px;
    line-height: 1.7;
}

.message-content {
    min-width: 0;
    overflow-wrap: anywhere;
}

.pixel-memory-confirmation {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    max-width: min(520px, 100%);
    padding: 14px 16px;
    color: var(--text-primary, #f5f2e9);
    background: linear-gradient(135deg, rgba(212, 175, 55, .13), rgba(212, 175, 55, .035) 68%, rgba(255, 255, 255, .025));
    border: 1px solid color-mix(in srgb, var(--pixel-ambient-accent, #d4af37) 38%, rgba(255, 255, 255, .1));
    border-radius: 14px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .055), 0 8px 28px rgba(0, 0, 0, .16);
    animation: pixelMemoryReveal .38s cubic-bezier(.2, .8, .2, 1) both;
}

.pixel-memory-confirmation-icon {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    color: var(--pixel-ambient-accent, #e3c86f);
    background: radial-gradient(circle at 35% 25%, rgba(255, 240, 185, .2), rgba(212, 175, 55, .12) 68%);
    border: 1px solid rgba(212, 175, 55, .25);
    border-radius: 13px;
    font-size: 16px;
}

.pixel-memory-confirmation-copy { display: grid; gap: 3px; min-width: 0; }
.pixel-memory-confirmation-copy strong { color: var(--text-primary, #f5f2e9); font-size: 14px; font-weight: 700; }
.pixel-memory-confirmation-copy span { color: var(--text-secondary, #b8b4aa); font-size: 12px; line-height: 1.5; }
.pixel-memory-confirmation-detail {
    grid-column: 1 / -1;
    margin: 0;
    padding: 10px 12px;
    color: var(--text-primary, #e8e1ce);
    background: rgba(0, 0, 0, .14);
    border-inline-start: 2px solid var(--pixel-ambient-accent, #d4af37);
    border-radius: 0 8px 8px 0;
    font-size: 13px;
    line-height: 1.55;
    overflow-wrap: anywhere;
}

@keyframes pixelMemoryReveal {
    from { opacity: 0; transform: translateY(7px) scale(.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    .pixel-memory-confirmation { animation: none; }
}

/* Stream Cursor Effect */
.message-content.stream::after { content: none; }

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

/* Assistant Message Actions Toolbar */
.message-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
    opacity: 0.72;
    transition: opacity var(--ease);
}

.message.ai:hover .message-actions,
.message.ai:focus-within .message-actions {
    opacity: 1;
}

.message-action {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-muted);
    transition: all var(--ease);
}
.message-action:hover {
    background: var(--surface-raised);
    color: var(--gold-light);
}
.message-action.active {
    color: var(--gold);
    background: var(--gold-subtle);
}

.message-action:focus-visible,
.user-action-btn:focus-visible,
.composer-btn:focus-visible,
.model-button:focus-visible,
.action-circle-btn:focus-visible,
.topbar-btn:focus-visible,
.chat-scroll-bottom-btn:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}

/* Thinking Indicator */
.thinking-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--surface-raised);
    border: 1px solid var(--border-gold);
    border-radius: var(--radius-full);
}

.thinking-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--gold);
    animation: thinkingDot 1.4s infinite ease-in-out both;
}
.thinking-dot:nth-child(1) { animation-delay: -0.32s; }
.thinking-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes thinkingDot {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1.1); opacity: 1; }
}

.thinking-label {
    font-size: 13px;
    color: var(--gold-light);
    font-weight: 500;
    margin-left: 4px;
}

/* Error States */
.message.error-state .error-bubble {
    background: rgba(255, 82, 82, 0.08);
    border: 1px solid rgba(255, 82, 82, 0.3);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.error-icon {
    color: var(--danger);
    font-size: 18px;
}

.error-title {
    font-size: 14px;
    font-weight: 600;
    color: #FF8585;
}

.error-desc {
    font-size: 13.5px;
    color: var(--text-secondary);
}

.error-retry-btn {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: rgba(255, 82, 82, 0.15);
    border: 1px solid rgba(255, 82, 82, 0.4);
    border-radius: var(--radius-sm);
    color: #FFA5A5;
    font-size: 13px;
    font-weight: 500;
    margin-top: 4px;
    transition: all var(--ease);
}
.error-retry-btn:hover {
    background: rgba(255, 82, 82, 0.25);
    color: #FFFFFF;
}

/* ======================================================================
   MARKDOWN & RICH RESPONSE FORMATTING
   ====================================================================== */

.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4 {
    color: var(--text);
    margin: 1.2em 0 0.5em;
    font-weight: 600;
    line-height: 1.3;
}
.message-content h1 { font-size: 1.5em; }
.message-content h2 { font-size: 1.3em; }
.message-content h3 { font-size: 1.15em; }

.message-content p {
    margin-bottom: 0.85em;
}
.message-content p:last-child {
    margin-bottom: 0;
}

.message-content ul,
.message-content ol {
    margin: 0.6em 0 0.85em 1.5em;
}
.message-content li {
    margin-bottom: 0.35em;
}

.message-content blockquote {
    margin: 1em 0;
    padding: 8px 16px;
    border-left: 3px solid var(--gold);
    background: var(--surface-raised);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-secondary);
    font-style: italic;
}

.message-content hr {
    border: 0;
    height: 1px;
    background: var(--border);
    margin: 1.5em 0;
}

.message-content a {
    color: var(--gold);
    text-decoration: underline;
    text-underline-offset: 3px;
}
.message-content a:hover {
    color: var(--gold-light);
}

.message-content table {
    display: block;
    width: 100%;
    max-width: 100%;
    border-collapse: collapse;
    margin: 1em 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow-x: auto;
}
.message-content th,
.message-content td {
    padding: 10px 14px;
    border: 1px solid var(--border);
    text-align: left;
    font-size: 13.5px;
}
.message-content th {
    background: var(--surface-raised);
    font-weight: 600;
    color: var(--gold-light);
}

/* Code Blocks */
.code-block {
    margin: 1em 0;
    border: 1px solid rgba(212, 175, 55, .12);
    border-radius: 22px;
    background: #141414;
    overflow: hidden;
    box-shadow: none;
}

.code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 40px;
    padding: 8px 17px 0;
    background: transparent;
    border: 0;
}

.code-language {
    font-size: 11px;
    font-family: "JetBrains Mono", monospace;
    color: var(--gold-light);
    font-weight: 600;
    text-transform: lowercase;
}

.copy-code {
    display: inline-flex;
    width: 28px;
    height: 28px;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
    color: #bab8b2;
    font-size: 12px;
    padding: 0;
    border-radius: 50%;
    transition: background .16s, color .16s;
}
.copy-code:hover {
    background: rgba(212, 175, 55, .12);
    color: var(--gold-light);
}

.code-body {
    display: block;
    padding: 0 17px 17px;
    overflow: hidden;
}

.code-block pre {
    margin: 0;
    padding: 13px 14px;
    overflow-x: auto;
    min-width: max-content;
    max-width: 100%;
    border: 0;
    border-radius: 12px;
    background: #202124;
    color: #e6e1d8;
    font-family: "JetBrains Mono", Menlo, Monaco, Consolas, monospace;
    font-size: 12.5px;
    line-height: 1.7;
}
.code-block pre code { display: block; min-width: max-content; padding: 0; background: transparent; }
.code-block .hljs-comment,.code-block .hljs-quote { color: #898b91; font-style: italic; }
.code-block .hljs-keyword,.code-block .hljs-selector-tag,.code-block .hljs-literal { color: #e3c35e; }
.code-block .hljs-title,.code-block .hljs-title.function_,.code-block .hljs-function .hljs-title { color: #e9c84a; }
.code-block .hljs-type,.code-block .hljs-built_in,.code-block .hljs-params { color: #b8c5f2; }
.code-block .hljs-string,.code-block .hljs-attr { color: #c9dda0; }
.code-block .hljs-number,.code-block .hljs-literal { color: #e6a777; }
.code-block .hljs-variable,.code-block .hljs-property { color: #e4e6eb; }
.code-block .hljs-meta,.code-block .hljs-operator,.code-block .hljs-punctuation { color: #b9bdc8; }

/* Inline Code */
.inline-code,
:not(pre) > code {
    background: rgba(212, 175, 55, 0.08);
    color: var(--gold-light);
    padding: 2px 7px;
    border-radius: 5px;
    font-family: "JetBrains Mono", monospace;
    font-size: 0.88em;
    border: 1px solid rgba(212, 175, 55, 0.12);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* Task Lists */
.task-item {
    list-style: none;
    margin-left: -1.5em;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}
.task-check {
    color: var(--text-muted);
    font-size: 15px;
    margin-top: 1px;
    flex-shrink: 0;
}
.task-check.checked {
    color: var(--gold);
}

/* Math Formatting */
.math-block {
    display: block;
    text-align: center;
    padding: 12px 16px;
    margin: 1em 0;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: "Cambria Math", Cambria, "Times New Roman", serif;
    font-size: 14px;
    color: var(--gold-light);
    overflow-x: auto;
}
.math-inline {
    font-family: "Cambria Math", Cambria, "Times New Roman", serif;
    font-size: 1em;
    color: var(--gold-light);
    background: rgba(212, 175, 55, 0.08);
    padding: 1px 5px;
    border-radius: 3px;
}
.math-inline mjx-container {
    vertical-align: middle;
}
.math-block mjx-container {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    color: inherit;
}
.math-block mjx-container[display="true"] {
    display: block;
    margin: 0.25em auto;
}

/* Strong / Bold text emphasis */
.message-content strong {
    color: var(--text);
    font-weight: 650;
}
.message-content em {
    color: var(--text-secondary);
    font-style: italic;
}

/* Strikethrough */
.message-content del {
    color: var(--text-muted);
    text-decoration: line-through;
}

/* ======================================================================
   COMPOSER (MESSAGE INPUT)
   ====================================================================== */

.composer-container {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: min(var(--content-width), calc(100% - 36px));
    z-index: var(--z-composer);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.composer-box {
    width: 100%;
    background: rgba(23, 24, 28, 0.95);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--border-gold);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
    box-shadow: var(--shadow-lg), 0 0 24px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: border-color var(--ease), box-shadow var(--ease);
}

.composer-box:focus-within {
    border-color: var(--gold);
    box-shadow: var(--shadow-lg), 0 0 0 3px rgba(212, 175, 55, 0.12);
}

#promptInput:focus,
#promptInput:focus-visible {
    border: 0 !important;
    outline: 0 !important;
    box-shadow: none !important;
}

.composer-input-row {
    width: 100%;
}

.composer-input-row textarea {
    width: 100%;
    min-height: 24px;
    max-height: 200px;
    resize: none;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
}

.composer-input-row textarea::placeholder {
    color: var(--text-muted);
}

.composer-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding-top: 4px;
}

.composer-toolbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.composer-btn {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all var(--ease);
}
.composer-btn:hover {
    background: var(--surface-hover);
    color: var(--gold);
}

/* Model Selector in Composer */
.model-selector {
    position: relative;
}

.model-button {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 5px 10px;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all var(--ease);
}
.model-button:hover {
    background: var(--surface-hover);
    color: var(--gold-light);
    border-color: var(--border-gold);
}

.model-btn-icon {
    font-size: 13px;
}
.model-chevron {
    font-size: 10px;
    color: var(--text-muted);
}

/* Floating Model Menu */
.model-menu {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 0;
    width: 340px;
    max-height: 380px;
    background: rgba(22, 23, 27, 0.98);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--border-gold);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 10px;
    display: none;
    flex-direction: column;
    gap: 6px;
    z-index: var(--z-dropdown);
    overflow-y: auto;
}

.model-menu.show {
    display: flex;
    animation: menuFadeIn 0.18s var(--ease);
}

@keyframes menuFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.model-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 6px 8px;
    border-bottom: 1px solid var(--border);
}
.model-menu-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}
.model-menu-badge {
    font-size: 11px;
    color: var(--gold);
    background: var(--gold-subtle);
    padding: 2px 6px;
    border-radius: 4px;
}

.model-menu-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.model-item {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    text-align: left;
    transition: all var(--ease);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.model-item:hover {
    background: var(--surface-hover);
    border-color: rgba(255, 255, 255, 0.08);
}

.model-item.selected {
    background: var(--surface-hover);
    border-color: var(--border-gold);
}

.model-item-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.model-item-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.model-item-name {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text);
}
.model-item.selected .model-item-name {
    color: var(--gold-light);
}

.model-item-badge {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
}
.badge-gemini, .badge-Google { background: rgba(66, 133, 244, 0.15); color: #8AB4F8; }
.badge-groq { background: rgba(245, 80, 54, 0.15); color: #FF8A65; }
.badge-nvidia { background: rgba(118, 185, 0, 0.15); color: #76B900; }
.badge-auto { background: var(--gold-subtle); color: var(--gold); }

.model-item-desc {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.35;
}

.model-caps {
    display: flex;
    gap: 4px;
    margin-top: 2px;
}

.cap-tag {
    font-size: 10px;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
    padding: 1px 5px;
    border-radius: 3px;
}

/* Action Circle Buttons (Send & Stop) */
.composer-toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.action-circle-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--ease);
}

.send-btn {
    background: var(--gold);
    color: var(--text-inverse);
    font-size: 14px;
    box-shadow: 0 4px 14px rgba(212, 175, 55, 0.35);
}
.send-btn:hover {
    background: var(--gold-light);
    transform: scale(1.05);
}
.send-btn:active {
    transform: scale(0.96);
}

.stop-btn {
    background: #E53935;
    color: #FFFFFF;
    font-size: 13px;
    box-shadow: 0 4px 14px rgba(229, 57, 53, 0.35);
    animation: stopPulse 1.8s infinite;
}
.stop-btn:hover {
    background: #FF5252;
}

@keyframes stopPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 10px rgba(229, 57, 53, 0.4); }
    50% { transform: scale(1.05); box-shadow: 0 0 18px rgba(229, 57, 53, 0.7); }
}

.composer-legal-hint {
    font-size: 11.5px;
    color: var(--text-muted);
    text-align: center;
}

/* Attachments Preview in Composer */
.attachment-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
    margin-bottom: 4px;
}
.attachment-card {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    font-size: 12px;
}
.attachment-thumb {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: 6px;
    background: var(--surface, #121214);
}
.attachment-card:has(.attachment-thumb) { padding: 6px; }
.user-chat-attachment-preview {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 280px;
}
.user-chat-attachment-preview > span { overflow-wrap: anywhere; }
.user-chat-attachment-thumb {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 4px;
    background: var(--surface, #121214);
}
.user-chat-attachment-preview .remove-att {
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    border: 0;
    color: inherit;
    background: transparent;
}
.attachment-name {
    font-weight: 500;
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.attachment-size {
    color: var(--text-muted);
    font-size: 11px;
}
.remove-file {
    color: var(--text-muted);
    transition: color var(--ease);
}
.remove-file:hover {
    color: var(--danger);
}

/* ======================================================================
   SETTINGS DIALOG MODAL
   ====================================================================== */

.settings-dialog {
    position: fixed;
    inset: 0;
    margin: auto;
    width: min(780px, calc(100vw - 32px));
    max-height: calc(100vh - 64px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255,255,255,0.03);
    color: var(--text);
    padding: 0;
    overflow: hidden;
    z-index: 10000;
}

.settings-dialog:not([open]) {
    display: none;
}

.settings-dialog[open] {
    display: flex;
    flex-direction: column;
}

.settings-dialog::backdrop {
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.dialog-header {
    height: 56px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}
.dialog-header h2 {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
}
.dialog-header h2 i {
    color: var(--text-muted);
    font-size: 14px;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all var(--ease);
}
.modal-close:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.settings-layout {
    display: flex;
    min-height: 440px;
    max-height: calc(100vh - 128px);
}

/* Sidebar Nav */
.settings-nav {
    width: 200px;
    border-right: 1px solid var(--border);
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex-shrink: 0;
    background: var(--bg);
}

.settings-tab {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-secondary);
    text-align: left;
    transition: all var(--ease);
    font-weight: 450;
}
.settings-tab i {
    width: 16px;
    text-align: center;
    font-size: 13px;
}
.settings-tab:hover {
    background: var(--surface-raised);
    color: var(--text);
}
.settings-tab.active {
    background: var(--surface-raised);
    color: var(--text);
    font-weight: 600;
}
.settings-tab.active i {
    color: var(--gold);
}

/* Content Area */
.settings-content {
    flex: 1;
    padding: 28px 32px;
    overflow-y: auto;
}

.settings-page {
    display: none;
    flex-direction: column;
    gap: 24px;
}
.settings-page.active {
    display: flex;
}

.settings-section-header h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
}

.settings-intro {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Setting Groups */
.settings-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.settings-group-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    padding: 0 2px 8px;
}

/* Setting Rows */
.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color var(--ease);
}
.setting-row:hover {
    border-color: rgba(255,255,255,0.12);
}

.setting-row + .setting-row,
.setting-row + .setting-row-select {
    margin-top: -1px;
}

.setting-row:first-of-type {
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.setting-row:last-of-type,
.setting-row-select:last-of-type {
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}
.setting-row:only-of-type {
    border-radius: var(--radius-sm);
}

.setting-row-select {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    cursor: default;
}

.setting-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.setting-icon-wrap {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--surface-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 13px;
    flex-shrink: 0;
}
.setting-row:hover .setting-icon-wrap {
    color: var(--gold);
    background: var(--gold-subtle);
}

.setting-info strong {
    display: block;
    font-size: 13.5px;
    font-weight: 550;
    color: var(--text);
}
.setting-info small {
    display: block;
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 1px;
}

/* Toggle Switch */
.setting-row input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 40px;
    height: 22px;
    border-radius: 11px;
    background: rgba(255, 255, 255, 0.12);
    position: relative;
    cursor: pointer;
    transition: background var(--ease);
    flex-shrink: 0;
}
.setting-row input[type="checkbox"]::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #FFFFFF;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    transition: transform var(--ease);
}
.setting-row input[type="checkbox"]:checked {
    background: var(--gold);
}
.setting-row input[type="checkbox"]:checked::after {
    transform: translateX(18px);
}

/* Inline Select */
.settings-select-inline {
    padding: 6px 10px;
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
    transition: border-color var(--ease);
}
.settings-select-inline:focus {
    border-color: var(--border-gold);
}

/* Profile Card */
.profile-card-pro {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}
.profile-avatar-large {
    width: 48px;
    height: 48px;
    font-size: 18px;
}
.profile-card-pro-info strong {
    display: block;
    font-size: 15px;
    font-weight: 600;
}
.profile-card-pro-info small {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Settings Fields */
.settings-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.settings-field-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    padding-left: 2px;
}
.settings-field-row {
    display: flex;
    gap: 8px;
}

.settings-memory-list { display: grid; gap: 8px; }
.settings-memory-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border-subtle); border-radius: 10px; background: var(--surface-1); }
.settings-memory-row span { overflow-wrap: anywhere; color: var(--text-primary); }
.settings-memory-row small { color: var(--text-muted); }
@media (max-width: 640px) { .settings-memory-row { grid-template-columns: minmax(0, 1fr) auto; } .settings-memory-row small { grid-column: 1; } .settings-memory-row button { grid-column: 2; grid-row: 1 / span 2; } }
.settings-input {
    flex: 1;
    padding: 10px 14px;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    transition: border-color var(--ease);
}
.settings-input:focus {
    border-color: var(--border-gold);
}

.settings-btn-primary {
    padding: 10px 18px;
    background: var(--gold);
    color: var(--text-inverse);
    font-weight: 600;
    font-size: 13px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all var(--ease);
    flex-shrink: 0;
}
.settings-btn-primary:hover {
    background: var(--gold-light);
}
.custom-model-settings-group { gap: 7px; }
.custom-model-form { display: grid; gap: 7px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-raised); }
.custom-model-form { min-width: 0; grid-template-columns: minmax(0, 1fr); }
.custom-model-form .settings-input,
.custom-model-form .settings-select-inline { box-sizing: border-box; width: min(240px, 100%); min-width: 0; max-width: 100%; }
.custom-model-form .settings-select-inline { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.custom-model-form .settings-intro { margin: 2px 0 8px; line-height: 1.5; }
.custom-model-form select { min-height: 38px; max-width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); background: var(--surface); }
.custom-model-form .settings-btn-primary { justify-self: start; }
.custom-model-error { color: var(--danger, #ff6b6b); font-size: 12px; }
.response-save-warning { margin: 8px 0 0; color: var(--danger, #ff6b6b); font-size: 12px; }
.custom-model-list { display: grid; gap: 6px; margin-top: 8px; }
.custom-model-entry { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 13px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-raised); }
.custom-model-entry-copy { display: grid; gap: 4px; min-width: 0; }
.custom-model-entry-copy strong { overflow: hidden; color: var(--text); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.custom-model-entry-copy small { color: var(--text-muted); font-size: 10px; overflow-wrap: anywhere; }
.custom-model-remove { flex: none; padding: 7px 9px; border: 1px solid var(--border); border-radius: 7px; color: var(--text-secondary); background: transparent; cursor: pointer; }

.settings-btn-secondary {
    padding: 9px 16px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all var(--ease);
}
.settings-btn-secondary:hover {
    border-color: var(--border-gold);
    color: var(--text);
}

.settings-action-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.settings-action-row strong {
    display: block;
    font-size: 13.5px;
    color: var(--text);
}
.settings-action-row small {
    display: block;
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 1px;
}

/* Keyboard Shortcuts */
.shortcut-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-secondary);
}
.shortcut-row + .shortcut-row {
    margin-top: -1px;
}
.shortcut-row:first-child {
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.shortcut-row:last-child {
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}
.shortcut-keys {
    display: flex;
    gap: 4px;
}
.shortcut-keys kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 24px;
    padding: 0 6px;
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 11px;
    font-family: inherit;
    font-weight: 600;
    color: var(--text-muted);
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

/* About Page */
.about-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}
.about-logo {
    width: 52px;
    height: 52px;
    flex-shrink: 0;
}
.about-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 2px 8px rgba(212, 175, 55, 0.25));
}
.about-info h4 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}
.about-version {
    display: inline-block;
    margin-top: 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--gold);
    background: var(--gold-subtle);
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid rgba(212, 175, 55, 0.2);
}

.about-detail-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    font-size: 13px;
}
.about-detail-row + .about-detail-row {
    margin-top: -1px;
}
.about-detail-row:first-child {
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.about-detail-row:last-child {
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}
.about-label {
    color: var(--text-secondary);
}
.about-value {
    color: var(--text);
    font-weight: 500;
}

.about-footer {
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
    padding: 8px 0 4px;
}

/* Danger Zone */
.danger-zone {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.danger-action-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.danger-action-row + .danger-action-row {
    margin-top: -1px;
    border-radius: 0;
}
.danger-action-row:first-child {
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.danger-action-row:last-child {
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.danger-info {
    display: flex;
    align-items: center;
    gap: 12px;
}
.danger-info > i {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--danger-subtle);
    color: var(--danger);
    border-radius: var(--radius-sm);
    font-size: 13px;
    flex-shrink: 0;
}
.danger-action-row strong {
    display: block;
    font-size: 13.5px;
    color: var(--text);
}
.danger-action-row small {
    display: block;
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 1px;
}
.danger-btn {
    padding: 8px 14px;
    background: var(--danger-subtle);
    border: 1px solid rgba(255, 82, 82, 0.25);
    border-radius: var(--radius-sm);
    color: var(--danger);
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all var(--ease);
    flex-shrink: 0;
}
.danger-btn:hover {
    background: rgba(255, 82, 82, 0.2);
    color: #FFFFFF;
    border-color: var(--danger);
}

/* ======================================================================
   CONTEXT MENU
   ====================================================================== */

.chat-context-menu {
    position: fixed;
    display: none;
    flex-direction: column;
    min-width: 170px;
    background: rgba(24, 25, 30, 0.98);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-gold);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    padding: 6px;
    z-index: 1500;
    gap: 2px;
}

.chat-context-menu.show {
    display: flex;
    animation: menuFadeIn 0.15s var(--ease);
}

.chat-context-menu button {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 4px;
    font-size: 13px;
    color: var(--text);
    text-align: left;
    transition: all var(--ease);
}
.chat-context-menu button:hover {
    background: var(--surface-hover);
    color: var(--gold-light);
}
.chat-context-menu button.danger-action:hover {
    background: rgba(255, 82, 82, 0.15);
    color: #FF7070;
}

/* ======================================================================
   RESPONSIVE DESIGN (MOBILE & TABLET UX)
   ====================================================================== */

.sidebar-overlay {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    height: var(--app-viewport-height, 100vh);
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: var(--z-overlay);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--ease), visibility var(--ease);
}

.sidebar-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* Desktop sidebar push layout */
@media (min-width: 841px) {
    .sidebar.expanded ~ .sidebar-overlay {
        display: none;
    }
    .sidebar.expanded ~ .main {
        margin-left: var(--sidebar-width);
        transition: margin-left var(--ease);
    }
}

@media (max-width: 840px) {
    .starter-cards-grid {
        grid-template-columns: 1fr;
    }

    .composer-container {
        width: calc(100% - 24px);
        bottom: 12px;
    }

    .chat-container {
        padding: 16px 12px 140px;
    }

    .model-menu {
        width: calc(100vw - 48px);
        max-width: 320px;
    }

    .settings-layout {
        flex-direction: column;
    }
    .settings-nav {
        width: 100%;
        flex-direction: row;
        overflow-x: auto;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
}

@media (max-width: 520px) {
    .welcome {
        padding: 16px 0 136px;
    }
    .welcome-title {
        font-size: 30px;
    }
    .welcome-subtitle {
        font-size: 14px;
        margin-bottom: 24px;
    }
    .topbar-center {
        display: none;
    }
    .message.user .bubble {
        padding: 10px 14px;
        font-size: 14px;
    }
    .message.ai .bubble {
        font-size: 14px;
    }
    .ai-avatar {
        width: 28px;
        height: 28px;
    }
    .message.ai {
        gap: 8px;
    }
    .message.ai .bubble {
        padding: 8px 12px;
        font-size: 14px;
    }
    .starter-card {
        min-height: 0;
        padding: 12px;
    }
    .composer-box {
        padding: 10px 12px;
        border-radius: var(--radius-md);
    }
}

/* Reduced Motion preference */
body.reduce-motion * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ======================================================================
   ARTWORKS & USER CHAT / CHAT ROOMS EXTENSIONS
   ====================================================================== */

/* --- Navigation Badges & Buttons --- */
.unread-badge-pill {
    background: var(--gold);
    color: var(--text-inverse);
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: var(--radius-full);
    margin-left: auto;
}

/* --- View Panel Visibility --- */
.app-view-panel {
    display: none;
    width: 100%;
    height: 100%;
    min-height: 0;
    min-width: 0;
    flex-direction: column;
}
.app-view-panel.active {
    display: flex;
}

/* ======================================================================
   ARTWORKS GALLERY & LIGHTBOX VIEWER
   ====================================================================== */
.artworks-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px 32px 60px;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

.artworks-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.artworks-title-group h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 12px;
}

.artworks-title-group h1 i {
    color: var(--gold);
}

.artworks-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
}

.artworks-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.artworks-search-box {
    position: relative;
    width: 240px;
}
.artworks-search-box input {
    width: 100%;
    padding: 8px 14px 8px 36px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text);
    font-size: 13px;
    outline: none;
    transition: var(--ease);
}
.artworks-search-box input:focus {
    border-color: var(--border-gold);
    box-shadow: 0 0 12px var(--gold-subtle);
}
.artworks-search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 13px;
}

.artworks-filter-select {
    padding: 8px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text);
    font-size: 13px;
    outline: none;
    cursor: pointer;
}
.artworks-filter-select:focus {
    border-color: var(--border-gold);
}

.artworks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

.artwork-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: transform var(--ease), border-color var(--ease), box-shadow var(--ease);
    cursor: pointer;
    display: flex;
    flex-direction: column;
}
.artwork-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-gold-strong);
    box-shadow: var(--shadow-gold), var(--shadow-md);
}

.artwork-card-thumb-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    background: var(--surface-raised);
    overflow: hidden;
}

.artwork-card-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}
.artwork-card:hover .artwork-card-thumb {
    transform: scale(1.05);
}

.artwork-card-hover-overlay {
    position: absolute;
    inset: 0;
    background: rgba(10, 10, 10, 0.45);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--ease);
}
.artwork-card:hover .artwork-card-hover-overlay {
    opacity: 1;
}

.artwork-zoom-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    background: var(--gold);
    color: var(--text-inverse);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    box-shadow: var(--shadow-sm);
}

.artwork-card-content {
    padding: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.artwork-card-category {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gold);
    margin-bottom: 6px;
}

.artwork-card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
    line-height: 1.3;
}

.artwork-card-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.artwork-card-meta {
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-muted);
}

/* Lightbox Modal */
.artwork-lightbox-dialog {
    position: fixed;
    inset: 0;
    margin: auto;
    background: rgba(10, 10, 12, 0.96);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-gold, rgba(234, 179, 8, 0.4));
    border-radius: var(--radius-lg, 16px);
    padding: 0;
    max-width: 1200px;
    width: 92vw;
    max-height: 88vh;
    height: 85vh;
    color: var(--text, #f4f4f5);
    overflow: hidden;
    outline: none;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8), 0 0 25px rgba(234, 179, 8, 0.15);
    z-index: 10000;
}

.artwork-lightbox-dialog::backdrop {
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.artwork-lightbox-dialog:fullscreen,
.artwork-lightbox-dialog.lightbox-fullscreen-fallback {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    border: none !important;
}

.artwork-lightbox-body {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: 100%;
}
@media (min-width: 800px) {
    .artwork-lightbox-body {
        flex-direction: row;
        height: 100%;
    }
}

.artwork-lightbox-image-container {
    flex: 1.5;
    position: relative;
    background: #050507;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    min-height: 350px;
}

.artwork-lightbox-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
    transform-origin: center center;
    will-change: transform;
    transition: transform 0.08s ease-out;
}

.lightbox-img-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(18, 18, 20, 0.75);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text, #f4f4f5);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: pointer;
    z-index: 15;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.lightbox-img-arrow:hover {
    background: var(--gold, #eab308);
    color: #000;
    border-color: var(--gold, #eab308);
    transform: translateY(-50%) scale(1.12);
    box-shadow: 0 4px 16px rgba(234, 179, 8, 0.4);
}
.lightbox-img-arrow.prev { left: 16px; }
.lightbox-img-arrow.next { right: 16px; }

.artwork-lightbox-zoom-bar {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(17, 18, 21, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    padding: 4px 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 10;
}
.artwork-lightbox-zoom-bar button {
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 14px;
    cursor: pointer;
    padding: 4px 6px;
    transition: color var(--ease);
}
.artwork-lightbox-zoom-bar button:hover {
    color: var(--gold);
}

.artwork-lightbox-sidebar {
    flex: 1;
    padding: 28px;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    overflow-y: auto;
    border-left: 1px solid var(--border);
}

.artwork-lightbox-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.artwork-lightbox-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
}

.artwork-lightbox-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: color var(--ease), background var(--ease);
}
.artwork-lightbox-close:hover {
    color: var(--danger);
    background: var(--danger-subtle);
}

.artwork-lightbox-details {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 24px;
}

.artwork-detail-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.artwork-detail-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--gold);
    letter-spacing: 0.5px;
}
.artwork-detail-value {
    font-size: 14px;
    color: var(--text);
    line-height: 1.5;
}

.artwork-lightbox-nav {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.lightbox-nav-btn {
    padding: 10px 18px;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--ease);
}
.lightbox-nav-btn:hover:not(:disabled) {
    border-color: var(--border-gold);
    color: var(--gold);
    background: var(--surface-hover);
}
.lightbox-nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ======================================================================
   USER CHAT & CHAT ROOMS VIEW (Pixel AI 2.0 Modern Redesign)
   ====================================================================== */

.user-chat-container {
    display: flex;
    flex: 1;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    background: var(--bg, #09090b);
}

/* ── Sidebar & Chat List ─────────────────────── */
.user-chat-sidebar {
    width: 320px;
    background: var(--surface, #121214);
    border-right: 1px solid var(--border, rgba(255, 255, 255, 0.08));
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.user-chat-sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.08));
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.user-chat-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.user-chat-brand h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text, #f4f4f5);
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}
.user-chat-brand h2 i {
    color: var(--gold, #eab308);
}

.user-chat-actions-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.chat-action-btn {
    padding: 8px 12px;
    background: var(--surface-raised, #18181b);
    border: 1px solid var(--border, rgba(255, 255, 255, 0.1));
    border-radius: var(--radius-md, 8px);
    color: var(--text, #f4f4f5);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.chat-action-btn:hover {
    border-color: var(--border-gold, rgba(234, 179, 8, 0.4));
    color: var(--gold, #eab308);
    background: var(--surface-hover, rgba(255, 255, 255, 0.06));
    transform: translateY(-1px);
}
.chat-action-btn.primary {
    background: linear-gradient(135deg, #eab308, #ca8a04);
    color: #000;
    border-color: #eab308;
    box-shadow: 0 2px 10px rgba(234, 179, 8, 0.25);
}
.chat-action-btn.primary:hover {
    background: linear-gradient(135deg, #facc15, #eab308);
    box-shadow: 0 4px 14px rgba(234, 179, 8, 0.35);
}

.user-chat-search-wrap {
    padding: 10px 16px 6px;
}
.user-chat-search-input {
    width: 100%;
    padding: 8px 12px 8px 34px;
    background: var(--surface-raised, #18181b);
    border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
    border-radius: var(--radius-md, 8px);
    color: var(--text, #f4f4f5);
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.user-chat-search-input:focus {
    border-color: var(--gold, #eab308);
    box-shadow: 0 0 0 2px rgba(234, 179, 8, 0.15);
}

.user-chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Custom Sleek Scrollbar */
.user-chat-list::-webkit-scrollbar,
.user-chat-messages-container::-webkit-scrollbar,
.pinned-panel::-webkit-scrollbar {
    width: 5px;
}
.user-chat-list::-webkit-scrollbar-thumb,
.user-chat-messages-container::-webkit-scrollbar-thumb,
.pinned-panel::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}
.user-chat-list::-webkit-scrollbar-thumb:hover,
.user-chat-messages-container::-webkit-scrollbar-thumb:hover {
    background: var(--gold, #eab308);
}

.chat-list-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted, #a1a1aa);
    letter-spacing: 0.6px;
    padding: 10px 8px 4px;
}

.chat-list-item {
    padding: 10px 12px;
    border-radius: var(--radius-md, 8px);
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: background 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
    border-left: 3px solid transparent;
    position: relative;
}
.chat-list-item:hover {
    background: var(--surface-hover, rgba(255, 255, 255, 0.05));
    transform: translateX(3px);
}
.chat-list-item.active {
    background: color-mix(in srgb, var(--gold, #eab308) 12%, var(--surface-raised, #18181b));
    border-left-color: var(--gold, #eab308);
}

.chat-item-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--surface-raised, #18181b);
    border: 1px solid var(--border-gold, rgba(234, 179, 8, 0.4));
    color: var(--gold, #eab308);
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
    position: relative;
}
.chat-item-avatar.room-avatar {
    background: color-mix(in srgb, var(--gold, #eab308) 15%, transparent);
    color: var(--gold, #eab308);
    border-color: var(--gold, #eab308);
}

.online-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    border: 2px solid var(--surface, #121214);
    position: absolute;
    bottom: 0;
    right: 0;
    box-shadow: 0 0 6px rgba(74, 222, 128, 0.6);
}

.chat-item-details {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chat-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.chat-item-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text, #f4f4f5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-item-time {
    font-size: 11px;
    color: var(--text-muted, #a1a1aa);
}

.chat-item-preview {
    font-size: 12px;
    color: var(--text-secondary, #d4d4d8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-badge {
    background: var(--gold, #eab308);
    color: #000;
    font-size: 10px;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(234, 179, 8, 0.4);
}

/* ── User Chat Main Workspace ───────────────── */
.user-chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg, #09090b);
    height: 100%;
    min-width: 0;
    min-height: 0;
    position: relative;
}

.user-chat-header {
    position: relative;
    min-height: 64px;
    padding: 0 16px;
    border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.08));
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface, #121214);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 20;
    flex-shrink: 0;
}

.user-chat-back-btn {
    display: none;
    margin-right: 12px;
    background: transparent;
    border: none;
    color: var(--gold, #eab308);
    font-size: 16px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: var(--radius-sm, 6px);
    transition: background 0.15s ease, transform 0.15s ease;
}
.user-chat-back-btn:hover {
    background: rgba(234, 179, 8, 0.15);
    transform: translateX(-2px);
}

.user-chat-header-avatar {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-gold, rgba(234, 179, 8, 0.4));
    border-radius: 50%;
    background: var(--surface-raised, #18181b);
    color: var(--gold, #eab308);
    font-size: 14px;
    font-weight: 700;
}
.user-chat-header-avatar.room-avatar {
    background: color-mix(in srgb, var(--gold, #eab308) 15%, transparent);
}

.user-chat-header-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
}

.user-chat-header-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--text, #f4f4f5);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-chat-header-sub {
    font-size: 11px;
    color: var(--text-muted, #a1a1aa);
    font-weight: 400;
}

.user-chat-header-actions {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    gap: 4px;
}
.user-chat-header-actions > .topbar-btn,
.user-chat-header-menu > summary {
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    list-style: none;
    cursor: pointer;
}
.user-chat-header-menu > summary::-webkit-details-marker { display: none; }
.user-chat-header-menu { position: relative; }
.user-chat-header-menu-panel {
    position: absolute;
    z-index: 80;
    top: calc(100% + 8px);
    right: 0;
    display: grid;
    min-width: 200px;
    gap: 3px;
    padding: 6px;
    border: 1px solid var(--border, rgba(255,255,255,.12));
    border-radius: 8px;
    background: var(--surface, #121214);
    box-shadow: 0 12px 32px rgba(0,0,0,.45);
}
.user-chat-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 38px;
    padding: 8px 10px;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: var(--text, #f4f4f5);
    cursor: pointer;
    text-align: left;
    white-space: nowrap;
}
.user-chat-menu-item:hover { background: var(--surface-hover, rgba(255,255,255,.06)); color: var(--gold, #eab308); }
.user-chat-menu-item.danger { color: var(--danger, #ef4444); }
.user-chat-menu-item i { width: 16px; text-align: center; }
.user-chat-header-menu .room-code-tag { justify-content: flex-start; min-height: 38px; }
#userChatSearchWrap { width: min(190px, 25vw); min-width: 0; }
#userChatSearchWrap[hidden] { display: none; }
#userChatSearchWrap input { min-width: 0; }

.room-code-tag {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    font-weight: 600;
    background: color-mix(in srgb, var(--gold, #eab308) 15%, transparent);
    color: var(--gold, #eab308);
    border: 1px solid rgba(234, 179, 8, 0.3);
    padding: 3px 10px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease;
}
.room-code-tag:hover {
    background: color-mix(in srgb, var(--gold, #eab308) 25%, transparent);
    transform: scale(1.04);
}

.user-chat-messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scroll-behavior: smooth;
    min-height: 0;
}

/* ── Message Rows & Glassmorphic Bubbles ───── */
.chat-msg-row {
    display: flex;
    gap: 12px;
    max-width: 78%;
    position: relative;
    animation: fadeInMsg 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeInMsg {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-msg-row.mine {
    margin-left: auto;
    flex-direction: row-reverse;
}

.chat-msg-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--surface-raised, #18181b);
    border: 1px solid var(--border, rgba(255, 255, 255, 0.1));
    color: var(--gold, #eab308);
    font-weight: 700;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.chat-msg-content-wrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.chat-msg-row.mine .chat-msg-content-wrap {
    align-items: flex-end;
}

.chat-msg-sender {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted, #a1a1aa);
}

.chat-msg-bubble {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.55;
    word-break: break-word;
    background: var(--surface-raised, #18181b);
    border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
    color: var(--text, #f4f4f5);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    position: relative;
}

.chat-msg-row:not(.mine) .chat-msg-bubble {
    border-top-left-radius: 4px;
}

.chat-msg-row.mine .chat-msg-bubble {
    background: linear-gradient(135deg, color-mix(in srgb, var(--gold, #eab308) 18%, #18181b), color-mix(in srgb, var(--gold, #eab308) 10%, #09090b));
    border: 1px solid color-mix(in srgb, var(--gold, #eab308) 30%, transparent);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    border-top-right-radius: 4px;
}

.chat-msg-row.sending {
    opacity: 0.8;
}

.chat-msg-time {
    font-size: 10px;
    color: var(--text-muted, #a1a1aa);
    margin-top: 2px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.system-msg-row {
    margin: 8px auto;
    padding: 6px 16px;
    background: var(--surface-raised, #18181b);
    border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
    border-radius: 20px;
    font-size: 12px;
    color: var(--text-secondary, #d4d4d8);
    text-align: center;
}

/* ── Hover Quick Actions Toolbar ───────────── */
.msg-hover-actions {
    position: absolute;
    top: -18px;
    right: 12px;
    background: rgba(18, 18, 20, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid color-mix(in srgb, var(--gold, #eab308) 35%, rgba(255, 255, 255, 0.1));
    border-radius: 20px;
    padding: 3px 8px;
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
    z-index: 20;
    transform: translateY(4px);
}

.chat-msg-row.mine .msg-hover-actions {
    left: 12px;
    right: auto;
}

.chat-msg-row:hover .msg-hover-actions {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.msg-hover-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary, #d4d4d8);
    font-size: 12px;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    transition: color 0.15s ease, transform 0.15s ease;
}
.msg-hover-btn:hover {
    color: var(--gold, #eab308);
    transform: scale(1.25);
}

/* Reactions Display */
.msg-reactions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}
.reaction-pill {
    padding: 3px 9px;
    background: var(--surface-raised, #18181b);
    border: 1px solid var(--border, rgba(255, 255, 255, 0.1));
    border-radius: 12px;
    font-size: 11px;
    color: var(--text-secondary, #d4d4d8);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.reaction-pill:hover, .reaction-pill.active {
    border-color: var(--gold, #eab308);
    background: color-mix(in srgb, var(--gold, #eab308) 18%, transparent);
    color: var(--gold, #eab308);
    transform: scale(1.08);
}

/* Message Attachments */
.chat-msg-attachments-wrap {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 6px;
}
.chat-msg-img-attachment {
    max-width: 280px;
    max-height: 200px;
    border-radius: var(--radius-md, 8px);
    object-fit: cover;
    border: 1px solid var(--border, rgba(255, 255, 255, 0.1));
    cursor: pointer;
    transition: transform 0.2s ease;
}
.chat-msg-img-attachment:hover {
    transform: scale(1.02);
}

/* ── User Chat Composer (Floating Pill) ─────── */
.user-chat-composer-wrap {
    padding: 12px 16px;
    border-top: 1px solid var(--border, rgba(255, 255, 255, 0.08));
    background: var(--surface, #121214);
    flex-shrink: 0;
}

.user-chat-composer-box {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg, #09090b);
    border: 1px solid var(--border, rgba(255, 255, 255, 0.12));
    border-radius: 24px;
    padding: 8px 16px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.user-chat-composer-box:focus-within {
    border-color: var(--gold, #eab308);
    box-shadow: 0 0 0 2px rgba(234, 179, 8, 0.18);
}

.user-chat-composer-box textarea {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text, #f4f4f5);
    font-size: 14px;
    resize: none;
    max-height: 120px;
    font-family: inherit;
    line-height: 1.4;
    padding: 4px 0;
}

/* ── Glassmorphic Dialog Modals & Backdrops ── */
dialog.chat-modal-dialog::backdrop {
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.chat-modal-dialog {
    position: fixed;
    inset: 0;
    margin: auto;
    background: var(--surface, #121214);
    border: 1px solid var(--border-gold, rgba(234, 179, 8, 0.35));
    border-radius: 16px;
    padding: 24px;
    width: 440px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    color: var(--text, #f4f4f5);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 20px rgba(234, 179, 8, 0.15);
    outline: none;
    z-index: 10000;
}

body.modal-open {
    overflow: hidden;
}

.chat-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.chat-modal-header h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text, #f4f4f5);
    margin: 0;
}

.chat-modal-input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}
.chat-modal-input-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary, #d4d4d8);
}
.chat-modal-input-group input {
    padding: 10px 14px;
    background: var(--bg, #09090b);
    border: 1px solid var(--border, rgba(255, 255, 255, 0.12));
    border-radius: var(--radius-md, 8px);
    color: var(--text, #f4f4f5);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
}
.chat-modal-input-group input:focus {
    border-color: var(--gold, #eab308);
}

.chat-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
}

/* ── Toast Notifications ─────────────────────── */
#pixelToastContainer {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.pixel-toast {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(18, 18, 20, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border, rgba(255, 255, 255, 0.1));
    border-radius: 12px;
    padding: 12px 18px;
    font-size: 13px;
    color: var(--text, #f4f4f5);
    box-shadow: 0 10px 32px rgba(0,0,0,0.5);
    transform: translateY(16px);
    opacity: 0;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
    pointer-events: auto;
    max-width: 360px;
}

.pixel-toast.visible {
    transform: translateY(0);
    opacity: 1;
}

.pixel-toast--success { border-color: #4ade80; }
.pixel-toast--success i { color: #4ade80; }
.pixel-toast--memory { border-color: color-mix(in srgb, var(--pixel-ambient-accent, #d4af37) 58%, rgba(255, 255, 255, .14)); background: linear-gradient(120deg, rgba(212, 175, 55, .12), rgba(18, 18, 20, .96) 72%); }
.pixel-toast--memory i { color: var(--pixel-ambient-accent, #e3c86f); }
.pixel-toast--error { border-color: var(--danger, #ef4444); }
.pixel-toast--error i { color: var(--danger, #ef4444); }
.pixel-toast--info i { color: var(--gold, #eab308); }

/* ── Reply Pulse Highlight Animation ──────── */
@keyframes pulseReplyHighlight {
    0% { background: rgba(234, 179, 8, 0.35); box-shadow: 0 0 0 rgba(234, 179, 8, 0); }
    50% { background: rgba(234, 179, 8, 0.5); box-shadow: 0 0 18px rgba(234, 179, 8, 0.4); }
    100% { background: transparent; box-shadow: 0 0 0 rgba(234, 179, 8, 0); }
}

.chat-msg-row.highlight-reply .chat-msg-bubble {
    animation: pulseReplyHighlight 1.5s ease-out;
}

/* ── Responsive Mobile Adjustments (WhatsApp-style) ── */
@media (max-width: 768px) {
    .user-chat-container {
        flex-direction: row;
        position: relative;
    }
    .user-chat-sidebar {
        width: 100%;
        height: 100%;
        display: flex;
    }
    .user-chat-main {
        display: none;
        width: 100%;
        height: 100%;
    }
    .user-chat-container.has-active-chat .user-chat-sidebar {
        display: none;
    }
    .user-chat-container.has-active-chat .user-chat-main {
        display: flex;
    }
    .user-chat-back-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    .user-chat-header {
        min-height: 60px;
        padding: 0 10px;
        gap: 6px;
    }
    .user-chat-header-avatar {
        width: 34px;
        height: 34px;
        flex-basis: 34px;
    }
    .user-chat-header-name { font-size: 14px; }
    .user-chat-header-actions { gap: 1px; }
    #userChatSearchWrap { width: min(150px, 28vw); }
    .chat-msg-row {
        max-width: 90%;
    }
}

@media (max-width: 840px) and (max-height: 520px) {
    .topbar {
        flex: 0 0 48px;
        height: 48px;
        min-height: 48px;
    }

    .composer-container {
        bottom: 6px;
        gap: 4px;
    }

    .composer-box {
        padding: 8px 10px;
        gap: 4px;
    }

    .composer-input-row textarea {
        max-height: 84px;
    }

    .composer-legal-hint {
        display: none;
    }

    .chat-container {
        padding-bottom: 116px;
    }

    .user-chat-header {
        min-height: 48px;
    }

    .user-chat-composer-wrap {
        padding: 8px 10px;
    }

    .user-chat-composer-box {
        gap: 8px;
        padding: 6px 10px;
    }

    .user-chat-composer-box textarea {
        max-height: 72px;
    }

}

/* -- Multi-Select Batch Bar & Checkboxes ------- */
.multi-select-bar {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(18, 18, 20, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-gold, rgba(234, 179, 8, 0.4));
    border-radius: 16px;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    z-index: 9999;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}

.multi-select-bar span {
    font-size: 13px;
    font-weight: 600;
    color: var(--gold, #eab308);
}

.chat-msg-checkbox {
    width: 18px;
    height: 18px;
    accent-color: var(--gold, #eab308);
    cursor: pointer;
    align-self: center;
}

.seen-by-label {
    font-size: 10px;
    color: var(--text-muted, #a1a1aa);
    margin-top: 2px;
}

/* ── Click-to-Open Action Menu ───────────────── */
.msg-action-menu {
    position: absolute;
    background: rgba(18, 18, 20, 0.97);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid color-mix(in srgb, var(--gold, #eab308) 30%, rgba(255, 255, 255, 0.1));
    border-radius: 12px;
    padding: 6px;
    display: flex;
    flex-direction: column;
    min-width: 160px;
    z-index: 50;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55), 0 0 1px rgba(234, 179, 8, 0.2);
    animation: menuFadeIn 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes menuFadeIn {
    from { opacity: 0; transform: scale(0.95) translateY(4px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.msg-action-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: transparent;
    border: none;
    color: var(--text, #f4f4f5);
    font-size: 13px;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.15s ease, color 0.15s ease;
    text-align: left;
    white-space: nowrap;
}
.msg-action-menu-item:hover {
    background: var(--surface-hover, rgba(255, 255, 255, 0.08));
    color: var(--gold, #eab308);
}
.msg-action-menu-item i {
    width: 16px;
    text-align: center;
    font-size: 12px;
    opacity: 0.7;
}
.msg-action-menu-item:hover i {
    opacity: 1;
}
.msg-action-menu-item.danger {
    color: var(--danger, #ef4444);
}
.msg-action-menu-item.danger:hover {
    background: rgba(239, 68, 68, 0.12);
    color: var(--danger, #ef4444);
}
.msg-action-menu-divider {
    height: 1px;
    background: var(--border, rgba(255, 255, 255, 0.08));
    margin: 4px 8px;
}

/* ── Reply Preview (in bubble) ───────────────── */
.chat-reply-preview {
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: rgba(255, 255, 255, 0.04);
    border-left: 3px solid var(--gold, #eab308);
    padding: 6px 10px;
    border-radius: 0 8px 8px 0;
    margin-bottom: 6px;
    max-width: 100%;
    cursor: pointer;
    transition: background 0.15s ease;
}
.chat-reply-preview:hover {
    background: rgba(255, 255, 255, 0.07);
}
.chat-reply-preview-author {
    font-size: 11px;
    font-weight: 700;
    color: var(--gold, #eab308);
    white-space: nowrap;
}
.chat-reply-preview-text {
    font-size: 12px;
    color: var(--text-secondary, #d4d4d8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

/* ── Reply-To Bar (in composer) ──────────────── */
.reply-to-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: var(--surface-raised, #18181b);
    border-left: 3px solid var(--gold, #eab308);
    border-top: 1px solid var(--border, rgba(255, 255, 255, 0.08));
}
.reply-to-bar .reply-to-text {
    flex: 1;
    font-size: 12px;
    color: var(--text-secondary, #d4d4d8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Empty State Screen ──────────────────────── */
.chat-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    flex: 1;
    gap: 16px;
    text-align: center;
    padding: 40px 24px;
}
.chat-empty-state-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--gold, #eab308) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--gold, #eab308) 25%, transparent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: var(--gold, #eab308);
    margin-bottom: 8px;
}
.chat-empty-state h2 {
    font-size: 22px;
    font-weight: 800;
    color: var(--text, #f4f4f5);
    letter-spacing: 1.5px;
    margin: 0;
}
.chat-empty-state p {
    font-size: 14px;
    color: var(--text-muted, #a1a1aa);
    max-width: 320px;
    line-height: 1.5;
    margin: 0;
}
.chat-empty-state .chat-action-btn {
    margin-top: 8px;
    padding: 10px 24px;
    font-size: 14px;
}

/* ── Inline Message Timestamp ────────────────── */
.chat-msg-bubble .msg-inline-time {
    float: right;
    font-size: 10px;
    color: var(--text-muted, #a1a1aa);
    margin-left: 12px;
    margin-top: 6px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    opacity: 0.8;
}
.chat-msg-row.mine .chat-msg-bubble .msg-inline-time {
    color: rgba(255, 255, 255, 0.55);
}

/* ── Pinned Messages Panel ───────────────────── */
.pinned-panel {
    max-height: 200px;
    overflow-y: auto;
    background: var(--surface-raised, #18181b);
    border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.08));
    padding: 10px 16px;
}
.pinned-panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text, #f4f4f5);
}
.pinned-msg-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s ease;
    font-size: 13px;
    color: var(--text-secondary, #d4d4d8);
}
.pinned-msg-item:hover {
    background: var(--surface-hover, rgba(255, 255, 255, 0.05));
}
.pinned-msg-item i {
    color: var(--gold, #eab308);
    font-size: 12px;
}

/* ── Typing Indicator ────────────────────────── */
.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 0;
}
.typing-indicator span {
    width: 6px;
    height: 6px;
    background: var(--text-muted, #a1a1aa);
    border-radius: 50%;
    animation: typingDot 1.4s infinite ease-in-out;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ── Topic Bar ───────────────────────────────── */
.user-chat-topic-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 20px;
    background: color-mix(in srgb, var(--gold, #eab308) 8%, var(--surface-raised, #18181b));
    border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.08));
    font-size: 13px;
    color: var(--text-secondary, #d4d4d8);
}

/* ── Composer Action Buttons ─────────────────── */
.composer-btn {
    background: transparent;
    border: none;
    color: var(--text-muted, #a1a1aa);
    font-size: 16px;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    transition: color 0.15s ease, background 0.15s ease;
    flex-shrink: 0;
}
.composer-btn:hover {
    color: var(--gold, #eab308);
    background: rgba(234, 179, 8, 0.1);
}

.action-circle-btn.send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #eab308, #ca8a04);
    color: #000;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 2px 8px rgba(234, 179, 8, 0.3);
}
.action-circle-btn.send-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 14px rgba(234, 179, 8, 0.45);
}

/* ── Floating Scroll-To-Bottom Button ────────── */
.chat-scroll-bottom-btn {
    position: absolute;
    bottom: 80px;
    right: 28px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--surface-raised, #18181b);
    border: 1px solid var(--border-gold, rgba(234, 179, 8, 0.4));
    color: var(--gold, #eab308);
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
    z-index: 25;
    transition: opacity 0.18s ease, transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
    animation: fadeInMsg 0.2s ease-out;
    touch-action: manipulation;
}
.chat-scroll-bottom-btn:hover {
    transform: translateY(-2px) scale(1.05);
    background: color-mix(in srgb, var(--gold, #eab308) 15%, var(--surface-raised, #18181b));
}
.chat-scroll-bottom-btn[hidden] { display: none; }
.chat-scroll-bottom-btn:focus-visible {
    outline: 2px solid var(--gold-light, #f3e5ab);
    outline-offset: 3px;
}
.ai-scroll-bottom-btn {
    right: auto;
    bottom: 146px;
    left: 50%;
    transform: translateX(-50%);
}
.ai-scroll-bottom-btn:hover {
    transform: translateX(-50%) translateY(-2px) scale(1.05);
}

.ai-scroll-bottom-btn {
    position: fixed;
    right: auto;
    bottom: auto;
    z-index: calc(var(--z-composer, 40) + 1);
}

.message.user .bubble {
    background: color-mix(in srgb, var(--surface-raised) 91%, var(--pixel-ambient-accent, var(--gold)) 9%);
    border-color: var(--border-strong);
}

.message.user:hover .bubble {
    border-color: color-mix(in srgb, var(--pixel-ambient-accent, var(--gold)) 28%, var(--border));
}

.message.ai .bubble {

    border-left-color: color-mix(in srgb, var(--pixel-ambient-accent, var(--gold)) 32%, transparent);
    border-radius: 2px var(--radius-sm) var(--radius-sm) 2px;
    padding-block: 10px;
}

/* ── Date Separator Badges ───────────────────── */
.chat-date-separator {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 16px auto;
    width: 100%;
}
.chat-date-separator span {
    background: var(--surface-raised, #18181b);
    border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
    color: var(--text-muted, #a1a1aa);
    font-size: 11px;
    font-weight: 600;
    padding: 3px 12px;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* ── Simple Emoji Picker Popup ───────────────── */
.emoji-picker-popup {
    position: absolute;
    bottom: 70px;
    right: 60px;
    background: rgba(18, 18, 20, 0.97);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-gold, rgba(234, 179, 8, 0.35));
    border-radius: 14px;
    padding: 10px;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    z-index: 50;
    animation: menuFadeIn 0.15s ease-out;
}
.emoji-picker-btn {
    background: transparent;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    transition: transform 0.12s ease, background 0.12s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}
.emoji-picker-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: scale(1.2);
}

@media (max-width: 840px) {
    .ai-scroll-bottom-btn { bottom: 136px; }
}

@media (max-width: 520px) {
    .ai-scroll-bottom-btn { bottom: 134px; }
}

@media (max-width: 840px) and (max-height: 520px) {
    .ai-scroll-bottom-btn { bottom: 112px; }
}

@media (hover: none) {
    .message-actions,
    .user-message-actions { opacity: 0.9; }

    .starter-card:hover { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .message,
    .starter-card,
    .chat-scroll-bottom-btn {
        animation: none;
        transition: none;
    }

    .chat-container { scroll-behavior: auto; }
}

/* Small, quiet metadata and safe embeds for assistant messages. */
.message-timestamp,
.response-model-meta {
    display: block;
    margin: 5px 2px 0;
    color: var(--text-muted, #a1a1aa);
    font-size: 11px;
    line-height: 1.4;
}

.response-model-meta { color: color-mix(in srgb, var(--gold, #d4af37) 68%, var(--text-muted, #a1a1aa)); }
.message.user .message-timestamp { text-align: right; }

.chat-edit-notice {
    min-height: 34px;
    padding: 6px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--gold, #d4af37);
    border-bottom: 1px solid var(--border, rgba(255,255,255,.08));
    font-size: 12px;
}
.chat-edit-notice[hidden] { display: none; }
.chat-edit-notice span { display: inline-flex; align-items: center; gap: 8px; }
.chat-edit-notice button {
    width: 28px;
    height: 28px;
    display: inline-grid;
    place-items: center;
    color: var(--text-muted, #a1a1aa);
    background: transparent;
    border: 0;
    cursor: pointer;
}
.chat-edit-notice button:hover { color: var(--text, #f4f4f5); }

.model-item.unavailable { opacity: .48; cursor: not-allowed; }
.model-item.unavailable:hover { background: transparent; }

.message-content img {
    max-width: min(100%, 720px);
    max-height: 70vh;
    border-radius: 6px;
    object-fit: contain;
}
.youtube-embed {
    width: min(100%, 720px);
    aspect-ratio: 16 / 9;
    margin-top: 12px;
    overflow: hidden;
    border: 1px solid var(--border, rgba(255,255,255,.08));
    border-radius: 8px;
    background: #000;
}
.youtube-embed iframe { width: 100%; height: 100%; display: block; border: 0; }

@media (max-width: 520px) {
    .message-timestamp, .response-model-meta { font-size: 10px; }
}

/* ======================================================================
   POLISHED SHELL + FIXED, SCROLLABLE SETTINGS
   ====================================================================== */
.sidebar {
    background: color-mix(in srgb, var(--surface) 96%, var(--pixel-ambient-accent, #d4af37) 4%);
    border-right-color: color-mix(in srgb, var(--border) 74%, transparent);
}

.sidebar-header {
    border-bottom-color: transparent;
}

.sidebar-actions {
    flex: 0 0 auto;
    gap: 3px;
    padding: 8px 12px 6px;
}

.sidebar-actions .new-chat-btn,
.sidebar-actions .creator-btn {
    min-height: 36px;
    padding: 0 11px;
    border: 1px solid transparent;
    border-radius: 9px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    box-shadow: none;
    transform: none;
}

.sidebar-actions .new-chat-btn:hover,
.sidebar-actions .creator-btn:hover {
    border-color: transparent;
    background: color-mix(in srgb, var(--pixel-ambient-accent, var(--gold)) 9%, var(--surface-hover));
    color: var(--text);
    box-shadow: none;
    transform: none;
}

.sidebar-actions .new-chat-btn i,
.sidebar-actions .creator-btn i,
.sidebar-actions .sidebar-footer-btn i {
    width: 17px;
    color: var(--text-muted);
    text-align: center;
    transition: color var(--ease), transform var(--ease);
}

.sidebar-actions .new-chat-btn:hover i,
.sidebar-actions .creator-btn:hover i,
.sidebar-actions .sidebar-footer-btn:hover i {
    color: var(--pixel-ambient-accent, var(--gold));
    transform: translateY(-1px);
}

.sidebar-actions .sidebar-footer-btn {
    width: 100%;
    min-height: 36px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 11px;
    border-radius: 9px;
    color: var(--text-secondary);
    font-size: 12px;
    text-align: left;
    transition: background var(--ease), color var(--ease);
}

.sidebar-actions .sidebar-footer-btn:hover,
.sidebar-actions .sidebar-footer-btn.is-active {
    background: var(--surface-hover);
    color: var(--text);
}

.sidebar-search {
    padding: 4px 12px 8px;
}

.sidebar-search-box {
    min-height: 34px;
    padding: 6px 10px;
    border-color: transparent;
    border-radius: 9px;
    background: color-mix(in srgb, var(--surface-raised) 90%, transparent);
}

.sidebar-search-box:focus-within {
    border-color: color-mix(in srgb, var(--pixel-ambient-accent, var(--gold)) 42%, transparent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--pixel-ambient-accent, var(--gold)) 9%, transparent);
}

.chat-history {
    min-height: 0;
    padding: 4px 10px 12px;
}

.history-title {
    padding: 8px 10px 5px;
    font-size: 10px;
    letter-spacing: .04em;
}

.conversation-item {
    min-height: 34px;
    padding: 7px 10px;
    border: 0;
    border-radius: 8px;
    font-size: 12px;
}

.conversation-item.active {
    background: color-mix(in srgb, var(--pixel-ambient-accent, var(--gold)) 10%, var(--surface-raised));
    color: var(--text);
    border: 0;
}

.sidebar-footer {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    flex: 0 0 auto;
    gap: 3px;
    padding: 8px 12px 10px;
    border-top-color: transparent;
}

.sidebar-footer-btn {
    min-height: 36px;
    padding: 0 11px;
    border-radius: 9px;
    font-size: 12px;
}

.sidebar-footer-btn i {
    width: 17px;
    color: var(--text-muted);
    text-align: center;
    transition: color var(--ease), transform var(--ease);
}

.sidebar-footer-btn:hover i,
.sidebar-footer-btn.is-active i {
    color: var(--pixel-ambient-accent, var(--gold));
    transform: translateY(-1px);
}

.sidebar-footer-btn.is-active {
    background: color-mix(in srgb, var(--pixel-ambient-accent, var(--gold)) 10%, var(--surface-raised));
    color: var(--text);
}

.profile-card {
    margin-top: 3px;
    padding-top: 6px;
    border-top-color: var(--border);
}

.profile-button {
    min-height: 42px;
    border: 1px solid transparent;
    background: transparent;
}

.profile-button:hover {
    border-color: transparent;
    background: var(--surface-hover);
}

.welcome-title {
    letter-spacing: -.035em;
}

.starter-card {
    min-height: 88px;
    padding: 14px;
    border-color: color-mix(in srgb, var(--border) 85%, transparent);
    border-radius: 10px;
    background: color-mix(in srgb, var(--surface-raised) 86%, transparent);
}

.starter-card:hover {
    border-color: color-mix(in srgb, var(--pixel-ambient-accent, var(--gold)) 38%, var(--border));
    background: color-mix(in srgb, var(--pixel-ambient-accent, var(--gold)) 5%, var(--surface-raised));
}

.starter-icon {
    transition: color var(--ease), background var(--ease), transform var(--ease);
}

.starter-card:hover .starter-icon {
    color: var(--pixel-ambient-accent, var(--gold));
    transform: translateY(-1px);
}

.topbar-btn,
.composer-btn,
.settings-tab,
.sidebar-close-btn,
.modal-close {
    transition: background var(--ease), color var(--ease), border-color var(--ease), transform var(--ease), box-shadow var(--ease);
}

.topbar-btn:hover,
.composer-btn:hover {
    color: var(--pixel-ambient-accent, var(--gold));
}

.app button:not(:disabled),
.settings-dialog button:not(:disabled) {
    transition: background-color var(--ease), color var(--ease), border-color var(--ease), box-shadow var(--ease), transform var(--ease);
}

.app button:not(:disabled):active,
.settings-dialog button:not(:disabled):active {
    transform: scale(.985);
}

.app button:focus-visible,
.settings-dialog button:focus-visible,
.app [role="button"]:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--pixel-ambient-accent, var(--gold)) 70%, white);
    outline-offset: 2px;
}

.composer-box {
    border-color: color-mix(in srgb, var(--pixel-ambient-accent, var(--gold)) 20%, var(--border));
}

.composer-box:focus-within {
    border-color: color-mix(in srgb, var(--pixel-ambient-accent, var(--gold)) 58%, var(--border));
    box-shadow: var(--shadow-lg), 0 0 0 3px color-mix(in srgb, var(--pixel-ambient-accent, var(--gold)) 10%, transparent);
}

.cursor-glow {
    z-index: 0;
    background: radial-gradient(circle, color-mix(in srgb, var(--pixel-ambient-accent, var(--gold)) 7%, transparent) 0%, transparent 70%);
}

body.pixel-cursor-glow-off .cursor-glow {
    display: none !important;
}

.settings-dialog {
    width: min(900px, calc(100vw - 40px));
    height: min(680px, calc(100dvh - 48px));
    max-height: calc(100dvh - 48px);
    border-radius: 18px;
    box-shadow: 0 28px 90px rgba(0, 0, 0, .58);
}

.dialog-header {
    flex: 0 0 56px;
    padding: 0 22px;
}

.settings-layout {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow: hidden;
}

.settings-nav {
    width: 200px;
    min-height: 0;
    padding: 16px 10px;
    overflow-y: auto;
    border-right-color: var(--border);
    background: color-mix(in srgb, var(--bg) 62%, var(--surface));
}

.settings-tab {
    min-height: 36px;
    flex: 0 0 auto;
    padding: 8px 10px;
    border: 1px solid transparent;
    border-radius: 9px;
}

.settings-tab.active {
    background: var(--surface-hover);
    color: var(--text);
}

.settings-tab.active i {
    color: var(--pixel-ambient-accent, var(--gold));
}

.settings-content {
    min-width: 0;
    min-height: 0;
    padding: 26px 28px;
    overscroll-behavior: contain;
}

.settings-page {
    gap: 22px;
}

.settings-section-header {
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.setting-row {
    min-height: 60px;
    padding: 10px 12px;
    border-color: transparent;
    border-radius: 9px !important;
    background: transparent;
}

.setting-row + .setting-row,
.setting-row + .setting-row-select {
    margin-top: 1px;
}

.setting-row:hover {
    border-color: transparent;
    background: var(--surface-raised);
}

.setting-row-select {
    min-height: 60px;
    border-color: transparent;
    border-radius: 9px;
    background: transparent;
}

.setting-icon-wrap {
    width: 30px;
    height: 30px;
    background: color-mix(in srgb, var(--surface-hover) 70%, transparent);
}

.settings-select-inline,
.settings-input {
    max-width: min(240px, 42%);
}

@media (max-width: 680px) {
    .settings-dialog {
        width: calc(100vw - 20px);
        height: min(760px, calc(100dvh - 20px));
        max-height: calc(100dvh - 20px);
        border-radius: 14px;
    }

    .settings-layout {
        flex-direction: column;
    }

    .settings-nav {
        width: 100%;
        min-height: 52px;
        flex: 0 0 auto;
        flex-direction: row;
        gap: 4px;
        padding: 8px 10px;
        overflow-x: auto;
        overflow-y: hidden;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .settings-tab {
        white-space: nowrap;
    }

    .settings-content {
        padding: 20px 16px;
    }
}

@media (max-height: 620px) and (min-width: 681px) {
    .settings-dialog {
        height: calc(100dvh - 24px);
        max-height: calc(100dvh - 24px);
    }
}

/* Pixel sidebar: restrained obsidian surfaces and meaningful gold states. */
.sidebar {
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, rgba(17, 18, 20, .80) 0%, rgba(10, 11, 13, .74) 48%, rgba(12, 13, 15, .82) 100%);
    -webkit-backdrop-filter: blur(22px) saturate(135%);
    backdrop-filter: blur(22px) saturate(135%);
    border-right: 1px solid rgba(255, 255, 255, .09);
    box-shadow: 8px 0 34px rgba(0, 0, 0, .2);
    overflow: hidden;
}

.sidebar-header {
    position: relative;
    flex: 0 0 var(--topbar-height);
    overflow: hidden;
    padding: 0 14px 0 16px;
    border-bottom: 1px solid rgba(255, 255, 255, .045);
    background: linear-gradient(110deg, rgba(212, 175, 55, .055), rgba(17, 18, 20, .24) 60%);
}

.sidebar-header::before {
    position: absolute;
    top: -48px;
    left: -38px;
    width: 150px;
    height: 110px;
    border-radius: 50%;
    background: radial-gradient(ellipse, rgba(212, 175, 55, .055), transparent 72%);
    content: "";
    pointer-events: none;
    animation: pixel-sidebar-header-glow 26s ease-in-out infinite alternate;
}

.sidebar-brand,
.sidebar-close-btn {
    position: relative;
    z-index: 1;
}

.sidebar-logo {
    width: 30px;
    height: 30px;
    filter: drop-shadow(0 2px 8px rgba(212, 175, 55, .08));
}

.sidebar-title {
    font-size: 16px;
    letter-spacing: -.025em;
}

.sidebar-version {
    padding: 2px 5px;
    border: 0;
    border-radius: 5px;
    background: rgba(212, 175, 55, .08);
    color: #d8bd69;
    font-size: 9px;
}

.sidebar-close-btn {
    width: 30px;
    height: 30px;
    border: 1px solid transparent;
    border-radius: 8px;
    transition: color 180ms ease, background-color 180ms ease, border-color 180ms ease, transform 180ms ease;
}

.sidebar-close-btn:hover {
    transform: translateX(-1px);
    border-color: rgba(255, 255, 255, .055);
    background: rgba(255, 255, 255, .045);
    color: #f3d76b;
}

.sidebar-actions {
    flex: 0 0 auto;
    gap: 3px;
    padding: 12px 12px 9px;
}

.sidebar-actions #newChatBtn {
    min-height: 40px;
    padding: 0 12px;
    border: 1px solid rgba(212, 175, 55, .20);
    border-radius: 10px;
    background: linear-gradient(120deg, rgba(212, 175, 55, .09), rgba(255, 255, 255, .025) 45%), #141518;
    color: #f1f0eb;
    font-size: 12px;
    font-weight: 600;
    box-shadow: inset 0 1px rgba(255, 255, 255, .035), 0 4px 14px rgba(0, 0, 0, .14);
    transition: background-color 190ms ease, border-color 190ms ease, box-shadow 190ms ease, color 190ms ease;
}

.sidebar-actions #newChatBtn i {
    color: #e1c25a;
    font-size: 12px;
}

.sidebar-actions #newChatBtn:hover {
    transform: none;
    border-color: rgba(212, 175, 55, .32);
    background: linear-gradient(120deg, rgba(212, 175, 55, .13), rgba(255, 255, 255, .04) 55%), #18191c;
    color: #fff;
    box-shadow: inset 0 1px rgba(255, 255, 255, .045), 0 5px 16px rgba(0, 0, 0, .2), 0 0 18px rgba(212, 175, 55, .045);
}

.sidebar-actions #newChatBtn:active {
    background: rgba(212, 175, 55, .15);
}

.sidebar-actions .new-chat-btn:not(#newChatBtn) {
    min-height: 36px;
    padding: 0 11px;
    border: 1px solid transparent;
    border-radius: 9px;
    background: transparent;
    color: #b7b7bd;
    font-size: 12px;
    font-weight: 500;
    box-shadow: none;
    transition: color 180ms ease, background-color 180ms ease, border-color 180ms ease;
}

.sidebar-actions .new-chat-btn:not(#newChatBtn) i {
    width: 17px;
    color: #85858c;
    font-size: 12px;
    text-align: center;
    transition: color 180ms ease;
}

.sidebar-actions .new-chat-btn:not(#newChatBtn):hover {
    transform: none;
    border-color: transparent;
    background: rgba(255, 255, 255, .045);
    color: #f0f0f2;
    box-shadow: inset 2px 0 rgba(212, 175, 55, .18);
}

.sidebar-actions .new-chat-btn:not(#newChatBtn):hover i {
    color: #d4af37;
}

.sidebar-actions .new-chat-btn.is-active {
    border-color: transparent;
    background: rgba(212, 175, 55, .085);
    color: #faf9f4;
    box-shadow: inset 2px 0 #d4af37;
}

.sidebar-actions .new-chat-btn.is-active i {
    color: #f3d76b;
}

.sidebar-actions .shortcut-key {
    border-color: rgba(255, 255, 255, .07);
    border-radius: 5px;
    background: rgba(255, 255, 255, .035);
    color: #85858c;
    font-size: 9px;
}

.sidebar-search {
    flex: 0 0 auto;
    padding: 3px 12px 9px;
}

.sidebar-search-box {
    min-height: 35px;
    gap: 9px;
    padding: 0 10px;
    border: 1px solid rgba(255, 255, 255, .055);
    border-radius: 9px;
    background: rgba(255, 255, 255, .027);
    transition: background-color 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.sidebar-search-box > i {
    color: #777880;
    font-size: 11px;
}

.sidebar-search-box input {
    min-width: 0;
    color: #eeedf0;
    font-size: 11px;
}

.sidebar-search-box input::placeholder {
    color: #73747b;
}

.sidebar-search-box:hover {
    background: rgba(255, 255, 255, .04);
}

.sidebar-search-box:focus-within {
    border-color: rgba(212, 175, 55, .38);
    background: rgba(18, 18, 19, .95);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, .07);
}

.chat-history {
    flex: 1 1 0;
    min-height: 0;
    padding: 3px 9px 12px;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, .11) transparent;
}

.history-group {
    margin-bottom: 12px;
}

.history-title {
    padding: 8px 10px 5px;
    color: #777880;
    font-size: 9px;
    font-weight: 650;
    letter-spacing: .12em;
}

.conversation-list {
    gap: 2px;
}

.conversation-item {
    min-width: 0;
    min-height: 33px;
    gap: 8px;
    padding: 6px 10px;
    border: 1px solid transparent;
    border-radius: 8px;
    color: #aaaab1;
    font-size: 11.5px;
    transition: background-color 170ms ease, color 170ms ease, border-color 170ms ease;
}

.conversation-item:hover {
    background: rgba(255, 255, 255, .04);
    color: #f0eff2;
}

.conversation-item.active {
    border-color: rgba(212, 175, 55, .09);
    background: rgba(212, 175, 55, .085);
    color: #f7f4e9;
    box-shadow: inset 2px 0 #d4af37;
    font-weight: 550;
}

.conversation-item .item-icon {
    width: 14px;
    color: #74757c;
    font-size: 10px;
    text-align: center;
}

.conversation-item.active .item-icon,
.conversation-item.pinned .item-icon {
    color: #e0c25c;
}

.chat-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-footer {
    position: relative;
    flex: 0 0 54px;
    height: 54px;
    box-sizing: border-box;
    margin-top: 0;
    gap: 3px;
    padding: 8px 12px 10px;
    border-top: 1px solid rgba(255, 255, 255, .055);
    background: linear-gradient(180deg, rgba(13, 14, 16, .96), #0b0c0e 34%);
}

.sidebar-footer > .sidebar-footer-btn,
.sidebar-footer > .profile-card {
    flex: 0 0 auto;
}

.sidebar-footer-btn {
    min-height: 36px;
    gap: 10px;
    padding: 0 11px;
    border: 1px solid transparent;
    border-radius: 9px;
    color: #b7b7bd;
    font-size: 12px;
    transition: color 180ms ease, background-color 180ms ease, border-color 180ms ease;
}

.sidebar-footer-btn i {
    width: 17px;
    color: #85858c;
    font-size: 12px;
    text-align: center;
    transition: color 180ms ease;
}

.sidebar-footer-btn:hover {
    background: rgba(255, 255, 255, .045);
    color: #f0eff2;
}

.sidebar-footer-btn:hover i {
    color: #d4af37;
    transform: none;
}

.sidebar-footer-btn.is-active {
    border-color: transparent;
    background: rgba(212, 175, 55, .085);
    color: #faf9f4;
    box-shadow: inset 2px 0 #d4af37;
}

.sidebar-footer-btn.is-active i {
    color: #f3d76b;
    transform: none;
}

.profile-card {
    position: relative;
    margin-top: 4px;
    padding: 7px 0 0;
    border-top: 1px solid rgba(255, 255, 255, .05);
}

.profile-button {
    min-width: 0;
    min-height: 44px;
    gap: 10px;
    padding: 5px 7px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    transition: background-color 180ms ease, border-color 180ms ease;
}

.profile-button:hover {
    border-color: rgba(255, 255, 255, .045);
    background: rgba(255, 255, 255, .04);
}

.profile-avatar {
    width: 32px;
    height: 32px;
    border: 1px solid rgba(212, 175, 55, .20);
    background: linear-gradient(145deg, rgba(212, 175, 55, .13), rgba(255, 255, 255, .04));
    color: #ecd477;
}

.profile-details {
    min-width: 0;
}

.profile-details strong,
.profile-details small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-details strong {
    color: #e4e3e7;
    font-size: 11px;
    font-weight: 600;
}

.profile-details small {
    color: #797a81;
    font-size: 9px;
}

.profile-menu-icon {
    flex: 0 0 auto;
    color: #777880;
    transition: color 180ms ease;
}

.account-menu[hidden] { display: none !important; }
.account-menu {
    position: fixed;
    z-index: 10000;
    right: auto;
    bottom: auto;
    display: grid;
    width: min(258px, calc(100vw - 24px));
    max-height: min(360px, calc(100vh - 24px));
    max-height: min(360px, calc(100dvh - 24px));
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    gap: 4px;
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 13px;
    background: rgba(24, 25, 28, .98);
    box-shadow: 0 16px 44px rgba(0, 0, 0, .48), 0 2px 8px rgba(0, 0, 0, .25);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
    transform-origin: bottom right;
    animation: account-menu-in 140ms ease-out;
}
.account-menu.is-below { transform-origin: top right; animation-name: account-menu-in-below; }
.account-menu-identity { display: grid; gap: 3px; padding: 9px 10px 10px; }
.account-menu-identity strong { overflow: hidden; color: #f1f0eb; font-size: 12px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.account-menu-identity small { overflow: hidden; color: #8e9098; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.account-menu-divider { height: 1px; margin: 2px 4px; background: rgba(255, 255, 255, .075); }
.account-menu-item { display: flex; min-height: 37px; align-items: center; gap: 11px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: #dedee3; font: inherit; font-size: 12px; text-align: left; cursor: pointer; }
.account-menu-item:hover, .account-menu-item:focus-visible { outline: none; background: rgba(255, 255, 255, .075); color: #fff; }
.account-menu-item i { width: 15px; color: #a7a8af; font-size: 12px; text-align: center; }
.account-menu-logout { color: #e7a49d; }
.account-menu-logout i { color: #df938a; }
.account-menu-logout:hover, .account-menu-logout:focus-visible { background: rgba(188, 83, 72, .14); color: #ffc0b9; }
@keyframes account-menu-in { from { opacity: 0; transform: translateY(4px) scale(.985); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes account-menu-in-below { from { opacity: 0; transform: translateY(-4px) scale(.985); } to { opacity: 1; transform: translateY(0) scale(1); } }

.profile-button:hover .profile-menu-icon {
    color: #d4af37;
}

.sidebar :is(button, input):focus-visible {
    outline: 2px solid rgba(243, 215, 107, .78);
    outline-offset: 2px;
}

body.light-mode .sidebar {
    background: linear-gradient(180deg, rgba(255, 255, 255, .84), rgba(249, 248, 245, .78) 55%, rgba(247, 246, 242, .84));
    -webkit-backdrop-filter: blur(22px) saturate(125%);
    backdrop-filter: blur(22px) saturate(125%);
    border-right-color: rgba(24, 25, 28, .08);
}

body.light-mode .sidebar-header {
    border-bottom-color: rgba(24, 25, 28, .055);
    background: linear-gradient(110deg, rgba(212, 175, 55, .045), transparent 60%);
}

body.light-mode .sidebar-title { color: #211f1a; }
body.light-mode .sidebar-close-btn { color: #72747b; }
body.light-mode .sidebar-close-btn:hover { background: rgba(24, 25, 28, .055); color: #8f7420; }

body.light-mode .sidebar-actions #newChatBtn {
    border-color: rgba(143, 116, 32, .24);
    background: linear-gradient(120deg, rgba(212, 175, 55, .10), rgba(255, 255, 255, .65) 50%), #f1efe8;
    color: #28251d;
    box-shadow: inset 0 1px rgba(255, 255, 255, .7), 0 3px 10px rgba(42, 35, 16, .06);
}

body.light-mode .sidebar-actions #newChatBtn i { color: #8f7420; }
body.light-mode .sidebar-actions .new-chat-btn:not(#newChatBtn) { color: #4a4d55; }
body.light-mode .sidebar-actions .new-chat-btn:not(#newChatBtn) i { color: #777a81; }
body.light-mode .sidebar-actions .new-chat-btn:not(#newChatBtn):hover { background: rgba(24, 25, 28, .045); color: #202126; }
body.light-mode .sidebar-actions .new-chat-btn.is-active { background: rgba(212, 175, 55, .12); color: #28251d; }
body.light-mode .sidebar-actions .shortcut-key { border-color: rgba(24, 25, 28, .09); background: rgba(24, 25, 28, .035); color: #6d6e74; }

body.light-mode .sidebar-search-box {
    border-color: rgba(24, 25, 28, .075);
    background: rgba(24, 25, 28, .035);
}

body.light-mode .sidebar-search-box > i,
body.light-mode .sidebar-search-box input::placeholder { color: #747680; }
body.light-mode .sidebar-search-box input { color: #24252a; }
body.light-mode .sidebar-search-box:focus-within { background: #fff; }
body.light-mode .history-title { color: #73757d; }
body.light-mode .conversation-item { color: #4b4d54; }
body.light-mode .conversation-item:hover { background: rgba(24, 25, 28, .045); color: #202126; }
body.light-mode .conversation-item.active { border-color: rgba(143, 116, 32, .13); background: rgba(212, 175, 55, .12); color: #29261e; }
body.light-mode .conversation-item .item-icon { color: #777981; }
body.light-mode .conversation-item.active .item-icon,
body.light-mode .conversation-item.pinned .item-icon { color: #8f7420; }

body.light-mode .sidebar-footer {
    border-top-color: rgba(24, 25, 28, .07);
    background: linear-gradient(180deg, rgba(250, 249, 246, .96), #f7f6f2 34%);
}

body.light-mode #sidebar .sidebar-footer,
body.light-mode #sidebar > .profile-card {
    background: rgba(250, 249, 246, .76);
    -webkit-backdrop-filter: blur(18px) saturate(125%);
    backdrop-filter: blur(18px) saturate(125%);
}

body.light-mode .sidebar-footer-btn { color: #4b4d54; }
body.light-mode .sidebar-footer-btn i { color: #777981; }
body.light-mode .sidebar-footer-btn:hover { background: rgba(24, 25, 28, .045); color: #202126; }
body.light-mode .sidebar-footer-btn.is-active { background: rgba(212, 175, 55, .12); color: #29261e; }
body.light-mode .profile-card { border-top-color: rgba(24, 25, 28, .065); }
body.light-mode .profile-button:hover { border-color: rgba(24, 25, 28, .045); background: rgba(24, 25, 28, .04); }
body.light-mode .profile-details strong { color: #292a2f; }
body.light-mode .profile-details small,
body.light-mode .profile-menu-icon { color: #72747b; }

@keyframes pixel-sidebar-header-glow {
    from { opacity: .62; transform: translate3d(0, 0, 0); }
    to { opacity: .92; transform: translate3d(14px, 5px, 0); }
}

@media (prefers-reduced-motion: reduce) {
    .sidebar-header::before { animation: none; }
    .sidebar :is(button, input) { transition-duration: .01ms; }
    .account-menu, .account-menu.is-below { animation: none; }
}

@media (max-height: 680px) {
    .sidebar-actions { gap: 1px; padding-block: 7px 5px; }
    .sidebar-actions #newChatBtn { min-height: 36px; }
    .sidebar-actions .new-chat-btn:not(#newChatBtn) { min-height: 32px; }
    .sidebar-search { padding-bottom: 5px; }
    .chat-history { padding-bottom: 8px; }
    .sidebar-footer { flex-basis: 132px; height: 132px; padding-block: 5px 7px; }
    .sidebar-footer-btn { min-height: 32px; }
    .profile-card { margin-top: 2px; padding-top: 4px; }
    .profile-button { min-height: 38px; }
    .profile-avatar { width: 28px; height: 28px; }
}

/* Keep footer controls above the independently scrolling history region. */
#sidebar .sidebar-footer {
    position: relative !important;
    z-index: 3 !important;
    flex: 0 0 auto;
    height: auto;
    padding: 8px 12px 10px;
    border-top: 1px solid rgba(255, 255, 255, .055);
    background: rgba(12, 13, 15, .72);
    -webkit-backdrop-filter: blur(18px) saturate(135%);
    backdrop-filter: blur(18px) saturate(135%);
}

#sidebar .chat-history {
    position: relative;
    z-index: 1;
    flex: 1 1 0;
    min-height: 0;
    padding-bottom: 12px;
}

#sidebar > .profile-card {
    position: relative;
    z-index: 3;
    flex: 0 0 auto;
    margin: 0;
    padding: 8px 12px 10px;
    border-top: 1px solid rgba(255, 255, 255, .055);
    background: rgba(12, 13, 15, .72);
    -webkit-backdrop-filter: blur(18px) saturate(135%);
    backdrop-filter: blur(18px) saturate(135%);
}

body.light-mode #sidebar > .profile-card {
    border-top-color: rgba(24, 25, 28, .065);
}

@media (max-height: 680px) {
    #sidebar .sidebar-footer { padding-block: 5px 7px; }
    #sidebar > .profile-card { padding-block: 5px 7px; }
}

/* Refined, single-row Pixel composer with contextual model controls. */
.composer-box {
    position: relative;
    gap: 10px;
}

.composer-toolbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 10px;
    padding-top: 0;
}

.composer-toolbar-left {
    flex: 0 0 auto;
    gap: 4px;
}

.composer-input-row {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
}

.composer-input-row textarea {
    display: block;
    width: 100%;
    min-width: 0;
    min-height: 40px;
    max-height: 200px;
    padding: 8px 2px;
    overflow-y: auto;
    line-height: 1.5;
}

.composer-toolbar-right {
    flex: 0 0 auto;
    gap: 6px;
}

.composer-btn {
    width: 38px;
    height: 40px;
    border-radius: 12px;
}

.composer-btn:hover {
    background: color-mix(in srgb, var(--pixel-ambient-accent, var(--gold)) 10%, transparent);
}

.model-button {
    min-height: 36px;
    max-width: 190px;
    gap: 7px;
    padding: 5px 9px;
    border-color: transparent;
    background: transparent;
    color: var(--text-secondary);
}

.model-button:hover,
.model-button[aria-expanded="true"] {
    border-color: color-mix(in srgb, var(--pixel-ambient-accent, var(--gold)) 24%, transparent);
    background: color-mix(in srgb, var(--pixel-ambient-accent, var(--gold)) 9%, transparent);
    color: var(--text);
}

body.light-mode .model-button {
    border-color: transparent;
    background: transparent;
    color: var(--text-secondary);
}

body.light-mode .model-button:hover,
body.light-mode .model-button[aria-expanded="true"] {
    border-color: color-mix(in srgb, var(--pixel-ambient-accent, var(--gold)) 28%, transparent);
    background: color-mix(in srgb, var(--pixel-ambient-accent, var(--gold)) 9%, transparent);
    color: var(--text);
}

.model-btn-name {
    max-width: clamp(46px, 13vw, 112px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.model-menu {
    right: 0;
    left: auto;
    width: min(340px, calc(100vw - 32px));
}

.attachment-container {
    max-height: min(224px, 28vh);
    overflow: auto;
    overscroll-behavior: contain;
    padding: 2px 1px 4px;
}

.attachment-card {
    position: relative;
    min-width: 0;
    max-width: min(270px, 100%);
    gap: 9px;
    padding: 7px 9px;
    border-color: color-mix(in srgb, var(--border) 72%, var(--pixel-ambient-accent, var(--gold)));
    border-radius: 12px;
    background: color-mix(in srgb, var(--surface-raised) 84%, transparent);
}

.attachment-left {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 9px;
}

.attachment-preview {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
}

.attachment-thumb {
    display: block;
    width: 44px;
    height: 44px;
    border-radius: 8px;
}

.attachment-file-icon {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border: 1px solid color-mix(in srgb, var(--pixel-ambient-accent, var(--gold)) 22%, transparent);
    border-radius: 10px;
    background: color-mix(in srgb, var(--pixel-ambient-accent, var(--gold)) 9%, transparent);
    color: var(--pixel-ambient-accent, var(--gold));
    font-size: 15px;
}

.attachment-info {
    min-width: 0;
}

.attachment-name {
    max-width: 180px;
    font-size: 12px;
}

.attachment-size {
    margin-top: 3px;
}

.attachment-card.has-image-preview {
    width: min(148px, calc(50% - 5px));
    max-width: 148px;
    flex: 0 0 auto;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 6px;
}

.has-image-preview .attachment-left {
    display: block;
}

.has-image-preview .attachment-preview,
.has-image-preview .attachment-thumb {
    width: 100%;
}

.has-image-preview .attachment-thumb {
    height: 88px;
    border-radius: 8px;
}

.has-image-preview .attachment-info {
    padding: 0 2px 1px;
}

.has-image-preview .attachment-name {
    max-width: 100%;
}

.has-image-preview .remove-file {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 25px;
    height: 25px;
    border: 1px solid rgba(255, 255, 255, .2);
    border-radius: 50%;
    background: rgba(12, 13, 15, .8);
    color: #fff;
    backdrop-filter: blur(10px);
}

.remove-file {
    display: grid;
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    place-items: center;
    border: 0;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
}

.remove-file:hover {
    background: color-mix(in srgb, var(--danger) 12%, transparent);
}

.composer-drop-overlay[hidden] {
    display: none;
}

.composer-drop-overlay {
    position: absolute;
    z-index: 5;
    inset: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    border: 1px dashed color-mix(in srgb, var(--pixel-ambient-accent, var(--gold)) 72%, white);
    border-radius: calc(var(--radius-lg) - 4px);
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--pixel-ambient-accent, var(--gold)) 12%, transparent), 0 0 30px color-mix(in srgb, var(--pixel-ambient-accent, var(--gold)) 10%, transparent);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    pointer-events: none;
    animation: composer-drop-in 150ms ease-out both;
}

.composer-box.is-file-dragover {
    border-color: var(--pixel-ambient-accent, var(--gold));
    box-shadow: var(--shadow-lg), 0 0 0 3px color-mix(in srgb, var(--pixel-ambient-accent, var(--gold)) 14%, transparent);
}

.composer-drop-icon {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border-radius: 13px;
    background: color-mix(in srgb, var(--pixel-ambient-accent, var(--gold)) 14%, transparent);
    color: var(--pixel-ambient-accent, var(--gold));
    font-size: 17px;
}

.composer-drop-copy {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.composer-drop-copy strong {
    color: var(--text);
    font-size: 13px;
    font-weight: 650;
}

.composer-drop-copy small {
    color: var(--text-muted);
    font-size: 11px;
}

@keyframes composer-drop-in {
    from { opacity: 0; transform: translateY(3px) scale(.99); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 560px) {
    .composer-box { padding: 9px 10px; }
    .composer-toolbar { gap: 5px; }
    .composer-toolbar-right { gap: 2px; }
    .composer-btn { width: 34px; height: 38px; }
    .model-button { gap: 5px; padding-inline: 5px; }
    .model-menu { right: -40px; }
    .attachment-card.has-image-preview { width: min(136px, calc(50% - 5px)); }
}

.composer-box:focus-within {
    outline: 1px solid color-mix(in srgb, var(--gold) 72%, white);
    outline-offset: 1px;
}

.composer-box {
    gap: 8px;
    padding: 8px 14px;
}

.composer-input-row textarea {
    min-height: 36px;
    padding-block: 6px;
}

.composer-btn {
    width: 36px;
    height: 36px;
}

@media (max-width: 560px) {
    .composer-box { padding: 7px 10px; }
    .composer-btn { width: 32px; height: 34px; }
}

.attachment-container:empty {
    display: none !important;
    margin: 0;
    padding: 0;
}

.composer-box {
    border-radius: 28px;
}

#atmosphereCustomColor {
    width: 56px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 28px;
    overflow: hidden;
    background: transparent;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
}

#atmosphereCustomColor::-webkit-color-swatch-wrapper {
    padding: 0;
    border-radius: 28px;
}

#atmosphereCustomColor::-webkit-color-swatch,
#atmosphereCustomColor::-moz-color-swatch {
    border: 0;
    border-radius: 28px;
}
