:root {
  --ink: #18352c;
  --ink-soft: #5b6e66;
  --forest: #1e5744;
  --forest-dark: #123c2f;
  --sage: #dce7dd;
  --paper: #f7f3e9;
  --white: #fffdf8;
  --gold: #b88735;
  --line: rgba(29, 76, 61, .16);
  --shadow: 0 18px 52px rgba(28, 58, 48, .10);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background: radial-gradient(circle at 90% 0%, rgba(172, 194, 174, .3), transparent 32rem), linear-gradient(180deg, #faf7ef, #f4efe3);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, textarea { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.chat-app { min-height: 100%; display: grid; grid-template-rows: auto 1fr auto; }
.chat-header {
  position: sticky; top: 0; z-index: 10;
  min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px max(20px, calc((100vw - 960px) / 2));
  border-bottom: 1px solid var(--line); background: rgba(250, 247, 239, .9); backdrop-filter: blur(16px);
}
.brand { min-width: 0; display: flex; align-items: center; gap: 10px; color: var(--forest-dark); text-decoration: none; }
.brand-mark { flex: 0 0 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: var(--paper); background: var(--forest); }
.brand > span:last-child { min-width: 0; display: grid; gap: 1px; }
.brand strong { overflow: hidden; font: 600 18px Georgia, serif; text-overflow: ellipsis; white-space: nowrap; }
.brand small { color: var(--ink-soft); font-size: 10px; }
.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.library-pill { max-width: 260px; overflow: hidden; padding: 7px 10px; border-radius: 999px; background: var(--sage); color: var(--forest); font-size: 10px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.new-chat { min-height: 34px; padding: 0 11px; border: 1px solid rgba(30, 87, 68, .2); border-radius: 9px; background: var(--white); color: var(--forest); font-size: 10px; font-weight: 800; cursor: pointer; }
.new-chat:hover, .new-chat:focus-visible { border-color: var(--forest); outline: 0; }

.conversation { width: 100%; max-width: 860px; margin: 0 auto; padding: 56px 24px 200px; }
.welcome { max-width: 680px; margin: 7vh auto 0; text-align: center; }
.welcome-mark { width: 46px; height: 46px; display: grid; place-items: center; margin: 0 auto 18px; border: 1px solid rgba(30, 87, 68, .18); border-radius: 50%; color: var(--gold); background: var(--white); box-shadow: var(--shadow); font-size: 20px; }
.eyebrow { margin: 0 0 11px; color: var(--gold); font-size: 10px; font-weight: 900; letter-spacing: .18em; }
.welcome h1, .blocked-state h1 { margin: 0 0 16px; color: var(--forest-dark); font: 500 clamp(34px, 7vw, 54px)/1.05 Georgia, "Times New Roman", serif; letter-spacing: -.03em; }
.welcome > p:not(.eyebrow) { max-width: 590px; margin: 0 auto; color: var(--ink-soft); font: 15px/1.7 Georgia, serif; }
.suggested-questions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 30px; }
.suggested-questions button { min-height: 92px; padding: 15px; border: 1px solid var(--line); border-radius: 15px; background: rgba(255, 253, 248, .8); color: var(--ink); font-size: 12px; line-height: 1.45; text-align: left; cursor: pointer; box-shadow: 0 8px 24px rgba(28, 58, 48, .04); }
.suggested-questions button:hover, .suggested-questions button:focus-visible { border-color: var(--gold); background: var(--white); outline: 0; transform: translateY(-1px); }

.message { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 13px; margin: 0 0 28px; animation: appear .2s ease-out; }
.message.user { grid-template-columns: minmax(0, 1fr); }
.message-avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--forest); font-size: 13px; }
.message.user .message-body { justify-self: end; max-width: min(650px, 88%); padding: 12px 16px; border-radius: 18px 18px 5px 18px; background: var(--sage); }
.message-body { min-width: 0; }
.message-body > p { margin: 4px 0 13px; font-size: 14px; line-height: 1.65; white-space: pre-wrap; }
.message-body > p:last-child { margin-bottom: 0; }
.answer-intro strong { color: var(--forest-dark); }
.source-card { margin: 10px 0; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: var(--white); box-shadow: 0 8px 24px rgba(28, 58, 48, .05); }
.source-card header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 13px; border-bottom: 1px solid var(--line); background: #f0f4eb; }
.source-card h2 { min-width: 0; margin: 0; overflow: hidden; color: var(--forest-dark); font: 600 16px Georgia, serif; text-overflow: ellipsis; white-space: nowrap; }
.source-card header span, .page-link { flex: 0 0 auto; color: var(--gold); font-size: 9px; font-weight: 900; letter-spacing: .06em; }
.page-link { padding:7px 9px; border:1px solid rgba(184,135,53,.3); border-radius:8px; background:#fffaf0; cursor:pointer; }
.page-link:hover, .page-link:focus-visible { color:#76551f; border-color:var(--gold); outline:0; }
.source-card blockquote { margin: 0; padding: 13px; color: #354940; font: 13px/1.62 Georgia, serif; }
.inline-page-link { display:inline; padding:1px 4px; border:0; border-bottom:1px solid var(--gold); border-radius:4px; color:#805f25; background:#fff5d9; font:inherit; font-weight:700; cursor:pointer; }
.inline-page-link:hover, .inline-page-link:focus-visible { color:#fff; background:var(--gold); outline:0; }
.source-card footer { padding: 9px 13px; border-top: 1px solid var(--line); color: var(--ink-soft); font-size: 9px; overflow-wrap: anywhere; }
.empty-answer { padding: 15px; border: 1px solid #dacaa8; border-radius: 13px; background: #fff9e9; color: #705b2e; font-size: 13px; line-height: 1.6; }
.typing { display: inline-flex; align-items: center; gap: 4px; min-height: 34px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--forest); animation: pulse 1s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .14s; }
.typing i:nth-child(3) { animation-delay: .28s; }

.composer-wrap {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 9;
  padding: 14px 20px max(13px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(247, 243, 233, 0), rgba(247, 243, 233, .94) 24%, #f7f3e9 55%);
}
.composer { width: min(780px, 100%); min-height: 58px; display: flex; align-items: flex-end; gap: 10px; margin: 0 auto; padding: 9px 9px 9px 17px; border: 1px solid rgba(30, 87, 68, .23); border-radius: 22px; background: var(--white); box-shadow: 0 14px 44px rgba(28, 58, 48, .14); }
.composer:focus-within { border-color: var(--forest); box-shadow: 0 14px 44px rgba(28, 58, 48, .14), 0 0 0 3px rgba(30, 87, 68, .08); }
.composer textarea { flex: 1; max-height: 150px; min-height: 38px; padding: 9px 0 7px; resize: none; overflow-y: auto; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 15px; line-height: 1.45; }
.composer textarea::placeholder { color: #85948e; }
.composer button { flex: 0 0 40px; height: 40px; border: 0; border-radius: 50%; background: var(--forest); color: white; font-size: 21px; font-weight: 800; cursor: pointer; }
.composer button:hover, .composer button:focus-visible { background: var(--forest-dark); outline: 3px solid rgba(30, 87, 68, .14); }
.composer button:disabled { cursor: default; opacity: .45; }
.composer-wrap > p { width: min(780px, 100%); margin: 8px auto 0; color: var(--ink-soft); font-size: 9px; line-height: 1.35; text-align: center; }

.blocked-state { width: min(620px, calc(100% - 40px)); min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; margin: 0 auto; text-align: center; }
.blocked-state > span { width: 48px; height: 48px; display: grid; place-items: center; margin-bottom: 20px; border-radius: 50%; background: var(--forest); color: white; font-size: 20px; }
.blocked-state > p:not(.eyebrow) { max-width: 500px; margin: 0 0 24px; color: var(--ink-soft); font: 15px/1.65 Georgia, serif; }
.blocked-state a { padding: 12px 18px; border-radius: 11px; background: var(--forest); color: white; font-size: 12px; font-weight: 800; text-decoration: none; }

@keyframes pulse { 0%, 70%, 100% { opacity: .25; transform: translateY(0); } 35% { opacity: 1; transform: translateY(-2px); } }
@keyframes appear { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@media (max-width: 700px) {
  .chat-header { min-height: 62px; padding: 9px 12px; }
  .brand strong { font-size: 15px; }
  .brand small, .library-pill { display: none; }
  .new-chat { min-height: 32px; padding: 0 9px; }
  .conversation { padding: 34px 14px 180px; }
  .welcome { margin-top: 3vh; }
  .welcome > p:not(.eyebrow) { font-size: 14px; }
  .suggested-questions { grid-template-columns: 1fr; margin-top: 24px; }
  .suggested-questions button { min-height: 0; }
  .message { grid-template-columns: 29px minmax(0, 1fr); gap: 9px; margin-bottom: 23px; }
  .message-avatar { width: 29px; height: 29px; }
  .message.user .message-body { max-width: 92%; }
  .source-card header { align-items: flex-start; }
  .source-card h2 { white-space: normal; }
  .composer-wrap { padding-left: 10px; padding-right: 10px; }
  .composer { min-height: 54px; border-radius: 19px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; }
}
