/* AI 搜索抽屉：右侧约一半屏宽，is-open 驱动过渡（避免 hidden 打断动画） */
.cs-ai-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.38);
  z-index: 1045;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.32s cubic-bezier(0.4, 0, 0.2, 1),
    visibility 0.32s step-end;
}

.cs-ai-drawer-backdrop.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.32s cubic-bezier(0.4, 0, 0.2, 1),
    visibility 0s step-start;
}

.cs-ai-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: 50vw;
  min-width: 280px;
  max-width: 100%;
  background: #fff;
  box-shadow: -12px 0 40px rgba(15, 23, 42, 0.14);
  z-index: 1050;
  transform: translateX(100%);
  pointer-events: none;
  visibility: hidden;
  transition: transform 0.34s cubic-bezier(0.32, 0.72, 0, 1),
    visibility 0.34s step-end,
    box-shadow 0.34s ease;
  display: flex;
  flex-direction: column;
  will-change: transform;
}

.cs-ai-drawer.is-open {
  transform: translateX(0);
  pointer-events: auto;
  visibility: visible;
  transition: transform 0.34s cubic-bezier(0.32, 0.72, 0, 1),
    visibility 0s step-start,
    box-shadow 0.34s ease;
}

.cs-ai-drawer-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.cs-ai-drawer-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid #e2e8f0;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
}

.cs-ai-drawer-mode-toggle {
  background: #fff !important;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.cs-ai-drawer-mode-toggle:focus {
  box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, 0.18);
}

.cs-ai-drawer-mode-menu .dropdown-item i.bx {
  font-size: 1.1rem;
}

.cs-ai-drawer-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: row;
}

.cs-ai-drawer-sessions {
  width: 36%;
  min-width: 7.5rem;
  max-width: 11rem;
  border-left: 1px solid #e2e8f0;
  background: #fafbfc;
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex-shrink: 0;
  transition: width 0.28s cubic-bezier(0.4, 0, 0.2, 1),
    min-width 0.28s cubic-bezier(0.4, 0, 0.2, 1),
    max-width 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.cs-ai-sessions-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  padding: 0.45rem 0.35rem 0.45rem 0.55rem;
  border-bottom: 1px solid #eef2f6;
  flex-shrink: 0;
}

.cs-ai-sessions-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: #64748b;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.cs-ai-sessions-toggle {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: #64748b !important;
  text-decoration: none !important;
  line-height: 1;
  transition: background 0.15s ease, color 0.15s ease;
}

.cs-ai-sessions-toggle:hover {
  color: #2563eb !important;
  background: rgba(37, 99, 235, 0.08) !important;
}

.cs-ai-sessions-toggle .bx {
  font-size: 1.25rem;
}

.cs-ai-session-list-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 会话区最小化：仅保留窄条 + 展开按钮 */
.cs-ai-drawer-sessions.cs-ai-sessions--collapsed {
  width: 2.75rem;
  min-width: 2.75rem;
  max-width: 2.75rem;
}

.cs-ai-drawer-sessions.cs-ai-sessions--collapsed .cs-ai-sessions-title {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.cs-ai-drawer-sessions.cs-ai-sessions--collapsed .cs-ai-sessions-toolbar {
  flex-direction: column;
  justify-content: flex-start;
  padding: 0.5rem 0.25rem;
  gap: 0.35rem;
  border-bottom-color: #e2e8f0;
}

.cs-ai-drawer-sessions.cs-ai-sessions--collapsed .cs-ai-session-list-wrap {
  display: none;
}

.cs-ai-drawer-sessions.cs-ai-sessions--collapsed .cs-ai-sessions-toggle {
  width: 2.25rem;
  height: 2.25rem;
}

.cs-ai-session-list {
  overflow-y: auto;
  flex: 1;
  padding-bottom: 0.5rem;
}

.cs-ai-session-row {
  display: flex;
  align-items: stretch;
  width: 100%;
  min-height: 2.35rem;
  border-bottom: 1px solid #eef2f6;
  gap: 0;
  box-sizing: border-box;
}

.cs-ai-session-row:hover {
  background: #eef2ff;
}

.cs-ai-session-row.is-active {
  background: #e0e7ff;
}

.cs-ai-session-row.is-active .cs-ai-session-main {
  font-weight: 600;
  color: #1e293b !important;
}

.cs-ai-session-row.is-pinned .cs-ai-session-main {
  box-shadow: none;
}

.cs-ai-session-pin {
  flex-shrink: 0;
  font-size: 0.75rem;
  color: #2563eb;
  line-height: 1;
}

.cs-ai-session-actions {
  flex: 0 0 auto;
  align-self: stretch;
  display: flex;
  align-items: stretch;
}

.cs-ai-session-more {
  border: none !important;
  border-radius: 0 !important;
  padding: 0.2rem 0.28rem !important;
  margin: 0 !important;
  color: #64748b !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  text-decoration: none !important;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.cs-ai-session-more.dropdown-toggle::after {
  display: none;
}

.cs-ai-session-row:hover .cs-ai-session-more,
.cs-ai-session-row:focus-within .cs-ai-session-more,
.cs-ai-session-more.show {
  opacity: 1;
}

@media (hover: none) {
  .cs-ai-session-more {
    opacity: 1;
  }
}

.cs-ai-session-more:hover,
.cs-ai-session-more:focus-visible,
.cs-ai-session-more.show {
  color: #2563eb !important;
  background: rgba(37, 99, 235, 0.08) !important;
}

.cs-ai-session-more .bx {
  font-size: 0.95rem;
}

.cs-ai-session-dropdown {
  min-width: 11rem;
  z-index: 1090 !important;
}

.cs-ai-session-dropdown .dropdown-item {
  font-size: 0.8125rem;
  padding: 0.45rem 0.75rem;
}

.cs-ai-session-dropdown .dropdown-item i.bx {
  font-size: 1.1rem;
}

/* AI 重命名会话（my-modal / layer.open）：内容与底部留白 */
.supfile-modal-overlay .supfile-modal:has(.cs-ai-chat-rename-layer) .supfile-modal-header {
  padding: 0.75rem 1.25rem;
}

.supfile-modal-overlay .supfile-modal:has(.cs-ai-chat-rename-layer) .supfile-modal-body {
  padding: 0 !important;
}

.supfile-modal-overlay .cs-ai-chat-rename-layer {
  padding: 1.1rem 1.35rem 1.2rem;
  box-sizing: border-box;
}

.supfile-modal-overlay .cs-ai-chat-rename-layer-hint {
  display: block;
  margin: 0 0 0.65rem;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.5;
  color: #64748b;
}

.supfile-modal-overlay .cs-ai-chat-rename-layer-input.supfile-modal-input {
  margin-top: 0;
  padding: 0.55rem 0.85rem;
  border-radius: 10px;
  border-width: 1px;
}

.supfile-modal-overlay .supfile-modal:has(.cs-ai-chat-rename-layer) .supfile-modal-footer {
  padding: 1rem 1.35rem 1.2rem;
  gap: 0.65rem;
}

.cs-ai-session-main {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  border: none !important;
  border-radius: 0 !important;
  padding: 0.45rem 0.35rem !important;
  font-size: 0.78rem !important;
  color: #334155 !important;
  text-align: left;
  display: flex !important;
  align-items: center !important;
  gap: 0.3rem !important;
}

.cs-ai-session-title-text {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cs-ai-session-item {
  display: block;
  width: 100%;
  padding: 0.45rem 0.5rem !important;
  font-size: 0.8rem;
  color: #334155 !important;
  border-radius: 0 !important;
  border-bottom: 1px solid #eef2f6;
}

.cs-ai-session-item:hover {
  background: #eef2ff !important;
}

.cs-ai-session-item.is-active {
  background: #e0e7ff !important;
  font-weight: 600;
}

.cs-ai-session-empty {
  font-size: 0.78rem;
}

.cs-ai-drawer-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.cs-ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0.65rem;
  background: #fff;
}

.cs-ai-msg {
  margin-bottom: 0.75rem;
  display: flex;
}

.cs-ai-msg-user {
  justify-content: flex-end;
}

/* 助手消息与资源卡片铺满主内容宽度，避免右侧大块留白 */
.cs-ai-msg-assistant {
  justify-content: flex-start;
  width: 100%;
  align-self: stretch;
}

.cs-ai-msg-user .cs-ai-msg-body {
  background: #2563eb;
  color: #fff;
  border-radius: 12px 12px 4px 12px;
  max-width: 92%;
  padding: 0.45rem 0.65rem;
  font-size: 0.875rem;
}

.cs-ai-msg-assistant .cs-ai-msg-body {
  flex: 1;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  background: #f1f5f9;
  color: #0f172a;
  border-radius: 12px 12px 12px 4px;
  padding: 0.5rem 0.65rem;
  font-size: 0.875rem;
}

.cs-ai-msg-text {
  white-space: pre-wrap;
  word-break: break-word;
}

/* 助手回复下方：接续追问芯片（类 ChatGPT 联想问句） */
.cs-ai-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.65rem;
  padding-top: 0.5rem;
  border-top: 1px dashed rgba(37, 99, 235, 0.22);
}

.cs-ai-suggestion-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 0.35rem 0.65rem;
  font-size: 0.78rem;
  line-height: 1.35;
  color: #1d4ed8;
  background: #fff;
  border: 1px solid rgba(37, 99, 235, 0.35);
  border-radius: 999px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.cs-ai-suggestion-chip:hover {
  background: rgba(37, 99, 235, 0.08);
  border-color: #2563eb;
  color: #1e40af;
}

.cs-ai-cards {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-self: stretch;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.cs-ai-card {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  background: #fff;
  color: #0f172a !important;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.cs-ai-card:hover {
  border-color: #93c5fd;
  background: #f8fafc;
}

.cs-ai-card-title {
  font-size: 0.82rem;
  display: block;
  word-break: break-word;
}

.cs-ai-card-sub {
  margin-top: 0.15rem;
}

.cs-ai-card .cs-ai-card-meta-row {
  margin-top: 0.28rem;
  font-size: 0.74rem;
  color: #64748b;
  line-height: 1.45;
  word-break: break-word;
}

.cs-ai-card .cs-ai-card-intro {
  margin: 0.35rem 0 0;
  line-height: 1.46;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.cs-ai-card-meta {
  margin-top: 0.25rem;
  color: #64748b;
}

/* 输入区：加大、圆角、阴影，发送为图标按钮 */
.cs-ai-composer {
  flex-shrink: 0;
  padding: 0.65rem 0.75rem 0.85rem;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
}

.cs-ai-composer-hint {
  padding: 0 0.15rem 0.4rem;
}

.cs-ai-composer-row {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.5rem 0.55rem 0.5rem 0.75rem;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.cs-ai-input {
  flex: 1;
  min-width: 0;
  min-height: 3.25rem;
  max-height: 8rem;
  padding: 0.55rem 0.35rem;
  font-size: 0.95rem;
  line-height: 1.45;
  border: 0 !important;
  box-shadow: none !important;
  resize: vertical;
  background: transparent;
}

.cs-ai-input:focus {
  box-shadow: none !important;
}

.cs-ai-send-btn {
  flex-shrink: 0;
  width: 2.65rem;
  height: 2.65rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #2563eb;
  border: none;
  color: #fff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
  transition: background 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
}

.cs-ai-send-btn:hover {
  background: #1d4ed8;
  color: #fff;
  transform: scale(1.04);
}

.cs-ai-send-btn:active {
  transform: scale(0.96);
}

.cs-ai-send-btn:disabled {
  opacity: 0.55;
  transform: none;
  cursor: not-allowed;
}

.cs-ai-send-btn .bx {
  font-size: 1.35rem;
  margin-left: 2px;
}

@media (max-width: 575.98px) {
  .cs-ai-drawer {
    width: 100%;
    min-width: 0;
  }
  .cs-ai-drawer-sessions {
    min-width: 6.5rem;
  }
  .cs-ai-drawer-sessions.cs-ai-sessions--collapsed {
    width: 2.5rem;
    min-width: 2.5rem;
    max-width: 2.5rem;
  }
  .cs-ai-input {
    font-size: 1rem;
  }
}

html.cs-ai-drawer-open {
  overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
  .cs-ai-drawer-backdrop,
  .cs-ai-drawer {
    transition-duration: 0.01ms !important;
  }
  .cs-ai-drawer-sessions {
    transition-duration: 0.01ms !important;
  }
  .cs-ai-send-btn {
    transition: none;
  }
}
