:root {
  --primary: #00695c; --primary-light: #00796b; --primary-hover: #004d40;
  --bg-gradient: linear-gradient(135deg, #e0f8f8 0%, #e8f5f9 45%, #f8f4ff 100%);
  --card-radius: 16px; --btn-radius: 12px;
  --shadow-sm: 0 4px 12px rgba(0,121,107,0.1); --shadow-md: 0 8px 24px rgba(0,121,107,0.15);
  --shadow-lg: 0 12px 32px rgba(0,121,107,0.2); --border-color: rgba(0,150,136,0.15);
}

body::before {
  content: ""; position: fixed; inset: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 1000"><defs><radialGradient id="g"><stop offset="0%" stop-color="%23ffffff" stop-opacity="0.08"/><stop offset="100%" stop-color="%23000000" stop-opacity="0"/></radialGradient></defs><circle cx="200" cy="200" r="300" fill="url(%23g)"/><circle cx="800" cy="300" r="250" fill="url(%23g)"/><circle cx="600" cy="800" r="350" fill="url(%23g)"/></svg>') center/cover no-repeat;
  pointer-events: none; z-index: -1;
}
h2.title {
  font-weight: 800; font-size: 2.8rem; text-align: center; margin: 30px 0 50px;
  background: linear-gradient(90deg, #004d40, #00796b); -webkit-background-clip: text;
  background-clip: text; -webkit-text-fill-color: transparent;
}
.chat-container { width: 100%; margin: 0; padding: 0; max-width: 100%; height: 100%; display: flex; flex-direction: column; }

.chat-flex-fill { height: 100%; max-height: 100%; overflow: hidden; display: flex; flex-direction: column; }

.quick-buttons { padding: 12px 20px; background: rgba(250,252,255,0.8); border-bottom: 1px solid var(--border-color); display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; flex-shrink: 0; }
.quick-btn { background: white; border: 2px solid var(--primary-light); color: var(--primary-light); border-radius: var(--btn-radius); padding: 10px 20px; font-size: 0.9rem; font-weight: 600; transition: all 0.3s ease; box-shadow: var(--shadow-sm); cursor: pointer; }
.quick-btn:hover { background: linear-gradient(135deg, var(--primary-light), var(--primary)); color: white; border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.quick-btn:active { transform: translateY(-1px); }

.copy-btn {
  position: absolute;
  right: 10px;
  bottom: 10px;
  opacity: 0;
  background: rgba(255, 255, 255, 0.9);
  color: #555;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.85rem;
  transition: all 0.2s;
  cursor: pointer;
  z-index: 10;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.bubble:hover .copy-btn { opacity: 1; }
.copy-btn:hover { 
  background: rgba(0, 0, 0, 0.1); 
  color: #000; 
  border-color: rgba(0, 0, 0, 0.2);
  transform: scale(1.05);
}

.modify-requirement-btn {
  position: absolute;
  right: 52px;
  bottom: 10px;
  opacity: 0;
  background: rgba(255, 255, 255, 0.9);
  color: #555;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.85rem;
  transition: all 0.2s;
  cursor: pointer;
  z-index: 10;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.bubble:hover .modify-requirement-btn { opacity: 1; }
.modify-requirement-btn:hover {
  background: rgba(0, 0, 0, 0.08);
  color: #000;
  border-color: rgba(0, 0, 0, 0.2);
  transform: scale(1.05);
}

/* 需求确认表：默认隐藏按钮；悬停表区域（wrap 含卡片与底部按钮位）时显示。注意 hover 规则特异性须高于默认隐藏，勿用低特异性的 !important 覆盖 */
.requirement-confirm-chat-wrap {
  position: relative;
  display: block;
  max-width: 100%;
  box-sizing: border-box;
  overflow: visible;
}
.message.user .bubble .requirement-confirm-chat-wrap .copy-btn,
.message.user .bubble .requirement-confirm-chat-wrap .modify-requirement-btn {
  opacity: 0;
  transition: opacity 0.2s ease;
}
.message.user .bubble .requirement-confirm-chat-wrap:hover .copy-btn,
.message.user .bubble .requirement-confirm-chat-wrap:hover .modify-requirement-btn {
  opacity: 1;
}
.message.user .bubble .requirement-confirm-chat-wrap .copy-btn {
  bottom: -34px;
}
.message.user .bubble .requirement-confirm-chat-wrap .modify-requirement-btn {
  bottom: -34px;
}

.bubble.ai h1, .bubble.ai h2, .bubble.ai h3, .bubble.ai h4, .bubble.ai h5, .bubble.ai h6 {
  margin: 32px 0 16px !important; font-weight: 700; color: #004d40;
  border-bottom: 2px solid #00796b; padding-bottom: 10px; line-height: 1.5;
  word-wrap: break-word; letter-spacing: 0.3px;
}
.bubble.ai h1:first-child, .bubble.ai h2:first-child, .bubble.ai h3:first-child,
.bubble.ai h4:first-child, .bubble.ai h5:first-child, .bubble.ai h6:first-child { margin-top: 0 !important; }
.bubble.ai h1 { font-size: 1.4em; border-width: 3px; margin: 40px 0 20px !important; font-weight: 800; }
.bubble.ai h2 { font-size: 1.25em; margin: 36px 0 18px !important; font-weight: 700; }
.bubble.ai h3 { font-size: 1.15em; color: #00695c; margin: 32px 0 16px !important; font-weight: 700; border-bottom-width: 1.5px; }
.bubble.ai h4 { font-size: 1.08em; margin: 28px 0 14px !important; font-weight: 600; border-bottom: 1px solid #b2dfdb; }
.bubble.ai h5 { font-size: 1.03em; margin: 24px 0 12px !important; font-weight: 600; border-bottom: none; color: #00695c; }
.bubble.ai h6 { font-size: 1.0em; margin: 22px 0 12px !important; font-weight: 600; border-bottom: none; color: #00796b; }
.bubble.ai h1::before, .bubble.ai h2::before, .bubble.ai h3::before,
.bubble.ai h4::before, .bubble.ai h5::before, .bubble.ai h6::before { content: none !important; }
.bubble.ai p { margin: 16px 0; line-height: 1.85; word-wrap: break-word; color: #333; text-align: justify; }
.bubble.ai p:first-child { margin-top: 0; }
.bubble.ai p:last-child { margin-bottom: 0; }
.bubble.ai p + p { margin-top: 18px; }
.bubble.ai p + h1, .bubble.ai p + h2, .bubble.ai p + h3, .bubble.ai p + h4, .bubble.ai p + h5, .bubble.ai p + h6 { margin-top: 28px !important; }
.bubble.ai h1 + p, .bubble.ai h2 + p, .bubble.ai h3 + p, .bubble.ai h4 + p, .bubble.ai h5 + p, .bubble.ai h6 + p { margin-top: 16px !important; }
.bubble.ai p + ul, .bubble.ai p + ol, .bubble.ai ul + p, .bubble.ai ol + p { margin-top: 20px !important; }
.bubble.ai h1 + ul, .bubble.ai h2 + ul, .bubble.ai h3 + ul, .bubble.ai h4 + ul, .bubble.ai h5 + ul, .bubble.ai h6 + ul,
.bubble.ai h1 + ol, .bubble.ai h2 + ol, .bubble.ai h3 + ol, .bubble.ai h4 + ol, .bubble.ai h5 + ol, .bubble.ai h6 + ol { margin-top: 16px !important; }
.bubble.ai ul, .bubble.ai ol { margin: 20px 0; padding-left: 28px; line-height: 1.8; }
.bubble.ai ul li, .bubble.ai ol li { margin: 12px 0; word-wrap: break-word; color: #333; padding-left: 8px; line-height: 1.8; position: relative; }
.bubble.ai ul li::marker { color: #00796b; font-weight: bold; }
.bubble.ai ul li ul, .bubble.ai ol li ol { margin: 16px 0; padding-left: 28px; }
.bubble.ai ul li ul li, .bubble.ai ol li ol li { margin: 14px 0; }
.bubble.ai ul li p, .bubble.ai ol li p { margin: 12px 0; line-height: 2.0; }
.bubble.ai ul li p:first-child, .bubble.ai ol li p:first-child { margin-top: 0; }
.bubble.ai ul li p:last-child, .bubble.ai ol li p:last-child { margin-bottom: 0; }
.bubble.ai strong { color: #004d40; font-weight: 900; }
.bubble.ai em { font-style: italic; color: #555; }
.bubble.ai blockquote { border-left: 5px solid #00796b; margin: 28px 0; padding: 20px 28px; background: #f0f8f8; border-radius: 0 12px 12px 0; font-style: italic; color: #004d40; line-height: 2.0; }
.bubble.ai blockquote p { margin: 12px 0; line-height: 2.0; }
.bubble.ai blockquote p:first-child { margin-top: 0; }
.bubble.ai blockquote p:last-child { margin-bottom: 0; }
.bubble.ai blockquote + p { margin-top: 24px !important; }
.bubble.ai * { text-indent: 0; }
.bubble.ai code { background: #f5f5f5; padding: 2px 6px; border-radius: 4px; font-family: 'Courier New', 'Consolas', 'Monaco', monospace; font-size: 0.88em; color: #c62828; border: 1px solid #e0e0e0; word-break: break-word; }
.bubble.ai p code, .bubble.ai li code, .bubble.ai td code { background: #f0f4f8; color: #1976d2; border-color: #b0bec5; font-size: 0.9em; }
.bubble.ai pre { margin: 24px 0 !important; padding: 20px 24px !important; line-height: 1.6; border-radius: 8px; background: #f8f9fa !important; border: 1px solid #d0e0e0; overflow-x: auto; overflow-y: hidden; box-shadow: 0 2px 6px rgba(0,0,0,0.08); font-family: 'Courier New', 'Consolas', 'Monaco', 'Menlo', monospace; white-space: pre; word-wrap: normal; position: relative; }
.bubble.ai pre + p, .bubble.ai p + pre { margin-top: 20px !important; }
.bubble.ai h1 + pre, .bubble.ai h2 + pre, .bubble.ai h3 + pre, .bubble.ai h4 + pre, .bubble.ai h5 + pre, .bubble.ai h6 + pre { margin-top: 16px !important; }
.bubble.ai pre code { background: transparent; padding: 0; border: none; color: #2c3e50; font-size: 0.88em; font-family: inherit; white-space: pre; word-wrap: normal; display: block; }
.bubble.ai pre.ascii-diagram { background: #fafbfc !important; border-color: #c8d8d8; padding: 22px 24px !important; }
.bubble.ai pre.ascii-diagram code { line-height: 1.4 !important; letter-spacing: 0.5px !important; font-size: 0.85em !important; color: #2c3e50 !important; white-space: pre !important; font-family: 'Courier New', 'Consolas', 'Monaco', 'Menlo', 'Liberation Mono', monospace !important; }
.bubble.ai pre.formula-block { background: #f8f9fa !important; border-color: #d0e0e0; text-align: center; }
.bubble.ai pre.formula-block code { color: #1976d2 !important; font-size: 0.95em !important; font-weight: 500; font-family: 'Times New Roman', 'STIX', 'Latin Modern Math', serif !important; }
.bubble.ai pre code { font-family: 'Courier New', 'Consolas', 'Monaco', 'Menlo', 'Liberation Mono', monospace; tab-size: 2; -moz-tab-size: 2; }
.bubble.ai table { width: 100%; margin: 24px 0; border-collapse: collapse; border: 1px solid #c8d8d8; border-radius: 8px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.08); background: #fff; display: table; table-layout: auto; }
.bubble.ai table + p, .bubble.ai p + table { margin-top: 20px !important; }
.bubble.ai h1 + table, .bubble.ai h2 + table, .bubble.ai h3 + table, .bubble.ai h4 + table, .bubble.ai h5 + table, .bubble.ai h6 + table { margin-top: 16px !important; }
.bubble.ai table thead { background: linear-gradient(to bottom, #f0f8f6, #e0f0ed); }
.bubble.ai table th { background: linear-gradient(to bottom, #f0f8f6, #e0f0ed); color: #004d40; font-weight: 700; padding: 14px 16px; text-align: left; border-bottom: 2px solid #00796b; border-right: 1px solid #d0e0e0; font-size: 0.92em; letter-spacing: 0.2px; white-space: normal; word-wrap: break-word; }
.bubble.ai table th:last-child { border-right: none; }
.bubble.ai table td { padding: 12px 16px; border-bottom: 1px solid #e8e8e8; border-right: 1px solid #f0f0f0; color: #333; line-height: 1.6; vertical-align: top; word-wrap: break-word; font-size: 0.93em; }
.bubble.ai table td:last-child { border-right: none; }
.bubble.ai table td:first-child { font-weight: 500; color: #004d40; }
.bubble.ai table tr:last-child td { border-bottom: none; }
.bubble.ai table tbody tr:nth-child(even) { background: #fafbfb; }
.bubble.ai table tbody tr:nth-child(odd) { background: #fff; }
.bubble.ai table tbody tr:hover { background: #f0f8f6 !important; transition: background 0.15s ease; }
.bubble.ai table tbody tr:hover td { color: #002e26; }
.bubble.ai hr { margin: 32px 0; border: none; border-top: 2px solid #e0e0e0; background: none; height: 0; }
.bubble.ai dl { margin: 20px 0; line-height: 1.9; }
.bubble.ai dt { font-weight: 700; color: #004d40; margin-top: 16px; margin-bottom: 8px; }
.bubble.ai dt:first-child { margin-top: 0; }
.bubble.ai dd { margin-left: 20px; margin-bottom: 12px; color: #333; }
.bubble.ai img { max-width: 100%; height: auto; margin: 28px 0; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); display: block; }

/* 移动端：Markdown 表格横向滚动，避免被强行压缩 */
@media (max-width: 768px) {
  .bubble.ai {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .bubble.ai table {
    display: block;
    width: max-content;
    max-width: none;
    min-width: 100%;
  }

  .bubble.ai table th,
  .bubble.ai table td {
    white-space: nowrap;
  }
}
.bubble.ai img.ai-image-unified {
  width: min(320px, 100%);
  height: 220px;
  object-fit: contain;
  background: #f7f9fb;
  border: 1px solid #d8e3e8;
  border-radius: 10px;
  cursor: zoom-in;
}
.bubble.ai p + img, .bubble.ai img + p { margin-top: 24px !important; }
.bubble.ai img:first-child { margin-top: 0; }
.bubble.ai img:last-child { margin-bottom: 0; }
.ai-image-preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.72);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 28px;
}
.ai-image-preview-overlay.show {
  display: flex;
}
.ai-image-preview-full {
  max-width: min(92vw, 1280px);
  max-height: 88vh;
  width: auto;
  height: auto;
  border-radius: 10px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
  background: #0f141a;
}
.ai-image-preview-close {
  position: absolute;
  top: 18px;
  right: 20px;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.ai-image-preview-close:hover {
  background: rgba(255, 255, 255, 0.26);
}
.bubble.ai a { color: #00796b; text-decoration: none; border-bottom: 1px solid transparent; transition: all 0.2s; font-weight: 500; }
.bubble.ai a:hover { color: #004d40; border-bottom-color: #00796b; }
.bubble.ai a:visited { color: #00695c; }
.bubble.ai video { max-width: 100%; height: auto; margin: 28px 0; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); display: block; background: #000; }
.bubble.ai p + video, .bubble.ai video + p { margin-top: 24px !important; }
.bubble.ai video:first-child { margin-top: 0; }
.bubble.ai video:last-child { margin-bottom: 0; }
.bubble.ai audio { width: 100%; margin: 28px 0; display: block; }
.bubble.ai p + audio, .bubble.ai audio + p { margin-top: 24px !important; }
.bubble.ai audio:first-child { margin-top: 0; }
.bubble.ai audio:last-child { margin-bottom: 0; }
.bubble.ai iframe { max-width: 100%; margin: 24px 0; border-radius: 8px; border: 1px solid #e0e0e0; }
pre { position: relative; border-radius: 14px; overflow: hidden; margin: 20px 0 !important; box-shadow: 0 4px 15px rgba(0,0,0,0.1); }
.code-copy { position: absolute; top: 10px; right: 10px; background: rgba(0,0,0,0.7); color: white; border: none; border-radius: 8px; padding: 6px 12px; font-size: 13px; cursor: pointer; z-index: 10; }
.code-copy:hover { background: #000; }

/* 旧样式已移至新样式部分，以下注释掉避免冲突 */
/* .chat-input { padding: 12px 20px; background: rgba(255,255,255,0.95); border-top: 1px solid var(--border-color); box-shadow: 0 -4px 20px rgba(0,0,0,0.05); flex-shrink: 0; } */
/* 旧样式已移至新样式部分，以下注释掉避免冲突 */
/* .chat-input .input-group { display: flex; align-items: center; gap: 10px; background: white; border-radius: 28px; padding: 6px 8px 6px 18px; box-shadow: 0 2px 8px rgba(0,121,107,0.08), 0 1px 3px rgba(0,0,0,0.05); transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); border: 2px solid var(--border-color); } */
/* .chat-input .input-group:focus-within { box-shadow: 0 4px 16px rgba(0,121,107,0.15), 0 2px 6px rgba(0,0,0,0.08); border-color: var(--primary-light); transform: translateY(-1px); background: #fafafa; } */
#user_msg { border: none; background: transparent; resize: none; padding: 10px 6px; font-size: 0.98rem; flex: 1; min-height: 38px; max-height: 120px; line-height: 1.5; color: #2c3e50; outline: none; overflow-y: auto; }
#user_msg::placeholder { color: #95a5a6; font-size: 0.95rem; }
.send-btn { width: 42px; height: 42px; min-width: 42px; min-height: 42px; border-radius: 50%; background: linear-gradient(135deg, #00796b 0%, #009688 100%); border: none; color: white; font-size: 1.2rem; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); display: flex; align-items: center; justify-content: center; flex-shrink: 0; box-shadow: 0 3px 12px rgba(0,121,107,0.35), 0 1px 4px rgba(0,0,0,0.1), inset 0 1px 0 rgba(255,255,255,0.25); cursor: pointer; position: relative; overflow: hidden; padding: 0; aspect-ratio: 1 / 1; }
.send-btn::before { content: ''; position: absolute; top: 50%; left: 50%; width: 0; height: 0; border-radius: 50%; background: rgba(255,255,255,0.3); transform: translate(-50%, -50%); transition: width 0.6s, height 0.6s; }
.send-btn:hover { background: linear-gradient(135deg, #00695c 0%, #00796b 100%); transform: translateY(-2px) scale(1.05); box-shadow: 0 6px 20px rgba(0,121,107,0.5), 0 4px 10px rgba(0,0,0,0.15), inset 0 1px 0 rgba(255,255,255,0.2); }
.send-btn:hover::before { width: 300px; height: 300px; }
.send-btn:hover i { transform: translateX(2px); }
.send-btn:active { transform: translateY(0) scale(0.98); box-shadow: 0 2px 8px rgba(0,121,107,0.4), inset 0 2px 4px rgba(0,0,0,0.1); }
.send-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.send-btn i { position: relative; z-index: 1; transition: transform 0.3s ease; }
/* 流式输出中：发送位切换为暂停（深色方块） */
.send-btn.is-stop {
  background: #1f2937 !important;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.08) !important;
}
.send-btn.is-stop::before { display: none; }
.send-btn.is-stop:hover {
  background: #111827 !important;
  transform: translateY(-1px) scale(1.03);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.08) !important;
}
.send-btn.is-stop:hover i { transform: none; }
.send-btn.is-stop:active {
  background: #0b1220 !important;
  transform: scale(0.98);
}
.send-btn.is-stop i { color: #fff; }
/* 旧 typing 样式保留以兼容，主样式见下方 .typing-indicator */
.typing { text-align: center; padding: 15px; color: #00796b; font-style: italic; }
.typing-dots span { animation: typing 1.4s infinite; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing { 0%, 60%, 100% { opacity: 0.3; } 30% { opacity: 1; } }
.error-message { background: #ffebee; color: #c62828; padding: 12px 20px; border-radius: 12px; margin: 10px 0; border-left: 4px solid #c62828; display: flex; align-items: center; gap: 10px; }
.error-message i { font-size: 1.2rem; }
.retry-btn { background: #00796b; color: white; border: none; border-radius: 20px; padding: 8px 16px; font-size: 0.9rem; cursor: pointer; margin-top: 10px; transition: all 0.2s; }
.retry-btn:hover { background: #00695c; transform: translateY(-2px); }
.component-list .btn {
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  border-radius: var(--btn-radius) !important;
  border-width: 2px !important;
  box-shadow: var(--shadow-sm);
}
.component-list .btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-light) !important;
}
.component-list .btn i {
  margin-right: 6px;
}


/* 强制左右布局 */
.main-layout > * {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

/* 确保左侧和右侧正确排列 */
.scheme-templates-section {
  grid-column: 1 !important;
  min-width: 0 !important;
  max-width: 100% !important;
  position: sticky;
  top: 100px;
  height: calc(100vh - 120px);
  max-height: calc(100vh - 120px);
  overflow: hidden;
  padding: 0;
  width: 100%;
  box-sizing: border-box;
  display: flex !important;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px);
  border-radius: var(--card-radius);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
}

/* 旧样式已移至文件末尾的新样式部分，以下注释掉避免冲突 */
/* .chat-section {
  grid-column: 2 !important;
  min-width: 0 !important;
  max-width: 100% !important;
  overflow: hidden;
  box-sizing: border-box;
  display: flex !important;
  flex-direction: column;
  height: calc(100vh - 120px);
  max-height: calc(100vh - 120px);
} */

/* 自定义滚动条样式 */
.scheme-templates-section::-webkit-scrollbar {
  width: 6px;
}
.scheme-templates-section::-webkit-scrollbar-track {
  background: rgba(0,121,107,0.05);
  border-radius: 10px;
}
.scheme-templates-section::-webkit-scrollbar-thumb {
  background: rgba(0,121,107,0.3);
  border-radius: 10px;
}
.scheme-templates-section::-webkit-scrollbar-thumb:hover {
  background: rgba(0,121,107,0.5);
}

.scheme-templates {
  display: flex !important;
  flex-direction: column;
  gap: 16px;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: 16px;
  background: rgba(250, 252, 255, 0.8);
}
.scheme-card {
  background: rgba(255, 255, 255, 0.95) !important;
  backdrop-filter: blur(10px);
  border-radius: var(--card-radius);
  padding: 16px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  transition: all 0.3s ease;
  cursor: pointer;
  position: relative;
  overflow: visible;
  width: 100%;
  color: #333 !important;
}
.scheme-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #00796b, #009688);
  transform: scaleX(0);
  transition: transform 0.3s ease;
}
.scheme-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-light);
  background: rgba(255, 255, 255, 1);
}
.scheme-card:hover::before {
  transform: scaleX(1);
}
.scheme-card-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--btn-radius);
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}
.scheme-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--primary-hover) !important;
  margin-bottom: 6px;
  line-height: 1.4;
  display: block !important;
}
.scheme-card-desc {
  color: #666 !important;
  font-size: 0.78rem;
  line-height: 1.5;
  margin-bottom: 10px;
  display: block !important;
}
.scheme-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}
.scheme-tag {
  background: rgba(0,121,107,0.12);
  color: var(--primary-light);
  padding: 3px 10px;
  border-radius: 8px;
  font-size: 0.7rem;
  font-weight: 500;
  border: 1px solid rgba(0,121,107,0.2);
}
.scheme-card-btn {
  margin-top: 12px;
  width: 100%;
  padding: 8px;
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  color: white;
  border: none;
  border-radius: var(--btn-radius);
  font-weight: 600;
  font-size: 0.85rem;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-sm);
}
.scheme-card:hover .scheme-card-btn {
  background: linear-gradient(135deg, var(--primary-hover), var(--primary-light));
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* 模板侧边栏标题 */
.scheme-templates-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  padding: 14px 22px;
  text-align: center;
  font-size: 1.3rem;
  font-weight: bold;
  letter-spacing: 0.5px;
  border-radius: var(--card-radius) var(--card-radius) 0 0;
  margin-bottom: 0;
  position: relative;
  flex-shrink: 0;
}

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


@media (max-width: 768px) {
  .main-layout {
    grid-template-columns: 1fr !important;
    gap: 24px;
  }
  .scheme-templates-section {
    position: static;
    max-height: none;
  }
  .scheme-templates {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
  }
}

/* 需求填写弹窗样式 */
.requirement-section {
  margin-bottom: 20px;
  background: rgba(250, 252, 255, 0.35);
  padding: 16px;
  border-radius: 12px;
}
.section-title {
  color: var(--primary-hover);
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 15px;
  display: flex;
  align-items: center;
}
.output-section {
  background: rgba(255, 255, 255, 0.8);
  padding: 12px;
  border-radius: 10px;
  margin-top: 10px;
  border: 1px solid var(--border-color);
}

/* 优化选项样式 */
.requirement-option {
  width: auto;
  min-height: 40px;
  padding: 8px 10px;
  margin: 0;
  border-radius: 8px;
  border: 1px solid rgba(0, 121, 107, 0.12);
  background: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}
.requirement-option:hover {
  background: rgba(0, 121, 107, 0.06);
  border-color: rgba(0, 121, 107, 0.28);
}
.requirement-option .form-check-input {
  margin-top: 0;
  margin-left: 0;
  flex: 0 0 auto;
  cursor: pointer;
}
.requirement-option .form-check-label {
  cursor: pointer;
  padding-left: 0;
  margin: 0;
  line-height: 1.35;
  flex: 1 1 auto;
  transition: color 0.2s ease;
}
.requirement-option:hover .form-check-label {
  color: var(--primary-hover);
}
.requirement-option .form-check-input:checked {
  background-color: var(--primary-light);
  border-color: var(--primary-light);
}
.requirement-option:has(.form-check-input:checked) {
  border-color: rgba(0, 121, 107, 0.45);
  background: rgba(0, 121, 107, 0.05);
}

/* 普通网格中的单选项卡片保持整齐 */
:is(#requirementModal, #productRequirementModal) .row.g-3 > [class*="col-"] > .form-check.requirement-option,
:is(#requirementModal, #productRequirementModal) .row.g-2 > [class*="col-"] > .form-check.requirement-option {
  width: 100%;
}

/* “不需要/需要”这类行内选项，使用更紧凑的胶囊样式 */
:is(#requirementModal, #productRequirementModal) .form-check-inline.requirement-option {
  min-height: 34px;
  min-width: 86px;
  padding: 6px 12px;
  border-radius: 10px;
  justify-content: center;
}
:is(#requirementModal, #productRequirementModal) .form-check-inline.requirement-option .form-check-label {
  flex: 0 1 auto;
}
:is(#requirementModal, #productRequirementModal) .d-flex.gap-3 {
  flex-wrap: wrap;
  align-items: center;
  row-gap: 8px;
}

/* 第4/5/6段的二选一开关：固定两列，避免忽左忽右 */
:is(#requirementModal, #productRequirementModal) .d-flex.gap-3:has(> .form-check-inline.requirement-option) {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(92px, 110px));
  column-gap: 10px;
  row-gap: 8px;
  justify-content: start;
}

/* 第5项三选项场景：单行三列，避免第三项换行（不依赖 :has 兼容） */
:is(#requirementModal, #productRequirementModal) .d-flex.gap-3.options-3-inline {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(92px, 130px)) !important;
  column-gap: 10px;
  row-gap: 8px;
  justify-content: start;
}

/* 这些分组的标题和输入框间距更紧凑 */
:is(#requirementModal, #productRequirementModal) .requirement-section .form-label.fw-bold.mb-2 {
  margin-bottom: 6px !important;
}
:is(#requirementModal, #productRequirementModal) .requirement-section .form-control.mt-2,
:is(#requirementModal, #productRequirementModal) .requirement-section textarea.form-control.mt-2 {
  margin-top: 8px !important;
}

/* 保护类四列卡片在中等屏更稳，不会视觉断层 */
:is(#requirementModal, #productRequirementModal) .requirement-section .row.g-3 > .col-md-6.col-lg-3 {
  min-width: 0;
}

/* “外形结构”纵向选项改为紧凑列表感 */
:is(#requirementModal, #productRequirementModal) .requirement-section .d-flex.flex-column.gap-2 .requirement-option {
  min-height: 36px;
  padding: 6px 10px;
}

/* 第4/5/6段独立重排版：字段面板化，信息分组更清晰 */
:is(#requirementModal, #productRequirementModal) .structured-section {
  background: rgba(248, 251, 252, 0.8);
}
:is(#requirementModal, #productRequirementModal) .structured-section > .border.rounded.p-3.bg-white.shadow-sm {
  background: #ffffff !important;
  border: 1px solid rgba(0, 121, 107, 0.12) !important;
  border-radius: 10px !important;
  padding: 12px !important;
}
:is(#requirementModal, #productRequirementModal) .structured-section .row.g-3 {
  --bs-gutter-x: 0.9rem;
  --bs-gutter-y: 0.9rem;
}
:is(#requirementModal, #productRequirementModal) .structured-section .row.g-3 > [class*="col-"] {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid rgba(0, 121, 107, 0.1);
  border-radius: 10px;
  background: #fcfefe;
}

/* 第1～3段：每行最多4列；同行内均分整行；末行仅余1个时不拉满（落单） */
:is(#requirementModal, #productRequirementModal) .req-options-grid-4 {
  --req-opt-gap: 0.75rem;
}
:is(#requirementModal, #productRequirementModal) .req-options-grid-4 .row.g-3 {
  display: flex;
  flex-wrap: wrap;
  gap: var(--req-opt-gap);
  margin-left: 0 !important;
  margin-right: 0 !important;
  --bs-gutter-x: 0;
  --bs-gutter-y: 0;
}
:is(#requirementModal, #productRequirementModal) .req-options-grid-4 .row.g-3 > [class*="col-"] {
  flex: 1 1 100%;
  min-width: 100%;
  max-width: none !important;
  width: auto !important;
}
@media (min-width: 576px) {
  :is(#requirementModal, #productRequirementModal) .req-options-grid-4 .row.g-3 > [class*="col-"] {
    flex: 1 1 calc((100% - 1 * var(--req-opt-gap)) / 2);
    min-width: calc((100% - 1 * var(--req-opt-gap)) / 2);
  }
}
@media (min-width: 768px) {
  :is(#requirementModal, #productRequirementModal) .req-options-grid-4 .row.g-3 > [class*="col-"] {
    flex: 1 1 calc((100% - 3 * var(--req-opt-gap)) / 4);
    min-width: calc((100% - 3 * var(--req-opt-gap)) / 4);
  }
  /* 末行落单（第5、9…个且为最后一个）：不 flex 拉满整行，保持约一列宽 */
  :is(#requirementModal, #productRequirementModal) .req-options-grid-4 .row.g-3:has(> :nth-child(2)) > [class*="col-"]:nth-child(4n + 1):last-child {
    flex-grow: 0;
    flex-basis: calc((100% - 3 * var(--req-opt-gap)) / 4);
    max-width: calc((100% - 3 * var(--req-opt-gap)) / 4);
  }
}

:is(#requirementModal, #productRequirementModal) .req-redesign .row.g-3 > [class*="col-"] {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 0 0 calc(50% - 0.45rem);
  max-width: calc(50% - 0.45rem);
  padding: 10px 12px;
  border: 1px solid rgba(0, 121, 107, 0.1);
  border-radius: 10px;
  background: #fcfefe;
}
:is(#requirementModal, #productRequirementModal) .structured-section .row.g-3 > [class*="col-"] .form-label {
  margin-bottom: 2px !important;
}
:is(#requirementModal, #productRequirementModal) .structured-section .row.g-3 > [class*="col-"] .form-control,
:is(#requirementModal, #productRequirementModal) .structured-section .row.g-3 > [class*="col-"] textarea.form-control {
  background: #fff;
}
:is(#requirementModal, #productRequirementModal) .req-redesign .row.g-3 > [class*="col-"] .form-control,
:is(#requirementModal, #productRequirementModal) .req-redesign .row.g-3 > [class*="col-"] textarea.form-control {
  background: #fff;
}

/* 外形结构单列选项：不要拉满整列，避免“条带感” */
:is(#requirementModal, #productRequirementModal) .structured-section .d-flex.flex-column.gap-2 .requirement-option {
  width: auto;
  min-width: 160px;
  max-width: 220px;
}
:is(#requirementModal, #productRequirementModal) .req-redesign .d-flex.flex-column.gap-2 .requirement-option {
  width: auto;
  min-width: 160px;
  max-width: 220px;
}

/* 第4/5/6段紧凑布局：保留信息层级，减少单项占位 */
:is(#requirementModal, #productRequirementModal) .req-compact-456 .border.rounded.p-3.bg-white.shadow-sm {
  padding: 12px !important;
}
:is(#requirementModal, #productRequirementModal) .req-compact-456 .row.g-3 {
  --bs-gutter-x: 0.65rem;
  --bs-gutter-y: 0.65rem;
}
:is(#requirementModal, #productRequirementModal) .req-compact-456 .row.g-3 > [class*="col-"] {
  border: 1px solid rgba(0, 121, 107, 0.12) !important;
  background: #fcfefe !important;
  padding: 8px 10px !important;
  gap: 6px !important;
  border-radius: 8px !important;
  flex: 0 0 auto;
  max-width: none;
}
:is(#requirementModal, #productRequirementModal) .req-compact-456 .form-label.fw-bold.mb-2 {
  margin-bottom: 6px !important;
}
:is(#requirementModal, #productRequirementModal) .req-compact-456 .form-check-inline.requirement-option {
  min-height: 32px;
  min-width: 78px;
  padding: 5px 10px;
}
:is(#requirementModal, #productRequirementModal) .req-compact-456 .form-control.mt-2,
:is(#requirementModal, #productRequirementModal) .req-compact-456 textarea.form-control.mt-2 {
  margin-top: 8px !important;
}

@media (max-width: 992px) {
  :is(#requirementModal, #productRequirementModal) .req-redesign .row.g-3 > [class*="col-"] {
    flex: 0 0 100%;
    max-width: 100%;
  }
}
.requirement-option .form-check-input:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 0.2rem rgba(0, 121, 107, 0.25);
}
:is(#requirementModal, #productRequirementModal) {
  z-index: 1055 !important;
}
:is(#requirementModal, #productRequirementModal).show {
  display: block !important;
}
:is(#requirementModal, #productRequirementModal) .modal-content {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-radius: var(--card-radius);
  border: none;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1056;
}
:is(#requirementModal, #productRequirementModal) .modal-header {
  border-radius: var(--card-radius) var(--card-radius) 0 0;
  border-bottom: none;
}
:is(#requirementModal, #productRequirementModal) .modal-body {
  flex: 1 1 auto;
  min-height: 0;
  max-height: calc(100vh - 200px);
  overflow-y: auto;
  padding: 20px !important;
}
:is(#requirementModal, #productRequirementModal) .form-label {
  color: #333;
  margin-bottom: 8px;
}
:is(#requirementModal, #productRequirementModal) .form-check-label {
  color: #555;
  cursor: pointer;
  font-size: 0.95rem;
}
:is(#requirementModal, #productRequirementModal) .form-control:focus,
:is(#requirementModal, #productRequirementModal) .form-check-input:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 0.2rem rgba(0, 121, 107, 0.25);
}
:is(#requirementModal, #productRequirementModal) .bg-light {
  background-color: rgba(248, 249, 250, 0.8) !important;
  border: 1px solid rgba(0, 121, 107, 0.1) !important;
}
:is(#requirementModal, #productRequirementModal) .border-top {
  border-top: 2px solid rgba(0, 121, 107, 0.15) !important;
  padding-top: 10px !important;
}

/* 让页面更简洁：收紧弹窗内分隔线 */
:is(#requirementModal, #productRequirementModal) hr {
  margin: 16px 0 !important;
  border-top: 1px solid rgba(0, 121, 107, 0.12) !important;
  background: transparent !important;
}

/* 需求弹窗：章节条（固定于标题栏下，与可滚动 body 分离） */
:is(#requirementModal, #productRequirementModal) .req-modal-chapter-strip {
  flex-shrink: 0;
  background: #fff;
  border-bottom: 1px solid rgba(0, 121, 107, 0.12);
  padding: 10px 20px;
}
:is(#requirementModal, #productRequirementModal) .req-modal-section-nav {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 8px 12px;
  margin: 0;
  background: #fff;
  border: 1px solid rgba(0, 121, 107, 0.12);
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0, 121, 107, 0.06);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
:is(#requirementModal, #productRequirementModal) .req-modal-section-nav-label {
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: #5c6560;
  margin-right: 2px;
  letter-spacing: 0.02em;
}
:is(#requirementModal, #productRequirementModal) .req-modal-section-nav-link {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: #198754;
  text-decoration: none;
  border: 1px solid rgba(25, 135, 84, 0.45);
  border-radius: 999px;
  background: #fff;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
:is(#requirementModal, #productRequirementModal) .req-modal-section-nav-link:hover,
:is(#requirementModal, #productRequirementModal) .req-modal-section-nav-link:focus {
  color: #fff;
  background: #198754;
  border-color: #198754;
  box-shadow: 0 2px 6px rgba(25, 135, 84, 0.25);
  outline: none;
}
:is(#requirementModal, #productRequirementModal) .req-modal-section-nav-link.is-active {
  color: #fff;
  background: #198754;
  border-color: #198754;
  box-shadow: 0 1px 4px rgba(25, 135, 84, 0.3);
}

/* 滚动时保留小节标题上下文 */
:is(#requirementModal, #productRequirementModal) .req-section-heading-sticky {
  position: sticky;
  top: 0;
  z-index: 4;
  background: #f8f9fa;
  padding-top: 6px !important;
  margin-top: -6px;
}

/* 需求弹窗：章节序号圆点、正文背景、工作温度「其他」输入（显示/隐藏仍由 JS 写 style 覆盖） */
:is(#requirementModal, #productRequirementModal) .req-section-number-badge {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}
:is(#requirementModal, #productRequirementModal) .req-modal-body-bg,
:is(#requirementConfirmModal, #productRequirementConfirmModal) .req-modal-body-bg {
  background: #f8f9fa;
}
:is(#requirementModal, #productRequirementModal) .req-temp-other-input {
  display: none;
  max-width: 300px;
}

/* 校验失败时短暂高亮对应章节 */
:is(#requirementModal, #productRequirementModal) .requirement-section.req-validation-flash {
  animation: reqSectionFlash 2.5s ease;
}
@keyframes reqSectionFlash {
  0%, 100% { box-shadow: none; }
  12%, 55% {
    box-shadow: 0 0 0 3px rgba(25, 135, 84, 0.4);
    border-radius: 8px;
  }
}

/* 需求确认表：可编辑单元格（自 requirement_modal 内联迁入） */
#confirmTableContent .requirement-edit-cell {
  min-height: 2em;
  padding: 8px;
  background: #fffef7;
  border: 1px dashed #ffc107;
  border-radius: 4px;
  outline: none;
}
#confirmTableContent .requirement-edit-cell:focus {
  background: #fff;
  border-color: #198754;
  box-shadow: 0 0 0 2px rgba(25, 135, 84, 0.2);
}

:is(#requirementModal, #productRequirementModal) .btn-success {
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  border: none;
  font-weight: 600;
  padding: 10px 24px;
  border-radius: var(--btn-radius);
  transition: all 0.3s ease;
}
:is(#requirementModal, #productRequirementModal) .btn-success:hover {
  background: linear-gradient(135deg, var(--primary-hover), var(--primary-light));
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

@media (max-width: 768px) {
  h2.title { font-size: 2rem; margin: 20px 0 30px; }
  .chat-container { padding: 0 6px; margin-bottom: 20px; }
  .quick-buttons { padding: 15px 10px; gap: 8px; }
  .quick-btn { padding: 8px 16px; font-size: 0.85rem; }
  /* 移动端保持与桌面一致的滚动行为，不限制消息区高度，让内容可以在输入框下方透出 */
  .chat-messages { padding: 15px; max-height: none; }
  .message { margin-bottom: 16px; gap: 8px; }
  .bubble { max-width: 100%; padding: 16px 20px; font-size: 0.95rem; line-height: 1.8; }
  .bubble.ai { padding: 18px 22px; }
  .bubble.ai p { margin: 18px 0; line-height: 2.0; }
  .bubble.ai p + p { margin-top: 20px; }
  .bubble.ai h1, .bubble.ai h2, .bubble.ai h3 { margin: 32px 0 18px !important; }
  .bubble.ai h4, .bubble.ai h5, .bubble.ai h6 { margin: 28px 0 16px !important; }
  .bubble.ai ul, .bubble.ai ol { margin: 20px 0; padding-left: 28px; line-height: 2.0; }
  .bubble.ai ul li, .bubble.ai ol li { margin: 14px 0; line-height: 2.0; }
  .chat-messages { padding: 20px 22px 90px 22px; }
  .chat-bottom-stack { padding: 0 6px 10px 6px; }
  .chat-input { padding: 5px 8px !important; }
  .chat-header { padding: 12px 18px; font-size: 1.15rem; }
  .quick-buttons { padding: 10px 15px; }
  .chat-input .input-group { padding: 0; gap: 5px; align-items: center; flex-wrap: nowrap; }
  #user_msg { padding: 6px 8px; min-height: 40px; font-size: 16px; line-height: 1.4; }
  .send-btn { width: 28px !important; height: 28px !important; min-width: 28px !important; min-height: 28px !important; font-size: 0.9rem !important; }
  .upload-btn { width: 26px !important; height: 26px !important; min-width: 26px !important; min-height: 26px !important; font-size: 15px !important; }
  .typing-indicator {
    max-width: min(760px, calc(100% - 12px));
  }
  .header-actions { top: 12px; right: 10px; gap: 8px; }
  .action-btn { width: 36px; height: 36px; font-size: 1rem; }
  .component-list { gap: 8px !important; }
  .component-list .btn { padding: 6px 16px !important; font-size: 0.9rem; }
  .scheme-templates { grid-template-columns: 1fr; gap: 16px; padding: 0 10px; }
  .scheme-card { padding: 18px; }
  .main-layout { padding: 0 6px; }
  :is(#requirementModal, #productRequirementModal) .modal-body { padding: 20px !important; }
  .requirement-section { padding: 15px; }
  .requirement-option { padding: 6px 10px; }
}

/* ========== 小屏基础布局调整：主区域全宽，保留侧边栏用于抽屉（手机常用宽度） ========== */
@media (max-width: 768px) {
  .main-layout {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: unset !important;
    height: 100% !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }

  .chat-section {
    width: 100% !important;
    max-width: 100% !important;
    flex: 1 !important;
    min-height: 0 !important;
  }
}

/* ========== 布局高度控制 ========== */
body {
  display: flex !important;
  flex-direction: column !important;
  min-height: 100vh !important;
  overflow-x: hidden !important;
  background: var(--bg-gradient) fixed !important;
  font-family: "Microsoft YaHei", "SF Pro Display", -apple-system, sans-serif !important;
  padding-top: 64px !important;
  margin: 0 !important;
}
.main-content-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.main-layout {
  display: grid !important;
  grid-template-columns: 280px 1fr !important;
  gap: 20px !important;
  width: 100% !important;
  align-items: stretch !important;
  height: calc(100vh - 120px) !important;
  min-height: 600px !important;
  overflow: hidden !important;
  max-width: 1600px !important;
  margin: 0 auto !important;
  padding: 0 !important;
}

/* ========== 电源助手区域整体优化 ========== */
.chat-section {
  background: white !important;
  border-radius: 12px !important;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08) !important;
  overflow: hidden !important;
  display: flex !important;
  flex-direction: column !important;
  height: 100% !important;
  max-height: 100% !important;
}

.chat-box {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  overflow: hidden !important;
  display: flex !important;
  flex-direction: column !important;
  height: 100% !important;
  flex: 1 !important;
  min-height: 0 !important;
}

/* 聊天 header 优化 */
.chat-header {
  padding: 16px 24px !important;
  background: linear-gradient(135deg, #ffffff 0%, #f8fdfa 100%) !important;
  border-bottom: 1px solid #e9ecef !important;
  position: sticky !important;
  top: 0 !important;
  z-index: 10 !important;
  flex-shrink: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  color: #212529 !important;
}
.chat-header .fw-bold {
  font-size: 1.25rem !important;
  color: #1a3c34;
  letter-spacing: 0.5px;
}
.header-actions {
  display: flex;
  gap: 12px;
  position: absolute;
  right: 24px;
}

/* 顶部栏左侧主界面按钮容器 */
.chat-header .header-actions.header-actions-left {
  left: 24px;
  right: auto !important;
}

/* 消息列表优化 - 底部留空让内容可滚动到输入框下方，实现透出 */
.chat-messages {
  position: relative;
  background: #ffffff !important;
  flex: 1 !important;
  overflow-y: auto !important;
  padding: 24px 36px 160px 36px !important;
  scroll-behavior: smooth !important;
  min-height: 0 !important;
}
/* 拖拽上传：文件拖到聊天窗口时高亮 + 中央提示 */
.chat-messages.drag-over {
  background: rgba(40, 167, 69, 0.06) !important;
  box-shadow: inset 0 0 0 2px rgba(40, 167, 69, 0.35);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}
.drop-zone-hint {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 10;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  pointer-events: none;
  color: #28a745;
  font-weight: 600;
  font-size: 1.1rem;
}
.drop-zone-hint i {
  font-size: 3rem;
  opacity: 0.9;
}
.drop-zone-hint small {
  font-weight: 400;
  font-size: 0.85rem;
  color: #6c757d;
}
.chat-messages.drag-over .drop-zone-hint {
  display: flex;
}

/* 需求填写建议提示 */
.requirement-suggestion {
  background: rgba(0, 121, 107, 0.1);
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  border: 1px solid rgba(0, 121, 107, 0.22);
  border-radius: 12px;
  padding: 8px 16px;
  margin: 0 auto 16px;
  max-width: fit-content;
  box-shadow: 0 2px 12px rgba(0, 121, 107, 0.08);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: fadeIn 0.4s ease;
}
.requirement-suggestion .suggestion-icon {
  color: var(--primary);
  font-size: 0.9rem;
  flex-shrink: 0;
  opacity: 0.9;
}
.requirement-suggestion .suggestion-text {
  color: #455a64;
  font-size: 0.85rem;
  line-height: 1.5;
}
.requirement-suggestion .suggestion-link {
  color: var(--primary-light);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: all 0.2s ease;
}
.requirement-suggestion .suggestion-link:hover {
  color: var(--primary-hover);
  border-bottom-color: var(--primary);
}

/* 消息容器样式 */
.message {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
}
.message.user {
  align-items: flex-end;
}
.message.ai {
  align-items: flex-start;
}
.message.system {
  align-items: center;
}

/* 气泡统一样式（主要用于用户消息） */
.bubble {
  padding: 14px 18px !important;
  border-radius: 16px !important;
  font-size: 15px;
  line-height: 1.6;
  max-width: 100%;
  word-break: break-word;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  position: relative;
}

/* AI 消息：视觉上取消气泡，仅保留排版样式（仍使用 .bubble.ai 作为内容容器，方便复用 Markdown 样式） */
.message.ai .bubble.ai {
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
  max-width: 100% !important;
  color: #212529;
  width: 100%;
}

/* AI 输出尾部的时间分割线 */
.ai-meta {
  margin-top: 16px;
}
.ai-meta-hr {
  margin: 8px 0 4px 0;
  border: none;
  border-top: 1px dashed #d0d7de;
}
.ai-meta-time {
  font-size: 12px;
  color: #9aa0a6;
  text-align: left;
}

/* 用户消息 - 淡绿 */
.message.user .bubble {
  background: #e8f5e9 !important;
  border: 1px solid #c8e6c9;
  color: #1b5e20;
  border-radius: 16px 16px 4px 16px !important;
  margin-left: auto;
}

/* 系统消息保持原样，但稍柔和 */
.message.system .bubble.system {
  background: #e3f2fd !important;
  border-left: 4px solid #2196f3 !important;
  color: #0c4a6e;
  padding: 12px 16px !important;
  margin-bottom: 12px;
  border-radius: 8px !important;
}

/* 用户消息 - 产品设计需求确认表卡片（聊天框内） */
.requirement-confirm-chat-card {
  background: #ffffff;
  border: 1px solid #00796b;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 121, 107, 0.15);
  max-width: 100%;
}
.requirement-confirm-chat-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #00695c, #00796b);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
}
.requirement-confirm-chat-card-header .bi {
  font-size: 1.2rem;
  opacity: 0.95;
}
.requirement-confirm-chat-card-body {
  padding: 12px 16px;
}
.requirement-confirm-chat-card-section {
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e0f2f1;
}
.requirement-confirm-chat-card-section:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}
.requirement-confirm-chat-card-label {
  font-weight: 600;
  color: #004d40;
  font-size: 0.9rem;
  margin-bottom: 6px;
  line-height: 1.4;
}
.requirement-confirm-chat-card-content {
  color: #37474f;
  font-size: 0.88rem;
  line-height: 1.65;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.requirement-confirm-chat-card-content br {
  white-space: normal;
}
.message.user .bubble .requirement-confirm-chat-card {
  margin: 0;
}

.requirement-source-store {
  position: absolute !important;
  width: 0 !important;
  height: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  overflow: hidden !important;
}

.requirement-confirm-edit-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10050;
  background: rgba(0, 0, 0, 0.45);
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}
.requirement-confirm-edit-overlay.show {
  display: flex;
}
.requirement-confirm-edit-dialog {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
  max-width: min(720px, 100%);
  width: 100%;
  max-height: min(88vh, 720px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(0, 121, 107, 0.2);
}
.requirement-confirm-edit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  background: linear-gradient(135deg, #00695c, #00796b);
  color: #fff;
  flex-shrink: 0;
}
.requirement-confirm-edit-header h5 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}
.requirement-confirm-edit-header .btn-close {
  filter: invert(1);
  opacity: 0.9;
}
.requirement-confirm-edit-body {
  padding: 16px 18px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.requirement-confirm-edit-row {
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid #e0f2f1;
}
.requirement-confirm-edit-row:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}
.requirement-confirm-edit-field-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: #004d40;
  margin-bottom: 6px;
}
.requirement-confirm-edit-row .req-edit-title {
  margin-bottom: 8px;
}
.requirement-confirm-edit-row .req-edit-content {
  margin-bottom: 8px;
  resize: vertical;
  min-height: 72px;
}
.requirement-confirm-edit-row .req-edit-remove {
  width: 100%;
}
.requirement-confirm-edit-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 18px 16px;
  border-top: 1px solid #e0f2f1;
  background: #fafafa;
  flex-shrink: 0;
}
.requirement-confirm-edit-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

textarea.requirement-confirm-edit-fulltext {
  width: 100%;
  min-height: min(50vh, 420px);
  box-sizing: border-box;
  font-size: 0.875rem;
  line-height: 1.55;
  resize: vertical;
  font-family: ui-monospace, 'Cascadia Mono', 'Segoe UI Mono', 'Consolas', monospace;
}

/* 打字指示器：与输入区同属 .chat-bottom-stack，纵向 gap 与输入框分离，不再用 bottom 像素硬凑 */
.typing-indicator {
  position: relative;
  left: auto;
  right: auto;
  bottom: auto;
  margin-left: auto;
  margin-right: auto;
  width: fit-content;
  max-width: min(760px, calc(100% - 24px));
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0;
  pointer-events: none;
  z-index: 15;
  box-sizing: border-box;
  flex-shrink: 0;
}
.typing-indicator-inner {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  margin-left: auto;
  margin-right: auto;
  background: rgba(0, 121, 107, 0.08);
  border: 1px solid rgba(0, 121, 107, 0.12);
  border-radius: 12px;
  font-size: 13px;
  color: #00796b;
  box-shadow: 0 2px 12px rgba(0, 121, 107, 0.06);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  flex-shrink: 0;
}
.typing-indicator-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  border: 2px solid rgba(0, 121, 107, 0.2);
  border-top-color: #00796b;
  border-radius: 50%;
  animation: typing-spin 0.65s linear infinite;
}
@keyframes typing-spin {
  to { transform: rotate(360deg); }
}
.typing-indicator-text {
  font-weight: 500;
  letter-spacing: 0.02em;
}
.typing-wait-countdown {
  flex-shrink: 0;
  font-size: 14px;
  line-height: 1.25;
  font-weight: 600;
  color: #006056;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  max-width: 100%;
}
.typing-indicator .typing-dots {
  display: inline-flex;
  min-width: 1.2em;
}
.typing-indicator .typing-dots span {
  animation: typing-blink 1.2s ease-in-out infinite;
  opacity: 0.35;
}
.typing-indicator .typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator .typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing-blink {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

/* 中断输出：父级 pointer-events:none，仅按钮可点 */
.typing-cancel-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 4px;
  padding: 0;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 121, 107, 0.12);
  color: #c62828;
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
  transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
}
.typing-cancel-btn:hover {
  background: rgba(198, 40, 40, 0.12);
  color: #b71c1c;
}
.typing-cancel-btn:active {
  transform: scale(0.98);
}
.typing-cancel-btn:focus-visible {
  outline: 2px solid rgba(0, 121, 107, 0.45);
  outline-offset: 2px;
}

.chat-cancelled-hint {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed rgba(0, 121, 107, 0.25);
  font-size: 0.82rem;
  color: #78909c;
  font-style: italic;
}

/* 回到底部：当用户未在底部附近时提示 */
.scroll-to-bottom-btn {
  position: absolute;
  right: 20px;
  bottom: 200px; /* 高于底部输入+思考条整体，避免被遮挡 */
  z-index: 20;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 12px;
  background: rgba(0, 121, 107, 0.1);
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  border: 1px solid rgba(0, 121, 107, 0.22);
  color: #00796b;
  cursor: pointer;
  overflow: hidden; /* 防止按钮内部文本节点影响布局 */
  font-size: 0; /* 让按钮文本不显示（仅保留 i 图标） */
  box-shadow: 0 2px 12px rgba(0, 121, 107, 0.08);
  transition: opacity 0.2s ease, transform 0.2s ease, background 0.2s ease;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(8px);
}

.scroll-to-bottom-btn.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

.scroll-to-bottom-btn:hover {
  background: rgba(0, 121, 107, 0.16);
  box-shadow: 0 2px 16px rgba(0, 121, 107, 0.12);
  transform: translateY(0) scale(1.05);
}

.scroll-to-bottom-btn i {
  font-size: 1.15rem;
  line-height: 1;
}

@media (max-width: 768px) {
  .scroll-to-bottom-btn {
    right: 12px;
    bottom: 180px;
  }
}

/* 兼容旧 id="typing" 的简版样式 - 透明悬浮 */
.typing {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 72px;
  margin-left: auto;
  margin-right: auto;
  width: fit-content;
  max-width: 760px;
  padding: 10px 20px;
  color: #00796b;
  font-style: italic;
  background: rgba(0, 121, 107, 0.08);
  border: 1px solid rgba(0, 121, 107, 0.12);
  border-radius: 12px;
  font-size: 13px;
  text-align: center;
  pointer-events: none;
  z-index: 5;
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 12px rgba(0, 121, 107, 0.06);
}
.typing-dots span {
  animation: blink 1.4s infinite;
  opacity: 0;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink {
  0%, 100% { opacity: 0.2; }
  50% { opacity: 1; }
}

/* 底部：思考条 + 输入区同一列，gap 控制间距（不依赖 bottom 像素） */
.chat-bottom-stack {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
  width: 100%;
  padding: 0 14px 12px;
  box-sizing: border-box;
  pointer-events: none;
}
/* 底部输入区：对话意图 + 输入框 */
.chat-composer-bottom {
  position: relative;
  left: auto;
  right: auto;
  bottom: auto;
  z-index: auto;
  pointer-events: none;
  padding: 0;
  display: flex !important;
  flex-direction: column !important;
  flex-wrap: nowrap !important;
  align-items: center;
  justify-content: flex-end;
  width: 100%;
  max-width: 640px;
  box-sizing: border-box;
}
.chat-composer-bottom .chat-input-wrapper {
  flex: 0 0 auto;
}
.chat-composer-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  width: 100%;
  pointer-events: auto;
}
.chat-action-group {
  display: flex;
  flex-direction: row;
  gap: 6px;
  flex: 0 0 auto;
  width: 100%;
  justify-content: center;
}
.chat-composer-row .chat-input-wrapper {
  flex: 1 1 auto;
  min-width: 0;
  max-width: none;
}
.chat-composer-row .chat-input {
  max-width: none;
  margin: 0;
}
/* 输入区域优化 - 浮在消息区底部，绿色毛玻璃可透出背后滚动文字 */
.chat-input-wrapper {
  position: relative;
  left: auto;
  right: auto;
  bottom: auto;
  padding: 0;
  width: 100%;
  max-width: 760px;
  z-index: auto;
  pointer-events: none;
}
.chat-input-wrapper > .chat-input {
  pointer-events: auto;
}
.chat-input {
  position: relative;
  bottom: auto;
  overflow: visible !important;
  padding: 6px 10px !important;
  background: rgba(0, 121, 107, 0.10);
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  border-radius: 12px;
  border: 1px solid rgba(0, 121, 107, 0.16);
  box-shadow: 0 1px 8px rgba(0, 121, 107, 0.06);
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  transition: background 0.25s ease, box-shadow 0.25s ease;
  /* 输入区：上方选中文件列表 + 下方 input-group（按钮与 textarea）纵向排列 */
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
}
.chat-input:hover {
  background: rgba(0, 121, 107, 0.10);
  box-shadow: 0 1px 8px rgba(0, 121, 107, 0.06);
}
.chat-input .form-control,
.chat-input .input-group .form-control,
#user_msg {
  border: none !important;
  border-radius: 0 !important;
  padding: 5px 10px !important;
  font-size: 14px;
  resize: none;
  min-height: 32px;
  max-height: 120px;
  line-height: 1.45;
  background: transparent !important;
  background-color: transparent !important;
  box-shadow: none !important;
  outline: none !important;
  transition: none;
}
.chat-input textarea.form-control,
.chat-input #user_msg.form-control {
  border: 0 !important;
  box-shadow: none !important;
  outline: none !important;
  -webkit-appearance: none;
  appearance: none;
}
.chat-input .form-control::placeholder,
#user_msg::placeholder {
  color: rgba(0, 0, 0, 0.45);
  font-size: 13px;
}
.chat-input .form-control:focus,
#user_msg:focus {
  border: none !important;
  box-shadow: none !important;
  outline: none !important;
  background: transparent !important;
  background-color: transparent !important;
}
.chat-input .input-group:focus-within {
  box-shadow: none !important;
  border: none !important;
  background: transparent !important;
}
.chat-input .input-group {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  outline: none !important;
  border-radius: 0 !important;
  padding: 0;
  width: 100%;
  min-width: 0;
  flex: 0 0 auto;
}
.send-btn {
  width: 32px !important;
  height: 32px !important;
  min-width: 32px !important;
  min-height: 32px !important;
  flex-shrink: 0;
  border-radius: 8px !important;
  background: #28a745 !important;
  border: none !important;
  transition: background 0.2s ease;
  padding: 0 !important;
  font-size: 0.95rem !important;
  display: flex;
  align-items: center;
  justify-content: center;
}
.send-btn:hover {
  background: #218838 !important;
}
.send-btn:active {
  background: #1e7e34 !important;
}

/* 滚动条美化 */
.chat-messages::-webkit-scrollbar {
  width: 6px;
}
.chat-messages::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}
.chat-messages::-webkit-scrollbar-thumb {
  background: #adb5bd;
  border-radius: 10px;
}
.chat-messages::-webkit-scrollbar-thumb:hover {
  background: #6c757d;
}

/* ========== 交互细节优化 ========== */
.action-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  background: rgba(255,255,255,0.9);
  border: 1px solid #dee2e6;
  padding: 0 !important;
  color: #495057;
}
.action-btn:hover {
  background: #e8f5e9;
  border-color: #28a745;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(40,167,69,0.15);
  color: #28a745;
}
.btn-sm {
  padding: 6px 12px !important;
}

/* ========== 上传按钮样式 ========== */
.upload-btn {
  width: 30px !important;
  height: 30px !important;
  min-width: 30px !important;
  min-height: 30px !important;
  border-radius: 50% !important;
  background: transparent !important;
  border: none !important;
  color: #6c757d !important;
  transition: all 0.2s ease;
  padding: 0 !important;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}
.upload-btn:hover {
  background: rgba(108, 117, 125, 0.1) !important;
  color: #495057 !important;
  transform: scale(1.1);
}
.upload-btn:active {
  background: rgba(108, 117, 125, 0.2) !important;
  transform: scale(0.95);
}

/* ========== 输入区左侧：找方案 / 找产品（图标 + 文字） ========== */
.chat-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 36px;
  padding: 0 12px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  color: #0d6e63;
  background: rgba(0, 121, 107, 0.10);
  border: 1px solid rgba(0, 121, 107, 0.16);
  box-shadow: 0 1px 8px rgba(0, 121, 107, 0.06);
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  flex-shrink: 0;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.chat-action-btn:hover {
  background: rgba(0, 121, 107, 0.12);
  border-color: rgba(0, 121, 107, 0.22);
}
.chat-action-btn:focus-visible {
  outline: 2px solid rgba(0, 121, 107, 0.45);
  outline-offset: 2px;
}
.chat-action-btn .bi {
  font-size: 14px;
  line-height: 1;
}
@media (max-width: 575.98px) {
  .chat-composer-row {
    flex-direction: column;
    gap: 6px;
  }
  .chat-action-group {
    flex-direction: row;
    justify-content: flex-start;
    width: 100%;
  }
  .chat-action-btn {
    padding: 0 8px;
    height: 34px;
  }
}

/* ========== 已选文件列表样式 ========== */
.selected-files {
  margin-top: 8px;
  padding: 8px;
  background: #f8f9fa;
  border-radius: 8px;
  max-height: 120px;
  overflow-y: auto;
}
.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  margin-bottom: 4px;
  background: white;
  border-radius: 6px;
  border: 1px solid #dee2e6;
  font-size: 13px;
}
.file-item:last-child {
  margin-bottom: 0;
}
.file-item-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  overflow: hidden;
}
.file-item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-item-size {
  color: #6c757d;
  font-size: 11px;
  flex-shrink: 0;
}
.file-item-remove {
  background: none;
  border: none;
  color: #dc3545;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.2s;
}
.file-item-remove:hover {
  background: #f8d7da;
}


/* ========== 最终兜底：小屏侧边栏抽屉样式与布局修正 ========== */
@media (max-width: 992px) {
  .main-layout {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: unset !important;
    height: 100% !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }

  .chat-section {
    width: 100% !important;
    max-width: 100% !important;
    flex: 1 !important;
    min-height: 0 !important;
  }

  /* 侧边栏：默认隐藏在左侧，作为抽屉面板 */
  .sidebar-section {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 78%;
    max-width: 340px;
    z-index: 1055;
    transform: translateX(-100%);
    transition: transform 0.28s ease-out;
    box-shadow: 0 0 20px rgba(0,0,0,0.25);
    border-radius: 0 16px 16px 0;
  }

  .sidebar-section.is-open {
    transform: translateX(0);
  }

  /* 抽屉遮罩层 */
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 1050;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease;
  }

  .sidebar-backdrop.show {
    opacity: 1;
    visibility: visible;
  }

  /* 悬浮打开按钮（仅移动端显示） */
  .sidebar-toggle-btn {
    position: fixed;
    bottom: 80px;
    left: 16px;
    z-index: 1060;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: #ffffff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.16);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #00796b;
    font-size: 1.2rem;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
  }

  .sidebar-toggle-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(0,0,0,0.22);
    background: #e8f5e9;
  }
}

/* ========== 超小屏优化：防止顶部按钮压住标题（保留“返回主界面”按钮） ========== */
@media (max-width: 576px) {
  .chat-header {
    padding: 8px 8px !important;
    justify-content: center !important;
  }

  .chat-header .fw-bold {
    font-size: 1.0rem !important;
    flex: 1 1 auto;
    margin: 0 6px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* 左右按钮都参与正常布局，不再绝对定位覆盖标题 */
  .chat-header .header-actions,
  .chat-header .header-actions.header-actions-left {
    position: static;
  }

  .chat-header .header-actions.header-actions-left {
    margin-right: 4px;
  }

  .chat-header .header-actions {
    margin-left: 4px;
    gap: 6px;
  }

  .chat-header .header-actions .action-btn,
  .chat-header .header-actions.header-actions-left .action-btn {
    width: 30px;
    height: 30px;
    font-size: 0.9rem;
  }
}

/* ========== 移动端弹窗可滚动修复：避免内容多时输入区/底部按钮丢失 ========== */
@media (max-width: 768px) {
  #requirementModal .modal-dialog,
  #requirementConfirmModal .modal-dialog,
  #productRequirementModal .modal-dialog,
  #productRequirementConfirmModal .modal-dialog {
    margin: 0 !important;
    max-width: 100% !important;
    height: 100dvh !important;
  }

  #requirementModal .modal-content,
  #requirementConfirmModal .modal-content,
  #productRequirementModal .modal-content,
  #productRequirementConfirmModal .modal-content {
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    display: flex;
    flex-direction: column;
  }

  #requirementModal .modal-body,
  #requirementConfirmModal .modal-body,
  #productRequirementModal .modal-body,
  #productRequirementConfirmModal .modal-body {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  #requirementModal .modal-footer,
  #requirementConfirmModal .modal-footer,
  #productRequirementModal .modal-footer,
  #productRequirementConfirmModal .modal-footer {
    flex-shrink: 0;
  }

}

/* ========== 全屏布局（components 页面专用，从 components.html 内联样式迁入） ========== */
body.components-fullscreen { padding-top: 0 !important; }
body.components-fullscreen .main-content-wrapper {
  min-height: 100vh !important;
  padding-top: max(16px, env(safe-area-inset-top, 0px)) !important;
  padding-right: max(16px, env(safe-area-inset-right, 0px)) !important;
  padding-bottom: max(16px, env(safe-area-inset-bottom, 0px)) !important;
  padding-left: max(16px, env(safe-area-inset-left, 0px)) !important;
  box-sizing: border-box !important;
  display: flex !important;
  flex-direction: column !important;
}
body.components-fullscreen .main-content-wrapper .container {
  height: calc(100dvh - max(16px, env(safe-area-inset-top, 0px)) - max(16px, env(safe-area-inset-bottom, 0px))) !important;
  max-height: calc(100dvh - max(16px, env(safe-area-inset-top, 0px)) - max(16px, env(safe-area-inset-bottom, 0px))) !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  flex: 1 !important;
  min-height: 0 !important;
  display: flex !important;
  flex-direction: column !important;
}
body.components-fullscreen .main-layout {
  flex: 1 !important;
  min-height: 0 !important;
  height: 100% !important;
  align-items: stretch !important;
}
body.components-fullscreen .main-layout > .sidebar-section {
  min-height: 100% !important;
  align-self: stretch !important;
}
body.components-fullscreen .scheme-templates-section {
  top: 0 !important;
  height: 100% !important;
  max-height: 100% !important;
}

/* ========== components 全屏：桌面单外壳工作台（与 max-width 992 抽屉断点对齐） ========== */
@media (min-width: 992px) {
  body.components-fullscreen .main-content-wrapper {
    padding: 0 !important;
  }

  body.components-fullscreen .main-content-wrapper .container {
    height: 100dvh !important;
    max-height: 100dvh !important;
  }

  body.components-fullscreen .main-content-wrapper > .container {
    max-width: none !important;
  }

  body.components-fullscreen .main-layout {
    gap: 0 !important;
    max-width: none !important;
    background: transparent !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    border: 0 !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
  }

  body.components-fullscreen .main-layout > .sidebar-section {
    border-radius: 0 !important;
    box-shadow: none !important;
    border-right: 1px solid rgba(15, 118, 110, 0.16) !important;
    background: linear-gradient(180deg, #f0fdfa 0%, #e8f0f3 100%) !important;
    padding: 16px !important;
    transition: background-color 0.2s ease, border-color 0.2s ease !important;
  }

  body.components-fullscreen .main-layout > .sidebar-section:hover {
    box-shadow: none !important;
    transform: none !important;
    background: linear-gradient(180deg, #f0fdfa 0%, #e8f0f3 100%) !important;
  }

  body.components-fullscreen .main-layout > .chat-section {
    border-radius: 0 !important;
    box-shadow: none !important;
    border: 0 !important;
    background: #ffffff !important;
  }
}

/* 手机端：固定整页高度 = dvh，防止内容撑高导致输入区被挤出 */
@media (max-width: 992px) {
  body.components-fullscreen {
    height: 100dvh !important;
    width: 100vw !important;
    overflow: hidden !important;
  }
  body.components-fullscreen .main-content-wrapper {
    height: 100dvh !important;
    min-height: 0 !important;
    overflow: hidden !important;
    padding: 0 !important;
  }

  body.components-fullscreen .main-layout {
    width: 100% !important;
    min-height: 0 !important;
  }

  body.components-fullscreen #user_msg {
    font-size: 16px !important;
    line-height: 1.4 !important;
  }

  body.components-fullscreen .main-content-wrapper .container {
    width: 100vw !important;
    max-width: none !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
  }

  body.components-fullscreen .chat-container {
    padding: 0 !important;
    margin-bottom: 0 !important;
  }

  body.components-fullscreen .chat-section,
  body.components-fullscreen .chat-box {
    width: 100% !important;
    height: 100% !important;
  }
}
/* container 最大宽度限制 */
body.components-fullscreen .main-content-wrapper > .container {
  max-width: none;
  width: 100%;
}

/* ========== components 统一工作台：强制覆盖前文 gap（含 max-width:768 里 gap:24px） ========== */
body.components-fullscreen .main-layout {
  gap: 0 !important;
}

@media (max-width: 768px) {
  body.components-fullscreen .main-layout {
    gap: 0 !important;
  }
}

/* ========== V2 统一设计令牌与覆盖层（大改版基础） ========== */
:root {
  --ui-primary: #0f766e;
  --ui-primary-strong: #115e59;
  --ui-secondary: #14b8a6;
  --ui-accent: #0369a1;
  --ui-bg: #f0fdfa;
  --ui-surface: #ffffff;
  --ui-surface-muted: #f4faf9;
  --ui-text: #134e4a;
  --ui-text-muted: #4b6764;
  --ui-border: #99f6e4;
  --ui-danger: #dc2626;
  --ui-focus-ring: rgba(15, 118, 110, 0.28);
  --ui-radius-sm: 10px;
  --ui-radius-md: 12px;
  --ui-radius-lg: 16px;
  --ui-shadow-sm: 0 2px 8px rgba(15, 118, 110, 0.08);
  --ui-shadow-md: 0 10px 28px rgba(15, 118, 110, 0.13);
  --ui-space-1: 4px;
  --ui-space-2: 8px;
  --ui-space-3: 12px;
  --ui-space-4: 16px;
  --ui-space-5: 20px;
  --ui-space-6: 24px;
  --ui-dur-fast: 150ms;
  --ui-dur-mid: 220ms;
  --composer-offset: 132px;
}

body.components-fullscreen .chat-section {
  border-radius: 0 !important;
  border: 0 !important;
  background: var(--ui-surface) !important;
  box-shadow: none !important;
}

body.components-fullscreen .chat-header {
  padding: 10px 16px !important;
  background: transparent !important;
  border-bottom: 1px solid rgba(15, 118, 110, 0.1) !important;
}

body.components-fullscreen .chat-header .fw-bold {
  color: var(--ui-text);
}

@media (min-width: 992px) {
  body.components-fullscreen .main-layout > .sidebar-section .chat-history-list {
    padding-right: 6px;
  }

  body.components-fullscreen .main-layout > .sidebar-section .chat-history-item {
    background: rgba(255, 255, 255, 0.78);
    border-color: rgba(15, 118, 110, 0.12);
    box-shadow: none;
  }

  body.components-fullscreen .main-layout > .sidebar-section .chat-history-item:hover {
    background: rgba(204, 251, 241, 0.48) !important;
    border-color: rgba(15, 118, 110, 0.24) !important;
    box-shadow: none;
  }

  body.components-fullscreen .main-layout > .sidebar-section .chat-history-item.active {
    background: rgba(204, 251, 241, 0.68) !important;
    border-color: rgba(15, 118, 110, 0.34) !important;
    box-shadow: none;
  }

  body.components-fullscreen .main-layout > .sidebar-section .chat-history-item .history-title {
    color: var(--ui-text);
  }

  body.components-fullscreen .main-layout > .sidebar-section .chat-history-item .history-time {
    color: var(--ui-text-muted);
  }
}

body.components-fullscreen .chat-messages {
  background: var(--ui-surface) !important;
  padding: var(--ui-space-4) max(16px, calc((100% - 768px) / 2)) calc(var(--composer-offset) + 24px) max(16px, calc((100% - 768px) / 2)) !important;
  overscroll-behavior: contain;
}

body.components-fullscreen .chat-messages > .message,
body.components-fullscreen .chat-messages > .requirement-suggestion,
body.components-fullscreen .chat-messages > .error-message {
  width: 100%;
  max-width: 768px;
  margin-left: auto;
  margin-right: auto;
}

body.components-fullscreen .chat-bottom-stack {
  gap: var(--ui-space-3);
  padding: 0 var(--ui-space-3) var(--ui-space-3);
}

body.components-fullscreen .chat-input {
  background: rgba(20, 184, 166, 0.1);
  border: 1px solid rgba(15, 118, 110, 0.25);
  border-radius: var(--ui-radius-md);
  box-shadow: var(--ui-shadow-sm);
  transition: background var(--ui-dur-mid) ease, box-shadow var(--ui-dur-mid) ease, border-color var(--ui-dur-mid) ease;
}

body.components-fullscreen .chat-input:hover,
body.components-fullscreen .chat-input:focus-within {
  background: rgba(20, 184, 166, 0.1);
  border-color: rgba(15, 118, 110, 0.25);
  box-shadow: var(--ui-shadow-sm);
}

body.components-fullscreen .chat-messages > .requirement-suggestion {
  width: fit-content !important;
  max-width: min(768px, calc(100% - 32px));
  justify-content: center;
  text-align: center;
  padding: 6px 12px;
}

body.components-fullscreen .send-btn {
  border-radius: 9px !important;
  background: linear-gradient(135deg, var(--ui-primary), var(--ui-secondary)) !important;
  transition: transform var(--ui-dur-fast) ease, box-shadow var(--ui-dur-fast) ease, filter var(--ui-dur-fast) ease;
}

body.components-fullscreen .send-btn.is-stop {
  background: #1f2937 !important;
  filter: none;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.08) !important;
}

body.components-fullscreen .send-btn.is-stop:hover {
  background: #111827 !important;
  filter: none;
}

body.components-fullscreen .send-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--ui-shadow-sm);
  filter: brightness(0.98);
}

body.components-fullscreen .chat-action-btn,
body.components-fullscreen .upload-btn,
body.components-fullscreen .action-btn {
  transition: background var(--ui-dur-fast) ease, color var(--ui-dur-fast) ease, border-color var(--ui-dur-fast) ease, transform var(--ui-dur-fast) ease;
}

body.components-fullscreen .typing-indicator-inner {
  background: rgba(20, 184, 166, 0.1);
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: var(--ui-radius-md);
}

body.components-fullscreen .scroll-to-bottom-btn {
  bottom: calc(var(--composer-offset) + var(--ui-space-3));
  border-radius: var(--ui-radius-md);
  background: rgba(20, 184, 166, 0.16);
  border: 1px solid rgba(15, 118, 110, 0.25);
  color: var(--ui-primary);
}

body.components-fullscreen .scroll-to-bottom-btn:hover {
  background: rgba(20, 184, 166, 0.22);
}

@media (max-width: 992px) {
  :root {
    --composer-offset: 120px;
  }
}

@media (max-width: 768px) {
  :root {
    --composer-offset: 112px;
  }

  body.components-fullscreen .chat-messages {
    padding: var(--ui-space-5) var(--ui-space-4) calc(var(--composer-offset) + 18px) var(--ui-space-4) !important;
  }

  body.components-fullscreen .chat-header,
  body.components-fullscreen .chat-header .header-actions,
  body.components-fullscreen .chat-header .header-actions.header-actions-left {
    align-items: center !important;
  }

  body.components-fullscreen .chat-header .header-actions {
    top: 50% !important;
    transform: translateY(-50%);
  }

  body.components-fullscreen .chat-input {
    padding: 4px 8px !important;
  }

  body.components-fullscreen #user_msg {
    min-height: 30px !important;
    padding: 4px 8px !important;
    line-height: 1.35 !important;
  }

  body.components-fullscreen .chat-messages > .requirement-suggestion {
    max-width: calc(100% - 20px);
    margin-left: auto;
    margin-right: auto;
  }
}

@media (max-width: 576px) {
  body.components-fullscreen .chat-header {
    align-items: center !important;
  }

  body.components-fullscreen .chat-header .header-actions,
  body.components-fullscreen .chat-header .header-actions.header-actions-left {
    align-items: center !important;
    transform: none !important;
  }

  body.components-fullscreen .chat-header .action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.components-fullscreen .chat-input,
  body.components-fullscreen .send-btn,
  body.components-fullscreen .chat-action-btn,
  body.components-fullscreen .upload-btn,
  body.components-fullscreen .action-btn,
  body.components-fullscreen .scroll-to-bottom-btn {
    transition: none !important;
  }
}

/* ========== V2 可访问性与响应式收口 ========== */
body.components-fullscreen .chat-action-btn:focus-visible,
body.components-fullscreen .action-btn:focus-visible,
body.components-fullscreen .upload-btn:focus-visible,
body.components-fullscreen .send-btn:focus-visible,
body.components-fullscreen .scroll-to-bottom-btn:focus-visible,
body.components-fullscreen .typing-cancel-btn:focus-visible {
  outline: 2px solid rgba(15, 118, 110, 0.52);
  outline-offset: 2px;
}

body.components-fullscreen .chat-action-btn,
body.components-fullscreen .upload-btn,
body.components-fullscreen .send-btn,
body.components-fullscreen .action-btn,
body.components-fullscreen .typing-cancel-btn {
  min-width: 32px;
  min-height: 32px;
}

@media (max-width: 768px) {
  body.components-fullscreen .chat-action-btn,
  body.components-fullscreen .upload-btn,
  body.components-fullscreen .send-btn,
  body.components-fullscreen .action-btn,
  body.components-fullscreen .typing-cancel-btn {
    min-width: 36px;
    min-height: 36px;
  }
}

body.components-fullscreen .typing-indicator-text,
body.components-fullscreen .typing-wait-countdown {
  color: #0f5f57;
}

/* 产品需求：选「电池检测维护」时隐藏直流输入列（:has 作后备，主逻辑在 sections.js updateInputOptions） */
#requirementForm:has(#product_category_battery_maint:checked) #input_category_dc_col {
  display: none !important;
}
