:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #173333;
  background: #eceee7;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-width: 320px; min-height: 100%; }
button, textarea { font: inherit; }
button { cursor: pointer; }

.shell {
  display: grid;
  grid-template-columns: minmax(270px, 370px) minmax(0, 1fr);
  gap: 22px;
  max-width: 1380px;
  min-height: 100dvh;
  margin: auto;
  padding: 22px;
}

.intro {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 600px;
  padding: 30px 28px;
  overflow: hidden;
  border-radius: 28px;
  background: #102829;
  color: #eff5e8;
  position: relative;
}

.intro::before {
  content: "";
  position: absolute;
  width: 360px;
  height: 360px;
  border: 1px solid rgba(213, 235, 191, .16);
  border-radius: 50%;
  top: 22%;
  right: -270px;
  box-shadow: 0 0 0 75px rgba(213, 235, 191, .025), 0 0 0 150px rgba(213, 235, 191, .025);
  pointer-events: none;
}

.brand { display: inline-flex; align-items: center; gap: 12px; width: fit-content; color: inherit; text-decoration: none; font-size: 25px; font-weight: 760; letter-spacing: -.07em; }
.brand-eight { color: #c2e07c; }
.brand-mark { display: grid; grid-template-columns: repeat(2, 7px); grid-template-rows: repeat(2, 7px); gap: 3px; transform: rotate(-25deg); }
.brand-mark span { border-radius: 2px; background: #c2e07c; }
.brand-mark span:last-child { grid-column: 1 / 3; width: 8px; }
.intro-copy { position: relative; z-index: 1; }
.eyebrow { color: #b6d78b; font-size: 10px; font-weight: 800; letter-spacing: .19em; }
.intro h1 { max-width: 330px; margin: 18px 0 18px; font-size: clamp(36px, 3.3vw, 55px); line-height: 1.02; letter-spacing: -.065em; font-weight: 650; }
.intro-description { max-width: 310px; color: #b7c8c3; line-height: 1.62; font-size: 15px; }
.feature-list { margin-top: 38px; display: grid; gap: 18px; color: #e6eee9; font-size: 13px; }
.feature-list div { display: flex; align-items: center; gap: 12px; }
.feature-dot { width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; background: #c2e07c; box-shadow: 0 0 0 4px rgba(194, 224, 124, .12); }
.intro-footer { color: #8ea59e; font-size: 11px; line-height: 1.6; }

.chat-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: calc(100dvh - 44px);
  min-height: 600px;
  overflow: hidden;
  border: 1px solid #dce3dc;
  border-radius: 28px;
  background: #fafbf8;
  box-shadow: 0 12px 50px rgba(15, 46, 39, .06);
}

.chat-header { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; padding: 18px 23px; border-bottom: 1px solid #e9eee7; background: rgba(250, 251, 248, .96); }
.avatar { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: #173d3b; color: #d3ed9d; font-weight: 800; font-size: 21px; }
.chat-header h2 { margin: 0; font-size: 14px; letter-spacing: -.02em; }
.chat-header p { margin: 3px 0 0; color: #748680; font-size: 11px; }
.online-dot { display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: #83bd66; vertical-align: 1px; }
.chapter-badge { margin-left: auto; padding: 7px 9px; border: 1px solid #dfe9d5; border-radius: 7px; color: #6b8b54; font-size: 9px; font-weight: 800; letter-spacing: .11em; white-space: nowrap; }

.messages { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 30px clamp(18px, 4vw, 58px); scroll-behavior: smooth; }
.welcome { max-width: 525px; margin: min(11vh, 90px) auto 0; text-align: center; }
.welcome-icon { display: grid; place-items: center; width: 54px; height: 54px; margin: 0 auto 20px; border-radius: 16px; background: #e8f0dc; color: #557d48; font-size: 28px; }
.welcome h3 { margin: 0 0 10px; font-size: clamp(22px, 2.2vw, 29px); line-height: 1.2; letter-spacing: -.045em; }
.welcome p { margin: 0 auto; max-width: 445px; color: #798780; font-size: 13px; line-height: 1.65; }
.suggestions { display: grid; gap: 8px; margin: 30px auto 0; max-width: 380px; text-align: left; }
.suggestion { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 13px 16px; border: 1px solid #e1e9e0; border-radius: 12px; background: #fff; color: #37504b; text-align: left; font-size: 12px; transition: border-color .2s, transform .2s; }
.suggestion:hover, .suggestion:focus-visible { border-color: #9ec78b; transform: translateY(-1px); }
.suggestion span { color: #83a773; font-size: 17px; }

.message { display: flex; gap: 10px; margin: 0 0 20px; animation: arrive .2s ease-out; }
.message.user { justify-content: flex-end; }
.message-avatar { flex: 0 0 28px; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 9px; background: #e8f0dc; color: #42694b; font-size: 15px; font-weight: 800; }
.message-body { min-width: 0; max-width: min(85%, 650px); }
.message-label { margin: 2px 0 6px; color: #8d9a93; font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.message-text { padding: 14px 17px; border: 1px solid #e7eee7; border-radius: 4px 15px 15px 15px; background: #fff; color: #263b38; font-size: 13px; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; box-shadow: 0 2px 10px rgba(18, 53, 43, .025); }
.message.user .message-text { border-color: #194944; border-radius: 15px 4px 15px 15px; background: #194944; color: #f7fcf2; }
.message.user .message-label { text-align: right; }
.message.thinking .message-text { color: #70827a; font-style: italic; }

.composer-area { flex: 0 0 auto; padding: 12px clamp(18px, 4vw, 58px) max(17px, env(safe-area-inset-bottom)); border-top: 1px solid #e9eee7; background: #fafbf8; }
.composer { display: flex; align-items: flex-end; gap: 10px; padding: 8px 8px 8px 15px; border: 1px solid #d9e3d7; border-radius: 15px; background: #fff; box-shadow: 0 3px 14px rgba(21, 57, 43, .04); }
.composer:focus-within { border-color: #9bbb88; box-shadow: 0 0 0 3px rgba(140, 191, 118, .14); }
.composer textarea { display: block; width: 100%; min-height: 34px; max-height: 140px; padding: 8px 0 5px; resize: none; border: 0; outline: 0; background: transparent; color: #1b3835; font-size: 13px; line-height: 1.5; }
.composer textarea::placeholder { color: #98a89d; }
.composer button { display: grid; place-items: center; flex: 0 0 36px; width: 36px; height: 36px; border: 0; border-radius: 10px; background: #173d3b; color: #fff; transition: background .2s, transform .2s; }
.composer button:hover:not(:disabled) { background: #296258; transform: translateY(-1px); }
.composer button:disabled { opacity: .45; cursor: not-allowed; }
.composer-note { margin: 9px 2px 0; color: #9aa69c; font-size: 10px; text-align: center; }
.error { margin: 0 0 9px; color: #a34539; font-size: 12px; }
.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 arrive { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 780px) {
  .shell { display: flex; flex-direction: column; gap: 0; height: 100dvh; min-height: 0; padding: 0; }
  .intro { flex: 0 0 auto; min-height: 0; padding: 15px 18px 16px; border-radius: 0; }
  .intro::before, .intro-description, .feature-list, .intro-footer { display: none; }
  .brand { font-size: 23px; }
  .intro-copy { margin-top: 12px; }
  .eyebrow { margin: 0 0 5px; font-size: 8px; }
  .intro h1 { max-width: none; margin: 0; font-size: 23px; line-height: 1.15; letter-spacing: -.045em; }
  .chat-card { flex: 1 1 auto; height: auto; min-height: 0; border: 0; border-radius: 18px 18px 0 0; margin-top: -1px; }
  .chat-header { padding: 12px 17px; }
  .avatar { width: 32px; height: 32px; border-radius: 9px; font-size: 18px; }
  .chapter-badge { font-size: 8px; }
  .messages { padding: 22px 16px; }
  .welcome { margin-top: min(8vh, 48px); }
  .welcome p { max-width: 310px; }
  .suggestions { margin-top: 20px; }
  .message-body { max-width: 88%; }
  .composer-area { padding: 10px 13px max(12px, env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
