:root {
  --navy: #121212;
  --navy-2: #ffffff;
  --ink: #121212;
  --green: #277245;
  --blue: #21325e;
  --sky: #21325e;
  --text: #1d2939;
  --muted: #475467;
  --input-bg: #f9fafb;
  --border: #d0d5dd;
  --brand-green: #2f8a54;
  --brand-gold: #ffc107;
  --user-bg: #e1ebe5;
  --focus: #21325e;
}

  #chatLauncher, #chatWindow, #chatWindow * { box-sizing: border-box; }

  #chatWindow, #chatWindow button, #chatWindow input, #chatWindow select, #chatWindow textarea { font-family: Arial, Helvetica, sans-serif; }
  #chatWindow .msg { color: var(--text); }
  #chatWindow .msg.user { color: var(--ink); }
  #chatWindow button { appearance: none; -webkit-appearance: none; }
  #chatWindow .chips .chip {
    background-color: rgba(47, 138, 84, 0.08) !important;
    background-image: none !important;
    border-color: var(--green) !important;
    color: var(--green) !important;
  }
  #chatWindow .chips .chip:hover,
  #chatWindow .chips .chip:focus-visible,
  #chatWindow .chips .chip.sel {
    background-color: var(--green) !important;
    background-image: none !important;
    border-color: var(--green) !important;
    color: #fff !important;
  }

  /* ------- Chat launcher ------- */
  #chatLauncher {
    position: fixed;
    right: 22px;
    bottom: 22px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--brand-green);
    border: none;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease;
    z-index: 1000;
  }
  #chatLauncher:hover { transform: scale(1.06); }
  #chatLauncher svg { width: 30px; height: 30px; fill: #fff; }
  #chatLauncher .launcher-close { display: none; }
  #chatLauncher.is-open .launcher-open { display: none; }
  #chatLauncher.is-open .launcher-close { display: block; }

  /* ------- Chat window ------- */
  #chatWindow {
    position: fixed;
    right: 22px;
    bottom: 100px;
    width: 400px;
    max-width: calc(100vw - 32px);
    height: min(600px, calc(100vh - 140px));
    background: var(--navy-2);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    transform: scale(0);
    opacity: 0;
    transition: transform 0.18s ease, opacity 0.18s ease;
    pointer-events: none;
    z-index: 1001;
  }
  #chatWindow.is-open { transform: scale(1); opacity: 1; pointer-events: auto; }

  .chat-header {
    background: var(--user-bg);
    border-bottom: 2px solid var(--brand-gold);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
  }
  .chat-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
  }
  .chat-logo img { width: 134px; height: auto; display: block; }
  .chat-header .who { line-height: 1.2; flex: 1; min-width: 0; }
  .chat-header .who span { display: block; font-size: 12px; color: var(--green); white-space: nowrap; }
  .chat-header .status { margin-left: auto; font-size: 11px; color: var(--ink); display: flex; align-items: center; gap: 5px; }
  .chat-header .status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--brand-green); }

  #chatBody {
    flex: 1;
    overflow-y: auto;
    padding: 18px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .msg {
    max-width: 84%;
    padding: 11px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
    animation: pop 0.18s ease;
  }
  @keyframes pop { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }

  .bot { background: var(--input-bg); border: 1px solid var(--border); align-self: flex-start; border-bottom-left-radius: 4px; }
  .user { background: var(--user-bg); color: var(--ink); align-self: flex-end; border-bottom-right-radius: 4px; font-weight: 500; }

  .typing { display: inline-flex; gap: 4px; align-items: center; }
  .typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
  .typing i:nth-child(2) { animation-delay: 0.2s; }
  .typing i:nth-child(3) { animation-delay: 0.4s; }
  @keyframes blink { 0%, 60%, 100% { opacity: 0.25; } 30% { opacity: 1; } }

  /* Quick reply chips */
  .chips { display: flex; flex-wrap: wrap; gap: 8px; align-self: flex-start; padding: 2px 0; }
  .chip {
    background: rgba(47, 138, 84, 0.08);
    border: 1px solid var(--green);
    color: var(--green);
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
  }
  #chatWindow .chips .chip {
    border-radius: 999px !important;
    box-shadow: none;
    line-height: 1.25;
  }
  .chip:hover { background: var(--green); color: #fff; }
  .state-quick { margin-top: 4px; }
  .state-quick .chip { min-width: 48px; }
  .state-other { margin-top: 8px; }
  .state-other[hidden] { display: none; }

  .consent {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 10px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
  }
  .consent input {
    flex: none;
    width: 16px;
    height: 16px;
    margin: 1px 0 0;
    accent-color: var(--green);
  }

  /* Inline form controls inside a bot bubble */
  .form-bubble { display: flex; flex-direction: column; gap: 8px; width: 100%; }
  .form-bubble input[type="text"],
  .form-bubble input[type="email"],
  .form-bubble input[type="tel"] {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--ink);
    font-size: 14px;
    font-family: inherit;
  }
  .form-bubble input:focus { outline: 2px solid var(--green); }

  /* Phone input with US flag + country code */
  .phone-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 0 0 0 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
  }
  .phone-wrap .flag { display: inline-flex; align-items: center; line-height: 1; }
  .phone-wrap input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    color: var(--ink);
    font-size: 14px;
    font-family: inherit;
    padding: 10px 12px 10px 0;
  }
  .phone-wrap input:focus { outline: none; }
  .phone-wrap:focus-within {
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(47, 138, 84, 0.24);
  }

  /* Custom dropdown */
  .form-bubble select {
    width: 100%;
    padding: 11px 38px 11px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background-color: #fff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%231e293b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 14px;
    color: var(--ink);
    font-size: 14px;
    font-family: inherit;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
  }
  .form-bubble select:hover { border-color: rgba(47, 138, 84, 0.75); }
  .form-bubble select:focus {
    outline: none;
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(47, 138, 84, 0.24);
  }
  .form-bubble select:disabled {
    background-color: rgba(47, 138, 84, 0.09);
    border-color: rgba(47, 138, 84, 0.4);
    color: var(--green);
    font-weight: 600;
    cursor: default;
    opacity: 1;
  }
  .form-bubble select option {
    background: #fff;
    color: var(--ink);
    font-size: 13px;
    padding: 4px 8px;
  }
  .form-bubble select optgroup { color: var(--muted); font-weight: 700; }
  .form-bubble .confirm {
    background: var(--green);
    color: var(--ink);
    border: none;
    border-radius: 8px;
    padding: 10px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
  }
  .form-bubble .confirm:hover { filter: brightness(1.08); }

  .form-hint { font-size: 11px; color: var(--muted); }

  .error-msg { color: #b42318; font-size: 13px; padding: 8px 12px; background: rgba(180, 35, 24, 0.08); border: 1px solid rgba(180, 35, 24, 0.4); border-radius: 10px; align-self: flex-start; }

  /* Summary card */
  .summary {
    background: #f9fafb;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    font-size: 13px;
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  .summary b { color: var(--green); }
  .summary .row { display: flex; gap: 6px; }
  .summary .row .k { color: var(--muted); min-width: 120px; }

  .action-row { display: flex; gap: 8px; }
  .btn {
    border: none;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
  }
  .btn-primary { background: var(--green); color: #fff; }
  .btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }

  .edit-btn {
    display: flex;
    width: fit-content;
    align-items: center;
    gap: 5px;
    margin-top: 10px;
    border: 1px solid rgba(18, 18, 18, 0.25);
    background: #fff;
    color: var(--green);
    border-radius: 999px;
    padding: 4px 12px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
  }
  #chatWindow .msg .edit-btn {
    width: fit-content;
    min-height: 0;
    border: 1px solid rgba(18, 18, 18, 0.25) !important;
    border-radius: 999px !important;
    background-color: #fff !important;
    background-image: none !important;
    color: var(--green) !important;
    box-shadow: none;
    line-height: 1.2;
  }
  #chatWindow .msg .edit-btn:hover,
  #chatWindow .msg .edit-btn:focus,
  #chatWindow .msg .edit-btn:focus-visible {
    border-color: var(--green) !important;
    background-color: var(--green) !important;
    color: #fff !important;
  }
  .edit-btn:hover {
    border-color: var(--green);
    color: #fff;
    background: var(--green);
  }
  .edit-btn svg { flex: none; }
  .answer-val { font-weight: 600; color: var(--text); }
  .msg.user .answer-val { color: var(--ink); }
  .msg.user .q { display: block; font-size: 13px; color: var(--ink); font-weight: 700; margin-bottom: 8px; }
  .edit-form { margin-top: 6px; }
  .edit-form .q { display: block; font-size: 13px; color: var(--text); font-weight: 700; margin-bottom: 6px; }
  .edit-row { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
  .edit-row input, .edit-row select {
    flex: 1;
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 14px;
    font-family: inherit;
    color: var(--ink);
    background: #fff;
  }
  .edit-row input:focus, .edit-row select:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(47, 138, 84, 0.24); }
  .edit-row .confirm {
    flex: none;
    background: var(--green);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
  }
  .edit-row .confirm:hover { filter: brightness(1.08); }
  .chip.sel { background: var(--green); color: #fff; opacity: 1; }

  /* Edit panel inside a green user bubble: white controls for contrast */
  .msg.user .chips .chip {
    background: #fff;
    border-color: rgba(18, 18, 18, 0.25);
    color: var(--ink);
  }
  .msg.user .chips .chip:hover { background: var(--navy); color: #fff; }
  .msg.user .chips .chip.sel {
    background: var(--navy);
    color: #fff;
    border-color: var(--navy);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.4);
  }
  .msg.user select.edit-select {
    width: 100%;
    padding: 11px 38px 11px 12px;
    border-radius: 8px;
    border: 1px solid rgba(18, 18, 18, 0.25);
    background-color: #fff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2306271a' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 14px;
    color: var(--ink);
    font-size: 14px;
    font-family: inherit;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    cursor: pointer;
  }
  .msg.user select.edit-select:focus {
    outline: none;
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(47, 138, 84, 0.28);
  }

  .chat-footer {
    padding: 10px 14px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 11px;
    color: var(--muted);
  }
  .chat-footer a { color: var(--green); text-decoration: none; }

  /* ------- Free-text question bar ------- */
  .chat-ask {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-width: 0;
    flex: 0 0 auto;
    padding: 10px 12px;
    border-top: 1px solid var(--border);
    background: var(--navy-2);
    overflow: hidden;
  }
  .chat-ask input {
    flex: 1 1 auto;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--input-bg);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
  }
  .chat-ask input::placeholder { color: var(--muted); }
  .chat-ask input:focus {
    outline: none;
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(47, 138, 84, 0.24);
  }
  .chat-ask button {
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: var(--green);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.15s ease, filter 0.15s ease;
  }
  .chat-ask button:hover { transform: scale(1.06); filter: brightness(1.08); }
  .chat-ask button:disabled { opacity: 0.55; cursor: default; transform: none; }

  /* Guide-backed question suggestions */
  .faq-suggestions {
    position: absolute;
    right: 12px;
    bottom: 62px;
    left: 12px;
    z-index: 2;
    min-width: 0;
    max-width: calc(100% - 24px);
    max-height: 220px;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--navy-2);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  }
  .faq-suggestions[hidden] { display: none; }
  .faq-suggestion {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 9px 10px;
    border: 0 !important;
    border-radius: 10px !important;
    background: transparent;
    color: var(--text);
    text-align: left;
    font: inherit;
    cursor: pointer;
    line-height: 1.35;
    white-space: normal;
    overflow-wrap: anywhere;
    box-shadow: none !important;
    transform: none;
  }
  .faq-suggestion:hover, .faq-suggestion.is-active { background: var(--input-bg); }
  .faq-suggestion-state {
    display: block;
    margin-top: 3px;
    color: var(--sky);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }
  #chatWindow .faq-suggestions {
    box-sizing: border-box !important;
    overflow-x: hidden !important;
    overscroll-behavior: contain;
  }
  #chatWindow .faq-suggestions .faq-suggestion {
    box-sizing: border-box !important;
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 12px !important;
    background-color: transparent !important;
    background-image: none !important;
    color: var(--green) !important;
    white-space: normal !important;
    overflow-wrap: anywhere;
    box-shadow: none !important;
    text-decoration: none !important;
  }
  #chatWindow .faq-suggestions .faq-suggestion:hover,
  #chatWindow .faq-suggestions .faq-suggestion:focus,
  #chatWindow .faq-suggestions .faq-suggestion:focus-visible,
  #chatWindow .faq-suggestions .faq-suggestion.is-active {
    border: 0 !important;
    border-radius: 12px !important;
    background-color: var(--green) !important;
    background-image: none !important;
    color: #fff !important;
    outline-color: var(--green) !important;
  }
  #chatWindow .faq-suggestions .faq-suggestion-state {
    color: var(--muted) !important;
  }
  #chatWindow .faq-suggestions .faq-suggestion:hover .faq-suggestion-state,
  #chatWindow .faq-suggestions .faq-suggestion:focus .faq-suggestion-state,
  #chatWindow .faq-suggestions .faq-suggestion:focus-visible .faq-suggestion-state,
  #chatWindow .faq-suggestions .faq-suggestion.is-active .faq-suggestion-state {
    color: #fff !important;
  }

  /* FAQ answer cards */
  .faq-card { display: flex; flex-direction: column; gap: 6px; }
  .faq-q { font-weight: 700; color: var(--green); font-size: 13px; line-height: 1.4; }
  .faq-a { font-size: 14px; }
  .faq-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    color: var(--muted);
    border-top: 1px dashed var(--border);
    padding-top: 6px;
  }
  .faq-pill {
    background: rgba(33, 50, 94, 0.08);
    border: 1px solid var(--sky);
    color: var(--sky);
    border-radius: 999px;
    padding: 2px 8px;
    font-weight: 700;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }
  .faq-related-label { font-size: 11px; color: var(--muted); align-self: flex-start; }
  .faq-note {
    font-size: 12px;
    color: var(--muted);
    background: rgba(33, 50, 94, 0.06);
    border: 1px solid rgba(33, 50, 94, 0.25);
    border-radius: 10px;
    padding: 7px 10px;
    margin-bottom: 2px;
  }
  .faq-note b { color: var(--sky); }

  /* Suggestion chips stack vertically — FAQ questions are full sentences */
  .chips.faq-chips { flex-direction: column; align-items: stretch; gap: 6px; }
  .chips.faq-chips .chip {
    text-align: left;
    white-space: normal;
    line-height: 1.35;
    border-radius: 12px;
  }

  .ask-hint { color: var(--muted); font-size: 13px; }

  #chatLauncher:focus-visible,
  #chatWindow :focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
  }

  #chatWindow .chat-ask {
    display: flex !important;
    flex-flow: row nowrap !important;
    align-items: center !important;
    width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    box-sizing: border-box !important;
  }
  #chatWindow .chat-ask input[type="text"] {
    flex: 1 1 0% !important;
    width: 0 !important;
    min-width: 0 !important;
    max-width: 100% !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    border-radius: 999px !important;
  }
  #chatWindow .chat-ask button {
    flex: 0 0 38px !important;
    width: 38px !important;
    min-width: 38px !important;
    height: 38px !important;
    min-height: 38px !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 50% !important;
    box-sizing: border-box !important;
  }

  @media (max-width: 480px) {
    #chatWindow { right: 8px; bottom: 90px; height: calc(100vh - 120px); }
  }
