:root {
  color-scheme: light;
  --bg: #f5efe4;
  --bg-accent: #e7d5bb;
  --panel: rgba(255, 251, 245, 0.88);
  --panel-border: rgba(84, 54, 27, 0.14);
  --text: #2f241b;
  --muted: #6d5b4a;
  --accent: #a0522d;
  --accent-strong: #7e3b1d;
  --user: #efe0ca;
  --assistant: #fffaf3;
  --shadow: 0 24px 60px rgba(93, 58, 31, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(160, 82, 45, 0.12), transparent 30%),
    radial-gradient(circle at bottom right, rgba(110, 70, 42, 0.16), transparent 28%),
    linear-gradient(160deg, var(--bg), #f9f4ec 42%, var(--bg-accent));
}

.shell {
  width: min(1100px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 3rem;
}

a {
  color: var(--accent-strong);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(260px, 0.9fr);
  gap: 1.2rem;
  align-items: start;
}

.hero {
  padding: 2rem 0 1.5rem;
}

.auth-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(84, 54, 27, 0.12);
  border-radius: 20px;
  background: rgba(255, 250, 244, 0.78);
}

.auth-label,
.auth-user {
  margin: 0;
}

.auth-label {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-strong);
}

.auth-user {
  margin-top: 0.25rem;
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 0.5rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--accent-strong);
}

h1 {
  margin: 0;
  font-size: clamp(2.2rem, 7vw, 4.4rem);
  line-height: 0.95;
  max-width: 10ch;
}

.intro,
.notice {
  max-width: 60ch;
  font-size: 1.05rem;
  line-height: 1.6;
}

.notice {
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  border-left: 4px solid var(--accent);
  background: rgba(255, 248, 240, 0.75);
}

.chat-panel {
  display: grid;
  gap: 1rem;
  padding: 1rem;
  border: 1px solid var(--panel-border);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.citations-panel {
  position: sticky;
  top: 1rem;
  display: grid;
  gap: 1rem;
  padding: 1rem;
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  background: rgba(255, 249, 241, 0.84);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.citations-panel-header h2 {
  margin: 0.15rem 0 0;
  font-size: 1.25rem;
}

.citations-eyebrow {
  margin: 0;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.7rem;
  color: var(--accent-strong);
}

.citations-empty {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.citations-list {
  display: grid;
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.citation-card {
  padding: 0.9rem 0.95rem;
  border-radius: 18px;
  background: rgba(255, 253, 249, 0.92);
  border: 1px solid rgba(84, 54, 27, 0.1);
}

.citation-source,
.citation-heading,
.citation-summary {
  margin: 0;
}

.citation-source {
  font-size: 0.76rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-strong);
}

.citation-heading {
  margin-top: 0.35rem;
  color: var(--text);
  line-height: 1.35;
  font-size: 0.98rem;
  font-weight: 700;
}

.citation-summary {
  margin-top: 0.35rem;
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.9rem;
}

.messages {
  display: grid;
  gap: 1rem;
  min-height: 360px;
  max-height: 60vh;
  overflow: auto;
  padding: 0.25rem;
}

.message {
  display: grid;
  gap: 0.4rem;
}

.message[data-role="user"] {
  justify-items: end;
}

.role {
  margin: 0;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.bubble {
  max-width: min(72ch, 100%);
  padding: 1rem 1.1rem;
  border-radius: 20px;
  white-space: pre-wrap;
  line-height: 1.55;
  background: var(--assistant);
  border: 1px solid rgba(84, 54, 27, 0.1);
}

.message[data-role="user"] .bubble {
  background: var(--user);
}

.composer {
  display: grid;
  gap: 0.75rem;
}

textarea {
  width: 100%;
  border: 1px solid rgba(84, 54, 27, 0.15);
  border-radius: 20px;
  padding: 1rem;
  resize: vertical;
  min-height: 120px;
  font: inherit;
  color: inherit;
  background: rgba(255, 252, 247, 0.96);
}

button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 0.9rem 1.4rem;
  font: inherit;
  font-weight: 700;
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  cursor: pointer;
}

.secondary-button {
  color: var(--text);
  background: rgba(255, 250, 244, 0.95);
  border: 1px solid rgba(84, 54, 27, 0.12);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4);
}

.composer-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.composer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.status {
  color: var(--muted);
  font-size: 0.95rem;
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(84, 54, 27, 0.12);
  color: var(--muted);
}

.site-footer-copy,
.site-footer-links {
  margin: 0;
}

.site-footer-links {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.legal-shell {
  width: min(980px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 3rem;
}

.legal-card {
  padding: 1.5rem;
  border: 1px solid var(--panel-border);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.legal-title {
  max-width: none;
  font-size: clamp(2rem, 5vw, 3.2rem);
}

.legal-updated {
  color: var(--muted);
  margin-top: 0.4rem;
}

.legal-card h2 {
  margin-top: 1.6rem;
  margin-bottom: 0.5rem;
  font-size: 1.25rem;
}

.legal-card p,
.legal-card li {
  line-height: 1.65;
}

.legal-list {
  padding-left: 1.25rem;
}

.legal-back {
  margin-top: 2rem;
}

.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: 720px) {
  .shell {
    width: min(100% - 1rem, 100%);
    padding-top: 1rem;
  }

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

  .chat-panel {
    border-radius: 22px;
    padding: 0.85rem;
  }

  .citations-panel {
    position: static;
    border-radius: 22px;
  }

  .composer-row {
    flex-direction: column;
    align-items: stretch;
  }

  .composer-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .auth-bar {
    flex-direction: column;
    align-items: stretch;
  }

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