/* ============================================
   ClipRadar 后台管理 - 样式表
   复用主站设计语言，独立布局
   ============================================ */

:root {
  --bg: #FFFFFF;
  --bg2: #F0F5FF;
  --bg3: #F8FAFC;
  --bg4: #F1F5F9;
  --ink: #0F172A;
  --muted: #64748B;
  --muted2: #94A3B8;
  --rule: #E2E8F0;
  --accent: #2563EB;
  --accent-light: #DBEAFE;
  --accent-dark: #1D4ED8;
  --accent-hover: #1E40AF;
  --green: #059669;
  --green-light: #D1FAE5;
  --green-bg: #ECFDF5;
  --orange: #D97706;
  --orange-light: #FEF3C7;
  --orange-bg: #FFFBEB;
  --red: #DC2626;
  --red-light: #FEE2E2;
  --red-bg: #FEF2F2;
  --purple: #7C3AED;
  --purple-light: #EDE9FE;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.12);
  --sidebar-w: 240px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* 全局隐藏原生滚动条，保留滚动功能（Firefox + Chromium 系） */
* { scrollbar-width: none; }
*::-webkit-scrollbar { width: 0; height: 0; display: none; }

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', 'PingFang SC', sans-serif;
  color: var(--ink);
  background: var(--bg3);
  line-height: 1.6;
  min-height: 100vh;
}

/* ============ 后台主体 ============ */
.admin-app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ============ 登录闸门 ============ */
.login-gate {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  z-index: 9999;
}
.login-gate-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 3rem 2.5rem;
  text-align: center;
  box-shadow: var(--shadow-lg);
  max-width: 400px;
  width: 90%;
}
.login-gate-icon { font-size: 3.5rem; margin-bottom: 1rem; }
.login-gate-card h1 {
  font-size: 1.5rem;
  color: var(--ink);
  margin-bottom: 0.75rem;
}
.login-gate-msg {
  color: var(--muted);
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}
.login-gate-btn { display: inline-block; text-decoration: none; }

/* ============ 顶部导航 ============ */
.admin-navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--rule);
}
.admin-nav-container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.admin-nav-brand { display: flex; align-items: center; gap: 0.5rem; }
.admin-logo-icon { font-size: 1.5rem; }
.admin-brand-text { font-size: 1.2rem; font-weight: 700; color: var(--accent); }
.admin-brand-sub { font-size: 0.8rem; color: var(--muted2); font-weight: 400; }
.admin-nav-actions { display: flex; gap: 0.75rem; align-items: center; }
.admin-info {
  font-size: 0.85rem;
  color: var(--muted);
  padding: 0.25rem 0.75rem;
  background: var(--bg4);
  border-radius: 999px;
}
.admin-nav-btn {
  padding: 0.5rem 1rem;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  font-family: inherit;
  display: inline-block;
}
.admin-nav-btn:hover { background: var(--bg4); color: var(--ink); }
.admin-nav-btn-danger:hover { background: var(--red-bg); color: var(--red); }

/* ============ 布局 ============ */
.admin-layout {
  display: flex;
  max-width: 1600px;
  margin: 0 auto;
  flex: 1 0 auto;
  width: 100%;
}

/* ============ 侧边栏 ============ */
.admin-sidebar {
  width: var(--sidebar-w);
  background: #fff;
  border-right: 1px solid var(--rule);
  padding: 1.5rem 0.75rem;
  flex-shrink: 0;
  position: sticky;
  top: 64px;
  height: calc(100vh - 64px);
  overflow-y: auto;
}
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.75rem 1rem;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  text-align: left;
  margin-bottom: 0.25rem;
}
.sidebar-item:hover { background: var(--bg4); color: var(--ink); }
.sidebar-item.active { background: var(--accent-light); color: var(--accent); }
.sidebar-icon { font-size: 1.1rem; }

/* ============ 内容区 ============ */
.admin-content {
  flex: 1;
  padding: 2rem;
  min-width: 0;
}
.admin-view { display: none; }
.admin-view.active { display: block; }

.view-header { margin-bottom: 1.5rem; }
.view-header h2 { font-size: 1.5rem; color: var(--ink); margin-bottom: 0.25rem; }
.view-desc { color: var(--muted); font-size: 0.9rem; }

/* ============ 统计卡片 ============ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
}
.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
  transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-icon {
  font-size: 1.75rem;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}
.stat-card-blue .stat-icon { background: var(--accent-light); }
.stat-card-red .stat-icon { background: var(--red-light); }
.stat-card-purple .stat-icon { background: var(--purple-light); }
.stat-card-green .stat-icon { background: var(--green-light); }
.stat-card-orange .stat-icon { background: var(--orange-light); }
.stat-card-pink .stat-icon { background: var(--purple-light); }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--ink); line-height: 1; }
.stat-label { font-size: 0.85rem; color: var(--muted); }

/* ============ 用户管理工具栏 ============ */
.users-toolbar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  align-items: center;
}
.search-box {
  flex: 1;
  position: relative;
  max-width: 400px;
}
.search-icon {
  position: absolute;
  left: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted2);
  font-size: 0.95rem;
}
.search-box input {
  width: 100%;
  padding: 0.625rem 0.875rem 0.625rem 2.5rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
.search-box input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }

/* ============ 表格 ============ */
.table-wrap {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--rule);
  overflow: hidden;
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.admin-table th {
  background: var(--bg4);
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
}
.admin-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--rule);
  color: var(--ink);
  vertical-align: middle;
}
.admin-table tbody tr:hover { background: var(--bg3); }
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table .empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--muted);
}

/* ============ 徽章 ============ */
.badge {
  display: inline-block;
  padding: 0.2rem 0.625rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 500;
  white-space: nowrap;
}
.badge-active { background: var(--green-bg); color: var(--green); }
.badge-banned { background: var(--red-bg); color: var(--red); }
.badge-admin { background: var(--accent-light); color: var(--accent); }
.badge-reviewer { background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(217, 119, 6, 0.15)); color: #d97706; }
.badge-onboarding { background: var(--purple-light); color: var(--purple); }

/* ============ 按钮 ============ */
.btn-primary, .btn-secondary, .btn-danger, .btn-success, .btn-warning {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg4); color: var(--ink); }
.btn-secondary:hover { background: var(--rule); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #047857; }
.btn-warning { background: var(--orange); color: #fff; }
.btn-warning:hover { background: #c2410c; }

.btn-sm { padding: 0.3rem 0.625rem; font-size: 0.8rem; }

.table-actions { display: flex; gap: 0.375rem; flex-wrap: wrap; }

/* ============ 分页 ============ */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.5rem;
}
.page-btn {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--rule);
  background: #fff;
  color: var(--ink);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  font-family: inherit;
  transition: all 0.2s;
}
.page-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.page-btn.current { background: var(--accent); color: #fff; border-color: var(--accent); }
.page-info { color: var(--muted); font-size: 0.85rem; margin: 0 0.5rem; }

/* ============ 抽屉 ============ */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1000;
  display: flex;
  justify-content: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.drawer-overlay.visible { opacity: 1; pointer-events: auto; }
.drawer {
  background: #fff;
  width: 640px;
  max-width: 90vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 32px rgba(0,0,0,0.1);
  transform: translateX(100%);
  transition: transform 0.3s;
}
.drawer-overlay.visible .drawer { transform: translateX(0); }
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--rule);
  flex-shrink: 0;
}
.drawer-header h3 { font-size: 1.15rem; color: var(--ink); }
.drawer-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--muted);
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}
.drawer-close:hover { background: var(--bg4); color: var(--ink); }
.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

/* ============ 抽屉内表单 ============ */
.detail-section { margin-bottom: 1.5rem; }
.detail-section-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--rule);
}
.form-row { margin-bottom: 0.875rem; }
.form-row label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
  font-weight: 500;
}
.form-row input, .form-row textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
.form-row input:focus, .form-row textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.form-row .checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.form-row input[type="checkbox"] { width: auto; }
.form-row.form-hint {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: -0.5rem;
  margin-bottom: 0.875rem;
  line-height: 1.5;
}
.detail-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 1.5rem;
  font-size: 0.88rem;
}
.detail-info-item { display: flex; flex-direction: column; gap: 0.15rem; }
.detail-info-label { color: var(--muted); font-size: 0.78rem; }
.detail-info-value { color: var(--ink); font-weight: 500; word-break: break-all; }
.detail-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

/* ============ Tab 切换 ============ */
.tab-bar {
  display: flex;
  gap: 0.25rem;
  border-bottom: 2px solid var(--rule);
  margin-bottom: 1rem;
}
.tab-item {
  padding: 0.5rem 1rem;
  background: none;
  border: none;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}
.tab-item:hover { color: var(--ink); }
.tab-item.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ============ 素材网格（管理员） ============ */
.material-grid-admin {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}
.material-card-admin {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg4);
  aspect-ratio: 1;
  cursor: pointer;
  border: 1px solid var(--rule);
}
.material-card-admin img, .material-card-admin video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.material-card-admin .material-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 50%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 0.5rem;
  opacity: 0;
  transition: opacity 0.2s;
}
.material-card-admin:hover .material-overlay { opacity: 1; }
.material-card-admin .material-name {
  color: #fff;
  font-size: 0.75rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.material-card-admin .material-delete-btn {
  position: absolute;
  top: 0.375rem;
  right: 0.375rem;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(220,38,38,0.9);
  color: #fff;
  border: none;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}
.material-card-admin:hover .material-delete-btn { opacity: 1; }
.material-card-admin .material-delete-btn:hover { background: var(--red); }
.material-card-admin .material-type-badge {
  position: absolute;
  top: 0.375rem;
  left: 0.375rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 500;
  color: #fff;
}
.material-card-admin .material-type-badge.image { background: var(--accent); }
.material-card-admin .material-type-badge.video { background: var(--purple); }

/* ============ 选题列表（管理员） ============ */
.topic-list-admin { display: flex; flex-direction: column; gap: 0.5rem; }
.topic-item-admin {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--rule);
  transition: all 0.2s;
}
.topic-item-admin:hover { background: var(--bg4); }
.topic-item-content { flex: 1; min-width: 0; }
.topic-item-title {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 0.15rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topic-item-time { font-size: 0.78rem; color: var(--muted); }
.topic-item-admin .topic-delete-btn {
  background: none;
  border: none;
  color: var(--muted2);
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  transition: all 0.2s;
  flex-shrink: 0;
}
.topic-item-admin .topic-delete-btn:hover { background: var(--red-bg); color: var(--red); }

/* ============ 弹窗 ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.visible { opacity: 1; pointer-events: auto; }
/* 确认弹窗层级高于详情弹窗，支持在详情中弹出确认（如修改素材大小） */
#confirmModal { z-index: 1200; }
.modal-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 440px;
  width: 90%;
  box-shadow: var(--shadow-lg);
}
.modal-card h3 { font-size: 1.1rem; margin-bottom: 0.5rem; color: var(--ink); }
.modal-card p { color: var(--muted); margin-bottom: 1rem; font-size: 0.92rem; white-space: pre-wrap; line-height: 1.6; }
.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1rem;
}
#confirmExtra { margin-bottom: 0.75rem; }
#confirmExtra input, #confirmExtra textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
}
#confirmExtra input:focus, #confirmExtra textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

/* ============ 详情弹窗 ============ */
.detail-modal-card { max-width: 600px; max-height: 85vh; display: flex; flex-direction: column; padding: 0; }
.detail-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--rule);
  flex-shrink: 0;
}
.detail-modal-header h3 { font-size: 1.1rem; color: var(--ink); }
.detail-modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}
.detail-preview {
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: var(--bg4);
  margin-bottom: 1rem;
  display: block;
}
.detail-info-list { display: flex; flex-direction: column; gap: 0.5rem; }
.detail-info-row {
  display: flex;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--rule);
  font-size: 0.88rem;
}
.detail-info-row:last-child { border-bottom: none; }
.detail-info-label {
  width: 80px;
  flex-shrink: 0;
  color: var(--muted);
  font-weight: 500;
}
.detail-info-value { color: var(--ink); flex: 1; word-break: break-all; }
/* 详情字段内联修改按钮（如素材大小） */
.btn-edit-inline {
  margin-left: 0.5rem;
  padding: 0.1rem 0.5rem;
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}
.btn-edit-inline:hover { background: var(--accent-light); color: var(--accent-hover); }
.detail-tags { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.detail-tag {
  padding: 0.15rem 0.5rem;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 4px;
  font-size: 0.78rem;
}
.detail-result {
  background: var(--bg3);
  border-radius: var(--radius-sm);
  padding: 1rem;
  font-size: 0.88rem;
  line-height: 1.7;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 400px;
  overflow-y: auto;
}
.detail-result h1, .detail-result h2, .detail-result h3 {
  margin: 0.75rem 0 0.4rem;
  font-size: 1rem;
}
.detail-result h1:first-child, .detail-result h2:first-child, .detail-result h3:first-child { margin-top: 0; }
.detail-result ul, .detail-result ol { padding-left: 1.5rem; margin: 0.4rem 0; }
.detail-result li { margin: 0.2rem 0; }
.detail-result p { margin: 0.4rem 0; }

/* ============ 选题对话流 ============ */
.admin-chat-mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  margin-top: 0.75rem;
}
.admin-chat-mode-badge.quick { background: var(--accent-light); color: var(--accent); }
.admin-chat-mode-badge.deep { background: var(--purple-light); color: var(--purple); }

.admin-chat-flow {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  max-height: 500px;
  overflow-y: auto;
  padding: 0.25rem 0.25rem 0.25rem 0;
}
.admin-chat-empty {
  text-align: center;
  color: var(--muted2);
  font-size: 0.85rem;
  padding: 1.5rem 0;
}

.admin-msg-row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
}
.admin-msg-row.user { flex-direction: row-reverse; }
.admin-msg-role {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--bg4);
  color: var(--muted);
}
.admin-msg-row.user .admin-msg-role { background: var(--accent); color: #fff; }
.admin-msg-row.assistant .admin-msg-role { background: var(--purple); color: #fff; }

.admin-msg-bubble {
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  line-height: 1.65;
  word-break: break-word;
  max-width: 80%;
}
.admin-msg-bubble.user {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.admin-msg-bubble.assistant {
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-bottom-left-radius: 4px;
}
.admin-msg-bubble .admin-msg-text { white-space: normal; }
.admin-msg-bubble .admin-msg-text:last-child { margin-bottom: 0; }
.admin-msg-refs {
  font-size: 0.74rem;
  opacity: 0.85;
  margin-top: 0.35rem;
}

/* markdown 元素 */
.admin-msg-bubble.assistant h1,
.admin-msg-bubble.assistant h2,
.admin-msg-bubble.assistant h3 {
  margin: 0.6rem 0 0.35rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
}
.admin-msg-bubble.assistant h1:first-child,
.admin-msg-bubble.assistant h2:first-child,
.admin-msg-bubble.assistant h3:first-child { margin-top: 0; }
.admin-msg-bubble.assistant ul,
.admin-msg-bubble.assistant ol { padding-left: 1.3rem; margin: 0.35rem 0; }
.admin-msg-bubble.assistant li { margin: 0.15rem 0; }
.admin-msg-bubble.assistant p { margin: 0.35rem 0; }
.admin-msg-bubble.assistant code {
  background: var(--bg3);
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  font-size: 0.82em;
  border: 1px solid var(--rule);
}
.admin-msg-bubble.assistant .admin-md-pre {
  background: var(--bg3);
  padding: 0.6rem;
  border-radius: 6px;
  overflow-x: auto;
  margin: 0.4rem 0;
  border: 1px solid var(--rule);
}
.admin-msg-bubble.assistant .admin-md-pre code {
  background: transparent;
  border: none;
  padding: 0;
}
.admin-msg-bubble.assistant strong { font-weight: 700; color: var(--ink); }
.admin-msg-bubble.assistant em { font-style: italic; }
.admin-msg-bubble.user code,
.admin-msg-bubble.user pre { background: rgba(255,255,255,0.2); }

/* 思考过程折叠块 */
.admin-thinking {
  background: var(--purple-light);
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  overflow: hidden;
}
.admin-thinking-header {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
  padding: 0.45rem 0.7rem;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--purple);
  font-family: inherit;
}
.admin-thinking-header:hover { background: rgba(124,58,237,0.08); }
.admin-thinking-icon { font-size: 0.85rem; }
.admin-thinking-arrow {
  margin-left: auto;
  transition: transform 0.25s ease;
  font-size: 1rem;
  font-weight: 700;
}
.admin-thinking.expanded .admin-thinking-arrow { transform: rotate(90deg); }
.admin-thinking-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  padding: 0 0.7rem;
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--purple);
  opacity: 0.9;
}
.admin-thinking.expanded .admin-thinking-content {
  max-height: 600px;
  padding: 0 0.7rem 0.5rem;
}

/* 匹配素材网格 */
.admin-msg-materials {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 0.4rem;
  margin-top: 0.5rem;
}
.admin-msg-material-item {
  background: var(--bg3);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--rule);
  cursor: default;
}
.admin-mat-thumb {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
  background: var(--bg4);
}
.admin-mat-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}
.admin-mat-name {
  padding: 0.2rem 0.35rem;
  font-size: 0.7rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.admin-mat-more {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--muted2);
  padding: 0.5rem;
}

/* ============ Toast ============ */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--ink);
  color: #fff;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  z-index: 2000;
  opacity: 0;
  transition: all 0.3s;
  pointer-events: none;
  box-shadow: var(--shadow-lg);
}
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }

/* ============ 页脚 ============ */
.site-footer {
  background: var(--bg);
  border-top: 1px solid var(--rule);
  padding: 1.25rem 1.5rem;
  flex-shrink: 0;
}
.footer-inner {
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: var(--muted);
}
.footer-copyright { font-weight: 500; color: var(--ink); }
.footer-beian {
  color: var(--muted);
  text-decoration: none;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  border: 1px solid transparent;
}
.footer-beian:hover {
  color: var(--accent);
  background: var(--accent-light);
  border-color: var(--accent-light);
}

/* ============ 系统诊断 ============ */
.diag-actions {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.diag-btn {
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.2s;
}
.diag-btn:hover { opacity: 0.9; }
.diag-results { display: flex; flex-direction: column; gap: 0.75rem; }
.diag-block {
  background: var(--bg3);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  border-left: 4px solid var(--rule);
}
.diag-block.ok { border-left-color: var(--green); }
.diag-block.warn { border-left-color: var(--orange); }
.diag-block.err { border-left-color: var(--red); }
.diag-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.diag-block-title { font-weight: 600; font-size: 0.95rem; }
.diag-status-pill {
  font-size: 0.75rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-weight: 600;
}
.diag-status-pill.ok { background: var(--green-light); color: var(--green); }
.diag-status-pill.warn { background: var(--orange-light); color: var(--orange); }
.diag-status-pill.err { background: var(--red-light); color: var(--red); }
.diag-meta {
  font-size: 0.78rem;
  color: var(--muted2);
  font-family: 'Consolas', 'Monaco', monospace;
  margin-bottom: 0.4rem;
}
.diag-body {
  font-size: 0.8rem;
  font-family: 'Consolas', 'Monaco', monospace;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 240px;
  overflow: auto;
  color: var(--ink);
}

/* ============ 用户记忆库管理 ============ */
.memory-admin-toolbar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
  align-items: center;
  flex-wrap: wrap;
}
.memory-admin-filter {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.memory-admin-chip {
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--rule);
  background: var(--bg);
  color: var(--muted);
  border-radius: 999px;
  font-size: 0.78rem;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.18s;
}
.memory-admin-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.memory-admin-chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.memory-admin-search {
  position: relative;
  flex: 1;
  min-width: 180px;
  max-width: 320px;
}
.memory-admin-search .search-icon {
  position: absolute;
  left: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.5;
  font-size: 0.85rem;
}
.memory-admin-search input {
  width: 100%;
  padding: 0.4rem 0.7rem 0.4rem 1.85rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-family: inherit;
  background: var(--bg);
  transition: all 0.2s;
}
.memory-admin-search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.memory-admin-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.75rem;
}
.memory-admin-card {
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0.7rem 0.85rem;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.memory-admin-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.memory-admin-card.pinned {
  border-color: var(--orange);
  background: linear-gradient(135deg, var(--bg) 0%, var(--orange-bg) 100%);
}
.memory-admin-card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.72rem;
}
.memory-admin-type-badge {
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.7rem;
}
.memory-admin-type-badge.script { background: var(--accent-light); color: var(--accent); }
.memory-admin-type-badge.music { background: var(--green-light); color: var(--green); }
.memory-admin-type-badge.inspiration { background: var(--purple-light); color: var(--purple); }
.memory-admin-card-time {
  color: var(--muted2);
  font-size: 0.7rem;
  margin-left: auto;
}
.memory-admin-pin {
  font-size: 0.85rem;
}
.memory-admin-card-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}

/* ============ 文件管理 ============ */
.files-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.files-filter {
  display: flex;
  gap: 0.375rem;
  flex-wrap: wrap;
}
.files-filter-chip {
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--rule);
  background: var(--bg);
  color: var(--muted);
  border-radius: 999px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}
.files-filter-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--bg3);
}
.files-filter-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}
.files-stats {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.875rem;
}
.files-stat-item {
  display: inline-flex;
  align-items: center;
  padding: 0.3rem 0.7rem;
  background: var(--bg3);
  border: 1px solid var(--rule);
  border-radius: 6px;
  font-size: 0.76rem;
  color: var(--muted);
  font-weight: 500;
}
.files-table th,
.files-table td {
  vertical-align: middle;
}
.files-table td:nth-child(1) { min-width: 220px; }
.files-table td:nth-child(5) { min-width: 130px; }
.files-table td:nth-child(7) { width: 130px; }

.file-type-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 6px;
  margin-right: 0.5rem;
  font-size: 0.95rem;
  vertical-align: middle;
  background: var(--bg3);
}
.file-type-icon.ft-image { background: var(--accent-light); }
.file-type-icon.ft-video { background: var(--purple-light); }
.file-type-icon.ft-audio { background: var(--green-light); }
.file-type-icon.ft-other { background: var(--bg4); }

.file-name-text {
  vertical-align: middle;
  font-size: 0.82rem;
  color: var(--ink);
  max-width: 260px;
  display: inline-block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-type-badge {
  display: inline-block;
  padding: 0.18rem 0.55rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
}
.file-type-badge.ft-image { background: var(--accent-light); color: var(--accent); }
.file-type-badge.ft-video { background: var(--purple-light); color: var(--purple); }
.file-type-badge.ft-audio { background: var(--green-light); color: var(--green); }
.file-type-badge.ft-other { background: var(--bg4); color: var(--muted); }

.file-owner-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
}
.file-owner-phone {
  font-size: 0.72rem;
  color: var(--muted2);
  line-height: 1.3;
}
.file-owner-unknown {
  color: var(--muted2);
  font-size: 0.8rem;
  font-style: italic;
}

.file-source-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}
.file-source-badge.material { background: var(--accent-light); color: var(--accent); }
.file-source-badge.memory { background: var(--purple-light); color: var(--purple); }
.file-source-badge.orphan {
  background: var(--orange-light);
  color: var(--orange);
  cursor: help;
}

.file-audio-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 1.5rem;
  background: var(--bg3);
  border-radius: var(--radius-sm);
}
.file-audio-icon {
  font-size: 2.5rem;
}
.file-audio-preview audio {
  width: 100%;
  max-width: 420px;
}

.file-preview-unsupported {
  padding: 2rem;
  text-align: center;
  color: var(--muted2);
  background: var(--bg3);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}
.memory-admin-card-content {
  font-size: 0.76rem;
  color: var(--muted);
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  white-space: pre-wrap;
  word-break: break-word;
}
.memory-admin-card-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.25rem;
}

/* ============ 响应式 ============ */
@media (max-width: 768px) {
  .admin-layout { flex-direction: column; }
  .admin-sidebar {
    width: 100%;
    height: auto;
    position: relative;
    top: 0;
    display: flex;
    overflow-x: auto;
    padding: 0.75rem;
    border-right: none;
    border-bottom: 1px solid var(--rule);
  }
  .sidebar-item { width: auto; white-space: nowrap; margin-bottom: 0; margin-right: 0.25rem; }
  .admin-content { padding: 1rem; }
  .detail-info-grid { grid-template-columns: 1fr; }
  .admin-table { font-size: 0.82rem; }
  .admin-table th, .admin-table td { padding: 0.5rem 0.625rem; }
}

/* ============ 参赛demo配置 ============ */
.demo-config-content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  max-width: 800px;
}
.demo-config-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--rule);
}
.demo-config-card-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 1rem;
}
.demo-config-desc {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.7;
  margin-bottom: 1rem;
}
.demo-config-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  background: var(--bg3);
  border-radius: var(--radius-sm);
}
.demo-config-toggle-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.demo-config-toggle-label {
  font-weight: 500;
  font-size: 0.95rem;
}
.demo-config-toggle-status {
  font-size: 0.8rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  display: inline-block;
  width: fit-content;
}
.demo-config-toggle-status.on {
  background: var(--green-light);
  color: var(--green);
}
.demo-config-toggle-status.off {
  background: var(--bg4);
  color: var(--muted);
}
.demo-config-meta {
  margin-top: 0.75rem;
  font-size: 0.78rem;
  color: var(--muted2);
}
.demo-config-url-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.demo-config-url {
  flex: 1;
  min-width: 200px;
  padding: 0.5rem 0.75rem;
  background: var(--bg4);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--ink);
  word-break: break-all;
}

/* 自定义开关组件 */
.demo-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}
.demo-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.demo-switch-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--muted2);
  border-radius: 26px;
  transition: 0.3s;
}
.demo-switch-slider::before {
  content: '';
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.3s;
}
.demo-switch input:checked + .demo-switch-slider {
  background: var(--green);
}
.demo-switch input:checked + .demo-switch-slider::before {
  transform: translateX(22px);
}

/* ============ 队列监控视图 ============ */

/* Worker 状态卡片 */
.queue-worker-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.queue-worker-info {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1;
  min-width: 240px;
}
.queue-worker-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.queue-worker-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted2);
  flex-shrink: 0;
}
.queue-worker-dot.alive {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(5, 150, 105, 0.18);
  animation: queue-pulse 1.6s ease-in-out infinite;
}
.queue-worker-dot.dead {
  background: var(--red);
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.15);
}
@keyframes queue-pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(5, 150, 105, 0.18); }
  50% { box-shadow: 0 0 0 7px rgba(5, 150, 105, 0.08); }
}
.queue-worker-status-text {
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
}
.queue-worker-status-text.alive { color: var(--green); }
.queue-worker-status-text.dead { color: var(--red); }
.queue-worker-meta {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.5;
}
.queue-worker-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.queue-auto-refresh {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.queue-auto-refresh input {
  margin: 0;
  cursor: pointer;
  accent-color: var(--accent);
}

/* 队列统计卡片网格（复用 stat-card，缩小最小宽度） */
.queue-stats-grid {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 0.875rem;
}
.queue-stats-grid .stat-card { padding: 1.1rem; }
.queue-stats-grid .stat-value { font-size: 1.6rem; }
.queue-stats-grid .stat-icon {
  font-size: 1.4rem;
  width: 40px;
  height: 40px;
}

/* 平均处理时长提示条 */
.queue-avg-info {
  background: var(--bg3);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.9rem;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 1.25rem;
}

/* 任务列表工具栏 */
.queue-tasks-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.875rem;
  flex-wrap: wrap;
}
.queue-filter {
  display: flex;
  gap: 0.375rem;
  flex-wrap: wrap;
}
.queue-filter-chip {
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--rule);
  background: var(--bg);
  color: var(--muted);
  border-radius: 999px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
  font-family: inherit;
}
.queue-filter-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--bg3);
}
.queue-filter-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}
.queue-tasks-meta {
  font-size: 0.8rem;
  color: var(--muted);
}

/* 任务表格：行状态色 */
.queue-table tbody tr.qrow-processing {
  background: rgba(217, 119, 6, 0.04);
}
.queue-table tbody tr.qrow-processing:hover {
  background: rgba(217, 119, 6, 0.08) !important;
}
.queue-table tbody tr.qrow-failed {
  background: rgba(220, 38, 38, 0.04);
}
.queue-table tbody tr.qrow-failed:hover {
  background: rgba(220, 38, 38, 0.08) !important;
}
.queue-table tbody tr.qrow-pending {
  background: rgba(37, 99, 235, 0.03);
}
.queue-table tbody tr.qrow-pending:hover {
  background: rgba(37, 99, 235, 0.07) !important;
}

/* 素材名单元格 */
.qmat-cell {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 180px;
}
.qmat-type-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  font-size: 0.85rem;
  background: var(--bg4);
  flex-shrink: 0;
}
.qmat-type-badge.video { background: var(--purple-light); }
.qmat-type-badge.image { background: var(--accent-light); }
.qmat-name {
  font-size: 0.82rem;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 用户单元格 */
.quser-cell {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

/* 压缩方式单元格 */
.qcompress-cell {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  cursor: help;
}
.quser-name {
  font-size: 0.82rem;
  color: var(--ink);
  font-weight: 500;
}
.quser-phone {
  font-size: 0.74rem;
  color: var(--muted2);
}

/* 状态徽章 */
.badge.qbadge-pending { background: var(--accent-light); color: var(--accent); }
.badge.qbadge-processing { background: var(--orange-bg); color: var(--orange); }
.badge.qbadge-done { background: var(--green-bg); color: var(--green); }
.badge.qbadge-failed { background: var(--red-bg); color: var(--red); }

/* 进度单元格 */
.qprog-cell {
  min-width: 140px;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.qprog-bar {
  width: 100%;
  height: 6px;
  background: var(--bg4);
  border-radius: 999px;
  overflow: hidden;
}
.qprog-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--purple));
  border-radius: 999px;
  transition: width 0.4s ease;
}
.qprog-text {
  font-size: 0.74rem;
  color: var(--muted);
}
.qprog-text.qprog-done { color: var(--green); font-weight: 500; }
.qprog-error {
  font-size: 0.74rem;
  color: var(--red);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: 220px;
}

/* 任务详情弹窗内的错误展示 */
.qdetail-section {
  margin-top: 1.25rem;
}
.qdetail-section-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.6rem;
}
.qdetail-error-pre {
  background: var(--red-bg);
  border: 1px solid var(--red-light);
  border-radius: var(--radius-sm);
  padding: 0.875rem 1rem;
  font-size: 0.8rem;
  font-family: 'Consolas', 'Monaco', monospace;
  color: var(--red);
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.6;
  max-height: 320px;
  overflow-y: auto;
}
.qdetail-actions {
  margin-top: 1.25rem;
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* 响应式：窄屏堆叠 */
@media (max-width: 720px) {
  .queue-worker-card {
    flex-direction: column;
    align-items: stretch;
  }
  .queue-worker-actions {
    justify-content: space-between;
  }
  .queue-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .queue-tasks-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
}
