/* The welcome screen follows the existing hidden state and scrolls within the visible viewport. */
body:has(#welcome:not([hidden])) {
  --entry-gutter: clamp(16px, 3vw, 36px);
  --entry-canvas: #bbc9d4;
  --entry-ink: #20252b;
  --entry-muted: #596473;
  --entry-accent: #215ce5;
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: var(--entry-gutter);
  background: var(--entry-canvas);
}

body:has(#welcome:not([hidden])) .app-shell {
  width: 100%;
  max-width: 1120px;
  height: auto;
  max-height: calc(var(--chat-viewport-height, 100dvh) - var(--entry-gutter) - var(--entry-gutter));
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid #ffffffb3;
  border-radius: 24px;
  background: #f5f8fa;
  box-shadow: 0 18px 45px #293d5019;
}

body:has(#welcome:not([hidden])) .app-shell > .brand-bar { display: none; }

#welcome {
  display: grid;
  grid-template-columns: minmax(0, 41fr) minmax(0, 59fr);
  grid-template-rows: minmax(594px, auto);
  padding: 0;
  color: var(--entry-ink);
  scrollbar-width: thin;
  scrollbar-color: #8398aa transparent;
}

#welcome .entry-sidebar,
#welcome .entry-panel { min-width: 0; }

#welcome .entry-sidebar {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 24px clamp(20px, 2vw, 26px) 66px clamp(27px, 4vw, 47px);
  background: #d4dfe7;
}

#welcome .entry-panel {
  padding: clamp(36px, 4.25vw, 52px) clamp(29px, 4vw, 47px) 46px clamp(32px, 4.5vw, 56px);
  background: #f5f8fa;
}

@supports ((backdrop-filter: blur(6px)) or (-webkit-backdrop-filter: blur(6px))) {
  body:has(#welcome:not([hidden])) .app-shell {
    background: #ffffff26;
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
  }
  #welcome .entry-sidebar { background: #d4dfe7e0; }
  #welcome .entry-panel { background: #f5f8faf5; }
}

#welcome .entry-logo {
  display: block;
  width: clamp(145px, 14vw, 184px);
  max-width: 100%;
  height: auto;
  margin: 0 0 -10px -7px;
}

#welcome .entry-kicker {
  margin: 28px 0 0;
  font-size: 15px;
  line-height: 1.35;
  font-weight: 750;
  letter-spacing: .15em;
}

#welcome .entry-support {
  margin: 17px 0 0;
  font-size: clamp(34px, 4vw, 48px);
  font-weight: 750;
  line-height: 1.04;
  letter-spacing: -.038em;
}

#welcome .entry-support-copy {
  margin: 20px 0 0;
  color: #505c6a;
  font-size: clamp(17px, 1.82vw, 22px);
  line-height: 1.32;
  letter-spacing: -.015em;
}

#welcome .entry-bubbles {
  display: grid;
  gap: 18px;
  width: 100%;
  margin-top: auto;
  padding-top: 36px;
}

#welcome .entry-bubble {
  display: flex;
  align-items: center;
  justify-self: start;
  gap: 13px;
  max-width: 100%;
  min-height: 55px;
  margin: 0;
  padding: 10px clamp(13px, 1.5vw, 17px);
  border: 1px solid #ffffffa6;
  border-radius: 12px;
  background: #f8fbfd;
  box-shadow: 0 3px 10px #31475d0e;
  font-size: clamp(14px, 1.46vw, 17px);
  font-weight: 550;
  line-height: 1.32;
}

#welcome .entry-bubble-icon { width: 36px; height: 32px; flex: none; color: var(--entry-accent); }

#welcome .entry-bubble-reply {
  justify-self: end;
  min-height: 48px;
  padding-inline: 23px;
  border-color: #eaf4fb8f;
  background: #dcebf6;
}

#welcome h1 {
  margin: 0;
  font-size: clamp(30px, 3.55vw, 40px);
  font-weight: 750;
  line-height: 1.13;
  letter-spacing: -.034em;
  text-wrap: balance;
}

#welcome .entry-lead {
  max-width: none;
  margin: 7px 0 0;
  color: var(--entry-muted);
  font-size: clamp(17px, 1.72vw, 20px);
  line-height: 1.4;
}

#welcome .entry-form { display: grid; gap: 18px; margin-top: 27px; }
#welcome .entry-field { display: grid; gap: 8px; min-width: 0; }
#welcome .entry-field > label { font-size: clamp(16px, 1.42vw, 19px); line-height: 1.28; font-weight: 750; }

#welcome .entry-name-control,
#welcome .phone-control {
  display: flex;
  align-items: center;
  width: 100%;
  min-width: 0;
  height: 54px;
  border: 1px solid #7a90a6;
  border-radius: 11px;
  background: #fff;
  box-shadow: none;
}

#welcome .entry-name-control:focus-within,
#welcome .phone-control:focus-within {
  border-color: var(--entry-accent);
  outline: 2px solid var(--entry-accent);
  outline-offset: 1px;
}

#welcome .entry-field-icon { width: 25px; height: 25px; margin-left: 20px; flex: none; color: #364150; }

#welcome .entry-name-control input,
#welcome .phone-control input {
  flex: 1;
  width: 1px;
  min-width: 0;
  height: 100%;
  min-height: 0;
  padding: 0 20px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  box-shadow: none;
  color: var(--entry-ink);
  font-size: clamp(16px, 1.65vw, 19px);
  outline: none;
}

#welcome .entry-name-control input::placeholder,
#welcome .phone-control input::placeholder { color: var(--entry-muted); opacity: 1; }

#welcome .country-picker { position: relative; width: 132px; height: 100%; border-right: 0; }
#welcome .country-picker::after { content: ""; position: absolute; inset: 11px 0 11px auto; width: 1px; background: #a8bacb; pointer-events: none; }
#welcome .country-trigger { min-height: 44px; gap: 10px; padding: 0 12px; border-radius: 10px 0 0 10px; }
#welcome .country-trigger:hover,
#welcome .country-trigger[aria-expanded="true"] { background: #edf3fa; }
#welcome .country-trigger:focus-visible { outline: 2px solid var(--entry-accent); outline-offset: -3px; }
#welcome .country-flag { width: 30px; height: 22.5px; }
#welcome #country-mark { color: var(--entry-ink); font-size: 16px; font-weight: 650; white-space: nowrap; font-variant-numeric: tabular-nums; }
#welcome .country-trigger .ui-icon { width: 15px; height: 15px; color: #364150; }
#welcome .country-trigger:disabled { cursor: default; background: #f3f6f9; }

#welcome :is(.entry-name-control, .phone-control):has(input[aria-invalid="true"]) { border-color: #ad2340; outline: 1px solid #ad23404d; }
#welcome :is(.entry-name-control, .phone-control):has(input[aria-invalid="true"]):focus-within { outline-width: 2px; outline-color: #ad2340; }
#welcome .phone-control #customer-phone[aria-invalid="true"] { box-shadow: none; }

#welcome .form-note { margin: 0; color: #465262; font-size: clamp(13px, 1.25vw, 16px); line-height: 1.4; }
#welcome .form-error { min-height: 0; margin: -2px 0 0; color: #9e253c; font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; }

#welcome .primary-button {
  width: 100%;
  max-width: none;
  min-height: 60px;
  margin: 6px 0 0;
  padding: 12px 20px;
  justify-content: center;
  gap: clamp(13px, 2.4vw, 29px);
  border: 0;
  border-radius: 12px;
  background: var(--entry-accent);
  color: #fff;
  box-shadow: none;
  font-size: clamp(16px, 1.65vw, 21px);
  font-weight: 700;
  line-height: 1.3;
  transform: none;
  transition: none;
}

#welcome .primary-button .ui-icon { width: 24px; height: 24px; }
#welcome .primary-button:hover { background: #174ecf; box-shadow: none; }
#welcome .primary-button:active { background: #1344b8; transform: none; }
#welcome .primary-button:focus-visible { outline: 3px solid var(--entry-accent); outline-offset: 3px; }
#welcome .primary-button:disabled { cursor: wait; background: #526ea7; color: #fff; }

#welcome .privacy-note {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  max-width: none;
  margin: 25px 0 0;
  padding-top: 18px;
  border-top: 1px solid #ccd7e1;
  color: #3e4958;
  font-size: clamp(13px, 1.18vw, 15px);
  line-height: 1.5;
}

#welcome .privacy-note .ui-icon { width: 21px; height: 21px; color: #313e4e; }

@media (max-width: 819px) {
  body:has(#welcome:not([hidden])) {
    --entry-gutter: clamp(12px, 4vw, 22px);
    padding-block: max(var(--entry-gutter), env(safe-area-inset-top)) max(var(--entry-gutter), env(safe-area-inset-bottom));
    padding-inline: max(var(--entry-gutter), env(safe-area-inset-left)) max(var(--entry-gutter), env(safe-area-inset-right));
  }
  body:has(#welcome:not([hidden])) .app-shell { position: relative; top: 0; max-width: 520px; border-radius: 21px; }
  #welcome { display: block; }
  #welcome .entry-sidebar { padding: 13px clamp(16px, 5vw, 26px) 20px; }
  #welcome .entry-brand { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; width: 100%; }
  #welcome .entry-logo { width: 124px; margin: -4px 0 -5px -5px; }
  #welcome .entry-kicker { margin: 0; font-size: 10px; letter-spacing: .13em; }
  #welcome .entry-support { margin-top: 6px; font-size: clamp(20px, 5.4vw, 28px); line-height: 1.14; }
  #welcome .entry-support-copy { margin-top: 6px; font-size: 14px; line-height: 1.35; }
  #welcome .entry-desktop-break,
  #welcome .entry-bubbles { display: none; }
  #welcome .entry-panel { padding: 23px clamp(16px, 5vw, 26px) 22px; }
  #welcome h1 { font-size: clamp(26px, 6.9vw, 34px); }
  #welcome .entry-lead { margin-top: 6px; font-size: 15px; }
  #welcome .entry-form { margin-top: 21px; gap: 16px; }
  #welcome .entry-field { gap: 7px; }
  #welcome .entry-field-icon { width: 22px; height: 22px; margin-left: 13px; }
  #welcome .entry-name-control input,
  #welcome .phone-control input { padding-inline: 11px; font-size: 16px; }
  #welcome .country-picker { width: 99px; }
  #welcome .country-trigger { gap: 6px; padding: 0 7px; }
  #welcome .country-flag { width: 24px; height: 18px; }
  #welcome #country-mark { font-size: 14px; }
  #welcome .country-trigger .ui-icon { width: 13px; height: 13px; }
  #welcome .primary-button { min-height: 54px; margin-top: 4px; padding-inline: 11px; font-size: 16px; }
  #welcome .primary-button .ui-icon { width: 20px; height: 20px; }
  #welcome .privacy-note { margin-top: 18px; padding-top: 13px; gap: 8px; }
  #welcome .privacy-note .ui-icon { width: 18px; height: 18px; }

  html[data-chat-keyboard] body:has(#welcome:not([hidden])) .app-shell {
    position: fixed;
    top: var(--chat-viewport-top, 0px);
    width: min(calc(100% - var(--entry-gutter) - var(--entry-gutter)), 520px);
    height: var(--chat-viewport-height, 100dvh);
    max-height: var(--chat-viewport-height, 100dvh);
    margin-inline: auto;
  }
  html[data-chat-keyboard] #welcome .entry-sidebar { padding-block: 6px; }
  html[data-chat-keyboard] #welcome .entry-logo { width: 101px; }
  html[data-chat-keyboard] #welcome .entry-support,
  html[data-chat-keyboard] #welcome .entry-support-copy { display: none; }
}

@media (max-width: 359px) {
  body:has(#welcome:not([hidden])) { --entry-gutter: 9px; }
  #welcome .entry-sidebar { padding: 8px 14px 13px; }
  #welcome .entry-logo { width: 105px; }
  #welcome .entry-support { font-size: 19px; }
  #welcome .entry-support-copy { margin-top: 4px; font-size: 13px; }
  #welcome .entry-panel { padding: 17px 14px 16px; }
  #welcome h1 { font-size: 25px; }
  #welcome .entry-lead { font-size: 14px; }
  #welcome .entry-form { margin-top: 16px; gap: 12px; }
  #welcome .entry-field { gap: 6px; }
  #welcome .entry-name-control,
  #welcome .phone-control { height: 52px; }
  #welcome .primary-button { min-height: 52px; }
  #welcome .privacy-note { margin-top: 14px; padding-top: 10px; font-size: 12px; line-height: 1.45; }
}

/* Shared brand header for the active conversation. */
.app-shell > .brand-bar { height: 72px; padding: 10px 20px; background: #fff; align-items: center; }
.app-shell > .brand-bar img { display: block; width: 116px; height: 50px; max-width: 42%; max-height: 100%; object-fit: contain; object-position: center; flex-shrink: 1; }
html[data-chat-keyboard] .app-shell > .brand-bar { height: 44px; padding: 4px 14px; }
html[data-chat-keyboard] .app-shell > .brand-bar img { width: 84px; height: 34px; }
