* { box-sizing: border-box; }

:root {
  --brand: #005f9e;
  --brand-dark: #004873;
  --brand-soft: #eaf4fb;
  --accent: #00a86b;
  --surface: #f5f7f9;
  --border: #dfe5ea;
  --text: #172231;
  --text-muted: #667384;
  --radius: 14px;
  --shadow: 0 20px 55px rgba(18, 42, 66, 0.22);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background: #edf2f5;
}

button, textarea { font: inherit; }
.hidden { display: none !important; }

.standalone-mode {
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 20%, rgba(0, 168, 107, 0.09), transparent 30%),
    linear-gradient(135deg, #eef5f8 0%, #f9fbfc 50%, #e8f1f5 100%);
}

.site-preview { max-width: 560px; padding: clamp(70px, 12vh, 150px) 48px; }
.preview-kicker { color: var(--brand); font-size: 13px; font-weight: 800; letter-spacing: 1.4px; }
.site-preview h2 {
  max-width: 500px;
  margin: 18px 0 16px;
  font-size: clamp(38px, 5vw, 66px);
  line-height: 1.03;
  letter-spacing: -2px;
}
.site-preview p { max-width: 470px; margin: 0; color: var(--text-muted); font-size: 19px; line-height: 1.6; }

.widget-launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 999;
  min-height: 54px;
  padding: 8px 18px 8px 8px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 12px 32px rgba(0, 95, 158, 0.32);
}

.launcher-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255,255,255,0.17);
  font-size: 18px;
}

.app {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 998;
  width: min(430px, calc(100vw - 32px));
  height: min(720px, calc(100dvh - 48px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  border: 1px solid rgba(0, 72, 115, 0.12);
  border-radius: 20px;
  box-shadow: var(--shadow);
  transform-origin: right bottom;
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
}

.app.widget-closed {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(18px) scale(0.97);
}

.embed-mode .app {
  position: relative;
  inset: auto;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.app-header {
  width: 100%;
  min-width: 0;
  min-height: 70px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  color: #fff;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  border-bottom: 3px solid var(--accent);
}

.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 12px;
  background: rgba(255,255,255,0.14);
  color: #fff;
  font-size: 20px;
  font-weight: 800;
}

.brand h1 { margin: 0; font-size: 17px; line-height: 1.2; }
.brand p {
  margin: 3px 0 0;
  color: rgba(255,255,255,0.78);
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-dot {
  width: 7px;
  height: 7px;
  margin-right: 3px;
  display: inline-block;
  border-radius: 50%;
  background: #5ce5a7;
  box-shadow: 0 0 0 3px rgba(92,229,167,0.13);
}

.header-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.header-actions form { margin: 0; }
.header-icon-btn, .header-text-btn {
  min-width: 36px;
  height: 36px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 10px;
  background: rgba(255,255,255,0.1);
  color: #fff;
  cursor: pointer;
}
.header-icon-btn svg { fill: currentColor; }
.header-text-btn { padding: 0 11px; font-size: 12px; }
.header-icon-btn:hover, .header-text-btn:hover { background: rgba(255,255,255,0.2); }
.header-icon-btn:disabled { opacity: 0.45; cursor: default; }

.chat-window {
  width: 100%;
  min-width: 0;
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 18px 14px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--surface);
  scroll-behavior: smooth;
}
.chat-window::-webkit-scrollbar { width: 5px; }
.chat-window::-webkit-scrollbar-thumb { background: #c9d2da; border-radius: 99px; }

.message { width: 100%; min-width: 0; display: flex; align-items: flex-end; gap: 8px; }
.message.user { justify-content: flex-end; }
.message.assistant { justify-content: flex-start; }
.avatar {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  margin-bottom: 2px;
  border-radius: 10px;
  background: transparent;
  border: none;
  padding: 0;
  box-shadow: none;
  overflow: hidden;
}

.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.message-col { width: calc(100% - 38px); min-width: 0; max-width: calc(100% - 38px); display: flex; flex-direction: column; gap: 8px; }
.message.user .message-col { max-width: 86%; }
.bubble {
  max-width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.58;
  overflow-wrap: anywhere;
}
.message.assistant .bubble {
  background: #fff;
  border: 1px solid var(--border);
  border-bottom-left-radius: 5px;
  box-shadow: 0 1px 3px rgba(18,42,66,0.04);
}
.message.user .bubble {
  background: var(--brand);
  color: #fff;
  border-bottom-right-radius: 5px;
  box-shadow: 0 3px 12px rgba(0,95,158,0.2);
}
.welcome-bubble { border-color: #cfe1ee !important; }
.welcome-bubble strong { display: inline-block; margin-bottom: 3px; }
.message.assistant .bubble a { color: var(--brand); }

.starter-prompts { display: flex; flex-wrap: wrap; gap: 7px; }
.starter-prompt {
  padding: 7px 10px;
  border: 1px solid #c9ddea;
  border-radius: 999px;
  background: #fff;
  color: var(--brand);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.starter-prompt:hover { background: var(--brand-soft); border-color: var(--brand); }

.typing .bubble { padding: 13px 16px; }
.dot {
  width: 7px;
  height: 7px;
  margin: 0 2px;
  display: inline-block;
  border-radius: 50%;
  background: #8995a2;
  animation: bounce 1.3s infinite ease-in-out both;
}
.dot:nth-child(2) { animation-delay: 0.16s; }
.dot:nth-child(3) { animation-delay: 0.32s; }
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-4px); opacity: 1; }
}

.bubble h3 { margin: 13px 0 5px; font-size: 14px; line-height: 1.35; }
.bubble h3:first-child { margin-top: 0; }
.bubble p { margin: 0 0 9px; }
.bubble p:last-child, .bubble > :last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: 5px 0 9px; padding-left: 20px; }
.bubble li { margin: 4px 0; }

.clarify-panel {
  padding: 11px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  border: 1px solid #c7ddec;
  border-radius: 12px;
  background: #eef7fb;
}
.clarify-label { color: var(--brand); font-size: 12.5px; font-weight: 700; }
.clarify-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.clarify-chip, .clarify-more {
  padding: 6px 9px;
  border: 1px solid #bdd7e8;
  border-radius: 9px;
  background: #fff;
  color: var(--brand);
  font-size: 11.5px;
  font-weight: 650;
  cursor: pointer;
}
.clarify-chip:hover { color: #fff; background: var(--brand); border-color: var(--brand); }
.clarify-chip-old { color: #6d28d9; border-color: #ddd0f8; }
.clarify-more { align-self: flex-start; border: 0; background: transparent; text-decoration: underline; }

.references {
  margin-top: 2px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: #fff;
}
.references-label {
  padding: 9px 11px;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}
.references-label::-webkit-details-marker { display: none; }
.references-label::before { content: '▸'; transition: transform 0.15s; }
.references[open] .references-label::before { transform: rotate(90deg); }
.references-chips { padding: 0 10px 9px; display: flex; flex-wrap: wrap; gap: 6px; }
.ref-chip {
  padding: 5px 8px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid #c8deec;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 11.5px;
  font-weight: 650;
  cursor: pointer;
}
.ref-chip-icon { font-size: 10px; }
.ref-chip-old { color: #6d28d9; background: #f5f0ff; border-color: #ddd0f8; }
.ref-docs { padding: 0 10px 10px; display: flex; flex-direction: column; gap: 6px; }
.ref-docs-heading { color: var(--text-muted); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.ref-doc-row { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.ref-doc-header { padding: 8px; display: flex; align-items: center; gap: 7px; }
.ref-doc-badge { padding: 2px 5px; flex: 0 0 auto; border-radius: 4px; font-size: 9px; font-weight: 800; text-transform: uppercase; }
.badge-manual { background: #e8f5e9; color: #2e7d32; }
.badge-datasheet { background: #e3f2fd; color: #1565c0; }
.badge-install { background: #fff3e0; color: #e65100; }
.badge-cert { background: #f3e5f5; color: #6a1b9a; }
.badge-other { background: #f1f3f5; color: #5f6872; }
.badge-page { background: #e0f7fa; color: #006064; }
.ref-doc-toggle {
  flex: 1;
  min-width: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 11.5px;
  cursor: pointer;
}
.ref-doc-name { overflow: hidden; text-overflow: ellipsis; }
.ref-doc-arrow { flex: 0 0 auto; color: var(--text-muted); }
.ref-doc-open { flex: 0 0 auto; color: var(--brand); font-size: 10.5px; text-decoration: none; }
.ref-doc-text {
  max-height: 180px;
  padding: 9px;
  overflow: auto;
  border-top: 1px solid var(--border);
  background: #f8fafb;
  color: #394655;
  font-size: 11.5px;
  line-height: 1.55;
}
.ref-doc-text.hidden { display: none; }
.ref-source-link { display: none; }

.composer { width: 100%; min-width: 0; flex: 0 0 auto; overflow: hidden; border-top: 1px solid var(--border); background: #fff; }
.chat-input-row { width: 100%; min-width: 0; margin: 0; padding: 11px 12px 7px; display: flex; align-items: flex-end; gap: 8px; }
#chat-input {
  flex: 1;
  width: 0;
  min-width: 0;
  min-height: 44px;
  max-height: 130px;
  padding: 11px 13px;
  resize: none;
  border: 1.5px solid #ccd5dd;
  border-radius: 13px;
  outline: 0;
  background: #f8fafb;
  color: var(--text);
  font-size: 14px;
}
#chat-input:focus { border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px rgba(0,95,158,0.1); }
#chat-input::placeholder { color: #929ca7; }
#send-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 0;
  border-radius: 13px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(0,95,158,0.25);
}
#send-btn:hover { background: var(--brand-dark); }
#send-btn:disabled { opacity: 0.45; cursor: default; }
.assistant-note { margin: 0; padding: 0 14px 9px; color: var(--text-muted); font-size: 10.5px; text-align: center; overflow-wrap: anywhere; }

.product-modal { position: fixed; inset: 0; z-index: 1200; display: flex; align-items: center; justify-content: center; }
.product-modal.hidden { display: none; }
.product-modal-backdrop { position: absolute; inset: 0; background: rgba(10,22,36,0.56); backdrop-filter: blur(3px); }
.product-modal-panel {
  position: relative;
  width: min(760px, 94vw);
  height: min(720px, 90vh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(0,0,0,0.28);
}
.product-modal-header { padding: 13px 15px; display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--brand); color: #fff; }
.product-modal-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 700; }
.product-modal-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.product-modal-open { color: #fff; font-size: 12px; text-decoration: none; }
.product-modal-close { width: 30px; height: 30px; border: 0; border-radius: 8px; background: rgba(255,255,255,0.15); color: #fff; cursor: pointer; }
.product-modal-frame { width: 100%; flex: 1; border: 0; }

@media (max-width: 780px) {
  .site-preview { display: none; }
  .app { right: 0; bottom: 0; width: 100vw; height: 100vh; height: 100dvh; border: 0; border-radius: 0; }
  .widget-launcher { right: 16px; bottom: 16px; }
  .product-modal-panel { width: 100vw; height: 100dvh; border-radius: 0; }
}

@media (max-width: 520px) {
  .app-header { padding: 0 9px; gap: 5px; }
  .brand { gap: 8px; min-width: 0; }
  .brand-mark { width: 36px; height: 36px; border-radius: 10px; }
  .brand p { display: none; }
  .header-actions { gap: 4px; }
  .header-icon-btn { min-width: 32px; width: 32px; height: 32px; }
  .header-text-btn { display: none; }
  .chat-window { padding-left: 10px; padding-right: 10px; }
  .message-col { width: calc(100% - 38px); min-width: 0; max-width: calc(100% - 38px); }
  .message.user .message-col { width: auto; max-width: 90%; }
  .starter-prompts { max-width: 100%; }
  .starter-prompt { max-width: 100%; white-space: normal; text-align: left; }
  .chat-input-row { padding-left: 9px; padding-right: 9px; }
  #send-btn { width: 42px; height: 42px; }
  .assistant-note { padding-left: 8px; padding-right: 8px; }
}

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

/* Vera avatar: human illustration in header, launcher and messages */
.avatar { border-radius: 50%; }
.brand-mark, .launcher-mark { padding: 0; overflow: hidden; border-radius: 50%; }
.brand-mark { border: 2px solid rgba(255,255,255,0.55); background: #e4f2f8; }
.launcher-mark { width: 40px; height: 40px; border: 2px solid rgba(255,255,255,0.55); background: #e4f2f8; }
.brand-mark .avatar-img, .launcher-mark .avatar-img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Header and launcher: show the avatar even where the template still has the "V" letter */
.brand-mark, .launcher-mark { background: #e4f2f8 url('vera-avatar.svg?v=2') center / cover no-repeat; color: transparent; font-size: 0; }
