.chat-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  height: calc(72px + var(--lg-edge-top));
  padding: var(--lg-edge-top) calc(22px + var(--lg-edge-right)) 0 calc(22px + var(--lg-edge-left));
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--sidebar-border);
  flex: none;
  z-index: 5;
}

/* the pinned message, a slim bar under the header; a tap jumps to it */
.pinned-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
  padding: 0 calc(14px + var(--lg-edge-right)) 0 calc(18px + var(--lg-edge-left));
  min-height: 48px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--sidebar-border);
  z-index: 4;
}

.pinned-bar[hidden] {
  display: none;
}

.pinned-open {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
  background: none;
  border: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.pinned-open svg {
  flex: none;
  color: var(--accent);
}

/* several pins: a column of ticks, the one on show lit */
.pinned-ticks {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-self: stretch;
  justify-content: center;
  margin-right: -4px;
}

.pinned-ticks i {
  display: block;
  width: 3px;
  flex: 1;
  max-height: 10px;
  min-height: 3px;
  border-radius: 2px;
  background: var(--accent);
  opacity: 0.3;
}

.pinned-ticks i.is-on {
  opacity: 1;
}

.chat-item-pin {
  flex: none;
  display: inline-flex;
  color: var(--muted);
  opacity: 0.8;
  transform: rotate(35deg);
}

.pinned-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding-left: 10px;
  border-left: 2px solid var(--accent);
}

.pinned-text b {
  font-size: 12.5px;
  font-weight: 650;
  color: var(--accent);
}

.pinned-snippet {
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pinned-close {
  flex: none;
  width: 34px;
  height: 34px;
  color: var(--muted);
}

.chat-header .avatar {
  width: 42px;
  height: 42px;
  font-size: 16px;
}

.chat-head-text {
  min-width: 0;
  flex: 1;
}

.chat-head-text h1 {
  font-size: 16.5px;
  font-weight: 700;
  letter-spacing: -0.2px;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-head-text p {
  margin: 1px 0 0;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 18px;
}

.chat-head-text p.is-online {
  color: var(--accent);
  font-weight: 550;
}

.chat-head-text p.is-typing {
  color: var(--accent);
}

.online-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #3ec07a;
  margin-right: 6px;
  vertical-align: 1px;
  box-shadow: 0 0 0 3px rgba(62, 192, 122, 0.15);
}

.back-btn {
  display: none;
  margin-left: -6px;
}

/* ——— Day streaks ——— */

.chat-head-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.streak-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: none;
  height: 22px;
  padding: 0 8px 0 6px;
  border: 0;
  border-radius: 11px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: #fff;
  background: linear-gradient(145deg, var(--streak-soft), var(--streak-core));
  box-shadow: 0 2px 10px var(--streak-glow);
  cursor: pointer;
  transition: transform 0.14s var(--ease), opacity 0.14s var(--ease);
}

.streak-chip svg {
  filter: drop-shadow(0 1px 1px rgba(90, 20, 0, 0.25));
}

.streak-chip:hover {
  transform: translateY(-1px);
}

.streak-chip:active {
  transform: scale(0.94);
}

/* A series nobody extended today burns grey, on every device at once: the
   payload carries the server day, so the chip does not wait for a push. */
.streak-chip.is-dim,
.chat-item-streak.is-dim {
  color: var(--muted);
  background: var(--surface-2);
  box-shadow: none;
}

.streak-chip.is-dim svg,
.chat-item-streak.is-dim svg {
  filter: none;
  opacity: 0.75;
}

.chat-item-streak {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex: none;
  height: 18px;
  padding: 0 6px 0 5px;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: #fff;
  background: linear-gradient(145deg, var(--streak-soft), var(--streak-core));
  box-shadow: 0 1px 6px var(--streak-glow);
  align-self: center;
}

.streak-chip.is-pop {
  animation: streak-pop 0.42s var(--ease);
}

.streak-chip.is-record {
  animation: streak-record 0.72s var(--ease);
}

@keyframes streak-pop {
  0% { transform: scale(1); }
  38% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

@keyframes streak-record {
  0% { transform: scale(1) rotate(0deg); box-shadow: 0 2px 8px var(--streak-glow); }
  30% { transform: scale(1.32) rotate(-7deg); box-shadow: 0 0 0 8px rgba(255, 160, 60, 0); }
  55% { transform: scale(1.14) rotate(6deg); }
  100% { transform: scale(1) rotate(0deg); box-shadow: 0 2px 8px var(--streak-glow); }
}

.streak-body {
  padding: 4px 20px 20px;
}

.streak-hero {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 14px 0 16px;
  text-align: center;
}

.streak-flame {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  color: #fff;
  background: radial-gradient(circle at 50% 65%, var(--streak-soft), var(--streak-core) 72%);
  box-shadow: 0 10px 26px var(--streak-glow);
}

.streak-flame.is-out {
  color: var(--muted);
  background: var(--surface-2);
  box-shadow: none;
}

.streak-ladder {
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.streak-step {
  display: grid;
  place-items: center;
  width: 34px;
  height: 22px;
  border-radius: 11px;
  font-size: 11px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  background: var(--surface-2);
}

.streak-step.is-reached {
  color: #fff;
  background: linear-gradient(145deg, var(--streak-soft), var(--streak-core));
  box-shadow: 0 1px 6px var(--streak-glow);
}

.streak-count {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1.1;
}

.streak-unit {
  font-size: 13px;
  font-weight: 650;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.streak-hint {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-2);
  max-width: 320px;
}

.streak-stats {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.streak-stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.streak-stat-value {
  font-size: 15px;
  font-weight: 750;
}

.streak-stat-caption {
  font-size: 11.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.streak-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.streak-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  border-radius: 10px;
}

.streak-row-glyph {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: var(--streak-core);
  background: color-mix(in srgb, var(--streak-core) 18%, transparent);
  flex: none;
}

.streak-row-glyph.is-dim {
  color: var(--muted);
  background: var(--surface-2);
}

.streak-row-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.streak-row-text strong {
  font-size: 14px;
  font-weight: 700;
}

.streak-row-text small {
  font-size: 12px;
  color: var(--muted);
}

.streak-none {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--muted);
}

/* ——— Space Coins ——— */

.coins-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 4px 20px 20px;
}

.coins-hero {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 16px 0 14px;
  border-radius: var(--radius-sm);
  background:
    radial-gradient(120% 130% at 50% -30%, color-mix(in srgb, #f2b83f 26%, transparent), transparent 62%),
    var(--surface-2);
  text-align: center;
}

.coins-mark {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  margin-bottom: 8px;
  border-radius: 50%;
  color: #4a3409;
  background: radial-gradient(circle at 38% 32%, #fff3c4, #f4bd4b 52%, #d99417);
  box-shadow:
    inset 0 1px 2px rgba(255, 255, 255, 0.7),
    0 10px 24px rgba(214, 146, 26, 0.36);
}

.coins-balance {
  font-size: 36px;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
}

.coins-balance-unit {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.7px;
}

.coins-stats {
  display: flex;
  gap: 10px;
}

.coins-stat {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.coins-stat-glyph {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 50%;
  color: var(--streak-core, var(--accent));
  background: color-mix(in srgb, var(--streak-core, var(--accent)) 16%, transparent);
}

.coins-stat-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 1px;
}

.coins-stat-value {
  font-size: 16px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.coins-stat-caption {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.coins-tasks {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.coins-task {
  --streak-soft: var(--accent);
  --streak-core: var(--accent);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.coins-task-glyph {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 50%;
  color: var(--streak-core);
  background: color-mix(in srgb, var(--streak-core) 18%, transparent);
}

.coins-task-main {
  flex: 1 1 150px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.coins-task-main strong {
  font-size: 13.5px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.coins-task-main small {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.coins-task-reward {
  order: 2;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: none;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  color: #4a3409;
  background: linear-gradient(150deg, #ffe9a3, #eeb034);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.coins-task-reward svg {
  width: 15px;
  height: 15px;
}

.coins-task-meta {
  order: 3;
  flex-basis: 100%;
  height: 6px;
  margin-top: 2px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text) 10%, transparent);
  overflow: hidden;
}

.coins-task-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--streak-soft), var(--streak-core));
  transition: width 0.3s var(--ease);
}

.coins-task.is-share .coins-task-fill {
  background: linear-gradient(90deg, #ffd772, #e2a021);
}

.coins-task.is-done .coins-task-reward {
  color: var(--muted);
  background: color-mix(in srgb, var(--text) 8%, transparent);
  box-shadow: none;
}

.coins-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.coins-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  border-radius: 10px;
}

.coins-row-amount {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: none;
  min-width: 64px;
  font-size: 13.5px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  color: #d99b1f;
}

.coins-row-amount.is-debit {
  color: var(--danger);
}

.coins-row-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.coins-row-text strong {
  font-size: 14px;
  font-weight: 700;
}

.coins-row-text small {
  font-size: 12px;
  color: var(--muted);
}

.coins-none {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.chat-body {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: linear-gradient(160deg, var(--chat-bg), var(--chat-bg-2));
  overflow: hidden;
  transition: background 0.25s var(--ease);
}

.chat-pattern {
  position: absolute;
  inset: 0;
  background-color: var(--pattern-color);
  opacity: var(--pattern-opacity);
  pointer-events: none;
  -webkit-mask-image: var(--chat-pattern);
  mask-image: var(--chat-pattern);
  -webkit-mask-size: 320px 320px;
  mask-size: 320px 320px;
  -webkit-mask-repeat: repeat;
  mask-repeat: repeat;
  z-index: 0;
}

.messages {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  /* A faint lamp above the thread: the accent of the theme, never its hue. */
  background-image: radial-gradient(
    900px 380px at 50% -10%,
    color-mix(in srgb, var(--accent) 8%, transparent),
    transparent 70%
  );
  padding: 18px clamp(20px, 6%, 90px) 10px;
  display: flex;
  flex-direction: column;
  scroll-behavior: auto;
}

.messages-inner {
  margin-top: auto;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  max-width: 980px;
}

.day-chip {
  align-self: center;
  margin: 14px 0 10px;
  padding: 4px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  backdrop-filter: blur(8px);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  user-select: none;
}

.msg-row {
  display: flex;
  margin: 1px 0;
}

/* Only the message that just arrived moves; the thread is rebuilt on every
   render and a blanket animation would replay it for all the old bubbles. */
.msg-row.is-new {
  animation: msg-in 0.2s var(--ease);
}

.msg-row.out {
  justify-content: flex-end;
}

.msg-wrap {
  position: relative;
  max-width: min(74%, 600px);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.msg-row.out .msg-wrap {
  align-items: flex-end;
}

.bubble {
  position: relative;
  padding: 7px 12px 8px;
  border-radius: 16px;
  border-bottom-left-radius: 6px;
  background: var(--bubble-in);
  color: var(--bubble-in-text);
  box-shadow: var(--bubble-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  font-size: 14.5px;
  line-height: 1.42;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.msg-row.out .bubble {
  border-radius: 16px;
  border-bottom-right-radius: 6px;
  background: var(--bubble-out);
  color: var(--bubble-out-text);
}

.bubble.has-media {
  padding: 4px;
}

.bubble.has-media .bubble-text {
  padding: 5px 8px 1px;
}

.bubble-text {
  white-space: pre-wrap;
}

/* Pulled toward the colour the bubble already writes its text in, so a link
   stays readable on every theme instead of only the light ones. */
.bubble-link {
  color: var(--accent);
  color: color-mix(in srgb, var(--accent) 72%, currentColor);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, currentColor 30%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.bubble-link:hover,
.bubble-link:focus-visible {
  text-decoration-color: currentColor;
}

.bubble-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

.bubble-reply {
  display: flex;
  gap: 8px;
  align-items: stretch;
  width: 100%;
  margin: 1px 0 6px;
  padding: 6px 9px;
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.07);
  text-align: left;
  max-width: 100%;
}

.bubble-reply::before {
  content: "";
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
  flex: none;
}

.reply-q {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 1px;
}

.reply-q-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
}

.reply-q-text {
  font-size: 12.5px;
  line-height: 1.35;
  opacity: 0.8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.bubble-media {
  display: block;
  border-radius: 12px;
  overflow: hidden;
  max-width: 100%;
  line-height: 0;
  background: rgba(0, 0, 0, 0.06);
  cursor: pointer;
  border: 0;
  padding: 0;
}

.bubble-media img {
  display: block;
  max-width: min(340px, 66vw);
  max-height: 420px;
  width: auto;
  height: auto;
}

/* Albums: one message, up to ten tiles. */
.bubble-album {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  width: min(330px, 72vw);
  border-radius: 12px;
  overflow: hidden;
}

.bubble-album.count-2,
.bubble-album.count-4 {
  grid-template-columns: repeat(2, 1fr);
  width: min(300px, 66vw);
}

.bubble-album.count-3 {
  grid-template-columns: repeat(2, 1fr);
  width: min(300px, 66vw);
}

.bubble-album.count-3 .album-tile:first-child {
  grid-row: span 2;
}

.album-tile {
  position: relative;
  aspect-ratio: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.08);
  cursor: pointer;
}

.album-tile img,
.album-tile video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.album-tile::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0);
  transition: background 0.15s;
  pointer-events: none;
}

.album-tile:hover::after {
  background: rgba(0, 0, 0, 0.08);
}

.album-play {
  position: absolute;
  left: 8px;
  bottom: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  pointer-events: none;
}

.album-play svg {
  width: 14px;
  height: 14px;
}

.bubble-media.is-video {
  cursor: default;
  position: relative;
}

.bubble-media video {
  display: block;
  width: min(340px, 66vw);
  max-height: 420px;
  background: #000;
}

.bubble.has-voice {
  min-width: min(268px, 62vw);
  padding: 6px 10px;
}

.voice-bubble {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 208px;
  padding: 3px 0;
}

.voice-play {
  flex: none;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  padding: 0 0 0 2px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--accent-contrast);
  box-shadow: 0 4px 12px var(--accent-soft);
  cursor: pointer;
}

.voice-play:hover {
  filter: brightness(1.07);
}

.voice-play svg {
  width: 15px;
  height: 15px;
}

.voice-wave {
  flex: 1;
  min-width: 0;
  height: 30px;
  display: flex;
  align-items: center;
  gap: 2px;
  cursor: pointer;
}

.voice-bar {
  flex: 1;
  min-width: 2px;
  height: calc(var(--h) * 100%);
  border-radius: 2px;
  background: currentColor;
  opacity: 0.26;
}

.voice-bar.is-filled {
  opacity: 0.85;
}

.voice-time {
  flex: none;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  opacity: 0.75;
}

.msg-meta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  float: right;
  margin: 6px 0 -2px 10px;
  font-size: 11px;
  color: var(--time-in);
  user-select: none;
}

.msg-row.out .msg-meta {
  color: var(--time-out);
}

.msg-meta svg {
  width: 14px;
  height: 14px;
}

/* Voice bubbles keep their timestamp inline — the overlay pill would cover the waveform. */
.bubble.media-only:not(.has-voice):not(.has-circle) .msg-meta {
  position: absolute;
  right: 9px;
  bottom: 9px;
  float: none;
  margin: 0;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.42);
  color: #fff;
  backdrop-filter: blur(4px);
}

.bubble.media-only.has-video .msg-meta {
  top: 9px;
  bottom: auto;
}

.msg-actions {
  position: absolute;
  top: -12px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transform: translateY(3px);
  transition: opacity 0.15s, transform 0.15s;
  z-index: 2;
}

.msg-row.in .msg-actions {
  right: 8px;
}

.msg-row.out .msg-actions {
  left: 8px;
}

.msg-row:hover .msg-actions,
.msg-row:focus-within .msg-actions {
  opacity: 1;
  transform: none;
}

.msg-action {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface);
  color: var(--muted);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: color 0.14s, transform 0.12s;
}

.msg-action:hover {
  color: var(--accent);
}

.msg-action:active {
  transform: scale(0.92);
}

.msg-action svg {
  width: 15px;
  height: 15px;
}

.bubble.flash {
  animation: msg-flash 1.2s ease;
}

@keyframes msg-flash {
  0%,
  100% {
    box-shadow: var(--bubble-shadow);
  }
  30% {
    box-shadow: 0 0 0 3px var(--accent);
  }
}

@keyframes msg-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.messages-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: auto;
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  gap: 10px;
}

.messages-empty .empty-icon {
  width: 72px;
  height: 72px;
  border-radius: 24px;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--surface) 62%, transparent);
  border: 1px solid var(--border);
  color: var(--accent);
  backdrop-filter: blur(8px);
  margin-bottom: 4px;
}

.messages-empty .empty-icon svg {
  width: 34px;
  height: 34px;
}

.messages-empty h3 {
  margin: 0;
  font-size: 16px;
  color: var(--text);
}

.messages-empty p {
  margin: 0;
  font-size: 13.5px;
  max-width: 320px;
  line-height: 1.55;
}

.scroll-bottom {
  position: absolute;
  right: 22px;
  bottom: 16px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface);
  color: var(--text-2);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  z-index: 3;
  transition: transform 0.15s, color 0.15s;
}

.scroll-bottom:hover {
  color: var(--accent);
  transform: translateY(-2px);
}

.scroll-bottom svg {
  width: 20px;
  height: 20px;
}

.composer-wrap {
  position: relative;
  z-index: 4;
  padding: 8px clamp(16px, 6%, 90px) calc(18px + var(--lg-edge-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: none;
}

.reply-bar,
.edit-bar,
.attachment {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 8px 10px;
  box-shadow: var(--shadow-sm);
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
  animation: msg-in 0.16s var(--ease);
}

.reply-stripe {
  width: 3px;
  align-self: stretch;
  border-radius: 2px;
  background: var(--accent);
  flex: none;
}

.reply-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  text-align: left;
}

.reply-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reply-label strong {
  font-weight: 700;
}

.reply-preview {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reply-bar .icon-btn,
.attachment .icon-btn {
  width: 32px;
  height: 32px;
}

.reply-bar .icon-btn svg,
.attachment .icon-btn svg {
  width: 16px;
  height: 16px;
}

/* ——— Message editing ——— */

.edit-stripe {
  width: 3px;
  align-self: stretch;
  border-radius: 2px;
  background: var(--accent);
  flex: none;
}

.edit-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  text-align: left;
}

.edit-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.edit-preview {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.edit-bar .icon-btn {
  width: 32px;
  height: 32px;
}

.edit-bar .icon-btn svg {
  width: 16px;
  height: 16px;
}

.composer-wrap.is-editing .composer {
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.msg-edited {
  margin-right: 3px;
  font-style: italic;
  opacity: 0.85;
}

.attach-strip {
  display: flex;
  gap: 6px;
  flex: none;
  max-width: min(420px, 52vw);
  overflow-x: auto;
  padding: 2px 2px 3px;
  scrollbar-width: thin;
}

.attach-tile {
  position: relative;
  flex: none;
  width: 52px;
  height: 52px;
  border-radius: 9px;
  overflow: hidden;
  background: var(--surface-2);
}

.attach-tile img,
.attach-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.attach-play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  background: rgba(0, 0, 0, 0.18);
  pointer-events: none;
}

.attach-play svg {
  width: 16px;
  height: 16px;
  filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.5));
}

.attach-tile-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  cursor: pointer;
}

.attach-tile-remove svg {
  width: 11px;
  height: 11px;
}

.attachment.is-uploading .attach-tile-remove {
  display: none;
}

.attachment-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  text-align: left;
}

.attachment-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attachment-size {
  font-size: 12px;
  color: var(--muted);
}

.attachment-progress {
  display: block;
  height: 3px;
  margin-top: 4px;
  border-radius: 2px;
  overflow: hidden;
  background: var(--border);
}

.attachment-progress-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 2px;
  background: var(--accent);
  transition: width 0.15s linear;
}

.composer-wrap.is-recording .composer {
  display: none;
}

.voice-rec {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 7px 8px;
  box-shadow: var(--shadow-sm);
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
  animation: msg-in 0.16s var(--ease);
}

.voice-rec-dot {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ff4d4d;
  animation: voice-pulse 1.1s ease-in-out infinite;
}

@keyframes voice-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.voice-rec-time {
  flex: none;
  min-width: 40px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.voice-level {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 3px;
  min-width: 0;
}

.voice-lvl {
  flex: 1;
  height: 5px;
  border-radius: 3px;
  background: var(--border);
  transition: background 0.09s linear;
}

.voice-lvl.is-on {
  background: var(--accent);
}

.voice-rec .voice-send {
  color: var(--accent);
}

/* ——— Video circles ——— */

.bubble.has-circle,
.msg-row.out .bubble.has-circle {
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  min-width: 0;
}

.circle-bubble {
  position: relative;
  width: min(206px, 54vw);
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  background: #101014;
  box-shadow: 0 0 0 2.5px color-mix(in srgb, var(--accent) 70%, transparent),
    0 8px 22px rgba(0, 0, 0, 0.32);
  cursor: pointer;
  animation: msg-in 0.16s var(--ease);
}

.circle-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

.circle-progress {
  position: absolute;
  inset: -1px;
  width: calc(100% + 2px);
  height: calc(100% + 2px);
  transform: rotate(-90deg);
  pointer-events: none;
}

.circle-progress circle {
  fill: none;
  stroke: #fff;
  stroke-width: 3.2;
  stroke-linecap: round;
  opacity: 0.92;
}

.circle-play {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  padding: 0 0 0 3px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.44);
  color: #fff;
  cursor: pointer;
  transition: opacity 0.18s;
}

.circle-play:hover {
  background: rgba(0, 0, 0, 0.6);
}

.circle-play.is-playing {
  opacity: 0;
}

.circle-bubble:hover .circle-play.is-playing {
  opacity: 1;
}

.circle-play svg {
  width: 19px;
  height: 19px;
}

.circle-time {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 13px;
  text-align: center;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.75);
  pointer-events: none;
}

.bubble.has-circle .bubble-text {
  padding: 6px 10px 0;
  color: var(--text);
}

.bubble.has-circle .msg-meta {
  float: none;
  position: static;
  display: flex;
  justify-content: flex-end;
  gap: 3px;
  padding: 3px 8px 0 0;
  margin: 0;
  border-radius: 0;
  background: transparent;
  backdrop-filter: none;
  color: var(--muted);
}

/* ——— Circle recorder ——— */

.note-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: calc(22px + var(--lg-edge-top)) calc(22px + var(--lg-edge-right))
    calc(22px + var(--lg-edge-bottom)) calc(22px + var(--lg-edge-left));
  background: rgba(8, 8, 12, 0.86);
  animation: fade-in 0.16s var(--ease);
}

.note-stage {
  position: relative;
  width: min(420px, 78vw);
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  background: #000;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.note-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.note-progress {
  position: absolute;
  inset: -1px;
  width: calc(100% + 2px);
  height: calc(100% + 2px);
  transform: rotate(-90deg);
  pointer-events: none;
}

.note-progress circle {
  fill: none;
  stroke-width: 3.4;
}

.note-progress circle:first-child {
  stroke: rgba(255, 255, 255, 0.18);
}

.note-progress circle:last-child {
  stroke: var(--accent);
  stroke-linecap: round;
}

.note-timer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 16px;
  text-align: center;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  color: #fff;
  text-shadow: 0 1px 5px rgba(0, 0, 0, 0.8);
}

.note-timer.is-live {
  color: #ff5f57;
}

.note-tools {
  display: flex;
  align-items: center;
  gap: 22px;
}

.note-btn {
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  padding: 0;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s, transform 0.12s;
}

.note-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.22);
}

.note-btn:active {
  transform: scale(0.94);
}

.note-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.note-btn svg {
  width: 22px;
  height: 22px;
}

.note-shutter {
  width: 72px;
  height: 72px;
  background: #fff;
  color: #d8262c;
  box-shadow: inset 0 0 0 4px rgba(216, 38, 44, 0.85);
}

.note-shutter:hover {
  background: #fff;
}

.note-send {
  background: var(--accent);
  color: var(--accent-contrast);
}

.note-zoom {
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(340px, 70vw);
  color: #fff;
}

.note-zoom input[type='range'] {
  flex: 1;
  min-width: 0;
  accent-color: var(--accent);
}

.note-zoom .note-btn {
  width: 34px;
  height: 34px;
}

.note-zoom .note-btn svg {
  width: 17px;
  height: 17px;
}

.composer-wrap .circle-btn.is-active {
  color: var(--accent);
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow-sm);
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
  transition: box-shadow 0.18s, border-color 0.18s;
}

.composer:focus-within {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  box-shadow: 0 6px 22px var(--accent-soft);
}

.attach-btn {
  width: 42px;
  height: 42px;
  flex: none;
  color: var(--muted);
}

.attach-btn:hover {
  color: var(--accent);
}

#message-input {
  flex: 1;
  min-width: 0;
  max-height: 160px;
  padding: 10px 2px 9px;
  border: 0;
  background: transparent;
  outline: none;
  resize: none;
  font-size: 14.5px;
  line-height: 1.45;
  overflow-y: auto;
  /* A bar inside a rounded pill reads as a defect, and on Windows the classic
     scrollbar draws its up/down arrows as one grey glyph in a short field. */
  scrollbar-width: none;
}

#message-input::-webkit-scrollbar {
  width: 0;
  height: 0;
}

/* The placeholder names the peer, and on a phone that is longer than the box.
   A wrapped placeholder looks like a second line of typed text. */
#message-input::placeholder {
  color: var(--faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.send-btn {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(140deg, var(--accent), color-mix(in srgb, var(--accent) 60%, #7b5cff));
  color: var(--accent-contrast);
  box-shadow: 0 8px 18px var(--accent-soft);
  transition: transform 0.14s, filter 0.14s, opacity 0.14s;
}

.send-btn svg {
  width: 21px;
  height: 21px;
  transform: translateX(1px);
}

.send-btn:hover {
  filter: brightness(1.07);
}

.send-btn:active {
  transform: scale(0.94);
}

.send-btn:disabled {
  opacity: 0.45;
  filter: none;
  cursor: default;
  box-shadow: none;
}

.send-spinner {
  width: 19px;
  height: 19px;
  border-radius: 50%;
  border: 2.2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Attach + emoji + recorder + send inside one 360px pill leaves the field about
   120px wide, so every message wraps after two words. The paint shrinks; the
   44px tap area from base.css still covers each button. */
@media (max-width: 430px) {
  .composer {
    gap: 4px;
    padding: 5px;
  }

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

  .composer .icon-btn svg {
    width: 19px;
    height: 19px;
  }

  .composer .attach-btn {
    width: 38px;
    height: 38px;
  }

  .composer .send-btn {
    width: 42px;
    height: 42px;
  }
}

/* Under about 380px the five controls leave a single-digit character count in
   one row, so the pill becomes two: attach and text, then the tools. */
@media (max-width: 380px) {
  .composer {
    flex-wrap: wrap;
    border-radius: 18px;
    row-gap: 2px;
  }

  .composer #message-input {
    order: 2;
    flex: 1 1 calc(100% - 42px);
  }

  .composer .attach-btn {
    order: 1;
  }

  .composer .emoji-btn,
  .composer .circle-btn,
  .composer .voice-btn,
  .composer .send-btn {
    order: 3;
  }

  .composer .emoji-btn {
    margin-left: auto;
  }
}

/* ——— Context menu ——— */

#context-menu {
  position: fixed;
  z-index: 80;
  min-width: 196px;
  max-width: calc(100vw - var(--lg-edge-inline) - 20px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  animation: pop-in 0.14s var(--ease);
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 11px;
  border-radius: 9px;
  font-size: 13.5px;
  text-align: left;
  color: var(--text);
  transition: background 0.12s;
}

.menu-item:hover:not(:disabled) {
  background: var(--hover);
}

.menu-item:disabled {
  opacity: 0.45;
  cursor: default;
}

.menu-item svg {
  width: 17px;
  height: 17px;
  color: var(--muted);
}

.menu-item:hover:not(:disabled) svg {
  color: var(--accent);
}

.menu-item.danger {
  color: var(--danger);
}

.menu-item.danger svg {
  color: var(--danger);
}

.menu-item.danger:hover:not(:disabled) {
  background: var(--danger-soft);
}

.menu-label {
  padding: 8px 11px 6px;
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: var(--faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}

.menu-sep {
  height: 1px;
  background: var(--border);
  margin: 5px 6px;
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ——— Theme popover ——— */

#theme-popover {
  position: fixed;
  z-index: 85;
  width: min(316px, calc(100vw - var(--lg-edge-inline) - 24px));
  max-height: calc(100dvh - var(--lg-edge-block) - 24px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 16px;
  animation: pop-in 0.16s var(--ease);
}

.popover-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.popover-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.popover-hint {
  font-size: 11px;
  color: var(--faint);
  white-space: nowrap;
}

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

.theme-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 4px;
  border-radius: 13px;
  border: 1.5px solid transparent;
  transition: background 0.14s, border-color 0.14s;
}

.theme-option:hover {
  background: var(--hover);
}

.theme-option.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.theme-swatch {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08), 0 2px 6px rgba(0, 0, 0, 0.12);
  display: grid;
  place-items: center;
  color: #fff;
}

.theme-swatch svg {
  width: 20px;
  height: 20px;
  padding: 3px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.32);
}

.theme-option span {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-2);
}

.theme-option.is-active span {
  color: var(--accent);
}

.popover-foot {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--faint);
  text-align: center;
}

/* ——— Language popover ——— */

#lang-popover {
  position: fixed;
  z-index: 85;
  width: min(220px, calc(100vw - var(--lg-edge-inline) - 20px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 16px;
  animation: pop-in 0.16s var(--ease);
}

.lang-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lang-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border-radius: 12px;
  border: 1.5px solid transparent;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-2);
  transition: background 0.14s, border-color 0.14s;
}

.lang-option:hover {
  background: var(--hover);
}

.lang-option.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.lang-check {
  width: 18px;
  display: grid;
  place-items: center;
  color: var(--accent);
}

/* ——— Modal ——— */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: calc(24px + var(--lg-edge-top)) calc(24px + var(--lg-edge-right))
    calc(24px + var(--lg-edge-bottom)) calc(24px + var(--lg-edge-left));
  background: var(--overlay);
  backdrop-filter: blur(5px);
  animation: fade-in 0.16s ease;
}

/* A sheet opened over a live call has to out-stack the call card (z-index 90). */
.modal-backdrop.is-over-call {
  z-index: 95;
}

.modal {
  width: min(480px, 100%);
  max-height: min(620px, calc(100dvh - var(--lg-edge-block) - 48px));
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modal-in 0.22s var(--ease);
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px 10px;
}

.modal-head h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 750;
  letter-spacing: -0.3px;
  flex: 1;
}

.modal-sub {
  margin: 0;
  padding: 0 20px 14px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.apps-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 2px 20px 18px;
}

.apps-link {
  display: block;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface);
  text-decoration: none;
}

.apps-link:hover,
.apps-link:focus-visible {
  border-color: var(--accent);
}

.apps-name {
  display: block;
  color: var(--accent);
  font-weight: 650;
}

.apps-hint {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.modal-search {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 20px 12px;
  padding: 0 13px;
  height: 44px;
  border-radius: 13px;
  background: var(--input-bg);
  border: 1.5px solid transparent;
}

.modal-search:focus-within {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.modal-search svg {
  width: 18px;
  height: 18px;
  color: var(--muted);
}

.modal-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  outline: none;
  height: 100%;
  font-size: 14px;
}

.modal-search input::placeholder {
  color: var(--faint);
}

.modal-results {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 12px 16px;
}

.result-hint {
  padding: 26px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.6;
}

.result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 10px;
  border-radius: 14px;
  text-align: left;
  transition: background 0.14s;
}

.result-item:hover {
  background: var(--hover);
}

.result-item .avatar {
  width: 46px;
  height: 46px;
  font-size: 17px;
}

.result-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.result-name {
  font-size: 14.5px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-username {
  font-size: 12.5px;
  color: var(--muted);
}

.result-badge {
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
  background: var(--accent-soft);
  padding: 3px 8px;
  border-radius: 999px;
  flex: none;
}

.result-loader {
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ——— Lightbox ——— */

#lightbox {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(40px + var(--lg-edge-top)) calc(40px + var(--lg-edge-right))
    calc(40px + var(--lg-edge-bottom)) calc(40px + var(--lg-edge-left));
  background: rgba(6, 10, 16, 0.92);
  backdrop-filter: blur(10px);
  animation: fade-in 0.18s ease;
}

#lightbox img,
#lightbox video {
  max-width: min(calc(92vw - var(--lg-edge-inline)), 1400px);
  max-height: calc(88dvh - var(--lg-edge-block));
  border-radius: 12px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  background: #000;
}

.lightbox-close {
  position: absolute;
  top: calc(22px + var(--lg-edge-top));
  right: calc(22px + var(--lg-edge-right));
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  transition: background 0.15s;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.22);
}

.lightbox-tools {
  position: absolute;
  top: calc(22px + var(--lg-edge-top));
  left: calc(22px + var(--lg-edge-left));
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  max-width: calc(100% - 140px);
}

.lightbox-tools[hidden] {
  display: none;
}

.lightbox-tool {
  height: 44px;
  padding: 0 16px 0 13px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.15s;
}

.lightbox-tool:hover {
  background: rgba(255, 255, 255, 0.22);
}

.lightbox-tool svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

@media (max-width: 520px) {
  .lightbox-tool span {
    display: none;
  }

  .lightbox-tool {
    width: 44px;
    padding: 0;
    justify-content: center;
  }
}

.lightbox-close svg {
  width: 22px;
  height: 22px;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  transition: background 0.15s;
}

.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.22);
}

.lightbox-nav svg {
  width: 24px;
  height: 24px;
}

.lightbox-nav.is-prev {
  left: calc(16px + var(--lg-edge-left));
}

.lightbox-nav.is-next {
  right: calc(16px + var(--lg-edge-right));
  transform: translateY(-50%) rotate(180deg);
}

.lightbox-count {
  position: absolute;
  top: calc(28px + var(--lg-edge-top));
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 13px;
}

/* ——— Toast ——— */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(30px + var(--lg-edge-bottom));
  transform: translate(-50%, 10px);
  z-index: 120;
  background: rgba(17, 24, 39, 0.94);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  max-width: min(calc(90vw - var(--lg-edge-inline)), 480px);
  text-align: center;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (hover: none) {
  .msg-actions {
    display: none;
  }
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
  }

  .chat-pane {
    display: none;
  }

  .app.chat-open .sidebar {
    display: none;
  }

  .app.chat-open .chat-pane {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 10;
  }

  .back-btn {
    display: inline-grid;
  }

  .chat-header {
    height: calc(64px + var(--lg-edge-top));
    padding: var(--lg-edge-top) calc(14px + var(--lg-edge-right)) 0 calc(14px + var(--lg-edge-left));
  }

  .messages {
    padding: 16px calc(16px + var(--lg-edge-right)) 8px calc(16px + var(--lg-edge-left));
  }

  .composer-wrap {
    padding: 8px calc(12px + var(--lg-edge-right)) calc(12px + var(--lg-edge-bottom))
      calc(12px + var(--lg-edge-left));
  }

  .scroll-bottom {
    right: calc(16px + var(--lg-edge-right));
  }
}

/* ——— Motion: entering and leaving a conversation ——— */

/* On a phone only one surface is on screen and they swap with `display`, which
   a transition cannot cross, so the move is a keyframe that replays every time
   a pane becomes visible. */
@media (max-width: 900px) {
  .app {
    /* The panes slide in from outside the screen. */
    overflow: hidden;
  }

  .app.chat-open .chat-pane {
    animation: pane-in 0.26s var(--ease);
  }

  .app:not(.chat-open) .sidebar {
    animation: list-in 0.26s var(--ease);
  }
}

@keyframes pane-in {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

@keyframes list-in {
  from {
    transform: translateX(-22%);
    opacity: 0.35;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes fab-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.85);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.scroll-bottom:not([hidden]) {
  animation: fab-in 0.18s var(--ease);
}

#lightbox img,
#lightbox video {
  animation: modal-in 0.22s var(--ease);
}

@media (max-width: 620px) {
  .msg-wrap {
    max-width: 86%;
  }

  .chat-head-text h1 {
    font-size: 15.5px;
  }

  .bubble-media img {
    max-width: min(300px, 74vw);
  }

  .attach-strip {
    max-width: 44vw;
  }

  .bubble-album {
    width: min(330px, 76vw);
  }
}

/* ——— Profile editing ——— */

.avatar.has-photo {
  background: var(--surface-2);
}

.avatar.has-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.profile-avatar-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 4px 20px 14px;
}

.profile-avatar-btn {
  width: 96px;
  height: 96px;
  padding: 0;
  border-radius: 50%;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  border: 2.5px solid var(--border);
  background: transparent;
  transition: border-color 0.15s, transform 0.12s;
}

.profile-avatar-btn:hover {
  border-color: var(--accent);
  transform: scale(1.03);
}

.profile-avatar-btn .avatar {
  width: 100% !important;
  height: 100% !important;
}

.profile-remove-photo {
  height: 34px;
  padding: 0 14px;
  border-radius: 11px;
  background: var(--input-bg);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 600;
  transition: background 0.15s, color 0.15s;
}

.profile-remove-photo:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.profile-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 20px 20px;
}

.profile-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--text-2);
}

.profile-field input {
  height: 44px;
  padding: 0 14px;
  border-radius: 13px;
  background: var(--input-bg);
  border: 1.5px solid transparent;
  outline: none;
  font-size: 14px;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.profile-field input:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.profile-field .field-control input {
  padding-left: 32px;
}

.profile-field input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.profile-field-hint {
  font-size: 12px;
  font-weight: 450;
  color: var(--muted);
  line-height: 1.45;
}

.profile-field-error {
  font-size: 13px;
  color: var(--danger);
  line-height: 1.4;
  margin-bottom: 4px;
}

/* ——— User profile card ——— */

.profile-modal {
  max-width: 420px;
}

.user-profile-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 8px 20px 20px;
}

.user-profile-loading {
  margin: 12px 0;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.user-profile-top {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-profile-titles {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
}

.user-profile-name {
  margin: 0;
  font-size: 20px;
  font-weight: 750;
  letter-spacing: -0.3px;
  overflow-wrap: anywhere;
}

.user-profile-username {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}

.user-profile-username:hover {
  text-decoration: underline;
}

.user-profile-badge {
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--input-bg);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 650;
}

.profile-fact {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--input-bg);
  color: var(--text-2);
  font-size: 13px;
}

.profile-fact svg {
  flex: none;
  color: var(--muted);
}

.profile-stat {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
}

.profile-stat > svg {
  flex: none;
  margin-top: 2px;
  color: #f28c28;
}

.profile-stat.is-hidden,
.profile-stat.is-empty {
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.profile-stat.is-hidden > svg,
.profile-stat.is-empty > svg {
  margin-top: 0;
  color: var(--muted);
}

.profile-stat-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.profile-stat-label {
  color: var(--faint);
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.profile-stat-value {
  font-size: 21px;
  font-weight: 750;
  letter-spacing: -0.2px;
}

.profile-stat-partner {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.profile-stat-partner:hover {
  text-decoration: underline;
}

.profile-privacy {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--input-bg);
}

.profile-privacy-head {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--faint);
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.profile-privacy-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
}

.profile-privacy-hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.switch {
  position: relative;
  flex: none;
  width: 46px;
  height: 27px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s;
}

.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.18s, background 0.18s;
}

.switch[aria-checked="true"] {
  border-color: var(--accent);
  background: var(--accent);
}

.switch[aria-checked="true"]::after {
  transform: translateX(19px);
  background: #fff;
}

.profile-action {
  width: 100%;
  margin-top: 2px;
}

.chat-head-text.is-clickable,
#chat-avatar.is-clickable {
  cursor: pointer;
}

.chat-head-text.is-clickable:hover #chat-title {
  color: var(--accent);
}

/* ——— Personal contact names ——— */

.contact-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 20px 20px;
}

.contact-top {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.contact-titles {
  min-width: 0;
}

.contact-real {
  font-size: 15.5px;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contact-handle {
  font-size: 12.5px;
  color: var(--muted);
}

.contact-hint {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--muted);
}

.contact-hint svg {
  flex: none;
  margin-top: 1px;
}

.contact-actions {
  display: flex;
  gap: 10px;
}

.contact-actions .btn-primary,
.contact-actions .btn-secondary {
  flex: 1;
}

/* ——— Sound settings ——— */

.sound-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 0 20px 20px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.sound-master {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--input-bg);
  cursor: pointer;
}

.sound-master input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
  cursor: pointer;
}

.sound-master-text {
  flex: 1;
  font-size: 14px;
  font-weight: 650;
  color: var(--text);
}

.sound-master-state {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}

.sound-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.sound-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.sound-head-label {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.sound-head-value {
  font-size: 12.5px;
  font-weight: 650;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.sound-range {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

.sound-presets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
}

.sound-preset {
  height: 40px;
  padding: 0 12px;
  border-radius: 12px;
  background: var(--input-bg);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 600;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s, transform 0.12s;
}

.sound-preset:hover {
  background: var(--hover);
  color: var(--text);
}

.sound-preset:active {
  transform: scale(0.97);
}

.sound-preset.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

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

.sound-row-name {
  flex: 1 1 40%;
  min-width: 0;
  font-size: 13.5px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sound-select {
  flex: 1 1 34%;
  min-width: 0;
  height: 38px;
  padding: 0 10px;
  border-radius: 11px;
  background: var(--input-bg);
  border: 1.5px solid transparent;
  outline: none;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.sound-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.sound-play {
  flex: none;
  color: var(--text-2);
}

.sound-play:hover {
  color: var(--accent);
}

.sound-melody-hint {
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}

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

.sound-melody-name {
  flex: 1 1 120px;
  min-width: 0;
  font-size: 13px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 460px) {
  .sound-row {
    flex-wrap: wrap;
  }

  .sound-row-name {
    flex-basis: 100%;
  }

  .sound-select {
    flex: 1 1 auto;
  }
}

/* ——— QR ——— */

.btn-secondary {
  height: 42px;
  padding: 0 18px;
  border-radius: 13px;
  background: var(--input-bg);
  color: var(--text-2);
  font-weight: 600;
  font-size: 13.5px;
  transition: background 0.15s, color 0.15s, transform 0.12s;
}

.btn-secondary:hover {
  background: var(--hover);
  color: var(--text);
}

.btn-secondary:active {
  transform: scale(0.97);
}

.qr-box {
  display: grid;
  place-items: center;
  padding: 4px 20px;
}

.qr-box canvas {
  width: 232px;
  height: 232px;
  border-radius: 18px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  background: #fff;
}

.qr-username {
  text-align: center;
  padding: 10px 20px 18px;
  font-size: 16.5px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.2px;
}

.qr-status {
  padding: 8px 20px;
  min-height: 24px;
}

.qr-video {
  display: block;
  width: min(360px, calc(100% - 40px));
  margin: 0 auto;
  border-radius: 16px;
  background: #000;
}

.qr-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 8px 20px 20px;
}

.modal-foot-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 6px 20px 18px;
  border-top: 1px solid var(--border);
  margin: 0 12px;
  padding-top: 12px;
}

.modal-scan {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.modal-scan svg {
  width: 17px;
  height: 17px;
}

.modal > .btn-primary {
  margin: 0 20px 20px;
}

/* ——— Groups & channels: message layout ——— */

.msg-body {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}

.msg-row.out .msg-body {
  flex-direction: row-reverse;
}

.msg-body > .bubble {
  min-width: 0;
}

.msg-body .avatar {
  flex: none;
  margin-bottom: 2px;
}

.msg-row.tight {
  margin-top: 0;
}

.msg-row.in.tight .msg-body {
  padding-left: 42px;
}

.msg-author {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 0 0 3px 42px;
  padding: 0 3px;
  font-size: 12.5px;
  font-weight: 650;
  line-height: 1.25;
  min-width: 0;
}

.msg-author-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-author-role {
  flex: none;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: var(--muted);
  background: var(--hover);
  padding: 1px 6px;
  border-radius: 999px;
}

.sc-0 { color: var(--sender-0); }
.sc-1 { color: var(--sender-1); }
.sc-2 { color: var(--sender-2); }
.sc-3 { color: var(--sender-3); }
.sc-4 { color: var(--sender-4); }
.sc-5 { color: var(--sender-5); }
.sc-6 { color: var(--sender-6); }

.sys-row {
  display: flex;
  justify-content: center;
  margin: 9px 0 8px;
  padding: 0 8px;
}

.sys-chip {
  max-width: min(78%, 540px);
  padding: 5px 13px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.45;
  text-align: center;
  box-shadow: var(--shadow-sm);
  overflow-wrap: anywhere;
  user-select: none;
}

/* ——— Reactions ——— */

.msg-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
  max-width: 100%;
}

.msg-row.out .msg-reactions {
  justify-content: flex-end;
}

.msg-row.in.tight .msg-reactions {
  margin-left: 42px;
}

.reaction-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px 3px 7px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 650;
  line-height: 1.2;
  transition: background 0.14s, border-color 0.14s, transform 0.12s;
}

.reaction-pill:hover {
  background: var(--hover);
}

.reaction-pill:active {
  transform: scale(0.93);
}

.reaction-pill.is-mine {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--accent);
}

.reaction-emoji {
  font-family: var(--font-emoji);
  font-size: 13.5px;
  line-height: 1;
}

.reaction-count {
  font-variant-numeric: tabular-nums;
}

/* ——— Channel composer notice ——— */

.composer-notice {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
  padding: 12px 16px;
  border-radius: 18px;
  border: 1px dashed var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

.notice-icon {
  display: grid;
  place-items: center;
  color: var(--accent);
  flex: none;
}

/* ——— Chat list badges ——— */

.chat-item-kind {
  display: inline-flex;
  align-items: center;
  vertical-align: -2px;
  margin-left: 6px;
  color: var(--muted);
}

.chat-item-kind svg {
  width: 14px;
  height: 14px;
}

.chat-item.is-active .chat-item-kind {
  color: var(--accent);
}

.chat-item-sender {
  color: var(--text-2);
  font-weight: 550;
}

/* ——— Emoji popover ——— */

#emoji-popover {
  position: fixed;
  z-index: 86;
  width: min(332px, calc(100vw - var(--lg-edge-inline) - 20px));
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  padding: 10px 12px 8px;
  animation: pop-in 0.16s var(--ease);
}

.emoji-tabs {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}

.emoji-tab {
  flex: none;
  width: 34px;
  height: 30px;
  border-radius: 9px;
  font-family: var(--font-emoji);
  font-size: 16px;
  line-height: 1;
  opacity: 0.55;
  transition: background 0.14s, opacity 0.14s, transform 0.12s;
}

.emoji-tab:hover {
  background: var(--hover);
  opacity: 0.85;
}

.emoji-tab.is-active {
  background: var(--accent-soft);
  opacity: 1;
}

.emoji-body {
  max-height: 206px;
  overflow-y: auto;
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 1px;
}

.emoji-choice {
  height: 34px;
  border-radius: 9px;
  font-family: var(--font-emoji);
  font-size: 20px;
  line-height: 1;
  transition: background 0.12s, transform 0.1s;
}

.emoji-choice:hover {
  background: var(--hover);
  transform: scale(1.14);
}

.emoji-choice:active {
  transform: scale(0.94);
}

/* ——— Stickers ——— */

.bubble.has-sticker,
.msg-row.out .bubble.has-sticker {
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  min-width: 0;
}

.bubble.has-sticker .msg-meta {
  opacity: 0;
  transition: opacity 0.14s;
}

.msg-row:hover .bubble.has-sticker .msg-meta {
  opacity: 1;
}

.sticker-bubble {
  position: relative;
  display: block;
  width: min(178px, 46vw);
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: transparent;
  cursor: pointer;
  overflow: visible;
  animation: msg-in 0.16s var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.sticker-media {
  display: block;
  width: 100%;
  height: auto;
  max-height: 240px;
  border-radius: 18px;
  object-fit: contain;
}

.sticker-bubble[data-kind='video'] .sticker-media {
  background: #0b0f18;
}

.sticker-bubble.is-frozen::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 18px;
  background: rgba(8, 10, 16, 0.34);
}

.sticker-bubble.is-frozen::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  margin-left: 3px;
  transform: translate(-50%, -50%);
  border-left: 15px solid #fff;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.45));
}

.emoji-tab svg {
  display: block;
  margin: 0 auto;
  width: 18px;
  height: 18px;
}

.sticker-panel {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 2px 1px 4px;
}

.sticker-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  transition: opacity 0.14s;
}

.sticker-grid.is-busy {
  opacity: 0.5;
  pointer-events: none;
}

.sticker-slot {
  position: relative;
}

.sticker-tile {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  transition: transform 0.12s var(--ease), border-color 0.14s, background 0.14s;
}

.sticker-tile img,
.sticker-tile video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.sticker-tile:hover {
  transform: scale(1.05);
  border-color: var(--accent);
}

.sticker-tile:active {
  transform: scale(0.94);
}

.sticker-tile.is-add {
  border-style: dashed;
  color: var(--muted);
  background: transparent;
}

.sticker-tile.is-add:hover {
  color: var(--accent);
  background: var(--hover);
}

.sticker-kill {
  position: absolute;
  top: -6px;
  right: -6px;
  display: grid;
  place-items: center;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  opacity: 0;
  cursor: pointer;
  transition: opacity 0.14s, background 0.14s, color 0.14s;
}

.sticker-slot:hover .sticker-kill,
.sticker-kill:focus-visible {
  opacity: 1;
}

.sticker-slot.is-arming .sticker-kill {
  opacity: 1;
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.sticker-note {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.35;
  text-align: center;
  color: var(--muted);
}

@media (hover: none) {
  .sticker-kill {
    opacity: 1;
  }
}

/* ——— Reaction popover ——— */

#reaction-popover {
  position: fixed;
  z-index: 86;
  max-width: calc(100vw - var(--lg-edge-inline) - 20px);
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  animation: pop-in 0.14s var(--ease);
}

.reaction-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1px;
  width: min(290px, calc(100vw - var(--lg-edge-inline) - 40px));
}

.reaction-choice {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-family: var(--font-emoji);
  font-size: 20px;
  line-height: 1;
  transition: background 0.12s, transform 0.1s;
}

.reaction-choice:hover {
  background: var(--hover);
  transform: scale(1.2);
}

.reaction-choice.is-mine {
  background: var(--accent-soft);
}

/* ——— Create & info modals ——— */

.modal-create-row {
  display: flex;
  gap: 10px;
  padding: 0 20px 12px;
}

.modal-create-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 46px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 650;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.12s;
}

.modal-create-btn:hover {
  background: var(--active);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  color: var(--accent);
}

.modal-create-btn:active {
  transform: scale(0.98);
}

.result-section {
  padding: 10px 10px 5px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--faint);
}

.info-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 0 20px 20px;
}

.info-top {
  display: flex;
  align-items: center;
  gap: 14px;
}

.info-titles {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.info-name {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.2px;
  overflow-wrap: anywhere;
}

.info-meta {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
}

.info-note {
  margin: 0;
  font-size: 12px;
  color: var(--faint);
  line-height: 1.5;
}

.info-body .result-section {
  padding: 4px 0 0;
}

.info-body .profile-avatar-row {
  padding: 0 0 6px;
}

.info-link {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

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

.invite-field {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 13px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text-2);
  font-size: 12.5px;
  outline: none;
}

.invite-field:focus {
  border-color: var(--accent);
  color: var(--text);
}

.invite-text {
  margin: -6px 0 14px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
  padding: 0 20px;
}

.member-list {
  display: flex;
  flex-direction: column;
  margin: 0 -8px;
}

.member-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 7px 8px;
  border-radius: 13px;
  text-align: left;
  cursor: pointer;
  transition: background 0.14s;
}

.member-row:hover {
  background: var(--hover);
}

.member-row .avatar {
  flex: none;
}

.member-main {
  flex: 1;
  min-width: 0;
}

.member-name {
  font-size: 14px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.member-username {
  font-size: 12px;
  color: var(--muted);
}

.member-role {
  flex: none;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 9px;
  border-radius: 999px;
}

.member-role.is-you {
  color: var(--muted);
  background: var(--hover);
}

.member-online {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3dd68c;
}

.member-add {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.member-add input {
  flex: 1 1 150px;
  min-width: 0;
  height: 42px;
  padding: 0 14px;
  border-radius: 13px;
  border: 1.5px solid transparent;
  background: var(--input-bg);
  color: var(--text);
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.member-add input:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.picker-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 20px 20px;
}

.picker-search {
  height: 42px;
  padding: 0 14px;
  border-radius: 13px;
  border: 1.5px solid transparent;
  background: var(--input-bg);
  color: var(--text);
  font-size: 13.5px;
  outline: none;
}

.picker-search:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.picker-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: min(46vh, 420px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.picker-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.14s;
}

.picker-row:hover {
  background: var(--surface-2);
}

.picker-row.is-picked {
  background: var(--accent-soft);
}

.picker-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.picker-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.picker-check {
  display: grid;
  place-items: center;
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: transparent;
  background: var(--surface-2);
  transition: color 0.14s, background 0.14s;
}

.picker-row.is-picked .picker-check {
  color: #fff;
  background: var(--accent);
}

.picker-empty {
  padding: 18px 6px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.picker-confirm {
  width: 100%;
  height: 46px;
}

.btn-danger {
  height: 46px;
  border-radius: 14px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 14px;
  font-weight: 650;
  transition: background 0.15s, transform 0.12s;
}

.btn-danger:hover {
  background: color-mix(in srgb, var(--danger) 20%, transparent);
}

.btn-danger:active {
  transform: scale(0.985);
}

.btn-danger:disabled {
  opacity: 0.6;
}

.modal-wide {
  width: 100%;
}

/* ——— Avatar presets ——— */

.profile-avatar-row {
  flex-wrap: wrap;
}

.avatar-presets {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  gap: 9px;
  padding-top: 2px;
}

.avatar-preset {
  aspect-ratio: 1;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 50%;
  background: none;
  overflow: hidden;
  cursor: pointer;
  transition:
    transform 0.16s var(--ease),
    border-color 0.16s var(--ease);
}

.avatar-preset img {
  display: block;
  width: 100%;
  height: 100%;
}

.avatar-preset:hover {
  transform: scale(1.07);
}

.avatar-preset.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ——— Service rows for calls ——— */

.sys-chip svg {
  margin-right: 6px;
  vertical-align: -2px;
}

/* ——— Call screen ——— */

/* Kept inside the render tree on purpose: a media element that is display:none
   can be skipped by a WebView's audio pipeline, and the far side would be silent. */
.call-remote {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 2px;
  height: 2px;
  opacity: 0.01;
  pointer-events: none;
}

.call-stage {
  position: relative;
  display: none;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 18px;
  background: #05070d;
}

.call-card.has-video {
  width: min(760px, 100%);
  gap: 10px;
  padding: 14px 16px 20px;
}

.call-card.has-video .call-stage {
  display: block;
}

.call-card.has-video .call-avatar {
  display: none;
}

.call-video {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #05070d;
}

.call-video.is-off {
  display: none;
}

/* A face should fill the frame instead of leaving black bars at the sides; a
   shared screen is the opposite — cropping it would eat the edges of the work. */
.call-video-main {
  object-fit: cover;
}

.call-video-main.is-screen {
  object-fit: contain;
}

/* Alone on the stage you see yourself the way a mirror would show you. */
.call-video-main.is-local {
  transform: scaleX(-1);
}

.call-video-main.is-local.is-screen {
  transform: none;
}

.call-video-pip.is-screen {
  object-fit: contain;
}

.call-video-pip,
.call-video-self {
  inset: auto;
  width: 27%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 12px;
  background: #0b1018;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
}

.call-video-pip {
  right: 10px;
  bottom: 10px;
}

.call-video-self {
  top: 10px;
  left: 10px;
  transform: scaleX(-1);
}

/* A shared screen is not a face in a window: it goes to the peer the way it is. */
.call-video-self.is-screen {
  transform: none;
}

/* The phone paints the shell's pictures here and hands the canvas to the call. It
   is read by the encoder, not by the eye, so one pixel in the corner is enough. */
.call-share-source,
.call-zoom-source {
  position: fixed;
  left: -2px;
  top: -2px;
  width: 1px;
  height: 1px;
  opacity: 0.01;
  pointer-events: none;
}

/* Zoom lives in the one corner nothing else claims: top-right. */
.call-zoom {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: rgba(8, 12, 20, 0.68);
  backdrop-filter: blur(8px);
  color: #fff;
}

.call-zoom[hidden] {
  display: none;
}

.call-zoom-btn {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: 50%;
  color: inherit;
  background: transparent;
  cursor: pointer;
  transition: background 0.14s var(--ease);
}

.call-zoom-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.16);
}

.call-zoom-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.call-zoom-value {
  min-width: 34px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.call-caption {
  position: absolute;
  bottom: 12px;
  left: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: rgba(8, 12, 20, 0.62);
}

.call-caption.is-off {
  display: none;
}

.call-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: calc(20px + var(--lg-edge-top)) calc(20px + var(--lg-edge-right))
    calc(20px + var(--lg-edge-bottom)) calc(20px + var(--lg-edge-left));
  background: rgba(6, 9, 16, 0.66);
  animation: call-in 0.2s var(--ease);
}

@keyframes call-in {
  from {
    opacity: 0;
  }
}

.call-card {
  width: min(320px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 30px 24px 26px;
  border: 1px solid color-mix(in srgb, var(--accent) 20%, var(--border));
  border-radius: 26px;
  background:
    radial-gradient(130% 90% at 50% 0%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 62%),
    var(--surface);
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: modal-in 0.24s var(--ease);
}

.call-avatar {
  display: block;
}

/* Folded away: the overlay stops swallowing clicks, the card makes room for a
   pill and the call itself keeps running in the background of the page. */
.call-overlay.is-minimized {
  background: transparent;
  pointer-events: none;
  padding: 0;
}

.call-overlay.is-minimized .call-card,
.call-bar {
  display: none;
}

.call-overlay.is-minimized .call-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  position: fixed;
  left: calc(12px + var(--lg-edge-left));
  right: calc(12px + var(--lg-edge-right));
  bottom: calc(12px + var(--lg-edge-bottom));
  max-width: 420px;
  margin: 0 auto;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: modal-in 0.2s var(--ease);
  z-index: 91;
  cursor: grab;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.call-overlay.is-minimized .call-bar.is-dragging {
  cursor: grabbing;
  animation: none;
  transition: none;
  box-shadow: var(--shadow-lg), 0 16px 36px rgba(0, 0, 0, 0.24);
}

/* Dragged somewhere: the pill leaves the centre line and hugs the corner that
   was closest when the finger let go. */
.call-overlay.is-minimized .call-bar.is-docked {
  margin: 0;
}

.call-overlay.is-minimized .call-bar.dock-left {
  left: calc(12px + var(--lg-edge-left));
  right: auto;
}

.call-overlay.is-minimized .call-bar.dock-right {
  right: calc(12px + var(--lg-edge-right));
  left: auto;
}

.call-overlay.is-minimized .call-bar.dock-top {
  top: calc(12px + var(--lg-edge-top));
  bottom: auto;
}

.call-overlay.is-minimized .call-bar.dock-bottom {
  bottom: calc(12px + var(--lg-edge-bottom));
  top: auto;
}

.call-bar-avatar {
  display: block;
  flex: none;
}

.call-bar-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.call-bar-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.call-bar-status {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.call-bar-btn {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 50%;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
  transition:
    transform 0.14s var(--ease),
    filter 0.14s var(--ease);
}

.call-bar-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

.call-bar-btn:last-child {
  background: var(--danger);
}

@media (max-width: 520px) {
  .call-overlay.is-minimized .call-bar {
    max-width: none;
  }

  /* Docked on a phone the pill gives back most of the width, so the corner it
     was dragged to stays free for the message field. */
  .call-overlay.is-minimized .call-bar.is-docked {
    max-width: min(340px, calc(100vw - 24px));
  }
}

.call-name {
  font-size: 19px;
  font-weight: 700;
  color: var(--text);
  overflow-wrap: anywhere;
}

.call-status {
  min-height: 20px;
  font-size: 14px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* The encryption chip. It is a button because the numbers behind it are the
   whole point of the shield: reading them is how you prove who is calling. */
.call-secure {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  align-self: center;
  margin: 2px 0 0;
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 650;
  cursor: pointer;
  transition:
    color 0.14s var(--ease),
    border-color 0.14s var(--ease),
    background 0.14s var(--ease);
}

.call-secure:hover {
  color: var(--text);
  border-color: var(--accent);
}

.call-secure.is-sealed,
.call-secure.is-verified {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  background: var(--accent-soft);
}

.call-secure.is-stalled,
.call-secure.is-broken {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 42%, var(--border));
  background: var(--danger-soft);
}

.call-secure svg {
  flex: none;
}

.call-secure-text {
  white-space: nowrap;
}

/* Folded into the pill the shield shrinks to a single dot of the same colour. */
.call-bar-secure {
  display: grid;
  place-items: center;
  flex: none;
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.call-bar-secure.is-sealed,
.call-bar-secure.is-verified {
  color: var(--accent);
  background: var(--accent-soft);
}

.call-bar-secure.is-stalled,
.call-bar-secure.is-broken {
  color: var(--danger);
  background: var(--danger-soft);
}

.call-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 6px;
}

.call-btn {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  padding: 0;
  border: none;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  transition:
    transform 0.14s var(--ease),
    filter 0.14s var(--ease);
}

.call-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
}

.call-btn:active {
  transform: scale(0.96);
}

.call-btn-accept {
  background: linear-gradient(160deg, #3ddc79, #1a9c52);
  box-shadow: 0 10px 24px rgba(28, 178, 94, 0.34);
}

.call-btn-end,
.call-btn-decline {
  background: linear-gradient(160deg, #ff6b6b, #cf2f46);
  box-shadow: 0 10px 24px rgba(207, 47, 70, 0.32);
}

.call-btn-retry {
  background: linear-gradient(160deg, #4aa8ff, #2b6fd6);
  box-shadow: 0 10px 24px rgba(43, 111, 214, 0.34);
}

.call-btn-mute {
  width: 48px;
  height: 48px;
  background: var(--surface-2);
  color: var(--text-2);
}

.call-btn-mute[aria-pressed='true'] {
  background: var(--danger-soft);
  color: var(--danger);
}

.call-btn-screen,
.call-btn-camera,
.call-btn-fullscreen,
.call-btn-speaker {
  width: 48px;
  height: 48px;
  background: var(--surface-2);
  color: var(--text-2);
}

.call-btn-speaker[aria-pressed='true'] {
  background: var(--accent-soft);
  color: var(--accent);
}

.call-btn-screen[aria-pressed='true'],
.call-btn-camera[aria-pressed='true'] {
  background: linear-gradient(160deg, #4aa3ff, #1f6fd0);
  color: #fff;
  box-shadow: 0 10px 24px rgba(31, 111, 208, 0.34);
}

.call-btn.is-unsupported {
  opacity: 0.45;
}

.call-actions {
  flex-wrap: wrap;
}

/* Full screen: the picture owns the display, only the controls stay on top.
   The class mirrors the Fullscreen API for WebViews that refuse to hand over
   the real screen, so both paths look identical. */
.call-overlay.is-fullscreen,
.call-overlay:fullscreen {
  padding: 0;
  background: #05070d;
}

.call-overlay.is-fullscreen .call-card,
.call-overlay:fullscreen .call-card {
  position: relative;
  width: 100%;
  max-width: none;
  height: 100%;
  padding: 0;
  border: none;
  border-radius: 0;
  background: #05070d;
  box-shadow: none;
  justify-content: flex-end;
  gap: 0;
  animation: none;
}

.call-overlay.is-fullscreen .call-card.has-video .call-stage,
.call-overlay:fullscreen .call-card.has-video .call-stage {
  position: absolute;
  inset: 0;
  aspect-ratio: auto;
  border-radius: 0;
}

.call-overlay.is-fullscreen .call-caption,
.call-overlay.is-fullscreen .call-name,
.call-overlay.is-fullscreen .call-status,
.call-overlay:fullscreen .call-caption,
.call-overlay:fullscreen .call-name,
.call-overlay:fullscreen .call-status {
  display: none;
}

.call-overlay.is-fullscreen .call-actions,
.call-overlay:fullscreen .call-actions {
  position: relative;
  z-index: 2;
  width: 100%;
  margin: 0;
  padding: 34px 18px calc(18px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to top, rgba(5, 7, 13, 0.78), rgba(5, 7, 13, 0));
}

/* In full screen the corner picture must not sit on top of the buttons. */
.call-overlay.is-fullscreen .call-video-pip,
.call-overlay:fullscreen .call-video-pip {
  bottom: calc(104px + env(safe-area-inset-bottom, 0px));
}

@media (max-width: 620px) {
  .call-actions {
    gap: 12px;
  }

  .call-btn,
  .call-btn-mute,
  .call-btn-screen,
  .call-btn-camera,
  .call-btn-fullscreen,
  .call-btn-speaker {
    width: 50px;
    height: 50px;
  }

  .call-card.has-video {
    padding: 10px 10px 16px;
  }

  .call-video-pip,
  .call-video-self {
    width: 32%;
  }
}

/* ——— End-to-end key verification ——— */

.e2ee-sheet {
  gap: 12px;
}

.e2ee-device {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 4px 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
}

/* Safety numbers are read out loud, so the groups of five are what the eye
   counts — the letter-spacing is the difference between "48291" and "4 8 2 9 1". */
.e2ee-number {
  grid-column: 1 / -1;
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.09em;
  color: var(--text);
  overflow-wrap: anywhere;
}

.e2ee-meta {
  font-size: 12px;
  color: var(--muted);
}

.e2ee-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 700;
}

.e2ee-confirm {
  justify-self: end;
  padding: 7px 13px;
  border: none;
  border-radius: 10px;
  font-size: 13px;
}

.e2ee-confirm:disabled {
  opacity: 0.55;
}

.e2ee-reset {
  align-self: flex-start;
  margin-top: 2px;
  color: var(--danger);
  font-size: 13px;
}

.e2ee-empty {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
}

/* ——— Deleting a message ——— */

.msg-action.is-danger:hover {
  color: var(--danger);
}

.msg-row.is-vanishing {
  overflow: hidden;
  pointer-events: none;
  transition:
    height 0.26s var(--ease),
    margin 0.26s var(--ease),
    opacity 0.18s linear;
}

.msg-row.is-vanishing .msg-wrap {
  transition: transform 0.24s var(--ease), opacity 0.18s linear;
}

.msg-row.in.is-vanishing .msg-wrap {
  transform-origin: left top;
}

.msg-row.out.is-vanishing .msg-wrap {
  transform-origin: right top;
}

.msg-row.is-vanishing.is-collapsed {
  height: 0;
  margin-block: 0;
  opacity: 0;
}

.msg-row.is-vanishing.is-collapsed .msg-wrap {
  transform: scale(0.84) translateY(-4px);
  opacity: 0;
}

.confirm-card {
  width: min(400px, 100%);
  max-height: none;
  padding: 20px;
  gap: 10px;
}

.confirm-head {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--danger);
}

.confirm-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 750;
  color: var(--text);
}

.confirm-preview {
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.4;
  max-height: 96px;
  overflow: hidden;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.confirm-hint {
  color: var(--muted);
  font-size: 13px;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

.confirm-cancel,
.confirm-accept {
  padding: 9px 16px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 650;
  transition: background 0.14s, color 0.14s, transform 0.12s;
}

.confirm-cancel {
  background: var(--surface-2);
  color: var(--text-2);
}

.confirm-cancel:hover {
  background: var(--border);
}

.confirm-accept {
  background: var(--danger-soft);
  color: var(--danger);
}

.confirm-accept:hover {
  background: color-mix(in srgb, var(--danger) 20%, transparent);
}

.confirm-cancel:active,
.confirm-accept:active {
  transform: scale(0.97);
}

@media (prefers-reduced-motion: reduce) {
  .msg-row.is-vanishing,
  .msg-row.is-vanishing .msg-wrap {
    transition-duration: 0.01s;
  }

  .msg-row.is-new,
  .app.chat-open .chat-pane,
  .app:not(.chat-open) .sidebar,
  .scroll-bottom:not([hidden]),
  .streak-chip.is-pop,
  .streak-chip.is-record,
  #lightbox img,
  #lightbox video {
    animation: none;
  }

  .chat-item:active,
  .streak-chip:hover,
  .streak-chip:active {
    transform: none;
  }
}

/* ——— Mute in chat + operator corner ——— */

.chat-mute-btn.is-muted {
  color: var(--danger);
  background: var(--danger-soft);
}

.chat-mute-btn.is-muted:hover {
  background: color-mix(in srgb, var(--danger) 20%, transparent);
}

.sidebar-operator-btn svg {
  width: 19px;
  height: 19px;
}

/* ——— What's new log + operator panel ——— */
/* Both are built from the theme's own variables, so the panels repaint with
   the theme and colour scheme the user picked. */

.log-modal,
.admin-modal {
  width: min(560px, 100%);
  max-height: min(700px, calc(100dvh - var(--lg-edge-block) - 48px));
}

.log-intro {
  margin: 0 20px 14px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
}

.log-body,
.admin-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  align-content: start;
  gap: 16px;
  padding: 0 20px 14px;
}

.log-version {
  display: grid;
  gap: 10px;
  padding: 15px 16px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.log-version.is-past {
  background: var(--surface);
  opacity: 0.82;
}

.log-version-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.log-version-number {
  font-size: 15.5px;
  font-weight: 800;
  letter-spacing: -0.2px;
  color: var(--accent-strong);
}

.log-version-date {
  font-size: 12px;
  color: var(--faint);
}

.log-version-you {
  margin-left: auto;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}

.log-items {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 9px;
}

.log-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.log-pill {
  flex: none;
  min-width: 66px;
  padding: 3px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  text-align: center;
}

.log-pill-added {
  border-color: transparent;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.log-pill-fixed {
  border-color: transparent;
  background: var(--danger-soft);
  color: var(--danger);
}

.log-item-text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
}

.log-done {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  /* The button reset leaves padding at zero, so on a phone the word "Done"
     is the button: its first and last letters sit on the rounded corners. */
  padding: 0 20px;
}

.log-done svg {
  width: 18px;
  height: 18px;
}

.log-done.is-acknowledged {
  background: var(--accent-soft);
  color: var(--accent-strong);
  box-shadow: none;
}

.admin-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 10px;
}

.admin-tile {
  display: grid;
  gap: 3px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.admin-tile-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--muted);
}

.admin-tile-value {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.admin-tile-hint {
  font-size: 11.5px;
  color: var(--faint);
}

.admin-list {
  display: grid;
  gap: 0;
  padding: 6px 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.admin-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 0;
  border-bottom: 1px solid var(--hover);
  font-size: 13px;
}

.admin-row:last-child {
  border-bottom: 0;
}

.admin-row-key {
  flex: none;
  color: var(--muted);
}

.admin-row-value {
  text-align: right;
  font-weight: 650;
  color: var(--text);
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.admin-subhead {
  margin: 4px 0 2px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--muted);
}

.admin-note {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.admin-offering {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.5;
  font-weight: 700;
  color: var(--accent-strong);
}

.admin-error {
  margin: 0;
  padding: 10px 13px;
  border-radius: 11px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
  line-height: 1.4;
}

.admin-login {
  display: grid;
  gap: 12px;
  padding: 0 20px 18px;
}

.admin-input {
  height: 46px;
  width: 100%;
  padding: 0 14px;
  border-radius: 13px;
  border: 1.5px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}

.admin-input::placeholder {
  color: var(--faint);
}

.admin-input:hover {
  border-color: color-mix(in srgb, var(--accent) 28%, var(--border));
}

.admin-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  background: var(--surface);
}

.admin-publish {
  display: grid;
  gap: 11px;
  padding: 15px 16px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.admin-publish-btn {
  width: 100%;
}

.admin-apk-input {
  width: 100%;
  font: inherit;
  font-size: 13px;
  color: var(--muted);
}

/* The card behind it is --surface-2, which is the same colour as --input-bg,
   so the picker button has to be the lighter surface or it reads as text. */
.admin-apk-input::file-selector-button {
  margin-right: 10px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.admin-publish-btn.is-danger {
  background: linear-gradient(135deg, var(--danger), color-mix(in srgb, var(--danger) 70%, #ff7a4d));
  color: #fff;
  box-shadow: 0 10px 24px var(--danger-soft);
}

@media (max-width: 620px) {
  .log-modal,
  .admin-modal {
    max-height: calc(92dvh - var(--lg-edge-block));
  }

  .log-item {
    gap: 8px;
  }

  .log-pill {
    min-width: 58px;
  }
}

/* 2.2.1: a file dragged over the window */
.drop-zone {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: color-mix(in srgb, var(--accent) 14%, rgba(8, 12, 20, 0.45));
  backdrop-filter: blur(3px);
  pointer-events: none;
}
.drop-zone[hidden] { display: none; }
.drop-zone-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 34px 46px;
  border: 2px dashed var(--accent);
  border-radius: 22px;
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
.drop-zone-card svg { color: var(--accent); }