/* ===== Grok Studio 全局样式（夜间 / 白天双主题）===== */
:root {
  --bg: #0b0e14;
  --bg-2: #10141d;
  --bg-3: #161b26;
  --border: #232a38;
  --border-2: #2d3648;
  --text: #e6e9f0;
  --text-dim: #8b93a7;
  --accent: #6c8cff;
  --accent-2: #8b5cf6;
  --green: #34d399;
  --red: #f87171;
  --yellow: #fbbf24;
  --radius: 12px;
  --sidebar-w: 240px;
  --shadow-lg: 0 24px 80px rgba(0,0,0,.55);
  --topbar-bg: rgba(11,14,20,.75);
  --code-bg: #0a0d13;
  --card-hover-shadow: 0 12px 30px rgba(0,0,0,.35);
}
/* 白天模式 */
html[data-theme="light"] {
  --bg: #f3f5f9;
  --bg-2: #ffffff;
  --bg-3: #eef1f6;
  --border: #dde3ec;
  --border-2: #cbd4e1;
  --text: #1c2333;
  --text-dim: #66708a;
  --accent: #4f6ef7;
  --accent-2: #7c3aed;
  --green: #10b981;
  --red: #ef4444;
  --yellow: #d97706;
  --shadow-lg: 0 24px 70px rgba(31,45,80,.18);
  --topbar-bg: rgba(255,255,255,.8);
  --code-bg: #f0f3f8;
  --card-hover-shadow: 0 12px 28px rgba(35,45,80,.14);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
:root { color-scheme: dark; }
html[data-theme="light"] { color-scheme: light; }
::selection { background: rgba(108,140,255,.32); }
button:focus-visible, a:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid rgba(108,140,255,.55); outline-offset: 2px; border-radius: 6px;
}
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  overflow: hidden;
}
#app { height: 100vh; }
a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select {
  font-family: inherit;
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:hover, textarea:hover, select:hover { border-color: var(--border-2); }
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108,140,255,.13);
}
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--accent) 40%, var(--border-2)); }
::-webkit-scrollbar-track { background: transparent; }
html[data-theme="light"] ::-webkit-scrollbar-thumb { background: #c4ccdb; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--bg-3); color: var(--text);
  border: 1px solid var(--border-2); border-radius: 9px;
  padding: 9px 16px; font-size: 14px; transition: all .15s;
}
.btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.btn:active { transform: scale(.97); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none; color: #fff; font-weight: 600;
}
.btn.primary:hover { opacity: 1; box-shadow: 0 6px 18px rgba(108,140,255,.32); }
.btn.danger { color: var(--red); }
.btn.danger:hover { background: rgba(248,113,113,.1); border-color: var(--red); }
.btn.small { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

/* ===== 布局 ===== */
.layout { display: flex; height: 100vh; }
.sidebar {
  width: var(--sidebar-w); min-width: var(--sidebar-w);
  background: var(--bg-2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow-y: auto; overflow-x: hidden;
  transition: width .2s ease, min-width .2s ease;
}
.sidebar.collapsed { width: 68px; min-width: 68px; }
.logo {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 14px 14px;
  font-size: 17px; font-weight: 700; letter-spacing: .3px;
}
.logo .mark {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; color: #fff;
}
.logo .logo-text { flex: 1; min-width: 0; white-space: nowrap; }
.side-toggle {
  width: 24px; height: 24px; border-radius: 7px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-3); border: 1px solid var(--border-2); color: var(--text-dim);
  font-size: 13px; line-height: 1; cursor: pointer; transition: all .15s;
}
.side-toggle:hover { color: var(--accent); border-color: var(--accent); }
/* 收起态：Logo 与切换按钮纵向居中排布，避免横向挤压 */
.sidebar.collapsed .logo { flex-direction: column; justify-content: center; gap: 10px; padding: 16px 6px 12px; }
.sidebar.collapsed .logo .logo-text { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px 0; }
.sidebar.collapsed .nav-item .txt { display: none; }
.sidebar.collapsed .nav-section { display: none; }
/* 收起态隐藏余额徽章：长数字在 68px 宽度内必然溢出，展开后恢复显示 */
.sidebar.collapsed .quota-chip { display: none; }
.sidebar.collapsed .user-chip { flex-direction: column; gap: 8px; padding: 9px 4px; }
.nav { padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 9px;
  color: var(--text-dim); cursor: pointer; font-size: 14px;
  transition: all .13s; user-select: none; position: relative;
}
.nav-item::before {
  content: ''; position: absolute; left: -10px; top: 22%; bottom: 22%;
  width: 3px; border-radius: 3px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  opacity: 0; transition: opacity .15s;
}
.nav-item.active::before { opacity: 1; }
.nav-item:hover { background: var(--bg-3); color: var(--text); }
.nav-item.active { background: rgba(108,140,255,.13); color: var(--accent); font-weight: 600; }
.nav-item .ico { width: 20px; text-align: center; font-size: 15px; transition: transform .15s; }
.nav-item:hover .ico { transform: scale(1.15); }
.nav-section {
  font-size: 11.5px; color: var(--text-dim); opacity: .65;
  padding: 14px 12px 5px; letter-spacing: .5px;
}
.sidebar-foot {
  border-top: 1px solid var(--border);
  padding: 12px; display: flex; flex-direction: column; gap: 9px;
}
.quota-chip {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: 9px; padding: 9px 11px;
}
.quota-chip span { color: var(--text-dim); font-size: 12px; }
.quota-chip b { color: var(--green); font-size: 14px; }
.user-chip {
  display: flex; align-items: center; gap: 9px;
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 10px;
}
.u-avatar {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
}
.u-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.u-info b { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.u-info span { font-size: 11px; color: var(--text-dim); }
.sidebar.collapsed .u-info { display: none; }
.u-logout {
  border: 1px solid var(--border-2); background: var(--bg-2);
  color: var(--text-dim); cursor: pointer; line-height: 1;
  width: 30px; height: 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s; flex-shrink: 0;
}
.u-logout svg { display: block; }
.u-logout:hover { color: var(--red); border-color: var(--red); background: rgba(248,113,113,.1); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 56px; min-height: 56px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px; background: var(--topbar-bg);
  backdrop-filter: blur(10px);
}
.topbar h2 { font-size: 15.5px; font-weight: 600; letter-spacing: .3px; }
.content { flex: 1; overflow-y: auto; }

/* ===== 登录/注册页 ===== */
.auth-wrap {
  height: 100vh; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(700px 400px at 15% 10%, rgba(108,140,255,.14), transparent),
    radial-gradient(700px 420px at 85% 90%, rgba(139,92,246,.13), transparent),
    var(--bg);
}
html[data-theme="light"] .auth-wrap {
  background:
    radial-gradient(700px 400px at 15% 10%, rgba(79,110,247,.12), transparent),
    radial-gradient(700px 420px at 85% 90%, rgba(124,58,237,.10), transparent),
    var(--bg);
}
.auth-card {
  width: 400px; max-width: calc(100vw - 32px);
  background: var(--bg-2); backdrop-filter: blur(12px);
  border: 1px solid var(--border); border-radius: 20px;
  padding: 36px 34px;
  box-shadow: var(--shadow-lg);
}
.auth-card h1 {
  font-size: 23px; margin-bottom: 4px;
  background: linear-gradient(135deg, var(--text) 40%, var(--accent));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.auth-card .sub { color: var(--text-dim); font-size: 13px; margin-bottom: 26px; }
.auth-card form { display: flex; flex-direction: column; gap: 13px; }
.auth-card input { padding: 11px 13px; }
.auth-switch { margin-top: 18px; text-align: center; font-size: 13px; color: var(--text-dim); }
.form-err { color: var(--red); font-size: 13px; min-height: 17px; }

/* ===== 对话工作台 ===== */
.chat-layout { display: flex; height: calc(100vh - 57px); }
.chat-side {
  width: 230px; min-width: 230px;
  border-right: 1px solid var(--border); background: var(--bg-2);
  display: flex; flex-direction: column;
}
.chat-side-head { padding: 12px; }
.chat-list { flex: 1; overflow-y: auto; padding: 0 8px 8px; }
.session-item {
  padding: 9px 11px; border-radius: 8px; cursor: pointer;
  color: var(--text-dim); font-size: 13.5px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  margin-bottom: 2px;
}
.session-item:hover { background: var(--bg-3); color: var(--text); }
.session-item.active { background: rgba(108,140,255,.12); color: var(--accent); }
.session-del { visibility: hidden; opacity: .55; font-size: 12px; padding: 2px 5px; border-radius: 5px; flex-shrink: 0; }
.session-item:hover .session-del { visibility: visible; }
.session-del:hover { background: rgba(248,113,113,.15); opacity: 1; }

.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 22px 0 10px; }

/* 微信式左右气泡 */
.msg-row { display: flex; padding: 8px 26px; gap: 10px; align-items: flex-start; }
.msg-row.ai { justify-content: flex-start; }
.msg-row.user { justify-content: flex-end; }
.avatar {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
}
.msg-row.user .avatar { order: 2; background: linear-gradient(135deg, #2f6bff, #6c8cff); color: #fff; }
.msg-row.ai .avatar { order: 0; background: linear-gradient(135deg, var(--accent-2), var(--accent)); color: #fff; }
.msg-col { max-width: 72%; min-width: 0; display: flex; flex-direction: column; }
.msg-row.user .msg-col { align-items: flex-end; }
.msg-row.ai .msg-col { align-items: flex-start; }
.msg-body {
  padding: 9px 13px; line-height: 1.7; font-size: 14.5px;
  border-radius: 4px 12px 12px 12px; word-break: break-word; overflow-wrap: anywhere;
}
.msg-row.ai .msg-body { background: var(--bg-2); border: 1px solid var(--border); border-top-left-radius: 4px; }
.msg-row.user .msg-body {
  background: linear-gradient(135deg, #3555c9, #4566d8); color: #f2f5ff;
  border-top-right-radius: 4px; border-bottom-right-radius: 4px;
  box-shadow: 0 4px 14px rgba(69,102,216,.22);
}
.msg-body .who { font-size: 11.5px; color: var(--text-dim); margin-bottom: 4px; }
.msg-body p { margin: 6px 0; }
.msg-body p:first-child { margin-top: 0; }
.msg-body p:last-child { margin-bottom: 0; }
.msg-body pre {
  background: var(--code-bg); border: 1px solid var(--border);
  border-radius: 9px; padding: 13px 15px; overflow-x: auto;
  margin: 9px 0; font-size: 13px; line-height: 1.55;
}
.msg-row.user .msg-body pre { background: rgba(10,13,19,.55); border-color: rgba(255,255,255,.16); }
html[data-theme="light"] .msg-row.user .msg-body pre { background: rgba(28,35,51,.08); border-color: rgba(255,255,255,.5); }
.msg-body code { font-family: Consolas, "Courier New", monospace; font-size: 13px; }
.msg-body :not(pre) > code { background: rgba(108,140,255,.12); padding: 1.5px 6px; border-radius: 5px; color: #a5b4fc; }
html[data-theme="light"] .msg-body :not(pre) > code { color: #4353c9; }
.msg-row.user .msg-body :not(pre) > code { background: rgba(255,255,255,.18); color: #fff; }
.msg-body ul, .msg-body ol { padding-left: 22px; margin: 6px 0; }
.msg-body table { border-collapse: collapse; margin: 8px 0; }
.msg-body th, .msg-body td { border: 1px solid var(--border-2); padding: 6px 12px; }
.msg-body blockquote { border-left: 3px solid var(--accent); padding-left: 12px; color: var(--text-dim); margin: 8px 0; }
.cursor-blink::after { content: "▍"; animation: blink 1s infinite; color: var(--accent); }
@keyframes blink { 50% { opacity: 0; } }

.chat-input-zone { padding: 12px 26px 18px; }
.chat-input-box {
  display: flex; gap: 10px; align-items: flex-end;
  background: var(--bg-2); border: 1px solid var(--border-2);
  border-radius: 14px; padding: 11px 12px;
  transition: border-color .15s, box-shadow .15s;
}
.chat-input-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108,140,255,.12);
}
.chat-input-box textarea {
  flex: 1; background: transparent; border: none; resize: none;
  max-height: 180px; line-height: 1.6; padding: 4px 2px; font-size: 14.5px;
}
.chat-hint { text-align: center; color: var(--text-dim); font-size: 11.5px; margin-top: 8px; opacity: .7; }

.welcome-hero { text-align: center; padding: 60px 20px 20px; }
.welcome-hero h2 {
  font-size: 25px; margin-bottom: 8px;
  background: linear-gradient(135deg, var(--text) 45%, var(--accent));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.welcome-hero p { color: var(--text-dim); }
.quick-cards { display: flex; gap: 12px; justify-content: center; margin-top: 28px; flex-wrap: wrap; }
.quick-card {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px;
  padding: 15px 17px; width: 220px; text-align: left; cursor: pointer; transition: all .15s;
}
.quick-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.quick-card b { display: block; margin-bottom: 4px; font-size: 13.5px; }
.quick-card span { color: var(--text-dim); font-size: 12.5px; line-height: 1.5; }

/* ===== 生图工作台 ===== */
.draw-layout { display: flex; height: calc(100vh - 57px); }
.draw-panel {
  width: 320px; min-width: 320px;
  border-right: 1px solid var(--border); background: var(--bg-2);
  padding: 18px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 15px;
}
.field label { display: block; font-size: 12.5px; color: var(--text-dim); margin-bottom: 6px; }
.field textarea { width: 100%; resize: vertical; min-height: 96px; line-height: 1.6; }
.field select { width: 100%; }
.seg-group { display: flex; gap: 6px; flex-wrap: wrap; }
.seg {
  flex: 1; min-width: 64px; text-align: center;
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 4px; cursor: pointer; font-size: 12.5px;
  color: var(--text-dim); transition: all .13s; user-select: none;
}
.seg.active {
  border-color: var(--accent); color: var(--accent);
  background: rgba(108,140,255,.14); font-weight: 600;
  box-shadow: 0 0 0 2px rgba(108,140,255,.1);
}
#draw-mode { flex-wrap: nowrap; }
#draw-mode .seg { font-size: 13.5px; padding: 9px 4px; }

/* 图片编辑上传区 */
.upload-box {
  border: 1.5px dashed var(--border-2); border-radius: 10px;
  background: var(--bg-3); cursor: pointer; transition: border-color .15s, background .15s;
}
.upload-box:hover, .upload-box.drag {
  border-color: var(--accent); background: rgba(108,140,255,.07);
  box-shadow: 0 0 0 3px rgba(108,140,255,.1);
}
.upload-empty {
  padding: 22px 10px; text-align: center; color: var(--text-dim);
  font-size: 12.5px; line-height: 1.8; user-select: none;
}
.upload-preview { position: relative; display: flex; flex-direction: column; gap: 8px; align-items: center; padding: 10px; }
.upload-preview img {
  max-width: 100%; max-height: 170px; border-radius: 8px;
  object-fit: contain; background: var(--bg-2); pointer-events: none;
}
.upload-preview button { pointer-events: auto; font-size: 12px; }

.draw-gallery { flex: 1; overflow-y: auto; padding: 22px; }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.g-card {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 14px; overflow: hidden; position: relative;
  animation: fadeIn .35s ease;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.g-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-2);
  box-shadow: var(--card-hover-shadow, 0 12px 30px rgba(0,0,0,.35));
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

/* 图片区：模糊背景铺满 + 原图完整展示（不裁切），加载骨架微光 */
.g-img-wrap { position: relative; aspect-ratio: 1; overflow: hidden; background: var(--bg-3); }
.g-img-wrap::before {
  content: ''; position: absolute; inset: 0; z-index: 1;
  background: linear-gradient(100deg, transparent 40%, rgba(255,255,255,.05) 50%, transparent 60%);
  background-size: 200% 100%;
  animation: gShimmer 1.8s infinite;
  pointer-events: none;
}
.g-img-wrap.done::before { content: none; }
@keyframes gShimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.g-img-wrap .g-bg {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; filter: blur(24px) saturate(1.3); transform: scale(1.18);
  opacity: .4; pointer-events: none;
}
.g-img-wrap .g-main {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; cursor: zoom-in;
  opacity: 0; transition: opacity .4s ease;
}
.g-img-wrap .g-main.loaded { opacity: 1; }

/* 信息区：提示词 + 复制按钮 + 标签 */
.g-meta { padding: 11px 13px 12px; border-top: 1px solid var(--border); }
.g-prompt { display: flex; align-items: flex-start; gap: 7px; }
.g-prompt-text {
  flex: 1; min-width: 0; font-size: 13px; color: var(--text); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.g-copy {
  flex-shrink: 0; width: 26px; height: 26px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-3); border: 1px solid var(--border);
  color: var(--text-dim); cursor: pointer; transition: all .15s;
}
.g-copy:hover { color: var(--accent); border-color: var(--accent); }
.g-copy svg { display: block; }
.g-tags { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.tag.plain { background: var(--bg-3); color: var(--text-dim); border: 1px solid var(--border); }
.g-time { margin-left: auto; font-size: 11.5px; color: var(--text-dim); opacity: .8; white-space: nowrap; }
.g-actions { position: absolute; top: 8px; right: 8px; display: flex; gap: 6px; }
.g-actions button {
  background: rgba(10,13,19,.78); color: #fff; border: 1px solid rgba(255,255,255,.14);
  border-radius: 7px; padding: 5px 9px; font-size: 12px; opacity: 0; transition: opacity .15s;
}
.g-card:hover .g-actions button { opacity: 1; }
.g-check {
  position: absolute; top: 8px; left: 8px; z-index: 2;
  background: rgba(10,13,19,.78); border: 1px solid rgba(255,255,255,.14);
  border-radius: 7px; padding: 5px; display: flex; align-items: center;
}
.g-check input { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }
.g-actions button.g-del { color: #ff7b72; }
html[data-theme="light"] .g-actions button.g-del { color: #ff9d94; }
html[data-theme="light"] .g-check, html[data-theme="light"] .g-actions button { background: rgba(28,35,51,.72); }
.gallery-toolbar {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px; margin-bottom: 16px;
  position: sticky; top: 0; z-index: 6;
  backdrop-filter: blur(8px);
}
/* 空状态 */
.empty-gallery { text-align: center; padding: 56px 0 44px; }
.empty-gallery .ico { font-size: 44px; opacity: .45; margin-bottom: 12px; }
.empty-gallery p { color: var(--text-dim); font-size: 14px; margin-bottom: 12px; }
.empty-gallery a { font-size: 13.5px; }
.img-placeholder {
  aspect-ratio: 1; display: flex; flex-direction: column; gap: 10px;
  align-items: center; justify-content: center; color: var(--text-dim);
  background: var(--bg-2); border-radius: 12px; border: 1px dashed var(--border-2);
}
.spinner {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid var(--border-2); border-top-color: var(--accent);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.lightbox {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(5,7,11,.88); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  cursor: zoom-out;
  animation: lbIn .18s ease;
}
@keyframes lbIn { from { opacity: 0; } to { opacity: 1; } }
.lightbox img {
  max-width: 92vw; max-height: 90vh; border-radius: 10px;
  box-shadow: 0 20px 70px rgba(0,0,0,.6);
  animation: lbZoom .22s ease;
}
@keyframes lbZoom { from { transform: scale(.94); opacity: 0; } to { transform: none; opacity: 1; } }
.lb-close {
  position: absolute; top: 20px; right: 24px; z-index: 2;
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2);
  color: #fff; font-size: 16px; cursor: pointer; transition: all .15s;
}
.lb-close:hover { background: rgba(248,113,113,.85); border-color: transparent; transform: rotate(90deg); }

/* ===== 通用页面（文档/密钥/设置/管理）===== */
.page { max-width: 900px; margin: 0 auto; padding: 28px 24px 60px; animation: pageIn .28s ease; }
@keyframes pageIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.page-wide { max-width: 1150px; }
.card {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 22px; margin-bottom: 16px;
  transition: border-color .18s;
}
.card:hover { border-color: color-mix(in srgb, var(--border) 60%, var(--border-2)); }
.loading-box { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 70px 0; color: var(--text-dim); font-size: 13.5px; }
.card h3 { font-size: 15px; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.card .desc { color: var(--text-dim); font-size: 13px; margin-bottom: 14px; line-height: 1.65; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.form-grid .full { grid-column: 1 / -1; }
.field input { width: 100%; }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left; color: var(--text-dim); font-weight: 500; font-size: 12.5px;
  padding: 9px 12px; border-bottom: 1px solid var(--border);
}
table.data td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: rgba(255,255,255,.015); }
html[data-theme="light"] table.data tr:hover td { background: rgba(79,110,247,.04); }
.tag {
  display: inline-block; padding: 2.5px 9px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600;
}
.tag.green { background: rgba(52,211,153,.13); color: var(--green); }
.tag.red { background: rgba(248,113,113,.13); color: var(--red); }
.tag.blue { background: rgba(108,140,255,.13); color: var(--accent); }
.tag.yellow { background: rgba(251,191,36,.14); color: var(--yellow); }
.key-text {
  font-family: Consolas, monospace; font-size: 12.5px;
  background: var(--code-bg); border: 1px solid var(--border);
  border-radius: 7px; padding: 3px 9px; word-break: break-all;
}

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 13px; margin-bottom: 18px; }
.stat-card {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px;
  position: relative; overflow: hidden;
  transition: transform .18s, border-color .18s;
}
.stat-card::after {
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 2.5px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  opacity: .3; transition: opacity .2s;
}
.stat-card:hover { transform: translateY(-2px); border-color: var(--border-2); }
.stat-card:hover::after { opacity: .85; }
.stat-card .num { font-size: 23px; font-weight: 700; margin-top: 3px; }
.stat-card .lbl { color: var(--text-dim); font-size: 12.5px; }

/* 管理后台标签页按钮 */
button[data-tab] { border-radius: 10px; padding: 8px 15px; font-size: 13.5px; }
button[data-tab]:not(.primary) { background: var(--bg-2); border: 1px solid var(--border); color: var(--text-dim); }
button[data-tab]:not(.primary):hover { color: var(--accent); border-color: var(--accent); transform: translateY(-1px); }

/* 文档页 */
.doc-page { line-height: 1.75; font-size: 14px; }
.doc-page h1 { font-size: 21px; margin-bottom: 6px; }
.doc-page h2 { font-size: 16px; margin: 26px 0 10px; padding-top: 14px; border-top: 1px solid var(--border); }
.doc-page p, .doc-page li { color: var(--text-dim); }
html[data-theme="light"] .doc-page p, html[data-theme="light"] .doc-page li { color: #3a4358; }
.doc-page pre {
  background: var(--code-bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 15px 17px; overflow-x: auto; margin: 10px 0 16px;
  font-size: 12.8px; line-height: 1.6; font-family: Consolas, monospace;
  position: relative;
}
.pre-copy {
  position: absolute; top: 7px; right: 7px;
  background: var(--bg-3); border: 1px solid var(--border-2); color: var(--text-dim);
  border-radius: 6px; padding: 3px 9px; font-size: 11.5px; cursor: pointer;
  opacity: 0; transition: all .15s;
}
.doc-page pre:hover .pre-copy { opacity: 1; }
.pre-copy:hover { color: var(--accent); border-color: var(--accent); }
.doc-page code.inline { background: rgba(108,140,255,.12); padding: 1.5px 6px; border-radius: 5px; font-family: Consolas, monospace; font-size: 12.8px; color: #a5b4fc; }
html[data-theme="light"] .doc-page code.inline, html[data-theme="light"] code.inline { color: #4353c9; }
.doc-page table.doc-t { width: 100%; border-collapse: collapse; margin: 10px 0 16px; font-size: 13px; }
.doc-page table.doc-t th, .doc-page table.doc-t td { border: 1px solid var(--border-2); padding: 8px 12px; text-align: left; }
.doc-page table.doc-t th { background: var(--bg-3); color: var(--text-dim); font-weight: 500; }

/* Toast */
#toast-box { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 500; display: flex; flex-direction: column; gap: 9px; align-items: center; }
.toast {
  background: var(--bg-3); border: 1px solid var(--border-2);
  color: var(--text); border-radius: 10px; padding: 11px 18px;
  font-size: 13.5px; box-shadow: 0 8px 28px rgba(0,0,0,.45);
  animation: toastIn .25s ease;
}
html[data-theme="light"] .toast { box-shadow: 0 8px 24px rgba(31,45,80,.14); }
.toast.ok { border-color: rgba(52,211,153,.5); border-left: 3.5px solid var(--green); }
.toast.err { border-color: rgba(248,113,113,.5); border-left: 3.5px solid var(--red); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; } }

.empty-tip { text-align: center; color: var(--text-dim); padding: 50px 0; font-size: 13.5px; }

tr.row-disabled { opacity: .55; }
code.inline { background: rgba(108,140,255,.12); padding: 1.5px 6px; border-radius: 5px; font-family: Consolas, monospace; font-size: 12.5px; color: #a5b4fc; }

/* 模态弹窗（用户详情等） */
.lightbox.modal { cursor: default; align-items: flex-start; padding-top: 7vh; overflow-y: auto; }
.modal-card {
  background: var(--bg-2); border: 1px solid var(--border-2); border-radius: var(--radius);
  padding: 20px 22px; width: min(860px, 94vw);
  box-shadow: var(--shadow-lg);
}
table.data td input[type="checkbox"] { accent-color: var(--accent); cursor: pointer; }

/* ===== 主题切换按钮 ===== */
.theme-toggle {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-3); border: 1px solid var(--border-2);
  cursor: pointer; font-size: 16px; transition: all .15s; user-select: none;
}
.theme-toggle:hover { border-color: var(--accent); transform: rotate(12deg); }
.theme-toggle.auth-theme { position: absolute; top: 22px; right: 22px; }
.btn.danger-solid {
  background: linear-gradient(135deg, #f87171, #ef4444);
  border: none; color: #fff; font-weight: 600;
}
html[data-theme="light"] .btn.danger-solid { background: linear-gradient(135deg, #ef4444, #dc2626); }
.btn.danger-solid:hover { opacity: .88; }

/* ===== 美化弹窗（uiAlert / uiConfirm / uiPrompt）===== */
.ui-modal-mask {
  position: fixed; inset: 0; z-index: 600;
  background: rgba(5,7,11,.55); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; transition: opacity .18s ease;
}
html[data-theme="light"] .ui-modal-mask { background: rgba(31,45,80,.32); }
.ui-modal-mask.show { opacity: 1; }
.ui-modal {
  width: min(400px, 94vw);
  background: var(--bg-2); border: 1px solid var(--border-2);
  border-radius: 16px; box-shadow: var(--shadow-lg);
  padding: 20px 22px;
  transform: translateY(10px) scale(.97); transition: transform .18s ease;
}
.ui-modal-mask.show .ui-modal { transform: translateY(0) scale(1); }
.ui-modal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.ui-modal-head h3 { font-size: 15.5px; margin: 0; }
.ui-modal-icon {
  width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 17px;
  background: rgba(108,140,255,.13);
}
.ui-modal-icon.danger { background: rgba(248,113,113,.14); }
.ui-modal-body { font-size: 13.5px; line-height: 1.7; color: var(--text); }
.ui-msg { white-space: normal; word-break: break-word; max-height: 46vh; overflow-y: auto; }
.ui-field-label { display: block; font-size: 12.5px; color: var(--text-dim); margin-bottom: 6px; }
.ui-modal-body input { width: 100%; padding: 10px 12px; }
.ui-modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
/* 多字段表单弹窗 */
.ui-form { max-height: 60vh; overflow-y: auto; padding-right: 4px; }
.ui-form-row { margin-bottom: 13px; }
.ui-form-row:last-child { margin-bottom: 0; }
.ui-form-row label { display: block; font-size: 12.5px; color: var(--text-dim); margin-bottom: 6px; }
.ui-form-hint { opacity: .75; font-size: 11.5px; }
.ui-form-row input, .ui-form-row select { width: 100%; }

@media (max-width: 860px) {
  .chat-side, .draw-panel { display: none; }
  :root { --sidebar-w: 66px; }
  .sidebar { width: 66px; min-width: 66px; }
  .logo { justify-content: center; padding: 18px 6px 14px; }
  .logo .logo-text, .side-toggle { display: none; }
  .nav-item .txt, .nav-section, .quota-chip { display: none; }
  .nav-item { justify-content: center; }
  .sidebar-foot { padding: 10px 8px; }
  .user-chip { flex-direction: column; gap: 8px; padding: 8px 2px; }
  .u-info { display: none; }
}
