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

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(99, 102, 241, 0.14), transparent 34rem),
    #eef2f7;
}

button,
textarea {
  font: inherit;
}

button {
  touch-action: manipulation;
}

.chat-shell {
  display: grid;
  grid-template-rows: auto minmax(320px, 1fr) auto;
  width: min(100%, 820px);
  min-height: calc(100vh - 48px);
  margin: 0 auto;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 22px;
  box-shadow: 0 24px 70px rgba(51, 65, 85, 0.16);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 28px;
  border-bottom: 1px solid #e2e8f0;
}

.eyebrow {
  margin: 0 0 4px;
  color: #6366f1;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.45rem, 4vw, 2rem);
  letter-spacing: -0.03em;
}

.assistant-description {
  max-width: 34rem;
  margin: 5px 0 0;
  color: #64748b;
  font-size: 0.9rem;
}

.mode-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 6px;
  color: #365314;
  background: #d9f99d;
  border-radius: 999px;
  letter-spacing: 0.04em;
}

.mode-badge[hidden] {
  display: none;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  padding: 28px;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.empty-state {
  margin: auto;
  color: #64748b;
  text-align: center;
}

.empty-state p {
  margin: 0 0 16px;
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.suggestion,
.feedback-button {
  padding: 7px 10px;
  color: #4338ca;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-radius: 999px;
  cursor: pointer;
}

.message {
  display: flex;
  flex-direction: column;
  max-width: min(78%, 620px);
}

.message-user {
  align-self: flex-end;
  align-items: flex-end;
}

.message-assistant {
  align-self: flex-start;
  align-items: flex-start;
}

.message-label {
  margin: 0 10px 6px;
  color: #64748b;
  font-size: 0.75rem;
  font-weight: 700;
}

.message-content {
  margin: 0;
  padding: 13px 16px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border-radius: 18px;
}

.message-user .message-content {
  color: #fff;
  background: #4f46e5;
  border-bottom-right-radius: 5px;
}

.message-assistant .message-content {
  color: #1e293b;
  background: #f1f5f9;
  border-bottom-left-radius: 5px;
}

.message-sources,
.feedback-controls {
  margin: 7px 8px 0;
  color: #64748b;
  font-size: 0.75rem;
}

.feedback-controls {
  display: flex;
  gap: 6px;
}

.feedback-button {
  padding: 4px 8px;
  font-size: 0.72rem;
}

.composer {
  padding: 20px 28px 24px;
  background: #fff;
  border-top: 1px solid #e2e8f0;
}

textarea {
  display: block;
  width: 100%;
  min-height: 72px;
  max-height: 180px;
  padding: 14px 16px;
  resize: vertical;
  color: #172033;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

textarea:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 40px;
  margin-top: 12px;
}

.status {
  margin: 0;
  color: #64748b;
  font-size: 0.875rem;
}

.status-error {
  color: #b91c1c;
}

.button {
  min-height: 40px;
  padding: 9px 16px;
  font-weight: 750;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease, background 120ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:focus-visible {
  outline: 3px solid rgba(99, 102, 241, 0.3);
  outline-offset: 2px;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.button-primary {
  color: #fff;
  background: #4f46e5;
}

.button-primary:hover:not(:disabled) {
  background: #4338ca;
}

.button-secondary {
  color: #334155;
  background: #e2e8f0;
}

.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;
}

.document-sources {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.document-source a {
  color: #4338ca;
  font-weight: 650;
  text-decoration: none;
}

.document-source a:hover {
  text-decoration: underline;
}

.document-source-meta {
  color: #64748b;
}

.document-source-excerpt {
  margin: 2px 0 0;
  padding: 6px 8px;
  color: #475569;
  font-size: 0.78rem;
  background: #f8fafc;
  border-radius: 6px;
}

.professional-warning {
  margin: 7px 8px 0;
  padding: 6px 8px;
  color: #92400e;
  font-size: 0.78rem;
  background: #fef3c7;
  border-radius: 6px;
}

.missing-info {
  margin: 7px 8px 0;
  color: #64748b;
  font-size: 0.78rem;
}

.suggestion-workflow {
  color: #15803d;
  background: #dcfce7;
  border-color: #86efac;
  font-weight: 700;
}

.workflow-controls {
  margin-top: 10px;
}

.workflow-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.workflow-input-row {
  display: flex;
  gap: 8px;
}

.workflow-input-row input {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  outline: none;
}

.workflow-input-row input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.workflow-result {
  max-width: min(94%, 640px);
}

.match-group {
  margin-top: 14px;
}

.match-group h3 {
  margin: 0 0 8px;
  font-size: 0.85rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.match-card {
  margin-bottom: 10px;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
}

.match-card h4 {
  margin: 0 0 4px;
  font-size: 0.95rem;
}

.match-meta {
  margin: 0 0 6px;
  color: #64748b;
  font-size: 0.78rem;
}

.match-description {
  margin: 0 0 8px;
  font-size: 0.85rem;
  line-height: 1.45;
}

.match-reason {
  margin: 6px 0 0;
  color: #b45309;
  font-size: 0.78rem;
}

.match-link {
  color: #4338ca;
  font-size: 0.8rem;
  font-weight: 650;
  text-decoration: none;
}

.match-link:hover {
  text-decoration: underline;
}

.workflow-list {
  margin: 4px 0 0;
  padding-left: 18px;
  font-size: 0.85rem;
  line-height: 1.5;
}

@media (max-width: 600px) {
  body {
    padding: 0;
  }

  .chat-shell {
    min-height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .chat-header,
  .messages,
  .composer {
    padding-left: 18px;
    padding-right: 18px;
  }

  .message {
    max-width: 88%;
  }
}
