.sca {
  --sca-primary: #079f9b;
  --sca-ink: #10263b;
  --sca-muted: #5d7184;
  --sca-border: #d9e7eb;
  position: fixed;
  z-index: 99990;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--sca-ink);
  letter-spacing: 0;
}

.sca *, .sca *::before, .sca *::after { box-sizing: border-box; }
.sca [hidden] { display: none !important; }

.sca__launcher {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 7px;
  padding: 10px 16px 10px 10px;
  background: var(--sca-primary);
  color: #fff;
  box-shadow: 0 12px 34px rgba(9, 38, 57, .22);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.sca__launcher-mark {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.48);
  border-radius: 50%;
  font-size: 16px;
}

.sca__dialog {
  position: absolute;
  right: 0;
  bottom: 62px;
  width: min(390px, calc(100vw - 24px));
  max-height: min(690px, calc(100vh - 100px));
  display: grid;
  grid-template-rows: auto minmax(130px, 1fr) auto auto auto;
  overflow: hidden;
  border: 1px solid var(--sca-border);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 22px 60px rgba(9, 38, 57, .25);
}

.sca__header {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  background: #102f43;
  color: #fff;
}
.sca__header > div { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sca__header strong, .sca__header small { display: block; }
.sca__header strong { font-size: 15px; line-height: 1.3; }
.sca__header small { margin-top: 2px; color: #c8d9e2; font-size: 11px; line-height: 1.3; }
.sca__status { width: 10px; height: 10px; flex: 0 0 auto; border-radius: 50%; background: #58d39b; box-shadow: 0 0 0 4px rgba(88,211,155,.15); }
.sca__close { width: 36px; height: 36px; flex: 0 0 auto; border: 0; background: transparent; color: #fff; font-size: 27px; line-height: 1; cursor: pointer; }

.sca__messages {
  min-height: 170px;
  padding: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #f6fafb;
}
.sca__message { max-width: 88%; margin: 0 0 11px; padding: 10px 12px; border-radius: 7px; white-space: pre-wrap; font-size: 14px; line-height: 1.48; }
.sca__message--assistant { background: #fff; border: 1px solid var(--sca-border); }
.sca__message--user { margin-left: auto; background: var(--sca-primary); color: #fff; }
.sca__message.is-pending { color: var(--sca-muted); font-style: italic; }

.sca__quick { display: flex; flex-wrap: wrap; gap: 7px; padding: 0 14px 12px; background: #f6fafb; }
.sca__quick button { border: 1px solid #b9d9dc; border-radius: 5px; padding: 7px 9px; background: #fff; color: #125b67; font: inherit; font-size: 12px; text-align: left; cursor: pointer; }

.sca__lead { padding: 14px; overflow-y: auto; border-top: 1px solid var(--sca-border); background: #fff; }
.sca__lead-intro { margin-bottom: 10px; }
.sca__lead-intro strong, .sca__lead-intro span { display: block; }
.sca__lead-intro strong { font-size: 15px; }
.sca__lead-intro span { margin-top: 3px; color: var(--sca-muted); font-size: 12px; line-height: 1.4; }
.sca__lead label:not(.sca__consent) { display: block; margin-top: 9px; font-size: 12px; font-weight: 700; }
.sca__lead input[type="text"], .sca__lead input[type="email"], .sca__lead input[type="tel"] { width: 100%; height: 40px; margin-top: 4px; border: 1px solid #bfd1d9; border-radius: 5px; padding: 8px 10px; color: var(--sca-ink); background: #fff; font: inherit; }
.sca__consent { display: grid; grid-template-columns: 18px 1fr; align-items: start; gap: 7px; margin: 11px 0; color: var(--sca-muted); font-size: 11px; line-height: 1.4; }
.sca__consent input { margin-top: 2px; }
.sca__consent a { color: #126a73; }
.sca__submit { width: 100%; min-height: 42px; border: 0; border-radius: 5px; background: var(--sca-primary); color: #fff; font: inherit; font-weight: 700; cursor: pointer; }
.sca__error { margin: 7px 0 0; color: #b42318; font-size: 12px; }
.sca__hp { position: absolute !important; left: -10000px !important; width: 1px !important; height: 1px !important; opacity: 0 !important; }

.sca__composer { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 8px; padding: 11px; border-top: 1px solid var(--sca-border); background: #fff; }
.sca__composer textarea { width: 100%; min-height: 42px; max-height: 100px; resize: vertical; border: 1px solid #bfd1d9; border-radius: 5px; padding: 10px; color: var(--sca-ink); background: #fff; font: inherit; font-size: 14px; }
.sca__composer button { min-height: 42px; border: 0; border-radius: 5px; padding: 0 13px; background: var(--sca-primary); color: #fff; font: inherit; font-weight: 700; cursor: pointer; }
.sca button:disabled { cursor: wait; opacity: .62; }
.sca button:focus-visible, .sca input:focus-visible, .sca textarea:focus-visible { outline: 3px solid color-mix(in srgb, var(--sca-primary), #fff 58%); outline-offset: 2px; }
.sca__privacy { margin: 0; padding: 7px 12px 9px; color: #718394; background: #fff; font-size: 10px; line-height: 1.35; text-align: center; }

@media (max-width: 600px) {
  .sca { right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); }
  .sca__launcher {
    width: 52px;
    min-width: 52px;
    padding: 10px;
    justify-content: center;
  }
  .sca__launcher > span:last-child:not(.sca__launcher-mark) { display: none; }
  .sca__dialog { position: fixed; inset: 10px 10px max(10px, env(safe-area-inset-bottom)); width: auto; max-height: none; border-radius: 7px; }
  .sca.is-open .sca__launcher { display: none; }
}

@media (prefers-reduced-motion: no-preference) {
  .sca__dialog { animation: sca-in .18s ease-out; }
  @keyframes sca-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
}
