:root {
  --bg: #faf9f6;
  --paper: #fffdf6;
  --cream: #fbf5e6;
  --ink: #2f3a4a;
  --muted: #8a94a3;
  --border: #e3d9c2;
  --line: #e0d5bd;
  --blue: #dce9f5;
  --blue-ink: #2f4a66;
  --green: #7fb069;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font-hand: "LuoRiShaTan", "Kalam", "Zhi Mang Xing", "LXGW WenKai", cursive;
  --font-body: "LXGW WenKai", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "Caveat", "LXGW WenKai", cursive;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  position: relative;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(circle at 18% 8%, rgba(251, 207, 232, 0.22), transparent 46%),
    radial-gradient(circle at 85% 4%, rgba(186, 214, 240, 0.28), transparent 42%),
    linear-gradient(rgba(0, 0, 0, 0.025) 1px, transparent 1px) 0 0 / 100% 26px,
    linear-gradient(90deg, rgba(0, 0, 0, 0.025) 1px, transparent 1px) 0 0 / 26px 100%,
    var(--bg);
}

h1,
h2,
p {
  margin: 0;
}

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

.muted {
  color: var(--muted);
}

.chat {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 760px;
  margin: 0 auto;
  background: linear-gradient(175deg, #fbf5e6 0%, #f7eeda 100%);
  border-left: 1px solid rgba(31, 41, 55, 0.06);
  border-right: 1px solid rgba(31, 41, 55, 0.06);
  box-shadow: 0 0 60px -30px rgba(31, 41, 55, 0.35);
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 22px;
  border-bottom: 1.5px dashed var(--line);
  background: rgba(255, 253, 246, 0.6);
}

.chat-header h1 {
  font-family: var(--font-hand);
  font-size: 18px;
  font-weight: 700;
}

.chat-header p {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
}

.avatar {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 13px;
  background: #fffdf6;
  border: 1px solid rgba(31, 41, 55, 0.08);
  box-shadow: 0 6px 14px -8px rgba(31, 41, 55, 0.3);
  color: var(--blue-ink);
  font-family: var(--font-hand);
  font-size: 18px;
  font-weight: 700;
  transform: rotate(-3deg);
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(127, 176, 105, 0.18);
}

.ghost {
  margin-left: auto;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fffdf6;
  color: #8a8163;
  font-family: var(--font-body);
  font-size: 13px;
  cursor: pointer;
  transition: color 0.2s, background 0.2s, transform 0.25s var(--ease);
}

.ghost:hover {
  color: var(--ink);
  background: #fff;
  transform: translateY(-1px);
}

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 26px 24px;
  scroll-behavior: smooth;
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  margin: 0;
  animation: in 0.6s var(--ease) both;
}

.empty[hidden] {
  display: none;
}

.empty h2 {
  font-family: var(--font-hand);
  font-size: 26px;
  font-weight: 700;
  color: var(--ink);
  padding-bottom: 7px;
  background: linear-gradient(90deg, rgba(150, 182, 216, 0.5), rgba(150, 182, 216, 0.22)) left bottom / 58% 11px no-repeat;
}

.suggestions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  margin-top: 10px;
}

.suggestions button {
  width: fit-content;
  padding: 12px 20px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: #fffdf6;
  color: #4b5563;
  font-family: var(--font-body);
  font-size: 15px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.3s var(--ease), box-shadow 0.3s;
}

.suggestions button:hover {
  border-color: #cbbc98;
  background: #fff;
  transform: translateY(-2px);
  box-shadow: 0 8px 16px -10px rgba(31, 41, 55, 0.28);
}

.msg {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 15px;
  white-space: pre-wrap;
  word-break: break-word;
  animation: in 0.4s var(--ease) both;
}

.msg.user {
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  background: var(--blue);
  color: var(--blue-ink);
}

.msg.assistant {
  align-self: flex-start;
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  background: #fffdf6;
  color: var(--ink);
}

.typing {
  display: inline-flex;
  gap: 5px;
  padding: 4px 0;
}

.typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #b9ac8d;
  animation: blink2 1.2s infinite;
}

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

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

@keyframes blink2 {
  0%, 60%, 100% { opacity: 0.4; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

@keyframes in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin: 0 18px 18px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #fffdf6;
  box-shadow: inset 0 2px 6px rgba(31, 41, 55, 0.04);
  transition: border-color 0.2s;
}

.composer:focus-within {
  border-color: #cbbc98;
}

.composer textarea {
  flex: 1;
  max-height: 160px;
  padding: 8px 0;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
}

.composer textarea::placeholder {
  color: #b3a98f;
}

.composer button {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 13px;
  background: linear-gradient(170deg, #dce9f5 0%, #c8dcee 100%);
  color: var(--blue-ink);
  cursor: pointer;
  box-shadow: 0 6px 12px -6px rgba(47, 74, 102, 0.35);
  transition: transform 0.25s var(--ease), filter 0.2s;
}

.composer button:hover:not(:disabled) {
  transform: translateY(-2px);
  filter: brightness(1.03);
}

.composer button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.composer svg {
  width: 18px;
  height: 18px;
}

/* ---------- 移动端：铺满整个屏幕 ---------- */
@media (max-width: 760px) {
  .chat {
    max-width: none;
    height: 100dvh; /* 动态视口高度，跟随浏览器地址栏伸缩，避免上下留白 */
    border-left: 0;
    border-right: 0;
    box-shadow: none;
  }
  .messages {
    padding: 18px 16px;
  }
  .composer {
    margin-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); /* iPhone 底部横条避让 */
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}


.msg.thinking {
  color: var(--muted);
}
