*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}

html,body{
  margin:0;padding:0;background:var(--bg);color:var(--text);
  font-family:var(--font-body);font-size:15px;line-height:1.75;
  height:100vh;
  height:100dvh;
  overflow:hidden;
  -webkit-tap-highlight-color:transparent;
  -webkit-text-size-adjust:100%;
}

.messages::-webkit-scrollbar,
.input-box textarea::-webkit-scrollbar,
.thinking-body::-webkit-scrollbar,
.code-block pre::-webkit-scrollbar,
.conv-list::-webkit-scrollbar{width:6px;height:6px}

.messages::-webkit-scrollbar-track,
.input-box textarea::-webkit-scrollbar-track,
.thinking-body::-webkit-scrollbar-track,
.code-block pre::-webkit-scrollbar-track,
.conv-list::-webkit-scrollbar-track{background:transparent}

.messages::-webkit-scrollbar-thumb,
.input-box textarea::-webkit-scrollbar-thumb,
.thinking-body::-webkit-scrollbar-thumb,
.code-block pre::-webkit-scrollbar-thumb,
.conv-list::-webkit-scrollbar-thumb{background:#d4d4d4;border-radius:3px}

/* ===== 应用外层：铺满全屏 ===== */
.app{
  max-width:none;
  margin:0;
  width:100%;
  height:100vh;
  height:100dvh;
  display:flex;
  gap:0;
  background:var(--panel);
  border-radius:0;
  overflow:hidden;
  padding:0;
  position:relative;
}

/* ===== 主区域 ===== */
.main{
  flex:1;display:flex;flex-direction:column;background:var(--panel);
  border-radius:0;border:none;
  overflow:hidden;min-width:0;
}

/* ===== 拖拽遮罩 ===== */
.drop-mask{
  position:absolute;inset:0;background:rgba(0,0,0,.04);
  border:2px dashed var(--border-strong);
  display:none;align-items:center;justify-content:center;
  z-index:9998;pointer-events:none;
  font-family:var(--font-title);font-size:18px;font-weight:600;
  color:var(--text);backdrop-filter:blur(2px);
  border-radius:0;
}
.drop-mask.show{display:flex}

/* ===== 消息区 ===== */
.messages{flex:1;overflow-y:auto;padding:24px;-webkit-overflow-scrolling:touch}
.msg{margin-bottom:24px;display:flex;flex-direction:column}
.welcome{margin:80px auto 40px;text-align:center;max-width:480px;padding:0 16px}
.welcome h1{font-family:var(--font-title);font-size:24px;font-weight:600;margin:0 0 12px;color:var(--text)}
.welcome p{color:var(--text-muted);font-size:14px;margin:0;line-height:1.8}

.msg-user{align-self:stretch;align-items:flex-end;max-width:100%}
.msg-user .bubble{
  max-width:78%;background:var(--user-bubble);color:var(--user-bubble-text);
  padding:12px 18px;border-radius:14px 0 14px 14px;
  white-space:pre-wrap;word-break:break-word;
}
.msg-user .bubble img.user-att-img{
  max-width:240px;max-height:240px;border-radius:8px;display:block;
  margin:6px 0;cursor:pointer;
}
.msg-user .bubble .att-file-tag{
  display:inline-block;background:rgba(255,255,255,.12);
  padding:3px 8px;border-radius:5px;font-size:12px;
  margin:3px 3px 0 0;font-family:var(--font-mono);
}

.msg-ai{align-self:stretch;max-width:100%;width:100%}
.msg-ai .ai-content{color:var(--text)}
.msg-ai .ai-content img{
  max-width:100%;max-height:50vh;width:auto;height:auto;object-fit:contain;
  border-radius:8px;margin:8px 0;border:1px solid var(--border);cursor:zoom-in;
  transition:opacity .15s;
}

.msg-actions{display:flex;gap:2px;margin-top:6px;align-items:center}
.msg-user .msg-actions{align-self:flex-end;justify-content:flex-end}
.msg-ai .msg-actions{align-self:flex-start;display:none}
.msg-ai.done .msg-actions{display:flex}

.action-btn{
  width:28px;height:28px;padding:0;background:transparent;border:none;
  border-radius:6px;color:var(--text-muted);cursor:pointer;
  display:inline-flex;align-items:center;justify-content:center;
  transition:background .15s,color .15s;flex-shrink:0;
}
.action-btn.copied{color:var(--success)}

.variant-switch{
  display:inline-flex;align-items:center;gap:1px;margin-left:4px;
  color:var(--text-muted);font-size:12px;user-select:none;
}
.variant-switch[data-count="1"]{visibility:hidden;width:0;overflow:hidden;margin-left:0}
.variant-btn{
  width:22px;height:22px;padding:0;background:transparent;border:none;
  border-radius:5px;color:var(--text-muted);cursor:pointer;
  display:inline-flex;align-items:center;justify-content:center;
  transition:background .15s,color .15s;flex-shrink:0;
}
.variant-btn:disabled{opacity:.3;cursor:not-allowed}
.variant-label{
  min-width:26px;text-align:center;font-variant-numeric:tabular-nums;
  font-size:12px;color:var(--text-muted);padding:0 2px;
}

/* ===== 思考框 ===== */
.thinking-box{
  margin:0 0 12px;border:1px solid var(--border);border-radius:8px;
  background:var(--code-bg);overflow:hidden;font-size:13px;
  display:block;width:fit-content;max-width:100%;
}
.thinking-box.expanded{width:100%}
.thinking-header{
  display:flex;align-items:center;gap:6px;padding:8px 12px;
  font-size:12px;color:var(--text-secondary);cursor:pointer;user-select:none;
  font-weight:500;white-space:nowrap;
}
.thinking-header .ic{width:13px;height:13px;flex-shrink:0}
.thinking-arrow{
  margin-left:6px;display:inline-flex;align-items:center;justify-content:center;
  width:12px;height:12px;color:var(--text-secondary);
  transition:transform .2s,color .15s;flex-shrink:0;
}
.thinking-arrow svg{width:100%;height:100%;display:block}
.thinking-box.expanded .thinking-arrow{transform:rotate(90deg);color:var(--text)}
.thinking-body{
  display:none;padding:10px 14px 12px;border-top:1px solid var(--border);
  font-size:13px;line-height:1.7;color:var(--text-secondary);white-space:pre-wrap;
  word-break:break-word;max-height:40vh;overflow-y:auto;
}
.thinking-box.expanded .thinking-body{display:block}
.thinking-dot{
  display:inline-block;width:6px;height:6px;background:var(--text-muted);
  border-radius:50%;margin:0 2px;animation:dotPulse .9s ease-in-out infinite;
  flex-shrink:0;
}
.search-box .thinking-header{cursor:default}

/* ===== 输入区 ===== */
.input-area{
  padding:12px 20px 16px;border-top:1px solid var(--border);
  flex-shrink:0;background:var(--panel);
  padding-bottom:calc(16px + env(safe-area-inset-bottom,0px));
}
.attachment-area{
  display:none;gap:8px;margin-bottom:8px;flex-wrap:wrap;
  max-height:120px;overflow-y:auto;
}
.attachment-area.active{display:flex}
.attachment-item{
  position:relative;display:inline-flex;align-items:center;gap:6px;
  background:var(--code-bg);border:1px solid var(--border);border-radius:8px;
  padding:4px 8px 4px 4px;font-size:12px;max-width:180px;flex-shrink:0;
}
.attachment-item img{width:40px;height:40px;object-fit:cover;border-radius:5px;flex-shrink:0}
.attachment-item .att-name{
  flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
  color:var(--text-secondary);font-family:var(--font-mono);font-size:11px;
}
.attachment-item .att-remove{
  position:absolute;top:-6px;right:-6px;width:18px;height:18px;
  border-radius:50%;border:none;background:#1f1f1f;color:#fff;
  font-size:12px;line-height:1;cursor:pointer;
  display:flex;align-items:center;justify-content:center;padding:0;
}

.input-box{
  display:grid;grid-template-columns:1fr auto auto;
  grid-template-areas:"input input input" "tools attach send";
  gap:6px 8px;align-items:end;background:var(--panel);
  border:1px solid var(--border-strong);border-radius:14px;
  padding:10px 10px 10px 14px;
}
.input-box textarea{
  grid-area:input;width:100%;border:none;background:transparent;
  font-family:var(--font-body);font-size:15px;line-height:1.6;
  color:var(--text);resize:none;outline:none;max-height:200px;
  min-height:48px;
  padding:2px 0;overflow-y:auto;
}
.input-box textarea::placeholder{color:var(--text-muted)}
.input-tools{grid-area:tools;display:flex;gap:6px;align-items:center;min-width:0;flex-wrap:wrap}
.tool-btn{
  height:30px;padding:0 10px;border-radius:15px;border:1px solid var(--border);
  background:var(--panel);color:var(--text-secondary);cursor:pointer;
  display:inline-flex;align-items:center;justify-content:center;gap:5px;
  flex-shrink:0;transition:background .15s,color .15s,border-color .15s;
  font-family:var(--font-body);font-size:12px;font-weight:500;white-space:nowrap;
}
.tool-btn .ic{width:14px;height:14px;flex-shrink:0}
.tool-btn.active{background:#1f1f1f;color:#fff;border-color:#1f1f1f}
.tool-btn:disabled,.tool-btn.disabled{opacity:.4;cursor:not-allowed;pointer-events:none}

.attach-btn{
  grid-area:attach;width:38px;height:38px;border:1px solid var(--border);border-radius:10px;
  background:var(--panel);color:var(--text-secondary);cursor:pointer;
  display:flex;align-items:center;justify-content:center;
  transition:background .15s,color .15s;flex-shrink:0;padding:0;
}
.attach-btn .ic{width:18px;height:18px}

.send-btn{
  grid-area:send;width:38px;height:38px;border:none;border-radius:10px;
  background:#1f1f1f;color:#fff;cursor:pointer;
  display:flex;align-items:center;justify-content:center;
  transition:background .15s,opacity .15s;flex-shrink:0;
}
.send-btn:disabled{opacity:.3;cursor:not-allowed}
.send-btn.streaming{background:#6b6b6b}

/* ===== 图标 ===== */
.ic{display:inline-block;width:15px;height:15px;background:currentColor;
  mask-size:contain;-webkit-mask-size:contain;
  mask-repeat:no-repeat;-webkit-mask-repeat:no-repeat;
  mask-position:center;-webkit-mask-position:center}
.ic-copy{mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='9' y='9' width='13' height='13' rx='2' ry='2'/%3E%3Cpath d='M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1'/%3E%3C/svg%3E");-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='9' y='9' width='13' height='13' rx='2' ry='2'/%3E%3Cpath d='M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1'/%3E%3C/svg%3E")}
.ic-check{mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E")}
.ic-download{mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4'/%3E%3Cpolyline points='7 10 12 15 17 10'/%3E%3Cline x1='12' y1='15' x2='12' y2='3'/%3E%3C/svg%3E");-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4'/%3E%3Cpolyline points='7 10 12 15 17 10'/%3E%3Cline x1='12' y1='15' x2='12' y2='3'/%3E%3C/svg%3E")}
.ic-send{mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='12' y1='19' x2='12' y2='5'/%3E%3Cpolyline points='5 12 12 5 19 12'/%3E%3C/svg%3E");-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='12' y1='19' x2='12' y2='5'/%3E%3Cpolyline points='5 12 12 5 19 12'/%3E%3C/svg%3E");width:18px;height:18px}
.ic-stop{mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='4' width='16' height='16' rx='2' ry='2'/%3E%3C/svg%3E");-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='4' width='16' height='16' rx='2' ry='2'/%3E%3C/svg%3E");width:15px;height:15px}
.ic-brain{mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9.5 2A2.5 2.5 0 0 1 12 4.5v15a2.5 2.5 0 0 1-4.96.44 2.5 2.5 0 0 1-2.96-3.08 3 3 0 0 1-.34-5.58 2.5 2.5 0 0 1 1.32-4.24 2.5 2.5 0 0 1 1.98-3A2.5 2.5 0 0 1 9.5 2Z'/%3E%3Cpath d='M14.5 2A2.5 2.5 0 0 0 12 4.5v15a2.5 2.5 0 0 0 4.96.44 2.5 2.5 0 0 0 2.96-3.08 3 3 0 0 0 .34-5.58 2.5 2.5 0 0 0-1.32-4.24 2.5 2.5 0 0 0-1.98-3A2.5 2.5 0 0 0 14.5 2Z'/%3E%3C/svg%3E");-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9.5 2A2.5 2.5 0 0 1 12 4.5v15a2.5 2.5 0 0 1-4.96.44 2.5 2.5 0 0 1-2.96-3.08 3 3 0 0 1-.34-5.58 2.5 2.5 0 0 1 1.32-4.24 2.5 2.5 0 0 1 1.98-3A2.5 2.5 0 0 1 9.5 2Z'/%3E%3Cpath d='M14.5 2A2.5 2.5 0 0 0 12 4.5v15a2.5 2.5 0 0 0 4.96.44 2.5 2.5 0 0 0 2.96-3.08 3 3 0 0 0 .34-5.58 2.5 2.5 0 0 0-1.32-4.24 2.5 2.5 0 0 0-1.98-3A2.5 2.5 0 0 0 14.5 2Z'/%3E%3C/svg%3E")}
.ic-search{mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E")}
.ic-refresh{mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8'/%3E%3Cpath d='M21 3v5h-5'/%3E%3Cpath d='M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16'/%3E%3Cpath d='M3 21v-5h5'/%3E%3C/svg%3E");-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8'/%3E%3Cpath d='M21 3v5h-5'/%3E%3Cpath d='M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16'/%3E%3Cpath d='M3 21v-5h5'/%3E%3C/svg%3E")}
.ic-edit{mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z'/%3E%3C/svg%3E");-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z'/%3E%3C/svg%3E")}
.ic-trash{mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='3 6 5 6 21 6'/%3E%3Cpath d='M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2'/%3E%3Cline x1='10' y1='11' x2='10' y2='17'/%3E%3Cline x1='14' y1='11' x2='14' y2='17'/%3E%3C/svg%3E");-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='3 6 5 6 21 6'/%3E%3Cpath d='M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2'/%3E%3Cline x1='10' y1='11' x2='10' y2='17'/%3E%3Cline x1='14' y1='11' x2='14' y2='17'/%3E%3C/svg%3E")}
.ic-chevron-left{mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='15 18 9 12 15 6'/%3E%3C/svg%3E");-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='15 18 9 12 15 6'/%3E%3C/svg%3E")}
.ic-chevron-right{mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='9 18 15 12 9 6'/%3E%3C/svg%3E");-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='9 18 15 12 9 6'/%3E%3C/svg%3E")}
.ic-plus{mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='12' y1='5' x2='12' y2='19'/%3E%3Cline x1='5' y1='12' x2='19' y2='12'/%3E%3C/svg%3E");-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='12' y1='5' x2='12' y2='19'/%3E%3Cline x1='5' y1='12' x2='19' y2='12'/%3E%3C/svg%3E")}

/* ===== Markdown 内容 ===== */
.ai-content h1,.ai-content h2,.ai-content h3,.ai-content h4,.ai-content h5,.ai-content h6{font-family:var(--font-title);margin:20px 0 12px;font-weight:600;line-height:1.3;color:var(--text)}
.ai-content h1{font-size:1.6em;padding-bottom:.3em;border-bottom:1px solid var(--border)}
.ai-content h2{font-size:1.35em;padding-bottom:.3em;border-bottom:1px solid var(--border)}
.ai-content h3{font-size:1.15em}
.ai-content h4{font-size:1em}
.ai-content>*:first-child{margin-top:0}
.ai-content>*:last-child{margin-bottom:0}
.ai-content p{margin:0 0 14px}
.ai-content p:last-child{margin-bottom:0}
.ai-content ul,.ai-content ol{padding-left:1.8em;margin:0 0 14px}
.ai-content li+li{margin-top:4px}
.ai-content li>ul,.ai-content li>ol{margin-top:4px;margin-bottom:0}
.ai-content blockquote{margin:0 0 14px;padding:0 1em;color:var(--text-secondary);border-left:3px solid var(--border-strong)}
.ai-content a{color:var(--text);text-decoration:underline}
.ai-content hr{height:1px;margin:20px 0;border:0;background:var(--border)}
.ai-content table{border-collapse:collapse;width:100%;margin:0 0 14px;font-size:14px;display:block;overflow-x:auto}
.ai-content th,.ai-content td{border:1px solid var(--border);padding:6px 12px}
.ai-content th{background:var(--code-bg);font-weight:600}
.ai-content tr:nth-child(2n) td{background:#fafafa}
.ai-content mark{background:#fef9c3;color:inherit}
.ai-content del{color:var(--text-secondary)}
.ai-content code:not(pre code),.thinking-body code:not(pre code){
  background:var(--code-bg);padding:.2em .4em;border-radius:5px;font-size:85%;
  font-family:var(--font-mono);font-feature-settings:"liga" 1,"calt" 1;
  word-break:break-word;border:1px solid var(--border);
}
.ai-content kbd{
  display:inline-block;padding:3px 6px;font-size:11px;line-height:1.2;
  color:var(--text);vertical-align:middle;background:var(--code-bg);border:1px solid var(--border);
  border-radius:5px;box-shadow:inset 0 -1px 0 var(--border);font-family:var(--font-mono);
}

.stream-block,.stream-tail{display:contents}

/* ===== 代码块 ===== */
.code-block{
  margin:0 0 14px;
  border:none;
  border-radius:8px;
  background:var(--code-bg);
  position:relative;
  overflow:clip;
}

.code-block-header{
  display:flex;align-items:center;justify-content:space-between;
  padding:5px 12px;
  background:#f0f0f0;
  border:1px solid var(--border);
  font-size:12px;color:var(--text-secondary);
  font-family:var(--font-mono);
  min-height:30px;
  position:sticky;
  top:-1px;
  z-index:2;
  border-radius:8px 8px 0 0;
  box-sizing:border-box;
  box-shadow:
    -12px 0 0 0 var(--panel),
     12px 0 0 0 var(--panel),
     0 -32px 0 0 var(--panel);
}

.code-block-actions{display:flex;gap:2px;align-items:center;position:relative;z-index:1}
.code-block-actions button{
  width:24px;height:24px;border-radius:5px;border:none;background:transparent;
  color:var(--text-secondary);cursor:pointer;display:flex;align-items:center;justify-content:center;
  padding:0;transition:background .15s,color .15s;
}
.code-block-actions button.copied{color:var(--success)}

.code-block pre{
  margin:0;
  padding:14px 16px;
  overflow:visible;
  background:transparent;
  font-size:13px;
  line-height:1.6;
  border:1px solid var(--border);
  border-top:0;
  border-radius:0 0 8px 8px;
  max-height:none;
  white-space:pre-wrap;
  word-break:break-word;
  overflow-wrap:anywhere;
  box-sizing:border-box;
}
.code-block pre code{
  background:transparent;padding:0;font-family:var(--font-mono);
  font-size:100%;font-feature-settings:"liga" 1,"calt" 1;
  white-space:pre-wrap;
  word-break:break-word;
  overflow-wrap:anywhere;
}
.code-block.collapsed pre{display:none}
.code-block.collapsed .code-block-header{
  border-radius:8px;
  border-bottom:1px solid var(--border);
}
.code-block .btn-fold-code .ic{transition:transform .2s}

/* ===== Mermaid ===== */
.mermaid-figure{margin:0 0 14px;border:1px solid var(--border);border-radius:8px;overflow:hidden;background:#fff}
.mermaid-viewport{
  position:relative;overflow:hidden;height:380px;max-height:50vh;min-height:220px;
  background:#fff;user-select:none;-webkit-user-select:none;touch-action:none;cursor:default;
}
.mermaid-viewport.can-pan{cursor:grab}
.mermaid-viewport.dragging{cursor:grabbing}
.mermaid-canvas{
  position:absolute;top:0;left:0;right:0;bottom:0;
  display:flex;align-items:center;justify-content:center;padding:16px;
  transform-origin:center center;transition:transform .12s ease-out;
}
.mermaid-viewport.dragging .mermaid-canvas{transition:none}
.mermaid-canvas svg{
  width:100%;height:100%;max-width:100%;max-height:100%;display:block;
  user-select:none;-webkit-user-select:none;pointer-events:none;
  shape-rendering:geometricPrecision;text-rendering:geometricPrecision;
}
.mermaid-controls{
  position:absolute;bottom:8px;right:8px;display:flex;gap:1px;
  background:rgba(255,255,255,.95);border:1px solid var(--border);border-radius:6px;
  box-shadow:0 1px 4px rgba(0,0,0,.06);padding:2px;z-index:2;user-select:none;
}
.mermaid-controls button{
  width:26px;height:26px;border:none;background:transparent;color:var(--text-secondary);
  cursor:pointer;border-radius:4px;font-size:14px;
  display:flex;align-items:center;justify-content:center;
  padding:0;font-family:inherit;line-height:1;
}
.mermaid-error{color:var(--danger);font-family:var(--font-mono);font-size:13px;text-align:left;white-space:pre-wrap;word-break:break-all;padding:8px}

.katex-display{overflow-x:auto;overflow-y:hidden;padding:4px 0}
.katex-error{color:var(--danger);font-family:var(--font-mono);font-size:13px;background:#fef2f2;padding:2px 6px;border-radius:4px}

.cursor-dot{
  display:inline-block;width:7px;height:7px;background:var(--text-muted);border-radius:50%;
  margin-left:5px;vertical-align:-1px;animation:dotPulse .9s ease-in-out infinite;
  flex-shrink:0;white-space:nowrap;
}
.ai-content>.cursor-dot{display:block;margin:6px 0 0 0}
@keyframes dotPulse{0%,100%{opacity:.3;transform:scale(.8)}50%{opacity:1;transform:scale(1)}}

/* ===== Toast ===== */
.toast{
  position:fixed;left:50%;bottom:32px;transform:translateX(-50%) translateY(20px);
  background:#1f1f1f;color:#fff;padding:10px 18px;border-radius:8px;
  font-size:13px;font-family:var(--font-body);z-index:99999;
  opacity:0;pointer-events:none;transition:opacity .2s,transform .2s;
  box-shadow:0 6px 24px rgba(0,0,0,.15);max-width:80vw;
}
.toast.show{opacity:1;transform:translateX(-50%) translateY(0);}
.toast.success{background:var(--success);}
.toast.error{background:var(--danger);}

/* ===== Modal ===== */
.modal-mask{
  position:fixed;inset:0;background:rgba(0,0,0,.4);
  display:none;align-items:center;justify-content:center;z-index:99998;
}
.modal-mask.show{display:flex;}
.modal{
  background:#fff;border-radius:12px;padding:20px 22px;min-width:300px;
  max-width:90vw;box-shadow:0 20px 60px rgba(0,0,0,.2);
  font-family:var(--font-body);
}
.modal-title{font-size:15px;font-weight:600;color:var(--text);margin-bottom:12px;}
.modal-textarea{
  width:100%;border:1px solid var(--border);border-radius:8px;
  padding:8px 10px;font-size:14px;font-family:inherit;
  outline:none;resize:vertical;min-height:36px;color:var(--text);
}
.modal-textarea:focus{border-color:var(--border-strong);}
.modal-actions{display:flex;gap:8px;justify-content:flex-end;margin-top:14px;}
.modal-actions button{
  padding:6px 16px;border-radius:8px;border:1px solid var(--border);
  background:#f5f5f5;color:var(--text);font-size:13px;cursor:pointer;
  font-family:inherit;font-weight:500;
}
.modal-actions button.primary{background:#1f1f1f;color:#fff;border-color:#1f1f1f;}
.modal-actions button.danger{background:var(--danger);color:#fff;border-color:var(--danger);}

/* ============================================================= */
/* ===== 所有 :hover 规则，只在有鼠标的设备上生效 ===== */
/* ============================================================= */
@media (hover:hover) and (pointer:fine){
  .msg-ai .ai-content img:hover{opacity:.9}
  .action-btn:hover{background:var(--hover);color:var(--text)}
  .variant-btn:hover:not(:disabled){background:var(--hover);color:var(--text)}
  .code-block-actions button:hover{background:var(--hover);color:var(--text)}
  .tool-btn:hover:not(.active):not(:disabled){background:var(--hover);color:var(--text)}
  .attach-btn:hover:not(:disabled){background:var(--hover);color:var(--text)}
  .send-btn:hover:not(:disabled){background:#000}
  .attachment-item .att-remove:hover{background:var(--danger)}
  .modal-actions button:hover{opacity:.85}
  .mermaid-controls button:hover{background:var(--hover)}
}