:root,
[data-theme="light"] {
  --bg: #f4faf6;
  --bg-rail: #f4faf6;
  --bg-panel: #ffffff;
  --bg-header: #ffffff;
  --bg-search: #eef6f1;
  --bg-input: #ffffff;
  --bg-hover: #eef6f1;
  --bg-active: #dcfce7;
  --bg-dropdown: #ffffff;
  --incoming: #ffffff;
  --outgoing: #dcfce7;
  --outgoing-tail: #dcfce7;
  --accent: #22c55e;
  --accent-2: #16a34a;
  --unread: #22c55e;
  --text: #102117;
  --text-sec: #5f6f66;
  --icon: #16a34a;
  --border: #e3eee6;
  --danger: #ef4444;
  --tick: #94a3b8;
  --tick-read: #0ea5e9;
  --shadow: 0 12px 32px rgba(16,163,74,.08);
  --composer: #ffffff;
  --chip: #ffffff;
  --modal: #ffffff;
  --quote-in: #22c55e;
  --quote-out: #16a34a;
  --wallpaper: #f3faf6;
  --login-top: #22c55e;
  --focus: rgba(34,197,94,.28);
  --badge-text: #ffffff;
  --rail-active: #16a34a;
  --sys-bg: #ffffff;
}

[data-theme="dark"] {
  --bg: #071512;
  --bg-rail: #071512;
  --bg-panel: #0c1c18;
  --bg-header: #0c1c18;
  --bg-search: #163029;
  --bg-input: #163029;
  --bg-hover: #163029;
  --bg-active: #1a3a32;
  --bg-dropdown: #10211c;
  --incoming: #1a2e28;
  --outgoing: #0f766e;
  --outgoing-tail: #0f766e;
  --accent: #4ade80;
  --accent-2: #22c55e;
  --unread: #34d399;
  --text: #f4fbf8;
  --text-sec: #8ba89e;
  --icon: #a7c4bb;
  --border: #1e332c;
  --danger: #f87171;
  --tick: #8ba89e;
  --tick-read: #38bdf8;
  --shadow: 0 8px 24px rgba(0,0,0,.28);
  --composer: #1a2e28;
  --chip: #0c1c18;
  --modal: #10211c;
  --quote-in: #34d399;
  --quote-out: #34d399;
  --wallpaper: #071512;
  --login-top: #22c55e;
  --focus: rgba(52,211,153,.35);
  --badge-text: #06231c;
  --rail-active: #fff;
  --sys-bg: #0c1c18;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; height: 100dvh; width: 100%; }
body.login-body { overflow: auto; background: #f3faf6; position: static; height: auto; min-height: 100dvh; }
body {
  font-family: Outfit, "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  font-size: 15px;
  letter-spacing: -0.01em;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}
body:not(.login-body) {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
}
button, input, textarea { font-family: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: var(--accent); }
img { max-width: 100%; display: block; }
svg { display: block; }
.wa-ico {
  width: 22px; height: 22px; display: inline-block; vertical-align: middle;
  overflow: visible; flex-shrink: 0;
}
.icon-btn .wa-ico, .rail-btn .wa-ico, .comp-ico .wa-ico, .cam-x .wa-ico, .mic-fab .wa-ico { width: 22px; height: 22px; }
.tab-ico > .wa-ico { width: 24px; height: 24px; }
.wa-fab .wa-ico { width: 24px; height: 24px; }
.attach-item .fab .wa-ico, .call-ctl .wa-ico, .call-hang .wa-ico, .call-accept .wa-ico { width: 22px; height: 22px; }
.ctx-ico .wa-ico { width: 16px; height: 16px; }
.cam-fab .wa-ico { width: 16px; height: 16px; }
.wa-empty-icon .wa-ico, .empty-chats-ico .wa-ico { width: 36px; height: 36px; }
.perm-logo .wa-ico { width: 32px; height: 32px; }
.perm-list .wa-ico { width: 18px; height: 18px; color: #16a34a; }
.search-box .wa-ico { width: 18px; height: 18px; }
.ci-type .wa-ico, .quote-prev .wa-ico { width: 14px; height: 14px; }
.ticks { width: 16px; height: 16px; }
.main-empty .empty-mark { width: 72px; height: 72px; color: #22c55e; }
.wa-av-circle .wa-ico { width: 36px; height: 36px; color: #22c55e; }
.wa-country .wa-ico { width: 14px; height: 14px; color: #16a34a; }
.group-ph .wa-ico { width: 28px; height: 28px; }
.contact-ava .wa-ico { width: 20px; height: 20px; color: #16a34a; }
.msg-reply-btn .wa-ico { width: 16px; height: 16px; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: #374045; border-radius: 10px; }
[data-theme="light"] ::-webkit-scrollbar-thumb { background: #ccc; }

/* ===== LOGIN (same layout, qrxmeet color + type) ===== */
.login-page {
  min-height: 100%;
  background: #f3faf6;
  overflow: auto;
  position: relative;
}
.login-page::before {
  content: "";
  position: absolute; left: 0; right: 0; top: 0; height: 222px;
  background: linear-gradient(135deg, #22c55e, #16a34a);
}
.login-wrap {
  position: relative;
  max-width: 920px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}
.login-brand {
  display: flex; align-items: center; gap: 12px;
  color: #fff; font-weight: 700; font-size: 15px; letter-spacing: .08em;
  margin-bottom: 36px;
}
.login-brand svg { width: 39px; height: 39px; }
.wa-bar { display: none; }
.login-card {
  background: #fff;
  color: #102117;
  border-radius: 24px;
  border: 1px solid rgba(34,197,94,.12);
  box-shadow: 0 18px 50px rgba(16,33,23,.08);
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  min-height: 420px;
  overflow: hidden;
}
.login-left { padding: 48px 48px 32px; }
.login-left h1 {
  font-size: 26px; font-weight: 700; letter-spacing: -.5px;
  margin-bottom: 24px; color: #102117; line-height: 1.25;
}
.wa-web-intro { margin-bottom: 28px; }
.login-steps { list-style: decimal; padding-left: 20px; color: #5f6f66; line-height: 1.85; font-size: 15px; font-weight: 500; }
.login-left form, .login-alt { margin-top: 20px; max-width: 360px; }
.wa-copy { color: #5f6f66; font-size: 14px; line-height: 1.55; margin-bottom: 22px; max-width: 420px; font-weight: 500; }
.wa-country {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 220px; max-width: 100%; margin: 0 auto 8px;
  padding: 8px 4px 10px; border-bottom: 2px solid #22c55e;
  color: #102117; font-size: 16px; font-weight: 600;
}
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: #5f6f66; margin-bottom: 4px; font-weight: 600; }
.field input {
  width: 100%; height: 42px; border: 0; border-bottom: 2px solid #22c55e;
  outline: none; font-size: 16px; padding: 0 4px; background: transparent; color: #102117;
}
.phone-row {
  display: flex; align-items: center; gap: 10px;
  max-width: 280px; margin: 0 auto;
  border-bottom: 2px solid #22c55e;
}
.phone-row input { border: 0; border-bottom: 0; flex: 1; min-width: 0; height: 42px; font-size: 16px; outline: none; background: transparent; color: #102117; }
.phone-cc { font-size: 16px; color: #102117; font-weight: 600; padding-bottom: 2px; }
.otp-sent { color: #16a34a; font-size: 14px; margin: 8px 0 12px; }
.otp-boxes { display: flex; gap: 10px; justify-content: center; margin: 8px 0 12px; }
.otp-boxes input {
  width: 36px; height: 44px; text-align: center; font-size: 22px; font-weight: 700; color: #102117;
  border: 0; border-bottom: 2px solid #22c55e; outline: none; background: transparent;
}
.wa-link { color: #16a34a; font-weight: 600; font-size: 14px; background: none; padding: 0; }
.wa-resend { color: #5f6f66; font-size: 13px; margin-top: 18px; }
.wa-av-circle {
  width: 96px; height: 96px; border-radius: 50%; background: #eef6f1;
  display: grid; place-items: center; margin: 8px auto 18px;
}
.wa-av-circle svg { fill: #22c55e; }
.wa-name-field { max-width: 320px; margin: 0 auto 8px; }
.qrx-mark { margin-bottom: 8px; }
.qrx-mark svg { width: 72px; height: 72px; }
.btn-green {
  background: #22c55e; color: #fff; height: 42px; padding: 0 24px;
  border-radius: 24px; font-weight: 700; font-size: 14px; letter-spacing: .2px; margin-top: 8px;
}
.btn-green:hover { background: #16a34a; }
.btn-green:disabled, .demo-btn:disabled { opacity: .55; cursor: default; }
.wa-next { display: block; margin: 28px auto 0; min-width: 88px; }
.demo-btn { margin-left: 8px; background: transparent; color: #16a34a; height: 40px; padding: 0 12px; font-weight: 600; }
.login-err { color: #ea4335; font-size: 13px; min-height: 18px; margin-top: 10px; text-align: center; font-weight: 600; }
.login-right {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px; background: #f8fbf9;
}
.qr-box {
  width: 264px; height: 264px; background: #fff; padding: 10px;
  border: 1px solid #e3eee6; border-radius: 16px; position: relative;
}
.qr-box canvas { width: 100%; height: 100%; }
.qr-logo {
  position: absolute; inset: 0; margin: auto; width: 46px; height: 46px;
  background: #fff; border-radius: 10px; display: grid; place-items: center;
}
.qr-hint { margin-top: 16px; color: #5f6f66; font-size: 13px; text-align: center; font-weight: 500; }
.login-tabs { display: flex; gap: 18px; margin-bottom: 8px; }
.login-tabs button { color: #5f6f66; font-size: 14px; padding-bottom: 6px; border-bottom: 2px solid transparent; }
.login-tabs button.on { color: #16a34a; border-color: #22c55e; font-weight: 600; }
.hidden { display: none !important; }

.wa-confirm {
  position: fixed; inset: 0; background: rgba(16,33,23,.45);
  display: grid; place-items: center; z-index: 50; padding: 24px;
}
.wa-confirm[hidden] { display: none !important; }
.wa-confirm-card {
  background: #fff; color: #102117; width: 100%; max-width: 360px;
  padding: 22px 22px 12px; border-radius: 16px;
  border: 1px solid rgba(34,197,94,.12);
  box-shadow: 0 17px 50px rgba(16,33,23,.16);
}
.wa-confirm-kicker { color: #5f6f66; font-size: 14px; font-weight: 500; }
.wa-confirm-num { font-size: 18px; font-weight: 700; margin: 10px 0 12px; }
.wa-confirm-q { color: #5f6f66; font-size: 14px; line-height: 1.45; }
.wa-confirm-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.wa-confirm-actions button {
  color: #16a34a; font-weight: 700; letter-spacing: .4px; font-size: 13px;
  padding: 12px 14px;
}

/* ===== APP SHELL ===== */
.app {
  height: 100%;
  width: 100%;
  display: flex;
  background:
    radial-gradient(520px 280px at 12% -10%, rgba(34,197,94,.10), transparent 60%),
    radial-gradient(420px 280px at 100% 0%, rgba(22,163,74,.08), transparent 55%),
    #f4faf6;
  overflow: hidden;
  min-height: 0;
}
.rail { display: none; }
.sidebar {
  width: 100%;
  max-width: none;
  min-width: 0;
  flex: 1 1 auto;
  background: transparent;
  display: flex;
  flex-direction: column;
  position: relative;
  min-height: 0;
}
.panel {
  background: transparent;
}
.side-head {
  min-height: 64px; padding: 14px 14px 6px 18px;
  display: flex; align-items: center; justify-content: space-between;
  background: transparent;
}
.brand-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 12px;
  background: linear-gradient(145deg, #4ade80, #16a34a);
  color: #fff; font-weight: 800; font-size: 18px;
  display: grid; place-items: center;
  box-shadow: 0 8px 18px rgba(22,163,74,.28);
  flex-shrink: 0;
}
.side-head h2 { font-size: 22px; font-weight: 800; letter-spacing: -.6px; color: #102117; }
.side-actions { display: flex; gap: 8px; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 14px; color: #16a34a;
  display: grid; place-items: center;
  background: #f4faf6;
  border: 1px solid #e3eee6;
}
.icon-btn:hover { background: #dcfce7; }
.search-wrap { padding: 8px 16px 10px; }
.search-box {
  background: #fff;
  border: 1px solid #e3eee6;
  border-radius: 16px;
  height: 48px;
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px;
  color: #16a34a;
  box-shadow: 0 6px 20px rgba(16, 33, 23, .04);
}
.search-box input {
  flex: 1; background: none; border: 0; outline: none;
  color: var(--text); font-size: 15px; font-weight: 500;
}
.search-box input::placeholder { color: #94a3b8; font-weight: 500; }
.filters { display: flex; gap: 8px; padding: 0 16px 12px; overflow-x: auto; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.chip {
  border: 0;
  background: #fff;
  color: #64748b;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 1px 0 rgba(15,23,42,.04);
}
.chip.on {
  background: #dcfce7;
  color: #166534;
  border-color: #dcfce7;
  font-weight: 700;
  box-shadow: none;
}
[data-theme="dark"] .chip.on { background: #0a332c; color: #34d399; border-color: #0a332c; box-shadow: none; }

.chat-list { flex: 1; overflow: auto; scrollbar-width: none; padding: 0 10px 108px; }
.chat-list::-webkit-scrollbar { display: none; }
.archive-row {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 16px;
  margin: 0 6px 8px; border-radius: 16px;
  color: var(--text); font-size: 15px; font-weight: 600; cursor: pointer;
  background: #fff;
}
.archive-row:hover { background: var(--bg-hover); }
.archive-ic { font-size: 18px; opacity: .85; width: 28px; text-align: center; color: #16a34a; }
.chat-item {
  display: flex; gap: 14px; align-items: center;
  padding: 12px 14px;
  margin: 0 6px 6px;
  border-radius: 18px;
  cursor: pointer; position: relative;
  background: #fff;
}
.chat-item:hover { background: #f0fdf7; }
.chat-item.active { background: #ecfdf5; }
.chat-item.unread-row .ci-name { font-weight: 700; }
.chat-item.unread-row .ci-preview { color: var(--text); }
.ci-av { position: relative; flex-shrink: 0; }
.ci-av img, .av {
  width: 52px; height: 52px; border-radius: 18px; object-fit: cover;
}
.ci-body { flex: 1; min-width: 0; padding: 2px 0 4px; }
.ci-top, .ci-bot { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.ci-name { font-size: 16px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.ci-time { font-size: 12px; color: var(--text-sec); flex-shrink: 0; font-weight: 600; }
.chat-item.unread-row .ci-time { color: var(--unread); }
.ci-preview {
  font-size: 13.5px; color: var(--text-sec); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 4px;
  min-width: 0;
}
.ci-type { font-size: 13px; }
.ci-preview.typing { color: var(--accent); font-style: italic; }
.ci-meta { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.unread-badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--unread); color: #fff; font-size: 11px; font-weight: 700;
  display: grid; place-items: center;
}
.pin-ic, .mute-ic { color: var(--text-sec); }
.empty-chats {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 64px 28px; color: var(--text-sec);
}
.empty-chats-ico {
  width: 72px; height: 72px; border-radius: 22px;
  background: #dcfce7; color: #16a34a;
  display: grid; place-items: center; margin-bottom: 16px;
}
.empty-chats h3 { color: #102117; font-size: 20px; font-weight: 800; margin-bottom: 6px; letter-spacing: -.4px; }
.empty-chats p { max-width: 260px; line-height: 1.45; font-weight: 500; }

.tabbar {
  position: absolute;
  left: 12px; right: 12px; bottom: 12px;
  height: 68px;
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom, 0px));
  display: flex;
  background: #fff;
  border: 1px solid #e3eee6;
  border-radius: 24px;
  box-shadow: 0 16px 40px rgba(16, 33, 23, .08);
  z-index: 12;
}
.tab-btn {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: #94a3b8; font-size: 11px; font-weight: 650;
}
.tab-btn.active { color: #16a34a; }
.tab-ico {
  position: relative; width: 52px; height: 30px;
  display: grid; place-items: center; border-radius: 12px;
  overflow: visible;
}
.tab-ico svg { width: 22px; height: 22px; display: block; }
.tab-btn.active .tab-ico { background: #d1fae5; color: #16a34a; }
.tab-badge {
  position: absolute; top: -2px; right: 4px;
  min-width: 16px; height: 16px; padding: 0 5px; border-radius: 8px;
  background: #22c55e; color: #fff; font-size: 10px; font-weight: 700;
  display: grid; place-items: center; line-height: 1;
}
.tab-badge[hidden] { display: none !important; }
.tab-ico .dot {
  position: absolute; top: 1px; right: 10px; width: 9px; height: 9px;
  background: #22c55e; border-radius: 50%; border: 2px solid #fff;
  box-sizing: border-box;
}
[data-theme="light"] .tab-btn { color: #94a3b8; }
[data-theme="light"] .tab-btn.active { color: #16a34a; }
[data-theme="light"] .tab-btn.active .tab-ico { background: #dcfce7; color: #16a34a; }
[data-theme="light"] .tab-ico .dot { border-color: #fff; }
.wa-fab {
  position: absolute; right: 18px; bottom: 96px;
  width: 58px; height: 58px; border-radius: 18px;
  background: linear-gradient(135deg, #22c55e, #16a34a); color: #fff;
  display: grid; place-items: center;
  box-shadow: 0 12px 28px rgba(22,163,74,.38);
  z-index: 13;
}
.wa-fab:hover { filter: brightness(1.06); }
.wa-empty-tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 32px; color: var(--text-sec);
}
.wa-empty-icon { color: var(--icon); margin-bottom: 12px; opacity: .7; }
.wa-empty-tab h3 { color: var(--text); font-weight: 800; margin-bottom: 8px; letter-spacing: -.3px; }
.wa-empty-tab p { max-width: 320px; line-height: 1.45; }
.wa-start-btn {
  margin-top: 22px; height: 44px; padding: 0 22px; border-radius: 14px;
  background: #22c55e; color: #fff; font-weight: 700; font-size: 14px;
}

#backChat { display: none; }

/* conversation */
.main {
  flex: 1 1 auto; min-width: 0; min-height: 0;
  display: flex; flex-direction: column;
  background: var(--wallpaper);
  position: relative;
  overflow: hidden;
}
.main-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--bg-panel); color: var(--text-sec); text-align: center; padding: 40px;
  border-bottom: 6px solid var(--accent);
}
.main-empty h3 { color: var(--text); font-weight: 800; font-size: 28px; letter-spacing: -.6px; margin: 18px 0 10px; }
.main-empty p { max-width: 460px; line-height: 1.5; font-size: 14px; }
.conv { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }
.conv-head {
  height: 64px; background: #fff;
  display: flex; align-items: center; padding: 0 10px 0 8px;
  gap: 6px; flex-shrink: 0; z-index: 6;
  position: relative;
  border-bottom: 1px solid #e6f4ee;
}
.conv-head .icon-btn { color: var(--icon); }
.rejoin-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 12px 0;
  padding: 10px 14px;
  border: 0;
  border-radius: 12px;
  background: #dcfce7;
  color: #166534;
  width: calc(100% - 24px);
  cursor: pointer;
  font: inherit;
  text-align: left;
}
.rejoin-bar b { color: #15803d; }
.rejoin-bar.hidden { display: none; }
.ci-rejoin { color: #15803d; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.conv-head .av { width: 40px; height: 40px; cursor: pointer; margin-left: 2px; }
.conv-title { flex: 1; min-width: 0; cursor: pointer; padding-left: 4px; }
.conv-title h3 {
  font-size: 16px; font-weight: 700; letter-spacing: -.2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-title span { font-size: 12.5px; color: var(--text-sec); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-title span:empty { display: none; }
.conv-wall {
  flex: 1; overflow-x: hidden; overflow-y: auto; padding: 8px 8px 10px;
  background-color: #eef8f2;
  background-image: none;
  position: relative;
  z-index: 1;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
  border: 0;
  box-shadow: none;
}
.conv-wall::-webkit-scrollbar { display: none; width: 0; height: 0; }
.conv.attach-open .conv-wall::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(243, 250, 246, .35);
  z-index: 8;
}
[data-theme="light"] .conv-wall {
  background-color: #eef8f2;
  background-image: none;
}
[data-theme="dark"] .conv-wall {
  background-color: #071512;
  background-image: none;
}
.day-chip {
  display: flex; justify-content: center; margin: 12px 0;
}
.day-chip span {
  background: #182229; color: #8696a0;
  font-size: 12.5px; padding: 5px 12px; border-radius: 8px;
  box-shadow: var(--shadow); text-transform: none;
}
[data-theme="light"] .day-chip span {
  background: #ffffff;
  color: #5f6f66;
  border: 1px solid #e3eee6;
  border-radius: 999px;
  font-weight: 600;
}
.sys-msg { display: flex; justify-content: center; margin: 8px 0; }
.sys-msg span {
  background: var(--sys-bg); color: #ffd279; font-size: 12.5px;
  padding: 6px 12px; border-radius: 8px; box-shadow: var(--shadow); max-width: 80%; text-align: center;
}
[data-theme="light"] .sys-msg span { color: #54656f; }
.msg-row { display: flex; align-items: center; gap: 4px; margin: 2px 0; touch-action: pan-y; max-width: 100%; }
.msg-row.mine { justify-content: flex-end; }
.msg-row.theirs { justify-content: flex-start; }
.msg-row.swiping { transition: none; }
.msg-row.flash .bubble { box-shadow: 0 0 0 2px var(--accent); }
.msg-reply-btn {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  color: var(--icon); background: var(--bg-header);
  display: grid; place-items: center; opacity: 0;
  pointer-events: none;
}
.msg-row:hover .msg-reply-btn,
.msg-row.show-reply .msg-reply-btn {
  opacity: 1; pointer-events: auto;
}
@media (pointer: coarse) {
  .msg-row .msg-reply-btn { display: none; }
  .msg-row.show-reply .msg-reply-btn { display: grid; opacity: 1; pointer-events: auto; }
}
.msg-row.mine .msg-reply-btn { order: -1; }
.bubble {
  max-width: 78%;
  padding: 6px 8px 8px 9px;
  border-radius: 12px;
  position: relative;
  box-shadow: 0 1px 0.5px rgba(11,20,26,.13);
  word-wrap: break-word;
}
.msg-row.theirs .bubble { background: var(--incoming); border-radius: 0 12px 12px 12px; }
.msg-row.mine .bubble { background: var(--outgoing); border-radius: 12px 0 12px 12px; }
.bubble.tail-l::before, .bubble.tail-r::before {
  content: ""; position: absolute; top: 0; width: 8px; height: 13px;
}
.bubble.tail-l::before {
  left: -8px;
  background: var(--incoming);
  clip-path: polygon(100% 0, 0 0, 100% 100%);
}
.bubble.tail-r::before {
  right: -8px;
  background: var(--outgoing);
  clip-path: polygon(0 0, 100% 0, 0 100%);
}
.gname { font-size: 12.8px; font-weight: 500; color: #53bdeb; margin-bottom: 2px; }
.quote {
  display: flex; align-items: flex-start; gap: 8px;
  border-left: 4px solid var(--quote-in);
  background: rgba(22, 163, 74, .1);
  border-radius: 8px;
  padding: 6px 8px 6px 8px; margin: 0 0 6px; font-size: 13px; color: var(--text);
  cursor: pointer; overflow: visible;
  max-width: 100%;
}
.msg-row.mine .quote { border-left-color: var(--quote-out); }
.quote-main { flex: 1; min-width: 0; }
.quote b { color: var(--quote-in); display: block; font-weight: 500; font-size: 12.8px; }
.msg-row.mine .quote b { color: var(--quote-out); }
.quote-prev {
  display: block;
  white-space: normal;
  overflow: visible;
  line-height: 1.35;
  word-break: break-word;
}
.reply-bar .quote-prev {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.quote-thumb {
  width: 52px; height: 52px; border-radius: 4px; object-fit: cover; flex-shrink: 0;
  background: #0b141a;
}
.quote-thumb.is-vid { position: relative; width: 52px; height: 52px; overflow: hidden; border-radius: 4px; }
.quote-thumb.is-vid img { width: 100%; height: 100%; object-fit: cover; }
.quote-thumb.is-vid span {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: #fff; font-size: 12px; text-shadow: 0 1px 3px #000;
}
.msg-text { font-size: 14.6px; line-height: 20px; white-space: pre-wrap; color: var(--text); }
.msg-text a { color: #53bdeb; text-decoration: underline; }
.link-card {
  background: rgba(0,0,0,.18); border-radius: 8px; padding: 8px 10px; margin-bottom: 6px;
}
.link-card-host { font-size: 13.2px; color: var(--text); word-break: break-all; }
.link-card-url { font-size: 12.5px; margin-top: 4px; }
.link-card-url a { color: #53bdeb; text-decoration: none; word-break: break-all; }
.call-card {
  display: flex; align-items: center; gap: 10px;
  min-width: 170px; padding: 2px 2px 0 0; cursor: pointer;
}
.call-ico {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  background: rgba(255,255,255,.08);
  color: #8696a0; display: grid; place-items: center;
}
.call-ico.missed { color: #ea4335; }
.msg-row.mine .call-ico { background: rgba(0,0,0,.2); color: #e9edef; }
.call-card b { display: block; font-weight: 400; font-size: 15.2px; color: var(--text); }
.call-card small { display: block; color: var(--text-sec); font-size: 13px; margin-top: 1px; }
.msg-meta {
  float: right; margin: 4px 0 -4px 8px;
  font-size: 11px; color: var(--text-sec);
  display: flex; align-items: center; gap: 3px;
}
.ticks { width: 16px; height: 16px; }
.ticks.read { color: var(--tick-read); }
.ticks.delivered, .ticks.sent { color: var(--tick); }
.star-mini { font-size: 10px; opacity: .8; }
.reactions {
  position: absolute; bottom: -10px; left: 8px;
  background: var(--incoming); border-radius: 10px; padding: 1px 6px;
  font-size: 12px; box-shadow: var(--shadow); display: flex; gap: 2px;
}
.msg-row.mine .reactions { left: auto; right: 8px; }
.msg-row .bubble.img-bubble {
  padding: 0;
  max-width: min(280px, 78%);
  background: transparent;
  box-shadow: none;
}
.bubble.img-bubble.tail-l::before,
.bubble.img-bubble.tail-r::before { display: none; }
.msg-row.mine .bubble.img-bubble .media-wrap,
.msg-row.mine .bubble.img-bubble .media-img,
.msg-row.mine .bubble.img-bubble .vid-thumb { border-radius: 12px 0 12px 12px; }
.msg-row.theirs .bubble.img-bubble .media-wrap,
.msg-row.theirs .bubble.img-bubble .media-img,
.msg-row.theirs .bubble.img-bubble .vid-thumb { border-radius: 0 12px 12px 12px; }
.media-wrap { position: relative; display: block; border-radius: 6px; overflow: hidden; background: transparent; }
.media-img {
  display: block;
  width: 100%;
  max-width: 280px;
  max-height: 320px;
  height: auto;
  object-fit: contain;
  object-position: center;
  border-radius: 6px;
  cursor: pointer;
  vertical-align: top;
}
.vid-thumb {
  position: relative;
  display: block;
  width: 100%;
  max-width: 280px;
  min-height: 160px;
  max-height: 280px;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  background: #0b141a;
}
.vid-thumb img, .vid-thumb video {
  display: block;
  width: 100%;
  height: 220px;
  object-fit: cover;
  pointer-events: none;
}
.vid-play {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(11, 20, 26, .55);
  border: 2px solid #fff;
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 18px;
  padding-left: 3px;
  pointer-events: none;
}
.vid-dur {
  position: absolute;
  left: 8px;
  bottom: 6px;
  font-size: 12px;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,.7);
  pointer-events: none;
}
.img-bubble .msg-meta {
  position: absolute;
  right: 8px;
  bottom: 6px;
  float: none;
  margin: 0;
  z-index: 1;
  color: #e9edef;
  text-shadow: 0 1px 2px rgba(0,0,0,.7);
}
.audio-player { display: flex; align-items: center; gap: 8px; min-width: 220px; }
.audio-player audio { height: 32px; width: 180px; }
.doc-card { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.poll { min-width: 230px; }
.poll-opt {
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin: 6px 0; cursor: pointer;
}
.poll-opt.on { border-color: var(--accent); }
.poll-bar { height: 3px; background: var(--accent); margin-top: 6px; border-radius: 2px; }

.composer {
  background: var(--composer);
  min-height: 62px;
  display: flex; align-items: flex-end;
  flex-wrap: nowrap;
  padding: 6px 7px max(8px, env(safe-area-inset-bottom, 0px));
  gap: 7px; flex-shrink: 0;
  position: relative;
  z-index: 6;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  border: 0;
  box-shadow: none;
  outline: none;
}
.composer::before, .composer::after { content: none; }
.composer-pill {
  flex: 1 1 auto; min-width: 0; background: #1f2c34; border-radius: 24px;
  min-height: 48px; max-height: 140px;
  display: flex; align-items: flex-end;
  padding: 4px 2px 4px 2px;
}
.comp-ico {
  width: 40px; height: 40px; border-radius: 50%;
  color: #8696a0; display: grid; place-items: center; flex-shrink: 0;
}
.composer-pill textarea {
  flex: 1 1 auto; min-width: 0; width: 0; border: 0; outline: none; background: none; resize: none;
  font-size: 16px; line-height: 22px; max-height: 120px;
  color: var(--text); padding: 9px 4px; min-height: 40px;
  box-shadow: none; -webkit-appearance: none; appearance: none;
}
.composer-pill textarea::placeholder { color: #8696a0; }
.mic-fab {
  width: 48px; height: 48px; border-radius: 50%; flex: 0 0 48px;
  background: #22c55e; color: #fff;
  display: grid; place-items: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.35);
  align-self: flex-end;
}
.mic-fab.hidden { display: none !important; }
.rec-bar {
  display: none; align-items: center; gap: 12px; flex: 1; min-width: 0;
  background: #1f2c34; border-radius: 24px; min-height: 48px;
  padding: 0 16px; color: var(--danger); font-size: 15px;
}
.rec-bar.show { display: flex; }
.rec-dot { width: 10px; height: 10px; background: var(--danger); border-radius: 50%; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .3; } }
[data-theme="light"] .composer { background: #f4faf6; border-top: 0; }
[data-theme="light"] .composer-pill,
[data-theme="light"] .rec-bar { background: #fff; border: 1px solid #e3eee6; box-shadow: 0 6px 18px rgba(16,33,23,.04); }
[data-theme="light"] .comp-ico { color: #16a34a; }
[data-theme="light"] .conv-head { background: #ffffff; }
[data-theme="light"] .conv-head .icon-btn,
[data-theme="light"] .conv-title h3 { color: #16a34a; }
[data-theme="light"] .conv-title span { color: #5f6f66; opacity: 1; }
.reply-bar {
  display: none; background: var(--composer); padding: 6px 60px 0 16px;
  align-items: stretch; gap: 8px;
}
.reply-bar.show { display: flex; }
.reply-bar .quote { flex: 1; margin: 0; cursor: default; }
.reply-close { color: var(--icon); padding: 0 8px; flex-shrink: 0; }

/* drawers */
.drawer {
  width: 0; overflow: hidden; background: var(--bg-panel);
  border-left: 0; display: flex; flex-direction: column;
  transition: width .18s ease;
}
.drawer.open { width: 400px; border-left: 1px solid var(--border); }
.drawer-head {
  height: 64px; background: var(--bg-header);
  display: flex; align-items: center; gap: 12px; padding: 0 14px;
  font-size: 18px; font-weight: 800; letter-spacing: -.3px;
}
.drawer-body { flex: 1; overflow: auto; }
.profile-hero { padding: 28px 0; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.profile-hero img { width: 200px; height: 200px; border-radius: 50%; object-fit: cover; }
.av-edit {
  position: relative;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
}
.av-edit img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.cam-fab {
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #22c55e;
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.4);
  pointer-events: none;
}
.cam-fab svg { width: 20px; height: 20px; }
.change-photo-btn { color: var(--accent); font-size: 15px; font-weight: 500; padding: 4px 8px; }
.change-photo-btn:hover { text-decoration: underline; }
.av-edit.sm { width: 80px; height: 80px; margin: 0 auto 12px; }
.av-edit.sm .cam-fab { width: 28px; height: 28px; right: 0; bottom: 0; }
.av-edit.sm .cam-fab svg { width: 14px; height: 14px; }
.info-block {
  background: #fff; padding: 14px 16px; margin: 8px 14px;
  border: 1px solid #e3eee6; border-radius: 16px;
}
.info-block small { color: #16a34a; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.info-block p { margin-top: 6px; font-size: 16px; font-weight: 600; }
.danger-row { color: var(--danger); padding: 14px 20px; display: flex; align-items: center; gap: 16px; cursor: pointer; }
.danger-row:hover { background: var(--bg-hover); }

/* panels inside sidebar */
.panel { display: none; flex-direction: column; flex: 1; min-height: 0; }
.panel.show { display: flex; }
#panel-settings, #panel-profile, #panel-newchat, #panel-status, #panel-calls, #panel-starred, #panel-archived { overflow-y: auto; padding-bottom: 108px; }
[data-theme="dark"] .settings-item,
[data-theme="dark"] .status-row,
[data-theme="dark"] .info-block,
[data-theme="dark"] .ctx,
[data-theme="dark"] .modal { background: var(--bg-panel); border-color: var(--border); color: var(--text); }
[data-theme="dark"] .settings-item > .icon-btn { background: rgba(255,255,255,.06); color: #4ade80; border-color: var(--border); }
.back-head {
  height: 64px; min-height: 64px; background: transparent;
  display: flex; align-items: center; gap: 8px;
  padding: 0 14px; font-size: 20px; font-weight: 800; letter-spacing: -.4px;
}

/* emoji */
.emoji-pop {
  position: absolute; left: 8px; bottom: 68px; width: min(430px, calc(100% - 16px)); height: 340px;
  background: var(--bg-dropdown); border-radius: 20px; border: 1px solid var(--border);
  box-shadow: 0 16px 40px rgba(16,33,23,.12);
  display: none; flex-direction: column; z-index: 20; overflow: hidden;
}
.emoji-pop.show { display: flex; }
.emoji-search { padding: 8px; }
.emoji-search input {
  width: 100%; background: var(--bg-input); border: 0; border-radius: 8px;
  height: 34px; padding: 0 10px; outline: none;
}
.emoji-cats { display: flex; padding: 0 6px; gap: 2px; border-bottom: 1px solid var(--border); }
.emoji-cats button { flex: 1; height: 36px; font-size: 18px; border-radius: 4px; }
.emoji-cats button.on { box-shadow: inset 0 -3px 0 var(--accent); }
.emoji-grid { flex: 1; overflow: auto; padding: 6px; display: grid; grid-template-columns: repeat(9, 1fr); gap: 2px; }
.emoji-grid button { font-size: 24px; height: 38px; border-radius: 6px; }
.emoji-grid button:hover { background: var(--bg-hover); }

.attach-scrim {
  display: none;
  position: absolute;
  top: 56px; left: 0; right: 0; bottom: 62px;
  background: transparent;
  z-index: 20;
}
.attach-scrim.show { display: block; }
.attach-menu {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 74px;
  display: none;
  flex-direction: column;
  align-items: stretch;
  z-index: 22;
  padding: 10px 18px 16px;
  background: #fff;
  border-radius: 28px;
  border: 1px solid #e7f5ec;
  box-shadow: 0 18px 48px rgba(16,33,23,.12);
}
.attach-menu.show { display: flex; }
.att-handle {
  width: 42px;
  height: 4px;
  border-radius: 4px;
  background: #d7e4dc;
  margin: 2px auto 14px;
}
.att-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px 8px;
  justify-items: center;
}
.attach-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: #3d4f46;
  background: transparent;
  padding: 0;
  width: 100%;
}
.attach-item .fab {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 0;
  display: grid;
  place-items: center;
  background: #3b82f6;
  box-shadow: 0 6px 14px rgba(16,33,23,.12);
  color: #fff;
}
.attach-item .fab svg { width: 22px; height: 22px; }
.att-label {
  background: transparent;
  color: #3d4f46;
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0;
  padding: 0;
  border-radius: 0;
  box-shadow: none;
  white-space: nowrap;
}
.attach-item:hover .att-label { background: transparent; color: #102117; }
.attach-item[data-att="image"] .fab { background: #3b82f6; }
.attach-item[data-att="location"] .fab { background: #14b8a6; }
.attach-item[data-att="contact"] .fab { background: #0ea5e9; }
.attach-item[data-att="document"] .fab { background: #7c6bf2; }
.attach-item[data-att="camera"] .fab { background: #f43f5e; }
.attach-item[data-att="poll"] .fab { background: #f59e0b; }
.attach-item[data-att="sticker"] .fab { background: #22c55e; }
.contact-card {
  display: flex; align-items: center; gap: 10px;
  min-width: 190px; text-align: left; color: inherit; cursor: pointer;
}
.contact-card b { display: block; font-size: 15px; font-weight: 700; }
.contact-card small { display: block; color: #5f6f66; font-size: 12.5px; margin-top: 2px; }
.contact-ava {
  width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0;
  background: #dcfce7; display: grid; place-items: center; font-size: 20px;
}
.contact-acts {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 6px;
}
.contact-acts button {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 6px 10px; border-radius: 16px;
  background: #f3faf6; color: #102117; font-weight: 700; font-size: 13px;
}
.contact-acts button .ico {
  width: 44px; height: 44px; border-radius: 50%;
  background: #22c55e; color: #fff;
  display: grid; place-items: center; font-size: 18px;
}
.contact-acts button:hover { background: #e7f6ec; }
.loc-card {
  display: flex; align-items: center; gap: 10px;
  min-width: 180px; color: inherit; text-decoration: none;
}
.loc-card b { display: block; font-size: 14.5px; font-weight: 700; }
.loc-card small { display: block; color: #16a34a; font-size: 12px; margin-top: 2px; }
.loc-pin {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: #ccfbf1; color: #0f766e;
  display: grid; place-items: center; font-size: 18px;
}
[data-theme="dark"] .attach-menu { background: #fff; border-color: #e7f5ec; }
[data-theme="dark"] .att-label,
[data-theme="dark"] .attach-item { color: #3d4f46; }

.ctx {
  position: fixed; z-index: 50; min-width: 248px;
  background: #fff; border-radius: 22px; border: 1px solid rgba(34,197,94,.16);
  box-shadow: 0 18px 48px rgba(16,33,23,.14);
  padding: 8px; display: none;
}
.ctx.show { display: block; }
.ctx button {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  border-radius: 14px; padding: 10px 12px;
  color: #102117; font-size: 14.5px; font-weight: 600; letter-spacing: -.15px;
}
.ctx button:hover { background: #eef8f2; color: #16a34a; }
.ctx-ico {
  width: 30px; height: 30px; border-radius: 10px; flex-shrink: 0;
  background: #eef8f2; color: #16a34a;
  display: grid; place-items: center;
}
.ctx-ico svg { width: 16px; height: 16px; }
.ctx-sep { height: 1px; margin: 6px 10px; background: #e3eee6; }
.ctx button.danger { color: #ef4444; }
.ctx button.danger .ctx-ico { background: #fef2f2; color: #ef4444; }
.ctx button.danger:hover { background: #fef2f2; color: #ef4444; }
[data-theme="dark"] .ctx button { color: var(--text); }
[data-theme="dark"] .ctx button:hover { background: var(--bg-hover); color: #4ade80; }
[data-theme="dark"] .ctx-ico { background: rgba(74,222,128,.12); color: #4ade80; }
[data-theme="dark"] .ctx-sep { background: var(--border); }

.modal-bg {
  position: fixed; inset: 0; background: rgba(16,33,23,.45);
  backdrop-filter: blur(6px);
  display: none; align-items: center; justify-content: center; z-index: 120;
  padding: 18px;
}
.modal-bg.show { display: flex; }
.modal {
  background: #fff; width: min(460px, 100%); border-radius: 28px;
  border: 1px solid rgba(34,197,94,.16);
  padding: 22px 22px 18px;
  box-shadow: 0 28px 70px rgba(16,33,23,.18);
  max-height: min(86vh, 720px);
  overflow: auto;
}
.modal h3 { font-weight: 800; font-size: 22px; letter-spacing: -.4px; margin-bottom: 14px; color: #102117; }
.modal .modal-sub { color: var(--text-sec); font-size: 14px; margin: -4px 0 14px; font-weight: 500; line-height: 1.45; }
.modal input[type="text"],
.modal input[type="password"],
.modal input[type="search"],
.modal input[type="tel"],
.modal input[type="number"],
.modal input:not([type]),
.modal textarea {
  width: 100%; background: #f3faf6; border: 1px solid #e3eee6; border-radius: 16px;
  outline: none; padding: 14px 16px; font-size: 15px; font-weight: 500; margin-bottom: 12px;
  color: var(--text); appearance: none; -webkit-appearance: none;
}
.modal input::placeholder, .modal textarea::placeholder { color: #94a3b8; font-weight: 500; }
.modal input:focus, .modal textarea:focus { border-color: #22c55e; background: #fff; box-shadow: 0 0 0 4px rgba(34,197,94,.12); }
.modal .search-box { margin-bottom: 12px; box-shadow: none; background: #f3faf6; }
.modal .search-box input { margin: 0; padding: 0; border: 0; background: transparent; box-shadow: none; width: auto; font-size: 15px; }
.modal .search-box:focus-within { border-color: #22c55e; background: #fff; box-shadow: 0 0 0 4px rgba(34,197,94,.12); }
.modal input[type="file"] {
  width: 100%; margin: 4px 0 12px; font-size: 13px; color: #5f6f66;
}
.modal input[type="file"]::file-selector-button {
  margin-right: 10px; border: 1px solid #bbf7d0; background: #f0fdf4;
  color: #16a34a; border-radius: 999px; padding: 8px 14px;
  font-weight: 700; font-size: 13px; cursor: pointer;
}
.modal .settings-item { margin: 0 0 8px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.modal-actions button {
  min-height: 42px; padding: 0 18px; color: #16a34a; font-weight: 700;
  border-radius: 999px; font-size: 14px;
}
.modal-actions button:hover { background: #f0fdf4; }
.modal-actions button:last-child:not(:only-child) {
  background: #22c55e; color: #fff;
  box-shadow: 0 8px 18px rgba(22,163,74,.28);
}
.modal-actions button:last-child:not(:only-child):hover { background: #16a34a; }
.group-ph {
  width: 100%; height: 100%; border-radius: 50%;
  background: #f0fdf4; color: #16a34a;
  border: 1px solid #d7f5e3;
  display: grid; place-items: center;
}
.group-ph[hidden], .av-edit img[hidden] { display: none !important; }
.contact-pick .empty-note {
  text-align: center; color: #5f6f66; font-size: 14px; font-weight: 500;
  padding: 22px 12px 8px; line-height: 1.45;
}

.status-row {
  display: flex; gap: 14px; align-items: center;
  margin: 0 12px 8px; padding: 12px 14px; cursor: pointer;
  background: #fff; border: 1px solid #e3eee6; border-radius: 18px;
}
.status-row:hover { background: #f0fdf4; }
.ring {
  position: relative;
  width: 52px; height: 52px; border-radius: 50%; padding: 2px;
  background: conic-gradient(#22c55e 0 100%, #22c55e 0);
}
.ring.seen { background: #3b4a54; }
.ring.mine { background: #3b4a54; }
[data-theme="light"] .ring.seen,
[data-theme="light"] .ring.mine { background: #d1fae5; }
.ring img, .ring .av { width: 100%; height: 100%; border: 2px solid var(--bg-panel); border-radius: 50%; object-fit: cover; }
.status-plus {
  position: absolute; right: -1px; bottom: -1px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #22c55e; color: #fff; font-size: 16px; line-height: 16px;
  display: grid; place-items: center; font-weight: 700;
  border: 2px solid var(--bg-panel);
}
.settings-item > .icon-btn {
  width: 42px; height: 42px; border-radius: 14px;
  color: #16a34a; background: #f4faf6; border: 1px solid #e3eee6; flex-shrink: 0;
}
.call-link-ic { background: #22c55e !important; color: #fff !important; width: 40px !important; height: 40px !important; }
.ch-find { background: #22c55e !important; color: #fff !important; width: 40px !important; height: 40px !important; }
.ci-name.missed { color: #ea4335; }
.call-log-row .icon-btn { color: #22c55e; width: 40px; height: 40px; }
.call-log-row .ci-bot { align-items: center; }

.status-viewer {
  position: fixed; inset: 0; background: #000; z-index: 70;
  display: none; flex-direction: column;
}
.status-viewer.show { display: flex; }
.sv-bar { height: 3px; background: #444; margin: 10px 12px 0; border-radius: 2px; overflow: hidden; }
.sv-bar i { display: block; height: 100%; width: 0; background: #fff; }
.sv-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; color: #fff; }
.sv-body { flex: 1; display: grid; place-items: center; padding: 20px; }
.sv-text {
  font-size: 32px; text-align: center; max-width: 640px; line-height: 1.35; color: #fff; font-weight: 500;
}

.settings-item {
  display: flex; gap: 14px; align-items: center;
  margin: 0 12px 8px; padding: 12px 14px; cursor: pointer;
  background: #fff; border: 1px solid #e3eee6; border-radius: 18px;
}
.settings-item:hover { background: #f0fdf4; }
.settings-item .av { width: 56px; height: 56px; border-radius: 18px; }
.settings-item h4 { font-weight: 700; font-size: 16px; letter-spacing: -.2px; }
.settings-item p { color: var(--text-sec); font-size: 13px; font-weight: 500; margin-top: 2px; }
.sec-label {
  margin: 14px 18px 8px; font-size: 12px; font-weight: 700;
  letter-spacing: .08em; color: #5f6f66;
}
.empty-note {
  text-align: center; color: #5f6f66; font-size: 14px; font-weight: 500;
  padding: 28px 20px; line-height: 1.45;
}

.toast {
  position: fixed; bottom: 96px; left: 50%; transform: translateX(-50%);
  background: #102117; color: #fff; padding: 12px 18px; border-radius: 14px;
  font-weight: 600; font-size: 14px;
  display: none; z-index: 130; box-shadow: var(--shadow);
}
.toast.show { display: block; }

.perm-gate {
  position: fixed; inset: 0; z-index: 90;
  background: #f6faf8;
  display: grid; place-items: center;
  padding: 24px 20px;
}
.perm-gate[hidden] { display: none !important; }
.perm-card {
  width: min(420px, 100%); text-align: center;
  background: #fff; border: 1px solid rgba(34,197,94,.14);
  border-radius: 28px; padding: 28px 22px;
  box-shadow: 0 24px 60px rgba(16,33,23,.08);
}
.perm-logo {
  width: 64px; height: 64px; margin: 0 auto 18px;
  border-radius: 16px; background: #22c55e; color: #fff;
  display: grid; place-items: center;
}
.perm-card h2 { font-size: 22px; font-weight: 600; margin-bottom: 10px; }
.perm-card > p { color: var(--text-sec); font-size: 15px; line-height: 1.45; margin-bottom: 22px; }
.perm-list { list-style: none; text-align: left; margin: 0 0 18px; }
.perm-list li {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 4px; color: var(--text); font-size: 15px;
  border-bottom: 1px solid var(--border);
}
.perm-list li span { width: 28px; text-align: center; font-size: 18px; }
.perm-note { min-height: 20px; color: #ea4335; font-size: 13px; }
.perm-btn { width: 100%; height: 48px; border-radius: 24px; font-size: 16px; margin-top: 8px; }

.lightbox {
  position: fixed; inset: 0; background: #0b141a; z-index: 75;
  display: none; flex-direction: column;
}
.lightbox.show { display: flex; }
.lightbox img, .lightbox video { max-height: calc(100% - 60px); margin: auto; max-width: 100%; display: none; }
.lightbox.show-img img { display: block; }
.lightbox.show-vid video { display: block; width: min(960px, 100%); background: #000; }
.lb-head { height: 60px; display: flex; align-items: center; padding: 0 16px; gap: 12px; }

.call-overlay {
  position: fixed; inset: 0; z-index: 85;
  width: 100%;
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  background: linear-gradient(180deg, #065f46 0%, #022c22 100%);
  display: none; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; text-align: center;
  padding:
    max(18px, env(safe-area-inset-top, 0px))
    max(16px, env(safe-area-inset-right, 0px))
    max(18px, env(safe-area-inset-bottom, 0px))
    max(16px, env(safe-area-inset-left, 0px));
  overflow: hidden;
  touch-action: manipulation;
}
.call-overlay.show { display: flex; }
.call-overlay #callRemoteAudio {
  position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none;
}
.call-grid {
  position: absolute; inset: 76px 12px 118px; z-index: 2;
  display: none; grid-template-columns: 1fr 1fr; gap: 8px;
}
.call-overlay.group-live .call-grid { display: grid; }
.call-overlay.group-live #callRemote { display: none !important; }
.call-tile { position: relative; background: #102117; border-radius: 14px; overflow: hidden; min-height: 120px; }
.call-tile video { width: 100%; height: 100%; object-fit: cover; background: #102117; }
.call-tile span { position: absolute; left: 8px; bottom: 8px; color: #fff; font-size: 13px; font-weight: 600; text-shadow: 0 1px 4px #000; }
.call-overlay #callRemote {
  display: none; position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; object-position: center center; background: #000; z-index: 0;
}
.call-overlay #callLocal {
  display: none; position: absolute;
  right: max(10px, env(safe-area-inset-right, 0px));
  top: calc(env(safe-area-inset-top, 0px) + 52px);
  width: min(28vw, 112px);
  height: calc(min(28vw, 112px) * 1.42);
  object-fit: cover; object-position: center center;
  border-radius: 12px; z-index: 2; background: #111;
  box-shadow: 0 4px 16px rgba(0,0,0,.45); opacity: 1;
}
.call-overlay.live #callRemote, .call-overlay.live #callLocal { display: block; }
.call-overlay.live .call-av { display: none; }
.call-overlay.connected .call-meta { display: none; }
.call-overlay.connected.has-hint .call-meta { display: block; }
.call-overlay.connected.has-hint .call-av,
.call-overlay.connected.has-hint h2,
.call-overlay.connected.has-hint .call-kind,
.call-overlay.connected.has-hint #callStatus { display: none; }
.call-meta { z-index: 2; position: relative; }
.call-timer {
  position: absolute; top: max(14px, env(safe-area-inset-top, 0px)); left: 50%;
  transform: translateX(-50%); z-index: 4;
  color: #fff; font-weight: 700; font-size: 15px; letter-spacing: .3px;
  font-variant-numeric: tabular-nums;
  background: rgba(0,0,0,.5); backdrop-filter: blur(8px);
  padding: 6px 14px; border-radius: 999px;
  text-shadow: 0 1px 4px rgba(0,0,0,.45);
}
.call-timer[hidden] { display: none !important; }
.call-av { width: 112px; height: 112px; border-radius: 32px; object-fit: cover; margin: 0 auto 12px; box-shadow: 0 16px 32px rgba(0,0,0,.25); }
.call-overlay h2 { font-size: 26px; font-weight: 800; letter-spacing: -.4px; }
.call-kind { color: #6ee7b7; font-size: 15px; }
.call-overlay #callStatus { color: var(--text-sec); font-size: 14px; }
.call-hint { color: #ea4335; font-size: 13px; max-width: 280px; margin: 8px auto 0; min-height: 0; }
.call-overlay.live .call-meta h2,
.call-overlay.live .call-kind,
.call-overlay.live #callStatus { text-shadow: 0 1px 6px #000; color: #fff; }
.call-actions { display: flex; gap: 36px; margin-top: 36px; z-index: 2; }
.call-actions.hidden { display: none !important; }
.call-hang, .call-accept {
  width: 64px; height: 64px; border-radius: 50%;
  color: #fff; display: grid; place-items: center;
}
.call-hang { background: #ea4335; }
.call-hang svg, .call-hang .wa-ico { transform: rotate(135deg); }
.call-accept { background: #22c55e; }
.call-accept svg, .call-accept .wa-ico { transform: none; }

/* In-call controls (mute / camera off / switch camera / end) */
.call-controls {
  display: flex; align-items: center; justify-content: space-evenly;
  gap: 6px; margin-top: 28px; z-index: 3;
  width: min(100%, 420px); max-width: calc(100vw - 16px);
  box-sizing: border-box;
  background: rgba(0,0,0,.55); padding: 8px 6px; border-radius: 40px;
  backdrop-filter: blur(8px);
}
.call-controls.hidden { display: none !important; }
.call-ctl {
  width: 46px; height: 46px; flex: 1 1 0; max-width: 50px; min-width: 0;
  border-radius: 50%;
  background: rgba(255,255,255,.22); color: #fff;
  display: grid; place-items: center; border: none; cursor: pointer;
  transition: background .15s, color .15s;
}
.call-ctl svg, .call-ctl .wa-ico { width: 22px; height: 22px; flex-shrink: 0; }
.call-ctl:active { transform: scale(.94); }
.call-ctl.off, .call-ctl.on { background: #fff; color: #111; }
.call-ctl.hidden { display: none !important; }
.call-controls .call-hang {
  width: 50px; height: 50px; flex: 0 0 50px; max-width: 50px;
}
/* Live video: dock controls at the bottom, fully inside the screen */
.call-overlay.live .call-controls {
  position: absolute; left: 8px; right: 8px; bottom: max(12px, env(safe-area-inset-bottom, 0px));
  margin: 0 auto; transform: none; width: auto;
}
/* Self-view acts like a mirror only for the front camera */
.call-overlay #callLocal.mirror { transform: scaleX(-1); }
.call-overlay #callLocal.is-screen { object-fit: contain; background: #000; }
.contact-pick .settings-item { width: 100%; text-align: left; font: inherit; color: inherit; }

.contact-pick { padding: 2px 0 4px; max-height: 280px; overflow: auto; }
.contact-pick label {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  margin-bottom: 6px;
  cursor: pointer;
  width: 100%;
  background: #fff;
  border: 1px solid #e3eee6;
  border-radius: 16px;
}
.contact-pick label:hover { background: #f0fdf4; border-color: #bbf7d0; }
.contact-pick .av {
  width: 40px !important;
  height: 40px !important;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.contact-pick .cp-meta { flex: 1; min-width: 0; }
.contact-pick .cp-meta b {
  display: block;
  font-weight: 400;
  font-size: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.contact-pick .cp-meta span {
  display: block;
  color: var(--text-sec);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.contact-pick input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  margin: 0 0 0 auto;
  flex-shrink: 0;
  border: 2px solid #8696a0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  position: relative;
}
.contact-pick input[type="checkbox"]:checked {
  background: #22c55e;
  border-color: #22c55e;
}
.contact-pick input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 2px;
  width: 5px;
  height: 9px;
  border: solid #111b21;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.online-dot {
  position: absolute; right: 1px; bottom: 1px; width: 10px; height: 10px;
  background: #22c55e; border: 2px solid var(--bg-panel); border-radius: 50%;
}

@media (min-width: 900px) {
  .sidebar {
    width: 420px;
    flex: 0 0 420px;
    max-width: 420px;
    border-right: 1px solid #e6f4ee;
    background: #f7fbf9;
  }
  .main { display: flex; }
  #backChat { display: none !important; }
}
@media (max-width: 899px) {
  .app:not(.chat-open) .main, .app:not(.chat-open) .drawer { display: none; }
  .app.chat-open .sidebar { display: none; }
  .app.chat-open .main {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }
  .app.chat-open .conv {
    flex: 1;
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }
  #backChat { display: grid; }
  .conv-head {
    flex: 0 0 56px;
    height: 56px;
    width: 100%;
  }
  .conv-head .icon-btn { width: 40px; height: 40px; flex-shrink: 0; }
  .conv-wall { padding: 8px 6px; min-height: 0; }
  .bubble { max-width: 85%; }
  .composer { gap: 6px; padding: 5px 6px 8px; }
  .comp-ico { width: 36px; height: 36px; }
  .mic-fab { width: 48px; height: 48px; flex: 0 0 48px; }
  .drawer.open { position: absolute; inset: 0; width: 100% !important; z-index: 8; }
  .emoji-pop { left: 8px; width: calc(100% - 16px); bottom: 62px; }
  .reply-bar { padding: 6px 56px 0 10px; flex-shrink: 0; }
}
.login-legal {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 16px;
  padding: 4px 20px 28px;
  background: #f3faf6;
  font-size: 13px;
}
.login-legal a { color: #166534; font-weight: 600; text-decoration: none; }
@media (max-width: 800px) {
  body.login-body { background: #fff; }
  .login-legal { background: #fff; padding-bottom: 22px; }
  .login-page { background: #fff; min-height: 100%; }
  .login-page::before { display: none; }
  .login-wrap { padding: 0; max-width: none; }
  .login-brand { display: none; }
  .wa-bar {
    display: flex; align-items: center; gap: 8px;
    height: 56px; padding: 0 8px 0 4px;
    background: #22c55e; color: #fff;
  }
  .wa-bar h2 { flex: 1; font-size: 18px; font-weight: 600; letter-spacing: -.2px; padding-left: 12px; }
  .wa-back { width: 44px; height: 44px; color: #fff; display: grid; place-items: center; }
  .wa-back:not(.hidden) + h2 { padding-left: 0; }
  .wa-help {
    width: 32px; height: 32px; border-radius: 50%;
    display: grid; place-items: center; font-weight: 700; opacity: .92;
  }
  .login-card {
    grid-template-columns: 1fr;
    min-height: calc(100dvh - 56px);
    box-shadow: none; border-radius: 0; border: 0;
  }
  .login-right, .wa-web-intro { display: none; }
  .login-left { padding: 28px 28px 40px; }
  .login-left form { max-width: none; }
  .wa-copy { text-align: center; margin-left: auto; margin-right: auto; }
}

/* Block bar (shown instead of composer when you blocked the contact) */
.block-bar {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 14px 16px; background: var(--composer); color: var(--text-sec);
  font-size: 14px; border-top: 1px solid var(--border);
}
.block-bar.hidden { display: none; }
.block-bar button {
  background: transparent; color: var(--accent); border: 0; font-size: 14px;
  font-weight: 600; cursor: pointer; padding: 6px 10px;
}

/* Select-messages action bar */
.select-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px; background: var(--composer); border-top: 1px solid var(--border);
}
.select-bar.hidden { display: none; }
.select-bar .sel-count { color: var(--text); font-weight: 600; flex: 1; }
.select-bar .select-actions { display: flex; gap: 6px; }
.select-bar .icon-btn { font-size: 18px; }
.msg-row.selecting { cursor: pointer; }
.msg-row.selecting.selected { background: rgba(34,197,94,.16); }
.msg-check {
  align-self: center; width: 22px; height: 22px; min-width: 22px; margin: 0 4px;
  border-radius: 50%; border: 2px solid var(--text-sec); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 13px;
}
.msg-row.selected .msg-check { background: var(--accent); border-color: var(--accent); }

.cam-sheet[hidden] { display: none !important; }
.cam-sheet {
  position: fixed; inset: 0; z-index: 96;
  background: #04140c;
  display: flex; flex-direction: column;
}
.cam-sheet video[hidden],
.cam-sheet #camStill[hidden] { display: none !important; }
.cam-sheet video, .cam-sheet #camStill {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; background: #04140c;
  z-index: 1;
}
.cam-top {
  position: relative; z-index: 2;
  display: flex; justify-content: space-between;
  padding: 16px 16px 0;
}
.cam-x {
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(255,255,255,.16); color: #fff;
  display: grid; place-items: center;
}
.cam-err {
  position: relative; z-index: 2; margin: auto 24px;
  color: #fff; text-align: center; font-weight: 600;
}
.cam-bar {
  position: relative; z-index: 2; margin-top: auto;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 18px 16px 28px;
}
.cam-bar.hidden { display: none; }
.cam-shutter {
  width: 74px; height: 74px; border-radius: 50%;
  border: 4px solid #fff; background: transparent; padding: 4px;
}
.cam-shutter::after {
  content: ""; display: block; width: 100%; height: 100%;
  border-radius: 50%; background: #22c55e;
}
.cam-act {
  min-height: 44px; padding: 0 16px; border-radius: 999px;
  background: rgba(255,255,255,.16); color: #fff; font-weight: 700;
}
.cam-act-go { background: #22c55e; color: #fff; }
.cam-pick {
  position: relative; z-index: 2;
  max-height: 42vh; overflow: auto;
  background: #fff; border-radius: 20px 20px 0 0;
  padding: 14px 12px 18px;
}
.cam-pick.hidden { display: none; }
.cam-pick p { font-weight: 800; margin: 0 8px 10px; color: #102117; }
.cam-pick button {
  display: block; width: 100%; text-align: left;
  padding: 12px 14px; border-radius: 14px;
  background: #f3faf6; color: #102117; font-weight: 700; margin-bottom: 8px;
}
