
        :root {
            --bg-primary: #212121;
            --bg-secondary: #171717;
            --bg-tertiary: #0d0d0d;
            --bg-card: #2f2f2f;
            --bg-card-hover: #373737;
            --bg-elevated: #303030;
            --bg-input: #2f2f2f;
            --bg-border: rgba(255, 255, 255, 0.08);

            --accent: #1e90ff;
            --accent-hover: #3aa0ff;
            --accent-dark: #0070dd;
            --accent-glow: rgba(30, 144, 255, 0.15);

            --primary: #ffffff;
            --primary-hover: #f3f3f3;
            --primary-glow: rgba(255, 255, 255, 0.12);
            
            /* Status Colors */
            --success: #10b981;
            --warning: #f59e0b;
            --danger: #ef4444;
            --danger-light: #fca5a5;
            --info: #1e90ff;
            
            /* Text Colors */
            --text-primary: #ececec;
            --text-secondary: rgba(255, 255, 255, 0.65);
            --text-muted: rgba(255, 255, 255, 0.40);
            --text-lead: #f3f7ff;
            --text-subtle: #c9d0dc;
            --text-blockquote: #c4d6f0;
            
            /* Gray Scale */
            --gray-400: #4a4a4a;
            --gray-500: #5a5a5a;
            
            /* Layout */
            --header-height: 58px;
            --radius-sm: 0.375rem;
            --radius-md: 0.5rem;
            --radius-lg: 1rem;
        }

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

        html,
        body {
            height: 100%;
        }

        body {
            font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
            background-color: var(--bg-primary);
            color: var(--text-primary);
            min-height: 100vh;
            line-height: 1.6;
            overflow: hidden;
        }

        .logo {
            display: flex;
            align-items: center;
            gap: 0.625rem;
            font-size: 1.25rem;
            font-weight: 600;
            color: var(--text-primary);
            text-decoration: none;
            letter-spacing: -0.01em;
        }

        .logo-icon {
            width: 32px;
            height: 32px;
            background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
            border-radius: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 700;
            font-size: 0.875rem;
            color: white;
            box-shadow: 0 4px 12px rgba(30, 144, 255, 0.25);
        }

        .logo-text {
            color: var(--text-primary);
            font-weight: 600;
        }

        .user-controls {
            display: none;
            align-items: center;
            gap: 0.75rem;
        }

        .user-controls.visible {
            display: flex;
        }

        .user-badge {
            padding: 0.5rem 1rem;
            border-radius: 8px;
            background: rgba(255, 255, 255, 0.05);
            color: var(--text-primary);
            font-size: 0.875rem;
            line-height: 1;
            font-weight: 500;
            border: 1px solid rgba(255, 255, 255, 0.08);
            transition: all 0.2s ease;
        }

        .user-badge:hover {
            background: rgba(255, 255, 255, 0.08);
            border-color: rgba(255, 255, 255, 0.12);
        }

        .logout-btn {
            appearance: none;
            border: 1px solid rgba(255, 255, 255, 0.1);
            background: transparent;
            color: var(--text-secondary);
            border-radius: 8px;
            padding: 0.5rem 1rem;
            cursor: pointer;
            line-height: 1;
            font-weight: 500;
            font-size: 0.875rem;
            transition: all 0.2s ease;
        }

        .logout-btn:hover {
            background: rgba(239, 68, 68, 0.1);
            border-color: rgba(239, 68, 68, 0.2);
            color: var(--danger-light);
        }

        body.auth-locked .nav-tabs-custom {
            display: none;
        }

        .auth-screen {
            min-height: 100vh;
            display: none;
            align-items: center;
            justify-content: center;
            padding: 2rem 1.25rem;
        }

        .auth-screen.visible {
            display: flex;
        }

        .auth-card {
            width: min(440px, 100%);
            background: var(--bg-card);
            border: 1px solid rgba(255, 255, 255, 0.07);
            border-radius: 1.25rem;
            padding: 1.5rem;
            box-shadow: 0 28px 80px rgba(0, 0, 0, 0.3);
        }

        .auth-title {
            font-size: 1.75rem;
            font-weight: 600;
            margin-bottom: 0.3rem;
        }

        .auth-subtitle {
            color: var(--text-secondary);
            margin-bottom: 1.25rem;
        }

        .auth-switcher {
            display: inline-flex;
            gap: 0.35rem;
            padding: 0.25rem;
            border-radius: 999px;
            background: rgba(255, 255, 255, 0.05);
            margin-bottom: 1.25rem;
        }

        .auth-switch-btn {
            appearance: none;
            border: none;
            background: transparent;
            color: var(--text-secondary);
            padding: 0.58rem 1rem;
            border-radius: 999px;
            cursor: pointer;
        }

        .auth-switch-btn.active {
            background: rgba(255, 255, 255, 0.09);
            color: var(--text-primary);
        }

        .auth-form {
            display: none;
        }

        .auth-form.active {
            display: block;
        }

        .auth-field {
            margin-bottom: 1rem;
        }

        .auth-label {
            display: block;
            margin-bottom: 0.45rem;
            color: var(--text-secondary);
            font-size: 0.92rem;
        }

        .auth-input {
            width: 100%;
            border: 1px solid rgba(255, 255, 255, 0.1);
            background: rgba(255, 255, 255, 0.04);
            color: var(--text-primary);
            border-radius: 0.9rem;
            padding: 0.82rem 0.95rem;
            outline: none;
        }

        .auth-input:focus {
            border-color: rgba(255, 255, 255, 0.22);
        }

        .auth-submit {
            width: 100%;
            appearance: none;
            border: none;
            background: var(--accent);
            color: var(--primary);
            border-radius: 0.95rem;
            padding: 0.88rem 1rem;
            font-weight: 600;
            cursor: pointer;
            transition: background 0.15s ease;
        }

        .auth-submit:hover {
            background: var(--accent-hover);
        }

        .auth-submit:disabled {
            opacity: 0.7;
            cursor: default;
        }

        .auth-error {
            min-height: 1.4rem;
            margin-bottom: 0.9rem;
            color: var(--danger-light);
            font-size: 0.92rem;
        }

        .nav-tab {
            padding: 0.5rem 1rem;
            border-radius: 8px;
            background: transparent;
            border: none;
            color: var(--text-secondary);
            font-weight: 500;
            font-size: 0.875rem;
            cursor: pointer;
            transition: all 0.2s ease;
            text-decoration: none;
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }

        .nav-tab:hover {
            color: var(--text-primary);
            background-color: rgba(255, 255, 255, 0.06);
        }

        .nav-tab.active {
            background: rgba(255, 255, 255, 0.1);
            color: var(--text-primary);
        }

        .nav-tab.disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }

        /* Main Content */
        .main-content {
            height: 100vh;
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }

        .tab-content {
            flex: 1;
            display: none;
            min-height: 0;
            overflow: hidden;
        }

        .tab-content.active {
            display: flex;
            flex-direction: column;
            min-height: 0;
        }

        .mobile-topbar {
            display: none;
        }

        .mobile-menu-overlay {
            display: none;
        }

        .home-layout {
            display: flex;
            height: 100%;
            min-height: 0;
            overflow: hidden;
        }

        .chat-sidebar {
            width: 280px;
            border-right: 1px solid rgba(255, 255, 255, 0.06);
            background: var(--bg-secondary);
            padding: 1rem 0.8rem;
            display: flex;
            flex-direction: column;
            gap: 0.9rem;
            overflow: hidden;
        }

        .chat-sidebar-top {
            flex: 1;
            min-height: 0;
            display: flex;
            flex-direction: column;
            gap: 0.9rem;
        }

        .sidebar-brand {
            display: inline-flex;
            align-items: center;
            gap: 0.625rem;
            color: var(--text-primary);
            text-decoration: none;
            padding: 0.2rem 0.2rem 0.45rem;
            font-size: 1.1rem;
            font-weight: 700;
            letter-spacing: -0.01em;
        }

        .mobile-topbar-brand {
            padding: 0;
            flex-shrink: 0;
        }

        .sidebar-new-chat {
            appearance: none;
            width: 100%;
            border: 1px solid rgba(255, 255, 255, 0.1);
            background: rgba(255, 255, 255, 0.04);
            color: var(--text-primary);
            border-radius: 0.9rem;
            padding: 0.75rem 0.9rem;
            text-align: left;
            display: flex;
            align-items: center;
            gap: 0.65rem;
            cursor: pointer;
        }

        .sidebar-new-chat:hover {
            background: rgba(255, 255, 255, 0.08);
        }

        .chat-history {
            display: flex;
            flex-direction: column;
            gap: 0.35rem;
            overflow-y: auto;
            min-height: 0;
        }

        .chat-history-item {
            width: 100%;
            border-radius: 0.85rem;
            padding: 0.75rem 0.85rem;
            display: flex;
            align-items: flex-start;
            justify-content: space-between;
            gap: 0.75rem;
            color: var(--text-secondary);
        }

        .chat-history-item:hover {
            background: rgba(255, 255, 255, 0.05);
            color: var(--text-primary);
        }

        .chat-history-item.active {
            background: rgba(255, 255, 255, 0.08);
            color: var(--text-primary);
        }

        .chat-history-title {
            font-size: 0.9rem;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .chat-history-main {
            min-width: 0;
            flex: 1;
            display: flex;
            flex-direction: column;
            gap: 0.22rem;
        }

        .chat-history-open {
            appearance: none;
            border: none;
            background: transparent;
            color: inherit;
            text-align: left;
            padding: 0;
            cursor: pointer;
            width: 100%;
        }

        .chat-history-meta {
            font-size: 0.75rem;
            color: var(--text-muted);
        }

        .chat-history-actions {
            display: inline-flex;
            align-items: center;
            gap: 0.25rem;
            flex-shrink: 0;
        }

        .chat-history-action {
            appearance: none;
            border: none;
            background: transparent;
            color: var(--text-muted);
            width: 24px;
            height: 24px;
            border-radius: 999px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
        }

        .chat-history-action:hover {
            background: rgba(255, 255, 255, 0.08);
            color: var(--text-primary);
        }

        .mobile-topbar-actions {
            display: inline-flex;
            align-items: center;
            gap: 0.55rem;
        }

        .mobile-topbar-btn {
            appearance: none;
            border: 1px solid rgba(255, 255, 255, 0.12);
            background: rgba(255, 255, 255, 0.06);
            color: var(--text-primary);
            width: 42px;
            height: 42px;
            border-radius: 0.9rem;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
        }

        .mobile-topbar-btn:hover {
            background: rgba(255, 255, 255, 0.12);
            border-color: rgba(255, 255, 255, 0.18);
            transform: translateY(-1px);
        }

        .mobile-topbar-btn.active {
            background: rgba(30, 144, 255, 0.18);
            border-color: rgba(30, 144, 255, 0.42);
            color: #ffffff;
        }

        .chat-sidebar-empty {
            color: var(--text-muted);
            font-size: 0.84rem;
            padding: 0.5rem 0.25rem;
        }

        .chat-sidebar-profile {
            display: none;
            flex-direction: column;
            gap: 0.5rem;
            margin-top: auto;
            padding-top: 0.85rem;
            border-top: 1px solid rgba(255, 255, 255, 0.08);
        }

        .chat-sidebar-profile.visible {
            display: flex;
        }

        .chat-sidebar-profile .user-badge {
            width: 100%;
            justify-content: flex-start;
            text-align: left;
            background: rgba(255, 255, 255, 0.06);
        }

        .chat-main {
            flex: 1;
            min-width: 0;
            display: flex;
            flex-direction: column;
            min-height: 0;
            overflow: hidden;
        }

        /* Chat Container */
        .chat-container {
            flex: 1;
            display: flex;
            flex-direction: column;
            padding: 0;
            gap: 0;
            max-width: 100%;
            margin: 0 auto;
            width: 100%;
            min-height: 0;
            overflow: hidden;
        }

        .chat-messages {
            flex: 1;
            background-color: transparent;
            border-radius: 0;
            border: none;
            padding: 2rem 0 8rem;
            overflow-y: auto;
            min-height: 0;
            max-height: none;
        }

        .message-main {
            display: flex;
            flex-direction: column;
            gap: 0.5rem;
            width: min(100%, 768px);
        }

        .message.user .message-main {
            align-items: flex-end;
        }

        .message.ai .message-main {
            align-items: flex-start;
        }

        .message.ai.rtl .message-main {
            align-items: flex-end;
        }

        .message.ai.rtl .message-content {
            direction: rtl;
            text-align: right;
        }

        .message.ai.rtl .message-content ul,
        .message.ai.rtl .message-content ol {
            padding-left: 0;
            padding-right: 1.4rem;
        }

        .message.ai.rtl .message-content blockquote {
            border-left: none;
            border-right: 3px solid rgba(30, 144, 255, 0.6);
            padding: 0.2rem 1rem 0.2rem 0;
            background: linear-gradient(270deg, rgba(30, 144, 255, 0.08), transparent 80%);
            border-radius: 0.6rem 0 0 0.6rem;
        }

        .show-more-button {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 0.5rem;
            padding: 0.75rem 1.5rem;
            margin: 0.5rem auto;
            background: var(--accent);
            color: var(--primary);
            border-radius: 0.8rem;
            font-weight: 600;
            cursor: pointer;
            transition: background 0.18s ease, transform 0.18s ease;
            font-size: 0.9rem;
            width: fit-content;
            max-width: 90%;
        }

        .show-more-button:hover {
            background: var(--accent-hover);
            transform: translateY(-1px);
        }

        .show-more-button:active {
            transform: translateY(0);
        }

        .message {
            width: min(100%, 860px);
            margin: 0 auto 1.5rem;
            display: flex;
            gap: 0.75rem;
            padding: 0 1.25rem;
        }

        .message.user {
            flex-direction: row-reverse;
            justify-content: flex-start;
        }

        .message-avatar {
            width: 28px;
            height: 28px;
            border-radius: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 0.9rem;
            flex-shrink: 0;
            margin-top: 0.15rem;
        }

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

        .message.ai .message-avatar {
            background-color: transparent;
            color: var(--text-secondary);
        }

        .message-content {
            background-color: transparent;
            padding: 0.15rem 0;
            border-radius: 0;
            border: none;
            word-wrap: break-word;
            width: 100%;
            font-size: 0.95rem;
            line-height: 1.7;
        }

        .message.user .message-content {
            background-color: var(--bg-card);
            color: var(--text-primary);
            width: auto;
            max-width: min(100%, 70%);
            padding: 0.65rem 1rem;
            border-radius: 1.25rem;
            border: none;
            margin-left: auto;
            font-size: 0.95rem;
            line-height: 1.6;
        }

        /* Message Action Bar */
        .message-actions-bar {
            display: flex;
            align-items: center;
            gap: 0.25rem;
            margin-top: 0.35rem;
            opacity: 1;
        }

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

        .msg-action-btn {
            appearance: none;
            border: none;
            background: transparent;
            color: var(--text-muted);
            width: 28px;
            height: 28px;
            border-radius: 0.35rem;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            font-size: 0.78rem;
            transition: all 0.15s ease;
            padding: 0;
        }

        .msg-action-btn:hover {
            color: var(--accent);
            background: var(--accent-glow);
        }

        .msg-action-btn.copied {
            color: var(--success);
        }

        .generation-status-card {
            width: min(100%, 520px);
            display: flex;
            align-items: flex-start;
            gap: 0.9rem;
            padding: 1rem 1.05rem;
            border-radius: 0.5rem;
            border: 1px solid var(--bg-border);
            background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.02));
        }

        .generation-status-logo {
            width: 38px;
            height: 38px;
            border-radius: 0.85rem;
            border: 1px solid rgba(255, 255, 255, 0.08);
            background: rgba(255, 255, 255, 0.04);
            display: inline-flex;
            align-items: center;
            justify-content: center;
            overflow: hidden;
            flex-shrink: 0;
            color: var(--text-secondary);
        }

        .generation-status-logo img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            display: block;
        }

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

        .generation-status-title {
            font-size: 0.98rem;
            font-weight: 600;
            color: var(--text-primary);
            margin-bottom: 0.15rem;
        }

        .generation-status-subtitle {
            font-size: 0.86rem;
            color: var(--text-secondary);
            line-height: 1.45;
        }

        .generation-status-progress {
            margin-top: 12px;
        }

        .generation-status-progress-bar {
            width: 100%;
            height: 6px;
            background-color: rgba(255, 255, 255, 0.08);
            border-radius: 3px;
            overflow: hidden;
            margin-bottom: 6px;
        }

        .generation-status-progress-fill {
            height: 100%;
            background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
            border-radius: 3px;
            width: 0%;
            transition: width 0.1s linear;
            box-shadow: 0 0 10px rgba(30, 144, 255, 0.4);
        }

        .generation-status-progress-text {
            font-size: 0.82rem;
            color: var(--text-secondary);
            font-weight: 400;
            text-align: center;
            font-variant-numeric: tabular-nums;
        }

        .generation-status-spinner {
            width: 32px;
            height: 32px;
            border-radius: 999px;
            border: 1px solid rgba(255, 255, 255, 0.08);
            background: rgba(255, 255, 255, 0.03);
            display: inline-flex;
            align-items: center;
            justify-content: center;
            color: var(--text-secondary);
            flex-shrink: 0;
        }

        .message-footer {
            display: flex;
            align-items: center;
            justify-content: flex-end;
            gap: 0.3rem;
            width: auto;
            margin-top: 0.2rem;
            align-self: flex-end;
        }

        .message-meta {
            font-size: 0.74rem;
            color: var(--text-muted);
            line-height: 1.3;
        }

        .message.user .message-footer {
            align-self: flex-end;
        }

        .message.ai .message-meta {
            margin-top: 0.38rem;
        }

        .message-rewind-btn {
            appearance: none;
            border: none;
            background: transparent;
            color: var(--text-muted);
            width: 22px;
            height: 22px;
            border-radius: 999px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: all 0.15s ease;
        }

        .message-rewind-btn:hover {
            color: var(--text-primary);
            background: rgba(255, 255, 255, 0.08);
        }

        .message.user.message-send-animate {
            animation: user-message-send 0.34s cubic-bezier(0.2, 0.8, 0.2, 1);
            transform-origin: right bottom;
        }

        @keyframes user-message-send {
            from {
                opacity: 0;
                transform: translateY(36px) translateX(12px) scale(0.92);
                filter: blur(1px);
            }
            to {
                opacity: 1;
                transform: translateY(0) translateX(0) scale(1);
                filter: blur(0);
            }
        }

        .thinking-block {
            margin: 0 0 0.95rem;
            width: 100%;
            border: 1px solid rgba(255, 255, 255, 0.08);
            border-radius: 0.95rem;
            background: rgba(255, 255, 255, 0.02);
            overflow: hidden;
            transform-origin: top center;
            transition: border-color 0.28s ease, background-color 0.28s ease, transform 0.28s ease, opacity 0.28s ease;
        }

        .thinking-toggle {
            width: 100%;
            border: none;
            background: transparent;
            color: var(--text-secondary);
            padding: 0.78rem 0.95rem;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 0.75rem;
            font-size: 0.92rem;
            cursor: pointer;
            text-align: left;
        }

        .thinking-toggle:hover {
            background: rgba(255, 255, 255, 0.03);
        }

        .thinking-toggle-label {
            display: inline-flex;
            align-items: center;
            gap: 0.45rem;
        }

        .thinking-chevron {
            transition: transform 0.24s cubic-bezier(0.4, 0, 0.2, 1);
            font-size: 0.85rem;
        }

        .thinking-block.collapsed .thinking-chevron {
            transform: rotate(-90deg);
        }

        .thinking-body {
            padding: 0 0.95rem 0.95rem;
            color: var(--text-secondary);
            font-size: 0.92rem;
            line-height: 1.7;
            background: rgba(0, 0, 0, 0.35);
            border-top: 1px solid rgba(255, 255, 255, 0.06);
            overflow-x: hidden;
            overflow-y: auto;
            max-height: 0;
            opacity: 0;
            transition: max-height 0.32s cubic-bezier(0.4, 0, 0.2, 1),
                        opacity 0.22s ease,
                        padding 0.28s cubic-bezier(0.4, 0, 0.2, 1),
                        border-top-color 0.22s ease;
        }

        .thinking-block.thinking-live .thinking-body {
            transition: none;
        }

        .thinking-block:not(.collapsed) .thinking-body {
            opacity: 1;
        }

        .thinking-block.collapsed .thinking-body {
            max-height: 0 !important;
            opacity: 0;
            padding-top: 0;
            padding-bottom: 0;
            border-top-color: transparent;
        }

        .thinking-block.thinking-collapsing .thinking-body {
            transition: max-height 0.32s cubic-bezier(0.4, 0, 0.2, 1),
                        opacity 0.2s ease,
                        padding 0.28s cubic-bezier(0.4, 0, 0.2, 1),
                        border-top-color 0.2s ease;
        }

        .thinking-body pre {
            margin: 0.75rem 0 0;
            white-space: pre-wrap;
            word-break: break-word;
            font: inherit;
        }

        .thinking-block.thinking-live {
            background: rgba(255, 255, 255, 0.025);
            border-color: rgba(255, 255, 255, 0.12);
        }

        .thinking-block.thinking-enter {
            opacity: 0;
            transform: translateY(6px) scale(0.99);
        }

        .thinking-block.thinking-enter-active {
            opacity: 1;
            transform: translateY(0) scale(1);
        }

        .thinking-block.thinking-collapsing {
            transition: border-color 0.3s ease, background-color 0.3s ease, transform 0.3s ease, opacity 0.3s ease;
        }

        .thinking-word {
            opacity: 0;
            animation: thought-word-fade 0.18s ease forwards;
        }

        @keyframes thought-word-fade {
            from {
                opacity: 0;
                transform: translateY(3px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        .response-reveal {
            opacity: 0;
            transform: translateY(6px);
            animation: response-line-fade 0.3s cubic-bezier(0.22, 1, 0.36, 1) forwards;
        }

        @keyframes response-line-fade {
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        /* Chat Input */
        .chat-input-container {
            flex-shrink: 0;
            background: linear-gradient(to top, var(--bg-primary) 60%, transparent);
            padding: 0 1.25rem 1rem;
        }

        .composer-shell {
            width: min(100%, 760px);
            margin: 0 auto;
            background: var(--bg-card);
            border: 1px solid rgba(255, 255, 255, 0.08);
            border-radius: 1.5rem;
            box-shadow: 0 14px 36px rgba(0, 0, 0, 0.18);
            padding: 0.8rem 0.9rem 0.75rem;
        }

        .attachment-preview {
            width: 100%;
            margin: 0 0 0.55rem;
            display: none;
            align-items: center;
            gap: 0.55rem;
            flex-wrap: wrap;
        }

        .attachment-chip {
            display: inline-flex;
            align-items: center;
            gap: 0.55rem;
            background: rgba(255, 255, 255, 0.06);
            border: 1px solid rgba(255, 255, 255, 0.08);
            color: var(--text-secondary);
            border-radius: 0.8rem;
            padding: 0.45rem 0.7rem;
            max-width: 100%;
            font-size: 0.84rem;
        }

        .attachment-chip-thumb {
            width: 36px;
            height: 36px;
            object-fit: cover;
            border-radius: 0.4rem;
            flex-shrink: 0;
        }

        .attachment-chip-name {
            max-width: 280px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .msg-attachment-chip {
            display: inline-flex;
            align-items: center;
            gap: 0.5rem;
            background: rgba(255, 255, 255, 0.07);
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 0.6rem;
            padding: 0.35rem 0.6rem;
            max-width: 100%;
            font-size: 0.82rem;
            color: var(--text-secondary);
        }

        .msg-attachment-thumb {
            width: 32px;
            height: 32px;
            object-fit: cover;
            border-radius: 0.35rem;
            flex-shrink: 0;
        }

        .msg-attachment-name {
            max-width: 200px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .attachment-chip-remove {
            appearance: none;
            background: transparent;
            border: none;
            color: var(--text-secondary);
            cursor: pointer;
            padding: 0;
            width: 18px;
            height: 18px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
        }

        .attachment-chip-remove:hover {
            color: var(--text-primary);
        }

        .chat-input-wrapper {
            position: relative;
            min-height: 84px;
            margin: 0;
            border: none;
            border-radius: 0;
            background: transparent;
            box-shadow: none;
            padding: 0;
        }

        .chat-input {
            width: 100%;
            background-color: transparent;
            border: none;
            color: var(--text-primary);
            padding: 0.12rem 0 0;
            border-radius: 0;
            resize: none;
            min-height: 74px;
            max-height: 190px;
            font-family: inherit;
            font-size: 1rem;
            line-height: 1.55;
        }

        .chat-input::placeholder {
            color: var(--text-muted);
        }

        .chat-input:focus {
            outline: none;
            box-shadow: none;
        }

        .send-btn {
            position: static;
            width: 40px;
            height: 40px;
            background-color: var(--accent);
            color: var(--primary);
            border: none;
            border-radius: 999px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.18s ease;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            padding: 0;
            min-width: 40px;
        }

        .send-btn:hover {
            background-color: var(--accent-hover);
            transform: translateY(-1px);
        }

        .send-btn.stop-mode {
            background-color: var(--gray-400);
            color: var(--primary);
        }

        .send-btn.stop-mode:hover {
            background-color: var(--gray-500);
        }

        .send-btn:disabled {
            opacity: 0.5;
            cursor: not-allowed;
            transform: none;
        }

        .composer-footer {
            margin-top: 0.45rem;
            display: flex;
            align-items: center;
            justify-content: flex-start;
            gap: 0.9rem;
            flex-wrap: nowrap;
        }

        .composer-tools {
            display: inline-flex;
            align-items: center;
            gap: 0.35rem;
            color: var(--text-muted);
            flex-shrink: 0;
        }

        .composer-tool {
            appearance: none;
            border: none;
            background: transparent;
            color: inherit;
            display: inline-flex;
            align-items: center;
            gap: 0.35rem;
            font-size: 0.84rem;
            padding: 0.24rem 0.4rem;
            border-radius: 0.55rem;
            cursor: default;
        }

        .composer-tool.icon-btn {
            width: 30px;
            height: 30px;
            justify-content: center;
            padding: 0;
            border: 1px solid rgba(255, 255, 255, 0.08);
            background: rgba(255, 255, 255, 0.03);
            color: var(--text-secondary);
            cursor: pointer;
            transition: all 0.18s ease;
        }

        .composer-tool.icon-btn:hover {
            color: var(--text-primary);
            border-color: rgba(255, 255, 255, 0.18);
            background: rgba(255, 255, 255, 0.06);
        }

        .composer-tool.icon-btn:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }

        .composer-tool-label {
            appearance: none;
            border: none;
            background: transparent;
            padding: 0;
            color: var(--text-muted);
            font-size: 0.83rem;
            line-height: 1;
            cursor: pointer;
        }

        .composer-tool-label:hover {
            color: var(--text-primary);
        }

        .chat-controls {
            display: flex;
            gap: 0.5rem;
            margin: 0;
            align-items: center;
            flex-wrap: nowrap;
            justify-content: flex-start;
            flex: 1;
            min-width: 0;
            overflow-x: auto;
            scrollbar-width: none;
        }

        .chat-controls::-webkit-scrollbar {
            display: none;
        }

        .control-select {
            display: inline-flex;
            min-width: 0;
            flex: 0 0 auto;
            position: relative;
        }

        .composer-select-native {
            display: none !important;
        }

        .composer-select-trigger {
            appearance: none;
            height: 36px;
            min-width: 70px;
            max-width: 100%;
            background-color: rgba(255, 255, 255, 0.06);
            border: 1px solid rgba(255, 255, 255, 0.08);
            color: var(--text-primary);
            padding: 0 0.75rem;
            border-radius: 0.8rem;
            font-size: 0.84rem;
            line-height: 1;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 0.55rem;
            cursor: pointer;
            transition: all 0.18s ease;
            flex: 0 0 auto;
            white-space: nowrap;
            width: 100%;
        }

        .composer-select-trigger:hover {
            border-color: rgba(255, 255, 255, 0.16);
            background-color: rgba(255, 255, 255, 0.09);
        }

        .composer-select-trigger:disabled {
            opacity: 0.5;
            cursor: not-allowed;
            transform: none;
        }

        .composer-select-trigger.is-open {
            border-color: rgba(30, 144, 255, 0.55);
            background-color: rgba(30, 144, 255, 0.12);
            box-shadow: 0 0 0 1px rgba(30, 144, 255, 0.18);
        }

        .composer-select-label {
            min-width: 0;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .composer-select-caret {
            font-size: 0.72rem;
            color: var(--text-secondary);
            flex-shrink: 0;
        }

        .composer-select-menu {
            position: fixed;
            top: 0;
            left: 0;
            z-index: 1100;
            display: none;
            min-width: 160px;
            max-width: min(320px, calc(100vw - 16px));
            max-height: min(320px, calc(100vh - 16px));
            overflow-y: auto;
            padding: 0.4rem;
            border-radius: 0.95rem;
            border: 1px solid rgba(255, 255, 255, 0.1);
            background: rgba(31, 31, 31, 0.98);
            box-shadow: 0 18px 48px rgba(0, 0, 0, 0.42);
            backdrop-filter: blur(12px);
        }

        .composer-select-menu-option {
            appearance: none;
            width: 100%;
            border: none;
            background: transparent;
            color: var(--text-primary);
            text-align: left;
            padding: 0.68rem 0.75rem;
            border-radius: 0.7rem;
            font-size: 0.84rem;
            line-height: 1.35;
            cursor: pointer;
            transition: background 0.16s ease, color 0.16s ease;
        }

        .composer-select-menu-option:hover {
            background: rgba(255, 255, 255, 0.08);
        }

        .composer-select-menu-option.active {
            background: rgba(30, 144, 255, 0.14);
            color: #9fd0ff;
        }

        .composer-select-menu-option:disabled {
            opacity: 0.45;
            cursor: not-allowed;
        }

        .model-selector,
        .thinking-selector,
        .attachment-btn {
            height: 36px;
            background-color: rgba(255, 255, 255, 0.06);
            border: 1px solid rgba(255, 255, 255, 0.08);
            color: var(--text-primary);
            padding: 0 0.8rem;
            border-radius: 0.8rem;
            font-size: 0.84rem;
            line-height: 1;
        }

        .model-selector option , .config-dropdown option , .thinking-selector option{
            background-color: var(--bg-card);
            
        }
        .model-selector {
            min-width: 0;
            width: auto;
        }

        .model-selector:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }

        .thinking-selector {
            min-width: 0;
            width: auto;
        }

        .thinking-selector:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }

        .attachment-btn {
            color: var(--text-secondary);
            cursor: pointer;
            transition: all 0.2s ease;
            display: inline-flex;
            align-items: center;
            gap: 0.42rem;
            white-space: nowrap;
        }

        .chat-note {
            width: min(100%, 760px);
            margin: 0.45rem auto 0;
            text-align: center;
            font-size: 0.78rem;
            color: var(--text-muted);
        }

        .model-config-dropdowns {
            display: flex;
            gap: 0.35rem;
            flex-wrap: nowrap;
            overflow-x: auto;
            scrollbar-width: none;
        }

        .model-config-dropdowns::-webkit-scrollbar {
            display: none;
        }

        .model-config-select {
            flex-shrink: 0;
        }

        .config-dropdown {
            height: 36px;
            background-color: rgba(255, 255, 255, 0.06);
            border: 1px solid rgba(255, 255, 255, 0.08);
            color: var(--text-primary);
            padding: 0 0.8rem;
            border-radius: 0.8rem;
            font-size: 0.84rem;
            line-height: 1;
            min-width: 70px;
        }

        .aspect-ratio-btn {
            appearance: none;
            cursor: pointer;
            text-align: left;
        }

        /* Custom Aspect Ratio Popup */
        .aspect-ratio-popup {
            position: fixed;
            background-color: var(--bg-card);
            box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
            z-index: 1200;
            border-radius: 12px;
            padding: 12px;
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 10px;
            min-width: 180px;
            border: 1px solid rgba(255, 255, 255, 0.1);
        }

        .aspect-ratio-square {
            width: 60px;
            height: 60px;
            background-color: rgba(255, 255, 255, 0.05);
            display: flex;
            justify-content: center;
            align-items: center;
            color: var(--text-secondary);
            font-size: 11px;
            border-radius: 8px;
            cursor: pointer;
            border: 2px solid rgba(255, 255, 255, 0.1);
            box-sizing: border-box;
            transition: all 0.2s ease;
            flex-direction: column;
            gap: 4px;
        }

        .aspect-ratio-square:hover {
            background-color: rgba(255, 255, 255, 0.1);
            border-color: rgba(255, 255, 255, 0.2);
        }

        .aspect-ratio-square.active {
            background-color: rgba(99, 102, 241, 0.2);
            border-color: #6366f1;
            color: var(--text-primary);
        }

        .aspect-ratio-square .ratio-preview {
            border: 2px solid currentColor;
            border-radius: 2px;
        }

        .aspect-ratio-square .ratio-label {
            font-weight: 500;
        }

        /* Media Preview Modal */
        .media-preview-modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: 2000;
            justify-content: center;
            align-items: center;
        }

        .media-preview-modal.visible {
            display: flex;
        }

        .media-preview-overlay {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.95);
        }

        .media-preview-container {
            position: relative;
            z-index: 1;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            width: 90%;
            height: 90%;
            max-width: 1400px;
        }

        .media-preview-header {
            position: absolute;
            top: 20px;
            right: 20px;
            display: flex;
            gap: 10px;
            z-index: 10;
        }

        .media-preview-close,
        .media-preview-control {
            width: 44px;
            height: 44px;
            background-color: rgba(255, 255, 255, 0.1);
            border: 1px solid rgba(255, 255, 255, 0.2);
            border-radius: 50%;
            color: white;
            cursor: pointer;
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 18px;
            transition: all 0.2s ease;
        }

        .media-preview-close:hover,
        .media-preview-control:hover {
            background-color: rgba(255, 255, 255, 0.2);
            transform: scale(1.05);
        }

        .media-preview-content {
            flex: 1;
            display: flex;
            justify-content: center;
            align-items: center;
            overflow: hidden;
            width: 100%;
            position: relative;
        }

        #mediaPreviewImage,
        #mediaPreviewVideo {
            max-width: 100%;
            max-height: 100%;
            object-fit: contain;
            transition: transform 0.3s ease;
            cursor: grab;
            position: relative;
            z-index: 1;
        }

        #mediaPreviewImage:active,
        #mediaPreviewVideo:active {
            cursor: grabbing;
        }

        .media-preview-controls {
            position: absolute;
            bottom: 30px;
            left: 50%;
            transform: translateX(-50%);
            display: flex;
            gap: 8px;
            background-color: rgba(30, 30, 30, 0.9);
            padding: 12px 16px;
            border-radius: 12px;
            border: 1px solid rgba(255, 255, 255, 0.1);
            backdrop-filter: blur(10px);
            z-index: 10;
        }

        .media-preview-control-btn {
            width: 40px;
            height: 40px;
            background-color: rgba(255, 255, 255, 0.05);
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 8px;
            color: white;
            cursor: pointer;
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 16px;
            transition: all 0.2s ease;
        }

        .media-preview-control-btn:hover {
            background-color: rgba(255, 255, 255, 0.15);
            transform: scale(1.05);
        }

        .media-preview-separator {
            width: 1px;
            background-color: rgba(255, 255, 255, 0.2);
            margin: 0 4px;
        }

        :root {
            --topic-blue: #0070C0;
            --topic-orange: #F7A600;
            --topic-yellow: #FFC000;
            --topic-green: #00B050;
            --topic-red: #C00000;
            --topic-gray: #BFBFBF;
            --topic-purple: #0070C0;
            --topic-teal: #00B050;
            --topic-light-blue: #0070C0;
            --topic-soft-yellow: #FFC000;
        }

        .message.ai .message-content {
            color: #BFBFBF;
        }

        .message.ai .message-content h1,
        .message.ai .message-content h2,
        .message.ai .message-content h3,
        .message.ai .message-content h4 {
            margin: 1.4rem 0 0.75rem;
            font-weight: 650;
            line-height: 1.3;
        }

        .message.ai .message-content h1 {
            font-size: 2rem;
            letter-spacing: -0.03em;
            color: var(--topic-blue);
        }

        .message.ai .message-content h2 {
            font-size: 1.5rem;
            letter-spacing: -0.02em;
            color: var(--topic-yellow);
        }

        .message.ai .message-content h3 {
            font-size: 1.2rem;
            color: var(--topic-green);
        }

        .message.ai .message-content h4 {
            color: var(--topic-purple);
        }

        .message.ai .message-content p,
        .message.ai .message-content ul,
        .message.ai .message-content ol {
            margin-bottom: 1rem;
        }

        .message.ai .message-content p {
            font-size: 1.04rem;
            line-height: 1.85;
            color: #BFBFBF;
        }

        .message.ai .message-content ul,
        .message.ai .message-content ol {
            padding-left: 1.4rem;
        }

        .message.ai .message-content li + li {
            margin-top: 0.35rem;
        }

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

        .message.ai .message-content strong {
            color: var(--topic-orange);
            font-weight: 800;
        }

        .message.ai .message-content em {
            color: var(--topic-soft-yellow);
            font-style: normal;
        }

        .message.ai .message-content a {
            color: var(--topic-blue);
            text-decoration: none;
        }

        .message.ai .message-content a:hover {
            text-decoration: underline;
        }

        .message.ai .message-content hr {
            border: none;
            border-top: 1px solid rgba(255, 255, 255, 0.12);
            margin: 1.4rem 0;
        }

        .message.ai .message-content .ai-lead {
            font-size: 1.16rem;
            line-height: 1.9;
            color: var(--text-lead);
            font-weight: 500;
        }

        .message.ai .message-content .ai-subtle {
            color: var(--text-subtle);
        }

        .message.ai .message-content .ai-accent-heading {
            font-weight: 800;
            letter-spacing: -0.02em;
        }

        .message.ai .message-content .ai-title-blue {
            color: var(--topic-blue);
            font-weight: 800;
        }

        .message.ai .message-content .ai-title-yellow {
            color: var(--topic-yellow);
            font-weight: 800;
        }

        .message.ai .message-content .ai-title-green {
            color: var(--topic-green);
            font-weight: 800;
        }

        .message.ai .message-content .ai-title-purple {
            color: var(--topic-purple);
            font-weight: 800;
        }

        .message.ai .message-content .ai-title-red {
            color: var(--topic-red);
            font-weight: 800;
        }

        .message.ai .message-content .ai-title-orange {
            color: var(--topic-orange);
            font-weight: 800;
        }

        .message.ai .message-content .ai-title-teal {
            color: var(--topic-teal);
            font-weight: 800;
        }

        .message.ai .message-content .ai-title-lightblue {
            color: var(--topic-light-blue);
            font-weight: 800;
        }

        .message.ai .message-content .ai-label {
            color: var(--topic-blue);
            font-weight: 800;
        }

        .message.ai .message-content .ai-label.ai-label-warning {
            color: var(--topic-orange);
        }

        .message.ai .message-content .ai-label.ai-label-important {
            color: var(--topic-red);
        }

        .message.ai .message-content .ai-label.ai-label-note {
            color: var(--topic-soft-yellow);
        }

        .message.ai .message-content .ai-label.ai-label-success {
            color: var(--topic-green);
        }

        .message.ai .message-content .ai-label.ai-label-idea {
            color: var(--topic-purple);
        }

        .message.ai .message-content .ai-label.ai-label-calm {
            color: var(--topic-teal);
        }

        .message.ai .message-content .ai-topic-inline {
            color: var(--topic-green);
            font-weight: 800;
        }

        .message.ai .message-content .ai-topic-inline.ai-topic-sub {
            color: var(--topic-purple);
        }

        .message.ai .message-content .ai-dialogue {
            color: var(--topic-light-blue);
            font-weight: 600;
        }

        .message.ai .message-content .ai-important {
            color: var(--topic-red);
            font-weight: 800;
        }

        .message.ai .message-content .ai-caution {
            color: var(--topic-orange);
            font-weight: 800;
        }

        .message.ai .message-content .ai-note {
            color: var(--topic-soft-yellow);
            font-weight: 700;
        }

        .message.ai .message-content .ai-positive {
            color: var(--topic-green);
            font-weight: 800;
        }

        .message.ai .message-content .ai-idea {
            color: var(--topic-purple);
            font-weight: 800;
        }

        .message.ai .message-content .ai-calm {
            color: var(--topic-teal);
            font-weight: 700;
        }

        .message.ai .message-content .ai-muted {
            color: var(--topic-gray);
        }

        .message.ai .message-content .ai-text-red {
            color: var(--topic-red);
            font-weight: 800;
        }

        .message.ai .message-content .ai-text-orange {
            color: var(--topic-orange);
            font-weight: 800;
        }

        .message.ai .message-content .ai-text-yellow {
            color: var(--topic-soft-yellow);
            font-weight: 700;
        }

        .message.ai .message-content .ai-text-green {
            color: var(--topic-green);
            font-weight: 800;
        }

        .message.ai .message-content .ai-text-purple {
            color: var(--topic-purple);
            font-weight: 800;
        }

        .message.ai .message-content .ai-text-teal {
            color: var(--topic-teal);
            font-weight: 700;
        }

        .message.ai .message-content .ai-text-lightblue {
            color: var(--topic-light-blue);
            font-weight: 700;
        }

        .message.ai .message-content .ai-text-gray {
            color: var(--topic-gray);
        }

        .message.ai .message-content blockquote {
            margin: 1rem 0;
            padding: 0.2rem 0 0.2rem 1rem;
            border-left: 3px solid rgba(30, 144, 255, 0.6);
            color: var(--text-blockquote);
            background: linear-gradient(90deg, rgba(30, 144, 255, 0.08), transparent 80%);
            border-radius: 0 0.6rem 0.6rem 0;
        }

        .message.ai .message-content code {
            background: rgba(255, 255, 255, 0.08);
            border-radius: 0.4rem;
            padding: 0.12rem 0.35rem;
            font-size: 0.92em;
            color: var(--topic-soft-yellow);
        }

        .message.ai .message-content li::marker {
            color: var(--topic-blue);
        }

        .message.ai .message-content ul ul > li::marker,
        .message.ai .message-content ol ol > li::marker,
        .message.ai .message-content ul ol > li::marker,
        .message.ai .message-content ol ul > li::marker {
            color: var(--topic-purple);
        }

        .message.ai .message-content pre {
            background: var(--bg-tertiary);
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 0.85rem;
            padding: 0.9rem 1rem;
            overflow-x: auto;
            margin: 1rem 0;
        }

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

        /* Image and Video Styles */
        .message.ai .message-content img {
            border-radius: 0.5rem;
            max-width: 300px;
            max-height: 300px;
            width: auto;
            height: auto;
            display: block;
            margin-top: 1rem;
            object-fit: contain;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        }

        .message.ai .message-content video {
            border-radius: 0.5rem;
            max-width: 100%;
            height: auto;
            display: block;
            margin-top: 1rem;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        }

        /* Upgrade Modal */
        .upgrade-modal {
            position: fixed;
            inset: 0;
            background: rgba(0, 0, 0, 0.8);
            display: none;
            align-items: center;
            justify-content: center;
            z-index: 2000;
            padding: 2rem;
        }

        .upgrade-modal.visible {
            display: flex;
        }

        .upgrade-modal-card {
            background: var(--bg-card);
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 1.25rem;
            padding: 2rem;
            max-width: 480px;
            width: 100%;
            text-align: center;
        }

        .upgrade-modal-title {
            font-size: 1.5rem;
            font-weight: 600;
            margin-bottom: 1rem;
            color: var(--text-primary);
        }

        .upgrade-modal-text {
            color: var(--text-secondary);
            margin-bottom: 2rem;
            line-height: 1.6;
        }

        .upgrade-modal-actions {
            display: flex;
            gap: 1rem;
            justify-content: center;
        }

        .upgrade-modal-btn {
            padding: 0.75rem 1.5rem;
            border-radius: 0.8rem;
            border: 1px solid rgba(255, 255, 255, 0.2);
            background: rgba(255, 255, 255, 0.1);
            color: var(--text-primary);
            cursor: pointer;
            font-weight: 500;
            transition: all 0.2s ease;
        }

        .upgrade-modal-btn:hover {
            background: rgba(255, 255, 255, 0.2);
        }

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

        .upgrade-modal-btn.primary:hover {
            background: var(--accent-hover);
        }

        /* Account restriction indicator */
        .account-restriction {
            background: rgba(245, 158, 11, 0.1);
            border: 1px solid rgba(245, 158, 11, 0.3);
            border-radius: 0.8rem;
            padding: 0.75rem 1rem;
            margin-bottom: 1rem;
            font-size: 0.85rem;
            color: var(--warning);
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }

        .account-restriction i {
            font-size: 1rem;
        }

        /* Placeholder content */
        .placeholder-content {
            text-align: center;
            color: var(--text-muted);
            padding: 4rem 2rem;
        }

        .placeholder-content i {
            font-size: 4rem;
            color: var(--bg-border);
            margin-bottom: 1rem;
        }

        .placeholder-content h3 {
            margin-bottom: 1rem;
            color: var(--text-primary);
        }

        /* Scrollbar Styling */
        ::-webkit-scrollbar {
            width: 8px;
        }

        ::-webkit-scrollbar-track {
            background: var(--bg-secondary);
        }

        ::-webkit-scrollbar-thumb {
            background: var(--bg-border);
            border-radius: 4px;
        }

        ::-webkit-scrollbar-thumb:hover {
            background: var(--text-muted);
        }

        /* Upgrade Page Styles */
        .upgrade-page {
            display: none;
            padding: 2rem;
            max-width: 1200px;
            margin: 0 auto;
            position: relative;
            z-index: 1;
        }

        .upgrade-page.visible {
            display: block;
        }

        .upgrade-header {
            text-align: center;
            margin-bottom: 3rem;
        }

        .upgrade-header h1 {
            font-size: 2.5rem;
            font-weight: 700;
            margin-bottom: 1rem;
            color: var(--text-primary);
        }

        .upgrade-header p {
            font-size: 1.1rem;
            color: var(--text-secondary);
            max-width: 600px;
            margin: 0 auto;
        }

        .plans-table {
            background: var(--bg-card);
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 1rem;
            overflow: hidden;
            margin-bottom: 2rem;
        }

        .plans-table table {
            width: 100%;
            border-collapse: collapse;
        }

        .plans-table th {
            background: rgba(255, 255, 255, 0.05);
            padding: 1.5rem 1rem;
            text-align: left;
            font-weight: 600;
            color: var(--text-primary);
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        }

        .plans-table td {
            padding: 1rem;
            border-bottom: 1px solid rgba(255, 255, 255, 0.05);
            color: var(--text-secondary);
        }

        .plans-table tr:last-child td {
            border-bottom: none;
        }

        .plan-name {
            font-weight: 600;
            color: var(--text-primary);
            font-size: 1.1rem;
        }

        .plan-price {
            font-size: 1.5rem;
            font-weight: 700;
            color: var(--primary);
        }

        .feature-check {
            color: var(--success);
            font-size: 1.2rem;
        }

        .feature-cross {
            color: var(--danger);
            font-size: 1.2rem;
        }

        .upgrade-btn {
            background: var(--accent);
            color: white;
            border: none;
            padding: 0.75rem 1.5rem;
            border-radius: 0.5rem;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
            text-decoration: none;
            display: inline-block;
        }

        .upgrade-btn:hover {
            transform: translateY(-2px);
            background: var(--accent-hover);
            box-shadow: 0 10px 20px rgba(30, 144, 255, 0.3);
        }

        .serial-modal {
            position: fixed;
            inset: 0;
            background: rgba(0, 0, 0, 0.8);
            display: none;
            align-items: center;
            justify-content: center;
            z-index: 3000;
            padding: 2rem;
        }

        .serial-modal.visible {
            display: flex;
        }

        .serial-modal-card {
            background: var(--bg-card);
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 1.25rem;
            padding: 2rem;
            max-width: 500px;
            width: 100%;
        }

        .config-modal {
            position: fixed;
            inset: 0;
            background: rgba(0, 0, 0, 0.72);
            display: none;
            align-items: center;
            justify-content: center;
            z-index: 3100;
            padding: 1.5rem;
        }

        .config-modal.visible {
            display: flex;
        }

        .config-modal-card {
            width: min(820px, 100%);
            min-height: min(560px, calc(100vh - 3rem));
            background: var(--bg-card);
            border: 1px solid rgba(255, 255, 255, 0.12);
            border-radius: 1rem;
            box-shadow: 0 28px 80px rgba(0, 0, 0, 0.42);
            padding: 1rem 1rem 0.9rem;
            display: flex;
            flex-direction: column;
        }

        .config-modal-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 1rem;
            margin-bottom: 0.75rem;
        }

        .config-modal-title {
            color: var(--text-primary);
            font-size: 1.1rem;
            font-weight: 700;
        }

        .config-close-btn {
            appearance: none;
            border: 1px solid rgba(255, 255, 255, 0.12);
            background: rgba(255, 255, 255, 0.04);
            color: var(--text-secondary);
            width: 36px;
            height: 36px;
            border-radius: 999px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
        }

        .config-close-btn:hover {
            color: var(--text-primary);
            background: rgba(255, 255, 255, 0.08);
        }

        .config-grid {
            display: grid;
            gap: 1rem;
        }

        .config-tab-row {
            display: flex;
            gap: 0.4rem;
            margin-bottom: 0.8rem;
            padding-bottom: 0.55rem;
            border-bottom: 1px solid rgba(255, 255, 255, 0.08);
        }

        .config-tab-panel {
            display: none;
            flex: 1;
        }

        .config-tab-panel.active {
            display: block;
        }

        .config-empty-state {
            min-height: 250px;
            border: 1px dashed rgba(255, 255, 255, 0.12);
            border-radius: 0.75rem;
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--text-secondary);
            background: rgba(255, 255, 255, 0.02);
            font-size: 0.92rem;
        }

        .config-row {
            display: grid;
            grid-template-columns: 130px minmax(0, 1fr);
            gap: 0.75rem;
            align-items: start;
        }

        .config-name {
            color: var(--text-primary);
            font-weight: 600;
            padding-top: 0.5rem;
        }

        .config-value-group {
            display: flex;
            flex-direction: column;
            gap: 0.55rem;
        }

        .config-pill-row {
            display: flex;
            flex-wrap: wrap;
            gap: 0.45rem;
        }

        .config-subpill-row {
            padding-top: 0.15rem;
        }

        .config-pill {
            appearance: none;
            border: 1px solid rgba(255, 255, 255, 0.12);
            background: rgba(255, 255, 255, 0.05);
            color: var(--text-secondary);
            padding: 0.54rem 0.85rem;
            border-radius: 0.85rem;
            font-size: 0.89rem;
            line-height: 1;
            cursor: pointer;
            transition: all 0.18s ease;
        }

        .config-tab-row .config-pill {
            border-radius: 0.7rem;
            padding: 0.58rem 0.95rem;
            background: transparent;
            border-color: rgba(255, 255, 255, 0.08);
        }

        .config-tab-row .config-pill.active {
            background: rgba(255, 255, 255, 0.12);
            border-color: rgba(255, 255, 255, 0.18);
            box-shadow: none;
        }

        .config-pill:hover {
            color: var(--text-primary);
            border-color: rgba(255, 255, 255, 0.22);
            background: rgba(255, 255, 255, 0.1);
        }

        .config-pill.active {
            color: var(--text-primary);
            border-color: rgba(255, 255, 255, 0.32);
            background: rgba(255, 255, 255, 0.14);
            box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
        }

        .config-select {
            width: 100%;
            min-height: 44px;
            border-radius: 0.85rem;
            border: 1px solid rgba(255, 255, 255, 0.12);
            background: rgba(255, 255, 255, 0.05);
            color: var(--text-primary);
            padding: 0.72rem 0.9rem;
            font-size: 0.95rem;
        }

        .config-select-hidden {
            display: none !important;
        }

        .config-input,
        .config-static-value {
            width: 100%;
            min-height: 42px;
            border-radius: 0.8rem;
            border: 1px solid rgba(255, 255, 255, 0.12);
            background: rgba(255, 255, 255, 0.05);
            color: var(--text-primary);
            padding: 0.7rem 0.9rem;
            font-size: 0.94rem;
        }

        .config-input:focus {
            outline: none;
            border-color: rgba(30, 144, 255, 0.65);
            box-shadow: 0 0 0 3px rgba(30, 144, 255, 0.16);
        }

        .config-static-hint {
            color: var(--text-secondary);
            font-size: 0.82rem;
            padding-left: 0.1rem;
        }

        .config-row.background-config-row {
            display: none;
        }

        .config-actions {
            display: flex;
            justify-content: flex-end;
            gap: 0.75rem;
            margin-top: auto;
            padding-top: 1rem;
        }

        .serial-modal-title {
            font-size: 1.5rem;
            font-weight: 600;
            margin-bottom: 1rem;
            color: var(--text-primary);
        }

        .serial-modal-subtitle {
            color: var(--text-secondary);
            margin-bottom: 1.5rem;
            font-size: 0.9rem;
        }

        .serial-input-group {
            margin-bottom: 1.5rem;
        }

        .serial-input {
            width: 100%;
            background: var(--bg-input);
            border: 1px solid rgba(255, 255, 255, 0.1);
            color: var(--text-primary);
            padding: 1rem;
            border-radius: 0.8rem;
            font-size: 1.1rem;
            text-align: center;
            letter-spacing: 2px;
            font-family: monospace;
        }

        .serial-input:focus {
            outline: none;
            border-color: var(--primary);
        }

        .serial-actions {
            display: flex;
            gap: 1rem;
            justify-content: center;
        }

        .serial-btn {
            padding: 0.75rem 1.5rem;
            border-radius: 0.8rem;
            border: 1px solid rgba(255, 255, 255, 0.2);
            background: rgba(255, 255, 255, 0.1);
            color: var(--text-primary);
            cursor: pointer;
            font-weight: 500;
            transition: all 0.2s ease;
        }

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

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

        .serial-btn:hover {
            transform: translateY(-1px);
        }

        .serial-error {
            color: var(--danger);
            font-size: 0.9rem;
            margin-top: 0.5rem;
            text-align: center;
        }

        .serial-success {
            color: var(--success);
            font-size: 0.9rem;
            margin-top: 0.5rem;
            text-align: center;
        }

        .back-btn {
            background: rgba(255, 255, 255, 0.1);
            color: var(--text-primary);
            border: 1px solid rgba(255, 255, 255, 0.2);
            padding: 0.75rem 1.5rem;
            border-radius: 0.8rem;
            margin-top: 1rem;
            display: inline-block;
            text-decoration: none;
            display: inline-flex;
            align-items: center;
            gap: 0.5rem;
            margin-bottom: 2rem;
            transition: all 0.2s ease;
        }

        .back-btn:hover {
            background: rgba(255, 255, 255, 0.2);
        }

        .profile-page {
            display: none;
            padding: 2rem;
            max-width: 1000px;
            margin: 0 auto;
            overflow-y: auto;
            height: 100vh;
        }

        .profile-page.visible {
            display: block;
        }

        .profile-hero {
            background: linear-gradient(135deg, rgba(30, 144, 255, 0.12) 0%, rgba(30, 144, 255, 0.05) 100%);
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 1.25rem;
            padding: 2rem;
            margin-bottom: 1.5rem;
            display: flex;
            gap: 1.5rem;
            align-items: center;
        }

        .profile-avatar {
            width: 72px;
            height: 72px;
            border-radius: 1.25rem;
            background: rgba(255, 255, 255, 0.08);
            border: 1px solid rgba(255, 255, 255, 0.12);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.75rem;
            color: var(--text-primary);
            flex-shrink: 0;
        }

        .profile-hero-main {
            flex: 1;
            min-width: 0;
        }

        .profile-hero-name {
            font-size: 1.8rem;
            font-weight: 700;
            margin-bottom: 0.35rem;
        }

        .profile-hero-meta {
            color: var(--text-secondary);
            display: flex;
            flex-wrap: wrap;
            gap: 0.75rem;
            font-size: 0.95rem;
        }

        .profile-pill {
            display: inline-flex;
            align-items: center;
            gap: 0.4rem;
            padding: 0.35rem 0.75rem;
            border-radius: 999px;
            background: rgba(255, 255, 255, 0.08);
            border: 1px solid rgba(255, 255, 255, 0.1);
            color: var(--text-primary);
            font-size: 0.85rem;
            line-height: 1;
        }

        .profile-pill-button {
            appearance: none;
            cursor: pointer;
            background: rgba(30, 144, 255, 0.14);
            border-color: rgba(30, 144, 255, 0.35);
            transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
        }

        .profile-pill-button:hover {
            background: rgba(30, 144, 255, 0.22);
            border-color: rgba(30, 144, 255, 0.5);
            color: #ffffff;
        }

        .profile-info-section {
            display: flex;
            flex-direction: column;
            gap: 1rem;
        }

        .profile-info-label {
            font-size: 0.9rem;
            font-weight: 600;
            color: var(--text-secondary);
        }

        .profile-info-textarea {
            width: 100%;
            min-height: 120px;
            background: var(--bg-input);
            border: 1px solid rgba(255, 255, 255, 0.12);
            border-radius: 0.8rem;
            padding: 1rem;
            color: var(--text-primary);
            font-size: 0.95rem;
            line-height: 1.6;
            resize: vertical;
            font-family: inherit;
        }

        .profile-info-textarea::placeholder {
            color: var(--text-muted);
        }

        .profile-info-textarea:focus {
            outline: none;
            border-color: var(--accent);
            box-shadow: 0 0 0 3px rgba(30, 144, 255, 0.15);
        }

        .profile-info-checkboxes {
            display: flex;
            flex-wrap: wrap;
            gap: 1rem;
        }

        .profile-info-checkbox {
            display: inline-flex;
            align-items: center;
            gap: 0.5rem;
            cursor: pointer;
            user-select: none;
        }

        .profile-info-checkbox input[type="checkbox"] {
            appearance: none;
            width: 20px;
            height: 20px;
            border: 2px solid rgba(255, 255, 255, 0.3);
            border-radius: 4px;
            background: transparent;
            cursor: pointer;
            position: relative;
            transition: all 0.18s ease;
        }

        .profile-info-checkbox input[type="checkbox"]:checked {
            background: var(--accent);
            border-color: var(--accent);
        }

        .profile-info-checkbox input[type="checkbox"]:checked::after {
            content: '✓';
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            color: white;
            font-size: 12px;
            font-weight: bold;
        }

        .profile-info-checkbox span {
            color: var(--text-primary);
            font-size: 0.9rem;
        }

        .profile-info-save-btn {
            appearance: none;
            border: none;
            background: var(--accent);
            color: var(--primary);
            padding: 0.75rem 1.5rem;
            border-radius: 0.8rem;
            font-weight: 600;
            cursor: pointer;
            transition: background 0.18s ease, transform 0.18s ease;
            display: inline-flex;
            align-items: center;
            gap: 0.5rem;
            align-self: flex-start;
        }

        .profile-info-save-btn:hover {
            background: var(--accent-hover);
            transform: translateY(-1px);
        }

        .profile-info-save-btn:active {
            transform: translateY(0);
        }

        .profile-grid {
            display: grid;
            grid-template-columns: repeat(12, 1fr);
            gap: 1.25rem;
        }

        .profile-card {
            grid-column: span 6;
            background: var(--bg-card);
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 1.25rem;
            padding: 1.5rem;
        }

        .profile-card.full {
            grid-column: span 12;
        }

        .profile-card-title {
            font-size: 1.05rem;
            font-weight: 650;
            margin-bottom: 1rem;
            color: var(--text-primary);
            display: flex;
            align-items: center;
            gap: 0.55rem;
        }

        .profile-row {
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 1rem;
            padding: 0.7rem 0;
            border-bottom: 1px solid rgba(255, 255, 255, 0.06);
        }

        .profile-row:last-child {
            border-bottom: none;
        }

        .profile-key {
            color: var(--text-muted);
            font-size: 0.9rem;
        }

        .profile-value {
            color: var(--text-primary);
            font-weight: 600;
            text-align: right;
            max-width: 65%;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .profile-actions {
            display: flex;
            flex-wrap: wrap;
            gap: 0.75rem;
            margin-top: 0.25rem;
        }

        .profile-action-btn {
            appearance: none;
            border: 1px solid rgba(255, 255, 255, 0.16);
            background: rgba(255, 255, 255, 0.08);
            color: var(--text-primary);
            padding: 0.75rem 1.05rem;
            border-radius: 0.9rem;
            cursor: pointer;
            font-weight: 600;
            display: inline-flex;
            align-items: center;
            gap: 0.55rem;
        }

        .profile-action-btn:hover {
            background: rgba(255, 255, 255, 0.12);
        }

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

        .profile-action-btn.primary:hover {
            background: var(--accent-hover);
            box-shadow: 0 10px 24px rgba(30, 144, 255, 0.28);
            transform: translateY(-1px);
        }

        /* Responsive */
        @media (max-width: 768px) {
            .upgrade-page {
                padding: 1rem;
            }

            .profile-page {
                padding: 1rem;
                height: 100vh;
                overflow-y: auto;
            }

            .config-row {
                grid-template-columns: 1fr;
                gap: 0.55rem;
            }

            .config-name {
                padding-top: 0;
            }

            .config-actions {
                flex-direction: column-reverse;
            }

            .profile-hero {
                padding: 1.5rem;
            }

            .profile-card {
                grid-column: span 12;
            }

            .plans-table {
                font-size: 0.9rem;
            }

            .plans-table th,
            .plans-table td {
                padding: 0.75rem 0.5rem;
            }

            .plan-price {
                font-size: 1.2rem;
            }

            .serial-modal-card {
                padding: 1.5rem;
            }
        }
        @media (max-width: 768px) {
            .message {
                padding: 0 0.9rem;
            }

            .mobile-topbar {
                display: flex;
                align-items: center;
                justify-content: space-between;
                gap: 0.75rem;
                padding: 0.9rem 1rem 0.8rem;
                border-bottom: 1px solid rgba(255, 255, 255, 0.06);
                background: var(--bg-secondary);
                position: relative;
                z-index: 31;
            }

            .mobile-menu-overlay {
                display: block;
                position: fixed;
                inset: 0;
                background: rgba(0, 0, 0, 0.48);
                opacity: 0;
                pointer-events: none;
                transition: opacity 0.2s ease;
                z-index: 29;
            }

            .mobile-menu-overlay.visible {
                opacity: 1;
                pointer-events: auto;
            }

            .message-main {
                width: 100%;
            }

            .message.user .message-content {
                max-width: 88%;
            }

            .chat-controls {
                overflow: visible;
                padding-bottom: 0;
            }

            .chat-input-container {
                padding: 0 0.9rem 0.9rem;
            }

            .composer-shell {
                position: relative;
                padding: 0.75rem 0.75rem 0.7rem;
            }

            .composer-footer {
                display: grid;
                grid-template-columns: auto 1fr;
                gap: 0.4rem;
                align-items: center;
            }

            .composer-tools {
                grid-row: 1;
                grid-column: 1;
                flex-shrink: 0;
            }

            .composer-tool-label span {
                display: none;
            }

            .composer-tool-label {
                display: inline-flex;
                align-items: center;
                justify-content: center;
                width: 30px;
                height: 30px;
                border: 1px solid rgba(255, 255, 255, 0.08);
                background: rgba(255, 255, 255, 0.03);
                border-radius: 0.55rem;
                font-size: 0.92rem;
            }

            .composer-footer > .chat-controls {
                display: grid;
                grid-column: 2;
                grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
                gap: 0.4rem;
                min-width: 0;
                width: 100%;
                overflow: visible;
            }

            .chat-controls > .control-select,
            .chat-controls > .model-config-dropdowns {
                width: 100%;
                min-width: 0;
            }

            .chat-controls > .control-select {
                display: flex;
            }

            .home-layout {
                flex-direction: column;
                position: relative;
            }

            .chat-sidebar {
                width: min(320px, calc(100vw - 2rem));
                max-width: calc(100vw - 2rem);
                height: calc(100vh - 1.2rem);
                position: fixed;
                top: 0.6rem;
                left: 0.6rem;
                border-right: 1px solid rgba(255, 255, 255, 0.06);
                border-bottom: none;
                max-height: none;
                border-radius: 1.25rem;
                box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
                z-index: 30;
                transform: translateX(calc(-100% - 1rem));
                transition: transform 0.22s ease;
                padding-top: 1.05rem;
                padding-bottom: 1rem;
            }

            .chat-sidebar.mobile-open {
                transform: translateX(0);
            }

            .chat-sidebar-top {
                overflow: hidden;
            }

            .chat-history {
                padding-right: 0.2rem;
            }

            .chat-sidebar-profile {
                margin-top: 0;
            }

            .message-content {
                max-width: 85%;
            }

            .chat-controls {
                justify-content: stretch;
            }

            .model-selector {
                min-width: 0;
            }

            .model-config-dropdowns {
                display: grid;
                grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
                width: 100%;
                overflow: visible;
            }

            .model-config-select,
            .config-dropdown,
            .aspect-ratio-btn,
            .chat-controls .composer-select-trigger {
                width: 100%;
                min-width: 0;
            }

            .chat-input-wrapper {
                position: relative;
                min-height: 84px;
                padding-right: 3.25rem;
            }

            .chat-input {
                padding-right: 3rem;
            }

            .chat-input-wrapper > .send-btn {
                position: absolute;
                top: 0.15rem;
                right: 0;
                width: 38px;
                height: 38px;
                z-index: 2;
            }
        }

        /* Follow-up interaction card */
        .followup-card {
            display: flex;
            flex-direction: column;
            gap: 0.6rem;
            position: relative;
            margin-top: 0.85rem;
            padding: 0.85rem 1rem;
            border: 1px solid rgba(255, 255, 255, 0.08);
            border-radius: 0.9rem;
            background: rgba(255, 255, 255, 0.025);
            width: 100%;
        }

        .followup-close {
            appearance: none;
            position: absolute;
            top: 0.45rem;
            right: 0.55rem;
            border: none;
            background: transparent;
            color: var(--text-muted);
            width: 24px;
            height: 24px;
            border-radius: 0.35rem;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            font-size: 1rem;
            line-height: 1;
        }

        .followup-close:hover {
            color: var(--text-primary);
            background: rgba(255, 255, 255, 0.08);
        }

        .followup-question {
            font-size: 0.85rem;
            color: var(--text-secondary);
            font-weight: 500;
        }

        .followup-choices {
            display: flex;
            flex-wrap: wrap;
            gap: 0.4rem;
        }

        .followup-pill {
            appearance: none;
            border: 1px solid rgba(255, 255, 255, 0.12);
            background: rgba(255, 255, 255, 0.05);
            color: var(--text-secondary);
            font-size: 0.82rem;
            padding: 0.3rem 0.8rem;
            border-radius: 999px;
            cursor: pointer;
            transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
            white-space: nowrap;
        }

        .followup-pill:hover {
            background: var(--accent-glow);
            border-color: rgba(30, 144, 255, 0.4);
            color: var(--accent);
        }

        .followup-pill:active {
            background: rgba(30, 144, 255, 0.25);
        }
