/* =========================================================================
   IMA Chat UI —— 聊天组件样式
   -------------------------------------------------------------------------
   · 所有类名统一使用 `ima-chat-` 前缀，避免污染宿主页面（seat-ui 等）。
   · 所有设计变量都定义在 `.ima-chat-root` 上（不写 :root），可局部覆盖。
   · 只依赖原生 CSS，无预处理器、无构建链。
   · 主色沿用 IMA seat-ui 的 teal #0f766e。
   ========================================================================= */

/* ---------- 根容器与设计变量 ---------- */
.ima-chat-root {
  /* 品牌色 */
  --ima-teal: #0f766e;
  --ima-teal-600: #0d9488;
  --ima-teal-700: #0b5f59;
  --ima-teal-50: #f0fdfa;
  --ima-teal-100: #ccfbf1;
  --ima-teal-200: #99f6e4;

  /* 中性色 */
  --ima-bg: #f6f8fa;
  --ima-surface: #ffffff;
  --ima-surface-2: #f9fafb;
  --ima-border: #e6eaef;
  --ima-border-strong: #d7dde5;
  --ima-ink: #1f2937;
  --ima-ink-2: #4b5563;
  --ima-muted: #8a94a6;

  /* 语义色 */
  --ima-success: #15803d;
  --ima-success-bg: #ecfdf5;
  --ima-warn: #b45309;
  --ima-warn-bg: #fffbeb;
  --ima-danger: #c0392b;
  --ima-danger-bg: #fef2f2;
  --ima-info: #1d4ed8;
  --ima-info-bg: #eef2ff;
  --ima-orange: #c2410c;
  --ima-orange-bg: #fff7ed;

  /* 尺寸 */
  --ima-radius: 14px;
  --ima-radius-sm: 10px;
  --ima-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
  --ima-shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --ima-max-width: 860px;

  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 320px;
  overflow: hidden;
  background: var(--ima-bg);
  color: var(--ima-ink);
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  text-align: left;
  isolation: isolate;
}

/* 宿主页往往有全局 reset，这里在组件内部收敛一下 */
.ima-chat-root *,
.ima-chat-root *::before,
.ima-chat-root *::after {
  box-sizing: border-box;
}
.ima-chat-root button {
  margin: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  line-height: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.ima-chat-root button:disabled {
  cursor: not-allowed;
}
.ima-chat-root textarea {
  font: inherit;
  color: inherit;
}
.ima-chat-root a {
  color: var(--ima-teal);
  text-decoration: none;
}
.ima-chat-root a:hover {
  text-decoration: underline;
}
.ima-chat-root code,
.ima-chat-root pre {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

/* ---------- 顶部标题栏 ---------- */
.ima-chat-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: rgba(255, 255, 255, .88);
  border-bottom: 1px solid var(--ima-border);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  z-index: 5;
}
.ima-chat-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.ima-chat-logo {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--ima-teal) 0%, #14b8a6 100%);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .5px;
  box-shadow: 0 4px 10px rgba(15, 118, 110, .28);
}
.ima-chat-headtext {
  min-width: 0;
}
.ima-chat-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--ima-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ima-chat-subtitle {
  font-size: 12px;
  color: var(--ima-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ima-chat-header-spacer {
  flex: 1 1 auto;
}
.ima-chat-mode {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--ima-surface-2);
  border: 1px solid var(--ima-border);
  color: var(--ima-muted);
  font-size: 12px;
  white-space: nowrap;
}
.ima-chat-mode-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #cbd5e1;
}
.ima-chat-mode.is-online {
  color: var(--ima-success);
  background: var(--ima-success-bg);
  border-color: #bbf7d0;
}
.ima-chat-mode.is-online .ima-chat-mode-dot {
  background: var(--ima-success);
}
.ima-chat-mode.is-demo {
  color: var(--ima-warn);
  background: var(--ima-warn-bg);
  border-color: #fde68a;
}
.ima-chat-mode.is-demo .ima-chat-mode-dot {
  background: #f59e0b;
}
.ima-chat-iconbtn {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: var(--ima-muted);
  transition: background .15s, color .15s;
}
.ima-chat-iconbtn:hover {
  background: var(--ima-surface-2);
  color: var(--ima-ink-2);
}
.ima-chat-iconbtn svg {
  width: 17px;
  height: 17px;
}

/* ---------- 消息滚动区 ---------- */
.ima-chat-body {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 22px 20px 10px;
  overscroll-behavior: contain;
}
.ima-chat-body::-webkit-scrollbar {
  width: 10px;
}
.ima-chat-body::-webkit-scrollbar-thumb {
  background: #d8dee7;
  border: 3px solid transparent;
  border-radius: 8px;
  background-clip: padding-box;
}
.ima-chat-body::-webkit-scrollbar-thumb:hover {
  background: #c2cad6;
  background-clip: padding-box;
  border: 3px solid transparent;
}
.ima-chat-inner {
  width: 100%;
  max-width: var(--ima-max-width);
  margin: 0 auto;
}
/* 消息较少时贴近输入框（类微信/ChatGPT 的对话流），内容超高时正常从顶部滚动 */
.ima-chat-inner.has-messages {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 100%;
}
/* 只有首条欢迎语时垂直居中，避免大面积空白 */
.ima-chat-inner.is-lonely {
  justify-content: center;
}

/* ---------- 空状态 / 欢迎语 ---------- */
.ima-chat-welcome {
  padding: 40px 8px 28px;
  text-align: center;
  animation: ima-chat-fade .35s ease both;
}
.ima-chat-welcome-logo {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--ima-teal) 0%, #14b8a6 100%);
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  box-shadow: 0 10px 26px rgba(15, 118, 110, .26);
}
.ima-chat-welcome h2 {
  margin: 0 0 6px;
  font-size: 19px;
  font-weight: 700;
  color: var(--ima-ink);
}
.ima-chat-welcome p {
  margin: 0 auto;
  max-width: 460px;
  color: var(--ima-muted);
  font-size: 13.5px;
}
.ima-chat-welcome-tips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 18px;
}
.ima-chat-welcome-tip {
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--ima-border);
  background: var(--ima-surface);
  color: var(--ima-ink-2);
  font-size: 13px;
  transition: .15s;
}
.ima-chat-welcome-tip:hover {
  border-color: var(--ima-teal-200);
  background: var(--ima-teal-50);
  color: var(--ima-teal);
}

/* ---------- 消息行 ---------- */
.ima-chat-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 18px;
  animation: ima-chat-rise .22s ease both;
}
.ima-chat-row.is-user {
  flex-direction: row-reverse;
}
.ima-chat-row.is-system {
  justify-content: center;
}
.ima-chat-avatar {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  margin-top: 20px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .3px;
  user-select: none;
}
.ima-chat-avatar.is-assistant {
  background: linear-gradient(135deg, var(--ima-teal) 0%, #14b8a6 100%);
  color: #fff;
  box-shadow: 0 3px 8px rgba(15, 118, 110, .24);
}
.ima-chat-avatar.is-user {
  background: #e8edf3;
  color: #475569;
}
.ima-chat-avatar.is-system {
  background: var(--ima-warn-bg);
  color: var(--ima-warn);
}
.ima-chat-main {
  min-width: 0;
  max-width: min(78%, 680px);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ima-chat-row.is-user .ima-chat-main {
  align-items: flex-end;
}
.ima-chat-row.is-system .ima-chat-main {
  max-width: 100%;
  width: 100%;
  align-items: center;
}
.ima-chat-row.is-system .ima-chat-avatar {
  display: none;
}
.ima-chat-row.is-system .ima-chat-meta {
  justify-content: center;
}

/* 带卡片的行：让卡片撑满可用宽度，气泡仍按内容自适应 */
.ima-chat-row.has-cards .ima-chat-main {
  width: 100%;
}
.ima-chat-row.has-cards .ima-chat-cards {
  width: 100%;
}
.ima-chat-row.has-cards .ima-chat-bubble {
  align-self: flex-start;
}
.ima-chat-row.is-user.has-cards .ima-chat-bubble {
  align-self: flex-end;
}
.ima-chat-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 2px;
  font-size: 11.5px;
  color: var(--ima-muted);
  line-height: 1.4;
}
.ima-chat-meta-name {
  font-weight: 600;
  color: var(--ima-ink-2);
}
.ima-chat-row.is-user .ima-chat-meta {
  justify-content: flex-end;
}
.ima-chat-meta-time {
  font-variant-numeric: tabular-nums;
  opacity: .85;
}

/* ---------- 气泡 ---------- */
.ima-chat-bubble {
  position: relative;
  max-width: 100%;
  padding: 11px 15px;
  border-radius: var(--ima-radius);
  background: var(--ima-surface);
  border: 1px solid var(--ima-border);
  box-shadow: var(--ima-shadow-sm);
  color: var(--ima-ink);
  font-size: 14.5px;
  line-height: 1.72;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.ima-chat-row.is-assistant .ima-chat-bubble {
  border-top-left-radius: 5px;
}
.ima-chat-row.is-user .ima-chat-bubble {
  background: var(--ima-teal);
  border-color: var(--ima-teal);
  color: #fff;
  border-top-right-radius: 5px;
  box-shadow: 0 4px 14px rgba(15, 118, 110, .18);
}
.ima-chat-row.is-user .ima-chat-bubble a {
  color: #ccfbf1;
}
.ima-chat-bubble.is-error {
  background: var(--ima-danger-bg);
  border-color: #fecaca;
  color: #7f1d1d;
}
.ima-chat-bubble.is-narrow {
  padding: 8px 13px;
}

/* 流式光标 */
.ima-chat-cursor {
  display: inline-block;
  width: 2px;
  height: 1.05em;
  margin-left: 2px;
  vertical-align: -2px;
  border-radius: 1px;
  background: var(--ima-teal);
  animation: ima-chat-blink 1s steps(2, start) infinite;
}
.ima-chat-row.is-user .ima-chat-cursor {
  background: #fff;
}
@keyframes ima-chat-blink {
  0%, 45% { opacity: 1; }
  46%, 100% { opacity: 0; }
}

/* 思考中三点 */
.ima-chat-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
}
.ima-chat-typing i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ima-teal-600);
  opacity: .45;
  animation: ima-chat-dot 1.2s infinite ease-in-out;
}
.ima-chat-typing i:nth-child(2) { animation-delay: .15s; }
.ima-chat-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes ima-chat-dot {
  0%, 60%, 100% { transform: translateY(0); opacity: .35; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* 中断标记 */
.ima-chat-aborted {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f1f5f9;
  color: var(--ima-muted);
  font-size: 11px;
  line-height: 1.6;
}

/* ---------- Markdown 渲染 ---------- */
.ima-chat-md > *:first-child { margin-top: 0; }
.ima-chat-md > *:last-child { margin-bottom: 0; }
.ima-chat-md p {
  margin: 0 0 8px;
}
.ima-chat-md h1,
.ima-chat-md h2,
.ima-chat-md h3,
.ima-chat-md h4 {
  margin: 14px 0 7px;
  font-weight: 700;
  line-height: 1.4;
}
.ima-chat-md h1 { font-size: 17px; }
.ima-chat-md h2 { font-size: 16px; }
.ima-chat-md h3 { font-size: 15px; }
.ima-chat-md h4 { font-size: 14px; }
.ima-chat-md ul,
.ima-chat-md ol {
  margin: 0 0 8px;
  padding-left: 21px;
}
.ima-chat-md li {
  margin: 2px 0;
}
.ima-chat-md li > ul,
.ima-chat-md li > ol {
  margin: 2px 0;
}
.ima-chat-md strong {
  font-weight: 700;
}
.ima-chat-md em {
  font-style: italic;
}

/* ---------- 关键词高亮（航班号 / 操作卡号 / 状态 / 时间 / 场景） ---------- */
.ima-chat-hl-flight,
.ima-chat-hl-op,
.ima-chat-hl-status,
.ima-chat-hl-time,
.ima-chat-hl-scene {
  padding: 0 3px;
  border-radius: 4px;
  font-weight: 600;
  white-space: nowrap;
}

/* 航班号：品牌 teal */
.ima-chat-hl-flight {
  color: var(--ima-teal-700);
  background: var(--ima-teal-50);
  border: 1px solid var(--ima-teal-100);
  font-variant-numeric: tabular-nums;
  letter-spacing: .2px;
}

/* 操作卡号：信息蓝 */
.ima-chat-hl-op {
  color: var(--ima-info);
  background: var(--ima-info-bg);
  border: 1px solid #dbe4ff;
}

/* 状态词：警示橙 */
.ima-chat-hl-status {
  color: var(--ima-warn);
  background: var(--ima-warn-bg);
  border: 1px solid #fde9c8;
}

/* 时间戳：中性深灰 + 等宽数字 */
.ima-chat-hl-time {
  color: var(--ima-ink-2);
  background: var(--ima-surface-2);
  border: 1px solid var(--ima-border);
  font-variant-numeric: tabular-nums;
}

/* 场景词：柔和青灰 */
.ima-chat-hl-scene {
  color: #0e7490;
  background: #ecfeff;
  border: 1px solid #cffafe;
}

/* 用户气泡（teal 底）内的高亮：统一用半透明白底，保证对比度 */
.ima-chat-row.is-user .ima-chat-hl-flight,
.ima-chat-row.is-user .ima-chat-hl-op,
.ima-chat-row.is-user .ima-chat-hl-status,
.ima-chat-row.is-user .ima-chat-hl-time,
.ima-chat-row.is-user .ima-chat-hl-scene {
  color: #ffffff;
  background: rgba(255, 255, 255, .2);
  border-color: rgba(255, 255, 255, .34);
}
.ima-chat-md hr {
  margin: 12px 0;
  border: 0;
  border-top: 1px solid var(--ima-border);
}
.ima-chat-md blockquote {
  margin: 8px 0;
  padding: 6px 12px;
  border-left: 3px solid var(--ima-teal-200);
  background: var(--ima-teal-50);
  border-radius: 0 8px 8px 0;
  color: var(--ima-ink-2);
}
.ima-chat-tablewrap {
  margin: 8px 0;
  overflow-x: auto;
  border: 1px solid var(--ima-border);
  border-radius: 8px;
}
.ima-chat-md table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.ima-chat-md th,
.ima-chat-md td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--ima-border);
  text-align: left;
  white-space: nowrap;
}
.ima-chat-md th {
  background: #f8fafc;
  font-weight: 600;
  color: var(--ima-ink-2);
}
.ima-chat-md tbody tr:last-child td { border-bottom: 0; }
.ima-chat-md code {
  padding: 1.5px 5px;
  border-radius: 5px;
  background: #f1f5f9;
  color: #0f4c48;
  font-size: .88em;
  border: 1px solid #e8edf3;
}
.ima-chat-row.is-user .ima-chat-md code {
  background: rgba(255, 255, 255, .18);
  border-color: rgba(255, 255, 255, .22);
  color: #fff;
}
.ima-chat-md pre {
  position: relative;
  margin: 8px 0;
  padding: 12px 14px;
  border-radius: var(--ima-radius-sm);
  background: #0f1e25;
  color: #dbeafe;
  font-size: 12.5px;
  line-height: 1.65;
  overflow-x: auto;
  white-space: pre;
  tab-size: 2;
}
.ima-chat-md pre code {
  display: block;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font-size: inherit;
  white-space: inherit;
}
.ima-chat-code-lang {
  position: absolute;
  top: 7px;
  right: 10px;
  font-size: 10.5px;
  letter-spacing: .4px;
  text-transform: uppercase;
  color: #7c93a3;
  user-select: none;
  pointer-events: none;
  transition: opacity .15s;
}
.ima-chat-code-copy {
  position: absolute;
  top: 5px;
  right: 6px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, .1);
  color: #b9cbd8;
  font-size: 11px;
  opacity: 0;
  transition: .15s;
}
.ima-chat-md pre:hover .ima-chat-code-copy { opacity: 1; }
.ima-chat-code-copy:hover { background: rgba(255, 255, 255, .2); color: #fff; }
.ima-chat-md pre:hover .ima-chat-code-lang { opacity: 0; }

/* ---------- 结构化卡片：通用 ---------- */
.ima-chat-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}
.ima-chat-card {
  background: var(--ima-surface);
  border: 1px solid var(--ima-border);
  border-radius: var(--ima-radius);
  box-shadow: var(--ima-shadow-sm);
  padding: 12px 14px;
  animation: ima-chat-rise .24s ease both;
}
.ima-chat-row.is-user .ima-chat-card {
  border-top-right-radius: 5px;
}
.ima-chat-row.is-assistant .ima-chat-card {
  border-top-left-radius: 5px;
}
.ima-chat-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.ima-chat-card-title {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ima-ink);
}
.ima-chat-card-head > .ima-chat-badge {
  margin-left: auto;
}
.ima-chat-card-summary {
  margin: 2px 0 8px;
  font-size: 12.5px;
  color: var(--ima-muted);
}
.ima-chat-card-desc {
  margin: 4px 0 10px;
  font-size: 13.5px;
  color: var(--ima-ink-2);
}
.ima-chat-card-foot {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--ima-border);
  font-size: 11.5px;
  color: var(--ima-muted);
}

/* 场景标签（flight / weather / flow ...） */
.ima-chat-tag {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 6px;
  background: var(--ima-teal-50);
  border: 1px solid #d3f0eb;
  color: var(--ima-teal);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .2px;
  white-space: nowrap;
  margin-right: 6px;
  flex-shrink: 0;
}
.ima-chat-tag.is-action {
  background: var(--ima-orange-bg);
  border-color: #fed7aa;
  color: var(--ima-orange);
}

/* ---------- 状态徽章 ---------- */
.ima-chat-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .2px;
  white-space: nowrap;
  background: #f1f5f9;
  color: #475569;
}
.ima-chat-badge::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: .75;
}
.ima-chat-badge.tone-success { background: var(--ima-success-bg); color: var(--ima-success); }
.ima-chat-badge.tone-warn { background: var(--ima-warn-bg); color: var(--ima-warn); }
.ima-chat-badge.tone-danger { background: var(--ima-danger-bg); color: var(--ima-danger); }
.ima-chat-badge.tone-info { background: var(--ima-info-bg); color: var(--ima-info); }
.ima-chat-badge.tone-orange { background: var(--ima-orange-bg); color: var(--ima-orange); }
.ima-chat-badge.tone-muted { background: #f3f4f6; color: #6b7280; }
.ima-chat-badge.tone-teal { background: var(--ima-teal-50); color: var(--ima-teal); }

/* ---------- 查询结果卡片 ---------- */
.ima-chat-qlist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ima-chat-qitem {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 4px 10px;
  padding: 9px 11px;
  border-radius: var(--ima-radius-sm);
  background: var(--ima-surface-2);
  border: 1px solid #eef2f6;
  transition: border-color .15s, background .15s;
}
.ima-chat-qitem:hover {
  border-color: var(--ima-teal-200);
  background: var(--ima-teal-50);
}
.ima-chat-qitem-main {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
}
.ima-chat-flight {
  font-family: "SFMono-Regular", Consolas, Menlo, monospace;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: .3px;
  color: var(--ima-ink);
  background: #fff;
  border: 1px solid var(--ima-border);
  border-radius: 6px;
  padding: 1px 7px;
}
.ima-chat-qitem-title {
  font-size: 13px;
  color: var(--ima-ink-2);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ima-chat-qitem-route {
  font-size: 11.5px;
  color: var(--ima-muted);
}
.ima-chat-qitem-side {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}
.ima-chat-qitem-time {
  font-size: 12px;
  color: var(--ima-ink-2);
  font-variant-numeric: tabular-nums;
}
.ima-chat-qitem-note {
  grid-column: 1 / -1;
  font-size: 11.5px;
  color: var(--ima-muted);
  line-height: 1.5;
}

/* ---------- 待确认动作卡片 ---------- */
.ima-chat-card--action {
  border-color: #fde68a;
  background: linear-gradient(180deg, #fffdf6 0%, #ffffff 60%);
  box-shadow: 0 1px 2px rgba(180, 83, 9, .05), 0 8px 22px rgba(180, 83, 9, .08);
}
.ima-chat-card--action .ima-chat-card-head {
  margin-bottom: 8px;
}
.ima-chat-kv {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 14px;
  margin: 8px 0 12px;
  padding: 9px 11px;
  border-radius: var(--ima-radius-sm);
  background: rgba(255, 255, 255, .75);
  border: 1px solid #f3e8c8;
  font-size: 12.5px;
}
.ima-chat-kv-k {
  color: var(--ima-muted);
  white-space: nowrap;
}
.ima-chat-kv-v {
  color: var(--ima-ink);
  font-weight: 600;
  word-break: break-word;
}
.ima-chat-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.ima-chat-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 13.5px;
  font-weight: 600;
  transition: transform .1s, background .15s, border-color .15s, opacity .15s;
}
.ima-chat-btn:active:not(:disabled) {
  transform: translateY(1px);
}
.ima-chat-btn.is-primary {
  background: var(--ima-teal);
  color: #fff;
  box-shadow: 0 4px 12px rgba(15, 118, 110, .24);
}
.ima-chat-btn.is-primary:hover:not(:disabled) {
  background: var(--ima-teal-700);
}
.ima-chat-btn.is-confirm {
  background: var(--ima-success);
  color: #fff;
  box-shadow: 0 4px 12px rgba(21, 128, 61, .22);
}
.ima-chat-btn.is-confirm:hover:not(:disabled) { background: #166534; }
.ima-chat-btn.is-danger {
  background: var(--ima-danger);
  color: #fff;
}
.ima-chat-btn.is-danger:hover:not(:disabled) { background: #a93226; }
.ima-chat-btn.is-ghost {
  background: #fff;
  border-color: var(--ima-border-strong);
  color: var(--ima-ink-2);
}
.ima-chat-btn.is-ghost:hover:not(:disabled) {
  border-color: #9ca3af;
  background: var(--ima-surface-2);
}
.ima-chat-btn:disabled {
  opacity: .5;
}
.ima-chat-resolved {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 4px;
  padding: 8px 11px;
  border-radius: var(--ima-radius-sm);
  background: var(--ima-success-bg);
  border: 1px solid #bbf7d0;
  color: var(--ima-success);
  font-size: 12.5px;
  font-weight: 600;
}

/* ---------- 系统提示条 ---------- */
.ima-chat-sysnote {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border-radius: 9px;
  background: #f1f5f9;
  border: 1px solid var(--ima-border);
  color: #52606f;
  font-size: 12.5px;
  line-height: 1.6;
}
.ima-chat-sysnote-icon {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin-top: 1px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #94a3b8;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  font-style: normal;
}
.ima-chat-sysnote-text {
  min-width: 0;
}
.ima-chat-sysnote-text p {
  margin: 0;
}
.ima-chat-sysnote.is-info {
  background: var(--ima-info-bg);
  border-color: #dbeafe;
  color: #1e40af;
}
.ima-chat-sysnote.is-info .ima-chat-sysnote-icon { background: #3b82f6; }
.ima-chat-sysnote.is-success {
  background: var(--ima-success-bg);
  border-color: #bbf7d0;
  color: #166534;
}
.ima-chat-sysnote.is-success .ima-chat-sysnote-icon { background: var(--ima-success); }
.ima-chat-sysnote.is-warn {
  background: var(--ima-warn-bg);
  border-color: #fde68a;
  color: #92400e;
}
.ima-chat-sysnote.is-warn .ima-chat-sysnote-icon { background: #f59e0b; }
.ima-chat-sysnote.is-error {
  background: var(--ima-danger-bg);
  border-color: #fecaca;
  color: #991b1b;
}
.ima-chat-sysnote.is-error .ima-chat-sysnote-icon { background: var(--ima-danger); }

/* 系统角色整行提示 */
.ima-chat-row.is-system .ima-chat-bubble {
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
  width: 100%;
  font-size: 12.5px;
  color: var(--ima-muted);
}

/* ---------- 消息操作（复制 / 重新生成） ---------- */
.ima-chat-msg-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 2px;
  opacity: 0;
  transition: opacity .15s;
}
.ima-chat-row:hover .ima-chat-msg-actions,
.ima-chat-row:focus-within .ima-chat-msg-actions {
  opacity: 1;
}
.ima-chat-msg-actions.is-visible {
  opacity: 1;
}
.ima-chat-actbtn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 26px;
  padding: 0 8px;
  border-radius: 7px;
  color: var(--ima-muted);
  font-size: 11.5px;
  transition: background .15s, color .15s;
}
.ima-chat-actbtn:hover {
  background: #eef2f6;
  color: var(--ima-ink-2);
}
.ima-chat-actbtn svg {
  width: 13px;
  height: 13px;
}

@media (hover: none) {
  .ima-chat-msg-actions { opacity: 1; }
}

/* ---------- 底部输入区 ---------- */
.ima-chat-composer {
  flex: 0 0 auto;
  padding: 8px 20px 14px;
  background: linear-gradient(180deg, rgba(246, 248, 250, 0) 0%, var(--ima-bg) 45%);
}
.ima-chat-composer-inner {
  max-width: var(--ima-max-width);
  margin: 0 auto;
}

/* 快捷指令 chips */
.ima-chat-chips {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 2px 1px 9px;
  scrollbar-width: none;
}
.ima-chat-chips::-webkit-scrollbar {
  display: none;
}
.ima-chat-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--ima-surface);
  border: 1px solid var(--ima-border);
  color: var(--ima-ink-2);
  font-size: 12.5px;
  white-space: nowrap;
  box-shadow: var(--ima-shadow-sm);
  transition: .15s;
}
.ima-chat-chip:hover:not(:disabled) {
  border-color: var(--ima-teal-200);
  background: var(--ima-teal-50);
  color: var(--ima-teal);
  transform: translateY(-1px);
}
.ima-chat-chip:disabled {
  opacity: .55;
}
.ima-chat-chip-icon {
  font-size: 12px;
  opacity: .8;
}

/* 输入框 */
.ima-chat-inputbox {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 7px 7px 7px 14px;
  border-radius: 16px;
  background: var(--ima-surface);
  border: 1px solid var(--ima-border-strong);
  box-shadow: var(--ima-shadow);
  transition: border-color .15s, box-shadow .15s;
}
.ima-chat-inputbox:focus-within {
  border-color: var(--ima-teal-600);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, .13), var(--ima-shadow);
}
.ima-chat-inputbox textarea {
  flex: 1 1 auto;
  min-width: 0;
  max-height: 132px;
  padding: 8px 0;
  border: 0;
  outline: none;
  background: transparent;
  resize: none;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ima-ink);
  overflow-y: auto;
}
.ima-chat-inputbox textarea::placeholder {
  color: #a3adbd;
}
.ima-chat-send {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 38px;
  min-width: 76px;
  padding: 0 15px;
  border-radius: 11px;
  background: var(--ima-teal);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: 0 3px 10px rgba(15, 118, 110, .26);
  transition: background .15s, opacity .15s, transform .1s;
}
.ima-chat-send:hover:not(:disabled) {
  background: var(--ima-teal-700);
}
.ima-chat-send:active:not(:disabled) {
  transform: translateY(1px);
}
.ima-chat-send:disabled {
  background: #cbd5e1;
  box-shadow: none;
  opacity: .8;
}
.ima-chat-send.is-stop {
  background: #fff;
  border: 1px solid #fecaca;
  color: var(--ima-danger);
  box-shadow: var(--ima-shadow-sm);
}
.ima-chat-send.is-stop:hover {
  background: var(--ima-danger-bg);
}
.ima-chat-send svg {
  width: 15px;
  height: 15px;
}
.ima-chat-hint {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 4px 0;
  font-size: 11px;
  color: #a3adbd;
}
.ima-chat-hint kbd {
  padding: 1px 4px;
  border-radius: 4px;
  background: #eef2f6;
  border: 1px solid #e2e8f0;
  font-family: inherit;
  font-size: 10.5px;
}

/* ---------- 轻提示 toast ---------- */
.ima-chat-toast {
  position: absolute;
  left: 50%;
  bottom: 152px;
  transform: translateX(-50%) translateY(6px);
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(31, 41, 55, .92);
  color: #fff;
  font-size: 12.5px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity .18s, transform .18s;
  z-index: 30;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .2);
}
.ima-chat-toast.is-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- 动画 ---------- */
@keyframes ima-chat-rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes ima-chat-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .ima-chat-root *,
  .ima-chat-root *::before,
  .ima-chat-root *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
  .ima-chat-header { padding: 10px 14px; }
  .ima-chat-body { padding: 16px 12px 6px; }
  .ima-chat-composer { padding: 6px 12px 10px; }
  .ima-chat-main { max-width: 86%; }
  .ima-chat-avatar { width: 26px; height: 26px; margin-top: 19px; font-size: 10.5px; }
  .ima-chat-bubble { padding: 10px 13px; font-size: 14px; }
  .ima-chat-subtitle { display: none; }
  .ima-chat-hint span:last-child { display: none; }
  .ima-chat-send { min-width: 44px; padding: 0 12px; }
  .ima-chat-send-label { display: none; }
  .ima-chat-qitem { grid-template-columns: 1fr; }
  .ima-chat-qitem-side { justify-content: flex-start; }
  .ima-chat-toast { bottom: 132px; }
}
