/* ===== 粟子决策台 · 对话页（品牌紫配色，禁蓝 230-283°） ===== */
:root {
  --purple: #B026CF;        /* 主色 289° */
  --purple-deep: #8A17A8;   /* 深紫 288° */
  --purple-light: #F7EAFB;  /* 浅底 286° */
  --ink: #2B1030;           /* 文字 290° */
  --gold: #FCD34D;          /* 金：仅 P1 */
  --red: #F43F5E;           /* 红：仅 P0 / error */
  --line: #EDD6F0;          /* 分隔线（浅紫灰） */
  --muted: #7A5C84;         /* 次要文字 */
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  display: flex;
  flex-direction: column;
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--purple-light);
  color: var(--ink);
}

/* ===== 顶部品牌栏 ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--purple);
  color: #FFFFFF;
  box-shadow: 0 2px 8px rgba(43, 16, 48, 0.25);
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.brand-icon {
  width: 36px; height: 36px;
  flex: none;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  background: var(--purple-deep);
  color: #FFFFFF;
  font-size: 18px; font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.brand-name { font-size: 16px; font-weight: 700; letter-spacing: 0.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 11px; opacity: 0.85; margin-top: 1px; }

.model-mount { flex: none; min-height: 34px; min-width: 60px; }

/* ===== 手机端顶栏收缩（2026-09-29：四元素挤爆修复）===== */
@media (max-width: 640px) {
  .topbar { padding: 8px 10px; gap: 8px; }
  .brand { gap: 7px; flex: none; }                  /* 自然宽度，13px 字号刚好放下完整「粟子决策台」 */
  .brand-text { min-width: 0; overflow: hidden; }  /* 无此行 nowrap 品牌名会撑穿容器、与模型选择器重叠 */
  .brand-icon { width: 30px; height: 30px; font-size: 15px; border-radius: 8px; }
  .brand-name { font-size: 13px; letter-spacing: 0; }
  .brand-en { display: none; }          /* 「Suzi SaaS 」前缀手机端隐藏，只留「粟子决策台」 */
  .brand-sub { display: none; }          /* 副标题手机端隐藏 */
  .model-mount { min-width: 0; min-height: 30px; max-width: 100px; overflow: hidden; }
  .model-mount .ms-trigger { max-width: 100%; }   /* ms-cur 自带省略号，超宽截断模型名 */
  .ask-back { margin-left: 0 !important; padding: 6px 9px !important; }  /* !important：压过 ask.html 内联 <style> 的 margin-left:8px */
  .ask-back-t { display: none; }                  /* 手机端返回只留 ← 箭头，给品牌名让位 */
  .ask-acct { font-size: 11px; padding: 5px 9px; margin-left: 0; }
  .chat { padding: 14px 10px 20px; }
  .oneline-card { font-size: 19px; padding: 10px 12px; }
  .msg.ai .bubble { max-width: 88%; }
  .msg.user .bubble { max-width: 82%; }
  .welcome { padding: 22px 14px; }
}

/* 🔒 登录提示行（欢迎区内） */
.login-note {
  display: flex; align-items: center; justify-content: center; gap: 5px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--muted);
  background: var(--purple-light);
  border: 1px dashed var(--purple);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 14px;
}
.login-note .ln-ico { font-size: 13px; }
.login-note a { color: var(--purple-deep); font-weight: 700; text-decoration: none; }
.login-note a:hover { text-decoration: underline; }

/* ===== 对话区 ===== */
.chat {
  flex: 1;
  overflow-y: auto;
  padding: 18px 14px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 欢迎卡 */
.welcome {
  margin: auto;
  max-width: 460px;
  text-align: center;
  background: #FFFFFF;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 22px;
}
.welcome-title { font-size: 18px; font-weight: 700; color: var(--purple-deep); }
.welcome-desc { font-size: 13px; color: var(--muted); margin: 10px 0 16px; line-height: 1.6; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip {
  border: 1px solid var(--purple);
  background: var(--purple-light);
  color: var(--purple-deep);
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.chip:hover { background: var(--purple); color: #FFFFFF; }

/* 气泡行 */
.msg { display: flex; gap: 10px; max-width: 100%; }
.msg.user { justify-content: flex-end; }

.msg-avatar {
  width: 32px; height: 32px;
  flex: none;
  border-radius: 50%;
  background: var(--purple);
  color: #FFFFFF;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700;
  margin-top: 2px;
}

.bubble {
  border-radius: 14px;
  padding: 10px 14px;
  line-height: 1.65;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.msg.user .bubble {
  background: var(--purple);
  color: #FFFFFF;
  border-bottom-right-radius: 4px;
  max-width: 70%;
  white-space: pre-wrap;
}

.msg.ai { align-items: flex-start; }
.msg.ai .bubble {
  background: #FFFFFF;
  color: var(--ink);
  border-bottom-left-radius: 4px;
  max-width: 75%;
  width: fit-content;
}

/* ===== 一行答案卡 ===== */
.oneline-card {
  font-size: 24px;
  font-weight: 700;
  color: var(--purple-deep);
  background: var(--purple-light);
  border-left: 4px solid var(--purple);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
  line-height: 1.45;
}

/* ===== 行动列表 ===== */
.actions-title {
  font-size: 12px; font-weight: 700; color: var(--muted);
  letter-spacing: 1px; margin-bottom: 8px;
}
.action-item { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 8px; }

.prio {
  flex: none;
  min-width: 30px;
  text-align: center;
  font-size: 11px; font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  color: #FFFFFF;
}
.prio.p0 { background: var(--red); }
.prio.p1 { background: var(--gold); color: var(--ink); }
.prio.p2 { background: var(--purple); }

.action-text { font-size: 13px; color: var(--ink); }

/* ===== 可折叠区（调度时间线 / 完整推演） ===== */
.fold { margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 10px; }
.fold summary {
  cursor: pointer;
  font-size: 12px; font-weight: 700; color: var(--purple-deep);
  user-select: none;
  list-style: none;
}
.fold summary::-webkit-details-marker { display: none; }
.fold summary::before { content: "▸ "; }
.fold[open] summary::before { content: "▾ "; }

.timeline { margin-top: 8px; border-left: 3px solid var(--purple); padding-left: 10px; }
.tl-row {
  display: flex; align-items: baseline; gap: 8px;
  padding: 4px 0;
  font-size: 13px;
}
.tl-role { font-weight: 700; color: var(--ink); }
.tl-stance { font-size: 11px; color: var(--muted); }
.tl-ms { margin-left: auto; font-size: 11px; color: var(--muted); white-space: nowrap; }
.tl-total {
  margin-top: 6px; padding-top: 6px;
  border-top: 1px solid var(--line);
  font-size: 11px; color: var(--muted);
}

.synthesis {
  margin-top: 8px;
  font-size: 12px;
  color: var(--ink);
  white-space: pre-wrap;
  max-height: 320px;
  overflow-y: auto;
  background: var(--purple-light);
  border-radius: 8px;
  padding: 10px;
}

/* meta 行 */
.meta-line { margin-top: 10px; font-size: 11px; color: var(--muted); }

/* 💰 积分回执行（2026-09-23：真实调用扣减后展示本次消耗与余额） */
.bill-line { margin-top: 5px; font-size: 11.5px; color: var(--purple-deep); font-weight: 600; }
.bill-dim { color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }

/* 错误卡动作区（重试 + 升级入口） */
.err-acts { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.upgrade-btn { font-size: 12px; color: var(--purple-deep); font-weight: 600; text-decoration: none;
  border: 1px solid currentColor; border-radius: 8px; padding: 6px 12px; white-space: nowrap; }
.upgrade-btn:hover { background: var(--purple-light); }

/* 头部账户 chip（登录 / 注册入口） */
.ask-acct { display: inline-flex; align-items: center; gap: 6px; flex: none; margin-left: 10px;
  font-size: 12px; font-weight: 600; color: var(--purple-deep); text-decoration: none;
  background: #FFFFFF; border: 1px solid #EAD1F0; border-radius: 999px; padding: 6px 12px; white-space: nowrap; }
.ask-acct:hover { background: var(--purple-light); }
.ask-acct .dot { width: 7px; height: 7px; border-radius: 50%; background: #C9A9D4; flex: 0 0 auto; }
.ask-acct .dot.on { background: #0F7B3E; }
@media (max-width: 420px) { .ask-acct { font-size: 11px; padding: 5px 9px; } }

/* ===== loading 态 ===== */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(43, 16, 48, 0.35);   /* 深紫半透明遮罩 */
  display: flex; align-items: center; justify-content: center;
}
.loading-overlay.hidden { display: none; }

.loading-card {
  background: #FFFFFF;
  border-radius: 14px;
  padding: 24px 32px;
  text-align: center;
  box-shadow: 0 8px 24px rgba(43, 16, 48, 0.3);
}
.loading-text { margin-top: 12px; font-size: 13px; color: var(--purple-deep); font-weight: 700; }

.spinner {
  width: 34px; height: 34px;
  margin: 0 auto;
  border: 4px solid var(--line);
  border-top-color: var(--purple);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== error 态 ===== */
.error-card {
  background: #FFFFFF;
  border: 1px solid var(--red);
  border-left: 4px solid var(--red);
  border-radius: 10px;
  padding: 10px 12px;
  margin-top: 8px;
  font-size: 13px;
}
.error-msg { color: var(--red); font-weight: 700; }
.retry-btn {
  margin-top: 8px;
  background: var(--red);
  color: #FFFFFF;
  border: none;
  border-radius: 6px;
  padding: 5px 14px;
  font-size: 12px;
  cursor: pointer;
}
.retry-btn:hover { opacity: 0.85; }

/* ===== 游客限次卡（2026-09-23 · Kimi 同款口径） ===== */
.quota-card {
  background: #FFFFFF;
  border: 1px solid rgba(176,38,207,.18);
  border-radius: 14px;
  padding: 16px 15px 14px;
  margin-top: 8px;
  text-align: center;
}
.quota-ico { font-size: 26px; line-height: 1; margin-bottom: 8px; }
.quota-t { font-size: 14.5px; font-weight: 700; color: #2B1030; line-height: 1.55; }
.quota-s { font-size: 12.5px; color: #8B7391; margin-top: 6px; }
.quota-acts { display: flex; gap: 9px; margin-top: 14px; justify-content: center; flex-wrap: wrap; }
.quota-btn {
  background: linear-gradient(135deg, #C13FE0 0%, #8A17A8 100%);
  color: #FFFFFF; text-decoration: none; font-size: 13px; font-weight: 600;
  padding: 10px 16px; border-radius: 11px; white-space: nowrap;
}
.quota-btn.ghost { background: #FFFFFF; color: #8A17A8; border: 1px solid #EDDAF1; }
.quota-btn:hover { opacity: .92; }

/* ===== 底部输入框（sticky） ===== */
.inputbar {
  position: sticky;
  bottom: 0;
  z-index: 10;
  display: flex;
  gap: 10px;
  align-items: flex-end;
  padding: 10px 14px;
  background: #FFFFFF;
  border-top: 1px solid var(--line);
}

#input {
  flex: 1;
  resize: none;
  max-height: 120px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--ink);
  background: #FFFFFF;
  outline: none;
  line-height: 1.5;
}
#input:focus { border-color: var(--purple); }

.send-btn {
  flex: none;
  background: var(--purple);
  color: #FFFFFF;
  border: none;
  border-radius: 12px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.send-btn:hover { background: var(--purple-deep); }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; }
