:root {
  --bg: #f6f0e6;
  --paper: rgba(255, 251, 245, 0.82);
  --paper-strong: rgba(255, 255, 255, 0.88);
  --ink: #1a2431;
  --accent: #0d7b73;
  --accent-soft: #d8efe7;
  --gold: #9b6b17;
  --line: rgba(26, 36, 49, 0.10);
  --danger: #9f1239;
  --shadow: 0 24px 80px rgba(26, 36, 49, 0.10);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 10%, rgba(13, 123, 115, 0.18), transparent 22%),
    radial-gradient(circle at 88% 14%, rgba(155, 107, 23, 0.16), transparent 18%),
    radial-gradient(circle at 50% 100%, rgba(13, 123, 115, 0.10), transparent 28%),
    linear-gradient(180deg, #fbf7ef 0%, #efe4cf 100%);
  font-family: "Iowan Old Style", "Palatino Linotype", "Noto Serif SC", serif;
}

.shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: 40px 20px 80px;
}

.hero,
.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(260px, 0.8fr);
  gap: 20px;
  padding: 30px;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  inset: auto -60px -90px auto;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(13, 123, 115, 0.18), transparent 68%);
  pointer-events: none;
}

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

h1,
h2,
h3 {
  margin: 0;
  font-weight: 700;
}

h1 {
  font-size: clamp(28px, 5vw, 42px);
  line-height: 1.12;
  max-width: 16ch;
}

.lead {
  max-width: 58ch;
  line-height: 1.65;
  font-size: 16px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 24px;
}

.card,
.evidence-card {
  background: var(--paper-strong);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
}

.hero-side {
  display: flex;
  align-items: stretch;
}

.info-stack {
  display: grid;
  gap: 14px;
  width: 100%;
}

.mini-card {
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 22px;
  padding: 20px;
}

.mini-card p {
  margin: 8px 0 0;
  line-height: 1.7;
}

.mini-label {
  display: inline-block;
  color: var(--gold);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
}

.label {
  display: block;
  color: rgba(30, 35, 48, 0.6);
  font-size: 13px;
  margin-bottom: 8px;
}

.panel {
  padding: 28px;
  margin-bottom: 24px;
}

.chat-layout {
  max-width: 980px;
  margin: 0 auto;
}

.chat-panel {
  min-width: 0;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.chat-window {
  display: grid;
  gap: 14px;
  min-height: 320px;
  padding-bottom: 6px;
}

.message {
  display: grid;
  gap: 8px;
}

.message-role {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(26, 36, 49, 0.52);
  font-weight: 700;
}

.message-body {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.75;
  border-radius: 20px;
  border: 1px solid var(--line);
  padding: 16px 18px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 8px 24px rgba(26, 36, 49, 0.04);
}

.message.user {
  justify-items: end;
}

.message.user .message-body {
  max-width: 84%;
  background: linear-gradient(135deg, rgba(13, 123, 115, 0.12), rgba(13, 123, 115, 0.06));
}

.message.assistant .message-body {
  max-width: 92%;
}

.composer {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.composer textarea {
  min-height: 92px;
  font-size: 15px;
}

.composer-tools {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
}

.secondary-button {
  background: rgba(26, 36, 49, 0.08);
  color: var(--ink);
}

textarea,
input,
select,
button {
  font: inherit;
}

textarea,
input,
select {
  width: 100%;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  padding: 14px 16px;
}

textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.65;
}

input {
  min-height: 48px;
}


button {
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #0f766e, #155e75);
  color: white;
  padding: 12px 22px;
  cursor: pointer;
}

.notice {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 16px;
}

.error {
  background: rgba(159, 18, 57, 0.09);
  color: var(--danger);
}

.answer pre {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.75;
  margin: 16px 0 0;
  font-family: "SFMono-Regular", "Menlo", monospace;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
}

a {
  color: #0f4c81;
}

.footer-note {
  color: rgba(26, 36, 49, 0.62);
  font-size: 14px;
  line-height: 1.7;
  padding: 4px 4px 0;
}

.prose {
  font-size: 15px;
}

.prose > :first-child {
  margin-top: 0;
}

.prose > :last-child {
  margin-bottom: 0;
}

.prose p,
.prose ul,
.prose ol,
.prose pre,
.prose blockquote {
  margin: 0 0 12px;
}

.prose ul,
.prose ol {
  padding-left: 22px;
}

.prose li {
  margin: 4px 0;
}

.prose code {
  font-family: "SFMono-Regular", "Menlo", monospace;
  background: rgba(26, 36, 49, 0.06);
  padding: 2px 6px;
  border-radius: 8px;
}

.references-panel {
  max-width: 980px;
  margin: 0 auto 24px;
}

.refs-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.refs-count {
  color: rgba(26, 36, 49, 0.56);
  font-size: 14px;
}

.reference-list {
  display: grid;
  gap: 12px;
}

.reference-card {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 8px 24px rgba(26, 36, 49, 0.04);
}

.reference-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.badge {
  display: inline-flex;
  width: 30px;
  height: 30px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.score,
.reference-meta {
  color: rgba(26, 36, 49, 0.62);
  font-size: 14px;
}

.reference-snippet {
  line-height: 1.65;
  margin: 10px 0 12px;
  color: rgba(26, 36, 49, 0.88);
}

@media (max-width: 720px) {
  .shell {
    padding: 20px 14px 50px;
  }

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

  .hero,
  .panel {
    padding: 20px;
    border-radius: 20px;
  }

  .chat-header,
  .composer-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .message.user .message-body,
  .message.assistant .message-body {
    max-width: 100%;
  }

  button {
    width: 100%;
  }
}
