:root {
  color-scheme: light;
  --ink: #13293e;
  --muted: #5f7180;
  --line: #dce7ee;
  --paper: #ffffff;
  --soft: #f2f7fb;
  --brand: #2f7abb;
  --brand-dark: #0063ba;
  --brand-light: #83cef2;
  --brand-wash: #eaf7fd;
  --accent: #faa61a;
  --accent-dark: #d98700;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 12% 4%, rgba(131, 206, 242, .32), transparent 28rem),
    linear-gradient(150deg, #ffffff 0%, #eaeef2 100%);
  color: var(--ink);
}

button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.shell {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 20px;
}

.chat-card {
  width: min(100%, 520px);
  height: min(680px, calc(100vh - 40px));
  min-height: 520px;
  display: grid;
  grid-template-rows: auto 1fr auto auto auto;
  overflow: hidden;
  background: rgba(255, 255, 255, .96);
  border: 1px solid rgba(47, 122, 187, .14);
  border-radius: 24px;
  box-shadow: 0 24px 70px rgba(19, 41, 62, .16), 0 2px 8px rgba(19, 41, 62, .06);
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 17px 18px 15px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-light) 100%);
  box-shadow: inset 0 -3px 0 var(--accent), 0 7px 18px rgba(47, 122, 187, .24);
  color: white;
  font-family: Georgia, serif;
  font-size: 24px;
  font-weight: 700;
}

.brand-copy { min-width: 0; flex: 1; }
.brand-copy h1 { margin: 2px 0 0; font-size: 17px; line-height: 1.15; letter-spacing: -.015em; }
.eyebrow { margin: 0; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.status-dot { display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px rgba(250,166,26,.17); }

.icon-button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.icon-button:hover { background: var(--soft); color: var(--ink); }
.icon-button svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.conversation {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 22px 18px 10px;
  scroll-behavior: smooth;
}

.message { display: flex; gap: 9px; margin: 0 0 17px; animation: arrive .22s ease-out; }
.message.user { justify-content: flex-end; }
.avatar { flex: 0 0 28px; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 9px; background: var(--brand-wash); color: var(--brand); font: 700 13px Georgia, serif; }
.message-body { min-width: 0; max-width: 82%; }
.bubble { padding: 11px 13px; border-radius: 6px 16px 16px 16px; background: var(--soft); font-size: 14px; line-height: 1.48; white-space: pre-wrap; }
.user .bubble { border-radius: 16px 16px 6px 16px; background: var(--brand-dark); color: white; }
.message-meta { margin-top: 6px; color: #818a93; font-size: 10px; }

.sources { margin-top: 8px; }
.sources summary { width: max-content; cursor: pointer; color: var(--brand-dark); font-size: 11px; font-weight: 700; }
.source-card { margin-top: 7px; padding: 9px 10px; border: 1px solid #c7e4f2; border-radius: 10px; background: var(--brand-wash); font-size: 11px; line-height: 1.35; color: #3f6075; }
.source-card strong { display: block; margin-bottom: 2px; color: var(--ink); }

.actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.action-link, .handoff-link { display: inline-flex; align-items: center; min-height: 34px; padding: 7px 10px; border: 1px solid #a9d4e9; border-radius: 10px; background: white; color: var(--brand-dark); font-size: 11px; font-weight: 700; text-decoration: none; cursor: pointer; }
.handoff-link { border-color: var(--brand); background: var(--brand); color: white; }

.typing .bubble { display: flex; gap: 4px; padding: 15px; }
.typing i { width: 5px; height: 5px; border-radius: 50%; background: #89919a; animation: blink 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }

.starter-wrap { display: flex; gap: 7px; overflow-x: auto; padding: 5px 18px 10px; scrollbar-width: none; }
.starter-wrap:empty { display: none; }
.starter-wrap::-webkit-scrollbar { display: none; }
.starter { flex: 0 0 auto; padding: 8px 11px; border: 1px solid var(--line); border-radius: 999px; background: white; color: #4c5660; font-size: 11px; font-weight: 650; cursor: pointer; }
.starter:hover { border-color: var(--accent); color: var(--brand-dark); background: var(--brand-wash); }

.composer { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 8px; margin: 0 14px; padding: 8px 8px 8px 14px; border: 1px solid #ccdce5; border-radius: 17px; background: white; box-shadow: 0 4px 16px rgba(19,41,62,.06); }
.composer:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47,122,187,.12); }
.composer textarea { width: 100%; max-height: 104px; resize: none; overflow-y: auto; border: 0; outline: 0; padding: 7px 0; background: transparent; color: var(--ink); font-size: 14px; line-height: 1.35; }
.composer textarea::placeholder { color: #9ba2a8; }
.send-button { width: 39px; height: 39px; display: grid; place-items: center; border: 0; border-radius: 12px; background: var(--accent); color: var(--ink); cursor: pointer; }
.send-button:hover { background: var(--accent-dark); }
.send-button:disabled { opacity: .48; cursor: wait; }
.send-button svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.disclaimer { margin: 7px 18px 11px; color: #8a9299; font-size: 9px; line-height: 1.35; text-align: center; }

dialog { width: min(92vw, 430px); padding: 0; border: 0; border-radius: 22px; box-shadow: 0 24px 80px rgba(17,25,32,.3); }
dialog::backdrop { background: rgba(18, 24, 29, .55); backdrop-filter: blur(3px); }
.handoff-card { padding: 24px; }
.dialog-top { display: flex; align-items: flex-start; gap: 12px; }
.dialog-top > div { flex: 1; }
.dialog-top h2 { margin: 5px 0 0; font-family: Georgia, serif; font-size: 25px; font-weight: 500; letter-spacing: -.02em; }
.dialog-top .icon-button { font-size: 24px; }
.dialog-intro { margin: 12px 0 18px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.handoff-card label { display: grid; gap: 6px; margin: 0 0 13px; color: #4f5962; font-size: 11px; font-weight: 700; }
.handoff-card input, .handoff-card textarea { width: 100%; padding: 11px 12px; border: 1px solid #ccdce5; border-radius: 11px; outline: 0; color: var(--ink); font-size: 14px; }
.handoff-card input:focus, .handoff-card textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47,122,187,.12); }
.primary-button { width: 100%; padding: 12px; border: 0; border-radius: 12px; background: var(--brand); color: white; font-weight: 750; cursor: pointer; }
.form-status { min-height: 18px; margin: 0 0 8px; color: var(--muted); font-size: 12px; }
.form-status.error { color: #a42e22; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

@keyframes arrive { from { opacity: 0; transform: translateY(5px); } }
@keyframes blink { 0%, 65%, 100% { opacity: .3; } 30% { opacity: 1; } }

@media (max-width: 560px) {
  .shell { padding: 0; }
  .chat-card { width: 100%; height: 100dvh; min-height: 440px; border: 0; border-radius: 0; box-shadow: none; }
  .message-body { max-width: 88%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; }
}
