@import url('theme.css');

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

body {
    font-family: var(--c-font-family);
    background: var(--c-bg-body);
    height: 100vh;
    display: flex;
    overflow: hidden;
}

/* 左侧边栏 - 对话列表 */
.sidebar {
    width: 260px;
    background: var(--c-bg-sidebar);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--c-border-subtle);
    transition: all 0.3s;
}

.sidebar-header {
    padding: 12px;
    border-bottom: 1px solid var(--c-border-subtle);
}

.new-chat-btn {
    width: 100%;
    padding: 12px;
    background: var(--c-accent-soft);
    border: 1px solid var(--c-accent-border);
    border-radius: 12px;
    color: var(--c-text);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.new-chat-btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.new-chat-btn-icon img {
    width: 16px;
    height: 16px;
    display: block;
    filter: var(--c-icon-accent-filter);
}

.new-chat-btn:hover {
    background: rgba(59, 130, 246, 0.18);
    border-color: var(--c-accent);
}

.conversations-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.conversation-item {
    padding: 12px;
    margin-bottom: 4px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--c-text);
    font-size: 14px;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    border-left: 3px solid transparent;
}

.conversation-item:hover {
    background: var(--c-bg-surface);
}

.conversation-item.active {
    background: var(--c-bg-raised);
    border-left-color: var(--c-accent);
}

.conversation-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

.conversation-actions {
    display: none;
    gap: 4px;
    align-items: center;
    position: relative;
}

.conversation-item:hover .conversation-actions {
    display: flex;
}

.conversation-action-btn {
    padding: 4px 8px;
    background: transparent;
    border: none;
    color: var(--c-text-secondary);
    cursor: pointer;
    border-radius: 4px;
    font-size: 12px;
}

.conversation-action-btn:hover {
    background: var(--c-bg-raised);
    color: var(--c-text);
}

/* 下拉菜单按钮 (三点) */
.conversation-menu-btn {
    padding: 4px 8px;
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    color: var(--c-text-muted);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.conversation-menu-btn:hover {
    background: var(--c-bg-raised);
    color: var(--c-text);
}

/* 下拉菜单容器 */
.conversation-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--c-bg-surface);
    border: 1px solid var(--c-bg-raised);
    border-radius: 6px;
    min-width: 140px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    display: none;
    overflow: hidden;
    margin-top: 4px;
}

.conversation-dropdown.show {
    display: block;
}

.dropdown-item {
    padding: 10px 16px;
    color: var(--c-text);
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
}

.dropdown-icon,
.icon-img {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    display: block;
    filter: invert(0.85);
    opacity: 0.9;
}

.dropdown-item.danger .dropdown-icon {
    filter: invert(0.55) sepia(1) saturate(5) hue-rotate(320deg);
}

.dropdown-item:hover {
    background: var(--c-bg-raised);
}

.dropdown-item.danger {
    color: var(--c-danger);
}

.dropdown-item.danger:hover {
    background: rgba(248, 81, 73, 0.15);
}

.dropdown-divider {
    height: 1px;
    background: var(--c-bg-raised);
    margin: 4px 0;
}

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

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 6px;
    color: var(--c-text);
    cursor: pointer;
}

.user-info:hover {
    background: var(--c-bg-surface);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--c-user-avatar);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--c-text);
    font-weight: 600;
    font-size: 14px;
}

.user-name {
    flex: 1;
    font-size: 14px;
}

/* 主区域 */
.main-area {
    display: flex;
    flex-direction: column;
    background: var(--c-bg-main);
    overflow: hidden;
    /* 消息区与输入框共用宽度 */
    --msg-header-name-size: 20px;
    --msg-header-time-size: 17px;
    --msg-header-line-height: 1.25;
    --msg-header-gap: 2px;
    --msg-avatar-size: calc(var(--msg-header-name-size) * var(--msg-header-line-height) + var(--msg-header-gap) + var(--msg-header-time-size) * var(--msg-header-line-height));
    --msg-aside-width: var(--msg-avatar-size);
    --msg-gap: 4px;
    --msg-side-gutter: 80px;
    --msg-h-padding: 20px;
    --msg-max-width: min(900px, calc(100% - var(--msg-aside-width) - var(--msg-gap) - 16px));
    --msg-lane-inset: calc(var(--msg-side-gutter) + var(--msg-aside-width) + var(--msg-gap));
    --msg-lane-width: calc(100% - 2 * var(--msg-lane-inset));
}

.chat-header {
    height: 60px;
    background: var(--c-bg-main);
    border-bottom: 1px solid var(--c-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    flex-shrink: 0;
    gap: 12px;
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.sidebar-toggle-btn {
    display: none;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--c-border);
    border-radius: 8px;
    background: transparent;
    color: var(--c-text);
    cursor: pointer;
    transition: background 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.sidebar-toggle-btn:hover {
    background: var(--c-bg-raised);
}

.sidebar-toggle-icon {
    position: relative;
    display: block;
    width: 16px;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
}

.sidebar-toggle-icon::before,
.sidebar-toggle-icon::after {
    content: '';
    position: absolute;
    left: 0;
    width: 16px;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
    transition: transform 0.2s;
}

.sidebar-toggle-icon::before {
    top: -5px;
}

.sidebar-toggle-icon::after {
    top: 5px;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99;
    background: var(--c-overlay);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.sidebar-backdrop:not([hidden]) {
    display: block;
}

.model-picker-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 108;
    background: var(--c-overlay);
}

.model-picker-backdrop:not([hidden]) {
    display: block;
}

.chat-title-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.chat-title {
    color: var(--c-text);
    font-size: 16px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-provider-badge {
    flex-shrink: 0;
    padding: 4px 10px;
    background: var(--c-bg-raised);
    border: 1px solid var(--c-border);
    border-radius: 12px;
    color: var(--c-text-secondary);
    font-size: 12px;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.header-btn {
    padding: 8px 16px;
    background: transparent;
    border: 1px solid var(--c-border);
    border-radius: 6px;
    color: var(--c-text);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.header-btn:hover {
    background: var(--c-bg-raised);
}

.header-btn-label--short {
    display: none;
}

.header-btn--mcp {
    display: none;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
}

.header-btn-icon {
    display: block;
    width: 16px;
    height: 16px;
    filter: brightness(0) invert(0.85);
    flex-shrink: 0;
}

/* 聊天容器 */
.chat-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px var(--msg-h-padding);
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-height: 0;
}

.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--c-text);
    text-align: center;
}

.welcome-icon {
    font-size: 48px;
    margin-bottom: 20px;
}

.welcome-title {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 12px;
}

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

.example-prompts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 12px;
    max-width: 800px;
    width: 100%;
}

.example-prompt {
    padding: 16px;
    background: var(--c-bg-card);
    border: 1px solid var(--c-border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.example-prompt:hover {
    background: var(--c-bg-card-hover);
    border-color: var(--c-border-strong);
}

.example-prompt-title {
    font-weight: 600;
    margin-bottom: 6px;
}

.example-prompt-text {
    font-size: 13px;
    color: var(--c-text-secondary);
}

/* 消息行：头像紧贴内容区两侧，整行与输入框同宽居中 */
.msg-row {
    display: flex;
    align-items: flex-start;
    width: calc(100% - 2 * var(--msg-side-gutter));
    margin-left: auto;
    margin-right: auto;
    gap: var(--msg-gap);
}

.msg-aside {
    flex: 0 0 var(--msg-aside-width);
    width: var(--msg-aside-width);
    display: flex;
    align-items: flex-start;
}

.msg-aside--left {
    justify-content: flex-end;
}

.msg-aside--right {
    justify-content: flex-start;
}

.msg-block {
    flex: 1 1 0;
    min-width: 0;
    max-width: min(900px, 100%);
    overflow: hidden;
}

.msg-row--assistant .msg-block {
    margin-right: auto;
}

.msg-row--user .msg-block {
    margin-left: auto;
}

.msg-block--user {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.msg-block--assistant {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

/* 顶栏：昵称 + 时间（头像在两侧 msg-aside 中） */
.msg-header {
    margin-bottom: 12px;
    width: 100%;
}

.msg-row--user .msg-header {
    text-align: right;
}

.msg-row--assistant .msg-header {
    text-align: left;
}

.msg-header-text {
    display: inline-flex;
    flex-direction: column;
    gap: var(--msg-header-gap);
    min-width: 0;
    max-width: 100%;
    min-height: var(--msg-avatar-size);
    justify-content: center;
}

.msg-row--user .msg-header-text {
    align-items: flex-end;
    text-align: right;
}

.msg-row--assistant .msg-header-text {
    align-items: flex-start;
    text-align: left;
}

.msg-sender {
    font-size: var(--msg-header-name-size);
    font-weight: 600;
    color: var(--c-text);
    line-height: var(--msg-header-line-height);
}

.msg-time {
    font-size: var(--msg-header-time-size);
    color: var(--c-text-muted);
    line-height: var(--msg-header-line-height);
}

.msg-avatar {
    width: var(--msg-avatar-size);
    height: var(--msg-avatar-size);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(var(--msg-avatar-size) * 0.46);
    font-weight: 600;
    flex-shrink: 0;
    overflow: hidden;
}

.msg-avatar--img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.msg-avatar--robot img {
    width: 58%;
    height: 58%;
    object-fit: contain;
    filter: brightness(0) invert(1);
}

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

.msg-row--assistant .msg-avatar {
    background: var(--c-assistant-avatar);
    color: var(--c-text);
}

.msg-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    max-width: 100%;
    width: 100%;
}

.msg-row--user .msg-body {
    align-items: flex-end;
}

.msg-row--assistant .msg-body {
    align-items: flex-start;
}

.msg-bubble {
    color: var(--c-text);
    line-height: 1.6;
    font-size: 15px;
    border-radius: 10px;
    padding: 12px 16px;
    max-width: 100%;
    box-sizing: border-box;
    overflow-wrap: break-word;
    word-break: break-word;
}

.msg-row--user .msg-bubble {
    width: max-content;
    max-width: 100%;
}

.msg-row--assistant .msg-bubble {
    width: 100%;
}

.msg-bubble--user {
    background: var(--c-user-bubble);
    border: 1px solid var(--c-user-bubble-border);
}

.msg-bubble--assistant {
    background: var(--c-assistant-bubble);
    border: 1px solid transparent;
}

/* Markdown 内容区（沿用 message-content 类名） */
.message-content {
    color: var(--c-text);
    line-height: 1.6;
    font-size: 15px;
}

.message-content :where(p, li, td, th, strong, em, del) {
    color: var(--c-text);
}

/* Markdown 样式 */
.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4,
.message-content h5,
.message-content h6 {
    margin-top: 16px;
    margin-bottom: 8px;
    font-weight: 600;
    line-height: 1.25;
    color: var(--c-text);
}

.message-content h1 {
    font-size: 2em;
    border-bottom: 1px solid var(--c-border);
    padding-bottom: 0.3em;
}

.message-content h2 {
    font-size: 1.5em;
    border-bottom: 1px solid var(--c-border);
    padding-bottom: 0.3em;
}

.message-content h3 {
    font-size: 1.25em;
}

.message-content h4 {
    font-size: 1em;
}

.message-content h5 {
    font-size: 0.875em;
}

.message-content h6 {
    font-size: 0.85em;
    color: var(--c-text-muted);
}

.message-content p {
    margin-top: 0;
    margin-bottom: 16px;
}

.message-content ul,
.message-content ol {
    margin-top: 0;
    margin-bottom: 16px;
    padding-left: 2em;
}

.message-content li {
    margin-bottom: 4px;
}

.message-content code {
    background: var(--c-bg-code);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
    color: var(--c-text);
}

.message-content :not(pre)>code {
    color: var(--c-text);
}

.message-content pre {
    background: var(--c-bg-code);
    padding: 16px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 16px 0;
    position: relative;
}

.message-content pre .copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 8px;
    background: var(--c-bg-raised);
    border: 1px solid var(--c-border);
    border-radius: 4px;
    color: var(--c-text);
    font-size: 12px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
}

.message-content pre:hover .copy-btn {
    opacity: 1;
}

.message-content pre .copy-btn:hover {
    background: var(--c-border);
}

.message-content pre .copy-btn.copied {
    background: var(--c-accent);
    border-color: var(--c-accent);
}

.message-content pre code {
    background: none;
    padding: 0;
    font-size: 0.9em;
    line-height: 1.5;
}

.message-content blockquote {
    margin: 16px 0;
    padding-left: 16px;
    border-left: 4px solid var(--c-border);
    color: var(--c-text-secondary);
}

.message-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 16px 0;
}

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

.message-content table th {
    background: var(--c-bg-code);
    font-weight: 600;
    color: var(--c-text);
}

.message-content a {
    color: var(--c-link);
    text-decoration: none;
}

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

.message-content hr {
    border: none;
    border-top: 1px solid var(--c-border);
    margin: 24px 0;
}

.message-content img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 8px 0;
}

/* 消息下方控制条（放置音频播放按钮） */
.message-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding-left: 4px;
}

.message-streaming-indicator {
    display: inline-flex;
    align-items: center;
    margin-left: auto;
    padding: 2px 4px;
    min-height: 30px;
}

.message-streaming-indicator[hidden] {
    display: none !important;
}

.audio-play-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 3px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--c-text-muted);
    cursor: pointer;
    font-size: 18px;
    transition: all 0.15s ease;
    margin: 0;
    opacity: 0.85;
}

/* SVG 图标尺寸与颜色继承 */
.audio-play-btn svg {
    width: 20px;
    height: 20px;
    display: block;
    fill: currentColor;
}

/* 播放动画：均衡器柱状条上下律动 */
@keyframes eqBounce {

    0%,
    100% {
        transform: scaleY(0.4);
    }

    50% {
        transform: scaleY(1);
    }
}

.audio-play-btn.playing .bar1 {
    animation: eqBounce 0.9s infinite ease-in-out;
    transform-origin: bottom;
}

.audio-play-btn.playing .bar2 {
    animation: eqBounce 0.9s infinite ease-in-out 0.1s;
    transform-origin: bottom;
}

.audio-play-btn.playing .bar3 {
    animation: eqBounce 0.9s infinite ease-in-out 0.2s;
    transform-origin: bottom;
}

.audio-play-btn.playing .bar4 {
    animation: eqBounce 0.9s infinite ease-in-out 0.3s;
    transform-origin: bottom;
}

.audio-play-btn:hover {
    border: 1px solid var(--c-accent);
    background: rgba(59, 130, 246, 0.05);
    opacity: 1;
}

.audio-play-btn.playing {
    border: 1px solid var(--c-accent);
    background: rgba(59, 130, 246, 0.1);
    color: var(--c-accent);
}

.audio-play-btn.playing:hover {
    background: rgba(59, 130, 246, 0.15);
}

/* 复制和重新生成按钮 */
.copy-message-btn,
.regenerate-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 3px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--c-text-muted);
    cursor: pointer;
    font-size: 16px;
    transition: all 0.15s ease;
    margin: 0;
    opacity: 0.85;
}

.copy-message-btn svg,
.regenerate-btn svg {
    width: 18px;
    height: 18px;
    display: block;
    fill: currentColor;
}

.copy-message-btn:hover,
.regenerate-btn:hover {
    border: 1px solid var(--c-accent);
    background: rgba(59, 130, 246, 0.05);
    opacity: 1;
}

.copy-message-btn.copied {
    color: var(--c-accent);
    border: 1px solid var(--c-accent);
    background: rgba(59, 130, 246, 0.1);
}

.agent-panel {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    border: 1px solid var(--c-border);
    border-radius: 10px;
    background: var(--c-bg-main);
    overflow: hidden;
    box-sizing: border-box;
}

.agent-panel-summary {
    width: 100%;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    border: none;
    background: transparent;
    color: var(--c-text);
    cursor: pointer;
    text-align: left;
    box-sizing: border-box;
}

.agent-panel-summary:hover {
    background: rgba(255, 255, 255, 0.03);
}

.agent-panel-summary-leading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.agent-panel-chevron {
    width: 7px;
    height: 7px;
    border-right: 1.5px solid var(--c-text-secondary);
    border-bottom: 1.5px solid var(--c-text-secondary);
    transform: rotate(-45deg);
    transition: transform 0.15s ease;
    flex-shrink: 0;
}

.agent-panel.is-expanded .agent-panel-chevron {
    transform: rotate(45deg);
}

.agent-panel-summary-text {
    font-size: 13px;
    font-weight: 600;
}

.agent-panel-summary-meta {
    font-size: 12px;
    color: var(--c-text-secondary);
    flex-shrink: 0;
    max-width: 50%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.agent-panel-body.agent-timeline {
    list-style: none;
    margin: 0;
    padding: 4px 12px 12px 8px;
}

.agent-timeline-item {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 8px;
    position: relative;
}

.agent-timeline-item:not(.agent-timeline-item--last) .agent-timeline-rail::after {
    content: "";
    position: absolute;
    left: 13px;
    top: 22px;
    bottom: -6px;
    width: 1px;
    background: var(--c-border);
}

.agent-timeline-rail {
    position: relative;
    display: flex;
    justify-content: center;
    padding-top: 6px;
}

.agent-timeline-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    z-index: 1;
    background: var(--c-bg-raised);
    border: 1px solid var(--c-border);
    color: var(--c-text-secondary);
}

.agent-timeline-dot--running {
    border-color: rgba(88, 166, 255, 0.45);
    background: rgba(88, 166, 255, 0.12);
}

.agent-timeline-dot--completed {
    border-color: var(--c-success-border);
    background: var(--c-success-soft);
    color: var(--c-success);
}

.agent-timeline-dot--error {
    border-color: rgba(248, 81, 73, 0.45);
    background: rgba(248, 81, 73, 0.12);
    color: var(--c-danger);
}

.agent-spinner {
    width: 10px;
    height: 10px;
    border: 1.5px solid rgba(88, 166, 255, 0.25);
    border-top-color: var(--c-link);
    border-radius: 50%;
    animation: agent-spin 0.8s linear infinite;
}

@keyframes agent-spin {
    to {
        transform: rotate(360deg);
    }
}

.agent-timeline-card {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    border: 1px solid transparent;
    border-radius: 8px;
    margin-bottom: 6px;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.agent-timeline-card[open] {
    border-color: var(--c-border-strong);
    background: rgba(0, 0, 0, 0.12);
}

.agent-timeline-card-summary {
    list-style: none;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
    padding: 8px 10px;
    cursor: pointer;
}

.agent-timeline-card-summary::-webkit-details-marker {
    display: none;
}

.agent-timeline-card-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
}

.agent-timeline-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--c-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.agent-timeline-status {
    font-size: 11px;
    flex-shrink: 0;
    padding: 1px 7px;
    border-radius: 999px;
    border: 1px solid transparent;
}

.agent-timeline-status--pending,
.agent-timeline-status--running {
    color: var(--c-link);
    border-color: rgba(88, 166, 255, 0.25);
    background: rgba(88, 166, 255, 0.08);
}

.agent-timeline-status--completed {
    color: var(--c-success);
    border-color: rgba(34, 197, 94, 0.25);
    background: rgba(34, 197, 94, 0.08);
}

.agent-timeline-status--error {
    color: var(--c-danger);
    border-color: rgba(248, 81, 73, 0.25);
    background: rgba(248, 81, 73, 0.08);
}

.agent-timeline-round {
    font-size: 11px;
    color: var(--c-text-muted);
}

.agent-timeline-preview {
    font-size: 12px;
    line-height: 1.45;
    color: var(--c-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.agent-timeline-card[open] .agent-timeline-preview {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.agent-timeline-card-body {
    padding: 0 10px 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.agent-tool-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.agent-tool-section-title {
    font-size: 12px;
    color: var(--c-text-secondary);
}

.agent-tool-pre {
    margin: 0;
    padding: 10px 12px;
    background: var(--c-bg-surface);
    border: 1px solid var(--c-border);
    border-radius: 8px;
    color: var(--c-text);
    font-size: 12px;
    line-height: 1.55;
    max-width: 100%;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    box-sizing: border-box;
}

.message-meta {
    margin-top: 8px;
    font-size: 12px;
    color: var(--c-text-muted);
    display: flex;
    gap: 12px;
}

/* 输入区域：横跨左侧 AI 与右侧用户消息的可视宽度 */
.input-area {
    padding: 12px var(--msg-h-padding) 20px;
    background: var(--c-bg-main);
    flex-shrink: 0;
}

.input-container {
    width: var(--msg-lane-width);
    max-width: none;
    margin-left: var(--msg-lane-inset);
    margin-right: var(--msg-lane-inset);
    position: relative;
}

.composer {
    display: flex;
    flex-direction: column;
    background: var(--c-bg-composer);
    border-radius: 14px;
    border: 1px solid var(--c-border);
    overflow: visible;
    transition: border-color 0.2s;
}

.composer-attachments {
    display: none;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 0;
}

.composer-attachments.has-images {
    display: flex;
    padding: 10px 12px 0;
}

.composer-attachments[hidden] {
    display: none !important;
    padding: 0;
}

.composer-thumb {
    position: relative;
    width: 56px;
    height: 56px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--c-border);
    cursor: zoom-in;
    flex-shrink: 0;
}

.composer-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.composer-thumb-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.composer-thumb-remove:hover {
    background: var(--c-danger);
}

.composer-thumb-status {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    pointer-events: none;
}

.composer-thumb-status::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 18px;
    height: 18px;
    margin: -9px 0 0 -9px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: composer-spin 0.7s linear infinite;
}

@keyframes composer-spin {
    to {
        transform: rotate(360deg);
    }
}

.composer-thumb-add {
    width: 56px;
    height: 56px;
    border: 1px dashed var(--c-border-strong);
    border-radius: 8px;
    background: transparent;
    color: var(--c-text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: border-color 0.15s, color 0.15s;
}

.composer-thumb-add:hover {
    border-color: var(--c-text-muted);
    color: var(--c-text);
}

.composer-thumb-add-icon {
    width: 22px;
    height: 22px;
    filter: invert(0.75);
    opacity: 0.9;
}

.composer-thumb-add:hover .composer-thumb-add-icon {
    filter: invert(0.92);
    opacity: 1;
}

.model-picker-name-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 6px;
}

.model-picker-tags {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.model-picker-tag {
    display: inline-block;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
    border-radius: 6px;
    vertical-align: middle;
}

.model-picker-tag--vision {
    background: var(--c-success-soft);
    color: var(--c-success);
}

.model-picker-tag--tool_calling {
    background: var(--c-accent-soft);
    color: var(--c-link);
}

.model-picker-tag--thinking {
    background: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
}

.msg-images {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.msg-image-thumb {
    max-width: 200px;
    max-height: 160px;
    border-radius: 8px;
    object-fit: cover;
    cursor: zoom-in;
    border: 1px solid var(--c-border);
}

.image-lightbox {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.image-lightbox.is-open {
    display: flex;
}

.image-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
}

.image-lightbox-content {
    position: relative;
    z-index: 1;
    max-width: min(92vw, 1200px);
    max-height: 90vh;
}

.image-lightbox-content img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.image-lightbox-close {
    position: absolute;
    top: -12px;
    right: -12px;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: var(--c-bg-raised);
    color: var(--c-text);
    font-size: 20px;
    cursor: pointer;
    z-index: 2;
}

.image-lightbox-close:hover {
    background: var(--c-danger);
}

.composer:focus-within {
    border-color: var(--c-accent);
    box-shadow: 0 0 0 1px var(--c-accent-border);
}

.composer-body {
    position: relative;
    min-height: 80px;
    overflow: visible;
}

.composer.is-voice-mode .composer-body {
    min-height: 72px;
}

.composer-voice-hold {
    display: none;
    width: 100%;
    min-height: 72px;
    padding: 16px 18px;
    border: none;
    background: transparent;
    color: var(--c-text);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 0;
    font-family: inherit;
    transition: background 0.15s, color 0.15s;
}

.composer:not(.is-voice-mode) .composer-voice-hold {
    display: none !important;
}

.composer.is-voice-mode .composer-voice-hold {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
}

.composer.is-voice-mode #messageInput {
    display: none;
}

.composer-voice-hold:hover:not(:disabled):not(.is-vhi-recording) {
    background: rgba(255, 255, 255, 0.04);
}

.composer-voice-hold:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

#messageInput {
    width: 100%;
    min-height: 80px;
    max-height: 220px;
    padding: 16px 18px 10px;
    background: transparent;
    border: none;
    color: var(--c-text);
    font-size: 15px;
    outline: none;
    resize: none;
    font-family: inherit;
    line-height: 1.5;
}

#messageInput::placeholder {
    color: var(--c-text-muted);
}

.composer-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 5px 10px 7px;
    border-top: 1px solid var(--c-border-inner);
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.toolbar-icon-btn,
.model-select-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 4px 8px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--c-text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.toolbar-icon-btn:hover,
.model-select-btn:hover {
    background: var(--c-bg-raised);
    border-color: var(--c-border);
    color: var(--c-text);
}

.toolbar-icon-btn img {
    display: block;
    filter: invert(0.8);
    opacity: 0.9;
}

.toolbar-divider {
    width: 1px;
    height: 16px;
    background: var(--c-border);
    flex-shrink: 0;
}

.model-picker-wrap {
    position: relative;
}

.model-select-btn {
    max-width: 220px;
}

.model-select-label {
    font-size: 13px;
    color: var(--c-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.model-picker {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    width: min(480px, calc(100vw - 48px));
    max-height: 400px;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    background: var(--c-bg-surface);
    border: 1px solid var(--c-border);
    border-radius: 12px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
    z-index: 200;
    padding: 10px;
}

.model-picker::-webkit-scrollbar {
    display: none;
}

.model-picker.show {
    display: block;
}

.model-picker-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 13px 16px;
    border: none;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
    transition: background 0.15s;
}

.model-picker-item:hover,
.model-picker-item.active {
    background: var(--c-bg-raised);
}

.model-picker-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--c-text);
}

.model-picker-desc {
    font-size: 13px;
    line-height: 1.55;
    color: var(--c-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.model-picker-empty {
    padding: 16px;
    text-align: center;
    color: var(--c-text-muted);
    font-size: 13px;
}

/* ── 思考设置按钮与弹出菜单 ── */
.thinking-picker-wrap {
    position: relative;
}

.thinking-btn--active img {
    filter: invert(84%) sepia(61%) saturate(1498%) hue-rotate(359deg) brightness(103%) contrast(98%) !important;
    opacity: 1 !important;
}

.thinking-btn--active {
    color: #facc15;
}

.thinking-picker {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    min-width: 100px;
    background: var(--c-bg-surface);
    border: 1px solid var(--c-border);
    border-radius: 10px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
    z-index: 200;
    padding: 6px;
    overflow: hidden;
}

.thinking-picker.show {
    display: block;
}

.thinking-option {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    background: transparent;
    font-size: 13px;
    color: var(--c-text);
    cursor: pointer;
    transition: background 0.12s;
    white-space: nowrap;
}

.thinking-option:hover {
    background: var(--c-bg-raised);
}

.thinking-option.active {
    background: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
    font-weight: 600;
}

/* ── 思考面板（消息内，可折叠） ── */
.thinking-panel {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    margin-bottom: 8px;
    border: 1px solid var(--c-border);
    border-radius: 10px;
    background: var(--c-bg-main);
    overflow: hidden;
}

.thinking-panel-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    cursor: pointer;
    color: var(--c-text-muted);
    font-size: 13px;
    line-height: 1.4;
    transition: background 0.12s;
    user-select: none;
}

.thinking-panel-summary:hover {
    background: var(--c-bg-raised);
}

.thinking-panel-summary-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
}

.thinking-panel-icon {
    display: block;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    filter: invert(0.65);
    opacity: 0.85;
}

.thinking-panel-status {
    font-size: 13px;
    color: var(--c-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.thinking-panel-actions {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.thinking-panel-copy-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--c-text-faint);
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.12s, color 0.12s;
}

.thinking-panel-copy-btn svg {
    width: 15px;
    height: 15px;
    fill: currentColor;
}

.thinking-panel-copy-btn:hover {
    background: var(--c-bg-raised);
    color: var(--c-text-secondary);
}

.thinking-panel-chevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    position: relative;
}

.thinking-panel-chevron::before {
    content: '';
    display: block;
    width: 7px;
    height: 7px;
    border-right: 1.5px solid var(--c-text-faint);
    border-bottom: 1.5px solid var(--c-text-faint);
    transform: rotate(-45deg);
    transition: transform 0.2s;
}

.thinking-panel.is-expanded .thinking-panel-chevron::before {
    transform: rotate(45deg);
}

.thinking-panel-body {
    padding: 8px 12px 12px;
    border-top: 1px solid var(--c-border-subtle);
}

.thinking-round {
    margin-bottom: 6px;
}

.thinking-round:last-child {
    margin-bottom: 0;
}

.thinking-round + .thinking-round {
    padding-top: 6px;
    border-top: 1px solid var(--c-border-subtle);
}

.thinking-round-label {
    font-size: 11px;
    color: var(--c-text-faint);
    margin-bottom: 4px;
}

.thinking-round-content {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 13px;
    line-height: 1.65;
    color: var(--c-text-muted);
}

.shortcut-hint {
    font-size: 11px;
    color: var(--c-text-faint);
    white-space: nowrap;
}

.send-btn-circle {
    position: relative;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border: none;
    border-radius: 50%;
    background: var(--c-accent);
    color: #fff;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
}

.send-btn-icon--stop {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.send-btn-icon--stop[hidden] {
    display: none !important;
}

.send-btn-stop-img {
    position: relative;
    z-index: 2;
    display: block;
    width: 16px;
    height: 16px;
    filter: brightness(0) invert(1);
    pointer-events: none;
}

.send-btn-orbit {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 22px;
    height: 22px;
    margin: -11px 0 0 -11px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.22);
    border-top-color: rgba(255, 255, 255, 0.95);
    border-right-color: rgba(255, 255, 255, 0.55);
    box-sizing: border-box;
    pointer-events: none;
    z-index: 1;
    animation: send-btn-orbit-spin 0.9s linear infinite;
    will-change: transform;
}

@keyframes send-btn-orbit-spin {
    to {
        transform: rotate(360deg);
    }
}

.send-btn-circle:hover:not(:disabled) {
    background: var(--c-accent-hover);
    transform: translateY(-1px);
}

.send-btn-circle--stop {
    background: #e5534b;
    box-shadow: 0 0 0 1px rgba(229, 83, 75, 0.35);
}

.send-btn-circle--stop:hover:not(:disabled) {
    background: #d44a42;
}

.send-btn-circle:disabled {
    background: var(--c-border);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.send-btn-circle:disabled .send-btn-orbit {
    display: none;
}

/* 助手消息加载动画 */
.msg-bubble--assistant.is-loading {
    min-width: 72px;
}

.msg-body > .agent-panel:not([hidden]):has(+ .assistant-thinking-status) {
    border-radius: 10px 10px 0 0;
}

.msg-body > .assistant-thinking-status {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 8px;
    padding: 10px 14px;
    border: 1px solid var(--c-border);
    border-radius: 10px;
    background: var(--c-bg-main);
    color: var(--c-text-muted);
    font-size: 0.8125rem;
    line-height: 1.4;
}

.msg-body > .agent-panel:not([hidden]) + .assistant-thinking-status {
    margin-top: 0;
    border-top: none;
    border-radius: 0 0 10px 10px;
}

.assistant-loading {
    display: flex;
    align-items: center;
    padding: 2px 0;
    min-height: 20px;
}

.assistant-loading-dots {
    display: grid;
    grid-template-columns: repeat(2, 5px);
    gap: 4px;
}

.assistant-loading-dots span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--c-accent);
    animation: assistant-dot-pulse 1.1s ease-in-out infinite;
}

.assistant-loading-dots span:nth-child(1) {
    animation-delay: 0s;
}

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

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

.assistant-loading-dots span:nth-child(4) {
    animation-delay: 0.45s;
}

@keyframes assistant-dot-pulse {

    0%,
    100% {
        opacity: 0.25;
        transform: scale(0.8);
    }

    50% {
        opacity: 1;
        transform: scale(1);
    }
}

/* 滚动条样式 */
.conversations-list::-webkit-scrollbar {
    display: none;
}

.chat-container::-webkit-scrollbar {
    width: 8px;
}

.chat-container::-webkit-scrollbar-track {
    background: transparent;
}

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

.chat-container::-webkit-scrollbar-thumb:hover {
    background: var(--c-text-faint);
}

/* 响应式 */
@media (max-width: 768px) {
    html {
        height: 100%;
        height: 100dvh;
    }

    body {
        height: 100dvh;
        max-height: 100dvh;
        min-height: 0;
    }

    .chat-workspace {
        flex: 1;
        min-height: 0;
        min-width: 0;
        height: 100%;
        max-height: 100dvh;
    }

    .chat-workspace .main-area {
        flex: 1;
        min-height: 0;
        height: 100%;
        max-height: 100dvh;
        --mobile-input-reserved: 148px;
    }

    .main-area {
        /* 移动端：头像贴近两侧，字号稍小 */
        --msg-header-name-size: 16px;
        --msg-header-time-size: 13px;
        --msg-header-gap: 2px;
        --msg-gap: 4px;
        --msg-side-gutter: 0px;
        /* 让头像紧贴屏幕边缘 */
        --msg-h-padding: 12px;
        --msg-lane-inset: calc(var(--msg-side-gutter) + var(--msg-aside-width) + var(--msg-gap));
        --msg-lane-width: calc(100% - 2 * var(--msg-lane-inset));
        width: 100%;
    }

    .sidebar-toggle-btn {
        display: inline-flex;
    }

    .header-btn--mcp {
        display: inline-flex;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        width: min(280px, 85vw);
        height: 100dvh;
        max-height: 100dvh;
        z-index: 100;
        transform: translateX(-100%);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.35);
    }

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

    .chat-header {
        height: 52px;
        padding: 0 12px;
        padding-top: env(safe-area-inset-top, 0px);
        gap: 8px;
        flex-shrink: 0;
    }

    .chat-title {
        font-size: 15px;
    }

    .ai-provider-badge {
        display: none;
    }

    .header-actions {
        flex-shrink: 0;
        gap: 4px;
    }

    .header-btn {
        padding: 6px 8px;
        font-size: 12px;
    }

    .header-btn-label--long {
        display: none;
    }

    .header-btn-label--short {
        display: inline;
    }

    .chat-container {
        flex: 1;
        min-height: 0;
        padding-top: 12px;
        padding-bottom: calc(var(--mobile-input-reserved) + env(safe-area-inset-bottom, 0px));
        gap: 16px;
    }

    .msg-block {
        max-width: 100%;
    }

    .msg-bubble {
        font-size: 14px;
        padding: 10px 14px;
    }

    .message-content {
        font-size: 14px;
    }

    .message-content pre {
        padding: 12px;
        font-size: 12px;
    }

    .input-area {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 110;
        padding: 8px var(--msg-h-padding);
        padding-bottom: max(12px, env(safe-area-inset-bottom, 12px));
        background: var(--c-bg-main);
        box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.2);
    }

    .input-container {
        width: 100%;
        max-width: 100%;
        margin-left: 0;
        margin-right: 0;
    }

    .composer-body {
        min-height: 48px;
    }

    .composer.is-voice-mode .composer-body {
        min-height: 48px;
    }

    #messageInput {
        min-height: 48px;
        max-height: 120px;
        padding: 10px 14px 6px;
        font-size: 16px;
    }

    .composer-toolbar {
        flex-wrap: nowrap;
        gap: 4px;
        padding: 4px 8px 6px;
    }

    .toolbar-left {
        flex: 1;
        min-width: 0;
        gap: 2px;
    }

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

    .shortcut-hint {
        display: none;
    }

    .model-select-btn {
        max-width: 96px;
        padding: 4px 6px;
    }

    .model-select-label {
        font-size: 12px;
    }

    .model-picker.model-picker--sheet {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        width: auto;
        max-height: min(360px, 50vh);
        margin: 0;
        padding: 0 0 env(safe-area-inset-bottom, 0px);
        border-radius: 16px 16px 0 0;
        border-bottom: none;
        z-index: 109;
        box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.45);
        animation: modelSheetSlideUp 0.22s ease-out;
    }

    .model-picker-header {
        padding: 14px 16px 10px;
        font-size: 15px;
        font-weight: 600;
        color: var(--c-text);
        border-bottom: 1px solid var(--c-border-inner);
        position: sticky;
        top: 0;
        background: var(--c-bg-surface);
        border-radius: 16px 16px 0 0;
    }

    .model-picker.model-picker--sheet .model-picker-item {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 14px 16px;
        border-radius: 0;
    }

    .model-picker.model-picker--sheet .model-picker-item.active {
        background: rgba(59, 130, 246, 0.1);
    }

    .model-picker.model-picker--sheet .model-picker-name {
        font-size: 15px;
        font-weight: 500;
    }

    .model-picker-check {
        flex-shrink: 0;
        color: var(--c-accent);
        font-size: 18px;
        font-weight: 700;
        line-height: 1;
    }

    .model-picker-desc,
    .model-picker-tags {
        display: none !important;
    }

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

    .example-prompts {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .welcome-title {
        font-size: 20px;
    }

    .welcome-subtitle {
        font-size: 13px;
        margin-bottom: 20px;
    }

    .welcome-icon {
        font-size: 40px;
        margin-bottom: 16px;
    }

    .conversation-item .conversation-actions {
        display: flex;
    }

    .toast-container {
        top: auto;
        right: 12px;
        left: 12px;
        bottom: calc(var(--mobile-input-reserved) + 12px + env(safe-area-inset-bottom, 0px));
        align-items: stretch;
    }

    .toast {
        min-width: 0;
        max-width: none;
        animation: slideInUp 0.3s ease-out;
    }

    .toast.hiding {
        animation: slideOutDown 0.3s ease-in forwards;
    }

    .empty-state {
        padding: 24px 16px;
    }

    .poetry-widget {
        z-index: 105;
    }
}

@media (max-width: 480px) {
    .toolbar-divider {
        display: none;
    }

    .model-select-btn {
        max-width: 72px;
    }

    .header-btn--mcp .header-btn-label--short {
        display: none;
    }

    .header-btn--mcp {
        padding: 6px;
    }

    .composer-voice-hold {
        min-height: 48px;
        font-size: 14px;
    }

    .msg-image-thumb {
        max-width: 140px;
        max-height: 120px;
    }
}

@keyframes slideInUp {
    from {
        transform: translateY(40px);
        opacity: 0;
    }

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

@keyframes modelSheetSlideUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

@keyframes slideOutDown {
    from {
        transform: translateY(0);
        opacity: 1;
    }

    to {
        transform: translateY(40px);
        opacity: 0;
    }
}

/* 空状态 */
.empty-state {
    padding: 40px;
    text-align: center;
    color: var(--c-text-muted);
    font-size: 14px;
}

/* 错误提示 */
.error-message {
    padding: 12px 16px;
    background: var(--c-danger);
    color: var(--c-text);
    border-radius: 8px;
    margin: 10px 0;
    font-size: 14px;
}

/* Toast 提示框 */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: var(--c-bg-surface);
    border: 1px solid var(--c-bg-raised);
    border-radius: 8px;
    padding: 12px 20px;
    min-width: 250px;
    max-width: 400px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 12px;
    pointer-events: auto;
    animation: slideInRight 0.3s ease-out;
    color: var(--c-text);
    font-size: 14px;
}

.toast.success {
    border-left: 4px solid var(--c-success);
}

.toast.error {
    border-left: 4px solid var(--c-danger);
}

.toast.info {
    border-left: 4px solid var(--c-link);
}

.toast.warning {
    border-left: 4px solid var(--c-warning);
}

.toast-icon {
    font-size: 20px;
    flex-shrink: 0;
}

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

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

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

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

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    margin-bottom: 2px;
}

.toast-message {
    font-size: 13px;
    color: var(--c-text-secondary);
}

.toast.hiding {
    animation: slideOutRight 0.3s ease-in forwards;
}

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

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

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

    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

/* Qwen ASR 实时识别结果显示 */
#asrRecognitionDisplay {
    display: none;
    padding: 8px 14px;
    background: linear-gradient(135deg, rgba(88, 166, 255, 0.15), rgba(59, 130, 246, 0.15));
    border-top: 1px solid var(--c-border);
    color: var(--c-text);
    font-size: 14px;
    line-height: 1.5;
    min-height: 32px;
    display: flex;
    align-items: center;
    word-wrap: break-word;
    word-break: break-all;
}

#asrRecognitionDisplay[hidden] {
    display: none !important;
}

#asrRecognitionDisplay.is-final {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.2), rgba(59, 130, 246, 0.1));
    border-top: 1px solid var(--c-accent);
    color: var(--c-success);
}

/* ===== 灯箱缩放功能样式 ===== */
.image-lightbox-zoom-hint {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 13px;
    padding: 4px 12px;
    border-radius: 20px;
    pointer-events: none;
    z-index: 10001;
    transition: opacity 0.2s;
}

.image-lightbox img {
    cursor: zoom-in;
    transition: transform 0.05s linear;
    transform-origin: center center;
    user-select: none;
    -webkit-user-drag: none;
}

@media (max-width: 768px) {
/* ── 图片灯箱 ── */
.image-lightbox {
        padding: 12px;
        align-items: center;
        justify-content: center;
    }

    .image-lightbox-content {
        max-width: calc(100vw - 24px);
        max-height: calc(100dvh - 24px);
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .image-lightbox-content img {
        max-width: 100%;
        max-height: calc(100dvh - 24px);
        object-fit: contain;
    }
}
