/* AI 生图站 全站样式 */
:root {
  --bg: #0b0d12;
  --panel: #141721;
  --panel2: #1a1e2b;
  --border: #262c3d;
  --text: #e8eaf2;
  --muted: #8b92a7;
  --primary: #6366f1;
  --primary2: #a855f7;
  --danger: #ef4444;
  --radius: 14px;
  --radius-sm: 10px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  background-image:
    radial-gradient(1200px 500px at 80% -10%, rgba(99, 102, 241, .13), transparent 60%),
    radial-gradient(900px 420px at -10% 10%, rgba(168, 85, 247, .10), transparent 60%);
  background-attachment: fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
}
a { color: #9ca8ff; text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: var(--panel2); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .85em; }
.center { text-align: center; }
.strong { font-weight: 600; }
.pad-lg { padding: 22px; }
.inline-form { display: inline-flex; gap: 8px; align-items: center; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(13, 15, 22, .82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1280px; margin: 0 auto; padding: 0 20px;
  height: 60px; display: flex; align-items: center; gap: 24px;
}
.brand {
  font-size: 19px; font-weight: 700; color: var(--text);
  display: flex; align-items: center; gap: 8px; white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  background: linear-gradient(135deg, var(--primary), var(--primary2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  font-size: 22px;
}
.nav { display: flex; gap: 6px; flex: 1; }
.nav-link {
  color: var(--muted); padding: 7px 14px; border-radius: 999px;
  font-size: 14.5px; transition: all .15s;
}
.nav-link:hover { color: var(--text); background: var(--panel2); text-decoration: none; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.quota { display: flex; gap: 8px; }
.quota-item {
  background: var(--panel); border: 1px solid var(--border);
  padding: 5px 12px; border-radius: 999px; font-size: 13px; color: var(--muted);
  white-space: nowrap;
}
.quota-item b { color: var(--text); }

/* ---------- 用户下拉菜单 ---------- */
.user-menu { position: relative; }
.user-menu-btn {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--border); color: var(--text);
  border-radius: 999px; padding: 6px 14px; font-size: 14px; cursor: pointer;
  transition: border-color .15s; max-width: 230px;
}
.user-menu-btn:hover { border-color: #3a4157; }
.um-avatar { font-size: 15px; }
.um-uname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.um-caret { color: var(--muted); font-size: 11px; }
.user-menu-panel {
  position: absolute; right: 0; top: calc(100% + 10px); min-width: 210px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 6px; box-shadow: 0 14px 40px rgba(0, 0, 0, .5); z-index: 80;
}
.um-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  border-radius: 8px; color: var(--text); font-size: 14px; transition: background .12s;
}
.um-item:hover { background: var(--panel2); text-decoration: none; }
.um-item.active {
  background: linear-gradient(135deg, rgba(99, 102, 241, .18), rgba(168, 85, 247, .18));
  color: #c3c9ff;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); background: var(--panel2); color: var(--text);
  border-radius: var(--radius-sm); padding: 9px 18px; font-size: 14.5px;
  cursor: pointer; transition: all .15s; white-space: nowrap; user-select: none;
}
.btn:hover { filter: brightness(1.15); text-decoration: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary2));
  border-color: transparent; color: #fff; font-weight: 600;
}
.btn-ghost { background: transparent; }
.btn-danger { background: rgba(239, 68, 68, .14); border-color: rgba(239, 68, 68, .4); color: #fca5a5; }
.btn-sm { padding: 5px 12px; font-size: 13px; border-radius: 8px; }
.btn-lg { padding: 13px 26px; font-size: 16px; }
.btn-block { width: 100%; }
.btn.disabled { opacity: .4; pointer-events: none; }

/* ---------- 布局 / 卡片 ---------- */
.page { max-width: 1280px; width: 100%; margin: 0 auto; padding: 26px 20px 60px; flex: 1; }
.page.narrow { max-width: 440px; }
.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}
.flashes { max-width: 1280px; margin: 14px auto -8px; padding: 0 20px; }
.flash {
  padding: 11px 16px; border-radius: var(--radius-sm); margin-bottom: 8px;
  font-size: 14px; border: 1px solid;
}
.flash-error { background: rgba(239, 68, 68, .1); border-color: rgba(239, 68, 68, .4); color: #fca5a5; }
.flash-ok { background: rgba(34, 197, 94, .1); border-color: rgba(34, 197, 94, .4); color: #86efac; }
.footer {
  border-top: 1px solid var(--border); padding: 24px 20px 28px; text-align: center;
  color: var(--muted); font-size: 13px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.footer-ad-wrap {
  max-width: 960px; width: 100%; margin: 0 auto;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.footer-ad-title {
  font-size: 12px; color: var(--muted); letter-spacing: .5px;
}
.footer-ad-link, .footer-ad-box {
  display: inline-block; max-width: 100%; border-radius: var(--radius-sm); overflow: hidden;
  border: 1px solid var(--border); transition: border-color .15s, transform .15s;
}
.footer-ad-link:hover {
  border-color: #3a4157; transform: translateY(-1px);
}
.footer-ad-img {
  max-width: 100%; height: auto; max-height: 120px; display: block;
  object-fit: cover;
}
.footer-links {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px 18px;
}
.footer-link-item {
  color: var(--muted); font-size: 13.5px; transition: color .15s;
}
.footer-link-item:hover {
  color: var(--text); text-decoration: underline;
}
.footer-copy {
  color: var(--muted); font-size: 12.5px;
}
.page-head { margin-bottom: 18px; }
.page-title { font-size: 26px; margin-bottom: 4px; }
.section-title { font-size: 17px; margin-bottom: 14px; }
.hint-bar {
  background: rgba(99, 102, 241, .08); border: 1px solid rgba(99, 102, 241, .25);
  border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13.5px;
  color: #b8bfdd; margin-bottom: 16px; line-height: 1.7;
}

/* ---------- 表单 ---------- */
.field-label { display: block; font-size: 13.5px; color: var(--muted); margin: 16px 0 7px; font-weight: 500; }
.field-label:first-child { margin-top: 0; }
.input {
  width: 100%; background: var(--panel2); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius-sm); padding: 10px 13px;
  font-size: 14.5px; outline: none; transition: border .15s;
}
.input:focus { border-color: var(--primary); }
.input::placeholder { color: #5a6072; }
textarea.input { resize: vertical; font-family: inherit; }
select.input { appearance: auto; }
.check-line { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; margin-top: 10px; cursor: pointer; }
.code-row { display: flex; gap: 10px; }
.code-row .input { flex: 1; }
.code-row .btn { flex: 0 0 auto; white-space: nowrap; }
.ts-box { margin-top: 14px; }
.ts-box .cf-turnstile { transform-origin: left; }
.check-line input { accent-color: var(--primary); width: 16px; height: 16px; }

/* ---------- 生图页 ---------- */
.draw-grid {
  display: grid; grid-template-columns: 420px 1fr; gap: 20px;
  align-items: start;
}
.form-card { position: sticky; top: 80px; }
.form-title { font-size: 22px; margin-bottom: 6px; }
.announce {
  background: rgba(245, 158, 11, .1); border: 1px solid rgba(245, 158, 11, .35);
  color: #fcd34d; border-radius: var(--radius-sm); padding: 9px 13px;
  font-size: 13.5px; margin: 10px 0;
}
.prompt-wrap textarea {
  width: 100%; min-height: 110px; background: var(--panel2);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); padding: 12px 14px; font-size: 14.5px; resize: vertical;
  outline: none; font-family: inherit;
}
.prompt-wrap textarea:focus { border-color: var(--primary); }
.prompt-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: var(--panel2); border: 1px solid var(--border); color: var(--muted);
  border-radius: 999px; padding: 6px 15px; font-size: 13.5px; cursor: pointer;
  transition: all .15s;
}
.chip:hover { color: var(--text); border-color: #3a4157; }
.chip.active {
  background: linear-gradient(135deg, rgba(99, 102, 241, .25), rgba(168, 85, 247, .25));
  border-color: var(--primary); color: #c3c9ff;
}
.count-input-wrap {
  display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13.5px;
}
.count-input-wrap input {
  width: 64px; background: var(--panel2); border: 1px solid var(--border);
  color: var(--text); border-radius: 999px; padding: 5px 6px 5px 14px;
  font-size: 13.5px; outline: none; -moz-appearance: textfield;
}
.count-input-wrap input:focus { border-color: var(--primary); }
.count-input-wrap input::-webkit-outer-spin-button,
.count-input-wrap input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.model-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.model-card {
  position: relative; background: var(--panel2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px; cursor: pointer;
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
  color: var(--text); transition: all .15s; text-align: left;
}
.model-card:hover { border-color: #3a4157; }
.model-card.active {
  border-color: var(--primary);
  background: linear-gradient(135deg, rgba(99, 102, 241, .16), rgba(168, 85, 247, .16));
}
.model-name { font-weight: 600; font-size: 14.5px; }
.model-price { font-size: 12.5px; color: var(--muted); }
.model-tag {
  position: absolute; top: 8px; right: 10px; font-size: 10.5px;
  color: var(--muted); background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; padding: 1px 7px;
}
.ref-box { display: flex; gap: 12px; align-items: stretch; }
.ref-add {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1.5px dashed var(--border); border-radius: var(--radius-sm);
  padding: 13px 20px; color: var(--muted); font-size: 13.5px; cursor: pointer;
  background: var(--panel2); transition: all .15s ease; user-select: none;
  min-height: 86px; min-width: 130px;
}
.ref-add:hover { border-color: var(--primary); color: var(--text); }
.ref-add-icon { font-size: 16px; font-weight: 700; line-height: 1; color: var(--primary); }
.ref-add-text { white-space: nowrap; }
.ref-add.ref-add-slim {
  flex-direction: column; gap: 4px; padding: 10px 16px; font-size: 12.5px;
}
.ref-add.ref-add-slim .ref-add-icon { font-size: 14px; opacity: .7; }
.ref-preview {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--panel2); padding: 4px; box-shadow: 0 4px 16px rgba(0, 0, 0, .25);
  min-width: 86px; min-height: 86px;
}
.ref-preview img {
  width: 78px; height: 78px; object-fit: cover; border-radius: 8px; display: block;
}
.ref-remove {
  position: absolute; top: -8px; right: -8px; width: 22px; height: 22px;
  border-radius: 50%; background: var(--danger); color: #fff; border: 2px solid var(--panel);
  cursor: pointer; font-size: 11px; line-height: 1; display: flex; align-items: center; justify-content: center;
  transition: transform .15s, background .15s;
}
.ref-remove:hover {
  background: #dc2626; transform: scale(1.1);
}
#btn-generate { margin-top: 20px; }
.cost-hint { text-align: center; color: #b8bfdd; font-size: 13px; margin-top: 10px; min-height: 20px; }

/* 生成结果区 */
.result-card { min-height: 480px; display: flex; flex-direction: column; gap: 16px; }
.gen-status { text-align: center; padding: 60px 20px; }
.gen-status .spinner {
  width: 44px; height: 44px; margin: 0 auto 14px;
  border: 3px solid var(--panel2); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.result-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.result-grid:empty { display: none; }
.result-item {
  border-radius: var(--radius-sm); overflow: hidden; cursor: pointer;
  border: 1px solid var(--border); position: relative;
  animation: pop .4s ease;
}
@keyframes pop { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: scale(1); } }
.result-item img { width: 100%; display: block; }
.empty-hint { text-align: center; color: var(--muted); padding: 90px 20px; font-size: 15px; }
.recent-card { margin-top: 20px; }
.recent-strip { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; }
.recent-thumb { flex: 0 0 auto; width: 110px; height: 110px; border-radius: var(--radius-sm); overflow: hidden; cursor: pointer; border: 1px solid var(--border); }
.recent-thumb img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- 画廊 / 历史 ---------- */
.sort-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.sort-tab {
  padding: 7px 18px; border-radius: 999px; font-size: 14px; color: var(--muted);
  border: 1px solid var(--border);
}
.sort-tab:hover { text-decoration: none; color: var(--text); }
.sort-tab.active {
  background: linear-gradient(135deg, rgba(99, 102, 241, .25), rgba(168, 85, 247, .25));
  border-color: var(--primary); color: #c3c9ff;
}
.gallery-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px;
}
.g-card {
  position: relative; border-radius: var(--radius-sm); overflow: hidden;
  cursor: pointer; border: 1px solid var(--border); background: var(--panel2);
  aspect-ratio: 1; transition: transform .15s, border-color .15s;
}
.g-card:hover { transform: translateY(-3px); border-color: #3a4157; }
.g-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.g-overlay {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: linear-gradient(transparent, rgba(5, 7, 12, .85));
  padding: 26px 12px 9px; display: flex; justify-content: space-between;
  align-items: flex-end; font-size: 12.5px;
}
.g-user { color: #cdd2e1; max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-likes { color: #f9a8d4; }
.g-likes.liked { color: #f43f5e; }
.pager { display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 22px; }

/* ---------- 代码块（API 文档） ---------- */
.code-block {
  background: #0d1017; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px 16px; font-size: 12.5px; line-height: 1.7; overflow-x: auto;
  color: #c9d1e9; font-family: ui-monospace, SFMono-Regular, Consolas, "Courier New", monospace;
  white-space: pre; margin-bottom: 10px;
}

/* ---------- 邀请页 / 注册页 ---------- */
.ref-banner {
  background: rgba(34, 197, 94, .1); border: 1px solid rgba(34, 197, 94, .4);
  color: #86efac; border-radius: var(--radius-sm); padding: 10px 14px;
  font-size: 13.5px; margin-bottom: 16px;
}
.reward-badges { display: flex; gap: 12px; margin: 18px 0; }
.reward-badge {
  flex: 1; background: linear-gradient(135deg, rgba(99, 102, 241, .12), rgba(168, 85, 247, .12));
  border: 1px solid rgba(99, 102, 241, .35); border-radius: var(--radius-sm);
  padding: 16px; text-align: center;
}
.reward-num { display: block; font-size: 24px; font-weight: 800; color: #a5b0ff; }
.reward-label { display: block; color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.invite-stats { display: flex; gap: 12px; margin-top: 20px; }
.invite-stats .stat-item {
  flex: 1; background: var(--panel2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px; text-align: center;
}
.invite-stats .stat-item b { display: block; font-size: 20px; }
.invite-stats .stat-item span { color: var(--muted); font-size: 12.5px; }

/* ---------- 灯箱 ---------- */
.viewer { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.viewer[hidden] { display: none; }
.viewer-mask { position: absolute; inset: 0; background: rgba(3, 5, 10, .88); backdrop-filter: blur(6px); }
.viewer-box {
  position: relative; max-width: min(1080px, 94vw); max-height: 92vh;
  display: flex; flex-direction: column; gap: 12px; z-index: 1;
}
.viewer-close {
  position: absolute; top: -14px; right: -14px; z-index: 2;
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--panel); color: var(--text); cursor: pointer; font-size: 14px;
}
.viewer-img-wrap {
  max-height: 68vh; display: flex; justify-content: center;
}
.viewer-img-wrap img { max-width: 100%; max-height: 68vh; border-radius: var(--radius); object-fit: contain; }
.viewer-info {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
}
.viewer-prompt { font-size: 14px; margin-bottom: 8px; word-break: break-all; max-height: 88px; overflow-y: auto; }
.viewer-meta { color: var(--muted); font-size: 12.5px; margin-bottom: 12px; }
.viewer-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- 登录注册 ---------- */
.auth-card { margin-top: 40px; padding: 30px 28px; }
.auth-title { font-size: 24px; margin-bottom: 4px; }
.auth-sub { color: var(--muted); font-size: 14px; margin-bottom: 22px; }
.auth-foot { margin-top: 18px; text-align: center; color: var(--muted); font-size: 14px; }
.auth-card .btn-block { margin-top: 24px; }

/* ---------- 错误页 ---------- */
.error-box { text-align: center; padding: 90px 20px; }
.error-code { font-size: 64px; font-weight: 700; background: linear-gradient(135deg, var(--primary), var(--primary2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.error-msg { color: var(--muted); margin: 12px 0 28px; }

/* ---------- 管理后台 ---------- */
.admin-body .page { max-width: none; padding: 0; }
.admin-wrap { display: flex; min-height: calc(100vh - 60px); max-width: 1440px; margin: 0 auto; width: 100%; }
.admin-side {
  width: 220px; flex: 0 0 auto; border-right: 1px solid var(--border);
  padding: 22px 14px; background: rgba(17, 20, 29, .6);
}
.admin-side-brand {
  display: flex; justify-content: space-between; align-items: center;
  font-weight: 700; font-size: 16px; padding: 0 10px 18px;
  border-bottom: 1px solid var(--border); margin-bottom: 14px;
}
.admin-side-brand span { display: block; font-size: 12px; color: var(--muted); font-weight: 400; margin-top: 3px; }
.admin-nav-toggle {
  display: none; background: var(--panel2); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; padding: 5px 10px; font-size: 16px;
  cursor: pointer; line-height: 1;
}
.admin-nav { display: flex; flex-direction: column; gap: 2px; }
.admin-nav-group {
  color: var(--muted); font-size: 11px; padding: 14px 14px 5px; letter-spacing: 1.5px;
  text-transform: uppercase; font-weight: 600;
}
.admin-nav-group:first-child { padding-top: 4px; }
.admin-nav a {
  color: var(--muted); padding: 9px 14px 9px 22px; border-radius: var(--radius-sm);
  font-size: 14px; transition: all .15s;
}
.admin-nav a:hover { color: var(--text); background: var(--panel2); text-decoration: none; }
.admin-nav a.active { background: linear-gradient(135deg, rgba(99, 102, 241, .2), rgba(168, 85, 247, .2)); color: #c3c9ff; }
.admin-back { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 16px; }
.admin-main { flex: 1; padding: 26px 30px 60px; min-width: 0; }
.admin-h1 { font-size: 22px; margin-bottom: 20px; }
.admin-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.admin-head .admin-h1 { margin-bottom: 0; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.stat-num { font-size: 26px; font-weight: 700; }
.stat-label { color: var(--muted); font-size: 13px; margin-top: 3px; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; color: var(--muted); font-weight: 500; padding: 9px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid rgba(38, 44, 61, .55); vertical-align: middle; }
.table tbody tr:hover { background: rgba(99, 102, 241, .05); }
.table .clip { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table .ops { white-space: nowrap; }
.table .ops .btn { margin: 2px 2px; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.cell-price { cursor: pointer; text-decoration: underline dotted rgba(139, 146, 167, .7); }
.fc-list {
  max-height: 300px; overflow-y: auto; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 12px;
  display: flex; flex-direction: column; gap: 6px; background: var(--panel2);
}
.fc-list label { display: flex; align-items: center; gap: 10px; font-size: 13.5px; cursor: pointer; }
.fc-list input { accent-color: var(--primary); width: 15px; height: 15px; }
.fc-list code { background: transparent; border: none; padding: 0; }
.row-disabled { opacity: .55; }
.badge {
  display: inline-block; font-size: 11.5px; padding: 2px 9px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--muted); white-space: nowrap;
}
.badge-done { background: rgba(34, 197, 94, .12); border-color: rgba(34, 197, 94, .4); color: #86efac; }
.badge-failed { background: rgba(239, 68, 68, .12); border-color: rgba(239, 68, 68, .4); color: #fca5a5; }
.badge-processing { background: rgba(245, 158, 11, .12); border-color: rgba(245, 158, 11, .4); color: #fcd34d; }
.search-bar { display: flex; gap: 10px; margin-bottom: 16px; max-width: 420px; }
.filter-bar { display: flex; gap: 8px; margin-bottom: 14px; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 4px 22px; }
.settings-full, .dlg-full { grid-column: 1 / -1; }
.dlg {
  background: var(--panel); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; width: min(460px, 92vw);
}
.dlg-wide { width: min(720px, 94vw); }
.dlg::backdrop { background: rgba(3, 5, 10, .8); backdrop-filter: blur(4px); }
.dlg-title { font-size: 17px; margin-bottom: 6px; }
.dlg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 18px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* ---------- Toast ---------- */
#toast-wrap {
  position: fixed; top: 72px; left: 50%; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.toast {
  background: var(--panel); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: 11px 20px; font-size: 14px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .45); animation: pop .25s ease;
  max-width: 80vw; word-break: break-all;
}
.toast-error { border-color: rgba(239, 68, 68, .5); }
.toast-ok { border-color: rgba(34, 197, 94, .5); }

/* ---------- 对话页 ---------- */
.chat-layout {
  display: grid; grid-template-columns: 240px 1fr; gap: 16px; min-height: calc(100vh - 200px);
  align-items: stretch;
}
.chat-sidebar { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.chat-conv-list { display: flex; flex-direction: column; gap: 4px; overflow-y: auto; flex: 1; }
.chat-conv-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-radius: var(--radius-sm); cursor: pointer;
  color: var(--muted); font-size: 13.5px; transition: background .12s;
}
.chat-conv-item:hover { background: var(--panel2); color: var(--text); }
.chat-conv-item.active {
  background: linear-gradient(135deg, rgba(99, 102, 241, .15), rgba(168, 85, 247, .15));
  color: #c3c9ff;
}
.chat-conv-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.chat-conv-del {
  background: transparent; border: none; color: var(--muted); cursor: pointer;
  font-size: 14px; padding: 2px; border-radius: 4px; opacity: 0; transition: opacity .12s;
}
.chat-conv-item:hover .chat-conv-del { opacity: 1; }
.chat-conv-del:hover { color: var(--danger); }
.chat-main {
  display: flex; flex-direction: column; padding: 0; overflow: hidden;
}
.chat-model-bar {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  border-bottom: 1px solid var(--border); background: rgba(26, 30, 43, .45);
}
.chat-model-options { display: flex; gap: 8px; overflow-x: auto; flex: 1; }
.chat-model-card {
  min-width: 130px; width: auto; padding: 7px 11px; flex-direction: row;
  align-items: center; justify-content: space-between; gap: 10px;
}
.chat-model-card .model-name { font-size: 13px; }
.chat-model-card .model-price { white-space: nowrap; }
.chat-messages {
  flex: 1; overflow-y: auto; padding: 20px;
  display: flex; flex-direction: column; gap: 14px;
}
.chat-msg { display: flex; gap: 10px; align-items: flex-start; }
.chat-msg-user { flex-direction: row-reverse; }
.chat-msg-avatar {
  width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 16px; background: var(--panel2); flex: 0 0 auto;
}
.chat-msg-bubble {
  max-width: 75%; padding: 11px 16px; border-radius: 14px; font-size: 14.5px;
  white-space: pre-wrap; word-break: break-word; line-height: 1.65;
}
.chat-msg-user .chat-msg-bubble {
  background: linear-gradient(135deg, var(--primary), var(--primary2)); color: #fff;
}
.chat-msg-assistant .chat-msg-bubble {
  background: var(--panel2); color: var(--text); border: 1px solid var(--border);
}
.chat-input-row {
  display: flex; gap: 10px; padding: 14px 16px; border-top: 1px solid var(--border);
}
.chat-input-row textarea {
  flex: 1; background: var(--panel2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: 10px 14px; font-size: 14.5px;
  resize: none; outline: none; font-family: inherit; min-height: 44px;
}
.chat-input-row textarea:focus { border-color: var(--primary); }
.chat-footer { padding: 0 16px 10px; text-align: center; }

/* ---------- 文学创作 ---------- */
.writing-result { display: flex; flex-direction: column; gap: 12px; }
.writing-actions { display: flex; gap: 8px; justify-content: flex-end; }
.writing-text {
  background: var(--panel2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 20px 22px; font-size: 14.5px; line-height: 1.85; color: var(--text);
  white-space: pre-wrap; word-break: break-word; max-height: 70vh; overflow-y: auto;
  font-family: "Noto Serif SC", "Source Han Serif SC", serif;
}

@media (max-width: 760px) {
  .chat-layout { grid-template-columns: 1fr; }
  .chat-sidebar { max-height: 180px; }
}/* ---------- 响应式 ---------- */
@media (max-width: 1024px) {
  .draw-grid { grid-template-columns: 1fr; }
  .form-card { position: static; }
}
@media (max-width: 900px) {
  .admin-wrap { flex-direction: column; }
  .admin-side { width: 100%; border-right: none; border-bottom: 1px solid var(--border); padding: 14px; }
  .admin-side-brand { padding: 0 4px 10px; margin-bottom: 0; }
  .admin-nav-toggle { display: block; }
  .admin-nav {
    display: none; flex-direction: column; gap: 2px;
    padding-top: 12px; border-top: 1px solid var(--border); margin-top: 10px;
  }
  .admin-nav.open { display: flex; }
  .admin-nav-group { padding: 10px 10px 3px; }
  .admin-nav a { padding: 9px 12px 9px 20px; }
  .admin-back { margin-top: 10px; border-top: none; padding-top: 0; }
  .admin-main { padding: 18px 14px 50px; }
  .chat-layout { grid-template-columns: 1fr; }
  .chat-sidebar { max-height: 180px; }
}
@media (max-width: 760px) {
  .topbar-inner { gap: 10px; padding: 0 12px; }
  .nav { gap: 0; }
  .nav-link { padding: 6px 8px; font-size: 13.5px; }
  .quota { display: none; }
  .table { font-size: 12.5px; }
  .table .ops .btn { margin: 1px; }
  /* 全站表格在手机上改成卡片式堆叠：每行纵向排列，不再横向溢出、裁切。
     覆盖记录页、统计页、API Key、兑换码及全部管理后台表格。 */
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: auto; }
  .table tr { padding: 12px 2px; border-bottom: 1px solid var(--border); }
  .table tr:last-child { border-bottom: none; }
  .table td { border: none; padding: 3px 8px; }
  .table .clip { max-width: none; white-space: normal; overflow: visible; text-overflow: clip; }
  .table .ops { white-space: normal; }
  .table .expand-text, .table .expand-err { max-width: 100%; }
  .table td[colspan] { text-align: center; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .model-cards { grid-template-columns: 1fr; }
  .brand { font-size: 16px; }
}
