*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
:root{
  --bg:#f7f8fa;--bg2:#ffffff;--bg3:#f0f1f3;--bg4:#e5e7eb;--bg5:#d1d5db;
  --text:#1a1a2e;--text2:#6b7280;--text3:#9ca3af;
  --accent:#4f46e5;--accent2:#6366f1;--accent-light:#eef2ff;--accent-dark:#3730a3;
  --user-bubble:#4f46e5;--user-text:#ffffff;
  --bot-bubble:#ffffff;--bot-text:#1a1a2e;
  --ok:#10b981;--warn:#f59e0b;--danger:#ef4444;--info:#3b82f6;
  --border:#e5e7eb;--border-light:#f0f1f3;
  --radius:12px;--radius-sm:8px;--radius-xs:6px;
  --shadow-sm:0 1px 2px rgba(0,0,0,.05);
  --shadow:0 1px 3px rgba(0,0,0,.08),0 1px 2px rgba(0,0,0,.04);
  --shadow-lg:0 10px 25px rgba(0,0,0,.08);
  --sidebar-w:280px;--header-h:60px;--agent-panel-w:300px;
  --transition:all .2s ease;
}

/* ── Theme System ── */
[data-theme="claude"]{
  --bg:#f5f0e8;--bg2:#ebe5d9;--bg3:#e2dace;--bg4:#d6cfc3;--bg5:#c8bfb0;
  --text:#2c2c2c;--text2:#5a5a5a;--text3:#8a8a8a;
  --accent:#c96442;--accent2:#d97a5a;--accent-light:#fceee8;--accent-dark:#a0502e;
  --user-bubble:#c96442;--user-text:#ffffff;
  --bot-bubble:#ffffff;--bot-text:#2c2c2c;
  --ok:#4a9c6d;--warn:#c4862b;--danger:#c94444;--info:#4a7fc9;
  --border:#d6cfc3;--border-light:#e2dace;
  --shadow-sm:0 1px 2px rgba(0,0,0,.06);
  --shadow:0 1px 3px rgba(0,0,0,.08),0 1px 2px rgba(0,0,0,.04);
  --shadow-lg:0 10px 25px rgba(0,0,0,.1);
}
[data-theme="dark"]{
  --bg:#1a1816;--bg2:#211f1b;--bg3:#2a2720;--bg4:#353128;--bg5:#433c32;
  --text:#e5ddd0;--text2:#a39b8c;--text3:#6d665b;
  --accent:#c96442;--accent2:#d97a5a;--accent-light:#2a1f18;--accent-dark:#a0502e;
  --card:#262320;
  --user-bubble:#c96442;--user-text:#ffffff;
  --bot-bubble:#211f1b;--bot-text:#e5ddd0;
  --ok:#6ee7a0;--warn:#fcd34d;--danger:#f87171;--info:#7db8f0;
  --border:#322c24;--border-light:#2a2520;
  --shadow-sm:0 1px 2px rgba(0,0,0,.3);
  --shadow:0 1px 3px rgba(0,0,0,.4),0 1px 2px rgba(0,0,0,.3);
  --shadow-lg:0 10px 25px rgba(0,0,0,.55);
}

html,body{width:100%;height:100%;margin:0;padding:0;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',system-ui,'Noto Sans SC',sans-serif;background:var(--bg);color:var(--text);font-size:14px;line-height:1.6;overflow:hidden}
a{color:var(--accent);text-decoration:none}
button{font:inherit;cursor:pointer;border:none;background:none;color:inherit}
input,textarea,select{font:inherit}

/* ── Layout ── */
.app{position:fixed;top:0;left:0;width:100vw;height:100vh;height:100dvh;display:flex;overflow:hidden;background:var(--bg)}

/* Layout panels */
.sidebar,
.agent-panel{flex-shrink:0;height:100%}
.main{flex:1;display:flex;flex-direction:column;min-width:0;height:100%;overflow:hidden}

/* ── Sidebar ── */
.sidebar{
  width:var(--sidebar-w);min-width:var(--sidebar-w);height:100%;
  transition:width .25s ease,min-width .25s ease;
  background:var(--bg2);border-right:1px solid var(--border);
  display:flex;flex-direction:column;z-index:20;
  overflow:hidden;
  position:relative;
}
.sidebar.collapsed{
  width:52px;min-width:52px;
}
.sidebar.collapsed .sidebar-header .sidebar-title,
.sidebar.collapsed .sidebar-header .sidebar-subtitle,
.sidebar.collapsed .new-chat-btn span,
.sidebar.collapsed .sidebar-search,
.sidebar.collapsed .session-list,
.sidebar.collapsed .sidebar-footer,
.sidebar.collapsed .sidebar-header .sidebar-logo + div,
.sidebar.collapsed #sidebarAgentIndicator{display:none!important}
.sidebar.collapsed .sidebar-header{justify-content:center;padding:16px 8px}
.sidebar.collapsed .new-chat-btn{padding:10px;border-radius:var(--radius-sm);justify-content:center}
.sidebar-toggle{
  position:absolute;top:50%;right:-14px;transform:translateY(-50%);
  width:28px;height:28px;border-radius:50%;background:var(--bg2);
  border:1px solid var(--border);display:grid;place-items:center;
  cursor:pointer;z-index:25;color:var(--text2);font-size:14px;
  transition:all .15s;
}
.sidebar-toggle:hover{background:var(--accent);color:#fff;border-color:var(--accent)}

.sidebar-header{
  padding:16px 20px;border-bottom:1px solid var(--border-light);
  display:flex;align-items:center;gap:12px;min-height:var(--header-h);
}
.sidebar-logo{
  width:36px;height:36px;border-radius:10px;
  background:linear-gradient(135deg,var(--accent),var(--accent-dark));
  display:grid;place-items:center;flex-shrink:0;
}
.sidebar-logo svg{width:20px;height:20px;color:#fff}
.sidebar-title{font-size:16px;font-weight:700;color:var(--text)}
.sidebar-subtitle{font-size:11px;color:var(--text3)}

.new-chat-btn{
  margin:12px 16px 8px;padding:10px 16px;border-radius:var(--radius-sm);
  background:var(--accent);color:#fff;font-size:13px;font-weight:600;
  display:flex;align-items:center;gap:8px;transition:var(--transition);
}
.new-chat-btn:hover{background:var(--accent2);transform:translateY(-1px)}
.new-chat-btn svg{width:16px;height:16px}

.sidebar-search{
  margin:4px 16px 8px;position:relative;
}
.sidebar-search input{
  width:100%;padding:8px 12px 8px 34px;border-radius:var(--radius-xs);
  border:1px solid var(--border);background:var(--bg);font-size:13px;
  outline:none;transition:border-color .2s;
}
.sidebar-search input:focus{border-color:var(--accent)}
.sidebar-search svg{
  position:absolute;left:10px;top:50%;transform:translateY(-50%);
  width:16px;height:16px;color:var(--text3);
}

.session-list{padding:4px 8px}
.session-item{
  display:flex;align-items:center;gap:10px;padding:10px 12px;
  border-radius:var(--radius-sm);cursor:pointer;transition:var(--transition);
  position:relative;
}
.session-item:hover{background:var(--bg3)}
.session-item.active{background:var(--accent-light);color:var(--accent2)}
.session-item.active::before{
  content:'';position:absolute;left:0;top:50%;transform:translateY(-50%);
  width:3px;height:24px;background:var(--accent);border-radius:0 2px 2px 0;
}
.session-icon{width:32px;height:32px;border-radius:8px;background:var(--bg3);
  display:grid;place-items:center;flex-shrink:0;font-size:14px}
.session-item.active .session-icon{background:var(--accent-light);color:var(--accent)}
.session-info{flex:1;min-width:0}
.session-name{font-size:13px;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.session-preview{font-size:11px;color:var(--text3);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-top:1px}
.session-meta{font-size:10px;color:var(--text3);flex-shrink:0;text-align:right}
.session-delete{
  opacity:0;width:24px;height:24px;border-radius:4px;display:grid;place-items:center;
  background:var(--bg2);transition:var(--transition);font-size:12px;color:var(--text3);
  flex-shrink:0;cursor:pointer;border:none;
}
.session-item:hover .session-actions{opacity:1}
.session-actions{opacity:0;display:flex;gap:2px;flex-shrink:0}
.session-actions .session-delete:hover{background:var(--danger);color:#fff}
.session-more-btn{
  width:24px;height:24px;border-radius:4px;display:grid;place-items:center;
  background:var(--bg2);transition:var(--transition);font-size:16px;color:var(--text3);
  flex-shrink:0;cursor:pointer;border:none;line-height:1;
}
.session-more-btn:hover{background:var(--bg3);color:var(--text)}
.session-context-menu{
  position:fixed;z-index:1000;background:var(--card);border:1px solid var(--border);
  border-radius:8px;box-shadow:0 4px 16px rgba(0,0,0,.15);padding:4px;min-width:140px;
  animation:menuFadeIn .15s ease-out;
}
@keyframes menuFadeIn{from{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}
.session-context-menu button{
  display:flex;align-items:center;gap:8px;width:100%;padding:8px 12px;border:none;
  background:none;color:var(--text);font-size:13px;cursor:pointer;border-radius:6px;
  transition:var(--transition);text-align:left;
}
.session-context-menu button:hover{background:var(--bg3)}
.session-context-menu button.danger{color:var(--danger)}
.session-context-menu button.danger:hover{background:rgba(239,68,68,.1)}
.session-rename{
  opacity:0;width:24px;height:24px;border-radius:4px;display:grid;place-items:center;
  background:var(--bg2);transition:var(--transition);font-size:12px;color:var(--text3);
  flex-shrink:0;cursor:pointer;border:none;
}
.session-rename:hover{background:var(--accent);color:#fff}
.session-rename-input{
  font-size:13px;font-weight:500;width:100%;padding:2px 6px;
  border:1px solid var(--accent);border-radius:4px;outline:none;
  background:var(--bg);color:var(--text);
}

.sidebar-footer{
  padding:12px 16px;border-top:1px solid var(--border-light);
  display:flex;flex-direction:column;gap:6px;
  flex-shrink:0;
}
.sidebar-footer-btn{
  display:flex;align-items:center;gap:10px;padding:8px 12px;
  border-radius:var(--radius-xs);font-size:13px;color:var(--text2);
  transition:var(--transition);
}
.sidebar-footer-btn:hover{background:var(--bg3);color:var(--text)}
.sidebar-footer-btn svg{width:16px;height:16px}
.sidebar-version-bar{padding:4px 12px;display:flex;align-items:center;gap:6px}

/* ── Main ── */
.main{flex:1;display:flex;flex-direction:column;overflow:hidden;min-width:0;background:var(--bg)}
.main-header{
  height:var(--header-h);min-height:var(--header-h);
  display:flex;align-items:center;gap:12px;padding:0 20px;
  background:var(--bg2);border-bottom:1px solid var(--border-light);
}
.toggle-sidebar{width:36px;height:36px;border-radius:var(--radius-xs);
  display:grid;place-items:center;color:var(--text2);transition:var(--transition)}
.toggle-sidebar:hover{background:var(--bg3);color:var(--text)}
.toggle-sidebar svg{width:20px;height:20px}
.main-title{flex:1;font-size:15px;font-weight:600;display:flex;align-items:center;gap:8px}
.main-title .dot{width:8px;height:8px;border-radius:50%;background:var(--ok)}
.header-actions{display:flex;gap:6px}
.header-btn{width:36px;height:36px;border-radius:var(--radius-xs);
  display:grid;place-items:center;color:var(--text2);transition:var(--transition)}
.header-btn:hover{background:var(--bg3);color:var(--text)}
.header-btn svg{width:18px;height:18px}

/* ── Messages ── */
.messages-container{flex:1;overflow-y:auto;padding:20px}
.messages-inner{max-width:900px;margin:0 auto;display:flex;flex-direction:column;gap:2px}

.message-row{display:flex;gap:10px;animation:msgIn .25s ease-out;align-items:flex-start}
.message-row.no-animate{animation:none !important}
@keyframes msgIn{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}
@keyframes blink{0%,100%{opacity:1}50%{opacity:0}}
.message-row.user{flex-direction:row-reverse}
.message-row>:nth-child(2){flex:1;min-width:0}

.message-avatar{
  width:32px;height:32px;border-radius:8px;flex-shrink:0;
  display:grid;place-items:center;font-size:12px;
}
.message-row.user .message-avatar{background:var(--accent);color:#fff}
.message-row.assistant .message-avatar{background:linear-gradient(135deg,var(--accent),var(--accent-dark));color:#fff}

.message-bubble{
  max-width:85%;padding:8px 12px;border-radius:var(--radius);
  font-size:14px;line-height:1.5;word-break:break-word;
  box-shadow:var(--shadow-sm);
  overflow-wrap:break-word;overflow:hidden;position:relative;
}
.message-row.user .message-bubble{
  background:var(--user-bubble);color:var(--user-text);
  max-width:70%;
}
.message-row.assistant .message-bubble{
  background:var(--bot-bubble);color:var(--bot-text);
  border:1px solid var(--border-light);
  max-width:95%;
}
/* Unified bubble wrapper for timeline content — always full width */
.msg-bubble-wrapper{max-width:95%!important;width:100%}
.msg-bubble-wrapper>.msg-timeline{gap:10px}

/* [v1.33.1] Multiple independent bubbles within a single message-row */
.message-row .message-bubble + .message-bubble {
  margin-top: 8px;
}

/* Tool bubbles styling - distinct from text bubbles */
.msg-bubble-tool {
  background: var(--bg2) !important;
  border: 1px solid var(--border) !important;
  border-left: 3px solid var(--accent) !important;
}

/* Container for multiple independent bubbles (streaming) */
.msg-bubbles-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.msg-bubbles-container .msg-timeline {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
/* [fix] .msg-bubbles-container 内子元素由 gap:8px 控制间距，不需要额外 margin */
.msg-bubbles-container .message-bubble + .message-bubble {
  margin-top: 0;
}
.msg-bubbles-container .v2-tool-event,
.msg-bubbles-container .inline-exec-event {
  margin: 0;
}
.message-bubble p{margin-bottom:4px}
.message-bubble p:last-child{margin-bottom:0}
.message-bubble code{
  background:rgba(0,0,0,.06);padding:2px 6px;border-radius:4px;
  font-family:'SF Mono','Fira Code','Cascadia Code',monospace;font-size:12.5px;
}
.message-row.user .message-bubble code{background:rgba(255,255,255,.2)}
.message-bubble pre{
  background:var(--bg3);color:var(--text);padding:14px 16px;border-radius:var(--radius-sm);
  overflow-x:auto;margin:8px 0;font-size:12.5px;line-height:1.5;
  font-family:'SF Mono','Fira Code','Cascadia Code',monospace;
  max-width:100%;white-space:pre-wrap;word-break:break-all;
}
.message-bubble pre code{background:none;padding:0;font-size:inherit}
.message-bubble strong{font-weight:600}
.message-bubble em{font-style:italic}
.message-bubble ul,.message-bubble ol{padding-left:20px;margin:2px 0}
.message-bubble li{margin:1px 0}
.message-bubble blockquote{
  border-left:3px solid var(--accent);padding:4px 12px;margin:8px 0;
  color:var(--text2);font-style:italic;
}
/* Markdown 标题样式 */
.message-bubble .md-header,
.timeline-segment .md-header,
#streamingContent .md-header {
  margin: 12px 0 8px 0;
  font-weight: 600;
  line-height: 1.3;
}
.message-bubble .md-header:first-child,
.timeline-segment .md-header:first-child,
#streamingContent .md-header:first-child {
  margin-top: 0;
}
.message-bubble h1.md-header { font-size: 1.5em; }
.message-bubble h2.md-header { font-size: 1.35em; }
.message-bubble h3.md-header { font-size: 1.2em; }
.message-bubble h4.md-header { font-size: 1.1em; }
.message-bubble h5.md-header { font-size: 1.05em; }
.message-bubble h6.md-header { font-size: 1em; color: var(--text2); }
#streamingContent h1.md-header { font-size: 1.5em; }
#streamingContent h2.md-header { font-size: 1.35em; }
#streamingContent h3.md-header { font-size: 1.2em; }
#streamingContent h4.md-header { font-size: 1.1em; }
#streamingContent h5.md-header { font-size: 1.05em; }
#streamingContent h6.md-header { font-size: 1em; color: var(--text2); }
.message-time{font-size:10px;color:var(--text3);margin-top:2px}

/* Execution Progress Timer */
.exec-timer{
  display:flex;align-items:center;gap:10px;
  padding:8px 14px;margin:4px 0 8px 0;
  background:var(--bg2);border:1px solid var(--border-light);
  border-radius:var(--radius-sm);box-shadow:var(--shadow-sm);
  animation:msgIn .2s ease-out;
  max-width:400px;
}
.exec-timer-icon{
  width:28px;height:28px;border-radius:6px;
  background:linear-gradient(135deg,var(--accent),var(--accent-dark));
  display:grid;place-items:center;flex-shrink:0;
  font-size:14px;
}
.exec-timer-body{flex:1;min-width:0}
.exec-timer-title{
  font-size:11px;font-weight:600;color:var(--text2);
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
  margin-bottom:3px;display:flex;align-items:center;gap:6px;
}
.exec-timer-title .pulse-dot{
  width:6px;height:6px;border-radius:50%;background:var(--ok);
  animation:pulseDot 1.2s infinite;
}
.exec-timer-title .pulse-dot.timeout{background:var(--danger)}
@keyframes pulseDot{0%,100%{opacity:1}50%{opacity:.3}}
.exec-timer-times{
  display:flex;gap:12px;font-size:11px;color:var(--text3);
}
.exec-timer-time{
  display:flex;align-items:baseline;gap:3px;
}
.exec-timer-time .time-val{
  font-size:18px;font-weight:700;font-variant-numeric:tabular-nums;
  color:var(--text);
  min-width:48px;
}
.exec-timer-time .time-unit{font-size:10px;color:var(--text3)}
.exec-timer-time.timeout .time-val{color:var(--danger);animation:pulseDot 1s infinite}
.exec-timer-bar{
  height:3px;background:var(--bg4);border-radius:2px;
  margin-top:4px;overflow:hidden;
}
.exec-timer-bar-fill{
  height:100%;border-radius:2px;
  background:linear-gradient(90deg,var(--ok),var(--info));
  transition:width .3s ease;
}
.exec-timer-bar-fill.warning{background:linear-gradient(90deg,var(--warn),var(--danger))}
.exec-timer-bar-fill.danger{background:var(--danger);animation:barPulse 1s infinite}
@keyframes barPulse{0%,100%{opacity:1}50%{opacity:.6}}
.exec-timer-code{
  font-family:'SF Mono','Fira Code','Cascadia Code',monospace;
  font-size:10px;color:var(--text3);margin-top:3px;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
  background:var(--bg);padding:2px 6px;border-radius:3px;
}

/* Streaming Indicator */
.streaming-indicator{
  display:inline-flex;align-items:center;gap:8px;
  margin-top:8px;padding:6px 14px;border-radius:18px;
  background:var(--bg3);font-size:12px;color:var(--text2);
  box-shadow:var(--shadow-sm);
}
.spinner{
  width:14px;height:14px;border:2px solid var(--bg5);
  border-top-color:var(--accent);border-radius:50%;
  animation:spin 1s linear infinite;
}
@keyframes spin{to{transform:rotate(360deg)}}
.streaming-dots{display:flex;gap:3px}
.streaming-dots .dot{
  width:3px;height:3px;border-radius:50%;background:var(--accent);
  animation:pulseDot 1.2s infinite;
}
.streaming-dots .dot:nth-child(2){animation-delay:.2s}
.streaming-dots .dot:nth-child(3){animation-delay:.4s}
@keyframes pulseDot{0%,100%{opacity:.3;transform:scale(.8)}50%{opacity:1;transform:scale(1.2)}}

/* ── Streaming Typing Cursor (打字机光标) ── */
.streaming-cursor{
  display:inline-block;width:2.5px;height:1.15em;
  background:var(--accent);border-radius:1.5px;
  margin-left:1px;vertical-align:text-bottom;
  animation:cursorBlink 1.06s step-end infinite;
  box-shadow:0 0 6px rgba(201,100,66,.35);
  position:relative;
}
@keyframes cursorBlink{0%,100%{opacity:1}50%{opacity:0}}

/* ── Smart Scroll-to-Bottom Button ── */
.scroll-to-bottom-btn{
  position:absolute;bottom:80px;right:24px;z-index:10;
  width:36px;height:36px;border-radius:50%;
  background:var(--bg2);border:1px solid var(--border);
  box-shadow:var(--shadow);display:none;place-items:center;
  cursor:pointer;color:var(--text2);font-size:16px;
  transition:var(--transition);opacity:0;transform:translateY(8px);
}
.scroll-to-bottom-btn.visible{
  display:grid;opacity:1;transform:translateY(0);
  animation:scrollBtnIn .25s ease-out;
}
.scroll-to-bottom-btn:hover{background:var(--accent);color:#fff;border-color:var(--accent)}
@keyframes scrollBtnIn{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}
.scroll-to-bottom-btn svg{width:18px;height:18px}

/* ── Tool Running Spinner ── */
.tool-running-spinner{
  display:inline-flex;align-items:center;justify-content:center;
  width:16px;height:16px;flex-shrink:0;
}
.tool-running-spinner::after{
  content:'';display:block;width:14px;height:14px;
  border:2px solid var(--border);
  border-top-color:var(--accent);border-radius:50%;
  animation:spin .8s linear infinite;
}
.v2-tool-event.tool-running{
  border-left-color:var(--accent);
  animation:toolRunPulse 2s ease-in-out infinite;
}
@keyframes toolRunPulse{
  0%,100%{box-shadow:0 0 0 0 rgba(201,100,66,.08)}
  50%{box-shadow:0 0 0 4px rgba(201,100,66,.12)}
}
.tool-elapsed-timer{
  font-size:10px;font-variant-numeric:tabular-nums;
  color:var(--text3);font-weight:500;
  display:inline-flex;align-items:center;gap:3px;
}
.tool-elapsed-timer .timer-dot{
  width:4px;height:4px;border-radius:50%;
  background:var(--accent);animation:pulseDot 1s infinite;
}

/* ── Thought Block Streaming Word Count ── */
.thought-word-count{
  font-size:10px;color:var(--text3);font-weight:400;
  margin-left:4px;opacity:.7;
}
.thought-block:not(.streaming) .thought-word-count{display:none}

/* ── Streaming Content Fade Transition ── */
.message-bubble.streaming-bubble{
  transition:opacity .15s ease;
}
.message-bubble.stream-fade-in{
  animation:streamFadeIn .3s ease-out;
}
@keyframes streamFadeIn{
  from{opacity:.85}
  to{opacity:1}
}

/* ── Streaming Status Bar (流式状态指示器) ── */
.stream-status-bar{
  display:flex;
  align-items:center;
  gap:8px;
  padding:6px 16px;
  margin:0 auto;
  max-width:900px;
  font-size:12px;
  color:var(--text2);
  background:var(--bg2);
  border:1px solid var(--border-light);
  border-radius:var(--radius-sm);
  box-shadow:var(--shadow-sm);
  transition:opacity .3s ease;
  position:sticky;
  bottom:0;
  z-index:5;
}
.stream-status-icon{
  font-size:14px;
  flex-shrink:0;
}
.stream-status-text{
  flex:1;
  font-weight:500;
}
.stream-status-spinner{
  flex-shrink:0;
}
.stream-status-spinner .spinner{
  width:12px;
  height:12px;
  border-width:1.5px;
}
/* [fix] streamStatusBar 中的 thinking-wave 动画（与 streaming-indicator 统一） */
.stream-status-wave{
  display:flex;align-items:center;gap:2px;height:16px;flex-shrink:0;
}
.stream-status-wave span{
  display:block;width:3px;border-radius:2px;
  background:var(--accent);
  animation:thinkingWave 1.2s ease-in-out infinite;
}
.stream-status-wave span:nth-child(1){height:6px;animation-delay:0s}
.stream-status-wave span:nth-child(2){height:10px;animation-delay:.15s}
.stream-status-wave span:nth-child(3){height:14px;animation-delay:.3s}
.stream-status-wave span:nth-child(4){height:10px;animation-delay:.45s}
.stream-status-wave span:nth-child(5){height:6px;animation-delay:.6s}

/* ── Streaming Message Row (流式消息行) ── */
.message-row.streaming{
  animation:none;
}
.message-row.streaming .message-content{
  position:relative;
}
#streamingContent{
  width:100%;
  max-width:95%;
  padding:12px 16px;
  border-radius:var(--radius);
  background:var(--bot-bubble);
  color:var(--bot-text);
  border:1px solid var(--border-light);
  font-size:14px;
  line-height:1.7;
  word-break:break-word;
  overflow-wrap:break-word;
  box-shadow:var(--shadow-sm);
  min-height:24px;
}
/* 流式分段之间的分隔线 */
.stream-segment-divider{
  border-top:1px solid var(--border-light);
  margin:10px 0 8px;
  opacity:.5;
}
/* #streamingContent: 当前活跃流式文本 — 气泡样式与历史消息一致 */
#streamingContent.streaming-bubble{
  background:var(--bot-bubble);color:var(--bot-text);
  border:1px solid var(--border-light);
  max-width:95%;width:100%;
  padding:8px 12px;border-radius:var(--radius);
  font-size:14px;line-height:1.5;word-break:break-word;
  box-shadow:var(--shadow-sm);
  overflow-wrap:break-word;overflow:hidden;position:relative;
}
/* 流式文本段落样式 */
#streamingContent .stream-text-part{
  display:block;
  width:100%;
}
#streamingContent p{margin-bottom:8px}
#streamingContent p:last-child{margin-bottom:0}
#streamingContent code{
  background:rgba(0,0,0,.06);padding:2px 6px;border-radius:4px;
  font-family:'SF Mono','Fira Code','Cascadia Code',monospace;font-size:12.5px;
}
#streamingContent pre{
  background:var(--bg3);color:var(--text);padding:14px 16px;border-radius:var(--radius-sm);
  overflow-x:auto;margin:8px 0;font-size:12.5px;line-height:1.5;
  font-family:'SF Mono','Fira Code','Cascadia Code',monospace;
  max-width:100%;white-space:pre-wrap;word-break:break-all;
}
#streamingContent pre code{background:none;padding:0;font-size:inherit}
#streamingContent ul,#streamingContent ol{padding-left:20px;margin:2px 0}
#streamingContent li{margin:1px 0}
#streamingContent blockquote{
  border-left:3px solid var(--accent);padding:4px 12px;margin:8px 0;
  color:var(--text2);font-style:italic;
}
/* [fix] 工具卡片在 .message-content 中与封存气泡交替显示 */
.message-content > .v2-tool-event,
#streamingContent .v2-tool-event{
  margin:8px 0;
}

/* [fix] 封存文本气泡样式 — 与历史消息 .message-bubble 完全一致 */
.message-content > .sealed-bubble{
  background:var(--bot-bubble);color:var(--bot-text);
  border:1px solid var(--border-light);
  max-width:95%;width:100%;
  padding:8px 12px;border-radius:var(--radius);
  font-size:14px;line-height:1.5;word-break:break-word;
  box-shadow:var(--shadow-sm);
  overflow-wrap:break-word;overflow:hidden;position:relative;
}
.message-content > .sealed-bubble + .sealed-bubble{
  margin-top:8px;
}
.message-content > .sealed-bubble p{margin-bottom:4px}
.message-content > .sealed-bubble p:last-child{margin-bottom:0}
.message-content > .sealed-bubble code{
  background:rgba(0,0,0,.06);padding:2px 6px;border-radius:4px;
  font-family:'SF Mono','Fira Code','Cascadia Code',monospace;font-size:12.5px;
}
.message-content > .sealed-bubble pre{
  background:var(--bg3);color:var(--text);padding:14px 16px;border-radius:var(--radius-sm);
  overflow-x:auto;margin:8px 0;font-size:12.5px;line-height:1.5;
  font-family:'SF Mono','Fira Code','Cascadia Code',monospace;
  max-width:100%;white-space:pre-wrap;word-break:break-all;
}

/* [fix] 用户中断消息气泡 — 轻量 inline 样式，不嵌套 message-row */
.stream-interrupt-bubble{
  display:flex;align-items:flex-start;gap:8px;
  margin:8px 0;padding:8px 14px;border-radius:12px;
  background:var(--user-bubble-bg,linear-gradient(135deg,#6366f1,#8b5cf6));
  color:var(--user-bubble-color,#fff);
  font-size:14px;line-height:1.6;word-break:break-word;
  max-width:85%;align-self:flex-end;
  box-shadow:0 1px 3px rgba(0,0,0,0.1);
  animation:fadeSlideIn .25s ease;
}
.stream-interrupt-bubble .stream-interrupt-avatar{
  font-size:16px;flex-shrink:0;margin-top:1px;
}
.stream-interrupt-bubble .stream-interrupt-text{
  flex:1;min-width:0;
}

/* 保留旧类名兼容（已在DOM中存在的） */
.stream-interrupt-row{
  animation:none !important;
}

/* ── Enhanced Streaming Indicator ── */
.streaming-indicator{
  display:inline-flex;align-items:center;gap:10px;
  margin-top:8px;padding:8px 16px;border-radius:20px;
  background:linear-gradient(135deg,var(--bg3),var(--bg2));
  font-size:12px;color:var(--text2);
  box-shadow:var(--shadow-sm);
  border:1px solid var(--border-light);
}
.streaming-indicator .thinking-wave{
  display:flex;align-items:center;gap:2px;height:16px;
}
.streaming-indicator .thinking-wave span{
  display:block;width:3px;border-radius:2px;
  background:var(--accent);
  animation:thinkingWave 1.2s ease-in-out infinite;
}
.streaming-indicator .thinking-wave span:nth-child(1){height:6px;animation-delay:0s}
.streaming-indicator .thinking-wave span:nth-child(2){height:10px;animation-delay:.15s}
.streaming-indicator .thinking-wave span:nth-child(3){height:14px;animation-delay:.3s}
.streaming-indicator .thinking-wave span:nth-child(4){height:10px;animation-delay:.45s}
.streaming-indicator .thinking-wave span:nth-child(5){height:6px;animation-delay:.6s}
@keyframes thinkingWave{
  0%,100%{transform:scaleY(.4);opacity:.4}
  50%{transform:scaleY(1);opacity:1}
}

/* ── Message Content Smooth Render ── */
.message-content{
  flex:1;min-width:0;width:100%;
  /* 确保所有子元素（thought-block, bubble 等）撑满宽度 */
  display:flex;flex-direction:column;align-items:stretch;
}
.stream-text-node{
  display:inline;
}
.stream-complete-flash{
  animation:completeFlash .4s ease-out;
}
@keyframes completeFlash{
  0%{background:rgba(217,119,6,.06)}
  100%{background:transparent}
}

/* ── Thought Block (Agent Thinking) ── */
.thought-block{width:100%!important;max-width:100%!important;display:flex;flex-direction:column;margin:0 0 10px 0;border:1px solid var(--border-light);border-radius:var(--radius-sm);overflow:hidden;background:linear-gradient(135deg,var(--accent-light),var(--bg2));animation:thoughtFadeIn .4s ease-out;flex-shrink:0;box-sizing:border-box;align-self:stretch}
.thought-block.streaming{border-color:var(--accent);box-shadow:0 0 12px rgba(217,119,6,.15)}
@keyframes thoughtFadeIn{from{opacity:0;transform:translateY(-6px)}to{opacity:1;transform:translateY(0)}}
.thought-block summary{display:flex;align-items:center;gap:8px;padding:8px 14px;cursor:pointer;font-size:12px;font-weight:600;color:var(--text2);user-select:none;transition:var(--transition);text-transform:uppercase;letter-spacing:.3px}
.thought-block summary:hover{background:var(--bg3)}
.thought-block summary .thought-icon{font-size:14px;display:inline-flex}
.thought-block.streaming summary .thought-icon{animation:brainPulse 1.5s ease-in-out infinite}
@keyframes brainPulse{0%,100%{transform:scale(1)}50%{transform:scale(1.15)}}
.thought-block summary .thought-label{flex:1}
.thought-block summary .thought-badge{font-size:10px;padding:2px 8px;border-radius:10px;background:var(--accent);color:#fff;font-weight:500;animation:badgePulse 1.2s ease-in-out infinite}
@keyframes badgePulse{0%,100%{opacity:1}50%{opacity:.6}}
.thought-block:not(.streaming) summary .thought-badge{background:var(--bg4);color:var(--text3);animation:none}
.thought-content{width:100%;padding:10px 14px 14px;font-size:13px;line-height:1.7;color:var(--text2);border-top:1px solid var(--border-light);max-height:300px;overflow-y:auto;overflow-x:hidden;word-break:break-word;overflow-wrap:break-word;box-sizing:border-box}
/* Reasoning (模型推理过程): limit to ~5 lines, scrollable */
.thought-block .thought-content.reasoning-content{max-height:calc(1.7em * 5 + 28px);min-height:0}
.thought-block .thought-content.reasoning-content::-webkit-scrollbar{width:4px}
.thought-block .thought-content.reasoning-content::-webkit-scrollbar-thumb{background:var(--bg4);border-radius:2px}
.thought-block .thought-content.reasoning-content::-webkit-scrollbar-track{background:transparent}

/* [fix] List indentation inside thought-content (reasoning blocks).
   Without this, <ul>/<ol> lists in the thought tab are flush-left with
   no indentation, making <li> items hard to read. */
.thought-content ul,.thought-content ol{padding-left:20px;margin:4px 0}
.thought-content li{margin:2px 0}
/* Real reasoning (模型真实推理): distinct from text output */
.thought-block.real-reasoning {
  border-color: var(--info);
  background: linear-gradient(135deg, rgba(59,130,246,0.08), var(--bg2));
}
.thought-block.real-reasoning.streaming {
  border-color: var(--info);
  box-shadow: 0 0 12px rgba(59,130,246,0.15);
}
.thought-block.real-reasoning summary .thought-badge {
  background: var(--info);
}
/* [v1.41] thought-block 已移入 message-content 内部，不再作为 messages-inner 直接子元素 */
.thought-content p{margin:4px 0;width:100%;max-width:100%;box-sizing:border-box}
.thought-content p:first-child{margin-top:0}
.thought-content p:last-child{margin-bottom:0}
.thought-content code{background:var(--bg3);padding:1px 5px;border-radius:3px;font-size:12px}
.thought-content pre{background:var(--bg);padding:10px 12px;border-radius:var(--radius-xs);margin:6px 0;font-size:12px;overflow-x:auto;width:100%;max-width:100%;box-sizing:border-box}

/* ── Exec Event Enhanced ── */
.exec-event-item{display:flex;gap:10px;padding:8px 0;animation:execEventSlide .3s ease-out;border-bottom:1px solid var(--border-light)}
.exec-event-item:last-child{border-bottom:none}
@keyframes execEventSlide{from{opacity:0;transform:translateX(-8px)}to{opacity:1;transform:translateX(0)}}
.typing-indicator.no-animate{animation:none !important}
.thought-block.no-animate{animation:none !important}
.exec-event-item.no-animate{animation:none !important}
.exec-event-icon{width:28px;height:28px;border-radius:6px;display:grid;place-items:center;flex-shrink:0;font-size:13px}
.exec-event-icon.tool{background:#eff6ff;color:#3b82f6}
.exec-event-icon.skill{background:#f0fdf4;color:#22c55e}
.exec-event-icon.code{background:#fefce8;color:#eab308}
.exec-event-icon.success{background:#ecfdf5;color:#10b981}
.exec-event-icon.error{background:#fef2f2;color:#ef4444}
.exec-event-icon.running{background:rgba(217,119,6,.12);color:#D97706;animation:brainPulse 1.2s infinite}
.exec-event-body{flex:1;min-width:0}
.exec-event-title{font-size:12px;font-weight:600;color:var(--text);margin-bottom:2px}
.exec-event-meta{font-size:11px;color:var(--text3);display:flex;gap:8px;align-items:center}
.exec-event-code{font-family:'SF Mono','Fira Code','Cascadia Code',monospace;font-size:11px;color:var(--text3);margin-top:4px;padding:4px 8px;background:var(--bg);border-radius:4px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;cursor:pointer}
.exec-event-code:hover{background:var(--bg3);color:var(--text)}
.exec-event-summary{font-size:11px;color:var(--text3);margin-top:3px;line-height:1.5;max-height:60px;overflow:hidden}
.exec-event-result-btn{margin-top:4px;padding:3px 10px;border-radius:4px;background:var(--bg3);border:1px solid var(--border);font-size:11px;color:var(--text2);cursor:pointer;transition:var(--transition);display:inline-flex;align-items:center;gap:4px}
.exec-event-result-btn:hover{border-color:var(--accent);color:var(--accent)}

/* Typing indicator */
.typing-indicator{
  display:flex;gap:10px;animation:msgIn .25s ease-out;
}
.typing-bubble{
  background:var(--bot-bubble);border:1px solid var(--border-light);
  border-radius:var(--radius);
  padding:14px 20px;display:flex;align-items:center;gap:5px;
  box-shadow:var(--shadow-sm);
}
.typing-dot{
  width:8px;height:8px;border-radius:50%;background:var(--text3);
  animation:typingBounce 1.4s infinite;
}
.typing-dot:nth-child(2){animation-delay:.2s}
.typing-dot:nth-child(3){animation-delay:.4s}
@keyframes typingBounce{
  0%,60%,100%{transform:translateY(0);opacity:.4}
  30%{transform:translateY(-6px);opacity:1}
}

/* Empty state */
.empty-state{
  flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;
  padding:40px 20px;color:var(--text3);text-align:center;
}
.empty-icon{font-size:56px;margin-bottom:16px;opacity:.5}
.empty-title{font-size:18px;font-weight:600;color:var(--text2);margin-bottom:8px}
.empty-desc{font-size:13px;max-width:400px;line-height:1.6;margin-bottom:24px}
.quick-actions{display:flex;flex-wrap:wrap;gap:8px;justify-content:center}
.quick-action{
  padding:8px 16px;border-radius:20px;background:var(--bg2);
  border:1px solid var(--border);font-size:13px;color:var(--text2);
  transition:var(--transition);
}
.quick-action:hover{border-color:var(--accent);color:var(--accent);background:var(--accent-light)}

/* ── Input Area ── */
.input-area{
  padding:16px 20px;background:var(--bg2);border-top:1px solid var(--border-light);
}
.input-wrapper{max-width:900px;margin:0 auto}
.input-box{
  display:flex;align-items:flex-end;gap:10px;
  background:var(--bg);border:1px solid var(--border);
  border-radius:var(--radius);padding:8px 12px;
  transition:border-color .2s,box-shadow .2s;
}
.input-box:focus-within{border-color:var(--accent);box-shadow:0 0 0 3px var(--accent-light)}
.text-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  width: 100%;
  flex: 1;
}
.input-box textarea{
  flex:1;border:none;background:none;outline:none;resize:none;
  font-size:14px;line-height:1.5;max-height:150px;min-height:80px;
  padding:8px 0;color:var(--text);
}
.input-box textarea::placeholder{color:var(--text3)}

/* [v1.16.12] 附件按钮 */
.attach-buttons {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
  padding-bottom: 2px;
}
.attach-btn {
  width:30px;height:30px;border:none;background:transparent;color:var(--text3);
  display:grid;place-items:center;border-radius:var(--radius-xs);
  cursor:pointer;transition:var(--transition);
}
.attach-btn:hover{color:var(--accent);background:var(--accent-light)}
.attach-btn svg{width:18px;height:18px}

/* [v1.16.12] 拖拽高亮 */
.input-box.drag-over{border-color:var(--accent) !important;box-shadow:0 0 0 2px rgba(217,119,6,.2)}

/* [v1.16.12] 附件预览 */
.attachment-preview {
  display:flex;flex-wrap:wrap;gap:8px;padding:8px 0;
  align-items:center;
}
.attachment-preview:empty{display:none}
.attachment-thumb {
  position:relative;border-radius:var(--radius-sm);overflow:hidden;
  border:1px solid var(--bg4);cursor:pointer;transition:var(--transition);
}
.attachment-thumb:hover{border-color:var(--accent)}
.attachment-thumb-image {
  width:80px;height:80px;
}
.attachment-thumb-image img {
  width:100%;height:100%;object-fit:cover;display:block;
}
.attachment-thumb-file {
  display:flex;flex-direction:column;align-items:center;justify-content:center;
  width:80px;height:80px;background:var(--bg3);padding:6px;gap:4px;
}
.attachment-file-icon{font-size:22px;line-height:1}
.attachment-file-name{
  font-size:10px;color:var(--text2);text-align:center;
  max-width:70px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
.attachment-remove {
  position:absolute;top:-2px;right:-2px;
  width:18px;height:18px;border-radius:50%;
  background:var(--danger);color:#fff;border:none;
  font-size:13px;line-height:1;cursor:pointer;
  display:none;align-items:center;justify-content:center;
  padding:0;
}
.attachment-thumb:hover .attachment-remove{display:flex}

/* [v1.16.12→18→19.3] 消息气泡中的附件 */
.msg-attachments {
  display:flex;flex-wrap:wrap;gap:8px;margin-bottom:8px;
}
.msg-attachments-images {
  margin-bottom:10px; /* 图片在气泡内容上方，底部留更多空间 */
}
.msg-attachments-files {
  margin-top:6px; /* 文件在气泡内容下方 */
}
/* [v1.20.3] 媒体嵌入播放器（在线音视频） */
.msg-attachments-media {
  margin-bottom:10px;
}
.msg-media-embed {
  background:var(--bg2);border:1px solid var(--bg4);border-radius:var(--radius-sm);
  overflow:hidden;max-width:640px;
}
.msg-media-header {
  display:flex;align-items:center;gap:6px;padding:6px 10px;
  background:var(--bg3);font-size:12px;color:var(--text2);
}
.msg-media-icon {font-size:14px}
.msg-media-label {flex:1;font-weight:500}
.msg-media-link {
  color:var(--accent);text-decoration:none;font-size:14px;padding:2px 4px;border-radius:4px;
}
.msg-media-link:hover {background:var(--accent-light)}
/* [v1.20.3] 本地音视频播放器 */
.msg-media-player {
  margin-bottom:8px;
}
.msg-media-player audio,
.msg-media-player video {
  border-radius:8px;
  box-shadow:0 1px 4px rgba(0,0,0,.1);
}
.msg-media-title {
  font-size:12px;color:var(--text2);margin-top:4px;padding:0 4px;
}
@media(max-width:768px){
  .msg-media-embed iframe { max-width:100%!important; }
  .msg-media-player audio, .msg-media-player video { max-width:100%!important; }
}
.msg-image-wrapper {
  max-width:300px;border-radius:var(--radius-sm);overflow:hidden;
  border:1px solid var(--bg4);cursor:pointer;
  position:relative;
  transition:border-color .2s, box-shadow .2s;
}
.msg-image-wrapper:hover{border-color:var(--accent);box-shadow:var(--shadow)}
.msg-image {
  width:100%;height:auto;display:block;max-height:300px;object-fit:cover;
  transition:max-height .3s ease;
}
.msg-image-wrapper:hover .msg-image{max-height:none}
/* [v1.19.3] Agent 发送的图片样式 */
.agent-image {
  border-color:var(--accent);
}
.agent-image::after {
  content:'点击查看大图 · ⬇ 下载';
}
/* [v1.16.18] 图片缩略图 hover 叠加层提示 */
.msg-image-wrapper::after {
  content:'点击查看大图';
  position:absolute;bottom:0;left:0;right:0;
  padding:4px 8px;text-align:center;
  background:linear-gradient(transparent,rgba(0,0,0,.5));
  color:#fff;font-size:11px;
  opacity:0;transition:opacity .2s;
  pointer-events:none;
}
.msg-image-wrapper:hover::after{opacity:1}
.msg-file-item {
  display:flex;align-items:center;gap:8px;padding:6px 10px;
  background:var(--bg3);border-radius:var(--radius-sm);
  font-size:13px;color:var(--text2);max-width:280px;
  cursor:pointer;transition:background .15s,border-color .15s;
  border:1px solid transparent;
}
.msg-file-item:hover{background:var(--bg4);border-color:var(--accent)}
.agent-file{border-color:var(--accent);background:var(--bg2)}
.msg-file-icon{font-size:18px;flex-shrink:0}
.msg-file-info{display:flex;flex-direction:column;gap:2px;min-width:0;flex:1}
.msg-file-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:500}
.msg-file-size{font-size:11px;color:var(--text3);flex-shrink:0}
.msg-file-actions{flex-shrink:0;margin-left:4px}
.msg-file-download{
  display:inline-flex;align-items:center;justify-content:center;
  width:28px;height:28px;border-radius:var(--radius-xs);
  font-size:16px;text-decoration:none;color:var(--text3);
  transition:background .15s, color .15s;
}
.msg-file-download:hover{background:var(--accent);color:#fff}

/* [v1.17→19.3] 移动端文件附件适配 */
@media (max-width: 768px) {
  .msg-file-item {
    max-width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    gap: 10px;
    min-height: 44px;
  }
  .msg-file-icon { font-size: 22px; }
  .msg-file-name { font-size: 14px; }
  .msg-attachments { gap: 10px; }
  .msg-image-wrapper { max-width: 100%; }
  .msg-file-download { width: 34px; height: 34px; font-size: 18px; }
}

/* [v1.17] 折叠文件内容样式 */
.file-content-collapse {
  border: 1px solid var(--bg4);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.file-content-collapse summary {
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text3);
  background: var(--bg2);
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.file-content-collapse summary:hover {
  color: var(--text2);
  background: var(--bg3);
}
.file-content-collapse[open] summary {
  border-bottom: 1px solid var(--bg4);
}
.file-content-collapse .collapse-body {
  padding: 10px 14px;
  max-height: 400px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.5;
}

.send-btn{
  width:36px;height:36px;border-radius:var(--radius-sm);
  background:var(--accent);color:#fff;
  display:grid;place-items:center;flex-shrink:0;
  transition:var(--transition);
}
.send-btn:hover{background:var(--accent2)}
.send-btn:disabled{opacity:.35;cursor:default}
.send-btn svg{width:18px;height:18px}

.stop-btn{
  width:36px;height:36px;border-radius:var(--radius-sm);
  background:var(--danger);color:#fff;
  display:grid;place-items:center;flex-shrink:0;
  transition:var(--transition);animation:pulse 1.5s infinite;
}
@keyframes pulse{0%,100%{opacity:1}50%{opacity:.6}}
.stop-btn svg{width:14px;height:14px}

.input-hint{font-size:11px;color:var(--text3);text-align:center;margin-top:6px}

/* ── Input Mode Toggle (Text/Voice) ── */
.input-mode-toggle {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--bg3);
  border-radius: var(--radius-sm);
  padding: 3px;
}
.input-mode-btn {
  width: 32px;
  height: 28px;
  border-radius: var(--radius-xs);
  border: none;
  background: transparent;
  color: var(--text3);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 0.2s;
}
.input-mode-btn svg {
  width: 16px;
  height: 16px;
}
.input-mode-btn:hover {
  color: var(--text);
}
.input-mode-btn.active {
  background: var(--bg2);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

/* ── Voice Input Area ── */
.voice-input-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  width: 100%;
}
.voice-record-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg2);
  color: var(--text2);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all 0.2s;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.voice-record-btn svg {
  width: 24px;
  height: 24px;
}
.voice-btn-text {
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
}
.voice-record-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}
.voice-record-btn.recording {
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  animation: voice-pulse 1.2s ease-in-out infinite;
}
.voice-record-btn.recording .voice-icon-mic { display: none; }
.voice-record-btn.recording .voice-icon-wave { display: block; }
.voice-record-btn.recording .voice-btn-text { color: var(--danger); }

@keyframes voice-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.3); }
  50% { box-shadow: 0 0 0 12px rgba(239, 68, 68, 0); }
}

.voice-status {
  font-size: 12px;
  color: var(--text3);
  text-align: center;
  min-height: 18px;
}

/* ── Voice Preview ── */
.voice-preview {
  padding: 12px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent-light);
  width: 100%;
  box-sizing: border-box;
}
.voice-preview-label {
  font-size: 11px;
  color: var(--accent);
  font-weight: 500;
  margin-bottom: 6px;
}
.voice-preview-text {
  font-size: 14px;
  color: var(--text);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 48px;
  max-height: 120px;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: var(--bg);
  resize: none;
  outline: none;
  font-family: inherit;
  box-sizing: border-box;
  transition: border-color 0.15s;
}
.voice-preview-text:focus {
  border-color: var(--accent);
}
.voice-preview-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}
.voice-preview-cancel {
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text2);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.15s;
}
.voice-preview-cancel:hover {
  border-color: var(--text3);
  color: var(--text);
}
.voice-preview-send {
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.15s;
}
.voice-preview-send:hover {
  opacity: 0.9;
}
.voice-preview-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Mobile voice input adjustments ── */
@media (max-width: 768px) {
  .voice-record-btn {
    width: 72px;
    height: 72px;
  }
  .voice-record-btn svg {
    width: 28px;
    height: 28px;
  }
  .voice-btn-text {
    font-size: 11px;
  }
  .voice-preview {
    padding: 10px;
  }
}

/* Dark theme early overrides (voice recording) */
[data-theme="dark"] .voice-record-btn.recording {
  background: rgba(239, 68, 68, 0.2);
}

/* ── Toast ── */
.toast-container{position:fixed;top:20px;right:20px;z-index:200;display:flex;flex-direction:column;gap:8px}
.toast{
  padding:12px 20px;border-radius:var(--radius-sm);font-size:13px;
  animation:toastIn .3s ease;box-shadow:var(--shadow-lg);max-width:360px;
  display:flex;align-items:center;gap:8px;
}
@keyframes toastIn{from{transform:translateX(20px);opacity:0}to{transform:translateX(0);opacity:1}}
.toast-error{background:#2d1515;color:#f87171;border:1px solid #3d1f1f}
.toast-success{background:#152d1e;color:#4ade80;border:1px solid #1f3d28}
.toast-info{background:#1a2535;color:#60a5fa;border:1px solid #253545}
.toast-warning{background:#2d2515;color:#fbbf24;border:1px solid #3d3019}

/* ── Confirm Dialog ── */
.modal-overlay{
  position:fixed;inset:0;background:rgba(0,0,0,.3);z-index:100;
  display:flex;align-items:center;justify-content:center;
  animation:fadeIn .15s ease;
}
@keyframes fadeIn{from{opacity:0}to{opacity:1}}
.modal{
  background:var(--bg2);border-radius:var(--radius);padding:24px;
  width:90%;max-width:400px;box-shadow:var(--shadow-lg);
}
.modal h3{font-size:16px;font-weight:600;margin-bottom:8px}
.modal p{font-size:13px;color:var(--text2);margin-bottom:20px}
.modal-actions{display:flex;gap:8px;justify-content:flex-end}
.modal-btn{
  padding:8px 20px;border-radius:var(--radius-sm);font-size:13px;font-weight:500;
  transition:var(--transition);
}
.modal-btn-cancel{background:var(--bg3);color:var(--text2)}
.modal-btn-cancel:hover{background:var(--bg4)}
.modal-btn-danger{background:var(--danger);color:#fff}
.modal-btn-danger:hover{background:#dc2626}

/* Scrollbar */
::-webkit-scrollbar{width:6px}
::-webkit-scrollbar-track{background:transparent}
::-webkit-scrollbar-thumb{background:var(--bg4);border-radius:3px}
::-webkit-scrollbar-thumb:hover{background:var(--bg5)}

/* ── Welcome Message ── */
.welcome-card{
  background:var(--bg2);border:1px solid var(--border-light);
  border-radius:var(--radius);padding:24px;margin:8px 0;
}
.welcome-card h2{font-size:18px;font-weight:700;margin-bottom:4px;display:flex;align-items:center;gap:8px}
.welcome-card h2 .emoji{font-size:24px}
.welcome-card .subtitle{font-size:13px;color:var(--text2);margin-bottom:16px}
.capabilities{display:grid;grid-template-columns:repeat(2,1fr);gap:8px}
.capability{
  display:flex;align-items:center;gap:8px;padding:8px 12px;
  border-radius:var(--radius-xs);background:var(--bg);font-size:12px;color:var(--text2);
}
.capability .cap-icon{font-size:16px}

/* ══════════════════════════════════════════════════════
   ── Agent Panel (RIGHT) ──
   ══════════════════════════════════════════════════════ */
.agent-panel{
  width:var(--agent-panel-w);min-width:0;height:100%;
  transition:width .25s ease,min-width .25s ease;
  background:var(--bg2);border-left:1px solid var(--border);
  display:flex;flex-direction:column;z-index:15;
  overflow:hidden;
  position:relative;
}
.agent-panel.collapsed{
  width:52px;min-width:52px;
}
.agent-panel.collapsed .agent-panel-header h3,
.agent-panel.collapsed .agent-list,
.agent-panel.collapsed .agent-create-btn,
.agent-panel.collapsed .agent-collapse-btn span{display:none}
.agent-panel.collapsed .agent-panel-footer{border-top:none;padding:4px}
.agent-toggle{
  position:absolute;top:50%;left:-14px;transform:translateY(-50%);
  width:28px;height:28px;border-radius:50%;background:var(--bg2);
  border:1px solid var(--border);display:grid;place-items:center;
  cursor:pointer;z-index:25;color:var(--text2);font-size:14px;
  transition:all .15s;
}
.agent-toggle:hover{background:var(--accent);color:#fff;border-color:var(--accent)}

.agent-panel-header{
  padding:16px 16px 12px;border-bottom:1px solid var(--border-light);
  display:flex;align-items:center;gap:10px;min-height:var(--header-h);
  flex-shrink:0;
}
.agent-panel-header h3{
  flex:1;font-size:15px;font-weight:700;display:flex;align-items:center;gap:8px;
  white-space:nowrap;
}
.agent-panel-header h3 .agents-emoji{font-size:18px}

.agent-create-btn{
  width:30px;height:30px;border-radius:var(--radius-xs);
  background:var(--accent);color:#fff;
  display:grid;place-items:center;flex-shrink:0;
  transition:var(--transition);font-size:16px;font-weight:600;
}
.agent-create-btn:hover{background:var(--accent2);transform:scale(1.05)}
.agent-create-btn svg{width:16px;height:16px}
.agent-manage-btn{
  width:30px;height:30px;border-radius:var(--radius-xs);
  background:var(--bg3);color:var(--text2);
  display:grid;place-items:center;flex-shrink:0;
  transition:var(--transition);font-size:16px;font-weight:600;
  border:1px solid var(--border);
}
.agent-manage-btn:hover{background:var(--bg4);color:var(--accent);transform:scale(1.05)}
.agent-manage-btn svg{width:16px;height:16px}

/* ── Agent Panel Sections ── */
.rp-section{border-bottom:1px solid var(--border-light);flex-shrink:0}
#rpDeptSection,#rpRecentSection,#rpGroupSection{border-bottom:1px solid var(--border-light)}
#rpHelperAgent{border-top:1px solid var(--border-light);flex-shrink:0}
.rp-section-header{
  display:flex;align-items:center;justify-content:space-between;
  padding:10px 14px 6px;cursor:pointer;user-select:none;
}
.rp-section-title{font-size:12px;font-weight:600;color:var(--text2);display:flex;align-items:center;gap:6px}
.rp-section-body{padding:0 8px 8px}
.rp-section-toggle{
  width:18px;height:18px;border-radius:3px;display:inline-grid;place-items:center;
  font-size:10px;color:var(--text3);flex-shrink:0;transition:var(--transition);
}
.rp-section-toggle:hover{background:var(--bg4);color:var(--text)}
.rp-section-toggle.expanded{transform:rotate(90deg)}
.rp-section-action-btn{
  width:20px;height:20px;border-radius:3px;border:none;
  background:transparent;color:var(--text3);
  display:inline-grid;place-items:center;flex-shrink:0;
  cursor:pointer;transition:var(--transition);
}
.rp-section-action-btn:hover{background:var(--bg4);color:var(--accent)}

/* Master Agent Card (全权Agent) */
.rp-master-card{
  display:flex;align-items:center;gap:12px;padding:14px;
  border-radius:var(--radius);cursor:pointer;transition:var(--transition);
  border:2px solid transparent;margin:8px 12px;
  background:linear-gradient(135deg,var(--accent-light),var(--bg));
}
.rp-master-card:hover{border-color:var(--accent);background:var(--accent-light)}
.rp-master-card.active{border-color:var(--accent);background:var(--accent-light);box-shadow:0 0 16px rgba(217,119,6,.15)}
.rp-master-avatar{
  width:44px;height:44px;border-radius:12px;flex-shrink:0;
  display:grid;place-items:center;font-size:22px;color:#fff;
  background:linear-gradient(135deg,var(--accent),var(--accent-dark));
}
.rp-master-info{flex:1;min-width:0}
.rp-master-name{font-size:14px;font-weight:700;color:var(--text)}
.rp-master-desc{font-size:11px;color:var(--text3);margin-top:2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}

/* Recent Agents (最近Agent) */
.rp-recent-grid{
  display:flex;gap:8px;padding:8px 12px;overflow-x:auto;flex-shrink:0;
}
.rp-recent-chip{
  display:flex;align-items:center;gap:6px;padding:6px 10px 6px 6px;
  border-radius:20px;background:var(--bg);border:1px solid var(--border);
  cursor:pointer;transition:var(--transition);flex-shrink:0;white-space:nowrap;
}
.rp-recent-chip:hover{border-color:var(--accent);background:var(--accent-light)}
.rp-recent-chip.active{border-color:var(--accent);background:var(--accent-light)}
.rp-recent-chip-avatar{
  width:24px;height:24px;border-radius:50%;display:grid;place-items:center;
  font-size:12px;color:#fff;flex-shrink:0;
}
.rp-recent-chip-name{font-size:12px;font-weight:500;color:var(--text2)}

/* Config Helper (配置助手) - fixed at bottom */
.rp-helper-card{
  display:flex;align-items:center;gap:12px;padding:12px 14px;
  border-radius:var(--radius);cursor:pointer;transition:var(--transition);
  border:1px solid transparent;margin:8px 12px;
  background:var(--bg);
}
.rp-helper-card:hover{border-color:var(--accent);background:var(--accent-light)}
.rp-helper-card.active{border-color:var(--accent);background:var(--accent-light)}
.rp-helper-avatar{
  width:36px;height:36px;border-radius:10px;flex-shrink:0;
  display:grid;place-items:center;font-size:18px;color:#fff;
  background:linear-gradient(135deg,#f59e0b,#f97316);
}

/* Department tree in right panel */
.rp-dept-item{
  display:flex;align-items:center;gap:8px;padding:8px 12px;
  border-radius:var(--radius-xs);cursor:pointer;transition:var(--transition);
  font-size:13px;
}
.rp-dept-item:hover{background:var(--bg3)}
.rp-dept-item.active{background:var(--accent-light);color:var(--accent)}
.rp-dept-agent-item{
  display:flex;align-items:center;gap:8px;padding:6px 12px 6px calc(12px + var(--depth, 0) * 20px);
  border-radius:var(--radius-xs);cursor:pointer;transition:var(--transition);
  font-size:13px;
}
.rp-dept-agent-item:hover{background:var(--bg3)}
.rp-dept-agent-item.active{background:var(--accent-light);color:var(--accent)}
.rp-dept-agent-avatar{
  width:24px;height:24px;border-radius:6px;display:grid;place-items:center;
  font-size:12px;color:#fff;flex-shrink:0;
}

/* [v1.23.51] Department group chat button */
.rp-dept-group-btn{
  margin-left:auto;flex-shrink:0;padding:2px 6px;border-radius:10px;
  font-size:11px;line-height:1;border:1px solid var(--border);
  background:var(--bg2);cursor:pointer;color:var(--text2);
  transition:var(--transition);
}
.rp-dept-group-btn:hover{background:var(--accent);color:#fff;border-color:var(--accent)}

/* Agent list */
.agent-list{flex:1;overflow-y:auto;padding:0}

.agent-card{
  display:flex;align-items:flex-start;gap:10px;padding:10px 12px;
  border-radius:var(--radius-sm);cursor:pointer;transition:var(--transition);
  position:relative;margin-bottom:4px;
  border:1px solid transparent;
}
.agent-card:hover{background:var(--bg3);border-color:var(--border-light)}
.agent-card.active{
  background:var(--accent-light);
  border-color:var(--accent);
}
.agent-card.active::after{
  content:'';position:absolute;right:0;top:50%;transform:translateY(-50%);
  width:3px;height:24px;background:var(--accent);border-radius:2px 0 0 2px;
}

/* Agent tree indent */
.agent-tree-children{margin-left:16px;border-left:1px dashed var(--border-light);padding-left:4px}
.agent-tree-toggle{
  width:18px;height:18px;border-radius:3px;
  display:inline-grid;place-items:center;font-size:10px;
  color:var(--text3);flex-shrink:0;transition:var(--transition)
}
.agent-tree-toggle:hover{background:var(--bg4);color:var(--text)}
.agent-tree-toggle.expanded{transform:rotate(90deg)}

/* Execution mode badge */
.exec-badge{
  font-size:9px;font-weight:600;padding:1px 5px;border-radius:4px;
  white-space:nowrap;flex-shrink:0;
}
.exec-badge.local{background:rgba(74,222,128,.15);color:#4ade80}
.exec-badge.sandbox{background:rgba(251,191,36,.15);color:#fbbf24}

/* Agent add-child button (shows on hover) */
.agent-add-child-btn{
  opacity:0;position:absolute;bottom:2px;right:6px;
  width:20px;height:20px;border-radius:4px;
  display:grid;place-items:center;font-size:12px;
  color:var(--text3);transition:var(--transition)
}
.agent-card:hover .agent-add-child-btn{opacity:1}
.agent-add-child-btn:hover{background:var(--accent-light);color:var(--accent)}

.agent-avatar{
  width:38px;height:38px;border-radius:10px;flex-shrink:0;
  display:grid;place-items:center;font-size:16px;font-weight:700;color:#fff;
  position:relative;
}
.agent-avatar .status-dot{
  position:absolute;bottom:-1px;right:-1px;width:11px;height:11px;
  border-radius:50%;background:var(--ok);border:2px solid var(--bg2);
}

.agent-info{flex:1;min-width:0;padding-top:2px}
.agent-name{
  font-size:13px;font-weight:600;color:var(--text);
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
  display:flex;align-items:center;gap:6px;
}
.agent-name .model-tag{
  font-size:9px;font-weight:500;padding:1px 6px;border-radius:8px;
  background:var(--bg3);color:var(--text3);white-space:nowrap;
  max-width:90px;overflow:hidden;text-overflow:ellipsis;
}
.agent-card.active .agent-name{color:var(--accent-dark)}
.agent-desc{
  font-size:11px;color:var(--text3);margin-top:2px;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
  line-height:1.4;
}

.agent-settings-btn{
  position:absolute;top:10px;right:8px;
  width:26px;height:26px;border-radius:6px;
  display:grid;place-items:center;
  color:var(--text3);opacity:0;
  transition:var(--transition);
}
.agent-card:hover .agent-settings-btn{opacity:1}
.agent-settings-btn:hover{background:var(--bg4);color:var(--text2)}
.agent-settings-btn svg{width:14px;height:14px}
.agent-chat-btn{
  position:absolute;top:10px;right:38px;
  width:26px;height:26px;border-radius:6px;
  display:grid;place-items:center;
  color:var(--text3);opacity:0;
  transition:var(--transition);border:none;background:none;cursor:pointer;
}
.agent-card:hover .agent-chat-btn{opacity:1}
.agent-chat-btn:hover{background:var(--success);color:#fff}
.agent-chat-btn svg{width:14px;height:14px}

/* Agent panel footer / collapse toggle */
.agent-panel-footer{
  padding:10px 16px;border-top:1px solid var(--border-light);
  flex-shrink:0;
}
.agent-collapse-btn{
  width:100%;padding:8px;border-radius:var(--radius-xs);
  display:flex;align-items:center;justify-content:center;gap:6px;
  font-size:12px;color:var(--text3);
  transition:var(--transition);
}
.agent-collapse-btn:hover{background:var(--bg3);color:var(--text2)}
.agent-collapse-btn svg{width:14px;height:14px}

/* ── Create / Edit Agent Modal ── */
.agent-modal{
  background:var(--bg2);border-radius:var(--radius);padding:28px;
  width:90%;max-width:520px;box-shadow:var(--shadow-lg);
  max-height:85vh;overflow-y:auto;
}
.agent-modal h3{font-size:18px;font-weight:700;margin-bottom:4px;display:flex;align-items:center;gap:8px}
.agent-modal .modal-subtitle{font-size:12px;color:var(--text3);margin-bottom:20px}

.agent-form-group{margin-bottom:16px}
.agent-form-group label{
  display:block;font-size:12px;font-weight:600;color:var(--text2);
  margin-bottom:6px;text-transform:uppercase;letter-spacing:.5px;
}
.agent-form-group input,
.agent-form-group textarea,
.agent-form-group select{
  width:100%;padding:10px 14px;border-radius:var(--radius-xs);
  border:1px solid var(--border);background:var(--bg);font-size:13px;
  outline:none;transition:border-color .2s;color:var(--text);
}
.agent-form-group input:focus,
.agent-form-group textarea:focus,
.agent-form-group select:focus{border-color:var(--accent)}
.agent-form-group textarea{resize:vertical;min-height:80px;line-height:1.5}
.agent-form-group .hint{font-size:11px;color:var(--text3);margin-top:4px}

.agent-avatar-picker{
  display:flex;gap:8px;margin-top:6px;flex-wrap:wrap;
}
.agent-avatar-option{
  width:36px;height:36px;border-radius:8px;
  display:grid;place-items:center;font-size:16px;cursor:pointer;
  border:2px solid transparent;transition:var(--transition);
}
.agent-avatar-option:hover{transform:scale(1.1)}
.agent-avatar-option.selected{border-color:var(--accent);box-shadow:0 0 0 2px var(--accent-light)}

.agent-modal-actions{
  display:flex;gap:8px;justify-content:flex-end;margin-top:24px;
  padding-top:16px;border-top:1px solid var(--border-light);
}
.agent-modal-btn{
  padding:10px 24px;border-radius:var(--radius-sm);font-size:13px;font-weight:600;
  transition:var(--transition);
}
.agent-modal-btn-cancel{background:var(--bg3);color:var(--text2)}
.agent-modal-btn-cancel:hover{background:var(--bg4)}
.agent-modal-btn-primary{background:var(--accent);color:#fff}
.agent-modal-btn-primary:hover{background:var(--accent2)}
.agent-modal-btn-delete{background:var(--danger);color:#fff;margin-right:auto}
.agent-modal-btn-delete:hover{background:#dc2626}

/* ── Active agent indicator in header ── */
.active-agent-badge{
  display:inline-flex;align-items:center;gap:6px;
  padding:3px 10px 3px 6px;border-radius:20px;
  background:var(--accent-light);font-size:12px;color:var(--accent);
  font-weight:500;
}
.active-agent-badge .badge-avatar{
  width:20px;height:20px;border-radius:50%;
  display:grid;place-items:center;font-size:10px;color:#fff;
}

/* ── Agent color themes ── */
.agent-color-0{background:linear-gradient(135deg,#6366f1,#8b5cf6)}
.agent-color-1{background:linear-gradient(135deg,#ec4899,#f43f5e)}
.agent-color-2{background:linear-gradient(135deg,#f59e0b,#f97316)}
.agent-color-3{background:linear-gradient(135deg,#10b981,#059669)}
.agent-color-4{background:linear-gradient(135deg,#3b82f6,#0ea5e9)}
.agent-color-5{background:linear-gradient(135deg,#8b5cf6,#a855f7)}
.agent-color-6{background:linear-gradient(135deg,#ef4444,#dc2626)}
.agent-color-7{background:linear-gradient(135deg,#14b8a6,#06b6d4)}

/* ── No agents empty state ── */
.agent-empty{
  flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;
  padding:24px 16px;color:var(--text3);text-align:center;
}
.agent-empty-icon{font-size:40px;margin-bottom:10px;opacity:.4}
.agent-empty-text{font-size:12px;line-height:1.5}

/* ── Tree node indent per depth ── */
.agent-tree-node[data-depth="1"]{margin-left:12px}
.agent-tree-node[data-depth="2"]{margin-left:24px}
.agent-tree-node[data-depth="3"]{margin-left:36px}
.agent-tree-node[data-depth="4"]{margin-left:48px}

/* ── Platform badge in agent cards ── */
.platform-badge{
  font-size:11px;white-space:nowrap;flex-shrink:0;
  display:inline-flex;align-items:center;
}

/* ── Platform Management Modal ── */
.platform-modal{
  background:var(--bg2);border-radius:var(--radius);padding:28px;
  width:92%;max-width:680px;box-shadow:var(--shadow-lg);
  max-height:88vh;overflow-y:auto;
}
.platform-modal h3{font-size:18px;font-weight:700;margin-bottom:4px}
.platform-modal .modal-subtitle{font-size:12px;color:var(--text3);margin-bottom:20px}

.platform-card{
  padding:16px;border-radius:var(--radius-sm);
  background:var(--bg);border:1px solid var(--border-light);
  margin-bottom:12px;transition:var(--transition);
}
.platform-card:hover{border-color:var(--accent)}
.platform-card-header{
  display:flex;align-items:center;gap:12px;margin-bottom:12px;
}
.platform-card-icon{
  width:42px;height:42px;border-radius:10px;
  display:grid;place-items:center;font-size:20px;flex-shrink:0;
  background:var(--bg3);
}
.platform-card-info{flex:1;min-width:0}
.platform-card-name{font-size:15px;font-weight:600;color:var(--text)}
.platform-card-desc{font-size:11px;color:var(--text3);margin-top:2px}
.platform-card-actions{
  display:flex;gap:8px;align-items:center;flex-shrink:0;
}
.platform-toggle{
  position:relative;width:44px;height:24px;border-radius:12px;
  background:var(--bg4);cursor:pointer;transition:var(--transition);
  border:none;padding:0;
}
.platform-toggle.on{background:var(--ok)}
.platform-toggle::after{
  content:'';position:absolute;top:2px;left:2px;width:20px;height:20px;
  border-radius:50%;background:#fff;transition:var(--transition);
  box-shadow:0 1px 3px rgba(0,0,0,.2);
}
.platform-toggle.on::after{left:22px}
.platform-card-btn{
  width:32px;height:32px;border-radius:var(--radius-xs);
  display:grid;place-items:center;font-size:14px;
  transition:var(--transition);color:var(--text3);
}
.platform-card-btn:hover{background:var(--bg3);color:var(--text)}
.platform-card-btn.delete:hover{background:#fef2f2;color:var(--danger)}

.platform-form{padding:14px;border-radius:var(--radius-xs);
  background:var(--bg2);border:1px solid var(--border-light);
  margin-top:10px;
}
.platform-form-row{
  display:flex;gap:10px;margin-bottom:10px;
}
.platform-form-row .agent-form-group{flex:1;margin-bottom:0}
.platform-form-row .agent-form-group:last-child{margin-bottom:0}

.platform-bound-agents{
  margin-top:12px;padding:10px 12px;border-radius:var(--radius-xs);
  background:var(--bg2);border:1px solid var(--border-light);
  font-size:12px;color:var(--text2);
}
.platform-bound-agents .agent-chip{
  display:inline-flex;align-items:center;gap:4px;
  padding:3px 10px;border-radius:12px;background:var(--accent-light);
  color:var(--accent);font-size:11px;font-weight:500;margin:2px 4px 2px 0;
}

.platform-empty{
  text-align:center;padding:40px 20px;color:var(--text3);
}
.platform-empty-icon{font-size:48px;margin-bottom:12px;opacity:.3}
.platform-empty-text{font-size:13px;margin-bottom:16px}
.platform-add-grid{
  display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:10px;
}
.platform-add-option{
  padding:16px 12px;border-radius:var(--radius-sm);
  background:var(--bg);border:1px dashed var(--border);
  cursor:pointer;text-align:center;transition:var(--transition);
}
.platform-add-option:hover{border-color:var(--accent);background:var(--accent-light);color:var(--accent)}
.platform-add-option .icon{font-size:28px;margin-bottom:6px}
.platform-add-option .name{font-size:12px;font-weight:600}

/* ── Agent form section (e.g. platform binding) ── */
.agent-form-section{
  margin:16px 0;padding:14px 16px;border-radius:var(--radius-sm);
  background:var(--bg);border:1px solid var(--border-light);
}
.agent-form-section-title{
  font-size:12px;font-weight:700;color:var(--text);
  margin-bottom:12px;text-transform:uppercase;letter-spacing:.5px;
}

.config-action-btn{
  padding:10px 18px;border-radius:var(--radius-sm);font-size:13px;font-weight:500;
  display:flex;align-items:center;gap:8px;transition:var(--transition);
  border:1px solid var(--border);
}
.config-action-btn:hover{border-color:var(--accent);color:var(--accent);background:var(--accent-light)}
.config-action-btn.primary{background:var(--accent);color:#fff;border-color:var(--accent)}
.config-action-btn.primary:hover{background:var(--accent2)}
.config-action-btn.danger{border-color:var(--danger);color:var(--danger)}
.config-action-btn.danger:hover{background:var(--danger);color:#fff}
.config-action-btn svg{width:16px;height:16px}

.config-action-btn:disabled{opacity:.5;cursor:not-allowed}

/* ══════════════════════════════════════════════════════
   ── Exec Mode Toggle (Local/Sandbox) + Global Lock ──
   ══════════════════════════════════════════════════════ */
.exec-mode-toggle{
  display:flex;align-items:center;gap:8px;
  padding:4px 10px;border-radius:var(--radius-sm);
  border:1px solid var(--border);background:var(--bg2);
  font-size:12px;
}
.exec-mode-info{
  display:flex;align-items:center;gap:5px;
}
.exec-mode-dot{
  width:8px;height:8px;border-radius:50%;flex-shrink:0;
  transition:background .2s;
}
.exec-mode-dot.local{background:var(--ok);box-shadow:0 0 6px rgba(16,185,129,.4)}
.exec-mode-dot.sandbox{background:var(--warn);box-shadow:0 0 6px rgba(245,158,11,.4)}
.exec-mode-label{font-weight:500;color:var(--text2)}
.exec-mode-btn{
  padding:4px 10px;border-radius:var(--radius-xs);
  font-size:11px;font-weight:600;
  background:var(--bg3);color:var(--text2);
  border:1px solid var(--border);
  transition:var(--transition);white-space:nowrap;
}
.exec-mode-btn:hover{background:var(--accent-light);color:var(--accent);border-color:var(--accent)}
.exec-mode-btn.active-local{
  background:#dcfce7;color:#166534;border-color:#86efac;
}
.exec-mode-btn.active-local:hover{background:#bbf7d0}

/* Lock indicator */
.lock-indicator{
  display:flex;align-items:center;gap:4px;
  padding:4px 8px;border-radius:var(--radius-xs);
  background:#fef2f2;border:1px solid #fecaca;
  font-size:11px;color:#991b1b;font-weight:500;
  cursor:pointer;transition:var(--transition);
}
.lock-indicator.hidden{display:none}
.lock-indicator:hover{background:#fee2e2}
.lock-icon{font-size:12px}

/* ══════════════════════════════════════════════════════
   ── Large Text Warning Dialog ──
   ══════════════════════════════════════════════════════ */
.largetext-modal{
  background:var(--bg2);border-radius:var(--radius);padding:28px;
  width:90%;max-width:480px;box-shadow:var(--shadow-lg);
  animation:fadeIn .15s ease;
}
.largetext-modal h3{font-size:16px;font-weight:700;margin-bottom:4px;display:flex;align-items:center;gap:8px}
.largetext-modal .modal-subtitle{font-size:12px;color:var(--text3);margin-bottom:20px}
.largetext-stats{
  display:grid;grid-template-columns:1fr 1fr 1fr;gap:8px;margin-bottom:20px;
}
.largetext-stat{
  padding:10px;border-radius:var(--radius-xs);
  background:var(--bg);text-align:center;
}
.largetext-stat-value{font-size:20px;font-weight:700;color:var(--text)}
.largetext-stat-label{font-size:10px;color:var(--text3);margin-top:2px}
.largetext-stat-value.warn{color:var(--warn)}
.largetext-options{display:flex;flex-direction:column;gap:8px;margin-bottom:20px}
.largetext-option{
  padding:14px 16px;border-radius:var(--radius-sm);
  border:2px solid var(--border);background:var(--bg);
  cursor:pointer;transition:var(--transition);
}
.largetext-option:hover{border-color:var(--accent);background:var(--accent-light)}
.largetext-option.selected{border-color:var(--accent);background:var(--accent-light)}
.largetext-option-title{font-size:13px;font-weight:600;color:var(--text);margin-bottom:4px}
.largetext-option-desc{font-size:11px;color:var(--text2);line-height:1.5}
.largetext-actions{display:flex;gap:8px;justify-content:flex-end}
.largetext-btn{
  padding:8px 20px;border-radius:var(--radius-sm);font-size:13px;font-weight:500;
  transition:var(--transition);
}
.largetext-btn-cancel{background:var(--bg3);color:var(--text2)}
.largetext-btn-cancel:hover{background:var(--bg4)}
.largetext-btn-confirm{background:var(--accent);color:#fff}
.largetext-btn-confirm:hover{background:var(--accent2)}

/* [v2.3] 移除 Mode Toggle (聊天/执行) CSS，固定执行模式 */

/* ══════════════════════════════════════════════════════
   ── Task Plan Panel ──
   ══════════════════════════════════════════════════════ */
.task-panel{
  max-width:900px;margin:0 auto 10px;
  border:1px solid var(--border);border-radius:var(--radius);
  background:var(--bg2);overflow:hidden;
  transition:all .25s ease;
  box-shadow:var(--shadow-sm);
}
.task-panel.task-auto-fade{
  transition:opacity 1s ease;
}
.task-panel.hidden{display:none}
.task-panel-header{
  display:flex;align-items:center;gap:8px;padding:8px 14px;
  background:var(--bg3);cursor:pointer;user-select:none;
  transition:var(--transition);
}
.task-panel-header:hover{background:var(--bg4)}
.task-panel-header .tp-icon{font-size:14px}
.task-panel-header .tp-title{flex:1;font-size:12px;font-weight:600;color:var(--text2);text-transform:uppercase;letter-spacing:.5px}
.task-panel-header .tp-count{
  font-size:11px;color:var(--text3);background:var(--bg);padding:2px 8px;
  border-radius:10px;font-weight:500;
}
.task-panel-header .tp-toggle{
  width:22px;height:22px;border-radius:4px;display:grid;place-items:center;
  color:var(--text3);transition:var(--transition);
}
.task-panel-header .tp-toggle:hover{background:var(--bg4);color:var(--text)}
.task-panel-header .tp-toggle svg{width:14px;height:14px;transition:transform .25s ease}
.task-panel-header .tp-toggle.expanded svg{transform:rotate(180deg)}
.task-panel-body{
  max-height:0;overflow:hidden;transition:max-height .4s cubic-bezier(.4,0,.2,1);
}
.task-panel-body.expanded{max-height:400px;overflow-y:auto}
.task-list{padding:6px 0}
.task-item{
  display:flex;align-items:center;gap:8px;padding:6px 14px;
  transition:var(--transition);position:relative;
}
.task-item:hover{background:var(--bg3)}
.task-checkbox{
  width:18px;height:18px;border-radius:5px;border:2px solid var(--bg5);
  display:grid;place-items:center;flex-shrink:0;cursor:pointer;
  transition:var(--transition);font-size:11px;color:transparent;
}
.task-checkbox:hover{border-color:var(--accent)}
.task-checkbox.checked{
  background:var(--ok);border-color:var(--ok);color:#fff}
.task-text{
  flex:1;font-size:13px;color:var(--text);line-height:1.4;transition:var(--transition);
}
.task-text.done{text-decoration:line-through;color:var(--text3);opacity:.7}
.task-item.task-done{opacity:.75}
.task-item.task-running .task-text{color:var(--accent);font-weight:500}
.task-checkbox.running{border-color:var(--accent);animation:pulse-border 1.5s infinite}
@keyframes pulse-border{0%,100%{border-color:var(--accent)}50%{border-color:transparent}}
.task-delete{
  width:22px;height:22px;border-radius:4px;display:grid;place-items:center;
  font-size:13px;color:var(--text3);opacity:0;transition:var(--transition);flex-shrink:0;
}
.task-item:hover .task-delete{opacity:1}
.task-delete:hover{background:#fef2f2;color:var(--danger)}
.task-empty{
  padding:20px;text-align:center;color:var(--text3);font-size:12px;
}
.task-empty-icon{font-size:24px;margin-bottom:6px;opacity:.4}
.task-add-row{
  display:flex;gap:6px;padding:8px 12px;border-top:1px solid var(--border-light);
}
.task-add-input{
  flex:1;padding:7px 10px;border:1px solid var(--border);border-radius:var(--radius-xs);
  background:var(--bg);font-size:12px;outline:none;transition:border-color .2s;
}
.task-add-input:focus{border-color:var(--accent)}
.task-add-input::placeholder{color:var(--text3)}
.task-add-btn{
  padding:7px 14px;border-radius:var(--radius-xs);background:var(--accent);color:#fff;
  font-size:12px;font-weight:500;transition:var(--transition);white-space:nowrap;
}
.task-add-btn:hover{background:var(--accent2)}
.task-add-btn:disabled{opacity:.4;cursor:default}

/* ══════════════════════════════════════════════════════
   ── Group Chat ──
   ══════════════════════════════════════════════════════ */
.sidebar-scroll{flex:1;overflow-y:auto;display:flex;flex-direction:column}

/* Groups Section in Sidebar */
.groups-section{border-top:1px solid var(--border-light);flex-shrink:0}
.groups-section-header{
  display:flex;align-items:center;justify-content:space-between;
  padding:10px 16px 6px;cursor:pointer;user-select:none;
}
.groups-section-title{font-size:12px;font-weight:600;color:var(--text2);display:flex;align-items:center;gap:6px}
.group-create-btn{
  width:24px;height:24px;border-radius:6px;
  display:grid;place-items:center;
  color:var(--text3);transition:var(--transition);font-size:14px;
}
.group-create-btn:hover{background:var(--bg3);color:var(--accent)}
.group-create-btn svg{width:14px;height:14px}
.group-list{padding:0 8px 8px}

.group-item{
  display:flex;align-items:center;gap:10px;padding:10px 12px;
  border-radius:var(--radius-sm);cursor:pointer;transition:var(--transition);
  position:relative;
}
.group-item:hover{background:var(--bg3)}
.group-item.active{background:var(--accent-light);color:var(--accent2)}
.group-item.active::before{
  content:'';position:absolute;left:0;top:50%;transform:translateY(-50%);
  width:3px;height:24px;background:var(--accent);border-radius:0 2px 2px 0;
}
.group-icon{
  width:32px;height:32px;border-radius:8px;background:var(--bg3);
  display:grid;place-items:center;flex-shrink:0;font-size:14px;
}
.group-item.active .group-icon{background:var(--accent-light);color:var(--accent)}
.group-info{flex:1;min-width:0}
.group-name{font-size:13px;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.group-preview{font-size:11px;color:var(--text3);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-top:1px}
.group-badge{
  font-size:10px;padding:1px 7px;border-radius:10px;
  background:var(--bg3);color:var(--text3);font-weight:500;flex-shrink:0;
}
.group-item.active .group-badge{background:var(--accent-light);color:var(--accent)}
.group-delete{
  opacity:0;position:absolute;right:8px;top:50%;transform:translateY(-50%);
  width:24px;height:24px;border-radius:4px;display:grid;place-items:center;
  background:var(--bg2);transition:var(--transition);font-size:12px;color:var(--text3);
  pointer-events:none;
}
.group-item:hover .group-delete{opacity:1;pointer-events:auto}
.group-delete:hover{background:var(--danger);color:#fff}

/* Group Chat Messages */
.group-msg-system{
  text-align:center;padding:8px 0;
  font-size:12px;color:var(--text3);
  animation:msgIn .25s ease-out;
}
.group-msg-row{display:flex;gap:10px;animation:msgIn .25s ease-out;align-items:flex-start}
.group-msg-row>:nth-child(2){flex:1;min-width:0}
.group-msg-avatar{
  width:32px;height:32px;border-radius:8px;flex-shrink:0;
  display:grid;place-items:center;font-size:12px;
}
.group-msg-name{
  font-size:11px;font-weight:600;color:var(--text2);margin-bottom:4px;
  display:flex;align-items:center;gap:6px;
}
.group-msg-name .role-badge{
  font-size:9px;padding:1px 5px;border-radius:4px;
  background:var(--bg3);color:var(--text3);font-weight:500;
}
.group-msg-bubble{
  max-width:95%;padding:12px 16px;border-radius:var(--radius);
  font-size:14px;line-height:1.5;word-break:break-word;
  box-shadow:var(--shadow-sm);background:var(--bot-bubble);color:var(--bot-text);
  border:1px solid var(--border-light);
  border-left:3px solid var(--accent);
  overflow-wrap:break-word;overflow:hidden;position:relative;
  user-select:text;-webkit-user-select:text;
}
.group-msg-bubble p{margin-bottom:8px}
.group-msg-bubble p:last-child{margin-bottom:0}
.group-msg-bubble code{
  background:rgba(0,0,0,.06);padding:2px 6px;border-radius:4px;
  font-family:'SF Mono','Fira Code','Cascadia Code',monospace;font-size:12.5px;
}
.group-msg-bubble pre{
  background:var(--bg3);color:var(--text);padding:14px 16px;border-radius:var(--radius-sm);
  overflow-x:auto;margin:8px 0;font-size:12.5px;line-height:1.5;
  font-family:'SF Mono','Fira Code','Cascadia Code',monospace;
}
.group-msg-bubble pre code{background:none;padding:0;font-size:inherit}
.group-msg-bubble strong{font-weight:600}
.group-msg-bubble em{font-style:italic}
.group-msg-bubble ul,.group-msg-bubble ol{padding-left:20px;margin:6px 0}
.group-msg-bubble li{margin:3px 0}
.group-msg-time{font-size:10px;color:var(--text3);margin-top:4px}

/* Group Modal */
.group-modal{
  background:var(--bg2);border-radius:var(--radius);padding:28px;
  width:90%;max-width:560px;box-shadow:var(--shadow-lg);
  max-height:85vh;overflow-y:auto;
}
.group-modal h3{font-size:18px;font-weight:700;margin-bottom:4px;display:flex;align-items:center;gap:8px}
.group-modal .modal-subtitle{font-size:12px;color:var(--text3);margin-bottom:20px}

/* Group member list in settings */
.group-member-item{
  display:flex;align-items:center;gap:10px;padding:10px 0;
  border-bottom:1px solid var(--border-light);
}
.group-member-item:last-child{border-bottom:none}
.group-member-info{flex:1;min-width:0}
.group-member-name{font-size:13px;font-weight:600;display:flex;align-items:center;gap:6px}
.group-member-role{
  font-size:10px;padding:1px 6px;border-radius:4px;font-weight:500;
}
.group-member-role.owner{background:#fef3c7;color:#92400e}
.group-member-role.admin{background:#dbeafe;color:#1e40af}
.group-member-role.member{background:var(--bg3);color:var(--text3)}
.group-member-remove{
  width:28px;height:28px;border-radius:6px;display:grid;place-items:center;
  color:var(--text3);transition:var(--transition);font-size:14px;
}
.group-member-remove:hover:not(:disabled){background:#fef2f2;color:var(--danger)}
.group-member-remove:disabled{opacity:.3;cursor:not-allowed}

/* Group color picker */
.color-picker-row{display:flex;gap:8px;flex-wrap:wrap;margin-top:6px}
.color-option{
  width:32px;height:32px;border-radius:8px;cursor:pointer;
  border:2px solid transparent;transition:var(--transition);
}
.color-option:hover{transform:scale(1.1)}
.color-option.selected{border-color:var(--accent);box-shadow:0 0 0 2px var(--accent-light)}

/* Group member picker in create modal */
.group-member-picker{max-height:200px;overflow-y:auto;padding:4px 0}
.group-member-pick-item{
  display:flex;align-items:center;gap:8px;padding:8px 10px;
  border-radius:var(--radius-xs);cursor:pointer;transition:var(--transition);
}
.group-member-pick-item:hover{background:var(--bg3)}
.group-member-pick-item input[type=checkbox]{width:16px;height:16px;accent-color:var(--accent)}
.group-member-pick-item .pick-agent-info{flex:1;min-width:0}
.group-member-pick-item .pick-agent-name{font-size:13px;font-weight:500}
.group-member-pick-item .pick-agent-desc{font-size:11px;color:var(--text3)}

/* ══════════════════════════════════════════════════════
   ── Setup Wizard ──
   ══════════════════════════════════════════════════════ */
.setup-wizard-overlay{
  position:fixed;inset:0;
  background:rgba(15,17,23,.85);
  backdrop-filter:blur(8px);
  z-index:500;
  display:flex;align-items:center;justify-content:center;
  animation:fadeIn .3s ease;
}
.setup-wizard{
  background:var(--bg2);border-radius:var(--radius);padding:40px;
  width:90%;max-width:600px;max-height:90vh;overflow-y:auto;
  box-shadow:var(--shadow-lg);animation:slideUp .4s ease;
  text-align:center;
}
@keyframes slideUp{
  from{transform:translateY(30px);opacity:0}
  to{transform:translateY(0);opacity:1}
}
.setup-wizard h2{
  font-size:24px;font-weight:700;margin-bottom:8px;
  display:flex;align-items:center;justify-content:center;gap:8px;
}
.setup-wizard .setup-subtitle{
  font-size:14px;color:var(--text2);margin-bottom:24px;line-height:1.6;
}
.setup-wizard .setup-desc{
  font-size:13px;color:var(--text3);margin-bottom:20px;line-height:1.7;
  text-align:left;
}

/* Setup wizard step indicator */
.setup-steps{
  display:flex;gap:8px;justify-content:center;margin-bottom:28px;
}
.setup-step-dot{
  width:8px;height:8px;border-radius:50%;background:var(--bg4);
  transition:var(--transition);
}
.setup-step-dot.active{background:var(--accent);width:24px;border-radius:4px}
.setup-step-dot.done{background:var(--ok)}

/* Provider cards */
.provider-card{
  border:2px solid var(--border);border-radius:var(--radius-sm);
  padding:16px;cursor:pointer;transition:var(--transition);
  text-align:left;margin-bottom:10px;
}
.provider-card:hover{border-color:var(--accent);background:var(--accent-light)}
.provider-card.selected{border-color:var(--accent);background:var(--accent-light)}
.provider-card .provider-icon{font-size:24px;margin-bottom:8px}
.provider-card .provider-name{font-size:14px;font-weight:600;margin-bottom:4px}
.provider-card .provider-desc{font-size:12px;color:var(--text3)}

/* Setup form */
.setup-form{text-align:left}
.setup-form .form-group{margin-bottom:16px}
.setup-form label{
  display:block;font-size:12px;font-weight:600;
  color:var(--text2);margin-bottom:6px;
}
.setup-form input,.setup-form select{
  width:100%;padding:10px 14px;border-radius:var(--radius-xs);
  border:1px solid var(--border);background:var(--bg);font-size:13px;
  outline:none;color:var(--text);
}
.setup-form input:focus,.setup-form select:focus{border-color:var(--accent)}
.setup-form .form-hint{font-size:11px;color:var(--text3);margin-top:4px}

.setup-status{
  margin-top:12px;padding:8px 12px;border-radius:var(--radius-xs);
  font-size:12px;display:none;align-items:center;gap:6px;
}
.setup-status.show{display:flex}
.setup-status.success{background:#ecfdf5;color:#065f46;border:1px solid #a7f3d0}
.setup-status.error{background:#fef2f2;color:#991b1b;border:1px solid #fecaca}
.setup-status.loading{background:#eff6ff;color:#1e3a5f;border:1px solid #bfdbfe}

.setup-actions{
  display:flex;gap:10px;justify-content:center;margin-top:28px;flex-wrap:wrap;
}
.setup-btn{
  padding:12px 28px;border-radius:var(--radius-sm);
  font-size:14px;font-weight:600;transition:var(--transition);
}
.setup-btn-primary{background:var(--accent);color:#fff}
.setup-btn-primary:hover{background:var(--accent2);transform:translateY(-1px)}
.setup-btn-secondary{background:var(--bg3);color:var(--text2)}
.setup-btn-secondary:hover{background:var(--bg4);color:var(--text)}
.setup-btn-skip{background:none;color:var(--text3);font-size:13px;text-decoration:underline}
.setup-btn-skip:hover{color:var(--text2)}

/* Setup summary in step 4 */
.setup-summary{
  background:var(--bg);border:1px solid var(--border-light);
  border-radius:var(--radius-sm);padding:16px;margin:16px 0;
  text-align:left;
}
.setup-summary .summary-row{
  display:flex;align-items:center;gap:8px;
  padding:6px 0;font-size:13px;
}
.setup-summary .summary-label{color:var(--text3);min-width:80px;font-size:12px}
.setup-summary .summary-value{color:var(--text);font-weight:500}

/* System Agent badge */
.system-badge{
  font-size:9px;font-weight:600;padding:1px 6px;
  border-radius:4px;background:var(--accent-light);color:var(--accent);
  white-space:nowrap;
}

/* ══════════════════════════════════════════════════════
   ── TTS (Text-to-Speech) ──
   ══════════════════════════════════════════════════════ */

/* Speaker toggle button in header */
.speaker-btn{
  width:36px;height:36px;border-radius:var(--radius-xs);
  display:grid;place-items:center;color:var(--text2);
  transition:var(--transition);
}
.speaker-btn:hover{background:var(--bg3);color:var(--text)}
.speaker-btn.active{
  background:var(--accent);color:#fff;
}
.speaker-btn.active:hover{background:var(--accent2)}
.speaker-btn svg{width:18px;height:18px}

/* Code block copy button */
.code-block-wrapper{
  position:relative;margin:8px 0;
}
.code-copy-btn{
  position:absolute;top:8px;right:8px;
  padding:3px 10px;border-radius:var(--radius-xs);
  background:rgba(255,255,255,.15);color:#cdd6f4;
  font-size:11px;font-weight:500;
  font-family:'SF Mono','Fira Code','Cascadia Code',monospace;
  cursor:pointer;opacity:0;
  transition:var(--transition);
  z-index:2;
}
.code-block-wrapper:hover .code-copy-btn{opacity:1}
.code-copy-btn:hover{background:rgba(255,255,255,.25);color:#fff}
.code-copy-btn.copied{background:rgba(16,185,129,.3);color:#a7f3d0}
.streaming-code-block{
  border-left:3px solid var(--primary,#6366f1);
  animation:stream-code-pulse 1.5s ease-in-out infinite;
}
.streaming-code-block .code-copy-btn{opacity:.5}
@keyframes stream-code-pulse{
  0%,100%{border-left-color:var(--primary,#6366f1)}
  50%{border-left-color:transparent}
}

/* Message action buttons (copy, speak) */
.msg-actions{
  display:flex;gap:4px;justify-content:flex-end;
  margin-top:4px;opacity:0;
  transition:opacity .2s ease;
}
.message-row.assistant:hover .msg-actions,
.message-row.user:hover .msg-actions{opacity:1}
.msg-action-btn{
  width:28px;height:28px;border-radius:var(--radius-xs);
  display:grid;place-items:center;
  color:var(--text3);transition:var(--transition);
}
.msg-action-btn:hover{background:var(--bg3);color:var(--accent)}
.msg-action-btn svg{width:14px;height:14px}
.msg-action-btn.tts-speaking{
  color:var(--accent);opacity:1;
  animation:ttsBtnPulse 1.2s ease-in-out infinite;
}
.msg-action-btn.tts-speaking:hover{color:#e74c3c;background:rgba(231,76,60,.1)}
@keyframes ttsBtnPulse{
  0%,100%{opacity:.7;transform:scale(1)}
  50%{opacity:1;transform:scale(1.1)}
}

/* TTS playing indicator */
.tts-playing-icon{
  display:inline-flex;align-items:center;justify-content:center;
  width:20px;height:20px;
}
.tts-playing-icon svg{
  width:14px;height:14px;
  color:var(--accent);
  animation:ttsPulse 1.2s ease-in-out infinite;
}
@keyframes ttsPulse{
  0%,100%{opacity:.4;transform:scale(.9)}
  50%{opacity:1;transform:scale(1.1)}
}

/* TTS voice selector dropdown */
.tts-voice-panel{
  position:absolute;top:calc(100% + 6px);right:0;
  width:220px;padding:8px;
  background:var(--bg2);border:1px solid var(--border);
  border-radius:var(--radius-sm);box-shadow:var(--shadow-lg);
  z-index:50;display:none;
}
.tts-voice-panel.show{display:block}
.tts-voice-item{
  display:flex;align-items:center;gap:8px;
  padding:7px 10px;border-radius:var(--radius-xs);
  cursor:pointer;font-size:12px;color:var(--text2);
  transition:var(--transition);
}
.tts-voice-item:hover{background:var(--bg3);color:var(--text)}
.tts-voice-item.active{background:var(--accent-light);color:var(--accent)}
.tts-voice-item .voice-icon{font-size:14px}
.tts-voice-item .voice-name{flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}

/* ── Dark Theme Overrides ── */
[data-theme="dark"] .message-bubble code{background:rgba(255,255,255,.1)}
[data-theme="dark"] .message-row.user .message-bubble code{background:rgba(0,0,0,.15)}
[data-theme="dark"] .message-bubble pre{background:#161412;color:#d4cdc0}
[data-theme="dark"] .group-msg-bubble code{background:rgba(255,255,255,.06)}
[data-theme="dark"] .group-msg-bubble pre{background:#161412;color:#d4cdc0}
[data-theme="dark"] .toast-error{background:rgba(127,29,29,.8);color:#fca5a5;border-color:rgba(239,68,68,.4)}
[data-theme="dark"] .toast-success{background:rgba(6,78,59,.8);color:#6ee7b7;border-color:rgba(16,185,129,.4)}
[data-theme="dark"] .toast-info{background:rgba(30,64,175,.8);color:#93c5fd;border-color:rgba(59,130,246,.4)}
[data-theme="dark"] .toast-warning{background:rgba(113,63,18,.8);color:#fcd34d;border-color:rgba(245,158,11,.4)}
[data-theme="dark"] .modal-overlay{background:rgba(0,0,0,.6)}
[data-theme="dark"] .exec-badge.local{background:rgba(74,222,128,.15);color:#4ade80}
[data-theme="dark"] .exec-badge.sandbox{background:rgba(251,191,36,.15);color:#fbbf24}
[data-theme="dark"] .mode-btn.active-chat{background:var(--bg2);color:var(--accent);box-shadow:var(--shadow-sm)}
[data-theme="dark"] .mode-btn.active-exec{background:var(--accent);color:#fff;box-shadow:var(--shadow-sm)}
[data-theme="dark"] .exec-mode-btn.active-local{background:rgba(74,222,128,.15);color:#4ade80;border-color:rgba(74,222,128,.3)}
[data-theme="dark"] .exec-mode-btn.active-local:hover{background:rgba(74,222,128,.25)}
[data-theme="dark"] .lock-indicator{background:rgba(127,29,29,.3);border-color:rgba(248,113,113,.3);color:#f87171}
[data-theme="dark"] .lock-indicator:hover{background:rgba(127,29,29,.5)}
[data-theme="dark"] .code-block-wrapper pre{background:#161412;color:#d4cdc0}
[data-theme="dark"] .code-copy-btn{background:var(--bg4);color:var(--text2)}
[data-theme="dark"] .code-copy-btn:hover{background:var(--bg5);color:var(--text)}
[data-theme="dark"] .code-copy-btn.copied{background:rgba(74,222,128,.3);color:#a7f3d0}
[data-theme="dark"] .group-member-role.owner{background:rgba(251,191,36,.15);color:#fbbf24}
[data-theme="dark"] .group-member-role.admin{background:rgba(96,165,250,.15);color:#60a5fa}
[data-theme="dark"] .setup-wizard-overlay{background:rgba(0,0,0,.9)}
[data-theme="dark"] .largetext-option:hover,[data-theme="dark"] .largetext-option.selected{border-color:var(--accent);background:rgba(217,119,6,.1)}
[data-theme="dark"] .platform-toggle{background:var(--bg4)}
[data-theme="dark"] .quick-action{background:var(--bg2);border-color:var(--border)}
[data-theme="dark"] .quick-action:hover{border-color:var(--accent);color:var(--accent);background:var(--accent-light)}
[data-theme="dark"] .task-delete:hover{background:rgba(127,29,29,.3)}
[data-theme="dark"] .platform-card-btn.delete:hover{background:rgba(127,29,29,.3)}
[data-theme="dark"] ::-webkit-scrollbar-thumb{background:var(--bg4)}
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover{background:var(--bg5)}
[data-theme="claude"] .sidebar-logo{background:linear-gradient(135deg,#c96442,#a0502e)}
[data-theme="claude"] .new-chat-btn{background:var(--accent)}
[data-theme="claude"] .new-chat-btn:hover{background:var(--accent2)}

/* ── Execution Events Panel ── */
.exec-events-panel{margin-top:10px;border:1px solid var(--border);border-radius:var(--radius-sm);overflow:hidden;background:var(--bg)}
.exec-events-header{display:flex;align-items:center;gap:6px;padding:8px 12px;background:var(--bg2);border-bottom:1px solid var(--border);cursor:pointer;font-size:12px;font-weight:600;color:var(--text2);user-select:none;transition:var(--transition)}
.exec-events-header:hover{background:var(--bg3);color:var(--text)}
.exec-events-header .events-chevron{transition:transform .2s ease;font-size:10px}
.exec-events-header.expanded .events-chevron{transform:rotate(90deg)}
.exec-events-header .events-count{background:var(--accent);color:#fff;font-size:10px;padding:0 6px;border-radius:10px;font-weight:700;min-width:18px;text-align:center}
.exec-events-body{max-height:0;overflow:hidden;transition:max-height .3s ease}
.exec-events-body.expanded{max-height:600px;overflow-y:auto}
.exec-event-item{display:flex;align-items:flex-start;gap:8px;padding:8px 12px;border-bottom:1px solid var(--border-light);font-size:12px;transition:background .15s}
.exec-event-item:last-child{border-bottom:none}
.exec-event-item:hover{background:var(--bg2)}
.exec-event-icon{width:20px;height:20px;border-radius:4px;display:grid;place-items:center;flex-shrink:0;font-size:11px;margin-top:1px}
.exec-event-icon.tool{background:#eff6ff;color:#3b82f6}
.exec-event-icon.code-run{background:#fef3c7;color:#d97706}
.exec-event-icon.code-ok{background:#dcfce7;color:#16a34a}
.exec-event-icon.code-fail{background:#fee2e2;color:#dc2626}
.exec-event-icon.code-timeout{background:#fce7f3;color:#db2777}
.exec-event-icon.skill{background:#f3e8ff;color:#7c3aed}
.exec-event-body{flex:1;min-width:0}
.exec-event-title{font-weight:600;color:var(--text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.exec-event-meta{font-size:11px;color:var(--text3);margin-top:2px;display:flex;gap:8px;flex-wrap:wrap}
.exec-event-meta .meta-tag{padding:0 4px;border-radius:3px;background:var(--bg3);white-space:nowrap}
.exec-event-code{margin-top:4px;padding:4px 8px;background:var(--bg3);border-radius:4px;font-family:'SF Mono',Monaco,Consolas,'Courier New',monospace;font-size:11px;color:var(--text2);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;cursor:pointer;transition:var(--transition)}
.exec-event-code:hover{background:var(--bg4);color:var(--text)}
.exec-event-summary{margin-top:3px;font-size:11px;color:var(--text3);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%}
.exec-event-result-btn{display:inline-flex;align-items:center;gap:4px;padding:2px 8px;margin-top:4px;border-radius:4px;background:var(--bg3);color:var(--accent);font-size:11px;cursor:pointer;border:none;transition:var(--transition)}
.exec-event-result-btn:hover{background:var(--accent-light);color:var(--accent-dark)}
.exec-event-result-btn svg{width:12px;height:12px}

/* ── Inline Exec Events (Timeline Interleaved) ── */
.msg-timeline{display:flex;flex-direction:column;gap:10px;overflow:hidden}
/* Text segment inside the unified bubble */
.timeline-segment{word-break:break-word;overflow-wrap:break-word}
.timeline-segment p{margin-bottom:8px}
.timeline-segment p:last-child{margin-bottom:0}
.timeline-segment code{background:rgba(0,0,0,.06);padding:2px 6px;border-radius:4px;font-family:'SF Mono','Fira Code','Cascadia Code',monospace;font-size:12.5px}
.timeline-segment pre{background:var(--bg3);color:var(--text);padding:14px 16px;border-radius:var(--radius-sm);overflow-x:auto;margin:8px 0;font-size:12.5px;line-height:1.5;max-width:100%;white-space:pre-wrap;word-break:break-all}
.timeline-segment strong{font-weight:600}
.timeline-segment em{font-style:italic}
.timeline-segment ul,.timeline-segment ol{padding-left:20px;margin:2px 0}
.timeline-segment li{margin:1px 0}
.timeline-segment blockquote{border-left:3px solid var(--accent);padding-left:12px;color:var(--text2);margin:6px 0}
/* Exec events inside a message-bubble need distinct background for contrast */
.message-bubble > .msg-timeline > .inline-exec-event{background:var(--bg);border-left-color:var(--accent)}
[data-theme="dark"] .message-bubble > .msg-timeline > .inline-exec-event{background:var(--bg)}
[data-theme="dark"] .message-bubble > .msg-timeline > .inline-exec-code{background:var(--bg2)}
.inline-exec-event{margin:2px 0;padding:8px 12px;background:var(--bg2);border-left:3px solid var(--border);border-radius:6px;font-size:13px;animation:execEventSlide .3s ease-out;display:flex;flex-direction:column;gap:4px}
.inline-exec-event.tool-success{border-left-color:#22c55e}
.inline-exec-event.tool-failed{border-left-color:#ef4444}
.inline-exec-event.tool-running{border-left-color:#f59e0b}
.inline-exec-event.tool-call-pending{border-left-color:#60a5fa}
.inline-exec-header{display:flex;align-items:center;gap:6px;min-height:20px;line-height:1}
.inline-exec-icon{font-size:14px;flex-shrink:0;width:18px;text-align:center}
.inline-exec-title{font-weight:600;color:var(--text);font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex:1;min-width:0}
.inline-exec-meta{color:var(--text3);font-size:11px;margin-left:auto;flex-shrink:0;white-space:nowrap}
.inline-exec-code{background:var(--bg);padding:8px 10px;border-radius:4px;font-family:'SF Mono','Fira Code','Cascadia Code',monospace;font-size:11.5px;color:var(--text2);overflow:hidden;cursor:pointer;transition:var(--transition);white-space:pre-wrap;word-break:break-all;line-height:1.5;max-height:80px}
.inline-exec-code:hover{background:var(--bg3)}
.inline-exec-code.expanded{max-height:none}
.inline-exec-summary{color:var(--text2);font-size:12px;line-height:1.5;word-break:break-word;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden}
.inline-exec-result-btn{background:none;border:1px solid var(--border);color:var(--text2);font-size:11px;padding:2px 8px;border-radius:4px;cursor:pointer;transition:var(--transition);flex-shrink:0}
.inline-exec-result-btn:hover{background:var(--bg2);border-color:var(--accent);color:var(--accent)}

/* ── [v1.37] Tool Result Preview (工具调用结果预览 + 展开) ── */
.tool-result-preview{margin:4px 0 2px;padding:6px 10px;background:var(--bg);border-radius:4px;border:1px solid var(--border);position:relative}
.tool-result-preview-text{color:var(--text2);font-size:12px;line-height:1.5;word-break:break-word;white-space:pre-wrap;font-family:'SF Mono','Fira Code','Cascadia Code',monospace;font-size:11.5px}
.tool-result-expand-btn{display:inline-block;font-size:11px;color:var(--accent);cursor:pointer;padding:2px 6px;margin-top:4px;border-radius:3px;transition:var(--transition);user-select:none}
.tool-result-expand-btn:hover{background:var(--bg2);text-decoration:underline}
/* 展开状态：隐藏预览，显示完整内容 */
.tool-result-preview.expanded{display:none}
.tool-result-preview.expanded + .tool-result-full{display:block !important}
.tool-result-full{margin:4px 0 2px;padding:8px 10px;background:var(--bg);border-radius:4px;border:1px solid var(--border);max-height:300px;overflow-y:auto}
.tool-result-full-pre{color:var(--text2);font-size:11.5px;line-height:1.5;word-break:break-word;white-space:pre-wrap;font-family:'SF Mono','Fira Code','Cascadia Code',monospace;margin:0;padding:0;background:none;border:none}

/* ── Tool Result Collapsible (合并卡片折叠区域) ── */
.tool-result-collapsible{border-top:1px dashed var(--border);margin-top:2px;padding-top:2px}
.tool-collapsible-toggle{font-size:11px;color:var(--text3);cursor:pointer;padding:2px 0;user-select:none;transition:var(--transition)}
.tool-collapsible-toggle:hover{color:var(--accent)}
.tool-collapsible-body{overflow:hidden;max-height:0;transition:max-height .25s ease}
.tool-result-collapsible:not(.collapsed) .tool-collapsible-body{max-height:300px;overflow-y:auto}
.tool-result-collapsible.collapsed .tool-collapsible-toggle::after{content:' ▸'}
.tool-result-collapsible:not(.collapsed) .tool-collapsible-toggle::after{content:' ▾'}

/* ── Execution Result Modal ── */
.exec-result-modal-overlay{position:fixed;inset:0;background:rgba(0,0,0,.5);z-index:1000;display:flex;align-items:center;justify-content:center;animation:fadeIn .15s ease}
.exec-result-modal{background:var(--bg);border:1px solid var(--border);border-radius:12px;width:min(680px,90vw);max-height:80vh;display:flex;flex-direction:column;box-shadow:0 20px 60px rgba(0,0,0,.25);animation:slideUp .2s ease}
.exec-result-modal-header{display:flex;align-items:center;justify-content:space-between;padding:14px 18px;border-bottom:1px solid var(--border);flex-shrink:0}
.exec-result-modal-header h3{font-size:14px;font-weight:700;display:flex;align-items:center;gap:8px}
.exec-result-modal-header h3 .status-icon{font-size:16px}
.exec-result-modal-close{width:28px;height:28px;border-radius:6px;display:grid;place-items:center;cursor:pointer;color:var(--text3);transition:var(--transition);border:none;background:none}
.exec-result-modal-close:hover{background:var(--bg3);color:var(--text)}
.exec-result-modal-tabs{display:flex;border-bottom:1px solid var(--border);padding:0 18px;flex-shrink:0}
.exec-result-tab{padding:8px 14px;font-size:12px;font-weight:600;color:var(--text3);cursor:pointer;border:none;background:none;border-bottom:2px solid transparent;transition:var(--transition)}
.exec-result-tab:hover{color:var(--text2)}
.exec-result-tab.active{color:var(--accent);border-bottom-color:var(--accent)}
.exec-result-modal-body{flex:1;overflow-y:auto;padding:16px 18px;min-height:0}
.exec-result-section{display:none}
.exec-result-section.active{display:block}
.exec-result-section pre{background:var(--bg3);border:1px solid var(--border-light);border-radius:8px;padding:12px 14px;font-family:'SF Mono',Monaco,Consolas,'Courier New',monospace;font-size:12px;line-height:1.6;white-space:pre-wrap;word-break:break-all;max-height:50vh;overflow-y:auto;color:var(--text)}
.exec-result-info{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:8px;margin-bottom:12px}
.exec-result-info-item{padding:8px 12px;background:var(--bg2);border-radius:6px}
.exec-result-info-item .label{font-size:11px;color:var(--text3);margin-bottom:2px}
.exec-result-info-item .value{font-size:13px;font-weight:600;color:var(--text)}
.exec-result-empty{text-align:center;padding:40px;color:var(--text3);font-size:13px}

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

/* Dark theme overrides for exec events */
[data-theme="dark"] .exec-event-icon.tool{background:rgba(59,130,246,.15);color:#93c5fd}
[data-theme="dark"] .exec-event-icon.code-run{background:rgba(217,119,6,.15);color:#fcd34d}
[data-theme="dark"] .exec-event-icon.code-ok{background:rgba(22,163,74,.15);color:#86efac}
[data-theme="dark"] .exec-event-icon.code-fail{background:rgba(220,38,38,.15);color:#fca5a5}
[data-theme="dark"] .exec-event-icon.code-timeout{background:rgba(219,39,119,.15);color:#f9a8d4}
[data-theme="dark"] .exec-event-icon.skill{background:rgba(217,119,6,.15);color:#fbbf24}
[data-theme="dark"] .exec-events-panel{background:var(--bg2);border-color:var(--border)}
[data-theme="dark"] .exec-result-modal{background:var(--bg2);border-color:var(--border)}
[data-theme="dark"] .exec-result-modal-body pre{background:#161412;color:#d4cdc0}
[data-theme="dark"] .exec-result-info-item{background:var(--bg3)}
[data-theme="dark"] .inline-exec-event{background:var(--bg3);border-left-color:var(--border)}
[data-theme="dark"] .inline-exec-event.tool-call-pending{border-left-color:rgba(96,165,250,.6)}
[data-theme="dark"] .inline-exec-code{background:var(--bg)}
[data-theme="dark"] .inline-exec-result-btn:hover{background:var(--bg4)}

  /* thought-block orphaned rules removed — see main .thought-block rule */

/* ══════════════════════════════════════════════════════
   ── Popout Mode (独立窗口) ──
   ══════════════════════════════════════════════════════ */
body.popout-mode .main{margin-left:0 !important;border-left:none !important}
body.popout-mode .agent-panel{display:none !important}
body.popout-mode .main-header{padding-left:12px}
body.popout-mode #popoutBtn{display:none !important}

/* ══════════════════════════════════════════════════════
   ── Mobile Responsive (≤768px) ──
   ══════════════════════════════════════════════════════ */

/* ── Mobile Overlay Backdrop (placed outside media query so JS can always use it) ── */
.mobile-overlay{
  position:fixed;inset:0;
  background:rgba(0,0,0,.4);
  z-index:45;
  opacity:0;visibility:hidden;
  transition:opacity .3s ease,visibility .3s ease;
  pointer-events:none;
}
.mobile-overlay.active{
  opacity:1;visibility:visible;
  pointer-events:auto;
}

/* ── Mobile Panel Close/Back Button ── */
.mobile-panel-close-btn{
  display:none; /* Hidden on desktop, shown on mobile via media query */
  align-items:center;gap:6px;
  padding:8px 14px;
  font-size:13px;font-weight:500;color:var(--accent);
  cursor:pointer;
  border-bottom:1px solid var(--border-light);
  background:var(--accent-light);
  transition:var(--transition);
  flex-shrink:0;
}
.mobile-panel-close-btn:hover{background:var(--bg3)}
.mobile-panel-close-btn svg{flex-shrink:0}

@media(max-width:768px){

  /* ── Sidebar: Fixed overlay sliding from left ── */
  .sidebar{
    position:fixed;
    left:0;top:0;
    width:85vw;max-width:320px;
    height:100vh;
    z-index:50;
    transform:translateX(-100%);
    transition:transform .3s cubic-bezier(.4,0,.2,1);
    box-shadow:none;
  }
  .sidebar.mobile-open{
    transform:translateX(0);
    box-shadow:4px 0 24px rgba(0,0,0,.15);
  }

  /* ── Agent Panel: Fixed overlay sliding from right ── */
  .agent-panel{
    position:fixed;
    right:0;top:0;
    width:85vw!important;max-width:340px;min-width:260px!important;
    height:100vh;
    z-index:50;
    transform:translateX(100%);
    transition:transform .3s cubic-bezier(.4,0,.2,1);
    box-shadow:none;
  }
  /* Override desktop collapsed state on mobile */
  .agent-panel.collapsed{
    width:85vw!important;min-width:260px!important;
  }
  .agent-panel.collapsed .agent-panel-header h3,
  .agent-panel.collapsed .agent-list,
  .agent-panel.collapsed .agent-create-btn,
  .agent-panel.collapsed .agent-collapse-btn span,
  .agent-panel.collapsed .agent-panel-footer{display:flex!important}
  .agent-panel.collapsed .agent-list{flex-direction:column!important}
  .agent-panel.collapsed .agent-collapse-btn span{display:inline!important}
  .agent-panel.mobile-open{
    transform:translateX(0);
    box-shadow:-4px 0 24px rgba(0,0,0,.15);
  }

  /* ── Hide desktop toggle buttons on mobile ── */
  .sidebar-toggle,
  .agent-toggle{
    display:none!important;
  }

  /* ── Show mobile close/back buttons ── */
  .mobile-panel-close-btn{
    display:flex;
  }

  /* ── Override desktop collapsed state on mobile: always full-width overlay, never icon-only ── */
  .sidebar.collapsed{
    width:85vw;min-width:0;max-width:320px;
  }
  .sidebar.collapsed .sidebar-header .sidebar-title,
  .sidebar.collapsed .sidebar-header .sidebar-subtitle,
  .sidebar.collapsed .new-chat-btn span,
  .sidebar.collapsed .sidebar-header .sidebar-logo + div,
  .sidebar.collapsed #sidebarAgentIndicator{display:flex!important}
  .sidebar.collapsed .sidebar-header{justify-content:flex-start;padding:16px 20px}
  .sidebar.collapsed .new-chat-btn{padding:12px 16px;justify-content:center}

  /* ── Show sidebar content on mobile (even when collapsed from desktop) ── */
  .sidebar.collapsed .sidebar-footer,
  .sidebar.collapsed .sidebar-search,
  .sidebar.collapsed .session-list{
    display:flex!important;
  }
  .sidebar.collapsed .sidebar-search{flex-direction:column}
  .sidebar.collapsed .session-list{flex-direction:column}
  .sidebar.collapsed .sidebar-footer{flex-direction:column}
  .sidebar-footer{padding-bottom:max(16px, calc(env(safe-area-inset-bottom) + 8px))}

  /* [v1.18.9] 确保移动端 sidebar 不影响主内容区域布局 */
  .app{display:flex;flex-direction:column;width:100%;height:100vh;height:100dvh}
  .chat-main{flex:1;overflow:hidden;display:flex;flex-direction:column;width:100%}
  .content-area{flex:1;display:flex;flex-direction:column;overflow:hidden}

  /* ── Header ── */
  .main-header{
    height:50px;min-height:50px;
    padding:0 12px;
  }
  .main-title{
    font-size:14px;
    white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
    min-width:0;
  }

  /* ── Messages ── */
  .messages-container{
    padding:12px;
  }
  .messages-inner{
    max-width:100%;
  }
  .message-row{gap:6px}
  .message-avatar{
    width:28px;height:28px;font-size:12px;
  }
  .message-row.assistant .message-bubble{
    max-width:100%;
  }
  .message-row.user .message-bubble{
    max-width:80%;
  }
  .message-bubble pre{
    font-size:12px;
  }

  /* ── Input Area ── */
  .input-area{
    padding:10px 12px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
  .input-wrapper{
    max-width:100%;
  }
  .input-box textarea{
    min-height:60px;
    max-height:120px;
  }

  /* ── Modals ── */
  .modal,
  .agent-modal,
  .platform-modal{
    width:95%;max-height:90vh;padding:20px;
  }

  /* ── Toast ── */
  .toast-container{
    top:12px;right:12px;left:12px;
  }
  .toast{
    max-width:100%;
  }

  /* ── Welcome Card Capabilities ── */
  .capabilities{
    grid-template-columns:1fr 1fr;
  }

  /* ── Execution Timer ── */
  .exec-timer{
    max-width:100%;
  }

  /* ── Empty State ── */
  .empty-icon{
    font-size:40px;
  }
  .empty-title{
    font-size:16px;
  }

  /* ── [fix] 移动端流式输出样式统一 ── */
  /* stream-status-bar 在移动端更醒目 */
  .stream-status-bar{
    position:sticky;
    bottom:0;
    z-index:5;
    max-width:100%;
    margin:0 4px;
    padding:8px 12px;
    font-size:12px;
    border-radius:8px;
  }
  .stream-status-wave span{
    width:2.5px;
  }
  /* streaming-indicator 移动端适配 */
  .streaming-indicator{
    padding:6px 12px;
    gap:8px;
    font-size:12px;
    border-radius:16px;
  }
  .streaming-indicator .thinking-wave span{
    width:2.5px;
  }
  /* thought-block 移动端优化 */
  .thought-block summary{
    padding:6px 10px;
    font-size:11px;
  }
  .thought-block .thought-content{
    padding:6px 10px;
    font-size:12px;
  }
  /* V2 工具卡片移动端优化 */
  .v2-tool-event{
    margin:4px 0;
  }
  .v2-tool-event .inline-exec-header{
    padding:6px 10px;
    font-size:12px;
  }
  .v2-tool-event .inline-exec-code{
    margin:0 10px 6px;
    font-size:11px;
    padding:6px 8px;
  }
  /* streamingContent 移动端 */
  #streamingContent{
    max-width:100%;
    padding:10px 12px;
    font-size:13px;
  }
  /* 流式光标移动端 */
  .streaming-cursor{
    width:2px;
  }
}

/* ══════════════════════════════════════════════════════
   ── Very Small Phones (≤480px) ──
   ══════════════════════════════════════════════════════ */
@media(max-width:480px){
  .message-bubble{
    max-width:92%;
  }
  .main-header{
    padding:0 8px;
  }
}

/* ══════════════════════════════════════════════════════
   V2 Structured Output Components
   ══════════════════════════════════════════════════════ */

/* V2 Tool Event Cards */
.v2-tool-event {
  margin: 8px 0;
  border-left: 3px solid var(--border, #e0e0e8);
  background: var(--bg2, rgba(99, 102, 241, 0.05));
  border-radius: var(--radius-xs, 6px);
  overflow: hidden;
  transition: border-color .3s ease, box-shadow .3s ease;
}
.v2-tool-event.tool-running {
  border-left-color: var(--accent, #D97706);
}
.v2-tool-event.tool-success {
  border-left-color: var(--ok, #10b981);
}
.v2-tool-event.tool-failed {
  border-left-color: var(--danger, #ef4444);
}

.v2-tool-event .inline-exec-header {
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.v2-tool-event .inline-exec-icon {
  font-size: 14px;
  flex-shrink: 0;
}

.v2-tool-event .inline-exec-title {
  font-weight: 500;
  color: var(--text, #1a1a2e);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.v2-tool-event .inline-exec-meta {
  font-size: 11px;
  color: var(--text3, #888);
  flex-shrink: 0;
  display: flex;
  gap: 6px;
  align-items: center;
}

.v2-tool-event .inline-exec-meta .meta-tag {
  background: var(--bg, #f0f0f5);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
}

.v2-tool-event .inline-exec-code {
  margin: 0 12px 8px;
  padding: 8px;
  background: var(--bg, #f5f5fa);
  border-radius: 4px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  color: var(--text2, #555);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 120px;
  overflow-y: auto;
  cursor: default;
}

.v2-tool-event .inline-exec-summary {
  margin: 0 12px 8px;
  padding: 6px 10px;
  background: var(--bg, #f5f5fa);
  border-radius: 4px;
  font-size: 12px;
  color: var(--text2, #555);
  line-height: 1.5;
  max-height: 100px;
  overflow-y: auto;
}

/* [v1.37] V2 Tool Event 结果预览样式 */
.v2-tool-event .tool-result-preview {
  margin: 4px 12px 6px;
}
.v2-tool-event .tool-result-full {
  margin: 4px 12px 6px;
}
.v2-tool-event .tool-result-expand-btn {
  color: var(--accent, #D97706);
}
.v2-tool-event .inline-exec-result-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 4px 12px 8px;
  padding: 4px 10px;
  background: var(--bg, #f0f0f5);
  border: 1px solid var(--border, #e0e0e8);
  border-radius: 4px;
  font-size: 12px;
  color: var(--accent, #D97706);
  cursor: pointer;
  transition: all 0.15s ease;
}

.v2-tool-event .inline-exec-result-btn:hover {
  background: var(--accent, #D97706);
  color: white;
  border-color: var(--accent, #D97706);
}

.v2-tool-event .inline-exec-result-btn svg {
  width: 14px;
  height: 14px;
}

/* V2 Task Plan */
.v2-task-plan {
  margin: 8px 0;
  border: 1px solid var(--border, #e0e0e8);
  border-radius: var(--radius-xs, 6px);
  overflow: hidden;
}

.v2-task-plan-header {
  padding: 8px 12px;
  background: var(--bg2, #f8f8fc);
  font-size: 12px;
  font-weight: 600;
  color: var(--text2, #555);
  border-bottom: 1px solid var(--border, #e0e0e8);
}

.v2-task-plan-body {
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text, #1a1a2e);
}

.v2-task-plan-body ul, .v2-task-plan-body ol {
  margin: 4px 0;
  padding-left: 20px;
}

.v2-task-plan-body li {
  margin: 2px 0;
}

/* V2 Ask User */
.v2-ask-user {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 10px 0;
  padding: 12px 14px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(139, 92, 246, 0.05));
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: var(--radius-xs, 8px);
}

.v2-ask-icon {
  font-size: 20px;
  flex-shrink: 0;
  margin-top: 2px;
}

.v2-ask-content {
  flex: 1;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text, #1a1a2e);
}

.v2-ask-content p {
  margin: 4px 0;
}

/* V2 Memory Saved Indicator */
.v2-memory-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text3, #888);
  margin-top: 4px;
}

/* V2 Callback Badge */
.v2-callback-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 500;
}

.v2-callback-badge.callback-yes {
  background: rgba(16, 185, 129, 0.1);
  color: #059669;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.v2-callback-badge.callback-no {
  background: rgba(245, 158, 11, 0.1);
  color: #d97706;
  border: 1px solid rgba(245, 158, 11, 0.2);
}


/* ── [v1.21.1] Markdown 表格样式 ── */
.md-table-wrapper{width:100%;overflow-x:auto;margin:10px 0;border-radius:var(--radius-sm);border:1px solid var(--border-light)}
.md-table-wrapper table{width:100%;border-collapse:collapse;font-size:13px;line-height:1.5}
.md-table-wrapper th{background:var(--bg3);color:var(--text);font-weight:600;text-align:left;padding:8px 12px;border:1px solid var(--border-light);white-space:nowrap}
.md-table-wrapper td{padding:7px 12px;border:1px solid var(--border-light);color:var(--text);vertical-align:top;word-break:break-word}
.md-table-wrapper tr:nth-child(even){background:var(--bg3)}
.md-table-wrapper tr:hover{background:var(--accent-light)}

/* ══════════════════════════════════════════════════════
   ── @ Mention Panel (v1.23.29) ──
   ══════════════════════════════════════════════════════ */
#atMentionPanel{
  background:var(--bg-secondary,var(--bg2));
  border:1px solid var(--border-color,var(--border));
  border-radius:8px;
  box-shadow:0 4px 16px rgba(0,0,0,.4);
  min-width:200px;
  max-width:320px;
  font-size:13px;
  padding:4px 0;
}
.at-mention-item{
  display:flex;
  align-items:center;
  gap:8px;
  padding:8px 12px;
  cursor:pointer;
  transition:background .15s;
}
.at-mention-item:hover,.at-mention-item.at-item-active{
  background:var(--bg-hover,rgba(255,255,255,.08));
}
.at-emoji{
  font-size:16px;
  width:24px;
  text-align:center;
  flex-shrink:0;
}
.at-name{
  font-weight:500;
  color:var(--text-primary,var(--text));
}
.at-path{
  font-size:11px;
  color:var(--text-secondary,var(--text3));
  margin-left:auto;
}
.at-all-btn{
  background:transparent;
  border:1px solid var(--accent);
  color:var(--accent);
  border-radius:6px;
  padding:4px 10px;
  font-size:12px;
  cursor:pointer;
  white-space:nowrap;
  transition:all .2s;
  flex-shrink:0;
}
.at-all-btn:hover{
  background:var(--accent);
  color:#fff;
}

/* ── [v1.24.0] Update Notification Banner ── */
.update-notification-banner{
  position:fixed;top:0;left:0;right:0;z-index:99998;
  transform:translateY(-100%);
  transition:transform .35s cubic-bezier(.4,0,.2,1);
  pointer-events:none;
}
.update-notification-banner.visible{
  transform:translateY(0);
  pointer-events:auto;
}
.update-banner-content{
  display:flex;align-items:center;gap:14px;
  padding:12px 20px;
  background:var(--bg2);
  border-bottom:1px solid var(--border);
  box-shadow:0 4px 20px rgba(0,0,0,.12);
}
.update-banner-icon{
  width:36px;height:36px;border-radius:10px;
  background:var(--accent-light);
  display:grid;place-items:center;flex-shrink:0;
  color:var(--accent);
  animation:bannerIconSpin 3s linear infinite;
}
@keyframes bannerIconSpin{
  0%{transform:rotate(0deg)}
  100%{transform:rotate(360deg)}
}
.update-banner-info{flex:1;min-width:0}
.update-banner-title{
  font-size:14px;font-weight:600;color:var(--text);
  display:flex;align-items:center;gap:6px;
  margin-bottom:2px;
}
.update-banner-ver{
  display:inline-block;padding:1px 8px;border-radius:10px;
  background:var(--accent);color:#fff;font-size:11px;font-weight:600;
  animation:bannerVerPulse 2s ease-in-out infinite;
}
@keyframes bannerVerPulse{
  0%,100%{opacity:1}
  50%{opacity:.75}
}
.update-banner-desc{
  display:flex;align-items:center;gap:12px;flex-wrap:wrap;
  font-size:12px;color:var(--text2);
}
.update-banner-countdown-wrap{
  display:flex;align-items:center;gap:2px;
}
.update-banner-cd-num{
  display:inline-block;min-width:20px;text-align:center;
  font-size:18px;font-weight:800;color:var(--accent);
  font-variant-numeric:tabular-nums;
  animation:bannerCdPulse 1s ease-in-out infinite;
  line-height:1;
}
@keyframes bannerCdPulse{
  0%,100%{transform:scale(1)}
  50%{transform:scale(1.15)}
}
.update-banner-reassure{
  display:inline-flex;align-items:center;gap:4px;
  padding:2px 10px;border-radius:12px;
  background:rgba(16,185,129,.08);color:var(--ok);
  font-size:11px;font-weight:500;
  border:1px solid rgba(16,185,129,.15);
}
.update-banner-reassure::before{
  content:'';display:inline-block;width:6px;height:6px;
  border-radius:50%;background:var(--ok);flex-shrink:0;
  animation:reassureDot 2s ease-in-out infinite;
}
@keyframes reassureDot{
  0%,100%{opacity:1;transform:scale(1)}
  50%{opacity:.4;transform:scale(.7)}
}
.update-banner-actions{
  display:flex;gap:8px;flex-shrink:0;
}
.update-banner-btn{
  padding:6px 16px;border-radius:var(--radius-xs);
  font-size:12px;font-weight:600;cursor:pointer;
  transition:var(--transition);white-space:nowrap;
  border:1px solid var(--border);
}
.update-banner-btn-primary{
  background:var(--accent);color:#fff;border-color:var(--accent);
}
.update-banner-btn-primary:hover{
  background:var(--accent2);transform:translateY(-1px);
  box-shadow:0 2px 8px rgba(201,100,66,.3);
}
.update-banner-btn-secondary{
  background:var(--bg);color:var(--text2);
}
.update-banner-btn-secondary:hover{
  background:var(--bg3);color:var(--text);
}
.update-banner-close{
  width:28px;height:28px;border-radius:50%;
  display:grid;place-items:center;flex-shrink:0;
  color:var(--text3);cursor:pointer;transition:var(--transition);
  border:none;background:none;
}
.update-banner-close:hover{
  background:var(--bg3);color:var(--text);
}
/* Banner dark theme */
[data-theme="dark"] .update-banner-content{
  background:var(--bg2);
  border-bottom-color:var(--border);
  box-shadow:0 4px 20px rgba(0,0,0,.35);
}
[data-theme="dark"] .update-banner-reassure{
  background:rgba(74,222,128,.08);
  border-color:rgba(74,222,128,.15);
}
/* Banner mobile responsive */
@media(max-width:768px){
  .update-banner-content{
    padding:10px 14px;gap:10px;flex-wrap:wrap;
  }
  .update-banner-desc{gap:6px}
  .update-banner-actions{width:100%;justify-content:flex-end}
  .update-banner-icon{width:32px;height:32px}
  .update-banner-cd-num{font-size:16px}
}

/* ── [v1.24.0] Update Overlay ── */
.update-overlay{
  position:fixed;inset:0;z-index:99999;
  display:flex;align-items:center;justify-content:center;
  background:rgba(0,0,0,.65);
  animation:updateOverlayIn .4s ease;
  backdrop-filter:blur(4px);
}
@keyframes updateOverlayIn{from{opacity:0}to{opacity:1}}
.update-overlay-content{
  background:var(--bg2);border-radius:16px;
  padding:40px 48px;text-align:center;
  max-width:420px;width:90%;
  box-shadow:0 25px 60px rgba(0,0,0,.3);
  border:1px solid var(--border);
  animation:updateContentIn .5s ease;
}
@keyframes updateContentIn{from{opacity:0;transform:scale(.92) translateY(16px)}to{opacity:1;transform:scale(1) translateY(0)}}
.update-overlay-icon{
  width:56px;height:56px;border-radius:50%;
  margin:0 auto 20px;
  display:flex;align-items:center;justify-content:center;
  background:var(--accent-light);
}
.update-spinner{
  width:28px;height:28px;
  border:3px solid var(--bg4);
  border-top-color:var(--accent);
  border-radius:50%;
  animation:spin 1s linear infinite;
}
.update-overlay-title{
  font-size:20px;font-weight:700;color:var(--text);
  margin-bottom:8px;
}
.update-overlay-status{
  font-size:14px;color:var(--text2);
  margin-bottom:24px;line-height:1.6;
}
.update-overlay-countdown{
  display:flex;align-items:baseline;justify-content:center;gap:6px;
  margin-bottom:20px;
}
.update-countdown-num{
  font-size:48px;font-weight:800;color:var(--accent);
  font-variant-numeric:tabular-nums;
  line-height:1;
  animation:countdownPulse 1.5s ease-in-out infinite;
}
@keyframes countdownPulse{0%,100%{opacity:1}50%{opacity:.7}}
.update-countdown-label{
  font-size:14px;color:var(--text2);font-weight:500;
}
.update-overlay-progress{
  width:100%;height:4px;background:var(--bg4);
  border-radius:2px;overflow:hidden;
  margin-bottom:20px;
}
.update-progress-bar{
  height:100%;width:0%;border-radius:2px;
  background:linear-gradient(90deg,var(--accent),var(--accent2));
  transition:width .5s ease;
}
.update-overlay-progress.active .update-progress-bar{
  animation:updateProgress 2s ease-in-out infinite;
}
@keyframes updateProgress{
  0%{width:5%;margin-left:0}
  50%{width:45%;margin-left:25%}
  100%{width:5%;margin-left:90%}
}
.update-overlay-reassure{
  display:flex;align-items:center;justify-content:center;gap:8px;
  padding:12px 20px;
  background:rgba(16,185,129,.08);
  border-radius:var(--radius-sm);
  color:var(--ok);font-size:13px;font-weight:500;
  line-height:1.5;
  border:1px solid rgba(16,185,129,.12);
}
.update-overlay-reassure svg{flex-shrink:0;color:var(--ok);opacity:.7}
.update-overlay.restarting .update-overlay-icon{
  background:rgba(239,68,68,.12);
}
.update-overlay.restarting .update-spinner{
  border-top-color:var(--danger);
}
.update-overlay.success .update-overlay-icon{
  background:rgba(16,185,129,.12);
}
.update-overlay.success .update-spinner{
  animation:none;
  border:none;
  border-top:none;
  font-size:24px;
  color:var(--ok);
}
.update-overlay.success .update-spinner::after{
  content:'✓';
  font-weight:700;
}
.update-overlay.failed .update-overlay-icon{
  background:rgba(239,68,68,.12);
}
.update-overlay.failed .update-spinner{
  animation:none;
  border:none;
  border-top:none;
  font-size:24px;
  color:var(--danger);
}
.update-overlay.failed .update-spinner::after{
  content:'✗';
  font-weight:700;
}

/* Update overlay dark theme */
[data-theme="dark"] .update-overlay{background:rgba(0,0,0,.8)}
[data-theme="dark"] .update-overlay-content{background:var(--bg2);border-color:var(--border)}
[data-theme="dark"] .update-overlay-reassure{
  background:rgba(74,222,128,.06);
  border-color:rgba(74,222,128,.1);
}

/* Mobile responsive for update overlay */
@media(max-width:480px){
  .update-overlay-content{padding:28px 24px}
  .update-countdown-num{font-size:36px}
  .update-overlay-title{font-size:18px}
}
/* [v3.0] 中断/恢复标记样式已移除（参考 ctz168/ide: 不再使用暂停/恢复横幅） */

/* ══════════════════════════════════════════════════════
   [fix] 代码块增强：语言标签 + 复制按钮 + 运行按钮
   ══════════════════════════════════════════════════════ */
.code-block-wrapper{
  position:relative;
  margin:6px 0;
}
.code-block-wrapper pre{
  padding-top:28px !important;
}
.code-lang{
  position:absolute;top:4px;left:8px;
  font-size:11px;color:var(--text3);opacity:.7;
  font-weight:500;text-transform:uppercase;
  pointer-events:none;z-index:2;
}
.code-copy-btn{
  position:absolute;top:4px;right:4px;
  border:none;background:var(--bg3);color:var(--text3);
  font-size:12px;padding:2px 8px;border-radius:4px;
  cursor:pointer;opacity:.6;z-index:2;line-height:1.4;
  transition:opacity .15s;
}
.code-copy-btn:hover{opacity:1}
.code-copy-btn:active{transform:scale(.9)}
.code-action-btn{
  position:absolute;top:4px;right:56px;
  border:none;background:var(--bg3);color:var(--text3);
  font-size:11px;padding:2px 8px;border-radius:4px;
  cursor:pointer;opacity:.6;z-index:2;line-height:1.4;
  white-space:nowrap;transition:opacity .15s;
}
.code-action-btn:hover{opacity:1}
.code-action-btn:active{transform:scale(.9)}
.code-run-btn{right:56px}

/* ══════════════════════════════════════════════════════
   [fix] 预览弹窗（HTML预览 / JS运行结果）
   ══════════════════════════════════════════════════════ */
.preview-popup-overlay{
  position:fixed;top:0;left:0;right:0;bottom:0;
  background:rgba(0,0,0,.55);z-index:99999;
  display:flex;align-items:center;justify-content:center;
  animation:previewPopupFadein .15s ease;
}
@keyframes previewPopupFadein{from{opacity:0}to{opacity:1}}
.preview-popup-modal{
  background:var(--bg);border:1px solid var(--border);
  border-radius:12px;width:85vw;max-width:960px;height:75vh;
  display:flex;flex-direction:column;overflow:hidden;
  box-shadow:0 8px 32px rgba(0,0,0,.4);
  animation:previewPopupScale .15s ease;
}
@keyframes previewPopupScale{from{transform:scale(.95);opacity:0}to{transform:scale(1);opacity:1}}
.preview-popup-header{
  display:flex;align-items:center;justify-content:space-between;
  padding:8px 14px;border-bottom:1px solid var(--border);flex-shrink:0;
}
.preview-popup-title{font-size:13px;font-weight:500;color:var(--text2)}
.preview-popup-close{
  border:none;background:transparent;color:var(--text3);
  font-size:16px;cursor:pointer;padding:2px 6px;border-radius:4px;
  line-height:1;transition:background .15s;
}
.preview-popup-close:hover{background:var(--bg3);color:var(--text)}
.preview-popup-iframe{flex:1;border:none;width:100%;height:100%;background:#fff}

/* ══════════════════════════════════════════════════════
   [fix] 思考块 toggle 按钮样式
   ══════════════════════════════════════════════════════ */
.thought-toggle{
  font-size:11px;color:var(--text3);
  flex-shrink:0;width:14px;text-align:center;
  cursor:pointer;user-select:none;
}

/* ══════════════════════════════════════════════════════
   [fix] KaTeX 公式样式
   ══════════════════════════════════════════════════════ */
.message-bubble .katex-display{
  margin:8px 0;overflow-x:auto;overflow-y:hidden;
  padding:4px 0;
}
.message-bubble .katex{font-size:1.05em}
#streamingContent .katex-display{margin:8px 0;overflow-x:auto}
#streamingContent .katex{font-size:1.05em}

/* 移动端预览弹窗适配 */
@media(max-width:768px){
  .preview-popup-modal{width:95vw;height:85vh;border-radius:8px}
  .code-action-btn{font-size:10px;padding:1px 6px}
  .code-copy-btn{font-size:11px;padding:1px 6px}
}
