:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --border: #e3e8f0;
  --border-strong: #cfd8e6;
  --text: #1b2434;
  --muted: #6b7891;
  --faint: #94a3b8;
  --primary: #2563eb;
  --primary-weak: #eff5ff;
  --primary-dark: #1d4ed8;
  --green: #16a34a;
  --green-weak: #ecfdf3;
  --amber: #d97706;
  --amber-weak: #fff8ec;
  --red: #dc2626;
  --red-weak: #fef2f2;
  --purple: #7c3aed;
  --purple-weak: #f5f3ff;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px -12px rgba(16, 24, 40, 0.14);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }

/* ---------------- 布局 ---------------- */

.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255,255,255,.88);
  backdrop-filter: saturate(1.6) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1280px; margin: 0 auto; padding: 0 22px;
  height: 58px; display: flex; align-items: center; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; }
.brand .logo {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, #3b82f6, #7c3aed);
  display: grid; place-items: center; color: #fff; font-size: 14px; font-weight: 800;
}
.brand small { font-weight: 500; color: var(--muted); font-size: 12px; margin-left: 2px; }
.topbar nav { display: flex; gap: 4px; margin-left: 8px; }
.topbar nav a {
  padding: 6px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; font-size: 13px;
}
.topbar nav a:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.topbar nav a.on { background: var(--primary-weak); color: var(--primary-dark); font-weight: 600; }
.spacer { flex: 1; }

.page { max-width: 1280px; margin: 0 auto; padding: 22px; }
.page.narrow { max-width: 980px; }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: minmax(0,1.15fr) minmax(0,1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
@media (max-width: 980px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
}

/* ---------------- 卡片 ---------------- */

.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.card > header {
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; background: var(--panel-2);
}
.card > header h3 { font-size: 14px; }
.card > header .sub { color: var(--muted); font-size: 12px; }
.card .body { padding: 18px; }
.card .body.tight { padding: 12px; }

/* ---------------- 统计块 ---------------- */

.stat { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: 12px; }
.stat .value { font-size: 22px; font-weight: 700; margin-top: 4px; letter-spacing: -0.02em; }
.stat .value small { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 3px; }

/* ---------------- 徽章 ---------------- */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  border: 1px solid transparent; white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.gray { background: #f1f5f9; color: #64748b; border-color: #e2e8f0; }
.badge.blue { background: var(--primary-weak); color: var(--primary-dark); border-color: #dbeafe; }
.badge.green { background: var(--green-weak); color: var(--green); border-color: #d1fae5; }
.badge.amber { background: var(--amber-weak); color: var(--amber); border-color: #fde68a; }
.badge.red { background: var(--red-weak); color: var(--red); border-color: #fecaca; }
.badge.purple { background: var(--purple-weak); color: var(--purple); border-color: #ddd6fe; }

.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .45 } }

/* ---------------- 按钮 ---------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 15px; border-radius: 9px; border: 1px solid var(--border-strong);
  background: #fff; color: var(--text); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all .14s ease; font-family: inherit; white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--panel-2); border-color: #b9c4d6; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger:hover:not(:disabled) { background: #b91c1c; border-color: #b91c1c; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover:not(:disabled) { background: var(--panel-2); color: var(--text); }
.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn.lg { padding: 11px 20px; font-size: 14px; border-radius: 10px; }
.btn.block { width: 100%; }

/* ---------------- 表单 ---------------- */

label.field { display: block; margin-bottom: 13px; }
label.field > span { display: block; font-size: 12.5px; font-weight: 600; color: #46536b; margin-bottom: 5px; }
label.field > span .req { color: var(--red); margin-left: 3px; }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 8px 11px; border: 1px solid var(--border-strong); border-radius: 9px;
  background: #fff; color: var(--text); font-size: 13.5px; font-family: inherit; transition: border .14s, box-shadow .14s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
textarea { min-height: 82px; resize: vertical; line-height: 1.55; }
input::placeholder, textarea::placeholder { color: var(--faint); }
.hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 0; }
.row > .fixed { flex: 0 0 auto; }
.switch { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: #46536b; }
.switch input { width: auto; }

/* ---------------- 表格 ---------------- */

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; font-size: 11.5px; font-weight: 650; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em; padding: 9px 12px;
  border-bottom: 1px solid var(--border); background: var(--panel-2); white-space: nowrap;
}
td { padding: 10px 12px; border-bottom: 1px solid #eef2f7; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafcff; }
.table-wrap { overflow-x: auto; }
.mono { font-family: var(--mono); font-size: 12px; }
.nowrap { white-space: nowrap; }

/* ---------------- 会话面板 ---------------- */

.hero {
  border-radius: var(--radius); border: 1px solid var(--border); background: var(--panel);
  box-shadow: var(--shadow); padding: 20px;
}
.hero-top { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.hero-title { font-size: 17px; font-weight: 700; }
.hero-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

.meter { display: flex; gap: 26px; flex-wrap: wrap; margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--border); }
.meter .m .k { color: var(--muted); font-size: 11.5px; }
.meter .m .v { font-size: 19px; font-weight: 700; font-family: var(--mono); letter-spacing: -0.02em; }
.meter .m .v.money { color: var(--primary-dark); }

.steps { display: flex; gap: 0; margin: 16px 0 4px; }
.step { flex: 1; display: flex; flex-direction: column; gap: 6px; position: relative; }
.step .bar { height: 4px; border-radius: 4px; background: #e8edf5; overflow: hidden; }
.step .bar i { display: block; height: 100%; width: 0; background: var(--primary); transition: width .5s ease; }
.step.done .bar i { width: 100%; }
.step.active .bar i { width: 60%; animation: slide 1.4s ease-in-out infinite; }
@keyframes slide { 0% { width: 25% } 50% { width: 78% } 100% { width: 25% } }
.step .t { font-size: 11.5px; color: var(--muted); }
.step.done .t { color: var(--green); font-weight: 600; }
.step.active .t { color: var(--primary); font-weight: 600; }

/* ---------------- 任务列表 ---------------- */

.task { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; background: #fff; }
.task:last-child { margin-bottom: 0; }
.task-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.task-head .name { font-weight: 650; font-size: 13.5px; }
.task-head .time { color: var(--faint); font-size: 12px; margin-left: auto; }
.task .prompt { color: var(--muted); font-size: 12.5px; margin-top: 6px; word-break: break-word; }
.progress { height: 5px; background: #eef2f7; border-radius: 4px; overflow: hidden; margin-top: 9px; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, #3b82f6, #7c3aed); transition: width .4s ease; }
.preview { margin-top: 11px; display: flex; gap: 10px; flex-wrap: wrap; }
.preview figure { margin: 0; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; background: #0f172a; }
.preview img, .preview video { display: block; max-width: 300px; max-height: 190px; }
.preview figcaption { font-size: 11.5px; padding: 5px 9px; background: var(--panel-2); color: var(--muted); display: flex; gap: 8px; align-items: center; }

/* ---------------- 提示条 ---------------- */

.alert { border-radius: 10px; padding: 10px 13px; font-size: 13px; border: 1px solid; display: flex; gap: 9px; align-items: flex-start; margin-bottom: 14px; }
.alert.info { background: var(--primary-weak); border-color: #dbeafe; color: #1e40af; }
.alert.warn { background: var(--amber-weak); border-color: #fde68a; color: #92400e; }
.alert.err { background: var(--red-weak); border-color: #fecaca; color: #991b1b; }
.alert.ok { background: var(--green-weak); border-color: #d1fae5; color: #166534; }

.empty { text-align: center; color: var(--faint); padding: 34px 10px; font-size: 13px; }

/* ---------------- 登录页 ---------------- */

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background:
  radial-gradient(900px 460px at 12% -10%, #e5edff 0%, transparent 60%),
  radial-gradient(760px 420px at 100% 110%, #f0e9ff 0%, transparent 58%), var(--bg); }
.login-card { width: 100%; max-width: 396px; background: var(--panel); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 24px 60px -28px rgba(16,24,40,.3); padding: 30px; }
.login-card .logo-lg { width: 46px; height: 46px; border-radius: 13px; background: linear-gradient(135deg,#3b82f6,#7c3aed); display: grid; place-items: center; color: #fff; font-size: 21px; font-weight: 800; margin-bottom: 16px; }
.login-card h1 { font-size: 20px; margin-bottom: 5px; }
.login-card .lead { color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.quick { display: flex; gap: 8px; margin-top: 14px; }
.quick .btn { flex: 1; }

/* ---------------- 模态框 ---------------- */

.modal-mask { position: fixed; inset: 0; background: rgba(15,23,42,.42); display: grid; place-items: center; z-index: 100; padding: 20px; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 460px; box-shadow: 0 30px 70px -20px rgba(15,23,42,.5); max-height: 90vh; overflow: auto; }
.modal header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; }
.modal header h3 { font-size: 15px; }
.modal .body { padding: 20px; }
.modal footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; background: var(--panel-2); }

/* ---------------- 其他 ---------------- */

.code {
  background: #0f172a; color: #cbd5e1; border-radius: 9px; padding: 13px 15px;
  font-family: var(--mono); font-size: 12px; line-height: 1.65; overflow-x: auto; white-space: pre;
}
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 600; word-break: break-all; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 9px; }
.toast .t { background: #111c2e; color: #fff; padding: 10px 15px; border-radius: 10px; font-size: 13px; box-shadow: 0 14px 34px -12px rgba(0,0,0,.5); animation: rise .22s ease; max-width: 380px; }
.toast .t.err { background: #b91c1c; }
.toast .t.ok { background: #15803d; }
@keyframes rise { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: none } }

/* ---------------- 我的产出 ---------------- */

.of-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.of-chip {
  padding: 5px 13px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--panel); color: var(--muted); font-size: 12.5px; cursor: pointer;
  font-family: inherit; transition: background .15s, color .15s, border-color .15s;
}
.of-chip:hover { background: var(--panel-2); color: var(--text); }
.of-chip.on { background: var(--primary-weak); border-color: #c7dbff; color: var(--primary-dark); font-weight: 650; }

.of-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(258px, 1fr)); gap: 14px; }
.of-card {
  border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
  background: #fff; display: flex; flex-direction: column;
}
.of-thumb {
  background: #0f172a; height: 154px; display: grid; place-items: center; overflow: hidden;
}
.of-thumb img, .of-thumb video { width: 100%; height: 100%; object-fit: contain; background: #0f172a; display: block; }
.of-thumb .ph { color: #94a3b8; font-size: 12px; text-align: center; padding: 0 12px; }
.of-thumb pre {
  color: #cbd5e1; font-family: var(--mono); font-size: 11.5px; line-height: 1.55;
  margin: 0; padding: 12px 13px; width: 100%; height: 100%; overflow: hidden;
  white-space: pre-wrap; word-break: break-word;
}
.of-body { padding: 11px 13px 13px; display: flex; flex-direction: column; gap: 5px; flex: 1; }
.of-name { font-size: 13px; font-weight: 650; word-break: break-all; line-height: 1.45; }
.of-row { font-size: 11.5px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.of-tag {
  display: inline-flex; padding: 1px 7px; border-radius: 6px; font-size: 11px; font-weight: 650;
  background: var(--panel-2); border: 1px solid var(--border); color: var(--muted);
}
.of-tag.video { background: var(--purple-weak); color: var(--purple); border-color: #e6e1ff; }
.of-tag.image { background: var(--primary-weak); color: var(--primary-dark); border-color: #d7e5ff; }
.of-tag.audio { background: var(--green-weak); color: var(--green); border-color: #c9f0d8; }
.of-tag.text { background: var(--amber-weak); color: var(--amber); border-color: #f6e3c4; }
.of-actions { display: flex; gap: 7px; margin-top: auto; padding-top: 8px; }
.of-actions .btn { flex: 1; text-align: center; text-decoration: none; }
.of-expire { font-size: 11.5px; color: var(--amber); }
.of-expire.soon { color: var(--red); font-weight: 650; }
