:root {
  --wa: #00a884;
  --wa-deep: #008069;
  --ink: #e9edef;
  --muted: #8696a0;
  --line: #2a3942;
  --panel: #111b21;
  --field: #202c33;
  --chat: #0b141a;
  --bubble: #202c33;
  --out: #005c4b;
  --chrome: #0b141a;
  --hover: #2a3942;
  --hang: #ea0038;
  --sans: "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --doodle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='360' height='360' fill='none' stroke='%231f2c33' stroke-width='1.4' stroke-linejoin='round'%3E%3Crect x='24' y='28' width='34' height='22' rx='8'/%3E%3Cpath d='M34 50l-6 8 12-8'/%3E%3Cpath d='M92 36c0-7 8-10 12-4 4-6 12-3 12 4 0 8-12 14-12 14S92 44 92 36z'/%3E%3Crect x='168' y='24' width='16' height='28' rx='4'/%3E%3Ccircle cx='250' cy='38' r='12'/%3E%3Cpath d='M244 36h2M254 36h2M244 42c2 3 10 3 12 0'/%3E%3Crect x='96' y='128' width='30' height='20' rx='4'/%3E%3Ccircle cx='190' cy='140' r='11'/%3E%3Cpath d='M236 132c8 0 14 6 14 14v6h-28v-6c0-8 6-14 14-14z'/%3E%3Crect x='108' y='236' width='26' height='18' rx='7'/%3E%3Cpath d='M176 248c0-8 10-12 14-4 5-8 14-4 14 4 0 10-14 16-14 16s-14-6-14-16z'/%3E%3Ccircle cx='270' cy='248' r='12'/%3E%3C/svg%3E");
}

html[data-theme="light"] {
  --ink: #111b21;
  --muted: #667781;
  --line: #e9edef;
  --panel: #f0f2f5;
  --field: #ffffff;
  --chat: #efeae2;
  --bubble: #ffffff;
  --out: #d9fdd3;
  --chrome: #d1d7db;
  --hover: #e6e8eb;
  --doodle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='360' height='360' fill='none' stroke='%23d9d1c7' stroke-width='1.4' stroke-linejoin='round'%3E%3Crect x='24' y='28' width='34' height='22' rx='8'/%3E%3Cpath d='M34 50l-6 8 12-8'/%3E%3Cpath d='M92 36c0-7 8-10 12-4 4-6 12-3 12 4 0 8-12 14-12 14S92 44 92 36z'/%3E%3Crect x='168' y='24' width='16' height='28' rx='4'/%3E%3Ccircle cx='250' cy='38' r='12'/%3E%3Cpath d='M244 36h2M254 36h2M244 42c2 3 10 3 12 0'/%3E%3Crect x='96' y='128' width='30' height='20' rx='4'/%3E%3Ccircle cx='190' cy='140' r='11'/%3E%3Cpath d='M236 132c8 0 14 6 14 14v6h-28v-6c0-8 6-14 14-14z'/%3E%3Crect x='108' y='236' width='26' height='18' rx='7'/%3E%3Cpath d='M176 248c0-8 10-12 14-4 5-8 14-4 14 4 0 10-14 16-14 16s-14-6-14-16z'/%3E%3Ccircle cx='270' cy='248' r='12'/%3E%3C/svg%3E");
  --sans: "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --doodle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='360' height='360' fill='none' stroke='%23d9d1c7' stroke-width='1.4' stroke-linejoin='round'%3E%3Crect x='24' y='28' width='34' height='22' rx='8'/%3E%3Cpath d='M34 50l-6 8 12-8'/%3E%3Cpath d='M92 36c0-7 8-10 12-4 4-6 12-3 12 4 0 8-12 14-12 14S92 44 92 36z'/%3E%3Crect x='168' y='24' width='16' height='28' rx='4'/%3E%3Cpath d='M172 24v-3a4 4 0 0 1 8 0v3M174 48h4'/%3E%3Ccircle cx='250' cy='38' r='12'/%3E%3Cpath d='M244 36h2M254 36h2M244 42c2 3 10 3 12 0'/%3E%3Cpath d='M40 150l8-14 8 14M44 142h8'/%3E%3Crect x='96' y='128' width='30' height='20' rx='4'/%3E%3Cpath d='M126 136h8l-8 8'/%3E%3Ccircle cx='190' cy='140' r='11'/%3E%3Cpath d='M190 134v8M186 138h8'/%3E%3Cpath d='M236 132c8 0 14 6 14 14v6h-28v-6c0-8 6-14 14-14z'/%3E%3Cpath d='M48 250c10 0 14 8 8 14-6 2-14 0-14-6 0-6 2-8 6-8z'/%3E%3Crect x='108' y='236' width='26' height='18' rx='7'/%3E%3Cpath d='M116 254l-4 7 9-7'/%3E%3Cpath d='M176 248c0-8 10-12 14-4 5-8 14-4 14 4 0 10-14 16-14 16s-14-6-14-16z'/%3E%3Ccircle cx='270' cy='248' r='12'/%3E%3Cpath d='M264 246h2M274 246h2M264 252c2 4 10 4 12 0'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14.5px;
  background: var(--chrome);
}

body::before {
  content: "";
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  height: 127px;
  background: var(--wa);
  z-index: 0;
}

button, input { font: inherit; color: inherit; }

button { cursor: pointer; }

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

svg { width: 22px; height: 22px; }

#i-send path { fill: currentColor; stroke: none; }

#bootSplash {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  place-items: center;
  align-content: center;
  gap: 14px;
  background: #000;
  color: #fff;
}

html.session-pending #bootSplash { display: grid; }
html.session-pending #gate { display: none !important; }

.boot-mark {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  background: var(--wa, #00a884);
  display: grid;
  place-items: center;
}

.boot-mark svg { width: 40px; height: 40px; }

.boot-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  opacity: 0.85;
}

html.pwa-standalone body,
@media (display-mode: standalone) {
  body { overscroll-behavior: none; }
}

html.pwa-standalone .credit-float,
@media (display-mode: standalone) {
  .credit-float { display: none !important; }
}

#gate, #shell { position: relative; z-index: 1; }

#gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 28px 16px;
}

.gate-card {
  width: min(420px, 100%);
  background: var(--panel);
  padding: 32px 28px 14px;
  box-shadow: 0 8px 28px rgba(11, 20, 26, 0.16);
}

.wa-logo {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--wa);
  display: grid;
  place-items: center;
}

.wa-logo svg { width: 30px; height: 30px; }

.brand {
  margin: 16px 0 0;
  color: var(--wa-deep);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 4px 0 0;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.lead, .hint { color: var(--muted); }

.lead { margin: 8px 0 0; line-height: 1.45; }

form { display: grid; gap: 12px; margin-top: 22px; }

label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }

input {
  width: 100%;
  border: 0;
  background: var(--field);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--ink);
}

.hint { margin: 8px 0 0; font-size: 13px; line-height: 1.4; }

.error { min-height: 1.2em; margin: 0; color: var(--hang); font-size: 13px; }

.primary {
  border: 0;
  border-radius: 24px;
  background: var(--wa);
  color: #fff;
  font-weight: 600;
  padding: 12px 16px;
}

.primary:hover { background: var(--wa-deep); }

.banner, #addrBlock {
  margin-top: 14px;
  padding: 12px;
  border-radius: 8px;
  background: #fff8e8;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.4;
}

.addr-title { margin: 0 0 6px; font-weight: 600; }

#addrList { margin: 0; padding-left: 18px; }

#addrList a { color: var(--wa-deep); }

.credit {
  margin: 18px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12.5px;
}

.credit-float {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 8px;
  z-index: 30;
  margin: 0;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  opacity: 0.38;
  pointer-events: none;
}

body.chat-open .credit-float { opacity: 0.22; }

#gate:not([hidden]) ~ .credit-float { display: none; }

.credit b { color: var(--ink); font-weight: 600; }

#shell {
  height: 100dvh;
  padding: 19px 16px 18px;
}

#layout {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(300px, 400px) minmax(0, 1fr);
  background: var(--panel);
  box-shadow: 0 1px 3px rgba(11, 20, 26, 0.12);
  overflow: hidden;
}

aside {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.side-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  overflow: hidden;
}

#panelSettings {
  grid-template-rows: auto;
  overflow: auto;
  padding: 8px 12px 16px;
}

.app-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.app-tabs button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 12px 8px;
  font-size: 14px;
  font-weight: 500;
}

.app-tabs button.is-on {
  color: var(--wa);
  box-shadow: inset 0 -2px 0 var(--wa);
}

.set-row.danger .set-row-text b { color: #e57373; }

body[data-main-tab="you"] #thread { display: none; }
body[data-main-tab="you"].chat-open aside { display: grid; }
body.hub-mode #shell { padding: 0; }
body.hub-mode .credit-float { bottom: max(72px, calc(env(safe-area-inset-bottom) + 64px)); }

.wa-side-head, .wa-conv-head {
  height: 60px;
  background: var(--panel);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  box-shadow: 0 1px 0 var(--line);
}

.wa-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--wa);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 600;
  flex: none;
  overflow: hidden;
  padding: 0;
}

.wa-avatar img, .person .avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.wa-side-title { display: grid; min-width: 0; }

.wa-side-title b { font-size: 16px; }

#connStatus { color: var(--muted); font-size: 13px; }

#leaveBtn {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  border-radius: 8px;
  padding: 8px 10px;
}

#leaveBtn:hover { background: var(--hover); }

.wa-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 12px;
  padding: 0 12px;
  background: var(--field);
  border-radius: 8px;
  color: var(--muted);
}

.wa-search svg { width: 16px; height: 16px; flex: none; }

.wa-search input { background: transparent; padding: 9px 0; }

.wa-side-scroll { overflow: auto; min-height: 0; }

.wa-chat {
  width: 100%;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  background: var(--panel);
  text-align: left;
}

.wa-chat-meta { min-width: 0; flex: 1; }

.wa-chat-top, .wa-chat-top b {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.wa-chat-top b {
  font-size: 16px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#roomTime { color: var(--muted); font-size: 12px; flex: none; }

#roomPreview {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wa-section {
  margin: 8px 16px 4px;
  color: var(--wa-deep);
  font-size: 13px;
  font-weight: 600;
}

aside .credit {
  margin: 0;
  padding: 12px 16px;
  background: var(--panel);
  border-top: 1px solid var(--line);
}

#peopleList { list-style: none; margin: 0; padding: 0; }

.person {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
}

.person .avatar, .avatar-fill {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 600;
  flex: none;
  overflow: hidden;
}

.person .meta { display: grid; min-width: 0; }

.person .meta b { font-weight: 500; font-size: 15px; }

.person .meta span { font-size: 12px; color: var(--wa); }
.person .meta span.is-seen { color: var(--muted); }

#thread {
  position: relative;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  background-color: #0b141a;
  background-image: url('/wall-dark.png');
  background-repeat: repeat;
  background-position: center top;
  background-size: 280px auto;
  overflow: hidden;
}

html[data-theme="light"] #thread {
  background-color: #f8f8f8;
  background-image: url('/wall-light.png');
  background-size: 280px auto;
}

.wa-conv-title { min-width: 0; flex: 1; }

.wa-conv-title b {
  display: block;
  font-size: 16px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#presence {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wa-conv-actions { display: flex; align-items: center; margin-left: auto; }

.wa-conv-actions button, #copyCode {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
}

.wa-conv-actions button:hover, #copyCode:hover { background: var(--hover); }

#log {
  overflow: auto;
  padding: 16px 7% 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: transparent;
}

.day {
  align-self: center;
  margin: 10px 0;
  padding: 6px 12px;
  border-radius: 8px;
  background: var(--bubble);
  color: var(--muted);
  font-size: 12.5px;
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
  text-transform: none;
  letter-spacing: 0;
}

.bubble {
  position: relative;
  width: fit-content;
  max-width: min(65%, 520px);
  margin: 1px 8px;
  padding: 6px 8px 4px 9px;
  border-radius: 7.5px;
  background: var(--bubble);
  color: var(--ink);
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
}

.bubble::before {
  content: "";
  position: absolute;
  top: 0;
  left: -8px;
  border-right: 8px solid var(--bubble);
  border-bottom: 10px solid transparent;
}

.bubble.follow::before { display: none; }

.bubble.mine {
  margin-left: auto;
  background: var(--out);
}

.bubble.mine::before {
  left: auto;
  right: -8px;
  border-right: 0;
  border-left: 8px solid var(--out);
}

.bubble .who { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 2px; }

.bubble p {
  display: inline;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.35;
  font-size: 14.2px;
}

.bubble time {
  float: right;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin: 8px 0 -2px 12px;
  font-size: 11px;
  color: var(--muted);
}

.ticks { display: inline-flex; color: #8696a0; }
.ticks[data-state="sent"] .tick-b { display: none; }
.ticks[data-state="read"] { color: #53bdeb; }
.ticks path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#emptyLog {
  display: none;
  position: absolute;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  z-index: 1;
  width: min(360px, calc(100% - 32px));
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--bubble);
  color: var(--muted);
  text-align: center;
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
  font-size: 13.5px;
  line-height: 1.4;
}

#thread.is-empty #emptyLog { display: block; }

#liveCall {
  margin: 8px 16px;
  padding: 8px 8px 8px 12px;
  border-radius: 8px;
  background: var(--bubble);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
}

#liveCall button {
  border: 0;
  border-radius: 16px;
  background: var(--wa);
  color: #fff;
  font-weight: 600;
  padding: 8px 12px;
}

#composer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--panel);
}

#composer input {
  flex: 1;
  border-radius: 8px;
  background: var(--field);
  padding: 11px 12px;
  font-size: 15px;
}

#backToChats {
  display: none;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  place-items: center;
  padding: 0;
}

.my-code {
  margin: 0;
  padding: 0 16px 8px;
  color: var(--wa);
  font-size: 13px;
  cursor: pointer;
}

.chat-empty {
  margin: 18px 16px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

#chatList { display: grid; }

button.wa-chat {
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

button.wa-chat.is-active { background: var(--hover); }

#newGroupBtn {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: var(--wa);
  font-weight: 600;
}

#noChat {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: var(--panel);
  z-index: 4;
}

#noChat[hidden] { display: none !important; }

#attachSheet {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 68px;
  z-index: 7;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
}

.attach-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.attach-grid button {
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
}

.att {
  display: grid;
  place-items: center;
  height: 64px;
  border-radius: 16px;
  color: #fff;
  font-weight: 600;
}

.att.photo { background: #ac44cf; }
.att.cam { background: #e91e63; }
.att.place { background: #1e88e5; }
.att.contact { background: #0097a7; }
.att.file { background: #5c6bc0; }
.att.poll { background: #43a047; }

#contactForm, #pollForm { display: grid; gap: 8px; margin-top: 12px; }
#contactForm input, #pollForm input {
  border-radius: 8px;
  background: var(--field);
  padding: 10px 12px;
}
#contactForm .primary, #pollForm .primary {
  border: 0;
  border-radius: 8px;
  background: var(--wa);
  color: #fff;
  padding: 10px 12px;
}

#btnVoice.is-rec { color: #e53935; }


.poll { display: grid; gap: 6px; margin-bottom: 4px; }
.poll button {
  border: 0;
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  text-align: left;
  padding: 8px 10px;
}
.poll button.is-mine { outline: 2px solid var(--wa); }

.bubble audio, .bubble a.file-link, .bubble a.place-link {
  display: block;
  margin-bottom: 4px;
  color: inherit;
}

#composer button[type="submit"] {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: var(--wa);
  color: #fff;
  display: grid;
  place-items: center;
  padding: 0;
  flex: none;
}

#composer button[type="submit"]:hover { background: var(--wa-deep); }

#incoming {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #0b141a;
  color: #e9edef;
}

.incoming-card { width: min(420px, 100%); text-align: center; }

.incoming-orb {
  width: 112px;
  height: 112px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: var(--wa);
  box-shadow: 0 0 0 12px rgba(0, 168, 132, 0.18);
}

.kicker {
  margin: 0;
  color: #8696a0;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 12px;
}

#incomingText {
  margin: 8px 0 0;
  font-size: 32px;
  font-weight: 400;
  line-height: 1.2;
}

.incoming-actions { display: flex; gap: 12px; margin-top: 28px; }

.incoming-actions button {
  flex: 1;
  border-radius: 24px;
  padding: 12px 16px;
  font-weight: 600;
}

#incomingLater {
  border: 0;
  background: #3b4a54;
  color: #fff;
}

#stage {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: #0b141a;
  color: white;
  display: grid;
}

#grid {
  min-height: 0;
  height: 100%;
  display: grid;
  gap: 8px;
  padding: 12px 12px 118px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  grid-auto-rows: minmax(0, 1fr);
}

#waiting {
  position: absolute;
  left: 20px;
  right: 20px;
  top: 24px;
  margin: 0;
  text-align: center;
  color: rgba(255, 255, 255, 0.8);
  pointer-events: none;
}

.tile {
  position: relative;
  min-height: 0;
  border-radius: 12px;
  overflow: hidden;
  background: #1f2c33;
}

.tile video, #selfVideo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #1f2c33;
}

.tile.cam-off video { opacity: 0; }

#selfVideo { transform: scaleX(-1); }

.tile audio {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.tile .avatar-fill, #selfAvatar {
  position: absolute;
  inset: 0;
  width: auto;
  height: auto;
  border-radius: 0;
  font-size: 42px;
}

.cap {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 2;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(11, 20, 26, 0.55);
  color: white;
  font-size: 13px;
}

#pip {
  position: absolute;
  right: 14px;
  bottom: 118px;
  z-index: 6;
  width: min(168px, 34vw);
  aspect-ratio: 3 / 4;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  background: #1f2c33;
}

#pip .cap { font-size: 12px; }

#pip.cam-off video { opacity: 0; }

.call-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  gap: 18px;
  padding: 16px 12px calc(18px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.55));
}

.ctl {
  width: 76px;
  min-height: 76px;
  border: 0;
  border-radius: 50%;
  background: #233138;
  color: white;
  display: grid;
  place-items: center;
  gap: 2px;
  padding-top: 8px;
}

.ctl span { font-size: 11px; }

.ctl .when-off { display: none; }

.ctl.is-off .when-on { display: none; }

.ctl.is-off .when-off { display: block; }

.ctl.is-off { background: #3b4a54; }

.ctl.danger { background: var(--hang); }

body.in-call #thread {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  height: min(72dvh, 640px);
  transform: translateY(110%);
  transition: transform 180ms ease;
  box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.28);
}

body.in-call.chat-open #thread { transform: none; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 50;
  max-width: min(440px, calc(100% - 24px));
  padding: 10px 14px;
  border-radius: 8px;
  background: #233138;
  color: #e9edef;
  font-size: 14px;
  line-height: 1.35;
}

.bubble img.photo {
  display: block;
  max-width: min(280px, 70vw);
  border-radius: 6px;
  margin-bottom: 4px;
}

.bubble img.sticker {
  width: 128px;
  height: 128px;
  object-fit: contain;
  display: block;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  flex: none;
}

#composer .icon-btn { width: 36px; height: 36px; }

#stickerBox, #admin, #cipherBox, #adminAuth {
  position: absolute;
  z-index: 5;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
}

#emojiBox {
  position: absolute;
  z-index: 6;
  left: 8px;
  right: 8px;
  bottom: 68px;
  height: min(360px, 46dvh);
  padding: 0;
  overflow: hidden;
  background: transparent;
  border: 0;
}

#emojiBox emoji-picker {
  width: 100%;
  height: 100%;
  --num-columns: 8;
}

#setAvatar { width: 64px; height: 64px; font-size: 22px; cursor: pointer; border: 0; }

#avatarBtn {
  margin-top: 4px;
  border: 0;
  background: transparent;
  color: var(--wa);
  padding: 0;
  font: inherit;
  font-size: 13px;
}

#stickerBox {
  left: 12px;
  right: 12px;
  bottom: 72px;
  max-height: 240px;
  overflow: auto;
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

#stickerBox button {
  width: 72px;
  height: 72px;
  border: 0;
  background: transparent;
  padding: 0;
}

#stickerBox img { width: 72px; height: 72px; object-fit: contain; }

#cipherBox, #adminAuth {
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  width: min(360px, calc(100% - 32px));
  border-radius: 12px;
  padding: 16px;
}

#admin {
  position: fixed;
  z-index: 35;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: grid;
  place-items: center;
  padding: 16px;
}

#admin .sheet {
  width: min(520px, 100%);
  max-height: min(86dvh, 760px);
  overflow: auto;
  background: var(--panel);
  color: var(--ink);
  border-radius: 12px;
  padding: 16px;
}

#admin h2 { margin: 0 0 8px; font-size: 20px; }

#admin section { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }

#admin h3 { margin: 0 0 8px; font-size: 15px; }

.row { display: flex; gap: 8px; align-items: center; }

.row input, #admin textarea { flex: 1; }

#admin textarea { min-height: 64px; border: 0; border-radius: 8px; background: var(--field); color: var(--ink); padding: 10px; }

.pack { display: grid; gap: 6px; margin-top: 10px; }

.sticker-mini { width: 48px; height: 48px; object-fit: contain; }

.ios-note { color: var(--muted); font-size: 13px; line-height: 1.4; }

#settings {
  position: fixed;
  inset: 0;
  z-index: 28;
  background: var(--chat);
  color: var(--ink);
  display: flex;
  flex-direction: column;
}

.set-head {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 56px;
  padding: 0 8px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.set-head b { font-size: 19px; font-weight: 500; }

.set-head button {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  display: grid;
  place-items: center;
}

.set-head svg, .set-ico svg { width: 24px; height: 24px; }

.set-body { overflow: auto; padding: 8px 0 32px; }

.set-profile {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 12px 16px 8px;
  padding: 14px;
  border-radius: 12px;
  background: var(--panel);
}

.set-profile b { display: block; font-size: 17px; }
.set-profile span { color: var(--muted); font-size: 13px; }

#settings section { margin: 18px 16px 0; }
#settings h3 { margin: 0 0 8px; color: var(--wa); font-size: 14px; font-weight: 600; }
.set-label { margin: 0 0 8px; color: var(--muted); font-size: 13px; }

.theme-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.theme-pick button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: center;
}

.swatch {
  display: block;
  height: 108px;
  border-radius: 10px;
  background-repeat: repeat;
  background-position: center;
  border: 3px solid transparent;
  box-shadow: inset 0 0 0 1px var(--line);
}

.swatch.light {
  background-color: #f8f8f8;
  background-image: url('/wall-light.png');
  background-size: 140px auto;
}

.swatch.dark {
  background-color: #0b141a;
  background-image: url('/wall-dark.png');
  background-size: 140px auto;
}

.theme-pick button.is-on .swatch { border-color: var(--wa); }
.theme-pick button.is-on { color: var(--wa); font-weight: 600; }

.set-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 0;
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
  padding: 12px;
  text-align: left;
}

.set-ico {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--field);
  color: var(--wa);
  display: grid;
  place-items: center;
  flex: none;
}

.set-row-text { display: grid; }
.set-row-text small { color: var(--muted); font-size: 13px; }
#settings .ios-note { margin: 10px 2px 0; }

#adminBtn { width: auto; padding: 0 10px; border-radius: 16px; }

#admin button, #adminAuth button, #cipherBox button {
  border: 0;
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  padding: 8px 12px;
}

#admin .primary, #adminAuth .primary, #cipherBox .primary {
  background: var(--wa);
  color: #fff;
}

@media (max-width: 800px) {
  body::before { display: none; }
  #shell { padding: 0; }
  html:not(.crew-v2) #layout { grid-template-columns: 1fr; }
  aside { border-right: 0; }
  html:not(.crew-v2) #thread { display: none; }
  html:not(.crew-v2) body.chat-open aside { display: none; }
  html:not(.crew-v2) body.chat-open #thread { display: grid; }
  html:not(.crew-v2) body[data-main-tab="you"] aside { display: grid; }
  html:not(.crew-v2) body[data-main-tab="you"] #thread { display: none; }
  #backToChats { display: grid; }
  .credit-float { bottom: 4px; }
  body.chat-open .credit-float { display: none; }
  #log { padding-inline: 12px; }
  .bubble { max-width: 86%; }
  h1 { font-size: 26px; }
}

@media (prefers-reduced-motion: reduce) {
  body.in-call #thread { transition: none; }
}
