:root {
  --bg: #f6f4ec;
  --bg-accent: radial-gradient(circle at top left, rgba(194, 164, 106, 0.35), transparent 28%),
    radial-gradient(circle at bottom right, rgba(27, 86, 67, 0.2), transparent 28%),
    linear-gradient(180deg, #f7f3e8 0%, #efe8d5 100%);
  --panel: rgba(255, 252, 245, 0.88);
  --panel-border: rgba(65, 52, 29, 0.12);
  --text: #1f241f;
  --muted: #5f655e;
  --brand: #1b5643;
  --brand-strong: #123c2f;
  --accent: #b28332;
  --assistant: #f0ead9;
  --user: #1b5643;
  --user-text: #f8fbf8;
  --shadow: 0 20px 45px rgba(63, 46, 14, 0.12);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  background-image: var(--bg-accent);
  color: var(--text);
  font-family: "Segoe UI", "Hiragino Sans", "Yu Gothic UI", sans-serif;
}

.page-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 40px 0 48px;
}

.hero {
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--brand);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.78rem;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2.2rem, 5vw, 4rem);
  line-height: 0.95;
}

.lead {
  margin: 16px 0 0;
  width: min(760px, 100%);
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.7;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr);
  gap: 20px;
}

.panel {
  backdrop-filter: blur(12px);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.chat-panel {
  display: flex;
  flex-direction: column;
  min-height: 72vh;
  overflow: hidden;
}

.messages {
  flex: 1;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}

.message {
  max-width: min(88%, 760px);
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  line-height: 1.7;
  animation: rise 180ms ease-out;
}

.message.assistant {
  align-self: flex-start;
  background: var(--assistant);
}

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


.message-body p,
.message-body ul,
.message-body h1,
.message-body h2,
.message-body h3,
.message-body h4,
.message-body h5,
.message-body h6 {
  margin: 0;
}

.message-body p + p,
.message-body p + ul,
.message-body ul + p,
.message-body ul + ul,
.message-body h1 + p,
.message-body h2 + p,
.message-body h3 + p,
.message-body h4 + p,
.message-body h5 + p,
.message-body h6 + p,
.message-body h1 + ul,
.message-body h2 + ul,
.message-body h3 + ul,
.message-body h4 + ul,
.message-body h5 + ul,
.message-body h6 + ul {
  margin-top: 0.6em;
}

.message-body ul {
  padding-left: 1.2em;
}

.message-body li + li {
  margin-top: 0.3em;
}

.message-body h1,
.message-body h2,
.message-body h3,
.message-body h4,
.message-body h5,
.message-body h6 {
  line-height: 1.35;
  font-weight: 700;
}

.message-body h1 {
  font-size: 1.28rem;
}

.message-body h2 {
  font-size: 1.18rem;
}

.message-body h3 {
  font-size: 1.08rem;
}

.message-body code {
  padding: 0.08em 0.38em;
  border-radius: 6px;
  background: rgba(15, 28, 21, 0.08);
  font-family: "Consolas", "Menlo", "Monaco", monospace;
  font-size: 0.92em;
}
.message.pending {
  opacity: 0.75;
}

.composer {
  padding: 18px;
  border-top: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.55);
}

.composer textarea {
  width: 100%;
  resize: vertical;
  min-height: 110px;
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(27, 86, 67, 0.18);
  font: inherit;
  color: inherit;
  background: rgba(255, 255, 255, 0.92);
}

.composer textarea:focus {
  outline: 2px solid rgba(27, 86, 67, 0.18);
  border-color: rgba(27, 86, 67, 0.38);
}

.composer-footer {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 12px 20px;
  font: inherit;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--brand));
  cursor: pointer;
}

button[disabled] {
  opacity: 0.65;
  cursor: progress;
}

.source-panel {
  padding: 24px;
}

.source-panel h2 {
  margin: 0 0 14px;
  font-size: 1.1rem;
}

.sources {
  display: grid;
  gap: 12px;
}

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

.source-card {
  padding: 14px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(65, 52, 29, 0.08);
}

.source-card a {
  color: var(--brand-strong);
  font-weight: 700;
  text-decoration: none;
  word-break: break-all;
}

.source-card p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.6;
}

.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 rise {
  from {
    transform: translateY(6px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@media (max-width: 900px) {
  .page-shell {
    width: min(100vw - 20px, 100%);
    padding-top: 24px;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .chat-panel {
    min-height: 60vh;
  }

  .composer-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  button {
    width: 100%;
  }
}

