:root {
  --wa-green: #075E54;
  --wa-light: #DCF8C6;
  --wa-bg: #ECE5DD;
  --ink: #111;
  --muted: #667;
  --card: #fff;
  --danger: #c0392b;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--wa-bg);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}
.hidden { display: none !important; }

#topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  background: var(--wa-green); color: #fff;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
}
#title-wrap { flex: 1; min-width: 0; }
#title { margin: 0; font-size: 19px; }
#subtitle { font-size: 13px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  font-size: 24px; background: none; border: none; color: #fff;
  min-width: 48px; min-height: 48px; cursor: pointer;
}
.pill-btn {
  background: rgba(255,255,255,.18); color: #fff;
  border: 1px solid rgba(255,255,255,.5); border-radius: 999px;
  font-size: 15px; padding: 10px 16px; min-height: 44px; cursor: pointer;
}
.pill-btn.resumed { background: #fff; color: var(--wa-green); font-weight: 600; }

main { max-width: 720px; margin: 0 auto; }

/* Conversation list */
.conv {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); padding: 14px 16px;
  border-bottom: 1px solid #ddd; cursor: pointer;
  min-height: 72px;
}
.conv:active { background: #f2f2f2; }
.avatar {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--wa-green); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 600; flex-shrink: 0;
}
.conv-body { flex: 1; min-width: 0; }
.conv-name { font-weight: 600; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.conv-preview { color: var(--muted); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.conv-time { font-size: 12px; color: var(--muted); flex-shrink: 0; }
.badge {
  font-size: 12px; font-weight: 700; border-radius: 999px;
  padding: 2px 8px; white-space: nowrap;
}
.badge.unread { background: #25D366; color: #fff; min-width: 24px; text-align: center; }
.badge.paused { background: #f39c12; color: #fff; }
.empty { text-align: center; color: var(--muted); padding: 60px 20px; font-size: 16px; line-height: 1.6; }

/* Thread */
#msg-list { padding: 12px 10px 90px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 85%; padding: 10px 12px; border-radius: 10px; font-size: 16px; line-height: 1.45; overflow-wrap: break-word; }
.msg.in { background: #fff; align-self: flex-start; border-top-left-radius: 2px; }
.msg.out { background: var(--wa-light); align-self: flex-end; border-top-right-radius: 2px; }
.msg .meta { font-size: 11px; color: var(--muted); margin-top: 4px; text-align: right; }
.msg img.thumb { max-width: 100%; border-radius: 8px; display: block; margin-bottom: 6px; }
.paused-banner {
  background: #fef3cd; color: #7a5b00; text-align: center;
  font-size: 14px; font-weight: 600; padding: 10px;
  position: sticky; top: 0; z-index: 5;
}

/* Composer */
#composer {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; gap: 8px; align-items: flex-end;
  background: #f0f0f0; padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  max-width: 720px; margin: 0 auto;
}
#reply-box {
  flex: 1; font-size: 17px; padding: 12px 14px;
  border: 1px solid #ccc; border-radius: 24px; resize: none;
  max-height: 120px; font-family: inherit;
}
#send-btn {
  width: 52px; height: 52px; border-radius: 50%; border: none;
  background: var(--wa-green); color: #fff; font-size: 22px; cursor: pointer;
  flex-shrink: 0;
}
#send-btn:disabled { opacity: .5; }

#toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
  background: #323232; color: #fff; padding: 12px 20px; border-radius: 8px;
  font-size: 15px; z-index: 50; max-width: 90%;
}
