/* AI 小耕 — 对话页（ChatGPT 式 · 深色科技风） */

:root {
  --ai-bg: #0a0c10;
  --ai-bg-2: #12151c;
  --ai-surface: rgba(22, 26, 36, 0.82);
  --ai-surface-2: rgba(30, 36, 50, 0.92);
  --ai-border: rgba(255, 255, 255, 0.08);
  --ai-border-glow: rgba(200, 169, 110, 0.22);
  --ai-text: #eef0f4;
  --ai-text-muted: #8b93a7;
  --ai-accent: #c8a96e;
  --ai-accent-2: #e4c88a;
  --ai-user: rgba(192, 57, 43, 0.18);
  --ai-user-border: rgba(192, 57, 43, 0.35);
  --ai-bot: rgba(255, 255, 255, 0.04);
  --ai-radius: 14px;
  --ai-max: 720px;
  --ai-font: 'DM Sans', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --ai-mono: 'DM Mono', 'SF Mono', monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body.ai-page {
  margin: 0;
  min-height: 100%;
  font-family: var(--ai-font);
  color: var(--ai-text);
  background: var(--ai-bg);
  -webkit-font-smoothing: antialiased;
}

.ai-bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(200, 169, 110, 0.08), transparent 55%),
    radial-gradient(ellipse 60% 40% at 100% 80%, rgba(192, 57, 43, 0.06), transparent 50%),
    linear-gradient(180deg, #0a0c10 0%, #0d1018 100%);
}

.ai-bg-grid::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, black 20%, transparent 75%);
}

.ai-shell {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 max(1rem, env(safe-area-inset-right, 0px)) 0 max(1rem, env(safe-area-inset-left, 0px));
}

/* ── Header ── */
.ai-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--ai-border);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(10, 12, 16, 0.75);
}

.ai-back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 10px;
  border: 1px solid var(--ai-border);
  color: var(--ai-text-muted);
  text-decoration: none;
  transition: border-color 0.2s, color 0.2s;
  flex-shrink: 0;
}

.ai-back:hover {
  border-color: var(--ai-border-glow);
  color: var(--ai-accent);
}

.ai-brand {
  flex: 1;
  min-width: 0;
}

.ai-brand-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.ai-brand-title span {
  color: var(--ai-accent);
}

.ai-brand-sub {
  margin: 0.15rem 0 0;
  font-size: 0.72rem;
  color: var(--ai-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-status {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.68rem;
  color: var(--ai-text-muted);
  font-family: var(--ai-mono);
  flex-shrink: 0;
}

.ai-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #3dd68c;
  box-shadow: 0 0 8px rgba(61, 214, 140, 0.6);
}

.ai-status.is-offline .ai-status-dot {
  background: #f87171;
  box-shadow: none;
}

/* ── Step progress ── */
.ai-steps {
  padding: 0.55rem 0 0.65rem;
  border-bottom: 1px solid var(--ai-border);
}

.ai-steps-list {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.ai-step {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  color: var(--ai-text-muted);
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  transition: color 0.2s, background 0.2s;
}

.ai-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  border: 1px solid var(--ai-border);
  font-family: var(--ai-mono);
  font-size: 0.65rem;
}

.ai-step.is-active {
  color: var(--ai-accent-2);
  background: rgba(200, 169, 110, 0.1);
}

.ai-step.is-active .ai-step-num {
  border-color: var(--ai-border-glow);
  background: rgba(200, 169, 110, 0.2);
  color: #fff;
}

.ai-step.is-done {
  color: #3dd68c;
}

.ai-step.is-done .ai-step-num {
  border-color: rgba(61, 214, 140, 0.45);
  background: rgba(61, 214, 140, 0.15);
}

.ai-step + .ai-step::before {
  content: '→';
  margin-right: 0.35rem;
  color: var(--ai-text-muted);
  opacity: 0.5;
  font-size: 0.65rem;
}

/* ── Chat area ── */
.ai-chat {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 0 1rem;
  scroll-behavior: smooth;
}

.ai-welcome {
  max-width: var(--ai-max);
  margin: 0 auto 1.5rem;
  padding: 1.25rem 1.35rem;
  border-radius: var(--ai-radius);
  border: 1px solid var(--ai-border);
  background: var(--ai-surface);
  backdrop-filter: blur(16px);
}

.ai-welcome h2 {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  font-weight: 600;
}

.ai-welcome p {
  margin: 0 0 0.75rem;
  font-size: 0.875rem;
  line-height: 1.65;
  color: var(--ai-text-muted);
}

.ai-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.ai-chip {
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--ai-border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--ai-text);
  font-size: 0.78rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.ai-chip:hover {
  border-color: var(--ai-border-glow);
  background: rgba(200, 169, 110, 0.08);
}

.ai-chip-handoff {
  border-color: rgba(200, 169, 110, 0.35);
  background: rgba(200, 169, 110, 0.12);
  color: var(--ai-accent-2);
}

.ai-chip.is-topic-match {
  border-color: rgba(200, 169, 110, 0.55);
  background: rgba(200, 169, 110, 0.16);
  box-shadow: 0 0 0 1px rgba(200, 169, 110, 0.2);
}

.ai-inline-cta {
  max-width: var(--ai-max);
  margin: 0.25rem auto 0;
  padding: 0.85rem 1rem;
  border-radius: var(--ai-radius);
  border: 1px dashed var(--ai-border-glow);
  background: rgba(200, 169, 110, 0.06);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  animation: ai-fade-in 0.35s ease;
}

.ai-inline-cta p {
  margin: 0;
  font-size: 0.8rem;
  color: var(--ai-text-muted);
  flex: 1;
  min-width: 160px;
}

.ai-msg-inline-cta .ai-bubble {
  padding: 0;
  border: none;
  background: transparent;
  max-width: 100%;
}

.ai-msg-inline-cta {
  flex-direction: column;
  align-items: stretch;
}

.ai-msg-inline-cta .ai-avatar {
  display: none;
}

.ai-messages {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: var(--ai-max);
  margin: 0 auto;
}

.ai-msg {
  display: flex;
  gap: 0.65rem;
  animation: ai-fade-in 0.35s ease;
}

@keyframes ai-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.ai-msg.is-user {
  flex-direction: row-reverse;
}

.ai-avatar {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  border: 1px solid var(--ai-border);
}

.ai-msg.is-assistant .ai-avatar {
  background: linear-gradient(135deg, rgba(200, 169, 110, 0.25), rgba(200, 169, 110, 0.05));
  color: var(--ai-accent-2);
}

.ai-msg.is-user .ai-avatar {
  background: var(--ai-user);
  border-color: var(--ai-user-border);
  color: #f5a8a0;
}

.ai-bubble {
  max-width: calc(100% - 2.75rem);
  padding: 0.75rem 1rem;
  border-radius: var(--ai-radius);
  font-size: 0.9rem;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.ai-msg.is-assistant .ai-bubble {
  background: var(--ai-bot);
  border: 1px solid var(--ai-border);
}

.ai-msg.is-user .ai-bubble {
  background: var(--ai-user);
  border: 1px solid var(--ai-user-border);
}

.ai-bubble strong {
  color: var(--ai-accent-2);
  font-weight: 600;
}

.ai-typing {
  display: inline-flex;
  gap: 4px;
  padding: 0.25rem 0;
}

.ai-typing span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ai-text-muted);
  animation: ai-bounce 1.2s infinite ease-in-out;
}

.ai-typing span:nth-child(2) { animation-delay: 0.15s; }
.ai-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes ai-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-4px); opacity: 1; }
}

/* ── Summary panel ── */
.ai-summary-panel {
  max-width: var(--ai-max);
  margin: 1.25rem auto 0;
  padding: 1.25rem;
  border-radius: var(--ai-radius);
  border: 1px solid var(--ai-border-glow);
  background: var(--ai-surface-2);
  backdrop-filter: blur(20px);
}

.ai-summary-panel[hidden] {
  display: none !important;
}

.ai-summary-panel h3 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  color: var(--ai-accent-2);
}

.ai-summary-lead {
  margin: 0 0 0.65rem;
  font-size: 0.8rem;
  color: var(--ai-text-muted);
  line-height: 1.55;
}

.ai-summary-panel.is-ready-submit {
  animation: ai-panel-glow 1.2s ease 2;
}

.ai-summary-panel.is-ready-submit .ai-btn-primary {
  animation: ai-pulse-btn 1.4s ease 3;
}

@keyframes ai-panel-glow {
  0%, 100% { box-shadow: none; }
  50% { box-shadow: 0 0 0 2px rgba(200, 169, 110, 0.35); }
}

@keyframes ai-pulse-btn {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

.ai-summary-body {
  font-size: 0.85rem;
  line-height: 1.7;
  color: var(--ai-text-muted);
  margin-bottom: 1rem;
}

.ai-summary-meta {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.ai-summary-meta dt {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ai-text-muted);
  margin: 0;
}

.ai-summary-meta dd {
  margin: 0.15rem 0 0;
  font-size: 0.82rem;
  color: var(--ai-text);
}

.ai-contact-fields {
  display: grid;
  gap: 0.55rem;
  margin-bottom: 1rem;
}

.ai-contact-fields label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.72rem;
  color: var(--ai-text-muted);
}

.ai-contact-fields input {
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--ai-border);
  background: rgba(0, 0, 0, 0.25);
  color: var(--ai-text);
  font: inherit;
  font-size: 0.85rem;
}

.ai-contact-fields input:focus {
  outline: none;
  border-color: var(--ai-border-glow);
}

.ai-consent {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--ai-text-muted);
  margin-bottom: 1rem;
  cursor: pointer;
}

.ai-consent input {
  margin-top: 0.15rem;
  accent-color: var(--ai-accent);
}

.ai-consent.is-pulse {
  color: var(--ai-accent-2);
  animation: ai-panel-glow 0.8s ease 2;
}

.ai-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.ai-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.6rem 1.1rem;
  border-radius: 10px;
  border: 1px solid var(--ai-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ai-text);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}

.ai-btn:hover:not(:disabled) {
  border-color: var(--ai-border-glow);
  background: rgba(200, 169, 110, 0.1);
}

.ai-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ai-btn-primary {
  background: linear-gradient(135deg, rgba(200, 169, 110, 0.35), rgba(200, 169, 110, 0.15));
  border-color: rgba(200, 169, 110, 0.45);
  color: #fff;
}

.ai-btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, rgba(200, 169, 110, 0.5), rgba(200, 169, 110, 0.22));
}

/* ── Success state ── */
.ai-success {
  max-width: var(--ai-max);
  margin: 1rem auto;
  padding: 1.25rem;
  border-radius: var(--ai-radius);
  border: 1px solid rgba(61, 214, 140, 0.35);
  background: rgba(61, 214, 140, 0.08);
  text-align: center;
}

.ai-success[hidden] { display: none !important; }

.ai-success h3 {
  margin: 0 0 0.5rem;
  color: #3dd68c;
  font-size: 1rem;
}

.ai-success p {
  margin: 0 0 1rem;
  font-size: 0.85rem;
  color: var(--ai-text-muted);
  line-height: 1.6;
}

.ai-success-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

.ai-success-links a {
  color: var(--ai-accent-2);
  text-decoration: none;
  font-size: 0.85rem;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--ai-border);
  border-radius: 8px;
}

.ai-success-links a:hover {
  border-color: var(--ai-border-glow);
}

/* ── Composer ── */
.ai-composer-wrap {
  position: sticky;
  bottom: 0;
  z-index: 10;
  padding: 0.75rem 0 max(0.85rem, env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, transparent, rgba(10, 12, 16, 0.92) 35%);
}

.ai-cta-bar {
  max-width: var(--ai-max);
  margin: 0 auto 0.55rem;
  padding: 0.75rem 1rem;
  border-radius: var(--ai-radius);
  border: 1px solid var(--ai-border-glow);
  background: var(--ai-surface-2);
  backdrop-filter: blur(16px);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.ai-cta-bar[hidden] {
  display: none !important;
}

.ai-cta-bar:not([hidden]) {
  animation: ai-fade-in 0.28s ease;
}

.ai-cta-bar.is-pulse {
  animation: ai-panel-glow 1.2s ease 3;
}

.ai-cta-hint {
  flex: 1;
  min-width: 140px;
  margin: 0;
  font-size: 0.78rem;
  color: var(--ai-text-muted);
  line-height: 1.5;
}

.ai-btn-handoff {
  width: 100%;
  padding: 0.7rem 1.15rem;
  font-size: 0.88rem;
}

@media (min-width: 480px) {
  .ai-btn-handoff {
    width: auto;
    flex-shrink: 0;
  }
}

.ai-composer {
  max-width: var(--ai-max);
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.55rem 0.55rem 0.55rem 1rem;
  border-radius: calc(var(--ai-radius) + 2px);
  border: 1px solid var(--ai-border);
  background: var(--ai-surface);
  backdrop-filter: blur(16px);
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.2);
}

.ai-composer:focus-within {
  border-color: var(--ai-border-glow);
}

.ai-composer textarea {
  flex: 1;
  min-height: 24px;
  max-height: 120px;
  resize: none;
  border: none;
  background: transparent;
  color: var(--ai-text);
  font: inherit;
  font-size: 0.9rem;
  line-height: 1.5;
  padding: 0.35rem 0;
}

.ai-composer textarea:focus {
  outline: none;
}

.ai-composer textarea::placeholder {
  color: var(--ai-text-muted);
}

.ai-send {
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, var(--ai-accent), #a8894a);
  color: #0a0c10;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, opacity 0.2s;
}

.ai-send:hover:not(:disabled) {
  transform: scale(1.04);
}

.ai-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.ai-footer-note {
  max-width: var(--ai-max);
  margin: 0.45rem auto 0;
  font-size: 0.68rem;
  color: var(--ai-text-muted);
  text-align: center;
  line-height: 1.5;
}

.ai-honeypot {
  position: absolute;
  left: -9999px;
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 600px) {
  .ai-brand-sub { display: none; }
  .ai-summary-meta { grid-template-columns: 1fr 1fr; }
  .ai-step-label { display: none; }
  .ai-step.is-active .ai-step-label { display: inline; }
}

@media (prefers-reduced-motion: reduce) {
  .ai-msg { animation: none; }
  .ai-typing span { animation: none; }
}
