:root {
  --paper: #f5f0e6;
  --ink: #24211d;
  --soft: #6e665b;
  --line: #d7cdbd;
  --panel: rgba(255,255,255,.58);
  --accent: #8b6f47;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 50% 0%, #fffaf0 0, var(--paper) 48%, #ede5d8 100%);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.shell { width: min(880px, calc(100% - 28px)); margin: 0 auto; padding: 52px 0 28px; }
.hero { position: relative; text-align: center; padding: 18px 16px 34px; border-bottom: 1px solid var(--line); }
.hero-actions { position: absolute; top: 4px; right: 0; }
.restart {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.45);
  color: var(--soft);
  font-size: .82rem;
  font-weight: 650;
  padding: 8px 11px;
  border-radius: 999px;
}
.restart:hover { color: var(--ink); background: rgba(255,255,255,.8); }
.eyebrow { font-size: 11px; letter-spacing: .22em; color: var(--soft); font-weight: 700; }
h1 { margin: 10px 0 8px; font-family: Georgia, "Times New Roman", serif; font-weight: 500; font-size: clamp(42px, 8vw, 72px); line-height: .98; }
.hero p { max-width: 640px; margin: 18px auto 0; color: var(--soft); line-height: 1.6; }
.chat { min-height: 52vh; padding: 30px 0 140px; }
.message { display: flex; margin: 18px 0; }
.message.user { justify-content: flex-end; }
.bubble { max-width: min(720px, 88%); padding: 16px 18px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); box-shadow: 0 8px 26px rgba(67,53,35,.05); line-height: 1.62; overflow: hidden; }
.user .bubble { background: #2f2a24; color: #fffaf1; border-color: #2f2a24; }
.message-content > :first-child { margin-top: 0; }
.message-content > :last-child { margin-bottom: 0; }
.message-content p { margin: 0 0 12px; }
.message-content h2,
.message-content h3,
.message-content h4,
.message-content h5 { font-family: Georgia, "Times New Roman", serif; font-weight: 600; line-height: 1.25; margin: 20px 0 8px; }
.message-content h2 { font-size: 1.35rem; }
.message-content h3 { font-size: 1.2rem; }
.message-content h4,
.message-content h5 { font-size: 1.05rem; }
.message-content ul,
.message-content ol { margin: 8px 0 14px; padding-left: 1.35rem; }
.message-content li { margin: 4px 0; }
.message-content blockquote { margin: 12px 0; padding: 8px 14px; border-left: 3px solid var(--line); color: var(--soft); }
.message-content code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; background: rgba(0,0,0,.055); padding: .1em .35em; border-radius: 5px; }
.message-content hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.table-wrap { width: 100%; overflow-x: auto; margin: 14px 0 16px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.35); }
table { width: 100%; border-collapse: collapse; min-width: 420px; font-size: .92rem; }
th, td { text-align: left; vertical-align: top; padding: 10px 12px; border-bottom: 1px solid var(--line); }
th { font-weight: 700; background: rgba(139,111,71,.08); }
tr:last-child td { border-bottom: 0; }
.muted { color: var(--soft); font-size: .92rem; }
.sources { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.sources strong { display: block; font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 7px; color: var(--soft); }
.source { font-size: .88rem; margin: 5px 0; color: var(--soft); }
.source b { color: var(--ink); font-weight: 600; }
.composer {
  position: fixed;
  left: 50%; bottom: 22px; transform: translateX(-50%);
  width: min(850px, calc(100% - 28px));
  display: flex; gap: 10px; align-items: flex-end;
  padding: 10px; border: 1px solid var(--line); border-radius: 20px;
  background: rgba(250,247,240,.93); backdrop-filter: blur(16px);
  box-shadow: 0 18px 55px rgba(50,42,32,.16);
}
textarea { flex: 1; resize: none; border: 0; outline: 0; background: transparent; color: var(--ink); font: inherit; padding: 10px 11px; line-height: 1.45; max-height: 180px; }
button { border: 0; border-radius: 13px; padding: 11px 18px; background: var(--ink); color: white; font-weight: 700; cursor: pointer; }
button:disabled { opacity: .55; cursor: wait; }
footer { text-align: center; color: var(--soft); font-size: .78rem; padding: 8px 0 0; }
.typing { opacity: .68; }
.error .bubble { border-color: #b98b82; }
.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; }
@media (max-width: 640px) {
  .shell { padding-top: 26px; }
  .hero { padding-top: 52px; padding-bottom: 24px; }
  .hero-actions { top: 4px; right: 4px; }
  .chat { padding-bottom: 130px; }
  .bubble { max-width: 94%; }
}
