:root {
  --bg: #efe7da;
  --panel: rgba(249, 245, 239, 0.84);
  --panel-strong: rgba(255, 252, 248, 0.96);
  --line: rgba(42, 32, 22, 0.12);
  --ink: #23180f;
  --muted: #716356;
  --accent: #9c3d13;
  --accent-strong: #7d2f0d;
  --user: #f3d6b2;
  --assistant: #f7f5f1;
  --shadow: 0 26px 80px rgba(44, 29, 18, 0.12);
  --radius-xl: 32px;
  --radius-lg: 24px;
  --radius-md: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Aptos", "Segoe UI Variable Text", "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 12% 10%, rgba(156, 61, 19, 0.22), transparent 22%),
    radial-gradient(circle at 88% 16%, rgba(36, 92, 72, 0.18), transparent 24%),
    linear-gradient(180deg, #ecdcc7 0%, #f6efe5 48%, #efe7da 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(35, 24, 15, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(35, 24, 15, 0.035) 1px, transparent 1px);
  background-size: 24px 24px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.45), transparent 78%);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.chat-panel {
  width: min(100%, 920px);
  height: min(88vh, 980px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 18px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--panel);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.panel-head h1 {
  margin: 0;
  font-family: "Georgia", "Times New Roman", "Songti SC", serif;
  font-size: clamp(34px, 5vw, 54px);
  letter-spacing: -0.05em;
}

.head-copy {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: auto;
  padding: 6px 4px 6px 0;
}

.message {
  max-width: min(82%, 680px);
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--assistant);
}

.message.user {
  align-self: end;
  background: var(--user);
}

.message.assistant {
  align-self: start;
}

.message.error {
  align-self: center;
  width: 100%;
  max-width: 100%;
  background: #fff0eb;
  border-color: rgba(156, 61, 19, 0.24);
}

.message-meta {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.message-body {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.7;
  font-size: 15px;
}

.composer {
  display: grid;
  gap: 10px;
  padding: 16px;
  border-radius: var(--radius-lg);
  background: var(--panel-strong);
  border: 1px solid rgba(42, 32, 22, 0.08);
}

.composer-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

textarea {
  width: 100%;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
  line-height: 1.7;
  min-height: 96px;
}

textarea::placeholder {
  color: #8f8275;
}

.composer-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.status {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

button {
  border: 0;
  border-radius: 999px;
  min-width: 108px;
  min-height: 48px;
  padding: 12px 20px;
  background: linear-gradient(145deg, var(--accent), var(--accent-strong));
  color: #fff8f2;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.18s ease, opacity 0.18s ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
}

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

  .chat-panel {
    height: min(94vh, 980px);
    padding: 18px;
  }

  .panel-head,
  .composer-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .message {
    max-width: 100%;
  }

  button {
    width: 100%;
  }
}
