/* 与 51cube.com 一致：中性灰底、近黑正文、官网按钮蓝 #2468DE。不加载网络字体。 */
:root {
  --ink: #1d1d1f;
  --ink-2: #424245;
  --muted: #6e6e73;
  --faint: #86868b;
  --canvas: #f5f5f7;
  --surface: #ffffff;
  --line: rgba(0, 0, 0, 0.08);
  --line-strong: rgba(0, 0, 0, 0.14);
  --accent: #2468de;
  --accent-press: #1d56bb;
  --accent-soft: #eaf1fd;
  --danger: #c4314b;
  --radius-panel: 18px;
  --radius-tile: 14px;
  --radius-btn: 12px;
  --font: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", -apple-system, system-ui, sans-serif;
  color-scheme: light;
}
/* 日文页面用日文字形，英文页面优先系统西文字体 */
:root:lang(ja) { --font: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", Meiryo, "Noto Sans JP", system-ui, sans-serif; }
:root:lang(en) { --font: -apple-system, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif; }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--canvas);
  color: var(--ink);
  font: 15px/1.65 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

.app { display: flex; flex-direction: column; height: 100%; height: 100dvh; max-width: 760px; margin: 0 auto; background: var(--canvas); }

/* 顶栏 */
.bar {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  height: 56px; padding: 0 12px 0 18px; padding-top: env(safe-area-inset-top);
  background: rgba(255, 255, 255, 0.92); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand .logo { display: block; height: 16px; width: auto; }
.badge {
  font-size: 12px; line-height: 20px; padding: 0 8px; border-radius: 999px;
  color: var(--accent); background: var(--accent-soft); font-weight: 500; white-space: nowrap;
}
.bar-actions { display: flex; align-items: center; gap: 2px; }
.ghost {
  white-space: nowrap;
  border: 0; background: none; padding: 6px 10px; border-radius: 8px;
  font-size: 14px; color: var(--ink-2);
}
.ghost:hover { background: rgba(0, 0, 0, 0.05); }
.icon {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 50%;
  background: none; color: var(--ink-2);
}
.icon:hover { background: rgba(0, 0, 0, 0.05); }
.icon svg { width: 18px; height: 18px; }

/* 对话区 */
.thread { flex: 1; overflow-y: auto; padding: 20px 16px 8px; scroll-behavior: smooth; overscroll-behavior: contain; }
.welcome { padding: 28px 4px 12px; }
.welcome h1 { font-size: 22px; line-height: 1.35; font-weight: 600; margin: 0 0 6px; letter-spacing: 0.01em; }
.welcome p { margin: 0 0 18px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 7px 14px; font-size: 14px; color: var(--ink); text-align: left;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }

.msg { margin: 0 0 14px; display: flex; flex-direction: column; }
.msg.user { align-items: flex-end; }
.msg.user .bubble {
  max-width: 82%; background: var(--accent); color: #fff; padding: 9px 14px;
  border-radius: var(--radius-panel) var(--radius-panel) 6px var(--radius-panel);
  white-space: pre-wrap; word-break: break-word;
}
.msg.bot .panel {
  max-width: 100%; background: var(--surface); padding: 12px 16px; border-radius: 6px var(--radius-panel) var(--radius-panel) var(--radius-panel);
  word-break: break-word;
}
.panel p { margin: 0 0 8px; }
.panel p:last-child { margin-bottom: 0; }
.panel .md-h { font-weight: 600; margin-top: 4px; }
.panel ul, .panel ol { margin: 4px 0 8px; padding-left: 1.3em; }
.panel li { margin: 2px 0; }
.panel a { color: var(--accent); text-decoration: none; }
.panel a:hover { text-decoration: underline; }
.panel code { font-size: 0.92em; background: var(--canvas); padding: 1px 5px; border-radius: 5px; }
.table-wrap { overflow-x: auto; margin: 6px -4px 10px; }
.panel table { border-collapse: collapse; font-size: 14px; line-height: 1.5; min-width: 100%; }
.panel th, .panel td { text-align: left; vertical-align: top; padding: 7px 10px; border-bottom: 1px solid var(--line); }
.panel th { font-weight: 600; color: var(--ink-2); background: var(--canvas); white-space: nowrap; }
.panel tr td:first-child { color: var(--muted); white-space: nowrap; }

.status { display: flex; align-items: center; gap: 8px; color: var(--faint); font-size: 14px; }
.status::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
  animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }
.panel .status + p, .panel .status + .tile { margin-top: 8px; }
.error-text { color: var(--danger); }

/* 产品卡片：与官网产品列表同样的浅灰底产品图 */
.tile {
  display: grid; grid-template-columns: 88px 1fr; grid-template-areas: "img body" "actions actions";
  gap: 4px 14px; align-items: center;
  margin: 10px 0; padding: 12px; background: var(--canvas); border-radius: var(--radius-tile);
}
.tile-img { grid-area: img; }
.tile-body { grid-area: body; }
.tile-actions { grid-area: actions; }
.tile + .tile { margin-top: 8px; }
.tile-img { width: 88px; height: 88px; border-radius: 10px; background: #fff; display: grid; place-items: center; overflow: hidden; }
.tile-img img { max-width: 100%; max-height: 100%; object-fit: contain; }
.tile-body { min-width: 0; }
.tile-name { font-weight: 600; font-size: 16px; line-height: 1.35; }
.tile-brief { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 13px; color: var(--muted); margin-top: 2px; }
.tile-price { font-size: 13px; color: var(--ink-2); margin-top: 4px; }
.tile-price b { font-weight: 600; color: var(--ink); }
.tile-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.tile-actions:empty { display: none; }
.btn {
  display: inline-flex; align-items: center; height: 32px; padding: 0 14px; border-radius: var(--radius-btn);
  font-size: 14px; font-weight: 500; text-decoration: none !important; border: 1px solid transparent; white-space: nowrap;
}
.btn.primary { background: var(--accent); color: #fff !important; }
.btn.primary:hover { background: var(--accent-press); }
.btn.secondary { background: var(--surface); color: var(--accent) !important; border-color: rgba(36, 104, 222, 0.35); }
.btn.secondary:hover { border-color: var(--accent); }
.btn.text { padding: 0 4px; color: var(--accent) !important; }
.tile-note { font-size: 13px; color: var(--faint); }

/* 回答下方：反馈 */
.meta { display: flex; align-items: center; gap: 4px; margin: 4px 0 0 4px; min-height: 28px; }
.fb {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; border: 0;
  background: none; color: var(--faint);
}
.fb svg { width: 16px; height: 16px; }
.fb:hover { color: var(--ink-2); background: rgba(0, 0, 0, 0.05); }
.fb[aria-pressed="true"] { color: var(--accent); }
.fb-form { display: flex; gap: 6px; margin: 6px 0 0 4px; }
.fb-form input {
  flex: 1; min-width: 0; height: 32px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff;
  font-size: 14px;
}
.fb-form button { height: 32px; padding: 0 12px; border-radius: 8px; border: 0; background: var(--ink); color: #fff; font-size: 14px; }
.fb-thanks { font-size: 13px; color: var(--faint); margin-left: 4px; }

/* 回答里附带的人工入口 */
.handoff { margin-top: 10px; padding: 10px 12px; border-radius: var(--radius-tile); background: var(--canvas); font-size: 14px; }
.handoff b { font-weight: 600; }
.handoff a { white-space: nowrap; }
.handoff-row { display: flex; flex-wrap: wrap; gap: 2px 10px; }
.handoff-row + .handoff-row { margin-top: 4px; }

/* 输入区 */
.composer {
  flex: none; padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--canvas);
}
#form {
  display: flex; align-items: flex-end; gap: 8px; padding: 6px 6px 6px 16px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 24px;
}
#form:focus-within { border-color: var(--accent); }
#input {
  flex: 1; border: 0; outline: none; resize: none; background: none; padding: 7px 0; max-height: 132px;
  line-height: 1.5; font-size: 15px;
}
#input::placeholder { color: var(--faint); }
.send {
  flex: none; width: 36px; height: 36px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: var(--accent); color: #fff;
}
.send svg { width: 18px; height: 18px; }
.send:disabled { background: #d2d2d7; cursor: default; }
.fineprint { margin: 8px 6px 0; font-size: 12px; line-height: 1.5; color: var(--faint); text-align: center; }
#counter { margin-right: 6px; }
#counter.warn { color: var(--danger); }

/* 内测口令 */
.gate { position: fixed; inset: 0; display: grid; place-items: center; background: var(--canvas); padding: 24px; z-index: 30; }
.gate-card {
  width: 100%; max-width: 340px; background: var(--surface); border-radius: var(--radius-panel); padding: 28px 24px;
  display: flex; flex-direction: column; gap: 10px; text-align: center;
}
.gate-card .logo { height: 20px; width: auto; margin: 0 auto 8px; }
.gate-card h2 { margin: 0; font-size: 20px; font-weight: 600; }
.gate-card p { margin: 0; color: var(--muted); font-size: 14px; }
.gate-card input {
  height: 44px; border: 1px solid var(--line-strong); border-radius: var(--radius-btn); padding: 0 14px; text-align: center; font-size: 16px;
}
.gate-card input:focus { outline: none; border-color: var(--accent); }
.gate-error { color: var(--danger) !important; min-height: 1.4em; }
.gate-submit {
  height: 44px; border: 0; border-radius: var(--radius-btn); background: var(--accent); color: #fff; font-size: 16px; font-weight: 500;
}
.gate-submit:hover { background: var(--accent-press); }

/* 人工客服面板 */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.28); z-index: 20; }
.sheet {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); width: 100%; max-width: 760px; z-index: 21;
  background: var(--surface); border-radius: 20px 20px 0 0; padding: 8px 20px calc(20px + env(safe-area-inset-bottom));
  animation: rise 0.22s ease-out;
}
@keyframes rise { from { transform: translate(-50%, 24px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; height: 48px; }
.sheet-head h2 { margin: 0; font-size: 17px; font-weight: 600; }
.contact { padding: 14px 0; border-top: 1px solid var(--line); }
.contact h3 { margin: 0 0 4px; font-size: 15px; font-weight: 600; }
.contact p { margin: 0; color: var(--muted); font-size: 14px; }
.contact .tel { font-size: 18px; font-weight: 600; color: var(--ink); text-decoration: none; letter-spacing: 0.02em; }
.contact .links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.sheet .note { margin: 6px 0 0; padding-top: 14px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }

@media (min-width: 761px) {
  .app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}
/* 在官网悬浮窗里：窄窗口、紧凑一点 */
.embedded .app { max-width: none; border: 0; }
.embedded .thread { padding: 16px 14px 6px; }
.embedded .welcome { padding-top: 14px; }
.embedded .welcome h1 { font-size: 19px; }
.embedded .composer { padding-left: 12px; padding-right: 12px; }
/* 悬浮窗里输口令时留着顶栏，右上角的关闭按钮一直能点到 */
.embedded .gate { top: calc(56px + env(safe-area-inset-top)); }
.gated #btn-human, .gated #btn-new { visibility: hidden; }
@media (max-width: 400px) { .embedded .badge { display: none; } }
@media (max-width: 420px) {
  .bar { padding-left: 14px; }
  .ghost { padding: 6px 8px; font-size: 13px; }
  .tile { grid-template-columns: 68px 1fr; column-gap: 12px; }
  .tile-img { width: 68px; height: 68px; }
}
@media (prefers-reduced-motion: reduce) {
  .status::before, .sheet { animation: none; }
  .thread { scroll-behavior: auto; }
}
