:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #08080c;
  --bg-grad: radial-gradient(120% 90% at 15% 0%, rgba(57, 135, 229, .22), transparent 60%),
             radial-gradient(120% 90% at 100% 10%, rgba(144, 133, 233, .2), transparent 55%),
             radial-gradient(140% 120% at 50% 100%, rgba(232, 123, 164, .16), transparent 55%);
  --surface: rgba(255, 255, 255, .045);
  --surface-2: rgba(255, 255, 255, .075);
  --surface-3: rgba(255, 255, 255, .105);
  --border: rgba(255, 255, 255, .1);
  --border-strong: rgba(255, 255, 255, .18);
  --ink-1: #fff;
  --ink-2: rgba(255, 255, 255, .72);
  --ink-3: rgba(255, 255, 255, .46);
  --gradient: linear-gradient(120deg, #5aa0f0 0%, #9085e9 48%, #e87ba4 100%);
  --accent: #7b91ef;
  --success: #34d058;
  --warning: #fab219;
  --danger: #ff718a;
  --shadow: 0 34px 80px -34px rgba(0, 0, 0, .82);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f6fb;
  --bg-grad: radial-gradient(120% 90% at 15% 0%, rgba(57, 135, 229, .16), transparent 60%),
             radial-gradient(120% 90% at 100% 10%, rgba(144, 133, 233, .14), transparent 55%),
             radial-gradient(140% 120% at 50% 100%, rgba(232, 123, 164, .12), transparent 55%);
  --surface: rgba(255, 255, 255, .72);
  --surface-2: rgba(255, 255, 255, .92);
  --surface-3: rgba(241, 243, 251, .96);
  --border: rgba(10, 12, 30, .1);
  --border-strong: rgba(10, 12, 30, .16);
  --ink-1: #14151c;
  --ink-2: #4a4c59;
  --ink-3: #8a8d9c;
  --gradient: linear-gradient(120deg, #2a78d6 0%, #6c5fd6 48%, #d55181 100%);
  --accent: #665fd9;
  --success: #0ca30c;
  --warning: #d98a00;
  --danger: #d94261;
  --shadow: 0 34px 80px -34px rgba(47, 52, 88, .28);
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background: transparent;
  color: var(--ink-1);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  letter-spacing: -.011em;
  -webkit-font-smoothing: antialiased;
}

button,
textarea { font: inherit; }

button { color: inherit; }

.mesh {
  position: fixed;
  z-index: -1;
  inset: 0;
  background: var(--bg-grad);
  background-size: 200% 200%;
  animation: mesh 22s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes mesh {
  from { background-position: 0 0, 100% 0, 50% 100%; }
  to { background-position: 40% 30%, 60% 70%, 50% 60%; }
}

.shell { width: min(1440px, calc(100% - 40px)); margin-inline: auto; }

.glass {
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.topbar-wrap { padding-top: 14px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  padding: 8px 12px 8px 18px;
  border-radius: 18px;
}

.brand { display: flex; align-items: center; gap: 10px; color: inherit; font-weight: 750; text-decoration: none; }

.brand-mark,
.assistant-avatar,
.message-avatar {
  display: grid;
  place-items: center;
  background: var(--gradient);
  color: white;
  font-weight: 800;
  box-shadow: 0 8px 22px -8px rgba(108, 95, 214, .7);
}

.brand-mark { width: 28px; height: 28px; border-radius: 8px; font-size: 14px; }

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.save-state { display: inline-flex; align-items: center; gap: 8px; margin-right: 4px; color: var(--ink-3); font-size: 12px; }
.save-state i { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 9px var(--success); }
.save-state.saving i { background: var(--warning); box-shadow: 0 0 9px var(--warning); }

.icon-button,
.panel-close {
  display: grid;
  place-items: center;
  width: 39px;
  height: 39px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
}

.icon-button:hover,
.panel-close:hover { border-color: var(--border-strong); color: var(--ink-1); }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 18px;
  border-radius: 12px;
  border: 0;
  font-weight: 650;
  cursor: pointer;
  transition: transform .16s ease, filter .16s ease, border-color .16s ease;
}

.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .42; }
.button-primary { background: var(--gradient); color: #fff; box-shadow: 0 10px 28px -10px rgba(108, 95, 214, .7); }
.button-primary:hover:not(:disabled) { filter: brightness(1.08); }
.button-secondary { border: 1px solid var(--border); background: var(--surface); color: var(--ink-2); }
.button-secondary:hover { border-color: var(--border-strong); color: var(--ink-1); }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 382px;
  gap: 18px;
  height: calc(100vh - 90px);
  min-height: 650px;
  padding: 18px 0 20px;
}

.conversation,
.brief-panel { min-height: 0; border-radius: 24px; }

.conversation { display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; overflow: hidden; }

.conversation-header {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}

.assistant-avatar { width: 43px; height: 43px; border-radius: 13px; font-size: 18px; }
.assistant-line { display: flex; align-items: center; gap: 9px; }
.assistant-line h1 { margin: 0; font-size: 16px; letter-spacing: -.02em; }
.conversation-header p { margin: 2px 0 0; color: var(--ink-3); font-size: 12px; }
.online-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 9px var(--success); }
.mobile-progress { display: none; margin-left: auto; border: 0; background: transparent; color: var(--ink-1); text-align: right; cursor: pointer; }
.mobile-progress span { display: block; font-size: 16px; font-weight: 700; }
.mobile-progress small { color: var(--ink-3); }

.messages {
  overflow-y: auto;
  padding: 30px clamp(18px, 4vw, 52px);
  scrollbar-color: var(--border-strong) transparent;
}

.message-row { display: flex; align-items: flex-start; gap: 11px; max-width: 760px; margin-bottom: 23px; animation: messageIn .3s ease both; }
.message-row.user { flex-direction: row-reverse; margin-left: auto; }
.message-avatar { flex: none; width: 30px; height: 30px; margin-top: 20px; border-radius: 9px; font-size: 12px; }
.message-row.user .message-avatar { display: none; }
.message-content { display: flex; flex-direction: column; align-items: flex-start; max-width: min(680px, calc(100vw - 120px)); }
.message-row.user .message-content { align-items: flex-end; }
.message-author { margin: 0 0 6px 3px; color: var(--ink-3); font-size: 11px; }
.message-bubble { padding: 13px 16px; border: 1px solid var(--border); border-radius: 17px 17px 17px 5px; background: var(--surface-2); white-space: pre-wrap; }
.message-row.user .message-bubble { border: 0; border-radius: 17px 17px 5px 17px; background: var(--gradient); color: #fff; }
.message-bubble strong { display: block; margin-bottom: 6px; }
.message-paragraph { display: block; }
.message-paragraph + .message-paragraph { margin-top: 10px; }
.message-guidance { color: var(--ink-2); font-size: 13px; line-height: 1.5; }
.message-time { margin-top: 5px; color: var(--ink-3); font-size: 10px; }

@keyframes messageIn { from { opacity: 0; transform: translateY(9px); } }

.typing-dots { display: flex; gap: 5px; padding: 5px 0; }
.typing-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); animation: typing 1s ease-in-out infinite; }
.typing-dots i:nth-child(2) { animation-delay: .13s; }
.typing-dots i:nth-child(3) { animation-delay: .26s; }
@keyframes typing { 50% { opacity: .3; transform: translateY(-3px); } }
.message-row.typing .message-avatar { animation: thinkingPulse 1.35s ease-in-out infinite; }
.message-row.typing .message-bubble { min-width: 64px; }
.message-row.typing .message-time { animation: thinkingText 1.35s ease-in-out infinite; }
@keyframes thinkingPulse {
  50% { transform: scale(.9); filter: brightness(1.25); box-shadow: 0 0 24px rgba(123, 145, 239, .72); }
}
@keyframes thinkingText { 50% { opacity: .45; } }

.quick-answers { padding: 0 18px 10px; }
.quick-answers[hidden] { display: none; }
.quick-answers-label { display: block; margin: 0 2px 8px; color: var(--ink-3); font-size: 11px; }
.quick-answer-list { display: flex; flex-wrap: wrap; gap: 8px; }
.quick-answer {
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-2);
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease, color .16s ease, transform .16s ease;
}
.quick-answer:hover:not(:disabled) { transform: translateY(-1px); border-color: var(--accent); color: var(--ink-1); }
.quick-answer.selected { border-color: var(--accent); background: rgba(123, 145, 239, .18); color: var(--ink-1); }
.quick-answer.other { border-style: dashed; }
.quick-answer:disabled { cursor: not-allowed; opacity: .46; }
.quick-answer-confirm {
  min-height: 38px;
  margin-top: 10px;
  padding: 7px 16px;
  border: 0;
  border-radius: 11px;
  background: var(--gradient);
  color: #fff;
  font-weight: 650;
  cursor: pointer;
}
.quick-answer-confirm:disabled { cursor: not-allowed; opacity: .42; }

.composer { margin: 0 18px 18px; padding: 10px 10px 7px 16px; border: 1px solid var(--border-strong); border-radius: 18px; background: var(--surface-2); }
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(90, 160, 240, .14); }
.composer textarea { width: calc(100% - 54px); max-height: 140px; resize: none; overflow-y: auto; border: 0; outline: 0; background: transparent; color: var(--ink-1); line-height: 1.45; vertical-align: middle; }
.composer textarea::placeholder { color: var(--ink-3); }
.send-button { float: right; display: grid; place-items: center; width: 42px; height: 42px; padding: 0; border: 0; border-radius: 12px; background: var(--gradient); cursor: pointer; }
.send-button svg { width: 21px; fill: none; stroke: #fff; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.composer-meta { clear: both; display: flex; justify-content: space-between; gap: 10px; padding-top: 7px; color: var(--ink-3); font-size: 10px; }
.composer-meta button { padding: 0; border: 0; background: transparent; color: var(--ink-3); cursor: pointer; }
.composer-meta button:hover { color: var(--ink-1); }

.brief-panel { display: flex; flex-direction: column; padding: 24px; overflow-y: auto; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; }
.panel-heading h2 { margin: 13px 0 0; font-size: 24px; line-height: 1.08; letter-spacing: -.035em; }
.panel-close { display: none; font-size: 22px; }
.eyebrow { display: inline-flex; align-items: center; gap: 7px; color: var(--ink-3); font-size: 11px; font-weight: 650; letter-spacing: .025em; text-transform: uppercase; }
.eyebrow i { width: 6px; height: 6px; border-radius: 50%; background: var(--success); box-shadow: 0 0 8px var(--success); }

.progress-card { margin-top: 24px; padding: 16px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface-2); }
.progress-copy { display: flex; align-items: baseline; justify-content: space-between; }
.progress-copy strong { font-size: 25px; letter-spacing: -.035em; }
.progress-copy span { color: var(--ink-3); font-size: 11px; }
.progress-track { height: 7px; margin-top: 12px; overflow: hidden; border-radius: 999px; background: var(--surface-3); }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--gradient); transition: width .35s ease; }
.progress-card p { margin: 11px 0 0; color: var(--ink-2); font-size: 11px; }

.sections { flex: 1; margin-top: 20px; }
.section-item { border-bottom: 1px solid var(--border); }
.section-button { display: flex; align-items: center; width: 100%; gap: 10px; padding: 14px 2px; border: 0; background: transparent; text-align: left; cursor: pointer; }
.section-status { flex: none; display: grid; place-items: center; width: 22px; height: 22px; border: 1px solid var(--border-strong); border-radius: 7px; color: var(--ink-3); font-size: 10px; }
.section-item.active .section-status { border-color: transparent; background: var(--gradient); color: #fff; }
.section-item.complete .section-status { border-color: rgba(52, 208, 88, .28); background: rgba(52, 208, 88, .12); color: var(--success); }
.section-name { flex: 1; font-size: 13px; font-weight: 600; }
.section-count { color: var(--ink-3); font-size: 10px; }
.section-chevron { color: var(--ink-3); transition: transform .2s ease; }
.section-item.open .section-chevron { transform: rotate(90deg); }
.section-fields { display: none; padding: 0 2px 13px 32px; }
.section-item.open .section-fields { display: grid; gap: 9px; }
.field-row { display: grid; grid-template-columns: 1fr auto; gap: 7px; align-items: center; color: var(--ink-3); font-size: 11px; }
.field-row.answered { color: var(--ink-2); }
.field-row button { overflow: hidden; padding: 0; border: 0; background: transparent; color: inherit; text-align: left; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.field-row button:hover { color: var(--ink-1); }
.field-state { width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); }
.field-row.answered .field-state { background: var(--success); box-shadow: 0 0 7px rgba(52, 208, 88, .5); }

.panel-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 22px; }
.panel-actions .button { padding-inline: 10px; font-size: 12px; }
.privacy-note { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 14px 0 0; color: var(--ink-3); font-size: 10px; }
.privacy-note svg { width: 13px; fill: none; stroke: currentColor; stroke-width: 1.7; }

.summary-modal { width: min(760px, calc(100% - 32px)); max-height: calc(100vh - 32px); padding: 0; border: 0; background: transparent; color: var(--ink-1); }
.summary-modal::backdrop { background: rgba(2, 3, 9, .72); backdrop-filter: blur(7px); }
.summary-card { display: flex; flex-direction: column; max-height: calc(100vh - 40px); padding: 26px; border-radius: 24px; }
.summary-card header { display: flex; justify-content: space-between; gap: 15px; }
.summary-card h2 { margin: 10px 0 0; font-size: 28px; }
.summary-content { overflow-y: auto; margin: 22px 0; }
.summary-group { padding: 17px 0; border-top: 1px solid var(--border); }
.summary-group h3 { margin: 0 0 12px; font-size: 15px; }
.summary-field { display: grid; grid-template-columns: 180px 1fr; gap: 16px; margin-top: 9px; font-size: 12px; }
.summary-field dt { color: var(--ink-3); }
.summary-field dd { margin: 0; white-space: pre-wrap; }
.summary-card footer { display: flex; justify-content: flex-end; gap: 9px; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .brief-panel { position: fixed; z-index: 10; inset: 84px 20px 20px; display: none; }
  .brief-panel.open { display: flex; }
  .panel-close, .mobile-progress { display: grid; }
  .mobile-progress { display: block; }
}

@media (max-width: 620px) {
  .shell { width: min(100% - 22px, 1440px); }
  .new-session { display: none; }
  .save-state { display: none; }
  .workspace { height: calc(100svh - 78px); min-height: 560px; padding-top: 10px; }
  .conversation { border-radius: 20px; }
  .messages { padding: 22px 15px; }
  .message-content { max-width: calc(100vw - 90px); }
  .composer { margin: 0 10px 10px; }
  .quick-answers { padding-inline: 10px; }
  .composer-meta > span { display: none; }
  .composer-meta { justify-content: flex-end; }
  .brief-panel { inset: 75px 11px 11px; padding: 20px; }
  .summary-field { grid-template-columns: 1fr; gap: 2px; }
}

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