:root {
  --bg: #eef1f4;
  --surface: #ffffff;
  --surface-soft: #f2f6f8;
  --border: #d6dee4;
  --ink: #17252b;
  --muted: #5c6a72;
  --brand: #0f766e;
  --brand-dark: #0b514c;
  --accent: #b45309;
  --success: #15803d;
  --danger: #b42318;
  --shadow: 0 10px 30px rgba(23, 37, 43, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Aptos", "Helvetica Neue", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.24);
  outline-offset: 1px;
}

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

.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark,
.agent-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border-radius: var(--radius);
  background: var(--brand);
  color: #ffffff;
  font-weight: 700;
}

.brand-mark {
  width: 44px;
  height: 44px;
  font-size: 18px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.site-header h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

.header-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.connection-badge,
.demo-tag,
.required-tag,
.ready-tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.connection-badge[data-state="ready"] {
  background: #e7f6ec;
  color: var(--success);
}

.connection-badge[data-state="missing"],
.required-tag {
  background: #fdf1e7;
  color: var(--accent);
}

.connection-badge[data-state="loading"] {
  background: #edf2f7;
  color: var(--muted);
}

.connection-badge[data-state="error"] {
  background: #fdeceb;
  color: var(--danger);
}

.demo-tag {
  background: var(--ink);
  color: #ffffff;
}

.demo-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  align-items: start;
}

.chat-panel {
  display: flex;
  flex-direction: column;
  height: min(760px, calc(100vh - 150px));
  min-height: 560px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.chat-agent {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.agent-avatar {
  width: 42px;
  height: 42px;
}

.chat-agent h2 {
  margin: 0;
  font-size: 16px;
  line-height: 1.25;
}

.chat-agent p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.online-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 5px;
  border-radius: 50%;
  background: var(--success);
  vertical-align: 1px;
}

.text-button {
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 600;
}

.text-button:hover {
  background: var(--surface-soft);
}

.quick-prompts {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
  scrollbar-width: thin;
}

.quick-prompt {
  flex: 0 0 auto;
  max-width: 250px;
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--brand-dark);
  font-size: 13px;
  text-align: left;
}

.quick-prompt:hover {
  border-color: var(--brand);
  background: #edf7f5;
}

.chat-messages {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding: 18px;
  background: #f8fafb;
}

.message-row {
  display: flex;
  width: 100%;
}

.message-row.user {
  justify-content: flex-end;
}

.bubble {
  max-width: 82%;
  padding: 10px 12px;
  border-radius: var(--radius);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.bubble.assistant {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink);
}

.bubble.user {
  background: var(--brand);
  color: #ffffff;
}

.message-time {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
}

.bubble.user .message-time {
  color: rgba(255, 255, 255, 0.82);
}

.typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 58px;
  min-height: 42px;
}

.typing-bubble span {
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  animation: typing-pulse 1.2s ease-in-out infinite;
}

.typing-bubble span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-bubble span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typing-pulse {
  0%,
  60%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.composer textarea {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  max-height: 120px;
  resize: vertical;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}

.composer textarea:focus {
  border-color: var(--brand);
}

.send-button {
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: var(--radius);
  background: var(--brand);
  color: #ffffff;
  font-weight: 600;
}

.send-button:hover {
  background: var(--brand-dark);
}

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

.info-column {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.info-section {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.section-heading h2 {
  margin: 0;
  font-size: 14px;
  line-height: 1.3;
}

.section-note,
.field-hint,
.disclaimer {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.section-note {
  margin-bottom: 12px;
}

.key-form {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.key-form input {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--ink);
}

.key-form input:focus {
  border-color: var(--brand);
}

.key-form button {
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--radius);
  background: var(--brand);
  color: #ffffff;
  font-weight: 600;
}

.field-hint {
  margin-bottom: 8px;
}

.field-error {
  margin: 8px 0 0;
  color: var(--danger);
  font-size: 13px;
}

.capability-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
}

.capability-list strong {
  display: block;
  color: var(--ink);
  font-size: 13px;
}

.topic-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.topic-cloud span {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
}

noscript {
  display: block;
  padding: 16px;
  color: var(--danger);
}

@media (max-width: 900px) {
  .demo-layout {
    grid-template-columns: 1fr;
  }

  .chat-panel {
    height: calc(100dvh - 190px);
    min-height: 540px;
  }

  .info-column {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .app-shell {
    padding: 14px;
  }

  .site-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-meta {
    justify-content: flex-start;
    width: 100%;
  }

  .connection-badge {
    flex: 1;
  }

  .chat-panel {
    height: calc(100dvh - 210px);
    min-height: 520px;
  }

  .chat-header {
    align-items: flex-start;
    padding: 12px;
  }

  .quick-prompts {
    padding: 10px 12px;
  }

  .chat-messages {
    padding: 12px;
  }

  .bubble {
    max-width: 88%;
  }

  .composer {
    padding: 10px 12px;
  }

  .send-button {
    padding: 0 12px;
  }

  .info-column {
    grid-template-columns: 1fr;
  }

  .key-form {
    flex-direction: column;
  }
}
