:root {
    /* ==============================
       全局颜色配置（柔和奶油 · 米色阅读感）
       ============================== */

    /* --- 主题色（奶油拿铁）--- */
    --primary-color: #8b7a66;        /* 温润米棕，克制高级 */
    --primary-rgb: 139, 122, 102;
    --primary-hover: #7a6a58;        /* 悬停略压 */
    --primary-active: #a08c74;       /* 激活轻提亮 */

    /* --- 背景色 --- */
    --bg-white: #ffffff;
    --bg-main: #faf7f2;              /* 奶油白，极舒适 */
    --bg-hover: #f3eee6;             /* 悬停像纸张叠层 */
    --bg-code: #faf7f2;              /* 代码块偏羊皮纸 */
    --bg-overlay: rgba(60, 50, 40, 0.55); /* 暖深色遮罩 */
    --page-background:
        radial-gradient(ellipse 65% 70% at 0% 0%, color-mix(in srgb, var(--primary-color) 14%, white), transparent 78%),
        radial-gradient(ellipse 58% 68% at 100% 100%, color-mix(in srgb, var(--primary-color) 12%, white), transparent 78%),
        #fff;

    /* --- 边框色 --- */
    --border-light: #e8e1d7;         /* 低存在感分割 */
    --border-medium: #d8cfc2;        /* 输入框/按钮 */
    --border-table: #e0d8cc;

    /* --- 文本色 --- */
    --text-main: #2f2a25;            /* 深咖灰，护眼 */
    --text-regular: #4a433c;         /* 正文 */
    --text-secondary: #6f665c;       /* 次要说明 */
    --text-muted: #9a9186;           /* 弱化信息 */
    --text-placeholder: #b8afa4;     /* 占位符 */

    /* --- 状态色（自然低饱和）--- */
    --status-success: #7a9b7e;       /* 鼠尾草绿 */
    --status-ready: #6b8f72;
    --status-info: #8aa1b1;          /* 奶灰蓝 */
    --status-error: #c26a5a;         /* 陶土红 */
}

:root[data-theme="sandstone"] {
    /* ==============================
       全局颜色配置（深蓝专业）
       ============================== */

    /* --- 主题色 --- */
    --primary-color: #3c6e8c;        /* 深蓝色 */
    --primary-rgb: 60, 110, 140;
    --primary-hover: #345e7a;        
    --primary-active: #467c9e;       

    /* --- 背景色 --- */
    --bg-white: #ffffff;
    --bg-main: #f5f8fa;              /* 冷灰蓝调 */
    --bg-hover: #eaf0f5;             
    --bg-code: #f0f5f8;              
    --bg-overlay: rgba(30, 45, 60, 0.55);

    /* --- 边框色 --- */
    --border-light: #d8e2ea;         
    --border-medium: #bfced9;        
    --border-table: #ccd9e3;

    /* --- 文本色 --- */
    --text-main: #1f2a33;            
    --text-regular: #35414a;         
    --text-secondary: #55626c;       
    --text-muted: #7c868f;           
    --text-placeholder: #9ba4ac;     

    /* --- 状态色 --- */
    --status-success: #4d8673;       
    --status-ready: #437562;
    --status-info: #4a7ba3;          /* 同色系深蓝 */
    --status-error: #b86457;         
}

:root[data-theme="evergreen"] {
    /* ==============================
       全局颜色配置（墨绿沉稳）
       ============================== */

    /* --- 主题色 --- */
    --primary-color: #3c6e5d;        /* 墨绿色 */
    --primary-rgb: 60, 110, 93;
    --primary-hover: #345e50;        
    --primary-active: #467c6a;       

    /* --- 背景色 --- */
    --bg-white: #ffffff;
    --bg-main: #f5f8f7;              /* 冷灰绿调 */
    --bg-hover: #eaf0ed;             
    --bg-code: #f0f5f3;              
    --bg-overlay: rgba(30, 45, 40, 0.55);

    /* --- 边框色 --- */
    --border-light: #d8e2de;         
    --border-medium: #bfcec8;        
    --border-table: #ccd9d3;

    /* --- 文本色 --- */
    --text-main: #1f2a26;            
    --text-regular: #35413c;         
    --text-secondary: #55645e;       
    --text-muted: #7c8883;           
    --text-placeholder: #9ba6a1;     

    /* --- 状态色 --- */
    --status-success: #4d8661;       
    --status-ready: #437554;
    --status-info: #648ba9;          
    --status-error: #b86457;   
}

:root[data-theme="ember"] {
    /* ==============================
       全局颜色配置（奶油米棕升级版）
       ============================== */

    /* --- 主题色（更干净高级）--- */
    --primary-color: #927b63;
    --primary-rgb: 146, 123, 99;
    --primary-hover: #7f6a55;
    --primary-active: #a48b72;

    /* --- 背景色 --- */
    --bg-white: #fffdf9;
    --bg-main: #f8f4ee;
    --bg-hover: #f1ebe2;
    --bg-code: #f7f2ea;
    --bg-overlay: rgba(55, 45, 35, 0.5);

    /* --- 边框色 --- */
    --border-light: #e9e1d6;
    --border-medium: #d7ccbd;
    --border-table: #e1d7ca;

    /* --- 文本色 --- */
    --text-main: #2e2924;
    --text-regular: #49423a;
    --text-secondary: #6d645a;
    --text-muted: #978d82;
    --text-placeholder: #b5ab9f;

    /* --- 状态色 --- */
    --status-success: #78937a;
    --status-ready: #68856b;
    --status-info: #839caf;
    --status-error: #bf6b5c;
}

:root[data-theme="ocean"] {
    --primary-color: #2c6b8f;
    --primary-rgb: 44, 107, 143;
    --primary-hover: #245a78;
    --primary-active: #3a82ad;

    --bg-white: #f7fbff;
    --bg-main: #edf5fb;
    --bg-hover: #e1edf7;
    --bg-code: #e7f1f9;
    --bg-overlay: rgba(29, 44, 56, 0.55);

    --border-light: #d4e3f0;
    --border-medium: #c2d6e6;
    --border-table: #ccdeed;

    --text-main: #1f2c36;
    --text-regular: #2f3e49;
    --text-secondary: #4c5d6a;
    --text-muted: #738494;
    --text-placeholder: #91a0ad;

    --status-success: #5f8f7a;
    --status-ready: #4f7d6a;
    --status-info: #6b8da4;
    --status-error: #b45d5a;
}

* {
    scrollbar-width: thin;          /* 滚动条宽度：auto, thin, none */
    scrollbar-color: var(--primary-color) #f1f1f1;  /* 滑块颜色  轨道颜色 */
}
/* ========== 新对话 landing 状态 ========== */
body.landing .chat-messages {
    display: none;
}

body.landing .chat-container {
    position: relative;
    height: 100%;
}

body.landing .chat-input-area {
    position: absolute;
    top: 60%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(760px, 92%);
    border-radius: 14px;
    height: 16vh;
}

/* 去掉输入框上方的渐变遮罩（landing 不需要） */
body.landing .chat-input-area::before {
    display: none;
}

/* 可选：隐藏滚动按钮 */
body.landing .scroll-buttons {
    display: none;
}

/* ==============================
   样式正文
   ============================== */

.top-navbar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-light);
    z-index: 1000;
    padding: 0 15px;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.nav-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 6px;
    transition: background-color 0.3s;
}

.nav-toggle:hover {
    background: var(--bg-hover);
}

.nav-toggle svg {
    width: 20px;
    height: 20px;
}

.status-indicator-mobile {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-hover);
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
}

.status-indicator-mobile .status-dot {
    width: 8px;
    height: 8px;
    background: var(--status-success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

/* 修改整体布局为左右分栏 */
.container {
    width: 100%;
    background: var(--page-background);
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    display: flex;
    height: 100vh;
    margin-top: 0;
}

/* 左侧面板样式 */
.new-botton {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 10px;
}

.new-chat {
    padding: 10px 15px;
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
    position: relative;
    min-width: 0;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.new-chat:hover {
    background: var(--bg-hover);
}

.left-panel {
    width: 300px;
    background: var(--bg-main);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.panel-header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: var(--bg-white);
    padding: 20px;
    text-align: center;
    position: relative;
}

.panel-header h1 {
    font-size: 1.5rem;
    margin-bottom: 5px;
    font-weight: 600;
}

.panel-header p {
    opacity: 0.9;
    font-size: 0.9rem;
    margin-bottom: 15px;
}

.panel-middle {
    padding: 16px 20px;
    color: var(--text-regular);
}

/* ============================
   Left panel header redesign
   ============================ */
.panel-header .panel-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.panel-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--bg-main);
    letter-spacing: 0.5px;
}

/* kebab */
.panel-menu {
    position: relative;
}

.panel-menu-btn{
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  flex-direction: column;      /* 竖向三点 */
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: 8px;
}

.panel-menu-btn span{
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text-placeholder);
}

/* hover 才出现背景 */
.panel-menu-btn:hover{
  background: var(--bg-hover);
}

/* 可选：按下态 */
.panel-menu-btn.active{
  background: var(--bg-hover);
}

/* dropdown */
.panel-menu-dropdown {
    position: absolute;
    right: 0;
    top: 40px;
    min-width: 200px;
    padding: 8px;
    border-radius: 12px;
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    box-shadow: 0 10px 30px rgba(var(--primary-rgb), 0.15); /* 使用主题色的柔和阴影 */
    z-index: 2000;
}

.panel-menu-divider {
    height: 1px;
    background: var(--border-light);
    margin: 6px 10px;
}

.panel-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 10px;
    border-radius: 10px;
    color: var(--text-regular);
}

.panel-menu-link {
    text-decoration: none;
    color: var(--text-regular);
    transition: background 0.2s;
}

.panel-menu-link:hover {
    background: var(--bg-hover);
    color: var(--primary-color);
}

/* 让 dropdown 内的 status-indicator 更紧凑 */
.panel-menu-dropdown .status-indicator {
    width: 100%;
    justify-content: flex-start;
    background: var(--bg-main);
}

/* ============================
   Image/File library buttons
   ============================ */
.library-links-vertical {
    display: flex;
    flex-direction: column;
    margin-bottom: 10px;
}

.library-btn-vertical {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: 12px;
    border: 1px solid var(--bg-main);
    background: var(--bg-main);
    color: var(--text-secondary);
    padding: 10px 0px;
    cursor: pointer;
    font-size: 14px;
    text-align: left;
}

.library-btn-vertical:hover{
    background: var(--bg-hover);
}

.library-ico {
    flex: 0 0 auto;
    opacity: 0.9;
}

/* 文案稍微更稳重 */
.library-btn-vertical span {
    font-weight: 500;
    letter-spacing: 0.2px;
}

/* ============================
   Library modal (like img viewer)
   ============================ */
#library-overlay {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: none;
}

#library-overlay .library-backdrop {
    position: absolute;
    inset: 0;
    background: var(--bg-overlay); /* 暖深色遮罩 */
}

#library-overlay .library-panel {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(92vw, 1100px);
    max-height: 88vh;
    background: var(--bg-main); /* 奶油底色 */
    border: 1px solid var(--border-medium);
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#library-overlay .library-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-white);
}

#library-overlay .library-title {
    color: var(--text-main);
    font-weight: 700;
    font-size: 15px;
}

#library-overlay .library-close {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid var(--border-light);
    background: var(--bg-main);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 18px;
    line-height: 28px;
    transition: all 0.2s;
}

#library-overlay .library-close:hover {
    background: var(--status-error);
    color: #fff;
    border-color: var(--status-error);
}

#library-overlay .library-body {
    padding: 12px;
    overflow: auto;
}

/* grid for images */
.library-img-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 12px;
}

.library-img-card {
    border: 1px solid var(--border-light);
    background: var(--bg-white);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.2s;
}

.library-img-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-medium);
}

.library-img-thumb {
    width: 100%;
    height: 140px;
    object-fit: cover;
    display: block;
    cursor: zoom-in;
    border-bottom: 1px solid var(--border-light);
}

.library-card-meta {
    padding: 10px;
    color: var(--text-secondary);
    font-size: 12px;
    min-width: 0;
}

.library-card-name {
    opacity: .9;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.library-card-size {
    opacity: .7;
    margin-top: 3px;
}

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

.library-action {
    flex: 1;
    border-radius: 10px;
    border: 1px solid var(--border-medium);
    background: var(--bg-main);
    color: var(--text-regular);
    padding: 8px 8px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.library-action:hover {
    background: var(--bg-hover);
    border-color: var(--primary-color);
}

.library-action.danger {
    border-color: var(--status-error);
    background: var(--bg-white);
    color: var(--status-error);
}

.library-action.danger:hover {
    background: var(--status-error);
    color: #fff;
}

/* files list */
.library-file-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.library-file-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--border-light);
    background: var(--bg-white);
}

.library-file-thumb, .library-file-ext {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    border-radius: 8px;
    border: 1px solid var(--border-light);
    background: var(--bg-main);
}

.library-file-thumb { object-fit: cover; }
.library-file-ext {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    font-size: 10px;
    font-weight: 700;
    overflow: hidden;
    padding: 2px;
    box-sizing: border-box;
}

.library-file-previewable { cursor: zoom-in; }
.library-file-info.library-file-previewable:focus-visible {
    outline: 2px solid var(--primary-color);
    border-radius: 4px;
}

.library-file-info {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.library-file-name {
    color: var(--text-main);
    font-weight: 650;
    font-size: 13px;
    word-break: break-word;
}

.library-file-sub {
    color: var(--text-muted);
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.library-file-actions {
    display: flex;
    gap: 8px;
    flex: 0 0 auto;
}

.library-text-overlay {
    position: fixed;
    inset: 0;
    z-index: 5100;
}
.library-text-backdrop {
    position: absolute;
    inset: 0;
    background: var(--bg-overlay);
}
.library-text-panel {
    position: absolute;
    inset: 6vh 5vw;
    max-width: 1000px;
    margin: auto;
    display: flex;
    flex-direction: column;
    background: var(--bg-white);
    border-radius: 12px;
    overflow: hidden;
}
.library-text-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
}
.library-text-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.library-text-head button { cursor: pointer; font-size: 22px; border: 0; background: none; color: var(--text-main); }
.library-text-content {
    flex: 1;
    overflow: auto;
    margin: 0;
    padding: 16px;
    color: var(--text-main);
    background: var(--bg-code);
    font-size: 13px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
/* ============================
   Library: search + groups
   ============================ */
.library-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-white); /* 顶部工具栏稍微提亮 */
}

.library-search {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border-medium);
  background: var(--bg-code); /* 搜索框使用羊皮纸偏色，增加输入感 */
  transition: border-color 0.2s;
}

.library-search:focus-within {
  border-color: var(--primary-color);
}

.library-search input {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-main);
  font-size: 13px;
}

.library-search input::placeholder {
  color: var(--text-placeholder);
}

.library-clear-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 0 6px;
  transition: color 0.2s;
}

.library-clear-btn:hover {
  color: var(--status-error); /* 清除按钮悬停时呈现警告感 */
}

.library-groups {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg-main);
}

.library-group {
  border: 1px solid var(--border-light);
  background: var(--bg-white);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.05);
}

.library-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  cursor: pointer;
  user-select: none;
  background: var(--bg-hover); /* 头部背景稍微加深 */
  border-bottom: 1px solid var(--border-light);
  transition: background 0.2s;
}

.library-group-head:hover {
  background: var(--border-light);
}

.library-group-title {
  color: var(--text-main);
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.library-group-badge {
  font-size: 11px;
  font-weight: 500;
  color: var(--primary-color);
  background: var(--bg-white);
  border: 1px solid var(--border-medium);
  padding: 2px 8px;
  border-radius: 999px;
}

.library-group-arrow {
  color: var(--text-muted);
  font-size: 14px;
  transition: transform .18s ease;
}

.library-group.collapsed .library-group-arrow {
  transform: rotate(-90deg);
}

.library-group-body {
  padding: 12px;
  background: var(--bg-white);
}

.library-group.collapsed .library-group-body {
  display: none;
}

.library-empty-hint {
  padding: 12px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  font-style: italic;
}

/* 历史记录区域 */
.panel-content {
    flex: 1;
    padding: 0 20px 20px 20px;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    height: 100%;
}

.panel-content::-webkit-scrollbar {
    display: none;
}

.panel-content {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.history-section {
    position: relative;
}

.history-top-title {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* 历史记录滚动按钮 */
.history-scroll-btn {
    position: fixed;
    left: 130px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-white);
    color: var(--text-regular);
    border: 1px solid var(--border-medium);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.history-scroll-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.history-scroll-top {
    top: 300px;
}

.history-scroll-bottom {
    bottom: 30px;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-date-group {
    margin-bottom: 5px;
}

.history-date-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 8px;
    padding: 0 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.history-date-group:last-child {
    margin-bottom: 0;
}

.history-item {
    padding: 8px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
    position: relative;
    min-width: 0;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 1px;
}

.history-item:hover {
    background: var(--bg-hover);
}

.history-item .delete-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0;
    transition: opacity 0.2s;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 2px;
}

.history-item:hover .delete-btn {
    opacity: 1;
}

.active-chat {
    color: var(--text-secondary);
    background: var(--border-light) !important;;
    font-size: 0.9rem;
}

/* 右侧面板样式 */
.right-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
    position: relative;
}

/* 聊天容器 */
.chat-container {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

/* 消息区域 */
.chat-messages {
    flex-grow: 1;
    overflow-y: hidden;
    padding: 20px;
    gap: 30px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* 输入区域 */
.chat-input-area {
    padding: 15px 15px;
    background: var(--bg-white);
    position: sticky;
    bottom: 0;
    z-index: 100;
}

.chat-input-area::before {
    content: "";
    position: absolute;
    top: -30px;
    left: 0;
    right: 0;
    height: 30px;
    pointer-events: none;
    background: linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0),
        var(--bg-white)
    );
}

.input-container {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
}

.send-button {
    background: var(--primary-color);
    color: var(--bg-white);
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s, transform 0.2s;
}

.send-button:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.send-button:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
    transform: none;
    color: #e1e1e1;
}

.send-button.stopping {
    background: var(--primary-color);
    cursor: pointer;
    color: var(--bg-white);
    position: relative;
}

.send-button.stopping:hover {
    background: var(--primary-hover);
}

.send-button.stopping svg {
    display: none;
}

.send-button.stopping::before {
    content: "";
    position: absolute;
    inset: 7px;
    border: 2px solid rgba(255, 255, 255, 0.22);
    border-top-color: rgba(255, 255, 255, 0.65);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.send-button.stopping::after {
    content: "";
    width: 17px;
    height: 17px;
    background: currentColor;
    border-radius: 3px;
}

@media (prefers-reduced-motion: reduce) {
    .send-button.stopping::before {
        animation: none;
    }
}

/* 定义旋转关键帧 */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 当按钮处于 loading 状态时，隐藏内部的 SVG 图标 */
.send-button.loading svg {
    display: none;
}

/* 利用伪元素制作加载圈 */
.send-button.loading::after {
    content: "";
    width: 18px; 
    height: 18px;
    border: 2px solid currentColor; /* 跟随字体颜色 */
    border-top-color: transparent;  /* 形成缺口 */
    border-radius: 50%;
    display: inline-block;
    animation: spin 0.8s linear infinite; /* 应用旋转动画 */
    vertical-align: middle;
}

.chat-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.left-controls {
    display: flex;
    align-items: center;
    gap: 3px;
}

.right-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.model-selector {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.model-selector label {
    font-weight: 500;
}
.model-select {
    padding: 4px 8px;
    border: 1px solid var(--border-medium);
    border-radius: 6px;
    background: var(--bg-white);
    color: var(--text-main);
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
    transition: all 0.3s;
}

.model-select:hover {
    border-color: var(--primary-color);
}

.model-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.1);
}

.clear-button {
    background: none;
    border: 1px solid var(--border-medium);
    color: var(--text-secondary);
    padding: 5px 15px;
    border-radius: 15px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.3s;
}

.clear-button:hover {
    background: var(--bg-hover);
    color: #475569;
}

.chat-text {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.message {
    display: flex;
    max-width: 80%;
    animation: fadeIn 0.3s ease;
}

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

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

.assistant-message {
    align-self: flex-start;
}

.message-content {
    padding: 12px 18px;
    border-radius: 18px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    position: relative;
}

/* 打字机效果光标 */
.typing-cursor::after {
    content: "|";
    animation: blink 1s infinite;
    opacity: 1;
}

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

/* 流式消息优化 */
.markdown-content pre {
    overflow-x: auto;
    background: #f5f5f5; /* 保持原样或使用 --bg-code，这里硬编码可能是为了特定高亮库 */
    padding: 1em;
    border-radius: 5px;
    word-break: break-word;
}

.markdown-content code {
    background: #f5f5f5;
    padding: 2px 4px;
    border-radius: 3px;
}

.user-message .message-content {
    background: var(--primary-color);
    color: var(--bg-white);
    border-bottom-right-radius: 4px;
    min-width: 140px;
}

.assistant-message .message-content {
    background: var(--bg-hover);
    color: var(--text-main);
    border-bottom-left-radius: 4px;
    min-width: 68px;
}

.assistant-message .message-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;      /* 增加一点顶部间距，让按钮和正文分开一点 */
    padding-top: 4px;     /* 可选：增加一点内边距 */
    justify-content: flex-start;
    opacity: 1;           /* 强制不透明 */
    visibility: visible;  /* 强制可见 */
}

.message-text {
    margin-bottom: 10px;
    line-height: 1.5;
    word-break: break-word;
}

.message-time {
    font-size: 0.7rem;
    opacity: 0.7;
    text-align: right;
}

/* 消息操作按钮 - 绝对定位不占空间 */
.message-content {
    position: relative;
}

.message-actions {
    position: absolute;
    bottom: 8px;
    left: 8px;
    display: flex;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.2s;
}

.message:hover .message-actions {
    opacity: 1;
}

.message-action-btn {
    background: rgba(255, 255, 255, 0);
    border: 0px solid rgba(0, 0, 0, 0.15);
    color: #bbb;
    padding: 4px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
}

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

.message-action-btn:hover {
    background: var(--bg-white);
    border-color: var(--primary-color);
    color: var(--primary-color);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
}

.user-message .message-action-btn {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.4);
    color: var(--bg-white);
}

.user-message .message-action-btn:hover {
    background: rgba(255, 255, 255, 0.35);
    border-color: var(--bg-white);
    color: var(--bg-white);
}

.user-message .message-action-btn svg {
    stroke: var(--bg-white);
}

/* 编辑模式样式 */
.message-edit-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.message-edit-textarea {
    width: 100%;
    min-height: 60px;
    padding: 10px;
    border: 1px solid var(--border-medium);
    border-radius: 8px;
    resize: vertical;
    font-size: 0.95rem;
    font-family: inherit;
    line-height: 1.5;
    outline: none;
}

.message-edit-textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.1);
}

.message-edit-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.message-edit-btn {
    padding: 6px 14px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.message-edit-confirm {
    background: var(--primary-color);
    color: var(--bg-white);
}

.message-edit-confirm:hover {
    background: var(--primary-hover);
}

.message-edit-cancel {
    background: var(--border-light);
    color: var(--text-secondary);
}

.message-edit-cancel:hover {
    background: var(--border-medium);
}

#message-input {
    flex: 1;
    padding: 12px 15px 0px 15px;
    border: 1px solid var(--border-medium);
    border-radius: 24px;
    outline: none;
    font-size: 1rem;
    transition: border-color 0.3s;
    resize: none;
    min-height: 20px;
    max-height: 120px;
    line-height: 1.5;
    font-family: inherit;
}

#message-input:focus {
    border-color: var(--primary-color);
}

/* 状态指示器 */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.2);
    padding: 5px 10px;
    border-radius: 20px;
    justify-content: center;
}

.status-dot {
    width: 10px;
    height: 10px;
    background: var(--status-success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

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

.status-text {
    font-size: 0.8rem;
}

/* 打字动画关键帧 */
@keyframes typing-bounce {
  0%, 80%, 100% { 
    transform: translateY(0);
  }
  40% {
    transform: translateY(-6px);
  }
}

/* 打字指示器样式 */
.typing-indicator {
  display: flex;
  padding: 8px 0;
}

.typing-indicator span {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin: 0 2px;
  background: var(--text-regular);
  border-radius: 50%;
  animation: typing-bounce 1.4s infinite ease-in-out;
}

/* 调整动画延迟实现交替效果 */
.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

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

/* 添加Markdown内容样式 */
.message-text.markdown-content {
    padding: 10px 0;
    line-height: 1.6;
}

.message-text.markdown-content h1,
.message-text.markdown-content h2,
.message-text.markdown-content h3,
.message-text.markdown-content h4,
.message-text.markdown-content h5,
.message-text.markdown-content h6 {
    margin: 1.2em 0 0.6em 0;
    font-weight: 600;
    line-height: 1.25;
}

.message-text.markdown-content h1 {
    font-size: 1.5em;
    border-bottom: 1px solid #eaecef;
    padding-bottom: 0.3em;
}

.message-text.markdown-content h2 {
    font-size: 1.3em;
    border-bottom: 1px solid #eaecef;
    padding-bottom: 0.3em;
}

.message-text.markdown-content h3 {
    font-size: 1.1em;
}

.message-text.markdown-content p {
    margin: 0.8em 0;
}

.message-text.markdown-content ul,
.message-text.markdown-content ol {
    padding-left: 1.5em;
    margin: 0.8em 0;
}

.message-text.markdown-content li {
    margin: 0.3em 0;
}

.message-text.markdown-content blockquote {
    margin: 0.8em 0;
    padding: 0.5em 1em;
    background-color: #f8f9fa;
    border-left: 4px solid var(--border-table);
    color: #6a737d;
}

.message-text.markdown-content code {
    background-color: rgba(175, 184, 193, 0.2);
    border-radius: 3px;
    padding: 0.2em 0.4em;
    font-size: 0.9em;
    font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', 'Menlo', monospace;
}

/* 代码块溢出处理 */
.message-text.markdown-content pre {
    background-color: var(--bg-code);
    border-radius: 6px;
    padding: 1em;
    overflow-x: auto;
    margin: 1em 0;
    line-height: 1.45;
    position: relative;
    white-space: pre-wrap;
}

.message-text.markdown-content pre code {
    background: none;
    padding: 0;
    font-size: 0.9em;
    overflow-x: auto;
    display: block;
    border-radius: 6px;
}

/* 复制按钮样式 */
.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #d1d5da;
    border-radius: 8px;
    padding: 4px 6px;
    font-size: 0.75rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    color: var(--text-regular);
}

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

.copy-btn:hover {
    background: var(--bg-white);
}

.copy-btn.copied {
    background: var(--primary-color);
    color: var(--bg-white);
    border-color: var(--primary-color);
}

.message-text.markdown-content table {
    border-collapse: collapse;
    margin: 1em 0;
    width: 100%;
}

.message-text.markdown-content table th,
.message-text.markdown-content table td {
    border: 1px solid var(--border-table);
    padding: 0.5em 1em;
    text-align: left;
}

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

.message-text.markdown-content hr {
    border: none;
    border-top: 1px solid #eaecef;
    margin: 1.5em 0;
}

/* 代码高亮样式增强 */
.hljs {
    background: var(--bg-code) !important;
    border-radius: 6px;
}

.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-overlay);
    z-index: 999;
}

.mobile-overlay.active {
    display: block;
}

/* 滚动按钮 */
.scroll-buttons {
    position: fixed;
    right: 25px;
    bottom: 200px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 100;
}

.question-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.question-nav-btn {
    width: 28px;
    height: 28px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--bg-white);
    color: var(--text-regular);
    border: 1px solid #bfbfbf;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    line-height: 1;
    transition: all 0.2s ease;
    white-space: nowrap;
    position: relative;
}

.question-nav-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-1px);
}

.question-nav-btn.active {
    background: var(--bg-hover);
    border-color: var(--primary-active);
    color: var(--primary-active);
}

.question-nav-tip {
    position: absolute;
    right: 100%;
    top: 50%;
    transform: translate(-8px, -50%);
    background: var(--bg-white);
    color: var(--text-regular);
    border: 1px solid var(--border-medium);
    border-radius: 8px;
    padding: 6px 8px;
    font-size: 12px;
    line-height: 1.2;
    white-space: nowrap;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 2;
}

.question-nav-btn:hover .question-nav-tip {
    opacity: 1;
    transform: translate(-10px, -50%);
}

.scroll-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    border-color: var(--border-light);
    color: var(--text-muted);
}

.scroll-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--bg-white);
    color: var(--text-regular);
    border: 1px solid #bfbfbf; 
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.scroll-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}
/* 搜索按钮 */
.search-toggle.icon-only {
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 8px;
    margin-left: 5px;
}
.search-toggle.icon-only:hover {
    background: rgba(0, 0, 0, 0.05);
}
.search-toggle.icon-only.active {
    background: rgba(0, 0, 0, 0.05);
}
.search-toggle.icon-only svg{
    color: var(--text-placeholder);
}
.search-toggle.icon-only:hover svg{
    color: var(--primary-active);
    opacity: 0.8;
}
.search-toggle.icon-only.active svg{
    color: var(--primary-active);
}

/* 上传文件 */
/* 输入框右侧的小图标按钮（回形针） */
.icon-btn {
    border: none;
    background: transparent;
    border-radius: 8px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.icon-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.icon-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.icon-btn svg{
    color: var(--text-placeholder);
}
.icon-btn:hover svg{
    color: var(--primary-active);
    opacity: 0.8;
}

/* 文件 chips 容器 */
.file-chip-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* 单个 chip */
.file-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 14px;
    border: 1px solid rgba(0, 0, 0, 0.10);
    background: rgba(0, 0, 0, 0.03);
    font-size: 13px;
}

.file-chip .meta {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    min-width: 0;
}

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

.file-chip .status {
    opacity: 0.75;
    font-size: 12px;
}

.file-chip .chip-action {
    width: 26px;
    height: 26px;
    border: none;
    background: transparent;
    border-radius: 10px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.file-chip .chip-action:hover {
    background: rgba(0, 0, 0, 0.06);
}

/* 摘要行：一行显示，几乎不占空间 */
.file-chip-summary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    /* 图标和文字间距 */
    margin-bottom: 6px;
    font-size: 13px;
    opacity: .85;
    padding: 0 10px;
}

/* 展开/收起按钮：图标风格 */
.chip-toggle-btn {
    width: 30px;
    height: 30px;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 2px 4px;
    font-size: 30px;
    line-height: 1;
    border-radius: 6px;
    opacity: .75;
}

.chip-toggle-btn:hover {
    background: rgba(0, 0, 0, .06);
    opacity: 1;
}

/* 展开后的 chips：固定高度，不再无限顶高输入框 */
.file-chip-bar {
    max-height: 120px;
    /* 你可以改成 96/140 等 */
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 10px;
    /* 给滚动条留点空间 */
    margin-bottom: 6px;
}

/* 上传文件状态 */
.status-ready {
    color: var(--status-ready); /* 绿色 */
}

.status-uploading {
    color: var(--status-info); /* 蓝色 */
    animation: pulse 1.5s infinite; /* 可选：呼吸动画 */
}

.status-failed {
    color: var(--status-error); /* 红色 */
}

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

.file-thumb {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 4px;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    font-size: 10px;
    font-weight: 700;
    color: var(--text-secondary);
    border: 0;
    padding: 0 2px;
    box-sizing: border-box;
}

.file-preview-trigger { cursor: zoom-in; }
.file-preview-trigger:hover { outline: 2px solid var(--border-medium); }
.file-preview-trigger:focus-visible { outline: 2px solid var(--primary-color); }

.file-upload-progress {
    width: 100%;
    height: 5px;
    accent-color: var(--status-info);
}

.file-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ==============================
   Model dropdown (logo + name)
   ============================== */

.model-dropdown {
    position: relative;
    display: inline-block;
}

.model-dropdown-btn {
    display: inline-flex;
    justify-content: space-between;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border: 1px solid var(--border-medium);
    border-radius: 6px;
    background: var(--bg-main);
    color: var(--text-main);
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
    transition: all 0.2s;
    max-width: 240px;        /* 固定最大宽度（可按需调整：160px/180px/220px） */
    min-width: 160px;        /* 最小宽度，防止太窄 */
}
/* ✅ 新增：控制内部文字容器的溢出 */
.model-dropdown-btn .model-item {
    min-width: 0;            /* 关键：允许 flex 子元素缩小 */
    overflow: hidden;
}

.model-dropdown-btn .model-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.model-dropdown-btn:hover {
    border-color: var(--primary-color);
}

.model-dropdown-btn:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.1);
}

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

.model-logo-wrap {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    overflow: hidden;
}

.model-logo {
    width: 18px;
    height: 18px;
    object-fit: contain;
    display: block;
}

.model-logo-emoji {
    font-size: 16px;
    line-height: 1;
}

.model-caret {
    opacity: 0.75;
}
.model-dropdown.open .model-caret {
    transform: rotate(180deg);
}
.model-dropdown-menu {
    position: absolute;
    left: 0;
    bottom: calc(100% + 6px);
    min-width: 220px;
    /* max-height: min(400px, calc(100vh - 120px)); */
    overflow: auto;
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.12);
    z-index: 2000;
    display: none;
    padding: 6px;
}

.model-dropdown.open .model-dropdown-menu {
    display: block;
}

.model-dropdown-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-main);
    user-select: none;
}

.model-dropdown-option:hover {
    background: var(--bg-hover);
}

.model-dropdown-option .provider {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-muted);
}

.model-dropdown-btn.disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

/* 回复气泡里的“模型标识条”（logo + name） */
.model-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    line-height: 1;
    padding: 6px 10px;
    border-radius: 999px;
    margin: 8px 0 2px 0;
    opacity: .9;
    border: 1px solid rgba(0,0,0,0.08);
    background: rgba(255,255,255,0.55);
    width: fit-content;
    user-select: none;
}

.assistant-message .model-badge {
    background: rgba(255,255,255,0.35);
}

/* ==============================
   model-badge 思考中：跑道流光（不占位方案）
   ============================== */
.model-badge {
    position: relative;
    border-radius: 999px;
    z-index: 0;
    /* 这里的 padding 你按原来的写，不受影响 */
}

.model-badge.thinking::before {
    content: "";
    position: absolute;
    /* 关键：通过负值 inset 向外扩展出边框空间，不占用内部 padding */
    inset: -2px; 
    border-radius: 999px;
    
    /* 1. 背景：使用重复渐变，确保无论多长都能填满 */
    background: linear-gradient(
        90deg, 
        #ff2d55, #ffcc00, #34c759, #00c7ff, #5e5ce6, #ff2d55
    );
    background-size: 200% 100%; /* 拉长背景，使流动更自然 */

    /* 2. 遮罩：体育场跑道的核心逻辑 */
    /* 这里的 3px 必须和上面的 inset 负值一致 */
    -webkit-mask: 
        linear-gradient(#000 0 0) content-box, 
        linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    
    /* 粗细控制：通过设置 padding 来决定 mask 留下的边框宽度 */
    padding: 2px; 
    pointer-events: none;
    z-index: -1;

    animation: badge-run 1.8s linear infinite;
}

@keyframes badge-run {
    0% { background-position: 0% 50%; }
    100% { background-position: 200% 50%; }
}

/* ==============================
   三个点 · 呼吸动画（无文字）
   ============================== */
.typing-dots {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    justify-content: center;
    height: 1em;
    margin: 30px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-secondary);
    opacity: 0.35;
    animation: dot-breathe 1.4s ease-in-out infinite;
}

/* 三个点错峰呼吸 */
.typing-dots span:nth-child(1) { animation-delay: 0s; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dot-breathe {
    0%   { opacity: 0.35; transform: scale(0.9); }
    50%  { opacity: 1;    transform: scale(1.15); }
    100% { opacity: 0.35; transform: scale(0.9); }
}

/* 生图模式按钮激活态 */
#image-toggle.active {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: var(--bg-hover);
}

/* 原图查看器 */
#img-viewer-overlay {
    position: fixed;
    inset: 0;
    z-index: 5000;
}

#img-viewer-overlay .img-viewer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.85);
}

#img-viewer-overlay .img-viewer-panel {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    max-width: min(92vw, 1200px);
    max-height: 88vh;
    background: #000;
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}

#img-viewer-overlay .img-viewer-img {
    display: block;
    max-width: 100%;
    max-height: calc(88vh - 20px);
    margin: 0 auto;
    border-radius: 10px;
}

#img-viewer-overlay .img-viewer-close {
    position: absolute;
    right: 10px;
    top: 6px;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 22px;
    line-height: 34px;
    background: rgba(255,255,255,0.15);
    color: #fff;
}

body.img-viewer-open {
    overflow: hidden;
}

/* ============================
   🎤 Voice input button
   ============================ */
.voice-btn {
    position: relative;
}

.voice-btn.active {
    background: rgba(0, 0, 0, 0.06);
}

.voice-btn.active svg {
    color: var(--primary-color);
}

.voice-btn.recording::after {
    content: "";
    position: absolute;
    right: 6px;
    top: 6px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ff3b30;
    box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.6);
    animation: voicePulse 1.2s infinite;
}

@keyframes voicePulse {
    0%   { box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.6); }
    70%  { box-shadow: 0 0 0 10px rgba(255, 59, 48, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 59, 48, 0); }
}


/* 图片模式：生图参考图状态 */
.status-ref { color: var(--status-info); font-weight: 600; }

/* ===== Image Compare ===== */
#img-compare-overlay{
  position:fixed;inset:0;background:rgba(0,0,0,.6);
  display:flex;align-items:center;justify-content:center;z-index:9999;
}
.img-compare-box{position:relative;width:80%;max-width:900px}
.img-compare-images img{position:absolute;top:0;left:0;width:100%}
.img-compare-slider{width:100%;position:relative;z-index:2}
.img-compare-close{
  position:absolute;top:-40px;right:0;font-size:30px;color:#fff;background:none;border:none;cursor:pointer
}


/* ===== 生图：提示词展示（气泡内） ===== */
.image-prompt{
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--text-regular);
  padding: 10px 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ===== 生图：点击文字切换 原图/生成图 ===== */
.image-toggle-wrap{
  display:flex;
  flex-direction:column;
  gap:10px;
  margin: 20px 0;
}

.image-toggle-tabs {
  display:inline-flex;
  gap:0;
  align-items:center;
  background: var(--bg-main);
  border: 1px solid var(--border-light);
  border-radius: 999px;
  padding: 4px;
  width: fit-content;
}

.image-toggle-tab{
  background: transparent;
  border: none;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-regular);
  opacity: .75;
  padding: 6px 12px;
  border-radius: 999px;
  transition: background-color .15s ease, opacity .15s ease, transform .15s ease;
}

.image-toggle-tab:hover{opacity: 1;}

.image-toggle-tab.active{
  opacity: 1;
  color: var(--text-main);
  background: var(--bg-white);
  box-shadow: 0 6px 16px rgba(0,0,0,.08);
}

.image-toggle-img{
  max-width:100%;
  border-radius: 14px;
  border: 1px solid var(--border-light);
  background: var(--bg-main);
  box-shadow: 0 10px 28px rgba(0,0,0,.10);
  object-fit: contain;
}

.image-generation-placeholder {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: min(340px, 78vw);
  aspect-ratio: 4 / 3;
  margin: 18px 0;
  overflow: hidden;
  border: 1px solid var(--border-light);
  border-radius: 14px;
  background: var(--bg-main);
  color: var(--text-secondary);
  font-size: 14px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .06);
}

.image-generation-placeholder::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(110deg, transparent 25%, rgba(var(--primary-rgb), .12) 50%, transparent 75%);
  transform: translateX(-100%);
  animation: image-generation-sweep 2.4s ease-in-out infinite;
}

.image-generation-placeholder svg {
  position: relative;
  width: 64px;
  height: 64px;
  color: var(--primary-color);
  opacity: .7;
}

.image-generation-point {
  animation: image-generation-point 1.5s ease-in-out infinite alternate;
}

@keyframes image-generation-point {
  from { transform: translateX(-5px); }
  to { transform: translateX(5px); }
}

@keyframes image-generation-sweep {
  to { transform: translateX(100%); }
}

@media (prefers-reduced-motion: reduce) {
  .image-generation-placeholder::before,
  .image-generation-point { animation: none; }
}

.image-compare {
    display: flex;
    gap: 12px;
    margin-top: 10px;
    align-items: stretch;
}

.image-compare-cell {
    flex: 1;
    min-width: 220px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.image-compare-label {
    font-size: 12px;
    color: var(--text-secondary);
    padding: 0 2px;
}

.image-compare-img {
    width: 100%;
    border-radius: 10px;
    border: 1px solid var(--border-light);
}

.generated-image-wrap {
  /* 对齐 .image-toggle-wrap 的卡片感 */
  border: 1px solid rgba(0,0,0,0.08);
  background: rgba(255,255,255,0.9);
  border-radius: 14px;
  padding: 10px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.06);
  overflow: hidden;
}

/* 普通模式每个 section 之间更紧凑、统一间距 */
.generated-image-wrap .image-section {
  margin-top: 10px;
}
.generated-image-wrap .image-section:first-child {
  margin-top: 0;
}

/* 2) 标题：让“原图/生成图”标题看起来像 toggle 的 tabs/标签 */
.generated-image-wrap .image-section-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: rgba(0,0,0,0.72);

  /* 做成“胶囊标签”风格，接近 toggle tab 视觉 */
  background: rgba(0,0,0,0.04);
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 999px;
  padding: 6px 10px;
  margin: 2px 0 10px 0;
}

/* 3) 网格：对齐卡片内排布，间距/对齐更像 toggle 模式 */
.generated-image-wrap .image-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* 4) 缩略图：统一成“卡片内图片”的风格（圆角、描边、阴影、hover） */
.generated-image-wrap .image-thumb {
  width: 100%;
  height: auto;
  display: block;

  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.08);
  box-shadow: 0 6px 16px rgba(0,0,0,0.06);

  background: rgba(0,0,0,0.02);
  object-fit: cover;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.generated-image-wrap .image-thumb:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(0,0,0,0.10);
}

/* 5) 提示词：对齐对比模式卡片内的 caption 位置与质感 */
.generated-image-wrap .image-prompt {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.06);
  background: rgba(0,0,0,0.03);
  color: rgba(0,0,0,0.70);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

/* ==============================
   引用模式 Badge（点击切换）
   ============================== */
.context-mode-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--border-medium);
    background: var(--bg-main);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 0 4px 0 6px;
}

.context-mode-badge:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: var(--bg-hover);
}

.context-mode-badge.active {
    background: (var(--bg-white));
    color: var(--primary-color);
}

.context-mode-badge .badge-text {
    line-height: 1;
}

/* ==============================
   Admin Settings
   ============================== */
.admin-page {
    max-width: 1100px;
    margin: 40px auto 80px;
    padding: 0 24px;
    color: var(--text-main);
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.admin-title-text {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

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

.admin-actions .admin-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border: 1px solid var(--border-medium);
    border-radius: 10px;
    color: var(--text-main);
    text-decoration: none;
    background: var(--bg-white);
    transition: all 0.2s ease;
}

.admin-actions .admin-link:hover {
    background: var(--bg-hover);
}

.admin-section {
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 8px 24px rgba(139, 122, 102, 0.08);
}

.admin-section-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 14px;
}

.admin-section-hint {
    margin-bottom: 14px;
    font-size: 13px;
    color: var(--text-secondary);
}

.admin-model-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 14px;
}

.admin-model-row {
    display: grid;
    grid-template-columns: 52px minmax(0, 1.2fr) minmax(0, 1.2fr) minmax(90px, 120px) minmax(110px, 140px) auto auto auto auto;
    gap: 10px;
    align-items: center;
    padding: 12px;
    border-radius: 12px;
    background: var(--bg-main);
    border: 1px solid var(--border-light);
}

.admin-row-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.admin-row-actions .admin-btn {
    padding-inline: 10px;
}

.admin-grid {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 12px;
    align-items: center;
}

.admin-label {
    font-size: 14px;
    color: var(--text-secondary);
}

.admin-input,
.admin-select {
    padding: 10px 12px;
    border: 1px solid var(--border-medium);
    border-radius: 10px;
    background: var(--bg-white);
    color: var(--text-main);
    font-size: 14px;
    min-width: 0;
}

.admin-textarea {
    min-height: 120px;
    resize: vertical;
    line-height: 1.5;
}

.admin-input[readonly] {
    background: var(--bg-hover);
    color: var(--text-secondary);
}

.admin-logo-slot {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
}

.admin-logo-preview {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.admin-logo-select {
    position: relative;
    min-width: 0;
}

.admin-logo-trigger {
    width: 100%;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid var(--border-medium);
    background: var(--bg-white);
    color: var(--text-main);
    cursor: pointer;
}

.admin-logo-trigger .admin-logo-thumb {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.admin-logo-trigger .admin-logo-name {
    flex: 1;
    text-align: left;
    font-size: 13px;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-logo-caret {
    font-size: 12px;
    color: var(--text-muted);
}

.admin-logo-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    max-height: 220px;
    overflow-y: auto;
    border-radius: 12px;
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    box-shadow: 0 12px 24px rgba(35, 25, 16, 0.15);
    z-index: 5;
}

.admin-logo-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    width: 100%;
    border: none;
    background: transparent;
    cursor: pointer;
    text-align: left;
}

.admin-logo-option:hover {
    background: var(--bg-hover);
}

.admin-logo-option .admin-logo-thumb {
    width: 22px;
    height: 22px;
    object-fit: contain;
}

.admin-logo-option .admin-logo-name {
    font-size: 13px;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-input:focus,
.admin-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}

.admin-switch {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

.admin-btn {
    padding: 8px 14px;
    border-radius: 10px;
    border: 1px solid var(--border-medium);
    background: var(--bg-white);
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s ease;
}

.admin-btn:hover {
    background: var(--bg-hover);
}

.admin-btn.primary {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}

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

.admin-btn.danger {
    border-color: var(--status-error);
    color: var(--status-error);
}

.admin-btn.danger:hover {
    background: rgba(194, 106, 90, 0.08);
}

.admin-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 20px;
}

.admin-save-bar {
    position: sticky;
    bottom: 0;
    width: min(980px, 92%);
    margin: 0 auto 16px;
    padding: 12px 18px;
    background: var(--bg-hover);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    backdrop-filter: blur(6px);
    z-index: 4;
}

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

.admin-dirty {
    display: none;
    color: var(--status-error);
    font-size: 13px;
    font-weight: 600;
}

.admin-dirty.active {
    display: inline-flex;
}

.admin-status.success {
    color: var(--status-success);
    font-weight: 600;
}

.admin-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.admin-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(41, 34, 27, 0.5);
    backdrop-filter: blur(2px);
}

body {
    background: var(--page-background);
    color: var(--text-main);
    margin: 0;
}

.admin-modal-card {
    position: relative;
    background: var(--bg-white);
    border-radius: 16px;
    padding: 20px;
    width: min(560px, 90vw);
    border: 1px solid var(--border-light);
    box-shadow: 0 20px 60px rgba(36, 24, 14, 0.2);
}

.admin-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.admin-modal-title {
    font-size: 18px;
    font-weight: 600;
}

.admin-modal-footer {
    margin-top: 16px;
    display: flex;
    justify-content: flex-end;
}

.admin-status {
    font-size: 14px;
    color: var(--text-secondary);
}

/* ==============================
   更多菜单
   ============================== */
.more-menu-wrap {
    position: relative;
    display: inline-block;
}

.more-btn.active {
    background: rgba(0, 0, 0, 0.06);
}

.more-btn.active svg {
    color: var(--text-secondary);
}

.more-menu-dropdown {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 100%;
    transform: translateX(-25%);
    min-width: 160px;
    padding: 6px;
    border-radius: 12px;
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    box-shadow: 0 10px 30px rgba(var(--primary-rgb), 0.15);
    z-index: 2000;
}

.more-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    margin: 3px 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-regular);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
    text-align: left;
}

.more-menu-item.active {
    background: rgba(var(--primary-rgb), 0.10);
    color: var(--primary-color);
}

.more-menu-item:hover {
    background: var(--bg-hover);
}

.more-menu-item.danger {
    color: var(--status-error);
}

.more-menu-item.danger:hover {
    background: rgba(194, 106, 90, 0.1);
}

.more-menu-item svg {
    flex-shrink: 0;
    opacity: 0.8;
}

.more-menu-item:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 输入框提示样式 */
::placeholder {
  opacity: 0.6;
  font-size: 0.9em;
}

/* 拖拽上传视觉反馈 */
#right-panel.drag-over {
    background: rgba(var(--primary-rgb), 0.08);
    border: 2px dashed var(--primary-color);
    border-radius: 12px;
}

#right-panel.drag-over::after {
    content: '释放以上传文件';
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 20px 40px;
    background: var(--primary-color);
    color: var(--bg-white);
    font-size: 18px;
    font-weight: 500;
    border-radius: 12px;
    pointer-events: none;
    z-index: 1000;
    box-shadow: 0 8px 32px rgba(var(--primary-rgb), 0.3);
}

@media (max-width: 999px) {
    body.landing .chat-input-area {
        top: 88%;
    }

    .top-navbar {
        display: flex;
    }

    .container {
        height: calc(100vh - 60px);
        border-radius: 0;
        flex-direction: row;
        position: relative;
        margin-top: 60px;
    }

    .mobile-close {
        display: flex;
    }

    .left-panel {
        position: fixed;
        top: 60px;
        left: 0;
        max-width: 300px;
        height: calc(100% - 60px);
        z-index: 1000;
        transform: translateX(-100%);
        border-right: none;
    }

    .left-panel.mobile-open {
        transform: translateX(0);
    }

    .right-panel {
        width: 100%;
    }

    .message {
        max-width: 90%;
    }

    .history-list {
        padding: 0 10px;
    }

    .chat-messages {
        height: calc(100% - 120px);
    }

    .chat-controls {
        align-items: flex-start;
        gap: 8px;
    }

    .chat-text {
        display: none;
    }

    .model-selector {
        font-size: 0.8rem;
    }

    .model-select {
        font-size: 0.8rem;
        padding: 3px 6px;
    }

    .model-dropdown-btn {
        max-width: 160px;
        min-width: 120px;
    }
}

@media (max-width: 900px) {
    .admin-model-row {
        grid-template-columns: 52px 1fr 1fr;
    }

    .admin-model-row .model-name {
        grid-column: 2 / -1;
    }

    .admin-row-actions,
    .admin-logo-select,
    .admin-switch,
    .admin-model-row .admin-btn.danger {
        grid-column: 1 / -1;
    }

    .admin-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 700px) {
    .model-selector label {
        display: none;
    }

    .image-compare {
        flex-direction: column;
    }

    .image-compare-cell {
        min-width: 0;
    }
}

@media (max-width: 600px) {
    .admin-model-row {
        grid-template-columns: 52px 1fr;
    }

    .admin-model-row .model-name {
        grid-column: 1 / -1;
    }

    .admin-model-row .admin-btn.danger {
        justify-self: start;
    }

    .admin-row-actions {
        flex-wrap: wrap;
    }

    .admin-switch {
        justify-self: start;
    }
}

@media (max-width: 520px) {
    .generated-image-wrap .image-grid {
        grid-template-columns: 1fr;
    }
    .scroll-buttons {
        right: 15px;
        bottom: 150px;
    }
}
