/* 玄果AI CAD 聊天浮窗样式（自包含，注入所有页面右下角） */
#xgai-root * { box-sizing: border-box; margin: 0; padding: 0; }
#xgai-root {
  --xgai-bg: #0d1117;
  --xgai-panel: #161b22;
  --xgai-border: #30363d;
  --xgai-text: #d2dce6;
  --xgai-muted: #8b949e;
  --xgai-accent: #58a6ff;
  --xgai-accent2: #a371f7;
  position: fixed; right: 20px; bottom: 20px; z-index: 2147483000;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px; line-height: 1.5; color: var(--xgai-text);
}
#xgai-toggle {
  display: flex; align-items: center; gap: 8px;
  background: linear-gradient(135deg, #4b2a8a, #7a3fd0);
  color: #fff; border: 1px solid rgba(255,255,255,.15);
  border-radius: 999px; padding: 10px 18px; cursor: pointer;
  font-size: 14px; font-weight: 600; box-shadow: 0 4px 20px rgba(0,0,0,.45);
  transition: transform .12s ease;
}
#xgai-toggle:hover { transform: translateY(-2px); }
#xgai-toggle .xgai-dot {
  width: 9px; height: 9px; border-radius: 50%; background: #4ade80;
  box-shadow: 0 0 6px #4ade80; flex: none;
}
#xgai-toggle.xgai-off .xgai-dot { background: #f87171; box-shadow: 0 0 6px #f87171; }
#xgai-panel {
  display: none; width: 400px; max-width: calc(100vw - 32px); height: 560px; max-height: calc(100vh - 120px);
  background: var(--xgai-panel); border: 1px solid var(--xgai-border); border-radius: 14px;
  box-shadow: 0 12px 48px rgba(0,0,0,.6); overflow: hidden; flex-direction: column;
  position: fixed; right: 20px; bottom: 78px; z-index: 2147483001;
}
#xgai-root.xgai-open #xgai-panel { display: flex; }
#xgai-panel.xgai-wide { width: 640px; }
#xgai-head {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  border-bottom: 1px solid var(--xgai-border); background: #10141b;
}
#xgai-head .xgai-title { font-weight: 700; font-size: 14px; flex: 1; }
#xgai-head .xgai-status { font-size: 12px; color: var(--xgai-muted); }
#xgai-status-badge { padding: 2px 8px; border-radius: 999px; font-size: 11px; }
#xgai-status-badge.xgai-ok { background: #123b26; color: #4ade80; }
#xgai-status-badge.xgai-off { background: #3b1414; color: #f87171; }
#xgai-close { background: none; border: none; color: var(--xgai-muted); font-size: 18px; cursor: pointer; padding: 0 4px; }
#xgai-close:hover { color: var(--xgai-text); }
#xgai-msgs { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.xgai-msg { max-width: 92%; padding: 8px 12px; border-radius: 10px; white-space: pre-wrap; word-break: break-word; }
.xgai-msg.xgai-user { align-self: flex-end; background: #1f3a5f; color: #e6f1ff; }
.xgai-msg.xgai-ai { align-self: flex-start; background: #10141b; border: 1px solid var(--xgai-border); }
.xgai-msg.xgai-sys { align-self: center; background: none; color: var(--xgai-muted); font-size: 12px; }
.xgai-msg .xgai-code { display: block; background: #0d1117; border: 1px solid var(--xgai-border); border-radius: 8px; padding: 8px 10px; margin-top: 6px; font-family: ui-monospace, Consolas, monospace; font-size: 12px; overflow-x: auto; max-height: 240px; white-space: pre; }
.xgai-msg .xgai-btn {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; margin-right: 6px;
  background: var(--xgai-accent); color: #fff; border: none; border-radius: 6px;
  padding: 5px 12px; font-size: 12px; cursor: pointer;
}
.xgai-msg .xgai-btn.xgai-sec { background: var(--xgai-accent2); }
.xgai-msg .xgai-btn:hover { filter: brightness(1.1); }
.xgai-msg .xgai-btn:disabled { opacity: .5; cursor: not-allowed; }
.xgai-tool { align-self: flex-start; font-size: 12px; color: var(--xgai-muted); display: flex; align-items: center; gap: 6px; }
.xgai-tool .xgai-spin { width: 10px; height: 10px; border: 2px solid var(--xgai-border); border-top-color: var(--xgai-accent); border-radius: 50%; animation: xgai-spin .8s linear infinite; flex: none; }
@keyframes xgai-spin { to { transform: rotate(360deg); } }
#xgai-input { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--xgai-border); background: #10141b; }
#xgai-input textarea {
  flex: 1; resize: none; height: 42px; max-height: 120px;
  background: #0d1117; color: var(--xgai-text); border: 1px solid var(--xgai-border);
  border-radius: 8px; padding: 8px 10px; font-size: 13px; outline: none; font-family: inherit;
}
#xgai-input textarea:focus { border-color: var(--xgai-accent); }
#xgai-upload {
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  width: 42px; border: 1px solid var(--xgai-border); border-radius: 8px;
  font-size: 17px; color: var(--xgai-muted); background: #0d1117; user-select: none;
}
#xgai-upload:hover { color: var(--xgai-text); border-color: var(--xgai-accent); }
#xgai-imgs { display: flex; gap: 6px; padding: 8px 12px 0; flex-wrap: wrap; }
.xgai-img { position: relative; width: 52px; height: 52px; border-radius: 8px; overflow: hidden; border: 1px solid var(--xgai-border); flex: none; }
.xgai-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.xgai-img-del {
  position: absolute; top: 1px; right: 1px; width: 16px; height: 16px; line-height: 14px;
  border: none; border-radius: 4px; background: rgba(0,0,0,.65); color: #fff; font-size: 11px; cursor: pointer; padding: 0;
}
.xgai-img-del:hover { background: #d33; }
#xgai-send {
  background: var(--xgai-accent); color: #fff; border: none; border-radius: 8px;
  padding: 0 16px; font-size: 13px; font-weight: 600; cursor: pointer;
}
#xgai-send:disabled { opacity: .5; cursor: not-allowed; }
#xgai-foot { padding: 6px 12px; font-size: 11px; color: var(--xgai-muted); border-top: 1px solid var(--xgai-border); display: flex; justify-content: space-between; }
#xgai-foot a { color: var(--xgai-accent); text-decoration: none; }
