        :root {
            color-scheme: light;
            --bg: #ffffff;
            --page: #f5f5f7;
            --panel: #ffffff;
            --panel-muted: #fbfbfd;
            --text: #1d1d1f;
            --muted: #6e6e73;
            --muted-2: #86868b;
            --line: #d2d2d7;
            --line-soft: #e8e8ed;
            --blue: #0071e3;
            --blue-hover: #0077ed;
            --blue-soft: #f0f7ff;
            --red: #d70015;
            --green: #1d7f3a;
            --radius-lg: 18px;
            --radius-md: 14px;
            --radius-sm: 10px;
            --shadow-pop: 0 14px 42px rgba(0, 0, 0, .14);
            --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
        }

        :root[data-theme="dark"] {
            color-scheme: dark;
            --bg: #000000;
            --page: #101010;
            --panel: #161617;
            --panel-muted: #1d1d1f;
            --text: #f5f5f7;
            --muted: #a1a1a6;
            --muted-2: #86868b;
            --line: #3a3a3c;
            --line-soft: #2c2c2e;
            --blue: #2997ff;
            --blue-hover: #46a6ff;
            --blue-soft: rgba(41, 151, 255, .14);
            --red: #ff453a;
            --green: #30d158;
            --shadow-pop: 0 18px 48px rgba(0, 0, 0, .5);
        }

        * {
            box-sizing: border-box;
        }

        html, body {
            height: 100%;
        }

        body {
            margin: 0;
            overflow: hidden;
            background: var(--page);
            color: var(--text);
            font-family: var(--font);
            -webkit-font-smoothing: antialiased;
            text-rendering: optimizeLegibility;
        }

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

        button {
            -webkit-tap-highlight-color: transparent;
        }

        ::selection {
            background: rgba(0, 113, 227, .18);
        }

        .app-shell {
            height: 100vh;
            height: 100dvh;
            min-height: 0;
            display: grid;
            grid-template-columns: 350px minmax(0, 1fr);
            overflow: hidden;
            background: var(--page);
        }

        .app-shell.sidebar-collapsed {
            grid-template-columns: 0 minmax(0, 1fr);
        }

        .app-shell.sidebar-collapsed .sidebar {
            max-height: 0;
            border-bottom: 0;
        }

        .app-shell.wide-mode .messages-inner,
        .app-shell.wide-mode .composer-inner,
        .app-shell.wide-mode .pending-files {
            width: min(1300px, 100%);
        }

        .messages-inner, .composer-inner, .pending-files {
            transition: width 0.3s ease;
        }

        .new-chat-btn, .settings-btn, .theme-btn, .sidebar-toggle-btn,
        .send-btn, .btn, .action-btn, .icon-btn, .custom-select-trigger,
        .thinking-header, .model-pill, .attach-btn, .code-copy-btn, .message-expand-btn {
            border: 0;
            cursor: pointer;
            transition: background-color .12s ease, border-color .12s ease, color .12s ease, transform .08s ease;
        }

        .new-chat-btn:active, .settings-btn:active, .theme-btn:active, .sidebar-toggle-btn:active,
        .send-btn:active, .btn:active, .action-btn:active, .icon-btn:active, .custom-select-trigger:active,
        .model-pill:active, .attach-btn:active, .code-copy-btn:active {
            transform: scale(.985);
        }

        .form-input, .form-select, .chat-input {
            width: 100%;
            background: transparent;
            border: 0;
            outline: 0;
            color: var(--text);
        }

        .form-input, .form-select {
            min-height: 42px;
            padding: 9px 11px;
            border: 1px solid var(--line);
            border-radius: 11px;
            background: var(--panel);
        }

        .form-input:focus, .form-select:focus,
        .input-wrap:focus-within,
        .custom-select.open .custom-select-trigger,
        .top-model-select.open .model-pill {
            border-color: var(--blue);
            box-shadow: 0 0 0 3px rgba(0, 113, 227, .12);
        }

        .top-model-option, .custom-option {
            width: 100%;
            min-height: 36px;
            padding: 8px 10px;
            border: 0;
            border-radius: 10px;
            background: transparent;
            color: var(--text);
            text-align: left;
            font-size: 13px;
            cursor: pointer;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .top-model-option:hover, .custom-option:hover {
            background: var(--page);
        }

        .top-model-option.selected, .custom-option.selected {
            color: var(--blue);
            background: var(--blue-soft);
            font-weight: 700;
        }

        .top-model-option.empty, .custom-option.empty {
            color: var(--muted);
            cursor: default;
        }

        .sidebar {
            min-width: 0;
            min-height: 0;
            overflow: hidden;
            background: var(--panel-muted);
            border-right: 1px solid var(--line-soft);
            display: flex;
            flex-direction: column;
        }

        .brand-area {
            flex: 0 0 auto;
            padding: 22px 18px 16px;
            border-bottom: 1px solid var(--line-soft);
        }

        .brand-header {
            display: flex;
            align-items: center;
            gap: 12px;
            margin-bottom: 16px;
        }

        .brand-logo {
            position: relative;
            flex: 0 0 auto;
            width: 40px;
            height: 40px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            border-radius: 12px;
            background: linear-gradient(135deg,
                color-mix(in srgb, var(--blue, #4f7cff) 92%, #fff 8%) 0%,
                color-mix(in srgb, var(--blue, #4f7cff) 60%, #a78bfa 40%) 100%);
            color: #fff;
            box-shadow:
                0 6px 16px -6px color-mix(in srgb, var(--blue, #4f7cff) 70%, transparent),
                inset 0 1px 0 rgba(255, 255, 255, .35);
        }

        .brand-logo svg {
            width: 22px;
            height: 22px;
            display: block;
            filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .15));
        }

        .brand-logo-glow {
            position: absolute;
            inset: -6px;
            border-radius: 16px;
            background: radial-gradient(closest-side,
                color-mix(in srgb, var(--blue, #4f7cff) 35%, transparent) 0%,
                transparent 70%);
            opacity: .55;
            pointer-events: none;
            z-index: -1;
            animation: brand-logo-pulse 4.2s ease-in-out infinite;
        }

        @keyframes brand-logo-pulse {
            0%, 100% { opacity: .35; transform: scale(1); }
            50% { opacity: .7; transform: scale(1.06); }
        }

        .brand-text {
            display: flex;
            flex-direction: column;
            line-height: 1.1;
            min-width: 0;
        }

        .brand-title {
            font-size: 20px;
            font-weight: 700;
            letter-spacing: -.02em;
            background: linear-gradient(90deg,
                var(--text) 0%,
                color-mix(in srgb, var(--text) 70%, var(--blue, #4f7cff) 30%) 100%);
            -webkit-background-clip: text;
            background-clip: text;
            -webkit-text-fill-color: transparent;
            margin: 0;
        }

        .brand-subtitle {
            font-size: 11px;
            font-weight: 600;
            letter-spacing: .14em;
            text-transform: uppercase;
            color: var(--muted-2, var(--muted));
            margin-top: 4px;
        }

        .toolbar-row {
            display: flex;
            gap: 8px;
        }

        .new-chat-btn {
            flex: 1;
            min-height: 40px;
            padding: 0 16px;
            border-radius: 999px;
            background: var(--blue);
            color: #fff;
            font-weight: 600;
        }

        .new-chat-btn:hover {
            background: var(--blue-hover);
        }

        .settings-btn {
            min-height: 40px;
            padding: 0 14px;
            border-radius: 999px;
            background: var(--panel);
            color: var(--text);
            border: 1px solid var(--line);
            font-weight: 600;
        }

        .theme-btn {
            width: 38px;
            height: 38px;
            padding: 0;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            font-size: 18px;
            border-radius: 999px;
            background: var(--panel);
            color: var(--text);
            border: 1px solid var(--line);
        }

        .sidebar-toggle-btn {
            min-height: 40px;
            padding: 0 14px;
            border-radius: 999px;
            background: var(--panel);
            color: var(--text);
            border: 1px solid var(--line);
            font-weight: 600;
        }

        .settings-btn:hover, .theme-btn:hover, .sidebar-toggle-btn:hover {
            background: var(--page);
        }

        .conversation-list {
            flex: 1 1 auto;
            min-height: 0;
            overflow-y: auto;
            overflow-x: hidden;
            overscroll-behavior: contain;
            padding: 10px;
            scrollbar-gutter: stable;
        }

        .conversation-item {
            width: 100%;
            display: grid;
            grid-template-columns: minmax(0, 1fr) auto;
            gap: 8px;
            align-items: center;
            padding: 12px 10px 12px 12px;
            margin-bottom: 4px;
            border-radius: 12px;
            border: 1px solid transparent;
            color: var(--text);
            cursor: pointer;
            background: transparent;
        }

        .conversation-item:hover, .conversation-item.active {
            background: var(--panel);
            border-color: var(--line-soft);
        }

        .conversation-item.active {
            border-color: var(--line);
        }

        .conversation-title {
            min-width: 0;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            font-size: 14px;
            font-weight: 500;
        }

        .conversation-meta {
            color: var(--muted-2);
            font-size: 12px;
            margin-top: 3px;
        }

        .conversation-actions {
            display: flex;
            gap: 3px;
            opacity: .82;
        }

        .icon-btn {
            width: 28px;
            height: 28px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            border-radius: 50%;
            background: transparent;
            color: var(--muted);
        }

        .icon-btn:hover {
            background: var(--page);
            color: var(--text);
        }

        .main {
            min-width: 0;
            min-height: 0;
            height: 100%;
            width: 100%;
            overflow: hidden;
            display: flex;
            flex-direction: column;
            background: var(--bg);
        }

        .app-header {
            flex: 0 0 auto;
            padding: 16px 28px 0;
            background:
                linear-gradient(180deg, color-mix(in srgb, var(--bg) 96%, var(--panel) 4%) 0%, color-mix(in srgb, var(--bg) 88%, transparent) 100%);
            border-bottom: 1px solid var(--line-soft);
            backdrop-filter: blur(18px);
            -webkit-backdrop-filter: blur(18px);
            z-index: 12;
        }

        .app-header-inner {
            width: min(1120px, 100%);
            margin: 0 auto;
            display: flex;
            flex-direction: column;
            gap: 10px;
        }

        /* ==================== 标签栏（分段控件） ==================== */
        .app-tabs {
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .app-tabs-inner {
            display: inline-flex;
            align-items: center;
            padding: 5px;
            border-radius: 18px;
            background: color-mix(in srgb, var(--panel) 76%, transparent);
            border: 1px solid color-mix(in srgb, var(--line-soft) 78%, transparent);
            box-shadow: inset 0 1px 0 rgba(255, 255, 255, .16), 0 10px 24px rgba(15, 23, 42, .05);
            gap: 4px;
        }

        :root[data-theme="dark"] .app-tabs-inner {
            background: color-mix(in srgb, var(--panel) 88%, transparent);
            border-color: color-mix(in srgb, var(--line) 72%, transparent);
            box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04), 0 12px 30px rgba(0, 0, 0, .22);
        }

        .app-tab {
            min-width: 112px;
            min-height: 40px;
            padding: 0 18px;
            border: 0;
            border-radius: 14px;
            background: transparent;
            color: var(--muted);
            font-weight: 600;
            font-size: 13px;
            letter-spacing: .01em;
            cursor: pointer;
            transition: color .18s ease, background-color .18s ease, box-shadow .18s ease, transform .18s ease;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 6px;
            position: relative;
            white-space: nowrap;
        }

        .app-tab:hover {
            color: var(--text);
            background: color-mix(in srgb, var(--panel) 78%, transparent);
        }

        .app-tab.active {
            background: linear-gradient(180deg, color-mix(in srgb, var(--panel) 96%, white 4%) 0%, var(--panel) 100%);
            color: var(--text);
            box-shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 20px rgba(15, 23, 42, .08);
        }

        :root[data-theme="dark"] .app-tab.active {
            background: linear-gradient(180deg, color-mix(in srgb, var(--panel) 94%, white 6%) 0%, var(--panel) 100%);
            box-shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 10px 24px rgba(0, 0, 0, .28);
        }

        .app-tab .tab-badge-new {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            min-width: 30px;
            height: 18px;
            padding: 0 6px;
            border-radius: 999px;
            background: color-mix(in srgb, var(--blue) 14%, transparent);
            border: 1px solid color-mix(in srgb, var(--blue) 24%, transparent);
            color: var(--blue);
            font-size: 9px;
            font-weight: 700;
            line-height: 1;
            letter-spacing: .08em;
            margin-left: 2px;
        }

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

        .tab-content.active {
            display: flex;
        }

        /* ==================== 站点统计 ==================== */
        .site-stats {
            flex: 0 0 auto;
            text-align: center;
            padding: 6px 14px 8px;
            font-size: 11px;
            color: var(--muted-2);
            background: var(--bg);
            letter-spacing: .02em;
        }

        .site-stats span {
            color: var(--muted);
            font-weight: 600;
        }

        /* ==================== 在线人数徽章 ==================== */
        .online-badges {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            margin-left: 8px;
            flex-wrap: wrap;
            justify-content: center;
            vertical-align: middle;
        }

        .online-badge {
            display: inline-flex;
            align-items: center;
            gap: 3px;
            padding: 2px 8px;
            border-radius: 999px;
            font-size: 10px;
            font-weight: 600;
            line-height: 1.4;
            border: 1px solid transparent;
        }

        .online-badge span,
        .online-total span {
            color: inherit !important;
            font-weight: 700;
        }

        .online-badge.chatting {
            background: rgba(59, 130, 246, 0.10);
            border-color: rgba(59, 130, 246, 0.25);
            color: #2563eb !important;
        }

        .online-badge.imaging {
            background: rgba(168, 85, 247, 0.10);
            border-color: rgba(168, 85, 247, 0.25);
            color: #9333ea !important;
        }

        .online-badge.idle {
            background: rgba(148, 163, 184, 0.12);
            border-color: rgba(148, 163, 184, 0.25);
            color: #64748b !important;
        }

        .online-total {
            margin-left: 4px;
            padding: 2px 8px;
            border-radius: 999px;
            background: rgba(34, 197, 94, 0.10);
            border: 1px solid rgba(34, 197, 94, 0.25);
            font-size: 10px;
            font-weight: 600;
            color: #16a34a !important;
        }

        :root[data-theme="dark"] .online-badge.chatting {
            background: rgba(96, 165, 250, 0.16);
            border-color: rgba(96, 165, 250, 0.35);
            color: #93c5fd !important;
        }

        :root[data-theme="dark"] .online-badge.imaging {
            background: rgba(192, 132, 252, 0.16);
            border-color: rgba(192, 132, 252, 0.35);
            color: #d8b4fe !important;
        }

        :root[data-theme="dark"] .online-badge.idle {
            background: rgba(148, 163, 184, 0.18);
            border-color: rgba(148, 163, 184, 0.35);
            color: #cbd5e1 !important;
        }

        :root[data-theme="dark"] .online-total {
            background: rgba(74, 222, 128, 0.16);
            border-color: rgba(74, 222, 128, 0.35);
            color: #86efac !important;
        }

        @media (max-width: 640px) {
            .online-badges {
                gap: 4px;
                margin-left: 4px;
            }
            .online-badge,
            .online-total {
                font-size: 9px;
                padding: 1px 6px;
            }
        }

        /* ==================== 消息中的图片 ==================== */
        .message-image {
            margin: 10px 0;
            border-radius: 14px;
            overflow: hidden;
            border: 1px solid var(--line-soft);
            background: var(--panel-muted);
            max-width: 600px;
        }

        .message-image img {
            display: block;
            width: 100%;
            height: auto;
            cursor: zoom-in;
            border-radius: 0;
        }

        .image-meta {
            padding: 10px 12px;
            border-top: 1px solid var(--line-soft);
        }

        .image-prompt {
            display: block;
            font-size: 13px;
            color: var(--muted);
            margin-bottom: 8px;
            line-height: 1.45;
            word-break: break-word;
        }

        .image-actions {
            display: flex;
            gap: 6px;
            flex-wrap: wrap;
        }

        .image-actions button {
            padding: 5px 11px;
            font-size: 12px;
            border-radius: 999px;
            border: 1px solid var(--line);
            background: var(--panel);
            color: var(--text);
            cursor: pointer;
            transition: all .15s ease;
        }

        .image-actions button:hover {
            background: var(--blue-soft);
            border-color: rgba(0, 113, 227, .28);
            color: var(--blue);
        }

        /* ==================== 图片灯箱 ==================== */
        .image-lightbox {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(0, 0, 0, .92);
            z-index: 2000;
            align-items: center;
            justify-content: center;
            padding: 30px;
        }

        .image-lightbox.active {
            display: flex;
        }

        .image-lightbox img {
            max-width: 92%;
            max-height: 92vh;
            border-radius: 10px;
            box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
        }

        .image-lightbox-close {
            position: absolute;
            top: 18px;
            right: 22px;
            width: 44px;
            height: 44px;
            border: none;
            border-radius: 50%;
            background: rgba(255, 255, 255, .12);
            color: #fff;
            font-size: 24px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .image-lightbox-close:hover {
            background: rgba(255, 255, 255, .22);
        }

        .topbar {
            position: relative;
            z-index: 60;
            min-height: 74px;
            padding: 18px 22px 20px;
            border: 1px solid color-mix(in srgb, var(--line-soft) 82%, transparent);
            border-radius: 24px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 18px;
            background: color-mix(in srgb, var(--panel) 78%, transparent);
            box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), 0 14px 36px rgba(15, 23, 42, .06);
            backdrop-filter: blur(18px);
            -webkit-backdrop-filter: blur(18px);
        }

        :root[data-theme="dark"] .topbar {
            background: color-mix(in srgb, var(--panel) 88%, transparent);
            border-color: color-mix(in srgb, var(--line) 76%, transparent);
            box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04), 0 16px 36px rgba(0, 0, 0, .24);
        }

        .chat-title-wrap {
            min-width: 0;
            display: flex;
            flex-direction: column;
            gap: 5px;
        }

        .chat-title {
            min-width: 0;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            color: var(--text);
            font-size: 22px;
            line-height: 1.15;
            font-weight: 720;
            letter-spacing: -.04em;
        }

        .chat-subtitle {
            color: var(--muted);
            font-size: 13px;
            line-height: 1.45;
        }

        .topbar-actions {
            display: flex;
            align-items: center;
            gap: 8px;
            flex-shrink: 0;
            flex-wrap: wrap;
            justify-content: flex-end;
        }

        .status-pill {
            color: var(--text);
            font-size: 12px;
            font-weight: 600;
            min-height: 40px;
            padding: 0 14px;
            border: 1px solid color-mix(in srgb, var(--line) 88%, transparent);
            border-radius: 14px;
            background: color-mix(in srgb, var(--panel) 94%, transparent);
            max-width: 240px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            box-shadow: inset 0 1px 0 rgba(255, 255, 255, .14);
        }
        .balance-pill {
            display: inline-flex;
            align-items: center;
            color: var(--text);
            font-size: 12px;
            font-weight: 600;
            min-height: 40px;
            padding: 0 12px;
            border: 1px solid color-mix(in srgb, var(--line) 88%, transparent);
            border-radius: 14px;
            background: color-mix(in srgb, var(--panel) 94%, transparent);
            white-space: nowrap;
            box-shadow: inset 0 1px 0 rgba(255, 255, 255, .14);
            user-select: none;
        }

        .top-model-select {
            position: relative;
            max-width: 260px;
            min-width: 168px;
        }

        .thinking-mode-toggle {
            display: inline-flex;
            align-items: stretch;
            min-height: 40px;
            padding: 3px;
            border: 1px solid color-mix(in srgb, var(--line) 88%, transparent);
            border-radius: 14px;
            background: color-mix(in srgb, var(--panel) 94%, transparent);
            box-shadow: inset 0 1px 0 rgba(255, 255, 255, .14);
            gap: 2px;
            flex-shrink: 0;
        }
        .thinking-mode-btn {
            appearance: none;
            border: 0;
            background: transparent;
            color: var(--muted);
            font-size: 12px;
            font-weight: 600;
            padding: 0 12px;
            border-radius: 11px;
            cursor: pointer;
            white-space: nowrap;
        }
        .thinking-mode-btn:hover {
            color: var(--text);
        }
        .thinking-mode-btn.active {
            background: color-mix(in srgb, var(--accent, #6366f1) 18%, var(--panel));
            color: var(--text);
            box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent, #6366f1) 40%, transparent);
        }

        .model-pill {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 10px;
            width: 100%;
            text-align: left;
            appearance: none;
        }

        .model-pill::after {
            content: "⌄";
            color: var(--muted-2);
            flex: 0 0 auto;
        }

        .top-model-options {
            position: absolute;
            top: calc(100% + 8px);
            right: 0;
            z-index: 50;
            display: none;
            width: min(320px, 82vw);
            max-height: 280px;
            overflow-y: auto;
            padding: 6px;
            border: 1px solid var(--line);
            border-radius: 16px;
            background: color-mix(in srgb, var(--panel) 96%, transparent);
            box-shadow: var(--shadow-pop);
            backdrop-filter: blur(18px);
            -webkit-backdrop-filter: blur(18px);
        }

        .top-model-select.open .top-model-options {
            display: block;
        }

        .messages {
            flex: 1;
            min-height: 0;
            overflow-y: auto;
            overflow-x: hidden;
            overscroll-behavior: contain;
            padding: 28px 28px 120px;
            scroll-behavior: auto;
            scrollbar-gutter: stable;
            background: var(--bg);
        }

        .messages-inner {
            width: min(920px, 100%);
            margin: 0 auto;
        }

        .empty-state {
            width: min(760px, 100%);
            margin: 9vh auto 0;
            text-align: center;
            padding: 28px 20px;
        }

        .empty-icon {
            width: 70px;
            height: 70px;
            margin: 0 auto 18px;
            border-radius: 22px;
            background: var(--panel);
            border: 1px solid var(--line-soft);
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--blue);
            font-size: 30px;
        }

        .empty-state h1 {
            margin: 0;
            font-size: clamp(34px, 5vw, 54px);
            line-height: 1.04;
            letter-spacing: -.055em;
            font-weight: 700;
        }

        .empty-state p {
            margin: 14px auto 0;
            max-width: 520px;
            color: var(--muted);
            font-size: 16px;
            line-height: 1.48;
        }

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

        .message-row {
            display: grid;
            grid-template-columns: 40px minmax(0, 1fr) 40px;
            gap: 14px;
            margin: 0 0 24px;
            align-items: start;
            animation: messageEnter 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
        }

        .assistant.message-row {
            grid-template-columns: 40px minmax(0, 1fr) 40px;
        }

        .assistant .avatar {
            grid-column: 1;
        }

        .assistant .message-block {
            grid-column: 2;
            text-align: left;
        }

        .assistant .message-card {
            margin-right: auto;
            margin-left: 0;
        }

        .user.message-row {
            grid-template-columns: 40px minmax(0, 1fr) 40px;
        }

        .user .message-block {
            grid-column: 2;
            text-align: right;
        }

        .user .message-card {
            margin-left: auto;
            margin-right: 0;
            text-align: left;
        }

        .avatar {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 12px;
            font-weight: 700;
            background: var(--panel-muted);
            color: var(--muted);
            border: 1px solid var(--line-soft);
            user-select: none;
        }

        .user .avatar {
            grid-column: 3;
            grid-row: 1;
            background: var(--text);
            color: var(--bg);
            border-color: var(--text);
        }

        .message-block {
            min-width: 0;
        }

        .role-label {
            margin: 0 0 6px;
            color: var(--muted);
            font-size: 12px;
            font-weight: 700;
            letter-spacing: .02em;
        }

        .user .role-label {
            text-align: right;
        }

        .message-card {
            width: fit-content;
            max-width: 850px;
            padding: 14px 16px;
            border: 1px solid var(--line-soft);
            border-radius: 18px;
            background: var(--panel);
            color: var(--text);
            line-height: 1.65;
            font-size: 15px;
            overflow-wrap: anywhere;
        }
        .app-shell.wide-mode .assistant .message-card {
            width: 100% !important;
            max-width: none !important;
        }
        .assistant .message-card {
            border-top-left-radius: 6px;
        }

        .user .message-card {
            background: var(--panel-muted);
            border-color: var(--line-soft);
            border-top-right-radius: 6px;
        }

        .message-actions {
            display: flex;
            gap: 8px;
            margin-top: 8px;
        }

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

        .action-btn {
            min-height: 30px;
            padding: 0 10px;
            border: 1px solid var(--line);
            border-radius: 999px;
            background: var(--panel);
            color: var(--muted);
            font-size: 12px;
        }

        .action-btn:hover {
            color: var(--text);
            background: var(--page);
        }

        .action-btn.primary-action {
            color: var(--blue);
            border-color: rgba(0, 113, 227, .28);
            background: var(--blue-soft);
        }

        .action-btn.copied {
            color: var(--green);
            border-color: rgba(29, 127, 58, .35);
            background: rgba(29, 127, 58, .08);
        }

        .message-card strong {
            font-weight: 700;
            color: var(--text);
            box-shadow: inset 0 -0.55em 0 rgba(0, 113, 227, 0.2);
            border-radius: 2px;
            padding: 0 2px;
            transition: box-shadow 0.2s ease;
        }

        :root[data-theme="dark"] .message-card strong {
            box-shadow: inset 0 -0.55em 0 rgba(41, 151, 255, 0.35);
        }

        .message-card h1, .message-card h2, .message-card h3, .message-card h4, .message-card h5, .message-card h6 {
            margin: 18px 0 8px;
            line-height: 1.2;
            letter-spacing: -.03em;
        }

        .assistant .message-card h1,
        .assistant .message-card h2,
        .assistant .message-card h3 {
            color: var(--blue);
            border-bottom: 1px dashed var(--line);
            padding-bottom: 6px;
            margin-top: 24px;
        }

        .assistant .message-card h1::before { content: '✨ '; }
        .assistant .message-card h2::before { content: '📌 '; }
        .assistant .message-card h3::before { content: '🔸 '; }
        .assistant .message-card h4::before { content: '🔹 '; }

        :root[data-theme="dark"] .assistant .message-card h1,
        :root[data-theme="dark"] .assistant .message-card h2,
        :root[data-theme="dark"] .assistant .message-card h3 {
            color: var(--blue-hover);
        }

        .message-card h1:first-child, .message-card h2:first-child, .message-card h3:first-child {
            margin-top: 0;
        }

        .message-card p {
            margin: 8px 0;
        }

        .message-card p:first-child {
            margin-top: 0;
        }

        .message-card p:last-child {
            margin-bottom: 0;
        }

        .message-card ul, .message-card ol {
            margin: 8px 0;
            padding-left: 23px;
        }

        .message-card li {
            margin: 3px 0;
        }

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

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

        .message-card code {
            font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
            font-size: .92em;
            padding: 2px 5px;
            border-radius: 6px;
            background: var(--page);
            border: 1px solid var(--line-soft);
        }

        .message-content-shell {
            position: relative;
        }

        .message-content-body {
            position: relative;
        }

        .message-content-body.collapsed {
            max-height: 260px;
            overflow: hidden;
        }

        .message-content-body.collapsed::after {
            content: "";
            position: absolute;
            left: 0;
            right: 0;
            bottom: 0;
            height: 72px;
            pointer-events: none;
            background: linear-gradient(to bottom, transparent, var(--panel));
        }

        .user .message-content-body.collapsed::after {
            background: linear-gradient(to bottom, transparent, var(--panel-muted));
        }

        .message-expand-btn {
            margin-top: 8px;
            min-height: 30px;
            padding: 0 11px;
            border: 1px solid var(--line);
            border-radius: 999px;
            background: var(--panel);
            color: var(--blue);
            font-size: 12px;
            font-weight: 700;
        }

        .message-expand-btn:hover {
            background: var(--blue-soft);
            border-color: rgba(0, 113, 227, .28);
        }

        .code-block {
            position: relative;
            margin: 12px 0;
        }

        .message-card pre {
            margin: 0;
            padding: 42px 13px 13px;
            overflow-x: auto;
            background: var(--page);
            border: 1px solid var(--line-soft);
            border-radius: 12px;
        }

        .code-block::before {
            content: "";
            position: absolute;
            top: 14px;
            left: 14px;
            width: 11px;
            height: 11px;
            border-radius: 50%;
            background: #ff5f56;
            box-shadow: 18px 0 0 #ffbd2e, 36px 0 0 #27c93f;
            z-index: 2;
        }

        .message-card pre code {
            padding: 0;
            border: 0;
            background: transparent;
        }

        .code-copy-btn {
            position: absolute;
            top: 8px;
            right: 8px;
            z-index: 2;
            width: 32px;
            height: 32px;
            border: 1px solid var(--line);
            border-radius: 9px;
            background: var(--panel);
            color: var(--muted);
            display: inline-flex;
            align-items: center;
            justify-content: center;
            font-weight: 700;
            line-height: 1;
        }

        .code-copy-btn:hover {
            color: var(--text);
            background: var(--blue-soft);
            border-color: rgba(0, 113, 227, .28);
        }

        .code-copy-btn.copied {
            color: var(--green);
            border-color: rgba(29, 127, 58, .35);
            background: rgba(29, 127, 58, .08);
        }

        .message-card blockquote {
            margin: 12px 0;
            padding: 10px 14px;
            border-left: 4px solid var(--blue);
            background: var(--blue-soft);
            border-radius: 0 8px 8px 0;
            color: var(--text);
        }

        .message-card table {
            width: 100%;
            border-collapse: collapse;
            margin: 12px 0;
            font-size: 14px;
        }

        .message-card th, .message-card td {
            border: 1px solid var(--line-soft);
            padding: 8px;
            text-align: left;
        }

        .message-card th {
            background: var(--page);
        }

        .message-card img {
            max-width: 100%;
            border-radius: 12px;
        }

        .message-card hr {
            border: 0;
            border-top: 1px solid var(--line-soft);
            margin: 16px 0;
        }

        .thinking-section {
            margin-bottom: 12px;
            border: 1px solid var(--line-soft);
            border-radius: 12px;
            background: var(--panel-muted);
            overflow: hidden;
        }

        body.thinking-hidden .thinking-section {
            display: none !important;
        }

        .typing-indicator {
            display: inline-flex;
            align-items: baseline;
            gap: 4px;
            padding: 4px 2px;
            line-height: 1;
            color: var(--muted);
            font-size: 14px;
            font-weight: 500;
        }
        .typing-indicator-label {
            letter-spacing: 0.2px;
            background: linear-gradient(
                90deg,
                var(--muted) 0%,
                var(--muted) 35%,
                color-mix(in srgb, var(--accent, #6366f1) 90%, var(--text)) 50%,
                var(--muted) 65%,
                var(--muted) 100%
            );
            background-size: 220% 100%;
            -webkit-background-clip: text;
            background-clip: text;
            -webkit-text-fill-color: transparent;
            animation: typing-shimmer 1.6s linear infinite;
        }
        .typing-indicator-dots {
            display: inline-flex;
            align-items: baseline;
            gap: 2px;
            margin-left: 2px;
        }
        .typing-indicator-dots span {
            display: inline-block;
            opacity: 0.25;
            animation: typing-dot 1.2s infinite ease-in-out;
        }
        .typing-indicator-dots span:nth-child(2) { animation-delay: 0.18s; }
        .typing-indicator-dots span:nth-child(3) { animation-delay: 0.36s; }
        @keyframes typing-dot {
            0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
            40% { opacity: 1; transform: translateY(-2px); }
        }
        @keyframes typing-shimmer {
            0% { background-position: 100% 0; }
            100% { background-position: -100% 0; }
        }

        .thinking-header {
            width: 100%;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            padding: 9px 11px;
            border-bottom: 1px solid var(--line-soft);
            background: var(--panel-muted);
            color: var(--muted);
            font-size: 13px;
            text-align: left;
        }

        .thinking-badge {
            font-size: 11px;
            font-weight: 600;
            color: var(--muted-2);
        }

        .thinking-content {
            max-height: 260px;
            overflow-y: auto;
            padding: 11px;
            color: var(--muted);
            font-size: 13px;
            line-height: 1.58;
        }

        .thinking-content.collapsed {
            display: none;
        }

        .composer {
            flex: 0 0 auto;
            border-top: 1px solid var(--line-soft);
            padding: 16px 28px 22px;
            background: color-mix(in srgb, var(--bg) 85%, transparent);
            backdrop-filter: blur(16px);
            -webkit-backdrop-filter: blur(16px);
            z-index: 10;
        }

        .composer-inner {
            width: min(920px, 100%);
            margin: 0 auto;
            display: grid;
            grid-template-columns: minmax(0, 1fr) auto;
            gap: 10px;
            align-items: end;
        }

        .input-wrap {
            min-width: 0;
            border: 1px solid var(--line);
            border-radius: 18px;
            background: var(--panel);
            overflow: hidden;
        }

        .chat-input {
            display: block;
            min-height: 48px;
            max-height: 180px;
            padding: 13px 15px;
            resize: none;
            font-size: 15px;
            line-height: 1.45;
        }

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

        .chat-input:disabled {
            color: var(--muted-2);
            background: var(--panel-muted);
        }

        .send-btn {
            min-height: 48px;
            padding: 0 22px;
            border-radius: 999px;
            background: var(--blue);
            color: #fff;
            font-weight: 600;
        }

        .send-btn:hover {
            background: var(--blue-hover);
        }

        .send-btn:disabled {
            background: var(--muted-2);
            cursor: not-allowed;
        }

        .send-btn.stop {
            background: var(--red);
        }

        .modal {
            position: fixed;
            inset: 0;
            z-index: 1000;
            display: none;
            align-items: center;
            justify-content: center;
            padding: 20px;
            background: rgba(0, 0, 0, .32);
        }

        .modal.active {
            display: flex;
        }

        .modal-content {
            width: min(520px, 100%);
            max-height: min(82vh, 760px);
            overflow-y: auto;
            background: var(--panel);
            color: var(--text);
            border-radius: 20px;
            border: 1px solid var(--line-soft);
            box-shadow: var(--shadow-pop);
            padding: 24px;
        }

        .modal-header {
            margin: 0 0 18px;
            font-size: 22px;
            line-height: 1.18;
            letter-spacing: -.035em;
            font-weight: 700;
        }

        .form-group {
            margin-bottom: 15px;
        }

        .form-label {
            display: block;
            margin: 0 0 7px;
            color: var(--text);
            font-size: 13px;
            font-weight: 700;
        }

        .form-label-row {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 10px;
            margin: 0 0 7px;
        }

        .form-label-row .form-label {
            margin: 0;
        }

        .buy-api-key-link {
            color: #d70015;
            font-size: 13px;
            font-weight: 700;
            text-decoration: none;
            white-space: nowrap;
        }

        .buy-api-key-link:hover {
            text-decoration: underline;
        }

        .info-text {
            margin-top: 5px;
            color: var(--muted);
            font-size: 12px;
            line-height: 1.35;
        }

        .import-export-btns, .modal-actions, .fetch-models-section, .model-mode-toggle {
            display: flex;
            gap: 9px;
        }

        .import-export-btns {
            margin-bottom: 16px;
        }

        .fetch-models-section {
            align-items: end;
            margin-bottom: 15px;
        }

        .fetch-models-section .form-group {
            margin-bottom: 0;
            flex: 1;
        }

        .model-mode-toggle {
            flex-wrap: wrap;
            padding: 10px;
            margin-bottom: 15px;
            background: var(--page);
            border-radius: 13px;
        }

        .model-mode-toggle label {
            display: inline-flex;
            gap: 6px;
            align-items: center;
            color: var(--muted);
            font-size: 13px;
            font-weight: 600;
            cursor: pointer;
        }

        .native-select-hidden {
            position: absolute;
            width: 1px;
            height: 1px;
            opacity: 0;
            pointer-events: none;
            clip-path: inset(50%);
        }

        .custom-select {
            position: relative;
        }

        .custom-select-trigger {
            width: 100%;
            min-height: 44px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            padding: 0 12px 0 14px;
            border-radius: 12px;
            border: 1px solid var(--line);
            background: var(--panel);
            color: var(--text);
            text-align: left;
        }

        .custom-select-trigger:hover {
            background: var(--page);
        }

        .custom-select-text {
            min-width: 0;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            font-size: 14px;
        }

        .custom-select-arrow {
            color: var(--muted);
            font-size: 16px;
            line-height: 1;
            transition: transform .12s ease;
        }

        .custom-select.open .custom-select-arrow {
            transform: rotate(180deg);
        }

        .custom-options {
            position: absolute;
            left: 0;
            right: 0;
            top: calc(100% + 6px);
            z-index: 20;
            display: none;
            max-height: 260px;
            overflow-y: auto;
            padding: 6px;
            border: 1px solid var(--line);
            border-radius: 14px;
            background: var(--panel);
            box-shadow: var(--shadow-pop);
        }

        .custom-select.open .custom-options {
            display: block;
        }

        .modal-actions {
            justify-content: flex-end;
            margin-top: 22px;
            flex-wrap: wrap;
        }

        .btn {
            min-height: 40px;
            padding: 0 16px;
            border-radius: 999px;
            font-weight: 600;
        }

        .btn-primary, .btn-info {
            background: var(--blue);
            color: #fff;
        }

        .btn-primary:hover, .btn-info:hover {
            background: var(--blue-hover);
        }

        .btn-secondary {
            background: var(--panel);
            color: var(--text);
            border: 1px solid var(--line);
        }

        .btn-secondary:hover {
            background: var(--page);
        }

        .btn-danger {
            background: var(--red);
            color: #fff;
        }

        .small-btn {
            min-height: 34px;
            padding: 0 12px;
            font-size: 12px;
        }

        .sr-only {
            position: absolute;
            width: 1px;
            height: 1px;
            padding: 0;
            margin: -1px;
            overflow: hidden;
            clip: rect(0, 0, 0, 0);
            border: 0;
        }

        .composer-inner.file-enabled {
            grid-template-columns: auto auto minmax(0, 1fr) auto;
        }

        .attach-btn,
        .prompt-lib-btn {
            height: 48px;
            padding: 0 14px;
            border: 1px solid var(--line);
            border-radius: 999px;
            background: var(--panel);
            color: var(--text);
            font-size: 14px;
            line-height: 1;
            font-weight: 500;
            cursor: pointer;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 4px;
            white-space: nowrap;
        }

        .attach-btn:hover,
        .prompt-lib-btn:hover {
            background: var(--page);
            border-color: var(--blue);
            color: var(--blue);
        }

        /* Announcement modal */
        .announcement-content {
            width: min(560px, 94vw);
            max-height: 80vh;
            display: flex;
            flex-direction: column;
        }

        .announcement-body {
            flex: 1 1 auto;
            overflow-y: auto;
            padding: 4px 2px 8px;
            font-size: 14px;
            line-height: 1.65;
            color: var(--text);
        }

        .announcement-body h1,
        .announcement-body h2,
        .announcement-body h3,
        .announcement-body h4 {
            margin: 6px 0 10px;
            color: var(--text);
        }

        .announcement-body p {
            margin: 8px 0;
        }

        .announcement-body ul,
        .announcement-body ol {
            margin: 8px 0;
            padding-left: 22px;
        }

        .announcement-body a {
            color: var(--blue);
            text-decoration: none;
        }

        .announcement-body a:hover {
            text-decoration: underline;
        }

        .announcement-body img {
            max-width: 100%;
            border-radius: 8px;
        }

        .announcement-body code {
            background: var(--panel-muted);
            padding: 1px 6px;
            border-radius: 4px;
            font-size: 13px;
        }

        .announcement-skip {
            flex: 1 1 auto;
            display: inline-flex;
            align-items: center;
            gap: 6px;
            font-size: 13px;
            color: var(--muted);
            cursor: pointer;
            user-select: none;
        }

        .announcement-skip input {
            margin: 0;
            cursor: pointer;
        }

        /* Prompt library modal */
        .prompt-lib-content {
            width: min(960px, 96vw);
            max-width: 960px;
            max-height: 88vh;
            display: flex;
            flex-direction: column;
        }

        .prompt-lib-toolbar {
            display: flex;
            gap: 10px;
            margin: 4px 0 10px;
        }

        .prompt-search-input {
            flex: 1 1 auto;
        }

        .prompt-tag-bar {
            display: flex;
            flex-wrap: wrap;
            gap: 6px;
            margin-bottom: 10px;
            max-height: 90px;
            overflow-y: auto;
            padding: 4px 0;
        }

        .prompt-tag-chip {
            display: inline-flex;
            align-items: center;
            padding: 4px 10px;
            border: 1px solid var(--line);
            border-radius: 999px;
            background: var(--panel);
            color: var(--text);
            font-size: 12px;
            cursor: pointer;
            user-select: none;
            transition: all .15s;
        }

        .prompt-tag-chip:hover {
            background: var(--page);
        }

        .prompt-tag-chip.active {
            background: var(--blue);
            color: #fff;
            border-color: var(--blue);
        }

        .prompt-list {
            flex: 1 1 auto;
            min-height: 320px;
            max-height: 56vh;
            overflow-y: auto;
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
            gap: 10px;
            padding: 4px;
        }

        .prompt-card {
            border: 1px solid var(--line);
            border-radius: 12px;
            background: var(--panel);
            padding: 12px 14px;
            cursor: pointer;
            transition: all .15s;
            display: flex;
            flex-direction: column;
            gap: 6px;
        }

        .prompt-card:hover {
            border-color: var(--blue);
            background: var(--page);
            transform: translateY(-1px);
        }

        .prompt-card-title {
            font-size: 14px;
            font-weight: 600;
            color: var(--text);
            line-height: 1.35;
        }

        .prompt-card-remark {
            font-size: 12px;
            color: var(--muted);
            line-height: 1.45;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;
        }

        .prompt-card-tags {
            display: flex;
            flex-wrap: wrap;
            gap: 4px;
            margin-top: 2px;
        }

        .prompt-card-tag {
            display: inline-block;
            padding: 1px 7px;
            border-radius: 4px;
            background: var(--panel-muted);
            color: var(--muted);
            font-size: 11px;
        }

        .prompt-list-empty {
            grid-column: 1 / -1;
            text-align: center;
            color: var(--muted-2);
            padding: 40px 0;
            font-size: 13px;
        }

        .prompt-detail-meta {
            font-size: 12px;
            color: var(--muted);
            margin-bottom: 10px;
            line-height: 1.5;
        }

        @media (max-width: 600px) {
            .prompt-list {
                grid-template-columns: 1fr;
            }
        }

        .pending-files {
            width: min(920px, 100%);
            margin: 0 auto 10px;
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
        }

        .file-chip {
            max-width: 260px;
            min-height: 32px;
            display: inline-flex;
            align-items: center;
            gap: 8px;
            padding: 5px 8px 5px 10px;
            border: 1px solid var(--line-soft);
            border-radius: 999px;
            background: var(--panel-muted);
            color: var(--text);
            font-size: 12px;
        }

        .file-chip-name {
            min-width: 0;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .file-chip-size {
            flex: 0 0 auto;
            color: var(--muted);
        }

        .file-chip-remove {
            width: 22px;
            height: 22px;
            border: 0;
            border-radius: 50%;
            background: transparent;
            color: var(--muted);
            cursor: pointer;
        }

        .file-chip-remove:hover {
            background: var(--page);
            color: var(--text);
        }

        .message-files {
            display: flex;
            flex-wrap: wrap;
            gap: 7px;
            margin-bottom: 10px;
        }

        .message-file-pill {
            max-width: 280px;
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 5px 9px;
            border: 1px solid var(--line-soft);
            border-radius: 999px;
            background: var(--page);
            color: var(--muted);
            font-size: 12px;
        }

        .message-file-pill span {
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        ::-webkit-scrollbar {
            width: 10px;
            height: 10px;
        }

        ::-webkit-scrollbar-track {
            background: transparent;
        }

        ::-webkit-scrollbar-thumb {
            background: color-mix(in srgb, var(--muted-2), transparent 28%);
            border-radius: 999px;
            border: 3px solid transparent;
            background-clip: padding-box;
        }

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

        @media (prefers-reduced-motion: reduce) {
            * {
                transition: none !important;
                scroll-behavior: auto !important;
                animation: none !important;
            }
        }

        @media (max-width: 900px) {
            .app-shell {
                grid-template-columns: 300px minmax(0, 1fr);
            }
            .topbar { padding: 14px 18px; }
            .messages { padding: 22px 18px 120px; }
            .composer { padding: 14px 18px 18px; }
            .status-pill { max-width: 180px; }
        }

        @media (max-width: 760px) {
            .app-header {
                padding: 12px 14px 0;
            }
            .app-header-inner {
                gap: 8px;
            }
            .app-tabs-inner {
                width: 100%;
                max-width: 100%;
                justify-content: center;
            }
            .app-tab {
                flex: 1;
                min-width: 0;
                padding: 0 10px;
                font-size: 12px;
                text-align: center;
            }
            .app-tab .tab-badge-new {
                min-width: 26px;
                height: 16px;
                padding: 0 5px;
                font-size: 8px;
            }
            .site-stats {
                padding: 4px 12px 6px;
                font-size: 10px;
            }
            .message-image {
                max-width: 100%;
            }
            .image-actions {
                flex-wrap: wrap;
            }
            .sidebar-toggle-btn {
                min-height: 36px;
                padding: 0 11px;
                font-size: 12px;
            }
            .app-shell {
                display: flex;
                flex-direction: column;
            }
            .sidebar {
                flex: none;
                width: 100%;
                max-height: 28vh;
                border-right: 0;
                border-bottom: 1px solid var(--line-soft);
            }
            .main {
                flex: 1;
                min-height: 0;
            }
            .brand-area { padding: 14px 12px 10px; }
            .brand-header { margin-bottom: 10px; }
            .brand-title { font-size: 19px; }
            .conversation-list { padding: 8px; }
            .topbar {
                min-height: 62px;
                padding: 12px 14px 14px;
                border-radius: 20px;
            }
            .chat-title { font-size: 19px; }
            .chat-subtitle { display: none; }
            .status-pill { display: block; max-width: 100%; }
            .messages { padding: 16px 12px 110px; }
            .empty-state { margin-top: 4vh; }
            .composer { padding: 10px 12px 12px; }
            .modal { align-items: flex-end; padding: 10px; }
            .modal-content {
                width: 100%;
                max-height: 88vh;
                border-radius: 18px;
                padding: 20px;
            }
            .custom-options { max-height: 220px; }
        }

        @media (max-width: 560px) {
            .toolbar-row {
                display: grid;
                grid-template-columns: 1fr auto;
            }
            .settings-btn { padding: 0 12px; }
            .app-header {
                padding: 10px 12px 0;
            }
            .topbar {
                padding: 12px 14px 14px;
                flex-direction: column;
                align-items: stretch;
                gap: 10px;
            }
            .topbar-actions {
                width: 100%;
                display: grid !important;
                grid-template-columns: minmax(0, 1fr) repeat(4, auto);
                justify-content: stretch;
                align-items: center;
                gap: 8px;
            }
            .top-model-select {
                min-width: 0;
                max-width: none;
            }
            .model-pill { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
            .top-model-options { left: 0; right: auto; width: min(100%, 88vw); }

            .message-row,
            .user.message-row,
            .assistant.message-row {
                grid-template-columns: 1fr;
                gap: 8px;
            }

            .avatar { display: none; }
            .user .message-block, .assistant .message-block { grid-column: auto; text-align: left; }
            .user .message-card, .assistant .message-card { width: auto; margin: 0; max-width: 100%;}
            .user .message-actions { justify-content: flex-start; }

            .composer-inner { grid-template-columns: 1fr; }
            .composer-inner.file-enabled {
                grid-template-columns: repeat(2, minmax(0, 1fr));
                grid-template-areas:
                    "prompt attach"
                    "input  input"
                    "send   send";
            }
            .composer-inner.file-enabled .prompt-lib-btn { grid-area: prompt; }
            .composer-inner.file-enabled .attach-btn { grid-area: attach; }
            .composer-inner.file-enabled .input-wrap { grid-area: input; }
            .composer-inner.file-enabled .send-btn { grid-area: send; }
            .send-btn { width: 100%; }
            .attach-btn, .prompt-lib-btn {
                min-height: 44px;
                padding: 0 12px;
                font-size: 13px;
                width: auto;
            }
            .file-chip { max-width: 100%; }
            .modal-actions .btn { flex: 1 1 auto; }
        }

        @media (max-width: 380px) {
            .brand-subtitle { display: none; }
            .brand-title { font-size: 18px; }
            .brand-logo { width: 34px; height: 34px; border-radius: 10px; }
            .brand-logo svg { width: 19px; height: 19px; }
            .empty-state h1 { font-size: 32px; }
        }
