*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font-family);
  font-size: var(--font-size-md);
  color: var(--text-primary);
  background: var(--bg-app);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}

img { image-orientation: from-image; }

/* ═══════════════════════ AUTH SCREEN ═══════════════════════ */
/* Auth ALWAYS dark — hardcoded, no theme vars */
#auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background:
    radial-gradient(circle at 18% 12%, rgba(85,124,219,.18), transparent 22%),
    radial-gradient(circle at 84% 18%, rgba(118,133,224,.10), transparent 26%),
    radial-gradient(circle at 50% 100%, rgba(39,83,174,.12), transparent 28%),
    linear-gradient(180deg, #03060c, #07101d 48%, #07111e 100%);
  position: relative;
  overflow-x: hidden;
  overflow-y: auto;
  color: #f5f8ff;
}

.auth-bg { position: absolute; inset: 0; overflow: hidden; z-index: 0; pointer-events: none; }

.auth-blob {
  position: absolute; border-radius: 50%;
  filter: blur(120px); opacity: 0.15;
  animation: authFloat 14s ease-in-out infinite;
}
.auth-blob-1 {
  width: 550px; height: 550px;
  background: radial-gradient(circle, rgba(121,157,255,.25), transparent 70%);
  top: -20%; left: -15%; animation-duration: 16s;
}
.auth-blob-2 {
  width: 650px; height: 650px;
  background: radial-gradient(circle, rgba(141,150,255,.2), transparent 70%);
  bottom: -25%; right: -15%; animation-duration: 20s; animation-delay: -5s;
}
.auth-blob-3 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(132,154,255,.15), transparent 70%);
  top: 35%; left: 45%; animation-duration: 18s; animation-delay: -9s;
}

@keyframes authFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25%      { transform: translate(35px, -45px) scale(1.06); }
  50%      { transform: translate(-25px, 25px) scale(0.94); }
  75%      { transform: translate(20px, 35px) scale(1.04); }
}

/* ── Glass card ── */
.auth-card {
  background: linear-gradient(180deg, rgba(8,12,21,.96), rgba(5,9,16,.985));
  backdrop-filter: blur(18px) saturate(1.14);
  -webkit-backdrop-filter: blur(18px) saturate(1.14);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 24px;
  padding: 28px 26px;
  width: 380px;
  max-width: 92vw;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.06),
    inset 0 -1px 0 rgba(255,255,255,.015),
    0 28px 60px rgba(0,0,0,.46);
  position: relative;
  z-index: 1;
}

/* ── Logo with neon animated border ── */
.auth-logo {
  display: flex; flex-direction: column;
  align-items: center; margin-bottom: 8px;
}

.auth-logo-wrap {
  position: relative;
  width: 96px; height: 96px;
  margin-bottom: 14px;
}

/* Subtle glow behind logo */
.auth-logo-glow {
  position: absolute;
  inset: -20px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(132,154,255,.24) 0%, rgba(132,154,255,.14) 28%, rgba(105,130,255,.06) 48%, rgba(80,110,210,0) 72%);
  filter: blur(18px);
  opacity: 0.85;
  animation: neonRotate 4s linear infinite;
  z-index: 0;
}

/* Neon border ring (sharp) */
.auth-logo-icon {
  position: relative;
  width: 96px; height: 96px;
  border-radius: 24px;
  display: grid; place-items: center;
  z-index: 1;
  overflow: hidden;
  background: #070d1a;
  border: 1px solid rgba(255,255,255,.15);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), inset 0 -1px 0 rgba(255,255,255,.02), 0 16px 32px rgba(0,0,0,.26);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  animation: breatheLogo 4.4s ease-in-out infinite;
}

.auth-logo-icon::before { display: none; }
.auth-logo-icon::after { display: none; }

.auth-logo-icon svg {
  position: relative;
  z-index: 2;
  width: 52px; height: 52px;
}
.auth-logo-icon img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

@keyframes breatheLogo {
  0%, 100% { transform: translateY(0); box-shadow: inset 0 1px 0 rgba(255,255,255,.08), inset 0 -1px 0 rgba(255,255,255,.02), 0 16px 32px rgba(0,0,0,.26); }
  50% { transform: translateY(-2px); box-shadow: inset 0 1px 0 rgba(255,255,255,.10), inset 0 -1px 0 rgba(255,255,255,.025), 0 20px 36px rgba(0,0,0,.30); }
}

.auth-logo-wrap::after { display: none; }

/* Logo text — clean white */
.auth-logo-text {
  font-size: 32px; font-weight: 800;
  letter-spacing: 0;
  color: #f5f8ff;
  -webkit-text-fill-color: #f5f8ff;
  background: none;
  text-shadow: none;
}

.auth-card .subtitle {
  text-align: center;
  color: #98a3bb;
  margin-bottom: 18px;
  font-size: 14px;
  letter-spacing: 0;
}

/* ── Dark inputs (NEVER white) ── */
.auth-input-group {
  display: flex; align-items: center;
  background: linear-gradient(180deg, rgba(255,255,255,.07), rgba(255,255,255,.02));
  border: 1px solid rgba(255,255,255,.11);
  border-radius: 16px;
  padding: 0 16px;
  margin-bottom: 12px;
  transition: transform .22s ease, border-color .22s ease, box-shadow .22s ease;
  height: 56px;
  position: relative;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.07), inset 0 -1px 0 rgba(255,255,255,.015), 0 18px 34px rgba(0,0,0,.26);
  backdrop-filter: blur(18px) saturate(1.14);
  -webkit-backdrop-filter: blur(18px) saturate(1.14);
}

.auth-input-group:hover,
.auth-input-group:focus-within {
  transform: translateY(-1px);
  border-color: rgba(255,255,255,.18);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.085), 0 16px 26px rgba(0,0,0,.20);
}

.auth-input-group:focus-within::after { display: none; }

.auth-input-icon {
  color: #98a3bb;
  flex-shrink: 0; margin-right: 12px; display: flex;
  opacity: .7;
  transition: color 0.2s;
}
.auth-input-group:focus-within .auth-input-icon {
  color: #f5f8ff;
}

.auth-input-group input {
  min-width: 0;
  flex: 1; border: none;
  background: transparent !important;
  color: #f5f8ff !important;
  font-size: 15px;
  outline: none; padding: 0; height: 100%;
  caret-color: #8d96ff;
  -webkit-text-fill-color: #f5f8ff;
}

.auth-input-group input::placeholder {
  color: #6f7b93 !important;
  -webkit-text-fill-color: #6f7b93;
}

/* Override any browser autofill */
.auth-input-group input:-webkit-autofill,
.auth-input-group input:-webkit-autofill:hover,
.auth-input-group input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px #07101d inset !important;
  -webkit-text-fill-color: #f5f8ff !important;
  border: none !important;
  transition: background-color 5000s ease-in-out 0s;
}

.auth-eye-btn {
  background: none; border: none;
  color: rgba(255,255,255,0.25);
  cursor: pointer; padding: 8px; display: flex;
  transition: all 0.2s;
  border-radius: 8px;
  touch-action: manipulation;
}
.auth-eye-btn:hover {
  color: rgba(255,255,255,0.7);
  background: rgba(255,255,255,0.05);
}
.auth-eye-btn .eye-closed { display: none; }
.auth-eye-btn.is-visible {
  color: rgba(255,255,255,0.82);
  background: rgba(255,255,255,0.06);
}
.auth-eye-btn.is-visible .eye-open { display: none; }
.auth-eye-btn.is-visible .eye-closed { display: block; }

/* ── Remember + Forgot ── */
.auth-options {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 14px; font-size: 13px;
}
.auth-remember {
  display: flex; align-items: center; gap: 8px;
  color: rgba(255,255,255,0.45); cursor: pointer;
  transition: color 0.15s;
}
.auth-remember:hover { color: rgba(255,255,255,0.65); }
.auth-remember input { display: none; }

.auth-checkbox {
  width: 18px; height: 18px;
  border: 1.5px solid rgba(255,255,255,0.15);
  border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s; flex-shrink: 0;
}
.auth-remember input:checked ~ .auth-checkbox {
  background: linear-gradient(135deg, #8d96ff, #6f7cff);
  border-color: transparent;
  box-shadow: 0 0 8px rgba(141,150,255,0.3);
}
.auth-remember input:checked ~ .auth-checkbox::after {
  content: '\2713'; color: #fff; font-size: 11px; font-weight: 700;
}

.auth-forgot {
  color: #98a3bb; text-decoration: none;
  font-weight: 500; transition: all 0.2s;
}
.auth-forgot:hover {
  color: #f5f8ff;
}

/* ── Primary button — glass ── */
.auth-card button#auth-submit {
  width: 100%; padding: 0; height: 52px;
  background: linear-gradient(180deg, rgba(255,255,255,.07), rgba(255,255,255,.02));
  color: #f5f8ff; border: 1px solid rgba(255,255,255,.12);
  border-radius: 17px;
  font-size: 18px; font-weight: 700;
  cursor: pointer;
  transition: transform .22s ease, border-color .22s ease, box-shadow .22s ease;
  letter-spacing: 0.02em;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.07), inset 0 -1px 0 rgba(255,255,255,.015), 0 18px 34px rgba(0,0,0,.26);
  backdrop-filter: blur(18px) saturate(1.14);
  -webkit-backdrop-filter: blur(18px) saturate(1.14);
  position: relative;
  overflow: hidden;
}

.auth-card button#auth-submit::before { display: none; }

.auth-card button#auth-submit:hover {
  transform: translateY(-1px);
  border-color: rgba(255,255,255,.18);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.085), 0 16px 26px rgba(0,0,0,.20);
}

.auth-card button#auth-submit:active {
  transform: scale(0.98);
}

/* ── Divider ── */
.auth-divider { text-align: center; margin: 20px 0; position: relative; }
.auth-divider::before {
  content: ''; position: absolute; top: 50%; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08), transparent);
}
.auth-divider span {
  position: relative;
  background: rgba(5,9,16,0.95);
  padding: 0 16px;
  color: #6f7b93;
  font-size: 13px;
}

/* ── QR button ── */
.auth-qr-btn {
  width: 100%; padding: 0 12px; height: 48px;
  background: linear-gradient(180deg, rgba(255,255,255,.07), rgba(255,255,255,.02));
  color: #f5f8ff;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 15px;
  font-size: 14px; font-weight: 700;
  cursor: pointer;
  transition: transform .22s ease, border-color .22s ease, box-shadow .22s ease;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.07), inset 0 -1px 0 rgba(255,255,255,.015), 0 18px 34px rgba(0,0,0,.26);
  backdrop-filter: blur(18px) saturate(1.14);
  -webkit-backdrop-filter: blur(18px) saturate(1.14);
}
.auth-qr-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(255,255,255,.18);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.085), 0 16px 26px rgba(0,0,0,.20);
}
.auth-qr-btn:active { transform: scale(0.98); }

/* ── Toggle + footer ── */
.auth-toggle { text-align: center; margin-top: 20px; font-size: 13px; color: rgba(255,255,255,0.3); }
.auth-toggle a {
  color: #8d96ff; text-decoration: none; cursor: pointer;
  font-weight: 600; transition: all 0.2s;
}
.auth-toggle a:hover {
  color: #f5f8ff;
}
.auth-action-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}
.auth-alt-link {
  min-height: 44px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: #8d96ff;
  text-decoration: none;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
  white-space: nowrap;
  touch-action: manipulation;
}
.auth-alt-link:hover { color: #f5f8ff; }
.auth-code-pane[hidden] { display: none; }
.auth-code-pane { width: 100%; min-width: 0; overflow-x: hidden; }
.auth-code-label {
  display: block;
  margin: 8px 0 8px;
  color: #98a3bb;
  font-size: 13px;
  font-weight: 700;
}
.auth-code-input-group input {
  min-width: 0;
  text-align: center;
  font-size: clamp(18px, 5.2vw, 20px);
  font-weight: 800;
  letter-spacing: 0;
}
.auth-card button#auth-code-submit {
  width: 100%;
  padding: 0;
  height: 52px;
  background: linear-gradient(180deg, rgba(255,255,255,.07), rgba(255,255,255,.02));
  color: #f5f8ff;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 17px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .22s ease, border-color .22s ease, box-shadow .22s ease;
  letter-spacing: 0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.07), inset 0 -1px 0 rgba(255,255,255,.015), 0 18px 34px rgba(0,0,0,.26);
}
.auth-card button#auth-code-submit:hover {
  transform: translateY(-1px);
  border-color: rgba(255,255,255,.18);
}
.auth-code-back {
  display: block;
  width: 100%;
  margin-top: 10px;
}
.auth-tester-note {
  margin-top: 10px;
  color: rgba(152,163,187,0.72);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-align: center;
  text-transform: lowercase;
}
.auth-tester-note-code {
  margin-top: 4px;
}

.auth-legacy-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
  margin-top: 8px;
  text-align: center;
}

.auth-lite-link,
.auth-device-check-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 28px;
  color: rgba(152,163,187,0.72);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-align: center;
  text-decoration: none;
  text-transform: lowercase;
}

.auth-lite-link:hover,
.auth-device-check-link:hover {
  color: #8d96ff;
}

.auth-device-check-link {
  color: rgba(141,150,255,0.76);
}

.auth-noscript {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(250,204,21,.28);
  border-radius: 12px;
  color: #fde68a;
  background: rgba(113,63,18,.22);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
  text-align: center;
}

.auth-noscript a {
  color: #fff7cc;
}

.auth-error {
  color: #ff596a; font-size: 13px;
  text-align: center; min-height: 20px; margin-bottom: 8px;
}

.auth-terms {
  text-align: center; margin-top: 12px;
  font-size: 11px; color: rgba(255,255,255,0.2);
  line-height: 1.6;
}
.auth-terms a {
  color: rgba(255,255,255,0.35);
  text-decoration: underline;
  text-decoration-color: rgba(255,255,255,0.1);
  text-underline-offset: 3px;
  transition: all 0.15s;
}
.auth-terms a:hover {
  color: #8d96ff;
  text-decoration-color: rgba(141,150,255,0.4);
}

/* ═══════════════════════ APP LAYOUT ═══════════════════════ */
#app-screen { display: none; height: 100vh; height: 100dvh; overflow: hidden; }
#app-screen.active { display: flex; }

/* ─── Sidebar ─── */
.sidebar {
  width: var(--sidebar-width); min-width: 260px; max-width: 40vw;
  display: flex; flex-direction: column;
  border-right: 1px solid var(--sidebar-border);
  background: var(--sidebar-bg);
}

.sidebar-header {
  display: flex; align-items: center;
  padding: 0 12px; height: 56px;
  background: var(--bg-header);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0; gap: 8px;
}

.sidebar-brand {
  flex: 1; font-size: 18px; font-weight: 800;
  letter-spacing: 0.06em; white-space: nowrap;
  text-decoration: none; cursor: pointer; text-align: center;
}
.sidebar-brand span:first-child { color: var(--text-primary); }
.sidebar-brand span:last-child {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

[data-theme="light"] .sidebar-brand {
  padding: 6px 10px;
  border-radius: 12px;
  background: linear-gradient(135deg, #06090d 0%, #0d1512 58%, #19311f 100%);
  box-shadow: inset 0 0 0 1px rgba(182,255,118,0.22), 0 8px 20px rgba(0,0,0,0.12);
}
[data-theme="light"] .sidebar-brand span:first-child {
  color: #ffffff;
  -webkit-text-fill-color: #ffffff;
}
[data-theme="light"] .sidebar-brand span:last-child {
  background: none;
  color: #b8ff73;
  -webkit-text-fill-color: #b8ff73;
}

/* Search row */
.sidebar-search-row {
  display: flex; align-items: center;
  background: var(--search-bg);
  border: 1px solid var(--search-border);
  border-radius: var(--radius-xxl);
  padding: 0 14px; height: 44px;
  margin: 10px 12px; flex-shrink: 0;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.sidebar-search-row:focus-within {
  border-color: var(--search-focus-border);
  box-shadow: 0 0 0 3px rgba(168,85,247,0.08);
}
.sidebar-search-row .sidebar-search-icon { flex-shrink: 0; color: var(--icon-color); margin-right: 10px; }
.sidebar-search-row input {
  flex: 1; border: none; background: transparent;
  color: var(--text-primary); font-size: var(--font-size-md);
  outline: none; min-width: 0; padding: 0;
}
.sidebar-search-row input::placeholder { color: var(--search-placeholder); }
.sidebar-search-inline { display: none; }
.sidebar-burger { flex-shrink: 0; }

.sidebar-footer {
  padding: 6px 16px; border-top: 1px solid var(--sidebar-border);
  font-size: 9px; color: var(--text-secondary); text-align: center;
  flex-shrink: 0; opacity: 0.3;
}

/* APP switch drawer */
.app-switch-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.42);
  z-index: 179;
}
.app-switch-backdrop.show { display: block; }
.app-switch-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(392px, calc(100vw - 20px));
  background: linear-gradient(180deg, rgba(8,13,24,.98), rgba(5,9,16,.99));
  border-right: 1px solid var(--sidebar-border);
  box-shadow: 24px 0 48px rgba(0,0,0,.34);
  transform: translateX(-104%);
  transition: transform 220ms cubic-bezier(.22, 1, .36, 1);
  z-index: 180;
  display: flex;
  flex-direction: column;
  color: var(--text-primary);
}
.app-switch-drawer.show { transform: translateX(0); }
.app-switch-header {
  height: 56px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-bottom: 1px solid var(--sidebar-border);
  background: var(--bg-header);
}
.app-switch-title {
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0;
}
.app-switch-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 22px;
}
.app-switch-primary,
.app-launch-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 72px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-primary);
  text-align: left;
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.app-switch-primary:hover,
.app-launch-item:hover {
  background: var(--bg-hover);
  border-color: var(--sidebar-border);
}
.app-launch-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}
.app-launch-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  overflow: hidden;
  flex: 0 0 72px;
  color: #fff;
  font-size: 22px;
  font-weight: 800;
  background: linear-gradient(135deg, #22c8d8, #7668ff 62%, #3fbf7f);
  box-shadow: 0 14px 28px rgba(0,0,0,.25);
}
.app-launch-icon.is-maglink {
  background: linear-gradient(135deg, #111827, #4769ff 58%, #1fd19a);
  font-size: 19px;
}
.app-launch-icon.is-back {
  background: rgba(255,255,255,.06);
  border: 1px solid var(--sidebar-border);
  color: var(--text-primary);
  box-shadow: none;
}
.app-launch-icon.is-small {
  width: 58px;
  height: 58px;
  flex-basis: 58px;
  font-size: 18px;
}
.app-launch-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.app-launch-name {
  font-size: 17px;
  font-weight: 750;
  letter-spacing: 0;
  color: var(--text-primary);
}
.app-launch-desc {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.35;
}
.app-launch-empty {
  padding: 14px 10px;
  color: var(--text-secondary);
  font-size: 13px;
}

/* Icon buttons */
.icon-btn {
  width: 40px; height: 40px;
  border: none; background: transparent;
  border-radius: var(--radius-lg); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--icon-color); font-size: 18px;
  transition: all 0.15s; flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--icon-hover); }
.icon-btn:active { background: var(--accent-light); color: var(--accent); }

/* ═══ Global Creation Menu (centered modal) ═══ */
.create-menu-modal {
  width: 380px;
  max-width: 92vw;
}

.create-menu-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 12px 16px;
}

.create-option {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 16px;
  border: none;
  background: transparent;
  border-radius: var(--radius-xl);
  cursor: pointer;
  color: var(--text-primary);
  font-size: var(--font-size-md);
  font-weight: 500;
  transition: background 0.15s;
  text-align: left;
}
.create-option:hover:not(.disabled) {
  background: var(--bg-hover);
}
.create-option:active:not(.disabled) {
  background: var(--accent-light);
}
.create-option.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}
.create-option-icon {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
  background: var(--bg-secondary);
  color: var(--accent);
  flex-shrink: 0;
}
.create-option-label {
  flex: 1;
}
.create-option-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  padding: 3px 10px;
  border-radius: 10px;
  white-space: nowrap;
}

/* Mobile: creation menu as bottom sheet */
@media (max-width: 480px) {
  .create-menu-modal {
    width: 100%;
    max-width: 100%;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    max-height: 85dvh;
    animation: creationMenuSheet 250ms ease;
  }
  @keyframes creationMenuSheet {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }
  .create-option {
    padding: 16px;
    font-size: 16px;
  }
  .create-option-icon {
    width: 48px;
    height: 48px;
  }
}

.search-bar { display: none; }

/* ═══ Voice Player Bar ═══ */
.voice-player-bar {
  position: absolute; top: var(--header-height); left: 12px; right: 12px;
  display: flex; align-items: center;
  padding: 8px 12px 14px; background: color-mix(in srgb, var(--bg-secondary) 90%, white 10%);
  border: 1px solid var(--border); border-radius: 18px; gap: 10px;
  box-shadow: 0 16px 36px rgba(0,0,0,0.18);
  z-index: 15; opacity: 0; visibility: hidden; pointer-events: none;
  transform: translateY(-8px) scale(0.98);
  transition: opacity 180ms ease, transform 180ms ease, visibility 180ms ease;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.voice-player-bar.active { opacity: 1; visibility: visible; pointer-events: auto; transform: translateY(0) scale(1); }

.vpb-play { width: 32px; height: 32px; border: none; border-radius: 50%; background: var(--accent); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: transform 0.15s; }
.vpb-play:hover { transform: scale(1.08); }
.vpb-info { flex: 1; min-width: 0; }
.vpb-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vpb-label { font-size: 11px; color: var(--accent); }
.vpb-time { font-size: 12px; color: var(--text-secondary); font-family: monospace; white-space: nowrap; }
.vpb-speed { padding: 2px 8px; border: 1px solid var(--border); border-radius: 6px; background: transparent; color: var(--text-primary); font-size: 12px; font-weight: 600; cursor: pointer; }
.vpb-speed:hover { border-color: var(--accent); color: var(--accent); }
.vpb-close { width: 28px; height: 28px; border: none; background: transparent; color: var(--text-secondary); font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; border-radius: 50%; }
.vpb-close:hover { background: var(--bg-hover); color: var(--text-primary); }
.vpb-seek {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 5px;
  height: 4px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--border) 70%, transparent);
  cursor: pointer;
  overflow: hidden;
  touch-action: none;
}
.vpb-seek-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 72%, white 28%));
  box-shadow: 0 0 10px var(--accent-glow);
  transition: width 80ms linear;
}
.vpb-seek:active .vpb-seek-fill { transition: none; }

/* ═══ Chat List ═══ */
.chat-list { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; }

.chat-item {
  display: flex; align-items: center;
  padding: 12px 16px; gap: 12px;
  cursor: pointer; transition: all 0.15s;
  position: relative;
  border-left: 3px solid transparent;
}
.chat-item:hover { background: var(--sidebar-item-hover); }
.chat-item.active { background: var(--sidebar-item-active-bg); border-left-color: var(--sidebar-item-active-border); }
.chat-item.previewing { background: color-mix(in srgb, var(--sidebar-item-active-bg) 72%, transparent); }
.chat-item.pinned-chat { border-left-color: color-mix(in srgb, var(--accent-dark, #5c3a99) 58%, transparent); }

.chat-item .avatar {
  width: 54px; height: 54px;
  border-radius: var(--radius-full);
  background: var(--accent-gradient);
  color: var(--text-white);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: var(--font-size-xl);
  flex-shrink: 0; position: relative;
  box-shadow: 0 2px 8px var(--shadow);
}
.chat-item .avatar img { width: 100%; height: 100%; border-radius: var(--radius-full); object-fit: cover; }

.online-dot {
  position: absolute; bottom: 1px; right: 1px;
  width: 14px; height: 14px;
  background: var(--online-dot);
  border: 2.5px solid var(--online-dot-border);
  border-radius: var(--radius-full);
  box-shadow: 0 0 6px var(--online-dot-glow);
}

.chat-info { flex: 1; min-width: 0; }
.chat-info-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.chat-name { font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -0.02em; display: flex; align-items: center; gap: 5px; }
.chat-pin-icon { width: 14px; height: 14px; display: inline-flex; align-items: center; justify-content: center; color: var(--accent-dark, #5c3a99); flex: 0 0 auto; }
.chat-pin-icon svg { width: 14px; height: 14px; }
.chat-time { font-size: 13px; color: var(--text-time); white-space: nowrap; margin-left: 8px; }
.chat-preview { font-size: var(--font-size-md); color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Unread badge with pulse */
.unread-badge {
  background: var(--unread-gradient);
  color: var(--text-white);
  font-size: 11px; font-weight: 700;
  min-width: 22px; height: 22px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 7px;
  position: absolute; right: 16px; bottom: 14px;
  box-shadow: 0 2px 8px var(--unread-glow);
  animation: badgePulse 2s ease-in-out infinite;
}

@keyframes badgePulse {
  0%, 100% { box-shadow: 0 2px 8px var(--unread-glow); }
  50% { box-shadow: 0 2px 16px var(--unread-glow), 0 0 24px var(--accent-glow); }
}

/* ═══ Chat Area ═══ */
.chat-area {
  flex: 1; display: flex; flex-direction: column;
  background: var(--chat-bg, var(--chat-area-bg));
  min-width: 0; position: relative; overflow: hidden;
}
.chat-area::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: var(--chat-bg-image, none);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 1;
}
.chat-header,
.messages-container,
.composer-reply,
.typing-indicator,
.composer,
.rec-strip,
.empty-state {
  position: relative;
  z-index: 1;
}
.chat-area.empty { align-items: center; justify-content: center; }
.chat-area.chat-opening .composer-reply,
.chat-area.chat-opening .composer,
.chat-area.chat-opening .typing-indicator {
  opacity: 0;
}
.chat-area .messages-container,
.chat-area .composer-reply,
.chat-area .composer,
.chat-area .typing-indicator {
  transition: opacity 120ms ease;
}
.chat-area.drag-over::after {
  content: '\041E\0442\043F\0443\0441\0442\0438\0442\0435 \0444\0430\0439\043B \0434\043B\044F \043E\0442\043F\0440\0430\0432\043A\0438';
  position: absolute;
  inset: calc(var(--header-height) + 22px) 24px calc(var(--composer-height) + 24px) 24px;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed color-mix(in srgb, var(--accent) 78%, white 22%);
  border-radius: 24px;
  background: color-mix(in srgb, var(--bg-primary) 70%, transparent);
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  pointer-events: none;
  box-shadow: 0 18px 44px rgba(0,0,0,0.24), inset 0 0 0 1px rgba(255,255,255,0.06);
  backdrop-filter: blur(14px) saturate(150%);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
}
.chat-area.drag-over .messages-container {
  filter: brightness(0.9);
}

.empty-state { text-align: center; color: var(--text-secondary); }
.empty-logo {
  width: 72px; height: 72px; border-radius: 20px;
  background: var(--empty-icon-gradient);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
  box-shadow: 0 8px 32px var(--shadow-lg), var(--neon-glow);
  color: #fff;
}
.empty-state h2 { font-size: 20px; font-weight: 700; margin-bottom: 6px; color: var(--text-primary); letter-spacing: -0.02em; }
.empty-state p { font-size: var(--font-size-md); color: var(--empty-text); }

.app-mode-panel {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  background: var(--chat-bg, var(--chat-area-bg));
  color: var(--text-primary);
}
.app-mode-panel[hidden] { display: none; }
.app-mode-head {
  height: 64px;
  flex: 0 0 64px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 18px;
  border-bottom: 1px solid var(--sidebar-border);
  background: var(--bg-header);
}
.app-mode-icon {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  overflow: hidden;
  flex: 0 0 46px;
  color: #fff;
  font-weight: 800;
  font-size: 16px;
  background: linear-gradient(135deg, #22c8d8, #7668ff 62%, #3fbf7f);
}
.app-mode-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.app-mode-icon-app {
  background: linear-gradient(135deg, #4769ff, #1fd19a);
  font-size: 13px;
  letter-spacing: 0;
}
.app-mode-title {
  min-width: 0;
  flex: 1;
  font-size: 18px;
  font-weight: 800;
}
.app-mode-status {
  margin-top: 2px;
  color: var(--text-secondary);
  font-size: 13px;
}
.app-mode-body {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
}
.app-home-body {
  display: block;
  overflow-y: auto;
  text-align: left;
  padding: 22px;
}
.app-hub-tools {
  width: min(920px, 100%);
  margin: 0 auto 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.app-hub-search {
  height: 46px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border: 1px solid var(--sidebar-border);
  border-radius: 8px;
  background: var(--search-bg);
  color: var(--text-secondary);
}
.app-hub-search input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 15px;
}
.app-hub-search input::placeholder { color: var(--search-placeholder); }
.app-hub-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  overflow: visible;
  padding-bottom: 0;
}
.app-hub-tab {
  height: 34px;
  flex: 0 1 auto;
  border: 1px solid var(--sidebar-border);
  border-radius: 8px;
  padding: 0 13px;
  background: transparent;
  color: var(--text-secondary);
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  white-space: nowrap;
}
.app-hub-tab em {
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: inline-grid;
  place-items: center;
  padding: 0 5px;
  background: rgba(255,255,255,.07);
  color: currentColor;
  font-style: normal;
  font-size: 11px;
  line-height: 1;
}
.app-hub-tab.active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, #4769ff, #1fd19a);
}
.app-hub-section {
  width: min(920px, 100%);
  margin: 0 auto 24px;
}
.app-hub-section-muted { opacity: .9; }
.app-hub-section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 14px;
  margin-bottom: 12px;
}
.app-hub-section-head h3 {
  font-size: 18px;
  margin: 0 0 3px;
  letter-spacing: 0;
}
.app-hub-section-head p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 13px;
}
.app-hub-section-head > span {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 800;
}
.app-hub-empty {
  width: min(920px, 100%);
  margin: 22px auto;
  color: var(--text-secondary);
  text-align: center;
  border: 1px dashed var(--sidebar-border);
  border-radius: 8px;
  padding: 24px;
}
.app-home-grid {
  width: 100%;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 22px 18px;
  align-content: start;
}
.app-home-strip {
  width: 100%;
  display: flex;
  justify-content: flex-start;
  align-items: stretch;
  gap: 14px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  padding: 2px 2px 10px;
}
.app-home-strip .app-home-card {
  flex: 0 0 168px;
  scroll-snap-align: start;
}
.app-home-item {
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  padding: 8px 4px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s, transform .15s;
}
.app-home-item:not(:disabled):hover {
  background: var(--bg-hover);
  transform: translateY(-1px);
}
.app-home-card {
  min-height: 224px;
  border: 1px solid var(--sidebar-border);
  background: rgba(255,255,255,.025);
  justify-content: flex-start;
  padding: 12px 10px;
}
.app-home-card.is-demo {
  border-style: dashed;
}
.app-home-icon {
  width: min(128px, 92%);
  aspect-ratio: 1;
  height: auto;
  border-radius: 24px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: linear-gradient(135deg, #22c8d8, #7668ff 62%, #3fbf7f);
  color: #fff;
  font-size: 22px;
  font-weight: 800;
  box-shadow: 0 14px 28px rgba(0,0,0,.22);
}
.app-home-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.app-home-name {
  width: 100%;
  max-width: 100%;
  min-height: 34px;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 750;
  line-height: 1.25;
  text-align: center;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.app-home-meta {
  max-width: 100%;
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.25;
  text-align: center;
}
.app-home-desc {
  width: 100%;
  max-width: 100%;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.28;
  text-align: center;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.app-home-item.is-placeholder {
  cursor: default;
  opacity: .78;
}
.app-home-icon.is-placeholder {
  background: rgba(255,255,255,.035);
  border: 1.5px dashed rgba(168,178,200,.42);
  color: rgba(168,178,200,.62);
  box-shadow: none;
  font-size: 15px;
  letter-spacing: 0;
}
.app-home-item.is-placeholder .app-home-name {
  color: rgba(168,178,200,.52);
}
.app-mode-card {
  width: min(520px, 100%);
}
.app-mode-card .app-mode-icon {
  width: 84px;
  height: 84px;
  margin: 0 auto 16px;
  font-size: 26px;
}
.app-mode-card h2 {
  font-size: 24px;
  margin-bottom: 8px;
  letter-spacing: 0;
}
.app-mode-card p {
  color: var(--text-secondary);
  line-height: 1.45;
  margin-bottom: 18px;
}
.app-mode-flow {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 18px;
}
.app-mode-flow-step {
  border: 1px solid var(--sidebar-border);
  border-radius: 8px;
  padding: 7px 10px;
  color: var(--text-secondary);
  background: rgba(255,255,255,.03);
  font-size: 12px;
  font-weight: 700;
}
.app-mode-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}
.app-mode-action {
  height: 42px;
  border: 1px solid var(--sidebar-border);
  border-radius: 8px;
  padding: 0 16px;
  background: var(--bg-hover);
  color: var(--text-primary);
  cursor: pointer;
  font-weight: 650;
}
.app-mode-action.primary {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, #4769ff, #1fd19a);
}

/* Chat header — glass */
.chat-header {
  display: flex; align-items: center;
  flex: 0 0 auto;
  padding: 8px 12px; min-height: var(--header-height);
  background: var(--bg-header);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border);
  gap: 10px; z-index: 10; flex-shrink: 0;
}

.chat-header .avatar {
  width: 42px; height: 42px;
  border-radius: var(--radius-full);
  background: var(--accent-gradient);
  color: var(--text-white);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; cursor: pointer; flex-shrink: 0;
  position: relative; transition: transform 0.15s;
}
.chat-header .avatar:hover { transform: scale(1.06); }
.chat-header .avatar img { width: 100%; height: 100%; border-radius: var(--radius-full); object-fit: cover; }

.chat-header .avatar .header-online-dot {
  position: absolute; bottom: 0; right: 0;
  width: 12px; height: 12px;
  background: var(--online-dot);
  border: 2px solid var(--bg-header);
  border-radius: 50%;
  box-shadow: 0 0 5px var(--online-dot-glow);
}

.chat-header-info {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 42px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
}
.chat-header-name { font-weight: 600; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -0.02em; }
.chat-header-status {
  font-size: var(--font-size-sm);
  line-height: 1.25;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.15s;
}
.chat-header-status.online { color: var(--online); }

.header-action-btn { width: 38px; height: 38px; border: none; background: transparent; border-radius: var(--radius-full); }

.pinned-message-bar {
  position: absolute;
  top: calc(var(--header-height) + 4px);
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 18px;
  background: color-mix(in srgb, var(--bg-elevated) 88%, rgba(15,17,28,0.22) 12%);
  border: 1px solid color-mix(in srgb, var(--accent-dark, #5c3a99) 18%, var(--border) 82%);
  box-shadow: 0 16px 40px rgba(15, 15, 24, 0.18);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-10px);
  transition: opacity 180ms ease, transform 180ms ease, visibility 180ms ease;
  z-index: 12;
}
.pinned-message-bar.show { opacity: 1; visibility: visible; pointer-events: auto; transform: translateY(0); }
.pinned-message-main { flex: 1; min-width: 0; cursor: pointer; }
.pinned-message-label { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent-dark, #5c3a99); margin-bottom: 2px; }
.pinned-message-text { font-size: 13px; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pinned-message-action {
  flex-shrink: 0;
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  background: color-mix(in srgb, var(--accent-dark, #5c3a99) 86%, white 14%);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

/* ═══ Messages ═══ */
.messages-container {
  display: block;
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 0;
  background: transparent;
}
.messages-container.has-pinned { padding-top: 70px; }
.messages-inner { max-width: var(--messages-max-width); margin: 0 auto; padding: 0 12px; width: 100%; }
.selection-toolbar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  margin: 8px 12px 0;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: color-mix(in srgb, var(--bg-primary) 88%, white 12%);
  box-shadow: 0 16px 36px var(--shadow-lg);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
}
.selection-toolbar.show { display: flex; animation: slideUp 180ms ease; }
.selection-toolbar-main { flex: 1; min-width: 0; }
.selection-toolbar-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.selection-toolbar-count { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.selection-toolbar-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.selection-toolbar-btn {
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transition-fast), opacity var(--transition-fast), transform var(--transition-fast);
}
.selection-toolbar-btn:hover { background: var(--bg-hover); transform: translateY(-1px); }
.selection-toolbar-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.selection-toolbar-btn.is-danger { color: var(--danger); }
.selection-toolbar-btn.is-close {
  width: 38px;
  height: 38px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  line-height: 1;
}
@media (max-width: 768px) {
  .selection-toolbar {
    flex-wrap: wrap;
    align-items: stretch;
    margin: 8px 10px 0;
    padding: 10px 12px;
    border-radius: 18px;
  }
  .selection-toolbar-main {
    width: 100%;
    order: 1;
  }
  .selection-toolbar-actions {
    width: 100%;
    order: 2;
    justify-content: stretch;
  }
  .selection-toolbar-btn {
    flex: 1 1 calc(50% - 6px);
    justify-content: center;
  }
  .selection-toolbar-btn.is-close {
    flex: 0 0 38px;
    order: 0;
    margin-left: auto;
  }
}

.date-separator { text-align: center; padding: 12px 0; }
.date-separator span {
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  color: var(--text-secondary);
  font-size: 13px; font-weight: 500;
  padding: 6px 16px; border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

.message {
  display: flex; margin: 3px 0; padding: 0 12px;
  max-width: 100%; align-items: flex-end;
  animation: msgSlideIn 190ms cubic-bezier(0.22, 1, 0.36, 1);
}
.message.selection-active { gap: 10px; cursor: pointer; }
.message.selected .bubble {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 70%, white 30%), 0 18px 38px rgba(168, 85, 247, 0.18);
}
.message.selected .bubble-circle-frame .bubble-video-circle {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 72%, white 28%), 0 18px 38px rgba(168, 85, 247, 0.2);
}
.message-select-toggle {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent) 55%, var(--border) 45%);
  background: color-mix(in srgb, var(--bg-secondary) 88%, white 12%);
  color: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  transition: transform var(--transition-fast), background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}
.message-select-toggle:hover { transform: scale(1.05); }
.message-select-toggle.selected {
  background: var(--accent-gradient);
  border-color: transparent;
  color: var(--text-white);
}
.message-select-check {
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
}

@keyframes msgSlideIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.message.incoming { justify-content: flex-start; }
.message.outgoing { justify-content: flex-end; }
.message.call-log-message {
  justify-content: center;
  padding: 6px 12px;
}
.call-log-card {
  width: min(360px, calc(100vw - 48px));
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 18px;
  background: color-mix(in srgb, var(--bg-glass) 82%, var(--bg-secondary) 18%);
  border: 1px solid var(--border);
  color: var(--text-primary);
  box-shadow: 0 12px 28px rgba(0,0,0,0.12);
}
.call-log-icon {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: linear-gradient(135deg, #3b82f6, #14b8a6);
}
.call-log-icon.is-missed,
.call-log-icon.is-failed {
  background: linear-gradient(135deg, #ef4444, #f59e0b);
}
.call-log-icon svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
}
.call-log-main {
  min-width: 0;
}
.call-log-title {
  font-size: 14px;
  font-weight: 750;
  line-height: 1.25;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.call-log-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  margin-top: 3px;
  font-size: 12px;
  line-height: 1.3;
  color: var(--text-secondary);
}
.call-log-meta span {
  min-width: 0;
  white-space: nowrap;
}

.message.incoming .msg-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  margin-right: 6px; flex-shrink: 0; font-size: 11px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; margin-bottom: 1px;
}
.message.incoming .msg-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.message-sender-link { cursor: pointer; }
.message-sender-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.bubble {
  max-width: var(--max-bubble-width);
  min-width: 80px;
  padding: 10px 14px 8px;
  border-radius: var(--radius-bubble);
  position: relative;
  word-wrap: break-word; overflow-wrap: anywhere; word-break: break-word;
  line-height: 1.45;
  will-change: transform;
  touch-action: pan-y;
}

/* Incoming bubble — dark glass */
.message.incoming .bubble {
  background: var(--bg-bubble-in);
  border: 1px solid var(--bubble-in-border);
  border-radius: var(--radius-bubble) var(--radius-bubble) var(--radius-bubble) 4px;
}
.message.incoming .bubble::before {
  content: ''; position: absolute;
  left: -8px; bottom: 0; width: 10px; height: 16px;
  background: var(--bg-bubble-in);
  clip-path: polygon(100% 0, 100% 100%, 0 100%, 62% 54%);
  clip-path: path('M10 16 C10 16 0 16 0 16 C3 16 6 12 8 8 C8.5 7 9 6 10 0 L10 16 Z');
}

/* Outgoing bubble — gradient + glow */
.message.outgoing .bubble {
  background: var(--bg-bubble-out);
  border-radius: var(--radius-bubble) var(--radius-bubble) 4px var(--radius-bubble);
  box-shadow: 0 2px 12px rgba(124,58,237,0.25);
}
.message.outgoing .bubble::after {
  content: ''; position: absolute;
  right: -8px; bottom: 0; width: 10px; height: 16px;
  background: var(--bg-bubble-out);
  clip-path: polygon(0 0, 38% 54%, 100% 100%, 0 100%);
  clip-path: path('M0 16 C0 16 10 16 10 16 C7 16 4 12 2 8 C1.5 7 1 6 0 0 L0 16 Z');
}

.message-author-name {
  display: block;
  margin: -1px 0 4px;
  font-size: 12px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.message-author-name.message-sender-link:hover { text-decoration: underline; }

.bubble.bubble-circle-frame {
  background: transparent !important;
  box-shadow: none !important;
  border: none !important;
  padding: 0;
  min-width: 0;
  overflow: visible;
}
.bubble.bubble-circle-frame::before,
.bubble.bubble-circle-frame::after { display: none !important; }
.bubble-circle-frame .bubble-meta {
  float: none;
  display: flex;
  justify-content: center;
  margin: 10px 0 0;
  width: 100%;
}

.bubble-text { font-size: var(--font-size-md); overflow-wrap: anywhere; word-break: break-word; line-height: 1.4; }
.bubble-text a { color: var(--text-link); }
.message.outgoing .bubble-text { color: var(--bubble-out-text); }
.message.incoming .bubble-text { color: var(--bubble-in-text); }
.message.outgoing .bubble-text a { color: rgba(255,255,255,0.85); text-decoration: underline; }

.bubble-meta { display: inline-flex; align-items: center; justify-content: flex-end; gap: 3px; margin-top: 3px; float: right; margin-left: 12px; min-height: 16px; }
.bubble-time { font-size: 12px; color: var(--text-time); }
.message.outgoing .bubble-time { color: var(--bubble-out-time); }
.bubble-pending { font-size: 11px; color: var(--text-secondary); letter-spacing: 0.02em; text-transform: lowercase; }
.bubble-pending.failed { color: #ff7b7b; }
.bubble-pending.progress { color: color-mix(in srgb, var(--accent) 72%, #fff 28%); font-weight: 600; }
.message.pending .bubble { opacity: 0.86; }
.message.pending.silent-pending .bubble { opacity: 1; }
.message.failed .bubble { opacity: 0.72; }

.bubble-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 19px;
  height: 12px;
  margin-left: 1px;
  color: rgba(205, 221, 255, 0.56);
  flex-shrink: 0;
}
.read-check-icon {
  width: 19px;
  height: 12px;
  display: block;
  overflow: visible;
}
.read-check-icon path {
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  vector-effect: non-scaling-stroke;
}
.read-check-icon .check-single { stroke-width: 1.72; }
.read-check-icon .check-back { opacity: 0.88; }
.read-check-icon .check-front { opacity: 1; }
.message.outgoing .bubble-status { color: rgba(214, 228, 255, 0.54); }
.bubble-status.read,
.message.outgoing .bubble-status.read { color: #8ed6ff; filter: drop-shadow(0 0 4px rgba(142, 214, 255, 0.15)); }

/* Reply */
.reply-preview {
  border-left: 3px solid var(--reply-border);
  padding: 4px 8px; margin-bottom: 6px;
  font-size: var(--font-size-sm);
  background: var(--reply-bg);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  cursor: pointer; max-width: 100%; overflow: hidden;
}
.message.outgoing .reply-preview { background: var(--reply-out-bg); border-left-color: var(--reply-out-border); }
.reply-preview .reply-name { color: var(--reply-name); font-weight: 600; font-size: var(--font-size-xs); }
.message.outgoing .reply-preview .reply-name { color: var(--reply-out-name); }
.reply-preview .reply-text { color: var(--reply-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.message.outgoing .reply-preview .reply-text { color: var(--reply-out-text); }

/* Reactions */
.reactions-bar { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.reaction {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 9px 4px 7px; border-radius: 999px;
  background: color-mix(in srgb, var(--reaction-bg) 88%, white 12%); font-size: 16px;
  cursor: pointer; transition: all var(--transition-fast);
  border: 1px solid rgba(255,255,255,0.08); line-height: 1;
  box-shadow: 0 6px 18px rgba(0,0,0,0.14);
}
.message.outgoing .reaction { background: var(--reaction-out-bg); }
.reaction:hover { background: var(--bg-active); transform: translateY(-1px) scale(1.02); }
.reaction.mine { background: color-mix(in srgb, var(--accent-light) 78%, white 22%); border-color: var(--accent-dim); }
.reaction-emoji { font-size: 18px; transform: translateY(-0.5px); }
.reaction-count { font-size: var(--font-size-xs); color: var(--reaction-count); font-weight: 500; }
.message.outgoing .reaction-count { color: var(--reaction-count-out); }

/* Media */
.bubble-media { margin: -10px -14px 4px; overflow: hidden; border-radius: inherit; position: relative; }
.bubble-media:first-child { border-radius: inherit; }
.bubble-media img, .bubble-media video { max-width: 100%; max-height: 360px; display: block; object-fit: cover; width: 100%; }
.bubble-media img { cursor: pointer; transition: filter 0.15s; }
.bubble-media img:hover { filter: brightness(0.92); }
.bubble-media video { object-fit: contain; background: #000; }
.bubble-media.video-media {
  width: min(320px, 72vw);
  max-width: 100%;
  aspect-ratio: var(--video-aspect-ratio, 16 / 9);
  background: #000;
}
.bubble-media.video-media.is-portrait {
  width: min(236px, 58vw);
}
.bubble-media.video-media.is-square {
  width: min(286px, 66vw);
}
.bubble-media.video-media video {
  width: 100%;
  height: 100%;
  max-height: none !important;
  object-fit: contain;
}
.bubble-media.video-media .video-poster-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-height: none !important;
  object-fit: cover;
  background: #000;
  z-index: 1;
  pointer-events: none;
}
.bubble-media.video-media .video-poster-img.is-unavailable {
  display: none;
}
.video-open-tap-layer {
  -webkit-appearance: none;
  appearance: none;
  position: absolute;
  inset: 0;
  z-index: 2;
  border: 0;
  padding: 10px;
  font: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(180deg, rgba(0,0,0,0.02) 0%, rgba(0,0,0,0.42) 100%);
}
.video-open-play {
  width: 66px;
  height: 66px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding-left: 3px;
  background: rgba(22,22,34,0.58);
  border: 1px solid rgba(255,255,255,0.18);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 26px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.32);
}
.video-open-duration {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(0,0,0,0.48);
  font-size: 12px;
  font-weight: 700;
}
.bubble-media.photo-media {
  width: min(320px, 72vw);
  max-width: 100%;
  aspect-ratio: var(--photo-aspect-ratio, 4 / 3);
  background: rgba(0,0,0,0.05);
}
.bubble-media.photo-media img {
  width: 100%;
  height: 100%;
  max-height: none !important;
  object-fit: cover;
}
.bubble-media + .bubble-meta, .bubble-media ~ .bubble-meta { position: relative; margin-top: -28px; padding: 0 8px 6px 0; z-index: 1; }
.bubble-media ~ .bubble-time { background: rgba(0,0,0,0.5); padding: 2px 6px; border-radius: 8px; color: #fff !important; font-size: 10px; }
.bubble-media ~ .bubble-status { color: var(--accent-dark, #5c3a99) !important; filter: drop-shadow(0 1px 2px rgba(255,255,255,0.65)); }

.bubble-file {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; background: rgba(0,0,0,0.15);
  border-radius: var(--radius-xl); margin-bottom: 4px;
  cursor: pointer; transition: background var(--transition-fast);
  border: 1px solid var(--border);
}
.bubble-file:hover { background: rgba(168,85,247,0.1); }
.bubble-file .file-icon { font-size: 36px; }
.file-info .file-name { font-weight: 600; font-size: var(--font-size-sm); }
.file-info .file-size { font-size: var(--font-size-xs); color: var(--text-secondary); }

/* Voice */
.bubble-voice { display: flex; align-items: center; gap: 10px; min-width: 200px; max-width: 320px; padding: 4px 0; border-radius: 18px; transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease; }
.bubble-voice.is-pending { opacity: 0.92; }
.bubble-voice.is-silent-pending { opacity: 1; }
.bubble-voice.is-failed { opacity: 0.72; }
.voice-play-btn {
  width: 46px; height: 46px; border: none; border-radius: var(--radius-full);
  background: var(--voice-btn-bg); color: var(--text-white);
  cursor: pointer; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: transform var(--transition-fast), box-shadow var(--transition-fast), filter var(--transition-fast);
  box-shadow: 0 2px 10px var(--accent-glow);
}
.voice-play-btn:hover { transform: scale(1.06); }
.voice-play-btn.playing,
.bubble-voice.is-playing .voice-play-btn {
  transform: scale(1.06);
  filter: saturate(1.12);
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent-glow) 72%, rgba(255,255,255,0.28));
}
.message.voice-active .bubble {
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 32%, transparent), var(--shadow-sm, 0 4px 16px rgba(0,0,0,0.08));
}
.bubble-voice.is-playing .voice-waveform .bar {
  transition: height 100ms ease, opacity 120ms ease, background 120ms ease;
}
.bubble-voice.just-started .voice-play-btn {
  animation: voiceStartPulse 560ms ease;
}
@keyframes voiceStartPulse {
  0% { transform: scale(0.92); }
  45% { transform: scale(1.12); }
  100% { transform: scale(1.06); }
}
.voice-right { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.voice-waveform { flex: 1; height: 26px; display: flex; align-items: center; gap: 2px; }
.voice-waveform .bar { width: 2px; border-radius: 1px; background: var(--voice-bar); transition: height 0.1s; opacity: 0.6; }
.voice-waveform .bar.played { opacity: 1; }
.voice-waveform .bar.bar-out { background: var(--voice-bar-out); opacity: 0.7; }
.voice-waveform .bar.bar-out.played { background: var(--voice-bar-played); opacity: 1; }
.voice-meta { display: flex; align-items: center; gap: 4px; }
.voice-state { font-size: 11px; font-weight: 600; text-transform: lowercase; }
.voice-state.pending { color: color-mix(in srgb, var(--accent) 72%, #fff 28%); }
.voice-state.failed { color: #ff7b7b; }
.voice-dot { font-size: 10px; color: var(--voice-duration); }
.voice-duration { font-size: var(--font-size-xs); color: var(--voice-duration); white-space: nowrap; font-weight: 500; }
.message.outgoing .voice-duration, .message.outgoing .voice-dot { color: var(--voice-duration-out); }
.message.outgoing .voice-waveform .bar:not(.bar-out) { background: rgba(255,255,255,0.45); }

.typing-indicator { padding: 4px 12px 4px 80px; font-size: var(--font-size-sm); color: var(--accent); font-style: italic; min-height: 22px; }
.typing-indicator:empty {
  display: none;
  min-height: 0;
  padding-top: 0;
  padding-bottom: 0;
}
.typing-indicator:empty::before {
  content: none;
  display: none;
}

/* ═══ Composer — Glass ═══ */
.composer {
  display: flex; align-items: flex-end;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
  background: var(--composer-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  gap: 6px; min-height: var(--composer-height);
  border-top: 1px solid var(--border);
}
.composer.has-text .composer-input-wrap {
  border-color: color-mix(in srgb, var(--composer-input-focus) 82%, white 18%);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}
.composer.is-readonly .composer-input-wrap {
  background: color-mix(in srgb, var(--composer-input-bg) 74%, var(--bg-secondary) 26%);
}
.composer.is-readonly .composer-btn,
.composer.is-readonly .emoji-btn,
.composer.is-readonly .action-btn {
  cursor: not-allowed;
  opacity: 0.42;
}

.composer-btn {
  width: 46px; height: 46px; border: none; background: transparent;
  border-radius: var(--radius-full); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); flex-shrink: 0;
  transition: color var(--transition-fast), background var(--transition-fast);
}
.composer-btn:hover { color: var(--accent); background: var(--bg-hover); }
.composer-btn:active { transform: scale(0.96); }

.composer-input-wrap {
  flex: 1; display: flex; align-items: flex-end;
  background: var(--composer-input-bg);
  border: 1px solid var(--composer-input-border);
  border-radius: 28px; padding: 0;
  position: relative; min-height: 46px;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
}
.composer-input-wrap:focus-within {
  border-color: var(--composer-input-focus);
  box-shadow: 0 0 0 3px rgba(168,85,247,0.08);
}
.composer textarea {
  flex: 1; border: none; background: transparent;
  padding: 12px 6px 12px 18px; font-size: var(--font-size-md);
  resize: none; max-height: 150px; outline: none;
  font-family: var(--font-family); color: var(--text-primary);
  line-height: 1.35; min-height: 46px;
}
.composer textarea::placeholder { color: var(--composer-placeholder); }
.composer textarea:disabled {
  cursor: not-allowed;
  color: var(--text-secondary);
  -webkit-text-fill-color: var(--text-secondary);
}
[data-theme="light"] .composer textarea {
  color: #111827;
  -webkit-text-fill-color: #111827;
  caret-color: #111827;
}
[data-theme="light"] .composer textarea:disabled {
  color: var(--text-secondary);
  -webkit-text-fill-color: var(--text-secondary);
}
.emoji-btn {
  width: 40px; height: 46px; border: none; background: none;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); flex-shrink: 0; transition: color var(--transition-fast);
}
.emoji-btn:hover { color: var(--accent); }
.emoji-btn:active { transform: scale(0.96); }

/* Action button: mic ↔ send — with glow */
.action-btn {
  width: 48px; height: 48px; border-radius: var(--radius-full);
  transition: background 200ms ease, color 200ms ease, transform 200ms cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 200ms ease;
  position: relative; overflow: hidden;
}
.action-btn .mic-icon, .action-btn .send-icon {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  transition: opacity 180ms ease, transform 200ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.action-btn.is-mic { background: var(--accent-light); color: var(--accent); }
.action-btn.is-mic:hover { background: rgba(168,85,247,0.18); }
.action-btn.is-mic .mic-icon { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.action-btn.is-mic .send-icon { opacity: 0; transform: translate(-50%, -50%) scale(0.3) rotate(-30deg); }
.action-btn.is-send {
  background: var(--accent-gradient-btn); color: var(--text-white);
  box-shadow: 0 4px 16px var(--accent-glow);
}
.action-btn.is-send:hover { transform: scale(1.08); box-shadow: 0 6px 24px var(--accent-glow), var(--neon-glow); }
.action-btn:active { transform: scale(0.95); }
.action-btn.is-send .send-icon { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.action-btn.is-send .mic-icon { opacity: 0; transform: translate(-50%, -50%) scale(0.3) rotate(30deg); }

/* Reply bar */
.composer-reply { display: none; align-items: center; padding: 9px 12px; background: color-mix(in srgb, var(--bg-header) 90%, white 10%); border-top: 1px solid var(--border); gap: 8px; }
.composer-reply.active { display: flex; }
.composer-reply-content { flex: 1; border-left: 3px solid var(--accent); padding-left: 10px; min-width: 0; }
.composer-reply-name { font-weight: 600; font-size: var(--font-size-sm); color: var(--accent); }
.composer-reply-text { font-size: var(--font-size-sm); color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer-reply-close { background: none; border: none; cursor: pointer; font-size: 20px; color: var(--text-secondary); padding: 4px; }

/* Attach menu */
.attach-menu { display: none; position: fixed; bottom: 68px; background: color-mix(in srgb, var(--bg-primary) 92%, white 8%); border-radius: 20px; box-shadow: 0 18px 44px var(--shadow-lg); overflow: hidden; z-index: 200; min-width: 200px; border: 1px solid var(--border); backdrop-filter: blur(20px); }
.attach-menu.show { display: block; animation: slideUp 200ms ease; }
@keyframes slideUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.attach-option { display: flex; align-items: center; gap: 14px; padding: 14px 20px; cursor: pointer; transition: background var(--transition-fast); white-space: nowrap; font-size: var(--font-size-md); }
.attach-option:hover { background: var(--bg-hover); }
.attach-option:active { background: var(--bg-active); }
.attach-option .attach-icon { font-size: 22px; }
.native-file-input {
  position: fixed;
  left: -10000px;
  top: auto;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* ═══ Context menu ═══ */
.context-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); z-index: 199; }
.context-overlay.show { display: block; animation: fadeIn 150ms ease; }
.context-menu {
  display: none; position: fixed;
  background: var(--bg-glass);
  backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 40px var(--shadow-lg);
  z-index: 200; min-width: 220px; max-width: 280px;
  overflow: hidden; animation: ctxIn 180ms cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes ctxIn { from { opacity: 0; transform: scale(0.9) translateY(4px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.context-menu.show { display: block; }
.context-reactions { display: flex; gap: 4px; padding: 10px 12px; border-bottom: 1px solid var(--border); justify-content: center; background: var(--bg-secondary); }
.context-reaction-btn { width: 40px; height: 40px; border: none; background: none; border-radius: var(--radius-full); cursor: pointer; font-size: 24px; transition: transform 200ms cubic-bezier(0.34, 1.56, 0.64, 1), background var(--transition-fast); display: flex; align-items: center; justify-content: center; }
.context-reaction-btn:hover { transform: scale(1.35); background: var(--bg-hover); }
.context-item { display: flex; align-items: center; gap: 14px; padding: 11px 18px; cursor: pointer; font-size: var(--font-size-md); transition: background 0.12s; color: var(--text-primary); }
.context-item:hover { background: var(--bg-hover); }
.context-item.danger { color: var(--danger); }
.context-item.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}
.context-item .ctx-icon { font-size: 18px; width: 24px; text-align: center; opacity: 0.7; }
.context-item.danger .ctx-icon { opacity: 1; }

/* ═══ Modal ═══ */
.modal-overlay { display: none; position: fixed; inset: 0; background: var(--bg-modal); z-index: 300; align-items: center; justify-content: center; animation: fadeIn 200ms ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-overlay.show { display: flex; }
.modal { background: var(--bg-primary); border: 1px solid var(--border); border-radius: var(--radius-xxl); width: 440px; max-width: 92vw; max-height: 80vh; overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,0.3), var(--neon-glow); animation: slideUp 250ms ease; }
.modal-header { display: flex; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--border); gap: 12px; }
.modal-header h3 { flex: 1; font-size: var(--font-size-lg); font-weight: 700; letter-spacing: -0.02em; }
.modal-body { padding: 16px 20px; overflow-y: auto; flex: 1; }
.modal-body input { width: 100%; padding: 14px 18px; border: 1px solid var(--border); border-radius: var(--radius-xl); font-size: var(--font-size-md); outline: none; margin-bottom: 16px; background: var(--bg-input); color: var(--text-primary); transition: border var(--transition-fast); }
.modal-body input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(168,85,247,0.1); }
.modal-body input::placeholder { color: var(--text-secondary); opacity: 0.5; }

.user-list-item { display: flex; align-items: center; gap: 14px; padding: 10px 12px; cursor: pointer; transition: background var(--transition-fast); border-radius: var(--radius-md); }
.user-list-item:hover { background: var(--bg-hover); }
.user-list-item .avatar { width: 46px; height: 46px; border-radius: var(--radius-full); background: var(--accent-gradient); color: var(--text-white); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: var(--font-size-lg); flex-shrink: 0; }
.user-list-item .user-info { flex: 1; }
.user-list-item .user-info .name { font-weight: 600; font-size: var(--font-size-md); }
.user-list-item .user-info .username { font-size: var(--font-size-sm); color: var(--text-secondary); }
.no-results { text-align: center; color: var(--text-secondary); padding: 24px; font-size: var(--font-size-sm); }

/* ═══ Member Chips ═══ */
.member-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 4px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
}
.member-chip .chip-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent-gradient);
  color: var(--text-white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}
.member-chip .chip-remove {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.15s;
  font-size: 14px;
  line-height: 1;
}
.member-chip .chip-remove:hover {
  color: var(--danger);
  background: rgba(239,68,68,0.1);
}

/* ═══ Voice recording strip ═══ */
.rec-strip { display: none; align-items: center; padding: 0 10px 0 14px; height: 58px; background: var(--composer-bg); border-top: 1px solid var(--border); gap: 12px; }
.rec-strip.active { display: flex; }
.rec-dot { width: 10px; height: 10px; background: var(--danger); border-radius: var(--radius-full); animation: recPulse 1s ease-in-out infinite; flex-shrink: 0; }
@keyframes recPulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.3; transform: scale(0.85); } }
.rec-time { font-size: 17px; font-weight: 500; font-variant-numeric: tabular-nums; min-width: 52px; color: var(--text-primary); }
.rec-slide-hint { display: flex; align-items: center; gap: 6px; color: var(--text-secondary); font-size: var(--font-size-sm); flex: 1; justify-content: center; cursor: pointer; padding: 8px 0; border-radius: var(--radius-md); transition: color var(--transition-fast); }
.rec-slide-hint:hover { color: var(--danger); }
.rec-slide-hint svg { animation: slideLeft 1.5s ease-in-out infinite; flex-shrink: 0; }
@keyframes slideLeft { 0%, 100% { transform: translateX(0); opacity: 0.5; } 50% { transform: translateX(-8px); opacity: 1; } }
.rec-mic-btn {
  width: 64px; height: 64px; border: none; border-radius: var(--radius-full);
  background: var(--voice-btn-bg); color: var(--text-white);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: -10px; margin-right: -4px;
  position: relative; z-index: 2;
  box-shadow: 0 0 0 0 var(--accent-glow), 0 4px 16px var(--accent-glow);
  animation: recBtnPulse 1.4s ease-in-out infinite;
}
@keyframes recBtnPulse {
  0% { box-shadow: 0 0 0 0 var(--accent-glow), 0 4px 16px var(--accent-glow); transform: scale(1); }
  50% { box-shadow: 0 0 0 16px rgba(124,58,237,0), 0 4px 24px var(--accent-glow); transform: scale(1.06); }
  100% { box-shadow: 0 0 0 0 rgba(124,58,237,0), 0 4px 16px var(--accent-glow); transform: scale(1); }
}

/* ═══ Lightbox ═══ */
.lightbox { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.92); z-index: 500; align-items: center; justify-content: center; cursor: zoom-out; touch-action: none; overscroll-behavior: contain; }
.lightbox.show { display: flex; animation: fadeIn 200ms ease; }
.lightbox img,
.lightbox video { max-width: 92vw; max-height: 88vh; object-fit: contain; border-radius: var(--radius-md); cursor: default; animation: scaleIn 200ms ease; user-select: none; -webkit-user-drag: none; transform: translate3d(0,0,0); transition: transform 240ms cubic-bezier(0.22, 1, 0.36, 1), opacity 220ms ease; will-change: transform, opacity; }
.lightbox video { background: #000; }
.lightbox.is-video-viewer video { width: 100vw; height: 100dvh; max-width: 100vw; max-height: 100dvh; border-radius: 0; }
.lightbox.photo-viewer-v2 img { touch-action: none; cursor: zoom-in; transform-origin: center center; }
.lightbox.swiping img,
.lightbox.swiping video { transition: none; }
@keyframes scaleIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.lightbox-close { position: absolute; top: 16px; right: 20px; width: 44px; height: 44px; background: rgba(255,255,255,0.12); border: none; border-radius: var(--radius-full); color: #fff; font-size: 24px; cursor: pointer; display: flex; align-items: center; justify-content: center; z-index: 2; }
.lightbox-close:hover { background: rgba(255,255,255,0.25); }
.lightbox-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; background: rgba(255,255,255,0.1); border: none; border-radius: var(--radius-full); color: #fff; font-size: 22px; cursor: pointer; display: flex; align-items: center; justify-content: center; z-index: 2; }
.lightbox-nav:hover { background: rgba(255,255,255,0.25); }
.lightbox-nav.prev { left: 16px; } .lightbox-nav.next { right: 16px; }
.lightbox-counter { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); color: rgba(255,255,255,0.6); font-size: var(--font-size-sm); z-index: 2; }
.lightbox-download { position: absolute; top: 16px; right: 76px; width: 44px; height: 44px; background: rgba(255,255,255,0.12); border: none; border-radius: var(--radius-full); color: #fff; font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; z-index: 2; text-decoration: none; }
.lightbox-download:hover { background: rgba(255,255,255,0.25); }

.file-viewer { display: none; position: fixed; inset: 0; z-index: 540; background: rgba(4,6,12,0.92); padding: max(10px, env(safe-area-inset-top, 0px)) 10px max(10px, env(safe-area-inset-bottom, 0px)); }
.file-viewer.show { display: flex; }
.file-viewer-shell { width: 100%; height: 100%; display: flex; flex-direction: column; overflow: hidden; border-radius: 18px; background: #0b0f18; border: 1px solid rgba(255,255,255,0.12); box-shadow: 0 20px 60px rgba(0,0,0,0.35); }
.file-viewer-bar { min-height: 56px; display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: rgba(12,16,26,0.96); border-bottom: 1px solid rgba(255,255,255,0.1); }
.file-viewer-back, .file-viewer-close, .file-viewer-download { height: 40px; min-width: 40px; border: 0; border-radius: 999px; background: rgba(255,255,255,0.1); color: #fff; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; font: inherit; cursor: pointer; }
.file-viewer-back { padding: 0 14px; font-weight: 700; }
.file-viewer-close { font-size: 24px; line-height: 1; }
.file-viewer-title { min-width: 0; flex: 1; color: #fff; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-viewer-frame { flex: 1; width: 100%; border: 0; background: #fff; }

/* ═══ Media Mosaic ═══ */
.media-mosaic { position: relative; display: grid; gap: 2px; border-radius: var(--radius-md); overflow: hidden; max-width: 100%; margin-bottom: 4px; }
.media-mosaic img, .media-mosaic video { width: 100%; height: 100%; object-fit: cover; cursor: pointer; display: block; }
.media-mosaic.has-photo,
.media-mosaic.has-video { width: min(420px, 82vw); contain: layout paint; transform: translateZ(0); }
.media-mosaic-video { position: relative; width: 100%; height: 100%; cursor: pointer; overflow: hidden; background: linear-gradient(135deg, rgba(14,14,22,0.92), rgba(72,61,146,0.46)); }
.media-mosaic-video-thumb,
.media-mosaic-video-placeholder { width: 100%; height: 100%; display: block; object-fit: cover; background: rgba(0,0,0,0.42); }
.media-mosaic-video-thumb.is-unavailable { display: none; }
.media-mosaic-video-placeholder { background: linear-gradient(135deg, rgba(14,14,22,0.92), rgba(72,61,146,0.46)); }
.media-mosaic.mosaic-1 .media-mosaic-video { aspect-ratio: var(--video-aspect-ratio, 16 / 9); max-height: 340px; }
.media-mosaic-video-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 10px; background: linear-gradient(180deg, rgba(0,0,0,0.02) 0%, rgba(0,0,0,0.5) 100%); color: #fff; pointer-events: none; }
.media-mosaic-video-play { width: 54px; height: 54px; border-radius: 999px; background: rgba(22,22,34,0.58); border: 1px solid rgba(255,255,255,0.18); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); display: inline-flex; align-items: center; justify-content: center; padding-left: 2px; font-size: 22px; box-shadow: 0 7px 20px rgba(0,0,0,0.32); }
.media-mosaic-video-duration { position: absolute; right: 10px; bottom: 10px; padding: 4px 8px; border-radius: 999px; background: rgba(0,0,0,0.48); font-size: 12px; font-weight: 700; letter-spacing: 0.02em; }
.media-mosaic.mosaic-1 { grid-template: 1fr / 1fr; }
.media-mosaic.mosaic-1 img, .media-mosaic.mosaic-1 video { max-height: 340px; object-fit: contain; background: rgba(0,0,0,0.05); }
.media-mosaic.mosaic-2 { grid-template: 200px / 1fr 1fr; }
.media-mosaic.mosaic-3 { grid-template: 140px 140px / 1.5fr 1fr; }
.media-mosaic.mosaic-3 > :first-child { grid-row: 1 / 3; }
.media-mosaic.mosaic-4 { grid-template: 150px 150px / 1fr 1fr; }
.media-mosaic.mosaic-5 { grid-template: 160px 120px / 1fr 1fr 1fr; }
.media-mosaic.mosaic-5 > :nth-child(1) { grid-column: 1 / 2; }
.media-mosaic.mosaic-5 > :nth-child(2) { grid-column: 2 / 4; }
.media-mosaic.mosaic-6 { grid-template: 130px 130px / 1fr 1fr 1fr; }
.mosaic-bubble { padding: 2px; overflow: hidden; }
.mosaic-more { position: relative; }
.mosaic-more::after { content: attr(data-more); position: absolute; inset: 0; background: rgba(0,0,0,0.5); color: #fff; font-size: 24px; font-weight: 700; display: flex; align-items: center; justify-content: center; }

.bubble-media.photo-media,
.bubble-media.video-media { position: relative; }
.media-upload-progress {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 2;
  background: radial-gradient(circle at center, rgba(0,0,0,0.28), rgba(0,0,0,0.12) 44%, rgba(0,0,0,0.02));
  border-radius: inherit;
}
.media-upload-progress-circle {
  position: relative;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    conic-gradient(var(--accent) var(--upload-progress-deg, 0deg), rgba(255,255,255,0.24) 0deg),
    rgba(7, 10, 18, 0.58);
  box-shadow: 0 8px 26px rgba(0,0,0,0.32), inset 0 0 0 1px rgba(255,255,255,0.18);
  transform: translateZ(0);
}
.media-upload-progress-circle::before {
  content: '';
  position: absolute;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(8, 10, 18, 0.82);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.1);
  z-index: 0;
}
.media-upload-progress-circle::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.18);
  border-top-color: rgba(255,255,255,0.86);
  border-right-color: rgba(255,255,255,0.36);
  animation: mediaUploadSpin 1s linear infinite;
  z-index: 1;
}
.media-upload-progress-percent {
  position: relative;
  z-index: 2;
  min-width: 34px;
  text-align: center;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  transform: none;
  backface-visibility: hidden;
  text-shadow: 0 1px 3px rgba(0,0,0,0.55);
}
@keyframes mediaUploadSpin {
  to { transform: rotate(360deg); }
}

/* ═══ Profile ═══ */
.profile-overlay { display: none; position: fixed; inset: 0; background: var(--bg-modal); z-index: 400; align-items: center; justify-content: center; animation: fadeIn 200ms ease; }
.profile-overlay.show { display: flex; }

.profile-card {
  background: var(--profile-bg, var(--bg-primary));
  border: 1px solid var(--border);
  border-radius: 20px;
  width: 400px;
  max-width: 95vw;
  max-height: 90vh;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 80px rgba(0,0,0,0.4), var(--neon-glow);
  animation: slideUp 280ms cubic-bezier(0.22, 1, 0.36, 1);
}

.profile-top {
  position: sticky;
  top: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  height: 56px;
  padding: 0 12px;
  flex: 0 0 auto;
  background: color-mix(in srgb, var(--bg-primary) 94%, transparent);
  border-bottom: 1px solid var(--border-light);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
}
.profile-back { background: none; border: none; color: var(--text-primary); font-size: 22px; cursor: pointer; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-full); transition: background 0.15s; }
.profile-back:hover { background: var(--bg-hover); }
.profile-title {
  position: absolute;
  left: 64px;
  right: 64px;
  text-align: center;
  font-size: var(--font-size-lg);
  font-weight: 700;
  letter-spacing: 0;
  pointer-events: none;
}
.profile-edit-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 10px;
  transition: all 0.15s;
}
.profile-edit-btn:hover { background: rgba(168,85,247,0.1); }

/* Profile body: inline editing overlay */
.profile-body {
  display: none;
  position: absolute;
  inset: 0;
  background: var(--bg-primary);
  z-index: 10;
  overflow-y: auto;
  padding: 20px;
  animation: slideUp 200ms ease;
}

.profile-hero {
  text-align: center;
  padding: 18px 24px 20px;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 0 0 auto;
}
.profile-hero > :not(.group-cover-bg) {
  position: relative;
  z-index: 1;
}
.profile-hero.has-cover {
  padding-top: 138px;
}
.profile-hero.has-cover .profile-avatar-wrap {
  margin-bottom: 12px;
}
.profile-avatar-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: max-content;
  max-width: 100%;
  margin: 0 auto 14px;
  align-self: center;
}

.profile-avatar {
  width: 110px; height: 110px;
  border-radius: var(--radius-full);
  border: 3px solid transparent;
  background: var(--accent-gradient);
  background-origin: border-box;
  background-clip: padding-box, border-box;
  color: var(--text-white);
  font-size: 38px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  box-shadow: 0 6px 24px var(--shadow-lg), var(--neon-glow);
  transition: transform 0.2s;
}
.profile-avatar:hover { transform: scale(1.04); }
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }

.profile-avatar-upload { position: absolute; inset: 0; background: rgba(0,0,0,0.5); border-radius: var(--radius-full); display: none; align-items: center; justify-content: center; color: #fff; font-size: 22px; cursor: pointer; }
.profile-avatar-wrap:hover .profile-avatar-upload { display: flex; }
#profile-avatar-wrap.channel-avatar-wrap .profile-avatar-upload {
  border-radius: 12px !important;
}

.profile-name-row { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 0 auto 2px; width: 100%; max-width: 100%; min-width: 0; }
.profile-name { font-size: 24px; font-weight: 700; letter-spacing: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; }
.profile-verified { display: flex; align-items: center; }
.profile-username-row { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 0 auto 6px; width: 100%; max-width: 100%; min-width: 0; }
.profile-username { font-size: var(--font-size-lg); color: var(--accent); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; }
.profile-qr-btn { background: none; border: none; color: var(--text-secondary); cursor: pointer; display: flex; padding: 2px; transition: color 0.15s; }
.profile-qr-btn:hover { color: var(--accent); }

/* Online pill badge */
.profile-status-badge { font-size: var(--font-size-sm); margin-bottom: 8px; font-weight: 500; }
.profile-status-badge.online {
  display: inline-block;
  color: #10B981;
  background: rgba(16,185,129,0.15);
  padding: 4px 14px;
  border-radius: 20px;
}
.profile-status-badge.offline { color: var(--text-secondary); }

.profile-bio { font-size: var(--font-size-md); color: var(--text-secondary); line-height: 1.5; margin: 8px auto 0; max-width: 320px; text-align: center; overflow-wrap: anywhere; }

/* Quick actions — circular */
.profile-quick-actions { display: flex; justify-content: center; gap: 20px; padding: 4px 20px 20px; flex: 0 0 auto; }
.profile-action-btn { display: flex; flex-direction: column; align-items: center; gap: 8px; cursor: pointer; min-width: 56px; }
.profile-action-icon {
  width: 56px; height: 56px;
  border-radius: var(--radius-full);
  background: rgba(255,255,255,0.05);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; transition: all 0.2s;
  border: 1px solid var(--border);
  color: var(--accent);
}
.profile-action-btn:hover .profile-action-icon {
  background: var(--accent);
  color: var(--text-white);
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 6px 20px var(--accent-glow), var(--neon-glow);
}
.profile-action-label { font-size: 12px; color: var(--text-secondary); font-weight: 500; text-transform: uppercase; letter-spacing: 0.02em; }

/* Profile sections */
.profile-sections { border-top: 1px solid var(--border); overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.profile-section-sep { height: 8px; background: var(--bg-secondary); }
.profile-menu-item { display: flex; align-items: center; padding: 16px 20px; cursor: pointer; transition: background var(--transition-fast); gap: 14px; border-bottom: 1px solid var(--border-light); }
.profile-menu-item:hover { background: var(--bg-hover); }
.profile-menu-item:last-child { border-bottom: none; }
.profile-menu-noninteractive { pointer-events: none; }
.profile-menu-static { pointer-events: none; opacity: .7; }
.profile-menu-icon { font-size: 20px; width: 28px; text-align: center; flex-shrink: 0; }
.profile-menu-label { flex: 1; font-size: var(--font-size-md); color: var(--text-primary); }
.profile-menu-label-strong { font-weight: 600; }
.profile-menu-label-danger { color: var(--danger); }
.profile-menu-sub { font-size: var(--font-size-sm); color: var(--text-secondary); }
.profile-menu-arrow { font-size: 18px; color: var(--text-secondary); }
.profile-menu-icon-inline { font-size: inherit; }
.profile-row-title { font-weight: 500; }
.profile-row-meta { font-size: 11px; color: var(--text-secondary); }
.profile-row-meta-break { word-break: break-all; }
.profile-row-actions { margin-left: auto; display: flex; gap: 4px; }
.profile-avatar-36,
.profile-avatar-36-img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
}
.profile-avatar-36 {
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
}
.profile-avatar-36-img { object-fit: cover; }
.profile-avatar-32 {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}
.profile-avatar-bg-e17076 { background: #e17076; }
.profile-avatar-bg-7bc862 { background: #7bc862; }
.profile-avatar-bg-e5ca77 { background: #e5ca77; }
.profile-avatar-bg-65aadd { background: #65aadd; }
.profile-avatar-bg-a695e7 { background: #a695e7; }
.profile-avatar-bg-ee7aae { background: #ee7aae; }
.profile-avatar-bg-6ec9cb { background: #6ec9cb; }
.profile-avatar-bg-faa774 { background: #faa774; }
.profile-status-dot { color: var(--online); margin-left: 4px; font-size: 8px; }
.profile-role-label { color: var(--accent); font-size: 10px; margin-left: 4px; }
.profile-subsection-label { font-size: 13px; font-weight: 600; margin-bottom: 8px; color: var(--text-secondary); }
.profile-subsection-label-spaced { margin: 12px 0 8px; }
.profile-admin-list-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.profile-admin-list-row-actionable { cursor: pointer; }
.profile-row-fill { flex: 1; min-width: 0; }
.profile-row-title-compact { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-inline-icon-btn { background: none; border: none; cursor: pointer; font-size: 16px; padding: 4px; }
.profile-creator-badge { font-size: 11px; color: var(--accent); }
.channel-settings-row-icon { font-size: 20px; }
.channel-settings-row-title { font-size: 14px; font-weight: 600; }
.channel-settings-row-sub { font-size: 12px; color: var(--text-secondary); }

.media-gallery-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 4px; }
.media-gallery-item { aspect-ratio: 1; overflow: hidden; cursor: pointer; border-radius: 2px; }
.media-gallery-item img { width: 100%; height: 100%; object-fit: cover; transition: transform var(--transition-fast); }
.media-gallery-item:hover img { transform: scale(1.05); }
.profile-content-title { margin-bottom: 12px; }
.profile-content-title-sm { margin-bottom: 8px; }
.profile-empty-text { color: var(--text-secondary); text-align: center; padding: 20px; }
.content-gallery-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.content-gallery-tile {
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}
.content-gallery-tile img { width: 100%; height: 100%; object-fit: cover; }

/* ═══ Chat Search Bar ═══ */
.chat-search-bar { display: none; align-items: center; padding: 6px 12px; background: var(--bg-header); border-bottom: 1px solid var(--border); gap: 8px; animation: slideDown 200ms ease; }
.chat-search-bar.show { display: flex; }
.chat-search-bar input { flex: 1; padding: 8px 14px; border: none; border-radius: 18px; background: var(--bg-secondary); color: var(--text-primary); font-size: var(--font-size-sm); outline: none; }
.chat-search-bar input::placeholder { color: var(--text-secondary); opacity: 0.5; }
.chat-search-nav { display: flex; align-items: center; gap: 4px; }
.chat-search-nav button { width: 32px; height: 32px; border: none; background: none; border-radius: var(--radius-full); color: var(--text-secondary); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 16px; }
.chat-search-nav button:hover { color: var(--accent); background: var(--bg-hover); }
.chat-search-count { font-size: var(--font-size-xs); color: var(--text-secondary); white-space: nowrap; min-width: 40px; text-align: center; }
.message.search-highlight .bubble { box-shadow: 0 0 0 2px var(--accent), var(--neon-glow); }

/* ═══ Video Circle ═══ */
.bubble-video-circle { position: relative; width: 288px; height: 288px; border-radius: var(--radius-full); overflow: hidden; cursor: pointer; margin-bottom: 4px; }
.bubble-video-circle video { width: 100%; height: 100%; object-fit: cover; border-radius: var(--radius-full); }
.bubble-video-circle .vc-play { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.2); border-radius: var(--radius-full); }
.bubble-video-circle .vc-play svg { filter: drop-shadow(0 1px 4px rgba(0,0,0,0.4)); }
.bubble-video-circle.playing .vc-play { background: transparent; }
.bubble-video-circle.playing .vc-play svg { opacity: 0; }
.bubble-video-circle .vc-ring { position: absolute; inset: -3px; border: 3px solid var(--accent); border-radius: var(--radius-full); pointer-events: none; }
.bubble-video-circle .vc-duration { position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,0.6); color: #fff; font-size: var(--font-size-xs); padding: 2px 8px; border-radius: 8px; }
.bubble-video-circle.is-pending { opacity: 0.94; }
.bubble-video-circle.is-failed { opacity: 0.72; }
.bubble-video-circle .vc-status {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 700;
  background: rgba(0,0,0,0.55); color: #fff; text-transform: lowercase; letter-spacing: 0.02em;
}
.bubble-video-circle .vc-status.pending { color: color-mix(in srgb, var(--accent) 72%, #fff 28%); }
.bubble-video-circle .vc-status.failed { color: #ff9e9e; }

/* ═══ Emoji Picker ═══ */
.emoji-picker { display: none; position: absolute; bottom: 56px; right: 0; width: 336px; max-height: 380px; background: color-mix(in srgb, var(--bg-primary) 92%, white 8%); border: 1px solid var(--border); border-radius: 22px; box-shadow: 0 16px 44px var(--shadow-lg); z-index: 150; overflow: hidden; animation: slideUp 200ms ease; backdrop-filter: blur(22px); }
.emoji-picker.show { display: flex; flex-direction: column; }
.emoji-picker-search { padding: 10px 12px 8px; border-bottom: 1px solid var(--border); }
.emoji-picker-search input { width: 100%; padding: 10px 14px; border: none; border-radius: 18px; background: color-mix(in srgb, var(--bg-secondary) 88%, white 12%); color: var(--text-primary); font-size: var(--font-size-sm); outline: none; }
.emoji-picker-tabs { display: flex; padding: 6px 8px; gap: 4px; border-bottom: 1px solid var(--border); }
.emoji-picker-tabs button { flex: 1; padding: 7px; border: none; background: none; font-size: 18px; cursor: pointer; border-radius: 14px; }
.emoji-picker-tabs button:hover { background: var(--bg-hover); }
.emoji-picker-tabs button.active { background: var(--bg-active); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08); }
.emoji-picker-grid { flex: 1; overflow-y: auto; padding: 8px 10px 12px; display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 4px; }
.emoji-picker-grid button { width: 36px; height: 36px; border: none; background: none; font-size: 22px; cursor: pointer; border-radius: 12px; display: flex; align-items: center; justify-content: center; transition: background var(--transition-fast), transform var(--transition-fast); }
.emoji-picker-grid button:hover { background: var(--bg-hover); transform: translateY(-1px) scale(1.14); }
.emoji-category-label { grid-column: 1 / -1; font-size: 11px; color: var(--text-secondary); font-weight: 700; padding: 8px 4px 4px; text-transform: uppercase; letter-spacing: 0.9px; }
.emoji-picker-empty { grid-column: 1 / -1; padding: 18px 10px; text-align: center; color: var(--text-secondary); font-size: var(--font-size-sm); }

/* ═══ Upload Progress ═══ */
.upload-bubble { position: relative; max-width: var(--max-bubble-width); }
.upload-bubble .upload-thumb { width: 220px; height: 220px; border-radius: var(--radius-md); object-fit: cover; display: block; filter: brightness(0.5); }
.upload-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-md); flex-direction: column; gap: 6px; }
.upload-ring { width: 56px; height: 56px; transform: rotate(-90deg); }
.upload-ring-bg { fill: none; stroke: rgba(255,255,255,0.2); stroke-width: 3; }
.upload-ring-progress { fill: none; stroke: var(--accent); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 157; stroke-dashoffset: 157; transition: stroke-dashoffset 200ms ease; }
.upload-percent { position: absolute; color: #fff; font-size: var(--font-size-sm); font-weight: 600; }
.upload-status { color: rgba(255,255,255,0.82); font-size: 11px; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; margin-top: 66px; }
.upload-cancel { position: absolute; bottom: 8px; right: 8px; width: 32px; height: 32px; background: rgba(0,0,0,0.5); border: none; border-radius: var(--radius-full); color: #fff; font-size: 14px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.upload-bubble.failed .upload-ring-progress { stroke: #ff7a8a; }
.upload-bubble.failed .upload-percent { color: #ffb4c2; }
.upload-bubble.failed .upload-status { color: #ffb4c2; }

.chat-peek {
  position: fixed;
  width: min(420px, calc(100vw - 24px));
  max-height: min(60vh, 520px);
  display: flex;
  flex-direction: column;
  border-radius: 24px;
  background: color-mix(in srgb, var(--bg-elevated) 92%, rgba(11, 13, 22, 0.14) 8%);
  border: 1px solid color-mix(in srgb, var(--accent-dark, #5c3a99) 18%, var(--border) 82%);
  box-shadow: 0 24px 60px rgba(10, 12, 20, 0.28);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(10px) scale(0.98);
  transition: opacity 180ms ease, transform 180ms ease, visibility 180ms ease;
  z-index: 140;
}
.chat-peek.show { opacity: 1; visibility: visible; pointer-events: auto; transform: translateY(0) scale(1); }
.chat-peek-head { padding: 16px 18px 12px; border-bottom: 1px solid var(--border); }
.chat-peek-title { font-size: 16px; font-weight: 700; color: var(--text-primary); }
.chat-peek-sub { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.chat-peek-body { overflow-y: auto; padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 8px; }
.chat-peek-row { padding: 10px 12px; border-radius: 16px; background: color-mix(in srgb, var(--bg-secondary) 84%, transparent); }
.chat-peek-author { display: block; font-size: 11px; font-weight: 700; color: var(--accent-dark, #5c3a99); margin-bottom: 4px; letter-spacing: 0.04em; text-transform: uppercase; }
.chat-peek-text { display: block; font-size: 13px; color: var(--text-primary); line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.chat-peek-empty,
.chat-peek-loading { padding: 14px 8px; text-align: center; color: var(--text-secondary); font-size: 13px; }
.chat-peek-actions { padding: 0 14px 14px; display: flex; justify-content: stretch; }
.chat-peek-pin-btn { width: 100%; border: 1px solid color-mix(in srgb, var(--accent-dark, #5c3a99) 24%, var(--border) 76%); border-radius: 14px; background: color-mix(in srgb, var(--accent-dark, #5c3a99) 10%, transparent); color: var(--accent-dark, #5c3a99); min-height: 40px; font-weight: 700; cursor: pointer; }
.chat-peek-pin-btn:active { transform: translateY(1px); }

/* ═══ Media Preview ═══ */
.media-preview-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.88); z-index: 350; flex-direction: column; align-items: center; justify-content: center; }
.media-preview-overlay.show { display: flex; animation: fadeIn 200ms ease; }
.media-preview-content { flex: 1; display: flex; align-items: center; justify-content: center; padding: 20px; max-width: 100%; overflow: hidden; }
.media-preview-content img, .media-preview-content video { max-width: 90vw; max-height: 70vh; object-fit: contain; border-radius: var(--radius-md); }
.media-preview-content.is-mosaic { width: 100%; }
.media-preview-mosaic-wrap { width: min(92vw, 760px); display: flex; flex-direction: column; gap: 14px; }
.media-preview-mosaic { display: grid; gap: 4px; border-radius: 22px; overflow: hidden; background: rgba(255,255,255,0.05); padding: 4px; width: 100%; box-shadow: 0 18px 40px rgba(0,0,0,0.28); }
.media-preview-mosaic-item { position: relative; border: none; padding: 0; margin: 0; background: rgba(255,255,255,0.04); min-height: 120px; cursor: pointer; overflow: hidden; border-radius: 16px; }
.media-preview-mosaic-item img { width: 100%; height: 100%; max-width: none; max-height: none; object-fit: cover; border-radius: 16px; display: block; transition: transform 160ms ease, filter 160ms ease; }
.media-preview-mosaic-item video,
.media-preview-video-placeholder { width: 100%; height: 100%; max-width: none; max-height: none; object-fit: cover; border-radius: 16px; display: block; background: rgba(0,0,0,0.42); }
.media-preview-video-placeholder { background: linear-gradient(135deg, rgba(12,14,24,0.96), rgba(84,74,180,0.48)); }
.media-preview-mosaic-item:hover img { transform: scale(1.03); }
.media-preview-mosaic-item:hover video { transform: scale(1.03); }
.media-preview-mosaic-item.active { box-shadow: inset 0 0 0 3px var(--accent), 0 0 0 1px rgba(255,255,255,0.08); }
.media-preview-mosaic-item.active img { filter: saturate(1.08) contrast(1.02); }
.media-preview-mosaic-video-badge { position: absolute; right: 10px; bottom: 10px; width: 34px; height: 34px; border-radius: 999px; background: rgba(0,0,0,0.56); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 14px; pointer-events: none; box-shadow: 0 8px 20px rgba(0,0,0,0.24); }
.media-preview-mosaic.mosaic-2 { grid-template: 240px / 1fr 1fr; }
.media-preview-mosaic.mosaic-3 { grid-template: 180px 180px / 1.3fr 1fr; }
.media-preview-mosaic.mosaic-3 > :first-child { grid-row: 1 / 3; }
.media-preview-mosaic.mosaic-4 { grid-template: 180px 180px / 1fr 1fr; }
.media-preview-mosaic.mosaic-5 { grid-template: 190px 140px / 1fr 1fr 1fr; }
.media-preview-mosaic.mosaic-5 > :nth-child(1) { grid-column: 1 / 2; }
.media-preview-mosaic.mosaic-5 > :nth-child(2) { grid-column: 2 / 4; }
.media-preview-mosaic.mosaic-6 { grid-template: 150px 150px / 1fr 1fr 1fr; }
.media-preview-mosaic-more { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.46); color: #fff; font-size: 28px; font-weight: 800; backdrop-filter: blur(2px); }
.media-preview-mosaic-hint { color: rgba(255,255,255,0.72); text-align: center; font-size: 13px; line-height: 1.4; }
.media-preview-bar { display: flex; align-items: center; padding: 12px 20px; gap: 12px; width: 100%; max-width: 600px; }
.media-preview-bar input { flex: 1; padding: 10px 16px; border: none; border-radius: 20px; background: rgba(255,255,255,0.12); color: #fff; font-size: var(--font-size-md); outline: none; }
.media-preview-bar input::placeholder { color: rgba(255,255,255,0.4); }
.media-preview-send { width: 48px; height: 48px; border: none; border-radius: var(--radius-full); background: var(--accent); color: var(--text-white); cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; box-shadow: 0 4px 16px var(--accent-glow); }
.media-preview-send:hover { transform: scale(1.05); }
.media-preview-close { position: absolute; top: 16px; left: 20px; width: 44px; height: 44px; background: rgba(255,255,255,0.12); border: none; border-radius: var(--radius-full); color: #fff; font-size: 24px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.media-preview-options { position: absolute; top: 16px; right: 20px; display: flex; gap: 8px; }
.media-quality-btn { padding: 6px 14px; border: 1.5px solid rgba(255,255,255,0.3); border-radius: 16px; background: none; color: rgba(255,255,255,0.7); font-size: var(--font-size-sm); cursor: pointer; }
.media-quality-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.media-quality-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.media-preview-strip { display: flex; gap: 6px; padding: 8px 20px; overflow-x: auto; }
.media-preview-thumb { width: 60px; height: 60px; border-radius: var(--radius-md); overflow: hidden; flex-shrink: 0; cursor: pointer; border: 2px solid transparent; opacity: 0.6; }
.media-preview-thumb.active { border-color: var(--accent); opacity: 1; }
.media-preview-thumb { position: relative; }
.media-preview-thumb img,
.media-preview-thumb video,
.media-preview-thumb .media-preview-video-placeholder { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: inherit; }
.media-preview-thumb .media-preview-mosaic-video-badge { right: 5px; bottom: 5px; width: 24px; height: 24px; font-size: 11px; }
.media-preview-add { width: 60px; height: 60px; border-radius: var(--radius-md); border: 2px dashed rgba(255,255,255,0.3); display: flex; align-items: center; justify-content: center; color: rgba(255,255,255,0.4); font-size: 24px; cursor: pointer; flex-shrink: 0; }

@media (max-width: 768px) {
  .media-preview-content { padding: 76px 14px 12px; }
  .media-preview-mosaic-wrap { width: min(100%, 94vw); gap: 10px; }
  .media-preview-mosaic { border-radius: 18px; padding: 3px; gap: 3px; }
  .media-preview-mosaic-item { min-height: 92px; border-radius: 14px; }
  .media-preview-mosaic-item img { border-radius: 14px; }
  .media-preview-mosaic.mosaic-2 { grid-template: 180px / 1fr 1fr; }
  .media-preview-mosaic.mosaic-3 { grid-template: 132px 132px / 1.2fr 1fr; }
  .media-preview-mosaic.mosaic-4 { grid-template: 132px 132px / 1fr 1fr; }
  .media-preview-mosaic.mosaic-5 { grid-template: 140px 108px / 1fr 1fr 1fr; }
  .media-preview-mosaic.mosaic-6 { grid-template: 108px 108px / 1fr 1fr 1fr; }
  .media-preview-mosaic-more { font-size: 22px; }
  .media-preview-bar { max-width: none; padding: 10px 14px calc(12px + env(safe-area-inset-bottom, 0px)); }
}

/* ═══ Settings ═══ */
.settings-overlay { display: none; position: fixed; inset: 0; z-index: 500; background: var(--bg-modal); align-items: center; justify-content: center; padding: 16px; box-sizing: border-box; }
.settings-overlay.show { display: flex; }
.settings-card { background: var(--bg-primary); border: 1px solid var(--border); border-radius: var(--radius-xl); width: 400px; max-width: 95vw; max-height: calc(100vh - 32px); overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,0.3), var(--neon-glow); animation: slideUp 250ms ease; }
.settings-header { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); flex: 0 0 auto; }
.settings-header h3 { font-size: var(--font-size-lg); font-weight: 700; }
.settings-body { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.settings-toggle { position: relative; width: 44px; height: 24px; flex-shrink: 0; }
.settings-toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: var(--border); border-radius: 12px; cursor: pointer; transition: background 200ms; }
.toggle-slider::before { content: ''; position: absolute; width: 20px; height: 20px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: transform 200ms; }
.settings-toggle input:checked + .toggle-slider { background: var(--accent); box-shadow: 0 0 10px var(--accent-glow); }
.settings-toggle input:checked + .toggle-slider::before { transform: translateX(20px); }
.admin-item .profile-menu-label { color: var(--accent); font-weight: 600; }

/* ═══ Link Preview ═══ */
.link-preview {
  display: block;
  position: relative;
  margin: 8px 0 4px;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.08);
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.04));
  text-decoration: none;
  color: inherit;
  box-shadow: 0 12px 28px rgba(0,0,0,0.18);
  backdrop-filter: blur(12px);
}
.link-preview-accent {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, var(--accent), rgba(255,255,255,0.7));
}
.link-preview-img { width: 100%; max-height: 220px; object-fit: cover; display: block; }
.link-preview-text { padding: 10px 12px 12px 14px; }
.link-preview-site { font-size: 11px; color: var(--accent); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 3px; }
.link-preview-title { font-size: 14px; font-weight: 700; color: var(--text-primary); margin-bottom: 4px; line-height: 1.3; }
.link-preview-desc { font-size: 12px; color: var(--text-secondary); line-height: 1.45; margin-bottom: 6px; }
.link-preview-url { font-size: 11px; color: var(--text-time); overflow-wrap: anywhere; word-break: break-word; }

/* ═══ VC Recording ═══ */
.vc-record-overlay { display: none; position: fixed; inset: 0; z-index: 9998; background: rgba(0,0,0,0.85); flex-direction: column; align-items: center; justify-content: center; gap: 16px; }
.vc-record-overlay.show { display: flex; }
.vc-record-circle { width: 280px; height: 280px; border-radius: 50%; overflow: hidden; position: relative; }
.vc-record-circle video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.vc-record-ring { position: absolute; width: 296px; height: 296px; border-radius: 50%; background: conic-gradient(var(--accent) 0deg, transparent 0deg); display: flex; align-items: center; justify-content: center; top: 50%; left: 50%; transform: translate(-50%, -50%); margin-top: -8px; }
.vc-record-timer { font-size: 18px; color: #fff; font-weight: 600; font-variant-numeric: tabular-nums; }
.vc-record-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: min(360px, calc(100vw - 32px)); }
.vc-record-btn {
  min-width: 120px; height: 48px; border: none; border-radius: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: var(--font-size-md); font-weight: 700; cursor: pointer;
  transition: transform var(--transition-fast), opacity var(--transition-fast), background var(--transition-fast);
}
.vc-record-btn:hover { transform: translateY(-1px); }
.vc-record-btn.is-cancel { background: rgba(255, 84, 104, 0.2); color: #ff8896; border: 1px solid rgba(255, 106, 125, 0.38); }
.vc-record-btn.is-send { background: var(--accent); color: #fff; box-shadow: 0 10px 24px var(--accent-glow); border: 1px solid rgba(255,255,255,0.12); }
.vc-record-btn:active { transform: translateY(0); }

/* ═══ Call Screen ═══ */
.call-overlay { display: none; position: fixed; inset: 0; z-index: 9999; flex-direction: column; height: 100dvh; min-height: 100dvh; overflow: hidden; }
.call-overlay.show { display: flex; }
.call-bg { position: absolute; inset: 0; background: linear-gradient(160deg, #131722 0%, #26324b 38%, #284a57 68%, #172028 100%); z-index: 0; }
.call-content { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 42px 18px 28px; padding: max(42px, env(safe-area-inset-top, 0px)) 18px max(28px, env(safe-area-inset-bottom, 0px)); gap: 10px; }
.call-overlay.incoming .call-bg { background: radial-gradient(circle at 50% 8%, rgba(255,255,255,0.16), transparent 28%), linear-gradient(180deg, #273043 0%, #141923 54%, #090b11 100%); }
.call-overlay.incoming .call-content { justify-content: flex-start; overflow: hidden; padding: max(72px, calc(58px + env(safe-area-inset-top, 0px))) 22px max(34px, calc(24px + env(safe-area-inset-bottom, 0px))); }
.call-overlay.video-active .call-bg { background: #050509; }
.call-overlay.video-active .call-content { justify-content: center; height: var(--app-height, 100dvh); overflow: hidden; padding: 0; gap: 0; }
.call-stage { width: min(96vw, 920px); height: min(58dvh, 560px); display: none; position: relative; border-radius: 22px; overflow: hidden; background: radial-gradient(circle at 50% 30%, rgba(255,255,255,0.12), transparent 42%), #050509; border: 1px solid rgba(255,255,255,0.14); box-shadow: 0 24px 80px rgba(0,0,0,0.32); aspect-ratio: 16 / 9; flex: 0 1 auto; min-height: 160px; }
.call-overlay.video-active .call-stage { display: block; position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; aspect-ratio: auto; border-radius: 0; border: 0; box-shadow: none; background: #050509; }
.call-remote-video { width: 100%; height: 100%; object-fit: cover; background: #050509; opacity: 0; transition: opacity 180ms ease; }
.call-remote-video.has-video { opacity: 1; }
.call-local-video { position: absolute; right: 14px; bottom: 14px; width: clamp(92px, 18vw, 154px); height: clamp(124px, 25vw, 206px); border-radius: 18px; object-fit: cover; background: rgba(0,0,0,0.42); border: 1px solid rgba(255,255,255,0.22); opacity: 0; transition: opacity 180ms ease, transform 180ms ease, width 180ms ease, height 180ms ease; box-shadow: 0 16px 36px rgba(0,0,0,0.34); transform: translateZ(0); pointer-events: auto; touch-action: manipulation; }
.call-local-video.has-video { opacity: 1; }
.call-overlay.video-active .call-local-video { top: calc(14px + env(safe-area-inset-top, 0px)); right: calc(14px + env(safe-area-inset-right, 0px)); bottom: auto; width: clamp(96px, 26vw, 142px); height: clamp(128px, 35vw, 190px); border-radius: 16px; transform: translateZ(0); z-index: 5; }
.call-overlay.video-active .call-local-video.has-video { cursor: zoom-in; }
.call-overlay.video-active.local-video-expanded .call-local-video { width: clamp(152px, 38vw, 240px); height: clamp(204px, 50vw, 320px); cursor: zoom-out; }
.call-overlay.video-active .call-local-video.mirror { transform: scaleX(-1); }
.call-avatar { width: 110px; height: 110px; border-radius: 50%; background: rgba(255,255,255,0.15); display: flex; align-items: center; justify-content: center; font-size: 40px; font-weight: 700; color: #fff; margin-bottom: 12px; overflow: hidden; }
.call-overlay.incoming .call-avatar { width: clamp(116px, 32vw, 154px); height: clamp(116px, 32vw, 154px); margin: 5dvh 0 18px; font-size: clamp(40px, 10vw, 58px); box-shadow: 0 28px 70px rgba(0,0,0,0.36); border: 1px solid rgba(255,255,255,0.18); }
.call-avatar img { width: 100%; height: 100%; object-fit: cover; }
.call-name { font-size: 28px; font-weight: 600; color: #fff; }
.call-overlay.incoming .call-name { width: min(560px, 92vw); text-align: center; font-size: clamp(28px, 7vw, 40px); line-height: 1.08; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.call-status { min-height: 22px; font-size: 15px; color: rgba(255,255,255,0.76); margin-bottom: auto; }
.call-overlay.incoming .call-status { margin: 10px 0 0; color: rgba(255,255,255,0.74); font-size: 16px; font-weight: 600; text-align: center; }
.call-overlay.video-active .call-avatar, .call-overlay.video-active .call-name { display: none; }
.call-overlay.video-active .call-status { position: absolute; top: calc(16px + env(safe-area-inset-top, 0px)); left: calc(16px + env(safe-area-inset-left, 0px)); z-index: 4; margin: 0; padding: 7px 11px; min-height: 0; max-width: calc(100vw - 188px); border-radius: 999px; color: rgba(255,255,255,0.88); background: rgba(0,0,0,0.32); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.call-quality-pill { min-height: 30px; display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 999px; color: rgba(255,255,255,0.92); background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.16); font-size: 13px; font-weight: 700; box-shadow: 0 12px 28px rgba(0,0,0,0.18); }
.call-overlay.video-active .call-quality-pill { position: absolute; top: calc(54px + env(safe-area-inset-top, 0px)); left: calc(16px + env(safe-area-inset-left, 0px)); z-index: 4; max-width: calc(100vw - 188px); background: rgba(0,0,0,0.34); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
.call-quality-pill[hidden] { display: none; }
.call-quality-dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 4px rgba(34,197,94,0.14); flex: 0 0 auto; }
.call-quality-pill.is-fair { background: rgba(245,158,11,0.18); border-color: rgba(245,158,11,0.34); }
.call-quality-pill.is-fair .call-quality-dot { background: #f59e0b; box-shadow: 0 0 0 4px rgba(245,158,11,0.18); }
.call-quality-pill.is-poor, .call-quality-pill.is-critical, .call-quality-pill.is-reconnecting { background: rgba(239,68,68,0.18); border-color: rgba(248,113,113,0.38); }
.call-quality-pill.is-poor .call-quality-dot, .call-quality-pill.is-critical .call-quality-dot, .call-quality-pill.is-reconnecting .call-quality-dot { background: #ef4444; box-shadow: 0 0 0 4px rgba(239,68,68,0.18); }
.call-quality-pill.is-recovered { background: rgba(34,197,94,0.18); border-color: rgba(74,222,128,0.34); }
.call-quality-pill.is-recovered .call-quality-dot { background: #22c55e; box-shadow: 0 0 0 4px rgba(34,197,94,0.14); }
.call-overlay.quality-poor .call-bg, .call-overlay.quality-critical .call-bg, .call-overlay.quality-reconnecting .call-bg { filter: saturate(0.92) brightness(0.92); }
.call-incoming-actions { display: none; gap: 14px; margin: 22px 0 auto; }
.call-overlay.incoming .call-incoming-actions { display: flex; width: min(360px, 86vw); justify-content: space-between; align-items: flex-end; margin: auto 0 0; }
.call-overlay.incoming .call-buttons { display: none; }
.call-answer-btn { border: 0; border-radius: 22px; background: transparent; color: #fff; font-size: 14px; font-weight: 700; padding: 0; min-width: 98px; min-height: 110px; display: inline-flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 10px; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.call-answer-icon { width: 74px; height: 74px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: #fff; box-shadow: 0 18px 42px rgba(0,0,0,0.34); transition: transform 160ms ease, filter 160ms ease; }
.call-answer-btn:active .call-answer-icon { transform: scale(0.94); filter: brightness(0.94); }
.call-answer-btn.accept .call-answer-icon { background: #22c55e; }
.call-answer-btn.decline .call-answer-icon { background: #ef4444; }
.call-answer-btn.decline .call-answer-icon svg { transform: rotate(135deg); }
.call-buttons { display: flex; flex-direction: column; gap: 24px; width: 100%; max-width: 340px; }
.call-overlay.video-active .call-buttons { position: absolute; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 5; width: min(420px, calc(100vw - 28px)); max-width: none; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: end; gap: 10px; transform: translateX(-50%); }
.call-btn-row { display: flex; justify-content: space-around; }
.call-overlay.video-active .call-btn-row { display: contents; }
.call-btn { display: flex; flex-direction: column; align-items: center; gap: 8px; cursor: pointer; }
.call-camera-switch { display: none; }
.call-overlay.video-active .call-camera-switch { display: flex; }
.call-btn.is-loading { opacity: 0.72; pointer-events: none; }
.call-overlay.video-active #call-speaker, .call-overlay.video-active #call-keypad { display: none; }
.call-overlay.video-active .call-btn { min-width: 0; }
.call-btn span { font-size: 12px; color: rgba(255,255,255,0.8); font-weight: 500; }
.call-overlay.video-active .call-btn span { white-space: nowrap; text-shadow: 0 1px 5px rgba(0,0,0,0.55); }
.call-btn-icon { width: 66px; height: 66px; border-radius: 50%; background: rgba(255,255,255,0.12); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border: 1px solid rgba(255,255,255,0.18); display: flex; align-items: center; justify-content: center; transition: background 200ms; }
.call-overlay.video-active .call-btn-icon { margin: 0 auto; background: rgba(0,0,0,0.36); }
.call-btn-icon:hover { background: rgba(255,255,255,0.22); }
.call-btn.active .call-btn-icon { background: rgba(130, 116, 255, 0.48); border-color: rgba(255,255,255,0.32); }
.call-btn.speaker-unsupported .call-btn-icon { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.1); }
.call-btn.end .end-icon { width: 72px; height: 72px; background: #EF4444; border: none; box-shadow: 0 4px 20px rgba(239,68,68,0.5); }
.call-btn.end .end-icon:hover { background: #DC2626; }

@media (max-width: 640px) {
  .call-content {
    padding: max(16px, env(safe-area-inset-top, 0px)) 12px max(12px, env(safe-area-inset-bottom, 0px));
    gap: 6px;
  }
  .call-overlay.incoming .call-content { padding: max(58px, calc(42px + env(safe-area-inset-top, 0px))) 18px max(28px, calc(20px + env(safe-area-inset-bottom, 0px))); }
  .call-overlay.incoming .call-avatar { margin-top: min(8dvh, 62px); margin-bottom: 16px; }
  .call-overlay.incoming .call-incoming-actions { width: min(330px, 88vw); }
  .call-answer-icon { width: 70px; height: 70px; }
  .call-answer-btn { min-width: 92px; min-height: 104px; font-size: 13px; }
  .call-overlay.video-active .call-content { justify-content: center; padding: 0; }
  .call-stage {
    width: min(100%, 420px);
    height: min(38dvh, 290px);
    min-height: 168px;
    border-radius: 18px;
  }
  .call-local-video {
    right: 10px;
    bottom: 10px;
    width: clamp(76px, 23vw, 108px);
    height: clamp(102px, 31vw, 144px);
    border-radius: 14px;
  }
  .call-overlay.video-active.local-video-expanded .call-local-video {
    width: clamp(132px, 44vw, 190px);
    height: clamp(176px, 58vw, 254px);
  }
  .call-avatar { width: 84px; height: 84px; font-size: 30px; margin-bottom: 6px; }
  .call-overlay.video-active .call-avatar { width: 56px; height: 56px; font-size: 20px; margin-bottom: 0; }
  .call-name { font-size: 21px; line-height: 1.2; max-width: 92vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .call-status { min-height: 18px; font-size: 13px; margin-bottom: 4px; }
  .call-overlay.video-active .call-status { margin-bottom: 4px; }
  .call-overlay.video-active .call-status { top: calc(12px + env(safe-area-inset-top, 0px)); left: calc(12px + env(safe-area-inset-left, 0px)); max-width: calc(100vw - 170px); font-size: 12px; }
  .call-overlay.video-active .call-quality-pill { top: calc(48px + env(safe-area-inset-top, 0px)); left: calc(12px + env(safe-area-inset-left, 0px)); max-width: calc(100vw - 170px); }
  .call-quality-pill { min-height: 26px; padding: 5px 9px; font-size: 12px; max-width: 92vw; }
  .call-buttons { gap: 12px; max-width: 300px; flex: 0 0 auto; }
  .call-btn { gap: 5px; }
  .call-btn-icon { width: 54px; height: 54px; }
  .call-btn.end .end-icon { width: 60px; height: 60px; }
  .call-btn span { font-size: 11px; }
}

@media (max-height: 700px) and (max-width: 640px) {
  .call-overlay.incoming .call-avatar { width: 96px; height: 96px; margin-top: 2dvh; font-size: 34px; }
  .call-overlay.incoming .call-name { font-size: 25px; }
  .call-answer-icon { width: 62px; height: 62px; }
  .call-answer-btn { min-height: 88px; }
  .call-stage { height: min(32dvh, 220px); min-height: 138px; }
  .call-overlay.video-active .call-avatar { display: none; }
  .call-buttons { gap: 8px; }
  .call-btn-icon { width: 50px; height: 50px; }
  .call-btn.end .end-icon { width: 56px; height: 56px; }
}

/* ═══ Contacts Panel ═══ */
.contacts-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.contacts-search-row {
  display: flex;
  align-items: center;
  background: var(--search-bg);
  border: 1px solid var(--search-border);
  border-radius: var(--radius-xxl);
  padding: 0 14px;
  height: 40px;
  margin: 8px 12px;
  flex-shrink: 0;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.contacts-search-row:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(168,85,247,0.08);
}
.contacts-search-icon {
  flex-shrink: 0;
  color: var(--icon-color);
  margin-right: 10px;
}
.contacts-search-row input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: var(--font-size-md);
  outline: none;
  min-width: 0;
  padding: 0;
}
.contacts-search-row input::placeholder {
  color: var(--search-placeholder);
}

.contacts-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.15s;
}
.contact-item:hover {
  background: var(--bg-hover);
}
.contact-item:active {
  background: var(--accent-light);
}

.contact-avatar {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent-gradient);
  color: var(--text-white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--font-size-lg);
  flex-shrink: 0;
  overflow: hidden;
}
.contact-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.contact-online-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 12px;
  height: 12px;
  background: var(--online);
  border-radius: 50%;
  border: 2px solid var(--sidebar-bg);
}

.contact-info {
  flex: 1;
  min-width: 0;
}
.contact-name {
  font-weight: 600;
  font-size: var(--font-size-md);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.contact-username {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.contact-status {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.contact-status.online {
  color: var(--online);
}

.contacts-empty {
  text-align: center;
  color: var(--text-secondary);
  padding: 40px 20px;
  font-size: var(--font-size-sm);
}

/* ═══ Chat Filters — Pill style ═══ */
.chat-filters {
  display: flex; padding: 8px 12px; gap: 8px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0; overflow-x: auto; scrollbar-width: none;
}
.chat-filters::-webkit-scrollbar { display: none; }

.filter-pill {
  padding: 8px 20px; border: none;
  background: transparent;
  color: var(--pill-text);
  font-size: 13px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  transition: all 0.2s;
  border-radius: 20px;
}
.filter-pill:hover { background: var(--bg-hover); color: var(--text-primary); }
.filter-pill.active {
  background: var(--pill-active-bg);
  color: var(--pill-active-text);
  box-shadow: 0 2px 8px var(--accent-glow);
}

/* ═══ Tab Bar — Glass with elevated active ═══ */
.tab-bar {
  display: flex;
  border-top: 1px solid rgba(255,255,255,0.06);
  background: var(--tab-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  flex-shrink: 0;
  padding: 0 4px;
}

.tab-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; gap: 3px;
  padding: 10px 0 8px; cursor: pointer;
  color: var(--tab-text);
  font-size: 11px; font-weight: 500;
  transition: all 0.2s; position: relative;
  text-transform: uppercase; letter-spacing: 0.02em;
}
.tab-item:hover { color: var(--text-primary); }
.tab-item.active { color: var(--tab-active); }
.tab-item svg { opacity: 0.4; transition: opacity 0.2s; }
.tab-item.active svg { opacity: 1; }

/* Elevated active tab with glow */
.tab-item.active::before {
  content: ''; position: absolute; top: -1px;
  left: 15%; right: 15%; height: 2px;
  background: var(--accent-gradient);
  border-radius: 0 0 2px 2px;
  box-shadow: 0 2px 10px var(--accent-glow);
}

.tab-avatar { width: 22px; height: 22px; border-radius: 50%; background: var(--accent-gradient); color: #fff; font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; overflow: hidden; border: 1.5px solid var(--border); }
.tab-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.tab-item.active .tab-avatar { border-color: var(--accent); box-shadow: 0 0 8px var(--accent-glow); }

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(168,85,247,0.15); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(168,85,247,0.3); }

/* ═══ Bot ═══ */
.bot-badge { display: inline-block; font-size: 9px; font-weight: 700; letter-spacing: 0.5px; padding: 2px 6px; border-radius: 4px; background: var(--accent-gradient-btn); color: #fff; vertical-align: middle; margin-left: 6px; line-height: 1.4; }
.message.bot-message .bubble { border-left: 3px solid var(--accent); }
.message.bot-message .bubble-text { white-space: pre-line; }
.chat-item.bot-chat .avatar { font-size: 22px; }
#bug-btn { font-size: 16px; }

/* ═══ EMPTY CHAT STATE ═══ */
.chat-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-secondary);
  gap: 8px;
}
.chat-empty-icon {
  opacity: 0.3;
  color: var(--accent);
}
.chat-empty-text {
  font-size: var(--font-size-lg);
  font-weight: 500;
}
.chat-empty-hint {
  font-size: var(--font-size-sm);
  opacity: 0.6;
}
.chat-list-error {
  min-height: 180px;
  padding: 34px 16px;
  text-align: center;
}
.chat-loading-state .chat-empty-icon {
  color: var(--accent);
  opacity: 0.75;
}
.chat-loading-dots {
  display: flex;
  gap: 7px;
  align-items: center;
  justify-content: center;
  min-height: 18px;
}
.chat-loading-dots span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
  animation: chatLoadPulse 1s ease-in-out infinite;
}
.chat-loading-dots span:nth-child(2) { animation-delay: .12s; }
.chat-loading-dots span:nth-child(3) { animation-delay: .24s; }
@keyframes chatLoadPulse {
  0%, 80%, 100% { transform: translateY(0); opacity: .38; }
  40% { transform: translateY(-5px); opacity: 1; }
}
.chat-load-error .chat-empty-icon {
  color: var(--danger, #ef4444);
  opacity: 0.75;
}
.chat-retry-btn {
  margin-top: 8px;
  padding: 10px 18px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--accent-gradient);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.chat-retry-btn:hover {
  filter: brightness(1.08);
}
.message.render-failed .bubble-render-error {
  border: 1px solid rgba(239, 68, 68, 0.24);
  background: var(--bg-primary);
}
.bubble-render-error .chat-empty-hint {
  margin-top: 4px;
  max-width: 260px;
  overflow-wrap: anywhere;
}
.history-page-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 8px 12px;
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
}
.history-page-marker button {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font: inherit;
  cursor: pointer;
}
.history-page-marker.loading span::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 8px;
  border: 2px solid color-mix(in srgb, var(--accent) 28%, transparent);
  border-top-color: var(--accent);
  border-radius: 50%;
  vertical-align: -1px;
  animation: historySpin .8s linear infinite;
}
@keyframes historySpin {
  to { transform: rotate(360deg); }
}

/* ═══ SCROLL TO BOTTOM FAB ═══ */
.scroll-fab {
  position: absolute;
  bottom: 70px;
  right: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transform: scale(0.5);
  pointer-events: none;
  transition: all var(--transition-spring);
  z-index: 10;
  box-shadow: 0 4px 12px var(--shadow);
}
.scroll-fab.visible {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}
.scroll-fab:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ═══ CHARACTER COUNTER ═══ */
.char-count {
  position: absolute;
  bottom: -16px;
  right: 60px;
  font-size: 10px;
  color: var(--text-secondary);
  opacity: 0;
  transition: opacity var(--transition-fast);
  pointer-events: none;
}
.char-count.visible { opacity: 1; }
.char-count.warn { color: var(--danger); }

/* ═══ KEYBOARD HINTS ═══ */
.keyboard-hints {
  text-align: center;
  font-size: 11px;
  color: var(--text-secondary);
  opacity: 0.5;
  padding: 2px 0 0;
  pointer-events: none;
  display: none;
}

/* ═══ TYPING INDICATOR ANIMATION ═══ */
.typing-indicator {
  padding: 4px 12px 4px 80px;
  font-size: var(--font-size-sm);
  color: var(--accent);
  min-height: 22px;
  opacity: 0;
  transition: opacity 200ms ease;
}
.typing-indicator:not(:empty) {
  opacity: 1;
}
.typing-indicator::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 6px;
  animation: typingDot 1.2s ease-in-out infinite;
  vertical-align: middle;
}
.typing-indicator:empty {
  display: none;
  min-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
}
.typing-indicator:empty::before {
  content: none;
  display: none;
}
@keyframes typingDot {
  0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
  30% { opacity: 1; transform: scale(1.1); }
}

#chat-area > .typing-indicator {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--composer-height) + env(safe-area-inset-bottom, 0px));
  z-index: 3;
  pointer-events: none;
  min-height: 0;
}
#chat-area > .typing-indicator:empty {
  display: none !important;
  height: 0 !important;
  min-height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
}
#chat-area > .typing-indicator:empty::before {
  content: none !important;
  display: none !important;
}

/* ═══ RESPONSIVE ═══ */
@media (max-width: 1024px) {
  :root { --sidebar-width: 340px; --messages-max-width: 100%; }
  .messages-inner { padding: 0 10px; }
}

@media (max-width: 768px) {
  :root { --sidebar-width: 100%; --max-bubble-width: 82%; }

  /* Sidebar as overlay */
  #app-screen {
    position: relative;
    overflow: hidden;
  }
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 100%; max-width: 100%; min-width: 0;
    z-index: 100;
    transform: translateX(0);
    transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
  }
  #app-screen.chat-open .sidebar {
    transform: translateX(-100%);
  }
  .chat-area {
    position: fixed;
    inset: 0;
    z-index: 101;
    display: flex !important;
    transform: translateX(100%);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: transform 240ms cubic-bezier(0.22, 1, 0.36, 1), opacity 180ms ease, visibility 240ms ease;
  }
  #app-screen.chat-open .chat-area {
    transform: translateX(0);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  /* Backdrop overlay when sidebar is open on mobile */
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 99;
    opacity: 0;
    transition: opacity var(--transition-normal);
  }
  #app-screen:not(.chat-open) .sidebar-backdrop {
    display: block;
    opacity: 1;
  }

  .messages-inner { padding: 0 6px; }
  .chat-header .back-btn { display: flex; }
  .chat-header { gap: 8px; }
  .chat-header-info { min-width: 0; }
  .chat-header-status { max-width: 100%; }
  .bubble-video-circle { width: 240px; height: 240px; }
  .pinned-message-bar { left: 10px; right: 10px; top: calc(var(--header-height) + env(safe-area-inset-top, 0px) + 2px); padding: 10px 12px; border-radius: 18px; }
  .messages-container.has-pinned { padding-top: 76px; }
  .voice-player-bar { top: calc(var(--header-height) + env(safe-area-inset-top, 0px)); left: 10px; right: 10px; border-radius: 16px; }
  .chat-peek { width: auto; left: 12px !important; right: 12px !important; bottom: calc(84px + env(safe-area-inset-bottom, 0px)) !important; top: auto !important; max-height: min(52vh, 420px); border-radius: 22px; }
  .emoji-picker { width: 100%; left: 0; right: 0; bottom: calc(56px + env(safe-area-inset-bottom, 0px)); border-radius: 20px 20px 0 0; max-height: 52vh; }
  .emoji-picker-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }

  #auth-screen {
    align-items: stretch;
    justify-content: flex-start;
    padding: 0;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    background:
      radial-gradient(ellipse at 50% 8%, rgba(78,112,217,0.24), transparent 36%),
      radial-gradient(ellipse at 10% 34%, rgba(81,99,190,0.12), transparent 30%),
      radial-gradient(ellipse at 92% 62%, rgba(126,94,255,0.10), transparent 34%),
      linear-gradient(180deg, #04070f 0%, #07101d 44%, #05050d 100%);
  }
  .auth-card {
    padding: calc(34px + env(safe-area-inset-top, 0px)) 18px calc(18px + env(safe-area-inset-bottom, 0px));
    width: 100%;
    max-width: 100%;
    border: none;
    border-radius: 0;
    min-height: var(--app-height, 100dvh);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    overflow-y: auto;
    overflow-x: hidden;
    background:
      radial-gradient(ellipse at 50% 13%, rgba(104,132,255,0.20), transparent 32%),
      radial-gradient(ellipse at 50% 47%, rgba(120,91,255,0.13), transparent 36%),
      radial-gradient(ellipse at 18% 64%, rgba(36,171,210,0.07), transparent 34%),
      linear-gradient(180deg, rgba(7,10,20,0.76) 0%, rgba(5,6,13,0.96) 52%, rgba(4,4,10,0.98) 100%);
    box-shadow: none;
  }
  .auth-blob { opacity: 0.34; }
  .auth-logo-wrap { width: 76px; height: 76px; margin-bottom: 10px; }
  .auth-logo-icon { width: 76px; height: 76px; border-radius: 20px; }
  .auth-logo-icon::before { border-radius: 20px; }
  .auth-logo-icon::after { inset: 3px; border-radius: 17px; }
  .auth-logo-glow { inset: -34px; border-radius: 30px; opacity: 1; filter: blur(24px); }
  .auth-logo-text { font-size: 26px; }
  .auth-card .subtitle { margin-bottom: 14px; }
  .auth-input-group {
    height: 50px;
    border-radius: 14px;
    margin-bottom: 10px;
    background: linear-gradient(180deg, rgba(255,255,255,.075), rgba(255,255,255,.025));
    box-shadow:
      inset 0 1px 0 rgba(255,255,255,.075),
      inset 0 -1px 0 rgba(255,255,255,.018),
      0 16px 34px rgba(0,0,0,.24),
      0 0 30px rgba(103,116,255,.055);
  }
  .auth-options { margin-bottom: 12px; }
  .auth-card button#auth-submit, .auth-card button#auth-code-submit { height: 50px; border-radius: 14px; }
  .auth-action-row { grid-template-columns: 1fr auto; gap: 10px; margin-top: 10px; }
  .auth-qr-btn { height: 46px; font-size: 13px; }
  .auth-alt-link { font-size: 12px; min-height: 42px; }
  .auth-terms { margin-top: 8px; line-height: 1.35; }

  .composer { padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px)); gap: 6px; }
  .composer-btn { width: 44px; height: 44px; }
  .composer-input-wrap { min-height: 48px; border-radius: 24px; }
  .composer textarea { padding: 12px 6px 12px 16px; min-height: 48px; font-size: var(--font-size-md); }
  .emoji-btn { width: 40px; height: 48px; }
  .action-btn { width: 48px; height: 48px; }
  .rec-strip { height: 54px; padding: 0 8px calc(env(safe-area-inset-bottom, 0px)); }

  .sidebar-header { padding: 0 10px; height: 52px; gap: 6px; }
  .app-switch-drawer { width: 100%; z-index: 220; }
  .app-switch-backdrop { z-index: 219; }
  .app-switch-header {
    height: calc(52px + env(safe-area-inset-top, 0px));
    min-height: calc(52px + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) 10px 0;
  }
  .app-switch-body { padding: 12px 10px 20px; }
  .app-launch-icon { width: 68px; height: 68px; flex-basis: 68px; }
  .app-mode-head {
    height: calc(58px + env(safe-area-inset-top, 0px));
    min-height: calc(58px + env(safe-area-inset-top, 0px));
    flex-basis: calc(58px + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) 12px 0;
  }
  .app-mode-body { padding: 18px; }
  .app-home-body { padding: 20px 14px; }
  .app-hub-tools { margin-bottom: 16px; gap: 10px; }
  .app-hub-search { height: 42px; padding: 0 12px; }
  .app-hub-search input { font-size: 14px; }
  .app-hub-tabs { gap: 7px; }
  .app-hub-tab { height: 31px; padding: 0 10px; font-size: 12px; }
  .app-hub-section { margin-bottom: 22px; }
  .app-hub-section-head { margin-bottom: 10px; }
  .app-hub-section-head h3 { font-size: 16px; }
  .app-home-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px 10px; }
  .app-home-strip { gap: 10px; padding-bottom: 8px; }
  .app-home-strip .app-home-card { flex-basis: calc((100% - 20px) / 3); }
  .app-home-card { min-height: 156px; border-color: transparent; background: transparent; padding: 6px 2px; }
  .app-home-icon { width: min(86px, 92%); border-radius: 18px; font-size: 22px; }
  .app-home-name { max-width: 100%; min-height: 31px; font-size: 12px; }
  .app-home-meta { max-width: 100%; font-size: 10px; }
  .app-home-desc { display: -webkit-box; font-size: 10px; }
  .sidebar-brand { font-size: 17px; }
  .sidebar-search-row { height: 42px; margin: 8px 10px; border-radius: 22px; padding: 0 14px; }
  .sidebar-search-row input { font-size: var(--font-size-md); }
  .icon-btn { width: 38px; height: 38px; }
  .chat-filters { padding: 6px 10px; gap: 6px; }
  .filter-pill { padding: 7px 18px; font-size: 13px; }

  .chat-item { padding: 12px 12px; gap: 12px; }
  .chat-item .avatar { width: 54px; height: 54px; font-size: 18px; }
  .chat-name { font-size: 16px !important; }
  .chat-preview { font-size: 14px !important; }
  .chat-time { font-size: 13px !important; }

  .tab-bar { padding-bottom: env(safe-area-inset-bottom, 0); }
  .tab-item { padding: 10px 0 8px; font-size: 11px; }
  .tab-item svg { width: 24px; height: 24px; }
  .sidebar-footer { display: none; }

  .bubble-text { font-size: 16px; }
  .bubble-time { font-size: 12px; }
  .date-separator span { font-size: 13px; }
  .composer textarea { font-size: 16px !important; }
  .chat-header-name { font-size: 17px; }
  .chat-header-status { font-size: 14px; }

  .sidebar-footer { padding: 4px 8px; font-size: 9px; }
  .attach-menu { left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); min-width: 0; width: auto; border-radius: 22px; }
  .attach-menu.mobile-popover {
    right: auto !important;
    width: min(292px, calc(100vw - 24px));
    min-width: min(292px, calc(100vw - 24px));
    border-radius: 22px;
    background: color-mix(in srgb, var(--bg-primary) 84%, transparent);
    -webkit-backdrop-filter: blur(24px) saturate(145%);
    backdrop-filter: blur(24px) saturate(145%);
    box-shadow: 0 18px 52px rgba(0,0,0,0.42), inset 0 0 0 1px rgba(255,255,255,0.08);
  }
  .attach-option { padding: 16px 18px; font-size: 16px; }
  .attach-menu.mobile-popover .attach-option {
    min-height: 58px;
    padding: 13px 20px;
    font-size: 18px;
    font-weight: 700;
  }
  .composer-reply { padding: 10px 12px; }
  .modal { width: 100%; max-width: 100%; border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-height: 90dvh; }
  .profile-overlay { align-items: stretch; justify-content: stretch; }
  .profile-card { width: 100%; max-width: 100%; border-radius: 0; max-height: var(--app-height, 100dvh); height: var(--app-height, 100dvh); border: none; }
  .settings-overlay {
    align-items: center;
    justify-content: center;
    padding: calc(14px + env(safe-area-inset-top, 0px)) 12px calc(16px + env(safe-area-inset-bottom, 0px));
  }
  .settings-card {
    width: min(430px, calc(100vw - 24px));
    max-width: calc(100vw - 24px);
    height: auto;
    max-height: calc(var(--app-height, 100dvh) - 30px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    border-radius: 22px;
  }
  .settings-header {
    min-height: 56px;
    padding: 14px 16px;
  }
  .settings-body {
    max-height: calc(var(--app-height, 100dvh) - 86px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    padding-bottom: 6px;
  }

  /* Profile internals: tighter spacing on mobile */
  .profile-top { height: calc(52px + env(safe-area-inset-top, 0px)); padding: env(safe-area-inset-top, 10px) 10px 0; }
  .profile-title { left: 56px; right: 56px; }
  .profile-hero { padding: 16px 18px 18px; align-items: center; }
  .profile-avatar-wrap { margin-left: auto; margin-right: auto; }
  .profile-avatar { width: 96px; height: 96px; font-size: 32px; }
  .profile-name { font-size: 22px; }
  .profile-quick-actions { gap: 12px; padding: 4px 12px 16px; overflow-x: auto; scrollbar-width: none; }
  .profile-quick-actions::-webkit-scrollbar { display: none; }
  .profile-action-btn { min-width: 60px; }
  .profile-action-icon { width: 48px; height: 48px; font-size: 18px; }
  .profile-menu-item { padding: 14px 16px; }
  .profile-body { padding: 16px; }
  .message-discussion-link { padding: 10px 12px; font-size: 14px; }

  .contacts-search-row { margin: 6px 10px; height: 38px; }
  .contact-avatar { width: 44px; height: 44px; font-size: 16px; }
  .contact-item { padding: 8px 12px; }
}

@media (max-width: 380px) {
  .auth-logo-text { font-size: 24px; letter-spacing: 0; }
  .auth-card { padding: calc(14px + env(safe-area-inset-top, 0px)) 14px calc(12px + env(safe-area-inset-bottom, 0px)); background: rgba(8,7,14,0.95); }
  .auth-logo-wrap { width: 64px; height: 64px; margin-bottom: 8px; }
  .auth-logo-icon { width: 64px; height: 64px; border-radius: 18px; }
  .auth-logo-icon::before { border-radius: 18px; }
  .auth-logo-icon::after { border-radius: 15px; }
  .auth-logo-icon svg { width: 42px; height: 42px; }
  .auth-input-group { height: 46px; }
  .auth-card button#auth-submit, .auth-card button#auth-code-submit { height: 46px; font-size: 15px; }
  .auth-qr-btn { min-width: 0; font-size: 12px; }
  .auth-action-row { gap: 8px; }
  .sidebar-brand { font-size: 15px; }
  .sidebar-search-row { height: 38px; padding: 0 10px; }
  .icon-btn { width: 34px; height: 34px; }
  .sidebar-header { gap: 4px; padding: 0 8px; }
  .filter-pill { font-size: 12px; padding: 6px 14px; }
  .chat-item .avatar { width: 48px; height: 48px; font-size: 15px; }
  .chat-item { padding: 10px 10px; gap: 10px; }
  .composer-btn { width: 40px; height: 40px; }
  .composer-input-wrap { min-height: 44px; }
  .composer textarea { min-height: 44px; padding-left: 14px; }
  .emoji-btn { height: 44px; }
  .action-btn { width: 42px; height: 42px; }
  .voice-player-bar { left: 8px; right: 8px; padding: 7px 10px 14px; gap: 8px; }
  .vpb-name { font-size: 12px; }
  .vpb-label, .vpb-time { font-size: 10px; }
  .vpb-speed { padding: 2px 6px; }
}

@media (max-width: 768px) and (max-height: 720px) {
  .auth-card { padding-top: calc(18px + env(safe-area-inset-top, 0px)); justify-content: flex-start; overflow-y: auto; }
  .auth-logo-wrap { width: 58px; height: 58px; margin-bottom: 6px; }
  .auth-logo-icon { width: 58px; height: 58px; border-radius: 16px; }
  .auth-logo-icon svg { width: 38px; height: 38px; }
  .auth-logo-text { font-size: 22px; }
  .auth-card .subtitle { margin-bottom: 10px; font-size: 13px; }
  .auth-input-group { height: 44px; }
  .auth-card button#auth-submit, .auth-card button#auth-code-submit { height: 44px; }
  .auth-options { margin-bottom: 8px; }
  .auth-terms { display: none; }
}

@media (min-width: 769px) {
  .chat-header .back-btn { display: none; }
  .keyboard-hints { display: none !important; }
}

/* Light theme: auth card should not be dark glass */
[data-theme="light"] .auth-card {
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(245,247,250,0.98));
  border: 1px solid rgba(0,0,0,0.08);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,1),
    0 28px 60px rgba(0,0,0,0.1);
}
[data-theme="light"] #auth-screen {
  background:
    radial-gradient(circle at 18% 12%, rgba(141,150,255,0.08), transparent 22%),
    radial-gradient(circle at 84% 18%, rgba(111,124,255,0.06), transparent 26%),
    linear-gradient(180deg, #eef1f5, #f5f7fa 48%, #eef1f5 100%);
}

@supports (padding-top: env(safe-area-inset-top)) {
  .sidebar-header { padding-top: env(safe-area-inset-top); height: calc(var(--header-height) + env(safe-area-inset-top)); }
  .chat-header { padding-top: calc(8px + env(safe-area-inset-top)); height: calc(var(--header-height) + env(safe-area-inset-top)); min-height: calc(var(--header-height) + env(safe-area-inset-top)); }
  #auth-screen { padding-top: env(safe-area-inset-top); }
  @media (max-width: 768px) {
    .sidebar-header { padding-top: env(safe-area-inset-top); height: calc(52px + env(safe-area-inset-top)); }
    .app-switch-header {
      height: calc(52px + env(safe-area-inset-top));
      min-height: calc(52px + env(safe-area-inset-top));
      padding-top: env(safe-area-inset-top);
    }
    .app-mode-head {
      height: calc(58px + env(safe-area-inset-top));
      min-height: calc(58px + env(safe-area-inset-top));
      flex-basis: calc(58px + env(safe-area-inset-top));
      padding-top: env(safe-area-inset-top);
    }
  }
}
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .composer { padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .rec-strip { padding-bottom: env(safe-area-inset-bottom); }
}

@supports (padding-top: constant(safe-area-inset-top)) {
  #auth-screen {
    padding-top: constant(safe-area-inset-top);
  }
  @media (max-width: 768px) {
    .auth-card {
      padding-top: calc(14px + constant(safe-area-inset-top));
      padding-bottom: calc(12px + constant(safe-area-inset-bottom));
    }
    .composer {
      padding-bottom: calc(8px + constant(safe-area-inset-bottom));
    }
    .rec-strip {
      padding-bottom: constant(safe-area-inset-bottom);
    }
    .pinned-message-bar {
      top: calc(var(--header-height) + constant(safe-area-inset-top) + 2px);
    }
    .voice-player-bar {
      top: calc(var(--header-height) + constant(safe-area-inset-top));
    }
    .chat-peek {
      bottom: calc(84px + constant(safe-area-inset-bottom)) !important;
    }
    .emoji-picker {
      bottom: calc(56px + constant(safe-area-inset-bottom));
    }
    .emoji-picker-grid {
      padding-bottom: calc(16px + constant(safe-area-inset-bottom));
    }
    .attach-menu {
      bottom: calc(76px + constant(safe-area-inset-bottom));
    }
    .modal {
      max-height: 90vh;
    }
    .profile-card {
      max-height: 100vh;
      height: 100vh;
    }
    .group-wizard-modal {
      height: 100vh;
    }
    .settings-overlay {
      padding-top: calc(14px + constant(safe-area-inset-top));
      padding-bottom: calc(16px + constant(safe-area-inset-bottom));
    }
    .settings-card {
      max-height: calc(100vh - 30px - constant(safe-area-inset-top) - constant(safe-area-inset-bottom));
    }
    .settings-body {
      max-height: calc(100vh - 86px - constant(safe-area-inset-top) - constant(safe-area-inset-bottom));
    }
    .app-switch-header {
      height: calc(52px + constant(safe-area-inset-top));
      min-height: calc(52px + constant(safe-area-inset-top));
      padding-top: constant(safe-area-inset-top);
    }
    .app-mode-head {
      height: calc(58px + constant(safe-area-inset-top));
      min-height: calc(58px + constant(safe-area-inset-top));
      flex-basis: calc(58px + constant(safe-area-inset-top));
      padding-top: constant(safe-area-inset-top);
    }
  }
}

/* ═══════════════════════ GROUP VISUAL IDENTITY ═══════════════════════ */

/* Group avatar: square-rounded instead of circular */
.group-avatar {
  border-radius: var(--radius-lg) !important;
}
.group-avatar img {
  border-radius: var(--radius-lg);
}

/* Cover background in group profile */
.group-cover-bg {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 180px;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  z-index: 0;
}
.group-cover-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 40%, var(--bg-primary));
}

/* Visibility badge */
.visibility-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-xl);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
}
.visibility-public {
  background: rgba(76, 175, 80, 0.15);
  color: #4caf50;
}
.visibility-private {
  background: rgba(244, 67, 54, 0.15);
  color: #f44336;
}
.visibility-closed {
  background: rgba(255, 152, 0, 0.15);
  color: #ff9800;
}

.group-type-label {
  opacity: 0.6;
  font-size: 12px;
  margin-right: 6px;
}

/* ═══ CREATE GROUP WIZARD ═══ */

/* Wizard steps indicator */
.wizard-steps {
  display: flex;
  justify-content: center;
  gap: 0;
  padding: 12px 16px 8px;
  border-bottom: 1px solid var(--border);
}
.wizard-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 1;
  position: relative;
  opacity: 0.4;
  transition: opacity 0.2s;
}
.wizard-step.active,
.wizard-step.completed {
  opacity: 1;
}
.wizard-step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  transition: all 0.2s;
}
.wizard-step.active .wizard-step-num {
  background: var(--accent-gradient);
  color: #fff;
}
.wizard-step.completed .wizard-step-num {
  background: var(--accent);
  color: #fff;
}
.wizard-step-label {
  font-size: 10px;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* Wizard navigation */
.wizard-nav {
  display: flex;
  justify-content: space-between;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--border);
}
.wizard-nav .btn {
  min-width: 100px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-xl);
  font-size: var(--font-size-md);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.wizard-nav .btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.wizard-nav .btn-ghost:hover {
  background: var(--bg-secondary);
}
.wizard-nav .btn-primary {
  background: var(--accent-gradient);
  color: #fff;
}

/* Visibility selector */
.visibility-selector {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}
.visibility-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-lg);
  border: 2px solid var(--border);
  cursor: pointer;
  transition: all 0.2s;
}
.visibility-option:hover {
  border-color: var(--accent);
  background: rgba(85, 124, 219, 0.05);
}
.visibility-option.active {
  border-color: var(--accent);
  background: rgba(85, 124, 219, 0.1);
}
.visibility-icon {
  font-size: 24px;
  line-height: 1;
}
.visibility-name {
  font-weight: 600;
  font-size: 14px;
}
.visibility-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.3;
}

/* Avatar / Cover upload */
.group-avatar-upload,
.group-cover-upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.avatar-upload-preview,
.cover-upload-preview {
  position: relative;
  overflow: hidden;
}
.avatar-upload-preview {
  width: 96px;
  height: 96px;
  border-radius: var(--radius-lg);
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}
.avatar-placeholder {
  color: var(--text-secondary);
  opacity: 0.5;
}
.avatar-upload-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-lg);
}
.cover-upload-preview {
  width: 100%;
  height: 120px;
  border-radius: var(--radius-lg);
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}
.cover-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  opacity: 0.5;
  font-size: 13px;
}
.cover-upload-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-lg);
}
.upload-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-xl);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}
.upload-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Admin toggle */
.admin-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 14px;
  font-weight: 500;
}
.admin-hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 24px;
  cursor: pointer;
  transition: 0.2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 2px;
  top: 2px;
  background: var(--text-secondary);
  border-radius: 50%;
  transition: 0.2s;
}
.toggle-switch input:checked + .toggle-slider {
  background: var(--accent);
  border-color: var(--accent);
}
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
  background: #fff;
}

/* Member chip with admin badge */
.member-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 4px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  font-size: 13px;
  transition: border-color 0.2s;
}
.member-chip-admin {
  border-color: var(--accent);
  background: rgba(85, 124, 219, 0.1);
}
.admin-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}

/* Member management buttons */
.member-promote-btn,
.member-demote-btn,
.member-remove-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 4px 6px;
  border-radius: 50%;
  transition: background 0.2s;
}
.member-promote-btn:hover { background: rgba(255, 193, 7, 0.15); }
.member-demote-btn:hover { background: rgba(158, 158, 158, 0.15); }
.member-remove-btn:hover { background: rgba(244, 67, 54, 0.15); }

/* Permission presets */
.permission-presets {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.preset-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius-lg);
  border: 2px solid var(--border);
  cursor: pointer;
  transition: all 0.2s;
}
.preset-option:hover {
  border-color: var(--accent);
}
.preset-option.active {
  border-color: var(--accent);
  background: rgba(85, 124, 219, 0.1);
}
.preset-icon {
  font-size: 24px;
  line-height: 1;
}
.preset-name {
  font-weight: 600;
  font-size: 14px;
}
.preset-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.3;
}

/* Group wizard modal: slightly wider */
.group-wizard-modal {
  max-width: 480px;
}

/* ═══ CHANNEL VISUAL IDENTITY ═══ */

/* Channel avatar: rounded square 12px (sharper than group's 16px) */
.channel-avatar {
  border-radius: 12px !important;
}
.channel-avatar img {
  border-radius: 12px;
}

/* Channel icon in chat list name */
.channel-icon {
  font-size: 12px;
  margin-right: 4px;
  opacity: 0.7;
}

/* Channel chat item in chat list: subtle tint */
.chat-item.channel-chat {
  background: rgba(85, 124, 219, 0.03);
}
.chat-item.channel-chat .avatar {
  border-radius: 12px;
}

/* Channel type label in profile */
.channel-type-label {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Channel action bar */
.channel-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  margin-top: 8px;
  border-radius: var(--radius-lg);
}
.channel-action-text {
  font-size: 13px;
  color: var(--text-secondary);
}
.channel-action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: none;
  border-radius: var(--radius-lg);
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}
.channel-action-btn:hover { opacity: 0.85; }
.channel-action-btn.danger {
  background: var(--danger);
}

/* Message views count */
.message-views {
  font-size: 11px;
  color: var(--text-time);
  margin-left: 8px;
  display: flex;
  align-items: center;
  gap: 3px;
}

/* Pinned indicator on channel messages */
.pinned-indicator {
  font-size: 11px;
  color: var(--accent);
  margin-right: 6px;
  font-weight: 600;
}

/* Message discussion link */
.message-discussion-link {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--accent);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.message-discussion-link:hover {
  background: rgba(85, 124, 219, 0.1);
}

/* Channel avatar placeholder in wizard */
.channel-avatar-placeholder {
  border-radius: 12px;
}

/* Request action buttons */
.req-approve-btn,
.req-reject-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  border-radius: 50%;
  transition: background 0.2s;
}
.req-approve-btn:hover { background: rgba(76, 175, 80, 0.15); }
.req-reject-btn:hover { background: rgba(244, 67, 54, 0.15); }

/* Invite action buttons */
.invite-copy-btn,
.invite-revoke-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 4px;
  border-radius: 50%;
  transition: background 0.2s;
}
.invite-copy-btn:hover { background: var(--bg-secondary); }
.invite-revoke-btn:hover { background: rgba(244, 67, 54, 0.1); }

/* ═══ MOBILE: group profile adjustments ═══ */
@media (max-width: 768px) {
  .group-cover-bg { height: 140px; }
  .profile-hero.has-cover {
    padding-top: 110px;
  }
  .wizard-steps { padding: 8px 12px 6px; }
  .wizard-step-label { font-size: 9px; }
  .group-wizard-modal { max-width: 100%; margin: 0; border-radius: 0; height: 100dvh; }
  .channel-action-bar { flex-direction: column; gap: 8px; align-items: flex-start; }
  .channel-action-btn { width: 100%; justify-content: center; }
  .lightbox img,
  .lightbox video { max-width: 100vw; max-height: 84dvh; border-radius: 0; }
  .lightbox-close, .lightbox-download { top: 12px; top: max(12px, env(safe-area-inset-top, 0px)); }
  .lightbox-nav { width: 52px; height: 52px; bottom: 18px; top: auto; transform: none; }
  .lightbox-nav.prev { left: 20px; }
  .lightbox-nav.next { right: 20px; }
  .lightbox-counter { bottom: calc(24px + env(safe-area-inset-bottom, 0)); }
}

/* Inline editor for group/channel settings */
.inline-editor {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 0;
}
.inline-editor input[type="text"],
.inline-editor input[type="url"],
.inline-editor input[type="email"] {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 14px;
}
.inline-editor .editor-title {
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 8px;
}

/* Settings panel */
.settings-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 0;
}
.settings-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-lg);
  cursor: pointer;
  border: 1px solid var(--border);
  transition: background 0.15s;
  font-size: 14px;
  font-weight: 600;
}
.settings-row:hover {
  background: var(--bg-secondary);
}
.settings-row.danger {
  color: var(--danger);
  border-color: rgba(244, 67, 54, 0.3);
}
.settings-row.danger:hover {
  background: rgba(244, 67, 54, 0.08);
}

.channel-settings-shell {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 8px 0 0;
}
.channel-settings-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 4px 8px;
}
.channel-settings-subtitle {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}
.channel-settings-back {
  margin-top: 4px;
}
.channel-search-results {
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--bg-secondary);
}
.channel-search-results .profile-menu-item {
  background: transparent;
}
.channel-search-empty {
  padding: 18px 16px;
  color: var(--text-secondary);
  text-align: center;
}
.profile-form-textarea {
  width: 100%;
  min-height: 110px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  resize: vertical;
  outline: none;
  font-family: inherit;
}
.profile-form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(168,85,247,0.1);
}

/* Mobile: inline editor and settings */
@media (max-width: 768px) {
  .inline-editor { padding: 12px 0; }
  .settings-panel { padding: 12px 0; }
  .settings-row { padding: 14px 12px; }
  .channel-settings-shell { padding-top: 4px; }
  .channel-search-results { max-height: 38dvh; }
  .profile-form-textarea { min-height: 96px; }
}

/* Message menu + preview polish */
.chat-preview-prefix {
  color: color-mix(in srgb, var(--text-primary) 72%, transparent);
  font-weight: 600;
}

.reply-preview .reply-name:empty,
.composer-reply-name:empty,
.chat-peek-author:empty {
  display: none;
}

.context-menu {
  display: none;
  flex-direction: column;
  gap: 10px;
  min-width: 276px;
  max-width: min(320px, calc(100vw - 24px));
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  overflow: visible;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.context-menu.show {
  display: flex;
}

.context-reactions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 0;
  border: 0;
  background: transparent;
}

.context-reactions-pill,
.context-action-list {
  background: rgba(16, 24, 37, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 22px 52px rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.context-reactions-pill {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 999px;
}

.context-reaction-btn,
.context-reaction-more {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 140ms ease, background 140ms ease, opacity 140ms ease;
}

.context-reaction-btn {
  font-size: 24px;
}

.context-reaction-btn:hover,
.context-reaction-more:hover,
.context-reaction-more.expanded {
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-1px);
}

.context-reaction-btn[data-busy="1"] {
  opacity: 0.6;
  pointer-events: none;
}

.context-reaction-more svg,
.ctx-icon svg {
  width: 20px;
  height: 20px;
  display: block;
}

.context-reactions-extra {
  display: none;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  max-width: min(288px, calc(100vw - 24px));
  padding: 8px 10px;
  border-radius: 22px;
  background: rgba(16, 24, 37, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 22px 52px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.context-reactions-extra.show {
  display: inline-flex;
}

.context-action-list {
  display: flex;
  flex-direction: column;
  padding: 10px 8px;
  border-radius: 22px;
  overflow: hidden;
}

.context-item {
  width: 100%;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 11px 16px;
  color: rgba(247, 250, 255, 0.96);
  text-align: left;
  cursor: pointer;
  border-radius: 16px;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 140ms ease, transform 140ms ease, color 140ms ease;
}

.context-item + .context-item {
  margin-top: 2px;
}

.context-item:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-1px);
}

.context-item:active {
  background: rgba(255, 255, 255, 0.12);
  transform: translateY(0);
}

.context-item.danger {
  color: #ff8989;
}

.ctx-icon {
  width: 20px;
  min-width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: rgba(236, 243, 255, 0.92);
  background: transparent;
  border: 0;
  border-radius: 0;
}

.context-item.danger .ctx-icon {
  color: currentColor;
  background: transparent;
  border-color: transparent;
}

.context-item[data-key="pin"] .ctx-icon,
.context-item[data-key="unpin"] .ctx-icon {
  color: rgba(255, 219, 120, 0.98);
  background: transparent;
  border-color: transparent;
}

.ctx-label {
  flex: 1;
  font-size: 15px;
  line-height: 1.2;
  font-weight: 520;
  letter-spacing: -0.01em;
}

@supports not (color: color-mix(in srgb, #000 50%, #fff 50%)) {
  .voice-player-bar,
  .selection-toolbar,
  .attach-menu,
  .emoji-picker {
    background: var(--bg-primary);
  }

  .vpb-seek {
    background: var(--border);
  }

  .vpb-seek-fill {
    background: var(--accent);
  }

  .chat-item.previewing {
    background: var(--sidebar-item-active-bg);
  }

  .chat-area.drag-over::after {
    border-color: var(--accent);
    background: var(--bg-primary);
  }

  .pinned-message-bar,
  .chat-peek {
    background: var(--bg-elevated);
    border-color: var(--border);
  }

  .pinned-message-strip {
    background: var(--accent-dark, #5c3a99);
  }

  .bubble-pending.progress,
  .voice-state.pending,
  .bubble-video-circle .vc-status.pending {
    color: var(--accent);
  }

  .reaction,
  .emoji-picker-search input,
  .chat-peek-row,
  .app-card,
  .attach-menu.mobile-popover {
    background: var(--bg-secondary);
  }

  .reaction.mine {
    background: var(--accent-light);
  }

  .composer.has-text .composer-input-wrap {
    border-color: var(--composer-input-focus);
  }

  .composer.is-readonly .composer-input-wrap,
  .composer-reply {
    background: var(--bg-header);
  }

  .profile-card {
    background: var(--bg-primary);
  }
}
/* CSP-safe initial layout utilities */
.is-initial-hidden {
  display: none;
}

.is-initial-flex {
  display: flex;
}

.sidebar-footer-accent {
  color: var(--accent);
}

.selected-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  min-height: 0;
}

.modal-primary-wide {
  width: 100%;
  margin-top: 12px;
  padding: 12px;
  border: none;
  border-radius: var(--radius-xl);
  background: var(--accent-gradient);
  color: #fff;
  font-weight: 700;
  font-size: var(--font-size-md);
  cursor: pointer;
}

.wizard-note {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.wizard-note-compact {
  margin-bottom: 8px;
}

.channel-link-section {
  margin-top: 16px;
}

.channel-link-results {
  max-height: 150px;
  overflow-y: auto;
  margin-top: 8px;
}

.channel-linked-group {
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
}

.compact-ghost-btn {
  padding: 4px 8px;
  font-size: 12px;
}
