/* === 购物助手 · 购物助手 === 扁平化 / 顶栏=品牌赭红 / 卡片=冷色 */
:root {
  /* 品牌色 — 取自 logo（favicon-gandan-v2.png 调色板）*/
  --brand: #c34125;
  --brand-strong: #a8351e;

  /* 冷色调 — 卡片 / 价格 / 装饰线 */
  --cool: #2563eb;
  --cool-strong: #1d4ed8;
  --cool-soft: #dbeafe;
  --cool-tint: #eff6ff;

  /* 中性 — 冷调白，与卡片冷色协调 */
  --bg: #f6f8fb;
  --bg-2: #eaeef5;
  --panel: #ffffff;
  --ink: #1f2937;
  --ink-2: #5b6472;
  --ink-3: #95a0b0;
  --line: #e3e8ef;
  --line-soft: #eef1f6;

  /* 功能色 */
  --green: #2f8a5a;
  --green-soft: #e7f4ed;
  --red: #c0392b;
  --red-soft: #fdecea;

  /* 扁平化：无玻璃、无深阴影；最多 1px 描边或 0 阴影 */
  --shadow: none;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%;
  overflow: hidden;            /* 整页不可滚动 — 只有 #messages 滚 */
  background: var(--bg);      /* 扁平：纯色，不要渐变 */
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "PingFang SC",
    "Hiragino Sans GB", "Microsoft Yahei", sans-serif;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}
body { display: flex; flex-direction: column; }

/* === 顶部栏：扁平 === */
header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 32px;
  background: var(--brand);
  border-bottom: 1px solid var(--brand-strong);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  width: 42px; height: 42px;
  object-fit: contain; display: block;
}
.login-logo {
  width: 36px; height: 36px;
  object-fit: contain;
}
.login-title {
  display: flex; align-items: center; gap: 10px;
  justify-content: center;
}
.name {
  font-size: 16px; font-weight: 600; letter-spacing: -0.025em;
  color: #fff;
}
.tag { font-size: 11.5px; color: rgba(255,255,255,0.75); margin-top: 1px;
       letter-spacing: 0.02em; }
.meta { display: flex; gap: 8px; align-items: center; }

/* 状态指示器：扁平 */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: 999px;
  font-size: 12px; font-weight: 500;
  background: rgba(255, 255, 255, 0.18);  /* 顶栏是品牌红，半透白底 */
  color: #fff;
  border: 1px solid transparent;
}
.pill::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
}
.pill.ok { color: #fff; background: rgba(255, 255, 255, 0.18); }
.pill.ok::before {
  background: #b9e6c7;
  animation: pulse 2s ease-in-out infinite;
}
.pill.bad { color: #fff; background: rgba(255, 255, 255, 0.18); }
.pill.bad::before { background: #ffd6c8; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

button.ghost {
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: transparent;
  color: #fff;
  border-radius: 8px; padding: 6px 14px;
  cursor: pointer; font-size: 13px; font-weight: 500;
  transition: all 0.15s;
}
button.ghost:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.7);
}

/* === 主区：历史(左) / 聊天或订单(中) / 购物车(右) === */
main {
  flex: 1;
  min-height: 0;                /* 占满 header 之外的剩余高度，底部不会被顶出屏幕 */
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 460px;
  grid-template-rows: 100%;
  grid-template-areas: "history main cart";
  overflow: hidden;
}

section#chat {
  grid-area: main;
  display: flex; flex-direction: column;
  min-width: 0; background: var(--bg);
  position: relative;
  overflow: hidden;            /* 容器不滚，让 #messages 滚 */
  height: 100%;
}

/* === 右侧栏：扁平，固定在 grid "cart" 区，不参与视图切换 === */
aside#rightbar {
  grid-area: cart;
  background: var(--bg);
  border-left: 1px solid var(--line);
  padding: 16px 14px;
  overflow: auto;
  display: flex; flex-direction: column; gap: 12px;
}
.side-block {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
}
/* 唯一 side-block：撑满侧栏剩余高度；里面的 cart-panel 自身滚动 */
.side-block-cart {
  display: flex; flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}
.side-block-cart .cart-panel {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(15,15,16,0.18) transparent;
  padding-right: 4px;
  margin-right: -4px;
}
.side-block-cart .cart-panel::-webkit-scrollbar { width: 5px; }
.side-block-cart .cart-panel::-webkit-scrollbar-thumb {
  background: rgba(15,15,16,0.18); border-radius: 999px;
}
.side-title {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; font-weight: 600; color: var(--ink);
  margin-bottom: 14px; letter-spacing: -0.01em;
}
.side-badge {
  background: var(--bg-2);
  color: var(--ink-2);
  padding: 2px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 500;
  letter-spacing: -0.005em;
}
.side-badge.zero { background: transparent; color: var(--ink-3); }
.side-badge.has { background: var(--brand); color: #fff; }

/* === 购物车面板 === */
.cart-panel { display: flex; flex-direction: column; gap: 10px; }
.cart-merchant { display: flex; flex-direction: column; gap: 8px; }
.cart-merchant-name {
  font-size: 12px; font-weight: 600;
  color: var(--ink-2); letter-spacing: 0.02em;
  padding: 4px 4px 2px;
  text-transform: none;
}
.cart-panel .cart-empty {
  font-size: 12.5px; color: var(--ink-3);
  padding: 28px 8px; text-align: center;
  background: rgba(15, 15, 16, 0.025);
  border-radius: 14px;
  border: 1px dashed rgba(15, 15, 16, 0.08);
}
.cart-panel .cart-err {
  font-size: 12.5px;
  padding: 14px 14px;
  background: var(--red-soft);
  border: 1px solid rgba(220, 38, 38, 0.15);
  border-radius: 14px;
  color: var(--ink);
  line-height: 1.55;
}
.cart-panel .cart-err-code {
  font-family: var(--mono);
  font-weight: 600; color: var(--red);
  font-size: 13px; margin-bottom: 4px;
}
.cart-panel .cart-err-msg {
  font-size: 12.5px; color: var(--ink); margin-bottom: 4px;
}
.cart-panel .cart-err-detail {
  font-family: var(--mono); font-size: 11px;
  color: var(--ink-2); word-break: break-all;
  background: var(--panel); padding: 6px 8px;
  border-radius: 6px; margin-top: 6px;
  max-height: 80px; overflow: auto;
}
.cart-panel .cart-item {
  display: grid;
  grid-template-columns: 40px 1fr 92px auto auto;
  align-items: center;
  gap: 10px;
  padding: 12px;
  min-height: 72px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  transition: border-color 0.18s;
  animation: cartPop 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes cartPop {
  0% { transform: scale(0.94); opacity: 0; }
  60% { transform: scale(1.01); }
  100% { transform: scale(1); opacity: 1; }
}
.cart-panel .cart-item:hover {
  border-color: var(--cool);
}
.cart-panel .cart-item .ci-thumb {
  width: 40px; height: 40px; border-radius: 6px;
  overflow: hidden;
  background: var(--cool-tint);
  display: grid; place-items: center;
}
.cart-panel .cart-item .ci-thumb img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
}
.cart-panel .cart-item .ci-thumb-fallback {
  font-size: 18px; font-weight: 600;
  color: var(--cool);
  letter-spacing: -0.02em;
  line-height: 1;
}
.cart-panel .cart-item .ci-body {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  gap: 3px; justify-content: center;
}
.cart-panel .cart-item .ci-name {
  font-size: 13.5px; font-weight: 600; line-height: 1.4;
  color: var(--ink);
  letter-spacing: -0.015em;
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.cart-panel .cart-item .ci-spec {
  font-size: 11.5px; line-height: 1.45;
  color: var(--ink-3);
  letter-spacing: -0.005em;
  display: -webkit-box; -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.cart-panel .cart-item .ci-meta {
  font-size: 11.5px; color: var(--ink-2); margin-top: 3px;
  display: flex; gap: 8px; align-items: center;
}
.cart-panel .cart-item .ci-price {
  color: var(--cool); font-weight: 600;
  font-size: 13.5px;
}
/* 数量增减步进器 */
.cart-panel .ci-qty-stepper {
  display: inline-flex; align-items: center;
  justify-self: end;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  overflow: hidden;
  flex-shrink: 0;
}
.cart-panel .ci-price,
.cart-panel .ci-del { justify-self: end; }
.cart-panel .ci-qty-btn {
  width: 22px; height: 24px;
  background: transparent; border: 0; cursor: pointer;
  color: var(--ink-2);
  display: grid; place-items: center;
  font-size: 14px; line-height: 1;
  transition: background 0.12s, color 0.12s;
}
.cart-panel .ci-qty-btn:hover { background: var(--cool-tint); color: var(--cool); }
.cart-panel .ci-qty-btn:active { background: var(--cool-soft); }
.cart-panel .ci-qty-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.cart-panel .ci-qty-val {
  min-width: 24px; padding: 0 4px;
  text-align: center; font-size: 12.5px; font-weight: 600;
  color: var(--ink);
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  line-height: 24px;
}
.cart-panel .cart-item.cart-row-loading { opacity: 0.55; pointer-events: none; }
.cart-panel .ci-check {
  width: 16px; height: 16px; border-radius: 5px; flex-shrink: 0;
  border: 1.5px solid rgba(15, 15, 16, 0.15);
  display: grid; place-items: center;
  font-size: 10px; color: transparent;
  transition: all 0.15s;
  background: rgba(255, 255, 255, 0.6);
}
.cart-panel .ci-check.on {
  background: var(--ink); border-color: var(--ink); color: #fff;
}
.cart-panel .ci-check.on::before { content: "✓"; font-weight: 700; }

/* 购物车行：删除按钮 + 加载/淡出动效 */
.cart-panel .cart-item .ci-del {
  width: 26px; height: 26px;
  border: none; border-radius: 8px;
  background: transparent;
  color: var(--ink-3);
  display: grid; place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  margin-left: 4px;
  transition: all 0.15s;
  opacity: 0;
}
.cart-panel .cart-item:hover .ci-del { opacity: 1; }
.cart-panel .cart-item .ci-del:hover {
  background: var(--red-soft);
  color: var(--red);
}
.cart-panel .cart-item .ci-del svg { width: 14px; height: 14px; }
.cart-panel .cart-item.removing {
  opacity: 0.5; pointer-events: none;
}
.cart-panel .cart-item.removed {
  opacity: 0; transform: translateX(20px);
  transition: all 0.2s ease;
}
.cart-panel .cart-item { overflow: hidden; }

/* Toast 提示 */
#toast-host {
  position: fixed; right: 24px; bottom: 92px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 999; pointer-events: none;
}
.toast {
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  letter-spacing: -0.005em;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.toast-err { background: var(--red); }

/* 购物车底部操作区：检查 + 去结算 */
.cart-actions {
  display: flex; gap: 8px;
  padding: 12px 4px 4px;
  border-top: 1px dashed rgba(15, 15, 16, 0.06);
  margin-top: 4px;
}
.cart-actions[hidden] { display: none; }
.cart-btn {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px; font-weight: 600;
  letter-spacing: -0.005em;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  text-decoration: none;
  transition: border-color 0.18s, background 0.18s;
}
.cart-btn:hover {
  background: var(--cool-tint);
  border-color: var(--cool);
}
.cart-btn-check .cart-btn-icon {
  width: 18px; height: 18px;
  color: currentColor;
  flex-shrink: 0;
  transition: transform 0.18s ease;
}
.cart-btn-check:hover .cart-btn-icon { transform: rotate(-6deg) scale(1.08); }
.cart-btn-primary {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}
.cart-btn-primary:hover {
  background: var(--brand-strong);
  border-color: var(--brand-strong);
}

.cart-totals {
  margin-top: 6px; padding: 14px;
  background: var(--panel);
  border-radius: 10px;
  border: 1px solid var(--line);
  font-size: 13px;
}
.cart-totals .line {
  display: flex; justify-content: space-between;
  margin: 5px 0; color: var(--ink-2);
}
.cart-totals .line span:last-child { color: var(--ink); font-weight: 500; }
.cart-totals .grand {
  font-size: 15px; font-weight: 700;
  margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--ink);
}
.cart-totals .grand span:last-child { color: var(--cool); }
.cart-totals .freight-free { color: var(--green); font-weight: 600; }
.cart-totals .checkout-btn {
  width: 100%; margin-top: 14px;
  padding: 12px;
  background: var(--brand); color: #fff;
  border: none; border-radius: 8px;
  font-size: 13.5px; font-weight: 600;
  cursor: pointer;
  transition: background 0.18s;
  letter-spacing: -0.005em;
}
.cart-totals .checkout-btn:hover:not(:disabled) {
  background: var(--brand-strong);
}
.cart-totals .checkout-btn:disabled {
  background: var(--line);
  color: var(--ink-3);
  cursor: not-allowed;
}

/* === 登录模态 === */
.login-modal {
  position: fixed; inset: 0;
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  animation: loginFade 0.18s ease-out;
}
.login-modal[hidden] { display: none; }
.login-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(15, 15, 16, 0.42);
  backdrop-filter: blur(2px);
}
.login-modal-panel {
  position: relative;
  width: min(420px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  overflow: auto;
  background: var(--panel);
  border-radius: 14px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
  padding: 28px 26px 24px;
  animation: loginPop 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.login-modal-close {
  position: absolute;
  top: 10px; right: 12px;
  width: 28px; height: 28px;
  border: 0; background: transparent;
  font-size: 22px; line-height: 1;
  color: var(--ink-3, #888);
  cursor: pointer;
  border-radius: 6px;
  font-family: inherit;
  padding: 0;
}
.login-modal-close:hover { background: rgba(0,0,0,0.06); color: var(--ink); }
/* 模态里的登录卡：去掉 .ui-card 自己的外边距/背景 */
.login-modal-panel .ui-login-card {
  margin: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
}
@keyframes loginFade {
  from { opacity: 0; } to { opacity: 1; }
}
@keyframes loginPop {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* === 聊天消息 — 唯一滚动区 === */
#messages {
  flex: 1 1 auto;
  min-height: 0;               /* flex 子项滚动需要 */
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 32px 20px 56px;
  display: flex; flex-direction: column; gap: 20px;
  scrollbar-width: thin;
  scrollbar-color: rgba(15, 15, 16, 0.18) transparent;
}
#messages::-webkit-scrollbar { width: 8px; }
#messages::-webkit-scrollbar-thumb {
  background: rgba(15, 15, 16, 0.18); border-radius: 999px;
}
#messages::-webkit-scrollbar-thumb:hover {
  background: rgba(15, 15, 16, 0.28);
}
.msg {
  display: flex; gap: 10px;
  max-width: 700px; width: 100%; margin: 0 auto;
  animation: msgIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
/* 双方头像再向外侧偏移：助手头像向左、用户头像向右 */
.msg.assistant .avatar { margin-left: -35px; }
.msg.user .avatar { margin-right: -35px; }
@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.msg .avatar {
  width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0;
  display: grid; place-items: center;
  font-size: 12.5px; font-weight: 600;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  letter-spacing: -0.02em;
}
.msg.user { flex-direction: row-reverse; }
.msg.user .avatar {
  background: var(--cool);
  color: #fff; border-color: var(--cool-strong);
}
/* 登录用户头像 — 扁平人头图标（替换原来的首字） */
.msg.user .avatar .ic-user {
  width: 17px;
  height: 17px;
}
.msg .body {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px 12px 12px 4px;
  padding: 10px 14px;
  font-size: 14.5px; line-height: 1.65;
  min-width: 60px; max-width: 100%;
  letter-spacing: -0.005em;
  color: var(--ink);
}
.msg.user .body {
  background: var(--cool);
  color: #fff;
  border-color: var(--cool-strong);
  border-radius: 12px 12px 4px 12px;
}
.msg .body:has(.text:empty):not(:has(.ui > *)) {
  padding: 0; border: none; background: transparent;
}

/* === Markdown 渲染样式（仅作用于消息文本 .text） === */
.msg .body .text p {
  margin: 0 0 12px;
  line-height: 1.75;
  letter-spacing: -0.005em;
}
.msg .body .text p:last-child { margin-bottom: 0; }
.msg .body .text strong {
  font-weight: 600; color: inherit;
  background: var(--cool-soft);
  padding: 0 2px;
  border-radius: 2px;
}
.msg.user .body .text strong {
  background: rgba(255,255,255,0.22);
}
.msg .body .text em { font-style: italic; color: var(--ink-2); }
.msg.user .body .text em { color: rgba(255, 255, 255, 0.85); }
.msg .body .text a {
  color: var(--cool); text-decoration: none;
  border-bottom: 1px solid var(--cool-soft);
  transition: border-color 0.15s;
}
.msg .body .text a:hover { border-color: var(--cool); }
.msg.user .body .text a {
  color: #fff; border-bottom-color: rgba(255, 255, 255, 0.5);
}
.msg.user .body .text a:hover { border-bottom-color: #fff; }
.msg .body .text code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: var(--cool-tint);
  padding: 1px 6px; border-radius: 4px;
  color: var(--cool);
}
.msg.user .body .text code {
  background: rgba(255, 255, 255, 0.18); color: #fff;
}
.msg .body .text pre {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px; margin: 10px 0;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.55;
}
.msg .body .text pre code {
  background: transparent; padding: 0; color: var(--ink);
  font-size: 13px;
}
.msg .body .text h1, .msg .body .text h2, .msg .body .text h3,
.msg .body .text h4, .msg .body .text h5, .msg .body .text h6 {
  margin: 14px 0 8px; font-weight: 600; line-height: 1.35;
  letter-spacing: -0.018em;
  color: var(--ink);
}
.msg .body .text h1 { font-size: 19px; }
.msg .body .text h2 { font-size: 17px; }
.msg .body .text h3 { font-size: 15.5px; }
.msg .body .text h4, .msg .body .text h5, .msg .body .text h6 { font-size: 14.5px; }
.msg .body .text ul, .msg .body .text ol {
  margin: 8px 0 10px; padding-left: 22px;
  line-height: 1.7;
}
.msg .body .text ul li, .msg .body .text ol li { margin: 4px 0; }
.msg .body .text li::marker { color: var(--cool); font-weight: 600; }
.msg .body .text hr {
  border: none; height: 1px;
  background: var(--line); margin: 14px 0;
}
.msg .body .text blockquote {
  margin: 10px 0; padding: 8px 14px;
  border-left: 3px solid var(--cool);
  background: var(--cool-tint);
  border-radius: 0 8px 8px 0;
  color: var(--ink-2);
  line-height: 1.65;
}
.msg .body .text blockquote p { margin: 0 0 4px; }

/* 流式文本光标 */
.cursor::after {
  content: "▍"; display: inline-block;
  color: var(--cool); font-weight: 400;
  animation: blink 1s steps(2, end) infinite;
  margin-left: 1px;
}
@keyframes blink { 50% { opacity: 0; } }

/* 工具调用小标记 */
.tool-bubbles {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px;
}
.tool-bubbles .bubble {
  font-family: var(--mono); font-size: 11.5px;
  padding: 3px 9px; border-radius: 4px;
  background: var(--bg-2); color: var(--ink-2);
  border: 1px solid var(--line);
}
.tool-bubbles .bubble.ok {
  background: var(--green-soft); color: var(--green); border-color: var(--green-soft);
}
.tool-bubbles .bubble.error {
  background: var(--red-soft); color: var(--red); border-color: var(--red-soft);
}

/* === UI 组件卡 === */
.ui-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 20px;
  margin-top: 14px;
  animation: msgIn 0.35s ease;
}
.ui-title {
  font-weight: 600; font-size: 15px;
  margin-bottom: 14px;
  display: flex; align-items: center; gap: 8px;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.ui-title::before {
  content: ""; width: 3px; height: 16px;
  background: var(--cool); border-radius: 2px;
}

/* 商品网格 — present_products 工具产出 */
.ui-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}
.ui-card-item {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--panel);
  display: flex; flex-direction: column;
  transition: all 0.2s ease;
}
.ui-card-item:hover {
  border-color: var(--cool);
}
.ui-card-item img {
  width: 100%; aspect-ratio: 1;
  object-fit: cover; background: var(--bg-2);
}
.ui-card-name {
  font-size: 13.5px; font-weight: 500; line-height: 1.45;
  color: var(--ink);
  padding: 12px 14px 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
  letter-spacing: -0.005em;
}
.ui-card-price {
  color: var(--cool); font-weight: 700; font-size: 17px;
  letter-spacing: -0.02em;
  padding: 6px 14px 14px;
}
.ui-card-reason {
  font-size: 11.5px; color: var(--green);
  margin: 0 12px 12px;
  background: var(--green-soft);
  padding: 6px 10px; border-radius: 6px;
  line-height: 1.5;
}
/* === 检索 loading 骨架屏 === */
.ui-search-loading .ui-title { font-weight: 500; color: var(--ink-2); }
.ui-search-loading .spinner {
  display: inline-block; width: 12px; height: 12px;
  border: 2px solid var(--cool-soft);
  border-top-color: var(--cool);
  border-radius: 50%;
  margin-right: 6px;
  animation: spin 0.8s linear infinite;
  vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.ui-card-item.skeleton { pointer-events: none; }
.ui-card-item.skeleton .sk-img {
  aspect-ratio: 1;
  background: linear-gradient(90deg,
    rgba(15, 15, 16, 0.04) 0%,
    rgba(15, 15, 16, 0.08) 50%,
    rgba(15, 15, 16, 0.04) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
.ui-card-item.skeleton .sk-line {
  height: 12px; border-radius: 6px; margin: 10px 14px 0;
  background: linear-gradient(90deg,
    rgba(15, 15, 16, 0.04) 0%,
    rgba(15, 15, 16, 0.08) 50%,
    rgba(15, 15, 16, 0.04) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
.ui-card-item.skeleton .sk-line.w70 { width: 70%; }
.ui-card-item.skeleton .sk-line.w40 { width: 40%; height: 14px; margin-top: 8px; }
@keyframes shimmer {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* 加车 + 按钮 — 浮在图片右上角，避免和描述重叠 */
.ui-card-add {
  position: absolute;
  right: 10px; top: 10px;
  width: 32px; height: 32px;
  border: none; border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 18px; line-height: 1; font-weight: 400;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.18s, background 0.18s;
  z-index: 2;
}
.ui-card-add:hover {
  background: var(--brand-strong);
  transform: scale(1.1);
}
.ui-card-add:active {
  transform: scale(0.92);
}
.ui-card-add:disabled {
  cursor: default;
}
.ui-card-add.done {
  background: var(--green);
}
.ui-card-add.err {
  background: var(--red);
}

/* 商品卡 + 按钮展开为数量选择器 */
.ui-card-add.stepper-open {
  width: auto; height: 32px;
  right: 10px; top: 10px;
  padding: 0 4px; gap: 2px;
  background: var(--ink);
  border-radius: 16px;
  display: flex; align-items: center;
}
.ui-card-add .stp-minus,
.ui-card-add .stp-plus,
.ui-card-add .stp-ok {
  border: none; background: transparent;
  color: #fff; cursor: pointer;
  width: 22px; height: 26px;
  font-size: 15px; line-height: 1;
  display: grid; place-items: center;
  border-radius: 4px;
  padding: 0;
}
.ui-card-add .stp-minus:hover,
.ui-card-add .stp-plus:hover,
.ui-card-add .stp-ok:hover {
  background: rgba(255, 255, 255, 0.16);
}
.ui-card-add .stp-ok {
  background: var(--brand);
  width: 26px;
  font-weight: 700;
  margin-left: 2px;
}
.ui-card-add .stp-ok:hover {
  background: var(--brand-strong);
}
.ui-card-add .stp-qty {
  width: 36px;
  border: none; background: transparent;
  color: #fff; text-align: center;
  font-size: 13px; font-weight: 600;
  outline: none;
  -moz-appearance: textfield;
  appearance: textfield;
}
.ui-card-add .stp-qty::-webkit-outer-spin-button,
.ui-card-add .stp-qty::-webkit-inner-spin-button {
  -webkit-appearance: none; margin: 0;
}
.ui-card-add.adding { opacity: 0.85; }
.ui-card-add.done {
  background: var(--green);
}

/* 商品网格 */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.product-card {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--panel);
  display: flex; flex-direction: column;
  position: relative; transition: all 0.2s;
}
.product-card:hover {
  border-color: var(--cool);
}
.product-card.highlight {
  border-color: var(--cool);
  box-shadow: 0 0 0 2px var(--cool-soft);
}
.product-card .badge {
  position: absolute; top: 10px; left: 10px;
  background: var(--cool); color: #fff;
  font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 4px;
  z-index: 1;
}
.product-card img {
  width: 100%; aspect-ratio: 1;
  object-fit: cover; background: var(--bg-soft);
}
.product-card .info { padding: 12px; }
.product-card .pname {
  font-size: 13.5px; font-weight: 500; line-height: 1.4;
  color: var(--ink);
}
.product-card .pmeta {
  font-size: 12px; color: var(--ink-2); margin: 4px 0;
}
.product-card .price {
  color: var(--cool); font-weight: 700; font-size: 17px;
  letter-spacing: -0.02em;
}
.product-card .reason {
  font-size: 12px; color: var(--green);
  margin-top: 8px;
  background: var(--green-soft);
  padding: 5px 8px; border-radius: 6px;
}

/* 对比表 */
.comparison table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.comparison th, .comparison td {
  padding: 10px 12px; text-align: left;
  border-bottom: 1px solid var(--line-soft);
}
.comparison tr:last-child td { border-bottom: none; }
.comparison th {
  font-weight: 600; color: var(--ink-2); background: var(--bg);
  font-size: 12px;
}
.comparison td.name { font-weight: 600; color: var(--ink); }
.comparison td.price { color: var(--cool); font-weight: 700; }

/* 聊天内购物车卡 */
.cart-summary .cart-list {
  display: flex; flex-direction: column; gap: 8px;
}
.cart-summary .cart-row {
  display: flex; gap: 12px; align-items: center;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: var(--bg);
}
.cart-summary .cart-row img {
  width: 52px; height: 52px; border-radius: 8px;
  object-fit: cover;
}
.cart-summary .cart-row .pname {
  font-size: 13.5px; font-weight: 500;
}
.cart-summary .cart-row .qty {
  color: var(--ink-2); font-size: 12px; margin-top: 2px;
}
.cart-summary .totals {
  margin-top: 14px; padding-top: 12px;
  border-top: 1px dashed var(--line);
  font-size: 13.5px;
}
.cart-summary .totals .line {
  display: flex; justify-content: space-between; margin: 5px 0;
}
.cart-summary .totals .grand {
  font-size: 16px; font-weight: 700;
  color: var(--ink); margin-top: 8px;
  padding-top: 8px; border-top: 1px solid var(--line);
}
.cart-summary .totals .grand span:last-child {
  color: var(--cool);
}
.cart-summary .coupon {
  margin-top: 10px; font-size: 12.5px; color: var(--green);
  background: var(--green-soft);
  padding: 8px 10px; border-radius: 6px;
}
.cart-summary .checkout-btn {
  margin-top: 14px; width: 100%; padding: 12px;
  background: var(--brand); color: #fff;
  border: none; border-radius: 8px;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.cart-summary .checkout-btn:hover { background: var(--brand-strong); }

/* 订单 */
.order-status .head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.order-status .head .id {
  font-family: var(--mono); font-size: 12px;
  color: var(--ink-2); margin-top: 2px;
}
.order-status .head .status {
  background: var(--cool-soft); color: var(--cool);
  padding: 4px 12px; border-radius: 999px;
  font-size: 12px; font-weight: 500;
}
.order-status .timeline {
  display: flex; flex-direction: column; gap: 4px;
  margin-top: 12px;
  padding-left: 12px;
  border-left: 2px solid var(--line);
}
.order-status .ev {
  display: flex; gap: 12px; font-size: 13px;
  padding: 6px 0;
  position: relative;
}
.order-status .ev::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: var(--cool);
  margin-top: 6px; flex-shrink: 0;
  position: absolute; left: -19px;
  box-shadow: 0 0 0 3px var(--bg);
}
.order-status .ev .time {
  color: var(--ink-2); font-size: 12px; min-width: 130px;
  font-variant-numeric: tabular-nums;
}

/* 选购指南 */
.guide .section {
  padding: 10px 0;
  border-bottom: 1px dashed var(--line);
}
.guide .section:last-child { border-bottom: none; }
.guide .section .h {
  font-weight: 600; margin-bottom: 6px;
  font-size: 14px;
}

/* 登录卡 */
.login-card {
  text-align: center; padding: 32px 24px;
  background: var(--cool-tint);
  border: 1px solid var(--cool-soft);
}
.login-icon {
  font-size: 32px; margin-bottom: 12px;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--panel);
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--cool-soft);
}
.login-title {
  font-size: 17px; font-weight: 600; color: var(--ink);
  margin-bottom: 6px; letter-spacing: -0.02em;
}
.login-reason {
  font-size: 13.5px; color: var(--ink-2);
  margin-bottom: 22px; line-height: 1.5;
}
.login-actions {
  display: flex; gap: 10px; justify-content: center;
}
.login-btn {
  display: inline-block; padding: 10px 24px;
  border-radius: 10px;
  font-size: 14px; font-weight: 600;
  text-decoration: none; cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
}
.login-btn.primary {
  background: var(--brand); color: #fff;
}
.login-btn.primary:hover { background: var(--brand-strong); }
.login-btn.ghost {
  background: transparent; color: var(--ink-2);
  border-color: var(--line);
}
.login-btn.ghost:hover {
  background: var(--bg-2); color: var(--ink);
}

/* === 输入区：固定底部，消息区独立滚动 === */
#composer {
  flex-shrink: 0;              /* 永远贴底，不被挤压 */
  padding: 14px 24px 18px;
  background: var(--panel);
  border-top: 1px solid var(--line);
}
.composer-inner {
  position: relative;
  max-width: 760px;
  margin: 0 auto;
}
#ai-notice {
  flex-shrink: 0;
  text-align: center;
  font-size: 10.5px;
  color: var(--ink-3);
  padding: 2px 0 8px;
  user-select: none;
}
#input {
  display: block;
  width: 100%;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 50px 8px 14px;   /* 右侧留出发送/暂停按钮的空间 */
  font-size: 13.5px; line-height: 1.5;
  outline: none;
  font-family: inherit;
  background: var(--panel);
  box-sizing: border-box;
  max-height: 120px;
  min-height: 36px;
  overflow-y: hidden;
  transition: border-color 0.15s;
  letter-spacing: -0.005em;
  color: var(--ink);
}
#input:hover {
  border-color: var(--line-soft);
}
#input:focus {
  border-color: var(--cool);
}
#input::placeholder { color: var(--ink-3); }
/* 发送 / 暂停 按钮 — 32×32 圆角方块，叠在 textarea 右侧垂直居中（modern chat 风格） */
.send-btn,
.pause-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px; height: 32px;
  border: none; border-radius: 8px;
  display: grid; place-items: center;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s, opacity 0.15s;
  padding: 0;
  z-index: 2;
}
/* class 上有 display: grid 时会盖住 UA 的 [hidden] { display: none }，所以显式重写 */
.send-btn[hidden],
.pause-btn[hidden] { display: none; }
.send-btn {
  background: var(--brand);
  color: #fff;
}
.send-btn:hover {
  background: var(--brand-strong);
}
.send-btn:active {
  transform: translateY(-50%) scale(0.94);
}
.send-btn:disabled {
  background: var(--line);
  color: var(--ink-3);
  cursor: not-allowed;
  opacity: 0.85;
}
.send-btn svg,
.pause-btn svg {
  width: 18px; height: 18px;
  display: block;
}
.pause-btn {
  background: var(--ink);
  color: #fff;
}
.pause-btn:hover {
  background: #000;
}
.pause-btn:active {
  transform: translateY(-50%) scale(0.94);
}
.pause-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* === 欢迎态 === */
.welcome {
  text-align: center;
  padding: 8px 24px 24px;
  max-width: 820px; margin: 0 auto;
  animation: msgIn 0.4s ease;
}
.welcome-mark {
  width: 64px; height: 64px; border-radius: 14px;
  background: var(--cool);
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 28px; font-weight: 700;
  margin-bottom: 16px;
  letter-spacing: -0.025em;
}
.welcome h1 {
  font-size: 24px; font-weight: 600;
  color: var(--ink); margin: 0 0 8px;
  letter-spacing: -0.025em;
  line-height: 1.25;
}
.welcome p {
  font-size: 14px; color: var(--ink-2);
  margin: 0 0 24px;
  letter-spacing: -0.005em;
  max-width: 540px; margin-left: auto; margin-right: auto;
  line-height: 1.6;
}
.welcome .suggestion-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.welcome .suggestion-grid button {
  text-align: left;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 10px;
  padding: 18px 20px;
  font-size: 13.5px;
  color: var(--ink);
  cursor: pointer;
  line-height: 1.55;
  transition: border-color 0.2s, background 0.2s;
  letter-spacing: -0.005em;
  position: relative;
}
.welcome .suggestion-grid button::before {
  content: "✦";
  display: inline-block;
  margin-right: 8px;
  color: var(--cool);
  font-size: 12px;
}
.welcome .suggestion-grid button:hover {
  border-color: var(--cool);
  background: var(--cool-tint);
  color: var(--ink);
}

/* === 小屏适配 === */
@media (max-width: 900px) {
  main { grid-template-columns: 1fr; }
  aside#rightbar { display: none; }
  #messages { padding: 20px 16px 8px; }
  #composer { padding: 12px 16px; }
  header { padding: 12px 16px; }
}
/* === 登录遮罩 === */
.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(43, 29, 24, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s;
}
.login-overlay.show {
  opacity: 1;
  pointer-events: auto;
}
.login-card {
  width: 380px;
  max-width: 92vw;
  padding: 36px 32px 30px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.login-title {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--ink);
}
.login-sub {
  font-size: 13px;
  color: var(--ink-2, #5b5b62);
  margin-top: -8px;
}
.login-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-2, #5b5b62);
}
.login-card input {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  background: var(--bg);
  transition: border-color 0.15s;
}
.login-card input:focus {
  border-color: var(--cool);
}
.login-card button[type="submit"] {
  margin-top: 4px;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
}
.login-card button[type="submit"]:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.login-card .code-row {
  display: flex;
  gap: 8px;
}
.login-card .code-row input {
  flex: 1;
  min-width: 0;
}
.login-card .code-row button {
  flex-shrink: 0;
  background: var(--bg-soft, #f1ede4);
  color: var(--ink);
  border: 1px solid rgba(15, 15, 16, 0.12);
  border-radius: 10px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.login-card .code-row button:hover:not(:disabled) {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}
.login-card .code-row button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.login-err {
  min-height: 18px;
  font-size: 12px;
  color: #b91c1c;
}
.login-hint {
  font-size: 11px;
  color: rgba(15, 15, 16, 0.45);
  text-align: center;
}

/* 用户身份胶囊 — 登录后头像 + 手机号，统一白色显示在红色顶栏上 */
#user-pill {
  font-size: 12px;
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.25);
}
#user-pill::before {
  background: rgba(255, 255, 255, 0.85);
}
#user-pill .ic-user {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  opacity: 0.95;
}
#user-pill .pill-name {
  font-weight: 500;
  letter-spacing: -0.005em;
}



/* === 首次响应前的 loading（打字动画） === */
.typing-dots {
  display: inline-flex;
  gap: 4px;
  padding: 8px 2px;
}
.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cool);
  opacity: 0.4;
  animation: tdot 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes tdot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* === 卡片内登录表单（扁平冷色） === */
.ui-login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink);
  animation: lgIn 0.35s cubic-bezier(0.34, 1.4, 0.5, 1);
}
@keyframes lgIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.ui-login-card .lg-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}
.ui-login-card .lg-logo {
  width: 34px;
  height: 34px;
  object-fit: contain;
  border-radius: 8px;
  flex-shrink: 0;
}
.ui-login-card .lg-ok {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--green-soft);
  color: var(--green);
  font-size: 16px; font-weight: 700;
  flex-shrink: 0;
}
.ui-login-card .lg-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.ui-login-card .lg-sub {
  font-size: 12px;
  color: var(--ink-2);
  margin-top: 2px;
}
.ui-login-card .lg-reason {
  font-size: 12.5px;
  color: var(--ink-2);
  background: var(--cool-tint);
  border-left: 2px solid var(--cool);
  padding: 7px 10px;
  border-radius: 0 6px 6px 0;
  margin: 12px 0 2px;
}
.ui-login-card .ui-login-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}
.ui-login-form .lg-phone,
.ui-login-form .lg-code {
  width: 100%;
  box-sizing: border-box;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  color: var(--ink);
  outline: none;
  background: var(--bg);
  transition: border-color 0.15s, background 0.15s;
}
.ui-login-form .lg-phone::placeholder,
.ui-login-form .lg-code::placeholder {
  color: var(--ink-3);
}
.ui-login-form .lg-phone:focus,
.ui-login-form .lg-code:focus {
  border-color: var(--cool);
  background: var(--panel);
}
.ui-login-form .lg-code-row {
  display: flex;
  gap: 8px;
}
.ui-login-form .lg-code-row .lg-code { flex: 1; }
.ui-login-form .lg-send {
  flex-shrink: 0;
  padding: 0 14px;
  border: 1px solid var(--cool);
  border-radius: 8px;
  background: var(--cool-tint);
  color: var(--cool);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
.ui-login-form .lg-send:not(:disabled):hover {
  background: var(--cool-soft);
}
.ui-login-form .lg-send:disabled { opacity: 0.5; cursor: not-allowed; }
.ui-login-form .lg-submit {
  margin-top: 2px;
  padding: 11px;
  border: none;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: background 0.15s;
}
.ui-login-form .lg-submit:not(:disabled):hover {
  background: var(--brand-strong);
}
.ui-login-form .lg-submit:disabled { opacity: 0.55; cursor: not-allowed; }
.ui-login-form .lg-err {
  min-height: 16px;
  font-size: 12px;
  color: var(--red);
}
.ui-login-form .lg-hint {
  font-size: 11px;
  color: var(--ink-3);
  text-align: center;
}

/* === 商品卡：单行横向滑动 === */
.ui-grid-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 2px 2px 8px;
  -webkit-overflow-scrolling: touch;
}
.ui-grid-row .ui-card-item {
  flex: 0 0 170px;
  scroll-snap-align: start;
}
.ui-grid-row::-webkit-scrollbar { height: 5px; }
.ui-grid-row::-webkit-scrollbar-track { background: transparent; }
.ui-grid-row::-webkit-scrollbar-thumb {
  background: rgba(15, 15, 16, 0.16);
  border-radius: 999px;
}

/* === 检索 loading：单行 === */
.ui-search-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-2);
  padding: 2px 0;
}
.ui-search-line .spinner { margin-right: 0; }

/* === 登录卡片：紧凑版 === */
.ui-login-card {
  padding: 15px 16px;
  border-radius: 18px;
}
.ui-login-card .lg-head { gap: 10px; }
.ui-login-card .lg-logo { width: 28px; height: 28px; border-radius: 7px; }
.ui-login-card .lg-ok { width: 28px; height: 28px; font-size: 14px; }
.ui-login-card .lg-title { font-size: 14px; }
.ui-login-card .lg-sub { font-size: 11px; }
.ui-login-card .lg-reason {
  font-size: 12px;
  padding: 5px 9px;
  margin: 9px 0 0;
}
.ui-login-card .ui-login-form { gap: 8px; margin-top: 9px; }
.ui-login-form .lg-phone,
.ui-login-form .lg-code { padding: 9px 11px; font-size: 13.5px; border-radius: 10px; }
.ui-login-form .lg-send { padding: 0 11px; font-size: 12px; border-radius: 10px; }
.ui-login-form .lg-submit { padding: 9px; font-size: 13.5px; border-radius: 10px; }
.ui-login-form .lg-err { min-height: 14px; font-size: 11.5px; }

/* === 助手头像用 logo 图 === */
.msg img.avatar-logo {
  object-fit: contain;
  padding: 3px;
}

/* === 订单卡片 === */
.ui-present_order_status { padding: 18px 20px; }
.od-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.od-no {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.od-badge {
  flex-shrink: 0;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--bg-2);
  color: var(--ink-2);
}
.od-badge.st-pay    { background: var(--cool-tint); color: var(--cool); }
.od-badge.st-ship   { background: var(--cool-soft); color: var(--cool-strong); }
.od-badge.st-transit{ background: #e0e7ff; color: #4338ca; }
.od-badge.st-done   { background: var(--green-soft); color: var(--green); }
.od-badge.st-cancel { background: var(--bg-2); color: var(--ink-3); }

.od-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: var(--cool-tint);
  border-radius: 8px;
  margin-bottom: 12px;
}
.od-item {
  display: flex;
  align-items: center;
  gap: 10px;
}
.od-item-img {
  width: 38px; height: 38px;
  border-radius: 8px;
  object-fit: cover;
  background: #eee;
  flex-shrink: 0;
}
.od-item-body { flex: 1; min-width: 0; }
.od-item-name {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.od-item-qty {
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 1px;
}
.od-item-price {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  flex-shrink: 0;
}

.od-amounts {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-bottom: 10px;
  border-bottom: 1px dashed rgba(15, 15, 16, 0.08);
  margin-bottom: 10px;
}
.od-amt {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--ink-2);
}
.od-amt.od-pay { font-size: 13.5px; color: var(--ink); }
.od-amt.od-pay b { color: var(--cool); font-weight: 700; }

.od-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 11.5px;
  color: var(--ink-3);
  margin-bottom: 12px;
}

.od-timeline {
  position: relative;
  padding-left: 4px;
}
.od-tl-item {
  position: relative;
  display: flex;
  gap: 12px;
  padding-bottom: 14px;
}
.od-tl-item:last-child { padding-bottom: 0; }
.od-tl-item::before {
  content: "";
  position: absolute;
  left: 4.5px;
  top: 14px;
  bottom: -2px;
  width: 1.5px;
  background: rgba(15, 15, 16, 0.1);
}
.od-tl-item:last-child::before { display: none; }
.od-tl-dot {
  width: 11px; height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 3px;
  background: #fff;
  border: 2.5px solid var(--cool);
  position: relative;
  z-index: 1;
}
.od-tl-item:first-child .od-tl-dot {
  background: var(--cool);
  border-color: var(--cool-soft);
}
.od-tl-body { flex: 1; min-width: 0; }
.od-tl-status {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.4;
}
.od-tl-time {
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 1px;
  font-variant-numeric: tabular-nums;
}
.od-tl-desc {
  font-size: 11.5px;
  color: var(--ink-2);
  margin-top: 2px;
  line-height: 1.5;
}

/* === 购物车底部总价 === */
.cart-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--ink-2);
}
.cart-total b {
  color: var(--cool);
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* === 购物车小结卡片 === */
.cs-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}
.cs-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}
.cs-count {
  font-size: 11.5px;
  color: var(--ink-3);
}
.cs-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: rgba(15, 15, 16, 0.025);
  border-radius: 12px;
  margin-bottom: 12px;
}
.cs-item {
  display: flex;
  align-items: center;
  gap: 10px;
}
.cs-img {
  width: 38px; height: 38px;
  border-radius: 8px;
  object-fit: cover;
  background: #eee;
  flex-shrink: 0;
}
/* 无图占位 — 扁平购物袋图标，冷色扁平 */
.cs-img-ph {
  display: grid;
  place-items: center;
  background: var(--cool-tint);
  color: var(--cool);
  border: 1px dashed var(--cool-soft);
}
.cs-img-ph svg {
  width: 20px;
  height: 20px;
}
.cs-body { flex: 1; min-width: 0; }
.cs-name {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cs-qty {
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 1px;
}
.cs-price {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.cs-empty {
  font-size: 12.5px;
  color: var(--ink-3);
  text-align: center;
  padding: 18px 0;
}
.cs-amounts {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 10px;
  border-top: 1px dashed rgba(15, 15, 16, 0.08);
}
.cs-amt {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--ink-2);
}
.cs-amt.cs-total { font-size: 13.5px; color: var(--ink); margin-top: 2px; }
.cs-amt.cs-total b {
  color: var(--cool);
  font-weight: 700;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}
.cs-coupon {
  margin-top: 10px;
  padding: 7px 10px;
  border-radius: 6px;
  background: var(--cool-tint);
  color: var(--cool);
  font-size: 12px;
  line-height: 1.5;
}

/* === 顶栏 Tab（聊天 / 订单） — 绝对居中、放大 === */
.header-tabs {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: inline-flex;
  gap: 4px;
  padding: 5px;
  background: rgba(15, 15, 16, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
  z-index: 1;
}
.header-tab {
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.82);
  padding: 8px 22px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  font-family: inherit;
  min-width: 72px;
  text-align: center;
}
.header-tab:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.10);
}
.header-tab.active {
  background: #fff;
  color: var(--brand);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}

/* === 左侧历史记录栏 === */
#history-panel {
  grid-area: history;
  display: flex; flex-direction: column;
  min-height: 0;
  background: var(--bg);
  border-right: 1px solid var(--line);
  overflow: hidden;
}
.history-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--line-soft);
  flex-shrink: 0;
}
.history-title {
  font-size: 13px; font-weight: 600;
  color: var(--ink-2);
  letter-spacing: 0.02em;
}
.history-new-btn {
  border: 0;
  background: var(--brand);
  color: #fff;
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  display: inline-flex; align-items: center;
  transition: background 0.15s, transform 0.1s;
  font-family: inherit;
  box-shadow: 0 1px 2px rgba(195, 65, 37, 0.25);
}
.history-new-btn:hover {
  background: var(--brand-strong);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(195, 65, 37, 0.32);
}
.history-new-btn:active {
  transform: translateY(0);
}
.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
}
.history-item {
  position: relative;
  display: flex; flex-direction: column; gap: 2px;
  padding: 10px 12px 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s;
  margin-bottom: 2px;
}
.history-item::before {
  content: "";
  position: absolute;
  left: 4px; top: 8px; bottom: 8px;
  width: 2px; border-radius: 2px;
  background: transparent;
}
.history-item:hover { background: var(--panel); }
.history-item.active {
  background: rgba(195, 65, 37, 0.08);
}
.history-item.active::before { background: var(--brand); }
.history-item-title {
  font-size: 13px;
  color: var(--ink);
  font-weight: 500;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.history-item-time {
  font-size: 11px;
  color: var(--ink-3, #888);
  letter-spacing: 0.01em;
}
.history-item-actions {
  position: absolute;
  right: 8px; top: 50%; transform: translateY(-50%);
  display: none;
  gap: 2px;
}
.history-item:hover .history-item-actions { display: inline-flex; }
.history-item.active .history-item-actions { display: inline-flex; }
.history-act-btn {
  width: 22px; height: 22px;
  border: 0; background: transparent;
  color: var(--ink-3, #888);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: inherit;
  padding: 0;
}
.history-act-btn:hover { background: rgba(0,0,0,0.06); color: var(--ink); }
.history-act-btn.del:hover { color: #c0392b; }
.history-rename-input {
  width: 100%;
  border: 1px solid var(--brand);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  outline: none;
}
.history-empty {
  padding: 24px 14px;
  text-align: center;
  font-size: 12px;
  color: var(--ink-3, #888);
  line-height: 1.6;
}
.history-list::-webkit-scrollbar { width: 6px; }
.history-list::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 3px;
}

/* === 主区视图面板（聊天 / 订单 共享同一列，购物车在右列不动） === */
#orders-view {
  grid-area: main;             /* 与 #chat 共占同一 grid 区域，靠 hidden 切换可见性 */
}
.view-pane {
  display: flex; flex-direction: column;
  min-height: 0; min-width: 0;
  background: var(--bg);
  position: relative;
  overflow: hidden;
  height: 100%;
}
.view-pane[hidden],
section#chat[hidden],
#orders-view[hidden] { display: none; }

/* === 订单视图：列表 / 详情 都在这个面板内 === */
#orders-view .orders-filters {
  display: flex; gap: 8px; flex-wrap: wrap;
  justify-content: center;
  padding: 14px 24px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--line-soft);
  flex-shrink: 0;
}
#orders-view .orders-filter {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink-2);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: -0.005em;
  font-family: inherit;
}
#orders-view .orders-filter:hover {
  border-color: var(--cool);
  color: var(--cool);
}
#orders-view .orders-filter.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}
#orders-view .orders-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 24px 24px;
  scrollbar-width: thin;
  scrollbar-color: rgba(15,15,16,0.18) transparent;
}
#orders-view .orders-body::-webkit-scrollbar { width: 6px; }
#orders-view .orders-body::-webkit-scrollbar-thumb {
  background: rgba(15,15,16,0.18); border-radius: 999px;
}

/* === 列表底部「查看更多订单」按钮 === */
#orders-view .orders-more {
  margin: 18px auto 8px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
#orders-view .orders-more-btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink-2);
  padding: 8px 22px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  min-width: 140px;
}
#orders-view .orders-more-btn:hover {
  border-color: var(--cool);
  color: var(--cool);
}
#orders-view .orders-more-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
#orders-view .orders-more-meta {
  font-size: 12px;
  color: var(--ink-2);
}
#orders-view .orders-more-end {
  margin: 18px auto 8px;
  text-align: center;
  color: var(--ink-2);
  font-size: 12px;
  padding: 8px 0;
}

/* 状态占位 */
#orders-view .orders-loading,
#orders-view .orders-empty,
#orders-view .orders-err {
  padding: 60px 20px;
  text-align: center;
  color: var(--ink-2);
  font-size: 13.5px;
}
#orders-view .orders-empty-title,
#orders-view .orders-err-title {
  font-size: 15px; font-weight: 600;
  color: var(--ink);
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}
#orders-view .orders-empty-sub,
#orders-view .orders-err-msg {
  color: var(--ink-3); font-size: 12.5px;
}
#orders-view .orders-err-msg {
  margin: 4px 0 14px;
  color: var(--ink-2);
}
#orders-view .orders-retry {
  margin-top: 4px;
  padding: 7px 18px;
  border: 1px solid var(--cool);
  background: var(--cool-tint);
  color: var(--cool);
  border-radius: 6px;
  font-size: 12.5px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
#orders-view .orders-retry:hover { background: var(--cool-soft); }
/* 列表 */
#orders-view .orders-list {
  display: flex; flex-direction: column; gap: 8px;
  max-width: 760px;
  margin: 0 auto;
}
#orders-view .orders-row {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.12s;
  animation: ordersRowIn 0.25s ease;
}
@keyframes ordersRowIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}
#orders-view .orders-row:hover {
  border-color: var(--cool);
  background: var(--cool-tint);
}
#orders-view .orders-row:active { transform: scale(0.995); }
#orders-view .orders-row-thumb {
  width: 48px; height: 48px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--cool-tint);
  display: grid; place-items: center;
  flex-shrink: 0;
}
#orders-view .orders-row-thumb img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
}
#orders-view .orders-row-thumb-fb {
  color: var(--cool);
  font-size: 22px;
  line-height: 1;
}
#orders-view .orders-row-mid {
  min-width: 0;
  display: flex; flex-direction: column; gap: 3px;
}
#orders-view .orders-row-no {
  font-size: 12.5px; font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.005em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#orders-view .orders-row-name {
  font-size: 12.5px;
  color: var(--ink-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#orders-view .orders-row-more { color: var(--ink-3); font-size: 11.5px; }
#orders-view .orders-row-time {
  font-size: 11.5px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
#orders-view .orders-row-right {
  display: flex; flex-direction: column; align-items: flex-end; gap: 4px;
  flex-shrink: 0;
}
#orders-view .orders-row-amt {
  font-size: 14px; font-weight: 700;
  color: var(--cool);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
#orders-view .orders-row-go {
  font-size: 11.5px;
  color: var(--ink-3);
  letter-spacing: 0.02em;
  margin-top: 2px;
}
#orders-view .orders-row:hover .orders-row-go { color: var(--cool); }
/* 详情：返回头 */
#orders-view .orders-detail-back {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 12px;
  max-width: 760px;
  margin-left: auto; margin-right: auto;
}
#orders-view .orders-back-btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink-2);
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12.5px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
#orders-view .orders-back-btn:hover {
  border-color: var(--cool);
  color: var(--cool);
  background: var(--cool-tint);
}
#orders-view .orders-detail-no {
  font-size: 12px;
  color: var(--ink-3);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
/* 详情卡容器：去掉外边距 */
#orders-view .ui-card.ui-present_order_status {
  margin-top: 0;
  max-width: 760px;
  margin-left: auto; margin-right: auto;
}
/* 订单视图未登录时嵌入的登录卡：居中显示 */
#orders-view .ui-login-card {
  max-width: 420px;
  margin: 40px auto 0;
}
/* 小屏：订单列表 row 紧凑 */
@media (max-width: 600px) {
  #orders-view .orders-row { grid-template-columns: 40px 1fr auto; gap: 10px; padding: 10px; }
  #orders-view .orders-row-thumb { width: 40px; height: 40px; }
}

