:root{font:15px system-ui,sans-serif;color:#172842;background:#edf2f9;--blue:#175ddd}*{box-sizing:border-box}body{margin:0}button,input,select{font:inherit}button{cursor:pointer;border:0;border-radius:10px;padding:10px 14px;background:var(--blue);color:white}button:focus-visible,input:focus-visible,select:focus-visible{outline:2px solid #0097ed;outline-offset:2px}input,select{border:1px solid #dbe4f1;border-radius:10px;padding:11px;background:#fff;color:inherit;min-width:0}main{display:grid;grid-template-columns:minmax(285px,340px) 1fr;height:100dvh;max-width:1500px;margin:auto;background:white}aside,section{display:flex;flex-direction:column;min-height:0;min-width:0}aside{border-right:1px solid #dbe4f1;padding:0 18px}header.brand{background:#0a1935;margin:0 -18px 14px;color:#b4cae9;display:grid;justify-items:center;padding:15px 12px;gap:4px}.brand img{max-width:180px;width:70%;height:74px;object-fit:contain}.brand span,footer,small{font-size:.82rem;color:#647994}.brand span{color:#c1d7f4}.toolbar,.chathead,#composer,.actions{display:flex;align-items:center;gap:12px}.toolbar{justify-content:space-between;margin-bottom:10px}h1,h2{margin:0;font-size:1.16rem}nav{display:flex;gap:5px;margin:12px 0}nav button,.actions button:first-child{background:#edf3fc;color:#224268;padding:7px 9px}nav button[aria-pressed=true]{background:#d4e5ff;color:#084cae}#threads,#messages{overflow:auto;flex:1}.thread{display:block;width:100%;text-align:left;background:white;color:#172842;padding:12px;margin:2px 0}.thread[aria-current=true]{background:#e6efff}.thread small{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin-top:4px}footer{padding:14px 0}.chathead{min-height:74px;padding:12px 24px;border-bottom:1px solid #dbe4f1}#messages{background:#f2f6fc;padding:24px;display:flex;flex-direction:column;gap:12px}.bubble{align-self:flex-start;max-width:min(85%,640px);padding:11px 14px;background:white;border-radius:12px;white-space:pre-wrap;overflow-wrap:anywhere}.bubble.mine{align-self:flex-end;background:#dceaff}.bubble small{display:block;margin-bottom:4px}#composer{padding:14px 24px}#composer input{flex:1}#back{display:none}dialog{width:min(420px,calc(100% - 32px));border:0;border-radius:16px;padding:24px;color:inherit}dialog::backdrop{background:#07153288}dialog label{display:grid;gap:5px;margin:12px 0}dialog label[hidden]{display:none}fieldset{border:1px solid #dbe4f1;border-radius:10px}#people label{display:flex;align-items:center;gap:8px}.actions{justify-content:flex-end}#error{color:#a92d28}.empty{color:#526982;margin:8px 0}@media(max-width:670px){main{display:block}aside,#chat{height:100%}#chat{display:none}.open #chat{display:flex}.open aside{display:none}#back{display:block}.chathead,#composer,#messages{padding-left:14px;padding-right:14px}}
[hidden]{display:none!important}#login{min-height:100dvh;display:grid;place-items:center;padding:24px}#signin{background:white;border-radius:18px;padding:26px;width:min(400px,100%);box-shadow:0 12px 38px #0a193519}#signin img{width:100%;height:90px;object-fit:contain;background:#0a1935;border-radius:12px;margin-bottom:18px}#signin label{display:grid;gap:5px;margin:14px 0}#login-status,#status{min-height:1em;margin:8px 0 0}#logout{background:#edf3fc;color:#224268}

/* Keep the app within the visible mobile viewport and allow panel scrolling. */
body { overflow: hidden; }
main { height: 100vh; height: 100dvh; }
#login { height: 100vh; height: 100dvh; min-height: 0; overflow: auto; }
@media (any-pointer: coarse) {
  html, body, *, dialog { touch-action: pan-x pan-y; }
  input, select { font-size: 16px; }
}
@media (max-width: 670px) {
  main {
    padding-top: env(safe-area-inset-top);
    padding-right: env(safe-area-inset-right);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
  }
  aside { border-right: 0; }
  #login {
    padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
      max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  }
  nav { flex-wrap: wrap; }
  dialog { max-height: 85dvh; }
}

:root {
  color-scheme: dark;
  color: #f2f5ff;
  background: #101420;
  --blue: #345de4;
  --panel: #141a29;
  --line: #2b354b;
  --muted: #aab7d1;
  --accent: #98b4ff;
}
main, aside, .chathead, #composer { background: var(--panel); }
aside { border-color: var(--line); padding: 0 20px; }
header.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  padding: 18px 0;
  background: transparent;
}
.brand img { width: 34px; height: 34px; object-fit: cover; border-radius: 10px; }
.brand span { color: var(--accent); font-weight: 750; letter-spacing: .12em; }
.toolbar h1 { font-size: 2rem; letter-spacing: -.035em; }
#new, #back, #composer button {
  width: 46px;
  height: 46px;
  flex: none;
  padding: 0;
  border-radius: 50%;
  font-size: 1.55rem;
}
#back { background: #26314a; }
input, select { background: #1d2639; border-color: var(--line); }
input::placeholder { color: var(--muted); }
#search, #composer input { border-radius: 24px; padding-inline: 16px; }
nav { gap: 7px; }
nav button, .actions button:first-child, #logout {
  border-radius: 18px;
  background: #222c43;
  color: #dbe4fb;
}
nav button[aria-pressed=true] { background: #344b86; color: #fff; }
.thread {
  display: flex;
  align-items: center;
  gap: 13px;
  background: transparent;
  color: inherit;
  margin: 0;
  padding: 12px 9px;
  min-height: 69px;
  border-bottom: 1px solid var(--line);
  border-radius: 12px;
}
.thread:hover, .thread[aria-current=true] { background: #243353; }
.thread-info, .chathead > div:last-child { min-width: 0; }
.thread strong, .chathead h2 { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  width: 45px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  flex: none;
  border-radius: 50%;
  background: #293c6b;
  color: #e4edff;
  font-weight: 750;
}
.avatar-group { background: #47356a; color: #ebdfff; }
.avatar-group::before {
  content: '';
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 10px 3px 0 -1px currentColor;
  transform: translate(-4px, -5px);
}
.avatar-group { position: relative; font-size: 0; }
.avatar-group::after {
  content: '';
  position: absolute;
  width: 17px;
  height: 7px;
  border-radius: 9px 9px 3px 3px;
  background: currentColor;
  transform: translate(-2px, 6px);
}
.avatar-broadcast { background: #194849; color: #adf2e7; }
.chathead { border-color: var(--line); }
#messages {
  background: radial-gradient(ellipse at top right, #1b2946, #0f1421 62%);
  padding-top: 26px;
}
.bubble { background: #242e45; border-radius: 5px 16px 16px; }
.bubble.mine { background: #2c4591; border-radius: 16px 5px 16px 16px; }
.bubble small { color: #becdff; font-weight: 700; }
.bubble time { display: block; text-align: right; color: #c5d1ee; font-size: .72rem; margin-top: 5px; }
footer, small, .empty { color: var(--muted); }
#chat-status { margin: 0; padding: 8px 14px; color: #ffd0cd; background: #472f3e; }
#composer { border-top: 1px solid var(--line); }
#signin, dialog { background: var(--panel); border: 1px solid var(--line); }
fieldset { border-color: var(--line); }
#error { color: #ffadac; }
@media (max-width: 670px) {
  aside { padding-inline: 14px; }
  header.brand { padding-block: 10px; }
  nav { flex-wrap: nowrap; overflow: auto; padding: 3px; }
  nav button { flex: none; }
  .chathead { min-height: 66px; gap: 9px; }
  #composer { padding-block: 9px; }
}

.access-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 26px;
  width: min(400px, 100%);
}
.access-card img { width: 100%; height: 90px; object-fit: contain; margin-bottom: 16px; }
.access-card label { display: grid; gap: 5px; margin: 14px 0; }
#login a { color: var(--accent); }
#login button:disabled { opacity: .6; cursor: wait; }

/* Keep the inbox navigation available while the conversation list scrolls. */
#workspace {
  --panel: #14151d;
  --line: #30323e;
  --muted: #b1b4c6;
  --accent: #bdbeff;
  --blue: #6156df;
}
#workspace aside { background: #111219; }
#workspace .brand { padding-block: 13px; }
#workspace .toolbar h1 { font-size: clamp(2rem, 8vw, 2.8rem); }
#workspace .thread { min-height: 74px; border-radius: 8px; padding-inline: 4px; }
#workspace .thread:hover, #workspace .thread[aria-current=true] { background: #222438; }
#workspace .avatar { width: 50px; }
#workspace .chathead .avatar { width: 41px; }
#workspace .avatar-direct { background: #344387; }
#workspace .avatar-group { background: #573675; }
#workspace .avatar-broadcast { background: #1d5555; }
#workspace #messages {
  background: radial-gradient(ellipse at top right, #242443, #13141d 66%);
}
#workspace .bubble.mine { background: #40388b; }
.inbox-footer {
  --dock-height: 76px;
  flex: 0 0 auto;
  position: relative;
  z-index: 1;
  margin-block-start: calc(-1 * var(--dock-height));
  padding: 0 0 max(12px, env(safe-area-inset-bottom));
  pointer-events: none;
}
#workspace #threads { padding-block-end: 84px; }
.inbox-footer #status:empty { display: none; }
.inbox-footer #status {
  margin: 0 12px 6px;
  padding: 5px 8px;
  border-radius: 9px;
  background: #181b2a;
  pointer-events: auto;
}
.inbox-dock {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: center;
  gap: 2px;
  margin: 0;
  padding: 5px;
  border: 1px solid rgba(212, 214, 255, .26);
  border-radius: 38px;
  background: #27283b;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), 0 8px 24px rgba(3, 5, 15, .48);
  pointer-events: auto;
}
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .inbox-dock {
    background: linear-gradient(135deg, rgba(128, 137, 217, .23), rgba(63, 67, 122, .08) 56%),
      rgba(29, 30, 45, .62);
    -webkit-backdrop-filter: blur(10px) saturate(1.45);
    backdrop-filter: blur(10px) saturate(1.45);
  }
}
.inbox-dock button {
  display: grid;
  grid-template-rows: 28px 1fr;
  place-items: center;
  gap: 4px;
  min-height: 64px;
  min-width: 0;
  padding: 8px 2px 6px;
  border-radius: 32px;
  background: transparent;
  color: #f5f4ff;
  font-size: clamp(.7rem, 3.2vw, .84rem);
  font-weight: 650;
  line-height: 1.1;
}
.inbox-dock button[aria-pressed=true] {
  background: linear-gradient(145deg, rgba(148, 134, 255, .40), rgba(75, 71, 137, .52));
  box-shadow: inset 0 1px 1px rgba(200, 200, 255, .28), 0 2px 7px rgba(12, 10, 25, .25);
}
.inbox-dock button:focus-visible { outline-offset: -2px; }
.inbox-dock .dock-icon {
  display: block;
  width: 28px;
  height: 28px;
  background: url("dock-icons.png") 0 center / 400% 100% no-repeat;
}
.inbox-dock [data-section=group] .dock-icon { background-position-x: 33.333%; }
.inbox-dock [data-section=broadcast] .dock-icon { background-position-x: 66.667%; }
.inbox-dock #open-profile .dock-icon { background-position-x: 100%; }
.dock-sections {
  container-type: inline-size;
  grid-template-columns: minmax(0, .76fr) minmax(0, .90fr) minmax(0, 1.52fr) minmax(0, .98fr) minmax(0, .76fr);
  gap: 4px;
}
.dock-sections button { padding-inline: 1px; }
.dock-sections .dock-label {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: clamp(.60rem, 3.55cqi, .76rem);
}
.dock-sections .community-icon {
  display: grid;
  grid-template-columns: repeat(2, 9px);
  grid-template-rows: repeat(2, 9px);
  place-content: center;
  gap: 3px;
  background: none;
}
.community-icon span { border: 1.6px solid currentColor; border-radius: 3px; }
.community-icon span:nth-child(2) { transform: translateY(-2px); }
.community-icon span:nth-child(4) { transform: translateY(-2px); }
.inbox-dock #open-profile .dock-icon:has(img:not([hidden])) { background-image: none; }
.dock-icon img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: inset 0 0 0 1px #b5a6f9;
}
.dock-icon img[hidden] { display: none; }
.profile-form { text-align: center; }
.profile-logo { width: 72px; height: 72px; object-fit: contain; border-radius: 50%; background: #202439; padding: 8px; }
.profile-form p { overflow-wrap: anywhere; }
.profile-form .actions { margin-top: 20px; }

#composer { position: relative; }
#composer #emoji-toggle { background: #292b40; color: #e1e0ff; }
#composer #emoji-list {
  position: absolute;
  z-index: 1;
  bottom: calc(100% + 8px);
  left: 14px;
  display: grid;
  width: min(365px, calc(100% - 28px));
  gap: 8px;
  padding: 10px;
  max-height: min(55dvh, 370px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #1e2030;
  box-shadow: 0 8px 22px #09091088;
}
#composer #emoji-list button { width: auto; min-height: 38px; height: auto; background: #292b40; color: #e1e0ff; }
#expression-tabs { display: flex; gap: 8px; }
#composer #expression-tabs [aria-pressed=true] { background: #4e4a91; }
#emoji-panel select { color: inherit; background: #292b40; padding: 6px; border: 1px solid var(--line); border-radius: 8px; }
#emoji-grid, #sticker-grid { display: grid; gap: 4px; margin-top: 8px; }
#emoji-grid { grid-template-columns: repeat(auto-fit, minmax(38px, 1fr)); }
#composer #emoji-grid button { padding: 2px; font-size: 1.35rem; }
#sticker-grid { grid-template-columns: repeat(auto-fit, minmax(68px, 1fr)); }
#sticker-grid img { display: block; margin: auto; width: 56px; height: 56px; object-fit: contain; }
#composer #sticker-grid button { width: 100%; padding: 4px; margin-bottom: 3px; }
#composer #sticker-grid .remove-sticker { font-size: .8rem; min-height: 34px; }
.inline-attachment.sticker { width: min(152px, 38vw); min-width: 0; }
.inline-attachment.sticker .inline-attachment-frame { background: transparent; }
.inline-attachment.sticker img { width: 100%; max-height: 152px; object-fit: contain; }
.bubble.sticker-bubble { background: transparent; }

.read-mark { display: block; font-size: .85rem; text-align: right; color: #d9d7ed; letter-spacing: -.08em; }
.read-mark.seen { color: #91eaff; }
#background-settings { margin-left: auto; font-size: .8rem; background: #282b42; }
#workspace #messages[data-background=ocean] { background: radial-gradient(ellipse at top right, #1c4a61, #102237 70%); }
#workspace #messages[data-background=forest] { background: radial-gradient(ellipse at top right, #265440, #112823 70%); }
#workspace #messages[data-background=night] { background: #101116; }
.profile-form input[type=file] { max-width: 100%; }

#workspace aside {
  background: #0e0f15;
  --line: #282936;
}
#workspace .toolbar { margin-bottom: 15px; }
#workspace .toolbar h1 { letter-spacing: -.045em; line-height: 1.05; }
.inbox-search {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 13px;
  border: 1px solid #303241;
  border-radius: 15px;
  background: #1b1c28;
  color: var(--muted);
}
.inbox-search span { font-size: 1.5rem; line-height: 1; }
.inbox-search #search { flex: 1; padding: 10px 0; border: 0; background: transparent; }
.inbox-search:focus-within { border-color: var(--accent); }
#workspace .thread {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr) auto;
  column-gap: 11px;
  align-items: center;
  min-height: 75px;
}
#workspace .thread strong { font-size: 1rem; }
#workspace .thread small { font-size: .86rem; }
#workspace .thread time { align-self: start; padding-top: 4px; color: #b7b5c8; font-size: .76rem; white-space: nowrap; }

.setup { max-width: 420px; }
.setup h1 { font-size: 1.45rem; margin: 14px 0; }
.setup button { margin: 6px 4px 0 0; }
.mark { display: block; overflow: hidden; aspect-ratio: 1.37; }
.mark img, .setup .mark img, .brand .mark img {
  display: block;
  width: 100%;
  height: auto;
  max-width: none;
  object-fit: initial;
  margin: 0;
  background: transparent;
  border-radius: 0;
}
.setup-mark { width: 130px; margin: 0 auto 14px; }
.brand-mark { width: 52px; }
#archive-messages { max-height: 50vh; overflow: auto; }
#archive-messages details { padding-block: 8px; border-bottom: 1px solid var(--line); }
#archive-messages p { overflow-wrap: anywhere; white-space: pre-wrap; }

#composer #attach-file {
  flex: 0 0 auto;
  min-width: 38px;
  padding-inline: 6px;
  background: #292b40;
}
#composer #attach-file:has(#community-attach-label:not([hidden])) {
  width: auto;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding-inline: 7px;
  font-size: .78rem;
}
#attachment-draft {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 14px;
  background: var(--panel);
  border-top: 1px solid var(--line);
}
#attachment-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bubble .chat-attachment {
  display: block;
  max-width: 100%;
  padding: 6px 0;
  color: #d5e5ff;
  text-decoration: underline;
  background: transparent;
  text-align: left;
  overflow-wrap: anywhere;
}
@media (max-width: 420px) {
  #composer { gap: 7px; }
  #composer input { padding-inline: 10px; }
}

#media-preview { width: min(720px, calc(100% - 28px)); max-height: min(90dvh, 760px); }
#media-preview-title { overflow-wrap: anywhere; }
#media-preview-status:empty { display: none; }
#media-preview-content img, #media-preview-content video {
  display: block;
  margin: 12px auto;
  max-width: 100%;
  max-height: 62dvh;
  width: auto;
  height: auto;
  object-fit: contain;
}
#media-preview .actions { margin-top: 12px; }

.inline-attachment {
  width: min(360px, 62vw);
  margin-block: 4px;
}
.inline-attachment-frame {
  overflow: hidden;
  border-radius: 10px;
  background: #191d2a;
}
.inline-attachment-frame img, .inline-attachment-frame video {
  display: block;
  width: 100%;
  max-height: 48vh;
  object-fit: contain;
}
.inline-attachment-frame video { min-height: 112px; }
.inline-attachment-expand {
  display: block;
  width: 100%;
  padding: 0;
  border-radius: 0;
  background: transparent;
  cursor: zoom-in;
}
.inline-attachment-status {
  display: grid;
  place-items: center;
  min-height: 108px;
  margin: 0;
  padding: 12px;
  text-align: center;
  color: #ccd6f2;
}
.attachment-card { display: flex; align-items: center; gap: 10px; min-width: 0; }
.attachment-card > div { min-width: 0; }
.attachment-card-icon {
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  height: 38px;
  border-radius: 10px;
  background: #232a46;
  font-size: 21px;
  color: #d5e5ff;
}
.attachment-card .chat-attachment { padding-block: 0; }
.attachment-card small { margin: 3px 0 0; }
#media-preview-content audio { display: block; width: 100%; margin: 14px 0; }

#incoming-attachment {
  position: fixed;
  z-index: 5;
  inset-block-start: max(14px, env(safe-area-inset-top));
  inset-inline-end: max(14px, env(safe-area-inset-right));
  width: min(360px, calc(100% - 28px));
  max-height: calc(100dvh - 28px);
  overflow: auto;
  gap: 12px;
  padding: 14px;
  color: inherit;
  background: #1c2133;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 12px 32px #07091380;
}
#incoming-attachment[hidden] { display: none; }
#incoming-attachment header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
#incoming-attachment-close { padding: 6px 12px; background: #343b53; }
#incoming-attachment-media .inline-attachment { width: 100%; }
#incoming-attachment-media :is(img, video) { max-height: min(34dvh, 240px); }
#incoming-attachment-open { align-self: flex-start; }

.avatar { overflow: hidden; }
.avatar-group.avatar-has-photo::before, .avatar-group.avatar-has-photo::after { display: none; }
.avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
.message-sender, #current-members li, #available-members label, #people label {
  display: flex;
  align-items: center;
  gap: 8px;
}
#current-members { list-style: none; padding: 0; display: grid; gap: 8px; }
#current-members, #available-members { max-height: 24dvh; overflow: auto; }
#members-dialog { max-height: 85dvh; }
#invite-members[hidden], #add-members[hidden] { display: none; }
.message-sender .avatar, #current-members .avatar, #available-members .avatar, #people .avatar,
#incoming-sender-avatar .avatar { flex: 0 0 30px; width: 30px; height: 30px; font-size: .8rem; }
.bubble .message-sender { display: flex; }
#incoming-attachment header strong { flex: 1; }

#workspace .chathead {
  flex: 0 0 auto;
  min-height: 74px;
  gap: 8px;
  padding-block: 9px;
  background: linear-gradient(115deg, #202546, #191d30 62%, #1c2540);
  border-color: #363e60;
}
#workspace .chathead #back,
#workspace .chat-identity,
#workspace .chat-call-actions {
  min-height: 48px;
  border: 1px solid rgba(176, 193, 246, .26);
  border-radius: 24px;
  background: rgba(67, 79, 125, .42);
  box-shadow: inset 0 1px 0 rgba(216, 222, 255, .10);
}
#workspace .chathead #back { flex: 0 0 46px; padding: 0; }
#workspace .chathead #back span {
  display: block;
  width: 11px;
  height: 11px;
  margin: 0 auto;
  border: solid #f0f4ff;
  border-width: 0 0 2px 2px;
  transform: translateX(2px) rotate(45deg);
}
#workspace .chat-identity {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  min-width: 0;
  gap: 9px;
  margin: 0;
  padding: 4px 10px 4px 5px;
  text-align: left;
}
.chat-identity-text { display: grid; min-width: 0; }
.chat-identity-text #title, .chat-identity-text #detail {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-identity-text #title { color: #f5f7ff; font-size: 1rem; font-weight: 750; }
.chat-identity-text #detail { color: #c1c9e6; font-size: .76rem; }
.chat-identity:not(:disabled):hover { border-color: #8595de; }
.chat-identity:disabled { cursor: default; }
.chat-identity #chat-avatar { flex-shrink: 0; }
#workspace .chathead .avatar { width: 37px; }
#workspace .chat-call-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  padding: 0 2px;
}
#workspace .chat-call-actions[hidden] { display: none; }
.chat-call-actions button { padding: 0; width: 43px; height: 44px; background: transparent; border-radius: 20px; }
.chat-call-actions button:hover { background: rgba(139, 159, 221, .22); }
.chat-call-actions :is(.chat-video-icon, .chat-phone-icon) {
  --call-icon-position: 0%;
  display: block;
  width: 27px;
  height: 27px;
  margin: auto;
  background: url("call-icons.png") var(--call-icon-position) center / 200% 100% no-repeat;
}
.chat-call-actions .chat-phone-icon { --call-icon-position: 100%; }

@supports (mask-image: url("call-icons.png")) or (-webkit-mask-image: url("call-icons.png")) {
  .chat-call-actions :is(.chat-video-icon, .chat-phone-icon) {
    background: var(--chat-call-icon-color, #fff);
    -webkit-mask: url("call-icons.png") var(--call-icon-position) center / 200% 100% no-repeat;
    mask: url("call-icons.png") var(--call-icon-position) center / 200% 100% no-repeat;
  }
}
@supports not ((mask-image: url("call-icons.png")) or (-webkit-mask-image: url("call-icons.png"))) {
  [data-theme=light] .chat-call-actions :is(.chat-video-icon, .chat-phone-icon) { filter: brightness(0); }
}
#call-dialog {
  position: fixed;
  inset: 0;
  inline-size: 100%;
  block-size: 100%;
  block-size: 100dvh;
  max-inline-size: none;
  max-block-size: none;
  margin: 0;
  border: 0;
  border-radius: 0;
  overflow: auto;
  padding: max(24px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(22px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  text-align: center;
  color: #f5f5ff;
  background:
    radial-gradient(ellipse at 50% 36%, #30345d 0%, transparent 54%),
    radial-gradient(circle at 93% 91%, #143b43 0%, transparent 44%),
    linear-gradient(150deg, #171e35 0%, #101322 60%, #121829 100%);
}
#call-dialog[open] {
  display: grid;
  grid-template-rows: auto minmax(130px, 1fr) auto;
  gap: 16px;
  align-items: center;
}
.call-header {
  position: relative;
  inline-size: min(620px, 100%);
  margin-inline: auto;
  padding: 0 52px;
}
.call-heading { min-width: 0; }
#call-kind {
  margin: 0 0 6px;
  color: #adbafa;
  font-size: .75rem;
  font-weight: 720;
  letter-spacing: .09em;
  text-transform: uppercase;
}
#call-title { font-size: clamp(1.55rem, 5vw, 2.3rem); overflow-wrap: anywhere; }
#call-state { margin: 6px auto 0; color: #c7cbea; font-size: .9rem; }
#call-elapsed { display: inline-block; margin-top: 6px; color: #b0ebde; font-variant-numeric: tabular-nums; }
#call-elapsed[hidden] { display: none; }
#call-minimize {
  position: absolute;
  inset-block-start: 2px;
  inset-inline-start: 0;
  inline-size: 44px;
  block-size: 44px;
  padding: 0;
  border: 1px solid #7980b451;
  border-radius: 16px;
  background: #333a5b88;
  font-size: 1.35rem;
}
.call-stage { position: relative; place-self: stretch; display: grid; place-items: center; min-height: 0; }
#call-avatar {
  display: grid;
  place-items: center;
  padding: 10px;
  border: 1px solid #8c9be070;
  border-radius: 50%;
  background: #919bf319;
  box-shadow: 0 0 0 10px #96a4fa0b, 0 18px 48px #0b102a99;
}
#call-avatar .avatar {
  width: clamp(120px, min(51vw, 29dvh), 250px);
  background: linear-gradient(135deg, #5658ad, #334574);
  font-size: clamp(2rem, 9vw, 4rem);
}
#call-videos { position: absolute; inset: 0; width: min(740px, 100%); margin-inline: auto; }
#call-videos video { display: block; border-radius: 18px; }
#call-remote-video { width: 100%; height: 100%; object-fit: contain; opacity: 0; }
#call-remote-video.is-playing { opacity: 1; background: #0c0e1b; }
#call-local-video {
  position: absolute;
  inset-inline-end: 9px;
  inset-block-end: 9px;
  width: clamp(72px, 22%, 144px);
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border: 1px solid #b7c2f3;
  background: #151928;
  transform: scaleX(-1);
}
#call-local-video[hidden], #call-videos[hidden] { display: none; }
.call-controls {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 17px clamp(10px, 4vw, 34px);
  width: min(520px, 100%);
  margin-inline: auto;
  padding: 16px 10px;
  border: 1px solid #a6aff43e;
  border-radius: 28px;
  background: #2b314bba;
  box-shadow: 0 10px 32px #0a0d1d88;
  backdrop-filter: blur(12px);
}
.call-controls button {
  display: grid;
  justify-items: center;
  gap: 7px;
  align-content: start;
  width: 78px;
  padding: 0 1px;
  color: #f6f5ff;
  background: transparent;
  font-size: .76rem;
  font-weight: 620;
}
.call-controls button[hidden] { display: none; }
.call-symbol {
  position: relative;
  display: grid;
  place-items: center;
  width: 51px;
  height: 51px;
  border: 1px solid #99a6e34b;
  border-radius: 50%;
  background: #202639;
}
.call-symbol::before, .call-symbol::after { content: ''; position: absolute; }
.phone-symbol::before, .camera-symbol::before {
  width: 23px; height: 23px;
  background: url("call-icons.png") 0 center / 200% 100% no-repeat;
}
.phone-symbol::before { background-position-x: 100%; }
#call-end .call-symbol { background: #a93256; border-color: #df6d8f; }
#call-end .call-symbol::before { transform: rotate(135deg); }
#call-accept .call-symbol { background: #267b69; border-color: #65b7a5; }
.mic-symbol::before { width: 8px; height: 16px; top: 12px; border: 2px solid currentColor; border-radius: 7px; }
.mic-symbol::after { width: 17px; height: 13px; top: 20px; border: 2px solid currentColor; border-top: 0; border-radius: 0 0 9px 9px; }
.sound-symbol::before { width: 16px; height: 19px; transform: translateX(-3px); background: currentColor; clip-path: polygon(0 35%, 38% 35%, 85% 0, 85% 100%, 38% 65%, 0 65%); }
.sound-symbol::after { width: 17px; height: 17px; transform: translateX(5px); border-right: 2px solid currentColor; border-radius: 50%; }
#call-mute[aria-pressed=true] .call-symbol, #call-camera[aria-pressed=false] .call-symbol {
  background: #4b4278;
  border-color: #b6a6ff;
}
#call-return {
  position: fixed;
  z-index: 7;
  inset-block-start: max(12px, env(safe-area-inset-top));
  inset-inline-start: 50%;
  transform: translateX(-50%);
  background: #226958;
  border: 1px solid #78bad0;
  border-radius: 20px;
  white-space: nowrap;
}
@media (max-width: 380px), (max-height: 500px) {
  .call-controls { gap: 8px; padding: 10px 4px; }
  .call-controls button { width: 66px; }
  .call-symbol { width: 43px; height: 43px; }
  #call-dialog[open] { gap: 8px; }
}
@media (max-width: 400px) {
  #workspace .chathead { gap: 6px; padding-inline: 8px; }
  #workspace .chathead #back { flex-basis: 42px; }
  #workspace .chat-identity { gap: 6px; padding-inline-end: 6px; }
  .chat-call-actions button { width: 40px; }
}

.inbox-toolbar-actions {
  display: flex;
  position: relative;
  align-items: center;
  gap: 6px;
}
#workspace .inbox-toolbar-actions > button {
  display: grid;
  place-items: center;
  min-width: 39px;
  min-height: 39px;
  padding: 0 9px;
  border-radius: 20px;
}
#workspace .inbox-toolbar-actions > button[hidden] { display: none; }
#inbox-menu-toggle, #inbox-camera { background: #292b40; }
#inbox-menu-toggle { font-size: 1.25rem; line-height: 1; }
.inbox-camera-icon {
  position: relative;
  width: 17px;
  height: 12px;
  border: 1.5px solid currentColor;
  border-radius: 4px;
}
.inbox-camera-icon::before, .inbox-camera-icon::after { content: ''; position: absolute; }
.inbox-camera-icon::before { width: 7px; height: 3px; top: -4px; left: 3px; border-radius: 2px 2px 0 0; background: currentColor; }
.inbox-camera-icon::after { width: 6px; height: 6px; inset: 2px auto auto 4px; border: 1.3px solid currentColor; border-radius: 50%; }
.inbox-menu {
  position: absolute;
  z-index: 5;
  inset: calc(100% + 8px) 0 auto auto;
  min-width: 178px;
  display: grid;
  gap: 4px;
  padding: 6px;
  border: 1px solid #4b4b70;
  border-radius: 15px;
  background: #23263b;
  box-shadow: 0 10px 30px #090911aa;
}
.inbox-menu[hidden] { display: none; }
.inbox-menu button { width: 100%; text-align: left; background: transparent; }
.inbox-menu button:hover { background: #3a366b; }
#workspace aside > nav { flex-wrap: nowrap; overflow-x: auto; flex-shrink: 0; scrollbar-width: thin; padding-bottom: 2px; }
#workspace aside > nav button { flex: 0 0 auto; white-space: nowrap; }
#workspace #inbox-archived {
  align-self: flex-start;
  min-height: 38px;
  margin-block: 0 5px;
  padding: 6px 10px;
  background: transparent;
  color: #c8c9de;
}
#inbox-feedback { padding: 5px 0; margin: 0; font-size: .8rem; color: #d2cdfa; }
#workspace .thread.inbox-selectable { grid-template-columns: 20px 44px minmax(0, 1fr) auto; }
#workspace .thread.inbox-selectable .avatar { width: 44px; }
.inbox-selection-marker {
  display: grid;
  place-items: center;
  width: 19px;
  height: 19px;
  border: 1px solid #8079a8;
  border-radius: 50%;
  font-size: .83rem;
}
.thread[aria-pressed=true] .inbox-selection-marker { color: #fff; background: #6658db; border-color: #a28dff; }
.inbox-row-meta { display: grid; justify-items: end; gap: 4px; align-self: start; padding-block-start: 3px; }
#workspace .inbox-row-meta time { padding: 0; }
.inbox-row-flags { color: #bcb8f1; font-size: .68rem; white-space: nowrap; }
.inbox-unread-badge {
  min-width: 19px;
  padding: 2px 5px;
  border-radius: 10px;
  text-align: center;
  background: #7468dc;
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
}
.inbox-dock[hidden] { display: none; }
.inbox-dock.inbox-selection-actions button {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 64px;
  line-height: 1.15;
  padding-inline: 4px;
}
.inbox-selection-actions button:disabled { opacity: .42; cursor: default; }
.inbox-selection-actions button:enabled:hover { background: #4b4484; }
@media (max-width: 375px) {
  #workspace .thread.inbox-selectable { column-gap: 5px; grid-template-columns: 19px 38px minmax(0, 1fr) auto; }
  #workspace .thread.inbox-selectable .avatar { width: 38px; }
}
.rotate-symbol { font-size: 1.55rem; }
.rotate-symbol::before, .rotate-symbol::after { content: none; }
#call-control-status { margin: 0; color: #d9d5fb; font-size: .82rem; }
#call-control-status:not([hidden]) { grid-row: 3; }
#call-local-video[data-facing=environment] { transform: none; }

#current-members .member-role { margin-inline-start: auto; color: var(--muted, #b8bdd2); }
#current-members .member-admin { margin-inline-start: auto; font-size: .85rem; padding: .36rem .55rem; }
#community-controls { margin-top: 1rem; }
#community-controls .actions { display: flex; flex-wrap: wrap; gap: .5rem; }
#delete-community { background: #812947; color: #fff; }

#community-bar { display: flex; gap: 8px; padding: 6px 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
#community-bar button { background: #292b40; color: #f3f3ff; padding: 6px 10px; }
#community-pin-banner { min-width: 0; display: flex; flex: 1 1 auto; align-items: center; gap: 8px; text-align: left; }
#community-pin-banner strong { flex: 0 0 auto; font-size: .82rem; }
#community-pin-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#community-dialog { width: min(480px, calc(100% - 24px)); max-height: 85dvh; overflow-y: auto; }
.community-tabs { display: flex; gap: 5px; flex-wrap: wrap; }
.community-tabs button { background: #292b40; }
.community-tabs [aria-pressed=true] { background: #514898; }
#community-dialog form:not([method=dialog]) { margin-block: 12px; }
#community-dialog h3 { margin-bottom: 8px; }
#community-pin-details p, #community-files li, #community-polls h3 { overflow-wrap: anywhere; }
#community-files { padding-inline-start: 18px; }
#community-files li { padding-block: 6px; }
.community-poll { display: grid; gap: 6px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.community-poll-option { display: flex; justify-content: space-between; align-items: center; gap: 8px; background: #292b40; text-align: left; }
.community-poll-option[aria-pressed=true] { background: #514898; }
.community-poll-choice { overflow-wrap: anywhere; }

#thread-photo-preview { display: grid; place-items: center; padding-block: 8px; }
#thread-photo-preview .avatar { width: 64px; height: 64px; }
#thread-photo-input { max-width: 100%; }
#thread-photo-status:empty { display: none; }

#avatar-editor { width: min(400px, calc(100% - 24px)); max-height: 88dvh; }
#avatar-editor h2 { margin-top: 0; }
.avatar-editor-stage {
  position: relative;
  width: min(240px, 60vw, 40dvh);
  margin: 8px auto 10px;
}
#avatar-editor-canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 50%;
  outline: 1px solid var(--line);
  cursor: grab;
  touch-action: none;
}
.avatar-editor-grid {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 50%;
  pointer-events: none;
}
.avatar-editor-grid span {
  position: absolute;
  background: rgba(255, 255, 255, .86);
  box-shadow: 0 0 2px 1px rgba(15, 20, 30, .68);
}
.avatar-editor-grid span:nth-child(-n+2) { inset-block: 0; width: 1px; }
.avatar-editor-grid span:nth-child(1) { left: 33.333%; }
.avatar-editor-grid span:nth-child(2) { left: 66.666%; }
.avatar-editor-grid span:nth-child(n+3) { inset-inline: 0; height: 1px; }
.avatar-editor-grid span:nth-child(3) { top: 33.333%; }
.avatar-editor-grid span:nth-child(4) { top: 66.666%; }
#avatar-editor-help { margin-block: 0 12px; color: var(--muted); font-size: .86rem; text-align: center; }
#avatar-editor-canvas:active { cursor: grabbing; }
#avatar-editor-canvas:focus-visible { outline: 2px solid #b2a9ff; }
#avatar-editor-zoom { width: 100%; }
#avatar-editor-status:empty { display: none; }

/* Day palette for the inbox, conversation and settings. */
:root[data-theme=light] {
  color-scheme: light;
  color: #202940;
  background: #f2f5fb;
  --blue: #3d45af;
  --panel: #fcfdff;
  --line: #d4dcee;
  --muted: #4e5b76;
  --accent: #304ba4;
}
[data-theme=light] #workspace {
  --blue: #3d45af;
  --panel: #fcfdff;
  --line: #d4dcee;
  --muted: #4e5b76;
  --accent: #304ba4;
}
[data-theme=light] #workspace aside {
  background: #f6f8fd;
  --line: #d4dcee;
}
[data-theme=light] input,
[data-theme=light] select { background: #f1f4fc; }
[data-theme=light] nav button,
[data-theme=light] .actions button:first-child,
[data-theme=light] #logout { background: #e9eef9; color: #2f3b64; }
[data-theme=light] nav button[aria-pressed=true] { background: #dce4fa; color: #28388d; }
[data-theme=light] .inbox-search,
[data-theme=light] .inbox-menu { background: #f5f7fd; border-color: var(--line); color: var(--muted); }
[data-theme=light] .inbox-menu button { background: transparent; color: #283653; }
[data-theme=light] .inbox-menu button:hover,
[data-theme=light] #workspace .thread:is(:hover, [aria-current=true]) { background: #e8edff; }
[data-theme=light] #workspace .thread time,
[data-theme=light] #workspace #inbox-archived,
[data-theme=light] #inbox-feedback { color: var(--muted); }
[data-theme=light] #inbox-menu-toggle,
[data-theme=light] #inbox-camera,
[data-theme=light] #workspace .chat-identity,
[data-theme=light] #workspace .chat-call-actions,
[data-theme=light] #workspace .chathead #back,
[data-theme=light] #composer #emoji-toggle,
[data-theme=light] #composer #attach-file,
[data-theme=light] #community-bar button { background: #e8edfb; color: #263761; border-color: var(--line); }
[data-theme=light] #workspace .chathead #back span { border-color: #263761; }
[data-theme=light] .chat-identity-text #title { color: #202940; }
[data-theme=light] .chat-identity-text #detail { color: var(--muted); }
[data-theme=light] #workspace #messages { background: radial-gradient(ellipse at top right, #eaf0ff, #f1f4fa 70%); }
[data-theme=light] #workspace #messages[data-background=ocean] { background: radial-gradient(ellipse at top right, #dfedf6, #eff6fc 70%); }
[data-theme=light] #workspace #messages[data-background=forest] { background: radial-gradient(ellipse at top right, #dfefe6, #f0f7f2 70%); }
[data-theme=light] #workspace #messages[data-background=night] { background: #e9edf6; }
[data-theme=light] .bubble { background: #fff; color: #29334c; box-shadow: 0 1px 4px #1f31551f; }
[data-theme=light] #workspace .bubble.mine { background: #dce6ff; }
[data-theme=light] #workspace .bubble.sticker-bubble { background: transparent; box-shadow: none; }
[data-theme=light] .bubble :is(time, small, .read-mark) { color: #4e5b76; }
[data-theme=light] .bubble .read-mark.seen { color: #304ba4; }
[data-theme=light] #incoming-attachment,
[data-theme=light] #composer #emoji-list { background: var(--panel); color: #202940; }
[data-theme=light] #emoji-panel select,
[data-theme=light] #composer #emoji-list button,
[data-theme=light] .community-tabs button,
[data-theme=light] .community-poll-option { background: #e9eef9; color: #2f3b64; }
[data-theme=light] #composer #expression-tabs [aria-pressed=true],
[data-theme=light] .community-poll-option[aria-pressed=true] { background: #d5e0fc; color: #243277; }
[data-theme=light] .inline-attachment-status { color: #4e5b76; }
[data-theme=light] .dock-sections {
  background: #f7f9ffec;
  border-color: #c2cbe4;
  box-shadow: 0 6px 20px #26385d26;
}
[data-theme=light] .dock-sections button { background: transparent; color: #283653; }
[data-theme=light] .dock-sections button[aria-pressed=true] { background: #dce4fa; color: #28388d; }
[data-theme=light] .dock-sections .dock-icon:not(.community-icon):not(:has(img:not([hidden]))) {
  filter: brightness(0) saturate(100%) opacity(.78);
}
[data-theme=light] #call-dialog { color: #f2f5ff; color-scheme: dark; }
[data-theme=light] #error { color: #922836; }
[data-theme=light] .bubble .chat-attachment { color: #304ba4; }
[data-theme=light] .chat-call-actions { --chat-call-icon-color: #263761; }
[data-theme=light] .inbox-footer #status {
  background: #f1f4fc;
  color: #29334c;
}

#threads .thread-swipe { position: relative; overflow: hidden; border-radius: 12px; }
#threads .thread-swipe > .thread { position: relative; z-index: 1; touch-action: pan-y; transition: transform .18s ease; }
#threads .thread-swipe[data-thread-action=delete] > .thread { transform: translateX(-86px); }
#threads .thread-swipe[data-thread-action=pin] > .thread { transform: translateX(86px); }
.thread-pin-action, .thread-delete-action {
  position: absolute; inset: 4px 0 4px auto; width: 82px; padding: 4px;
  background: #a32e51; color: #fff;
}
.thread-pin-action { inset-inline: 0 auto; background: var(--blue); }
#messages { overflow-x: hidden; }
#messages .bubble[data-pinnable] { position: relative; touch-action: pan-y; transition: transform .18s ease; }
#messages .bubble[data-pin-open] { transform: translateX(66px); }
.message-pin-action {
  position: absolute; inset: 50% calc(100% + 5px) auto auto; transform: translateY(-50%);
  min-width: 59px; padding: 7px 5px; white-space: nowrap; font-size: .82rem;
}
#chat-pinned-bar { display: flex; align-items: center; gap: 6px; padding: 6px 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
#chat-pinned-open { display: flex; flex: 1; min-width: 0; gap: 8px; text-align: left; }
#chat-pinned-open strong { flex: none; }
#chat-pinned-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#owned-chats-list { padding: 0; list-style: none; }
#owned-chats-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
#owned-chats-list span, #pinned-message-body { overflow-wrap: anywhere; }
#pinned-message-body { white-space: pre-wrap; }
#owned-chats-list button { flex: none; background: #a32e51; color: #fff; }
@media (prefers-reduced-motion: reduce) {
  #threads .thread-swipe > .thread, #messages .bubble[data-pinnable] { transition: none; }
}
