:root {
  --wa-header: #075e54;
  --wa-header-2: #064e46;
  --wa-teal: #128c7e;
  --wa-send: #00a884;
  --wa-bubble-in: #fff;
  --wa-bubble-out: #d9fdd3;
  --wa-meta: #667781;
  --wa-link: #027eb5;
  --wa-composer: #f0f2f5;
  --wa-app-width: 420px;
  --wa-vvh: 100dvh;
  --wa-vvt: 0px;
}

@supports (height: 100svh) {
  :root {
    --wa-vvh: 100svh;
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html,
body {
  margin: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  background: #0b141a;
  color: #111b21;
  touch-action: manipulation;
}

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

.wa-shell {
  display: flex;
  align-items: stretch;
  justify-content: center;
  overflow: hidden;
  min-height: 0;
}

.wa-app {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: var(--wa-app-width);
  height: 100%;
  min-height: 0;
  min-width: 0;
  position: relative;
  overflow: hidden;
  background: #e5ddd5;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.04), 0 18px 50px rgba(0, 0, 0, 0.45);
  isolation: isolate;
}

html.embedded,
html.embedded body {
  height: 100%;
  background: #e5ddd5;
}

html.embedded .wa-shell {
  position: fixed;
  top: var(--wa-vvt, 0px);
  left: 0;
  width: 100%;
  min-height: 0;
  height: var(--wa-vvh, 100%);
  padding: 0;
}

html.embedded .wa-app {
  max-width: 100%;
  height: 100%;
  box-shadow: none;
}

.wa-header {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(180deg, var(--wa-header) 0%, var(--wa-header-2) 100%);
  color: #fff;
  padding: max(8px, env(safe-area-inset-top, 0px)) 10px 8px 12px;
  min-height: calc(62px + env(safe-area-inset-top, 0px));
  flex-shrink: 0;
  z-index: 30;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
}

.wa-avatar {
  position: relative;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
}

.wa-avatar-photo {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  background: #e8e8e8;
  box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.25);
}

.wa-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 18%;
  display: block;
}

.wa-online {
  position: absolute;
  right: 0;
  bottom: 1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #31a24c;
  border: 2px solid var(--wa-header);
}

.wa-header-text {
  flex: 1;
  min-width: 0;
}

.wa-header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: 2px;
}

.wa-header-action {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: rgba(255, 255, 255, 0.92);
  cursor: pointer;
  transition: background 0.15s ease;
}

.wa-header-action:hover {
  background: rgba(255, 255, 255, 0.12);
}

.wa-header-action:active {
  background: rgba(255, 255, 255, 0.2);
}

.wa-header-action:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.wa-icon-eraser {
  display: block;
  width: 22px;
  height: 22px;
  background: currentColor;
  mask: url('./icon-eraser.png') center / contain no-repeat;
  -webkit-mask: url('./icon-eraser.png') center / contain no-repeat;
}

.wa-confirm-sheet {
  position: absolute;
  inset: 0;
  background: rgba(11, 20, 26, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 40;
}

.wa-confirm-sheet:not([hidden]) {
  display: flex;
}

.wa-confirm-panel {
  width: 100%;
  max-width: 320px;
  background: #fff;
  border-radius: 14px;
  padding: 20px 18px 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
}

.wa-confirm-title {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  color: #111b21;
}

.wa-confirm-desc {
  margin: 10px 0 18px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--wa-meta);
}

.wa-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.wa-confirm-btn {
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  background: #f0f2f5;
  color: #111b21;
}

.wa-confirm-btn.wa-confirm-danger {
  background: #e53935;
  color: #fff;
}

.wa-confirm-btn:hover {
  filter: brightness(0.97);
}

.wa-title {
  font-weight: 600;
  font-size: 15.5px;
  letter-spacing: 0.01em;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wa-status {
  font-size: 12.5px;
  opacity: 0.88;
  margin-top: 1px;
}

.wa-thread {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scroll-padding-bottom: 16px;
  padding: 10px 8px 20px;
  background: #e5ddd5;
}

.wa-scroll-anchor {
  width: 100%;
  height: 1px;
  flex-shrink: 0;
  pointer-events: none;
  visibility: hidden;
}

.wa-day {
  display: flex;
  justify-content: center;
  margin: 6px 0 12px;
}

.wa-day span {
  background: #e1f2fa;
  color: #51656f;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 8px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08);
}

.wa-row {
  display: flex;
  margin: 3px 0 4px;
  animation: wa-in 0.18s ease-out;
}

@keyframes wa-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.wa-row.bot {
  justify-content: flex-start;
}

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

.wa-cluster {
  max-width: 86%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.wa-bubble {
  position: relative;
  padding: 7px 9px 5px 10px;
  border-radius: 8px;
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-size: 14.4px;
  line-height: 1.38;
}

.wa-bubble code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.92em;
}

.wa-bubble strong {
  font-weight: 700;
}

.wa-bubble em {
  font-style: italic;
}

.wa-bubble s {
  text-decoration: line-through;
}

.wa-row.bot .wa-bubble {
  background: var(--wa-bubble-in);
  border-top-left-radius: 0;
}

.wa-row.bot .wa-bubble.code {
  word-break: break-all;
  font-family: ui-monospace, Consolas, "Courier New", monospace;
  font-size: 13px;
  user-select: all;
  -webkit-user-select: all;
}

.wa-row.user .wa-bubble {
  background: var(--wa-bubble-out);
  border-top-right-radius: 0;
}

.wa-row.bot .wa-bubble::before,
.wa-row.user .wa-bubble::before {
  content: "";
  position: absolute;
  top: 0;
  width: 10px;
  height: 10px;
}

.wa-row.bot .wa-bubble::before {
  left: -7px;
  background: radial-gradient(circle at 0 10px, transparent 7px, #fff 7.2px);
}

.wa-row.user .wa-bubble::before {
  right: -7px;
  background: radial-gradient(circle at 10px 10px, transparent 7px, var(--wa-bubble-out) 7.2px);
}

.wa-time {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  float: right;
  margin: 4px 0 0 10px;
  font-size: 11px;
  color: var(--wa-meta);
  line-height: 1;
}

.wa-ticks {
  color: #53bdeb;
  font-size: 13px;
  letter-spacing: -1px;
}

.wa-bubble a.wa-inline-link {
  color: var(--wa-link);
  text-decoration: underline;
  word-break: break-all;
}

.wa-bubble img {
  display: block;
  max-width: min(220px, 100%);
  height: auto;
  border-radius: 6px;
  margin: 2px 0 6px;
}

.wa-actions {
  margin-top: 2px;
  background: #fff;
  border-radius: 0 0 8px 8px;
  overflow: hidden;
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
  border-top: 1px solid #f0f2f5;
}

.wa-cluster .wa-bubble + .wa-actions {
  border-radius: 0 0 8px 8px;
}

.wa-chip,
.wa-list-open,
.wa-cta {
  display: block;
  width: 100%;
  min-height: 44px;
  border: none;
  border-bottom: 1px solid #f0f2f5;
  background: #fff;
  color: var(--wa-link);
  padding: 12px;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  text-decoration: none;
}

.wa-chip:last-child,
.wa-list-open:last-child,
.wa-cta:last-child {
  border-bottom: none;
}

.wa-chip:active,
.wa-list-open:active,
.wa-cta:active,
.wa-list-row:active {
  background: #f5f6f6;
}

.wa-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
  padding: 6px 8px max(10px, env(safe-area-inset-bottom, 0px));
  background: var(--wa-composer);
}

.wa-input-wrap {
  flex: 1;
  background: #fff;
  border-radius: 24px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08);
}

.wa-input {
  width: 100%;
  border: none;
  border-radius: 24px;
  padding: 11px 16px;
  font-size: 15px;
  outline: none;
  background: transparent;
}

.wa-send {
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 50%;
  background: var(--wa-send);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22);
}

.wa-send:disabled {
  opacity: 0.45;
  cursor: default;
}

.wa-typing {
  display: none;
}

.wa-typing-bubble {
  min-width: 56px;
  padding: 12px 14px 10px;
}

.wa-dots {
  display: flex;
  gap: 4px;
  align-items: center;
  height: 14px;
}

.wa-dots i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9aa3a8;
  animation: wa-dot 1.1s infinite ease-in-out;
}

.wa-dots i:nth-child(2) {
  animation-delay: 0.15s;
}

.wa-dots i:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes wa-dot {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.45;
  }
  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

.wa-list-sheet {
  position: absolute;
  inset: 0;
  background: rgba(11, 20, 26, 0.45);
  display: none;
  align-items: flex-end;
  z-index: 40;
}

.wa-list-sheet:not([hidden]) {
  display: flex;
}

.wa-list-panel {
  width: 100%;
  max-height: 72%;
  background: #fff;
  border-radius: 16px 16px 0 0;
  overflow: auto;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.18);
}

.wa-list-grab {
  width: 36px;
  height: 4px;
  border-radius: 4px;
  background: #d1d7db;
  margin: 8px auto 0;
}

.wa-list-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px 10px;
  font-weight: 600;
  color: #111b21;
  border-bottom: 1px solid #f0f2f5;
}

.wa-list-close {
  border: none;
  background: transparent;
  color: var(--wa-teal);
  font-weight: 600;
  cursor: pointer;
}

.wa-list-row {
  display: block;
  width: 100%;
  min-height: 44px;
  text-align: left;
  border: none;
  border-bottom: 1px solid #f0f2f5;
  background: #fff;
  padding: 13px 16px;
  cursor: pointer;
}

.wa-list-row strong {
  display: block;
  font-size: 15px;
  color: #111b21;
  font-weight: 600;
}

.wa-list-row span {
  display: block;
  margin-top: 3px;
  font-size: 13px;
  color: var(--wa-meta);
  white-space: pre-wrap;
}

@media (max-width: 719px), (max-height: 540px) {
  .wa-shell {
    position: fixed;
    top: var(--wa-vvt, 0px);
    left: 0;
    width: 100%;
    height: var(--wa-vvh, 100dvh);
    padding: 0;
    align-items: stretch;
  }

  .wa-app {
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    box-shadow: none;
  }
}

@media (min-width: 720px) and (min-height: 541px) {
  .wa-shell {
    position: relative;
    height: 100%;
    align-items: center;
    padding: max(24px, env(safe-area-inset-top, 0px)) max(24px, env(safe-area-inset-right, 0px))
      max(24px, env(safe-area-inset-bottom, 0px)) max(24px, env(safe-area-inset-left, 0px));
  }

  .wa-app {
    height: min(860px, calc(var(--wa-vvh, 100dvh) - 48px));
    max-height: 100%;
    border-radius: 16px;
  }

  html.embedded .wa-shell {
    padding: 0;
  }

  html.embedded .wa-app {
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }
}

@media (max-width: 360px) {
  .wa-title {
    font-size: 14px;
  }

  .wa-cluster {
    max-width: 92%;
  }

  .wa-header {
    gap: 8px;
    padding-left: 10px;
    padding-right: 8px;
  }
}

@media (max-height: 500px) {
  .wa-header {
    min-height: 48px;
    padding-top: max(6px, env(safe-area-inset-top, 0px));
    padding-bottom: 6px;
  }

  .wa-title {
    font-size: 14px;
  }

  .wa-composer {
    padding-top: 4px;
    padding-bottom: max(6px, env(safe-area-inset-bottom, 0px));
  }

  .wa-send {
    width: 44px;
    height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .wa-row {
    animation: none;
  }

  .wa-dots i {
    animation: none;
  }
}

.wa-header-action:focus-visible,
.wa-list-close:focus-visible,
.wa-chip:focus-visible,
.wa-list-open:focus-visible,
.wa-cta:focus-visible,
.wa-list-row:focus-visible,
.wa-confirm-btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.wa-send:focus-visible,
.wa-input:focus-visible {
  outline: 2px solid var(--wa-header);
  outline-offset: 2px;
}

/* Modo embed (iframe / widget) */
body.wa-embed,
body.wa-embed html {
  background: #e5ddd5;
}

body.wa-embed .wa-shell {
  padding: 0;
  min-height: 100dvh;
}

body.wa-embed .wa-app {
  max-width: none;
  width: 100%;
  height: 100dvh;
  border-radius: 0;
  box-shadow: none;
}

body.wa-embed .wa-header {
  padding-right: 6px;
}

.wa-embed-close {
  margin-left: 0;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.wa-embed-close:not([hidden]) {
  display: grid;
}

.wa-embed-close:active {
  background: rgba(255, 255, 255, 0.22);
}

.wa-unavailable {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 24px;
  text-align: center;
  color: #475569;
  font: 600 15px/1.5 system-ui, sans-serif;
  background: #f8fafc;
}
