/* AI小金 — 打磨层。放在 ai-xiaojin.css 之后，沿用站点的橙色和墨黑。 */

:root {
  --ai-gold: #f8b038;
  --ai-cta: #f09000;
  --ai-cta-deep: #d98200;
  --ai-ink: #1a1307;
  --ai-bg: #0b0d12;
  --ai-surface: rgba(24, 28, 38, 0.86);
  --ai-surface-2: rgba(32, 37, 50, 0.94);
  --ai-border: rgba(255, 255, 255, 0.1);
  --ai-text: #f2f4f8;
  --ai-text-muted: #9aa3b6;
  --ai-radius: 16px;
  --ai-radius-sm: 10px;
  --ai-max: 100%;
  --ai-ease: cubic-bezier(0.16, 1, 0.3, 1);
}

/* 浏览器自带的部分也跟着主题 */
::selection { background: rgba(248, 176, 56, 0.35); color: #fff; }
textarea, input { caret-color: var(--ai-gold); }
.ai-chat { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.18) transparent; }
.ai-chat::-webkit-scrollbar { width: 8px; }
.ai-chat::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.16); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
.ai-chat::-webkit-scrollbar-thumb:hover { background: rgba(248, 176, 56, 0.5); background-clip: content-box; }
:focus-visible { outline: 2px solid var(--ai-gold); outline-offset: 2px; }

.ai-shell { max-width: none; padding: 0 clamp(14px, 3.2vw, 24px); }

/* ── 顶栏 ── */
.ai-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas:
    "back title tools"
    "back sub sub";
  align-items: center;
  column-gap: 12px;
  row-gap: 2px;
  padding: 14px 0 12px;
}
.ai-back { grid-area: back; align-self: start; margin-top: 2px; }
.ai-brand { display: contents; }
.ai-header-tools {
  grid-area: tools;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.ai-back { width: 38px; height: 38px; border-radius: 12px; }
.ai-brand-title {
  grid-area: title;
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 30px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ai-brand-title::before {
  content: '金';
  display: inline-grid;
  vertical-align: middle;
  margin: -2px 10px 0 0;
  place-items: center;
  width: 30px;
  height: 30px;
  line-height: 1;
  border-radius: 9px;
  background: linear-gradient(145deg, #ffc760, var(--ai-cta));
  color: var(--ai-ink);
  font-size: 15px;
  font-weight: 800;
  box-shadow: 0 4px 14px rgba(240, 144, 0, 0.35);
}
.ai-brand-title span { color: #fff; }
.ai-brand-sub {
  grid-area: sub;
  margin-top: 0;
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.ai-header-fill {
  padding: 8px 14px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(145deg, #ffc760, var(--ai-cta));
  color: var(--ai-ink);
  font-size: 0.82rem;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(240, 144, 0, 0.3);
  transition: transform 0.2s var(--ai-ease), box-shadow 0.2s var(--ai-ease);
}
.ai-header-fill:hover { background: linear-gradient(145deg, #ffd079, #f59a10); transform: translateY(-1px); }
.ai-status { padding: 4px 9px; border-radius: 999px; background: rgba(255, 255, 255, 0.05); font-size: 0.72rem; }

/* ── 步骤条 ── */
.ai-steps { padding: 8px 0 10px; }
.ai-step { font-size: 0.78rem; }

/* ── 欢迎区 ── */
.ai-chat { padding: 18px 0 12px; }
.ai-welcome {
  padding: 22px 20px 20px;
  border-radius: 20px;
  background:
    radial-gradient(120% 90% at 0% 0%, rgba(248, 176, 56, 0.1), transparent 55%),
    var(--ai-surface);
  border-color: rgba(255, 255, 255, 0.1);
}
.ai-welcome h2 { margin: 0 0 10px; font-size: 1.32rem; line-height: 1.3; font-weight: 700; text-wrap: balance; }
.ai-welcome p { font-size: 0.93rem; line-height: 1.75; color: #b4bccd; max-width: 62ch; }
.ai-welcome p strong { color: #ffcf75; font-weight: 600; }
.ai-welcome .ai-entry-scene { font-size: 0.78rem; }

.ai-chips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.ai-chip {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--ai-border);
  background: rgba(255, 255, 255, 0.045);
  font-size: 0.9rem;
  line-height: 1.35;
  text-align: left;
  color: var(--ai-text);
  transition: transform 0.2s var(--ai-ease), border-color 0.2s, background 0.2s;
}
.ai-chip:hover { transform: translateY(-1px); border-color: rgba(248, 176, 56, 0.5); background: rgba(248, 176, 56, 0.1); }
.ai-chip:active { transform: translateY(0); }
.ai-chip-form {
  grid-column: 1 / -1;
  order: -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border: 0;
  background: linear-gradient(145deg, #ffc760, var(--ai-cta));
  color: var(--ai-ink);
  font-size: 0.98rem;
  font-weight: 700;
  box-shadow: 0 8px 22px rgba(240, 144, 0, 0.28);
}
.ai-chip-form::after { content: '→'; font-size: 1.1rem; }
.ai-chip-form:hover { background: linear-gradient(145deg, #ffd079, #f59a10); border: 0; }
.ai-chip-handoff { grid-column: 1 / -1; text-align: center; }

/* ── 消息 ── */
.ai-messages { display: flex; flex-direction: column; gap: 16px; }
.ai-msg { gap: 10px; }
.ai-avatar { width: 34px; height: 34px; border-radius: 11px; font-size: 0.8rem; }
.ai-msg.is-assistant .ai-avatar {
  background: linear-gradient(145deg, #ffc760, var(--ai-cta));
  color: var(--ai-ink);
  border: 0;
  font-weight: 800;
}
.ai-bubble { font-size: 0.97rem; line-height: 1.75; padding: 12px 16px; max-width: calc(100% - 46px); }
.ai-msg.is-assistant .ai-bubble {
  background: rgba(255, 255, 255, 0.065);
  border-color: rgba(255, 255, 255, 0.11);
  border-top-left-radius: 5px;
}
.ai-msg.is-user .ai-bubble {
  background: linear-gradient(145deg, rgba(240, 144, 0, 0.28), rgba(240, 144, 0, 0.16));
  border-color: rgba(248, 176, 56, 0.4);
  border-top-right-radius: 5px;
  color: #fff;
}
.ai-msg-main { max-width: calc(100% - 46px); }
.ai-typing span { background: var(--ai-gold); }

/* 行动卡片 */
.ai-action-card { border-radius: 12px; }

/* ── 底部输入 ── */
.ai-composer-wrap { padding: 12px 0 max(14px, env(safe-area-inset-bottom, 0px)); background: linear-gradient(180deg, transparent, rgba(11, 13, 18, 0.96) 30%); }
.ai-composer {
  align-items: center;
  gap: 8px;
  padding: 8px 8px 8px 16px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(28, 33, 45, 0.96);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.ai-composer:focus-within { border-color: rgba(248, 176, 56, 0.6); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3), 0 0 0 3px rgba(248, 176, 56, 0.14); }
.ai-composer textarea { font-size: 1rem; line-height: 1.5; padding: 6px 0; }
.ai-send {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(145deg, #ffc760, var(--ai-cta));
  color: var(--ai-ink);
  box-shadow: 0 4px 14px rgba(240, 144, 0, 0.3);
}
.ai-footer-note { font-size: 0.72rem; margin-top: 8px; }

/* 顾问提示条 / 按钮 */
.ai-cta-bar { border-radius: 16px; padding: 12px 14px; }
.ai-btn { border-radius: 12px; padding: 10px 16px; font-size: 0.92rem; }
.ai-btn-primary {
  background: linear-gradient(145deg, #ffc760, var(--ai-cta));
  border: 0;
  color: var(--ai-ink);
  font-weight: 700;
  box-shadow: 0 6px 18px rgba(240, 144, 0, 0.28);
}
.ai-btn-primary:hover:not(:disabled) { background: linear-gradient(145deg, #ffd079, #f59a10); }

/* 摘要面板、成功态 */
.ai-summary-panel { border-radius: 18px; padding: 18px; }
.ai-summary-panel h3 { font-size: 1.05rem; }
.ai-summary-body { font-size: 0.95rem; line-height: 1.75; }
.ai-success { border-radius: 18px; }

/* 资料表单也用同一套 */
.ai-qf__card { border-radius: 22px 22px 0 0; padding: 22px 20px 20px; }
.ai-qf__title { font-size: 1.2rem; }
.ai-qf__lead { font-size: 0.9rem; }
.ai-qf__form { gap: 12px; }
.ai-qf__form label { font-size: 0.86rem; }
.ai-qf__form input[type='text'],
.ai-qf__form input[type='tel'],
.ai-qf__form select,
.ai-qf__form textarea { padding: 12px 14px; border-radius: 12px; font-size: 1rem; }
.ai-qf__form input:focus,
.ai-qf__form select:focus,
.ai-qf__form textarea:focus { outline: none; border-color: rgba(248, 176, 56, 0.65); box-shadow: 0 0 0 3px rgba(248, 176, 56, 0.16); }
.ai-qf__submit { padding: 14px; font-size: 1rem; }
.ai-qf-nudge { margin-left: 44px; border-radius: 16px; }
.ai-qf { animation: ai-qf-in 0.22s ease-out; }
.ai-qf__card { animation: ai-qf-up 0.34s var(--ai-ease); }
@keyframes ai-qf-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes ai-qf-up { from { transform: translateY(24px); opacity: 0.4; } to { transform: none; opacity: 1; } }

/* ── 多端 ── */
.ai-qf__card { max-height: 92vh; max-height: 92dvh; padding-bottom: max(20px, env(safe-area-inset-bottom, 0px)); }
.ai-chip, .ai-btn, .ai-send, .ai-header-fill, .ai-back { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.ai-bubble { overflow-wrap: anywhere; }
.ai-action-card { min-height: 44px; }

/* 手机和窄窗口（小窗内的 iframe 宽度也算） */
@media (max-width: 520px) {
  .ai-shell { padding: 0 max(12px, env(safe-area-inset-right, 0px)) 0 max(12px, env(safe-area-inset-left, 0px)); }
  .ai-header { padding-top: max(12px, env(safe-area-inset-top, 0px)); gap: 10px; }
  .ai-back { width: 40px; height: 40px; }
  .ai-header-fill { min-height: 40px; padding: 0 14px; }
  .ai-brand-sub { display: -webkit-box; font-size: 0.74rem; }
  .ai-welcome { padding: 18px 16px 16px; border-radius: 18px; }
  .ai-welcome h2 { font-size: 1.2rem; }
  .ai-chip { min-height: 46px; padding: 11px 12px; font-size: 0.88rem; }
  .ai-bubble { font-size: 0.96rem; padding: 11px 14px; }
  .ai-avatar { width: 32px; height: 32px; }
  .ai-bubble, .ai-msg-main { max-width: calc(100% - 42px); }
  .ai-qf-nudge { margin-left: 0; }
  .ai-composer textarea { font-size: 16px; } /* iOS 低于 16px 会放大页面 */
  .ai-qf__form input[type='text'],
  .ai-qf__form input[type='tel'],
  .ai-qf__form select,
  .ai-qf__form textarea { font-size: 16px; min-height: 46px; }
  .ai-qf__submit { min-height: 50px; }
  .ai-footer-note { font-size: 0.68rem; }
}
@media (max-width: 340px) {
  .ai-chips { grid-template-columns: 1fr; }
  .ai-step-label { display: none; }
  .ai-step.is-active .ai-step-label { display: inline; }
}

/* 横屏手机：留出对话区 */
@media (max-height: 520px) {
  .ai-steps { display: none; }
  .ai-brand-sub { display: none; }
  .ai-welcome { padding: 12px 14px; }
  .ai-welcome h2 { font-size: 1.05rem; margin-bottom: 6px; }
  .ai-footer-note { display: none; }
  .ai-qf__card { max-height: 100dvh; border-radius: 0; }
}

/* 触屏没有 hover，别留下悬浮后的位移 */
@media (hover: none) {
  .ai-chip:hover, .ai-header-fill:hover { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .ai-qf, .ai-qf__card { animation: none; }
  .ai-chip, .ai-header-fill { transition: none; }
}
