/* ============================================================
   AARCH · Homepage AI Scene Advisor
   独立样式层：只覆盖 hero 布局与 Agent 组件，不动原有视觉
   ============================================================ */

.hero-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(380px, 472px);
  gap: clamp(24px, 2.6vw, 52px);
  align-items: center;
}

.hero-copy { min-width: 0; }

.hero-question {
  font-size: clamp(54px, 6.1vw, 112px);
  line-height: 1.14;
  letter-spacing: -.035em;
}

/* ---------------- 卡片 ---------------- */

.hero-agent [hidden] { display: none !important; }

.hero-agent {
  position: relative;
  z-index: 3;
  align-self: center;
  width: 100%;
  max-width: 472px;
  justify-self: end;
}

.agent-card {
  position: relative;
  display: flex;
  height: clamp(480px, calc(100svh - 300px), 600px);
  padding: 0;
  border: 1px solid rgba(var(--rgb-line), .18);
  border-radius: 18px;
  flex-direction: column;
  overflow: hidden;
  background:
    radial-gradient(120% 80% at 80% 0%, rgba(var(--rgb-panel), .16), transparent 60%),
    rgba(var(--rgb-bg), .82);
  box-shadow:
    0 40px 90px -30px rgba(0, 0, 0, .85),
    inset 0 1px 0 rgba(255, 255, 255, .09);
  backdrop-filter: blur(18px) saturate(120%);
  transition: height .45s cubic-bezier(.22, .8, .28, 1), border-color .3s;
}

.agent-card::after {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  content: "";
  pointer-events: none;
  background:
    radial-gradient(90% 55% at 50% -10%, rgba(var(--rgb-accent), .10), transparent 70%),
    linear-gradient(180deg, rgba(255, 255, 255, .04), transparent 22%);
}

.agent-edge {
  position: absolute;
  inset: -1px;
  z-index: 2;
  padding: 1px;
  border-radius: inherit;
  background: conic-gradient(from 0deg, transparent 0 52%, rgba(var(--rgb-accent), .18) 58%, rgba(255, 255, 255, .8) 64%, rgba(var(--rgb-accent), .18) 70%, transparent 76%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  pointer-events: none;
  animation: agent-edge-run 8s linear infinite;
  opacity: .75;
}

@keyframes agent-edge-run { to { transform: rotate(1turn); } }

.agent-topbar {
  position: relative;
  z-index: 3;
  display: flex;
  height: 46px;
  padding: 0 16px;
  border-bottom: 1px solid rgba(var(--rgb-line), .10);
  align-items: center;
  gap: 10px;
  color: var(--muted-3);
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 9px;
  letter-spacing: .12em;
}

.agent-live {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ink);
  font-family: var(--sans, system-ui, sans-serif);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .02em;
}

.agent-live i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent-bright);
  box-shadow: 0 0 0 4px rgba(var(--rgb-accent), .10), 0 0 12px rgba(var(--rgb-accent), .7);
  animation: agent-live 2.4s ease-in-out infinite;
}

@keyframes agent-live {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .45; transform: scale(.82); }
}

.agent-model {
  margin-left: auto;
  padding: 4px 8px;
  border: 1px solid rgba(var(--rgb-line), .18);
  border-radius: 3px;
  color: var(--muted-2);
  font-size: 8px;
  letter-spacing: .16em;
}

.agent-collapse {
  width: 24px;
  height: 24px;
  margin-left: 2px;
  padding: 0;
  border: 1px solid rgba(var(--rgb-line), .18);
  border-radius: 50%;
  color: var(--muted-3);
  background: transparent;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  transition: .2s;
}

.agent-collapse:hover { color: #fff; border-color: rgba(255, 255, 255, .5); }

/* ---------------- 待机态 ---------------- */

.agent-stage {
  position: relative;
  z-index: 3;
  display: flex;
  flex: 1;
  padding: 6px 22px 10px;
  flex-direction: column;
  justify-content: center;
  transition: opacity .3s, transform .4s;
}

.agent-greeting {
  margin: 0;
  color: var(--ink);
  font-size: 21px;
  font-weight: 600;
  line-height: 1.55;
  letter-spacing: -.012em;
}

.agent-greeting b {
  font-weight: 600;
  background: linear-gradient(180deg, #ffffff, var(--muted-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.agent-greeting-sub {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.85;
}

/* ---------------- 对话态 ---------------- */

.agent-thread {
  position: relative;
  z-index: 3;
  display: none;
  padding: 4px 18px 6px;
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(var(--rgb-line), .25) transparent;
}

.agent-thread::-webkit-scrollbar { width: 5px; }
.agent-thread::-webkit-scrollbar-thumb { border-radius: 4px; background: rgba(var(--rgb-line), .22); }

.msg {
  display: flex;
  margin-bottom: 14px;
  gap: 9px;
  animation: msg-in .34s cubic-bezier(.22, .8, .28, 1) both;
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(10px); filter: blur(3px); }
  to { opacity: 1; transform: none; filter: none; }
}

.msg-tag {
  display: grid;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  margin-top: 2px;
  border: 1px solid rgba(var(--rgb-line), .30);
  border-radius: 50%;
  place-items: center;
  color: var(--ink);
  font-family: var(--mono, monospace);
  font-size: 8px;
  background: linear-gradient(160deg, var(--panel), var(--bg-soft));
}

.msg-body {
  max-width: calc(100% - 32px);
  padding: 10px 13px;
  border: 1px solid rgba(var(--rgb-line), .10);
  border-radius: 3px 12px 12px 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, .045);
  font-size: 13.5px;
  line-height: 1.8;
  word-break: break-word;
  white-space: pre-wrap;
}

.msg-body strong { color: var(--ink); font-weight: 600; }
.msg-body code { padding: 1px 5px; border-radius: 3px; background: rgba(var(--rgb-accent), .10); font-family: var(--mono, monospace); font-size: 11px; }

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

.msg-user .msg-body {
  border-color: rgba(var(--rgb-line), .22);
  border-radius: 12px 3px 12px 12px;
  color: var(--accent-ink);
  background: linear-gradient(140deg, var(--accent-bright), var(--accent));
  font-weight: 500;
}

.msg-img {
  display: block;
  width: 100%;
  max-width: 200px;
  margin: 2px 0 6px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, .12);
}

.msg-typing { display: inline-flex; gap: 4px; padding: 3px 0; align-items: center; }

.msg-typing i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--muted-2);
  animation: msg-dot 1.1s ease-in-out infinite;
}

.msg-typing i:nth-child(2) { animation-delay: .16s; }
.msg-typing i:nth-child(3) { animation-delay: .32s; }

@keyframes msg-dot {
  0%, 60%, 100% { opacity: .25; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

.agent-caret::after {
  display: inline-block;
  width: 1px;
  height: 12px;
  margin-left: 2px;
  content: "";
  background: var(--accent-bright);
  vertical-align: -2px;
  animation: caret .9s steps(1) infinite;
}

@keyframes caret { 50% { opacity: 0; } }

/* ---------------- 输入区 ---------------- */

.agent-composer {
  position: relative;
  z-index: 3;
  display: flex;
  margin: 8px 14px 10px;
  padding: 6px 6px 6px 10px;
  border: 1px solid rgba(var(--rgb-line), .16);
  border-radius: 12px;
  align-items: flex-end;
  gap: 6px;
  background: rgba(255, 255, 255, .05);
  transition: border-color .25s, box-shadow .25s;
}

.agent-composer:focus-within {
  border-color: rgba(var(--rgb-accent), .45);
  box-shadow: 0 0 0 3px rgba(var(--rgb-accent), .07);
}

.agent-field { display: block; flex: 1; min-width: 0; }

.agent-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.agent-field textarea {
  display: block;
  width: 100%;
  max-height: 96px;
  padding: 6px 2px;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.6;
  resize: none;
}

.agent-field textarea::placeholder { color: var(--muted-3); }

.agent-attach,
.agent-send {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  place-items: center;
  background: transparent;
  cursor: pointer;
  transition: .2s;
}

.agent-attach svg,
.agent-send svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.agent-attach { color: var(--muted-3); }
.agent-attach:hover { color: var(--ink); background: rgba(255, 255, 255, .06); }

.agent-send {
  color: var(--accent-ink);
  background: linear-gradient(140deg, var(--ink), var(--accent));
}

.agent-send:hover { filter: brightness(1.08); }
.agent-send:disabled { opacity: .35; cursor: default; filter: none; }

.agent-suggest {
  position: relative;
  z-index: 3;
  display: grid;
  padding: 0 14px 12px;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.agent-suggest button {
  padding: 9px 11px;
  border: 1px solid rgba(var(--rgb-line), .14);
  border-radius: 8px;
  overflow: hidden;
  color: var(--muted);
  background: rgba(255, 255, 255, .02);
  font-family: inherit;
  font-size: 12px;
  line-height: 1.4;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  transition: .2s;
}

.agent-suggest button:hover { color: var(--ink); border-color: rgba(var(--rgb-accent), .40); background: rgba(255, 255, 255, .055); }

.agent-note {
  position: relative;
  z-index: 3;
  padding: 0 16px 12px;
  color: var(--muted-3);
  font-family: var(--mono, monospace);
  font-size: 8.5px;
  letter-spacing: .08em;
  text-align: center;
}

/* ---------------- 图片预览 ---------------- */

.agent-attach-preview {
  position: relative;
  z-index: 3;
  display: flex;
  margin: 0 14px 2px;
  align-items: center;
  gap: 10px;
}

.agent-attach-preview img {
  width: 46px;
  height: 46px;
  border: 1px solid rgba(var(--rgb-line), .25);
  border-radius: 7px;
  object-fit: cover;
}

.agent-attach-preview button {
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid rgba(var(--rgb-line), .25);
  border-radius: 50%;
  color: var(--muted-3);
  background: transparent;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}

.agent-attach-preview button:hover { color: #fff; }

/* ---------------- 留资卡片 ---------------- */

.agent-lead {
  margin: 4px 0 14px;
  padding: 14px;
  border: 1px solid rgba(var(--rgb-line), .26);
  border-radius: 10px;
  background: linear-gradient(160deg, rgba(255, 255, 255, .055), rgba(255, 255, 255, .015));
  animation: msg-in .34s cubic-bezier(.22, .8, .28, 1) both;
}

.lead-head {
  display: flex;
  margin-bottom: 8px;
  align-items: center;
  justify-content: space-between;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
}

.lead-head button {
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  color: var(--muted-3);
  background: transparent;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

.agent-lead p { margin-bottom: 10px; color: var(--muted-2); font-size: 11.5px; line-height: 1.7; }

.agent-lead input,
.agent-lead textarea {
  display: block;
  width: 100%;
  margin-bottom: 7px;
  padding: 8px 9px;
  border: 1px solid rgba(var(--rgb-line), .16);
  border-radius: 6px;
  outline: 0;
  color: var(--ink);
  background: rgba(var(--rgb-bg), .6);
  font-family: inherit;
  font-size: 12px;
  resize: none;
  transition: border-color .2s;
}

.agent-lead input:focus,
.agent-lead textarea:focus { border-color: rgba(var(--rgb-accent), .48); }
.agent-lead input::placeholder,
.agent-lead textarea::placeholder { color: var(--muted-3); }

.agent-lead button[type="submit"] {
  width: 100%;
  margin-top: 3px;
  padding: 9px;
  border: 0;
  border-radius: 6px;
  color: var(--accent-ink);
  background: linear-gradient(140deg, var(--accent-bright), var(--accent));
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}

.agent-lead button[type="submit"]:disabled { opacity: .5; cursor: default; }

.lead-done { padding: 12px 2px; color: var(--ink-2); font-size: 11.5px; line-height: 1.8; }

/* ---------------- 对话态布局切换 ---------------- */

.hero-agent[data-state="chat"] .agent-card { height: clamp(520px, calc(100svh - 214px), 700px); }
.hero-agent[data-state="chat"] .agent-stage { display: none; }
.hero-agent[data-state="chat"] .agent-thread { display: block; }
.hero-agent[data-state="chat"] .agent-suggest { display: none; }

/* ---------------- 移动端入口 ---------------- */

.agent-fab {
  position: fixed;
  right: 18px;
  bottom: 20px;
  z-index: 60;
  display: none;
  padding: 8px 14px 8px 8px;
  border: 1px solid rgba(var(--rgb-line), .30);
  border-radius: 40px;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  background: rgba(var(--rgb-bg), .92);
  box-shadow: 0 14px 40px rgba(0, 0, 0, .55), 0 0 0 1px rgba(255, 255, 255, .04) inset;
  backdrop-filter: blur(14px);
  cursor: pointer;
  font-family: inherit;
  font-size: 11.5px;
  transition: .25s;
}

.agent-fab:hover { border-color: rgba(var(--rgb-accent), .6); transform: translateY(-2px); }

.fab-orb {
  display: grid;
  width: 30px;
  height: 30px;
  border: 1px solid rgba(var(--rgb-line), .28);
  border-radius: 50%;
  place-items: center;
  color: var(--ink);
  background: linear-gradient(160deg, var(--panel), var(--bg-soft));
  font-size: 11px;
  font-weight: 700;
  box-shadow: 0 0 18px rgba(var(--rgb-accent), .22);
}

.fab-orb sup { margin-left: 1px; color: var(--muted-2); font-family: var(--mono, monospace); font-size: 6px; vertical-align: super; }

/* ---------------- 响应式 ---------------- */

@media (max-width: 1200px) {
  .hero-question { font-size: clamp(50px, 5.6vw, 92px); }
}

@media (max-width: 980px) {
  .hero-layout {
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }

  .hero-question { font-size: clamp(56px, 9.4vw, 88px); }

  .hero-agent {
    width: 100%;
    max-width: 520px;
    margin: 46px auto 0;
    justify-self: center;
  }

  .agent-card { height: 520px; }
  .hero-agent[data-state="chat"] .agent-card { height: 560px; }
  .agent-greeting { font-size: 19px; }
}

@media (max-width: 640px) {
  .hero-question { font-size: clamp(48px, 13.2vw, 64px); line-height: 1.08; }
  .hero-agent { margin-top: 40px; }

  .agent-fab { display: inline-flex; }

  body.agent-open .agent-fab { display: none; }

  body.agent-open::before {
    position: fixed;
    inset: 0;
    z-index: 70;
    content: "";
    background: rgba(var(--rgb-bg), .62);
    backdrop-filter: blur(5px);
  }

  .hero-agent {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 80;
    max-width: none;
    margin: 0;
    padding: 10px;
    transform: translateY(102%);
    transition: transform .4s cubic-bezier(.22, .8, .28, 1), opacity .3s;
    opacity: 0;
    pointer-events: none;
  }

  body.agent-open .hero-agent {
    transform: none;
    opacity: 1;
    pointer-events: auto;
  }

  .agent-card {
    height: min(88svh, 700px);
    border-radius: 16px;
    background: rgba(var(--rgb-bg), .97);
  }

  .hero-agent[data-state="chat"] .agent-card { height: min(88svh, 700px); }
  .agent-stage { padding: 22px 18px 2px; }
  .agent-greeting { font-size: 18px; }
  .agent-greeting-sub { font-size: 12px; }
  .agent-suggest { padding: 0 12px 10px; gap: 6px; }
  .agent-suggest button { padding: 8px 10px; font-size: 11px; }
  .agent-note { padding-bottom: 10px; }

  body.agent-open { overflow: hidden; }
}

@media (prefers-reduced-motion: reduce) {
  .agent-edge, .agent-live i { animation: none !important; }
  .msg, .agent-lead { animation: none; }
  .agent-card { transition: none; }
}
