/* ========== 智能体页：园林风 · 半透明见景 ========== */

:root {
  --agent-embed-inset-top: clamp(14px, 3.5vh, 32px);
  --agent-embed-inset-side: clamp(12px, 3.5vw, 28px);
  --agent-embed-inset-bottom: clamp(14px, 3.5vh, 36px);
  --agent-back-size: min(10vw, 46px);
  /* 墨色 / 纸色 / 青绿 / 淡朱 — 贴近园景 UI */
  --agent-ink: #1e1c1a;
  --agent-paper: rgba(248, 244, 236, 0.92);
  --agent-paper-dim: rgba(235, 228, 214, 0.55);
  --agent-moss: rgba(72, 92, 78, 0.55);
  --agent-moss-deep: #4a5c52;
  --agent-edge: rgba(200, 188, 168, 0.38);
  --agent-edge-inner: rgba(60, 54, 48, 0.12);
  --agent-panel: rgba(32, 30, 28, 0.34);
  --agent-panel-2: rgba(24, 22, 20, 0.28);
  --agent-text: rgba(245, 241, 233, 0.94);
  --agent-text-muted: rgba(210, 202, 188, 0.62);
  --agent-font-ui: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC",
    system-ui, sans-serif;
  --agent-font-display: "Songti SC", "SimSun", "STSong", "Noto Serif SC", serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body.agent-page {
  overflow: hidden;
  background: #1a1816;
  font-family: var(--agent-font-ui);
  -webkit-font-smoothing: antialiased;
}

/* 背景：轻晕，不压死画面 */
.agent-page__bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  z-index: 0;
  pointer-events: none;
}

.agent-page__vignette {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(
      ellipse 90% 75% at 50% 42%,
      transparent 0%,
      rgba(20, 18, 16, 0.22) 100%
    ),
    linear-gradient(180deg, rgba(28, 26, 22, 0.12) 0%, rgba(18, 16, 14, 0.35) 100%);
}

/* 主嵌入区：整块聊天浮在景上 */
.agent-page__embed {
  position: fixed;
  left: var(--agent-embed-inset-side);
  right: var(--agent-embed-inset-side);
  top: var(--agent-embed-inset-top);
  bottom: var(--agent-embed-inset-bottom);
  z-index: 10;
  border-radius: 6px;
  overflow: hidden;
  filter: drop-shadow(0 12px 40px rgba(0, 0, 0, 0.28));
}

/* 启动遮罩：略透，见一点底图 */
.agent-boot {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  background: rgba(28, 26, 22, 0.45);
  backdrop-filter: blur(10px) saturate(0.9);
  -webkit-backdrop-filter: blur(10px) saturate(0.9);
  transition: opacity 0.45s ease, visibility 0.45s ease;
}

.agent-boot.is-done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.agent-boot__label {
  margin: 0;
  font-family: var(--agent-font-display);
  font-size: clamp(1.1rem, 3vw, 1.45rem);
  font-weight: 600;
  letter-spacing: 0.28em;
  color: var(--agent-text);
}

.agent-boot__dots::after {
  content: "...";
  font-size: 1.25rem;
  letter-spacing: 0.12em;
  color: var(--agent-paper-dim);
  animation: agent-boot-pulse 1.15s ease-in-out infinite;
}

@keyframes agent-boot-pulse {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .agent-boot__dots::after {
    animation: none;
    opacity: 0.85;
    content: "…";
  }
}

/* ========== 聊天外壳：半透明 + 纸边意 ========== */
.agent-chat {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 100%;
  border-radius: 4px;
  border: 1px solid var(--agent-edge);
  background: linear-gradient(
    165deg,
    var(--agent-panel) 0%,
    var(--agent-panel-2) 100%
  );
  backdrop-filter: blur(18px) saturate(0.88);
  -webkit-backdrop-filter: blur(18px) saturate(0.88);
  box-shadow: inset 0 1px 0 rgba(255, 250, 240, 0.06),
    inset 0 0 0 1px var(--agent-edge-inner), 0 8px 32px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

/* 顶栏：返回在面板内 */
.agent-chat__head {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 10px 10px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(180, 170, 152, 0.2);
  background: rgba(0, 0, 0, 0.08);
}

.agent-chat__back {
  justify-self: start;
  display: flex;
  align-items: center;
  justify-content: center;
  width: calc(var(--agent-back-size) + 14px);
  height: calc(var(--agent-back-size) + 14px);
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  text-decoration: none;
  line-height: 0;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.12s ease, opacity 0.2s ease;
}

.agent-chat__back:hover,
.agent-chat__back:focus-visible {
  outline: none;
}

.agent-chat__back:active {
  transform: scale(0.97);
}

.agent-chat__back img {
  display: block;
  width: var(--agent-back-size);
  height: auto;
  object-fit: contain;
  opacity: 0.9;
  filter: brightness(1.08) contrast(0.95);
  transition: opacity 0.2s ease, filter 0.2s ease;
}

.agent-chat__back:hover img,
.agent-chat__back:focus-visible img {
  opacity: 1;
  filter: brightness(1.12) contrast(0.95);
}

.agent-chat__title {
  grid-column: 2;
  justify-self: center;
  margin: 0;
  font-family: var(--agent-font-display);
  font-size: clamp(1.28rem, 3.6vw, 1.65rem);
  font-weight: 600;
  letter-spacing: 0.48em;
  text-indent: 0.48em;
  color: rgba(240, 235, 224, 0.92);
}

.agent-chat__head-spacer {
  width: calc(var(--agent-back-size) + 14px);
  height: 1px;
  justify-self: end;
}

.agent-chat__messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: clamp(12px, 2.5vh, 22px) clamp(12px, 2.8vw, 20px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--agent-moss) transparent;
}

.agent-chat__messages::-webkit-scrollbar {
  width: 5px;
}

.agent-chat__messages::-webkit-scrollbar-thumb {
  background: var(--agent-moss);
  border-radius: 4px;
}

.agent-chat__bubble {
  max-width: min(90%, 520px);
  padding: 12px 17px;
  font-size: clamp(0.98rem, 2.15vw, 1.0625rem);
  line-height: 1.74;
  letter-spacing: 0.035em;
  word-break: break-word;
  border-radius: 3px;
  animation: agent-bubble-in 0.32s ease;
}

@keyframes agent-bubble-in {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .agent-chat__bubble {
    animation: none;
  }
}

/* 用户：宣纸色 */
.agent-chat__bubble--user {
  align-self: flex-end;
  margin-left: auto;
  color: var(--agent-ink);
  background: var(--agent-paper);
  border: 1px solid rgba(100, 92, 82, 0.18);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
}

/* 知微：淡墨底 */
.agent-chat__bubble--ai {
  align-self: flex-start;
  color: var(--agent-text);
  background: rgba(255, 253, 248, 0.1);
  border: 1px solid rgba(200, 192, 176, 0.18);
}

.agent-chat__bubble--thinking {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--agent-text-muted);
  font-size: clamp(0.9rem, 1.9vw, 0.97rem);
  font-style: normal;
  font-family: var(--agent-font-display);
  letter-spacing: 0.12em;
  background: rgba(255, 253, 248, 0.06);
  border: 1px dashed rgba(160, 150, 135, 0.35);
}

.agent-chat__thinking-dots::after {
  content: "...";
  font-family: var(--agent-font-ui);
  color: var(--agent-paper-dim);
  animation: agent-boot-pulse 1s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .agent-chat__thinking-dots::after {
    animation: none;
    content: "…";
  }
}

/* 底栏 */
.agent-chat__composer {
  display: flex;
  align-items: stretch;
  gap: 10px;
  padding: clamp(10px, 1.8vh, 14px) clamp(12px, 2.8vw, 16px);
  border-top: 1px solid rgba(180, 170, 152, 0.18);
  background: rgba(0, 0, 0, 0.12);
}

.agent-chat__input {
  flex: 1;
  min-width: 0;
  padding: 13px 17px;
  font-family: inherit;
  font-size: clamp(0.98rem, 2.15vw, 1.0625rem);
  letter-spacing: 0.03em;
  color: var(--agent-text);
  background: rgba(255, 253, 248, 0.08);
  border: 1px solid rgba(175, 165, 150, 0.28);
  border-radius: 3px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.agent-chat__input::placeholder {
  color: var(--agent-text-muted);
}

.agent-chat__input:focus {
  border-color: rgba(120, 145, 128, 0.55);
  background: rgba(255, 253, 248, 0.11);
  box-shadow: 0 0 0 2px rgba(90, 110, 98, 0.2);
}

/* 发送：石青绿，忌亮金 */
.agent-chat__send {
  flex-shrink: 0;
  padding: 0 clamp(18px, 3.5vw, 26px);
  font-family: inherit;
  font-size: clamp(0.84rem, 1.85vw, 0.9rem);
  font-weight: 600;
  letter-spacing: 0.18em;
  text-indent: 0.18em;
  color: rgba(252, 250, 245, 0.95);
  cursor: pointer;
  border: 1px solid rgba(72, 92, 82, 0.6);
  border-radius: 3px;
  background: linear-gradient(180deg, #5d7268 0%, var(--agent-moss-deep) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 2px 10px rgba(0, 0, 0, 0.2);
  transition: transform 0.12s ease, filter 0.2s ease, border-color 0.2s ease;
}

.agent-chat__send:hover {
  filter: brightness(1.05);
  border-color: rgba(100, 125, 110, 0.65);
}

.agent-chat__send:active {
  transform: scale(0.98);
}

.agent-chat__send:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  transform: none;
  filter: grayscale(0.15);
}
