:root {
  color-scheme: light;
  --ink: #20231f;
  --muted: #686f64;
  --paper: #fbf6eb;
  --paper-strong: #fffdf7;
  --line: #ded4bd;
  --leaf: #1f6f5b;
  --leaf-dark: #164c42;
  --sun: #f2b84b;
  --clay: #cf6f48;
  --blue: #335d7e;
  --shadow: 0 24px 80px rgba(51, 62, 48, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(120deg, rgba(31, 111, 91, 0.10), transparent 36%),
    radial-gradient(circle at 82% 18%, rgba(242, 184, 75, 0.26), transparent 30%),
    linear-gradient(145deg, #f8efdc 0%, #eef4ec 48%, #f9f1e5 100%);
}

button,
textarea {
  font: inherit;
}

.app-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: clamp(16px, 3vw, 32px);
}

.chat-panel {
  width: min(980px, 100%);
  height: min(820px, calc(100dvh - 32px));
  min-height: 620px;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  overflow: hidden;
  border: 1px solid rgba(64, 83, 72, 0.22);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 253, 247, 0.94), rgba(251, 246, 235, 0.96)),
    var(--paper);
  box-shadow: var(--shadow);
}

.masthead {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  padding: clamp(22px, 4vw, 42px) clamp(20px, 4vw, 44px) 20px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(31, 111, 91, 0.10), rgba(242, 184, 75, 0.12)),
    repeating-linear-gradient(135deg, rgba(32, 35, 31, 0.025) 0 1px, transparent 1px 12px);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--leaf-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  max-width: 700px;
  font-family: "Songti SC", "STSong", "SimSun", serif;
  font-size: clamp(2rem, 5vw, 4.7rem);
  line-height: 0.96;
  font-weight: 900;
}

.status-pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid rgba(31, 111, 91, 0.25);
  border-radius: 999px;
  color: var(--leaf-dark);
  background: rgba(255, 253, 247, 0.76);
  font-size: 0.88rem;
  font-weight: 700;
}

.status-pill span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--leaf);
  box-shadow: 0 0 0 5px rgba(31, 111, 91, 0.13);
}

.messages {
  overflow-y: auto;
  padding: 28px clamp(16px, 4vw, 44px);
  scroll-behavior: smooth;
}

.message {
  display: flex;
  gap: 12px;
  margin: 0 0 18px;
}

.message.user {
  justify-content: flex-end;
}

.avatar {
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--leaf-dark);
  font-weight: 900;
}

.message.user .avatar {
  order: 2;
  background: var(--blue);
}

.bubble {
  max-width: min(680px, calc(100% - 54px));
  padding: 14px 16px;
  border: 1px solid rgba(64, 83, 72, 0.16);
  border-radius: 8px;
  background: var(--paper-strong);
  line-height: 1.72;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message.user .bubble {
  color: #fff;
  border-color: rgba(51, 93, 126, 0.24);
  background: var(--blue);
}

.message.pending .bubble {
  color: var(--muted);
}

.typing {
  display: inline-flex;
  gap: 5px;
  align-items: center;
}

.typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1s infinite ease-in-out;
}

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

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

.quick-prompts {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 0 clamp(16px, 4vw, 44px) 14px;
}

.quick-prompts button {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 8px 13px;
  border: 1px solid rgba(207, 111, 72, 0.34);
  border-radius: 999px;
  color: #814125;
  background: rgba(255, 245, 231, 0.82);
  cursor: pointer;
}

.composer {
  display: grid;
  grid-template-columns: 1fr 48px;
  gap: 10px;
  align-items: end;
  padding: 14px clamp(16px, 4vw, 44px) clamp(18px, 3vw, 28px);
  border-top: 1px solid var(--line);
  background: rgba(255, 253, 247, 0.78);
}

textarea {
  width: 100%;
  max-height: 148px;
  min-height: 48px;
  resize: none;
  padding: 13px 15px;
  border: 1px solid rgba(64, 83, 72, 0.24);
  border-radius: 8px;
  color: var(--ink);
  background: #fffefa;
  outline: none;
  line-height: 1.55;
}

textarea:focus {
  border-color: rgba(31, 111, 91, 0.7);
  box-shadow: 0 0 0 4px rgba(31, 111, 91, 0.12);
}

#send-button {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--leaf);
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease;
}

#send-button:hover {
  transform: translateY(-1px);
  background: var(--leaf-dark);
}

#send-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

#send-button svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

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

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

@media (max-width: 700px) {
  .app-shell {
    padding: 0;
  }

  .chat-panel {
    width: 100%;
    height: 100dvh;
    min-height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  .masthead {
    flex-direction: column;
    gap: 14px;
  }

  .status-pill {
    align-self: flex-start;
  }

  .messages {
    padding-top: 20px;
  }

  .avatar {
    flex-basis: 34px;
    width: 34px;
    height: 34px;
    font-size: 0.9rem;
  }

  .bubble {
    max-width: calc(100% - 46px);
    font-size: 0.96rem;
  }
}
