:root {
  --warm-white: #fafaf8;
  --warm-white-dark: #f0ede8;
  --text-primary: #2d2d2d;
  --text-secondary: #68635d;
  --accent: #b8860b;
  --accent-hover: #9a7209;
  --accent-light: #f5edd6;
  --border: #e5e1da;
  --muted: #8a8278;
  --shadow: 0 24px 80px rgba(45, 45, 45, 0.08);
  --heading: "Lora", Georgia, serif;
  --body: "Inter", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(184, 134, 11, 0.12), transparent 34rem),
    linear-gradient(180deg, var(--warm-white) 0%, #f7f4ee 100%);
  color: var(--text-primary);
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button,
a,
textarea {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(420px, 1.08fr);
  gap: 28px;
  padding: 24px;
}

.intro-panel,
.chat-panel {
  min-height: calc(100vh - 48px);
}

.intro-panel {
  display: flex;
  flex-direction: column;
  gap: 56px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
  font-weight: 700;
}

.brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: inset 0 0 0 6px var(--accent-light);
}

.nav-label {
  color: var(--text-secondary);
  font-size: 14px;
}

.hero {
  width: min(760px, 100%);
  margin: auto 0;
  padding-bottom: 56px;
}

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

h1,
h2 {
  margin: 0;
  font-family: var(--heading);
  font-weight: 500;
  line-height: 1.08;
}

.hero h1 {
  max-width: 720px;
  font-size: clamp(46px, 7vw, 86px);
}

.hero-copy {
  max-width: 680px;
  margin: 28px 0 0;
  color: var(--text-secondary);
  font-family: var(--heading);
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.38;
}

.hero-note {
  max-width: 620px;
  margin: 24px 0 0;
  color: var(--text-secondary);
  font-size: 16px;
  line-height: 1.65;
}

.chat-panel {
  display: grid;
  align-items: stretch;
}

.chat-shell {
  min-height: calc(100vh - 48px);
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(250, 250, 248, 0.82);
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

.message {
  max-width: 86%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  background: var(--warm-white);
}

.message p {
  margin: 0;
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.55;
  white-space: pre-wrap;
}

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

.user-message {
  align-self: flex-end;
  border-color: rgba(184, 134, 11, 0.38);
  background: #fffaf0;
}

.pending-message p {
  color: var(--muted);
}

.chat-form {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--border);
  padding: 16px;
  background: rgba(250, 250, 248, 0.96);
}

.chat-form label {
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 700;
}

textarea {
  width: 100%;
  min-height: 96px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
  color: var(--text-primary);
  line-height: 1.45;
}

textarea:focus {
  border-color: var(--accent);
  outline: none;
}

.form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#exchange-count {
  color: var(--text-secondary);
  font-size: 13px;
}

.button {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 12px 18px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

@media (hover: hover) and (pointer: fine) {
  .button:hover {
    transform: translateY(-1px);
  }
}

.button-primary {
  background: var(--accent);
  color: #fff;
}

.button-primary:hover {
  background: var(--accent-hover);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.handoff {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  place-items: center;
  padding: 24px;
  background: rgba(45, 45, 45, 0.42);
  backdrop-filter: blur(8px);
}

.handoff.active {
  display: grid;
}

.handoff-card {
  width: min(560px, 100%);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 30px;
  background: var(--warm-white);
  box-shadow: var(--shadow);
}

.handoff-card h2 {
  font-size: clamp(34px, 5vw, 52px);
}

.handoff-card p {
  margin: 18px 0 24px;
  color: var(--text-secondary);
  font-size: 16px;
  line-height: 1.65;
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
    gap: 18px;
    padding: 18px;
  }

  .intro-panel,
  .chat-panel,
  .chat-shell {
    min-height: auto;
  }

  .intro-panel {
    gap: 38px;
  }

  .hero {
    padding: 16px 0 18px;
  }

  .chat-shell {
    min-height: 64vh;
  }

  .message {
    max-width: 94%;
  }
}
