/* ============================================================
   云上 AI · 浅色控制台主题（白 + 浅蓝）
   多页面共享样式
   ============================================================ */

:root {
  --bg: #f3f7fc;
  --surface: #ffffff;
  --surface-2: #f8fbff;
  --border: #e4ecf5;
  --border-strong: #cfdff0;

  --text: #1b2a41;
  --text-2: #55688a;
  --text-3: #93a3bd;

  --primary: #3d8bfd;
  --primary-deep: #2f6fe0;
  --primary-soft: #eaf3ff;
  --primary-line: #b9d6ff;
  --grad: linear-gradient(135deg, #61a5ff 0%, #3d8bfd 100%);

  --success: #1fa97c;
  --success-soft: #e5f6ef;
  --danger: #e5484d;
  --danger-soft: #fdecec;
  --warn: #d97706;
  --warn-soft: #fdf3e3;
  --running: #3d8bfd;
  --running-soft: #eaf3ff;

  --sidebar-w: 236px;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 8px 28px rgba(43, 88, 153, 0.08);
  --shadow-soft: 0 3px 12px rgba(43, 88, 153, 0.07);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 600; }
p { margin: 0; }
button { font-family: inherit; }
a { text-decoration: none; color: inherit; }

/* ============ 侧边栏 ============ */

.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  z-index: 30;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 18px;
}
.side-logo {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--grad);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(61, 139, 253, 0.35);
  flex: none;
}
.side-name {
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.side-section {
  font-size: 11px;
  color: var(--text-3);
  padding: 14px 10px 6px;
  letter-spacing: 0.5px;
}
.side-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: background 0.14s, color 0.14s;
}
.side-item svg { flex: none; opacity: 0.85; }
.side-item:hover { background: var(--surface-2); color: var(--text); }
.side-item.active {
  background: var(--primary-soft);
  color: var(--primary-deep);
  font-weight: 600;
}
.side-item.active svg { opacity: 1; }

.side-bottom { border-top: 1px solid var(--border); padding-top: 10px; }

/* ============ 主区域 ============ */

.main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.tb-title h1 { font-size: 17px; }
.tb-title p { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.tb-right { display: flex; align-items: center; gap: 12px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-2);
  padding: 6px 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  white-space: nowrap;
}
.chip b { font-weight: 700; }
.chip-balance { background: var(--primary-soft); border-color: var(--primary-line); color: var(--primary-deep); }
.chip-balance b { color: var(--primary-deep); }

.pill-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--success);
}
.pill-dot.busy { background: var(--running); animation: pulse 1.6s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(61, 139, 253, 0.45); }
  70% { box-shadow: 0 0 0 7px rgba(61, 139, 253, 0); }
  100% { box-shadow: 0 0 0 0 rgba(61, 139, 253, 0); }
}

.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--grad);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  flex: none;
}
.tb-user { font-size: 13px; color: var(--text-2); font-weight: 500; }

/* ============ 公告：顶栏铃铛 + 弹框列表 ============ */

.ann-bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex: none;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.ann-bell:hover {
  color: var(--primary-deep);
  border-color: var(--primary-line);
  background: var(--primary-soft);
}
.ann-dot {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--danger);
  border: 1.5px solid var(--surface);
}
.ann-dot[hidden] { display: none; }

.ann-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 60vh;
  overflow-y: auto;
}
.ann-empty {
  font-size: 13px;
  color: var(--text-3);
  text-align: center;
  padding: 26px 0;
}
.ann-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 12px 14px;
}
.ann-item-head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ann-item-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  flex: 1;
  min-width: 0;
  word-break: break-all;
}
.ann-item-time {
  font-size: 12px;
  color: var(--text-3);
  flex: none;
}
.ann-item-close {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-3);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.ann-item-close:hover { background: var(--border); color: var(--text); }
.ann-item-close:disabled { opacity: 0.5; cursor: not-allowed; }
.ann-item-body {
  margin: 8px 0 0;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--text-2);
  white-space: pre-wrap;
  word-break: break-word;
}

.content {
  padding: 26px 28px 48px;
  width: 100%;
  max-width: 1160px;
  margin: 0 auto;
}

/* ============ 按钮 ============ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.12s, opacity 0.12s, background 0.15s, border-color 0.15s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-lg { padding: 12px 30px; font-size: 14px; font-weight: 600; border-radius: 999px; }
.btn-sm { padding: 6px 13px; font-size: 12.5px; }

.btn-primary {
  background: var(--grad);
  color: #fff;
  box-shadow: 0 6px 16px rgba(61, 139, 253, 0.32);
}
.btn-primary:hover:not(:disabled) { opacity: 0.93; box-shadow: 0 8px 20px rgba(61, 139, 253, 0.4); }

.btn-ghost {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-2);
}
.btn-ghost:hover:not(:disabled) { border-color: var(--primary-line); color: var(--primary-deep); background: var(--primary-soft); }

.btn-danger {
  background: var(--danger, #e5484d);
  border-color: transparent;
  color: #fff;
}
.btn-danger:hover:not(:disabled) { opacity: 0.92; }

.btn-soft {
  background: var(--primary-soft);
  color: var(--primary-deep);
  border-color: var(--primary-line);
}
.btn-soft:hover:not(:disabled) { background: #dcebff; }

/* ============ 表单 ============ */

.field { display: flex; flex-direction: column; gap: 7px; position: relative; }
.field-label { font-size: 13px; color: var(--text-2); font-weight: 500; }
.hint { color: var(--text-3); font-size: 12px; font-weight: 400; }

input, textarea, select {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--surface-2);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary-line);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(61, 139, 253, 0.13);
}
textarea { resize: vertical; line-height: 1.65; }

.form-error {
  margin: 14px 0 0;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
  border: 1px solid rgba(229, 72, 77, 0.22);
}
.queue-note {
  margin: 14px 0 0;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 13px;
  border: 1px solid rgba(217, 119, 6, 0.2);
}

/* ============ 卡片 ============ */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-soft);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.panel-title { font-size: 16px; font-weight: 700; }
.panel-sub { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }

/* ============ 生成页 · 大卡片 ============ */

.hero-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 26px 28px;
  box-shadow: var(--shadow);
}

.hero-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; }
.hero-kicker {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--primary);
  text-transform: uppercase;
}
.hero-title { font-size: 21px; margin-top: 3px; }
.hero-sub { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.hero-mark {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: var(--grad);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(61, 139, 253, 0.35);
}

.prompt-box { position: relative; }
/* 底栏（添加参考图/字数）钉在 textarea 上，而不是整个盒子——
   否则缩略图把盒子撑高后，绝对定位的底栏会沉底压在缩略图上 */
.prompt-area { position: relative; }
.prompt-box .prompt-editor { min-height: 425px; font-size: 14.5px; padding-bottom: 40px; }
/* 图片生成页用 textarea（不是 contenteditable），同样要给高度并留出底栏空间，
   否则框只有两行高、且“添加参考图/字数”底栏会压住最后一行文字 */
.prompt-box textarea {
  min-height: 220px;
  padding-bottom: 40px;
  line-height: 1.65;
}
.prompt-foot {
  position: absolute;
  left: 13px; right: 13px; bottom: 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}
.prompt-foot .btn,
.prompt-foot .up-inline { pointer-events: auto; }
.char-count { font-size: 11.5px; color: var(--text-3); background: var(--surface-2); padding: 2px 8px; border-radius: 999px; }

.up-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px dashed var(--border-strong);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12.5px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.up-inline:hover { border-color: var(--primary-line); color: var(--primary-deep); background: var(--primary-soft); }

.thumbs {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0 0;
  padding: 0;
}
.thumbs:empty { margin: 0; }
.thumb {
  position: relative;
  width: 62px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.thumb-media {
  position: relative;
  width: 62px; height: 62px;
  border-radius: 9px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb button {
  position: absolute;
  top: 3px; right: 3px;
  width: 18px; height: 18px;
  border: none; border-radius: 50%;
  background: rgba(27, 42, 65, 0.62);
  color: #fff; font-size: 12px; line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  z-index: 2;
}
/* 缩略图下方的编号标签：图1 / 音频1 */
.thumb-label {
  display: inline-block;
  max-width: 62px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 11px;
  line-height: 16px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.thumb-label:hover { color: var(--primary-deep); background: var(--primary-soft); }
/* 音频缩略图 */
.thumb-audio .thumb-media {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #eaf1fb, #dce8f8);
  color: var(--primary-deep);
}
.thumb-audio-icon { display: flex; align-items: center; justify-content: center; }
.thumb-audio-dur {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 1px 0;
  background: rgba(27, 42, 65, 0.55);
  color: #fff;
  font-size: 10px;
  text-align: center;
}

/* ---------------- 提示词编辑器（contenteditable） ---------------- */
.prompt-editor {
  width: 100%;
  min-height: 425px;
  max-height: 800px;
  overflow-y: auto;
  padding: 10px 13px 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  line-height: 1.65;
  font-family: inherit;
  background: var(--surface-2);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  white-space: pre-wrap;
  word-break: break-word;
}
.prompt-editor:focus {
  outline: none;
  border-color: var(--primary-line);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(61, 139, 253, 0.13);
}
.prompt-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--text-3);
  pointer-events: none;
}

/* 提示词里的 @素材 chip：蓝色文字 + 右侧小缩略图 */
.mention-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0 1px;
  padding: 1px 5px 1px 7px;
  border-radius: 6px;
  background: var(--primary-soft);
  vertical-align: -2px;
  line-height: 1.5;
  white-space: nowrap;
  user-select: none;
}
.mention-chip-label {
  color: var(--primary-deep);
  font-weight: 600;
  font-size: 14px;
}
.mention-chip-thumb {
  width: 16px; height: 16px;
  border-radius: 4px;
  object-fit: cover;
  flex: none;
  background: var(--surface);
}
.mention-chip-thumb.is-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-deep);
}

/* ---------------- @ 引用选择浮层 ---------------- */
/* 紧凑浮层：贴着光标出现，不再横跨整个输入框 */
.mention-menu {
  position: absolute;
  left: 13px; top: 9px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 268px;
  max-width: calc(100% - 26px);
  max-height: 300px;
  overflow-y: auto;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
  box-shadow: 0 14px 36px rgba(16, 32, 58, 0.16);
}
.mention-menu[hidden] { display: none; }
/* 顶部提示行：插入参考素材 */
.mention-head {
  padding: 5px 9px 7px;
  font-size: 12.5px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mention-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-width: 0;
  padding: 7px 9px;
  border: none;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font: inherit;
}
.mention-item:hover,
.mention-item.is-active { background: var(--primary-soft); }
.mention-icon {
  width: 30px; height: 30px;
  flex: none;
  border-radius: 7px;
  overflow: hidden;
  background: var(--surface-2);
  color: var(--primary-deep);
  display: flex; align-items: center; justify-content: center;
}
.mention-icon img { width: 100%; height: 100%; object-fit: cover; }
.mention-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mention-empty {
  padding: 10px 12px;
  font-size: 12.5px;
  color: var(--text-3);
}

/* ============ 图片生成结果（横向卡片列表） ============ */
.img-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.img-row {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--card, #fff);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: 0 1px 3px rgba(20, 20, 40, .05);
}
.img-row-thumb {
  flex: 0 0 96px;
  width: 96px;
  height: 96px;
  border-radius: 10px;
  overflow: hidden;
  display: block;
  background: #f1f1f6;
}
.img-row-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.img-row-info {
  flex: 1 1 auto;
  min-width: 0;
}
.img-row-prompt {
  margin: 0 0 6px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-1, #1c1c28);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.img-row-meta {
  margin: 0;
  font-size: 12px;
  color: var(--text-3, #8a8a99);
}
.img-row-meta .cost {
  color: var(--primary-deep, #2f6bff);
}
.img-row-actions {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
.status-tag {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.status-tag.done { color: #1aa15a; background: rgba(26, 161, 90, .12); }
.status-tag.fail { color: #e0483b; background: rgba(224, 72, 59, .12); }
.status-tag.pending { color: #b06a00; background: rgba(176, 106, 0, .12); }

.opt-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 18px;
}

.submit-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 22px;
}
.price-note { font-size: 13px; color: var(--text-3); }
.price-note b { color: var(--primary-deep); font-weight: 700; }

/* 提交状态行（图片生成页用）：进行中 / 成功 / 失败 */
.submit-status {
  margin: 14px 0 0;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: var(--primary-deep);
  font-size: 13px;
  border: 1px solid var(--primary-line);
}
.submit-status.is-ok {
  background: var(--success-soft);
  color: var(--success);
  border-color: rgba(31, 169, 124, 0.22);
}
.submit-status.is-err {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: rgba(229, 72, 77, 0.22);
}

/* ============ 筛选 chips ============ */

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-filter {
  padding: 6px 15px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 12.5px;
  cursor: pointer;
  transition: all 0.14s;
}
.chip-filter:hover { border-color: var(--primary-line); color: var(--primary-deep); }
.chip-filter.active {
  background: var(--primary-soft);
  border-color: var(--primary-line);
  color: var(--primary-deep);
  font-weight: 600;
}

/* ============ 任务列表 ============ */

.task-list {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 4px 18px;
}
.task-list:empty { display: none; }

.task-row {
  display: flex;
  gap: 16px;
  padding: 15px 2px;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}
.task-row:last-child { border-bottom: none; }

.row-media {
  position: relative;
  width: 158px;
  aspect-ratio: 16 / 9;
  flex: none;
  border-radius: 10px;
  overflow: hidden;
  background: linear-gradient(135deg, #eaf2fc 0%, #dceafc 100%);
}
.row-media video { width: 100%; height: 100%; object-fit: cover; display: block; background: #0b1220; }
.row-media .row-img { width: 100%; height: 100%; object-fit: cover; display: block; background: #0b1220; cursor: pointer; }
.row-media .row-thumb { width: 100%; height: 100%; object-fit: cover; display: block; background: #0b1220; cursor: pointer; }

.row-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-3);
  font-size: 12px;
}
.row-placeholder .ph-spinner {
  width: 20px; height: 20px;
  border: 2.5px solid rgba(61, 139, 253, 0.18);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
.row-placeholder .ph-icon { font-size: 18px; opacity: 0.65; }
.row-placeholder.is-failed { color: var(--danger); }
@keyframes spin { to { transform: rotate(360deg); } }

.row-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
/* 行右侧操作列：状态徽标 + 操作按钮（下载 / 重试 / 取消）自上而下一列，
   整体贴右缘、顶端对齐，与首行提示词齐平，避免按钮悬在卡片中部与徽标脱节 */
.row-side {
  flex: none;
  margin-left: auto;
  align-self: flex-start;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 18px;
  padding-left: 8px;
}
.row-side .btn { white-space: nowrap; }
.row-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.row-top .task-prompt { flex: 1; min-width: 0; }
.task-prompt {
  font-size: 13.5px;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-all;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid transparent;
  background: var(--surface-2);
  white-space: nowrap;
  flex: none;
}
.badge::before {
  content: "";
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
}
.badge-pending   { color: #7a8aa5; border-color: var(--border); }
.badge-running   { color: var(--running); border-color: var(--primary-line); background: var(--running-soft); }
.badge-succeeded { color: var(--success); border-color: rgba(31, 169, 124, 0.28); background: var(--success-soft); }
.badge-failed    { color: var(--danger); border-color: rgba(229, 72, 77, 0.28); background: var(--danger-soft); }

.task-meta {
  font-size: 11.5px;
  color: var(--text-3);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.task-meta .dot { opacity: 0.5; }
.task-meta .cost-tag { color: var(--accent, #2f6bff); font-weight: 600; }
/* 任务 ID 行：用户报障时凭此联系管理员定位（admin 卡片与用户卡片共用） */
.task-id-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}
.task-id {
  font-size: 11.5px;
  color: var(--text-3);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.2px;
}
.btn-xs {
  padding: 2px 8px;
  font-size: 11px;
  line-height: 1.5;
  border-radius: 7px;
}
.img-row-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text-3);
}
.task-error {
  font-size: 12px;
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: 8px;
  padding: 6px 10px;
  word-break: break-all;
  align-self: flex-start;
}
/* 「生成中」已用时长：弱化显示，不抢失败的错误条 */
.task-elapsed {
  font-size: 11.5px;
  color: var(--text-3);
  opacity: 0.85;
  align-self: flex-start;
}

/* ============ 空状态 ============ */

.empty { text-align: center; padding: 54px 20px; color: var(--text-3); }
.empty-mark {
  width: 62px; height: 62px;
  margin: 0 auto 14px;
  border-radius: 18px;
  background: var(--primary-soft);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
}
.empty-title { font-size: 15px; color: var(--text-2); font-weight: 600; margin-bottom: 4px; }
.empty-sub { font-size: 13px; }

/* ============ 登录页 ============ */

.auth-wrap {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: hidden;
  background:
    radial-gradient(900px 500px at 12% -8%, rgba(97, 165, 255, 0.16) 0%, transparent 55%),
    radial-gradient(800px 480px at 96% 108%, rgba(61, 139, 253, 0.14) 0%, transparent 55%),
    var(--bg);
}
.auth-card {
  position: relative;
  width: 100%;
  max-width: 392px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 32px 30px 28px;
  box-shadow: var(--shadow);
}
.auth-brand { display: flex; align-items: center; gap: 10px; justify-content: center; }
.auth-brand .side-logo { width: 38px; height: 38px; border-radius: 11px; }
.auth-name { font-size: 19px; font-weight: 700; }
.auth-sub { margin: 8px 0 22px; text-align: center; color: var(--text-3); font-size: 13px; }

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 11px;
  margin-bottom: 20px;
}
.tab {
  flex: 1;
  padding: 8px 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.tab.active {
  background: var(--surface);
  color: var(--primary-deep);
  font-weight: 600;
  box-shadow: var(--shadow-soft);
}
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-form[hidden] { display: none; }
.btn-block { width: 100%; }

/* 服务条款滚动框 + 勾选（注册前必须同意） */
.terms-box {
  max-height: 190px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-soft, #f6f9fc);
  padding: 12px 14px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--text-3);
  white-space: pre-wrap;
  word-break: break-word;
}
.terms-box:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.terms-box.is-expanded { max-height: 420px; }
.terms-agree {
  display: flex; align-items: center; gap: 9px;
  font-size: 12.5px; color: var(--text-2);
  cursor: pointer; user-select: none;
}
.terms-agree input {
  width: 15px; height: 15px; flex: none;
  accent-color: var(--primary);
  cursor: pointer;
}
.terms-agree a { color: var(--primary); text-decoration: none; font-weight: 600; }
.terms-agree a:hover { text-decoration: underline; }

/* ============ 响应式 ============ */

@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }
  .sidebar {
    top: auto; right: 0;
    width: 100%;
    height: 56px;
    flex-direction: row;
    align-items: center;
    padding: 0 12px;
    border-right: none;
    border-top: 1px solid var(--border);
  }
  .side-brand, .side-section, .side-bottom { display: none; }
  .side-nav { flex-direction: row; justify-content: space-around; flex: 1; }
  .side-item { flex-direction: column; gap: 3px; font-size: 11px; padding: 6px 12px; }
  .main { margin-left: 0; padding-bottom: 56px; }
  .tb-user { display: none; }
  .content { padding: 18px 14px 40px; }
  .opt-row { grid-template-columns: 1fr; }
  .topbar { padding: 12px 14px; }
}

/* ============ 后台管理 ============ */

.admin-login {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 12% -8%, rgba(97, 165, 255, 0.16) 0%, transparent 55%),
    radial-gradient(800px 480px at 96% 108%, rgba(61, 139, 253, 0.14) 0%, transparent 55%),
    var(--bg);
  z-index: 100;
}
.admin-login[hidden] { display: none; }
.admin-login .auth-card { max-width: 380px; }

.tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 20px;
  width: 100%;
}
.tab-bar .tab {
  flex: 1 1 0;
  min-width: 84px;
  padding: 9px 12px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s;
}
.tab-bar .tab:hover:not(.active) { background: var(--surface); color: var(--text); }
.tab-bar .tab.active {
  background: var(--primary-soft);
  color: var(--primary-deep);
  font-weight: 600;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-soft);
}
.stat-card .stat-label { font-size: 12.5px; color: var(--text-3); }
.stat-card .stat-value { font-size: 24px; font-weight: 700; margin-top: 6px; color: var(--text); }
.stat-card .stat-value small { font-size: 13px; color: var(--text-3); font-weight: 500; margin-left: 3px; }
.stat-card.accent .stat-value { color: var(--primary-deep); }

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}
.admin-table th, .admin-table td {
  text-align: left;
  padding: 13px 16px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.admin-table th {
  background: var(--surface-2);
  color: var(--text-2);
  font-weight: 600;
  font-size: 12px;
}
.admin-table td { color: var(--text); vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table .mono { font-variant-numeric: tabular-nums; }
.admin-table .row-actions { display: flex; gap: 8px; }
.admin-table .name-cell { font-weight: 600; }
.admin-table .op-cell { color: var(--text-3); }
/* 公告正文列：内容可能很长，允许换行并限高 */
.admin-table .ann-cell {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
  color: var(--text-2);
  max-width: 420px;
  max-height: 92px;
  overflow-y: auto;
}

.disabled-tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 600;
  color: var(--danger); background: var(--danger-soft);
  padding: 3px 11px; border-radius: 999px;
}
.enabled-tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 600;
  color: var(--success); background: var(--success-soft);
  padding: 3px 11px; border-radius: 999px;
}
.ok-tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 600;
  color: var(--success); background: var(--success-soft);
  padding: 3px 11px; border-radius: 999px;
}

.bill-row { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-start; }
.bill-table-wrap { flex: 1; min-width: 300px; }

.task-owner {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--primary-deep);
  background: var(--primary-soft);
  border: 1px solid var(--primary-line);
  padding: 2px 9px;
  border-radius: 999px;
  align-self: flex-start;
}

.more-row { display: flex; justify-content: center; margin-top: 16px; }

/* ============ 自动清理条 ============ */

.prompt-preview {
  margin: 0;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}
#tab-prompt textarea { width: 100%; }

.cleanup-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap;
  padding: 16px 18px; margin-bottom: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}
.cleanup-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cleanup-actions select { width: auto; min-width: 108px; padding: 6px 10px; }
.cleanup-actions input { width: auto; min-width: 108px; padding: 6px 10px; }

/* ============ 任务页：一键下载 / 下载目录 ============ */

.btn-dl-all {
  background: linear-gradient(135deg, #22c07d, #12946a);
  color: #fff;
  border: 1px solid rgba(10, 110, 76, 0.35);
  box-shadow: 0 6px 16px rgba(18, 148, 106, 0.28);
}
.btn-dl-all:hover:not(:disabled) { filter: brightness(1.05); box-shadow: 0 8px 20px rgba(18, 148, 106, 0.36); }
.btn-dl-all:disabled { opacity: 0.6; cursor: progress; }

.dl-dir-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 11px 14px; margin: 0 0 16px;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text-2);
}
.dl-dir-name {
  font-weight: 600; color: var(--text);
  max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dl-dir-row .hint { margin-left: auto; }

/* ============ 任务页：创建时间筛选 ============ */

.date-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 11px 14px; margin: 0 0 14px;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text-2);
}
.date-label { font-weight: 600; color: var(--text); }
.date-sep { color: var(--text-3); }
.date-row input[type="date"] { width: auto; min-width: 140px; padding: 6px 10px; cursor: pointer; }

/* 任务列表分页栏（上一页 / 跳页 / 下一页） */
.page-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 11px 14px; margin: 14px 0 0;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text-2);
}
.page-info { display: inline-flex; align-items: center; gap: 6px; }
.page-input {
  width: 56px; padding: 5px 8px; text-align: center;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font-size: 13px;
}
.page-input:focus { outline: none; border-color: var(--accent); }
.page-row .btn:disabled { opacity: 0.45; cursor: not-allowed; }
.date-row .hint { margin-left: auto; }

/* ============ 轻提示 toast ============ */

.toast-wrap {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  z-index: 9999; pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 10px;
  min-width: 220px; max-width: 86vw;
  padding: 12px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  box-shadow: 0 12px 32px rgba(23, 43, 77, 0.16);
  font-size: 13.5px; line-height: 1.5; color: var(--text);
  animation: toast-in 0.22s ease-out;
}
.toast.is-ok { border-left-color: var(--success); }
.toast.is-err { border-left-color: var(--danger); }
.toast.is-info { border-left-color: var(--primary); }
.toast.is-out { opacity: 0; transition: opacity 0.25s ease; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* ============ 模型计费配置 ============ */

.cfg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.cfg-add { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.cfg-add input { flex: 1 1 130px; min-width: 0; }
.cfg-price-input { width: 110px; padding: 6px 10px; }
@media (max-width: 900px) {
  .cfg-grid { grid-template-columns: 1fr; }
}

/* ============ 用户名下拉菜单 ============ */

.tb-user-clickable { cursor: pointer; user-select: none; }
.tb-user-clickable:hover { color: var(--primary-deep); }

.user-menu {
  position: fixed;
  z-index: 200;
  min-width: 168px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 14px 36px rgba(23, 43, 77, 0.18);
  padding: 6px;
  overflow: hidden;
}
.user-menu[hidden] { display: none; }
.user-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 13px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 13.5px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.14s, color 0.14s;
}
.user-menu-item:hover { background: var(--primary-soft); color: var(--primary-deep); }

/* ============ 兑换码弹框 ============ */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(20, 33, 56, 0.42);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.modal-overlay[hidden] { display: none; }
.modal-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px 24px 22px;
  box-shadow: 0 24px 60px rgba(23, 43, 77, 0.28);
  animation: modal-in 0.2s ease-out;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 17px; font-weight: 700; }
.modal-close {
  width: 30px; height: 30px;
  border: none; border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 20px; line-height: 1;
  cursor: pointer;
}
.modal-close:hover { background: var(--border); color: var(--text); }
.modal-sub { font-size: 12.5px; color: var(--text-3); margin: 6px 0 16px; }
.modal-msg { font-size: 14px; color: var(--text); margin: 0 0 18px; line-height: 1.6; }
.modal-btns { display: flex; gap: 10px; justify-content: flex-end; }
.modal-input { margin-bottom: 0; }
.redeem-input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--surface-2);
  color: var(--text);
  letter-spacing: 0.5px;
}
.redeem-input:focus {
  outline: none;
  border-color: var(--primary-line);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(61, 139, 253, 0.13);
}
.redeem-history { margin-top: 20px; border-top: 1px solid var(--border); padding-top: 14px; }
.redeem-history-head { font-size: 12.5px; color: var(--text-2); font-weight: 600; margin-bottom: 10px; }
.redeem-history-list { display: flex; flex-direction: column; gap: 8px; max-height: 220px; overflow-y: auto; }
.redeem-history-empty { font-size: 12.5px; color: var(--text-3); padding: 4px 0; }
.redeem-history-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 9px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.rhi-code { font-size: 13px; font-weight: 600; color: var(--text); letter-spacing: 0.4px; }
.rhi-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }
.rhi-amount { font-size: 13px; font-weight: 700; color: var(--success); }
.rhi-time { font-size: 11px; color: var(--text-3); }
