:root {
  --bg: #0f1115;
  --bg-soft: #161a22;
  --card: #1b202b;
  --border: #2a3040;
  --text: #e6e9f0;
  --muted: #8b93a7;
  --primary: #4f7cff;
  --primary-hover: #6a90ff;
  --danger: #e5484d;
  --success: #30a46c;
  --warn: #f5a623;
  --radius: 10px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
}
a { color: var(--primary); text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }

/* 顶栏 */
#topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: 56px;
  background: var(--bg-soft); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.brand { font-size: 16px; font-weight: 600; }
#topbar nav { display: flex; align-items: center; gap: 16px; }
.nav-link { color: var(--muted); padding: 4px 8px; border-radius: 6px; }
.nav-link:hover, .nav-link.active { color: var(--text); background: var(--card); }

/* 布局 */
#app { max-width: 1200px; margin: 0 auto; padding: 24px; }
.grid-2 { display: grid; grid-template-columns: 400px 1fr; gap: 24px; align-items: start; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* 卡片 */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 20px;
}
.card h2 { font-size: 16px; margin-bottom: 16px; }
.card h3 { font-size: 14px; margin-bottom: 8px; color: var(--muted); font-weight: 500; }

/* 表单 */
label { display: block; margin: 12px 0 4px; color: var(--muted); font-size: 13px; }
input[type=text], input[type=password], input[type=number], input[type=search], textarea, select {
  width: 100%; padding: 9px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg-soft); color: var(--text);
  font-size: 14px; font-family: inherit;
}
textarea { resize: vertical; min-height: 90px; }
input:focus, textarea:focus, select:focus { outline: 1px solid var(--primary); border-color: var(--primary); }
input[type=checkbox] { width: auto; margin-right: 6px; }
.fixed-value {
  width: 100%; padding: 9px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg-soft); color: var(--text);
  font-size: 14px; min-height: 39px;
}
.prompt-wrap { position: relative; }
.prompt-wrap textarea { padding-right: 18px; }
.hidden-prompt-textarea { display: none !important; }
.prompt-editor {
  width: 100%; min-height: 300px; padding: 18px;
  border: 1px solid rgba(139,103,255,.42); border-radius: 12px;
  background: #080b11; color: #edf2ff; font-size: 14px; font-family: inherit;
  line-height: 1.8; white-space: pre-wrap; overflow-y: auto;
}
.prompt-editor:focus { outline: 1px solid var(--primary); border-color: var(--primary); }
.prompt-editor:empty::before { content: attr(data-placeholder); color: var(--muted); }
.prompt-material-chip {
  display: inline-flex; align-items: center; gap: 5px; max-width: min(190px, 100%);
  border: 1px solid rgba(139,103,255,.7); background: rgba(35,30,66,.92);
  color: #eef1ff; border-radius: 7px; padding: 2px 6px 2px 3px;
  font-size: 12px; line-height: 1.2; vertical-align: middle; margin: 0 2px;
}
.prompt-material-chip.inline { display: inline-flex; }
.prompt-material-chip img {
  width: 20px; height: 20px; border-radius: 4px; object-fit: cover; flex: 0 0 auto;
}
.prompt-material-audio,
.material-audio-mini {
  width: 20px; height: 20px; border-radius: 4px; display: inline-grid; place-items: center;
  flex: 0 0 auto; color: #c9d6ff; background: rgba(74,111,255,.22); border: 1px solid rgba(141,166,255,.35);
}
.prompt-material-chip span {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.prompt-material-chip button {
  border: 0; background: transparent; color: #d8def0; cursor: pointer; font-size: 15px;
  width: 16px; height: 16px; line-height: 14px; flex: 0 0 auto;
}
.prompt-material-chip button:hover { color: #fff; }
.material-menu {
  position: absolute; top: 0; left: 8px; z-index: 20;
  width: min(300px, calc(100% - 16px)); max-height: 220px; overflow-x: hidden; overflow-y: auto;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0,0,0,.28); padding: 6px;
}
.material-item {
  width: 100%; border: 0; background: transparent; color: var(--text);
  display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 9px; align-items: center;
  padding: 7px 8px; border-radius: 6px; cursor: pointer; text-align: left; overflow: hidden;
}
.material-item:hover { background: var(--card); }
.material-menu-thumb {
  width: 34px; height: 34px; display: grid; place-items: center; overflow: hidden;
  border-radius: 5px; background: var(--card); border: 1px solid var(--border);
}
.material-menu-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.material-menu-audio { color: #c9d6ff; font-size: 18px; line-height: 1; }
.material-item-copy { width: 100%; min-width: 0; overflow: hidden; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; }
.material-token {
  display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
  color: var(--primary); font-weight: 600; white-space: nowrap;
}
.material-name { display: block; width: 100%; max-width: 100%; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.material-empty { color: var(--muted); padding: 10px; font-size: 13px; }
.check-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.check-row label { margin: 0; color: var(--text); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.copy-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: start; }
.copy-row textarea { min-height: 72px; }

/* 文件上传 */
.file-box {
  margin-top: 12px; padding: 14px; border: 1px dashed var(--border);
  border-radius: 8px; text-align: center; color: var(--muted); cursor: pointer;
  transition: border-color .15s;
}
.file-box:hover { border-color: var(--primary); }
.file-box img, .file-box video { max-width: 100%; max-height: 160px; border-radius: 6px; margin-top: 8px; display: block; margin-left: auto; margin-right: auto; }
.file-box .file-name { font-size: 12px; margin-top: 6px; word-break: break-all; }
.file-box input { display: none; }
.multi-preview { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.multi-preview-item {
  position: relative;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: grab;
  user-select: none;
  transition: border-color .15s, background-color .15s, opacity .15s, transform .15s;
}
.multi-preview-item:active { cursor: grabbing; }
.multi-preview-item.dragging { opacity: .42; transform: scale(.97); }
.multi-preview-item.drag-over {
  border-color: var(--primary);
  background: rgba(47,140,255,.1);
  box-shadow: 0 0 0 2px rgba(47,140,255,.18);
}
.multi-preview-item img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; max-height: none; margin-top: 0; }
.multi-preview-item .file-name { font-size: 11px; line-height: 1.3; pointer-events: none; }
.preview-remove {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; padding: 0;
  border: 1px solid rgba(255,255,255,.28); border-radius: 999px; background: rgba(8,12,20,.78);
  color: #fff; font-size: 16px; line-height: 18px; cursor: pointer;
}
.preview-remove:hover { background: rgba(220,38,38,.9); border-color: rgba(255,255,255,.4); }
.audio-preview-list { width: 100%; display: grid; gap: 8px; }
.audio-preview-item {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 24px;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #111827;
  text-align: left;
}
.audio-preview-item span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--text); }
.audio-preview-item small { color: var(--muted); }
.inline-remove {
  position: static;
  display: inline-grid;
  place-items: center;
}

/* 按钮 */
.btn {
  display: inline-block; padding: 9px 18px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); cursor: pointer; font-size: 14px;
  transition: all .15s;
}
.btn:hover { border-color: var(--primary); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger-solid {
  background: #ef4444;
  border-color: #ef4444;
  color: #fff;
  font-weight: 700;
  box-shadow: 0 0 0 1px rgba(239,68,68,.2), 0 8px 18px rgba(239,68,68,.18);
}
.btn-danger-solid:hover {
  background: #ff5656;
  border-color: #ff5656;
}
.btn-ghost { background: transparent; border: none; color: var(--muted); }
.btn-ghost:hover { color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-inline { margin-left: 8px; padding: 3px 8px; }
.btn-block { width: 100%; margin-top: 16px; padding: 11px; font-size: 15px; }

/* 配额条 */
.quota-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.quota-track { flex: 1; height: 8px; background: var(--bg-soft); border-radius: 4px; overflow: hidden; }
.quota-fill { height: 100%; background: var(--primary); border-radius: 4px; transition: width .4s; }
.quota-fill.low { background: var(--warn); }
.quota-text { font-size: 13px; color: var(--muted); white-space: nowrap; }

/* 表格 */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
th { color: var(--muted); font-weight: 500; white-space: nowrap; }
td .prompt-cell { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td .actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* 徽标 */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; white-space: nowrap; }
.badge.pending { background: #3a3f4d; color: #b8c0d0; }
.badge.processing { background: rgba(79,124,255,.15); color: #7ea0ff; }
.badge.downloading { background: rgba(245,166,35,.15); color: var(--warn); }
.badge.succeeded { background: rgba(48,164,108,.15); color: #4cc38a; }
.badge.failed { background: rgba(229,72,77,.15); color: #f16a6e; }

/* 任务列表 */
.task-item { display: flex; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.task-item:last-child { border-bottom: none; }
.task-main { flex: 1; min-width: 0; }
.task-meta { font-size: 12px; color: var(--muted); margin-top: 4px; }
.task-error { color: var(--danger); font-size: 12px; margin-top: 4px; }
.task-video { margin-top: 10px; }
.task-video video { width: 100%; max-width: 420px; border-radius: 8px; background: #000; display: block; }
.task-actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }

/* Tab */
.tabs { display: flex; gap: 8px; margin-bottom: 16px; border-bottom: 1px solid var(--border); padding-bottom: 12px; flex-wrap: wrap; }
.tab { padding: 7px 16px; border-radius: 8px; cursor: pointer; color: var(--muted); border: 1px solid transparent; }
.tab.active { background: var(--card); color: var(--text); border-color: var(--border); }

/* 统计卡片 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stat .num { font-size: 26px; font-weight: 600; }
.stat .lbl { color: var(--muted); font-size: 13px; }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal { background: var(--card); border: 1px solid var(--border); border-radius: 12px; width: 100%; max-width: 440px; max-height: 85vh; overflow-y: auto; }
.modal.modal-wide { max-width: 600px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); font-weight: 600; }
.modal-close { background: none; border: none; color: var(--muted); font-size: 16px; cursor: pointer; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); }

/* Toast */
#toast-root { position: fixed; top: 68px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--card); border: 1px solid var(--border); border-left: 3px solid var(--primary); padding: 12px 18px; border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.4); animation: slidein .2s ease; max-width: 360px; }
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } }

/* 登录页 */
.login-wrap { min-height: 70vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 100%; max-width: 380px; }
.login-card .brand { text-align: center; font-size: 20px; margin-bottom: 8px; }
.login-card .sub { text-align: center; color: var(--muted); margin-bottom: 20px; }

/* 过滤器行 */
.filter-row { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.filter-row select, .filter-row input { width: auto; }
.user-search-row {
  padding: 12px 0;
  margin-bottom: 10px;
}
.user-search-row input,
.user-search-row input[type=search] {
  appearance: none;
  -webkit-appearance: none;
  width: 260px;
  max-width: 100%;
  min-height: 40px;
  background: var(--bg-soft) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  border-radius: 8px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.03);
}
.user-search-row input[type=search]::placeholder {
  color: var(--muted);
}
.user-search-row input[type=search]:focus {
  outline: none;
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px rgba(139,103,255,.16), inset 0 1px 0 rgba(255,255,255,.04);
}
.pager { display: flex; justify-content: flex-end; gap: 10px; align-items: center; margin-top: 14px; }
.agent-summary {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 12px;
  color: var(--text);
}
.detail-meta { margin: 10px 0 14px; }
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.detail-subtitle { font-size: 15px; margin: 16px 0 10px; }
.detail-log-table th, .detail-log-table td { padding: 10px 12px; }
.detail-form-tail {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  margin-top: 8px;
}
.detail-inline-actions .modal-foot {
  border-top: 0;
  padding: 0;
}
.user-detail-modal > .modal-foot {
  display: none;
}
.red { color: var(--red); }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }

/* 状态提示 */
.status-note { font-size: 13px; padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.status-note.ok { background: rgba(48,164,108,.12); color: #4cc38a; }
.status-note.fail { background: rgba(229,72,77,.12); color: #f16a6e; }
.status-note.unknown { background: rgba(245,166,35,.12); color: var(--warn); }

/* 空态 */
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* SD2 redesign */
:root {
  --page: #090b10;
  --panel: #141922;
  --panel-2: #10141b;
  --line: #2a3140;
  --purple: #8b67ff;
  --blue: #4d8dff;
  --green: #28b446;
  --red: #ff4e55;
}
body {
  background:
    radial-gradient(circle at 48% 12%, rgba(139, 103, 255, .08), transparent 28%),
    linear-gradient(180deg, #0b0d13 0%, #080a0f 100%);
}
#app { max-width: none; width: 100%; min-height: 100vh; padding: 0; }
.logo-mark {
  width: 44px; height: 44px; display: grid; place-items: center;
  border-radius: 10px; color: #fff; font-weight: 800;
  background: linear-gradient(135deg, #8c64ff, #4e8dff);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18);
}
.green { color: var(--green); }

.user-shell, .admin-shell {
  min-height: 100vh;
  display: grid;
  background: var(--page);
}
.user-shell { grid-template-columns: 244px 1fr; }
.admin-shell { grid-template-columns: 220px 1fr; }
.admin-shell {
  display: block;
}
.user-sidebar, .admin-sidebar {
  min-height: 100vh;
  border-right: 1px solid var(--line);
  background: rgba(16, 20, 27, .82);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
}
.admin-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 220px;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
  z-index: 40;
}
.admin-sidebar .side-nav {
  overflow-y: auto;
  padding-right: 2px;
}
.side-current-user {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  margin-top: auto;
  margin-bottom: 12px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
}
.side-current-user span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.online-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--primary);
}
#admin-logout {
  margin-top: 0;
}
.side-brand { display: flex; align-items: center; gap: 12px; }
.side-brand b { display: block; font-size: 16px; line-height: 1.2; }
.side-brand span { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.side-nav { display: flex; flex-direction: column; gap: 8px; }
.side-nav a {
  color: #9da8bd;
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 600;
}
.side-nav a.active, .side-nav a:hover {
  color: #fff;
  background: rgba(139, 103, 255, .13);
  border-color: rgba(139, 103, 255, .58);
}
.admin-nav a.active, .admin-nav a:hover {
  background: rgba(40, 180, 70, .13);
  border-color: rgba(40, 180, 70, .36);
  color: #43d064;
}
.side-status {
  margin-top: auto;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.03);
  color: #aeb8ca;
  border-radius: 8px;
  padding: 12px;
  font-size: 12px;
}
.side-status span {
  width: 7px; height: 7px; border-radius: 50%; display: inline-block;
  background: var(--purple); margin-right: 6px;
}

.user-main { padding: 32px 34px 40px; min-width: 0; }
.workspace-head {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(360px, 760px) auto;
  gap: 24px;
  align-items: center;
  margin-bottom: 30px;
}
.workspace-head.compact-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 30px;
  min-height: 56px;
}
.workspace-head h1, .admin-head h1 {
  font-size: 28px;
  line-height: 1.1;
  margin: 0 0 8px;
}
.workspace-head p { color: var(--muted); margin: 0; }
.notice {
  justify-self: center;
  width: 100%;
  max-width: 760px;
  text-align: center;
  padding: 14px 18px;
  border-radius: 8px;
  border: 1px solid rgba(208, 125, 47, .48);
  background: rgba(90, 47, 24, .5);
  color: #fff0d5;
  font-weight: 700;
}
.retention-warning {
  flex: 1 1 auto;
  max-width: 720px;
  margin: 0 auto;
  text-align: center;
  border: 2px solid #ff4059;
  background: rgba(255, 64, 89, .14);
  color: #fff;
  border-radius: 6px;
  padding: 14px 18px;
  font-size: 16px;
  line-height: 1.35;
  font-weight: 800;
}
.quota-pill {
  flex: 0 0 auto;
  white-space: nowrap;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.04);
  border-radius: 8px;
  padding: 12px 18px;
  font-weight: 700;
}
.create-grid {
  display: grid;
  grid-template-columns: 416px minmax(520px, 1fr) 464px;
  gap: 16px;
  align-items: stretch;
}
.panel {
  background: rgba(20, 25, 34, .86);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  min-width: 0;
}
.panel h2 { font-size: 16px; margin: 0 0 18px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; }
.panel-head h2 { margin: 0; }
.panel-head span { color: var(--muted); font-size: 12px; }
.asset-panel-head { align-items: center; }
.asset-head-actions { display: inline-flex; align-items: center; gap: 10px; white-space: nowrap; }
.hint-line, .support-note {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.025);
  color: #9ba7bd;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
}
.asset-panel { display: flex; flex-direction: column; gap: 14px; }
.large-upload {
  min-height: 154px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border-color: rgba(139,103,255,.28);
}
.compact-upload { margin-top: 0; }
.prompt-panel textarea {
  min-height: 300px;
  background: #080b11;
  border-color: rgba(139,103,255,.42);
  border-radius: 12px;
  padding: 18px;
  color: #edf2ff;
}
.support-note {
  border-color: rgba(139,103,255,.58);
  color: #eef1ff;
  margin: 38px 0 18px;
}
.form-row-4 {
  display: grid;
  grid-template-columns: minmax(150px, 1.05fr) minmax(120px, .9fr) minmax(120px, .9fr) minmax(96px, .72fr);
  gap: 10px;
}
.form-row-4 label { margin-top: 0; }
.model-picker {
  position: relative;
}
.model-picker-button {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111827;
  color: #f2f6ff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
}
.model-picker-button > span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.model-picker-button:focus {
  outline: 1px solid var(--primary);
  border-color: var(--primary);
}
.model-picker-caret {
  color: #9ca8bc;
  font-size: 16px;
  line-height: 1;
  flex: 0 0 auto;
}
.model-picker-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  z-index: 60;
  width: min(600px, calc(100vw - 48px));
  max-height: 380px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px;
  border: 1px solid rgba(139, 103, 255, .55);
  border-radius: 10px;
  background: #080c14;
  box-shadow: 0 18px 44px rgba(0, 0, 0, .48);
}
.model-picker-menu::-webkit-scrollbar {
  width: 8px;
}
.model-picker-menu::-webkit-scrollbar-track {
  background: #0b111c;
  border-radius: 999px;
}
.model-picker-menu::-webkit-scrollbar-thumb {
  background: #6757a8;
  border-radius: 999px;
}
.model-picker-option {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #edf2ff;
  display: grid;
  grid-template-columns: minmax(130px, 1fr) auto;
  gap: 12px;
  align-items: center;
  text-align: left;
  cursor: pointer;
}
.model-picker-option:hover,
.model-picker-option.active {
  border-color: rgba(139, 103, 255, .7);
  background: rgba(139, 103, 255, .18);
}
.model-picker-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.model-picker-text b,
.model-picker-text small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.model-picker-text b {
  font-size: 13px;
}
.model-picker-text small {
  color: #8fa0bf;
  font-size: 11px;
}
.model-picker-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}
.model-copy-badge {
  color: #aeb9cf;
  font-size: 12px;
  white-space: nowrap;
}
.model-price-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 24px;
  padding: 0 8px;
  border: 1px solid rgba(77, 145, 255, .28);
  border-radius: 8px;
  background: rgba(77, 145, 255, .08);
  color: #d8e4ff;
  font-size: 12px;
  white-space: nowrap;
}
.model-price-badge b {
  color: #58d8f7;
  font-weight: 800;
}
.duration-dropdown {
  position: relative;
}
.duration-dropdown-button {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111827;
  color: #f2f6ff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}
.duration-dropdown-button:focus {
  outline: 1px solid var(--primary);
  border-color: var(--primary);
}
.duration-dropdown-caret {
  color: #9ca8bc;
  font-size: 16px;
  line-height: 1;
}
.duration-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 40;
  max-height: 212px;
  overflow-y: auto;
  overflow-x: hidden;
  border: 1px solid rgba(88, 128, 255, .45);
  border-radius: 8px;
  background: #0f1624;
  box-shadow: 0 18px 36px rgba(0, 0, 0, .36);
}
.duration-dropdown-menu::-webkit-scrollbar {
  width: 8px;
}
.duration-dropdown-menu::-webkit-scrollbar-track {
  background: #0b111c;
  border-radius: 999px;
}
.duration-dropdown-menu::-webkit-scrollbar-thumb {
  background: #5f6d85;
  border-radius: 999px;
}
.duration-dropdown-menu::-webkit-scrollbar-thumb:hover {
  background: #7b89a3;
}
.duration-dropdown-option {
  width: 100%;
  height: 34px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: #edf2ff;
  text-align: left;
  cursor: pointer;
}
.duration-dropdown-option:hover,
.duration-dropdown-option.active {
  background: #2563eb;
  color: #fff;
}
.cost-row {
  display: flex;
  justify-content: flex-end;
  gap: 16px;
  color: #9ca8bc;
  font-size: 12px;
  margin-top: 36px;
}
#audio-fixed { color: #b9c6dc; }
.btn-primary {
  border: 0;
  background: linear-gradient(90deg, #8b67ff, #4d91ff);
  font-weight: 800;
}
.task-panel { max-height: calc(100vh - 148px); overflow: hidden; display: flex; flex-direction: column; }
.task-panel #task-list { overflow: auto; padding-right: 4px; }
.task-item {
  padding: 12px 0;
  border-bottom-color: var(--line);
}
.task-row {
  cursor: pointer;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.task-row:hover {
  background: rgba(255,255,255,.035);
}
.task-item .prompt-cell {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #fff;
  font-weight: 700;
  margin-top: 6px;
}
.task-retry-mini {
  flex: 0 0 auto;
}
.task-video video { max-width: 100%; }
.creation-library-selection {
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.025);
}
.creation-library-title {
  margin-bottom: 8px;
  color: #c7d0e2;
  font-size: 12px;
  font-weight: 700;
}
.creation-library-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.material-chip {
  min-width: 0;
  max-width: 100%;
  height: 34px;
  display: inline-grid;
  grid-template-columns: 26px minmax(0, auto) auto auto;
  align-items: center;
  gap: 7px;
  padding: 3px 7px 3px 3px;
  border: 1px solid rgba(139,103,255,.42);
  border-radius: 6px;
  background: rgba(139,103,255,.1);
}
.material-chip.automatic {
  border-color: rgba(77,141,255,.5);
  background: rgba(77,141,255,.1);
}
.material-chip img {
  width: 26px;
  height: 26px;
  object-fit: cover;
  border-radius: 4px;
}
.material-chip > span {
  overflow: hidden;
  color: #edf2ff;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.material-chip small { color: #9aa9c2; white-space: nowrap; }
.material-chip button {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #bcc7db;
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
}
.creation-library-empty { color: var(--muted); font-size: 12px; }

.material-library-page { min-width: 0; }
.material-library-head { align-items: center; }
.material-library-head .btn { flex: 0 0 auto; }
.material-library-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 308px;
  gap: 16px;
  align-items: start;
}
.material-browser, .material-detail { margin: 0; }
.material-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 126px;
  gap: 10px;
  margin-bottom: 14px;
}
.material-summary {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0 12px;
  border-bottom: 1px solid var(--line);
  color: #aeb9cd;
}
.material-summary > div { display: flex; align-items: center; gap: 12px; }
.material-summary b { color: #eef2fb; white-space: nowrap; }
.material-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(142px, 1fr));
  gap: 10px;
  padding-top: 14px;
}
.material-grid-empty { grid-column: 1 / -1; }
.material-card {
  position: relative;
  min-width: 0;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.025);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.material-card:hover, .material-card.active {
  border-color: rgba(139,103,255,.68);
  background: rgba(139,103,255,.065);
}
.material-card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: block;
  object-fit: cover;
  border-radius: 6px;
  background: #080b11;
}
.material-audio-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: linear-gradient(135deg, rgba(74,111,255,.22), rgba(139,103,255,.18));
  border: 1px solid rgba(141,166,255,.25);
  color: #dce6ff;
}
.material-audio-thumb span { font-size: 34px; line-height: 1; }
.material-audio-thumb small {
  max-width: 80%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}
.material-card strong, .material-card small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.material-card strong { margin-top: 7px; }
.material-card small { color: var(--muted); }
.material-card-check {
  position: absolute;
  z-index: 2;
  top: 13px;
  left: 13px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 1px solid #596275;
  border-radius: 6px;
  background: rgba(9,11,16,.82);
  color: #fff;
  font-weight: 800;
}
.material-card-check.checked {
  border-color: var(--purple);
  background: var(--purple);
}
.material-detail { position: sticky; top: 20px; }
.material-detail-preview {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: block;
  object-fit: contain;
  border-radius: 6px;
  background: #080b11;
}
.material-detail-audio {
  min-height: 132px;
  display: grid;
  gap: 14px;
  place-items: center;
  padding: 22px;
  border-radius: 6px;
  background: linear-gradient(135deg, rgba(74,111,255,.2), rgba(139,103,255,.16));
  border: 1px solid rgba(141,166,255,.22);
}
.material-detail-audio > span { font-size: 36px; color: #dce6ff; }
.material-detail-audio audio { width: 100%; }
.material-detail-meta { margin: 14px 0; }
.material-detail-meta > div {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}
.material-detail-meta dt { color: var(--muted); }
.material-detail-meta dd {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}
.material-name-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}
.material-detail .btn-block { width: 100%; margin-top: 10px; }
.page-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 28px;
}
.page-head h1 {
  font-size: 30px;
  line-height: 1.1;
  margin: 0 0 6px;
}
.page-head p {
  color: var(--muted);
  margin: 0;
}
.task-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
}
.task-toolbar select {
  width: auto;
  min-width: 90px;
}
.history-panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(20,25,34,.58);
  padding: 30px 14px;
}
.history-row {
  display: grid;
  grid-template-columns: 44px 112px minmax(0, 1fr) auto auto;
  gap: 16px;
  align-items: center;
  min-height: 92px;
  padding: 18px 12px;
  margin: 0 0 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.025);
  cursor: pointer;
}
.history-row:hover {
  border-color: rgba(139,103,255,.48);
  background: rgba(139,103,255,.045);
}
.history-check-hit {
  width: 44px;
  min-height: 64px;
  justify-self: center;
  display: grid;
  place-items: center;
  border-radius: 10px;
  cursor: pointer;
}
.history-check-hit:hover .history-check-box {
  border-color: #a78bfa;
  background: rgba(139,103,255,.14);
}
.history-check {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.history-check-box {
  width: 34px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 2px solid #657087;
  border-radius: 7px;
  background: rgba(255,255,255,.08);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.history-check:checked + .history-check-box {
  border-color: #8b67ff;
  background: linear-gradient(135deg, #8b67ff, #4f8cff);
  box-shadow: 0 0 0 3px rgba(139,103,255,.16);
}
.history-check:checked + .history-check-box::after {
  content: "";
  width: 8px;
  height: 13px;
  border: solid #fff;
  border-width: 0 3px 3px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}
.history-check:disabled + .history-check-box {
  opacity: .35;
}
.history-check-hit:has(.history-check:disabled) {
  cursor: not-allowed;
}
.history-thumb {
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(139,103,255,.42), rgba(77,141,255,.22));
  color: #cfc6ff;
  font-size: 12px;
}
.history-main {
  min-width: 0;
}
.history-title {
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-actions {
  display: flex;
  gap: 8px;
}
.settings-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(20,25,34,.58);
  padding: 18px;
  margin-bottom: 14px;
}
.settings-card h2 {
  font-size: 16px;
  margin: 0 0 14px;
}
.usage-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.usage-stats div {
  min-height: 68px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(255,255,255,.025);
}
.usage-stats span {
  color: var(--muted);
  font-size: 12px;
}
.usage-stats b {
  font-size: 22px;
  line-height: 1;
}
.purple-text { color: var(--purple); }
.red-text { color: #ff6572; }
.section-title {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  margin: 8px 0 10px;
}
.usage-log {
  max-height: 196px;
  overflow: auto;
  border: 1px solid rgba(42,49,64,.75);
  border-radius: 8px;
}
.usage-line {
  display: grid;
  grid-template-columns: 220px 1fr 80px;
  gap: 12px;
  padding: 7px 10px;
  border-bottom: 1px solid rgba(42,49,64,.65);
}
.usage-line span { color: var(--muted); }
.usage-line b { color: #fff; font-weight: 600; }
.usage-line em {
  color: #ff6572;
  font-style: normal;
  font-weight: 800;
  text-align: right;
}
.task-detail-mask {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(2, 4, 8, .62);
  backdrop-filter: blur(10px);
  display: flex;
  justify-content: flex-end;
}
.task-detail {
  width: min(580px, 100vw);
  height: 100vh;
  background: #0f1219;
  border-left: 1px solid var(--line);
  box-shadow: -24px 0 80px rgba(0,0,0,.42);
  display: flex;
  flex-direction: column;
}
.task-detail-head {
  min-height: 56px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: start;
}
.task-detail-head h2 {
  font-size: 22px;
  line-height: 1.35;
  margin: 8px 0 0;
}
.task-detail-body {
  padding: 16px 24px 24px;
  overflow: auto;
}
.task-detail-body section {
  padding: 0 0 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.task-detail-body h3 {
  margin: 0 0 12px;
  font-size: 14px;
}
.detail-video-box {
  min-height: 0;
  display: grid;
  gap: 12px;
  justify-items: center;
}
.detail-video-box video {
  width: 66.666%;
  max-height: 62vh;
  object-fit: contain;
  border-radius: 8px;
  background: #000;
}
.detail-download-row {
  width: 66.666%;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  align-items: stretch;
}
.detail-download-row input {
  min-width: 0;
  height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(139,103,255,.42);
  border-radius: 7px;
  background: rgba(255,255,255,.045);
  color: #eef2ff;
  outline: none;
}
.detail-download-row input:focus {
  border-color: #8b67ff;
  box-shadow: 0 0 0 3px rgba(139,103,255,.16);
}
.detail-download-row .btn {
  width: 100%;
  justify-content: center;
}
.detail-prompt {
  max-height: 180px;
  overflow-y: auto;
  padding: 12px 14px;
  border: 1px solid rgba(42,49,64,.95);
  border-radius: 8px;
  background: rgba(9,11,16,.42);
  color: #f0f4ff;
  font-size: 15px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
  scrollbar-width: thin;
  scrollbar-color: rgba(139,103,255,.62) rgba(255,255,255,.06);
}
.detail-prompt::-webkit-scrollbar {
  width: 8px;
}
.detail-prompt::-webkit-scrollbar-track {
  background: rgba(255,255,255,.06);
  border-radius: 999px;
}
.detail-prompt::-webkit-scrollbar-thumb {
  background: rgba(139,103,255,.62);
  border-radius: 999px;
}
.detail-list {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 0;
}
.detail-list dt,
.detail-list dd {
  padding: 8px 0;
  border-bottom: 1px solid rgba(42,49,64,.72);
}
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; color: #f0f4ff; word-break: break-all; }
.detail-error {
  background: rgba(229,72,77,.1);
  border: 1px solid rgba(229,72,77,.28);
  border-radius: 8px;
  padding: 10px 12px;
}

.admin-main {
  min-width: 0;
  margin-left: 220px;
  min-height: 100vh;
}
.admin-head {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(20, 25, 34, .72);
}
.admin-head h1 { font-size: 16px; margin: 0; }
#admin-body { padding: 24px 28px; }
.stats-overview-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(20,25,34,.86);
  margin-bottom: 20px;
  overflow: hidden;
}
.stats-range-toolbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.stats-range-fields { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.stats-range-fields b { font-size: 14px; white-space: nowrap; }
.stats-range-fields input[type=date] {
  width: 150px;
  height: 34px;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #1b2230;
  color: var(--text);
  color-scheme: dark;
}
.stats-range-note { color: var(--muted); font-size: 12px; text-align: right; white-space: nowrap; }
.stats-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  padding: 18px;
}
.stats-summary-card {
  min-height: 116px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(18,23,31,.76);
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.stats-summary-card span { color: var(--muted); font-size: 13px; }
.stats-summary-card b { font-size: 29px; line-height: 1.2; margin: 6px 0 2px; }
.stats-summary-card small { color: var(--muted); font-size: 12px; }
.orange { color: var(--warn); }
.stats-channel-card { padding: 0; overflow: hidden; }
.stats-section-head {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
}
.stats-section-head h2 { margin: 0; font-size: 15px; }
.stats-table-wrap { overflow-x: auto; }
.stats-channel-table { border: 0; border-radius: 0; table-layout: fixed; }
.stats-channel-table th:first-child, .stats-channel-table td:first-child { width: 29%; }
.stats-channel-table th, .stats-channel-table td { padding: 13px 12px; }
.stats-channel-table td:first-child b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stats-empty-row { text-align: center; padding: 36px 12px !important; }
#admin-body > .card, .admin-card, #admin-body > .stat-grid + .card {
  background: rgba(20, 25, 34, .86);
  border-color: var(--line);
}
.admin-logo { background: linear-gradient(135deg, #2db65f, #4d8dff); }
.stat {
  border-radius: 8px;
  background: rgba(20,25,34,.86);
  border-color: var(--line);
}
table {
  background: rgba(20,25,34,.58);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
th, td { border-bottom-color: var(--line); }
tr:hover td { background: rgba(255,255,255,.018); }
.badge-action {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
.btn-detail {
  background: #243045;
  border-color: #33435f;
  color: #dce8ff;
}
.btn-recharge {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
.btn-dark-danger {
  background: #211923;
  border-color: #4b2630;
  color: #ff7b86;
}
.btn-dark-danger:hover {
  border-color: #ff6572;
  color: #fff;
}
.model-admin-card {
  padding: 0;
  overflow: hidden;
}
@media (max-width: 1100px) {
  .stats-range-toolbar { align-items: flex-start; flex-direction: column; }
  .stats-range-note { text-align: left; white-space: normal; }
  .stats-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  #admin-body { padding: 16px; }
  .stats-summary-grid { grid-template-columns: 1fr; }
  .stats-range-fields { align-items: stretch; }
  .stats-range-fields input[type=date] { width: 100%; }
}
.model-admin-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}
.model-admin-head h2 {
  margin: 0 0 6px;
  font-size: 16px;
}
.model-tabs {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
}
.model-admin-grid {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 620px;
}
.model-list-pane {
  padding: 14px;
  border-right: 1px solid var(--line);
  background: rgba(14,18,26,.35);
  min-height: 0;
  height: min(720px, calc(100vh - 180px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.model-list-title {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}
.model-add-btn {
  margin: 0 0 12px;
}
.model-list {
  display: grid;
  gap: 8px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(9,12,18,.26);
}
.model-list-item {
  width: 100%;
  min-height: 58px;
  padding: 12px;
  overflow: hidden;
  text-align: left;
  color: var(--text);
  background: #202734;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}
.model-list-item b {
  display: block;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.model-list-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.model-list-item.active {
  border-color: var(--green);
  background: #1b2735;
}
.model-editor-pane {
  min-width: 0;
  padding: 20px;
}
.model-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}
.model-default-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  white-space: nowrap;
}
.model-default-check input {
  width: 16px;
  height: 16px;
}
.model-title-row h2 {
  margin: 0 0 6px;
  font-size: 18px;
}
.model-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.model-tags span {
  padding: 3px 8px;
  color: #8db6ff;
  font-size: 12px;
  background: #1b2331;
  border-radius: 999px;
}
.model-tags input {
  width: auto;
  min-width: 72px;
  max-width: 220px;
  padding: 3px 8px;
  color: #8db6ff;
  font-size: 12px;
  line-height: 1.3;
  background: #1b2331;
  border: 1px solid transparent;
  border-radius: 999px;
}
.model-tags input:focus {
  outline: none;
  border-color: rgba(139,103,255,.78);
  box-shadow: 0 0 0 3px rgba(139,103,255,.16);
}
.model-checks {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}
.model-checks label {
  margin: 0;
  color: var(--text);
}
.model-form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}
.model-form-grid label {
  margin: 0;
}
.model-admin-card input:not([type]),
.model-admin-card input[type=text],
.model-admin-card input[type=number],
.model-admin-card select {
  width: 100%;
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid rgba(148,163,184,.22);
  border-radius: 9px;
  background: rgba(15,23,42,.72);
  color: #eef2ff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.03);
}
.model-admin-card input:not([type])::placeholder,
.model-admin-card input[type=text]::placeholder,
.model-admin-card input[type=number]::placeholder {
  color: rgba(148,163,184,.72);
}
.model-admin-card input:not([type]):focus,
.model-admin-card input[type=text]:focus,
.model-admin-card input[type=number]:focus,
.model-admin-card select:focus {
  outline: none;
  border-color: rgba(139,103,255,.78);
  box-shadow: 0 0 0 3px rgba(139,103,255,.16), inset 0 1px 0 rgba(255,255,255,.04);
}
.model-wide {
  grid-column: span 2;
}
.model-media-limits {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.model-description-row {
  grid-column: 1 / -1;
}
.model-prompt-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
}
.model-save-row {
  grid-column: 1 / -1;
}
.model-support-line {
  margin: 12px 0 16px;
}
.model-error-box {
  padding: 14px;
  border: 1px solid rgba(229,72,77,.45);
  border-radius: 8px;
  background: rgba(37,25,33,.72);
}
.model-error-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.model-error-head b {
  color: #ff6572;
}
.model-error-item {
  padding-top: 12px;
  margin-top: 12px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.model-error-item:first-of-type {
  padding-top: 0;
  margin-top: 0;
  border-top: 0;
}
.model-error-item summary {
  margin: 8px 0;
  color: #dce8ff;
  cursor: pointer;
}
.model-error-item pre {
  padding: 10px;
  color: #ff6572;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  background: #090d14;
  border-radius: 6px;
}
.model-error-actions {
  display: flex;
  justify-content: flex-end;
}
.account-pagination {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  padding-top: 12px;
  flex-wrap: wrap;
}
.admin-task-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.admin-stat-card {
  min-height: 96px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(20,25,34,.86);
}
.admin-stat-card span {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
}
.admin-stat-card b {
  font-size: 30px;
  line-height: 1;
}
.blue { color: #438cff; }
.admin-task-toolbar {
  padding: 16px 20px;
  margin: 0;
  border-bottom: 1px solid var(--line);
}
.admin-task-toolbar h3 {
  margin: 0;
  font-size: 16px;
}
.admin-task-toolbar .spacer { flex: 1; }
.admin-task-toolbar input { min-width: 260px; }
.ledger-card { overflow: visible; }
.ledger-toolbar { padding: 18px 20px; margin: 0; border-bottom: 1px solid var(--line); }
.ledger-toolbar h2 { margin: 0; font-size: 17px; }
.ledger-toolbar .spacer { flex: 1; }
.ledger-toolbar input { width: min(320px, 32vw); }
.ledger-toolbar select { min-width: 142px; }
.ledger-table { border: 0; border-radius: 0; table-layout: auto; }
.ledger-table th, .ledger-table td { white-space: nowrap; }
.ledger-delta, .ledger-balance { font-weight: 700; }
.ledger-delta.positive, .ledger-balance { color: #22c55e; }
.ledger-delta.negative { color: #ff4d55; }
.admin-task-table {
  border: 0;
  border-radius: 0;
}
.admin-task-table tr[data-admin-task] {
  cursor: pointer;
}
.admin-task-table tr[data-admin-task]:hover td {
  background: rgba(127, 96, 255, .08);
}
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.copy-mini {
  border: 0;
  background: transparent;
  color: #bcd3ff;
  cursor: pointer;
  padding: 0 4px;
}
.linklike { color: #268cff; }
.admin-detail-mask { background: rgba(2,4,8,.72); }
.admin-task-detail {
  width: min(640px, 100vw);
  background: #151b24;
}
.admin-task-detail-head {
  min-height: 68px;
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.admin-task-detail-head h2 {
  margin: 0;
  font-size: 18px;
}
.admin-asset-item {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}
.admin-asset-item a {
  color: #2f8cff;
  word-break: break-all;
}
.admin-asset-item img {
  max-width: 100%;
  max-height: 180px;
  object-fit: contain;
  object-position: left center;
  border-radius: 6px;
  background: #0b0e14;
}

@media (max-width: 1280px) {
  .user-shell, .admin-shell { grid-template-columns: 1fr; }
  .user-sidebar, .admin-sidebar { position: static; min-height: auto; }
  .admin-shell { display: grid; }
  .admin-sidebar { width: auto; height: auto; overflow: visible; }
  .admin-main { margin-left: 0; }
  .create-grid, .workspace-head { grid-template-columns: 1fr; }
  .model-admin-grid { grid-template-columns: 1fr; }
  .model-list-pane {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    height: auto;
    overflow: visible;
  }
  .model-list {
    max-height: 360px;
  }
  .model-form-grid { grid-template-columns: 1fr 1fr; }
  .model-media-limits { grid-template-columns: 1fr 1fr; }
  .task-panel { max-height: none; }
  .material-library-layout { grid-template-columns: minmax(0, 1fr) 280px; }
  .workspace-head.compact-head {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  .retention-warning {
    order: 2;
    flex-basis: 100%;
    max-width: none;
  }
}
@media (max-width: 760px) {
  .user-main, #admin-body { padding: 16px; }
  .form-row-4 { grid-template-columns: 1fr 1fr; }
  .workspace-head h1 { font-size: 24px; }
  .page-head, .task-toolbar { flex-direction: column; align-items: stretch; }
  .history-row { grid-template-columns: 44px 1fr; gap: 12px; }
  .history-thumb, .history-row > .badge, .history-actions { grid-column: 2; }
  .usage-stats, .usage-line { grid-template-columns: 1fr; }
  .usage-line em { text-align: left; }
  .material-library-layout { grid-template-columns: 1fr; }
  .material-toolbar { grid-template-columns: 1fr; }
  .material-summary { align-items: flex-start; flex-direction: column; }
  .material-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .material-detail { position: static; }
  .retention-warning { font-size: 14px; padding: 12px; }
}
