:root {
  --accent: #3390ec;
  --accent-soft: rgba(51, 144, 236, 0.12);
  --bg: #ffffff;
  --sidebar: #ffffff;
  --surface: #f4f4f5;
  --hover: #f4f4f5;
  --active: #3390ec;
  --border: #e6e6e6;
  --text: #0f1419;
  --muted: #707579;
  --chat-bg: #d9e2c8;
  --chat-pattern: radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.35) 0, transparent 45%),
    radial-gradient(circle at 80% 70%, rgba(255, 255, 255, 0.25) 0, transparent 40%),
    linear-gradient(160deg, #cfdcb4 0%, #dfe6c9 45%, #c7d8b9 100%);
  --bubble-in: #ffffff;
  --bubble-out: #e3fee0;
  --bubble-meta-in: #8b9399;
  --bubble-meta-out: #4fae4e;
  --danger: #e53935;
  --danger-soft: rgba(229, 57, 53, 0.1);
  --danger-border: rgba(229, 57, 53, 0.55);
  --shadow: 0 1px 2px rgba(16, 35, 47, 0.15);
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #8774e1;
    --accent-soft: rgba(135, 116, 225, 0.16);
    --bg: #212121;
    --sidebar: #212121;
    --surface: #2c2c2c;
    --hover: #2c2c2c;
    --active: #8774e1;
    --border: #303030;
    --text: #ffffff;
    --muted: #aaaaaa;
    --chat-bg: #0f0f0f;
    --chat-pattern: radial-gradient(circle at 15% 25%, rgba(135, 116, 225, 0.12) 0, transparent 40%),
      radial-gradient(circle at 85% 75%, rgba(80, 160, 120, 0.1) 0, transparent 40%),
      linear-gradient(160deg, #10151a 0%, #0f0f0f 100%);
    --bubble-in: #212121;
    --bubble-out: #766ac8;
    --bubble-meta-in: #8a8a8a;
    --bubble-meta-out: rgba(255, 255, 255, 0.65);
    --danger: #ff5c5c;
    --danger-soft: rgba(255, 92, 92, 0.14);
    --danger-border: rgba(255, 92, 92, 0.6);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

button {
  font: inherit;
  color: inherit;
}

a {
  color: var(--accent);
}

.icon {
  width: 22px;
  height: 22px;
  flex: none;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 13px;
}

/* ---------------------------------------------------------------- boot & auth */

.boot {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
}

.spinner {
  width: 32px;
  height: 32px;
  margin: 24px auto;
  border-radius: 50%;
  border: 3px solid var(--accent-soft);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

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

.auth-screen {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: var(--chat-pattern), var(--chat-bg);
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg);
  border-radius: 20px;
  padding: 32px 28px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  text-align: center;
}

.auth-logo {
  width: 88px;
  height: 88px;
  margin: 0 auto 16px;
  background: url("/favicon.svg") center / contain no-repeat;
}

.auth-card h1 {
  margin: 0 0 4px;
  font-size: 24px;
}

.auth-card .field {
  text-align: left;
  margin-top: 24px;
}

.notice {
  margin-top: 20px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--accent-soft);
  font-size: 14px;
  text-align: left;
  line-height: 1.45;
}

.field {
  display: block;
  margin-bottom: 14px;
}

.field span {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.form-error {
  color: var(--danger);
  font-size: 14px;
  min-height: 1em;
  margin: 4px 0 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: 12px;
  border: 0;
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-ghost {
  background: var(--surface);
}

.btn-ghost.danger {
  color: var(--danger);
}

.btn-block {
  width: 100%;
}

/* ---------------------------------------------------------------- layout */

.layout {
  display: grid;
  grid-template-columns: minmax(300px, 420px) 1fr;
  grid-template-rows: minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--border);
  background: var(--sidebar);
}

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

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

.icon-btn:hover,
.icon-btn.active {
  background: var(--hover);
  color: var(--accent);
}

#deleted-toggle.active {
  background: var(--danger-soft);
  color: var(--danger);
}

.search-box {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  height: 42px;
  padding: 0 12px;
  border-radius: 22px;
  background: var(--surface);
  border: 2px solid transparent;
}

.search-box:focus-within {
  border-color: var(--accent);
  background: var(--bg);
}

.search-icon {
  color: var(--muted);
  display: inline-flex;
}

.search-icon .icon {
  width: 20px;
  height: 20px;
}

.search-box input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font: inherit;
}

.search-scope {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 45%;
  padding: 3px 6px 3px 10px;
  border-radius: 12px;
  border: 0;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  cursor: pointer;
}

.search-scope span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-scope .icon {
  width: 14px;
  height: 14px;
}

.tabs {
  display: flex;
  gap: 2px;
  padding: 0 8px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs button {
  position: relative;
  padding: 10px 12px;
  border: 0;
  background: none;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}

.tabs button.active {
  color: var(--accent);
}

.tabs button.active::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--accent);
}

.tabs .tab-deleted.active {
  color: var(--danger);
}

.tabs .tab-deleted.active::after {
  background: var(--danger);
}

.list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 6px;
}

.list-empty {
  padding: 32px 20px;
  text-align: center;
  color: var(--muted);
  line-height: 1.5;
}

.list-caption {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 10px 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.list-caption .icon {
  width: 16px;
  height: 16px;
  color: var(--danger);
}

.chat-item,
.result {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 12px;
  background: none;
  text-align: left;
  cursor: pointer;
}

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

.chat-item.active {
  background: var(--active);
  color: #fff;
}

.chat-item.active .chat-item-date,
.chat-item.active .chat-item-preview,
.chat-item.active .preview-sender {
  color: rgba(255, 255, 255, 0.85);
}

.chat-item.compact {
  padding: 6px 10px;
}

.chat-item-body,
.result-body {
  flex: 1;
  min-width: 0;
}

.chat-item-top,
.chat-item-bottom,
.result-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-item-title,
.result-title {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-item-date,
.result-date {
  flex: none;
  font-size: 12px;
  color: var(--muted);
}

.chat-item-bottom {
  margin-top: 3px;
}

.chat-item-preview,
.result-text {
  flex: 1;
  min-width: 0;
  color: var(--muted);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-sender,
.result-sender {
  color: var(--text);
}

.preview-deleted .icon {
  width: 14px;
  height: 14px;
  margin-right: 3px;
  vertical-align: -2px;
  color: var(--danger);
}

.badge-deleted {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex: none;
  padding: 2px 7px 2px 5px;
  border-radius: 10px;
  background: var(--danger);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}

.badge-deleted .icon {
  width: 13px;
  height: 13px;
}

.result {
  align-items: flex-start;
}

.result-deleted {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 3px;
  font-size: 12px;
  color: var(--danger);
}

.result-deleted .icon {
  width: 13px;
  height: 13px;
}

.result-thumb {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  flex: none;
}

.load-more {
  display: block;
  width: calc(100% - 12px);
  margin: 8px 6px 16px;
  padding: 10px;
  border-radius: 10px;
  border: 0;
  background: var(--surface);
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}

.sidebar-status {
  border-top: 1px solid var(--border);
  padding: 6px;
}

.status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.status-line:hover {
  background: var(--hover);
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
}

.dot-ok {
  background: #4fae4e;
}

.dot-busy {
  background: #f0a020;
  animation: pulse 1.6s ease-in-out infinite;
}

.dot-warn {
  background: #f0a020;
}

.dot-bad {
  background: var(--danger);
}

@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}

/* ---------------------------------------------------------------- avatars */

.avatar {
  display: grid;
  place-items: center;
  flex: none;
  border-radius: 50%;
  overflow: hidden;
  color: #fff;
  font-weight: 600;
  background: var(--accent);
  user-select: none;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-saved {
  background: var(--accent);
}

.avatar-saved .icon {
  width: 55%;
  height: 55%;
}

/* ---------------------------------------------------------------- chat pane */

.chat {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--chat-pattern), var(--chat-bg);
}

.chat-empty {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 16px;
}

.chat-empty-card {
  padding: 10px 18px;
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.22);
  color: #fff;
  text-align: center;
}

.chat-empty-card p {
  margin: 4px 0;
}

.chat-empty-card .muted {
  color: rgba(255, 255, 255, 0.8);
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  z-index: 2;
}

.back-btn {
  display: none;
}

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

.chat-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-subtitle {
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sub-deleted {
  color: var(--danger);
}

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

.messages-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 12px 12px 8px;
}

.messages-loading {
  padding-top: 20vh;
}

.chat-footer {
  padding: 10px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  background: var(--bg);
  border-top: 1px solid var(--border);
}

.jump-down {
  position: absolute;
  right: 20px;
  bottom: 60px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 0;
  display: grid;
  place-items: center;
  background: var(--bg);
  color: var(--muted);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  z-index: 3;
}

/* ---------------------------------------------------------------- messages */

.day-sep,
.service {
  display: flex;
  justify-content: center;
  margin: 10px 0;
}

.day-sep span,
.service span {
  padding: 4px 10px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.25);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  max-width: 80%;
}

.service.is-deleted span {
  background: rgba(229, 57, 53, 0.75);
}

.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  margin: 2px 0;
}

.msg-row.run-start {
  margin-top: 8px;
}

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

.msg-avatar {
  width: 34px;
  flex: none;
  align-self: flex-start;
}

.msg-row.highlight .bubble {
  animation: flash 2s ease-out;
}

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

.bubble {
  position: relative;
  max-width: min(480px, 82%);
  min-width: 64px;
  padding: 6px 10px 6px;
  border-radius: var(--radius);
  background: var(--bubble-in);
  box-shadow: var(--shadow);
  overflow-wrap: anywhere;
}

.out .bubble {
  background: var(--bubble-out);
}

.bubble.is-deleted {
  background-image: linear-gradient(var(--danger-soft), var(--danger-soft));
  box-shadow: 0 0 0 1.5px var(--danger-border), var(--shadow);
}

.bubble.bare {
  background: none;
  box-shadow: none;
  padding: 0;
}

.bubble.bare.is-deleted {
  padding: 4px;
  box-shadow: 0 0 0 1.5px var(--danger-border);
  background: var(--danger-soft);
}

.bubble.media-only {
  padding: 0;
  overflow: hidden;
}

.bubble.media-only .meta {
  position: absolute;
  right: 6px;
  bottom: 6px;
  padding: 2px 6px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
}

.bubble.media-only .meta .time,
.bubble.media-only .meta .edited {
  color: #fff;
}

.bubble.has-visual:not(.media-only) .media-visual,
.bubble.has-visual:not(.media-only) .album {
  margin: 4px -6px 4px;
}

.keep-note {
  display: flex;
  align-items: center;
  gap: 5px;
  /* Never widen the bubble beyond its media. */
  width: 0;
  min-width: 100%;
  margin: 4px 0 2px;
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 12px;
  font-weight: 500;
}

.keep-note .icon {
  width: 14px;
  height: 14px;
}


.sender {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 2px;
}

.via {
  font-weight: 400;
  color: var(--muted);
}

.text {
  white-space: pre-wrap;
  line-height: 1.4;
}

.text pre,
.text code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

.text code {
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.06);
}

.text pre {
  margin: 4px 0;
  padding: 8px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.06);
  white-space: pre-wrap;
}

.text blockquote {
  margin: 4px 0;
  padding: 2px 8px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 4px;
}

.spoiler {
  background: var(--muted);
  color: transparent;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.spoiler.revealed {
  background: transparent;
  color: inherit;
}

.mention,
.tag {
  color: var(--accent);
}

.out .text a,
.out .mention,
.out .tag {
  color: #3a8e3a;
}

.meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 2px;
  font-size: 12px;
  color: var(--bubble-meta-in);
  white-space: nowrap;
}

.out .meta {
  color: var(--bubble-meta-out);
}

.edited {
  border: 0;
  padding: 0;
  background: none;
  font-size: 12px;
  font-style: italic;
  color: inherit;
  cursor: pointer;
  text-decoration: underline dotted;
}

.deleted-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 7px 1px 5px;
  border-radius: 10px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.deleted-pill .icon {
  width: 12px;
  height: 12px;
}

.mini-deleted {
  color: var(--danger);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.service .mini-deleted {
  color: #fff;
}

.fwd {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--accent);
  margin-bottom: 3px;
}

.fwd .icon {
  width: 15px;
  height: 15px;
}

.reply {
  margin: 2px 0 5px;
  padding: 3px 8px;
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  background: var(--accent-soft);
  cursor: pointer;
  font-size: 13px;
  min-width: 0;
}

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

.reply-text {
  color: var(--text);
  opacity: 0.85;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reply-deleted {
  border-left-color: var(--danger);
  background: var(--danger-soft);
}

.media-visual {
  display: block;
  position: relative;
  max-width: 100%;
  overflow: hidden;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.08);
}

.bubble.media-only .media-visual {
  border-radius: var(--radius);
}

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

.media-visual video {
  object-fit: contain;
  background: #000;
}

.media-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  max-width: 100%;
  min-width: 200px;
  min-height: 110px;
  margin: 4px 0;
  padding: 14px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.06);
  text-align: center;
}

.ph-icon {
  color: var(--muted);
}

.ph-label {
  font-weight: 600;
}

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

.album {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 3px;
  width: min(360px, 70vw);
  border-radius: 10px;
  overflow: hidden;
}

.bubble.media-only .album {
  border-radius: var(--radius);
}

.album-tile {
  position: relative;
  display: block;
  height: 150px;
  background: rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

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

.album-tile .media-placeholder {
  min-width: 0;
  height: 100%;
  margin: 0;
  border-radius: 0;
}

.album-tile.tile-file {
  height: auto;
  grid-column: 1 / -1;
  background: none;
}

.tile-deleted {
  outline: 3px solid var(--danger);
  outline-offset: -3px;
}

.round-wrap {
  position: relative;
  width: 220px;
  height: 220px;
}

.round {
  width: 220px;
  height: 220px;
  border-radius: 50%;
  object-fit: cover;
  background: #000;
  cursor: pointer;
  display: block;
}

.round-dur {
  position: absolute;
  left: 8px;
  bottom: 8px;
  padding: 1px 6px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 12px;
}

.voice,
.audio {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 2px 0;
}

.voice audio,
.audio audio {
  height: 40px;
  max-width: 100%;
  width: 280px;
}

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

.audio-title {
  width: 100%;
  font-weight: 600;
  font-size: 14px;
}

.audio-dl {
  color: var(--muted);
}

.sticker {
  display: block;
  width: 170px;
  height: 170px;
  object-fit: contain;
}

.sticker-fallback {
  display: grid;
  place-items: center;
  width: 140px;
  height: 140px;
  font-size: 64px;
  line-height: 1;
}

.sticker-fallback small {
  font-size: 12px;
  color: var(--muted);
}

.doc,
.card-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 2px;
  color: inherit;
  text-decoration: none;
  min-width: 0;
}

.doc-icon,
.card-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  flex: none;
}

.out .doc-icon,
.out .card-icon {
  background: #4fae4e;
}

.doc-missing .doc-icon {
  background: var(--muted);
}

.doc-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.doc-name,
.card-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-size,
.card-sub {
  font-size: 13px;
  color: var(--muted);
}

.call-missed .card-icon {
  background: var(--danger);
}

.poll {
  min-width: 220px;
}

.poll-q {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  margin-bottom: 6px;
}

.poll ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.poll li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.poll-votes,
.poll-total {
  font-size: 13px;
  color: var(--muted);
}

.poll-total {
  margin-top: 6px;
}

.dice {
  font-size: 15px;
}

.dice-emoji {
  font-size: 40px;
}

.webpage {
  display: block;
  margin: 6px 0 2px;
  padding: 4px 8px;
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  background: var(--accent-soft);
  color: inherit;
  text-decoration: none;
  font-size: 14px;
}

.wp-site {
  font-weight: 600;
  color: var(--accent);
}

.wp-title {
  font-weight: 600;
}

.wp-desc {
  color: var(--text);
  opacity: 0.85;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------------------------------------------------------------- modals */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.45);
  animation: fade 0.15s ease-out;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

.modal {
  width: 100%;
  max-width: 420px;
  max-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  background: var(--bg);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

.modal.wide {
  max-width: 560px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px 4px 20px;
}

.modal-head h2 {
  margin: 0;
  font-size: 19px;
}

.modal-body {
  padding: 8px 20px 20px;
  overflow-y: auto;
}

.stats {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 16px;
  margin: 8px 0 16px;
}

.stats dt {
  color: var(--muted);
}

.stats dd {
  margin: 0;
  text-align: right;
  font-weight: 500;
}

.menu-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.menu-actions .btn {
  justify-content: flex-start;
}

.connect-form p {
  line-height: 1.45;
}

.connect-done {
  text-align: center;
}

.done-mark {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin: 8px auto;
  border-radius: 50%;
  background: #4fae4e;
  color: #fff;
}

.version {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.version:last-child {
  border-bottom: 0;
}

.version-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 14px;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.9);
  animation: fade 0.15s ease-out;
}

.lightbox img {
  max-width: 96vw;
  max-height: 90vh;
  object-fit: contain;
}

.lightbox-bar {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 6px;
}

.lightbox-bar .icon-btn {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

/* ---------------------------------------------------------------- mobile */

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

  .layout .chat {
    display: none;
  }

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

  .layout.chat-open .chat {
    display: flex;
  }

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

  .messages-inner {
    padding: 8px 8px 6px;
  }

  .bubble {
    max-width: 88%;
  }

  .jump-down {
    right: 14px;
  }
}
