/* ============================================================
   AI Site · 全局样式
   设计变量集中在 :root，改配色只改这里；深浅色由 [data-theme] 控制。
   ============================================================ */

:root {
  --bg: #f6f7fb;
  --bg-soft: #ffffff;
  --panel: #ffffff;
  --panel-2: #f9fafc;
  --border: #e3e8ef;
  --border-strong: #cfd8e3;
  --text: #111827;
  --text-soft: #4b5563;
  --muted: #6b7280;
  --muted-2: #9aa3af;
  --accent: #4f46e5;
  --accent-strong: #4338ca;
  --accent-soft: rgba(79, 70, 229, 0.1);
  --accent-ink: #ffffff;
  --ok: #059669;
  --ok-soft: rgba(5, 150, 105, 0.12);
  --warn: #b45309;
  --warn-soft: rgba(180, 83, 9, 0.12);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.1);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 7px;
  --shadow: 0 12px 32px rgba(17, 24, 39, 0.08);
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.06);
  --mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, sans-serif;
}

[data-theme='dark'] {
  --bg: #0b1020;
  --bg-soft: #0f1526;
  --panel: #131a2c;
  --panel-2: #172033;
  --border: #243049;
  --border-strong: #33415c;
  --text: #e8edf7;
  --text-soft: #c3ccdd;
  --muted: #94a3b8;
  --muted-2: #6b7a90;
  --accent: #818cf8;
  --accent-strong: #a5b4fc;
  --accent-soft: rgba(129, 140, 248, 0.16);
  --accent-ink: #0b1020;
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, 0.14);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.14);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.14);
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4 { margin: 0 0 10px; font-weight: 650; line-height: 1.3; letter-spacing: -0.01em; }
h1 { font-size: 30px; }
h2 { font-size: 22px; }
h3 { font-size: 17px; }
p { margin: 0 0 10px; }

code, pre { font-family: var(--mono); font-size: 13px; }

/* 行内代码（后台状态行用） */
.code-inline {
  font-family: var(--mono); font-size: 12px; padding: 2px 7px; border-radius: 6px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
}

/* ------------------------------ 通用组件 ------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.06s;
  white-space: nowrap;
}
.btn:hover { background: var(--panel-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--panel-2); }
.btn-danger { border-color: var(--danger); color: var(--danger); background: transparent; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-lg { padding: 11px 22px; font-size: 15px; }
.btn-block { width: 100%; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; margin-bottom: 6px; font-size: 12.5px; color: var(--text-soft); font-weight: 550; }
.input, .select, .textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  background: var(--bg-soft);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.textarea { resize: vertical; min-height: 90px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 5px; }

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge-accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card-pad { padding: 18px 20px; }
.card-title { font-size: 15px; font-weight: 650; margin-bottom: 4px; }
.card-sub { font-size: 12.5px; color: var(--muted); }

.spacer { flex: 1 1 auto; }
.row { display: flex; align-items: center; gap: 8px; }
.row-wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); }
.center { text-align: center; }
.hidden { display: none !important; }

/* ------------------------------ 顶栏 / 导航 ------------------------------ */

.site-head {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 24px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 15.5px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #06b6d4);
  color: #fff; font-size: 15px; font-weight: 800;
}
.head-links { display: flex; align-items: center; gap: 4px; }
.head-user-email { max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.head-link {
  padding: 6px 11px; border-radius: var(--radius-xs);
  color: var(--text-soft); font-size: 13.5px;
}
.head-link:hover { background: var(--panel-2); text-decoration: none; color: var(--text); }
.head-link.is-active { color: var(--accent); background: var(--accent-soft); }

.lang-switch { display: inline-flex; align-items: center; }
/* 语言下拉：5 种语言用按钮太挤，统一用一个紧凑的 select */
.lang-select {
  width: auto; min-width: 104px; max-width: 150px;
  padding: 5px 10px; font-size: 12.5px; border-radius: 999px;
  background: var(--panel); cursor: pointer;
}

.icon-btn {
  width: 34px; height: 34px; display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: var(--radius-xs);
  background: var(--panel); color: var(--text-soft); cursor: pointer; font-size: 15px;
}
.icon-btn:hover { background: var(--panel-2); }

/* ------------------------------ 落地页 ------------------------------ */

.hero { max-width: 1080px; margin: 0 auto; padding: 68px 24px 34px; text-align: center; }
.hero-kicker {
  display: inline-block; margin-bottom: 18px; padding: 5px 13px;
  border-radius: 99px; background: var(--accent-soft); color: var(--accent);
  font-size: 12.5px; font-weight: 600;
}
.hero h1 { font-size: clamp(30px, 4.6vw, 50px); letter-spacing: -0.025em; margin-bottom: 16px; }
.hero h1 em { font-style: normal; background: linear-gradient(120deg, var(--accent), #06b6d4); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p.lead { max-width: 620px; margin: 0 auto 26px; font-size: 16.5px; color: var(--muted); }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.hero-note { margin-top: 14px; font-size: 12.5px; color: var(--muted-2); }

.features { max-width: 1080px; margin: 0 auto; padding: 26px 24px 60px; display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.feature { padding: 20px; }
.feature-icon {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-size: 18px; margin-bottom: 12px;
}
.feature h3 { margin-bottom: 6px; }
.feature p { margin: 0; font-size: 13px; color: var(--muted); }

.steps { max-width: 1080px; margin: 0 auto; padding: 10px 24px 70px; }
.steps-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-top: 18px; }
.step { padding: 16px 18px; }
.step-num { font-size: 12px; font-weight: 700; color: var(--accent); }

.site-foot {
  border-top: 1px solid var(--border);
  padding: 22px 24px;
  color: var(--muted-2);
  font-size: 12.5px;
  display: flex; gap: 14px; align-items: center; flex-wrap: wrap;
  max-width: 1080px; margin: 0 auto;
}

.announce {
  max-width: 1080px; margin: 16px auto 0; padding: 10px 14px;
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: var(--radius-xs); background: var(--panel); font-size: 13px;
}

/* ------------------------------ 认证页 ------------------------------ */

.auth-wrap { min-height: 100%; display: grid; place-items: center; padding: 40px 18px; }
.auth-card { width: min(420px, 100%); padding: 28px 26px; }
.auth-card h1 { font-size: 23px; margin-bottom: 6px; }
.auth-card .sub { color: var(--muted); font-size: 13.5px; margin-bottom: 20px; }
.auth-alt { margin-top: 16px; font-size: 13px; color: var(--muted); text-align: center; }
.form-msg { margin-bottom: 12px; padding: 9px 12px; border-radius: var(--radius-xs); font-size: 13px; }
.form-msg.err { background: var(--danger-soft); color: var(--danger); }
.form-msg.ok { background: var(--ok-soft); color: var(--ok); }

/* ------------------------------ 聊天页 ------------------------------ */

.chat-shell { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: 268px; flex: 0 0 268px; display: flex; flex-direction: column;
  border-right: 1px solid var(--border); background: var(--panel-2);
}
.sidebar-head { padding: 14px; display: flex; align-items: center; gap: 8px; }
.sidebar-body { flex: 1 1 auto; overflow-y: auto; padding: 8px; }
.sidebar-foot { padding: 10px; border-top: 1px solid var(--border); }
.sidebar-label { padding: 6px 8px; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted-2); }
.conv-item {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 10px; border-radius: var(--radius-xs);
  color: var(--text-soft); cursor: pointer; font-size: 13.5px;
}
.conv-item:hover { background: var(--panel); }
.conv-item.is-active { background: var(--panel); color: var(--text); box-shadow: var(--shadow-sm); }
.conv-title { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-del { opacity: 0; border: 0; background: transparent; color: var(--muted-2); cursor: pointer; font-size: 13px; padding: 2px 4px; border-radius: 5px; }
.conv-item:hover .conv-del { opacity: 1; }
.conv-del:hover { color: var(--danger); background: var(--danger-soft); }
.user-box { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: var(--radius-xs); }
.user-box:hover { background: var(--panel); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 12px; flex: 0 0 auto;
}
.user-email { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chat-main { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; }
.chat-head {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  border-bottom: 1px solid var(--border); background: var(--panel);
}
.chat-head .model-select { max-width: 260px; }
.quota-pill { font-size: 12px; color: var(--muted); white-space: nowrap; }

.messages { flex: 1 1 auto; overflow-y: auto; padding: 22px 16px 8px; }
.msg-wrap { max-width: 820px; margin: 0 auto 18px; display: flex; gap: 10px; }
.msg-wrap.user { flex-direction: row-reverse; }
.msg-avatar {
  width: 30px; height: 30px; border-radius: 9px; flex: 0 0 auto;
  display: grid; place-items: center; font-size: 14px;
  background: var(--accent-soft); color: var(--accent);
}
.msg-wrap.user .msg-avatar { background: var(--panel-2); color: var(--muted); }
.msg-bubble {
  padding: 11px 14px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--border);
  font-size: 14.5px; line-height: 1.72; max-width: min(660px, 100%);
  overflow-wrap: anywhere;
}
.msg-wrap.user .msg-bubble { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.msg-bubble > *:last-child { margin-bottom: 0; }
.msg-bubble p { margin: 0 0 9px; }
.msg-bubble h1, .msg-bubble h2, .msg-bubble h3 { margin: 14px 0 7px; font-size: 1.05em; }
.msg-bubble ul, .msg-bubble ol { margin: 6px 0 10px; padding-left: 22px; }
.msg-bubble li { margin: 3px 0; }
.msg-bubble blockquote {
  margin: 8px 0; padding: 6px 12px; border-left: 3px solid var(--border-strong);
  color: var(--muted); background: var(--panel-2); border-radius: 0 8px 8px 0;
}
.msg-bubble code { background: var(--panel-2); padding: 1px 5px; border-radius: 5px; font-size: 0.92em; }
.msg-wrap.user .msg-bubble code { background: rgba(255,255,255,0.18); }
.msg-bubble pre {
  position: relative; margin: 10px 0; padding: 12px 14px; overflow-x: auto;
  background: #0f172a; color: #e2e8f0; border-radius: 10px; font-size: 12.5px; line-height: 1.6;
}
.msg-bubble pre code { background: transparent; padding: 0; color: inherit; }
.code-copy {
  position: absolute; top: 6px; right: 8px; padding: 2px 8px;
  border: 1px solid rgba(255,255,255,0.22); border-radius: 6px;
  background: rgba(255,255,255,0.08); color: #cbd5e1; font-size: 11px; cursor: pointer;
}
.msg-meta { margin-top: 6px; font-size: 11.5px; color: var(--muted-2); }
.msg-error { color: var(--danger); font-size: 13px; }

.typing-dot { display: inline-block; width: 7px; height: 7px; margin-right: 3px; border-radius: 50%; background: var(--muted-2); animation: blink 1.2s infinite; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

.composer { padding: 10px 16px 18px; }
.composer-inner {
  max-width: 820px; margin: 0 auto; display: flex; gap: 8px; align-items: flex-end;
  padding: 8px; border: 1px solid var(--border-strong); border-radius: 16px;
  background: var(--panel); box-shadow: var(--shadow-sm);
}
.composer-inner:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer textarea {
  flex: 1 1 auto; border: 0; outline: none; resize: none; background: transparent; color: var(--text);
  font: inherit; font-size: 14.5px; line-height: 1.6; max-height: 180px; padding: 6px 4px;
}
.composer-foot { max-width: 820px; margin: 8px auto 0; display: flex; gap: 10px; align-items: center; font-size: 11.5px; color: var(--muted-2); }

/* ------------------------------ 附件 ------------------------------ */

.attach-btn { flex: 0 0 auto; align-self: flex-end; margin-bottom: 2px; }
.composer.is-drag .composer-inner { border-color: var(--accent); background: var(--accent-soft); }
.attach-tray { max-width: 820px; margin: 0 auto 8px; display: flex; gap: 8px; flex-wrap: wrap; }
.attach-chip {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; max-width: 280px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--panel);
}
.attach-chip.is-error { border-color: var(--danger); }
.attach-thumb {
  width: 34px; height: 34px; flex: 0 0 auto; border-radius: 6px; overflow: hidden;
  display: grid; place-items: center; background: var(--panel-2); font-size: 17px;
}
.attach-thumb img { width: 100%; height: 100%; object-fit: cover; }
.attach-info { display: flex; flex-direction: column; min-width: 0; }
.attach-name { font-size: 12px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-meta { font-size: 10.5px; color: var(--muted); }
.attach-warn { font-size: 10px; color: var(--warn); }
.attach-remove { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 12px; padding: 2px; }

.msg-text { white-space: pre-wrap; word-break: break-word; }
.msg-attachments { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.attach-images { display: flex; gap: 6px; flex-wrap: wrap; }
.attach-image img { display: block; max-width: 220px; max-height: 180px; border-radius: 10px; }
.file-card {
  display: flex; align-items: center; gap: 8px; max-width: 340px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--panel);
  text-decoration: none; color: inherit;
}
.file-card:hover { border-color: var(--accent); }
.file-icon { font-size: 16px; }
.file-name { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { margin-left: auto; font-size: 10.5px; color: var(--muted); white-space: nowrap; }

.empty-state { max-width: 620px; margin: 8vh auto 0; text-align: center; padding: 0 18px; }
.empty-state h2 { font-size: 24px; }
.empty-state p { color: var(--muted); }
.suggest-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-top: 22px; text-align: left; }
.suggest {
  padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--panel); cursor: pointer; font-size: 13px; color: var(--text-soft);
}
.suggest:hover { border-color: var(--accent); color: var(--text); }

/* ------------------------------ 设置 / 文档 ------------------------------ */

.page { max-width: 860px; margin: 0 auto; padding: 28px 20px 60px; }
.page-head { margin-bottom: 20px; }
.page-head h1 { font-size: 24px; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.panel h2 { font-size: 16px; margin-bottom: 4px; }
.panel .panel-sub { color: var(--muted); font-size: 12.5px; margin-bottom: 16px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab {
  padding: 8px 14px; border: 0; background: transparent; color: var(--muted);
  font: inherit; font-size: 13.5px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab.is-on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.key-row, .log-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 0;
  border-bottom: 1px solid var(--border); font-size: 13px;
}
.key-row:last-child, .log-row:last-child { border-bottom: 0; }
.key-secret { font-family: var(--mono); font-size: 12.5px; background: var(--panel-2); padding: 2px 8px; border-radius: 5px; }

pre.code-block {
  background: #0f172a; color: #e2e8f0; padding: 14px 16px; border-radius: var(--radius-sm);
  overflow-x: auto; font-size: 12.5px; line-height: 1.65; margin: 10px 0;
}

/* ------------------------------ 后台 ------------------------------ */

.admin-shell { display: flex; min-height: 100vh; }
.admin-nav {
  width: 210px; flex: 0 0 210px; padding: 16px 10px;
  border-right: 1px solid var(--border); background: var(--panel-2);
  display: flex; flex-direction: column; gap: 3px;
}
.admin-nav .brand { padding: 0 8px 14px; }
.admin-link {
  padding: 8px 11px; border-radius: var(--radius-xs); color: var(--text-soft);
  font-size: 13.5px; cursor: pointer; border: 0; background: transparent; text-align: left; font-family: inherit;
}
.admin-link:hover { background: var(--panel); }
.admin-link.is-on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.admin-main { flex: 1 1 auto; min-width: 0; padding: 22px 26px 50px; }
.admin-head { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.admin-head h1 { font-size: 21px; margin: 0; }

.stat-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 18px; }
.stat { padding: 15px 16px; }
.stat-label { font-size: 12px; color: var(--muted); }
.stat-value { font-size: 25px; font-weight: 700; letter-spacing: -0.02em; margin-top: 2px; }
.stat-sub { font-size: 11.5px; color: var(--muted-2); }

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.table th {
  text-align: left; font-weight: 600; color: var(--muted); font-size: 12px;
  padding: 9px 10px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.table tr:last-child td { border-bottom: 0; }
table.table tr:hover td { background: var(--panel-2); }

.chart { display: flex; align-items: flex-end; gap: 8px; height: 132px; padding-top: 8px; }
.chart-bar { flex: 1 1 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; height: 100%; }
.chart-fill { width: 100%; max-width: 46px; border-radius: 6px 6px 2px 2px; background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 55%, transparent)); min-height: 3px; }
.chart-label { font-size: 10.5px; color: var(--muted-2); white-space: nowrap; }

/* ------------------------------ 弹窗 / 提示 ------------------------------ */

.modal-mask {
  position: fixed; inset: 0; z-index: 90; display: grid; place-items: center;
  padding: 18px; background: rgba(15, 23, 42, 0.45); backdrop-filter: blur(2px);
}
.modal {
  width: min(560px, 100%); max-height: 88vh; overflow-y: auto;
  background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow);
}
.modal-head { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 650; }
.modal-body { padding: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 13px 18px; border-top: 1px solid var(--border); }

#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 120; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 10px 14px; border-radius: var(--radius-xs); font-size: 13px;
  background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow);
  animation: toast-in 0.18s ease-out; max-width: 340px;
}
.toast.err { border-color: var(--danger); color: var(--danger); }
.toast.warn { border-color: var(--warn); color: var(--warn); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid var(--border-strong); border-top-color: var(--accent);
  animation: spin 0.7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------ 响应式 ------------------------------ */

@media (max-width: 860px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 60; transform: translateX(-100%); transition: transform 0.2s; box-shadow: var(--shadow); }
  .sidebar.is-open { transform: none; }
  .chat-head .quota-pill { display: none; }
  .admin-shell { flex-direction: column; }
  .admin-nav { width: auto; flex: 0 0 auto; flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); padding: 8px; }
  .admin-nav .brand { display: none; }
  .admin-main { padding: 16px; }
  .site-head { padding: 10px 14px; }
  .hero { padding-top: 40px; }
  .msg-bubble { max-width: 100%; }
}

/* 页面级小工具类：CSP 禁止内联 style，所以统一定义在这里 */
.boot-screen { display: flex; justify-content: center; padding: 24px; }
.mt-10 { margin-top: 10px; }
.mt-20 { margin-top: 20px; }
.mb-12 { margin-bottom: 12px; }
.h2-sm { font-size: 15px; margin-bottom: 4px; }

/* ------------------------------ 公开 API 文档页 ------------------------------ */

.api-hero { padding: 26px 0 10px; }
.api-hero h1 { font-size: clamp(26px, 3.6vw, 38px); letter-spacing: -0.02em; margin-bottom: 12px; }
.api-hero .lead { font-size: 15.5px; color: var(--muted); max-width: 640px; margin-bottom: 20px; }
.api-hero .hero-actions { justify-content: flex-start; }
.api-hero .hero-note { margin-top: 12px; }

.api-field {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; margin: 14px 0;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.api-field-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.api-field code { font-size: 13px; word-break: break-all; }

.endpoints { display: flex; flex-direction: column; gap: 2px; }
.endpoint {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13px;
}
.endpoint:last-child { border-bottom: 0; }
.endpoint code { font-size: 13px; }
.endpoint-desc { color: var(--muted); font-size: 12.5px; }
.method {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em;
  padding: 2px 7px; border-radius: 5px; background: var(--panel-2);
  border: 1px solid var(--border); color: var(--muted);
}
.method.post { background: var(--accent-soft); color: var(--accent); }
.method.get { background: var(--ok-soft); color: var(--ok); }

.api-steps { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-top: 6px; }
.api-step { padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--panel-2); }
.api-step h3 { font-size: 14px; margin: 6px 0 4px; }
.api-step p { margin: 0; font-size: 12.5px; color: var(--muted); }
.api-step .step-num { font-size: 12px; font-weight: 700; color: var(--accent); }

.code-tabs { display: flex; gap: 4px; margin-bottom: 10px; flex-wrap: wrap; }
.code-tab {
  border: 1px solid var(--border); background: transparent; color: var(--muted);
  padding: 5px 11px; border-radius: 999px; font-size: 12.5px; cursor: pointer; font-family: inherit;
}
.code-tab:hover { color: var(--text); }
.code-tab.is-on { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 600; }

.code-shell { position: relative; }
.code-shell .code-copy { position: absolute; top: 8px; right: 8px; z-index: 1; }
.code-shell pre.code-block { margin: 0; max-height: 460px; }

.pg-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.pg-row .select { max-width: 240px; }
[data-playground] .textarea { min-height: 84px; }
.api-signin { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

.bullets { margin: 0; padding-left: 20px; color: var(--muted); font-size: 13.5px; line-height: 1.7; }
.bullets li { margin-bottom: 4px; }

/* ------------------------------ 条款 / 隐私页 ------------------------------ */

.legal { max-width: 760px; line-height: 1.7; }
.legal h1 { font-size: 30px; letter-spacing: -0.02em; margin-bottom: 6px; }
.legal .lead { color: var(--text-soft); font-size: 15px; margin: 18px 0 8px; }
.legal h2 { font-size: 16px; margin: 30px 0 8px; }
.legal p, .legal li { font-size: 14px; color: var(--text-soft); }
.legal ul { padding-left: 20px; margin: 8px 0; }
.legal li { margin-bottom: 6px; }

/* ------------------------------ 预览提示弹窗 ------------------------------ */

.beta-note { font-size: 13.5px; line-height: 1.65; color: var(--text-soft); }
.beta-note p { margin: 0 0 10px; }
.beta-note ul { margin: 0 0 10px; padding-left: 18px; }
.beta-note li { margin-bottom: 6px; }
.beta-note strong { color: var(--text); }

/* ------------------------------ 画图页 ------------------------------ */

.image-controls { gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.image-controls .field { margin-bottom: 0; min-width: 130px; }
.image-controls .btn { margin-bottom: 2px; }

.image-grid {
  display: grid; gap: 16px; margin-top: 18px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.image-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column;
}

.image-canvas { display: grid; gap: 2px; background: var(--border); }
.image-canvas-1 { grid-template-columns: 1fr; }
.image-canvas-2 { grid-template-columns: 1fr 1fr; }
.image-canvas a { display: block; line-height: 0; background: var(--bg-soft, #f3f4f6); }
.image-canvas img { width: 100%; height: auto; display: block; aspect-ratio: 1 / 1; object-fit: cover; }

.image-pending {
  min-height: 220px; display: flex; flex-direction: column; gap: 8px;
  align-items: center; justify-content: center; background: var(--bg-soft, #f3f4f6);
  padding: 20px; text-align: center;
}

.image-meta { padding: 12px 14px 14px; }
.image-prompt { font-size: 13.5px; line-height: 1.5; margin-bottom: 6px; word-break: break-word; }
.image-actions { gap: 8px; margin-top: 10px; }

/* Credits chip in the chat header and the images page */
.credits-box { gap: 8px; }
.credits-pill {
  font-size: 12.5px; color: var(--text-soft); border: 1px solid var(--border);
  border-radius: 999px; padding: 4px 10px; white-space: nowrap;
}
@media (max-width: 860px) {
  .credits-box { display: none; }
}

/* ------------------------------ 客服窗口 ------------------------------ */

.support-root {
  position: fixed; right: 18px; bottom: 18px; z-index: 80;
  display: flex; flex-direction: column; align-items: flex-end; gap: 10px;
}
/* 聊天页底部是输入框，按钮抬高一点，别挡住发送 */
.support-root--raised { bottom: 96px; }

.support-launcher {
  position: relative; display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--panel); color: var(--text); font: inherit; font-size: 13px;
  cursor: pointer; box-shadow: var(--shadow);
}
.support-launcher:hover { border-color: var(--border-strong); }
.support-launcher svg { width: 18px; height: 18px; flex: 0 0 auto; }
.support-launcher.is-open { background: var(--accent); border-color: transparent; color: var(--accent-ink); }

.support-badge {
  position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: var(--danger); color: #fff;
  font-size: 11px; line-height: 18px; text-align: center; font-weight: 700;
}

.support-panel {
  width: min(384px, calc(100vw - 28px));
  max-height: min(640px, calc(100vh - 120px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  animation: support-in 0.16s ease-out;
}
.support-panel[hidden] { display: none; }
@keyframes support-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.support-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 10px 10px 16px; border-bottom: 1px solid var(--border);
}
.support-title { font-weight: 650; font-size: 14px; }
.support-body {
  padding: 14px 16px 16px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 12px;
}

.support-intro { margin: 0; font-size: 13px; line-height: 1.6; color: var(--text-soft); }
.support-mail { display: flex; align-items: center; gap: 8px; font-size: 12.5px; flex-wrap: wrap; }
.support-links { display: flex; flex-wrap: wrap; gap: 6px 12px; }
.support-link { font-size: 12.5px; }

.support-section-title {
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted-2);
}
.support-note { margin: 0; font-size: 12px; line-height: 1.55; color: var(--muted); }
.support-time { font-size: 11.5px; color: var(--muted-2); }

.support-ticket-list { display: flex; flex-direction: column; gap: 8px; }
.support-ticket {
  display: flex; flex-direction: column; gap: 4px; width: 100%; text-align: left;
  padding: 9px 11px; border-radius: var(--radius-sm); cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--border);
  color: var(--text); font: inherit;
}
.support-ticket:hover { border-color: var(--border-strong); }
.support-ticket-top { display: flex; align-items: center; gap: 7px; }
.support-ticket-subject {
  flex: 1 1 auto; min-width: 0; font-size: 13px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.support-ticket-preview {
  font-size: 12px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.support-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--danger); flex: 0 0 auto; }

.support-chip {
  font-size: 10.5px; font-weight: 600; padding: 2px 7px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--muted); white-space: nowrap;
}
.support-chip.is-open { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.support-chip.is-answered { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.support-chip.is-resolved { color: var(--ok); border-color: var(--border); }
.support-chip.is-closed { color: var(--muted-2); }

.support-form { display: flex; flex-direction: column; gap: 10px; }
.support-form .field { margin: 0; }
.support-form .textarea { min-height: 96px; }
.support-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

.support-created { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; padding: 8px 0; }
.support-created h3 { margin: 0; font-size: 15px; }
.support-ok {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  background: var(--ok-soft); color: var(--ok); font-size: 22px; font-weight: 700;
}
.support-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 19px; letter-spacing: 0.1em; }

.support-ticket-head { display: flex; align-items: center; gap: 8px; }
.support-code-sm { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--muted-2); }

.support-msgs { display: flex; flex-direction: column; gap: 10px; }
.support-msg {
  max-width: 90%; padding: 8px 11px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--border);
}
.support-msg.is-user { align-self: flex-end; background: var(--accent-soft); border-color: transparent; }
.support-msg-meta { font-size: 10.5px; color: var(--muted-2); margin-bottom: 3px; }
.support-msg-text { font-size: 13px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }

.support-reply { min-height: 74px; }

.nowrap { white-space: nowrap; }

/* 后台工单详情 */
.ticket-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-bottom: 12px; font-size: 12px; color: var(--muted); }
.ticket-thread { display: flex; flex-direction: column; gap: 10px; max-height: 320px; overflow-y: auto; padding: 4px 2px 10px; }
.ticket-msg { max-width: 92%; padding: 8px 11px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--border); }
.ticket-msg.is-admin { align-self: flex-end; background: var(--accent-soft); border-color: transparent; }
.ticket-msg-meta { font-size: 10.5px; color: var(--muted-2); margin-bottom: 3px; }
.ticket-msg-text { font-size: 13px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }

@media (max-width: 520px) {
  .support-root { right: 12px; bottom: 12px; }
  .support-root--raised { bottom: 92px; }
  .support-launcher { padding: 10px 13px; }
  .support-launcher-text { display: none; }
  .support-panel { max-height: calc(100vh - 96px); }
}
