:root {
  color-scheme: dark;
  --bg: #0e1621;
  --bg-alt: #111a24;
  --panel: #17212b;
  --panel-2: #1f2c3a;
  --panel-3: #243447;
  --text: #e7eef6;
  --muted: #8a9bb0;
  --muted-2: #5c6e81;
  --accent: #2ea6ff;
  --accent-2: #4fbeff;
  --danger: #ff6464;
  --bubble-me: #2b5278;
  --bubble-them: #1f2c3a;
  --border: rgba(255, 255, 255, 0.08);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  --radius: 12px;
  --radius-sm: 10px;
  --ease: 180ms ease;

  /* Native Inset Overrides for HyperOS/Xiaomi */
  --st: max(env(safe-area-inset-top, 0px), var(--native-safe-top, 0px));
  --sb: max(env(safe-area-inset-bottom, 0px), var(--native-safe-bottom, 0px));
  --sl: max(env(safe-area-inset-left, 0px), var(--native-safe-left, 0px));
  --sr: max(env(safe-area-inset-right, 0px), var(--native-safe-right, 0px));
  
  /* Layout Constants */
  --header-height: 64px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  max-width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at top left, rgba(46, 166, 255, 0.08), transparent 25%),
    linear-gradient(180deg, #101923 0%, #0b1118 100%);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}

body {
  overflow: hidden;
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: 100%;
  height: 100%;
  overscroll-behavior: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

input,
textarea {
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px; /* MD3 slightly rounded */
  outline: none;
}

input:focus,
textarea:focus {
  border-color: rgba(46, 166, 255, 0.75);
  box-shadow: 0 0 0 2px rgba(46, 166, 255, 0.18);
}

#app {
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  max-width: 100vw;
}

.auth {
  min-height: 100%;
  display: grid;
  grid-template-columns: minmax(300px, 420px) 1fr;
  overflow: hidden;
}

.auth__panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 22px;
  padding: 
    calc(40px + var(--st)) 
    calc(40px + var(--sr)) 
    40px 
    calc(40px + var(--sl));
  background: linear-gradient(180deg, var(--panel-2), rgba(15, 23, 33, 0.98));
  border-right: 1px solid var(--border);
}

.auth__art {
  position: relative;
  background:
    linear-gradient(145deg, rgba(46, 166, 255, 0.16), transparent 52%),
    linear-gradient(180deg, #182433 0%, #0d141d 100%);
}

.auth__brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(180deg, #3bb3ff, #1d93f3);
  box-shadow: 0 12px 30px rgba(29, 147, 243, 0.38);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.brand-mark svg {
  width: 24px;
  height: 24px;
  fill: white;
}

.auth__title {
  margin: 0;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.05;
  max-width: 12ch;
}

.auth__subtitle {
  margin: 0;
  max-width: 42ch;
  color: var(--muted);
  line-height: 1.55;
}

.auth-card {
  width: min(100%, 420px);
  padding: 22px;
  border-radius: 24px; /* MD3 large card */
  background: var(--panel-2);
  border: 1px solid var(--border);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3); /* MD3 Elevation */
  
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}

.tab {
  flex: 1;
  border: 0;
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--muted);
  padding: 12px 14px;
  transition: background var(--ease), color var(--ease), transform var(--ease);
  min-height: 48px;
}

.tab.is-active {
  background: rgba(46, 166, 255, 0.18);
  color: var(--text);
}

.auth-form {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 8px;
}

.field label {
  font-size: 0.8125rem;
  color: var(--muted);
}

.field input,
.field textarea {
  width: 100%;
  padding: 12px 14px;
}

.auth-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 6px;
}

.primary,
.secondary,
.ghost,
.icon-button {
  border: 0;
  border-radius: 999px;
  transition: transform var(--ease), background var(--ease), color var(--ease), opacity var(--ease);
}

.primary {
  background: linear-gradient(180deg, #2ea6ff, #2495ea);
  color: white;
  padding: 12px 16px;
  font-weight: 600;
  box-shadow: 0 10px 22px rgba(36, 149, 234, 0.28);
}

.secondary {
  background: var(--panel-2);
  color: var(--text);
  padding: 11px 14px;
}

.ghost {
  background: transparent;
  color: var(--muted);
  padding: 10px 12px;
}

.icon-button {
  width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--panel-2);
  color: var(--text);
}

.sidebar__new-chat {
  width: 48px;
  height: 48px;
  flex: none;
}

.icon-button svg {
  width: 20px;
  height: 20px;
  display: block;
}

.icon-button svg:not([fill="none"]) {
  fill: currentColor;
}

.icon-button svg[fill="none"] {
  fill: none !important;
  stroke: currentColor;
}

.icon-button#hangup-btn svg {
  fill: none !important;
  stroke: currentColor;
  stroke-width: 2.15;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.primary:hover,
.secondary:hover,
.ghost:hover,
.icon-button:hover,
.tab:hover {
  transform: translateY(-1px);
}

.primary:active,
.secondary:active,
.ghost:active,
.icon-button:active,
.tab:active {
  transform: translateY(0);
}

.error {
  min-height: 20px;
  color: #ff9a9a;
  font-size: 0.8125rem;
}

.shell {
  width: 100%;
  max-width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: 340px 1fr;
  background: rgba(11, 17, 24, 0.5);
  overflow: hidden;
}

.sidebar {
  background: linear-gradient(180deg, var(--panel-2), rgba(17, 26, 36, 0.98));
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  position: relative;
}

.sidebar__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 
    calc(18px + var(--st)) 
    calc(16px + var(--sr)) 
    12px 
    calc(16px + var(--sl));
}

.sidebar__title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.sidebar__user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sidebar__user-info strong {
  font-size: 0.9375rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

.sidebar__user-info span {
  font-size: 0.6875rem;
  color: #2ecc71; /* Green color for 'Logged in' status */
  font-weight: 500;
}

.sidebar__search {
  padding: 8px 12px;
}

.sidebar__search input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 8px;
}

.sidebar__chat-container {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.search-results,
.thread-list {
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  min-height: 0;
  padding: 4px 8px 76px 8px;
}

.section-label {
  padding: 10px 8px 6px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.search-empty {
  padding: 24px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 0.875rem;
}

.thread-item,
.user-item {
  width: 100%;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 6px;
  background: transparent;
  border: 0;
  color: var(--text);
  border-radius: 8px;
  transition: background var(--ease);
  min-height: 48px;
}

.thread-item:hover,
.user-item:hover,
.thread-item.is-active {
  background: rgba(255, 255, 255, 0.05);
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: white;
  font-weight: 700;
  flex: none;
  overflow: hidden;
  position: relative;
}

.status-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 11px;
  height: 11px;
  background: #2ecc71;
  border: 2px solid var(--bg);
  border-radius: 50%;
  z-index: 5;
  box-shadow: 0 0 4px rgba(46, 204, 113, 0.4);
}

.status-online {
  color: #2ecc71 !important;
}

.avatar--sm .status-dot {
  width: 10px;
  height: 10px;
  bottom: 0;
  right: 0;
}

.avatar--sm {
  width: 38px;
  height: 38px;
  font-size: 0.8125rem;
  box-shadow: 0 0 0 2px rgba(46, 166, 255, 0.18);
  flex: none;
}

.avatar--button {
  border: 0;
  padding: 0;
  background: inherit;
  cursor: pointer;
  position: relative;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
  transition: transform var(--ease), box-shadow var(--ease);
}

.avatar--button:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 0 1px rgba(46, 166, 255, 0.25);
}

.avatar--editable {
  isolation: isolate;
}

.avatar__edit {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(10, 20, 31, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #f5f9ff;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}

.avatar__edit svg {
  width: 10px;
  height: 10px;
  stroke: currentColor;
  fill: none;
}

.avatar__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thread-item__meta,
.user-item__meta {
  min-width: 0;
  display: grid;
  gap: 3px;
  flex: 1;
}

.thread-item__title,
.user-item__title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thread-item__preview,
.user-item__preview {
  color: var(--muted);
  font-size: 0.8125rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thread-item__time {
  color: var(--muted-2);
  font-size: 0.75rem;
}

.main {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
  min-height: 0;
  height: 100%;
  position: relative;
  overflow: hidden;
  width: 100%;
  max-width: 100vw;
  background: linear-gradient(rgba(14, 22, 33, 0.92), rgba(14, 22, 33, 0.92)), url('background.jpg');
  background-size: cover;
  background-position: center;
}

.chat-header {
  min-height: calc(var(--header-height) + var(--st));
  max-height: calc(var(--header-height) + var(--st));
  overflow: visible;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 
    calc(6px + var(--st)) 
    calc(12px + var(--sr)) 
    6px 
    calc(12px + var(--sl));
  background: #111a24; /* Solid background to cover safe area grid leak */
  border-bottom: 1px solid var(--border);
  z-index: 100;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

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

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

.chat-header__title-row strong {
  display: block;
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.chat-header__title span {
  font-size: 0.6875rem;
  color: var(--muted);
  margin-left: 2px;
}

.chat-header__title span {
  color: var(--muted);
  font-size: 0.75rem;
}

.chat-header__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.status-pill {
  padding: 4px 10px;
  background: var(--panel-3);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  max-width: 140px;
  transition: all 0.2s ease;
  overflow: hidden;
  text-overflow: ellipsis;
}

.permission-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 999px;
  border: 0;
  font-size: 0.8125rem;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
  min-height: 48px;
}

/* Mobile refinements */
@media (max-width: 480px) {
  .permission-btn__label,
  .status-pill span:not(#call-timer-header) {
    display: none;
  }
  
  .permission-btn, .status-pill {
    padding: 8px;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .chat-header__title span {
    display: none; /* Hide 'Online/Offline' text to save vertical space */
  }

  .chat-header {
    gap: 6px;
    padding-left: 8px;
    padding-right: 8px;
  }
}

@keyframes telegramCallGradient {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.call-viewport {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  display: none;
  background: linear-gradient(135deg, #1e70a6, #2a4b8d, #1a2a4b, #228b9c);
  background-size: 300% 300%;
  animation: telegramCallGradient 12s ease infinite;
  overflow: hidden;
  padding: 
    var(--st) 
    var(--sr) 
    var(--sb) 
    var(--sl);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.call-viewport.is-visible {
  display: block;
}

.call-viewport--minimized {
  top: auto;
  left: auto;
  right: 20px;
  bottom: 80px;
  width: var(--min-w, 220px);
  height: var(--min-h, 160px);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  border: 2px solid var(--accent);
  cursor: move;
  min-width: 160px;
  min-height: 120px;
  padding: 0;
}

.resize-handle {
  position: absolute;
  top: -5px;
  left: -5px;
  width: 20px;
  height: 20px;
  cursor: nwse-resize;
  z-index: 100;
}

.call-viewport:not(.call-viewport--minimized) .resize-handle {
  display: none;
}

.call-viewport--minimized .call-window--primary {
  border-radius: 0;
}

.call-viewport--minimized .call-window--secondary {
  display: none;
}

.call-window {
  position: absolute;
  overflow: hidden;
  background: transparent;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
}

.call-window video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: transparent;
}

.call-window--primary {
  inset: 0;
  z-index: 1;
}

.call-window--secondary {
  top: calc(20px + var(--st));
  right: calc(20px + var(--sr));
  width: 150px;
  height: 200px;
  z-index: 2;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  border: 2px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  background: transparent;
  overflow: hidden;
}

.call-window--secondary:hover {
  transform: scale(1.02);
}

.call-window__label {
  position: absolute;
  bottom: 10px;
  left: 10px;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  font-size: 0.6875rem;
  pointer-events: none;
}

.call-controls {
  position: absolute;
  bottom: calc(30px + var(--sb));
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  gap: 16px;
  padding: 12px 20px;
  border-radius: 24px;
  background: rgba(23, 33, 43, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.call-viewport:hover .call-controls,
.call-viewport:hover .call-viewport__top-actions {
  opacity: 1;
  pointer-events: auto;
}

.call-viewport--minimized .call-controls {
  bottom: 10px;
  padding: 6px 10px;
  gap: 8px;
  transform: translateX(-50%) scale(0.8);
  opacity: 0;
  pointer-events: none;
}

.call-viewport--minimized:hover .call-controls {
  opacity: 1;
}

.call-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 0;
  display: grid;
  place-items: center;
  color: white;
  background: rgba(255, 255, 255, 0.1);
  cursor: pointer;
  transition: all 0.2s;
}

.call-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.call-btn:active {
  transform: translateY(0);
}

.call-btn--danger {
  background: #ff3b30;
  box-shadow: 0 8px 20px rgba(255, 59, 48, 0.3);
}

.call-btn--danger:hover {
  background: #ff453a;
}

.call-btn--active {
  background: var(--accent);
  box-shadow: 0 8px 20px rgba(46, 166, 255, 0.3);
}

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

.call-viewport__top-actions {
  position: absolute;
  top: calc(20px + var(--st));
  left: calc(20px + var(--sl));
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.call-viewport--minimized .call-viewport__top-actions {
  display: flex;
  top: 10px;
  left: 10px;
  transform: scale(0.8);
  transform-origin: top left;
}

.call-banner {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  z-index: 20;
  background: rgba(14, 22, 33, 0.98);
  
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 30px;
  padding-top: var(--st);
  padding-bottom: var(--sb);
  padding-left: var(--sl);
  padding-right: var(--sr);
}

.call-banner[hidden] {
  display: none !important;
}

.call-banner__avatar {
  position: relative;
  display: grid;
  place-items: center;
}

.avatar--xl {
  width: 120px;
  height: 120px;
  font-size: 2.5rem;
  box-shadow: none;
  z-index: 2;
}

.call-banner__pulse {
  position: absolute;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(46, 166, 255, 0.2);
  z-index: 1;
  animation: pulse 2s infinite ease-out;
}

.call-banner__pulse--2 {
  animation-delay: 1s;
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(2.5); opacity: 0; }
}

.call-banner__info {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2;
}

.call-banner__info strong {
  font-size: 1.75rem;
  font-weight: 600;
  color: #fff;
}

.call-banner__info span {
  font-size: 1rem;
  color: var(--muted);
}

.call-banner__actions {
  display: flex;
  gap: 60px;
  margin-top: 40px;
  z-index: 2;
}

.action-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 0;
  display: grid;
  place-items: center;
  color: #fff;
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.2s;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

.action-btn:hover {
  transform: scale(1.05);
}

.action-btn:active {
  transform: scale(0.95);
}

.action-btn svg {
  width: 32px;
  height: 32px;
}

.action-btn--decline {
  background: #ff595a;
}

.action-btn--accept {
  background: #34c759;
  animation: bounce 2s infinite ease-in-out;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.action-btn--accept:hover {
  animation: none;
  transform: scale(1.05);
}

.messages {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px calc(8px + var(--sr)) 16px calc(16px + var(--sl));
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(56, 177, 255, 0.88) rgba(255, 255, 255, 0.08);
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
}

.messages::-webkit-scrollbar {
  width: 12px;
}

.messages::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 999px;
}

.messages::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(58, 179, 255, 0.96), rgba(30, 145, 232, 0.96));
  border-radius: 999px;
  border: 2px solid rgba(15, 23, 33, 0.94);
  min-height: 44px;
}

.messages::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(72, 188, 255, 1), rgba(35, 155, 245, 1));
}

.messages__empty {
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  padding: 40px;
}

.message {
  max-width: 84%;
  padding: 10px 14px;
  border-radius: 18px;
  background: var(--bubble-them);
  border: 1px solid rgba(255, 255, 255, 0.04);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  overflow-wrap: anywhere;
  word-break: break-word;
  position: relative;
  display: flex;
  flex-direction: column;
}

.message.is-me {
  align-self: flex-end;
  background: var(--bubble-me);
}

.message__body {
  white-space: pre-wrap;
  line-height: 1.45;
  word-break: break-word;
}

.message__meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.6875rem;
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
  padding: 
    10px 
    calc(16px + var(--sr)) 
    calc(var(--sb) + 12px) 
    calc(16px + var(--sl));
  min-height: calc(var(--sb) + 60px);
  background: var(--panel);
  border-top: 1px solid var(--border);
}

.composer input {
  resize: none;
  height: 46px;
  padding: 13px 14px;
  line-height: 1.25;
  border-radius: 23px;
}

.composer input::placeholder {
  color: var(--muted-2);
}

.composer__actions {
  display: flex;
  gap: 10px;
  align-items: end;
}

.composer-tool {
  width: 48px;
  height: 48px;
  border-radius: 14px;
}

.composer-tool svg {
  width: 22px;
  height: 22px;
}

.composer-tool svg[fill="none"] {
  fill: none !important;
  stroke: currentColor;
}

.send-button {
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(180deg, #2ea6ff, #1f93eb);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 22px rgba(36, 149, 234, 0.28);
}

.send-button svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
  transform: translateX(1px);
}

.send-button:hover {
  transform: translateY(-1px);
}

.send-button:active {
  transform: translateY(0);
}

.emoji-picker {
  display: none;
  position: absolute;
  right: 12px;
  bottom: 76px;
  width: min(360px, calc(100% - 24px));
  padding: 8px;
  border-radius: 14px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.emoji-picker.is-open {
  display: block;
}

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

.emoji-chip {
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: white;
  width: 100%;
  padding: 4px 0;
  line-height: 1;
  display: grid;
  place-items: center;
  font-size: 1.375rem;
}

.emoji-chip:hover {
  background: rgba(255, 255, 255, 0.09);
}

.picker-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-bottom: 8px;
}

.picker-tabs {
  display: inline-flex;
  gap: 6px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.picker-tab {
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  padding: 7px 12px;
  font-size: 0.75rem;
}

.picker-tab.is-active {
  background: rgba(46, 166, 255, 0.18);
  color: var(--text);
}

.picker-body {
  overflow: hidden;
}

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

.gif-chip {
  border: 0;
  padding: 6px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  display: grid;
  gap: 6px;
  text-align: left;
}

.gif-chip img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 10px;
}

.gif-chip span {
  font-size: 0.6875rem;
  color: var(--muted);
  text-align: center;
}

.gif-chip:hover {
  background: rgba(255, 255, 255, 0.08);
}

.message__media {
  display: grid;
  gap: 8px;
}

.message__gif {
  display: block;
  max-width: 100%;
  width: auto;
  height: auto;
  border-radius: 12px;
}

.message__caption {
  white-space: pre-wrap;
  line-height: 1.45;
  word-break: break-word;
}

.status-pill {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-size: 0.75rem;
}

.status-pill--active-call {
  background: rgba(52, 199, 89, 0.15);
  color: #34c759;
  font-weight: 600;
  border: 1px solid rgba(52, 199, 89, 0.3);
}

.active-call-view {
  display: flex;
  flex: 1;
  width: 100%;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.active-call-view[hidden] {
  display: none !important;
}

.audio-call-ui {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.audio-call-ui__avatar {
  position: relative;
  display: grid;
  place-items: center;
}

.avatar--xxl {
  width: 160px;
  height: 160px;
  font-size: 3.75rem;
  box-shadow: 0 16px 32px rgba(0,0,0,0.3);
  z-index: 2;
}

.audio-call-ui__wave {
  position: absolute;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: rgba(46, 166, 255, 0.15);
  z-index: 1;
  animation: audioWave 2s infinite ease-out;
}

.audio-call-ui__wave--2 {
  animation-delay: 1s;
}

@keyframes audioWave {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(1.8); opacity: 0; }
}

.audio-call-ui__info {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.audio-call-ui__info strong {
  font-size: 1.5rem;
  color: #fff;
}

.audio-call-ui__info span {
  font-size: 1rem;
  color: #34c759;
  font-weight: 500;
}

.icon-button.is-muted {
  background: #ff595a;
  color: #fff;
}

.mobile-only {
  display: none;
}

@media (max-width: 980px) {
  :root {
    --st: max(env(safe-area-inset-top, 32px), var(--native-safe-top, 32px));
    --sb: max(env(safe-area-inset-bottom, 16px), var(--native-safe-bottom, 16px));
  }

  .auth {
    grid-template-columns: 1fr;
  }

  .auth__art {
    display: none;
  }

  .shell {
    grid-template-columns: 1fr;
    position: relative;
  }

  .sidebar {
    position: absolute;
    inset: 0 auto 0 0;
    width: min(88vw, 340px);
    transform: translateX(-100%);
    transition: transform 220ms ease;
    z-index: 20;
    box-shadow: 24px 0 40px rgba(0, 0, 0, 0.35);
    padding-bottom: var(--sb);
    padding-left: var(--sl);
    padding-top: var(--st);
  }

  .shell.is-sidebar-open .sidebar {
    transform: translateX(0);
  }

  .mobile-only {
    display: inline-flex;
  }

  .video-grid {
    grid-template-columns: 1fr;
  }

  .video-box--local {
    min-height: 130px;
  }

  .message {
    max-width: 92%;
  }

  .emoji-picker__grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .gif-picker__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .emoji-picker {
    left: calc(12px + var(--sl));
    right: calc(12px + var(--sr));
    width: auto;
    bottom: calc(70px + var(--sb));
  }
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #2ecc71;
  position: absolute;
  bottom: -1px;
  right: -1px;
  box-shadow: 0 0 4px rgba(46, 204, 113, 0.6);
}

.status-online {
  color: #2ecc71;
}

.avatar {
  position: relative;
}

/* Avatar Viewer Modal */
.avatar-viewer {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  padding: 20px;
}

.avatar-viewer.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.avatar-viewer__content {
  position: relative;
  max-width: min(100%, 500px);
  max-height: 80vh;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5);
  transform: scale(0.9);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.avatar-viewer.is-visible .avatar-viewer__content {
  transform: scale(1);
}

.avatar-viewer__img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.avatar-viewer__close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 0;
  color: white;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.2s;
}

.avatar-viewer__close:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Sidebar Mask for Mobile */
.sidebar-mask {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  
  z-index: 15;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

@media (max-width: 980px) {
  .sidebar-mask {
    display: block;
  }
  .shell.is-sidebar-open .sidebar-mask {
    opacity: 1;
    pointer-events: auto;
  }
}


/* Fluid Responsive Overrides (300px to 480px) */
@media (max-width: 480px) {
  #app, .shell, .main {
    width: 100vw;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .auth__panel {
    padding: calc(20px + var(--st)) clamp(15px, 5vw, 40px) 20px clamp(15px, 5vw, 40px);
  }

  .auth__title {
    font-size: clamp(24px, 8vw, 32px);
  }

  .chat-header {
    padding: 
      calc(8px + var(--st)) 
      max(clamp(6px, 2vw, 12px), var(--sr)) 
      8px 
      max(clamp(6px, 2vw, 12px), var(--sl));
    gap: clamp(4px, 1.5vw, 10px);
  }

  .chat-header .icon-button, .chat-header .permission-btn {
    width: clamp(34px, 10vw, 42px);
    height: clamp(34px, 10vw, 42px);
    padding: clamp(6px, 1.5vw, 10px);
    min-height: 48px;
}

  .chat-header__title-row strong {
    font-size: clamp(14px, 4vw, 17px);
  }

  .status-pill {
    padding: 4px clamp(6px, 2vw, 10px);
    font-size: clamp(10px, 3vw, 12px);
    max-width: clamp(70px, 25vw, 120px);
  }

  .composer {
    display: flex;
    align-items: flex-end;
    padding: 
      8px 
      max(clamp(6px, 2vw, 12px), var(--sr)) 
      max(12px, calc(var(--sb) + 8px)) 
      max(clamp(6px, 2vw, 12px), var(--sl));
    gap: clamp(4px, 2vw, 10px);
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
    min-width: 0;
  }

  .composer__actions {
    display: flex;
    gap: clamp(4px, 1.5vw, 10px);
    flex-shrink: 0;
  }

  .composer input {
    flex: 1;
    min-width: 0;
    padding: 10px clamp(10px, 3vw, 14px);
    font-size: clamp(14px, 4vw, 16px);
    height: clamp(38px, 10vw, 46px);
  }

  .send-button, .composer-tool {
    width: clamp(38px, 10vw, 46px);
    height: clamp(38px, 10vw, 46px);
    border-radius: clamp(10px, 3vw, 14px);
    flex-shrink: 0;
  }

  .message {
    max-width: clamp(85%, 95vw, 95%);
    padding: 8px clamp(10px, 3vw, 14px);
    font-size: clamp(14px, 4vw, 15px);
  }

  /* Call UI fluid scaling */
  .call-banner__info strong {
    font-size: clamp(18px, 6vw, 24px);
  }
  .avatar--xl {
    width: clamp(80px, 25vw, 110px);
    height: clamp(80px, 25vw, 110px);
  }

  /* Ultra-narrow screen optimizations (<= 330px) */
  @media (max-width: 330px) {
    .chat-header {
      padding-left: 4px;
      padding-right: 4px;
      gap: 2px;
    }

    .status-pill {
      display: none; /* Hide status pill to save space for title and buttons */
    }

    .chat-header__title-row strong {
      max-width: 120px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .composer {
      padding-left: 4px;
      padding-right: 4px;
      gap: 4px;
    }


    .composer-tool#emoji-toggle-btn {
      display: flex; /* Restore emoji button */
    }

    .composer input {
      padding: 10px 8px;
      height: 36px;
    }

    .send-button, .composer-tool {
      width: 36px;
      height: 36px;
      border-radius: 10px;
    }
  }
}

/* Call Log and System Messages */
.message-system {
  display: flex;
  justify-content: center;
  margin: 16px 0;
  width: 100%;
}

.message-system__body {
  background: rgba(18, 27, 37, 0.6);
  
  padding: 6px 14px;
  border-radius: 12px;
  font-size: 0.8125rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.call-log-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  color: var(--accent);
}

.call-log-icon svg {
  width: 14px;
  height: 14px;
}

/* ─── Photo Messages ─────────────────────────────────────────────────── */

.message__photo {
  display: block;
  max-width: 280px;
  max-height: 360px;
  width: 100%;
  height: auto;
  border-radius: 12px;
  object-fit: cover;
  cursor: zoom-in;
  transition: opacity 0.18s ease, transform 0.18s ease;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
}

.message__photo:hover {
  opacity: 0.92;
  transform: scale(1.015);
}

.message__media {
  padding: 0;
  line-height: 0;
}

/* ─── Lightbox ───────────────────────────────────────────────────────── */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(4, 8, 14, 0.96);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  gap: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.lightbox.is-visible {
  opacity: 1;
  pointer-events: all;
}

.lightbox__img {
  max-width: 100%;
  max-height: calc(100vh - 140px);
  border-radius: 14px;
  object-fit: contain;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
  animation: lightbox-in 0.22s ease;
}

@keyframes lightbox-in {
  from { transform: scale(0.93); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.lightbox__close {
  position: absolute;
  top: calc(16px + var(--st, 0px));
  right: 16px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.18s ease;
  backdrop-filter: blur(8px);
}

.lightbox__close:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: scale(1.08);
}

.lightbox__close svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.lightbox__download {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  background: rgba(46, 166, 255, 0.18);
  border: 1px solid rgba(46, 166, 255, 0.35);
  border-radius: 999px;
  color: var(--accent-2);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 600;
  transition: background 0.18s ease, transform 0.18s ease;
}

.lightbox__download:hover {
  background: rgba(46, 166, 255, 0.28);
  transform: translateY(-1px);
}

.lightbox__download svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
}

/* Photo send button: pulse when uploading */
#photo-btn.is-uploading {
  animation: photo-pulse 1s ease-in-out infinite;
  opacity: 0.7;
}

@keyframes photo-pulse {
  0%, 100% { opacity: 0.7; }
  50%       { opacity: 0.4; }
}

/* ─── Photo Context Menu ─────────────────────────────────────────────── */

.photo-menu {
  position: fixed;
  z-index: 10000;
  background: var(--panel-3);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  min-width: 172px;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.9);
  transform-origin: top left;
  transition: opacity 0.14s ease, transform 0.14s ease;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.photo-menu.is-visible {
  opacity: 1;
  pointer-events: all;
  transform: scale(1);
}

.photo-menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 13px 16px;
  background: transparent;
  border: 0;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.14s ease;
}

.photo-menu__item:hover {
  background: rgba(255, 255, 255, 0.07);
}

.photo-menu__item + .photo-menu__item {
  border-top: 1px solid var(--border);
}

.photo-menu__item svg {
  width: 16px;
  height: 16px;
  flex: none;
  stroke: currentColor;
  fill: none;
}

.photo-menu__item--danger {
  color: var(--danger);
}

.photo-menu__item--danger:hover {
  background: rgba(255, 100, 100, 0.1);
}

/* APK Download Link Styles */
.apk-download-container {
  margin-top: 15px;
  display: flex;
  justify-content: center;
  width: 100%;
}

.sidebar__footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: rgba(16, 26, 36, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
}

.apk-download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  background: rgba(46, 166, 255, 0.1);
  border: 1px solid rgba(46, 166, 255, 0.2);
  border-radius: var(--radius-sm);
  transition: background var(--ease), border-color var(--ease), transform var(--ease);
  width: 100%;
  text-align: center;
}

.apk-download-link:hover {
  background: rgba(46, 166, 255, 0.18);
  border-color: rgba(46, 166, 255, 0.4);
  transform: translateY(-1px);
  color: var(--accent-2);
}

.apk-download-link:active {
  transform: translateY(0);
}

.apk-download-link svg {
  margin-right: 8px;
  flex-shrink: 0;
  fill: currentColor;
}

.scroll-bottom-btn {
  position: absolute;
  bottom: 80px;
  right: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface-light, #2b3a4a);
  color: var(--text-primary, #fff);
  border: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.2s;
}
.scroll-bottom-btn.visible {
  opacity: 1;
  pointer-events: auto;
}
.scroll-bottom-btn:hover {
  transform: scale(1.1);
}
.main { position: relative; }

/* ========== APK Update Banner ========== */
.apk-update-banner {
  margin: 8px 12px 4px;
  border-radius: 14px;
  background: linear-gradient(135deg, #1a3a5c 0%, #0d2440 60%, #122b4a 100%);
  border: 1px solid rgba(46, 166, 255, 0.35);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(46, 166, 255, 0.12) inset;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: apkBannerIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  flex-shrink: 0;
}

@keyframes apkBannerIn {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.apk-update-banner__icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(46, 166, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
  animation: apkPulse 2.4s ease-in-out infinite;
}

@keyframes apkPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(46, 166, 255, 0.35); }
  50%       { box-shadow: 0 0 0 8px rgba(46, 166, 255, 0); }
}

.apk-update-banner__text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.apk-update-banner__text strong {
  font-size: 13px;
  color: var(--accent-2);
  line-height: 1.2;
}

.apk-update-banner__text span {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.3;
}

.apk-update-banner__btn {
  flex-shrink: 0;
  padding: 7px 14px;
  border-radius: 20px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: background 180ms ease, transform 180ms ease, box-shadow 180ms ease;
  box-shadow: 0 2px 10px rgba(46, 166, 255, 0.4);
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.apk-update-banner__btn:hover {
  background: var(--accent-2);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(46, 166, 255, 0.55);
}

.apk-update-banner__btn:active {
  transform: translateY(0);
}

/* ========== Auth page APK download button ========== */
.apk-download-container {
  margin-top: 18px;
  display: flex;
  justify-content: center;
}

.apk-download-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 22px;
  border-radius: 30px;
  background: linear-gradient(135deg, rgba(46, 166, 255, 0.15), rgba(46, 166, 255, 0.06));
  border: 1px solid rgba(46, 166, 255, 0.3);
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background 200ms ease, border-color 200ms ease, transform 200ms ease, box-shadow 200ms ease;
  box-shadow: 0 2px 12px rgba(46, 166, 255, 0.12);
}

.apk-download-btn:hover {
  background: linear-gradient(135deg, rgba(46, 166, 255, 0.25), rgba(46, 166, 255, 0.12));
  border-color: rgba(46, 166, 255, 0.55);
  transform: translateY(-1px);
  box-shadow: 0 4px 18px rgba(46, 166, 255, 0.25);
}

.apk-download-btn:active {
  transform: translateY(0);
}

/* ========== Update dot on refresh icon button ========== */
.icon-button.has-update-dot {
  position: relative;
  color: var(--accent);
}

.icon-button.has-update-dot::after {
  content: '';
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ff6b35;
  border: 2px solid var(--panel);
  animation: updateDotPulse 2s ease-in-out infinite;
}

@keyframes updateDotPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%       { transform: scale(1.3); opacity: 0.7; }
}

/* ========== File message card ========== */
.message__file-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  text-decoration: none;
  min-width: 200px;
  max-width: 320px;
  transition: background 150ms ease, border-color 150ms ease;
  user-select: none;
}

.message__file-card:hover {
  background: rgba(0, 0, 0, 0.3);
  border-color: rgba(46, 166, 255, 0.35);
}

.message__file-icon {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 10px;
  background: rgba(46, 166, 255, 0.15);
  color: var(--accent, #2ea6ff);
  display: flex;
  align-items: center;
  justify-content: center;
}

.message__file-icon svg {
  width: 22px;
  height: 22px;
}

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

.message__file-name {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text, #e7eef6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.message__file-meta {
  font-size: 11.5px;
  color: var(--muted, #8a9bb0);
}

.message__file-download {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted, #8a9bb0);
  background: rgba(255, 255, 255, 0.05);
  transition: background 150ms ease, color 150ms ease;
  text-decoration: none;
}

.message__file-download:hover {
  background: rgba(46, 166, 255, 0.2);
  color: var(--accent, #2ea6ff);
}

.message__file-download svg {
  width: 18px;
  height: 18px;
}

/* ========== Drag & Drop Overlay ========== */
.drop-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(14, 22, 33, 0.92);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
  border: 2px dashed rgba(46, 166, 255, 0.6);
  border-radius: 16px;
  margin: 8px;
}

.drop-overlay.is-active {
  opacity: 1;
  pointer-events: all;
}

.drop-overlay__content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  padding: 32px 40px;
  border-radius: 20px;
  background: rgba(46, 166, 255, 0.08);
  border: 1px solid rgba(46, 166, 255, 0.25);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  transform: scale(0.95);
  transition: transform 180ms ease;
}

.drop-overlay.is-active .drop-overlay__content {
  transform: scale(1);
}

.drop-overlay__icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(46, 166, 255, 0.2);
  color: var(--accent, #2ea6ff);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: bounceDrop 1.5s infinite ease-in-out;
}

.drop-overlay__icon svg {
  width: 32px;
  height: 32px;
}

.drop-overlay__text {
  font-size: 1.15rem;
  font-weight: 600;
  color: #fff;
}

.drop-overlay__sub {
  font-size: 0.85rem;
  color: var(--muted, #8a9bb0);
}

@keyframes bounceDrop {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* ========== FAB - Round Blue Button for adding users ========== */
.fab-add-user {
  position: absolute;
  right: 18px;
  bottom: 18px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3bb3ff 0%, #1b86e6 100%);
  color: #ffffff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(27, 134, 230, 0.45);
  cursor: pointer;
  z-index: 10;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.fab-add-user:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 6px 20px rgba(27, 134, 230, 0.6);
  background: linear-gradient(135deg, #4dc0ff 0%, #2090f5 100%);
}

.fab-add-user:active {
  transform: translateY(0) scale(0.96);
  box-shadow: 0 2px 8px rgba(27, 134, 230, 0.4);
}

.fab-add-user svg {
  width: 24px;
  height: 24px;
  stroke: #ffffff;
  fill: none !important;
}

/* ========== Add User Modal ========== */
.add-user-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.add-user-modal.is-visible {
  opacity: 1;
  visibility: visible;
}

.add-user-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
}

.add-user-modal__dialog {
  position: relative;
  z-index: 1;
  width: 90%;
  max-width: 420px;
  max-height: 80vh;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  animation: modalScaleIn 0.2s ease;
}

@keyframes modalScaleIn {
  from {
    transform: scale(0.95);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.add-user-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.add-user-modal__header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

.add-user-modal__close {
  background: transparent;
  border: none;
  color: var(--muted);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.add-user-modal__close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.add-user-modal__close svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none !important;
}

.add-user-modal__form {
  padding: 16px 20px 8px;
}

.add-user-modal__search {
  display: flex;
  gap: 10px;
}

.add-user-modal__search input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.9375rem;
  outline: none;
  transition: border-color 0.15s ease;
}

.add-user-modal__search input:focus {
  border-color: var(--accent);
}

.add-user-modal__search button {
  padding: 10px 18px;
  border-radius: 10px;
  font-weight: 600;
}

.add-user-modal__error {
  margin-top: 8px;
  font-size: 0.8125rem;
  color: var(--danger, #ff5c5c);
}

.add-user-modal__list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px 16px;
  min-height: 120px;
  max-height: 340px;
}

.add-user-modal__loading,
.add-user-modal__empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 0.875rem;
}

.add-user-modal__item {
  width: 100%;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: transparent;
  border: 0;
  border-radius: 10px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s ease;
}

.add-user-modal__item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.add-user-modal__item-info {
  min-width: 0;
  flex: 1;
}

.add-user-modal__item-name {
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.add-user-modal__item-hint {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 2px;
}

/* ========== Chat Header 3-Dots Menu Dropdown ========== */
.chat-menu-wrapper {
  position: relative;
  display: inline-flex;
}

.chat-menu-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  background: var(--panel-2, #17212b);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.45);
  padding: 6px;
  z-index: 100;
  display: none;
  flex-direction: column;
  gap: 2px;
  backdrop-filter: blur(12px);
  animation: dropdownFade 0.15s ease;
}

@keyframes dropdownFade {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-menu-dropdown.is-visible {
  display: flex;
}

.chat-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
}

.chat-menu-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.chat-menu-item--danger {
  color: #ff6b6b;
}

.chat-menu-item--danger:hover {
  background: rgba(255, 107, 107, 0.12);
  color: #ff8585;
}

.chat-menu-item__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.chat-menu-item__icon svg {
  width: 16px;
  height: 16px;
  fill: none !important;
  stroke: currentColor;
}

/* ========== Refresh button spinning animation ========== */
.icon-button.is-refreshing svg {
  animation: spinRefresh 0.65s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes spinRefresh {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}



