/* HAZ-215: Chat Widget (全局常驻悬浮入口)
 * Namespace: aha-cw- (避免与现有 UI 污染)
 * Z-index 规划：ball/panel = 800，低于 tooltip(9999) 和 modal(9000)，高于 sidebar(120)
 */

/* 登录态门禁：Chat 入口只在登录后的工作台出现。
 * - auth-gate-active：登录页 + Document/Product/Use case 等公开营销路由（main.js render() 统一切换）
 * - auth-bootstrap-pending：鉴权初始化未完成（boot 首帧），防止登录页一闪现气泡
 * 隐藏根元素即可同时遮住悬浮球和面板。 */
body.auth-gate-active #aha-chat-widget,
body.auth-bootstrap-pending #aha-chat-widget {
  display: none !important;
}

/* ─── 悬浮球 ─── */
/* 反相双模式：background=--text-main / color=--color-bg，token 切主题自动翻转。
   浅色模式 = 近黑底+白图标；深色模式 = 近白底+黑图标。26px（80% of 33px）。 */
.aha-cw-ball {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 800;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-full);
  border: none;
  background: var(--text-main);
  color: var(--color-bg);
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  box-shadow: var(--shadow-sm);
  --aha-cw-ball-x: 0px;
  --aha-cw-ball-y: 0px;
  transition: transform var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out),
              opacity var(--duration-fast) var(--ease-out);
  touch-action: none;
  user-select: none;
  will-change: transform;
}

.aha-cw-ball:hover {
  animation: aha-cw-ball-hover 420ms var(--ease-out) both;
  box-shadow: var(--shadow-md);
  opacity: 0.82;
}

@keyframes aha-cw-ball-hover {
  0% { transform: translate3d(var(--aha-cw-ball-x, 0px), var(--aha-cw-ball-y, 0px), 0) scale(1); }
  58% { transform: translate3d(var(--aha-cw-ball-x, 0px), var(--aha-cw-ball-y, 0px), 0) scale(1.14); }
  100% { transform: translate3d(var(--aha-cw-ball-x, 0px), var(--aha-cw-ball-y, 0px), 0) scale(1.08); }
}

.aha-cw-ball:active {
  cursor: grabbing;
}

.aha-cw-ball--open {
  opacity: 0;
  pointer-events: none;
}

/* Mobile: 固定不拖，普通指针 */
@media (max-width: 767px) {
  .aha-cw-ball {
    cursor: pointer;
    touch-action: auto;
  }
}

/* ─── 面板容器 ─── */
.aha-cw-panel {
  position: fixed;
  bottom: 64px;
  right: 16px;
  z-index: 800;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 96px);
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* 初始隐藏态（hidden + pointer-events: none） */
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px) scale(0.97);
  transition: opacity var(--duration-base) var(--ease-out),
              transform var(--duration-base) var(--ease-out);
}

.aha-cw-panel--open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* Mobile: 全屏 */
@media (max-width: 767px) {
  .aha-cw-panel {
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    border: none;
  }
}

/* ─── 面板头部 ─── */
.aha-cw-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 8px 10px 14px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
  background: var(--color-card);
}

.aha-cw-panel-title {
  font-size: var(--text-control);
  font-weight: var(--weight-semibold);
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1;
}

.aha-cw-header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

/* 头部「新对话」按钮（Multica 风格） */
.aha-cw-new-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  color: var(--text-main);
  font-size: var(--text-control);
  font-weight: var(--weight-medium);
  font-family: var(--font-sans);
  cursor: pointer;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  transition: background var(--duration-fast);
}

.aha-cw-new-btn:hover {
  background: var(--secondary);
}

.aha-cw-new-label { line-height: 1; }

/* ─── 消息列表 ─── */
.aha-cw-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 12px 4px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  /* 保持自然滚动，不用 scroll-behavior: smooth（用户上翻时防止抢占） */
}

.aha-cw-messages::-webkit-scrollbar {
  width: 4px;
}

.aha-cw-messages::-webkit-scrollbar-thumb {
  background: var(--color-border-strong);
  border-radius: 2px;
}

/* ─── 消息气泡 ─── */
.aha-cw-msg {
  display: flex;
  flex-direction: column;
  max-width: 88%;
}

.aha-cw-msg--user {
  align-self: flex-end;
  align-items: flex-end;
}

.aha-cw-msg--assistant {
  align-self: flex-start;
  align-items: flex-start;
}

.aha-cw-bubble {
  padding: 8px 11px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
}

.aha-cw-msg--user .aha-cw-bubble {
  background: var(--primary-accent);
  color: #fff;
  border-bottom-right-radius: var(--radius-xs);
}

.aha-cw-msg--assistant .aha-cw-bubble {
  background: var(--secondary);
  color: var(--text-main);
  border-bottom-left-radius: var(--radius-xs);
}

/* Markdown 内容 */
.aha-cw-md > p { margin: 0 0 6px; }
.aha-cw-md > p:last-child { margin-bottom: 0; }
.aha-cw-md code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: rgba(0, 0, 0, 0.07);
  padding: 1px 4px;
  border-radius: var(--radius-xs);
}
.aha-cw-md pre {
  background: rgba(0, 0, 0, 0.06);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  margin: 6px 0;
  overflow-x: auto;
}
.aha-cw-md pre code { background: none; padding: 0; }
.aha-cw-md h1, .aha-cw-md h2, .aha-cw-md h3 {
  font-size: 13.5px;
  font-weight: var(--weight-semibold);
  margin: 8px 0 4px;
}
.aha-cw-md ul, .aha-cw-md ol { padding-left: 18px; margin: 4px 0; }
.aha-cw-md li { margin-bottom: 2px; }
.aha-cw-md strong { font-weight: var(--weight-semibold); }
.aha-cw-md a { color: var(--primary-accent); text-decoration: underline; }

html[data-theme="dark"] .aha-cw-md code { background: rgba(255, 255, 255, 0.1); }
html[data-theme="dark"] .aha-cw-md pre { background: rgba(255, 255, 255, 0.07); }

/* ─── 消息动作（复制/重新生成） ─── */
.aha-cw-msg-actions {
  display: flex;
  gap: 2px;
  margin-top: 4px;
  opacity: 0;
  transition: opacity var(--duration-fast);
}

.aha-cw-msg:hover .aha-cw-msg-actions,
.aha-cw-msg:focus-within .aha-cw-msg-actions {
  opacity: 1;
}

.aha-cw-action-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: var(--radius-sm);
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--text-muted);
  transition: background var(--duration-fast), color var(--duration-fast);
}

.aha-cw-action-btn:hover {
  background: var(--secondary);
  color: var(--text-main);
}

/* ─── 思考中动画 ─── */
.aha-cw-msg--thinking .aha-cw-bubble {
  padding: 12px 14px;
}

.aha-cw-thinking-dots {
  display: flex;
  gap: 4px;
  align-items: center;
}

.aha-cw-thinking-dots span {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--text-muted);
  animation: aha-cw-dot-bounce 1.4s infinite;
}

.aha-cw-thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.aha-cw-thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes aha-cw-dot-bounce {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

/* ─── 空态 ─── */
.aha-cw-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 6px;
  padding: 24px 22px;
  text-align: center;
}

.aha-cw-empty-title {
  font-size: 1.18rem;
  font-weight: var(--weight-semibold);
  color: var(--text-main);
  margin: 0;
}

.aha-cw-empty-sub {
  font-size: var(--text-caption);
  color: var(--text-subtle);
  margin: 0 0 14px;
}

/* Multica 风格整行建议卡 */
.aha-cw-suggest {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 340px;
}

.aha-cw-suggest-card {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-card);
  color: var(--text-main);
  font-size: var(--text-caption);
  font-family: var(--font-sans);
  padding: 11px 14px;
  cursor: pointer;
  transition: border-color var(--duration-fast), background var(--duration-fast);
}

.aha-cw-suggest-card:hover {
  border-color: var(--primary-accent);
  background: var(--secondary);
}

.aha-cw-suggest-icon { font-size: 15px; line-height: 1; flex-shrink: 0; }
.aha-cw-suggest-text { flex: 1; }

.aha-cw-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  max-width: 300px;
}

.aha-cw-chip {
  border: 1px solid var(--color-border);
  background: transparent;
  border-radius: var(--radius-full);
  padding: 5px 12px;
  font-size: var(--text-caption);
  font-family: var(--font-sans);
  cursor: pointer;
  color: var(--text-muted);
  transition: border-color var(--duration-fast), color var(--duration-fast),
              background var(--duration-fast);
  text-align: left;
}

.aha-cw-chip:hover {
  border-color: var(--primary-accent);
  color: var(--primary-accent);
  background: var(--surface-muted);
}

/* ─── 输入区（Claude Desktop 风格 composer） ─── */
.aha-cw-panel-footer {
  padding: 8px 12px 14px;
  border-top: none;
  flex-shrink: 0;
  background: transparent;
}

/* 一模一样照搬 Claude：整个就是一个圆角卡片，文字/光标直接在卡片里，里面绝不再套第二层框 */
.aha-cw-composer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  padding: 12px 14px 10px;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--duration-fast) var(--ease-out);
}

.aha-cw-composer:focus-within {
  border-color: var(--color-border-strong);
}

.aha-cw-input {
  width: 100%;
  border: none;
  background: transparent;
  resize: none;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-main);
  outline: none;
  /* 大空白输入框（默认就高，像 Claude Desktop），自动增高到上限再滚 */
  min-height: 54px;
  max-height: 224px;
  overflow-y: auto;
  padding: 2px 4px;
  font-family: var(--font-sans);
}

.aha-cw-input::placeholder {
  color: var(--text-subtle);
}

/* 必须用更高特异性 + !important，压过 11-materials-assets-overrides.css 里的全局
 * `textarea { border:1px solid var(--color-border) !important; background: var(--color-bg) !important }`。
 * 否则聊天输入框会套上自己的边框和异色底色，变成"框中框"、且颜色与卡片不一致。
 * 设计上输入框是嵌在 .aha-cw-composer 卡片内的裸输入区——唯一的框是卡片本身。 */
.aha-cw-composer .aha-cw-input,
.aha-cw-composer .aha-cw-input:focus,
.aha-cw-composer .aha-cw-input:hover {
  background: transparent !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
}

/* 底排：左 + ，右 模型选择 + 发送 */
.aha-cw-composer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.aha-cw-composer-left {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.aha-cw-composer-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.aha-cw-plus-btn {
  width: 30px;
  height: 30px;
  border: none;            /* 老板：左下角加号不要圈，只留 + 号 */
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  transition: background var(--duration-fast), color var(--duration-fast);
}

.aha-cw-plus-btn:hover {
  background: var(--secondary);
  color: var(--text-main);
}

.aha-cw-plus-btn .phosphor-icon {
  font-size: 18px;
  line-height: 1;
}

/* 圆形发送按钮：空=灰，有输入=黑（icon 随主题反色，亮/暗都清晰） */
.aha-cw-send-btn {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: var(--radius-full);
  background: var(--text-main);
  color: var(--color-card);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  transition: background var(--duration-fast), opacity var(--duration-fast);
}

.aha-cw-send-btn:hover {
  opacity: 0.85;
}

/* 空输入：灰色圆，输入后变黑 */
.aha-cw-send-btn:disabled {
  background: var(--secondary);
  color: var(--text-subtle);
  cursor: not-allowed;
}

.aha-cw-send-btn.aha-cw-stop {
  background: var(--color-danger);
  color: #fff;
}

.aha-cw-send-btn.aha-cw-stop:hover {
  background: #b02e10;
}

.aha-cw-hint {
  margin: 6px 2px 0;
  font-size: var(--text-caption);
  color: var(--text-subtle);
  text-align: center;
}

/* ─── 模型选择器 ─── */
.aha-cw-model {
  position: relative;
}

.aha-cw-model-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  max-width: 168px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: var(--text-caption);
  font-family: var(--font-sans);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  transition: background var(--duration-fast), color var(--duration-fast);
}

.aha-cw-model-btn:hover:not(:disabled) {
  background: var(--secondary);
  color: var(--text-main);
}

.aha-cw-model-btn:disabled {
  cursor: default;
  opacity: 0.7;
}

.aha-cw-model-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.aha-cw-model-name,
.aha-cw-model-opt-label {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.aha-cw-model-name strong,
.aha-cw-model-opt-label strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.aha-cw-model-name small,
.aha-cw-model-opt-label small {
  color: var(--text-subtle);
  font-size: 0.68rem;
  font-weight: var(--weight-regular);
  line-height: 1.15;
}

.aha-cw-model-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  max-width: 260px;
  max-height: 260px;
  overflow-y: auto;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 4px;
  z-index: 2;
}

.aha-cw-model-opt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text-main);
  font-size: var(--text-caption);
  font-family: var(--font-sans);
  text-align: left;
  cursor: pointer;
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  transition: background var(--duration-fast);
}

.aha-cw-model-opt:hover {
  background: var(--secondary);
}

.aha-cw-model-opt.is-active {
  color: var(--primary-accent);
  font-weight: var(--weight-medium);
}

/* ─── reduced motion ─── */
@media (prefers-reduced-motion: reduce) {
  .aha-cw-panel,
  .aha-cw-ball,
  .aha-cw-send-btn,
  .aha-cw-chip,
  .aha-cw-action-btn,
  .aha-cw-msg-actions {
    transition: none !important;
    animation: none !important;
  }
}

body.user-motion-off .aha-cw-panel,
body.user-motion-off .aha-cw-ball {
  transition: none !important;
  animation: none !important;
}

/* 暗色主题：默认 primary-accent 近白，发送按钮图标改用深色确保对比 */
html[data-theme="dark"] .aha-cw-send-btn:not(.aha-cw-stop) {
  color: var(--color-bg);
}

/* ─── resize 把手（左 / 上 / 左上角 三向无极） ─── */
.aha-cw-resize-l,
.aha-cw-resize-t,
.aha-cw-resize-tl {
  position: absolute;
  z-index: 3;
  background: transparent;
  touch-action: none;
  user-select: none;
}

.aha-cw-resize-l {
  top: 0;
  left: 0;
  width: 8px;
  height: 100%;
  cursor: ew-resize;
}

.aha-cw-resize-t {
  top: 0;
  left: 0;
  width: 100%;
  height: 8px;
  cursor: ns-resize;
}

.aha-cw-resize-tl {
  top: 0;
  left: 0;
  width: 12px;
  height: 12px;
  cursor: nwse-resize;
  z-index: 4;
}

/* 无可见阴影/方块，只靠光标(↘ / ↔ / ↕)提示可拉伸 */

/* 移动端不需要 resize 把手 */
@media (max-width: 767px) {
  .aha-cw-resize-l,
  .aha-cw-resize-t,
  .aha-cw-resize-tl { display: none; }
}

/* ─── 附件 chips ─── */
.aha-cw-attach-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 2px;
}

.aha-cw-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 180px;
  padding: 4px 6px 4px 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  color: var(--text-muted);
  font-size: var(--text-caption);
}

.aha-cw-file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.aha-cw-file-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-subtle);
  cursor: pointer;
  padding: 1px;
  border-radius: var(--radius-xs);
  font-size: 12px;
}

.aha-cw-file-x:hover {
  color: var(--text-main);
  background: var(--secondary);
}

.aha-cw-model-opt-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── 面板标题小图标（品牌圆盘，缩小为 16px 陶土） ─── */
.aha-cw-title-mark {
  display: inline-flex;
  align-items: center;
  color: var(--primary-accent);
}
.aha-cw-title-mark svg {
  width: 16px;
  height: 16px;
  display: block;
}

/* ─── 头部左侧组（新对话 + 历史） ─── */
.aha-cw-header-left {
  display: flex;
  align-items: center;
  gap: 2px;
}

/* 历史会话折叠面板 */
.aha-cw-history {
  position: absolute;
  top: 46px;
  left: 10px;
  width: 244px;
  max-width: calc(100% - 20px);
  max-height: 320px;
  overflow-y: auto;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 6;
  padding: 6px;
}

.aha-cw-hist-head {
  font-size: var(--text-caption);
  color: var(--text-subtle);
  padding: 4px 8px 6px;
}

.aha-cw-hist-list { display: flex; flex-direction: column; gap: 2px; }

.aha-cw-hist-row {
  position: relative;
  /* 锁定行高，hover 切图标 / 进重命名 / 进确认态都不允许行高抖动 */
  min-height: 32px;
}

.aha-cw-hist-open {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text-main);
  font-size: var(--text-caption);
  font-family: var(--font-sans);
  cursor: pointer;
  padding: 7px 9px;
  padding-right: 66px;
  border-radius: var(--radius-sm);
  transition: background var(--duration-fast), color var(--duration-fast);
}

.aha-cw-hist-row:hover .aha-cw-hist-open,
.aha-cw-hist-row:focus-within .aha-cw-hist-open { background: var(--secondary); }
.aha-cw-hist-row.is-active .aha-cw-hist-open { color: var(--primary-accent); }
.aha-cw-hist-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
/* 行内重命名输入框：原地改文字，长相跟静态 .aha-cw-hist-title 一模一样。
   全局 input/.input-field 规则用 !important 给所有 input 加了 border / 背景 / box-shadow ring / height:40px，
   这里必须同样用 !important 反压，让框、底、ring、padding、撑高全部消失。
   字号 / 行高 / 颜色 / 字体全 inherit；不撑高、不撑宽、行高列宽都不变（老板视觉验收点） */
.aha-cw-hist-rename-input {
  flex: 1 !important;
  min-width: 0 !important;
  width: auto !important;
  border: 0 !important;
  background: transparent !important;
  /* 父按钮在 renaming 态时被 disabled 会把字色拉灰，这里强制锁回 title 主色，跟静态显示一致 */
  color: var(--text-main) !important;
  font: inherit !important;
  letter-spacing: inherit !important;
  padding: 0 !important;
  margin: 0 !important;
  outline: 0 !important;
  outline-offset: 0 !important;
  box-shadow: none !important;
  height: auto !important;
  min-height: 0 !important;
  line-height: inherit !important;
  border-radius: 0 !important;
  -webkit-appearance: none !important;
  appearance: none !important;
}
.aha-cw-hist-rename-input:focus,
.aha-cw-hist-rename-input:focus-visible,
.aha-cw-hist-rename-input:hover {
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  outline: 0 !important;
}
.aha-cw-hist-time {
  color: var(--text-subtle);
  flex-shrink: 0;
  font-size: 11px;
  transition: opacity var(--duration-fast), transform var(--duration-fast);
}

/* 右侧 action 容器：固定占位（top/right + transform 居中），保证替换原时间位时行宽不抖 */
.aha-cw-hist-actions {
  position: absolute;
  top: 50%;
  right: 9px;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  gap: 2px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-fast);
}
.aha-cw-hist-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  color: var(--text-subtle);
  cursor: pointer;
  padding: 0;
  border-radius: var(--radius-xs);
  transition: color var(--duration-fast), background var(--duration-fast);
}
.aha-cw-hist-action .phosphor-icon {
  font-size: 14px;
  line-height: 1;
  color: currentColor;
}
.aha-cw-hist-action:hover,
.aha-cw-hist-action:focus-visible {
  background: var(--secondary-strong, color-mix(in srgb, var(--text-main) 8%, transparent));
  color: var(--text-main);
}
.aha-cw-hist-rename:hover,
.aha-cw-hist-rename:focus-visible {
  color: var(--primary-accent, #d97757);
}
.aha-cw-hist-delete:hover,
.aha-cw-hist-delete:focus-visible {
  background: color-mix(in srgb, var(--danger, #dc2626) 12%, transparent);
  color: var(--danger, #dc2626);
}
/* 删除二次确认态：trash 持续显红，不靠 hover 触发；同时整个 actions 强制可见 */
.aha-cw-hist-action[data-confirm-state="confirm"] {
  background: color-mix(in srgb, var(--danger, #dc2626) 18%, transparent);
  color: var(--danger, #dc2626);
}
.aha-cw-hist-row.is-confirming-delete .aha-cw-hist-actions,
.aha-cw-hist-row.is-renaming .aha-cw-hist-actions {
  opacity: 1;
  pointer-events: auto;
}
.aha-cw-hist-action:disabled {
  opacity: 0.35;
  pointer-events: none;
}
.aha-cw-hist-row:hover .aha-cw-hist-time,
.aha-cw-hist-row:focus-within .aha-cw-hist-time,
.aha-cw-hist-row.is-confirming-delete .aha-cw-hist-time,
.aha-cw-hist-row.is-renaming .aha-cw-hist-time {
  opacity: 0;
  transform: translateX(-4px);
}
.aha-cw-hist-row:hover .aha-cw-hist-actions,
.aha-cw-hist-row:focus-within .aha-cw-hist-actions {
  opacity: 1;
  pointer-events: auto;
}
.aha-cw-hist-empty,
.aha-cw-hist-loading { padding: 14px 8px; text-align: center; color: var(--text-subtle); font-size: var(--text-caption); }

/* ─── 合并下拉：模型 · 思考程度（对齐 Claude 详情） ─── */
.aha-cw-model-btn { max-width: 240px; }
.aha-cw-model-name { max-width: 150px; }
.aha-cw-model-effort {
  color: var(--text-subtle);
  flex-shrink: 0;
}
.aha-cw-model-menu { min-width: 232px; max-width: 280px; padding: 6px; }
.aha-cw-sel-hint {
  font-size: 11.5px;
  color: var(--text-subtle);
  line-height: 1.45;
  margin: 2px 8px 6px;
}
.aha-cw-sel-group {
  font-size: 11px;
  color: var(--text-subtle);
  font-weight: var(--weight-medium);
  padding: 4px 8px 2px;
}
.aha-cw-sel-divider {
  height: 1px;
  background: var(--color-border);
  margin: 6px 4px;
}
.aha-cw-sel-empty {
  padding: 8px 9px;
  color: var(--text-subtle);
  font-size: var(--text-caption);
}
.aha-cw-opt-note {
  color: var(--text-subtle);
  font-style: normal;
  font-size: 11px;
  margin-left: 4px;
}

/* 思考程度入口行（hover 触发 flyout，不做界面切换） */
.aha-cw-effort-wrap {
  position: relative;
}

.aha-cw-sel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text-main);
  font-size: var(--text-caption);
  font-family: var(--font-sans);
  cursor: default;
  padding: 8px 9px;
  border-radius: var(--radius-sm);
  transition: background var(--duration-fast);
}
.aha-cw-sel-row:hover { background: var(--secondary); }
.aha-cw-sel-row-val {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: var(--text-subtle);
}

/* flyout：position:fixed 逃出 overflow:hidden 面板，由 JS 定位到 effort-row 左侧。
   主菜单保持打开不收起，完全对齐 Claude「Effort ›」悬停旁弹效果。 */
.aha-cw-effort-flyout {
  position: fixed;  /* 逃出面板 overflow:hidden，JS 动态设 top/left */
  min-width: 180px;
  max-width: 240px;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 810;     /* 高于面板(800) */
  /* 入场动画：从右侧微微滑入（左弹时从右向左） */
  animation: aha-cw-flyout-in var(--duration-base) var(--ease-out);
}

@keyframes aha-cw-flyout-in {
  from { opacity: 0; transform: translateX(6px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* flyout 隐藏走 hidden 属性即可，无需额外 CSS */

/* header 图标按钮：扁平无灰框（和「+新对话」「左下角+」一致，hover 才有微底） */
.aha-cw-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: 17px;
  transition: background var(--duration-fast), color var(--duration-fast);
}
.aha-cw-icon-btn:hover {
  background: var(--secondary);
  color: var(--text-main);
}
