/* ==========================================================================
   流光 Lumen · 极简 AI 对话
   清透底色 + 墨色文字 + 暖阳色点缀；首页参照助手类产品布局
   ========================================================================== */

:root {
  --bg-top: #EDF5F1;
  --bg: #F7F6F2;
  --surface: #FFFFFF;
  --ink: #22211D;
  --ink-2: #57544B;
  --muted: #9C988C;
  --line: #E8E5DB;
  --line-strong: #D8D4C7;
  --accent: #F0A03C;
  --accent-deep: #E0823A;
  --accent-soft: rgba(240, 160, 60, 0.12);
  --danger: #B4432F;
  --danger-soft: rgba(180, 67, 47, 0.08);
  --cream: #FFFDF8;
  --grad-text: linear-gradient(92deg, #3D7FD9 0%, #2FA184 38%, #F0A03C 72%, #E05B3A 100%);
  --shadow-sm: 0 1px 2px rgba(34, 33, 29, 0.05);
  --shadow-md: 0 2px 6px rgba(34, 33, 29, 0.04), 0 18px 44px -18px rgba(34, 33, 29, 0.16);
  --shadow-lg: 0 8px 20px rgba(34, 33, 29, 0.08), 0 32px 80px -24px rgba(34, 33, 29, 0.28);
  --r-lg: 22px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Helvetica Neue", sans-serif;
  --mono: "SF Mono", "JetBrains Mono", "Cascadia Code", Consolas, "Courier New", monospace;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg) 42%);
  background-attachment: fixed;
  color: var(--ink);
  line-height: 1.7;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: rgba(240, 160, 60, 0.25); }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
textarea, input { font-family: inherit; color: var(--ink); }

img { -webkit-user-drag: none; }

/* ---- 背景氛围 ---------------------------------------------------------- */

.ambient {
  position: fixed; inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  will-change: transform;
}

.blob-a {
  width: 46vmax; height: 46vmax;
  left: -14vmax; top: -18vmax;
  background: radial-gradient(circle at 40% 40%, rgba(126, 200, 165, 0.22), transparent 65%);
}

.blob-b {
  width: 40vmax; height: 40vmax;
  right: -16vmax; top: 26vh;
  background: radial-gradient(circle at 55% 45%, rgba(133, 180, 255, 0.16), transparent 65%);
}

.blob-c {
  width: 34vmax; height: 34vmax;
  left: 28vw; bottom: -20vmax;
  background: radial-gradient(circle at 50% 50%, rgba(240, 160, 60, 0.12), transparent 65%);
}

/* 细腻噪点，增加质感 */
.grain {
  position: fixed; inset: -50%;
  pointer-events: none;
  z-index: 0;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain-shift 9s steps(6) infinite;
}

@keyframes grain-shift {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-2%, 2%); }
  40% { transform: translate(2%, -1%); }
  60% { transform: translate(-1%, -2%); }
  80% { transform: translate(1%, 2%); }
}

/* ---- 整体布局 ---------------------------------------------------------- */

.app {
  position: relative;
  z-index: 1;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---- 顶栏 -------------------------------------------------------------- */

.topbar {
  flex: none;
  height: 64px;
  padding: 0 clamp(16px, 4vw, 32px);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  user-select: none;
}

.brand-mark {
  width: 30px; height: 30px;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(240, 160, 60, 0.35));
}

.brand-name {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.14em;
}

.brand-name em {
  font-style: normal;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  margin-left: 8px;
  vertical-align: 2px;
}

.topbar-actions { display: flex; gap: 6px; }

.icon-btn {
  width: 38px; height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--ink-2);
  transition: background 0.25s var(--ease-out), color 0.25s, transform 0.25s var(--ease-out);
}

.icon-btn svg { width: 19px; height: 19px; }
.icon-btn:hover { background: rgba(34, 33, 29, 0.06); color: var(--ink); }
.icon-btn:active { transform: scale(0.92); }

.icon-btn.small { width: 34px; height: 34px; border-radius: 10px; }
.icon-btn.small svg { width: 17px; height: 17px; }

/* ---- 聊天滚动区 -------------------------------------------------------- */

.chat-scroll {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  padding: 0 16px;
}

.chat-scroll::-webkit-scrollbar { width: 5px; }
.chat-scroll::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; }
.chat-scroll::-webkit-scrollbar-track { background: transparent; }

/* ==========================================================================
   首页（空对话状态）：吉祥物 + 渐变标语 + 功能宫格 + 滚动建议
   ========================================================================== */

.home {
  max-width: 680px;
  margin: 0 auto;
  min-height: calc(100dvh - 264px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4px 0 18px;
}

.mascot {
  width: clamp(84px, 13vw, 112px);
  height: auto;
  filter: drop-shadow(0 14px 24px rgba(240, 160, 60, 0.28));
  will-change: transform;
}

.slogan {
  margin-top: 16px;
  font-size: clamp(20px, 3.4vw, 27px);
  font-weight: 600;
  letter-spacing: 0.05em;
  background: var(--grad-text);
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: slogan-flow 9s linear infinite;
}

@keyframes slogan-flow {
  0% { background-position: 0% 50%; }
  100% { background-position: -220% 50%; }
}

/* ---- 功能宫格卡片 ------------------------------------------------------ */

.feature-card {
  margin-top: 26px;
  width: 100%;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 24px;
  box-shadow: var(--shadow-md);
  padding: 18px 14px 12px;
}

.feature-pages {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}
.feature-pages::-webkit-scrollbar { display: none; }

.feature-page {
  flex: 0 0 100%;
  scroll-snap-align: center;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px 8px;
  padding: 0 6px;
}

.feature {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 2px;
  border-radius: 14px;
  transition: transform 0.3s var(--ease-out);
}

.feature:active { transform: scale(0.95); }

.feature-img {
  width: clamp(80px, 11vw, 104px);
  aspect-ratio: 1;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 6px 16px -6px rgba(34, 33, 29, 0.18);
  transition: transform 0.35s var(--ease-out), box-shadow 0.35s;
}

.feature-img img { width: 100%; height: 100%; object-fit: cover; display: block; }

@media (hover: hover) {
  .feature:hover { transform: translateY(-3px); }
  .feature:hover .feature-img { transform: scale(1.045) rotate(-1deg); box-shadow: 0 14px 26px -8px rgba(34, 33, 29, 0.26); }
}

.feature-name {
  font-size: 13px;
  color: var(--ink-2);
  letter-spacing: 0.02em;
}

.feature-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding-top: 12px;
}

.feature-dots i {
  width: 6px; height: 6px;
  border-radius: 99px;
  background: var(--line-strong);
  transition: width 0.3s var(--ease-out), background 0.3s;
}

.feature-dots i.on { width: 16px; background: var(--accent); }

/* ---- 滚动建议标签（跑马灯） -------------------------------------------- */

.chip-rows {
  width: 100%;
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
  /* 两端淡出遮罩 */
  mask-image: linear-gradient(90deg, transparent 0, #000 6%, #000 94%, transparent 100%);
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 6%, #000 94%, transparent 100%);
}

.chip-line {
  display: flex;
  gap: 10px;
  width: max-content;
  will-change: transform;
}

.chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  font-size: 13px;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 99px;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
  transition: border-color 0.25s, color 0.25s, box-shadow 0.25s, transform 0.25s var(--ease-out);
}

.chip:hover {
  border-color: var(--line-strong);
  color: var(--ink);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.chip:active { transform: scale(0.96); }

/* ==========================================================================
   消息
   ========================================================================== */

.messages {
  max-width: 760px;
  margin: 0 auto;
  padding: 18px 0 30px;
}

.msg { margin-bottom: 26px; }

/* 用户消息：墨色气泡，右对齐 */
.msg.user {
  display: flex;
  justify-content: flex-end;
}

.msg.user .bubble {
  max-width: min(78%, 520px);
  padding: 11px 16px 12px;
  background: var(--ink);
  color: var(--cream);
  font-size: 15px;
  line-height: 1.75;
  border-radius: 20px 20px 6px 20px;
  box-shadow: 0 10px 26px -12px rgba(34, 33, 29, 0.45);
  word-break: break-word;
  white-space: pre-wrap;
}

/* AI 消息：无边框排版 + 光点头像 */
.msg.assistant .ai-row {
  display: flex;
  gap: 13px;
  align-items: flex-start;
}

.ai-orb {
  flex: none;
  width: 26px; height: 26px;
  margin-top: 4px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #FFD84D, #F0A03C 70%);
  box-shadow: inset 0 -2px 5px rgba(0, 0, 0, 0.12), 0 4px 12px -4px rgba(240, 160, 60, 0.55);
}

.msg.assistant.pending .ai-orb { animation: orb-pulse 1.6s ease-in-out infinite; }

@keyframes orb-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.82); opacity: 0.65; }
}

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

/* 思考中圆点 */
.dots { display: inline-flex; gap: 5px; padding: 8px 0 2px; }

.dots i {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--line-strong);
  animation: dot-bounce 1.2s ease-in-out infinite;
}

.dots i:nth-child(2) { animation-delay: 0.15s; }
.dots i:nth-child(3) { animation-delay: 0.3s; }

@keyframes dot-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.55; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* Markdown 排版 */
.md {
  font-size: 15.5px;
  line-height: 1.85;
  color: var(--ink);
  word-break: break-word;
}

.md > * + * { margin-top: 0.9em; }
.md h1, .md h2, .md h3, .md h4 { font-weight: 600; line-height: 1.4; margin-top: 1.5em; }
.md h1 { font-size: 1.35em; } .md h2 { font-size: 1.22em; } .md h3 { font-size: 1.1em; }
.md ul, .md ol { padding-left: 1.4em; }
.md li + li { margin-top: 0.35em; }
.md li::marker { color: var(--accent-deep); }
.md a { color: var(--accent-deep); text-decoration-color: rgba(224, 130, 58, 0.35); text-underline-offset: 3px; }
.md strong { font-weight: 650; }
.md blockquote {
  border-left: 2px solid var(--accent);
  padding: 2px 0 2px 14px;
  color: var(--ink-2);
}
.md hr { border: none; border-top: 1px solid var(--line); margin: 1.4em 0; }
.md code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: rgba(34, 33, 29, 0.055);
  border: 1px solid rgba(34, 33, 29, 0.05);
  padding: 2px 6px;
  border-radius: 6px;
}
.md pre {
  position: relative;
  background: #26241F;
  color: #EFEAE0;
  border-radius: 14px;
  padding: 16px 18px;
  overflow-x: auto;
  font-size: 13.5px;
  line-height: 1.7;
  box-shadow: var(--shadow-md);
}
.md pre code { background: none; border: none; padding: 0; font-size: inherit; color: inherit; }
.md table { border-collapse: collapse; font-size: 0.92em; width: 100%; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--line); padding: 7px 12px; text-align: left; }
.md th { background: rgba(34, 33, 29, 0.03); font-weight: 600; }

/* 流式输出光标 */
.md.streaming > :last-child::after,
.md.streaming:empty::after {
  content: "";
  display: inline-block;
  width: 8px; height: 16px;
  margin-left: 3px;
  vertical-align: -2px;
  border-radius: 2px;
  background: var(--accent-deep);
  animation: caret-blink 0.9s steps(2) infinite;
}

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

/* 消息操作 */
.msg-actions {
  margin-top: 8px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 0.3s var(--ease-out), transform 0.3s var(--ease-out);
}

.msg:hover .msg-actions,
.msg-actions:focus-within { opacity: 1; transform: none; }

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
  padding: 4px 9px;
  border-radius: 8px;
  transition: color 0.2s, background 0.2s;
}

.action-btn svg { width: 13px; height: 13px; }
.action-btn:hover { color: var(--ink); background: rgba(34, 33, 29, 0.05); }

/* 错误卡片 */
.error-card {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--danger-soft);
  border: 1px solid rgba(180, 67, 47, 0.18);
  border-radius: 14px;
  padding: 12px 15px;
  font-size: 13.5px;
  color: var(--danger);
  line-height: 1.6;
}

.error-card svg { flex: none; width: 16px; height: 16px; margin-top: 3px; }
.error-card .action-btn { color: var(--danger); font-weight: 500; text-decoration: underline; text-underline-offset: 3px; }
.error-card .action-btn:hover { background: rgba(180, 67, 47, 0.08); }

/* ==========================================================================
   输入区
   ========================================================================== */

.composer-wrap {
  flex: none;
  position: relative;
  padding: 6px clamp(14px, 4vw, 32px) calc(10px + env(safe-area-inset-bottom));
}

.to-bottom {
  position: absolute;
  left: 50%;
  top: -46px;
  transform: translateX(-50%);
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
  display: grid;
  place-items: center;
  color: var(--ink-2);
  z-index: 5;
}

.to-bottom svg { width: 16px; height: 16px; }
.to-bottom:hover { color: var(--ink); }

.composer {
  max-width: 760px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: var(--shadow-md);
  padding: 10px 12px 10px 20px;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.composer:focus-within {
  border-color: var(--line-strong);
  box-shadow: 0 2px 6px rgba(34, 33, 29, 0.04), 0 24px 56px -20px rgba(34, 33, 29, 0.22);
}

.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

#input {
  flex: 1;
  border: none;
  outline: none;
  background: none;
  resize: none;
  font-size: 15.5px;
  line-height: 1.65;
  max-height: 168px;
  padding: 9px 0;
  color: var(--ink);
}

#input::placeholder { color: var(--muted); }

.send-btn {
  flex: none;
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--cream);
  display: grid;
  place-items: center;
  transition: background 0.3s var(--ease-out), transform 0.3s var(--ease-out), opacity 0.3s;
  will-change: transform;
}

.send-btn svg { width: 18px; height: 18px; }
.send-btn .ico-stop { display: none; }

.send-btn:disabled {
  background: var(--line);
  color: var(--muted);
  cursor: default;
}

.send-btn:not(:disabled):hover { background: #3A372F; }
.send-btn:not(:disabled):active { transform: scale(0.9); }

/* 生成中：按钮变为停止态 */
.composer.streaming .send-btn {
  background: var(--accent-deep);
  color: #FFF7EE;
  animation: stop-pulse 2s ease-in-out infinite;
}

.composer.streaming .send-btn .ico-send { display: none; }
.composer.streaming .send-btn .ico-stop { display: block; }

@keyframes stop-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(224, 130, 58, 0.35); }
  50% { box-shadow: 0 0 0 8px rgba(224, 130, 58, 0.12); }
}

.model-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--muted);
  padding: 3px 10px 3px 8px;
  margin: 2px 0 2px -8px;
  border-radius: 99px;
  transition: color 0.25s, background 0.25s;
}

.model-chip:hover { color: var(--ink-2); background: rgba(34, 33, 29, 0.045); }

.model-chip .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--line-strong);
  transition: background 0.3s, box-shadow 0.3s;
}

.model-chip.ok .dot {
  background: #5D8A66;
  box-shadow: 0 0 0 3px rgba(93, 138, 102, 0.15);
}

.composer-hint {
  text-align: center;
  font-size: 11.5px;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-top: 10px;
  user-select: none;
}

/* 品牌与提示（单行页脚） */
.composer-hint .brand-link {
  color: inherit;
  text-decoration: none;
  transition: color 0.25s;
}

.composer-hint .brand-link:hover { color: var(--accent-deep); }

/* ---- Toast ------------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 110px;
  transform: translateX(-50%);
  z-index: 60;
  background: var(--ink);
  color: var(--cream);
  font-size: 13px;
  padding: 9px 18px;
  border-radius: 99px;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  white-space: nowrap;
}

/* ---- 滚动淡出遮罩 ------------------------------------------------------- */

.chat-scroll {
  mask-image: linear-gradient(to bottom, transparent 0, #000 20px, #000 calc(100% - 8px), transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 20px, #000 calc(100% - 8px), transparent 100%);
}

/* ==========================================================================
   响应式
   ========================================================================== */

/* 平板/窄桌面：保持 6 格一页的轮播，加大留白 */
@media (min-width: 760px) and (max-width: 1199.98px) {
  .feature-card { padding: 24px 20px 16px; }
  .feature-page { gap: 22px 10px; }
  .feature-name { font-size: 13.5px; }
}

/* 宽屏：空间足够时两页并排铺开为 2×6 */
@media (min-width: 1200px) {
  .feature-pages { overflow: visible; display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; }
  .feature-page { flex: initial; padding: 0; }
  .feature-card { padding: 22px 18px 14px; }
  .feature-img { width: clamp(72px, 6.2vw, 92px); }
  .feature-dots { display: none; }
}

/* 平板及以下 */
@media (max-width: 1024px) {
  .home { max-width: 600px; }
  .messages { max-width: 680px; }
  .composer { max-width: 680px; }
}

/* 手机 */
@media (max-width: 640px) {
  .topbar { height: 56px; padding: 0 12px; }
  .brand-mark { width: 26px; height: 26px; }
  .brand-name { font-size: 16px; }
  .brand-name em { display: none; }

  .chat-scroll { padding: 0 12px; }

  .home { min-height: calc(100dvh - 240px); padding-top: 8px; }
  .slogan { margin-top: 14px; letter-spacing: 0.03em; }

  .feature-card { margin-top: 22px; padding: 14px 10px 8px; border-radius: 20px; }
  .feature-page { gap: 12px 6px; }
  .feature-img { width: 72px; border-radius: 15px; }
  .feature-name { font-size: 12px; }

  .chip-rows { margin-top: 20px; gap: 8px; }
  .chip { padding: 8px 13px; font-size: 12.5px; }

  .messages { padding: 14px 0 20px; }
  .msg { margin-bottom: 20px; }

  .msg.user .bubble { max-width: 86%; font-size: 14.5px; }
  .md { font-size: 14.5px; }

  .composer-wrap { padding: 4px 10px calc(8px + env(safe-area-inset-bottom)); }
  .composer { padding: 8px 8px 8px 16px; border-radius: 24px; }
  #input { font-size: 15px; }
  .send-btn { width: 40px; height: 40px; }
  .composer-hint { font-size: 10.5px; margin-top: 8px; }
  /* 手机无键盘回车习惯，隐藏快捷键提示让页脚保持单行 */
  .hint-keys { display: none; }
  .to-bottom { top: -42px; }

    .toast { bottom: 130px; max-width: 86vw; white-space: normal; text-align: center; }
}

/* ---- 动效降级 ---------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .grain { animation: none; }
  .slogan { animation: none; }
  .msg.assistant.pending .ai-orb { animation: none; }
  .chat-scroll { scroll-behavior: auto; }
  * { transition-duration: 0.01ms !important; }
}
