/* 代码工作台 · AI 对话坞（黑白磨砂灰 · mini 聊天窗口） */
.cw-chat {
  --cw-ink: #111111;
  --cw-text: #1b2430;
  --cw-muted: #6b7686;
  --cw-line: #dbe1e7;
  --cw-soft: #f5f6f7;
  display: flex;
  flex-direction: column;
  height: clamp(320px, 40vh, 380px);
  min-height: 320px;
  margin-top: 12px;
  border: 1px solid var(--cw-line);
  border-radius: 14px;
  overflow: hidden;
  background: linear-gradient(145deg, rgba(255,255,255,.94), rgba(246,248,250,.84));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.96), 0 10px 26px rgba(15,23,42,.055);
  backdrop-filter: blur(18px) saturate(1.06);
  -webkit-backdrop-filter: blur(18px) saturate(1.06);
  color: var(--cw-text);
  font-size: 12px;
}
.cw-chat * { box-sizing: border-box; }
.cw-chat [hidden] { display: none !important; }

/* 代码框压缩，把高度让给聊天窗口 */
#codeInput {
  height: 168px;
  min-height: 150px;
  max-height: 300px;
}
.cw-app .code-area {
  height: 168px;
  min-height: 150px;
  max-height: 300px;
}

/* 头部 */
.cw-chat-head {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 0 0 auto;
  min-height: 46px;
  padding: 7px 10px;
  border-bottom: 1px solid rgba(15,23,42,.075);
  background: linear-gradient(135deg, rgba(255,255,255,.84), rgba(242,245,248,.68));
}
.cw-chat-title {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}
.cw-chat-mark {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #fff;
  background: #111111;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.22), 0 5px 12px rgba(0,0,0,.15);
  font-size: 9.5px;
  font-weight: 850;
  letter-spacing: .04em;
}
.cw-chat-title strong {
  display: block;
  font-size: 12.5px;
  line-height: 1.25;
  color: var(--cw-text);
}
.cw-chat-title small {
  display: block;
  margin-top: 1px;
  overflow: hidden;
  color: var(--cw-muted);
  font-size: 10px;
  line-height: 1.35;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.cw-chat-status {
  flex: 0 0 auto;
  max-width: 132px;
  overflow: hidden;
  border: 1px solid rgba(17,17,17,.11);
  border-radius: 999px;
  padding: 4px 7px;
  color: #59616b;
  background: rgba(255,255,255,.72);
  font-size: 9.5px;
  font-weight: 750;
  line-height: 1.1;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.cw-chat-status::before {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-right: 4px;
  border-radius: 50%;
  background: #111111;
  vertical-align: 1px;
  opacity: .5;
}

/* 对话内容区：始终可见 */
.cw-chat-log {
  flex: 1 1 auto;
  min-height: 108px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 10px 7px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background:
    radial-gradient(circle at 18% 0%, rgba(17,17,17,.025), transparent 34%),
    rgba(248,249,250,.7);
  scrollbar-width: thin;
}
.cw-chat-log::-webkit-scrollbar { width: 7px; }
.cw-chat-log::-webkit-scrollbar-thumb { border-radius: 99px; background: rgba(17,17,17,.14); }

.cw-chat-empty {
  flex: 1;
  min-height: 96px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 14px 16px;
  text-align: center;
  color: var(--cw-muted);
}
.cw-chat-empty-icon {
  width: 33px;
  height: 33px;
  margin-bottom: 2px;
  border: 1px solid rgba(17,17,17,.1);
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: #252a30;
  background: rgba(255,255,255,.82);
  box-shadow: 0 6px 16px rgba(15,23,42,.055);
}
.cw-chat-empty-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.cw-chat-empty strong {
  color: #252a30;
  font-size: 11.5px;
  font-weight: 760;
}
.cw-chat-empty p {
  max-width: 250px;
  margin: 0;
  color: #7a838f;
  font-size: 10px;
  line-height: 1.45;
}

.cw-chat-msg {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  min-width: 0;
}
.cw-chat-msg.user { justify-content: flex-end; }
.cw-chat-msg.assistant { justify-content: flex-start; }
.cw-chat-avatar {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: #fff;
  background: #222426;
  font-size: 7.5px;
  font-weight: 800;
  letter-spacing: .03em;
}
.cw-chat-bubble {
  max-width: 84%;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 7px 9px;
  font-size: 11px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.cw-chat-msg.user .cw-chat-bubble {
  color: #fff;
  background: #111111;
  border-color: #111111;
  border-bottom-right-radius: 4px;
  box-shadow: 0 5px 14px rgba(0,0,0,.12);
}
.cw-chat-msg.assistant .cw-chat-bubble {
  color: #1b2430;
  background: #edf0f3;
  border-color: #dfe4e9;
  border-bottom-left-radius: 4px;
}
.cw-chat-bubble.is-error {
  color: #6e2525;
  background: #f7eaea;
  border-color: #e7cccc;
}

/* 输入坞 */
.cw-chat-composer {
  flex: 0 0 auto;
  padding: 7px 9px 9px;
  border-top: 1px solid rgba(15,23,42,.065);
  background: rgba(255,255,255,.78);
}
.cw-chat-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-height: 82px;
  margin-bottom: 6px;
  overflow-y: auto;
  scrollbar-width: thin;
}
.cw-chat-attachment {
  position: relative;
  min-width: 0;
  max-width: 100%;
  display: flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--cw-line);
  border-radius: 8px;
  padding: 3px 18px 3px 3px;
  background: #fff;
}
.cw-chat-attachment img {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: 5px;
  object-fit: cover;
  background: #eef2f6;
}
.cw-chat-file-icon {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: 5px;
  display: grid;
  place-items: center;
  color: #fff;
  background: #343b44;
  font-size: 7.5px;
  font-weight: 850;
  letter-spacing: .03em;
}
.cw-chat-attachment-copy { min-width: 0; }
.cw-chat-attachment-name {
  display: block;
  max-width: 140px;
  overflow: hidden;
  color: #25303d;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.3;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.cw-chat-attachment-meta {
  display: block;
  margin-top: 1px;
  color: #8490a0;
  font-size: 9px;
  line-height: 1.2;
}
.cw-chat-attachment-remove {
  position: absolute;
  right: 2px;
  top: 2px;
  width: 15px;
  height: 15px;
  border: 0;
  border-radius: 50%;
  padding: 0;
  display: grid;
  place-items: center;
  color: #fff;
  background: rgba(17,17,17,.6);
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
}
.cw-chat-attachment-remove:hover { background: #111111; }

.cw-chat-notice {
  margin-bottom: 6px;
  border: 1px solid #e4cfcf;
  border-radius: 8px;
  padding: 6px 8px;
  color: #6f2929;
  background: #f8eeee;
  font-size: 10px;
  line-height: 1.4;
  white-space: pre-wrap;
}

.cw-chat-input {
  display: block;
  width: 100%;
  height: 38px;
  min-height: 38px;
  max-height: 92px;
  resize: none;
  overflow-y: auto;
  border: 1px solid #dfe4e9;
  border-radius: 9px;
  padding: 7px 9px;
  color: var(--cw-text);
  background: rgba(255,255,255,.94);
  font: 11.5px/1.5 Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  outline: 0;
  transition: border-color .16s ease, box-shadow .16s ease;
}
.cw-chat-input::placeholder { color: #98a2b0; }
.cw-chat-input:focus {
  border-color: #111111;
  box-shadow: 0 0 0 3px rgba(17,17,17,.07);
}

.cw-chat-tools {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  margin-top: 6px;
}
.cw-chat-add,
.cw-chat-stop,
.cw-chat-send {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  padding: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease, color .16s ease, opacity .16s ease;
}
.cw-chat-add {
  border: 1px solid #dfe4e9;
  color: #3b4552;
  background: rgba(255,255,255,.92);
}
.cw-chat-add:hover { border-color: #111111; color: #111111; }
.cw-chat-stop {
  border: 1px solid #dfe4e9;
  color: #4f5b69;
  background: #fff;
}
.cw-chat-stop:hover { border-color: #111111; color: #111111; }
.cw-chat-send {
  border: 1px solid #111111;
  color: #fff;
  background: #111111;
  box-shadow: 0 5px 14px rgba(0,0,0,.14);
}
.cw-chat-send:hover { background: #000; border-color: #000; }
.cw-chat-send:disabled,
.cw-chat-add:disabled,
.cw-chat-stop:disabled {
  cursor: not-allowed;
  opacity: .5;
  box-shadow: none;
}
.cw-chat-send:disabled { color: #7f8a97; background: #e8edf1; border-color: #e8edf1; }
.cw-chat-add svg,
.cw-chat-stop svg,
.cw-chat-send svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* mini 模型触发器 */
.cw-chat-model-trigger {
  min-width: 0;
  max-width: 225px;
  height: 30px;
  flex: 0 1 auto;
  display: flex;
  align-items: center;
  gap: 5px;
  border: 1px solid #dfe4e9;
  border-radius: 9px;
  padding: 0 6px 0 4px;
  color: #33404e;
  background: rgba(255,255,255,.94);
  font: 650 10.5px/1 Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  outline: 0;
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease, opacity .16s ease;
}
.cw-chat-model-trigger:hover { border-color: #111111; }
.cw-chat-model-trigger:disabled { cursor: not-allowed; opacity: .55; }
.cw-chat-model-mark {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--mark, #111111);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .02em;
}
.cw-chat-model-mark.is-mini {
  width: 19px;
  height: 19px;
  border-radius: 6px;
  font-size: 8px;
}
.cw-chat-model-name {
  min-width: 0;
  max-width: 126px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cw-chat-effort-badge {
  flex: 0 0 auto;
  min-width: 18px;
  border-radius: 5px;
  padding: 2px 4px;
  color: #fff;
  background: hsl(var(--cw-effort-hue, 210) 72% 48%);
  font-size: 8.5px;
  font-weight: 750;
  line-height: 1.25;
  text-align: center;
}
.cw-chat-model-chevron {
  flex: 0 0 auto;
  width: 11px;
  height: 11px;
  fill: none;
  stroke: #7c858f;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.cw-chat-spacer { flex: 1 1 auto; min-width: 0; }
.cw-chat.is-dragging {
  border-color: #111111;
  box-shadow: inset 0 0 0 2px rgba(17,17,17,.11), 0 10px 28px rgba(15,23,42,.08);
}
.cw-chat button:focus-visible,
.cw-chat textarea:focus-visible,
.cw-chat input:focus-visible,
.cw-chat-picker button:focus-visible {
  outline: 2px solid #111111;
  outline-offset: 2px;
}

/* 模型与思考浮层（fixed，避免被卡片 overflow 裁切） */
.cw-chat-picker {
  position: fixed;
  z-index: 9999;
  width: 292px;
  max-height: calc(100vh - 20px);
  overflow-y: auto;
  border: 1px solid rgba(17,17,17,.13);
  border-radius: 16px;
  padding: 10px;
  color: #1b2430;
  background: rgba(255,255,255,.98);
  box-shadow: 0 22px 55px rgba(15,23,42,.18), 0 3px 10px rgba(15,23,42,.08);
  backdrop-filter: blur(22px) saturate(1.08);
  -webkit-backdrop-filter: blur(22px) saturate(1.08);
  font: 12px/1.35 Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  scrollbar-width: thin;
}
.cw-chat-picker[hidden] { display: none !important; }
.cw-chat-picker * { box-sizing: border-box; }
.cw-chat-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 1px 8px;
}
.cw-chat-picker-head strong {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .02em;
}
.cw-chat-picker-close {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  padding: 0;
  display: grid;
  place-items: center;
  color: #727b86;
  background: transparent;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.cw-chat-picker-close:hover { color: #111111; background: rgba(17,17,17,.06); }
.cw-chat-model-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.cw-chat-model-row {
  width: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 6px;
  color: #33404e;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.cw-chat-model-row:hover { background: rgba(17,17,17,.04); }
.cw-chat-model-row.is-active {
  border-color: rgba(17,17,17,.1);
  background: #f1f3f4;
}
.cw-chat-model-row .cw-chat-model-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 10px;
}
.cw-chat-model-row-copy {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.cw-chat-model-row-copy strong {
  overflow: hidden;
  font-size: 11.5px;
  font-weight: 750;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cw-chat-model-row-copy small {
  overflow: hidden;
  color: #7c858f;
  font-size: 9.5px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cw-chat-row-check {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: #111111;
  font-size: 10px;
  line-height: 1;
  opacity: 0;
  transform: scale(.85);
  transition: opacity .15s ease, transform .15s ease;
}
.cw-chat-model-row.is-active .cw-chat-row-check { opacity: 1; transform: scale(1); }
.cw-chat-effort-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 10px 1px 5px;
}
.cw-chat-effort-head span {
  font-size: 10.5px;
  font-weight: 750;
  color: #4c5560;
}
.cw-chat-effort-head small {
  overflow: hidden;
  color: #8a929c;
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cw-chat-efforts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: 3px;
  padding: 3px;
  border: 1px solid rgba(17,17,17,.09);
  border-radius: 9px;
  background: #f3f5f6;
}
.cw-chat-effort-option {
  height: 27px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 0 5px;
  color: #66707c;
  background: transparent;
  font: 700 10.5px/1 Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.cw-chat-effort-option:hover { color: #111111; }
.cw-chat-effort-option.is-active {
  border-color: #111111;
  color: #fff;
  background: #111111;
  box-shadow: 0 2px 6px rgba(0,0,0,.14);
}

@media (max-width: 460px) {
  .cw-chat { height: 310px; min-height: 300px; }
  .cw-chat-title small { display: none; }
  .cw-chat-model-trigger { max-width: 178px; }
  .cw-chat-model-name { max-width: 94px; font-size: 10px; }
  .cw-app .code-area { height: 150px; min-height: 140px; }
  .cw-chat-picker { width: min(292px, calc(100vw - 20px)); }
}

@media (prefers-reduced-motion: reduce) {
  .cw-chat *,
  .cw-chat *::before,
  .cw-chat *::after,
  .cw-chat-picker *,
  .cw-chat-picker *::before,
  .cw-chat-picker *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}

/* ===== v1.2：长方形代码卡片、官方 logo、思考滑杆与粒子动画 ===== */

/* 代码区域收成一张更矮的长方形卡片，右下角留出完整代码入口 */
.cw-code-shell {
  position: relative;
}

.cw-code-shell #codeInput {
  display: block;
  box-sizing: border-box;
  width: 100%;
  height: 112px;
  min-height: 112px;
  max-height: 112px;
  resize: none;
  padding: 11px 13px 38px;
  border-radius: 12px;
  background: #3b4148;
  color: #eef1f3;
  font: 11px/1.6 "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 1px 2px rgba(15, 18, 21, 0.1);
}

.cw-code-shell #codeInput:focus {
  outline: none;
  background: #414850;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 0 0 2px rgba(17, 17, 17, 0.1);
}

.cw-code-expand {
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 25px;
  padding: 0 9px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 7px;
  background: rgba(24, 27, 31, 0.78);
  color: #f4f5f6;
  font: 650 9.5px/1 "Inter", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0.01em;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.cw-code-expand svg {
  width: 11px;
  height: 11px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.cw-code-expand:hover {
  background: rgba(40, 44, 49, 0.9);
  border-color: rgba(255, 255, 255, 0.28);
}

.cw-code-expand:active {
  transform: translateY(1px);
}

.cw-code-expand:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.7);
  outline-offset: 2px;
}

/* 聊天窗占满右侧主内容区；代码输入移到页面底部 dock 后，聊天从上到下完整展开 */
.cw-chat {
  height: clamp(540px, calc(100vh - 236px), 780px);
  min-height: 540px;
  margin-top: 0;
}

.cw-chat-head {
  min-height: 42px;
  padding: 5px 9px 5px 10px;
}

/* AI 修改独立板块：像其他分类模块一样由左侧入口切换，点击后展示完整聊天 */
.cw-app .editor-workspace {
  grid-template-columns: 88px minmax(0, 1fr);
}

.cw-app .editor-scroll {
  padding-left: 10px;
  padding-right: 10px;
}

.cw-app .editor-toolbar-actions {
  gap: 5px;
}

.cw-app .editor-toolbar-actions .btn {
  padding-inline: 8px;
  white-space: nowrap;
}

.cw-app .category-rail {
  overflow-y: auto;
  scrollbar-width: thin;
}

.category-ai-mark {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  color: #fff;
  background: #17191c;
  font-size: 10px;
  font-weight: 850;
  line-height: 1;
  letter-spacing: .03em;
}

.category-item.active .category-ai-mark {
  color: #17191c;
  background: #fff;
}

.group-card[data-group="ai"] > summary {
  min-height: 52px;
  padding: 8px 12px;
}

.group-card[data-group="ai"] .cw-ai-step {
  font-size: 9px;
  letter-spacing: .02em;
}

.group-card[data-group="ai"] .cw-ai-status {
  max-width: 112px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* AI 修改模块：聊天直接作为模块内容，铺满右栏高度，不再套独立卡片 */
.editor-scroll:has(#cwAiGroup.category-active) {
  overflow: hidden;
  padding: 0;
}

.editor-scroll:has(#cwAiGroup.category-active) .group-list {
  height: 100%;
  min-height: 0;
  grid-template-rows: minmax(0, 1fr);
  gap: 0;
  padding: 0;
}

#cwAiGroup.group-card {
  height: 100%;
  min-height: 0;
  display: none;
  border: 0;
  border-radius: 0;
  background: rgba(255, 255, 255, 0.8);
  box-shadow: none;
  overflow: hidden;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

#cwAiGroup.group-card.category-active {
  display: flex;
  flex-direction: column;
}

#cwAiGroup > .cw-ai-head {
  flex: 0 0 48px;
  height: 48px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 6px 12px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
  background: rgba(255, 255, 255, 0.92);
  cursor: default;
}

#cwAiGroup > .cw-ai-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  background: transparent;
}

#cwAiGroup .cw-chat.is-section {
  flex: 1 1 auto;
  width: 100%;
  height: auto;
  min-height: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

#cwAiGroup .cw-chat.is-section .cw-chat-log {
  flex: 1 1 auto;
  min-height: 0;
  padding: 12px 12px 10px;
  border: 0;
  border-radius: 0;
  background: transparent;
}

#cwAiGroup .cw-chat.is-section .cw-chat-composer {
  flex: 0 0 auto;
  padding: 8px 10px 10px;
  border-top: 1px solid rgba(15, 23, 42, 0.06);
  background: rgba(255, 255, 255, 0.72);
}

.cw-chat.is-section {
  margin-top: 0;
}

.cw-chat.is-section .cw-chat-effort-badge {
  display: none;
}

.cw-chat.is-section .cw-chat-model-name {
  max-width: 104px;
}

.cw-chat-title strong {
  font-size: 11px;
  letter-spacing: 0.02em;
}

.cw-chat-title small,
.cw-chat-status {
  display: none !important;
}

.cw-chat-log {
  min-height: 120px;
  gap: 10px;
}

.cw-chat-empty {
  padding: 8px 6px;
}

.cw-chat-empty strong {
  font-size: 11.5px;
  color: #41464d;
}

/* 模型选择：恢复 DeepSeek / 豆包官方品牌色，不再做黑白单色 */
.cw-chat-model-logo {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid rgba(17, 17, 17, 0.1);
  background: #ffffff;
  color: #111214;
}

.cw-chat-model-logo[data-logo="deepseek"] svg path {
  fill: #5786fe;
}

.cw-chat-model-logo[data-logo="doubao"] svg path:nth-child(1) { fill: #1e37fc; }
.cw-chat-model-logo[data-logo="doubao"] svg path:nth-child(2) { fill: #37e1be; }
.cw-chat-model-logo[data-logo="doubao"] svg path:nth-child(3) { fill: #a569ff; }
.cw-chat-model-logo[data-logo="doubao"] svg path:nth-child(4) { fill: #1e37fc; }

.cw-chat-model-logo svg {
  display: block;
  width: 17px;
  height: 17px;
}

.cw-chat-model-logo.is-mini {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border-color: rgba(17, 17, 17, 0.08);
  background: #fbfbfc;
}

.cw-chat-model-logo.is-mini svg {
  width: 12.5px;
  height: 12.5px;
}

.cw-chat-model-trigger {
  gap: 5px;
  height: 30px;
  padding: 0 8px 0 7px;
}

.cw-chat-model-row .cw-chat-model-logo {
  width: 29px;
  height: 29px;
  background: #ffffff;
}

/* 三档思考强度：30px 圆角轨道 + 粒子填充 + 果冻 thumb */
.cw-chat-efforts {
  display: block;
  padding: 2px 0 0;
  border: 0;
  background: transparent;
}

.cw-chat-effort-shell {
  --effort-ratio: 0;
  --effort-hue: 210;
  --effort-press: 1;
  --effort-jelly-x: 1;
  --effort-jelly-y: 1;
  --effort-jelly-offset: 0px;
  --effort-jelly-skew: 0deg;
  --effort-jelly-left: 50%;
  --effort-jelly-right: 50%;
  min-width: 0;
}

.cw-chat-effort-slider {
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 15px;
  outline: none;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.cw-chat-effort-slider:focus-visible {
  outline: 2px solid hsl(var(--effort-hue, 210) 72% 55% / 0.38);
  outline-offset: 3px;
}

.cw-chat-effort-slider:active {
  cursor: grabbing;
}

.cw-chat-effort-track {
  position: relative;
  width: 100%;
  height: 30px;
  overflow: hidden;
  border: 1px solid hsl(var(--effort-hue, 210) 60% 48% / 0.2);
  border-radius: 999px;
  background: hsl(var(--effort-hue, 210) 24% 94%);
  box-shadow: inset 0 1px 2px rgba(17, 17, 17, 0.05);
}

.cw-chat-effort-fill {
  position: absolute;
  inset: 0;
  clip-path: inset(0 calc((100% - 31px) * (1 - var(--effort-ratio))) 0 0 round 999px);
  -webkit-clip-path: inset(0 calc((100% - 31px) * (1 - var(--effort-ratio))) 0 0 round 999px);
}

.cw-chat-effort-fill canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.cw-chat-effort-dots {
  position: absolute;
  inset: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}

.cw-chat-effort-shell.is-max .cw-chat-effort-dots {
  opacity: 0;
}

.cw-chat-effort-dots span {
  position: absolute;
  top: 50%;
  width: 4px;
  height: 4px;
  margin-top: -2px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 0 0 1px rgba(17, 17, 17, 0.14);
}

.cw-chat-effort-dots span:nth-child(1) { left: 6%; }
.cw-chat-effort-dots span:nth-child(2) { left: 50%; margin-left: -2px; }
.cw-chat-effort-dots span:nth-child(3) { right: 5%; }

.cw-chat-effort-thumb {
  position: absolute;
  top: 2px;
  left: calc((100% - 27px) * var(--effort-ratio) + 1px);
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid hsl(var(--effort-hue, 210) 72% 55% / 0.3);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.14),
    0 5px 14px hsl(var(--effort-hue, 210) 70% 52% / 0.22);
  transform: translateX(var(--effort-jelly-offset)) skewX(var(--effort-jelly-skew)) scale(var(--effort-jelly-x), var(--effort-jelly-y));
  transform-origin: var(--effort-jelly-left) var(--effort-jelly-right);
  scale: var(--effort-press);
  pointer-events: none;
  transition: transform 280ms cubic-bezier(0.22, 1, 0.36, 1), scale 140ms ease, box-shadow 180ms ease;
}

.cw-chat-effort-shell[data-dragging="true"] .cw-chat-effort-thumb {
  transition: none;
  box-shadow:
    0 2px 3px rgba(0, 0, 0, 0.18),
    0 8px 20px hsl(var(--effort-hue, 210) 70% 52% / 0.28);
}

.cw-chat-effort-labels {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  margin-top: 5px;
  padding: 0 2px;
}

.cw-chat-effort-label {
  justify-self: center;
  padding: 3px 5px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #8a929c;
  font: 650 9.5px/1.2 "Inter", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  cursor: pointer;
  transition: color 160ms ease, background 160ms ease;
}

.cw-chat-effort-label:first-child { justify-self: start; }
.cw-chat-effort-label:last-child { justify-self: end; }

.cw-chat-effort-label.is-active {
  color: hsl(var(--effort-hue, 210) 74% 42%);
  background: hsl(var(--effort-hue, 210) 70% 54% / 0.12);
}

.cw-chat-effort-label:hover {
  color: hsl(var(--effort-hue, 210) 65% 38%);
}

.cw-chat-effort-head small {
  max-width: 68%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
}

/* 思考中：mini 粒子形态 + 3×3 脉冲格 + 计时与步骤 */
.cw-chat-thinking {
  align-items: flex-start;
  animation: cw-think-in 220ms ease both;
}

.cw-chat-thinking-card {
  display: flex;
  align-items: center;
  gap: 7px;
  max-width: 88%;
  padding: 6px 9px 6px 6px;
  border: 1px solid rgba(17, 17, 17, 0.07);
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(17, 17, 17, 0.04);
}

.cw-chat-thinking-orb {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #ffffff 0%, #f0f1f2 58%, #e4e6e8 100%);
  box-shadow: inset 0 0 0 1px rgba(17, 17, 17, 0.04);
}

.cw-chat-thinking-orb canvas {
  display: block;
  width: 34px;
  height: 34px;
}

.cw-chat-thinking-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.cw-chat-thinking-title {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #111214;
  font-size: 10.5px;
}

.cw-chat-thinking-title strong {
  font-weight: 700;
}

.cw-chat-thinking-time {
  color: #9aa1a9;
  font: 500 9px/1 "SFMono-Regular", Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

.cw-chat-thinking-grid {
  display: grid;
  grid-template-columns: repeat(3, 3px);
  grid-template-rows: repeat(3, 3px);
  gap: 1px;
}

.cw-chat-thinking-grid i {
  display: block;
  width: 3px;
  height: 3px;
  border-radius: 1px;
  background: #111214;
  opacity: 0.25;
  animation: cw-think-pulse 1.2s ease-in-out infinite;
  animation-delay: calc(var(--i) * -0.13s);
}

.cw-chat-thinking-copy small {
  color: #6b747f;
  font-size: 9.5px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@keyframes cw-think-pulse {
  0%, 100% { opacity: 0.18; transform: scale(0.82); }
  45% { opacity: 1; transform: scale(1.08); }
}

@keyframes cw-think-in {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 查看完整代码：遮罩 + 磨砂对话框 + 深色等宽编辑区 */
body.cw-code-modal-open {
  overflow: hidden;
}

.cw-code-modal {
  position: fixed;
  inset: 0;
  z-index: 10001;
  display: grid;
  place-items: center;
  padding: 18px;
}

.cw-code-modal[hidden] {
  display: none;
}

.cw-code-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(13, 15, 18, 0.46);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.cw-code-modal-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  width: min(820px, 100%);
  max-height: min(86vh, 780px);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 18px;
  background: #f9faf9;
  box-shadow: 0 22px 70px rgba(10, 12, 15, 0.28);
  animation: cw-code-modal-in 180ms ease both;
}

@keyframes cw-code-modal-in {
  from { opacity: 0; transform: translateY(6px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.cw-code-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid rgba(17, 17, 17, 0.07);
}

.cw-code-modal-head > div {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.cw-code-modal-head strong {
  color: #111214;
  font-size: 13px;
  letter-spacing: -0.01em;
}

.cw-code-modal-head small {
  color: #8a929c;
  font: 500 9.5px/1 "SFMono-Regular", Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

.cw-code-modal-close {
  width: 25px;
  height: 25px;
  border: 0;
  border-radius: 7px;
  background: rgba(17, 17, 17, 0.06);
  color: #3b4047;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.cw-code-modal-close:hover {
  background: rgba(17, 17, 17, 0.1);
}

.cw-code-modal-input {
  flex: 1 1 auto;
  box-sizing: border-box;
  width: 100%;
  min-height: 300px;
  margin: 0;
  padding: 15px 17px;
  border: 0;
  border-radius: 0;
  outline: none;
  resize: none;
  background: #3b4148;
  color: #edf0f2;
  caret-color: #ffffff;
  font: 11.5px/1.66 "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  tab-size: 2;
}

.cw-code-modal-input::placeholder {
  color: rgba(237, 240, 242, 0.45);
}

.cw-code-modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-top: 1px solid rgba(17, 17, 17, 0.07);
  color: #8a929c;
  font-size: 9.5px;
}

.cw-code-modal-done {
  height: 29px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: #111214;
  color: #ffffff;
  font: 650 10px/1 "Inter", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  cursor: pointer;
}

.cw-code-modal-done:hover {
  background: #26282b;
}

@media (max-width: 460px) {
  .cw-code-shell #codeInput {
    height: 104px;
    min-height: 104px;
    max-height: 104px;
  }
  .cw-chat { height: 430px; min-height: 410px; }
  .cw-code-modal-panel { max-height: 90vh; border-radius: 14px; }
  .cw-code-modal-input { min-height: 240px; font-size: 11px; }
  .cw-code-expand { right: 7px; bottom: 7px; }
}

/* AI 思考实时进度（流式思考增量） */
.cw-chat-thinking-live {
  display: block;
  margin-top: 5px;
  font-size: 11px;
  line-height: 1.5;
  color: #7b8594;
  letter-spacing: .02em;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}