/* ============================================================
   智工集市 v7 · Grok Bot 风格重塑(零依赖,无外部资源)
   设计语言:纯白底 + 品红 #E91E8C 主色 + 大圆角 + 柔和阴影 + 大量留白
   布局:桌面 = 左侧固定侧边栏(会话列表+导航+额度) + 聊天优先主区域
         移动 = 顶栏抽屉 + 底部 5 Tab(保留)
   既有类名全部保留,页面逻辑零改动
   ============================================================ */
:root {
  /* Grok Bot 实测设计令牌:气泡 #c82779 / 背景 #fcfcfc / 选中 #e4e4e4 / 头像 #f64da3 */
  --primary: #c82779;
  --primary-600: #a91e64;
  --primary-50: #fbf0f6;
  --primary-100: #f6d9e8;
  --bg: #fcfcfc;
  --bg-soft: #f2f2f3;
  --card: #ffffff;
  --text: #17171c;
  --muted: #7a7a85;
  --border: #e6e6e9;
  --danger: #dc2626;
  --green: #16a34a;
  --blue: #2563eb;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(23, 23, 28, 0.05), 0 4px 16px rgba(23, 23, 28, 0.05);
  --shadow-lg: 0 8px 30px rgba(23, 23, 28, 0.12);
  --tabbar-h: 56px;
  --sbw: 282px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: calc(15px * var(--ui-font-scale, 1));
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
h1, h2, h3, h4 { line-height: 1.35; }
main { min-height: calc(100vh - 110px); padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px); }

.container { max-width: 640px; margin: 0 auto; padding: 0 14px; }
.container-wide { max-width: 640px; }
.muted { color: var(--muted); }
.small { font-size: calc(13px * var(--ui-font-scale, 1)); }
.hidden { display: none !important; }
.clamp1, .clamp2 { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
.clamp1 { -webkit-line-clamp: 1; }
.clamp2 { -webkit-line-clamp: 2; }
.row-between { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.span-all { grid-column: 1 / -1; }
.footnote { margin-top: 14px; }

/* ============================================================
   侧边栏(#nav 渲染为 .sb)—— 桌面固定左栏;移动端抽屉
   ============================================================ */
#nav {
  position: fixed; inset: 0 auto 0 0; width: var(--sbw); z-index: 90;
  background: var(--bg);
  display: flex; flex-direction: column;
  transform: translateX(-100%); transition: transform 0.22s ease;  /* 移动端默认藏起,抽屉化 */
}
body.sb-open #nav { transform: translateX(0); box-shadow: var(--shadow-lg); }
.sb-backdrop { position: fixed; inset: 0; background: rgba(23, 23, 28, 0.4); z-index: 85; border: none; padding: 0; }
.sb-burger {
  position: fixed; top: 10px; left: 10px; z-index: 84;
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--border);
  background: #fff; cursor: pointer; font-size: calc(18px * var(--ui-font-scale, 1)); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; box-shadow: var(--shadow);
}
.sb { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.sb-top { padding: 14px 14px 8px; display: flex; flex-direction: column; gap: 10px; }
.sb-brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: calc(16px * var(--ui-font-scale, 1)); color: var(--text); padding: 2px 4px; }
.sb-brand i {
  width: 26px; height: 26px; border-radius: 9px; background: var(--primary); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-style: normal; font-size: calc(13px * var(--ui-font-scale, 1)); font-weight: 800;
}
.sb-new {
  display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); background: #fff;
  border-radius: 12px; min-height: 42px; padding: 0 12px; cursor: pointer; font-family: inherit;
  font-size: calc(14px * var(--ui-font-scale, 1)); font-weight: 600; color: var(--text); transition: 0.15s; text-align: left;
}
.sb-new:hover { border-color: var(--primary); color: var(--primary); }
.sb-new i { font-style: normal; font-size: calc(17px * var(--ui-font-scale, 1)); color: var(--primary); line-height: 1; }
.sb-search {
  border: 1px solid transparent; background: #efeff1; border-radius: 12px; min-height: 38px;
  padding: 0 12px; font-family: inherit; font-size: calc(14px * var(--ui-font-scale, 1)); color: var(--text); width: 100%;
}
.sb-search:focus { outline: none; background: #fff; border-color: var(--primary); }
.sb-label { font-size: calc(11px * var(--ui-font-scale, 1)); color: var(--muted); padding: 10px 18px 4px; letter-spacing: 1px; }
/* QA-fix(PC对齐): 隐藏侧栏原生滚动条(Windows 显示 ▲▼ 滑块很突兀),保留滚动能力 */
.sb-convs { flex: 1; overflow-y: auto; padding: 2px 10px 8px; min-height: 60px; scrollbar-width: none; -ms-overflow-style: none; }
.sb-convs::-webkit-scrollbar { display: none; width: 0; height: 0; }
.sb-conv {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 12px;
  color: var(--text); margin-bottom: 2px; transition: background 0.12s;
}
.sb-conv:hover { background: #ececee; }
.sb-conv.active { background: #e4e4e4; }
.sb-conv .avatar { width: 34px; height: 34px; font-size: calc(14px * var(--ui-font-scale, 1)); border-radius: 50%; }
.sb-conv-txt { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.sb-conv-txt b { font-size: calc(14px * var(--ui-font-scale, 1)); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-conv-txt i { font-style: normal; font-size: calc(12px * var(--ui-font-scale, 1)); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-hint { font-size: calc(12px * var(--ui-font-scale, 1)); color: var(--muted); padding: 8px 10px; line-height: 1.6; }
.sb-nav { padding: 4px 10px 8px; border-top: 1px solid var(--border); }
.sb-link {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 12px;
  color: var(--text); font-size: calc(14px * var(--ui-font-scale, 1)); margin-bottom: 2px; transition: background 0.12s;
}
.sb-link:hover { background: #ececee; }
.sb-link.active { background: #e4e4e4; font-weight: 600; }
.sb-link .ico { width: 19px; height: 19px; flex-shrink: 0; }
.sb-foot { border-top: 1px solid var(--border); padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; }
.sb-quota { cursor: pointer; }
.sb-quota-row { display: flex; justify-content: space-between; font-size: calc(12px * var(--ui-font-scale, 1)); color: var(--muted); margin-bottom: 5px; }
.sb-quota-row b { color: var(--text); font-weight: 600; }
.sb-quota-bar { height: 6px; border-radius: 999px; background: #e7e7ec; overflow: hidden; }
.sb-quota-bar i { display: block; height: 100%; background: var(--primary); border-radius: 999px; transition: width 0.3s; }
.sb-quota-bar i.full { background: var(--danger); }
.sb-user-row { display: flex; align-items: center; gap: 9px; }
.sb-user-row .avatar { width: 32px; height: 32px; font-size: calc(13px * var(--ui-font-scale, 1)); }
.sb-user-name { flex: 1; min-width: 0; font-size: calc(13px * var(--ui-font-scale, 1)); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.sb-logout { border: none; background: none; color: var(--muted); font-size: calc(12px * var(--ui-font-scale, 1)); cursor: pointer; font-family: inherit; padding: 4px 6px; border-radius: 8px; }
.sb-logout:hover { color: var(--danger); background: #fff; }
.sb-guest { display: flex; gap: 8px; }
.sb-guest .btn { flex: 1; min-height: 38px; padding: 6px 10px; font-size: calc(13px * var(--ui-font-scale, 1)); }

/* ============================================================
   底部 Tab(移动端)
   ============================================================ */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 80;
  display: flex; background: rgba(255, 255, 255, 0.96); backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab-item {
  flex: 1; min-height: var(--tabbar-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: calc(11px * var(--ui-font-scale, 1)); position: relative;
}
.tab-item .tab-ico { width: 22px; height: 22px; }
.tab-item .tab-label { line-height: 1.2; }
.btn-primary { background: var(--primary); color: #fff; }
.tab-item.active { color: var(--primary); font-weight: 600; }
.tab-dot { position: absolute; top: 7px; right: calc(50% - 17px); width: 8px; height: 8px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 2px #fff; }

/* ---------- 图标 / 头像 ---------- */
.ico { width: 18px; height: 18px; vertical-align: -3px; }
.ico-sm { width: 16px; height: 16px; vertical-align: -2px; }
.avatar { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; color: #fff; font-weight: 700; flex-shrink: 0; overflow: hidden; }
.av-sm { width: 28px; height: 28px; font-size: calc(13px * var(--ui-font-scale, 1)); }
.av-md { width: 40px; height: 40px; font-size: calc(16px * var(--ui-font-scale, 1)); }
.av-lg { width: 56px; height: 56px; font-size: calc(22px * var(--ui-font-scale, 1)); }
.msg-avatar { width: 30px; height: 30px; font-size: calc(12px * var(--ui-font-scale, 1)); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; cursor: pointer; font-family: inherit; font-size: calc(14px * var(--ui-font-scale, 1)); line-height: 1.4;
  padding: 10px 18px; min-height: 44px; border-radius: 12px; background: var(--primary); color: #fff;
  transition: background 0.15s, opacity 0.15s, transform 0.06s; white-space: nowrap; text-align: center;
}
.btn:hover { background: var(--primary-600); }
.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-sm { padding: 8px 13px; font-size: calc(13px * var(--ui-font-scale, 1)); }
.btn-lg { padding: 12px 28px; font-size: calc(16px * var(--ui-font-scale, 1)); }
.btn-block { width: 100%; }
.btn-light { background: #fff; color: var(--primary-600); }
.btn-light:hover { background: var(--primary-50); }
.btn-outline-light { background: transparent; color: #fff; border: 1px solid rgba(255, 255, 255, 0.55); }
.btn-outline-light:hover { background: rgba(255, 255, 255, 0.12); }
.btn-outline { background: #fff; color: var(--primary); border: 1px solid var(--primary-100); }
.btn-outline:hover { background: var(--primary-50); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); background: var(--bg-soft); }
.btn-danger-outline { background: #fff; color: var(--danger); border: 1px solid #fecaca; }
.btn-danger-outline:hover { background: #fef2f2; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

/* ---------- 卡片与网格 ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 14px; }
.card h3 { margin: 0 0 10px; font-size: calc(16px * var(--ui-font-scale, 1)); }
.card h3.row-between { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.grid { display: grid; grid-template-columns: 1fr; gap: 14px; margin-bottom: 14px; }
.cols-3 { grid-template-columns: 1fr; }
.cols-4 { grid-template-columns: 1fr 1fr; }

/* ---------- 徽章 ---------- */
.badge { display: inline-block; font-size: calc(12px * var(--ui-font-scale, 1)); line-height: 1.6; padding: 2px 10px; border-radius: 999px; font-weight: 500; white-space: nowrap; }
.b-blue { background: #e3ecfe; color: #1d4ed8; }
.b-green { background: #dcfce7; color: #15803d; }
.b-orange { background: #ffedd5; color: #c2410c; }
.b-red { background: #fee2e2; color: #b91c1c; }
.b-gray { background: #ececef; color: #5b5b66; }
.b-pink { background: var(--primary-100); color: var(--primary-600); }
.chip { display: inline-block; font-size: calc(12px * var(--ui-font-scale, 1)); background: var(--primary-50); color: var(--primary-600); border-radius: 8px; padding: 3px 9px; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- 表单 ---------- */
label { display: block; font-size: calc(13px * var(--ui-font-scale, 1)); font-weight: 600; color: var(--text); margin-bottom: 12px; }
.input {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px; min-height: 44px;
  border: 1px solid var(--border); border-radius: 12px;
  font-size: calc(16px * var(--ui-font-scale, 1)); font-family: inherit; background: #fff; color: var(--text); font-weight: 400;
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(200, 39, 121, 0.12); }
.input:disabled { background: var(--bg-soft); color: var(--muted); cursor: not-allowed; }
textarea.input { resize: vertical; }
label .muted.small { display: block; font-weight: 400; margin-top: 4px; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 0 16px; margin-top: 14px; }
.form-grid .span-all { margin-bottom: 12px; }
.code-row { display: flex; gap: 8px; }
.code-row .input { flex: 1; min-width: 0; }
.code-row .btn { flex-shrink: 0; }
select.input { appearance: auto; }

/* ---------- 分段控件 ---------- */
.seg { display: flex; background: #ececef; border-radius: 12px; padding: 4px; gap: 4px; margin: 12px 0; }
.seg-btn { flex: 1; border: none; background: transparent; border-radius: 9px; min-height: 40px; font-size: calc(14px * var(--ui-font-scale, 1)); color: var(--muted); font-family: inherit; cursor: pointer; padding: 0 8px; }
.seg-btn.active { background: #fff; color: var(--primary); font-weight: 600; box-shadow: 0 1px 4px rgba(23, 23, 28, 0.12); }

/* ---------- 折叠 / 筛选 ---------- */
.collapse-card { margin-bottom: 14px; }
.collapse-toggle { background: none; border: none; padding: 8px 0; min-height: 44px; color: var(--primary); font-weight: 600; font-size: calc(14px * var(--ui-font-scale, 1)); cursor: pointer; font-family: inherit; text-align: left; }
.filter-row { display: flex; gap: 12px; align-items: center; margin: 14px 0; flex-wrap: wrap; }
.pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { border: 1px solid var(--border); background: #fff; border-radius: 999px; padding: 0 14px; min-height: 44px; font-size: calc(13px * var(--ui-font-scale, 1)); cursor: pointer; color: var(--text); font-family: inherit; transition: 0.15s; }
.pill:hover { border-color: var(--primary); color: var(--primary); }
.pill.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.search { flex: 1; min-width: 150px; margin-left: auto; margin-top: 0; }

/* ---------- 落地页(未登录访客) ---------- */
.hero { background: linear-gradient(135deg, #7d1c50 0%, #c82779 55%, #f64da3 100%); color: #fff; padding: 52px 0 66px; text-align: center; }
.hero-kicker { opacity: 0.85; letter-spacing: 3px; font-size: calc(12px * var(--ui-font-scale, 1)); margin: 0; }
.hero h1 { font-size: calc(27px * var(--ui-font-scale, 1)); margin: 14px 0 0; }
.hero-sub { font-size: calc(15px * var(--ui-font-scale, 1)); opacity: 0.94; margin: 14px auto 26px; max-width: 560px; }
.hero-cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.hero .btn-light { color: var(--primary-600); }
.stat-bar-wrap { position: relative; z-index: 2; margin-top: -34px; }
.stat-bar { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.stat { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 12px; text-align: center; min-width: 0; flex: 1; }
.stat b { display: block; font-size: calc(18px * var(--ui-font-scale, 1)); color: var(--primary); }
.stat span { font-size: calc(12px * var(--ui-font-scale, 1)); color: var(--muted); }
.section { margin-top: 40px; }
.section-title { font-size: calc(20px * var(--ui-font-scale, 1)); margin: 0 0 14px; }
.plan { display: flex; flex-direction: column; gap: 10px; margin-bottom: 0; border: 1.5px solid var(--primary-100); }
.plan-name { font-weight: 700; font-size: calc(17px * var(--ui-font-scale, 1)); }
.plan-price { font-size: calc(32px * var(--ui-font-scale, 1)); font-weight: 800; color: var(--primary); }
.plan-price span { font-size: calc(14px * var(--ui-font-scale, 1)); color: var(--muted); font-weight: 400; }
.plan-features { margin: 0; padding-left: 18px; font-size: calc(14px * var(--ui-font-scale, 1)); }
.plan .btn { margin-top: auto; }
.promo h3 { margin: 0 0 8px; color: var(--primary); }
.promo p { margin: 0; font-size: calc(14px * var(--ui-font-scale, 1)); color: var(--muted); }

/* ---------- 页头 / 提示 ---------- */
.page-head { margin: 22px 0 16px; }
.page-head h1 { font-size: calc(23px * var(--ui-font-scale, 1)); margin: 0 0 6px; }
.page-head p { margin: 0; }
.sub-title { margin: 20px 0 12px; font-size: calc(16px * var(--ui-font-scale, 1)); }
.empty-state { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 32px 16px; margin-bottom: 14px; }
.page-loading { text-align: center; color: var(--muted); padding: 48px 0; }
.login-hint { background: var(--primary-50); border: 1px solid var(--primary-100); color: var(--primary-600); border-radius: var(--radius); padding: 12px 16px; font-size: calc(14px * var(--ui-font-scale, 1)); margin-bottom: 14px; }

/* ---------- 模板 / AI员工 卡片 ---------- */
.t-card, .bot-card { display: flex; flex-direction: column; gap: 6px; margin-bottom: 0; transition: box-shadow 0.15s, transform 0.15s; }
.t-card:hover, .bot-card:hover { box-shadow: var(--shadow-lg); }
.t-card h3 { margin: 4px 0 0; }
.t-card p { margin: 0; }
.t-card .btn { margin-top: auto; align-self: flex-start; }
.t-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.price { font-weight: 700; color: var(--primary); font-size: calc(15px * var(--ui-font-scale, 1)); }
.price.free { color: var(--green); }
.t-meta { font-size: calc(12px * var(--ui-font-scale, 1)); color: var(--muted); }
.bot-card h3 { margin: 0; }
.bot-avatar { width: 44px; height: 44px; border-radius: 14px; background: var(--primary-50); color: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: calc(18px * var(--ui-font-scale, 1)); }

/* ============================================================
   聊天(Grok 风):悬浮胶囊头 + 大圆角输入胶囊 + 粉色用户气泡
   .chatg 用于 AI 员工对话;.chat-wrap 保留给付费聊天页
   ============================================================ */
.chatg { display: flex; flex-direction: column; height: calc(100vh - 24px); min-height: 420px; position: relative; }
.chatg-head {
  position: sticky; top: 10px; z-index: 5; align-self: center;
  display: inline-flex; align-items: center; gap: 9px;
  background: rgba(255, 255, 255, 0.92); backdrop-filter: blur(8px);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 7px 16px 7px 8px; box-shadow: var(--shadow); margin: 10px auto 0;
}
.chatg-head .avatar { width: 30px; height: 30px; font-size: calc(13px * var(--ui-font-scale, 1)); background: #f64da3; }
.chatg-head b { font-size: calc(14px * var(--ui-font-scale, 1)); }
.chatg-head .muted { font-size: calc(12px * var(--ui-font-scale, 1)); max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chatg-back { border: none; background: #f1f1f4; color: var(--muted); width: 28px; height: 28px; border-radius: 50%; cursor: pointer; font-size: calc(14px * var(--ui-font-scale, 1)); flex-shrink: 0; }
.chatg-msgs { flex: 1; overflow-y: auto; padding: 18px 6px 12px; display: flex; flex-direction: column; gap: 6px; min-height: 120px; }
.chatg-empty { margin: auto; text-align: center; padding: 30px 16px; }
.chatg-empty h2 { font-size: calc(24px * var(--ui-font-scale, 1)); margin: 0 0 8px; }
.chatg-empty p { color: var(--muted); margin: 0 0 18px; }
.chatg-suggest { display: flex; flex-direction: column; gap: 9px; max-width: 380px; margin: 0 auto; }
.chatg-suggest button {
  border: 1px solid var(--border); background: #fff; border-radius: 14px; min-height: 46px;
  font-family: inherit; font-size: calc(14px * var(--ui-font-scale, 1)); color: var(--text); cursor: pointer; transition: 0.15s; text-align: left; padding: 0 16px;
}
.chatg-suggest button:hover { border-color: var(--primary); color: var(--primary); }
.chat-notice {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: #f0f0f1; border: none; border-radius: 14px;
  padding: 10px 14px; margin: 0 14px 8px; font-size: calc(13px * var(--ui-font-scale, 1)); color: var(--muted);
}
.chat-notice .btn { min-height: 32px; padding: 4px 14px; font-size: calc(13px * var(--ui-font-scale, 1)); margin-left: auto; background: #0c64c1; }
.chat-notice .btn:hover { background: #0a55a4; }
.chat-notice .x { border: none; background: none; color: var(--muted); cursor: pointer; font-size: calc(16px * var(--ui-font-scale, 1)); padding: 0 4px; }
.chatg-inputbar {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); background: #fff; border-radius: 26px;
  padding: 8px 10px; margin: 0 14px 16px; box-shadow: var(--shadow);
}
.chatg-inputbar:focus-within { border-color: #c82779; box-shadow: 0 0 0 3px rgba(200, 39, 121, 0.1); }
.chatg-inputbar .input {
  flex: 1; margin-top: 0; min-width: 0; border: none; background: transparent;
  min-height: 40px; box-shadow: none; font-size: calc(16px * var(--ui-font-scale, 1)); padding: 6px 4px;
}
.chatg-inputbar .input:focus { box-shadow: none; }
.cbtn {
  width: 38px; height: 38px; border-radius: 50%; border: none; background: var(--bg-soft);
  color: var(--muted); cursor: pointer; font-size: calc(16px * var(--ui-font-scale, 1)); flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center; transition: 0.15s;
}
.cbtn:hover { background: var(--primary-50); color: var(--primary); }
.cbtn.send { background: var(--primary); color: #fff; font-size: calc(14px * var(--ui-font-scale, 1)); width: auto; border-radius: 20px; padding: 0 18px; font-weight: 600; }
.cbtn.send:hover { background: var(--primary-600); }
.scroll-btm {
  position: absolute; right: 22px; bottom: 96px; width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--border); background: #fff; box-shadow: var(--shadow); cursor: pointer;
  font-size: calc(16px * var(--ui-font-scale, 1)); color: var(--muted); display: none; z-index: 4;
}
.scroll-btm.show { display: inline-flex; align-items: center; justify-content: center; }

/* 付费聊天页(旧结构)兼容同一视觉 */
.chat-wrap { display: flex; flex-direction: column; height: calc(100vh - 196px); min-height: 400px; }
@supports (height: 100dvh) { .chat-wrap { height: calc(100dvh - 196px); } }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; flex-wrap: wrap; margin-bottom: 0; border-radius: var(--radius); }
.chat-head h2 { margin: 0; font-size: calc(17px * var(--ui-font-scale, 1)); }
.chat-head p { margin: 0; }
.chat-head-info { min-width: 0; flex: 1; }
.chat-quota { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 14px; margin-top: 10px; margin-bottom: 10px; }
.chat-quota .chip { font-size: calc(12px * var(--ui-font-scale, 1)); }
.chat-msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 4px; min-height: 120px; margin-top: 0; }
.msg-row { display: flex; align-items: flex-end; gap: 8px; margin-bottom: 10px; }
.msg-col { max-width: 76%; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.msg-name { font-size: calc(11px * var(--ui-font-scale, 1)); color: var(--muted); padding: 0 4px; }
.bubble { padding: 10px 15px; border-radius: 20px; font-size: calc(14.5px * var(--ui-font-scale, 1)); line-height: 1.55; word-break: break-word; }
.msg-row.buyer, .msg-row.ai { justify-content: flex-start; }
.msg-row.seller, .msg-row.me { justify-content: flex-end; }
.msg-row.buyer .msg-col, .msg-row.ai .msg-col { align-items: flex-start; }
.msg-row.seller .msg-col, .msg-row.me .msg-col { align-items: flex-end; }
.msg-row.buyer .bubble, .msg-row.ai .bubble { background: var(--bg-soft); border: 1px solid var(--border); border-top-left-radius: 6px; }
.msg-row.seller .bubble, .msg-row.me .bubble { background: #c82779; color: #fff; border-radius: 24px; }
.chat-err { color: var(--danger); font-size: calc(13px * var(--ui-font-scale, 1)); text-align: center; }
.chat-input { display: flex; gap: 10px; padding: 12px; margin-top: 10px; border-radius: 24px; }
.chat-input .input { flex: 1; margin-top: 0; min-width: 0; border: none; box-shadow: none; padding: 6px 4px; }
.chat-input .input:focus { box-shadow: none; }

/* ---------- 会话列表 ---------- */
.chat-list { display: grid; gap: 10px; }
.chat-item { display: flex; align-items: center; gap: 12px; color: inherit; padding: 14px; margin-bottom: 0; }
.chat-item-main { flex: 1; min-width: 0; }
.chat-item-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.chat-item-arrow { color: #c9c9d0; font-size: calc(20px * var(--ui-font-scale, 1)); flex-shrink: 0; }

/* ---------- 广场 ---------- */
.publish-card { padding: 14px; }
.publish-card .input { margin-top: 0; }
.pub-content { margin-top: 10px !important; }
.pub-actions { margin-top: 10px; align-items: center; }
.post-list { display: grid; gap: 12px; }
.post-card, .post-mini { display: flex; flex-direction: column; gap: 8px; margin-bottom: 0; }
.post-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.post-author { cursor: pointer; border-radius: 10px; }
.post-who { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.post-who b { font-size: calc(14px * var(--ui-font-scale, 1)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.post-title { margin: 0; font-size: calc(16px * var(--ui-font-scale, 1)); }
.post-content { margin: 0; white-space: pre-wrap; word-break: break-word; font-size: calc(14px * var(--ui-font-scale, 1)); }
.post-imgs { display: flex; gap: 6px; }
.post-img { width: 100px; height: 100px; object-fit: cover; border-radius: 12px; border: 1px solid var(--border); }
.post-foot { display: flex; align-items: center; gap: 2px; margin-top: 2px; }
.foot-btn { display: inline-flex; align-items: center; gap: 5px; border: none; background: none; color: var(--muted); font-family: inherit; font-size: calc(13px * var(--ui-font-scale, 1)); padding: 0 10px; min-height: 44px; cursor: pointer; border-radius: 10px; }
.foot-btn:hover { background: var(--bg-soft); }
.like-btn.liked { color: var(--primary); }
.like-btn.liked svg { fill: var(--primary); stroke: var(--primary); }
.foot-btn.chat-btn { color: var(--primary); font-weight: 600; }
.comment-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }
.comment-item { display: flex; gap: 10px; }
.comment-main { flex: 1; min-width: 0; }
.comment-main p { margin: 2px 0 0; font-size: calc(14px * var(--ui-font-scale, 1)); white-space: pre-wrap; word-break: break-word; }
.comment-meta { display: flex; gap: 8px; align-items: baseline; font-size: calc(13px * var(--ui-font-scale, 1)); flex-wrap: wrap; }
.c-author { font-weight: 600; }
.comment-form { display: flex; gap: 8px; }
.comment-form .input { margin-top: 0; flex: 1; min-width: 0; }

/* ---------- 用户主页 / 我的 ---------- */
.user-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.user-head-main { flex: 1; min-width: 140px; }
.user-head-main h2 { margin: 0; font-size: calc(18px * var(--ui-font-scale, 1)); }
.user-head-acts { display: flex; gap: 8px; flex-wrap: wrap; }
.me-profile { display: flex; align-items: center; gap: 14px; }
.me-profile-main { min-width: 0; }
.me-profile-main h2 { margin: 0; font-size: calc(18px * var(--ui-font-scale, 1)); }
.me-profile-main p { margin: 2px 0 0; }
.member-card {
  background: linear-gradient(135deg, #7d1c50 0%, #c82779 60%, #f64da3 100%);
  color: #fff; border-radius: 18px; padding: 18px; margin-bottom: 14px;
  display: flex; flex-direction: column; gap: 8px;
  box-shadow: 0 10px 26px rgba(200, 39, 121, 0.35); border: none;
}
.member-state { font-size: calc(12px * var(--ui-font-scale, 1)); background: rgba(255, 255, 255, 0.22); padding: 2px 10px; border-radius: 999px; }
.member-line { margin: 0; opacity: 0.92; font-size: calc(14px * var(--ui-font-scale, 1)); }
.member-line.small { font-size: calc(12px * var(--ui-font-scale, 1)); opacity: 0.8; }
.member-card .btn-light { align-self: flex-start; }
.progress { height: 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.28); overflow: hidden; }
.progress i { display: block; height: 100%; background: #fff; border-radius: 999px; transition: width 0.3s; }
.me-grid { display: grid; grid-template-columns: 1fr; gap: 14px; margin-bottom: 14px; }
.me-grid .card { margin-bottom: 0; }
.credit-balance { font-size: calc(28px * var(--ui-font-scale, 1)); font-weight: 800; color: var(--primary); margin: 0; }
.credit-balance.green { color: var(--green); }
.me-entry { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: inherit; padding: 16px 18px; }
.me-entry-title { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.me-entry .row-between { flex: 1; justify-content: flex-end; align-items: center; gap: 10px; }
.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.quick-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; border: 1px solid var(--border); border-radius: 12px; padding: 0 14px; min-height: 44px; font-size: calc(14px * var(--ui-font-scale, 1)); color: var(--text); }
.quick-item:hover { border-color: var(--primary); color: var(--primary); }

/* ---------- 通知 ---------- */
.notif-list { display: grid; gap: 10px; }
.notif-item { margin-bottom: 0; }
.notif-item.unread { border-left: 3px solid var(--primary); background: var(--primary-50); }
.notif-content { margin: 6px 0 0; }

/* ---------- 需求大厅 ---------- */
.tabs { display: flex; gap: 8px; border-bottom: 2px solid var(--border); margin: 8px 0 16px; }
.tab { background: none; border: none; padding: 0 14px; min-height: 44px; font-size: calc(15px * var(--ui-font-scale, 1)); cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -2px; font-family: inherit; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.demand-card .d-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.demand-card .d-top .price { margin-left: auto; }
.demand-card h3 { margin: 8px 0 4px; font-size: calc(16px * var(--ui-font-scale, 1)); }
.demand-card p { margin: 0; }
.d-meta { margin-top: 8px; }
.deliverable { margin-top: 8px; background: var(--bg-soft); border: 1px dashed var(--border); border-radius: 10px; padding: 8px 10px; font-size: calc(13px * var(--ui-font-scale, 1)); }

/* ---------- 钱包 ---------- */
.wallet-top { display: grid; grid-template-columns: 1fr; gap: 14px; margin-bottom: 14px; }
.wallet-top .card { margin-bottom: 0; }
.balance-card { display: flex; gap: 24px; align-items: center; }
.wallet-top .balance-card { flex-wrap: wrap; align-content: center; row-gap: 14px; }
.wallet-top .balance-card .bal-item { flex: 1 1 100px; }
.wallet-top .wallet-funding-note { flex-basis: 100%; margin: 0; overflow-wrap: anywhere; }
.wallet-reward-table { min-width: 640px; }
.wallet-reward-table th, .wallet-reward-table td { min-width: 80px; }
.wallet-reward-table .badge { max-width: 220px; white-space: normal; }
.bal-item span { display: block; font-size: calc(13px * var(--ui-font-scale, 1)); color: var(--muted); }
.bal-main { font-size: calc(28px * var(--ui-font-scale, 1)); color: var(--green); }
.bal-sub { font-size: calc(20px * var(--ui-font-scale, 1)); color: var(--muted); }
.invite-code { font-size: calc(24px * var(--ui-font-scale, 1)); font-weight: 800; letter-spacing: 2px; color: var(--primary); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; margin: 4px 0 8px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
/* AI usage dashboard (user page and admin tab) */
.usage-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 16px 0; }
.usage-stat { background: var(--surface, #fff); border: 1px solid var(--border, #e5e2dc); border-radius: 12px; padding: 14px 16px; }
.usage-stat span { color: var(--muted, #8a8578); font-size: calc(13px * var(--ui-font-scale, 1)); }
.usage-stat b { display: block; font-size: calc(26px * var(--ui-font-scale, 1)); font-variant-numeric: tabular-nums; margin: 4px 0 2px; }
.usage-stat small { color: var(--muted, #8a8578); font-size: calc(12px * var(--ui-font-scale, 1)); }
.usage-balance { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; background: var(--surface, #fff); border: 1px solid var(--border, #e5e2dc); border-radius: 12px; padding: 16px; margin: 12px 0; }
.usage-balance-total b { font-size: calc(28px * var(--ui-font-scale, 1)); font-variant-numeric: tabular-nums; }
.usage-balance-total small { display: block; color: var(--muted, #8a8578); font-size: calc(12px * var(--ui-font-scale, 1)); }
.usage-kinds { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; flex: 1; min-width: 220px; }
.usage-kinds div { text-align: center; } .usage-kinds span { display: block; color: var(--muted, #8a8578); font-size: calc(12px * var(--ui-font-scale, 1)); } .usage-kinds b { font-variant-numeric: tabular-nums; }
.usage-range { display: inline-flex; gap: 4px; margin: 8px 0; } .usage-range button { padding: 5px 12px; border: 1px solid var(--border, #e5e2dc); border-radius: 999px; background: transparent; cursor: pointer; }
.usage-range button[aria-selected="true"] { background: var(--accent, #d9622b); color: #fff; border-color: transparent; }
.usage-split { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.usage-panel { background: var(--surface, #fff); border: 1px solid var(--border, #e5e2dc); border-radius: 12px; padding: 14px 16px; margin: 12px 0; }
.usage-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: baseline; padding: 6px 0; border-bottom: 1px dashed var(--border, #eee); }
.usage-row b { font-variant-numeric: tabular-nums; } .usage-row em { color: var(--muted, #8a8578); font-style: normal; font-size: calc(12px * var(--ui-font-scale, 1)); }
.usage-table { width: 100%; border-collapse: collapse; font-size: calc(13px * var(--ui-font-scale, 1)); } .usage-table th, .usage-table td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border, #eee); white-space: nowrap; }
.usage-table .usage-tokens { font-variant-numeric: tabular-nums; color: var(--muted, #6b6558); } .usage-table .usage-failed { opacity: .7; } .usage-table code { font-size: calc(12px * var(--ui-font-scale, 1)); }
.usage-pack-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.usage-pack { text-align: left; border: 1px solid var(--border, #e5e2dc); border-radius: 12px; padding: 12px 14px; background: var(--surface, #fff); cursor: pointer; }
.usage-pack b { display: block; } .usage-pack span { font-size: calc(22px * var(--ui-font-scale, 1)); font-weight: 700; } .usage-pack small { display: block; color: var(--muted, #8a8578); font-size: calc(12px * var(--ui-font-scale, 1)); margin-top: 4px; }
.usage-filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-bottom: 12px; } .usage-grant { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; align-items: end; }
.usage-grant .span-all { grid-column: 1 / -1; }
table { width: 100%; border-collapse: collapse; font-size: calc(14px * var(--ui-font-scale, 1)); }
th { text-align: left; font-size: calc(12px * var(--ui-font-scale, 1)); color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--bg-soft); vertical-align: top; }
.pos { color: var(--green); font-weight: 600; }
.neg { color: var(--danger); font-weight: 600; }
.small-table th, .small-table td { padding: 6px 8px; }

/* ---------- 认证页 ---------- */
.auth-wrap { display: flex; justify-content: center; padding: 32px 0 48px; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card h2 { margin: 0 0 4px; }
.auth-card form { margin-top: 16px; }
/* 注册页:邀请码独立一栏(注册按钮下方,视觉上次要) */
.reg-invite-row { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border); }
.reg-invite-row label { margin-bottom: 4px; }
.auth-alt { margin-top: 14px; }

/* ---------- 管理后台 ---------- */
.admin-tabs { display: flex; gap: 8px; overflow-x: auto; margin: 0 0 16px; padding-bottom: 4px; scrollbar-width: none; }
.admin-tabs::-webkit-scrollbar { display: none; }
.admin-tab { border: 1px solid var(--border); background: #fff; border-radius: 999px; padding: 0 16px; min-height: 44px; font-size: calc(14px * var(--ui-font-scale, 1)); cursor: pointer; color: var(--text); font-family: inherit; white-space: nowrap; }
.admin-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.admin-grid { display: grid; grid-template-columns: 1fr; gap: 14px; align-items: start; }
.admin-grid .card { margin-bottom: 0; }
.sec-body { margin-top: 10px; }
.stat-card { text-align: center; padding: 14px 10px; margin-bottom: 0; }
.stat-card b { display: block; font-size: calc(20px * var(--ui-font-scale, 1)); color: var(--primary); word-break: break-all; }
.stat-card span { font-size: calc(12px * var(--ui-font-scale, 1)); color: var(--muted); }
.review-item { border-bottom: 1px solid var(--bg-soft); padding: 10px 0; }
.review-item:last-child { border-bottom: none; }
.set-card { max-width: 640px; }
.mini-item { display: flex; align-items: baseline; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--bg-soft); flex-wrap: wrap; font-size: calc(14px * var(--ui-font-scale, 1)); }
.mini-item:last-child { border-bottom: none; }
.mini-list { display: flex; flex-direction: column; }

/* ---------- 素材 ---------- */
.mat-card { display: flex; flex-direction: column; gap: 6px; margin-bottom: 0; }
.mat-card h3 { margin: 4px 0 0; }
.mat-card p { margin: 0; flex: 1; }

/* ---------- 人工收款 ---------- */
.pay-amount { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.pay-amount > span { font-size: calc(13px * var(--ui-font-scale, 1)); color: var(--muted); }
.pay-price { font-size: calc(26px * var(--ui-font-scale, 1)); font-weight: 800; color: var(--primary); }
.pay-tiers { margin-top: 4px; width: 100%; }
.pay-hint { background: var(--primary-50); border: 1px solid var(--primary-100); color: var(--primary-600); border-radius: 10px; padding: 8px 12px; font-size: calc(13px * var(--ui-font-scale, 1)); margin: 10px 0; }
.pay-warn { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; border-radius: 10px; padding: 8px 12px; font-size: calc(13px * var(--ui-font-scale, 1)); }
.qr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin: 10px 0; }
.qr-item { margin: 0; text-align: center; }
.qr-item img { width: 100%; max-width: 170px; height: auto; object-fit: contain; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
.qr-item figcaption { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; font-size: calc(13px * var(--ui-font-scale, 1)); align-items: center; }
.proof-preview { margin: 4px 0 10px; }
.proof-preview img { width: 120px; height: 120px; object-fit: cover; border-radius: 12px; border: 1px solid var(--border); }
.mo-list { display: flex; flex-direction: column; }
.mo-item { padding: 10px 0; border-bottom: 1px solid var(--bg-soft); display: flex; flex-direction: column; gap: 4px; }
.mo-item:last-child { border-bottom: none; }
.mo-remark { background: #fef2f2; border: 1px dashed #fecaca; color: #b91c1c; border-radius: 8px; padding: 6px 10px; font-size: calc(13px * var(--ui-font-scale, 1)); word-break: break-word; }
.mo-remark-user { background: var(--bg-soft); border-color: var(--border); color: var(--text); }
.qr-manage-list { display: flex; flex-direction: column; }
.qr-manage-item { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 0; border-bottom: 1px solid var(--bg-soft); }
.qr-manage-item:last-child { border-bottom: none; }
.qr-manage-item .btn-row { margin-top: 0; margin-left: auto; }
.qr-manage-main { flex: 1; min-width: 140px; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.qr-thumb { width: 64px; height: 64px; object-fit: contain; border: 1px solid var(--border); border-radius: 10px; background: #fff; flex-shrink: 0; }
.proof-thumb { width: 64px; height: 64px; object-fit: cover; border: 1px solid var(--border); border-radius: 8px; cursor: zoom-in; align-self: flex-start; }
.proof-full { display: block; max-width: 100%; max-height: 70vh; margin: 0 auto; border-radius: 10px; }
.grant-radio { display: flex; align-items: center; gap: 8px; font-weight: 600; margin: 10px 0 4px; cursor: pointer; }
.grant-radio input { width: 16px; height: 16px; flex-shrink: 0; }

/* ---------- 弹层 ---------- */
#modal-root { position: fixed; inset: 0; z-index: 120; }
.modal-mask { position: absolute; inset: 0; background: rgba(23, 23, 28, 0.5); }
.modal-sheet {
  position: absolute; left: 0; right: 0; bottom: 0; background: #fff;
  border-radius: 22px 22px 0 0; max-height: 84vh; overflow-y: auto;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  animation: sheet-up 0.22s ease;
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0.4; } to { transform: translateY(0); opacity: 1; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.modal-head .post-head { flex: 1; min-width: 0; }
.modal-close { border: none; background: var(--bg-soft); width: 36px; height: 36px; border-radius: 50%; font-size: calc(20px * var(--ui-font-scale, 1)); line-height: 1; color: var(--muted); cursor: pointer; flex-shrink: 0; }
.modal-close:hover { background: var(--primary-50); color: var(--primary); }
.modal-loading { padding: 44px 0; text-align: center; color: var(--muted); }
.modal-foot { margin-top: 6px; }

/* ---------- Toast ---------- */
#toast-root { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 130; display: flex; flex-direction: column; gap: 8px; align-items: center; width: max-content; max-width: 92vw; }
.toast { background: #17171c; color: #fff; padding: 10px 18px; border-radius: 12px; font-size: calc(14px * var(--ui-font-scale, 1)); box-shadow: var(--shadow-lg); max-width: 92vw; animation: toast-in 0.2s ease; }
.toast.success { background: #065f46; }
.toast.error { background: #b91c1c; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* ============================================================
   移动端(默认):顶栏抽屉触发 + 底部 Tab
   ============================================================ */
@media (max-width: 767.98px) {
  #view { padding-top: 0; }
  .container { max-width: 640px; padding: 0 14px; }
}

/* ============================================================
   桌面 ≥768px:侧边栏接管,底部 Tab 隐藏
   ============================================================ */
@media (min-width: 768px) {
  body:not(.sb-collapsed) #nav { transform: none; }   /* 侧边栏常驻(可一键收起) */
  body.sb-collapsed #nav { transform: translateX(-100%); }
  .sb-backdrop { display: none !important; }
  body:not(.sb-collapsed) .sb-burger { display: none; }
  body.sb-collapsed .sb-burger { display: inline-flex; }
  .sb-collapse { display: inline-flex; position: absolute; top: 14px; right: 12px; }
  #tabbar { display: none; }
  body:not(.sb-collapsed) main {
    margin-left: var(--sbw);
  }
  main {
    min-height: 100vh;
    padding-bottom: 48px;
    transition: margin-left 0.22s ease;
  }
  .container { max-width: 900px; padding: 0 24px; }
  .container-wide { max-width: 1120px; }

  .grid { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
  .cols-3 { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
  .cols-4 { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
  .form-grid { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
  .wallet-top { grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 16px; }
  .me-grid { grid-template-columns: 1fr 1fr; }
  .quick-grid { grid-template-columns: repeat(4, 1fr); }
  .admin-grid { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }

  .btn { min-height: 38px; padding: 8px 18px; }
  .btn-sm { padding: 5px 12px; font-size: calc(13px * var(--ui-font-scale, 1)); min-height: 32px; }
  .input { min-height: 40px; font-size: calc(14px * var(--ui-font-scale, 1)); }
  .pill { min-height: 36px; }
  .seg-btn { min-height: 38px; }
  .admin-tab { min-height: 38px; }
  .tab { min-height: 40px; }
  .collapse-toggle { min-height: 36px; }
  .foot-btn { min-height: 36px; }
  .quick-item { min-height: 40px; }

  .hero { padding: 76px 0 84px; }
  .hero h1 { font-size: calc(40px * var(--ui-font-scale, 1)); }
  .hero-sub { font-size: calc(17px * var(--ui-font-scale, 1)); }
  .hero-kicker { font-size: calc(13px * var(--ui-font-scale, 1)); }
  .stat-bar { gap: 14px; }
  .stat { padding: 12px 26px; min-width: 130px; flex: initial; }
  .stat b { font-size: calc(24px * var(--ui-font-scale, 1)); }
  .section-title { font-size: calc(22px * var(--ui-font-scale, 1)); }
  .page-head h1 { font-size: calc(26px * var(--ui-font-scale, 1)); }
  .card { padding: 20px; }
  .balance-card { gap: 32px; }
  .search { max-width: 320px; }

  .chatg { height: 100vh; }
  .chat-wrap { height: calc(100vh - 40px); }

  .modal-sheet {
    left: 50%; right: auto; bottom: auto; top: 50%; transform: translate(-50%, -50%);
    width: 580px; max-width: 92vw; border-radius: 18px; max-height: 82vh;
    padding: 20px; animation: none;
  }
  #toast-root { top: 20px; }
}

/* ============================================================
   v8 · Grok 纯净侧边栏 + 语音交互 + 欢迎页
   ============================================================ */
.sb-actions { display: flex; gap: 8px; }
.sb-round {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--border);
  background: #fff; cursor: pointer; font-size: calc(15px * var(--ui-font-scale, 1)); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; transition: 0.15s;
}
.sb-round:hover { background: #e4e4e4; }
.sb-rows { display: flex; flex-direction: column; gap: 1px; }
.sb-row {
  display: flex; align-items: center; gap: 10px; border: none; background: none;
  padding: 8px 10px; min-height: 40px; border-radius: 10px; cursor: pointer;
  font-family: inherit; font-size: calc(13.5px * var(--ui-font-scale, 1)); color: var(--text); text-align: left; width: 100%;
}
.sb-row:hover { background: #ececee; }
.sb-ico { width: 20px; text-align: center; flex-shrink: 0; font-size: calc(14px * var(--ui-font-scale, 1)); }
.sb-row-txt { flex: 1; text-align: left; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-row-txt b { font-weight: 600; }
.chev { color: var(--muted); font-size: calc(14px * var(--ui-font-scale, 1)); flex-shrink: 0; }
.sb-div { height: 1px; background: var(--border); margin: 8px 10px; }
.sb-app-row { display: flex; align-items: center; gap: 9px; }
.sb-appbtn {
  margin-left: auto; background: var(--bg-soft); border: 1px solid var(--border);
  color: var(--text); font-size: calc(12.5px * var(--ui-font-scale, 1)); padding: 6px 12px; border-radius: 10px;
}
.sb-appbtn:hover { border-color: var(--primary); color: var(--primary); }
.sb-expander {
  display: flex; width: 100%; align-items: center; justify-content: space-between;
  border: none; background: none; font-family: inherit; font-size: calc(11.5px * var(--ui-font-scale, 1)); color: var(--muted);
  padding: 10px 10px 4px; cursor: pointer; letter-spacing: 1px;
}
.sb-expander:hover { color: var(--text); }
.sb-expander .chev { transition: transform 0.15s; }
.sb-expander.open .chev { transform: rotate(90deg); }
.sb-biz { display: flex; flex-direction: column; }

/* 语音模式 */


/* 欢迎页(未登录) */
.welcome { min-height: calc(100vh - 60px); display: flex; align-items: center; justify-content: center; }
.welcome-box { text-align: center; padding: 20px; }
.welcome-logo {
  width: 64px; height: 64px; border-radius: 20px; background: #c82779; color: #fff;
  font-size: calc(30px * var(--ui-font-scale, 1)); font-weight: 800; display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 14px; box-shadow: 0 10px 26px rgba(200, 39, 121, 0.35);
}
.welcome-box h1 { margin: 0 0 6px; font-size: calc(26px * var(--ui-font-scale, 1)); }
.welcome-tip { margin-top: 18px; }

/* 设置/支持弹层内容 */
.set-line { font-size: calc(13.5px * var(--ui-font-scale, 1)); line-height: 1.7; border-radius: 10px; padding: 9px 12px; margin: 6px 0; }
.set-line.ok { background: #f0faf4; color: #14683a; }
.set-line.warn { background: #fdf5e8; color: #8a5a12; }
.set-links { display: flex; flex-wrap: wrap; gap: 8px; }
.set-link {
  border: 1px solid var(--border); background: #fff; color: var(--text);
  border-radius: 10px; padding: 7px 13px; font-size: calc(13px * var(--ui-font-scale, 1));
}
.set-link:hover { border-color: var(--primary); color: var(--primary); }

/* ============================================================
   v9 · Grok 设置弹窗 / 日期分隔 / 通知条 / 全屏语音 / 暗色主题
   ============================================================ */
.day-sep { text-align: center; color: var(--muted); font-size: calc(12px * var(--ui-font-scale, 1)); padding: 14px 0 6px; }
.chat-notice { display: flex; align-items: center; gap: 10px; background: #f0f0f1; border: none; border-radius: 14px; padding: 11px 16px; margin: 0 14px 10px; font-size: calc(13.5px * var(--ui-font-scale, 1)); }
.chat-notice-ico { color: var(--muted); }
.chat-notice-txt { flex: 1; min-width: 0; }
.chat-notice-link { border: none; background: none; color: var(--text); font-family: inherit; font-size: calc(13px * var(--ui-font-scale, 1)); cursor: pointer; padding: 6px 8px; border-radius: 8px; }
.chat-notice-link:hover { background: #e4e4e4; }
.chat-notice-cta { background: #0c64c1; min-height: 34px; }
.chat-notice-cta:hover { background: #0a55a4; }
.chat-notice-x { border: none; background: none; color: var(--muted); cursor: pointer; font-size: calc(15px * var(--ui-font-scale, 1)); padding: 4px 6px; }

.cbtn.plus { background: var(--bg-soft); }

/* 设置弹窗(Grok 式大对话框) */
#settings-root { position: fixed; inset: 0; z-index: 140; }
.setmodal-mask { position: absolute; inset: 0; background: rgba(23, 23, 28, 0.45); }
.setmodal {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(1240px, 94vw); height: min(880px, 92vh);
  background: var(--bg); border-radius: 18px; box-shadow: var(--shadow-lg);
  display: flex; overflow: hidden;
}
.setmodal-x { position: absolute; top: 18px; right: 20px; border: none; background: none; font-size: calc(18px * var(--ui-font-scale, 1)); color: var(--muted); cursor: pointer; z-index: 2; }
.setmodal-nav { width: 240px; border-right: 1px solid var(--border); padding: 16px 12px; flex-shrink: 0; }
.setnav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; border: none; background: none;
  font-family: inherit; font-size: calc(14px * var(--ui-font-scale, 1)); color: var(--text); padding: 10px 12px; min-height: 42px;
  border-radius: 10px; cursor: pointer; text-align: left;
}
.setnav-item:hover { background: var(--bg-soft); }
.setnav-item.active { background: #e4e4e4; font-weight: 600; }
.setnav-ico { width: 20px; text-align: center; }
.setmodal-body { flex: 1; overflow-y: auto; padding: 26px 34px; }
.set-h2 { font-size: calc(21px * var(--ui-font-scale, 1)); margin: 0 0 18px; }
.set-sec { font-size: calc(12.5px * var(--ui-font-scale, 1)); color: var(--muted); margin: 18px 0 8px; }
.set-card { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 6px 18px; margin-bottom: 16px; }
[data-theme="dark"] .set-card { background: #1f1f22; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 0; border-bottom: 1px solid var(--bg-soft); }
.set-row:last-child { border-bottom: none; }
.set-row > span:first-child, .set-row > div:first-child { font-size: calc(14px * var(--ui-font-scale, 1)); }
.set-select { border: 1px solid var(--border); background: #fff; border-radius: 10px; min-height: 36px; padding: 0 10px; font-family: inherit; font-size: calc(13.5px * var(--ui-font-scale, 1)); color: var(--text); }
[data-theme="dark"] .set-select { background: #26262a; }
.tgl { position: relative; display: inline-block; width: 46px; height: 27px; flex-shrink: 0; }
.tgl input { opacity: 0; width: 0; height: 0; }
.tgl i { position: absolute; inset: 0; background: #d5d5da; border-radius: 999px; transition: 0.2s; cursor: pointer; }
.tgl i::before { content: ""; position: absolute; width: 21px; height: 21px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.25); }
.tgl input:checked + i { background: #0b93ff; }
.tgl input:checked + i::before { transform: translateX(19px); }
.promo-flex { display: flex; gap: 20px; align-items: flex-start; justify-content: space-between; padding: 8px 0; }
.promo-t { font-size: calc(17px * var(--ui-font-scale, 1)); font-weight: 700; }
.promo-d { font-size: calc(14px * var(--ui-font-scale, 1)); margin-top: 4px; }
.promo-s { font-size: calc(12.5px * var(--ui-font-scale, 1)); color: var(--muted); margin-top: 4px; }
.promo-btn { background: #17171c; margin-top: 14px; }
.promo-btn:hover { background: #333; }
.promo-tile {
  width: 150px; height: 84px; border-radius: 14px; flex-shrink: 0;
  background: linear-gradient(135deg, #c82779, #f64da3);
  color: #fff; font-size: calc(30px * var(--ui-font-scale, 1)); font-weight: 800; display: flex; align-items: center; justify-content: center;
}
.acct-row { display: flex; align-items: center; gap: 13px; padding: 8px 0; }
.acct-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.acct-sub { color: var(--muted); font-size: calc(13px * var(--ui-font-scale, 1)); }
.icon-btn { border: none; background: none; cursor: pointer; color: var(--muted); padding: 0 4px; }
.pill-btn { border: none; background: var(--bg-soft); border-radius: 999px; padding: 9px 18px; font-family: inherit; font-size: calc(13.5px * var(--ui-font-scale, 1)); cursor: pointer; color: var(--text); }
.pill-btn:hover { background: #e4e4e4; }
.rules-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 4px 0 12px; }
.rules-table { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.rules-head { display: flex; gap: 12px; padding: 10px 14px; color: var(--muted); font-size: calc(12.5px * var(--ui-font-scale, 1)); border-bottom: 1px solid var(--border); }
.rules-head span:first-child { flex: 1; }
.quota-bar { height: 8px; border-radius: 999px; background: #e7e7ec; overflow: hidden; margin: 8px 0 14px; }
.quota-bar i { display: block; height: 100%; background: #c82779; border-radius: 999px; }
.set-link { display: inline-block; }

/* 暗色主题(设置 - 主题 深色) */
[data-theme="dark"] {
  --bg: #191919; --bg-soft: #232326; --card: #1f1f22; --text: #f0f0f2; --muted: #9a9aa4;
  --border: #2c2c31; --shadow: 0 1px 3px rgba(0,0,0,0.4);
}
[data-theme="dark"] .sb-search, [data-theme="dark"] .sb-new, [data-theme="dark"] .sb-round,
[data-theme="dark"] .pill, [data-theme="dark"] .btn-outline, [data-theme="dark"] .set-select,
[data-theme="dark"] .chatg-inputbar, [data-theme="dark"] .qr-item img { background: #232326; }
[data-theme="dark"] .sb-conv:hover, [data-theme="dark"] .sb-link:hover, [data-theme="dark"] .sb-row:hover { background: #26262a; }
[data-theme="dark"] .sb-conv.active, [data-theme="dark"] .sb-link.active, [data-theme="dark"] .setnav-item.active { background: #333338; }
[data-theme="dark"] .msg-row.buyer .bubble, [data-theme="dark"] .msg-row.ai .bubble { background: #26262a; border-color: #2c2c31; }
[data-theme="dark"] .card, [data-theme="dark"] .stat, [data-theme="dark"] .modal-sheet { background: #1f1f22; }
[data-theme="dark"] .chatg-head { background: rgba(25, 25, 25, 0.92); }
[data-theme="dark"] .tab-item { background: rgba(25, 25, 25, 0.96); }

/* v9.3 Bot 粉脸头像(Tofu 式)+ SVG 图标尺寸 */
.botface { background: #f64da3 !important; position: relative; }
.botface .eye { position: absolute; width: 13%; height: 24%; background: #fff; border-radius: 999px; top: 30%; }
.botface .eye.l { left: 27%; }
.botface .eye.r { right: 27%; }
.botface.has-badge .vbadge {
  position: absolute; right: -6%; bottom: -6%; width: 42%; height: 42%;
  background: #ffb020; border: 2px solid #fcfcfc; border-radius: 50%;
}
.sb-row .ico { width: 19px; height: 19px; flex-shrink: 0; color: #3f3f48; }
.sb-round .ico { width: 19px; height: 19px; }
.cbtn .ico { width: 19px; height: 19px; }
.chatg-head .botface { width: 30px; height: 30px; font-size: calc(13px * var(--ui-font-scale, 1)); }

/* v9.4 语音按钮常显波形 + 胶囊头比例(Grok 实测) */
.chatg-head { padding: 8px 20px 8px 10px; gap: 10px; }
.chatg-head b { font-size: calc(15px * var(--ui-font-scale, 1)); }
.chatg-head .botface { width: 32px; height: 32px; }

/* ============================================================
   v9.5 中窄宽度(768–1100px):侧栏收缩为图标栏(Grok 同款)
   顶=当前会话粉脸大头照;中=⊕新建+市场;底=账户圆标
   ============================================================ */
.sb-rail-ava { display: none; }
@media (min-width: 768px) and (max-width: 1099.98px) {
  :root { --sbw: 84px; }
  #nav { width: var(--sbw); }
  main { margin-left: var(--sbw); }
  .container { max-width: 640px; padding: 0 16px; }
  .sb-top { align-items: center; padding: 12px 8px 6px; }
  .sb-actions, .sb-search, .sb-label, .sb-nav .sb-link:not(.sb-link-market),
  .sb-rows, .sb-div, .sb-biz, .sb-expander, .sb-appbtn, .sb-user-name, .sb-logout { display: none !important; }
  .sb-rail-ava {
    display: inline-flex; align-items: center; justify-content: center;
    width: 52px; height: 52px; border-radius: 16px; background: #ececee; margin: 2px auto 10px;
  }
  .sb-rail-ava .botface { width: 44px; height: 44px; font-size: calc(16px * var(--ui-font-scale, 1)); }
  .sb-rail-ava .avatar { width: 40px; height: 40px; font-size: calc(15px * var(--ui-font-scale, 1)); }
  .sb-new { width: 48px; height: 48px; border-radius: 50%; justify-content: center; padding: 0; }
  .sb-new i { margin: 0; }
  .sb-nav { border-top: none; padding: 6px 10px; }
  .sb-link { justify-content: center; padding: 11px 0; }
  .sb-app-row { justify-content: center; padding: 10px 0 calc(12px + env(safe-area-inset-bottom)); }
}
.sb-rail-link { display: none; align-items: center; justify-content: center; padding: 11px 0; color: var(--text); border-radius: 12px; }
.sb-rail-link .ico { width: 20px; height: 20px; }
.sb-rail-link:hover { background: #ececee; }
@media (min-width: 768px) and (max-width: 1099.98px) {
  .sb-rail-link { display: inline-flex; }
}
/* 首页视频位 */
.hero-video { position: relative; margin-top: 16px; }
.hero-video video { width: 100%; border-radius: var(--r, 12px); display: block; background: #000; }
.hero-video .btn { position: absolute; right: 10px; bottom: 10px; }


.browser-controls{margin-bottom:12px}.runtime-nav,.runtime-type{display:flex;gap:8px;flex-wrap:wrap;margin:8px 0}.runtime-nav input,.runtime-type input{flex:1;min-width:180px}.runtime-state{min-height:20px;overflow-wrap:anywhere}

/* Keep content beside the sidebar and mobile controls outside the drawer. */
.sb-backdrop{display:none}
@media(min-width:768px){
 body:not(.sb-collapsed) #view{margin-left:var(--sbw);width:calc(100% - var(--sbw))}
 body.sb-collapsed #view{margin-left:0;width:100%}
 #nav .sb{overflow-y:auto}
}
@media(max-width:767.98px){
 #view{margin-left:0;width:100%;padding-top:54px}
 #nav{transform:translateX(-100%)}
 body.sb-open #nav{transform:translateX(0)}
 body.sb-open>.sb-backdrop{display:block;z-index:89}
 body>.sb-burger{display:inline-flex;z-index:88}
}

/* 沙箱运营：节点红黄绿灯 */
.ops-light { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; background: var(--muted); }
.ops-light.ops-green { background: var(--green); }
.ops-light.ops-yellow { background: #d97706; }
.ops-light.ops-red { background: var(--danger); }
.ops-alerts { border-left: 4px solid var(--danger); }
.ops-alerts p { margin: 4px 0; }

/* 用户运营：时间线与每日活跃柱 */
.uo-event { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.uo-icon { flex: 0 0 28px; height: 28px; border-radius: 50%; background: var(--bg-soft); color: var(--text); font-size: calc(12px * var(--ui-font-scale, 1)); display: flex; align-items: center; justify-content: center; }
.uo-icon.uo-risk { background: var(--danger); color: #fff; }
.uo-icon.uo-payment { background: var(--green); color: #fff; }
.uo-icon.uo-admin { background: var(--blue); color: #fff; }
.ua-bars { display: flex; align-items: flex-end; gap: 3px; height: 140px; margin: 12px 0; overflow-x: auto; }
.ua-bar { flex: 1 0 14px; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.ua-bar i { display: block; width: 100%; min-height: 2px; background: var(--primary); border-radius: 3px 3px 0 0; }
.ua-bar small { font-size: calc(10px * var(--ui-font-scale, 1)); color: var(--muted); margin-top: 2px; white-space: nowrap; }

/* 驾驶舱 v2 */
.cockpit2 { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .cockpit2 { grid-template-columns: minmax(0, 1fr); } }
.cockpit2-banner { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; padding: 12px 16px; border-radius: 12px; border: 1px solid var(--border); background: var(--card); }
.cockpit2-banner small { color: var(--muted); margin-left: auto; }
.cockpit2-banner.cockpit2-red { border-left: 4px solid var(--danger); }
.cockpit2-banner.cockpit2-yellow { border-left: 4px solid #d97706; }
.cockpit2-banner.cockpit2-green { border-left: 4px solid var(--green); }
.cockpit2-drill { cursor: pointer; }
.cockpit2-drill:hover, .cockpit2-drill:focus-visible { border-color: var(--primary); outline: none; }
.cockpit2-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin: 12px 0; }
.cockpit2-chart { margin: 0; border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; background: var(--card); }
.cockpit2-chart figcaption { display: flex; gap: 8px; align-items: baseline; margin-bottom: 6px; }
.cockpit2-chart figcaption span { color: var(--muted); font-size: calc(13px * var(--ui-font-scale, 1)); }
.cockpit2-chart figcaption b { font-size: calc(18px * var(--ui-font-scale, 1)); font-variant-numeric: tabular-nums; color: var(--text); }
.cockpit2-chart figcaption small { color: var(--muted); font-size: calc(12px * var(--ui-font-scale, 1)); }
.cockpit2-chart svg { width: 100%; height: auto; display: block; }
.cockpit2-bar { fill: var(--primary); }
.cockpit2-line { fill: none; stroke: var(--primary); stroke-width: 2; }
.cockpit2-axis { stroke: var(--border); stroke-width: 1; }
.cockpit2-tick { fill: var(--muted); font-size: calc(10px * var(--ui-font-scale, 1)); }
.cockpit2-alerts { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow: auto; }
.cockpit2-alert { border: 1px solid var(--border); border-left-width: 4px; border-radius: 10px; padding: 8px 10px; margin: 8px 0; }
.cockpit2-alert.cockpit2-sev-critical { border-left-color: var(--danger); }
.cockpit2-alert.cockpit2-sev-warning { border-left-color: #d97706; }
.cockpit2-alert.is-resolved { opacity: .6; }
.cockpit2-alert p { margin: 4px 0; }
.cockpit2-dot { fill: var(--primary); stroke: var(--card); stroke-width: 2; }
