:root,
[data-theme="mono"] {
  --bg: #0a0a0a;
  --bg-2: #111111;
  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.28);
  --text: #f5f5f5;
  --muted: #9a9a9a;
  --invert: #ffffff;
  --invert-text: #0a0a0a;
  --accent: #ffffff;
  --glow: rgba(255, 255, 255, 0.08);
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  --font-display: "Syne", sans-serif;
  --font-body: "IBM Plex Sans", sans-serif;
}

[data-theme="midnight"] {
  --bg: #070b16;
  --bg-2: #0d1426;
  --line: rgba(140, 170, 255, 0.16);
  --line-strong: rgba(160, 190, 255, 0.35);
  --text: #e8eefc;
  --muted: #8b9bb8;
  --invert: #d7e3ff;
  --invert-text: #0a1224;
  --accent: #8eb6ff;
  --glow: rgba(90, 140, 255, 0.16);
}

[data-theme="snow"] {
  --bg: #f3f3f1;
  --bg-2: #ffffff;
  --line: rgba(0, 0, 0, 0.1);
  --line-strong: rgba(0, 0, 0, 0.22);
  --text: #121212;
  --muted: #6b6b6b;
  --invert: #121212;
  --invert-text: #f7f7f5;
  --accent: #222222;
  --glow: rgba(0, 0, 0, 0.05);
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.12);
}

[data-theme="ember"] {
  --bg: #140c0a;
  --bg-2: #1d1210;
  --line: rgba(255, 180, 120, 0.16);
  --line-strong: rgba(255, 190, 140, 0.35);
  --text: #f7ebe3;
  --muted: #b89a8c;
  --invert: #ffd2b0;
  --invert-text: #1a0e0a;
  --accent: #ffb07a;
  --glow: rgba(255, 140, 80, 0.14);
}

[data-theme="forest"] {
  --bg: #08110d;
  --bg-2: #0e1a14;
  --line: rgba(140, 220, 170, 0.14);
  --line-strong: rgba(150, 230, 180, 0.32);
  --text: #e8f6ee;
  --muted: #8aa897;
  --invert: #b8f0cc;
  --invert-text: #07140e;
  --accent: #7fd9a4;
  --glow: rgba(80, 200, 130, 0.14);
}

[data-theme="ocean"] {
  --bg: #061318;
  --bg-2: #0b1c24;
  --line: rgba(100, 210, 220, 0.14);
  --line-strong: rgba(120, 220, 230, 0.32);
  --text: #e6f7f8;
  --muted: #7ea3a8;
  --invert: #9ef0f5;
  --invert-text: #061418;
  --accent: #5fd5de;
  --glow: rgba(60, 190, 200, 0.14);
}

* { box-sizing: border-box; }

:root {
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --kb: 0px;
}

html {
  margin: 0;
  width: 100%;
  height: var(--app-height, 100%);
  min-height: var(--app-height, 100%);
  background: var(--bg, #0a0a0a);
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  margin: 0;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: auto;
  width: 100%;
  height: var(--app-height, 100%);
  min-height: var(--app-height, 100%);
  overflow: hidden;
  overscroll-behavior: none;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(1200px 600px at 10% -10%, var(--glow), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, var(--glow), transparent 50%),
    linear-gradient(180deg, var(--bg-2) 0%, var(--bg) 45%, var(--bg) 100%);
  transition: background 0.35s ease, color 0.25s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

#app {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: auto;
  width: 100%;
  height: var(--app-height, 100%);
  min-height: var(--app-height, 100%);
  max-height: var(--app-height, 100%);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg, #0a0a0a);
}


input, textarea, [contenteditable="true"] {
  -webkit-user-select: text;
  user-select: text;
}

button, input, textarea { font: inherit; color: inherit; }
input, textarea, select { font-size: 16px; }
textarea {
  resize: vertical;
  min-height: 84px;
}
button { cursor: pointer; border: none; background: none; }

.app-shell {
  height: 100%;
  width: 100%;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
  padding: 0;
  background: var(--bg, #0a0a0a);
}

.app-shell:has(.auth-card) {
  place-items: center;
  display: grid;
  padding: 20px;
  overflow: auto;
}

.auth-card, .app-frame {
  width: 100%;
  height: 100%;
  min-height: 0;
  border: none;
  border-radius: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01));
  box-shadow: none;
  backdrop-filter: blur(10px);
  overflow: hidden;
  animation: rise 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.auth-card {
  width: min(420px, 100%);
  height: auto;
  padding: 36px 32px 28px;
  position: relative;
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(18px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.brand {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.04em;
  font-size: 2.2rem;
  margin: 0 0 8px;
}

.brand span { opacity: 0.45; }

.sub {
  color: var(--muted);
  margin: 0 0 28px;
  line-height: 1.45;
}

.field { display: grid; gap: 8px; margin-bottom: 14px; }

.field label {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.field input, .field textarea, .modal input, .modal textarea, .search-input {
  width: 100%;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--text) 4%, transparent);
  border-radius: 14px;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.field input:focus, .field textarea:focus, .modal input:focus, .modal textarea:focus, .search-input:focus {
  border-color: var(--line-strong);
  background: color-mix(in srgb, var(--text) 8%, transparent);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 560px) {
  .field-row { grid-template-columns: 1fr; }
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 999px;
  padding: 12px 18px;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  width: 100%;
  background: var(--invert);
  color: var(--invert-text);
  font-weight: 600;
  margin-top: 8px;
}

.btn-ghost {
  border: 1px solid var(--line);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 12px;
}

.btn-icon {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.btn-icon .ui-svg,
.btn-send .ui-svg,
.call-btn .ui-svg,
.media-bar-btn .ui-svg,
.voice-play .ui-svg,
.video-note-play .ui-svg,
.settings-ico .ui-svg,
.chat-item-more .ui-svg,
.archive-link .ui-svg,
.pending-file-label .ui-svg {
  display: block;
  pointer-events: none;
}

.btn-send {
  display: grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  padding-inline: 12px;
}

.btn-hold {
  touch-action: none;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.btn-hold.is-recording {
  transform: scale(1.12);
  background: color-mix(in srgb, #ff5a5a 22%, transparent);
  border-color: #ff5a5a;
  box-shadow: 0 0 0 4px rgba(255, 90, 90, 0.18);
}

.btn-hold.will-cancel {
  background: color-mix(in srgb, var(--text) 10%, transparent);
  border-color: var(--line-strong);
  box-shadow: none;
  opacity: 0.7;
}


.switch-auth {
  margin-top: 18px;
  text-align: center;
  color: var(--muted);
  font-size: 0.92rem;
}

.switch-auth button {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.error {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 0.9rem;
}

.app-frame {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  flex: 1;
  min-height: 0;
  height: auto;
  width: 100%;
}

.app-frame > * {
  min-height: 0;
  min-width: 0;
  height: 100%;
  overflow: hidden;
}

.sidebar {
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  background: rgba(0, 0, 0, 0.25);
  min-width: 0;
  height: 100%;
  overflow: hidden;
}

.sidebar-top {
  padding: 18px 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sidebar-brand {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.03em;
  font-size: 1.35rem;
}

.sidebar-actions { display: flex; gap: 8px; }

.me-row {
  padding: 0 16px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar-wrap {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 42px;
  height: 42px;
}
.avatar-wrap.xs { width: 28px; height: 28px; }
.avatar-wrap.sm { width: 34px; height: 34px; }
.avatar-wrap.lg { width: 64px; height: 64px; }
.avatar-wrap.xl { width: 140px; height: 140px; }
.avatar-wrap.xs.has-aura::before,
.avatar-wrap.xs.has-aura::after { inset: -3px; }
.avatar-wrap.has-aura::before,
.avatar-wrap.has-aura::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}
.avatar-wrap.has-aura::after {
  content: none;
}
.avatar-wrap .avatar {
  position: relative;
  z-index: 1;
}

.avatar-wrap.has-aura.aura-glow::before,
.avatar-wrap.has-aura.aura-pulse::before {
  background: radial-gradient(circle, color-mix(in srgb, var(--aura, #2f7cf6) 55%, transparent) 0%, transparent 70%);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--aura, #2f7cf6) 70%, transparent);
  animation: aura-pulse 1.8s ease-in-out infinite;
}
.avatar-wrap.has-aura.aura-pulse::before {
  animation: aura-pulse-strong 1.15s ease-in-out infinite;
}

.avatar-wrap.has-aura.aura-smoke::before {
  inset: -7px;
  background:
    radial-gradient(circle at 30% 40%, color-mix(in srgb, var(--aura) 40%, transparent), transparent 55%),
    radial-gradient(circle at 70% 60%, color-mix(in srgb, var(--aura) 28%, #888) 0%, transparent 60%);
  filter: blur(2px);
  opacity: 0.85;
  animation: aura-smoke 3.6s ease-in-out infinite;
}
.avatar-wrap.has-aura.aura-smoke::after {
  content: "";
  inset: -10px;
  background: radial-gradient(circle, transparent 45%, color-mix(in srgb, var(--aura) 22%, transparent) 70%, transparent 80%);
  filter: blur(3px);
  animation: aura-smoke 4.8s ease-in-out infinite reverse;
}

.avatar-wrap.has-aura.aura-ember::before {
  background:
    radial-gradient(circle at 50% 70%, color-mix(in srgb, var(--aura) 65%, #ff6a00) 0%, transparent 55%),
    radial-gradient(circle, color-mix(in srgb, var(--aura) 35%, transparent) 0%, transparent 72%);
  box-shadow: 0 0 12px color-mix(in srgb, var(--aura) 45%, #ff4d00);
  animation: aura-ember 2.2s ease-in-out infinite;
}

.avatar-wrap.has-aura.aura-fire::before {
  inset: -6px;
  background:
    conic-gradient(from 0deg, transparent, color-mix(in srgb, var(--aura) 80%, #ff9a3c), transparent 40%, color-mix(in srgb, var(--aura) 70%, #ff3b00), transparent 75%);
  filter: blur(1.5px);
  animation: aura-fire-spin 1.4s linear infinite;
  opacity: 0.9;
}
.avatar-wrap.has-aura.aura-fire::after {
  content: "";
  inset: -2px;
  background: radial-gradient(circle, color-mix(in srgb, var(--aura) 40%, #ffb000) 0%, transparent 68%);
  animation: aura-pulse-strong 0.9s ease-in-out infinite;
}

.avatar-wrap.has-aura.aura-vortex::before {
  inset: -6px;
  background: conic-gradient(
    from 90deg,
    transparent,
    color-mix(in srgb, var(--aura) 75%, #fff),
    transparent,
    color-mix(in srgb, var(--aura) 55%, #000),
    transparent
  );
  animation: aura-fire-spin 2.8s linear infinite;
  filter: blur(0.5px);
  opacity: 0.85;
}
.avatar-wrap.has-aura.aura-vortex::after {
  content: "";
  inset: -1px;
  border: 2px solid color-mix(in srgb, var(--aura) 70%, transparent);
  opacity: 0.65;
  animation: aura-fire-spin 4s linear infinite reverse;
}

.avatar-wrap.has-aura.aura-ripple::before {
  background: transparent;
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--aura) 55%, transparent);
  animation: aura-ripple 2s ease-out infinite;
}
.avatar-wrap.has-aura.aura-ripple::after {
  content: "";
  background: transparent;
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--aura) 40%, transparent);
  animation: aura-ripple 2s ease-out infinite 0.7s;
}

.avatar-wrap.has-aura.aura-spark::before {
  background: radial-gradient(circle, color-mix(in srgb, var(--aura) 50%, transparent) 0%, transparent 70%);
  box-shadow:
    0 0 0 2px color-mix(in srgb, var(--aura) 60%, transparent),
    10px -8px 0 -7px color-mix(in srgb, var(--aura) 90%, #fff),
    -9px 6px 0 -7px color-mix(in srgb, var(--aura) 90%, #fff),
    7px 10px 0 -8px color-mix(in srgb, var(--aura) 80%, #fff),
    -11px -5px 0 -8px color-mix(in srgb, var(--aura) 80%, #fff);
  animation: aura-spark 1.3s steps(2, end) infinite;
}

.avatar-wrap.has-aura.aura-neon::before {
  background: transparent;
  box-shadow:
    0 0 0 2px color-mix(in srgb, var(--aura) 90%, #fff),
    0 0 14px 2px color-mix(in srgb, var(--aura) 70%, transparent),
    0 0 28px 4px color-mix(in srgb, var(--aura) 35%, transparent);
  animation: aura-neon 1.6s ease-in-out infinite;
}

.avatar-wrap.has-aura.aura-halo::before {
  inset: -8px;
  background: transparent;
  border: 2px solid color-mix(in srgb, var(--aura) 55%, transparent);
  opacity: 0.75;
  animation: aura-halo 2.8s ease-in-out infinite;
}
.avatar-wrap.has-aura.aura-halo::after {
  content: "";
  inset: -3px;
  background: radial-gradient(circle, color-mix(in srgb, var(--aura) 35%, transparent) 0%, transparent 72%);
  border: 1px solid color-mix(in srgb, var(--aura) 80%, #fff);
  animation: aura-pulse 2s ease-in-out infinite;
}

@keyframes aura-pulse {
  0%, 100% { transform: scale(0.96); opacity: 0.75; }
  50% { transform: scale(1.08); opacity: 1; }
}
@keyframes aura-pulse-strong {
  0%, 100% { transform: scale(0.92); opacity: 0.65; }
  50% { transform: scale(1.14); opacity: 1; }
}
@keyframes aura-smoke {
  0%, 100% { transform: scale(0.98) translateY(0); opacity: 0.55; }
  50% { transform: scale(1.12) translateY(-2px); opacity: 0.95; }
}
@keyframes aura-ember {
  0%, 100% { transform: scale(0.97); filter: brightness(0.95); }
  40% { transform: scale(1.06); filter: brightness(1.25); }
  70% { transform: scale(1.02); filter: brightness(1.05); }
}
@keyframes aura-fire-spin {
  to { transform: rotate(360deg); }
}
@keyframes aura-ripple {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--aura) 55%, transparent); opacity: 1; }
  100% { box-shadow: 0 0 0 12px transparent; opacity: 0; }
}
@keyframes aura-spark {
  0% { filter: brightness(1); }
  50% { filter: brightness(1.35); }
  100% { filter: brightness(1); }
}
@keyframes aura-neon {
  0%, 100% { opacity: 0.75; filter: brightness(1); }
  50% { opacity: 1; filter: brightness(1.3); }
}
@keyframes aura-halo {
  0%, 100% { transform: scale(0.96) rotate(0deg); opacity: 0.55; }
  50% { transform: scale(1.08) rotate(8deg); opacity: 0.95; }
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(145deg, #fff, #777);
  color: #111;
  display: grid;
  place-items: center;
  font-weight: 700;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid var(--line-strong);
}

.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 64px; height: 64px; font-size: 1.3rem; }
.avatar.xl { width: 140px; height: 140px; font-size: 2.6rem; }
.avatar.sm { width: 34px; height: 34px; font-size: 0.8rem; }
.avatar.xs { width: 28px; height: 28px; font-size: 0.68rem; }

.name-with-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}
.dev-badge {
  display: inline-flex;
  color: #2f7cf6;
  flex-shrink: 0;
  line-height: 0;
}
.msg-author {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.chat-header-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.me-meta { min-width: 0; flex: 1; }
.me-meta strong, .chat-item-title strong, .chat-header h2 {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.me-meta strong { display: block; }
.me-meta span { color: var(--muted); font-size: 0.86rem; }

.chat-list {
  overflow: auto;
  padding: 6px 10px 16px;
  flex: 1;
}

.chat-item-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px;
  align-items: stretch;
  gap: 0;
  min-height: 64px;
  margin-bottom: 4px;
  border-radius: 16px;
  -webkit-tap-highlight-color: transparent;
  animation: fade-in 0.28s ease;
}

.chat-item-wrap.active {
  background: rgba(255, 255, 255, 0.06);
  outline: 1px solid var(--line);
}

.chat-item-wrap:active,
.chat-item:active {
  background: rgba(255, 255, 255, 0.08);
}

.chat-item-more {
  width: 48px;
  min-width: 48px;
  min-height: 48px;
  border-radius: 12px;
  color: var(--muted);
  display: grid;
  place-items: center;
  align-self: center;
  touch-action: manipulation;
  z-index: 1;
}

.chat-item {
  width: 100%;
  min-height: 64px;
  text-align: left;
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 12px;
  padding: 12px 8px 12px 12px;
  border-radius: 16px;
  margin-bottom: 0;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover { background: #e8e8e8; }
  .btn-ghost:hover {
    border-color: var(--line-strong);
    background: rgba(255, 255, 255, 0.04);
  }
  .btn-icon:hover { background: rgba(255, 255, 255, 0.06); }
  .chat-item-wrap:hover,
  .chat-item-wrap:focus-within {
    background: rgba(255, 255, 255, 0.06);
  }
  .chat-item-more:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
  }
  .archive-link:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
  }
  .call-hist-item:hover,
  .settings-row:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--line);
  }
  .people-results .chat-item:hover {
    background: rgba(255, 255, 255, 0.06);
  }
  .chat-header-main:hover {
    background: color-mix(in srgb, var(--text) 6%, transparent);
  }
  .message:hover .msg-more {
    opacity: 1;
    border-color: var(--line);
    background: color-mix(in srgb, var(--text) 6%, transparent);
  }
  .msg-menu button:hover {
    background: color-mix(in srgb, var(--text) 8%, transparent);
  }
  .forward-item:hover {
    background: color-mix(in srgb, var(--text) 5%, transparent);
  }
  .theme-swatch:hover { transform: translateY(-1px); }
  .result-row:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--line);
  }
  .action-row:hover {
    background: rgba(255, 255, 255, 0.05);
  }
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.chat-item-title {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.chat-item-title time {
  color: var(--muted);
  font-size: 0.75rem;
  flex-shrink: 0;
}

.chat-item-main {
  min-width: 0;
}

.chat-item-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.chat-item p {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.chat-item.has-unread strong {
  font-weight: 700;
}

.chat-item.has-unread p {
  color: var(--text);
  opacity: 0.85;
}

.unread-badge {
  flex-shrink: 0;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  background: var(--text);
  color: var(--bg);
}

.chat-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
  padding-bottom: var(--kb, 0px);
  box-sizing: border-box;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 120px),
    repeating-linear-gradient(0deg, transparent, transparent 31px, rgba(255, 255, 255, 0.015) 32px);
}

.chat-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  flex-shrink: 0;
}

.chat-header-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
  text-align: left;
  border-radius: 14px;
  padding: 4px 8px 4px 4px;
  transition: background 0.2s ease;
}

.chat-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.chat-header p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.messages-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 22px 20px;
}

.jump-bottom {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 6;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, var(--text) 12%);
  color: var(--text);
  display: grid;
  place-items: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  cursor: pointer;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.jump-bottom.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
}

.jump-bottom:not(.hidden):active {
  transform: scale(0.96);
}

.message-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  width: 100%;
  margin: 0 0 10px;
  animation: msg-in 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.message-row.mine {
  flex-direction: row-reverse;
  justify-content: flex-start;
}

.message-row.theirs {
  justify-content: flex-start;
}

.msg-avatar {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0 0 18px;
  cursor: pointer;
  flex-shrink: 0;
  line-height: 0;
  border-radius: 50%;
}

.msg-avatar:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.message {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: min(520px, calc(100% - 40px));
  width: auto;
  height: auto;
  text-align: left;
  min-width: 0;
}

.message-row.mine .message {
  align-items: flex-end;
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.bubble {
  display: inline-block;
  box-sizing: border-box;
  padding: 10px 14px;
  border-radius: 18px;
  line-height: 1.45;
  white-space: normal;
  border: 1px solid var(--line);
  max-width: 520px;
}

.message-row.mine .bubble {
  background: var(--invert);
  color: var(--invert-text);
  border-color: var(--invert);
  border-bottom-right-radius: 6px;
}

.message-row.theirs .bubble {
  background: color-mix(in srgb, var(--text) 6%, transparent);
  border-bottom-left-radius: 6px;
}

.bubble-media {
  padding: 8px;
  display: block;
}

.msg-text {
  display: block;
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: normal;
}

.msg-text + .msg-text,
.msg-image + .msg-text,
.msg-file + .msg-text {
  margin-top: 6px;
}

.msg-image {
  display: block;
  border-radius: 12px;
  overflow: hidden;
  max-width: min(320px, 70vw);
}

.msg-image img {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: cover;
}

.msg-file {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  min-width: 180px;
  padding: 4px;
}

.msg-file-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: color-mix(in srgb, var(--text) 12%, transparent);
}

.message-row.mine .msg-file-icon {
  background: color-mix(in srgb, var(--invert-text) 12%, transparent);
}

.msg-file-meta {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.msg-file-meta strong {
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-file-meta small {
  opacity: 0.7;
  font-size: 0.75rem;
}

.msg-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 0.75rem;
  color: var(--muted);
  padding: 4px 4px 0;
  line-height: 1.2;
}

.message-row.mine .msg-meta { justify-content: flex-end; }
.message-row.theirs .msg-meta { justify-content: flex-start; }

.msg-edited {
  opacity: 0.7;
  font-style: italic;
}

.msg-ticks {
  display: inline-flex;
  align-items: center;
  gap: 0;
  font-size: 0.82rem;
  line-height: 1;
  opacity: 0.75;
  font-weight: 700;
}

.msg-ticks .tick {
  display: inline-block;
  width: 0.55em;
  text-align: center;
}

.msg-ticks.delivered {
  opacity: 0.9;
}

.msg-ticks.read {
  opacity: 1;
  color: var(--text);
}

.msg-receipt {
  font-size: 0.72rem;
  opacity: 0.75;
  text-transform: lowercase;
}

.msg-more {
  width: 26px;
  height: 22px;
  border-radius: 8px;
  border: 1px solid transparent;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1;
  opacity: 0.55;
  transition: opacity 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.msg-more:focus {
  opacity: 1;
  border-color: var(--line);
  background: color-mix(in srgb, var(--text) 6%, transparent);
}

.msg-forward {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 6px;
  padding-left: 8px;
  border-left: 2px solid var(--accent);
}

.bubble-deleted {
  opacity: 0.55;
  font-style: italic;
  background: transparent !important;
  border-style: dashed !important;
  color: var(--muted) !important;
}

.msg-menu {
  position: fixed;
  z-index: 80;
  min-width: 180px;
  padding: 6px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  box-shadow: var(--shadow);
  display: grid;
  gap: 2px;
  animation: rise 0.18s ease;
}

.msg-menu button {
  text-align: left;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--text);
  transition: background 0.15s ease;
}

.msg-menu button.danger {
  color: #ff8f8f;
}

[data-theme="snow"] .msg-menu button.danger {
  color: #b42318;
}

.avatar-crop-overlay {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: grid;
  place-items: end center;
  padding: 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
  background: rgba(0, 0, 0, 0.65);
  animation: fade-in 0.2s ease;
}

.avatar-crop-card {
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--bg-2);
  box-shadow: var(--shadow);
  padding: 20px;
  display: grid;
  gap: 14px;
  animation: rise 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.avatar-crop-card h3 {
  margin: 0;
  font-family: var(--font-display);
  letter-spacing: -0.03em;
}

.avatar-crop-card .hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.avatar-crop-stage {
  display: grid;
  place-items: center;
  padding: 8px 0;
}

.avatar-crop-viewport {
  width: 280px;
  height: 280px;
  border-radius: 50%;
  overflow: hidden;
  position: relative;
  touch-action: none;
  cursor: grab;
  border: 2px solid var(--line-strong);
  background: #111;
  flex-shrink: 0;
}

.avatar-crop-viewport:active {
  cursor: grabbing;
}

.avatar-crop-viewport img {
  position: absolute;
  left: 0;
  top: 0;
  max-width: none;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
  will-change: transform;
}

.avatar-crop-zoom {
  display: grid;
  gap: 8px;
}

.avatar-crop-zoom span {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.avatar-crop-zoom input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(28px, calc(env(safe-area-inset-bottom, 0px) + 16px));
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  pointer-events: none;
  z-index: 120;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--text);
  box-shadow: var(--shadow);
  transition: opacity 0.2s ease, transform 0.2s ease;
  font-size: 0.9rem;
  max-width: min(92vw, 360px);
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.forward-list {
  display: grid;
  gap: 6px;
  max-height: 320px;
  overflow: auto;
  margin: 8px 0 4px;
}

.forward-item {
  display: grid;
  grid-template-columns: auto 34px 1fr;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.15s ease;
}

.forward-item input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.notify-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 16px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  cursor: pointer;
}

.notify-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.notify-prompt {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: end center;
  padding: 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
  background: rgba(0, 0, 0, 0.55);
  animation: fade-in 0.2s ease;
}

.notify-prompt-card {
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--bg-2);
  box-shadow: var(--shadow);
  padding: 22px;
  display: grid;
  gap: 16px;
  animation: rise 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  max-height: min(85dvh, 720px);
  overflow: auto;
}

.notify-prompt-text strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.25rem;
  letter-spacing: -0.03em;
  margin-bottom: 6px;
}

.notify-prompt-text p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.notify-footnote {
  font-size: 0.9rem;
}

.modal-footnote {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.4;
}

.notify-steps {
  margin: 12px 0 0;
  padding-left: 1.2rem;
  color: var(--text);
  display: grid;
  gap: 8px;
  font-size: 0.92rem;
  line-height: 1.4;
}

.notify-steps li::marker {
  color: var(--muted);
}

.notify-prompt-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.composer {
  padding: 10px 12px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

body.kb-open .composer {
  padding-bottom: 8px !important;
}

.chat-panel.swipe-back {
  will-change: transform;
}

.composer-field {
  position: relative;
  min-width: 0;
}

.composer-field input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--text) 5%, transparent);
  border-radius: 22px;
  padding: 10px 16px;
  outline: none;
}

.composer-field input:focus {
  border-color: var(--line-strong);
  background: color-mix(in srgb, var(--text) 8%, transparent);
}

.composer-end {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.composer .btn-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
}

.composer.is-typing #btn-voice,
.composer.is-typing #btn-circle {
  display: none;
}

.composer:not(.is-typing) .btn-send {
  display: none !important;
}

.composer.is-typing .btn-send {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  margin: 0;
  padding: 0;
  border-radius: 50%;
  display: grid !important;
  place-items: center;
  font-size: 1rem;
  flex-shrink: 0;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.bubble-voice,
.bubble-circle {
  background: transparent !important;
  border-color: transparent !important;
  padding: 0 !important;
}

.voice-note {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 10px;
  align-items: center;
  min-width: 220px;
  max-width: 320px;
  padding: 10px 12px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--text) 6%, transparent);
}

.message-row.mine .voice-note {
  background: var(--invert);
  color: var(--invert-text);
  border-color: var(--invert);
}

.voice-play {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--text) 10%, transparent);
  display: grid;
  place-items: center;
  font-size: 0.85rem;
}

.message-row.mine .voice-play {
  border-color: color-mix(in srgb, var(--invert-text) 20%, transparent);
  background: color-mix(in srgb, var(--invert-text) 10%, transparent);
  color: var(--invert-text);
}

.voice-wave {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 28px;
}

.voice-wave span {
  width: 3px;
  border-radius: 99px;
  background: currentColor;
  opacity: 0.55;
  height: var(--h, 40%);
  flex-shrink: 0;
}

.voice-note.playing .voice-wave span {
  animation: voice-bar 0.8s ease-in-out infinite;
}

.voice-note.playing .voice-wave span:nth-child(2) { animation-delay: 0.1s; }
.voice-note.playing .voice-wave span:nth-child(3) { animation-delay: 0.2s; }
.voice-note.playing .voice-wave span:nth-child(4) { animation-delay: 0.05s; }
.voice-note.playing .voice-wave span:nth-child(5) { animation-delay: 0.15s; }

@keyframes voice-bar {
  0%, 100% { transform: scaleY(0.55); }
  50% { transform: scaleY(1); }
}

.voice-time {
  font-size: 0.78rem;
  opacity: 0.75;
  min-width: 36px;
  text-align: right;
}

.voice-note audio { display: none; }

.video-note {
  position: relative;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--line-strong);
  cursor: pointer;
  background: #000;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  flex-shrink: 0;
  transform-origin: center center;
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.22s ease;
  z-index: 1;
}

.video-note.playing {
  transform: scale(1.14);
  z-index: 3;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

.video-note video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.video-note video::-webkit-media-controls {
  display: none !important;
}

.video-note-play {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.video-note-time {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  font-size: 0.75rem;
  color: #fff;
  background: rgba(0, 0, 0, 0.45);
  padding: 2px 8px;
  border-radius: 999px;
  pointer-events: none;
}

.media-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  flex-shrink: 0;
  min-height: 44px;
}

.media-bar-btn,
.media-bar-speed {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: color-mix(in srgb, var(--text) 6%, transparent);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 600;
}

.media-bar-speed {
  width: auto;
  min-width: 40px;
  padding: 0 8px;
  font-variant-numeric: tabular-nums;
}

.media-bar-seek {
  flex: 1;
  min-width: 0;
  accent-color: var(--accent);
  height: 4px;
}

.media-bar-time {
  font-size: 0.78rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
}

.record-overlay {
  position: fixed;
  inset: 0;
  z-index: 99998;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.62);
  pointer-events: none;
}

.record-overlay.hold-mode {
  align-items: end;
  padding-bottom: max(96px, calc(env(safe-area-inset-bottom, 0px) + 88px));
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.15), rgba(0, 0, 0, 0.55));
}

.record-overlay.will-cancel .record-card {
  border-color: color-mix(in srgb, #ff5a5a 55%, var(--line));
  opacity: 0.85;
}

.record-card {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--bg-2);
  padding: 18px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
  pointer-events: none;
}

.record-hint {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
}

.record-overlay.will-cancel .record-hint {
  color: #ff8a8a;
}

.record-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.record-top strong { flex: 1; }

.record-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ff5a5a;
  box-shadow: 0 0 0 0 rgba(255, 90, 90, 0.5);
  animation: pulse 1.2s infinite;
}

#record-preview {
  width: 240px;
  height: 240px;
  border-radius: 50%;
  object-fit: cover;
  margin: 0 auto;
  background: #000;
  border: 2px solid var(--line-strong);
}

.record-voice-visual {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.record-voice-visual span {
  width: 5px;
  height: 18px;
  border-radius: 99px;
  background: var(--accent);
  animation: voice-bar 0.9s ease-in-out infinite;
}

.record-voice-visual span:nth-child(2) { animation-delay: 0.1s; height: 36px; }
.record-voice-visual span:nth-child(3) { animation-delay: 0.2s; height: 52px; }
.record-voice-visual span:nth-child(4) { animation-delay: 0.15s; height: 28px; }
.record-voice-visual span:nth-child(5) { animation-delay: 0.25s; height: 44px; }

.record-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.attach-btn {
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  width: 44px;
  height: 44px;
  border-radius: 50%;
}

.pending-file {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 12px 8px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--text) 5%, transparent);
  font-size: 0.88rem;
  flex-shrink: 0;
}

.pending-file button {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.empty-chat {
  height: 100%;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 40px;
}

.empty-chat h2 {
  font-family: var(--font-display);
  font-size: 2rem;
  letter-spacing: -0.04em;
  margin: 0 0 10px;
}

.empty-chat p { color: var(--muted); margin: 0; max-width: 340px; }

.typing {
  min-height: 20px;
  padding: 0 22px 8px;
  color: var(--muted);
  font-size: 0.82rem;
  flex-shrink: 0;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 20px;
  animation: fade-in 0.2s ease;
}

.modal {
  width: min(480px, 100%);
  max-height: min(90vh, 820px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--bg-2);
  box-shadow: var(--shadow);
  padding: 22px;
  animation: rise 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.modal-wide { width: min(560px, 100%); }

.theme-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.theme-swatch {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 10px 10px;
  text-align: left;
  position: relative;
  overflow: hidden;
  min-height: 68px;
  transition: transform 0.18s ease, border-color 0.18s ease;
}

.theme-swatch span {
  position: relative;
  z-index: 1;
  font-size: 0.82rem;
  font-weight: 600;
}

.theme-swatch.active { border-color: var(--accent); outline: 1px solid var(--accent); }

.theme-mono { background: linear-gradient(135deg, #111, #333); color: #fff; }
.theme-midnight { background: linear-gradient(135deg, #0b1224, #2a4d8f); color: #e8eefc; }
.theme-snow { background: linear-gradient(135deg, #fff, #d9d9d5); color: #111; }
.theme-ember { background: linear-gradient(135deg, #2a1410, #c56a3a); color: #ffe8d8; }
.theme-forest { background: linear-gradient(135deg, #0d1c14, #2f8a57); color: #e8f6ee; }
.theme-ocean { background: linear-gradient(135deg, #0a1d24, #2aa0ab); color: #e6f7f8; }

.profile-bio {
  white-space: pre-wrap;
  line-height: 1.45;
  margin: 0 0 14px;
}

.profile-status {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

.profile-facts {
  display: grid;
  gap: 10px;
  margin-bottom: 8px;
}

.profile-facts div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.profile-facts span {
  color: var(--muted);
  font-size: 0.84rem;
}

.modal h3 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  letter-spacing: -0.03em;
}

.modal .hint {
  color: var(--muted);
  margin: 0 0 18px;
  font-size: 0.9rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.search-results, .member-results {
  margin-top: 12px;
  max-height: 280px;
  overflow: auto;
  display: grid;
  gap: 6px;
}

.result-row {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid transparent;
  transition: background 0.2s ease, border-color 0.2s ease;
  width: 100%;
  text-align: left;
}

.result-row strong { display: block; }
.result-row span { color: var(--muted); font-size: 0.84rem; }

.chip-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.84rem;
  background: rgba(255, 255, 255, 0.04);
}

.online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.45); }
  70% { box-shadow: 0 0 0 8px rgba(255, 255, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); }
}

.boot {
  font-family: var(--font-display);
  letter-spacing: -0.04em;
  font-size: 1.6rem;
  animation: rise 0.4s ease;
}

.hidden { display: none !important; }

@media (max-width: 860px) {
  .app-shell:has(.auth-card) { padding: 0; }
  .auth-card {
    width: 100%;
    height: 100%;
    border-radius: 0;
    border: none;
    box-shadow: none;
    padding: max(24px, env(safe-area-inset-top, 0px)) 20px max(24px, env(safe-area-inset-bottom, 0px));
    overflow: auto;
  }
  .app-frame {
    grid-template-columns: 1fr;
    height: 100%;
  }
  .app-frame.show-chat .sidebar { display: none; }
  .app-frame:not(.show-chat) .chat-panel { display: none; }
  .back-btn { display: grid !important; }

  .sidebar-top {
    padding-top: 12px;
  }
  .me-row {
    padding-inline: 12px;
    gap: 10px;
    flex-wrap: wrap;
  }
  .me-meta {
    flex: 1 1 140px;
    min-width: 0;
  }
  .btn-logout {
    padding: 8px 10px;
    font-size: 0.82rem;
    margin-left: auto;
  }
  .chat-list {
    padding-bottom: 12px;
    -webkit-overflow-scrolling: touch;
  }
  .chat-item {
    padding: 14px 12px;
    border-radius: 14px;
  }

  .chat-header {
    padding: 10px;
    gap: 8px;
  }
  .chat-header h2 { font-size: 1.05rem; }
  .chat-panel {
    touch-action: pan-y;
  }
  .messages {
    padding: 12px 10px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
  }
  .chat-panel.swipe-back,
  .chat-panel.swipe-back .messages {
    touch-action: none;
  }
  .message { max-width: min(88%, 520px); }
  .bubble { max-width: min(88vw, 520px); }
  .msg-image { max-width: min(260px, 78vw); }
  .voice-note {
    min-width: 0;
    width: min(280px, 78vw);
    max-width: 78vw;
  }
  .video-note {
    width: min(184px, 56vw);
    height: min(184px, 56vw);
  }
  .media-bar {
    padding: 8px 10px;
    gap: 8px;
  }
  .media-bar-time {
    font-size: 0.72rem;
  }
  .msg-menu {
    min-width: min(220px, calc(100vw - 24px));
    max-width: calc(100vw - 24px);
  }
  .msg-meta {
    flex-wrap: wrap;
    gap: 4px 8px;
  }

  .composer {
    gap: 6px;
    padding: 8px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }
  .composer .btn-icon,
  .attach-btn,
  .composer .btn-send {
    width: 42px;
    height: 42px;
  }
  .composer-field input,
  .composer-field textarea {
    min-height: 42px;
    border-radius: 21px;
  }
  .composer-end { gap: 4px; }

  .typing { padding-inline: 12px; }
  .pending-file { margin-inline: 8px; }

  .overlay, .notify-prompt {
    padding: 12px;
    padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
    align-items: end;
    place-items: end center;
  }
  .modal, .notify-prompt-card, .modal-wide {
    width: 100%;
    max-height: min(90dvh, 820px);
    border-radius: 20px 20px 16px 16px;
    padding: 18px 16px max(16px, env(safe-area-inset-bottom, 0px));
  }
  .modal-actions {
    position: sticky;
    bottom: 0;
    padding-top: 8px;
    background: linear-gradient(180deg, transparent, var(--bg-2) 30%);
  }
  .theme-grid { grid-template-columns: repeat(2, 1fr); }
  .search-results, .member-results, .forward-list { max-height: 38dvh; }
  .empty-chat { padding: 28px 20px; }
  .empty-chat h2 { font-size: 1.55rem; }
  .record-card {
    width: min(420px, 100%);
    border-radius: 20px;
  }
  .record-overlay {
    padding: 12px;
    padding-bottom: max(88px, calc(env(safe-area-inset-bottom, 0px) + 72px));
  }

  #record-preview {
    width: min(200px, 64vw);
    height: min(200px, 64vw);
  }
  .record-overlay.hold-mode {
    padding-inline: 12px;
  }

  .brand { font-size: 1.9rem; }
  .auth-card .sub { margin-bottom: 20px; }
}

@media (display-mode: standalone), (display-mode: fullscreen) {
  .sidebar-top {
    padding-top: max(16px, var(--sat));
  }
  .chat-header {
    padding-top: max(12px, var(--sat));
  }
  .app-frame:not(.show-chat) .sidebar,
  .app-frame.show-chat .chat-panel {
    padding-bottom: 0;
  }
}

html.standalone .sidebar-top {
  padding-top: max(16px, var(--sat));
}

html.standalone .chat-header {
  padding-top: max(12px, var(--sat));
}

html.standalone .composer {
  padding-bottom: calc(10px + var(--sab));
}

html.standalone body.kb-open .composer {
  padding-bottom: 8px !important;
}

.back-btn { display: none; }

html.call-active,
html.call-active body {
  overflow: hidden !important;
  overscroll-behavior: none;
  touch-action: none;
}

html.call-active #app {
  height: 100% !important;
  min-height: 100% !important;
}

#call-root {
  position: fixed;
  inset: 0;
  z-index: 200;
  pointer-events: none;
}

#call-root:empty {
  display: none;
}

#call-root .call-overlay {
  pointer-events: auto;
}

.call-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding:
    max(24px, env(safe-area-inset-top, 0px))
    20px
    max(24px, env(safe-area-inset-bottom, 0px));
  background:
    radial-gradient(900px 500px at 50% 20%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 60%),
    linear-gradient(180deg, var(--bg-2), var(--bg));
  --call-level: 0;
  animation: fade-in 0.25s ease;
}

.call-top {
  text-align: center;
  width: min(480px, 100%);
}

.call-title {
  color: var(--muted);
  font-size: 0.86rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.call-peer-name {
  font-family: var(--font-display);
  font-size: 1.7rem;
  letter-spacing: -0.03em;
}

.call-peer-nick {
  color: var(--muted);
  margin-top: 4px;
}

.call-mode-hint {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.82rem;
}

.call-diag {
  display: none;
}

.call-net {
  margin-top: 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
}

.call-net-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #888;
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 18%, transparent);
}

.call-net[data-quality="excellent"] .call-net-dot { background: #5dff9a; color: #5dff9a; }
.call-net[data-quality="good"] .call-net-dot { background: #b7ff6a; color: #b7ff6a; }
.call-net[data-quality="fair"] .call-net-dot { background: #ffd166; color: #ffd166; }
.call-net[data-quality="poor"] .call-net-dot { background: #ff6b6b; color: #ff6b6b; }
.call-net[data-quality="checking"] .call-net-dot { background: #8a8a8a; color: #8a8a8a; }

.call-net-rtt {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.call-overlay[data-phase="connecting"] #call-status-label,
.call-overlay[data-phase="ringing"] #call-status-label {
  color: var(--accent);
}

.call-overlay[data-phase="in_call"] #call-status-label {
  color: #7dffa3;
}

.call-stage {
  flex: 1;
  width: min(560px, 100%);
  display: grid;
  place-items: center;
  gap: 22px;
  min-height: 0;
}

.call-avatar-wrap {
  position: relative;
  width: min(220px, 56vw);
  height: min(220px, 56vw);
  display: grid;
  place-items: center;
}

.call-aura {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
  opacity: calc(0.25 + var(--call-level) * 0.75);
  transform: scale(calc(1 + var(--call-level) * 0.45));
  transition: transform 0.08s linear, opacity 0.08s linear;
  pointer-events: none;
}

.call-aura.a1 { inset: -8%; }
.call-aura.a2 {
  inset: -18%;
  opacity: calc(0.15 + var(--call-level) * 0.55);
  transform: scale(calc(1 + var(--call-level) * 0.7));
}
.call-aura.a3 {
  inset: -30%;
  opacity: calc(0.08 + var(--call-level) * 0.4);
  transform: scale(calc(1 + var(--call-level) * 0.95));
  box-shadow: 0 0 40px color-mix(in srgb, var(--accent) calc(var(--call-level) * 55%), transparent);
}

.call-avatar-circle {
  position: relative;
  z-index: 2;
  border-radius: 50%;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.call-avatar-circle .avatar.xl {
  width: min(140px, 36vw);
  height: min(140px, 36vw);
}

.call-eq {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 5px;
  height: 36px;
}

.call-eq span {
  width: 4px;
  height: 100%;
  border-radius: 99px;
  background: var(--accent);
  opacity: 0.75;
  transform: scaleY(0.2);
  transform-origin: center bottom;
}

.call-video-frame {
  position: relative;
  width: min(420px, 92vw);
  aspect-ratio: 3 / 4;
  max-height: min(62vh, 640px);
  border-radius: 22px;
  overflow: hidden;
  background: #000;
  border: 1px solid color-mix(in srgb, var(--accent) calc(30% + var(--call-level) * 50%), var(--line));
  box-shadow:
    0 0 0 calc(2px + var(--call-level) * 10px) color-mix(in srgb, var(--accent) calc(var(--call-level) * 40%), transparent),
    0 20px 50px rgba(0, 0, 0, 0.45);
  transition: box-shadow 0.08s linear, border-color 0.08s linear;
}

.call-video-frame video#call-remote-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #000;
}

.call-local-pip {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 28%;
  max-width: 140px;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: #111;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.call-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: min(420px, 100%);
  padding-bottom: 8px;
}

.call-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-size: 1.35rem;
  background: color-mix(in srgb, var(--text) 8%, transparent);
  color: var(--text);
  transition: transform 0.15s ease, background 0.15s ease;
}

.call-btn:active { transform: scale(0.96); }

.call-btn.accept {
  background: #2fbf71;
  border-color: #2fbf71;
  color: #06140c;
  width: 72px;
  height: 72px;
}

.call-btn.reject {
  background: #e25555;
  border-color: #e25555;
  color: #fff;
}

.call-btn.active {
  outline: 2px solid var(--accent);
}

.call-overlay.status-ringing .call-aura {
  animation: call-ring 1.4s ease-out infinite;
}

.call-overlay.status-ringing .call-aura.a2 { animation-delay: 0.2s; }
.call-overlay.status-ringing .call-aura.a3 { animation-delay: 0.4s; }

@keyframes call-ring {
  0% { transform: scale(1); opacity: 0.55; }
  100% { transform: scale(1.35); opacity: 0; }
}

#call-remote-audio {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  left: 0;
  top: 0;
}

.call-ear-veil {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 50;
  background: #000;
  pointer-events: none;
}

html.call-near-ear .call-ear-veil {
  display: block;
}

html.call-near-ear .call-stage,
html.call-near-ear .call-top {
  opacity: 0.02;
}

html.call-near-ear .call-actions {
  opacity: 0.2;
}

.call-overlay.earpiece {
  filter: none;
}

.call-btn.speaker.active {
  background: color-mix(in srgb, var(--accent) 28%, transparent);
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
}

@media (max-width: 860px) {
  .chat-header-actions .btn-icon {
    width: 40px;
    height: 40px;
  }
  .call-btn {
    width: 58px;
    height: 58px;
  }
  .call-btn.accept {
    width: 66px;
    height: 66px;
  }
}

.tab-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
  flex-shrink: 0;
  border-top: 1px solid var(--line);
  background: var(--bg);
  backdrop-filter: blur(14px);
  padding: 6px 8px;
  padding-bottom: calc(6px + var(--sab-px, env(safe-area-inset-bottom, 0px)));
  z-index: 40;
  margin: 0;
}

#modal-root {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
}

#modal-root:empty {
  display: none;
}

#modal-root:not(:empty) {
  pointer-events: auto;
}

.tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 52px;
  padding: 8px 4px;
  border-radius: 12px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.tab-btn .tab-ico {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  line-height: 0;
  pointer-events: none;
}

.tab-btn .ui-svg,
.tab-btn .tab-svg {
  width: 24px;
  height: 24px;
  display: block;
  opacity: 0.72;
  transition: opacity 0.15s ease;
  pointer-events: none;
}

.tab-btn.active {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.tab-btn.active .ui-svg,
.tab-btn.active .tab-svg {
  opacity: 1;
}

.app-frame.show-chat ~ .tab-bar {
  display: none;
}

@media (min-width: 861px) {
  .app-shell:not(:has(.auth-card)) {
    flex-direction: row;
    align-items: stretch;
  }

  .app-shell:not(:has(.auth-card)) > .app-frame {
    order: 2;
    flex: 1;
    min-width: 0;
    height: 100%;
  }

  .app-shell:not(:has(.auth-card)) > .tab-bar {
    order: 1;
    position: relative;
    left: auto;
    right: auto;
    bottom: auto;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    gap: 6px;
    width: 76px;
    height: 100%;
    min-height: 0;
    margin: 0;
    padding: 16px 8px 16px;
    border-top: none;
    border-right: 1px solid var(--line);
    background: color-mix(in srgb, var(--bg) 94%, transparent);
  }

  .app-shell:not(:has(.auth-card)) > .app-frame {
    padding-bottom: 0;
  }

  .app-shell:not(:has(.auth-card)) > #modal-root {
    order: 3;
  }

  .app-frame.show-chat ~ .tab-bar {
    display: flex;
  }

  .tab-btn {
    width: 100%;
    min-height: 64px;
    padding: 12px 6px;
    gap: 5px;
    font-size: 0.66rem;
  }
}

.archive-link {
  margin: 0 12px 8px;
  padding: 12px 14px;
  min-height: 48px;
  border-radius: 12px;
  text-align: left;
  color: var(--muted);
  border: 1px solid var(--line);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 10px;
  width: calc(100% - 24px);
  touch-action: manipulation;
}

.sidebar-search-wrap {
  padding: 0 12px 10px;
}

.sidebar-search {
  width: 100%;
  min-height: 42px;
  border-radius: 21px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--text) 5%, transparent);
  padding: 10px 14px;
  color: var(--text);
  outline: none;
}

.sidebar-search:focus {
  border-color: var(--line-strong);
}

.search-section-label {
  padding: 4px 16px;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.people-results {
  padding: 0 10px 16px;
  max-height: 40%;
  overflow: auto;
}

.call-hist-item {
  width: 100%;
  text-align: left;
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 12px;
  padding: 14px 12px;
  min-height: 64px;
  border-radius: 16px;
  touch-action: manipulation;
}

.settings-panel {
  padding: 8px 12px 20px;
  overflow: auto;
  flex: 1;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior: contain;
}

.settings-row {
  width: 100%;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px 12px;
  min-height: 64px;
  border-radius: 16px;
  text-align: left;
  margin-bottom: 6px;
  border: 1px solid transparent;
  touch-action: manipulation;
}

.settings-row.settings-row-solo {
  grid-template-columns: minmax(0, 1fr);
  display: flex;
  align-items: center;
  min-height: 52px;
  padding: 14px 16px;
}

.settings-row-label {
  display: block;
  width: 100%;
  font-weight: 600;
  font-size: 0.98rem;
  line-height: 1.35;
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  color: var(--text);
}

.settings-row-danger .settings-row-label {
  color: #ff6b6b;
}

.settings-row-solo .chat-item-main,
.settings-row-solo .chat-item-title,
.settings-row-solo .chat-item-title strong {
  overflow: visible;
  text-overflow: unset;
  white-space: normal;
}

.settings-ico {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  color: var(--text);
}

.pending-file-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.people-results .chat-item {
  pointer-events: auto;
  min-height: 56px;
  margin-bottom: 4px;
  cursor: pointer;
  touch-action: manipulation;
}

.settings-toggle input {
  width: 18px;
  height: 18px;
}

.settings-block {
  margin-top: 16px;
  padding: 8px 4px;
}

.settings-block-title {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 8px;
  padding-inline: 8px;
}

.blocked-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px;
  border-radius: 12px;
  border: 1px solid var(--line);
  margin-bottom: 6px;
  font-size: 0.9rem;
}

.settings-logout {
  width: 100%;
  margin-top: 18px;
}

.action-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 12px 0 18px;
}

.action-row {
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  color: var(--text);
  font-weight: 600;
}

.action-row.danger {
  color: #ff7b7b;
}

.blocked-banner {
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0px));
  text-align: center;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: 0.92rem;
}

html.standalone .tab-bar {
  padding-bottom: calc(8px + var(--sab-px, env(safe-area-inset-bottom, 0px)));
}

@media (max-width: 860px) {
  .app-shell:not(:has(.auth-card)) {
    min-height: 0;
  }

  .app-shell:not(:has(.auth-card)) > .app-frame {
    flex: 1 1 auto;
    min-height: 0;
  }

  .sidebar,
  .chat-panel {
    background: color-mix(in srgb, var(--bg) 88%, transparent);
  }
}

/* ---------- Offline / update banners ---------- */
.offline-banner,
.update-banner {
  flex-shrink: 0;
  text-align: center;
  padding: 8px 12px;
  font-size: 0.84rem;
  font-weight: 600;
  z-index: 30;
}

.offline-banner {
  padding-top: calc(6px + var(--sat, env(safe-area-inset-top, 0px)));
  background: #ff6b6b;
  color: #fff;
}

.update-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  background: color-mix(in srgb, var(--accent) 18%, var(--bg));
  color: var(--text);
  border-bottom: 1px solid var(--line);
}

.update-banner button {
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 6px 12px;
  background: var(--invert);
  color: var(--invert-text);
  font-weight: 600;
  touch-action: manipulation;
}

.offline-banner.hidden,
.update-banner.hidden,
.sync-banner.hidden {
  display: none;
}

.sync-banner {
  flex-shrink: 0;
  margin: 0 14px 2px;
  padding: 4px 2px 6px;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--muted);
  animation: sync-pulse 1.4s ease-in-out infinite;
}

@keyframes sync-pulse {
  0%,
  100% {
    opacity: 0.55;
  }
  50% {
    opacity: 1;
  }
}

/* ---------- Notify prompt "never ask" link ---------- */
.notify-prompt-never {
  display: block;
  width: 100%;
  text-align: center;
  margin-top: 10px;
  padding: 6px;
  font-size: 0.78rem;
  color: var(--muted);
  text-decoration: underline;
}

/* ---------- Message highlight (deep link jump) ---------- */
.msg-highlight .bubble {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Reply bar (composer) ---------- */
.reply-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--text) 4%, transparent);
}

.reply-bar-info {
  flex: 1;
  min-width: 0;
  border-left: 2px solid var(--accent);
  padding-left: 10px;
}

.reply-bar-info strong {
  display: block;
  font-size: 0.82rem;
}

.reply-bar-info p {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reply-bar button {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--muted);
  flex-shrink: 0;
}

/* ---------- Reply quote inside bubble ---------- */
.msg-quote {
  border-left: 2px solid currentColor;
  opacity: 0.85;
  padding: 4px 8px;
  margin-bottom: 6px;
  border-radius: 6px;
  background: color-mix(in srgb, currentColor 8%, transparent);
  cursor: pointer;
}

.msg-quote strong {
  display: block;
  font-size: 0.78rem;
}

.msg-quote p {
  margin: 1px 0 0;
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}

/* ---------- Reactions ---------- */
.msg-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
  padding: 0 4px;
}

.message-row.mine .msg-reactions {
  justify-content: flex-end;
}

.reaction-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--text) 6%, transparent);
  font-size: 0.82rem;
  line-height: 1.5;
}

.reaction-chip.mine {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}

.reaction-chip span {
  font-size: 0.75rem;
  color: var(--muted);
}

.msg-menu-reacts {
  display: flex;
  justify-content: space-between;
  gap: 2px;
  padding: 4px 6px 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}

.msg-menu-reacts button {
  font-size: 1.3rem;
  padding: 4px 6px;
  border-radius: 10px;
  line-height: 1;
}

@media (hover: hover) and (pointer: fine) {
  .msg-menu-reacts button:hover,
  .reaction-chip:hover {
    background: color-mix(in srgb, var(--text) 12%, transparent);
  }
}

/* ---------- Pending / failed messages ---------- */
.msg-pending {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1.6px solid currentColor;
  border-top-color: transparent;
  opacity: 0.6;
  animation: msg-pending-spin 0.8s linear infinite;
}

@keyframes msg-pending-spin {
  to { transform: rotate(360deg); }
}

.msg-failed {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.msg-retry,
.msg-discard {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  font-size: 0.85rem;
  line-height: 1;
  color: #ff8f8f;
  border: 1px solid color-mix(in srgb, #ff8f8f 40%, transparent);
}

.bubble-failed {
  border-color: #ff8f8f !important;
}

.bubble-pending {
  opacity: 0.72;
}

/* ---------- Older messages loader ---------- */
.older-loader {
  height: 0;
  overflow: hidden;
  text-align: center;
  transition: height 0.15s ease;
}

.older-loader.loading {
  height: 30px;
  overflow: visible;
  display: grid;
  place-items: center;
}

.older-loader.loading::before {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  border-top-color: var(--text);
  animation: msg-pending-spin 0.7s linear infinite;
}

/* ---------- Textarea composer ---------- */
.composer-field textarea {
  width: 100%;
  max-height: 120px;
  min-height: 44px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--text) 5%, transparent);
  border-radius: 22px;
  padding: 11px 16px;
  outline: none;
  resize: none;
  overflow-y: auto;
  font-family: var(--font-body);
  font-size: 0.98rem;
  line-height: 1.35;
}

.composer-field textarea:focus {
  border-color: var(--line-strong);
  background: color-mix(in srgb, var(--text) 8%, transparent);
}

/* ---------- Pin / mute icons in chat list ---------- */
.pin-ico,
.mute-ico {
  display: inline-flex;
  color: var(--muted);
  flex-shrink: 0;
}

/* ---------- Folder chips ---------- */
.folder-chips {
  display: flex;
  gap: 6px;
  padding: 4px 14px 10px;
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}

.folder-chips::-webkit-scrollbar {
  display: none;
}

.folder-chip {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
}

.folder-chip.active {
  background: var(--invert);
  color: var(--invert-text);
  border-color: var(--invert);
}

.folder-chip-add {
  display: grid;
  place-items: center;
  padding: 6px 10px;
}

/* ---------- Folders management modal ---------- */
.folders-list {
  display: grid;
  gap: 10px;
  margin: 10px 0;
  max-height: 45vh;
  overflow-y: auto;
}

.folder-row {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
}

.folder-row-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.folder-rename {
  flex: 1;
  border: 1px solid transparent;
  background: transparent;
  padding: 6px 8px;
  border-radius: 10px;
  font-weight: 600;
}

.folder-rename:focus {
  border-color: var(--line);
  background: color-mix(in srgb, var(--text) 5%, transparent);
}

.folder-chats-list {
  display: grid;
  gap: 4px;
  max-height: 160px;
  overflow-y: auto;
  padding: 4px 6px;
}

.folder-chat-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  padding: 4px 0;
}

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.88);
  display: grid;
  place-items: center;
  padding: 24px;
  animation: rise 0.15s ease;
}

.lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 10px;
  object-fit: contain;
}

.lightbox-close {
  position: fixed;
  top: calc(16px + var(--sat, env(safe-area-inset-top, 0px)));
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  display: grid;
  place-items: center;
}

/* ---------- Media gallery modal ---------- */
.media-gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  max-height: 60vh;
  overflow-y: auto;
  margin: 10px 0;
}

.gallery-thumb {
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
}

.gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gallery-file {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

/* ---------- Group info modal ---------- */
.group-info-avatar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin: 0 0 16px;
}

.group-avatar-btn {
  cursor: pointer;
}

.call-group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  gap: 14px;
  width: min(420px, 100%);
  justify-items: center;
}

.call-group-peer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  min-width: 0;
}

.call-group-peer .name {
  font-size: 0.78rem;
  color: var(--muted);
  max-width: 96px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.call-group-peer.joined .name {
  color: var(--text);
}

.call-group-peer .avatar {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent);
}

.group-members {
  display: grid;
  gap: 4px;
  max-height: 260px;
  overflow-y: auto;
  margin: 8px 0 12px;
}

.group-member-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  border-radius: 12px;
}

.group-member-row .btn-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--line);
  flex-shrink: 0;
}

.role-tag {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 500;
}

@media (hover: hover) and (pointer: fine) {
  .group-member-row:hover,
  .folder-row:hover {
    background: color-mix(in srgb, var(--text) 4%, transparent);
  }
}

/* ---------- Action rows as radio labels (privacy modal) ---------- */
.action-row {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.action-row input[type="radio"] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.draft-preview {
  color: var(--muted);
  font-style: italic;
}

.pinned-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--text) 4%, transparent);
}

.pinned-bar-main {
  flex: 1;
  min-width: 0;
  text-align: left;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  color: inherit;
}

.pinned-bar-main p {
  margin: 2px 0 0;
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pinned-ico {
  color: var(--muted);
  flex-shrink: 0;
}

.stories-strip {
  display: flex;
  gap: 10px;
  padding: 10px 14px 6px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
}

.story-avatar {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px solid var(--line);
  padding: 0;
  background: transparent;
  cursor: pointer;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.story-avatar.unseen {
  border-color: var(--accent, #7dd3fc);
}

.story-add {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--muted);
}

.story-viewer {
  width: min(420px, 92vw);
  max-height: 88vh;
  background: var(--panel, #111);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.story-viewer-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.story-viewer-head time {
  margin-left: auto;
  margin-right: 8px;
  font-size: 0.82rem;
  color: var(--muted);
}

.story-viewer-body {
  padding: 12px;
  overflow: auto;
}

.story-viewer-body img {
  width: 100%;
  border-radius: 12px;
  display: block;
  margin-bottom: 10px;
}

.story-viewer-nav {
  display: flex;
  justify-content: space-between;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
}

.mention-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 4px);
  z-index: 30;
  background: var(--panel, #111);
  border: 1px solid var(--line);
  border-radius: 12px;
  max-height: 180px;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.mention-dropdown button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: none;
  background: transparent;
  padding: 8px 10px;
  text-align: left;
  cursor: pointer;
  color: inherit;
}

.msg-mention {
  color: var(--accent, #7dd3fc);
  font-weight: 600;
}

.quote-float {
  position: fixed;
  z-index: 120;
  border: 1px solid var(--line);
  background: var(--panel, #111);
  color: inherit;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.82rem;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.message-row.swipe-reply {
  box-shadow: inset 4px 0 0 var(--accent, #7dd3fc);
}

.message-row.swipe-delete {
  box-shadow: inset -4px 0 0 #ff6b6b;
}

.message-row {
  transition: transform 0.08s linear;
}

.invite-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.invite-row input {
  flex: 1;
  min-width: 0;
}

.emoji-grid-pop {
  position: fixed;
  z-index: 130;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  padding: 8px;
  background: var(--panel, #111);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.emoji-grid-pop button {
  border: none;
  background: transparent;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px;
  border-radius: 8px;
}

.msg-menu-reacts .react-more {
  font-weight: 700;
}

.btn-mint-life {
  min-width: 40px;
  height: 40px;
  padding: 0 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, #5fd5de 16%, transparent);
  color: #5fd5de;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  touch-action: manipulation;
}

.btn-mint-life:active {
  transform: scale(0.97);
}

.mint-life-list {
  display: grid;
  gap: 8px;
  max-height: min(60vh, 520px);
  overflow: auto;
  margin: 8px 0 4px;
  padding-right: 2px;
}

.life-row {
  display: grid;
  grid-template-columns: 28px 40px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
}

.life-rank {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--muted);
  text-align: center;
}

.life-main {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.life-main strong {
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.life-main span {
  color: var(--muted);
  font-size: 0.8rem;
}

.life-row.mint {
  border-color: color-mix(in srgb, #5fd5de 55%, var(--line));
  background: color-mix(in srgb, #5fd5de 14%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, #5fd5de 20%, transparent);
}

.life-row.mint .life-rank,
.life-row.mint .life-main strong {
  color: #5fd5de;
}

.life-row.silver {
  border-color: color-mix(in srgb, #c0c0c0 50%, var(--line));
  background: color-mix(in srgb, #c0c0c0 12%, transparent);
}

.life-row.silver .life-rank,
.life-row.silver .life-main strong {
  color: #d7d7d7;
}

.life-row.bronze {
  border-color: color-mix(in srgb, #cd7f32 50%, var(--line));
  background: color-mix(in srgb, #cd7f32 14%, transparent);
}

.life-row.bronze .life-rank,
.life-row.bronze .life-main strong {
  color: #e0a15a;
}
