/* ════════════════════════════════════════════
   Army Bank — Messenger PWA
   Army Bank visual system
   Light bank theme · Emerald + Gold accents
════════════════════════════════════════════ */

:root {
  /* ── Bank palette ─────────────────────── */
  --blue:        #1f6b4c;
  --blue-hover:  #18553d;
  --blue-light:  #e7f2ec;
  --blue-dim:    rgba(31,107,76,.12);
  --blue-glow:   rgba(31,107,76,.2);
  --sand:        #c4a064;
  --sand-light:  #f1e7d4;

  /* Surfaces */
  --sidebar-bg:  #edf2ef;
  --sidebar-active: #ffffff;
  --sidebar-text: #5f7267;
  --sidebar-text-active: #1f6b4c;

  --bg:          #f3f7f3;
  --surface:     #ffffff;
  --surface-2:   #f6faf7;
  --border:      #d8e4dd;
  --border-soft: #e7efe9;

  /* Text */
  --text:        #122419;
  --text-2:      #4f6558;
  --muted:       #8ea194;

  /* Status */
  --green:       #22c55e;
  --red:         #ef4444;
  --orange:      #f59e0b;
  --gold:        #c4a064;
  --assistant-badge: #f2f8f4;
  --assistant-badge-ring: rgba(31,107,76,.2);
  --assistant-card-start: #103b2d;
  --assistant-card-mid: #1f6b4c;
  --assistant-card-end: #9a7841;
  --assistant-card-glow: rgba(15,59,45,.22);

  /* Shape */
  --radius:      12px;
  --radius-lg:   16px;
  --radius-sm:   8px;
  --radius-xs:   6px;
  --shadow:      0 2px 12px rgba(30,40,80,.07);
  --shadow-lg:   0 8px 32px rgba(30,40,80,.10);

  /* Layout */
  --sidebar-w:   300px;
  --topbar-h:    60px;

  /* Fonts */
  --font:        'Manrope', system-ui, -apple-system, sans-serif;
  --font-mono:   'JetBrains Mono', ui-monospace, monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
html.overlay-lock, body.overlay-lock { overscroll-behavior: none; }
body.overlay-lock #app { pointer-events: none; }
body.overlay-lock .modal-overlay:not([hidden]),
body.overlay-lock .call-incoming:not([hidden]),
body.overlay-lock .call-screen:not([hidden]),
body.overlay-lock .photo-viewer:not([hidden]) { pointer-events: auto; }

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d0d5e4; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #b8bdd0; }

/* ════════════════════════════════════════════
   AUTH — SPLIT LOGIN (ref: Nummus Bank)
════════════════════════════════════════════ */
.auth-screen {
  position: fixed; inset: 0;
  display: flex;
  z-index: 100;
  background:
    radial-gradient(circle at 14% 10%, rgba(31,107,76,.12), transparent 42%),
    radial-gradient(circle at 92% 88%, rgba(196,160,100,.14), transparent 46%),
    linear-gradient(135deg, #ecf4ef 0%, #f2f7f4 42%, #edf4ef 100%);
}

.auth-form-panel {
  flex: 0 0 46%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 46px 42px;
  background: linear-gradient(180deg, rgba(255,255,255,.86), rgba(255,255,255,.62));
  border-right: 1px solid rgba(31,107,76,.10);
}
.auth-form-inner {
  width: min(440px, 100%);
  border-radius: 24px;
  border: 1px solid rgba(31,107,76,.14);
  background: rgba(255,255,255,.92);
  box-shadow: 0 22px 46px rgba(20, 44, 34, .12);
  padding: 30px 30px 26px;
}
.auth-form-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 0 12px 0 8px;
  border-radius: 999px;
  border: 1px solid rgba(31,107,76,.2);
  background: linear-gradient(180deg, rgba(236,247,241,.94), rgba(230,243,235,.94));
  color: #2c5c45;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: 16px;
}
.auth-form-kicker img {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  display: block;
}
.auth-form-title {
  font-size: 32px;
  font-weight: 780;
  letter-spacing: -.02em;
  color: var(--text);
  margin-bottom: 26px;
}

.field-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 20px; }
.field-label {
  font-size: 12px; font-weight: 600; color: var(--text-2);
  text-transform: uppercase; letter-spacing: .04em;
}
.field-input {
  width: 100%; background: var(--surface);
  border: 1.5px solid var(--border); border-radius: var(--radius-xs);
  padding: 12px 14px; color: var(--text);
  font-family: var(--font); font-size: 15px; outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.field-input::placeholder { color: var(--muted); }
.field-input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-dim); }

.field-password-wrap { position: relative; }
.field-password-wrap .field-input { padding-right: 48px; }
.btn-eye {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  color: var(--muted); padding: 4px; transition: color .15s;
}
.btn-eye:hover { color: var(--text-2); }

.auth-error {
  background: rgba(239,68,68,.08); border: 1px solid rgba(239,68,68,.25);
  border-radius: var(--radius-xs); padding: 10px 14px;
  color: var(--red); font-size: 14px; margin-bottom: 16px;
}

.btn-primary {
  width: 100%; background: var(--blue); color: #fff; border: none;
  border-radius: var(--radius-xs); padding: 13px;
  font-family: var(--font); font-size: 15px; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: background .15s, transform .1s;
}
.btn-primary:hover { background: var(--blue-hover); }
.btn-primary:active { transform: scale(.98); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.auth-hint { text-align: center; font-size: 13px; color: var(--muted); margin-top: 24px; }

.auth-switch {
  text-align: center; font-size: 13px; color: var(--text-2); margin-top: 20px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.auth-switch-link {
  background: none; border: none; cursor: pointer;
  color: var(--blue); font-size: 13px; font-weight: 600;
  padding: 0; text-decoration: underline; text-underline-offset: 2px;
  transition: color .15s;
}
.auth-switch-link:hover { color: var(--blue-hover); }

/* Right branded panel */
.auth-brand-panel {
  flex: 1;
  background: linear-gradient(144deg, #0f3b2d 0%, #1f6b4c 54%, #8f6f39 120%);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
}
.auth-brand-shell {
  width: min(460px, calc(100% - 56px));
  border-radius: 28px;
  border: 1px solid rgba(255,255,255,.2);
  background:
    linear-gradient(155deg, rgba(255,255,255,.18), rgba(255,255,255,.06));
  box-shadow: 0 26px 50px rgba(6, 18, 14, .30);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  padding: 34px 28px 30px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.auth-brand-logo {
  width: 128px;
  height: 128px;
  opacity: .96;
  filter: drop-shadow(0 10px 22px rgba(0,0,0,.22));
}
.auth-brand-name {
  font-size: clamp(30px, 3.1vw, 40px);
  font-weight: 780;
  color: #f4fbf5;
  margin-top: 16px;
  letter-spacing: -.02em;
  line-height: 1.04;
}
.auth-brand-sub {
  margin-top: 14px;
  color: rgba(236, 249, 240, .86);
  font-size: 16px;
  line-height: 1.5;
  max-width: 420px;
}
.auth-brand-pills {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.auth-brand-pills span {
  min-height: 30px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.23);
  background: rgba(255,255,255,.13);
  color: rgba(244, 252, 246, .92);
  font-size: 12px;
  font-weight: 670;
  display: inline-flex;
  align-items: center;
}
.auth-brand-panel::before, .auth-brand-panel::after {
  content: ''; position: absolute; border-radius: 50%; background: rgba(255,255,255,.04);
}
.auth-brand-panel::before { width: 420px; height: 420px; top: -120px; right: -90px; }
.auth-brand-panel::after { width: 320px; height: 320px; bottom: -70px; left: -70px; }

.spinner {
  width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff; border-radius: 50%;
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ════════════════════════════════════════════
   APP LAYOUT
════════════════════════════════════════════ */
.app { display: flex; height: 100dvh; overflow: hidden; background: var(--bg); }

/* ════════════════════════════════════════════
   SIDEBAR — lavender
════════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; display: flex; flex-direction: column;
  background:
    radial-gradient(circle at 12% 0, rgba(31,107,76,.08), transparent 34%),
    linear-gradient(180deg, #eef4f0, #eaf1ed);
  overflow: hidden;
  border-right: 1px solid rgba(18,56,38,.08);
  box-shadow: inset -1px 0 0 rgba(255,255,255,.38);
}
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between; padding: 18px 18px 14px;
  border-bottom: 1px solid rgba(31,107,76,.08);
}
.sidebar-header-left { display: flex; align-items: center; gap: 10px; }
.sidebar-logo-icon {
  width: 36px; height: 36px; background: var(--blue); border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 14px;
  box-shadow: 0 2px 8px rgba(74,124,250,.3);
}
.sidebar-logo-icon img {
  width: 24px;
  height: 24px;
  display: block;
}
.sidebar-title { font-size: 16px; font-weight: 700; color: var(--text); }
.sidebar-header-right { display: flex; gap: 2px; }
#btn-sidebar-logout {
  color: #7e8f84;
}
#btn-sidebar-logout:hover {
  color: #b5464a;
  background: rgba(181,70,74,.1);
}

.sidebar-search { position: relative; padding: 10px 12px 10px; }
.search-icon {
  position: absolute; left: 24px; top: 50%; transform: translateY(-50%);
  color: var(--muted); pointer-events: none;
}
.sidebar-search .search-icon { top: calc(50% - 5px); }
.search-input {
  width: 100%; background: var(--surface); border: 1.5px solid transparent;
  border-radius: 24px; padding: 9px 14px 9px 36px;
  color: var(--text); font-family: var(--font); font-size: 13px;
  outline: none; transition: border-color .2s, box-shadow .2s; box-shadow: var(--shadow);
}
.search-input::placeholder { color: var(--muted); }
.search-input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-dim); }

.diag-card {
  margin: 0 12px 10px;
  border-radius: 12px;
  border: 1px solid rgba(31,107,76,.16);
  background: linear-gradient(180deg, rgba(255,255,255,.88), rgba(246,250,247,.9));
  box-shadow: 0 8px 20px rgba(20,49,36,.08);
  padding: 10px 10px 8px;
}
.diag-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.diag-title {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #4f6558;
}
.diag-refresh {
  border: 1px solid rgba(31,107,76,.2);
  background: rgba(255,255,255,.75);
  color: #1f6b4c;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.diag-refresh:hover {
  background: rgba(231,242,236,.9);
  border-color: rgba(31,107,76,.32);
}
.diag-grid { display: grid; gap: 6px; }
.diag-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid rgba(31,107,76,.1);
  background: rgba(255,255,255,.62);
}
.diag-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #94a3b8;
  box-shadow: 0 0 0 3px rgba(148,163,184,.18);
}
.diag-row[data-state="ok"] .diag-dot {
  background: #16a34a;
  box-shadow: 0 0 0 3px rgba(22,163,74,.2);
}
.diag-row[data-state="warn"] .diag-dot {
  background: #d97706;
  box-shadow: 0 0 0 3px rgba(217,119,6,.19);
}
.diag-row[data-state="bad"] .diag-dot {
  background: #dc2626;
  box-shadow: 0 0 0 3px rgba(220,38,38,.17);
}
.diag-label {
  font-size: 12px;
  color: #32483d;
  font-weight: 650;
}
.diag-note {
  margin-top: 8px;
  font-size: 11px;
  color: #5f7267;
  line-height: 1.35;
}
.diag-actions {
  margin-top: 8px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}
.diag-action-btn {
  min-height: 32px;
  border-radius: 9px;
  border: 1px solid rgba(31,107,76,.16);
  background: rgba(255,255,255,.78);
  color: #1f5a41;
  font-size: 12px;
  font-weight: 680;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.diag-action-btn:hover {
  background: rgba(239,248,243,.95);
  border-color: rgba(31,107,76,.28);
}
.diag-action-btn:disabled {
  opacity: .58;
  cursor: wait;
}

.conv-list { flex: 1; overflow-y: auto; padding: 8px 8px 10px; }
.conv-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 60px 24px; color: var(--muted); font-size: 13px;
  text-align: center; line-height: 1.6;
}
.conv-empty svg { opacity: .4; }

.conv-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; cursor: pointer;
  border-radius: 14px;
  transition: background .15s, box-shadow .15s, border-color .15s, transform .12s;
  margin-bottom: 4px;
  position: relative;
  border: 1px solid transparent;
  background: rgba(255,255,255,.58);
  min-height: 64px;
}
.conv-item:hover {
  background: rgba(255,255,255,.9);
  border-color: rgba(31,107,76,.14);
  transform: translateY(-1px) scale(1.003);
}
.conv-item.active {
  background: var(--sidebar-active);
  border-color: rgba(31,107,76,.24);
  box-shadow: 0 11px 24px rgba(20,49,36,.13);
}
.conv-item.active::before {
  content: '';
  position: absolute;
  left: -1px;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 999px;
  background: linear-gradient(180deg, #1f6b4c, #c4a064);
}
.conv-item.active .conv-name { color: var(--blue); }

.conv-avatar {
  width: 44px; height: 44px; border-radius: 50%; background: var(--blue-light);
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700; color: var(--blue); text-transform: uppercase;
  border: 1px solid rgba(31,107,76,.14);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.55);
}
.conv-item.active .conv-avatar {
  background: linear-gradient(145deg, #1f6b4c, #2f7b59);
  color: #fff;
  border-color: rgba(31,107,76,.25);
}

.conv-info { flex: 1; min-width: 0; }
.conv-name {
  font-size: 14px; font-weight: 600; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; color: var(--text); transition: color .15s;
}
.conv-name.with-verified {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
}
.conv-preview {
  font-size: 12px; color: #5f7267; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; margin-top: 2px;
}
.conv-preview-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
}
.conv-preview-icon {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #4f6f5f;
  background: rgba(31,107,76,.09);
  flex-shrink: 0;
  font-size: 11px;
  line-height: 1;
}
.conv-preview-icon svg {
  width: 12px;
  height: 12px;
  display: block;
}
.conv-preview-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.conv-time { font-size: 11px; color: var(--muted); font-family: var(--font-mono); }
.conv-unread {
  background: var(--blue); color: #fff; font-size: 11px; font-weight: 700;
  border-radius: 999px;
  padding: 1px 7px;
  min-width: 18px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(31,107,76,.28);
}

/* ════════════════════════════════════════════
   CHAT AREA
════════════════════════════════════════════ */
.chat-area {
  flex: 1; display: flex; flex-direction: column; min-width: 0;
  background: var(--bg); position: relative;
}

.chat-topbar {
  display: flex; align-items: center; justify-content: space-between;
  height: var(--topbar-h); padding: 0 24px;
  background: var(--surface); border-bottom: 1px solid var(--border-soft); flex-shrink: 0;
}
.chat-topbar-section {
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .08em; color: var(--muted);
}
.chat-topbar-right { display: flex; align-items: center; gap: 14px; }
.network-pill {
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}
.network-pill[data-state="ok"] {
  color: #2e8a5f;
  border-color: rgba(46,138,95,.25);
  background: rgba(46,138,95,.08);
}
.network-pill[data-state="warn"] {
  color: #8a6a2a;
  border-color: rgba(180,140,70,.3);
  background: rgba(205,165,88,.14);
}
.network-pill[data-state="bad"] {
  color: #b43646;
  border-color: rgba(229,89,89,.34);
  background: rgba(229,89,89,.11);
}
.topbar-bell {
  width: 36px; height: 36px; border-radius: 50%; border: none;
  background: var(--surface-2); color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .15s; position: relative;
}
.topbar-bell:hover { background: var(--blue-light); color: var(--blue); }
.topbar-bell .badge {
  position: absolute; top: 2px; right: 2px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--red); border: 2px solid var(--surface);
}
.topbar-avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--blue);
  color: #fff; font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  text-transform: uppercase; cursor: pointer;
}

.chat-empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px; padding: 40px; text-align: center;
}
.chat-empty-icon { opacity: .35; }
.chat-empty-title { font-size: 18px; font-weight: 600; color: var(--text-2); }
.chat-empty-sub { font-size: 13px; color: var(--muted); }

.chat-view { display: flex; flex-direction: column; height: 100%; }

.chat-header {
  display: flex; align-items: center; gap: 14px; padding: 14px 24px;
  background:
    radial-gradient(circle at 0 0, rgba(31,107,76,.06), transparent 38%),
    linear-gradient(180deg, #ffffff, #f7fbf8);
  border-bottom: 1px solid var(--border-soft);
  box-shadow: 0 1px 0 rgba(255,255,255,.65);
  flex-shrink: 0;
}
.back-btn { display: none; }
.chat-header-avatar {
  width: 42px; height: 42px; border-radius: 50%; background: var(--blue-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; color: var(--blue);
  text-transform: uppercase; flex-shrink: 0;
}
.chat-header-avatar.assistant {
  background: var(--assistant-badge);
  border: 1px solid var(--assistant-badge-ring);
  color: var(--blue);
}
.chat-header-name { font-size: 15px; font-weight: 700; color: var(--text); }
.chat-header-name.with-verified {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.chat-header-status { font-size: 12px; color: var(--text-2); font-family: var(--font-mono); margin-top: 1px; }
.chat-header-status.online { color: #2f7f59; }
.chat-header-status.online::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
  vertical-align: middle;
  background: #2fb470;
  box-shadow: 0 0 0 3px rgba(47,180,112,.14);
}
.chat-header-info {
  min-width: 0;
  flex: 1;
}
.chat-header-name,
.chat-header-status {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.assistant-panel {
  margin: 12px 24px 0;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(21,66,49,.14);
  box-shadow: 0 14px 28px var(--assistant-card-glow);
  background:
    radial-gradient(circle at 90% 12%, rgba(255,255,255,.24), transparent 30%),
    linear-gradient(138deg, var(--assistant-card-start), var(--assistant-card-mid) 58%, var(--assistant-card-end));
  color: #f2faf4;
}
.assistant-panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.assistant-panel-avatar {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.13);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.assistant-panel-title {
  font-size: 17px;
  font-weight: 760;
  letter-spacing: -.01em;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.assistant-panel-sub {
  margin-top: 2px;
  color: rgba(240, 251, 244, .84);
  font-size: 13px;
  line-height: 1.45;
}
.assistant-quick-actions {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.assistant-quick-btn {
  min-height: 34px;
  border-radius: 11px;
  border: 1px solid rgba(255,255,255,.22);
  background: rgba(255,255,255,.14);
  color: #f3fbf5;
  font-size: 12px;
  font-weight: 680;
  letter-spacing: .01em;
  padding: 0 11px;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease, transform .1s ease;
}
.assistant-quick-btn:hover {
  background: rgba(255,255,255,.22);
  border-color: rgba(255,255,255,.34);
}
.assistant-quick-btn:active { transform: translateY(1px); }
.assistant-quick-btn:disabled { opacity: .62; cursor: wait; }

.messages-wrap {
  flex: 1; overflow-y: auto; padding: 20px 24px;
  display: flex; flex-direction: column;
  overscroll-behavior: contain;
  background:
    radial-gradient(circle at 8% 12%, rgba(31,107,76,.06), transparent 32%),
    radial-gradient(circle at 92% 86%, rgba(196,160,100,.07), transparent 34%),
    linear-gradient(180deg, #f4f8f4, #f1f6f2);
}
.chat-view.assistant-chat .messages-wrap {
  background:
    radial-gradient(circle at 8% 12%, rgba(31,107,76,.08), transparent 34%),
    radial-gradient(circle at 92% 86%, rgba(196,160,100,.12), transparent 36%),
    linear-gradient(180deg, #f2f7f3, #eef5f1);
}
.messages-list {
  width: min(100%, 980px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  justify-content: flex-end;
}
.scroll-anchor { height: 1px; flex-shrink: 0; }

.scroll-bottom-fab {
  position: absolute;
  right: 26px;
  bottom: 94px;
  z-index: 24;
  min-height: 38px;
  border-radius: 999px;
  border: 1px solid rgba(18, 58, 42, .16);
  background: rgba(255,255,255,.95);
  color: #1a4f39;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .01em;
  cursor: pointer;
  box-shadow: 0 12px 26px rgba(16, 44, 33, .18);
  backdrop-filter: blur(8px);
  transform: translateY(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease, background .16s ease, border-color .16s ease;
}
.scroll-bottom-fab.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.scroll-bottom-fab:hover {
  background: #ffffff;
  border-color: rgba(18, 58, 42, .24);
}
.scroll-bottom-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(31,107,76,.1);
  font-size: 13px;
  line-height: 1;
}
.scroll-bottom-label { font-family: var(--font-main); }
.scroll-bottom-unread {
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  background: linear-gradient(140deg, #1f6b4c, #2e8a5f);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  font-size: 10px;
  font-family: var(--font-mono);
  box-shadow: 0 6px 12px rgba(17, 63, 45, .28);
}

.msg-date-divider {
  text-align: center;
  margin: 14px 0 8px;
  color: #7f9488;
  font-size: 11px; font-family: var(--font-mono); position: relative;
  letter-spacing: .02em;
}
.msg-date-divider::before, .msg-date-divider::after {
  content: ''; position: absolute; top: 50%; width: calc(50% - 60px); height: 1px; background: var(--border);
}
.msg-date-divider::before { left: 0; }
.msg-date-divider::after { right: 0; }

.msg-bubble-wrap {
  display: flex; align-items: flex-end; gap: 8px; max-width: 65%;
  animation: fadeSlideUp .2s ease both;
}
@keyframes fadeSlideUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.msg-bubble-wrap.me { align-self: flex-end; flex-direction: row-reverse; }
.msg-bubble-wrap.them { align-self: flex-start; }
.msg-bubble-wrap.them.assistant { max-width: min(78%, 760px); }

.msg-sender-avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--blue-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: var(--blue); flex-shrink: 0; text-transform: uppercase;
}
.msg-sender-avatar.assistant {
  background: var(--assistant-badge);
  border: 1px solid var(--assistant-badge-ring);
}

.msg-bubble {
  padding: 11px 15px;
  border-radius: 17px;
  font-size: 14px;
  line-height: 1.55; word-break: break-word; position: relative;
}
.msg-bubble-wrap.me .msg-bubble {
  background: linear-gradient(150deg, #1f6b4c, #2a7a58);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 10px 18px rgba(22,64,46,.2);
}
.msg-bubble-wrap.them .msg-bubble {
  background: rgba(255,255,255,.95);
  color: var(--text);
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(21,66,49,.12);
  box-shadow: 0 8px 16px rgba(17,43,31,.07);
}
.msg-bubble-wrap.them.assistant .msg-bubble {
  background:
    linear-gradient(145deg, rgba(255,255,255,.98), rgba(240,249,244,.95));
  border: 1px solid rgba(31,107,76,.18);
  box-shadow: 0 10px 20px rgba(17,43,31,.08);
}
.msg-bubble.deleted { opacity: .45; font-style: italic; }
.msg-deleted-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 4px;
  font-style: normal;
}
.msg-link {
  color: #2a6dba;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.msg-bubble-wrap.me .msg-link {
  color: rgba(255,255,255,.95);
}

.assistant-statement-bubble {
  min-width: min(420px, 100%);
  width: min(100%, 520px);
  max-width: 100%;
  border-radius: 16px;
  background: linear-gradient(152deg, #ffffff, #f4fbf7);
  border: 1px solid rgba(31,107,76,.2);
  box-shadow: 0 10px 26px rgba(16, 45, 33, .12);
  padding: 12px 12px 11px;
}
.assistant-statement-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.assistant-statement-icon {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, rgba(31,107,76,.14), rgba(196,160,100,.18));
  color: #1f6b4c;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}
.assistant-statement-title {
  font-size: 13px;
  font-weight: 760;
  color: #153325;
}
.assistant-statement-period {
  margin-top: 1px;
  font-size: 11px;
  color: #5b7164;
  font-family: var(--font-mono);
}
.assistant-statement-summary {
  color: #355548;
  font-size: 12px;
  line-height: 1.45;
  margin-bottom: 9px;
}
.assistant-statement-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: 10px;
  padding: 0 12px;
  background: #1f6b4c;
  color: #fff;
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .01em;
}
.assistant-statement-btn:hover {
  background: #18553d;
}
.assistant-statement-note {
  margin-top: 6px;
  font-size: 11px;
  color: #6e8679;
}

.msg-time { font-size: 10px; color: var(--muted); font-family: var(--font-mono); margin-top: 3px; padding: 0 4px; }
.msg-bubble-wrap.me .msg-time { text-align: right; }
.msg-bubble-wrap.them .msg-time { text-align: left; }
.msg-inner { display: flex; flex-direction: column; }

.msg-input-bar {
  display: flex; align-items: flex-end; gap: 10px; padding: 14px 24px;
  border-top: 1px solid rgba(21,66,49,.1);
  background:
    linear-gradient(180deg, rgba(255,255,255,.92), rgba(247,252,249,.92));
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  flex-shrink: 0;
  box-shadow: 0 -10px 28px rgba(14,43,31,.08);
}
.msg-input {
  flex: 1; background: var(--surface-2); border: 1.5px solid var(--border);
  border-radius: 22px; padding: 11px 18px; color: var(--text);
  font-family: var(--font); font-size: 14px; outline: none; resize: none;
  max-height: 120px; overflow-y: auto; transition: border-color .2s, box-shadow .2s; line-height: 1.5;
}
.msg-input::placeholder { color: var(--muted); }
.msg-input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-dim); }

.btn-send {
  width: 42px; height: 42px; border-radius: 50%; background: var(--blue); border: none;
  color: #fff; display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0; transition: background .15s, transform .1s;
  box-shadow: 0 2px 10px var(--blue-glow);
}
.btn-send:hover { background: var(--blue-hover); }
.btn-send:active { transform: scale(.93); }
.btn-send:disabled { opacity: .35; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-attach {
  width: 42px; height: 42px; border-radius: 50%;
  border: 1.5px solid rgba(196,160,100,.38);
  background: linear-gradient(180deg, #fff8ec, #f7edd9);
  color: #9f7a3f;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s, transform .12s ease;
}
.btn-attach:hover {
  border-color: rgba(196,160,100,.62);
  background: linear-gradient(180deg, #fdf3df, #f5e8ce);
  color: #8f6a2f;
}
.btn-attach:active { transform: scale(.95); }

/* ════════════════════════════════════════════
   MODAL
════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(26,29,46,.35);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; z-index: 200; padding: 16px;
}
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  width: min(480px, 100%); max-height: 80dvh; display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg); overflow: hidden;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 22px 16px; border-bottom: 1px solid var(--border-soft); flex-shrink: 0;
}
.modal-title { font-size: 17px; font-weight: 700; color: var(--text); }
.modal-close { color: var(--muted); }
.modal-search { position: relative; padding: 12px 16px; flex-shrink: 0; }
.modal-search .search-icon { left: 28px; top: 50%; }
.modal-search .search-input { border-radius: var(--radius-sm); box-shadow: none; border: 1.5px solid var(--border); }
.modal-search .search-input:focus { border-color: var(--blue); }

.user-search-results { flex: 1; overflow-y: auto; padding: 4px 10px 14px; }
.search-hint { text-align: center; color: var(--muted); font-size: 13px; padding: 32px 16px; }
.user-result-item {
  display: flex; align-items: center; gap: 12px; padding: 10px;
  border-radius: var(--radius-sm); cursor: pointer; transition: background .15s;
}
.user-result-item:hover { background: var(--blue-light); }
.user-result-avatar {
  width: 40px; height: 40px; border-radius: 50%; background: var(--blue-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: var(--blue); flex-shrink: 0; text-transform: uppercase;
}
.user-result-name { font-size: 14px; font-weight: 600; color: var(--text); }
.user-result-meta { font-size: 12px; color: var(--text-2); font-family: var(--font-mono); margin-top: 2px; }

/* Call settings modal */
.call-settings-list {
  padding: 12px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}
.call-setting-row,
.call-setting-block {
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: var(--surface-2);
  padding: 12px 12px;
}
.call-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.call-setting-row-split {
  align-items: flex-start;
}
.call-setting-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.call-setting-sub {
  font-size: 12px;
  line-height: 1.35;
  color: var(--muted);
  font-weight: 500;
}
.call-setting-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.call-setting-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.call-setting-inline {
  display: flex;
  align-items: center;
  gap: 10px;
}
.call-setting-inline input[type="range"] {
  width: 100%;
  accent-color: var(--blue);
}
.call-setting-inline span {
  min-width: 44px;
  text-align: right;
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
}
.call-setting-hint {
  margin-top: -2px;
  margin-bottom: 2px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: rgba(31,107,76,.06);
  color: #2f6650;
  font-size: 12px;
  line-height: 1.35;
  padding: 9px 10px;
}
.call-settings-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.call-settings-advanced {
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: var(--surface-2);
  overflow: hidden;
}
.call-settings-advanced-summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  padding: 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.call-settings-advanced-summary::-webkit-details-marker {
  display: none;
}
.call-settings-advanced-summary::after {
  content: '▾';
  font-size: 12px;
  color: var(--text-2);
  transition: transform .18s ease;
}
.call-settings-advanced[open] .call-settings-advanced-summary::after {
  transform: rotate(180deg);
}
.diag-card-in-settings {
  margin: 0;
  border: 0;
  border-top: 1px solid var(--border-soft);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  padding: 10px 12px 12px;
}

/* Bank tools modal */
.btn-primary.btn-secondary {
  background: #edf5f0;
  color: #1f6b4c;
  border: 1px solid #cfe0d6;
}
.btn-primary.btn-secondary:hover {
  background: #e4efe8;
  border-color: #bfd4c7;
}
.bank-tools-list {
  padding: 12px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bank-link-status {
  font-size: 12px;
  color: var(--text-2);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 8px 10px;
  background: var(--surface-2);
}
.bank-link-status.warn {
  border-color: rgba(239, 68, 68, .22);
  color: #b42335;
  background: #fff5f5;
}
.bank-account-chip {
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(15,59,45,.95), rgba(44,98,72,.95));
  color: #effbf4;
  padding: 12px;
  display: grid;
  gap: 8px;
}
.bank-chip-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 12px;
}
.bank-chip-line strong {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: .02em;
}
.bank-tools-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.bank-period-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.bank-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--text-2);
}
.bank-field input,
.bank-field select {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  padding: 10px 11px;
  outline: none;
}
.bank-field input:focus,
.bank-field select:focus {
  border-color: var(--blue);
}
.bank-tools-hint {
  margin: 0;
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.45;
}
.bank-tools-hint code {
  font-family: var(--font-mono);
  font-size: 11px;
  background: #f2f4fa;
  border: 1px solid #dce4f3;
  border-radius: 7px;
  padding: 1px 5px;
}

/* ════════════════════════════════════════════
   COMMON
════════════════════════════════════════════ */
.icon-btn {
  background: none; border: none; cursor: pointer; color: var(--text-2);
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--blue-light); color: var(--blue); }

.toast {
  position: fixed; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%) translateY(12px);
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  font-size: 13px; padding: 10px 20px; border-radius: 24px; box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s;
  white-space: normal; text-align: center; line-height: 1.35;
  z-index: 999; max-width: min(calc(100vw - 24px), 720px);
  overflow-wrap: anywhere;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-color: rgba(239,68,68,.3); color: var(--red); }

/* ════════════════════════════════════════════
   CHAT HEADER ACTIONS (call button)
════════════════════════════════════════════ */
.chat-header-actions { margin-left: auto; display: flex; gap: 4px; }
#btn-chat-logout { display: none; }
#btn-call.active-call {
  background: rgba(31,107,76,.14);
  color: #1f6b4c;
  box-shadow: inset 0 0 0 1px rgba(31,107,76,.22);
}
#btn-call.busy {
  opacity: .62;
  pointer-events: none;
}

/* ════════════════════════════════════════════
   VOICE RECORD BUTTON
════════════════════════════════════════════ */
.btn-voice {
  width: 42px; height: 42px; border-radius: 50%; border: 1.5px solid var(--border);
  background: var(--surface-2); color: var(--text-2); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .15s, border-color .15s, color .15s, transform .12s ease;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.btn-voice:hover { background: var(--blue-light); border-color: var(--blue); color: var(--blue); }
.btn-voice:active { transform: scale(.98); }
.btn-voice.recording {
  background: var(--red); border-color: var(--red); color: #fff;
  animation: pulse-record 1s ease infinite;
}
@keyframes pulse-record {
  0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,.4); }
  50%      { box-shadow: 0 0 0 8px rgba(239,68,68,0); }
}

/* Voice message bubble */
.voice-bubble { min-width: 220px; }
.voice-player {
  display: flex; flex-direction: column; align-items: stretch; gap: 8px; min-width: 220px;
}
.voice-player-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .01em;
}
.voice-icon {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255,255,255,.16);
}
.voice-title { opacity: .94; }
.voice-wave {
  display: flex;
  align-items: end;
  gap: 3px;
  height: 16px;
}
.voice-wave span {
  width: 4px;
  border-radius: 6px;
  background: currentColor;
  opacity: .7;
}
.voice-wave span:nth-child(1) { height: 5px; }
.voice-wave span:nth-child(2) { height: 12px; }
.voice-wave span:nth-child(3) { height: 8px; }
.voice-wave span:nth-child(4) { height: 14px; }
.voice-wave span:nth-child(5) { height: 6px; }
.recording-indicator .voice-wave span {
  animation: rec-wave 1s ease-in-out infinite;
}
.recording-indicator .voice-wave span:nth-child(2) { animation-delay: .08s; }
.recording-indicator .voice-wave span:nth-child(3) { animation-delay: .16s; }
.recording-indicator .voice-wave span:nth-child(4) { animation-delay: .24s; }
.recording-indicator .voice-wave span:nth-child(5) { animation-delay: .32s; }
@keyframes rec-wave {
  0%,100% { transform: scaleY(.72); opacity: .55; }
  50% { transform: scaleY(1.28); opacity: .9; }
}
.voice-player audio {
  height: 34px;
  width: 100%;
  outline: none;
  border-radius: 12px;
}
.msg-bubble-wrap.me .voice-player audio {
  filter: saturate(.85) brightness(1.04);
}
.msg-bubble-wrap.them .voice-icon {
  background: var(--blue-light);
}
.msg-bubble-wrap.them .voice-title {
  color: var(--text-2);
}

/* Image message bubble */
.image-bubble {
  padding: 4px;
  background: transparent;
  border: 0;
}
.photo-stack {
  display: grid;
  gap: 6px;
  border-radius: 14px;
  overflow: hidden;
  min-width: 180px;
  max-width: min(66vw, 360px);
  background: rgba(17,33,24,.08);
  padding: 4px;
}
.photo-stack.count-1 { grid-template-columns: 1fr; }
.photo-stack.count-2 { grid-template-columns: 1fr 1fr; }
.photo-stack.count-3 {
  grid-template-columns: 1.1fr .9fr;
  grid-template-rows: 1fr 1fr;
}
.photo-stack.count-3 .photo-tile:first-child { grid-row: span 2; min-height: 202px; }
.photo-stack.count-4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.photo-tile {
  position: relative;
  display: block;
  border: 0;
  padding: 0;
  border-radius: 12px;
  overflow: hidden;
  background: #1f3428;
  min-height: 112px;
  cursor: zoom-in;
}
.photo-tile.loading {
  background: linear-gradient(90deg, rgba(26,52,40,.72), rgba(39,74,57,.74), rgba(26,52,40,.72));
  background-size: 200% 100%;
  animation: photo-shimmer 1.15s linear infinite;
}
.photo-tile::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 60%, rgba(0,0,0,.18));
  pointer-events: none;
}
.photo-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  filter: blur(14px) saturate(.92);
  transform: scale(1.001);
  transition: transform .26s ease, filter .28s ease, opacity .24s ease;
}
.photo-tile.ready img,
.photo-tile img.ready {
  opacity: 1;
  filter: blur(0) saturate(1);
}
.photo-tile.error::before {
  content: 'Фото недоступне';
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,.9);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
  background: rgba(9,12,16,.42);
}
.photo-tile:hover img { transform: scale(1.03); filter: blur(0) saturate(1.03); }
.photo-more {
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 2;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(10,16,22,.62);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  backdrop-filter: blur(2px);
}

/* Recording mode strip */
.recording-indicator {
  --swipe-progress: 0;
  position: relative;
  overflow: hidden;
  flex: 1;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border: 1.5px solid rgba(239,68,68,.32);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(239,68,68,.10), rgba(239,68,68,.06));
  transition: border-color .18s ease, background .18s ease, transform .18s ease;
}
.recording-indicator::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(239,68,68,.18), rgba(239,68,68,0));
  transform: translateX(calc((1 - var(--swipe-progress)) * 100%));
  transition: transform .12s linear;
  pointer-events: none;
}
.recording-indicator > * {
  position: relative;
  z-index: 1;
}
.recording-indicator.swiping {
  transform: translateX(calc(var(--swipe-progress) * -16px));
  border-color: rgba(239,68,68,.5);
  background: linear-gradient(180deg, rgba(239,68,68,.14), rgba(239,68,68,.08));
}
.recording-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--red);
  flex-shrink: 0;
  animation: rec-dot 1s ease infinite;
}
@keyframes rec-dot {
  0%,100% { transform: scale(1); opacity: .95; }
  50% { transform: scale(1.24); opacity: .55; }
}
.recording-label {
  font-size: 12px;
  font-weight: 700;
  color: #8f1f24;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.recording-time {
  font-family: var(--font-mono);
  font-size: 12px;
  color: #8f1f24;
  min-width: 44px;
}
.recording-swipe {
  font-size: 11px;
  color: #9a4448;
  white-space: nowrap;
  opacity: calc(.65 + (var(--swipe-progress) * .35));
}
.recording-cancel {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: #8f1f24;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  opacity: calc(.68 + (var(--swipe-progress) * .32));
}
.recording-cancel:hover {
  background: rgba(143,31,36,.1);
}
.msg-input-bar.recording-mode .msg-input,
.msg-input-bar.recording-mode .btn-send,
.msg-input-bar.recording-mode .btn-attach {
  display: none;
}

/* Fullscreen photo viewer */
.photo-viewer {
  position: fixed;
  inset: 0;
  z-index: 260;
  background: radial-gradient(circle at 20% 18%, rgba(31,107,76,.16), rgba(8,12,16,.92) 55%);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 56px 22px 68px;
}
.photo-viewer-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.22);
  background: rgba(10,14,18,.45);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.photo-viewer-img {
  --pv-scale: 1;
  --pv-tx: 0px;
  --pv-ty: 0px;
  --pv-drag-x: 0px;
  max-width: min(96vw, 980px);
  max-height: min(84dvh, 820px);
  width: auto;
  height: auto;
  border-radius: 16px;
  object-fit: contain;
  box-shadow: 0 18px 42px rgba(0,0,0,.42);
  transform: translate3d(var(--pv-drag-x), 0, 0) translate3d(var(--pv-tx), var(--pv-ty), 0) scale(var(--pv-scale));
  transform-origin: center center;
  transition: transform .22s ease, filter .26s ease, opacity .26s ease;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.photo-viewer-img.zoomed { cursor: grab; }
.photo-viewer-img.zoomed:active { cursor: grabbing; }
.photo-viewer-img.gesture-active { transition: filter .26s ease, opacity .26s ease; }
.photo-viewer-img.drag-release {
  transition: transform .2s cubic-bezier(.2, .8, .25, 1), filter .26s ease, opacity .26s ease;
}
.photo-viewer-img.loading {
  opacity: .84;
  filter: blur(14px) saturate(.88);
}
@keyframes photo-shimmer {
  from { background-position: 0% 0; }
  to { background-position: 200% 0; }
}
.photo-viewer-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.24);
  background: rgba(10,14,18,.45);
  color: #fff;
  cursor: pointer;
  font-size: 30px;
  line-height: 1;
}
.photo-viewer-nav.prev { left: 14px; }
.photo-viewer-nav.next { right: 14px; }
.photo-viewer-meta {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.2);
  background: rgba(10,14,18,.45);
  color: rgba(255,255,255,.92);
  font-family: var(--font-mono);
  font-size: 12px;
}

/* ════════════════════════════════════════════
   MODAL TABS
════════════════════════════════════════════ */
.modal-tabs {
  display: flex; border-bottom: 1px solid var(--border-soft); padding: 0 16px; flex-shrink: 0;
}
.modal-tab {
  flex: 1; padding: 11px 0; font-size: 14px; font-weight: 600; color: var(--text-2);
  background: none; border: none; border-bottom: 2px solid transparent;
  cursor: pointer; transition: color .15s, border-color .15s; margin-bottom: -1px;
}
.modal-tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.modal-tab:hover:not(.active) { color: var(--text); }

/* ════════════════════════════════════════════
   GROUP CREATION
════════════════════════════════════════════ */
.modal-group-form { padding: 0 0 4px; display: flex; flex-direction: column; }
.modal-group-form .field-input { margin: 14px 16px 0; width: calc(100% - 32px); }
.group-preview-card {
  margin: 12px 16px 0;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(31,107,76,.18);
  background: linear-gradient(152deg, rgba(236,247,241,.95), rgba(243,249,245,.95));
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
}
.group-preview-avatar {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(140deg, #1f6b4c, #285f49);
  color: #f2faf4;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
}
.group-preview-name {
  font-size: 13px;
  font-weight: 740;
  color: #183628;
}
.group-preview-sub {
  margin-top: 1px;
  font-size: 11px;
  color: #5f786a;
}
.group-preview-info {
  min-width: 0;
}
.group-preview-name,
.group-preview-sub {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.group-preview-badges {
  display: flex;
  align-items: center;
  gap: 4px;
}
.group-preview-badge {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #e6f2ec;
  color: #2b6650;
  border: 1px solid #cfe2d8;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}
.group-preview-badge.more {
  width: auto;
  min-width: 22px;
  border-radius: 999px;
  padding: 0 7px;
}

.group-selected-list {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 16px;
  min-height: 0;
}
.group-chip {
  display: flex; align-items: center; gap: 5px; background: var(--blue-light);
  color: var(--blue); font-size: 12px; font-weight: 600; border-radius: 16px;
  padding: 4px 10px 4px 8px;
}
.group-chip button {
  background: none; border: none; cursor: pointer; color: var(--blue);
  font-size: 14px; line-height: 1; padding: 0; margin: 0;
}
.group-chip button:hover { color: var(--red); }

.modal-group-footer { padding: 12px 16px 16px; flex-shrink: 0; }

/* Group avatar in conv list */
.conv-avatar.group { background: var(--blue); color: #fff; font-size: 13px; }
.conv-item.active .conv-avatar.group { background: var(--blue-hover); }
.chat-header-avatar.group { background: var(--blue); color: #fff; }

.conv-avatar.assistant {
  background: var(--assistant-badge);
  color: var(--blue);
  border: 1px solid var(--assistant-badge-ring);
}
.assistant-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}
.assistant-glyph svg {
  width: 72%;
  height: 72%;
  display: block;
}

.verified-inline {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 2px rgba(8,30,20,.18));
}
.verified-inline svg {
  width: 16px;
  height: 16px;
  display: block;
}
.verified-inline.static {
  width: 17px;
  height: 17px;
}

/* ════════════════════════════════════════════
   INCOMING CALL OVERLAY
════════════════════════════════════════════ */
.call-incoming {
  position: fixed; top: 24px; right: 24px; z-index: 500;
  animation: slideInRight .3s ease;
}
@keyframes slideInRight { from { opacity: 0; transform: translateX(60px); } to { opacity: 1; transform: translateX(0); } }

.call-incoming-card {
  background:
    radial-gradient(circle at 95% 6%, rgba(196,160,100,.22), transparent 38%),
    linear-gradient(152deg, rgba(255,255,255,.96), rgba(240,248,244,.96));
  border: 1px solid rgba(20,71,51,.2);
  border-radius: 22px;
  box-shadow: 0 26px 44px rgba(11,34,25,.3);
  padding: 22px 22px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  min-width: 312px;
  backdrop-filter: blur(6px);
}
.call-secure-label {
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #2f6b52;
  font-weight: 760;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(31,107,76,.2);
  background: rgba(234,245,239,.9);
}
.call-avatar {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: linear-gradient(140deg, #1f6b4c, #2c7b58);
  color: #fff; font-size: 22px; font-weight: 700; text-transform: uppercase;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 8px rgba(31,107,76,.14);
  animation: ring 1.7s ease infinite;
}
@keyframes ring {
  0%,100% { box-shadow: 0 0 0 0 rgba(31,107,76,.28); }
  50%      { box-shadow: 0 0 0 16px rgba(31,107,76,0); }
}
.call-caller-name {
  font-size: 20px;
  font-weight: 760;
  color: #133425;
  letter-spacing: -.01em;
  text-align: center;
}
.call-label {
  font-size: 13px;
  color: #355749;
  font-family: var(--font-mono);
}
.call-incoming-meta {
  margin-top: -2px;
  font-size: 11px;
  color: #668376;
}

.call-incoming-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 8px;
  width: 100%;
}
.btn-call-reject, .btn-call-accept {
  min-height: 88px;
  border-radius: 16px;
  border: 1px solid rgba(20,71,51,.12);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
  transition: transform .1s, filter .15s, border-color .15s, background .15s;
  background: rgba(255,255,255,.72);
  color: #173629;
}
.btn-call-reject:active, .btn-call-accept:active { transform: scale(.93); }
.btn-call-reject .call-action-icon,
.btn-call-accept .call-action-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-call-reject .call-action-icon {
  background: var(--red);
  color: #fff;
  box-shadow: 0 6px 14px rgba(239,68,68,.32);
}
.btn-call-accept .call-action-icon {
  background: var(--green);
  color: #fff;
  box-shadow: 0 6px 14px rgba(34,197,94,.28);
}
.btn-call-reject:hover {
  border-color: rgba(239,68,68,.28);
  background: rgba(254,246,246,.96);
}
.btn-call-accept:hover {
  border-color: rgba(34,197,94,.28);
  background: rgba(243,252,246,.96);
}
.call-action-label {
  font-size: 11px;
  font-weight: 720;
  letter-spacing: .03em;
  text-transform: uppercase;
}

/* ════════════════════════════════════════════
   ACTIVE CALL SCREEN
════════════════════════════════════════════ */
.call-screen {
  position: fixed; inset: 0; z-index: 400;
  background:
    radial-gradient(circle at 14% 16%, rgba(255,255,255,.1), transparent 30%),
    radial-gradient(circle at 88% 14%, rgba(196,160,100,.18), transparent 34%),
    linear-gradient(160deg, #0f3b2d 0%, #1f6b4c 64%, #324f40 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  padding: 18px;
}
.call-screen::before,
.call-screen::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}
.call-screen::before {
  width: min(42vw, 360px);
  height: min(42vw, 360px);
  left: -8vw;
  bottom: -12vw;
  background: radial-gradient(circle, rgba(255,255,255,.12), rgba(255,255,255,0));
}
.call-screen::after {
  width: min(36vw, 280px);
  height: min(36vw, 280px);
  right: -7vw;
  top: -8vw;
  background: radial-gradient(circle, rgba(196,160,100,.32), rgba(196,160,100,0));
}
.call-screen-shell {
  width: min(430px, calc(100% - 20px));
  border-radius: 28px;
  border: 1px solid rgba(255,255,255,.2);
  background:
    radial-gradient(circle at 82% 12%, rgba(196,160,100,.22), transparent 38%),
    linear-gradient(168deg, rgba(255,255,255,.16), rgba(255,255,255,.08));
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  box-shadow: 0 24px 54px rgba(6, 18, 14, .36);
  padding: 22px 22px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  position: relative;
  z-index: 1;
}
.call-screen-chip {
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.24);
  background: rgba(255,255,255,.14);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(241,251,244,.88);
  font-weight: 700;
}
.call-screen-avatar-wrap {
  position: relative;
  margin-top: 6px;
}
.call-screen-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: linear-gradient(140deg, rgba(255,255,255,.22), rgba(255,255,255,.12));
  backdrop-filter: blur(8px);
  font-size: 34px;
  font-weight: 700;
  text-transform: uppercase;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 12px rgba(255,255,255,.07);
}
.call-screen-avatar-wrap::after {
  content: '';
  position: absolute;
  inset: -12px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.16);
  animation: callPulse 2.6s ease-in-out infinite;
}
@keyframes callPulse {
  0%,100% { transform: scale(1); opacity: .65; }
  50% { transform: scale(1.05); opacity: .28; }
}
.call-screen-name {
  font-size: 32px;
  font-weight: 760;
  letter-spacing: -.02em;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.call-screen-status {
  font-size: 15px;
  color: rgba(255,255,255,.72);
  min-height: 22px;
}
.call-screen-mic-state {
  margin-top: -2px;
  font-size: 12px;
  color: rgba(236,249,240,.88);
  min-height: 18px;
  font-family: var(--font-mono);
}
.call-screen-timer {
  font-size: 30px;
  font-family: var(--font-mono);
  color: rgba(244,252,246,.92);
  margin-top: 2px;
}
.call-screen-peers {
  width: 100%;
  min-height: 30px;
  margin-top: 2px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}
.call-peer-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.22);
  color: rgba(247,253,249,.92);
  font-size: 11px;
  letter-spacing: .02em;
}
.call-peer-chip.state-joined {
  background: rgba(46, 138, 95, .24);
  border-color: rgba(122, 214, 164, .38);
}
.call-peer-chip.state-invited,
.call-peer-chip.state-ringing {
  background: rgba(212, 176, 112, .22);
  border-color: rgba(212, 176, 112, .34);
}
.call-peer-chip.state-left,
.call-peer-chip.state-rejected,
.call-peer-chip.state-missed {
  opacity: .72;
}
.call-peer-chip-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255,255,255,.82);
  box-shadow: 0 0 0 2px rgba(255,255,255,.14);
}
.call-peer-chip.state-joined .call-peer-chip-dot {
  background: #70d69f;
}

.call-screen-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  margin-top: 12px;
}
.btn-call-mute {
  min-height: 72px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.28);
  background: rgba(255,255,255,.12);
  color: #fff;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn-call-mute:hover { background: rgba(255,255,255,.22); }
.btn-call-mute.muted { background: rgba(255,255,255,.85); color: var(--text); }
.btn-call-mute .mic-off-slash {
  opacity: 0;
  transition: opacity .15s ease;
}
.btn-call-mute.muted .mic-off-slash {
  opacity: 1;
}
.btn-call-mute .call-action-icon,
.btn-call-end .call-action-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,.14);
}
.btn-call-end {
  min-height: 72px;
  border-radius: 16px;
  border: 1px solid rgba(239,68,68,.44);
  background: rgba(239,68,68,.92);
  color: #fff;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: filter .15s, background .15s;
  box-shadow: 0 7px 18px rgba(239,68,68,.33);
}
.btn-call-end:hover { filter: brightness(1.1); }
.btn-call-end .call-action-icon {
  background: rgba(255,255,255,.2);
}
.btn-call-mute .call-action-label,
.btn-call-end .call-action-label {
  font-size: 10px;
  letter-spacing: .08em;
}
.call-screen-footnote {
  margin-top: 4px;
  font-size: 11px;
  color: rgba(236,249,240,.68);
}

/* ════════════════════════════════════════════
   MOBILE
════════════════════════════════════════════ */
@media (max-width: 720px) {
  .auth-brand-panel { display: none; }
  .auth-form-panel {
    flex: 1;
    padding: 30px 20px;
    background: transparent;
    border-right: 0;
  }
  .auth-form-inner {
    width: min(420px, 100%);
    padding: 24px 20px 20px;
    border-radius: 18px;
    box-shadow: 0 16px 28px rgba(18,38,29,.12);
  }
  .auth-form-title {
    font-size: 30px;
    margin-bottom: 22px;
  }
  :root { --sidebar-w: 100vw; }
  .app { position: relative; }
  .sidebar { position: absolute; inset: 0; z-index: 10; transition: transform .25s ease; }
  .sidebar.hidden { transform: translateX(-100%); }
  .chat-area { position: absolute; inset: 0; z-index: 5; }
  .chat-topbar { display: none; }
  .back-btn { display: flex !important; }
  #btn-chat-logout {
    display: inline-flex;
    color: #9c4549;
  }
  #btn-chat-logout:hover { background: rgba(181,70,74,.1); }
  .sidebar-search {
    padding: 8px 10px 10px;
  }
  .diag-card {
    margin: 0 10px 10px;
  }
  .diag-card-in-settings {
    margin: 0;
    padding: 10px 10px 12px;
  }
  .sidebar-search .search-input {
    min-height: 42px;
    border-radius: 14px;
    font-size: 14px;
  }
  .conv-list {
    padding: 8px 8px calc(10px + env(safe-area-inset-bottom, 0px));
  }
  .conv-item {
    min-height: 68px;
    padding: 10px 10px;
    border-radius: 14px;
  }
  .conv-avatar {
    width: 42px;
    height: 42px;
    font-size: 15px;
  }
  .conv-name {
    font-size: 15px;
  }
  .conv-preview {
    font-size: 12px;
  }
  .conv-time {
    font-size: 10px;
  }
  .msg-bubble-wrap { max-width: 88%; }
  .messages-wrap { padding: 12px 12px; }
  .messages-list { width: 100%; }
  .scroll-bottom-fab {
    right: 12px;
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    min-height: 36px;
    padding: 0 11px;
    font-size: 11px;
    gap: 6px;
  }
  .msg-input-bar {
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  }
  .chat-header {
    padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 12px;
    gap: 10px;
  }
  .sidebar-header {
    padding-top: calc(14px + env(safe-area-inset-top, 0px));
  }
  .chat-header-avatar {
    width: 38px;
    height: 38px;
    font-size: 14px;
  }
  .chat-header-name {
    font-size: 14px;
  }
  .chat-header-status {
    font-size: 11px;
  }
  .chat-header-actions {
    gap: 2px;
  }
  .chat-header-actions .icon-btn {
    width: 34px;
    height: 34px;
  }
  .chat-header-actions [data-open-call-settings],
  .chat-header-actions #btn-bank-tools {
    display: none;
  }
  .assistant-panel {
    margin: 8px 12px 0;
    padding: 12px;
    border-radius: 14px;
  }
  .assistant-panel-avatar {
    width: 46px;
    height: 46px;
    border-radius: 14px;
  }
  .assistant-panel-title {
    font-size: 15px;
  }
  .assistant-panel-sub {
    font-size: 12px;
  }
  .assistant-quick-actions {
    margin-top: 10px;
    gap: 6px;
  }
  .assistant-quick-btn {
    min-height: 32px;
    font-size: 11px;
    border-radius: 10px;
    padding: 0 10px;
  }
  .assistant-statement-bubble {
    min-width: 0;
    width: min(100%, 86vw);
  }
  .assistant-statement-summary {
    font-size: 11px;
  }
  .assistant-statement-btn {
    width: 100%;
  }
  .photo-stack { max-width: 76vw; }
  .btn-attach, .btn-voice, .btn-send { width: 40px; height: 40px; }
  .msg-input {
    font-size: 16px;
    padding: 10px 14px;
    border-radius: 16px;
  }
  .msg-bubble {
    font-size: 15px;
    padding: 11px 13px;
    line-height: 1.5;
  }
  .msg-time {
    font-size: 11px;
  }
  .recording-label { display: none; }
  .recording-indicator { gap: 8px; padding: 0 10px; }
  .recording-swipe {
    max-width: 96px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .recording-cancel { padding: 4px 6px; }
  .photo-viewer { padding: 52px 10px 60px; }
  .photo-viewer-img {
    max-width: calc(100vw - 16px);
    max-height: calc(100dvh - 120px);
    border-radius: 12px;
  }
  .photo-viewer-nav {
    width: 36px;
    height: 36px;
    font-size: 26px;
  }
  .photo-viewer-nav.prev { left: 8px; }
  .photo-viewer-nav.next { right: 8px; }

  .call-incoming {
    left: max(10px, env(safe-area-inset-left, 0px));
    right: max(10px, env(safe-area-inset-right, 0px));
    top: calc(env(safe-area-inset-top, 0px) + 10px);
    width: auto;
    animation: fadeSlideUp .24s ease;
  }

  .call-incoming-card {
    width: 100%;
    min-width: 0;
    border-radius: 20px;
    padding: 16px 14px 14px;
    gap: 8px;
    box-shadow: 0 12px 28px rgba(15, 32, 24, .2);
  }

  .call-avatar {
    width: 58px;
    height: 58px;
    font-size: 21px;
  }

  .call-caller-name {
    font-size: 28px;
    line-height: 1.12;
    text-align: center;
    word-break: break-word;
  }

  .call-label {
    font-size: 14px;
  }

  .call-incoming-meta {
    font-size: 10px;
  }

  .call-incoming-btns {
    width: 100%;
    gap: 8px;
    margin-top: 4px;
  }

  .btn-call-reject,
  .btn-call-accept {
    min-height: 82px;
  }

  .btn-call-reject .call-action-icon,
  .btn-call-accept .call-action-icon {
    width: 40px;
    height: 40px;
  }

  .call-screen {
    padding:
      calc(8px + env(safe-area-inset-top, 0px))
      12px
      calc(8px + env(safe-area-inset-bottom, 0px));
  }

  .call-screen-shell {
    width: 100%;
    border-radius: 22px;
    padding: 18px 14px 14px;
    gap: 8px;
  }

  .call-screen-chip {
    min-height: 26px;
    font-size: 9px;
  }

  .call-screen-avatar {
    width: 82px;
    height: 82px;
    font-size: 31px;
  }

  .call-screen-name {
    font-size: 20px;
  }

  .call-screen-status {
    font-size: 14px;
  }
  .call-screen-mic-state {
    font-size: 11px;
  }

  .call-screen-timer {
    font-size: 28px;
  }
  .call-screen-peers {
    gap: 5px;
  }
  .call-peer-chip {
    font-size: 10px;
    min-height: 22px;
    padding: 0 8px;
  }

  .call-screen-btns {
    margin-top: 10px;
  }

  .btn-call-mute,
  .btn-call-end {
    min-height: 66px;
    border-radius: 14px;
  }

  .call-screen-footnote {
    font-size: 10px;
  }

  .call-settings-list {
    padding: 10px 12px 14px;
  }
  .call-settings-tools {
    grid-template-columns: 1fr;
  }
  .bank-tools-list {
    padding: 10px 12px 14px;
  }
  .bank-tools-actions,
  .bank-period-grid {
    grid-template-columns: 1fr;
  }
}

[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ── Presence dot ── */
.presence-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid rgba(245,250,247,.96);
  box-shadow: 0 0 0 2px rgba(34,197,94,.14);
  pointer-events: none;
}

/* ── Call bubble ── */
.call-bubble {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.88rem;
  color: var(--text-secondary, #666);
  font-style: italic;
}
.call-icon { font-style: normal; }

@media (prefers-reduced-motion: reduce) {
  .photo-tile.loading { animation: none !important; }
  .photo-viewer-img { transition: none !important; }
  .call-avatar,
  .call-screen-avatar-wrap::after,
  .call-incoming,
  .call-screen {
    animation: none !important;
  }
}

/* Group Panel */
#group-panel {
  position: fixed;
  top: 0; right: 0;
  width: min(340px, 100vw);
  height: 100%;
  background: var(--surface, #fff);
  border-left: 1px solid var(--border, #e5e7eb);
  z-index: 120;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 24px rgba(0,0,0,.12);
  animation: slideInRight .2s ease;
}
#group-panel[hidden] { display: none; }
@keyframes slideInRight { from { transform: translateX(100%); } to { transform: translateX(0); } }
.group-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px;
  border-bottom: 1px solid var(--border, #e5e7eb);
}
.group-panel-title { flex: 1; font-size: 16px; font-weight: 600; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-panel-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.group-section-label { font-size: 12px; font-weight: 600; color: var(--text-muted, #6b7280); text-transform: uppercase; letter-spacing: .05em; }
.group-members-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.group-member-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 8px;
  transition: background .15s;
}
.group-member-item:hover { background: var(--hover, #f3f4f6); }
.group-member-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--accent, #3b82f6);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
  flex-shrink: 0;
  position: relative;
}
.group-member-info { flex: 1; min-width: 0; }
.group-member-name { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-member-status { font-size: 11px; color: var(--text-muted, #6b7280); }
.group-member-badge { font-size: 10px; background: var(--accent, #3b82f6); color: #fff; border-radius: 4px; padding: 1px 5px; }
.group-member-remove { background: none; border: none; cursor: pointer; color: var(--text-muted, #6b7280); font-size: 16px; padding: 4px; border-radius: 4px; }
.group-member-remove:hover { background: #fee2e2; color: #ef4444; }
.group-actions { display: flex; flex-direction: column; gap: 8px; margin-top: auto; padding-top: 16px; }
.btn-secondary { padding: 10px; border-radius: 8px; border: 1px solid var(--border, #e5e7eb); background: var(--surface, #fff); cursor: pointer; font-size: 14px; font-weight: 500; transition: background .15s; }
.btn-secondary:hover { background: var(--hover, #f3f4f6); }
.btn-danger { padding: 10px; border-radius: 8px; border: none; background: #fee2e2; color: #ef4444; cursor: pointer; font-size: 14px; font-weight: 500; }
.btn-danger:hover { background: #fecaca; }
.msg-sender-name { font-size: 11px; font-weight: 600; color: var(--accent, #3b82f6); margin-bottom: 2px; }
