/* ===== Chat Saver 完整功能页面 - 浅色主题（贴合积分系统） ===== */

/* 容器 */
.cs-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

/* 头部 */
.cs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 16px;
  border-bottom: 2px solid #f1f5f9;
  margin-bottom: 20px;
}
.cs-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.cs-header-logo {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 20px;
  font-weight: 800;
}
.cs-header-title {
  font-size: 20px;
  font-weight: 800;
  color: #1e293b;
  margin: 0;
}
.cs-header-desc {
  font-size: 12px;
  color: #94a3b8;
  margin: 2px 0 0;
}
.cs-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.cs-btn-icon {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #64748b;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}
.cs-btn-icon:hover {
  background: #f8fafc;
  color: #667eea;
  border-color: #667eea;
}

/* 权限提示条 */
.cs-permission-bar {
  background: linear-gradient(135deg, rgba(102,126,234,0.06), rgba(118,75,162,0.04));
  border: 1px solid rgba(102,126,234,0.15);
  border-radius: 12px;
  padding: 12px 18px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: #475569;
}
.cs-permission-bar .badge {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.cs-permission-bar .highlight {
  color: #667eea;
  font-weight: 600;
}

/* 主布局 - 左右两栏 */
.cs-main-grid {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 20px;
  margin-bottom: 20px;
}
@media (max-width: 900px) {
  .cs-main-grid {
    grid-template-columns: 1fr;
  }
}

/* 卡片通用样式 */
.cs-card {
  background: #fff;
  border-radius: 16px;
  border: 1px solid rgba(0,0,0,0.06);
  box-shadow: 0 2px 12px rgba(0,0,0,0.04);
  padding: 20px;
  transition: all 0.3s;
}
.cs-card:hover {
  box-shadow: 0 4px 20px rgba(0,0,0,0.06);
}
.cs-card-title {
  font-size: 15px;
  font-weight: 700;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 16px;
}
.cs-card-title .icon {
  font-size: 16px;
}

/* ===== 添加对话链接卡片 ===== */
.cs-add-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.cs-add-actions {
  display: flex;
  gap: 6px;
}
.cs-link-btn {
  font-size: 11px;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 6px;
  border: none;
  background: none;
  transition: all 0.2s;
}
.cs-link-btn:hover {
  color: #667eea;
  background: rgba(102,126,234,0.06);
}
.cs-link-btn.active {
  color: #667eea;
  background: rgba(102,126,234,0.1);
}

/* 帮助提示 */
.cs-help-box {
  background: linear-gradient(135deg, rgba(102,126,234,0.06), rgba(118,75,162,0.04));
  border: 1px solid rgba(102,126,234,0.15);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 14px;
  font-size: 12px;
  color: #475569;
  display: none;
}
.cs-help-box.show {
  display: block;
}
.cs-help-box ol {
  margin: 6px 0 0 16px;
  padding: 0;
  color: #64748b;
}
.cs-help-box ol li {
  margin-bottom: 3px;
}

/* 输入行 */
.cs-input-row {
  display: flex;
  gap: 10px;
}
.cs-input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 10px;
  border: 2px solid #e2e8f0;
  background: #f8fafc;
  font-size: 13px;
  color: #1e293b;
  outline: none;
  transition: all 0.2s;
}
.cs-input:focus {
  border-color: #667eea;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(102,126,234,0.1);
}
.cs-input::placeholder {
  color: #94a3b8;
}
.cs-btn-add {
  padding: 10px 20px;
  border-radius: 10px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  white-space: nowrap;
}
.cs-btn-add:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(102,126,234,0.35);
}

/* 批量输入 */
.cs-batch-area {
  display: none;
}
.cs-batch-area.show {
  display: block;
}
.cs-batch-textarea {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 2px solid #e2e8f0;
  background: #f8fafc;
  font-size: 12px;
  color: #1e293b;
  outline: none;
  resize: vertical;
  min-height: 100px;
  font-family: 'SF Mono', Monaco, monospace;
  transition: all 0.2s;
}
.cs-batch-textarea:focus {
  border-color: #667eea;
  background: #fff;
}
.cs-batch-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
}
.cs-batch-count {
  font-size: 11px;
  color: #94a3b8;
}

/* ===== 跟踪的对话列表 ===== */
.cs-tracked-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.cs-tracked-count {
  font-size: 11px;
  color: #94a3b8;
  background: #f1f5f9;
  padding: 2px 10px;
  border-radius: 20px;
  margin-left: 8px;
}
.cs-select-all-btn {
  font-size: 11px;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 6px;
  border: none;
  background: none;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
}
.cs-select-all-btn:hover {
  color: #667eea;
  background: rgba(102,126,234,0.06);
}

/* 搜索和筛选 */
.cs-filter-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.cs-search-wrap {
  flex: 1;
  position: relative;
}
.cs-search-wrap .search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  font-size: 13px;
}
.cs-search-input {
  width: 100%;
  padding: 7px 10px 7px 30px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  font-size: 12px;
  color: #1e293b;
  outline: none;
  transition: all 0.2s;
}
.cs-search-input:focus {
  border-color: #667eea;
  background: #fff;
}
.cs-filter-select {
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  font-size: 12px;
  color: #475569;
  outline: none;
  cursor: pointer;
}

/* 对话列表项 */
.cs-link-list {
  max-height: 360px;
  overflow-y: auto;
}
.cs-link-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid rgba(0,0,0,0.04);
  margin-bottom: 8px;
  transition: all 0.2s;
}
.cs-link-item:hover {
  background: #f1f5f9;
  border-color: rgba(102,126,234,0.15);
}
.cs-link-checkbox {
  cursor: pointer;
  font-size: 16px;
  color: #94a3b8;
  flex-shrink: 0;
}
.cs-link-checkbox.checked {
  color: #667eea;
}
.cs-link-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.cs-link-dot.pending { background: #94a3b8; }
.cs-link-dot.fetching { background: #f59e0b; animation: pulse 1.5s infinite; }
.cs-link-dot.success { background: #22c55e; }
.cs-link-dot.error { background: #ef4444; }
.cs-link-info {
  flex: 1;
  min-width: 0;
}
.cs-link-title {
  font-size: 13px;
  color: #1e293b;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cs-link-url {
  font-size: 11px;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.cs-link-stats {
  font-size: 10px;
  color: #22c55e;
  margin-top: 2px;
}
.cs-link-error {
  font-size: 10px;
  color: #ef4444;
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.cs-link-time {
  font-size: 10px;
  color: #94a3b8;
  flex-shrink: 0;
}
.cs-link-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s;
}
.cs-link-item:hover .cs-link-actions {
  opacity: 1;
}
.cs-link-action-btn {
  padding: 4px;
  border-radius: 6px;
  border: none;
  background: none;
  cursor: pointer;
  color: #94a3b8;
  font-size: 14px;
  transition: all 0.2s;
}
.cs-link-action-btn:hover {
  background: rgba(102,126,234,0.1);
  color: #667eea;
}
.cs-link-action-btn.delete:hover {
  background: rgba(239,68,68,0.1);
  color: #ef4444;
}

/* 空状态 */
.cs-empty {
  text-align: center;
  padding: 40px 20px;
}
.cs-empty-icon {
  font-size: 48px;
  opacity: 0.3;
  margin-bottom: 12px;
}
.cs-empty-text {
  font-size: 14px;
  color: #94a3b8;
  font-weight: 500;
}
.cs-empty-hint {
  font-size: 12px;
  color: #cbd5e1;
  margin-top: 4px;
}

/* 已选择提示 */
.cs-selected-hint {
  font-size: 11px;
  color: #667eea;
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ===== 备份控制卡片 ===== */
.cs-backup-btn {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
}
.cs-backup-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(102,126,234,0.35);
}
.cs-backup-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}
.cs-backup-btn.backing-up {
  background: linear-gradient(135deg, #a5b4fc, #c4b5fd);
}

/* 进度条 */
.cs-progress-wrap {
  margin-top: 12px;
  display: none;
}
.cs-progress-wrap.show {
  display: block;
}
.cs-progress-bar {
  height: 6px;
  background: #f1f5f9;
  border-radius: 3px;
  overflow: hidden;
}
.cs-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #667eea, #764ba2);
  border-radius: 3px;
  transition: width 0.3s;
  width: 0%;
}
.cs-progress-text {
  font-size: 10px;
  color: #94a3b8;
  text-align: center;
  margin-top: 4px;
}

/* 自动保存 */
.cs-autosave-section {
  margin-top: 20px;
}
.cs-autosave-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.cs-autosave-label {
  font-size: 13px;
  color: #475569;
  display: flex;
  align-items: center;
  gap: 6px;
}
/* 开关 */
.cs-switch {
  position: relative;
  width: 40px;
  height: 22px;
  background: #e2e8f0;
  border-radius: 11px;
  cursor: pointer;
  transition: all 0.3s;
  border: none;
  padding: 0;
}
.cs-switch.on {
  background: linear-gradient(135deg, #667eea, #764ba2);
}
.cs-switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: all 0.3s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.cs-switch.on .cs-switch-knob {
  left: 20px;
}
/* 间隔设置 */
.cs-interval-row {
  display: none;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.cs-interval-row.show {
  display: flex;
}
.cs-interval-label {
  font-size: 12px;
  color: #64748b;
}
.cs-interval-input {
  width: 60px;
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  font-size: 12px;
  color: #1e293b;
  text-align: center;
  outline: none;
}
.cs-interval-input:focus {
  border-color: #667eea;
}
/* 自动保存状态 */
.cs-autosave-status {
  display: none;
  font-size: 11px;
}
.cs-autosave-status.show {
  display: block;
}
.cs-autosave-active {
  color: #22c55e;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.cs-autosave-active .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  animation: pulse 2s infinite;
}
.cs-autosave-countdown {
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ===== 最新备份卡片 ===== */
.cs-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}
.cs-stat-item {
  text-align: center;
  padding: 12px 8px;
  background: linear-gradient(135deg, #f8fafc, #f1f5f9);
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,0.04);
}
.cs-stat-icon {
  font-size: 14px;
  color: #94a3b8;
  margin-bottom: 4px;
}
.cs-stat-value {
  font-size: 18px;
  font-weight: 800;
  color: #1e293b;
}
.cs-stat-label {
  font-size: 10px;
  color: #94a3b8;
  margin-top: 2px;
}

/* 备份时间 */
.cs-backup-time {
  font-size: 11px;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
}

/* 对话预览 */
.cs-preview-section {
  margin-bottom: 14px;
}
.cs-preview-label {
  font-size: 11px;
  color: #94a3b8;
  margin-bottom: 6px;
}
.cs-preview-btn {
  width: 100%;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid rgba(0,0,0,0.04);
  cursor: pointer;
  font-size: 12px;
  color: #1e293b;
  margin-bottom: 6px;
  transition: all 0.2s;
}
.cs-preview-btn:hover {
  background: #f1f5f9;
  border-color: rgba(102,126,234,0.15);
}
.cs-preview-btn .eye-icon {
  color: #667eea;
}
.cs-preview-btn .msg-count {
  margin-left: auto;
  color: #94a3b8;
  font-size: 11px;
}

/* 导出按钮 */
.cs-export-section {
  margin-bottom: 12px;
}
.cs-export-label {
  font-size: 11px;
  color: #94a3b8;
  margin-bottom: 8px;
}
.cs-zip-btn {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(245,158,11,0.1), rgba(234,88,12,0.1));
  border: 1px solid rgba(245,158,11,0.2);
  color: #92400e;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
  margin-bottom: 6px;
}
.cs-zip-btn:hover {
  background: linear-gradient(135deg, rgba(245,158,11,0.15), rgba(234,88,12,0.15));
  border-color: rgba(245,158,11,0.3);
}
.cs-zip-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.cs-zip-hint {
  font-size: 10px;
  color: #94a3b8;
  text-align: center;
}

/* 其他格式导出 */
.cs-other-export {
  margin-top: 12px;
}
.cs-other-export-label {
  font-size: 11px;
  color: #94a3b8;
  margin-bottom: 8px;
}
.cs-export-btns {
  display: flex;
  gap: 8px;
}
.cs-export-btn {
  flex: 1;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #475569;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s;
}
.cs-export-btn:hover {
  border-color: #667eea;
  color: #667eea;
  background: rgba(102,126,234,0.04);
}
.cs-export-btn .icon-html { color: #8b5cf6; }
.cs-export-btn .icon-md { color: #3b82f6; }
.cs-export-btn .icon-json { color: #22c55e; }

/* JSON下拉 */
.cs-json-dropdown {
  position: relative;
}
.cs-json-menu {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  z-index: 10;
  margin-bottom: 4px;
  overflow: hidden;
}
.cs-json-menu.show {
  display: block;
}
.cs-json-option {
  padding: 8px 12px;
  font-size: 11px;
  color: #475569;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: all 0.15s;
}
.cs-json-option:hover {
  background: rgba(102,126,234,0.06);
  color: #667eea;
}

/* 无备份状态 */
.cs-no-backup {
  text-align: center;
  padding: 30px 20px;
}
.cs-no-backup-icon {
  font-size: 40px;
  opacity: 0.3;
  margin-bottom: 10px;
}
.cs-no-backup-text {
  font-size: 13px;
  color: #94a3b8;
}
.cs-no-backup-hint {
  font-size: 11px;
  color: #cbd5e1;
  margin-top: 4px;
}

/* ===== 运行日志面板 ===== */
.cs-logs-panel {
  background: #fff;
  border-radius: 16px;
  border: 1px solid rgba(0,0,0,0.06);
  box-shadow: 0 2px 12px rgba(0,0,0,0.04);
  overflow: hidden;
  margin-bottom: 20px;
}
.cs-logs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  cursor: pointer;
  transition: background 0.2s;
}
.cs-logs-header:hover {
  background: #f8fafc;
}
.cs-logs-title {
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 8px;
}
.cs-logs-badge {
  font-size: 10px;
  color: #94a3b8;
  background: #f1f5f9;
  padding: 2px 8px;
  border-radius: 20px;
}
.cs-logs-error-badge {
  font-size: 10px;
  color: #ef4444;
  background: rgba(239,68,68,0.1);
  padding: 2px 8px;
  border-radius: 20px;
  border: 1px solid rgba(239,68,68,0.2);
  animation: pulse 2s infinite;
}
.cs-logs-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.cs-logs-clear-btn {
  font-size: 11px;
  color: #94a3b8;
  cursor: pointer;
  padding: 3px 10px;
  border-radius: 6px;
  border: none;
  background: none;
  transition: all 0.2s;
}
.cs-logs-clear-btn:hover {
  color: #ef4444;
  background: rgba(239,68,68,0.06);
}
.cs-logs-toggle {
  font-size: 14px;
  color: #94a3b8;
  transition: transform 0.3s;
}
.cs-logs-toggle.expanded {
  transform: rotate(180deg);
}

/* 日志内容 */
.cs-logs-body {
  display: none;
  max-height: 250px;
  overflow-y: auto;
  padding: 0 20px 16px;
}
.cs-logs-body.show {
  display: block;
}
.cs-log-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 12px;
  margin-bottom: 2px;
  transition: background 0.15s;
}
.cs-log-item:hover {
  background: #f8fafc;
}
.cs-log-item.error {
  background: rgba(239,68,68,0.04);
}
.cs-log-icon {
  flex-shrink: 0;
  margin-top: 1px;
}
.cs-log-icon.success { color: #22c55e; }
.cs-log-icon.error { color: #ef4444; }
.cs-log-icon.warn { color: #f59e0b; }
.cs-log-icon.info { color: #3b82f6; }
.cs-log-time {
  color: #94a3b8;
  font-size: 11px;
  font-family: 'SF Mono', Monaco, monospace;
  flex-shrink: 0;
}
.cs-log-msg {
  color: #475569;
  word-break: break-all;
}
.cs-log-item.error .cs-log-msg {
  color: #dc2626;
}
.cs-log-empty {
  text-align: center;
  padding: 24px;
  color: #94a3b8;
  font-size: 13px;
}

/* ===== 对话预览弹窗 ===== */
.cs-modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 10000;
  justify-content: center;
  align-items: center;
}
.cs-modal-overlay.show {
  display: flex;
}
.cs-modal {
  background: #fff;
  border-radius: 20px;
  width: 92%;
  max-width: 700px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 60px rgba(0,0,0,0.2);
}
.cs-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  border-bottom: 1px solid #f1f5f9;
}
.cs-modal-title {
  font-size: 16px;
  font-weight: 700;
  color: #1e293b;
}
.cs-modal-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #94a3b8;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.2s;
}
.cs-modal-close:hover {
  background: #f1f5f9;
  color: #1e293b;
}
.cs-modal-search {
  padding: 10px 24px;
  border-bottom: 1px solid #f1f5f9;
}
.cs-modal-search input {
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  font-size: 12px;
  outline: none;
}
.cs-modal-search input:focus {
  border-color: #667eea;
}
.cs-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
}
.cs-msg-item {
  padding: 10px 14px;
  margin-bottom: 8px;
  border-radius: 10px;
  border-left: 3px solid;
}
.cs-msg-item.user {
  background: rgba(102,126,234,0.04);
  border-left-color: #667eea;
}
.cs-msg-item.assistant {
  background: rgba(34,197,94,0.04);
  border-left-color: #22c55e;
}
.cs-msg-role {
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 4px;
}
.cs-msg-item.user .cs-msg-role { color: #667eea; }
.cs-msg-item.assistant .cs-msg-role { color: #22c55e; }
.cs-msg-content {
  font-size: 13px;
  color: #475569;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
}

/* ===== 确认对话框 ===== */
.cs-confirm-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 10001;
  justify-content: center;
  align-items: center;
}
.cs-confirm-overlay.show {
  display: flex;
}
.cs-confirm-box {
  background: #fff;
  border-radius: 16px;
  width: 92%;
  max-width: 380px;
  padding: 24px;
  box-shadow: 0 25px 60px rgba(0,0,0,0.2);
}
.cs-confirm-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}
.cs-confirm-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(239,68,68,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ef4444;
  font-size: 18px;
  flex-shrink: 0;
}
.cs-confirm-title {
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
}
.cs-confirm-msg {
  font-size: 12px;
  color: #64748b;
  margin-top: 4px;
  line-height: 1.5;
}
.cs-confirm-btns {
  display: flex;
  gap: 10px;
}
.cs-confirm-cancel {
  flex: 1;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #64748b;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}
.cs-confirm-cancel:hover {
  background: #f8fafc;
}
.cs-confirm-ok {
  flex: 1;
  padding: 10px;
  border-radius: 10px;
  border: none;
  background: #ef4444;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.cs-confirm-ok:hover {
  background: #dc2626;
}

/* 页脚 */
.cs-footer {
  text-align: center;
  padding: 16px 0;
  font-size: 11px;
  color: #94a3b8;
  border-top: 1px solid #f1f5f9;
}

/* 隐藏文件输入 */
.cs-hidden-input {
  display: none;
}

/* 加载动画 */
@keyframes cs-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.cs-spin {
  animation: cs-spin 1s linear infinite;
  display: inline-block;
}

/* ===== 沙盒文件打包提示（一体化版） ===== */
.cs-sandbox-tip {
  background: linear-gradient(135deg, rgba(34,197,94,0.06), rgba(16,185,129,0.08));
  border: 1px solid rgba(34,197,94,0.2);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
  transition: all 0.3s;
}
.cs-sandbox-tip::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px; height: 100%;
  background: linear-gradient(180deg, #22c55e, #10b981);
  border-radius: 4px 0 0 4px;
}
.cs-sandbox-tip:hover {
  border-color: rgba(34,197,94,0.35);
  box-shadow: 0 2px 12px rgba(34,197,94,0.08);
}
.cs-sandbox-tip-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.cs-sandbox-tip-icon {
  font-size: 20px;
  flex-shrink: 0;
}
.cs-sandbox-tip-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.cs-sandbox-tip-title {
  font-size: 13px;
  font-weight: 700;
  color: #166534;
}
.cs-sandbox-tip-desc {
  font-size: 11.5px;
  color: #475569;
  line-height: 1.5;
}
.cs-sandbox-tip-desc strong {
  color: #166534;
  font-weight: 700;
}
.cs-sandbox-tip-prompt {
  background: linear-gradient(135deg, #f8fdf9, #f0fdf4);
  border: 1px dashed rgba(34,197,94,0.35);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12px;
  color: #1e293b;
  line-height: 1.6;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
  margin-bottom: 12px;
  word-break: break-all;
  user-select: all;
}
.cs-sandbox-tip-copy {
  width: 100%;
  padding: 10px 16px;
  border-radius: 10px;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.25s;
  margin-bottom: 12px;
}
.cs-sandbox-tip-copy:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(34,197,94,0.35);
  background: linear-gradient(135deg, #16a34a, #15803d);
}
.cs-sandbox-tip-copy:active {
  transform: translateY(0);
}
.cs-sandbox-tip-copy.copied {
  background: linear-gradient(135deg, #059669, #047857);
}
.cs-sandbox-tip-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
.cs-sandbox-step {
  font-size: 11px;
  color: #64748b;
}
.cs-sandbox-step b {
  color: #166534;
  font-weight: 700;
}
.cs-sandbox-step-sep {
  color: #94a3b8;
  font-size: 11px;
}
@media (max-width: 600px) {
  .cs-sandbox-tip {
    padding: 14px 14px;
  }
  .cs-sandbox-tip-steps {
    flex-direction: column;
    gap: 4px;
  }
  .cs-sandbox-step-sep {
    display: none;
  }
}
  .cs-sandbox-detail-steps {
    flex-direction: column;
    gap: 4px;
  }
  .cs-sandbox-step-sep {
    display: none;
  }
}

/* ===== v45: 备份自动清空设置 ===== */
.cs-retention-card {
  position: relative;
  overflow: hidden;
}
.cs-retention-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px; height: 100%;
  background: linear-gradient(180deg, #ef4444, #f97316);
  border-radius: 4px 0 0 4px;
}
.cs-retention-desc {
  font-size: 12px;
  color: #64748b;
  line-height: 1.6;
  margin-bottom: 12px;
}
.cs-retention-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.cs-retention-label {
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  white-space: nowrap;
}
.cs-retention-input {
  width: 80px;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  color: #1e293b;
  background: #fff;
  transition: border-color 0.2s;
  outline: none;
}
.cs-retention-input:focus {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239,68,68,0.1);
}
.cs-retention-unit {
  font-size: 13px;
  color: #64748b;
}
.cs-retention-save-btn {
  padding: 8px 20px;
  border-radius: 8px;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.25s;
}
.cs-retention-save-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 12px rgba(239,68,68,0.3);
  background: linear-gradient(135deg, #dc2626, #b91c1c);
}
.cs-retention-save-btn:active { transform: translateY(0); }
.cs-retention-save-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.cs-retention-status {
  font-size: 12px;
  min-height: 18px;
  margin-bottom: 8px;
  transition: all 0.3s;
}
.cs-retention-status.success { color: #16a34a; }
.cs-retention-status.error { color: #dc2626; }
.cs-retention-status.info { color: #2563eb; }
.cs-retention-cleanup-btn {
  padding: 8px 16px;
  border-radius: 8px;
  background: transparent;
  color: #ef4444;
  font-size: 12px;
  font-weight: 500;
  border: 1px dashed rgba(239,68,68,0.4);
  cursor: pointer;
  transition: all 0.25s;
}
.cs-retention-cleanup-btn:hover {
  background: rgba(239,68,68,0.06);
  border-color: rgba(239,68,68,0.6);
}
.cs-retention-cleanup-btn:disabled { opacity: 0.5; cursor: not-allowed; }
@media (max-width: 600px) {
  .cs-retention-row { flex-direction: column; align-items: flex-start; gap: 8px; }
  .cs-retention-input { width: 100%; }
  .cs-retention-save-btn { width: 100%; }
}

/* ===== v45: 前台自动清空状态提示 ===== */
.cs-retention-hint {
  font-size: 12px;
  padding: 10px 16px;
  border-radius: 10px;
  margin-bottom: 16px;
  display: none;
  align-items: center;
  gap: 6px;
  line-height: 1.6;
}
.cs-retention-hint.active {
  display: flex;
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}
.cs-retention-hint.safe {
  display: flex;
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}
.cs-retention-hint-icon {
  font-size: 14px;
  flex-shrink: 0;
}


/* ===== Mobile overflow fix 2026-04-11 ===== */
@media (max-width: 600px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  .cs-container,
  .cs-main-grid,
  .cs-header,
  .cs-header-left,
  .cs-header-actions,
  .cs-card,
  .cs-panel,
  .cs-sandbox-tip,
  .cs-sandbox-tip-text,
  .cs-sandbox-tip-prompt,
  .cs-add-header,
  .cs-input-row,
  .cs-batch-footer,
  .cs-filter-row {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  .cs-header,
  .cs-header-left,
  .cs-header-actions,
  .cs-add-header,
  .cs-input-row,
  .cs-batch-footer,
  .cs-filter-row {
    flex-wrap: wrap;
    gap: 10px;
  }

  .cs-header-title,
  .cs-header-desc,
  .cs-sandbox-tip-title,
  .cs-sandbox-tip-desc,
  .cs-sandbox-tip-prompt,
  .cs-empty-text,
  .cs-file-path,
  .cs-stat-label,
  .cs-stat-value {
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .cs-sandbox-tip-prompt {
    white-space: pre-wrap;
  }

  .cs-sandbox-tip-steps {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .cs-sandbox-tip-copy,
  .cs-action-btn,
  .cs-submit-btn,
  .cs-back-btn {
    max-width: 100%;
  }
}


/* ===== Enhanced Mobile Fix - 2026-04-11 v2 ===== */
/* Fix right-side truncation on mobile devices */
@media (max-width: 768px) {
  /* Force all containers to respect viewport width */
  .cs-container {
    padding: 0 10px !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }
  
  /* Grid must be single column on mobile */
  .cs-main-grid {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }
  
  /* Header responsive */
  .cs-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 10px !important;
    padding: 14px 0 12px !important;
  }
  .cs-header-actions {
    flex-wrap: wrap !important;
    width: 100% !important;
  }
  .cs-header-title {
    font-size: 17px !important;
  }
  
  /* Permission bar responsive */
  .cs-permission-bar {
    flex-direction: column !important;
    text-align: center !important;
    gap: 6px !important;
    padding: 10px 12px !important;
    font-size: 12px !important;
  }
  
  /* Cards must not overflow */
  .cs-card {
    padding: 14px !important;
    max-width: 100% !important;
    overflow: hidden !important;
  }
  
  /* Add header responsive */
  .cs-add-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 8px !important;
  }
  .cs-add-actions {
    width: 100% !important;
    flex-wrap: wrap !important;
  }
  
  /* Input row responsive */
  .cs-input-row {
    flex-direction: column !important;
    gap: 8px !important;
  }
  .cs-input-row .cs-input {
    width: 100% !important;
  }
  .cs-input-row .cs-btn-add {
    width: 100% !important;
  }
  
  /* Sandbox tip responsive */
  .cs-sandbox-tip {
    padding: 12px !important;
  }
  .cs-sandbox-tip-prompt {
    font-size: 11px !important;
    word-break: break-all !important;
    overflow-wrap: anywhere !important;
    max-width: 100% !important;
  }
  .cs-sandbox-tip-header {
    flex-direction: column !important;
    gap: 8px !important;
  }
  .cs-sandbox-tip-copy {
    font-size: 12px !important;
    padding: 8px 12px !important;
  }
  
  /* Batch textarea responsive */
  .cs-batch-textarea {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }
  .cs-batch-footer {
    flex-direction: column !important;
    gap: 8px !important;
  }
  
  /* Filter row responsive */
  .cs-filter-row {
    flex-direction: column !important;
    gap: 8px !important;
  }
  .cs-search-wrap {
    width: 100% !important;
  }
  .cs-filter-select {
    width: 100% !important;
  }
  
  /* Link items responsive */
  .cs-link-item {
    padding: 10px !important;
  }
  .cs-link-item .link-title {
    font-size: 13px !important;
  }
  .cs-link-item .link-url {
    font-size: 11px !important;
  }
  
  /* Backup button responsive */
  .cs-backup-btn {
    width: 100% !important;
    font-size: 13px !important;
  }
  
  /* Autosave section responsive */
  .cs-autosave-row {
    flex-wrap: wrap !important;
  }
  .cs-interval-row {
    flex-wrap: wrap !important;
    gap: 6px !important;
  }
  
  /* Logs responsive */
  .cs-log-item {
    font-size: 11px !important;
    padding: 4px 10px !important;
    word-break: break-all !important;
  }
  
  /* Tool select area responsive */
  #toolSelectArea {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
  
  /* Tracked list responsive */
  .cs-tracked-header {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }
  
  /* Selected hint responsive */
  .cs-selected-hint {
    font-size: 12px !important;
  }
  
  /* Right column cards */
  .cs-right-col .cs-card {
    margin-bottom: 14px !important;
  }
  
  /* Retention hint */
  .cs-retention-hint {
    font-size: 12px !important;
    padding: 8px 12px !important;
  }
}

/* Extra small devices */
@media (max-width: 480px) {
  .cs-container {
    padding: 0 6px !important;
  }
  .cs-card {
    padding: 12px !important;
    border-radius: 12px !important;
  }
  .cs-header-logo {
    width: 36px !important;
    height: 36px !important;
    font-size: 16px !important;
  }
  .cs-header-title {
    font-size: 15px !important;
  }
  .cs-btn-icon {
    padding: 5px 10px !important;
    font-size: 11px !important;
  }
}


/* ===== Critical Mobile Fix - 2026-04-12 ===== */
/* Force all ancestors to respect viewport width on mobile */
@media (max-width: 768px) {
  html, body {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100vw !important;
  }
  
  #section-tools {
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
    padding: 0 !important;
  }
  
  #section-tools > .cs-container {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 8px !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
  }
  
  #csToolArea {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
    padding: 0 !important;
    box-sizing: border-box !important;
  }
  
  #csToolArea > div {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 8px !important;
    box-sizing: border-box !important;
  }
  
  /* Tool select area - single column */
  #toolSelectArea {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  
  /* All cs- elements must respect width */
  .cs-container,
  .cs-main-grid,
  .cs-card,
  .cs-header,
  .cs-add-card,
  .cs-tracked-card,
  .cs-backup-card,
  .cs-sandbox-tip,
  .cs-permission-bar,
  .cs-retention-card {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
  }
  
  /* Force single column grid */
  .cs-main-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  
  /* Input row must stack */
  .cs-input-row {
    flex-direction: column !important;
    gap: 8px !important;
    width: 100% !important;
  }
  .cs-input-row > * {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }
  
  /* Buttons must not overflow */
  .cs-btn-add,
  .cs-btn-icon,
  .cs-action-btn,
  .cs-submit-btn,
  .cs-backup-btn,
  .cs-sandbox-tip-copy,
  button {
    max-width: 100% !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    box-sizing: border-box !important;
  }
  
  /* Sandbox tip prompt must wrap */
  .cs-sandbox-tip-prompt {
    font-size: 10px !important;
    word-break: break-all !important;
    overflow-wrap: anywhere !important;
    white-space: pre-wrap !important;
    max-width: 100% !important;
    padding: 8px !important;
  }
  
  /* Header actions wrap */
  .cs-header-actions {
    flex-wrap: wrap !important;
    gap: 6px !important;
    width: 100% !important;
  }
  
  /* Add header actions wrap */
  .cs-add-header {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
  }
  .cs-add-actions {
    flex-wrap: wrap !important;
    gap: 6px !important;
  }
  
  /* Batch textarea */
  .cs-batch-textarea {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }
  
  /* Filter row */
  .cs-filter-row {
    flex-direction: column !important;
    gap: 8px !important;
  }
  .cs-search-wrap,
  .cs-filter-select {
    width: 100% !important;
    max-width: 100% !important;
  }
  
  /* Logs */
  .cs-log-item {
    word-break: break-all !important;
    font-size: 11px !important;
  }
  
  /* Tracked list header */
  .cs-tracked-header {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
  }
  
  /* Link items */
  .cs-link-item {
    padding: 8px !important;
  }
  .cs-link-actions {
    flex-wrap: wrap !important;
    gap: 4px !important;
  }
  .cs-link-actions button {
    font-size: 11px !important;
    padding: 4px 8px !important;
  }
  
  /* Autosave */
  .cs-autosave-row {
    flex-direction: column !important;
    gap: 8px !important;
  }
  .cs-interval-row {
    flex-wrap: wrap !important;
    gap: 6px !important;
  }
  
  /* Backup list items */
  .cs-backup-item {
    padding: 8px !important;
  }
  .cs-backup-item-actions {
    flex-wrap: wrap !important;
    gap: 4px !important;
  }
  
  /* Selected hint */
  .cs-selected-hint {
    flex-wrap: wrap !important;
    gap: 6px !important;
    font-size: 12px !important;
  }
}

/* Extra small phones */
@media (max-width: 400px) {
  #section-tools > .cs-container {
    padding: 0 4px !important;
  }
  .cs-card {
    padding: 10px !important;
    border-radius: 10px !important;
  }
  .cs-header-title {
    font-size: 14px !important;
  }
  .cs-header-logo {
    width: 32px !important;
    height: 32px !important;
    font-size: 14px !important;
  }
  .cs-btn-icon {
    font-size: 10px !important;
    padding: 4px 8px !important;
  }
}
