:root {
  --navy-950: #08182a;
  --navy-900: #10243e;
  --navy-800: #183553;
  --navy-700: #234765;
  --blue-600: #1776b6;
  --blue-500: #2795d3;
  --blue-100: #dff2fc;
  --blue-50: #f1f9fd;
  --gold-500: #e7a92f;
  --ink: #172538;
  --muted: #617083;
  --line: #dbe3ea;
  --surface: #ffffff;
  --canvas: #f3f6f8;
  --danger: #a33c3c;
  --shadow: 0 18px 45px rgba(18, 38, 58, .12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; margin: 0; }

body {
  min-width: 320px;
  background:
    radial-gradient(circle at 85% -10%, rgba(39, 149, 211, .11), transparent 33rem),
    var(--canvas);
}

button, textarea { font: inherit; }
button { color: inherit; }
button:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 3px solid rgba(39, 149, 211, .45);
  outline-offset: 2px;
}

svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: fixed; z-index: 100;
  left: 1rem; top: -5rem;
  padding: .75rem 1rem;
  border-radius: .5rem;
  background: var(--surface);
  color: var(--navy-900);
}
.skip-link:focus { top: 1rem; }

.page-shell { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  height: 74px;
  padding: 0 clamp(1rem, 4vw, 3.25rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: #fff;
  background: linear-gradient(115deg, var(--navy-950), var(--navy-800));
  box-shadow: 0 1px 0 rgba(255,255,255,.08);
}

.brand { display: inline-flex; align-items: center; gap: .75rem; color: inherit; text-decoration: none; }
.brand-mark {
  width: 2.65rem; height: 2.65rem;
  display: grid; place-items: center;
  border: 1px solid rgba(255,255,255,.58);
  border-radius: 50%;
  font-family: Georgia, serif;
  font-size: 1.55rem;
  color: var(--navy-950);
  background: #fff;
  box-shadow: inset 0 0 0 3px var(--gold-500);
}
.brand-mark-small { width: 2.25rem; height: 2.25rem; font-size: 1.25rem; flex: 0 0 auto; }
.brand-copy { display: grid; line-height: 1.05; }
.brand-copy strong { font-size: 1.05rem; letter-spacing: .05em; }
.brand-copy span { margin-top: .25rem; color: rgba(255,255,255,.72); font-size: .78rem; }
.topbar-actions { display: flex; align-items: center; gap: 1rem; }
.service-state { display: inline-flex; gap: .5rem; align-items: center; color: rgba(255,255,255,.78); font-size: .83rem; }
.state-dot { display: inline-block; width: .48rem; height: .48rem; border-radius: 50%; background: #58ca8b; box-shadow: 0 0 0 3px rgba(88,202,139,.15); }

.button {
  min-height: 2.55rem;
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  border-radius: .7rem;
  padding: .55rem .9rem;
  font-weight: 650;
  cursor: pointer;
}
.button-secondary { border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.08); color: #fff; }
.button-secondary:hover { background: rgba(255,255,255,.15); }

.chat-layout {
  flex: 1;
  width: min(100%, 1030px);
  margin: 0 auto;
  padding: clamp(1rem, 2.5vw, 2rem);
  display: flex;
}

.chat-card {
  min-height: calc(100vh - 74px - clamp(2rem, 5vw, 4rem));
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(20, 55, 81, .1);
  border-radius: 1.15rem;
  background: rgba(255,255,255,.96);
  box-shadow: var(--shadow);
}

.welcome { margin: auto; width: min(100%, 690px); padding: 3rem 2rem 2.2rem; text-align: center; }
.welcome[hidden] { display: none; }
.assistant-avatar {
  width: 2.65rem; height: 2.65rem;
  display: grid; place-items: center;
  border-radius: .8rem;
  color: #fff;
  background: linear-gradient(145deg, var(--navy-800), var(--blue-600));
  box-shadow: 0 8px 18px rgba(23,118,182,.2);
}
.assistant-avatar-large { width: 3.75rem; height: 3.75rem; margin: 0 auto 1.3rem; border-radius: 1.05rem; }
.assistant-avatar-large svg { width: 1.75rem; height: 1.75rem; }
.eyebrow { margin: 0 0 .65rem; color: var(--blue-600); font-size: .78rem; font-weight: 760; letter-spacing: .09em; text-transform: uppercase; }
.welcome h1 { margin: 0; color: var(--navy-900); font-family: Georgia, "Times New Roman", serif; font-size: clamp(2rem, 4.5vw, 3.3rem); font-weight: 500; letter-spacing: -.025em; }
.welcome-copy { max-width: 590px; margin: 1rem auto 0; color: var(--muted); font-size: 1.05rem; line-height: 1.65; }

.suggestions { margin-top: 2.2rem; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; }
.suggestion, .widget-starter {
  min-height: 4.8rem;
  display: flex; align-items: center; justify-content: space-between; gap: .65rem;
  padding: .9rem 1rem;
  border: 1px solid var(--line);
  border-radius: .85rem;
  background: var(--surface);
  color: var(--navy-800);
  text-align: left;
  font-size: .9rem;
  font-weight: 650;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.suggestion:hover, .widget-starter:hover { transform: translateY(-1px); border-color: #a9cde2; box-shadow: 0 8px 18px rgba(31,68,94,.08); }
.suggestion svg { width: 1rem; color: var(--blue-600); flex: 0 0 auto; }

.conversation { flex: 1; overflow-y: auto; padding: 1.6rem clamp(1rem, 5vw, 4.5rem); scroll-behavior: smooth; }
.conversation:empty { display: none; }
.message { display: grid; grid-template-columns: 2.65rem minmax(0, 1fr); gap: .8rem; margin: 0 0 1.35rem; }
.message.user { grid-template-columns: minmax(0, 1fr); justify-items: end; }
.message.user .message-avatar { display: none; }
.message-avatar { width: 2.35rem; height: 2.35rem; display: grid; place-items: center; border-radius: .7rem; color: #fff; background: linear-gradient(145deg, var(--navy-800), var(--blue-600)); }
.message-avatar::before { content: "O"; font-family: Georgia, serif; font-size: 1.05rem; }
.message-content { min-width: 0; padding-top: .15rem; font-size: .98rem; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.message.user .message-content { max-width: min(80%, 650px); padding: .72rem 1rem; border-radius: 1rem 1rem .3rem 1rem; color: #fff; background: var(--navy-800); white-space: pre-wrap; }
.message.is-error .message-content { color: var(--danger); }
.message-status { display: flex; align-items: center; gap: .65rem; color: var(--muted); font-size: .92rem; }
.thinking-dots { display: inline-flex; align-items: center; gap: .22rem; min-width: 1.65rem; }
.thinking-dots i { width: .35rem; height: .35rem; border-radius: 50%; background: var(--blue-500); animation: think 1.15s infinite ease-in-out; }
.thinking-dots i:nth-child(2) { animation-delay: .14s; }
.thinking-dots i:nth-child(3) { animation-delay: .28s; }
@keyframes think { 0%, 65%, 100% { opacity: .28; transform: translateY(0); } 32% { opacity: 1; transform: translateY(-.2rem); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }

.sources { margin-top: 1rem; padding-top: .85rem; border-top: 1px solid var(--line); }
.sources strong { display: block; margin-bottom: .45rem; color: var(--muted); font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; }
.source-list { display: flex; flex-wrap: wrap; gap: .45rem; }
.source-link { display: inline-flex; align-items: center; gap: .35rem; padding: .35rem .55rem; border: 1px solid #c9dce8; border-radius: .5rem; color: #11689d; background: var(--blue-50); font-size: .82rem; font-weight: 650; text-decoration: none; }
.source-link:hover { text-decoration: underline; }

.composer-wrap { position: relative; padding: .75rem clamp(1rem, 5vw, 4.5rem) 1rem; border-top: 1px solid var(--line); background: rgba(255,255,255,.98); }
.privacy-note { display: flex; align-items: flex-start; justify-content: center; gap: .45rem; margin-bottom: .65rem; color: var(--muted); font-size: .78rem; line-height: 1.45; }
.privacy-note svg { width: .95rem; height: .95rem; margin-top: .08rem; flex: 0 0 auto; color: var(--blue-600); }
.composer { display: flex; align-items: flex-end; gap: .65rem; padding: .45rem .45rem .45rem 1rem; border: 1px solid #bfcdd8; border-radius: 1rem; background: var(--surface); box-shadow: 0 5px 20px rgba(18,52,76,.07); }
.composer:focus-within { border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(39,149,211,.12), 0 5px 20px rgba(18,52,76,.07); }
.composer textarea { flex: 1; min-height: 2.55rem; max-height: 9rem; resize: none; padding: .55rem 0 .4rem; border: 0; outline: 0; color: var(--ink); background: transparent; line-height: 1.45; }
.composer textarea::placeholder { color: #8793a0; }
.send-button { width: 2.75rem; height: 2.75rem; flex: 0 0 auto; display: grid; place-items: center; border: 0; border-radius: .75rem; color: #fff; background: var(--blue-600); cursor: pointer; transition: background .15s ease, transform .15s ease; }
.send-button:hover { background: #0d669f; }
.send-button:active { transform: scale(.96); }
.send-button:disabled { cursor: not-allowed; background: #87a2b4; }
.button-spinner { display: none; width: 1rem; height: 1rem; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
.send-button.is-busy .send-icon { display: none; }
.send-button.is-busy .button-spinner { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }
.fine-print { margin: .55rem 0 0; color: #7a8794; text-align: center; font-size: .72rem; }

body[data-mode="widget"] { height: 100vh; min-height: 420px; overflow: hidden; background: #fff; }
.widget-shell { height: 100vh; display: flex; flex-direction: column; overflow: hidden; background: var(--surface); }
.widget-header { min-height: 4.3rem; display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .75rem .85rem; color: #fff; background: linear-gradient(115deg, var(--navy-950), var(--navy-800)); }
.widget-identity { display: flex; align-items: center; gap: .65rem; }
.widget-identity > span:last-child { display: grid; line-height: 1.1; }
.widget-identity strong { font-size: .98rem; }
.widget-identity small { margin-top: .32rem; display: flex; align-items: center; gap: .4rem; color: rgba(255,255,255,.72); font-size: .69rem; }
.widget-actions { display: flex; gap: .25rem; }
.icon-button { width: 2.25rem; height: 2.25rem; display: grid; place-items: center; border: 0; border-radius: .55rem; color: #fff; background: transparent; cursor: pointer; }
.icon-button:hover { background: rgba(255,255,255,.12); }
.widget-chat { flex: 1; min-height: 0; display: flex; overflow: hidden; }
.widget-welcome { width: 100%; padding: 2rem 1.3rem; }
.widget-welcome .assistant-avatar { margin: 0 auto 1rem; }
.widget-welcome h1 { font-size: 1.5rem; }
.widget-welcome p { margin: .7rem 0 1.25rem; color: var(--muted); font-size: .9rem; }
.widget-starter { min-height: auto; margin: 0 auto; padding: .65rem .8rem; font-size: .82rem; }
.widget-conversation { width: 100%; padding: 1rem; }
.widget-conversation .message { grid-template-columns: 2.2rem minmax(0, 1fr); gap: .55rem; margin-bottom: 1rem; }
.widget-conversation .message-avatar { width: 2rem; height: 2rem; }
.widget-conversation .message-content { font-size: .9rem; line-height: 1.55; }
.widget-conversation .message.user { grid-template-columns: minmax(0,1fr); }
.widget-conversation .message.user .message-content { max-width: 88%; }
.widget-composer-wrap { padding: .65rem .75rem .6rem; border-top: 1px solid var(--line); background: #fff; }
.widget-composer { padding-left: .75rem; border-radius: .85rem; }
.widget-composer textarea { font-size: .9rem; }
.widget-composer .send-button { width: 2.5rem; height: 2.5rem; }
.widget-warning { margin: .4rem 0 0; color: #7a8794; text-align: center; font-size: .67rem; }

@media (max-width: 700px) {
  .topbar { height: 64px; padding: 0 .9rem; }
  .brand-copy span, .service-state { display: none; }
  .button-secondary { min-height: 2.35rem; padding: .45rem .7rem; font-size: .84rem; }
  .chat-layout { padding: 0; }
  .chat-card { min-height: calc(100vh - 64px); border: 0; border-radius: 0; box-shadow: none; }
  .welcome { padding: 2.2rem 1rem 1.5rem; }
  .suggestions { grid-template-columns: 1fr; margin-top: 1.5rem; }
  .suggestion { min-height: 3.6rem; }
  .conversation { padding: 1.15rem 1rem; }
  .composer-wrap { padding: .65rem .75rem .75rem; }
  .privacy-note { text-align: left; }
}

@media (max-height: 700px) and (min-width: 701px) {
  .welcome { padding-top: 1.5rem; }
  .assistant-avatar-large { width: 3rem; height: 3rem; margin-bottom: .8rem; }
  .welcome h1 { font-size: 2.2rem; }
  .suggestions { margin-top: 1.25rem; }
}
