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

/* Remix Icon 统一样式 - 继承父元素字体大小 */
[class^="ri-"], [class*=" ri-"] {
    font-style: normal;
    line-height: 1;
}

:root {
    /* Glassmorphism + Soft UI Evolution - Light Mode */
    --bg: #f8fafc;
    --bg2: rgba(255, 255, 255, 0.85);
    --card: rgba(255, 255, 255, 0.7);
    --text: #1e293b;
    --text2: #475569;
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --accent-light: rgba(99, 102, 241, 0.1);
    --user: #6366f1;
    --user-text: #ffffff;
    --ai: rgba(255, 255, 255, 0.9);
    --ai-text: #1e293b;
    --border: rgba(226, 232, 240, 0.8);
    --sidebar: rgba(255, 255, 255, 0.85);
    --shadow: rgba(15, 23, 42, 0.04);
    --shadow-md: rgba(15, 23, 42, 0.08);
    --shadow-lg: rgba(15, 23, 42, 0.12);
    --shadow-xl: rgba(15, 23, 42, 0.16);
    --success: #10b981;
    --success-light: rgba(16, 185, 129, 0.1);
    --warning: #f59e0b;
    --error: #ef4444;
    --radius: 16px;
    --radius-sm: 12px;
    --radius-lg: 20px;
    --radius-xl: 24px;
    --blur: 12px;
    --blur-lg: 20px;
}

[data-theme="dark"] {
    /* Glassmorphism + Soft UI Evolution - Dark Mode */
    --bg: #0f172a;
    --bg2: rgba(30, 41, 59, 0.85);
    --card: rgba(51, 65, 85, 0.7);
    --text: #f1f5f9;
    --text2: #94a3b8;
    --accent: #818cf8;
    --accent-hover: #6366f1;
    --accent-light: rgba(129, 140, 248, 0.15);
    --user: #6366f1;
    --user-text: #ffffff;
    --ai: rgba(30, 41, 59, 0.9);
    --ai-text: #f1f5f9;
    --border: rgba(51, 65, 85, 0.8);
    --sidebar: rgba(30, 41, 59, 0.85);
    --shadow: rgba(0, 0, 0, 0.2);
    --shadow-md: rgba(0, 0, 0, 0.3);
    --shadow-lg: rgba(0, 0, 0, 0.4);
    --shadow-xl: rgba(0, 0, 0, 0.5);
    --success: #34d399;
    --success-light: rgba(52, 211, 153, 0.15);
    --warning: #fbbf24;
    --error: #f87171;
    --blur: 12px;
    --blur-lg: 20px;
    --blur: 12px;
    --blur-lg: 20px;
}

html,
body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, sans-serif;
    transition: background-color 0.2s ease-out, color 0.2s ease-out;
}

body {
    background: var(--bg);
    color: var(--text);
    display: flex;
}

/* 移动端按钮默认隐藏 */
.mobile-header-btn {
    display: none !important;
}

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

.sidebar {
    width: 280px;
    background: var(--sidebar);
    backdrop-filter: blur(var(--blur));
    -webkit-backdrop-filter: blur(var(--blur));
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    box-shadow: 2px 0 16px var(--shadow);
}

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

.sidebar-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    line-height: 1;
}

.sidebar-header h2 i {
    font-size: 1.2rem;
    display: flex;
    align-items: center;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border);
}

.btn-settings {
    width: 100%;
    background: var(--bg2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.15s ease-out;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-settings:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}

.btn-new {
    background: var(--accent);
    color: white;
    border: none;
    padding: 0 16px;
    height: 32px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s ease-out;
    line-height: 1;
}

.btn-new i[class^="ri-"] {
    font-size: inherit;
    line-height: inherit;
}

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

/* 搜索栏样式 */
.search-bar {
    padding: 12px;
    display: flex;
    flex-direction: row;
    gap: 8px;
    align-items: center;
}

.search-input-wrap {
    flex: 1;
    position: relative;
    min-width: 0;
}

.search-input-wrap .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text2);
    pointer-events: none;
}

.search-input {
    display: block;
    width: 100%;
    height: 38px;
    padding: 0 12px 0 36px;
    margin: 0;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text);
    font-size: 0.85rem;
    box-sizing: border-box;
    transition: border-color 0.15s ease-out;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent);
}

.search-input::placeholder {
    color: var(--text2);
    opacity: 0.6;
}

.btn-refresh {
    width: 38px;
    height: 38px;
    min-width: 38px;
    padding: 0;
    margin: 0;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--text2);
    font-size: 1rem;
    transition: all 0.15s ease-out;
}

.btn-refresh:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}

.btn-refresh.loading i {
    animation: spin 1s linear infinite;
}

/* 角色卡分组列表 */
.persona-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 12px 12px 12px;
}

.persona-group {
    margin-bottom: 8px;
    animation: slideInRight 0.2s ease;
}

.persona-group-header {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    background: var(--bg2);
    backdrop-filter: blur(var(--blur));
    -webkit-backdrop-filter: blur(var(--blur));
    border: 1px solid var(--border);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s ease-out;
    gap: 10px;
}

.persona-group-header:hover {
    border-color: var(--accent);
    background: var(--accent-light);
    box-shadow: 0 2px 8px var(--shadow-md);
}

.persona-group.expanded .persona-group-header {
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    border-bottom-color: var(--border);
}

.persona-group-icon {
    width: 32px;
    height: 32px;
    background: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.8rem;
    font-weight: 600;
    flex-shrink: 0;
}

.persona-group-info {
    flex: 1;
    min-width: 0;
}

.persona-group-name {
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.persona-group-meta {
    font-size: 0.75rem;
    color: var(--text2);
    margin-top: 2px;
}

.persona-group-arrow {
    color: var(--text2);
    transition: all 0.2s;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

.persona-group-header:hover .persona-group-arrow {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent);
}

.persona-group.expanded .persona-group-arrow {
    transform: rotate(180deg);
}

.persona-group-actions {
    display: none;
    gap: 4px;
}

.persona-group-header:hover .persona-group-actions {
    display: flex;
}

.persona-sessions {
    display: none;
    background: var(--bg);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    padding: 8px;
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transition: opacity 0.2s ease, max-height 0.3s ease;
}

.persona-group.expanded .persona-sessions {
    display: block;
    opacity: 1;
    max-height: 500px;
}

.persona-session-item {
    padding: 10px 14px;
    border-radius: 12px;
    cursor: pointer;
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease-out;
    background: var(--bg2);
}

.persona-session-item:last-child {
    margin-bottom: 0;
}

.persona-session-item:hover {
    background: var(--accent-light);
    box-shadow: 0 2px 8px var(--shadow-md);
}

.persona-session-item.active {
    background: var(--accent);
    color: white;
}

.persona-session-info {
    flex: 1;
    overflow: hidden;
}

.persona-session-name {
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.persona-session-meta {
    font-size: 0.7rem;
    color: var(--text2);
    margin-top: 2px;
}

.persona-session-item.active .persona-session-meta {
    color: rgba(255, 255, 255, 0.8);
}

.persona-session-actions {
    display: none;
    gap: 4px;
}

.persona-session-item:hover .persona-session-actions,
.persona-session-item.active .persona-session-actions {
    display: flex;
}

.persona-add-session {
    padding: 8px 12px;
    text-align: center;
    color: var(--accent);
    font-size: 0.8rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease-out;
}

.persona-add-session:hover {
    background: var(--accent-light);
    box-shadow: 0 2px 8px var(--shadow-md);
}

.session-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 12px 12px 12px;
}

.session-item {
    padding: 12px 14px;
    border-radius: 12px;
    cursor: pointer;
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease-out;
    border: 1px solid transparent;
    animation: slideInRight 0.2s ease;
}

.session-item:hover {
    background: var(--card);
    backdrop-filter: blur(var(--blur));
    -webkit-backdrop-filter: blur(var(--blur));
    border-color: var(--border);
    box-shadow: 0 2px 8px var(--shadow-md);
}

.session-item.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.session-info {
    flex: 1;
    overflow: hidden;
}

.session-name {
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.session-meta {
    font-size: 0.75rem;
    color: var(--text2);
    margin-top: 4px;
}

.session-item.active .session-meta {
    color: rgba(255, 255, 255, 0.8);
}

.session-actions {
    display: none;
    gap: 4px;
}

.session-item:hover .session-actions,
.session-item.active .session-actions {
    display: flex;
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text2);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--accent-light);
    color: var(--accent);
}

.btn-icon.delete:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

.session-item.active .btn-icon {
    color: rgba(255, 255, 255, 0.8);
}

.session-item.active .btn-icon:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.session-item.active .btn-icon.delete:hover {
    background: rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.header {
    background: var(--bg2);
    backdrop-filter: blur(var(--blur));
    -webkit-backdrop-filter: blur(var(--blur));
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 12px var(--shadow);
}

.header h1 {
    font-size: 1.2rem;
    font-weight: 600;
}

.header-right {
    display: flex;
    gap: 12px;
    align-items: center;
}

.header input {
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0 14px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    transition: all 0.2s;
    width: 110px;
    height: 36px;
}

.header input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.dropdown {
    position: relative;
}

.dropdown-btn {
    background: var(--bg2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0 14px;
    height: 38px;
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 160px;
    justify-content: space-between;
    transition: all 0.15s ease-out;
}

.dropdown-btn:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}

.dropdown.open .dropdown-btn {
    border-color: var(--accent);
    background: var(--accent-light);
}

.dropdown.open .dropdown-btn svg {
    transform: rotate(180deg);
}

.dropdown-btn svg {
    transition: transform 0.15s ease-out;
    flex-shrink: 0;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--bg2);
    backdrop-filter: blur(var(--blur));
    -webkit-backdrop-filter: blur(var(--blur));
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 8px 24px var(--shadow-lg);
    z-index: 50;
    max-height: 280px;
    overflow-y: auto;
    display: none;
    opacity: 0;
    transform: translateY(-10px);
}

.dropdown.open .dropdown-menu {
    display: block;
    animation: slideDown 0.15s ease-out forwards;
}

.dropdown-item {
    padding: 10px 14px;
    cursor: pointer;
    transition: all 0.2s ease-out;
    border-bottom: 1px solid var(--border);
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover {
    background: var(--card);
    backdrop-filter: blur(var(--blur));
    -webkit-backdrop-filter: blur(var(--blur));
}

.dropdown-item.active {
    background: var(--accent-light);
    color: var(--accent);
}

.dropdown-item-name {
    font-size: 0.85rem;
    font-weight: 500;
}

.dropdown-item-model {
    font-size: 0.75rem;
    color: var(--text2);
    margin-top: 2px;
}

.dropdown-item.active .dropdown-item-model {
    color: var(--accent);
    opacity: 0.8;
}

.header button {
    background: var(--bg2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0 14px;
    height: 38px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.15s ease-out;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header button:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}

.theme-toggle {
    width: 38px;
    padding: 0 !important;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    background: var(--bg);
}

@keyframes msgFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 消息容器 - 包含头像和气泡 */
.msg-wrapper {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: msgFadeIn 0.25s ease-out;
}

.msg-wrapper.user {
    flex-direction: row-reverse;
    align-self: flex-end;
}

.msg-wrapper.ai {
    align-self: flex-start;
}

/* 头像样式 */
.msg-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 600;
}

.msg-wrapper.ai .msg-avatar {
    background: var(--accent-light);
    color: var(--accent);
}

.msg-wrapper.user .msg-avatar {
    background: var(--user);
    color: var(--user-text);
}

/* 消息气泡 */
.msg {
    max-width: 100%;
    padding: 14px 18px;
    border-radius: var(--radius-lg);
    line-height: 1.6;
    word-wrap: break-word;
    position: relative;
    transition: box-shadow 0.2s ease-out;
}

@media (prefers-reduced-motion: reduce) {
    .msg-wrapper {
        animation: none;
    }
}

.msg:hover {
    box-shadow: 0 4px 16px var(--shadow-md);
}

.msg.user {
    background: linear-gradient(135deg, var(--user) 0%, var(--accent-hover) 100%);
    color: var(--user-text);
    border-radius: var(--radius-lg);
    border-bottom-right-radius: 6px;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.2);
}

.msg.ai {
    background: var(--ai);
    backdrop-filter: blur(var(--blur));
    -webkit-backdrop-filter: blur(var(--blur));
    color: var(--ai-text);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    border-bottom-left-radius: 6px;
    box-shadow: 0 2px 8px var(--shadow-md);
}

.msg .meta {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 6px;
    font-weight: 500;
}

.msg.ai .meta {
    color: var(--text2);
}

.msg pre {
    background: rgba(0, 0, 0, 0.08);
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 12px 0;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.msg.ai pre {
    background: var(--card);
    border-color: var(--border);
}

.msg code {
    font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', Consolas, monospace;
    font-size: 0.875em;
    line-height: 1.5;
}

/* Markdown 渲染样式 */
.msg-content {
    display: block;
}

.msg-content > *:first-child {
    margin-top: 0;
}

.msg-content > *:last-child {
    margin-bottom: 0;
}

.msg-content p {
    margin: 0.5em 0;
    line-height: 1.6;
}

.msg-content h1,
.msg-content h2,
.msg-content h3,
.msg-content h4,
.msg-content h5,
.msg-content h6 {
    margin: 1em 0 0.5em 0;
    font-weight: 600;
    line-height: 1.3;
}

.msg-content h1 { font-size: 1.4em; }
.msg-content h2 { font-size: 1.25em; }
.msg-content h3 { font-size: 1.1em; }
.msg-content h4 { font-size: 1em; }

.msg-content ul,
.msg-content ol {
    margin: 0.5em 0;
    padding-left: 1.5em;
}

.msg-content li {
    margin: 0.25em 0;
    line-height: 1.5;
}

.msg-content blockquote {
    margin: 0.5em 0;
    padding: 0.5em 1em;
    border-left: 3px solid var(--accent);
    background: rgba(99, 102, 241, 0.05);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.msg.user .msg-content blockquote {
    border-left-color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.1);
}

.msg-content table {
    border-collapse: collapse;
    margin: 0.5em 0;
    width: 100%;
    font-size: 0.9em;
}

.msg-content th,
.msg-content td {
    border: 1px solid var(--border);
    padding: 8px 12px;
    text-align: left;
}

.msg-content th {
    background: var(--card);
    font-weight: 600;
}

.msg.user .msg-content th,
.msg.user .msg-content td {
    border-color: rgba(255, 255, 255, 0.2);
}

.msg.user .msg-content th {
    background: rgba(255, 255, 255, 0.1);
}

.msg-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1em 0;
}

.msg.user .msg-content hr {
    border-top-color: rgba(255, 255, 255, 0.2);
}

.msg-content a {
    color: var(--accent);
    text-decoration: none;
}

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

.msg.user .msg-content a {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: underline;
}

.msg-content img {
    max-width: 100%;
    border-radius: var(--radius-sm);
    margin: 0.5em 0;
}

/* 行内代码样式 */
.msg-content code:not(pre code) {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85em;
}

.msg.ai .msg-content code:not(pre code) {
    background: var(--card);
}

.msg.user .msg-content code:not(pre code) {
    background: rgba(255, 255, 255, 0.15);
}

/* 代码块样式 */
.msg-content pre {
    position: relative;
    margin: 0.5em 0;
}

.msg-content pre code {
    display: block;
    padding: 0;
    background: transparent;
}

.msg-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.6);
}

.msg.ai .msg-footer {
    color: var(--text2);
    border-top-color: var(--border);
}

.msg-tokens {
    display: flex;
    align-items: center;
    gap: 4px;
}

.msg-actions {
    display: flex;
    gap: 2px;
}

.msg-action-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.msg.ai .msg-action-btn {
    color: var(--text2);
}

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

.msg-action-btn.delete:hover {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}

.msg-action-btn svg {
    width: 14px;
    height: 14px;
}

.tool-card {
    background: rgba(99, 102, 241, 0.06);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(99, 102, 241, 0.15);
    border-radius: var(--radius-sm);
    margin: 12px 0;
    overflow: hidden;
    transition: all 0.2s ease-out;
}

.tool-card:hover {
    border-color: rgba(99, 102, 241, 0.25);
    box-shadow: 0 4px 12px var(--shadow-md);
}

.tool-card.thinking {
    background: rgba(245, 158, 11, 0.06);
    border-color: rgba(245, 158, 11, 0.15);
}

.tool-card.thinking:hover {
    border-color: rgba(245, 158, 11, 0.25);
}

.tool-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease-out;
}

.tool-header:hover {
    background: rgba(99, 102, 241, 0.08);
}

.tool-card.thinking .tool-header:hover {
    background: rgba(245, 158, 11, 0.08);
}

.tool-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    font-weight: 500;
}

.tool-title .icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.tool-arrow {
    transition: transform 0.2s;
    color: var(--text2);
}

.tool-card.open .tool-arrow {
    transform: rotate(180deg);
}

.tool-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .tool-body {
    background: rgba(0, 0, 0, 0.2);
}

.tool-card.open .tool-body {
    max-height: 500px;
}

.tool-content {
    padding: 14px;
    font-size: 0.85rem;
}

.tool-section {
    margin-bottom: 10px;
}

.tool-section-title {
    color: var(--accent);
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tool-section pre {
    background: var(--card);
    padding: 10px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 0;
    font-size: 0.8rem;
    max-height: 200px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    word-break: break-word;
}

.tool-status {
    font-size: 0.75rem;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    font-weight: 500;
}

.tool-status.running {
    background: var(--warning);
    color: #000;
}

.tool-status.done {
    background: var(--success);
    color: #000;
}

.input-area {
    background: var(--bg);
    padding: 16px 24px 20px 24px;
    border-top: none;
}

/* 输入工具栏 - 简洁风格 */
.input-toolbar {
    display: flex;
    gap: 6px;
    max-width: 900px;
    margin: 0 auto 12px auto;
    align-items: center;
    flex-wrap: wrap;
}

.toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    height: 32px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 16px;
    color: var(--text2);
    font-size: 0.8rem;
    cursor: pointer;
    transition: color 0.15s ease-out, background 0.15s ease-out, border-color 0.15s ease-out;
    white-space: nowrap;
    box-sizing: border-box;
}

.toolbar-btn:hover {
    color: var(--accent);
    background: var(--accent-light);
    border-color: var(--accent);
}

.toolbar-btn:active {
    background: rgba(99, 102, 241, 0.15);
}

.toolbar-btn.active {
    color: var(--accent);
    background: var(--accent-light);
    border-color: var(--accent);
}

.toolbar-btn .badge {
    background: var(--accent);
    color: white;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 2px;
    font-weight: 500;
}

.toolbar-divider {
    width: 1px;
    height: 16px;
    background: var(--border);
    margin: 0 4px;
    opacity: 0.5;
}

/* 工具栏下拉菜单 */
.toolbar-dropdown {
    position: relative;
}

.toolbar-dropdown-menu {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    min-width: 220px;
    max-width: 320px;
    max-height: 300px;
    overflow-y: auto;
    background: var(--bg2);
    backdrop-filter: blur(var(--blur));
    -webkit-backdrop-filter: blur(var(--blur));
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 8px 24px var(--shadow-lg);
    z-index: 50;
    display: none;
    opacity: 0;
    transform: translateY(10px);
}

@keyframes slideUpMenu {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.toolbar-dropdown.open .toolbar-dropdown-menu {
    display: block;
    animation: slideUpMenu 0.15s ease-out forwards;
}

.toolbar-dropdown-header {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.toolbar-dropdown-item {
    padding: 10px 14px;
    cursor: pointer;
    transition: all 0.2s ease-out;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.toolbar-dropdown-item:last-child {
    border-bottom: none;
}

.toolbar-dropdown-item:hover {
    background: var(--accent-light);
    backdrop-filter: blur(var(--blur));
    -webkit-backdrop-filter: blur(var(--blur));
}

.toolbar-dropdown-item.active {
    background: var(--accent-light);
    color: var(--accent);
}

.toolbar-dropdown-item-icon {
    width: 32px;
    height: 32px;
    background: var(--card);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1rem;
    color: var(--text2);
}

.toolbar-dropdown-item.active .toolbar-dropdown-item-icon {
    background: var(--accent);
    color: white;
}

.toolbar-dropdown-item-info {
    flex: 1;
    min-width: 0;
}

.toolbar-dropdown-item-name {
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.toolbar-dropdown-item-desc {
    font-size: 0.75rem;
    color: var(--text2);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.toolbar-dropdown-item.active .toolbar-dropdown-item-desc {
    color: var(--accent);
    opacity: 0.8;
}

.toolbar-empty {
    padding: 20px;
    text-align: center;
    color: var(--text2);
    font-size: 0.85rem;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border);
    transition: 0.3s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked+.toggle-slider {
    background-color: var(--accent);
}

.toggle-switch input:checked+.toggle-slider:before {
    transform: translateX(20px);
}

/* 样式设置面板 */
.style-section {
    margin-bottom: 24px;
}

.style-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 12px;
    color: var(--text);
}

.style-options {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.style-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--card);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.style-option i[class^="ri-"] {
    font-size: 1.25rem;
}

.style-option:hover {
    border-color: var(--accent);
}

.style-option.active {
    border-color: var(--accent);
    background: var(--accent-light);
    color: var(--accent);
}

.color-options {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.color-option {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 3px solid transparent;
    background: var(--color);
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.color-option:hover {
    transform: scale(1.1);
}

.color-option.active {
    border-color: var(--text);
    box-shadow: 0 0 0 2px var(--bg2);
}

.color-option.active::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 14px;
    font-weight: bold;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* 自定义颜色按钮 */
.color-option.custom {
    background: var(--card);
    border: 2px dashed var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
}

.color-option.custom:hover {
    border-color: var(--accent);
    border-style: solid;
}

.color-option.custom .custom-icon {
    font-size: 18px;
    color: var(--text2);
    line-height: 1;
}

.color-option.custom:hover .custom-icon {
    color: var(--accent);
}

.color-option.custom.active {
    border-style: solid;
}

.color-option.custom.active .custom-icon {
    display: none;
}

/* 自定义颜色输入区域 */
.custom-color-input {
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.custom-color-preview-box {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 2px solid var(--border);
    background: var(--accent);
    flex-shrink: 0;
}

.custom-color-input input[type="text"] {
    flex: 1;
    min-width: 0;
    padding: 8px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: 'SF Mono', 'Fira Code', Consolas, monospace;
    font-size: 0.9rem;
    text-transform: uppercase;
}

.custom-color-input input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
}

.btn-apply-color {
    padding: 8px 16px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.btn-apply-color:hover {
    opacity: 0.9;
}

/* 重置按钮 */
.btn-reset-style {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text2);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-reset-style:hover {
    border-color: var(--error);
    color: var(--error);
    background: rgba(239, 68, 68, 0.05);
}

.input-wrap {
    display: flex;
    gap: 12px;
    max-width: 900px;
    margin: 0 auto;
    align-items: flex-end;
    background: var(--bg2);
    backdrop-filter: blur(var(--blur));
    -webkit-backdrop-filter: blur(var(--blur));
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 8px 8px 8px 20px;
    box-shadow: 0 4px 20px var(--shadow-lg);
}

.input-wrap textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text);
    padding: 10px 0;
    font-size: 1rem;
    resize: none;
    min-height: 44px;
    max-height: 200px;
    font-family: inherit;
    transition: none;
    overflow-y: auto;
    line-height: 1.5;
}

.input-wrap textarea::placeholder {
    color: var(--text2);
    opacity: 0.6;
}

.input-wrap textarea:focus {
    outline: none;
}

.input-wrap button.send-btn {
    background: var(--accent);
    color: white;
    border: none;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
    cursor: pointer;
    font-weight: 500;
    font-size: 1.25rem;
    transition: background 0.15s ease-out, transform 0.15s ease-out;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* 语音输入按钮 */
.input-wrap button.voice-btn {
    background: transparent;
    color: var(--text2);
    border: none;
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.25rem;
    transition: all 0.15s ease-out;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    align-self: flex-end;
    margin-bottom: 2px;
}

.input-wrap button.voice-btn:hover {
    color: var(--accent);
    background: var(--accent-bg, rgba(99, 102, 241, 0.1));
}

.input-wrap button.voice-btn.recording {
    color: var(--error);
    background: rgba(239, 68, 68, 0.1);
    animation: pulse-recording 1s ease-in-out infinite;
}

@keyframes pulse-recording {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.input-wrap button.send-btn:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: scale(1.05);
}

.input-wrap button.send-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.input-wrap button.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 打字动画优化 */
.typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 0;
}

.typing span {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
    opacity: 0.6;
    animation: typingBounce 1.2s ease-in-out infinite;
}

.typing span:nth-child(2) {
    animation-delay: 0.15s;
}

.typing span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes typingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.6;
    }
    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .typing span {
        animation: typingPulse 1.5s ease-in-out infinite;
    }
    
    @keyframes typingPulse {
        0%, 100% { opacity: 0.4; }
        50% { opacity: 1; }
    }
}

/* 空状态优化 */
.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text2);
    padding: 40px 20px;
}

.empty-state .icon {
    width: 80px;
    height: 80px;
    background: var(--accent-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    font-size: 2.5rem;
    color: var(--accent);
}

.empty-state-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.empty-state-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--success);
    margin-bottom: 16px;
}

.empty-state-status .status-dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: statusPulse 2s ease-in-out infinite;
}

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

.empty-state-desc {
    font-size: 0.9rem;
    color: var(--text2);
    text-align: center;
    max-width: 300px;
    line-height: 1.5;
}

.empty-state div:last-child {
    font-size: 1.1rem;
}

/* 动画关键帧 */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

/* 按钮点击效果 */
.btn-new:active,
.btn-add-small:active,
.btn-confirm:active,
.send-btn:active {
    transform: scale(0.95);
}

/* 设置面板切换动画 */
.settings-panel.active {
    animation: fadeIn 0.2s ease;
}

.settings-detail.active {
    animation: slideInRight 0.25s ease;
}

.settings-detail.closing {
    animation: slideOutRight 0.2s ease forwards;
}

@keyframes slideOutRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(20px);
    }
}

/* 工具栏下拉菜单动画 */
.toolbar-dropdown.open .toolbar-dropdown-menu {
    animation: slideDown 0.2s ease forwards;
}

/* 卡片悬停效果 - 使用阴影而非 scale 避免布局偏移 */
.provider-item:hover,
.model-item:hover,
.mcp-item:hover {
    box-shadow: 0 6px 20px var(--shadow-lg);
}

/* 会话项悬停效果 - 使用阴影而非 translateX */
.session-item:hover,
.persona-session-item:hover {
    box-shadow: 0 2px 8px var(--shadow-md);
}

/* 加载骨架屏效果 */
.skeleton {
    background: linear-gradient(90deg, var(--card) 25%, var(--border) 50%, var(--card) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    z-index: 1100;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.modal.show {
    display: flex;
    animation: fadeIn 0.2s ease forwards;
}

.modal.closing {
    display: flex;
    animation: fadeOut 0.2s ease forwards;
}

.modal.show .modal-content {
    animation: slideUp 0.3s ease forwards;
}

.modal.closing .modal-content {
    animation: slideDown 0.25s ease forwards;
}

.modal-content {
    background: var(--bg2);
    backdrop-filter: blur(var(--blur-lg));
    -webkit-backdrop-filter: blur(var(--blur-lg));
    padding: 24px;
    border-radius: var(--radius-xl);
    min-width: 340px;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 12px 48px var(--shadow-xl);
    border: 1px solid var(--border);
    transform: translateY(20px) scale(0.98);
    opacity: 0;
}

.modal-content.wide {
    min-width: 500px;
}

.modal-content h3 {
    margin-bottom: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-content label {
    display: block;
    font-size: 0.85rem;
    color: var(--text2);
    margin-bottom: 6px;
}

.modal-content input,
.modal-content select {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 16px;
    font-size: 0.95rem;
    transition: border-color 0.15s ease-out;
}

.modal-content input:focus,
.modal-content select:focus {
    outline: none;
    border-color: var(--accent);
}

/* 自定义下拉选择器 */
.custom-select {
    position: relative;
    width: 100%;
    margin-bottom: 16px;
}

.custom-select-btn {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s;
    text-align: left;
}

.custom-select-btn:hover {
    border-color: var(--accent);
}

.custom-select.open .custom-select-btn {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

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

.custom-select-btn svg {
    transition: transform 0.2s;
    flex-shrink: 0;
    color: var(--text2);
}

.custom-select-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.custom-select-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--bg2);
    backdrop-filter: blur(var(--blur));
    -webkit-backdrop-filter: blur(var(--blur));
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 24px var(--shadow-lg);
    z-index: 60;
    max-height: 240px;
    overflow-y: auto;
    display: none;
    opacity: 0;
    transform: translateY(-10px);
}

.custom-select.open .custom-select-menu {
    display: block;
    animation: slideDown 0.2s ease forwards;
}

.custom-select-item {
    padding: 10px 14px;
    cursor: pointer;
    transition: all 0.2s ease-out;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.custom-select-item:last-child {
    border-bottom: none;
}

.custom-select-item:hover {
    background: var(--card);
    backdrop-filter: blur(var(--blur));
    -webkit-backdrop-filter: blur(var(--blur));
}

.custom-select-item.active {
    background: var(--accent-light);
    color: var(--accent);
}

.custom-select-item-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.85rem;
    font-weight: 600;
    color: white;
}

.custom-select-item-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

.modal-actions button {
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    border: none;
    font-weight: 500;
    transition: all 0.15s ease-out;
}

.modal-actions .btn-cancel {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}

.modal-actions .btn-cancel:hover {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
}

.modal-actions .btn-confirm {
    background: var(--accent);
    color: white;
}

.modal-actions .btn-confirm:hover {
    background: var(--accent-hover);
}

.modal-actions .btn-danger {
    background: var(--error);
    color: white;
}

.modal-actions .btn-danger:hover {
    opacity: 0.9;
}

.item-list {
    margin-bottom: 20px;
}

.list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: var(--card);
    border-radius: 12px;
    margin-bottom: 8px;
    border: 1px solid var(--border);
}

.list-item.current {
    border-color: var(--accent);
    background: var(--accent-light);
}

.list-item-info {
    flex: 1;
}

.list-item-name {
    font-weight: 500;
    font-size: 0.95rem;
}

.list-item-detail {
    font-size: 0.8rem;
    color: var(--text2);
    margin-top: 4px;
}

.list-item-actions {
    display: flex;
    gap: 6px;
}

.btn-icon-text {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    font-size: 0.8rem;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text2);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s ease-out;
}

.btn-icon-text:hover {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
}

.btn-icon-text.delete:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--error);
    color: var(--error);
}

.btn-icon-text svg {
    width: 14px;
    height: 14px;
}

.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 12px;
}

.tab {
    padding: 8px 16px;
    border-radius: 16px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.15s ease-out;
    background: transparent;
    border: none;
    color: var(--text2);
}

.tab:hover {
    background: var(--card);
    color: var(--text);
}

.tab.active {
    background: var(--accent);
    color: white;
}

.tab-content {
    display: none;
}

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

/* 三层设置导航样式 */
.settings-container {
    display: flex;
    height: 450px;
    gap: 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
}

/* 设置模态框特殊样式 */
.settings-modal-content {
    width: 700px;
    max-width: 90vw;
    padding: 0 !important;
    overflow: hidden;
    transition: width 0.3s ease;
}

/* 当有详情面板时，宽度变大 */
.settings-modal-content.with-detail {
    width: 980px !important;
}

/* 不同面板的宽度 */
.settings-modal-content.panel-about,
.settings-modal-content.panel-plugins {
    width: 850px;
}

.settings-modal-content.panel-tools {
    width: 850px;
}

.settings-modal-content.panel-style {
    width: 760px;
}

/* 其他面板标准宽度 */
.settings-modal-content.panel-providers,
.settings-modal-content.panel-stt,
.settings-modal-content.panel-mcp,
.settings-modal-content.panel-personas,
.settings-modal-content.panel-memory,
.settings-modal-content.panel-openapi {
    width: 700px;
}

.settings-modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.settings-nav {
    width: 140px;
    background: var(--bg2);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    padding: 8px;
    gap: 2px;
    border-right: 1px solid var(--border);
    overflow-y: auto;
}

/* 设置导航分组 */
.settings-nav-group {
    margin-top: 8px;
}

.settings-nav-group:first-child {
    margin-top: 0;
}

.settings-nav-group-title {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 12px 4px 12px;
    margin-bottom: 2px;
}

.settings-nav-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--text2);
    border: none;
    background: transparent;
    text-align: left;
    transition: all 0.15s ease-out;
    display: flex;
    align-items: center;
    gap: 8px;
    border-radius: 12px;
}

.settings-nav-item:hover {
    background: var(--card);
    color: var(--text);
}

.settings-nav-item.active {
    background: var(--accent);
    color: white;
}

.settings-nav-item svg {
    width: 16px;
    height: 16px;
}

.settings-nav-item i {
    font-size: 1rem;
    width: 16px;
    text-align: center;
}

.settings-panel {
    flex: 1;
    background: var(--bg);
    display: none;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.settings-panel.active {
    display: flex;
}

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

.settings-panel-header h4 {
    font-size: 1rem;
    font-weight: 600;
}

.settings-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    min-width: 0;
}

.settings-detail {
    width: 0;
    max-width: 0;
    background: var(--bg2);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-left: 1px solid var(--border);
    opacity: 0;
    transition: width 0.3s ease, max-width 0.3s ease, opacity 0.3s ease;
}

.settings-detail.active {
    width: 280px;
    max-width: 280px;
    opacity: 1;
}

.settings-detail.closing {
    width: 0;
    max-width: 0;
    opacity: 0;
}

.settings-detail-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.settings-detail-header h4 {
    font-size: 0.95rem;
    font-weight: 600;
}

.settings-detail-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.settings-form label {
    display: block;
    font-size: 0.8rem;
    color: var(--text2);
    margin-bottom: 6px;
    margin-top: 12px;
}

.settings-form label:first-child {
    margin-top: 0;
}

.settings-form input,
.settings-form select,
.settings-form textarea {
    width: 100%;
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    transition: all 0.2s;
}

.settings-form input:focus,
.settings-form select:focus,
.settings-form textarea:focus {
    outline: none;
    border-color: var(--accent);
}

/* 下拉选择框包装器 */
.select-wrapper {
    position: relative;
    width: 100%;
}

.select-wrapper select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    width: 100%;
    padding: 10px 36px 10px 12px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.9rem;
    cursor: pointer;
    transition: border-color 0.2s;
}

.select-wrapper select:hover {
    border-color: var(--accent);
}

.select-wrapper select:focus {
    outline: none;
    border-color: var(--accent);
}

.select-wrapper::after {
    content: '';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid var(--text2);
    pointer-events: none;
}

/* 自定义复选框 */
.custom-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
    cursor: pointer;
    user-select: none;
}

.custom-checkbox input[type="checkbox"] {
    display: none;
}

.custom-checkbox .checkmark {
    position: relative;
    width: 20px;
    height: 20px;
    min-width: 20px;
    border: 2px solid var(--border);
    border-radius: 4px;
    background: var(--card);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.custom-checkbox:hover .checkmark {
    border-color: var(--accent);
}

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

.custom-checkbox input[type="checkbox"]:checked+.checkmark::after {
    content: '';
    width: 6px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    display: block;
}

.custom-checkbox .checkbox-text {
    color: var(--text);
    font-size: 0.9rem;
}

/* 文字按钮 */
.btn-text {
    background: none;
    border: none;
    color: var(--text2);
    cursor: pointer;
    padding: 4px 8px;
    font-size: 0.85rem;
    transition: color 0.2s;
}

.btn-text:hover {
    color: var(--accent);
}

/* 帮助按钮 */
.btn-help {
    background: none;
    border: none;
    color: var(--text2);
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-help:hover {
    color: var(--accent);
    background: var(--accent-light);
}

/* API对话筛选区域 */
.api-filter-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg2);
}

.api-filter-label {
    font-size: 0.9rem;
    color: var(--text2);
}

.api-filter-select,
.api-filter-btn {
    height: 36px;
    padding: 0 12px;
    font-size: 0.9rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    cursor: pointer;
    box-sizing: border-box;
}

.api-filter-select {
    min-width: 120px;
}

.api-filter-select:hover,
.api-filter-select:focus,
.api-filter-btn:hover {
    outline: none;
    border-color: var(--accent);
}

.api-filter-btn:hover {
    color: var(--accent);
}

.settings-form-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.settings-form-actions button {
    flex: 1;
    padding: 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: none;
    font-weight: 500;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.settings-form-actions .btn-danger {
    flex: 1;
    background: transparent;
    color: var(--error);
    border: 1px solid var(--error);
}

.settings-form-actions .btn-danger:hover {
    background: var(--error);
    color: white;
}

.provider-item,
.model-item,
.mcp-item {
    padding: 12px;
    background: var(--card);
    backdrop-filter: blur(var(--blur));
    -webkit-backdrop-filter: blur(var(--blur));
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s ease-out;
    animation: slideInRight 0.2s ease;
}

.provider-item:hover,
.model-item:hover,
.mcp-item:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 12px var(--shadow-md);
}

.provider-item.active,
.model-item.active,
.mcp-item.active {
    border-color: var(--accent);
    background: var(--accent-light);
}

.provider-item-name,
.model-item-name,
.mcp-item-name {
    font-weight: 500;
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.provider-item-detail,
.model-item-detail,
.mcp-item-detail {
    font-size: 0.8rem;
    color: var(--text2);
}

.model-tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    margin-left: 4px;
}

.model-tags-row {
    display: flex;
    gap: 4px;
    margin-top: 4px;
}

.tag-checkbox-group {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.tag-checkbox {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-width: 70px;
    height: 34px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
    background: var(--bg2);
    transition: all 0.2s;
}

.tag-checkbox:hover {
    border-color: var(--accent);
}

.tag-checkbox.active {
    border-color: var(--accent);
    background: var(--accent-light);
}

.tag-checkbox input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.tag-checkbox svg {
    width: 14px;
    height: 14px;
}

.model-list-section {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.model-list-section h5 {
    font-size: 0.85rem;
    color: var(--text2);
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-add-small {
    padding: 5px 12px;
    font-size: 0.75rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn-add-small:hover {
    background: var(--accent-hover);
}

.btn-outline-small {
    padding: 5px 12px;
    font-size: 0.75rem;
    background: transparent;
    color: var(--text2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn-outline-small:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(99, 102, 241, 0.05);
}

.btn-outline-small svg {
    width: 12px;
    height: 12px;
}

/* 模型列表弹窗项目 */
.provider-model-item {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.provider-model-item:last-child {
    border-bottom: none;
}

.provider-model-item:hover {
    background: var(--card);
}

.provider-model-item.embedding {
    opacity: 0.75;
}

.provider-model-item-info {
    flex: 1;
    min-width: 0;
}

.provider-model-item-name {
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.provider-model-item-meta {
    font-size: 0.75rem;
    color: var(--text2);
    margin-top: 4px;
}

.provider-model-item-action {
    flex-shrink: 0;
    margin-left: 12px;
}

/* 模型列表弹窗样式 */
.modal-header-bar {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header-bar h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-close-btn {
    background: none;
    border: none;
    color: var(--text2);
    cursor: pointer;
    padding: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 1.25rem;
    transition: all 0.2s;
}

.modal-close-btn:hover {
    background: var(--card);
    color: var(--text);
}

/* 模型弹窗搜索栏 */
#providerModelsModal .modal-search-bar {
    padding: 12px 20px;
    background: var(--bg2);
    display: flex;
    flex-direction: row;
    gap: 10px;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

#providerModelsModal .modal-search-wrap {
    flex: 1;
    position: relative;
    min-width: 0;
    display: block;
}

#providerModelsModal .modal-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text2);
    pointer-events: none;
    z-index: 1;
}

#providerModelsModal .modal-search-input {
    display: block;
    width: 100%;
    height: 36px;
    padding: 0 12px 0 38px;
    margin: 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.9rem;
    box-sizing: border-box;
    outline: none;
    transition: all 0.2s;
    font-family: inherit;
}

#providerModelsModal .modal-search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

#providerModelsModal .modal-search-input::placeholder {
    color: var(--text2);
}

#providerModelsModal .modal-search-refresh {
    width: 36px;
    height: 36px;
    min-width: 36px;
    padding: 0;
    margin: 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--text2);
    font-size: 1rem;
    transition: all 0.2s;
}

#providerModelsModal .modal-search-refresh:hover {
    border-color: var(--accent);
    color: var(--accent);
}

#providerModelsModal .modal-search-refresh.loading i {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* 筛选标签页 */
.modal-filter-tabs {
    display: flex;
    padding: 0 20px;
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
}

.modal-filter-tab {
    padding: 14px 20px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text2);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: -1px;
}

.modal-filter-tab:hover {
    color: var(--text);
}

.modal-filter-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.modal-footer-bar {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg2);
}

.modal-footer-bar span {
    font-size: 0.85rem;
    color: var(--text2);
}

.modal-action-btn {
    padding: 8px 20px;
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.modal-action-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* 模型标签样式 */
.model-tag,
.model-type-tag {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 500;
    margin-left: 4px;
    vertical-align: middle;
}

.model-type-tag {
    font-size: 0.65rem;
}

/* 模型分组样式 */
.model-section-title {
    font-size: 0.75rem;
    color: var(--text2);
    font-weight: 500;
    padding: 8px 0 6px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.model-section-divider {
    height: 1px;
    background: var(--border);
    margin: 12px 0;
}

.model-item.embedding {
    opacity: 0.8;
}

.model-item.embedding .model-item-name {
    color: var(--text2);
}

.preset-model-item.embedding {
    opacity: 0.8;
}

.preset-model-item.embedding .preset-model-item-name {
    color: var(--text2);
}

/* 开关样式 */
.toggle-switch {
    position: relative;
    width: 36px;
    height: 20px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border);
    transition: 0.3s;
    border-radius: 20px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked+.toggle-slider {
    background-color: var(--accent);
}

.toggle-switch input:checked+.toggle-slider:before {
    transform: translateX(16px);
}

/* 供应商信息卡片 */
.provider-info-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    margin-bottom: 16px;
}

.provider-info-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.provider-info-header > div {
    flex: 1;
    min-width: 0;
}

.provider-info-name {
    font-weight: 600;
    font-size: 1rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.provider-info-detail {
    font-size: 0.8rem;
    color: var(--text2);
    margin-top: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-edit-small {
    padding: 4px 10px;
    font-size: 0.75rem;
    background: transparent;
    color: var(--text2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    white-space: nowrap;
}

.btn-edit-small:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-text-small {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.btn-text-small:hover {
    background: var(--accent-light);
}

/* 预设模型列表 */
.preset-model-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card);
}

.preset-model-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: all 0.15s;
}

.preset-model-item:last-child {
    border-bottom: none;
}

.preset-model-item:hover {
    background: var(--accent-light);
}

.preset-model-item-name {
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
}

.preset-model-item-id {
    font-size: 0.75rem;
    color: var(--text2);
    margin-top: 2px;
}

/* MCP 项目带开关 */
.mcp-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mcp-item-content {
    flex: 1;
    min-width: 0;
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

.status-dot.connected {
    background: var(--success);
}

.status-dot.disconnected {
    background: var(--error);
}

/* 插件项目样式 */
.plugin-item {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s ease-out;
}

.plugin-item:hover {
    box-shadow: 0 4px 12px var(--shadow-md);
}

.plugin-item.expanded {
    box-shadow: 0 4px 12px var(--shadow-md);
}

.plugin-item.disabled {
    opacity: 0.5;
}

.plugin-item.disabled .plugin-item-name {
    text-decoration: line-through;
}

.plugin-item-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
}

.plugin-item-icon {
    width: 40px;
    height: 40px;
    background: var(--accent-light);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.plugin-item-icon i {
    font-size: 1.5rem;
    color: var(--accent);
}

.plugin-item-info {
    flex: 1;
    min-width: 0;
}

.plugin-item-name {
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.plugin-item-meta {
    font-size: 0.8rem;
    color: var(--text2);
}

.plugin-item-arrow {
    font-size: 1.2rem;
    color: var(--text2);
    transition: transform 0.2s ease-out;
}

.plugin-item.expanded .plugin-item-arrow {
    transform: rotate(180deg);
}

.plugin-item-detail {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    border-top: 1px solid var(--border);
}

.plugin-item-detail.active {
    max-height: 500px;
}

.plugin-detail-section {
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

.plugin-detail-section:last-child {
    border-bottom: none;
}

.plugin-detail-label {
    font-size: 0.75rem;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    font-weight: 600;
}

.plugin-detail-value {
    font-size: 0.9rem;
    color: var(--text);
    line-height: 1.6;
}

.plugin-detail-tools {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.plugin-tool-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--text);
}

.plugin-tool-item i {
    color: var(--accent);
    font-size: 1rem;
}

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

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

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

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

/* LaTeX 公式样式 */
.katex-display {
    margin: 1em 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0.5em 0;
}

.katex {
    font-size: 1.1em;
}

.msg .katex-display {
    background: var(--card);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin: 12px 0;
}

.msg.user .katex-display {
    background: rgba(255, 255, 255, 0.1);
}

.latex-error {
    color: var(--error);
    background: rgba(239, 68, 68, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
}

@media (max-width: 768px) {
    .sidebar {
        width: 220px;
    }

    .header {
        padding: 12px 16px;
    }

    .messages {
        padding: 16px;
    }
    
    .mobile-header-btn {
        display: none;
    }
}

@media (max-width: 600px) {
    html, body {
        height: 100%;
        height: 100dvh; /* 动态视口高度，适配移动端浏览器地址栏 */
        overflow: hidden;
    }
    
    body {
        flex-direction: column;
    }

    /* 移动端侧边栏 - 抽屉式 */
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 280px;
        max-width: 85vw;
        height: 100%;
        max-height: none;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        border-right: 1px solid var(--border);
        border-bottom: none;
    }
    
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    
    /* 移动端遮罩层 */
    .mobile-sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        opacity: 0;
        transition: opacity 0.3s ease;
    }
    
    .mobile-sidebar-overlay.show {
        display: block;
        opacity: 1;
    }
    
    /* 移动端头部按钮 */
    .mobile-header-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        gap: 6px;
        padding: 8px 14px;
        background: var(--card);
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        color: var(--text);
        cursor: pointer;
        font-size: 0.85rem;
        transition: all 0.2s;
        line-height: 1;
    }
    
    .mobile-header-btn i {
        font-size: 1.1rem;
        line-height: 1;
        display: flex;
        align-items: center;
    }
    
    .mobile-header-btn svg {
        flex-shrink: 0;
    }
    
    .mobile-header-btn:hover {
        border-color: var(--accent);
    }
    
    .mobile-settings-btn {
        padding: 8px;
    }
    
    .mobile-settings-btn span {
        display: none;
    }

    .header {
        flex-wrap: wrap;
        gap: 8px;
    }

    .header input {
        width: 80px;
    }

    .msg {
        max-width: 90%;
    }

    .modal-content {
        min-width: auto !important;
        max-width: calc(100vw - 24px) !important;
        max-height: calc(100dvh - 24px) !important;
        margin: 12px;
        width: 100% !important;
        overflow-y: auto;
    }
    
    /* 设置模态框移动端适配 */
    .settings-modal-content {
        width: 100% !important;
        max-width: calc(100vw - 24px) !important;
        max-height: calc(100dvh - 24px) !important;
        overflow: hidden !important;
    }
    
    .settings-modal-content.with-detail,
    .settings-modal-content.panel-about,
    .settings-modal-content.panel-tools,
    .settings-modal-content.panel-style,
    .settings-modal-content.panel-providers,
    .settings-modal-content.panel-stt,
    .settings-modal-content.panel-mcp,
    .settings-modal-content.panel-personas,
    .settings-modal-content.panel-memory,
    .settings-modal-content.panel-openapi {
        width: 100% !important;
    }
    
    /* 设置页面移动端适配 */
    .settings-container {
        flex-direction: column;
        height: auto;
        min-height: 400px;
        max-height: calc(100dvh - 48px);
        overflow: hidden;
        position: relative;
    }
    
    .settings-nav {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 8px;
        gap: 4px;
        flex-shrink: 0;
        /* 隐藏滚动条但保持可滚动 */
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    .settings-nav::-webkit-scrollbar {
        display: none;
    }
    
    /* 移动端隐藏分组标题 */
    .settings-nav-group {
        display: contents;
        margin-top: 0;
    }
    
    .settings-nav-group-title {
        display: none;
    }
    
    .settings-nav-item {
        flex-direction: column;
        padding: 8px 12px;
        font-size: 0.75rem;
        white-space: nowrap;
        flex-shrink: 0;
        line-height: 1.2;
        align-items: center;
        justify-content: center;
    }
    
    .settings-nav-item svg {
        width: 18px;
        height: 18px;
    }
    
    .settings-panel {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        display: none;
    }
    
    .settings-panel.active {
        display: flex;
    }
    
    .settings-panel-header {
        padding: 12px;
    }
    
    .settings-panel-header h4 {
        font-size: 1rem;
    }
    
    .settings-panel-content {
        overflow-y: auto;
        flex: 1;
        padding: 12px;
    }
    
    /* 二级详情面板 - 移动端使用绝对定位叠加 */
    .settings-detail {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100% !important;
        max-width: 100% !important;
        border-left: none;
        z-index: 10;
        overflow-y: auto;
        transform: translateX(100%);
        opacity: 0;
        transition: transform 0.3s ease, opacity 0.3s ease;
    }
    
    /* 强制不透明背景 */
    [data-theme="dark"] .settings-detail {
        background: #1e293b !important;
    }
    
    :root .settings-detail,
    body:not([data-theme="dark"]) .settings-detail {
        background: #ffffff !important;
    }
    
    .settings-detail.active {
        transform: translateX(0);
        opacity: 1;
    }
    
    .settings-detail.closing {
        transform: translateX(100%);
        opacity: 0;
    }
    
    .settings-detail-header {
        padding: 12px 16px;
    }
    
    .settings-detail-content {
        padding: 12px;
    }
    
    .settings-form input,
    .settings-form select,
    .settings-form textarea {
        font-size: 16px; /* 防止iOS缩放 */
    }
    
    /* 隐藏桌面端侧边栏底部设置按钮 */
    .sidebar-footer {
        display: none;
    }
    
    /* 主区域布局 - 确保输入框始终可见 */
    .main {
        width: 100%;
        height: 100vh;
        height: 100dvh; /* 动态视口高度 */
        display: flex;
        flex-direction: column;
    }
    
    .header {
        flex-shrink: 0;
    }
    
    .messages {
        flex: 1;
        overflow-y: auto;
        min-height: 0;
    }
    
    .input-area {
        flex-shrink: 0;
        padding: 12px 12px 16px 12px;
    }
    
    .input-toolbar {
        gap: 4px;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: visible;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none; /* Firefox */
        -ms-overflow-style: none; /* IE/Edge */
        padding-bottom: 6px;
        margin-bottom: 10px;
    }
    
    .input-toolbar::-webkit-scrollbar {
        display: none; /* Chrome/Safari */
    }
    
    .toolbar-btn {
        padding: 6px 8px;
        font-size: 0.75rem;
        flex-shrink: 0;
        height: 30px;
    }
    
    .toolbar-btn svg {
        width: 14px;
        height: 14px;
    }
    
    .toolbar-divider {
        flex-shrink: 0;
        height: 14px;
    }
    
    .toolbar-dropdown {
        position: static;
    }
    
    .toolbar-dropdown-menu {
        position: fixed;
        bottom: 100px;
        bottom: calc(100px + env(safe-area-inset-bottom));
        left: 12px;
        right: 12px;
        max-height: 50vh;
        width: auto;
        min-width: auto;
        z-index: 1050;
    }
    
    /* 设置面板中的下拉菜单使用绝对定位 */
    .settings-panel .toolbar-dropdown {
        position: relative;
    }
    
    .settings-panel .toolbar-dropdown-menu {
        position: absolute;
        bottom: auto;
        top: calc(100% + 4px);
        left: auto;
        right: 0;
        max-height: 300px;
        width: auto;
        min-width: 160px;
        z-index: 100;
    }
    
    .input-wrap {
        padding: 6px 6px 6px 16px;
        border-radius: var(--radius-lg);
    }
    
    .input-wrap textarea {
        font-size: 16px; /* 防止iOS缩放 */
        min-height: 40px;
        padding: 8px 0;
    }
    
    .input-wrap button.send-btn {
        width: 40px;
        height: 40px;
    }
    
    /* 移动端消息头像 */
    .msg-avatar {
        width: 32px;
        height: 32px;
    }
    
    .msg-wrapper {
        gap: 10px;
        max-width: 90%;
    }
}

/* Toast 通知样式 */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1300;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: var(--bg2);
    backdrop-filter: blur(var(--blur));
    -webkit-backdrop-filter: blur(var(--blur));
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 14px 20px;
    box-shadow: 0 8px 24px var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 280px;
    max-width: 400px;
    animation: toastIn 0.3s ease-out;
    pointer-events: auto;
}

.toast.hiding {
    animation: toastOut 0.3s ease forwards;
}

.toast-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.toast-icon.success {
    color: var(--success);
}

.toast-icon.error {
    color: var(--error);
}

.toast-icon.warning {
    color: var(--warning);
}

.toast-icon.info {
    color: var(--accent);
}

.toast-content {
    flex: 1;
    font-size: 0.9rem;
    line-height: 1.4;
}

.toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text2);
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    transition: all 0.15s ease-out;
}

.toast-close:hover {
    background: var(--accent-light);
    color: var(--accent);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }

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

/* Alert 对话框样式 */
.alert-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    z-index: 1200;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
}

.alert-modal.show {
    display: flex;
    animation: fadeIn 0.2s ease forwards;
}

.alert-modal.closing {
    display: flex;
    animation: fadeOut 0.2s ease forwards;
}

.alert-modal.show .alert-content {
    animation: scaleIn 0.25s ease forwards;
}

.alert-modal.closing .alert-content {
    animation: scaleOut 0.2s ease forwards;
}

@keyframes scaleOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.95);
    }
}

.alert-content {
    background: var(--bg2);
    backdrop-filter: blur(var(--blur-lg));
    -webkit-backdrop-filter: blur(var(--blur-lg));
    padding: 24px;
    border-radius: var(--radius-xl);
    min-width: 320px;
    transform: scale(0.95);
    opacity: 0;
    max-width: 450px;
    box-shadow: 0 12px 48px var(--shadow-xl);
    border: 1px solid var(--border);
    animation: alertIn 0.2s ease-out;
}

@keyframes alertIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

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

.alert-header .alert-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.alert-header .alert-icon.error {
    color: var(--error);
}

.alert-header .alert-icon.warning {
    color: var(--warning);
}

.alert-header .alert-icon.info {
    color: var(--accent);
}

.alert-header h4 {
    font-size: 1.1rem;
    font-weight: 600;
}

.alert-body {
    color: var(--text2);
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 20px;
}

.alert-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.alert-actions button {
    padding: 10px 24px;
    border-radius: 16px;
    cursor: pointer;
    border: 1px solid var(--border);
    font-weight: 500;
    transition: all 0.15s ease-out;
    background: var(--bg2);
    color: var(--text);
}

.alert-actions button:hover {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
}

.alert-btn-ok {
    background: var(--accent) !important;
    color: white !important;
    border-color: var(--accent) !important;
}

.alert-btn-ok:hover {
    background: var(--accent-hover) !important;
    border-color: var(--accent-hover) !important;
}
