:root {
  --wa-header:   #075E54;   /* verde-petróleo do topo */
  --wa-teal:     #128C7E;
  --wa-accent:   #00A884;   /* verde do botão enviar */
  --wa-bg:       #ECE5DD;   /* bege do fundo do chat */
  --wa-out:      #DCF8C6;   /* balão enviado */
  --wa-in:       #FFFFFF;   /* balão recebido */
  --wa-encrypt:  #FDF6CC;   /* pílula de criptografia */
  --wa-tick:     #53BDEB;   /* tique azul */
  --wa-meta:     #667781;   /* hora/cinza */
  --wa-text:     #111B21;
  --wa-sub:      #54656F;
  --line:        #d9d2ca;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  color: var(--wa-text);
  -webkit-font-smoothing: antialiased;
  background: #d0d5d4;
}

.app { height: 100%; display: grid; place-items: center; }

.screen {
  width: 100%;
  max-width: 460px;
  height: min(820px, 100vh);
  background: var(--wa-bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 18px 50px -20px rgba(0,0,0,.4);
}
.hidden { display: none !important; }

/* ===================== LOBBY ===================== */
.lobby {
  background:
    linear-gradient(180deg, var(--wa-header) 0 220px, var(--wa-bg) 220px);
  padding: 0;
  justify-content: flex-start;
}
.lobby__hero { padding: 40px 28px 28px; color: #fff; text-align: center; }
.lobby__badge {
  width: 70px; height: 70px; margin: 0 auto 16px;
  display: grid; place-items: center;
  background: rgba(255,255,255,.15); border-radius: 50%; color: #fff;
}
.lobby__title { font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
.lobby__sub { margin-top: 8px; font-size: 14px; line-height: 1.5; color: rgba(255,255,255,.85); }

.lobby__card {
  margin: -8px 20px 0; background: #fff; border-radius: 14px;
  padding: 22px 20px; box-shadow: 0 8px 24px -12px rgba(0,0,0,.3);
}
.field { display: block; }
.field__label {
  display: block; font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--wa-teal); margin-bottom: 8px;
}
.field__input {
  width: 100%; padding: 12px 14px; font-size: 15px;
  border: 1px solid var(--line); border-radius: 10px; outline: none;
  background: #fff; color: var(--wa-text); transition: border-color .15s, box-shadow .15s;
}
.field__input:focus { border-color: var(--wa-accent); box-shadow: 0 0 0 3px rgba(0,168,132,.14); }

.lobby__actions { display: flex; gap: 10px; margin-top: 16px; }
.btn {
  flex: 1; font: inherit; font-size: 14px; font-weight: 600;
  padding: 12px 16px; border-radius: 24px; border: 1px solid transparent;
  cursor: pointer; transition: transform .05s, background .15s, border-color .15s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--primary { background: var(--wa-accent); color: #fff; }
.btn--primary:hover:not(:disabled) { background: #019e7c; }
.btn--ghost { background: #fff; color: var(--wa-teal); border-color: var(--wa-teal); }
.btn--ghost:hover { background: #f2faf8; }

.btn--share {
  width: 100%; margin-top: 10px; font-size: 13px;
  color: var(--wa-teal); border-color: var(--wa-teal); background: #fff;
}
.btn--share:hover { background: #f2faf8; }
.share-feedback {
  margin-top: 8px; font-size: 13px; color: var(--wa-teal);
  text-align: center; animation: pop .14s ease-out;
}
.status { margin-top: 14px; min-height: 18px; font-size: 13px; color: #b23b3b; text-align: center; }

.note { margin: 20px; font-size: 13px; color: var(--wa-sub); }
.note summary { cursor: pointer; color: var(--wa-teal); font-weight: 600; }
.note p { margin-top: 10px; line-height: 1.55; }
.note strong { color: #b23b3b; }

/* ===================== CHAT ===================== */
.wa-header {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 10px; background: var(--wa-header); color: #fff;
  flex-shrink: 0;
}
.wa-icon {
  display: grid; place-items: center; color: #fff; background: none; border: none;
  width: 38px; height: 38px; border-radius: 50%; cursor: pointer;
}
.wa-icon:hover { background: rgba(255,255,255,.12); }
.wa-back { margin-right: -2px; }
.wa-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  background: rgba(255,255,255,.22); color: #cfeee7;
  display: grid; place-items: center;
}
.wa-peer { flex: 1; min-width: 0; line-height: 1.25; padding-left: 4px; }
.wa-peer__name {
  display: block; font-size: 16px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.wa-peer__status { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: rgba(255,255,255,.8); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: transparent; }
.dot--on { background: #6ee7b7; }
.dot--wait { background: #ffd479; }
.dot--off { background: #ff9b9b; }
.wa-header__actions { display: flex; }

.wa-chat {
  flex: 1; overflow-y: auto; padding: 12px 16px 18px;
  background-color: var(--wa-bg);
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20width%3D'130'%20height%3D'130'%3E%3Cg%20fill%3D'none'%20stroke%3D'%231f7a6a'%20stroke-opacity%3D'0.05'%20stroke-width%3D'2'%3E%3Cg%20transform%3D'translate(20%2C22)'%3E%3Crect%20x%3D'0'%20y%3D'13'%20width%3D'22'%20height%3D'16'%20rx%3D'3'%2F%3E%3Cpath%20d%3D'M4%2013%20v-4%20a7%207%200%200%201%2014%200%20v4'%2F%3E%3C%2Fg%3E%3Cg%20transform%3D'translate(82%2C80)'%3E%3Crect%20x%3D'0'%20y%3D'13'%20width%3D'22'%20height%3D'16'%20rx%3D'3'%2F%3E%3Cpath%20d%3D'M4%2013%20v-4%20a7%207%200%200%201%2014%200%20v4'%2F%3E%3C%2Fg%3E%3C%2Fg%3E%3C%2Fsvg%3E");
  display: flex; flex-direction: column; gap: 4px;
}

.wa-encrypt {
  align-self: center; max-width: 88%; margin: 6px auto 12px;
  background: var(--wa-encrypt); color: #5b5430;
  font-size: 12.5px; line-height: 1.5; text-align: center;
  padding: 8px 14px; border-radius: 8px;
  box-shadow: 0 1px 1px rgba(0,0,0,.08);
}
.wa-encrypt svg { vertical-align: -1px; margin-right: 3px; opacity: .8; }
.wa-safety { font-weight: 700; letter-spacing: .02em; color: #4a4422; white-space: nowrap; }

.wa-messages { display: flex; flex-direction: column; gap: 4px; }

.msg {
  position: relative; max-width: 78%;
  padding: 6px 9px 8px 9px; border-radius: 8px;
  font-size: 14.6px; line-height: 1.4; word-wrap: break-word; white-space: pre-wrap;
  box-shadow: 0 1px .5px rgba(0,0,0,.13);
  animation: pop .14s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

.msg--me   { align-self: flex-end; background: var(--wa-out); border-top-right-radius: 2px; }
.msg--them { align-self: flex-start; background: var(--wa-in); border-top-left-radius: 2px; }

.msg__text { display: inline; }
.msg__meta {
  float: right; margin: 6px 0 -2px 8px;
  font-size: 11px; color: var(--wa-meta);
  display: inline-flex; align-items: center; gap: 3px; user-select: none;
}
.msg__ticks { color: var(--wa-tick); font-size: 12px; letter-spacing: -2px; }

.msg--sys {
  align-self: center; max-width: 90%; text-align: center;
  background: rgba(225,245,254,.92); color: #315b6b;
  font-size: 12.5px; padding: 5px 12px; border-radius: 8px;
  box-shadow: 0 1px .5px rgba(0,0,0,.1); margin: 4px auto;
}

/* ===================== COMPOSER ===================== */
.wa-footer { flex-shrink: 0; }

.emoji-picker {
  background: #fff; border-top: 1px solid var(--line);
  padding: 6px 8px; display: flex; flex-wrap: wrap; gap: 0;
  max-height: 164px; overflow-y: auto;
}
.emoji-picker button {
  font-size: 22px; background: none; border: none; padding: 3px 5px;
  cursor: pointer; border-radius: 6px; line-height: 1.3;
}
.emoji-picker button:hover { background: #f0f2f5; }

.wa-composer {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 8px 10px; background: #F0F2F5;
}
.wa-inputwrap {
  flex: 1; display: flex; align-items: center; gap: 4px;
  background: #fff; border-radius: 24px; padding: 4px 6px;
}
.wa-emoji, .wa-clip {
  display: grid; place-items: center; color: #54656F; padding: 6px;
  border: none; background: none; cursor: pointer; flex-shrink: 0; border-radius: 50%;
}
.wa-emoji:hover:not(:disabled), .wa-clip:hover:not(:disabled) { color: var(--wa-teal); background: #f0f2f5; }
.wa-emoji:disabled, .wa-clip:disabled { opacity: .4; cursor: not-allowed; }
.wa-input {
  flex: 1; border: none; outline: none; background: none;
  font: inherit; font-size: 15px; padding: 8px 4px; color: var(--wa-text);
}
.wa-input::placeholder { color: #8696a0; }
.wa-input:disabled { color: #9aa6ac; }

.wa-send, .wa-mic {
  width: 46px; height: 46px; flex-shrink: 0; border: none; cursor: pointer;
  border-radius: 50%; background: var(--wa-accent); color: #fff;
  display: grid; place-items: center; transition: background .15s, transform .05s;
}
.wa-send:hover:not(:disabled), .wa-mic:hover:not(:disabled) { background: #019e7c; }
.wa-send:active:not(:disabled), .wa-mic:active:not(:disabled) { transform: scale(.94); }
.wa-send:disabled, .wa-mic:disabled { background: #8fb9ae; cursor: not-allowed; }
.wa-mic.recording {
  background: #e53935;
  animation: pulse-rec 1s ease-in-out infinite;
}
@keyframes pulse-rec {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(229,57,53,.5); }
  50%       { transform: scale(1.07); box-shadow: 0 0 0 8px rgba(229,57,53,0); }
}

.msg--file, .msg--audio { max-width: 75%; padding: 6px 9px 24px; }
.msg--audio audio { width: 220px; max-width: 100%; height: 36px; display: block; margin-bottom: 4px; }
.msg--file { max-width: 75%; padding: 6px 9px 24px; }
.msg__img {
  max-width: 100%; max-height: 220px; display: block;
  border-radius: 6px; cursor: pointer;
}
.msg__file-link {
  display: block; color: var(--wa-teal); text-decoration: none;
  font-size: 14px; word-break: break-all; line-height: 1.4;
}
.msg__file-link:hover { text-decoration: underline; }
.msg__file-link small { color: var(--wa-meta); }

@media (max-width: 480px) {
  .screen { max-width: 100%; height: 100vh; box-shadow: none; }
}
