/* ═══════════════════════════════════════════════════════════════
   SilaevPro Messenger — Design System 2026
   Premium dark theme · Mobile-first · Glassmorphism accents
   ═══════════════════════════════════════════════════════════════ */

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; }

/* ── Global overflow guard ── */
html, body { overflow-x: clip; max-width: 100vw; }
* { max-width: 100%; min-width: 0; }

/* ── Design Tokens ── */
:root {
  color-scheme: dark;

  /* Backgrounds */
  --bg:          #03060c;
  --bg-gradient-start: #03060c;
  --bg-gradient-end: #0a111f;
  --panel:       #0a111f;
  --surface:     #0e1729;
  --surface-2:   #121f32;
  --surface-3:   #16263e;
  --overlay:     rgba(3, 6, 12, 0.92);

  /* Accent — Electric Blue & Cyber Purple */
  --accent:      #2b7fff;
  --accent-2:    #5d9eff;
  --accent-purple: #8b5cf6;
  --accent-soft: rgba(43, 127, 255, 0.12);
  --accent-glow: rgba(43, 127, 255, 0.25);

  /* Text */
  --text:        #f0f4fa;
  --text-2:      #b9c8e8;
  --muted:       #6c86a3;

  /* Borders */
  --line:        rgba(67, 97, 128, 0.2);
  --line-2:      rgba(67, 97, 128, 0.35);

  /* Semantic */
  --success:     #22c55e;
  --danger:      #ef4444;
  --warning:     #f59e0b;

  /* Message bubbles */
  --bubble-in:   #111a2c;
  --bubble-out:  #1e3a6b;
  --bubble-gradient-start: #1e3a6b;
  --bubble-gradient-end: #1f3f75;

  /* Elevation */
  --shadow-xs:   0 1px 2px rgba(0,0,0,0.3);
  --shadow-sm:   0 4px 12px rgba(0,0,0,0.25);
  --shadow:      0 8px 24px rgba(0,0,0,0.3);
  --shadow-lg:   0 16px 40px rgba(0,0,0,0.4);
  --shadow-xl:   0 24px 64px rgba(0,0,0,0.5);

  /* Radii */
  --radius-sm:   8px;
  --radius:      14px;
  --radius-lg:   20px;
  --radius-xl:   28px;
  --radius-2xl:  32px;
  --radius-pill: 999px;

  /* Transitions */
  --ease:        0.2s cubic-bezier(0.2, 0.9, 0.4, 1.1);
  --ease-spring: 0.3s cubic-bezier(0.34, 1.4, 0.64, 1);

  /* App height (JS-managed) */
  --app-height: 100dvh;
  --keyboard-inset: 0px;
  --viewport-top-inset: 0px;
  --viewport-bottom-inset: 0px;

  /* Layout rules */
  --layout-sidebar-width: 360px;
  --layout-sidebar-top-min: 214px;
  --layout-content-header-min: 82px;
  --layout-composer-min: 84px;
  --layout-stream-min: 160px;
  --layout-mobile-chrome-width: 100%;
}

/* ── Base ── */
html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14.5px;
  line-height: 1.5;
  background: radial-gradient(ellipse at 20% 30%, rgba(43, 127, 255, 0.08) 0%, transparent 50%),
              radial-gradient(ellipse at 80% 70%, rgba(139, 92, 246, 0.06) 0%, transparent 50%),
              var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  font-weight: 450;
}

::selection {
  background: rgba(43, 127, 255, 0.35);
  color: #fff;
}

/* ── Typography ── */
h1, h2, h3, h4, h5, h6 { font-weight: 600; letter-spacing: -0.02em; }
h1 { font-size: 1.8rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.1rem; }

/* ── Inputs ── */
input, select, textarea {
  width: 100%;
  padding: 12px 16px;
  background: rgba(10, 18, 30, 0.7);
  color: var(--text);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.95rem;
  transition: all var(--ease);
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(43, 127, 255, 0.15);
}

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

/* ── Buttons ── */
button {
  padding: 10px 18px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--ease);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

button:hover {
  transform: translateY(-1px);
  background: var(--accent-2);
  box-shadow: var(--shadow-sm);
}

button:active { transform: translateY(0); }
button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.ghost-btn {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-2);
  border: 1px solid var(--line);
}

.ghost-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.secondary-btn {
  background: rgba(43, 127, 255, 0.12);
  color: var(--accent-2);
  border: 1px solid rgba(43, 127, 255, 0.25);
}

.danger-btn {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.danger-btn:hover {
  background: rgba(239, 68, 68, 0.25);
  color: #ff8a8a;
}

.icon-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border-radius: var(--radius-sm);
}

.send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 4px 12px rgba(43, 127, 255, 0.3);
}

.send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 18px rgba(43, 127, 255, 0.4);
}

.send-btn .btn-label {
  display: none;
}

.attach-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  font-size: 1.3rem;
}

.btn-glyph { font-size: 1.1rem; line-height: 1; }

/* ── Utilities ── */
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.85rem; }

.card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}

.plain-card {
  padding: 20px;
}

/* ────────────────────────────────────────────────
   AUTH PAGES — Modern Gradient Design
   ──────────────────────────────────────────────── */
.auth-panel {
  min-height: var(--app-height);
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(ellipse at 0% 20%, rgba(43, 127, 255, 0.12), transparent 60%),
              radial-gradient(ellipse at 100% 80%, rgba(139, 92, 246, 0.08), transparent 50%),
              var(--bg);
}

.auth-shell {
  width: min(1100px, 100%);
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 40px;
  align-items: center;
}

.auth-brand { padding: 20px; }

.brand-badge {
  display: inline-flex;
  padding: 8px 18px;
  background: linear-gradient(135deg, rgba(43, 127, 255, 0.2), rgba(139, 92, 246, 0.2));
  border: 1px solid rgba(43, 127, 255, 0.3);
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  color: var(--accent-2);
}

.auth-brand h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 800;
  margin: 24px 0 16px;
  background: linear-gradient(135deg, #fff, var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.auth-brand p {
  color: var(--text-2);
  font-size: 1rem;
  line-height: 1.6;
  max-width: 90%;
}

.auth-card-shell {
  background: rgba(10, 18, 30, 0.7);
  backdrop-filter: blur(20px);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-2xl);
  padding: 28px;
  box-shadow: var(--shadow-lg);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 4px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
}

.auth-tab {
  background: transparent;
  color: var(--muted);
  padding: 10px;
  border-radius: var(--radius);
}

.auth-tab.active {
  background: var(--accent);
  color: white;
}

.auth-page { display: grid; gap: 20px; }
.auth-card-head h2 { font-size: 1.3rem; margin-bottom: 4px; }
.auth-form-stack { display: grid; gap: 16px; }

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

.field > span {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.auth-page-footer {
  display: grid;
  gap: 12px;
  margin-top: 8px;
}

.auth-page-footer > button:first-child {
  background: linear-gradient(135deg, var(--accent), var(--accent-purple));
  padding: 14px;
  font-weight: 700;
}

/* Verification */
.verification-list { display: grid; gap: 12px; margin-bottom: 20px; }
.verification-item {
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.demo-code {
  margin-top: 12px;
  padding: 10px 14px;
  background: rgba(43, 127, 255, 0.1);
  border-radius: var(--radius-sm);
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--accent-2);
}

/* ────────────────────────────────────────────────
   APP SHELL
   ──────────────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, var(--layout-sidebar-width)) minmax(0, 1fr);
  grid-template-areas: "sidebar content";
  width: 100%;
  height: var(--app-height);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
  isolation: isolate;
}

/* ── Sidebar ── */
.sidebar {
  grid-area: sidebar;
  border-right: 1px solid var(--line);
  background: var(--panel);
  display: grid;
  grid-template-rows: 1fr;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.desktop-sidebar-rail {
  display: none;
}

.sidebar-main {
  display: grid;
  grid-template-rows: minmax(var(--layout-sidebar-top-min), auto) minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
}

.sidebar-top {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--line);
  min-width: 0;
  overflow: hidden;
  align-self: start;
}

.profile-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-lg);
  min-width: 0;
}

.profile-meta {
  min-width: 0;
}

.profile-meta strong {
  display: block;
  font-size: 1rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-actions {
  grid-column: span 2;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.compact-field {
  gap: 8px;
}

.quick-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.sections-menu-trigger {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.action-badge {
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: white;
  font-size: 0.72rem;
  font-weight: 700;
}

.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-purple));
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 1rem;
  color: white;
  overflow: hidden;
}

.avatar img { width: 100%; height: 100%; object-fit: cover; }
.large-avatar { width: 56px; height: 56px; font-size: 1.2rem; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(34, 197, 94, 0.12);
  border-radius: var(--radius-pill);
  font-size: 0.7rem;
  font-weight: 600;
  color: #4ade80;
}

.status-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}

/* Chat list */
.chat-list {
  overflow-y: auto;
  padding: 8px;
  scrollbar-width: thin;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overscroll-behavior: contain;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-width: 0;
  padding: 12px;
  border-radius: var(--radius);
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: all var(--ease);
  border: 1px solid transparent;
}

.chat-item:hover {
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--line);
}

.chat-item.active {
  background: linear-gradient(135deg, rgba(43, 127, 255, 0.15), rgba(139, 92, 246, 0.1));
  border-color: rgba(43, 127, 255, 0.3);
}

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

.chat-item-topline {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.chat-item-topline strong {
  flex: 1 1 auto;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-item-meta {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
}

.chat-item-preview {
  font-size: 0.8rem;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-item-time {
  font-size: 0.7rem;
  color: var(--muted);
}

.chat-unread {
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  background: var(--accent);
  border-radius: var(--radius-pill);
  font-size: 0.7rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: white;
}

/* ── Content Area ── */
.content {
  grid-area: content;
  display: grid;
  grid-template-areas:
    "header"
    "call"
    "pinned"
    "search"
    "stream"
    "composer"
    "status";
  grid-template-rows:
    minmax(var(--layout-content-header-min), auto)
    auto
    auto
    auto
    minmax(var(--layout-stream-min), 1fr)
    minmax(var(--layout-composer-min), auto)
    auto;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
  align-items: stretch;
  isolation: isolate;
}

.content-header {
  grid-area: header;
}

#call-banner {
  grid-area: call;
}

#pinned-message-banner {
  grid-area: pinned;
}

#chat-search-bar {
  grid-area: search;
}

#empty-chat-state,
#messages {
  grid-area: stream;
  min-height: 0;
  height: 100%;
}

#composer-form {
  grid-area: composer;
}

.call-status {
  grid-area: status;
}

.content-header,
#call-banner,
#pinned-message-banner,
#chat-search-bar,
#composer-form,
.call-status {
  width: 100%;
  min-width: 0;
}

.content-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  background: rgba(10, 18, 30, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  min-width: 0;
  min-height: var(--layout-content-header-min);
  flex-shrink: 0;
  overflow: hidden;
}

.header-main {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1 1 auto;
  min-width: 0;
}

.chat-header-toggle {
  background: transparent;
  padding: 0;
  text-align: left;
  display: grid;
  gap: 2px;
  width: 100%;
  min-width: 0;
  justify-items: start;
  align-content: center;
  overflow: hidden;
}

.chat-header-toggle h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#chat-subtitle {
  font-size: 0.75rem;
  color: var(--text-2);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-subtitle-online { color: var(--success); }

.typing-line {
  min-height: 18px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.75rem;
  color: var(--accent-2);
}

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.icon-text-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.icon-only-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
}

/* Call banner */
.call-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 12px 20px;
  background: linear-gradient(135deg, rgba(43, 127, 255, 0.12), rgba(139, 92, 246, 0.08));
  border-bottom: 1px solid rgba(43, 127, 255, 0.2);
  overflow: hidden;
}

.call-banner-body,
.pinned-banner-body {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.call-banner-body strong { color: var(--accent-2); }

#call-banner-text,
#pinned-message-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.call-banner-actions,
.pinned-banner-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.call-status {
  padding: 6px 24px 12px;
  font-size: 0.82rem;
  color: var(--text-2);
}

/* Pinned banner */
.pinned-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 10px 20px;
  background: rgba(245, 158, 11, 0.08);
  border-bottom: 1px solid rgba(245, 158, 11, 0.2);
  border-left: 4px solid var(--warning);
  overflow: hidden;
}

.search-bar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 12px 20px;
  background: rgba(10, 18, 30, 0.88);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}

.search-bar input {
  min-width: 0;
}

.search-pin-caption {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: var(--radius-pill);
  background: rgba(43, 127, 255, 0.12);
  color: var(--accent-2);
  font-size: 0.72rem;
  font-weight: 700;
}

/* Messages */
.messages {
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: flex-end;
  min-width: 0;
  min-height: 0;
  height: 100%;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}

.messages > * {
  min-width: 0;
}

.date-divider {
  text-align: center;
  margin: 16px 0 8px;
}

.date-divider span {
  padding: 4px 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-pill);
  font-size: 0.7rem;
  color: var(--muted);
}

.unread-divider span {
  background: rgba(43, 127, 255, 0.14);
  color: var(--accent-2);
}

.message {
  width: fit-content;
  max-width: 70%;
  min-width: 0;
  padding: 10px 14px;
  border-radius: 20px;
  background: var(--bubble-in);
  align-self: flex-start;
  border: 1px solid rgba(93, 126, 163, 0.14);
  box-shadow: var(--shadow-xs);
}

.message.mine {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--bubble-gradient-start), var(--bubble-gradient-end));
  border-color: rgba(93, 158, 255, 0.2);
}

.message-body {
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.message-meta {
  display: flex;
  gap: 8px;
  font-size: 0.65rem;
  color: var(--muted);
  margin-top: 4px;
  margin-bottom: 8px;
}

.message-topline {
  display: grid;
  gap: 8px;
  margin-bottom: 8px;
}

.forward-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-2);
}

.message-quote {
  width: 100%;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(93, 126, 163, 0.2);
  border-radius: 16px;
  text-align: left;
  box-shadow: none;
}

.message-quote:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: none;
}

.message-quote-text {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.message-quote-text strong {
  font-size: 0.75rem;
  color: var(--accent-2);
}

.message-quote-text span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-2);
  font-size: 0.82rem;
}

.message-deleted {
  font-style: italic;
  color: var(--muted);
}

.message-file {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(93, 126, 163, 0.22);
  border-radius: 18px;
}

.message-file-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: rgba(43, 127, 255, 0.12);
  font-size: 1.1rem;
}

.message-file-body {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.message-file-name {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-file-download {
  color: var(--accent-2);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
}

.message-file-download:hover {
  text-decoration: underline;
}

.message-image {
  display: block;
  overflow: hidden;
  border-radius: var(--radius);
}

.message-image img {
  display: block;
  width: min(280px, 100%);
  max-width: 280px;
  max-height: 280px;
  border-radius: var(--radius);
  object-fit: cover;
  cursor: pointer;
}

/* Voice message */
.message-voice {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 100%;
  min-width: 200px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(93, 126, 163, 0.22);
  border-radius: 18px;
}

.voice-play-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.voice-player-body {
  display: grid;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.voice-waveform {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 32px;
  min-width: 0;
}

.voice-waveform.compact {
  width: 100%;
  overflow: hidden;
}

.voice-wave-bar {
  width: 3px;
  background: var(--accent-2);
  border-radius: var(--radius-pill);
}

.voice-duration {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
}

.message-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.reaction-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(93, 126, 163, 0.22);
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  color: var(--text-2);
  box-shadow: none;
}

.reaction-chip:hover {
  background: rgba(43, 127, 255, 0.14);
  color: #fff;
  transform: none;
}

.message-read-meta {
  display: inline-flex;
  align-items: center;
  margin-top: 8px;
  padding: 4px 8px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-size: 0.72rem;
}

/* Message actions menu */
.message-action-menu {
  position: fixed;
  z-index: 100;
  background: rgba(10, 18, 30, 0.98);
  backdrop-filter: blur(16px);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-lg);
  padding: 8px;
  min-width: 180px;
  box-shadow: var(--shadow-lg);
  animation: menuFadeIn 0.15s ease;
}

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

.message-action-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.85rem;
  justify-content: flex-start;
}

.message-action-btn:hover { background: rgba(255, 255, 255, 0.05); }

.message-reaction-picker {
  display: flex;
  gap: 4px;
  padding-bottom: 8px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--line);
}

.message-reaction-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(93, 126, 163, 0.22);
  box-shadow: none;
}

.message-reaction-btn:hover {
  background: rgba(43, 127, 255, 0.14);
  transform: none;
}

.danger-action {
  color: #f87171;
}

.danger-action:hover {
  background: rgba(239, 68, 68, 0.18);
}

/* Composer */
.composer {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  padding: 12px 20px;
  background: rgba(10, 18, 30, 0.95);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  min-width: 0;
  min-height: var(--layout-composer-min);
  align-self: end;
  flex-shrink: 0;
}

.composer-main {
  flex: 1;
  display: grid;
  gap: 8px;
  min-width: 0;
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-xl);
  padding: 8px 16px;
  border: 1px solid var(--line);
}

.composer-main input {
  background: transparent;
  border: none;
  padding: 8px 0;
  min-width: 0;
}

.composer-main input:focus {
  box-shadow: none;
}

.reply-banner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  background: rgba(43, 127, 255, 0.1);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-bottom: 8px;
}

.reply-banner-text {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.reply-banner-text span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-preview,
.voice-preview {
  display: grid;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(93, 126, 163, 0.22);
  border-radius: 18px;
}

.voice-preview-meta {
  display: grid;
  gap: 4px;
}

.voice-preview audio {
  width: 100%;
}

.voice-preview-actions {
  display: flex;
  justify-content: flex-end;
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px;
  color: var(--muted);
}

.empty-icon {
  font-size: 4rem;
  margin-bottom: 16px;
  opacity: 0.6;
}

/* ── Modals ── */
.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 50;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
}

.modal-card {
  position: relative;
  width: min(500px, calc(100vw - 32px));
  max-height: 80vh;
  background: linear-gradient(135deg, #0e1729, #0a111f);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-2xl);
  padding: 24px;
  overflow-y: auto;
  z-index: 1;
  box-shadow: var(--shadow-xl);
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.contact-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.contact-list > section {
  display: grid;
  gap: 12px;
}

.contact-list > section > .muted {
  margin: 2px 2px 0;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.contact-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow-sm);
}

.contact-item .avatar {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
}

.contact-body {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.contact-body strong {
  color: var(--text);
}

.contact-body > div {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.contact-body img {
  display: block;
  max-width: min(220px, 100%);
  border-radius: 16px;
}

.contact-body audio {
  width: min(260px, 100%);
}

.contact-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.media-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.media-tab {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(93, 126, 163, 0.22);
  background: rgba(255, 255, 255, 0.035);
  color: var(--text-2);
  font-weight: 600;
  box-shadow: none;
}

.media-tab.active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

/* ── Settings Sidebar ── */
.settings-shell {
  position: fixed;
  inset: 0;
  z-index: 60;
}

.settings-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.settings-sidebar {
  position: absolute;
  top: 0;
  right: 0;
  width: min(420px, 100%);
  height: 100%;
  background: linear-gradient(180deg, #0e1729, #0a111f);
  border-left: 1px solid var(--line);
  overflow-y: auto;
  animation: slideInRight 0.25s ease;
}

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.settings-main-sidebar {
  width: min(960px, calc(100vw - 24px));
  padding: 24px 24px 28px;
  background:
    radial-gradient(circle at top left, rgba(43, 127, 255, 0.16), transparent 34%),
    radial-gradient(circle at top right, rgba(139, 92, 246, 0.12), transparent 30%),
    linear-gradient(180deg, rgba(15, 24, 39, 0.98), rgba(7, 12, 22, 0.98));
  box-shadow: var(--shadow-xl);
}

.profile-sidebar {
  padding: 24px;
}

.settings-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
  padding: 4px 4px 20px;
  border-bottom: 1px solid rgba(93, 126, 163, 0.22);
}

.settings-header-copy {
  display: grid;
  gap: 8px;
}

.settings-header-copy h3 {
  margin: 0;
  font-size: clamp(1.35rem, 1.2rem + 0.6vw, 1.85rem);
  letter-spacing: -0.03em;
}

.settings-header-copy p {
  margin: 0;
  max-width: 680px;
  line-height: 1.6;
  color: var(--text-2);
}

.settings-kicker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  padding: 7px 12px;
  background: rgba(43, 127, 255, 0.12);
  border: 1px solid rgba(93, 158, 255, 0.22);
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-2);
}

.settings-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  margin-bottom: 22px;
  padding: 18px 20px;
  background: linear-gradient(135deg, rgba(18, 31, 50, 0.9), rgba(11, 18, 31, 0.92));
  border: 1px solid rgba(93, 126, 163, 0.26);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow);
}

.settings-toolbar-summary {
  display: grid;
  gap: 6px;
}

.settings-toolbar-summary strong {
  font-size: 0.98rem;
  color: var(--text);
}

.settings-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.settings-nav-btn {
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(93, 126, 163, 0.22);
  border-radius: var(--radius-pill);
  color: var(--text-2);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1;
}

.settings-nav-btn:hover {
  background: rgba(43, 127, 255, 0.12);
  border-color: rgba(93, 158, 255, 0.35);
  color: #fff;
  transform: translateY(-1px);
}

.settings-nav-btn.active {
  background: linear-gradient(135deg, rgba(43, 127, 255, 0.9), rgba(93, 158, 255, 0.85));
  border-color: rgba(160, 208, 255, 0.55);
  color: #fff;
  box-shadow: 0 10px 24px rgba(43, 127, 255, 0.18);
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-bottom: 12px;
}

.settings-section {
  display: grid;
  gap: 18px;
  padding: 24px;
  background: linear-gradient(180deg, rgba(16, 25, 40, 0.92), rgba(10, 17, 31, 0.94));
  border: 1px solid rgba(93, 126, 163, 0.22);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.settings-section-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.95fr);
  gap: 20px;
  align-items: start;
}

.settings-section-title {
  display: grid;
  gap: 8px;
}

.settings-section h3 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
}

.settings-section-copy {
  margin: 0;
  color: var(--text-2);
  font-size: 0.92rem;
  line-height: 1.65;
}

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

.settings-profile-card {
  margin: 0;
  padding: 18px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(93, 126, 163, 0.2);
  border-radius: var(--radius-xl);
}

.settings-profile-meta {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.settings-profile-meta strong {
  font-size: 1.12rem;
  color: var(--text);
}

.settings-avatar {
  width: 72px;
  height: 72px;
  font-size: 1.45rem;
  box-shadow: 0 16px 32px rgba(43, 127, 255, 0.2);
}

.settings-field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.settings-inline-note {
  min-height: 20px;
  padding: 0 2px;
}

.settings-status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.settings-status-grid .verification-item {
  height: 100%;
  display: grid;
  gap: 8px;
  padding: 16px 18px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(93, 126, 163, 0.2);
}

.settings-public-id-value {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text);
}

.contact-share-card {
  display: grid;
  grid-template-columns: 148px minmax(0, 1fr);
  gap: 20px;
  align-items: center;
  padding: 18px;
  background: linear-gradient(135deg, rgba(18, 31, 50, 0.92), rgba(10, 17, 31, 0.95));
  border: 1px solid rgba(93, 126, 163, 0.22);
  border-radius: var(--radius-xl);
}

.contact-share-meta {
  display: grid;
  gap: 10px;
}

.contact-share-meta strong {
  font-size: 1rem;
  color: var(--text);
}

.contact-share-link {
  word-break: break-all;
  line-height: 1.55;
  color: var(--text-2);
}

.settings-action-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* Switch row */
.switch-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.settings-toggle-grid {
  display: grid;
  gap: 12px;
}

.settings-toggle-card {
  padding: 16px 18px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(93, 126, 163, 0.2);
  border-radius: var(--radius-xl);
}

.settings-toggle-card span {
  color: var(--text-2);
  line-height: 1.55;
}

.switch-row input[type="checkbox"] {
  width: 44px;
  height: 24px;
  appearance: none;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-pill);
  position: relative;
  cursor: pointer;
  transition: all var(--ease);
  margin-top: 2px;
  flex: 0 0 auto;
}

.switch-row input[type="checkbox"]:checked {
  background: var(--accent);
}

.switch-row input[type="checkbox"]::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  top: 3px;
  left: 3px;
  transition: transform var(--ease);
}

.switch-row input[type="checkbox"]:checked::after {
  transform: translateX(20px);
}

.settings-device-card {
  display: grid;
  gap: 16px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(93, 126, 163, 0.2);
  border-radius: var(--radius-xl);
}

.settings-device-status {
  display: grid;
  gap: 8px;
  padding: 0;
  border: none;
  background: transparent;
}

.settings-submit-row {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  margin-top: 4px;
  background: rgba(9, 15, 27, 0.94);
  border: 1px solid rgba(93, 126, 163, 0.24);
  border-radius: var(--radius-2xl);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-lg);
}

.settings-submit-copy {
  display: grid;
  gap: 4px;
}

.settings-submit-copy strong {
  color: var(--text);
  font-size: 0.95rem;
}

.settings-submit-row button {
  padding: 14px 24px;
  background: linear-gradient(135deg, var(--accent), var(--accent-purple));
  box-shadow: 0 16px 32px rgba(43, 127, 255, 0.18);
}

.profile-quick-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

/* Contact QR */
.contact-qr {
  width: 132px;
  height: 132px;
  background: white;
  border-radius: 18px;
  padding: 10px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.22);
}

/* Call modal */
.call-modal-card {
  width: min(600px, calc(100vw - 32px));
}

.call-screen {
  display: flex;
  flex-direction: column;
  gap: 20px;
  text-align: center;
}

.call-screen-head {
  display: flex;
  align-items: center;
  gap: 16px;
  text-align: left;
}

.call-avatar {
  width: 80px;
  height: 80px;
  font-size: 1.5rem;
}

.call-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 16px;
}

.call-media-host {
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius);
  min-height: 120px;
  display: grid;
  place-items: center;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 18, 30, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-pill);
  padding: 10px 20px;
  color: var(--text);
  font-size: 0.85rem;
  z-index: 200;
  white-space: nowrap;
  box-shadow: var(--shadow);
  animation: toastSlideUp 0.2s ease;
}

@keyframes toastSlideUp {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Push setup banner */
.push-setup-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(10, 18, 30, 0.98);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--accent);
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 45;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.push-banner-body {
  display: flex;
  align-items: center;
  gap: 12px;
}

.push-banner-icon { font-size: 1.5rem; }
.push-banner-text strong { display: block; font-size: 0.9rem; }
.push-banner-text span { font-size: 0.75rem; color: var(--muted); }

/* ────────────────────────────────────────────────
   DESKTOP TELEGRAM-INSPIRED (≥961px)
   ──────────────────────────────────────────────── */
@media (min-width: 961px) {
  .app-shell {
    --layout-sidebar-width: 476px;
    --layout-sidebar-top-min: 196px;
    --layout-content-header-min: 86px;
    --layout-composer-min: 96px;
    grid-template-columns: 476px 1fr;
    background: linear-gradient(180deg, #d7ebfb, #bedcf3);
  }

  .sidebar {
    grid-template-columns: 92px minmax(0, 1fr);
    border-right: 1px solid rgba(187, 204, 220, 0.92);
    background: #eef3f7;
  }

  .desktop-sidebar-rail {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 18px 10px 16px;
    background: linear-gradient(180deg, #33485e, #2a3b4d);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
  }

  .desktop-rail-btn {
    display: grid;
    justify-items: center;
    gap: 8px;
    min-height: 72px;
    padding: 10px 8px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 24px;
    color: rgba(228, 236, 245, 0.78);
    box-shadow: none;
    font-size: 0.74rem;
    font-weight: 700;
  }

  .desktop-rail-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    transform: none;
    box-shadow: none;
  }

  .desktop-rail-icon {
    font-size: 1.28rem;
    line-height: 1;
  }

  .desktop-rail-spacer {
    flex: 1 1 auto;
  }

  .sidebar-main {
    background: linear-gradient(180deg, #fafbfd, #f0f4f8);
  }

  .sidebar-top {
    padding: 14px 16px 16px;
    border-bottom: 1px solid rgba(214, 224, 234, 0.95);
    background: rgba(255, 255, 255, 0.9);
  }

  .profile-card {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 14px;
    margin-bottom: 16px;
    padding: 0;
    background: transparent;
    border-radius: 0;
  }

  .profile-card .avatar {
    width: 52px;
    height: 52px;
    box-shadow: 0 8px 18px rgba(74, 149, 240, 0.2);
  }

  .profile-meta strong {
    font-size: 1.2rem;
    color: #223344;
  }

  .profile-meta .status-pill {
    background: rgba(76, 163, 102, 0.12);
    color: #3a8c57;
  }

  .profile-actions {
    display: none;
  }

  .compact-field > span {
    display: none;
  }

  #chat-filter-input {
    padding: 14px 18px;
    background: #eef2f6;
    color: #243546;
    border: 1px solid #d8e0e8;
    border-radius: 999px;
    font-size: 0.98rem;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
  }

  #chat-filter-input::placeholder {
    color: #8e9aa7;
  }

  .quick-actions {
    margin-top: 12px;
  }

  .sections-menu-trigger {
    padding: 10px 14px;
    background: #fff;
    color: #4d6378;
    border: 1px solid #d7e0e8;
    box-shadow: 0 6px 14px rgba(182, 196, 210, 0.15);
  }

  .sections-menu-trigger:hover {
    background: #f7fafc;
    color: #27435c;
    transform: none;
  }

  .chat-list {
    padding: 10px 10px 14px;
    background: linear-gradient(180deg, #ffffff, #f1f5f8);
  }

  .chat-item {
    padding: 14px 16px;
    border-radius: 18px;
    background: transparent;
    border: 1px solid transparent;
    box-shadow: none;
    color: #243546;
  }

  .chat-item:hover {
    background: #eef4f8;
    border-color: #d8e3ec;
    transform: none;
  }

  .chat-item.active {
    background: linear-gradient(180deg, #e0efff, #d5e6f8);
    border-color: #bbd6ef;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
  }

  .chat-item .avatar {
    width: 54px;
    height: 54px;
    box-shadow: none;
  }

  .chat-item-topline strong {
    color: #1f2f3e;
  }

  .chat-item-preview {
    color: #7a8896;
    font-size: 0.93rem;
  }

  .chat-item-time {
    color: #98a5b1;
    font-size: 0.82rem;
  }

  .chat-unread {
    background: linear-gradient(180deg, #5ab2f6, #469ce8);
  }

  .content {
    position: relative;
    background: linear-gradient(180deg, #d7ebfb, #bedcf3);
  }

  .content::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
      radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.22), transparent 32%),
      linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.05));
    pointer-events: none;
  }

  .content > * {
    position: relative;
    z-index: 1;
  }

  .content-header {
    padding: 18px 26px;
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(18px);
    border-bottom: 1px solid rgba(194, 207, 221, 0.9);
  }

  #chat-avatar {
    width: 52px;
    height: 52px;
    box-shadow: none;
  }

  .chat-header-toggle h2 {
    color: #223546;
    font-size: 1.24rem;
  }

  #chat-subtitle {
    color: #667b8e;
    font-size: 0.92rem;
  }

  .typing-line {
    color: #3d8fd2;
    font-size: 0.82rem;
  }

  #audio-call-btn {
    padding: 12px 20px;
    border-radius: 999px;
    background: rgba(63, 116, 167, 0.08);
    border: 1px solid rgba(113, 146, 179, 0.24);
    color: #35526c;
    box-shadow: none;
  }

  #audio-call-btn:hover {
    background: rgba(63, 116, 167, 0.12);
    color: #20384f;
    transform: none;
  }

  .call-banner,
  .pinned-banner,
  .search-bar,
  .composer {
    background: rgba(255, 255, 255, 0.76);
    border-color: rgba(193, 206, 220, 0.92);
    box-shadow: none;
  }

  .call-banner,
  .pinned-banner,
  .search-bar {
    border-bottom: 1px solid rgba(193, 206, 220, 0.92);
  }

  .search-bar {
    background: rgba(255, 255, 255, 0.68);
  }

  .search-pin-caption {
    background: rgba(92, 159, 217, 0.14);
    color: #43729a;
  }

  .search-bar input {
    background: rgba(255, 255, 255, 0.84);
    border-color: rgba(193, 206, 220, 0.92);
    color: #243546;
  }

  .messages {
    padding: 28px 34px 22px;
  }

  .date-divider span {
    background: rgba(85, 151, 207, 0.18);
    color: #466e91;
  }

  #empty-chat-state {
    background: transparent;
    color: #47657e;
  }

  #empty-chat-state .empty-icon {
    display: none;
  }

  #empty-chat-state h3 {
    margin: 0;
    font-size: 1.4rem;
    color: #35506a;
  }

  #empty-chat-state p {
    margin: 0;
    padding: 12px 18px;
    border-radius: 999px;
    background: rgba(71, 139, 192, 0.52);
    color: white;
    font-size: 1rem;
  }

  .message {
    max-width: 58%;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(193, 205, 216, 0.95);
    border-radius: 18px 18px 18px 8px;
    box-shadow: 0 10px 22px rgba(106, 141, 169, 0.14);
  }

  .message.mine {
    background: linear-gradient(180deg, #daeefe, #ccdef2);
    border-color: rgba(179, 208, 234, 0.95);
    border-radius: 18px 18px 8px 18px;
  }

  .message-body,
  .message-file-name,
  .message-quote-text span,
  .message-file-download,
  .message-deleted {
    color: #263849;
  }

  .message-meta,
  .message-read-meta,
  .voice-duration,
  .message-quote-text strong,
  .forward-label {
    color: #6e8396;
  }

  .message-file,
  .message-voice,
  .message-quote,
  .upload-preview,
  .voice-preview,
  .reply-banner {
    background: rgba(255, 255, 255, 0.56);
    border-color: rgba(193, 205, 216, 0.85);
  }

  .message-file-icon,
  .voice-play-btn {
    background: rgba(94, 165, 223, 0.12);
  }

  .reaction-chip {
    background: rgba(255, 255, 255, 0.62);
    border-color: rgba(193, 205, 216, 0.85);
    color: #5d7488;
  }

  .reaction-chip:hover {
    background: rgba(97, 161, 214, 0.16);
    color: #2e5675;
  }

  .composer {
    gap: 12px;
    padding: 18px 24px 20px;
    border-top: 1px solid rgba(193, 206, 220, 0.92);
    backdrop-filter: blur(18px);
  }

  .composer .ghost-btn,
  .attach-btn {
    background: #eef3f8;
    border: 1px solid #d3dee8;
    color: #42576a;
    box-shadow: none;
  }

  .composer .ghost-btn:hover,
  .attach-btn:hover {
    transform: none;
    background: #e8eef4;
  }

  .composer-main {
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid #d3dee8;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  }

  #message-input {
    color: #223546;
    font-size: 1rem;
  }

  #message-input::placeholder {
    color: #8f9baa;
  }
}

/* ────────────────────────────────────────────────
   MOBILE RESPONSIVE (≤960px)
   ──────────────────────────────────────────────── */
@media (max-width: 960px) {
  .app-shell {
    --layout-sidebar-width: 100vw;
    --layout-sidebar-top-min: 220px;
    --layout-content-header-min: 132px;
    --layout-composer-min: 104px;
    --layout-mobile-chrome-width: min(calc(100vw - 20px), 560px);
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0;
    width: 85%;
    max-width: 320px;
    padding-top: env(safe-area-inset-top, 0px);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 30;
  }

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

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

  .content {
    grid-template-rows:
      minmax(var(--layout-content-header-min), auto)
      auto
      auto
      auto
      minmax(var(--layout-stream-min), 1fr)
      minmax(var(--layout-composer-min), auto)
      auto;
  }

  .content-header,
  .call-banner,
  .pinned-banner,
  .search-bar,
  .messages,
  .composer {
    padding-left: 16px;
    padding-right: 16px;
  }

  .message {
    max-width: 85%;
  }

  .auth-shell {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .auth-brand {
    text-align: center;
  }

  .auth-brand p {
    max-width: 100%;
  }

  .settings-sidebar {
    width: 100%;
    border-left: none;
  }

  .settings-main-sidebar,
  .profile-sidebar {
    padding: 18px 16px 24px;
  }

  .settings-header {
    padding: 2px 0 16px;
    margin-bottom: 16px;
  }

  .settings-toolbar {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .settings-nav {
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
  }

  .settings-nav::-webkit-scrollbar {
    display: none;
  }

  .settings-section-head,
  .settings-field-grid,
  .settings-status-grid,
  .contact-share-card {
    grid-template-columns: 1fr;
  }

  .settings-submit-row {
    flex-direction: column;
    align-items: stretch;
  }

  .profile-quick-actions {
    grid-template-columns: 1fr;
  }

  .settings-action-grid {
    flex-direction: column;
  }

  .contact-share-card {
    justify-items: start;
  }

  .call-banner,
  .pinned-banner {
    align-items: flex-start;
  }

  .call-banner-actions,
  .pinned-banner-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .search-bar {
    grid-template-columns: minmax(0, 1fr) auto auto;
  }

  .search-pin-caption {
    grid-column: 1 / -1;
  }

  .app-shell {
    background: linear-gradient(180deg, #d6ebb2, #c5e39b 62%, #c0dd95);
  }

  .sidebar {
    width: 100%;
    max-width: none;
    background: linear-gradient(180deg, #d8ecb8, #c8e19f);
  }

  .sidebar-main {
    background: transparent;
  }

  .sidebar-top {
    margin: 14px 12px 12px;
    padding: 16px;
    background: rgba(249, 255, 240, 0.54);
    border: 1px solid rgba(164, 191, 120, 0.32);
    border-radius: 32px;
    backdrop-filter: blur(18px);
    box-shadow: 0 18px 36px rgba(124, 153, 83, 0.14);
  }

  .profile-card {
    margin-bottom: 14px;
    background: transparent;
  }

  .profile-card .avatar {
    box-shadow: 0 14px 24px rgba(88, 153, 63, 0.16);
  }

  .profile-meta strong {
    color: #20310d;
  }

  .profile-actions .ghost-btn,
  .sections-menu-trigger {
    background: rgba(255, 255, 255, 0.62);
    border: 1px solid rgba(164, 191, 120, 0.28);
    color: #345018;
    box-shadow: 0 10px 22px rgba(124, 153, 83, 0.12);
  }

  #chat-filter-input {
    background: rgba(255, 255, 255, 0.6);
    border-color: rgba(164, 191, 120, 0.28);
    color: #20310d;
  }

  #chat-filter-input::placeholder {
    color: #74855d;
  }

  .chat-list {
    padding: 0 12px 18px;
    background: transparent;
  }

  .chat-item {
    margin-bottom: 8px;
    background: rgba(250, 255, 244, 0.48);
    border: 1px solid rgba(164, 191, 120, 0.22);
    border-radius: 28px;
    box-shadow: 0 12px 26px rgba(124, 153, 83, 0.08);
    color: #223610;
  }

  .chat-item:hover {
    background: rgba(255, 255, 255, 0.62);
    border-color: rgba(164, 191, 120, 0.28);
  }

  .chat-item.active {
    background: rgba(252, 255, 247, 0.84);
    border-color: rgba(164, 191, 120, 0.34);
    box-shadow: 0 14px 30px rgba(124, 153, 83, 0.12);
  }

  .chat-item-topline strong {
    color: #20310d;
  }

  .chat-item-preview,
  .chat-item-time {
    color: #62764a;
  }

  .chat-unread {
    background: linear-gradient(180deg, #86cb53, #68b636);
  }

  .content {
    position: relative;
    background: linear-gradient(180deg, #dff1c0, #d2e9af 36%, #c7e29f);
    overflow: hidden;
  }

  .content::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
      radial-gradient(circle at 20% 18%, rgba(255, 255, 255, 0.4), transparent 28%),
      radial-gradient(circle at 85% 20%, rgba(255, 255, 255, 0.28), transparent 22%),
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cg fill='none' stroke='%2393b35f' stroke-width='1.4' opacity='0.22'%3E%3Ccircle cx='26' cy='28' r='8'/%3E%3Cpath d='M66 18c12 0 20 8 20 20-10 0-20-8-20-20Z'/%3E%3Cpath d='M108 48l18 18M126 48l-18 18'/%3E%3Cpath d='M26 108c8-14 18-22 30-24-2 12-10 24-30 24Z'/%3E%3Crect x='94' y='102' width='22' height='22' rx='5'/%3E%3Cpath d='M94 113h22'/%3E%3Cpath d='M54 124c0-8 6-14 14-14s14 6 14 14-6 14-14 14-14-6-14-14Z'/%3E%3Cpath d='M130 126c4-8 11-13 20-14-2 8-8 15-20 14Z'/%3E%3C/g%3E%3C/svg%3E");
    background-size: auto, auto, 160px 160px;
    background-repeat: no-repeat, no-repeat, repeat;
    pointer-events: none;
    opacity: 0.8;
  }

  .content > * {
    position: relative;
    z-index: 1;
  }

  body.chat-open-mobile.keyboard-open .app-shell {
    height: calc(var(--app-height) + var(--viewport-top-inset));
    margin-top: calc(var(--viewport-top-inset) * -1);
  }

  body.chat-open-mobile.keyboard-open #messages,
  body.chat-open-mobile.keyboard-open #empty-chat-state {
    padding-bottom: calc(112px + var(--viewport-bottom-inset));
  }

  .content-header,
  #call-banner,
  #pinned-message-banner,
  #chat-search-bar,
  .composer,
  .call-status {
    width: var(--layout-mobile-chrome-width);
    justify-self: center;
  }

  body.chat-open-mobile.keyboard-open .composer {
    position: fixed;
    left: 50%;
    bottom: calc(8px + var(--viewport-bottom-inset));
    width: var(--layout-mobile-chrome-width);
    margin: 0;
    transform: translateX(-50%);
    z-index: 12;
  }

  .content-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: center;
    justify-items: center;
    gap: 12px;
    padding: calc(12px + env(safe-area-inset-top, 0px)) 14px 10px;
    background: transparent;
    border-bottom: none;
  }

  .header-main {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    width: 100%;
  }

  #mobile-menu-btn,
  #mobile-back-btn,
  .content-header .icon-text-btn {
    background: rgba(252, 255, 247, 0.78);
    border: 1px solid rgba(167, 194, 125, 0.3);
    color: #233611;
    box-shadow: 0 16px 34px rgba(124, 153, 83, 0.15);
    backdrop-filter: blur(18px);
  }

  #mobile-menu-btn,
  #mobile-back-btn {
    width: 56px;
    height: 56px;
    border-radius: 28px;
    font-size: 1.8rem;
    line-height: 1;
  }

  .chat-header-toggle {
    min-height: 60px;
    padding: 12px 18px;
    background: rgba(252, 255, 247, 0.82);
    border: 1px solid rgba(167, 194, 125, 0.34);
    border-radius: 30px;
    box-shadow: 0 18px 36px rgba(124, 153, 83, 0.14);
    backdrop-filter: blur(20px);
  }

  .chat-header-toggle h2 {
    color: #1f320c;
    font-size: 1.18rem;
  }

  #chat-subtitle {
    color: #647a4b;
    font-size: 0.84rem;
  }

  .typing-line {
    color: #6a983b;
  }

  .content-header .actions {
    width: 100%;
    justify-content: center;
  }

  .content-header .icon-text-btn {
    width: auto;
    min-width: 144px;
    height: 52px;
    padding: 0 18px;
    border-radius: 999px;
    gap: 10px;
    font-weight: 700;
  }

  .content-header .icon-text-btn span:last-child {
    display: inline;
  }

  .call-banner,
  .pinned-banner,
  .search-bar {
    margin: 6px 12px 0;
    padding: 14px 16px;
    background: rgba(250, 255, 243, 0.8);
    border: 1px solid rgba(167, 194, 125, 0.32);
    border-radius: 30px;
    backdrop-filter: blur(20px);
    box-shadow: 0 16px 34px rgba(124, 153, 83, 0.12);
  }

  .call-banner,
  .pinned-banner {
    align-items: center;
  }

  .pinned-banner {
    border-left: none;
  }

  .call-banner-body strong,
  .pinned-banner-body strong {
    color: #1f320c;
  }

  #call-banner-text,
  #pinned-message-text {
    color: #587041;
  }

  .call-banner-actions,
  .pinned-banner-actions {
    width: auto;
    justify-content: flex-end;
    flex-wrap: nowrap;
  }

  .call-banner .ghost-btn,
  .call-banner .danger-btn,
  .pinned-banner .icon-only-btn,
  .search-bar .icon-only-btn {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid rgba(167, 194, 125, 0.3);
    color: #335216;
    box-shadow: none;
  }

  .search-pin-caption {
    background: rgba(119, 165, 66, 0.16);
    color: #5b8130;
  }

  .search-bar input {
    background: rgba(255, 255, 255, 0.62);
    border-color: rgba(167, 194, 125, 0.28);
    color: #1f320c;
  }

  .search-bar input::placeholder {
    color: #72875a;
  }

  .messages {
    padding: 18px 12px 12px;
    gap: 14px;
    background: transparent;
  }

  #empty-chat-state {
    justify-content: center;
    gap: 12px;
    padding: 96px 28px 36px;
    color: #3b5f1b;
    background: transparent;
  }

  #empty-chat-state .empty-icon {
    display: none;
  }

  #empty-chat-state h3 {
    margin: 0;
    color: #294313;
  }

  #empty-chat-state p {
    margin: 0;
    padding: 12px 18px;
    background: rgba(105, 164, 66, 0.72);
    color: white;
    border-radius: 999px;
  }

  .date-divider span {
    background: rgba(106, 167, 63, 0.8);
    color: white;
    box-shadow: 0 10px 18px rgba(111, 150, 69, 0.16);
  }

  .message {
    max-width: 90%;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(174, 200, 132, 0.28);
    border-radius: 30px 30px 30px 14px;
    box-shadow: 0 14px 30px rgba(117, 145, 82, 0.1);
  }

  .message.mine {
    background: linear-gradient(180deg, rgba(242, 255, 220, 0.98), rgba(224, 246, 176, 0.96));
    border-color: rgba(160, 207, 105, 0.34);
    border-radius: 30px 30px 14px 30px;
  }

  .message-body,
  .message-file-name,
  .message-file-download,
  .message-deleted {
    color: #223610;
  }

  .message-meta,
  .message-read-meta,
  .voice-duration,
  .message-quote-text strong {
    color: #67804b;
  }

  .forward-label {
    color: #5f9730;
  }

  .message-file,
  .message-voice,
  .message-quote,
  .reply-banner,
  .upload-preview,
  .voice-preview {
    background: rgba(255, 255, 255, 0.48);
    border-color: rgba(174, 200, 132, 0.32);
  }

  .message-file-icon,
  .voice-play-btn {
    background: rgba(118, 180, 63, 0.15);
    color: #4f7f22;
  }

  .reaction-chip {
    background: rgba(255, 255, 255, 0.56);
    border-color: rgba(174, 200, 132, 0.32);
    color: #55752d;
  }

  .reaction-chip:hover {
    background: rgba(145, 205, 85, 0.2);
    color: #365813;
  }

  .composer {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 10px;
    width: min(calc(100% - 20px), 560px);
    padding: 10px 12px calc(14px + env(safe-area-inset-bottom, 0px));
    margin: auto auto 0;
    background: transparent;
    border-top: none;
    backdrop-filter: none;
  }

  .composer .ghost-btn,
  .attach-btn {
    width: 52px;
    height: 52px;
    background: rgba(252, 255, 247, 0.88);
    border: 1px solid rgba(167, 194, 125, 0.34);
    color: #294313;
    box-shadow: 0 16px 32px rgba(124, 153, 83, 0.14);
  }

  .composer-main {
    min-height: 56px;
    padding: 8px 18px;
    background: rgba(252, 255, 247, 0.9);
    border: 1px solid rgba(167, 194, 125, 0.36);
    border-radius: 32px;
    box-shadow: 0 16px 32px rgba(124, 153, 83, 0.14);
  }

  .composer-main input {
    color: #21350f;
    font-size: 0.98rem;
  }

  .composer-main input::placeholder {
    color: #74855d;
  }

  .send-btn {
    width: auto;
    min-width: 142px;
    height: 54px;
    padding: 0 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border-radius: 999px;
    background: linear-gradient(180deg, #84d34d, #5ead2b);
    box-shadow: 0 18px 32px rgba(118, 180, 63, 0.3);
  }

  .send-btn:hover {
    transform: none;
    background: linear-gradient(180deg, #8ada54, #66b533);
  }

  .send-btn .btn-label {
    display: inline;
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.01em;
  }

}

/* ────────────────────────────────────────────────
   SMALL MOBILE (≤640px)
   ──────────────────────────────────────────────── */
@media (max-width: 640px) {
  .message {
    max-width: 92%;
  }

  .composer {
    gap: 8px;
    width: calc(100% - 16px);
    padding: 8px 10px calc(12px + env(safe-area-inset-bottom, 0px));
  }

  .content-header {
    padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 10px;
    gap: 10px;
  }

  .modal-card {
    padding: 18px;
  }

  .call-actions {
    grid-template-columns: 1fr 1fr;
  }

  .call-actions button:first-child {
    grid-column: span 2;
  }

  .header-main {
    gap: 10px;
  }

  .chat-header-toggle {
    gap: 1px;
    min-height: 52px;
    padding: 8px 14px;
  }

  .content-header .icon-text-btn {
    min-width: 132px;
    height: 48px;
    padding: 0 16px;
    border-radius: 24px;
  }

  .message-file {
    grid-template-columns: 1fr;
  }

  .message-voice {
    min-width: 0;
  }

  .voice-play-btn,
  .send-btn,
  .icon-only-btn,
  .attach-btn {
    width: 48px;
    height: 48px;
  }

  .send-btn {
    width: auto;
    min-width: 124px;
    padding: 0 16px;
  }

  .composer-main {
    padding: 7px 14px;
  }

  .composer-main input {
    padding: 6px 0;
    font-size: 0.96rem;
  }

  .send-btn .btn-label {
    font-size: 0.84rem;
  }

  .settings-header-copy h3 {
    font-size: 1.35rem;
  }

  .settings-section {
    padding: 20px;
  }

  .contact-qr {
    width: 120px;
    height: 120px;
  }

  .settings-submit-row button {
    width: 100%;
  }
}

/* ────────────────────────────────────────────────
   ANIMATIONS & MICRO-INTERACTIONS
   ──────────────────────────────────────────────── */
@keyframes messageAppear {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message {
  animation: messageAppear 0.2s ease;
}

@keyframes ripple {
  0% {
    box-shadow: 0 0 0 0 rgba(43, 127, 255, 0.4);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(43, 127, 255, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(43, 127, 255, 0);
  }
}

button:active {
  animation: ripple 0.4s ease-out;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-pill);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}
