:root {
  --bg:     #040911;
  --bg2:    #070f1e;
  --bg3:    #030709;
  --brd:    #0f1e35;
  --txt:    #eef2ff;
  --muted:  #4a6080;
  --muted2: #8ba0bc;
  --green:  #1fff72;
  --green2: #00cc55;
  --green-dim: rgba(31,255,114,.12);
  --blue:   #3b82f6;
  --red:    #ef4444;
  --radius: 12px;
  --sidebar-w: 300px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body {
  height: 100%; background: var(--bg); color: var(--txt);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px; overflow: hidden;
}

.screen { width: 100%; height: 100dvh; }
.hidden { display: none !important; }

/* ── Auth screens ───────────────────────────── */
.auth-screen {
  display: flex; align-items: center; justify-content: center;
  background: var(--bg3);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.auth-box {
  background: var(--bg2); border: 1px solid var(--brd);
  border-radius: 16px; padding: 36px 32px; width: 380px; max-width: 95vw;
}
.no-access-box { text-align: center; }
.no-access-icon { font-size: 48px; margin-bottom: 16px; }
.no-access-title { font-size: 20px; font-weight: 700; color: #fff; margin-bottom: 12px; }
.no-access-text { font-size: 14px; color: var(--muted); line-height: 1.6; margin-bottom: 20px; }
.no-access-admin {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(74,222,128,.12); border: 1px solid rgba(74,222,128,.3);
  color: var(--green); border-radius: 12px; padding: 10px 20px;
  font-size: 16px; font-weight: 600; text-decoration: none; margin-bottom: 20px;
  transition: background .2s;
}
.no-access-admin:hover { background: rgba(74,222,128,.22); }
.no-access-admin-icon { font-size: 18px; }
.no-access-brand { font-size: 11px; color: var(--muted); opacity: .6; letter-spacing: .5px; }

.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo .brand { font-size: 26px; font-weight: 800; color: var(--green); letter-spacing: .3px; }
.auth-logo .brand span { font-weight: 700; color: #fff; letter-spacing: 3px; margin-left: 4px; }
.auth-logo p { font-size: 12px; color: var(--muted); margin-top: 4px; letter-spacing: .5px; }

.field-group { margin-bottom: 16px; }
.field-group label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 5px; letter-spacing: .5px; text-transform: uppercase; }
.field-group input { width: 100%; padding: 11px 13px; background: var(--bg); border: 1px solid var(--brd); border-radius: 8px; color: var(--txt); font-size: 15px; outline: none; transition: border .2s; }
.field-group input:focus { border-color: var(--green); }
.field-group input::placeholder { color: var(--muted); }
.field-hint { font-size: 11px; color: var(--muted); margin-top: 5px; }
.req { color: var(--green); }

.input-prefix-wrap { display: flex; align-items: center; }
.input-prefix { padding: 11px 0 11px 13px; background: var(--bg); border: 1px solid var(--brd); border-right: none; border-radius: 8px 0 0 8px; color: var(--muted); font-size: 15px; }
.input-prefix-wrap input { border-radius: 0 8px 8px 0 !important; border-left: none !important; }

.btn-primary { width: 100%; padding: 12px; background: var(--green); color: #0f172a; border: none; border-radius: 8px; font-size: 14px; font-weight: 700; cursor: pointer; transition: opacity .2s; letter-spacing: .3px; margin-bottom: 10px; }
.btn-primary:hover { opacity: .85; }
.btn-ghost { width: 100%; padding: 10px; background: transparent; color: var(--muted); border: 1px solid var(--brd); border-radius: 8px; font-size: 13px; cursor: pointer; transition: all .15s; margin-bottom: 6px; }
.btn-ghost:hover { color: var(--txt); border-color: var(--txt); }

.error-msg { margin-top: 10px; font-size: 12px; text-align: center; padding: 8px 12px; background: rgba(239,68,68,.1); border: 1px solid var(--red); border-radius: 8px; color: #fca5a5; }
.auth-hint { text-align: center; font-size: 11px; color: var(--muted); margin-top: 12px; }
.green-link { color: var(--green); text-decoration: none; font-weight: 700; }
.muted-text { font-size: 12px; color: var(--muted); }

/* ── Link bot screen ────────────────────────── */
.link-steps { margin-bottom: 20px; }
.step { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.step-num { width: 24px; height: 24px; border-radius: 50%; background: var(--green); color: #0f172a; font-size: 12px; font-weight: 800; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 1px; }
.step-text { font-size: 13px; color: var(--muted2); line-height: 1.5; }
.cmd-box { display: flex; align-items: center; justify-content: space-between; background: var(--bg); border: 1px solid var(--green); border-radius: 8px; padding: 10px 14px; margin: 4px 0 14px 36px; cursor: pointer; transition: background .15s; }
.cmd-box:hover { background: var(--green-dim); }
.cmd-box span:first-child { font-family: monospace; font-size: 14px; color: var(--green); font-weight: 600; }
.cmd-copy { font-size: 11px; color: var(--muted); }

/* ── Code input ─────────────────────────────── */
.code-inputs { display: flex; gap: 10px; justify-content: center; margin-bottom: 16px; }
.code-digit { width: 46px; height: 56px; border-radius: 10px; background: var(--bg); border: 1px solid var(--brd); color: var(--green); font-size: 24px; font-weight: 800; text-align: center; outline: none; transition: border .15s, background .15s; caret-color: var(--green); }
.code-digit:focus { border-color: var(--green); background: var(--green-dim); }
.code-digit.filled { border-color: var(--green); }
.resend-row { text-align: center; margin: 6px 0 12px; min-height: 28px; }
#logout-btn:hover { background: rgba(239,68,68,.1); border-color: var(--red) !important; }

/* ── App screen: position fixed prevents iOS keyboard scroll ── */
#app-screen {
  position: fixed;
  top: 0; left: 0; right: 0;
  /* height is set dynamically via JS (window.visualViewport.height) */
  overflow: hidden;
}

/* ── Layout ─────────────────────────────────── */
.app-layout { display: flex; height: 100%; overflow: hidden; }

.sidebar { width: var(--sidebar-w); min-width: var(--sidebar-w); background: var(--bg2); border-right: 1px solid var(--brd); display: flex; flex-direction: column; overflow: hidden; }
.chat-area { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; background: var(--bg); position: relative; }

/* ── Sidebar header ─────────────────────────── */
.sidebar-header {
  display: flex; align-items: center; gap: 10px;
  padding: calc(12px + env(safe-area-inset-top)) 14px 12px;
  border-bottom: 1px solid var(--brd); flex-shrink: 0;
}
.my-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--green); color: #0f172a; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px; cursor: pointer; flex-shrink: 0; }
.app-title { flex: 1; font-size: 15px; font-weight: 800; color: var(--green); letter-spacing: .3px; }
.app-title span { font-weight: 700; color: #ffffff; letter-spacing: 3px; font-size: 14px; margin-left: 4px; }
.icon-btn { width: 32px; height: 32px; border-radius: 7px; border: 1px solid var(--brd); background: transparent; cursor: pointer; font-size: 16px; color: var(--muted); display: flex; align-items: center; justify-content: center; transition: all .15s; }
.icon-btn:hover { border-color: var(--green); color: var(--green); }

/* ── Search ─────────────────────────────────── */
.search-bar { padding: 10px 12px; border-bottom: 1px solid var(--brd); }
.search-bar input { width: 100%; padding: 8px 12px; background: var(--bg); border: 1px solid var(--brd); border-radius: 8px; color: var(--txt); font-size: 13px; outline: none; transition: border .2s; }
.search-bar input:focus { border-color: var(--green); }
.search-bar input::placeholder { color: var(--muted); }

/* ── Conversation list ──────────────────────── */
.conversations-list { flex: 1; overflow-y: auto; }
.conversations-list::-webkit-scrollbar { width: 4px; }
.conversations-list::-webkit-scrollbar-track { background: transparent; }
.conversations-list::-webkit-scrollbar-thumb { background: var(--brd); border-radius: 4px; }

.conv-item { display: flex; align-items: center; gap: 11px; padding: 11px 14px; cursor: pointer; border-bottom: 1px solid rgba(51,65,85,.5); transition: background .15s; position: relative; }
.conv-item:hover { background: rgba(74,222,128,.06); }
.conv-item.active { background: var(--green-dim); border-left: 2px solid var(--green); }

.conv-avatar { width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0; background: var(--bg); border: 1px solid var(--brd); color: var(--green); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 16px; position: relative; }
.conv-avatar .online-dot { position: absolute; bottom: 1px; right: 1px; width: 11px; height: 11px; border-radius: 50%; background: var(--green); border: 2px solid var(--bg2); animation: onlinePulse 2.5s ease-in-out infinite; }
@keyframes onlinePulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:.65;transform:scale(.9)} }

.conv-info { flex: 1; overflow: hidden; min-width: 0; }
.conv-name { font-weight: 600; font-size: 14px; color: var(--txt); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-last { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.conv-last.is-typing { color: var(--green); font-style: italic; }
.typing-dots { display: inline-flex; gap: 2px; margin-left: 2px; vertical-align: middle; }
.typing-dots span { width: 4px; height: 4px; border-radius: 50%; background: var(--green); display: inline-block; animation: tdot .9s infinite; }
.typing-dots span:nth-child(2){animation-delay:.15s}
.typing-dots span:nth-child(3){animation-delay:.3s}
@keyframes tdot { 0%,60%,100%{transform:translateY(0)} 30%{transform:translateY(-4px)} }

.conv-right { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; flex-shrink: 0; padding-left: 6px; }
.conv-status { font-size: 10px; color: var(--muted); white-space: nowrap; text-align: right; }
.conv-status.online { color: var(--green); font-weight: 700; }
.conv-unread { min-width: 20px; height: 20px; border-radius: 10px; background: var(--green); color: #0f172a; font-size: 11px; font-weight: 800; display: flex; align-items: center; justify-content: center; padding: 0 5px; line-height: 1; }
.empty-state { padding: 40px 20px; text-align: center; color: var(--muted); font-size: 13px; line-height: 1.6; }
.empty-state .empty-icon { font-size: 36px; margin-bottom: 12px; opacity: .4; }

/* ── Chat placeholder ───────────────────────── */
.chat-placeholder { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); }
.placeholder-icon svg { width: 80px; height: 80px; opacity: .15; }
.chat-placeholder p { font-size: 14px; }

/* ── Chat view ──────────────────────────────── */
.chat-view {
  display: flex; flex-direction: column; height: 100%; position: relative;
  background:
    radial-gradient(ellipse 55% 35% at 5% 95%, rgba(74,222,128,.09) 0%, transparent 50%),
    radial-gradient(ellipse 45% 35% at 95% 5%, rgba(59,130,246,.09) 0%, transparent 50%),
    #0f172a;
}

.chat-header {
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  border-bottom: 1px solid var(--brd); background: var(--bg2); flex-shrink: 0;
}
.back-btn {
  display: none;
  border: none !important;
  background: transparent !important;
  color: rgba(255,255,255,.75) !important;
  width: 36px !important; height: 36px !important;
  border-radius: 50% !important;
  transition: background .15s, color .15s !important;
}
.back-btn:hover { background: rgba(255,255,255,.08) !important; color: #fff !important; }
.chat-header-avatar { width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; background: var(--bg); border: 1px solid var(--brd); color: var(--green); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; }
.chat-header-info { flex: 1; min-width: 0; }
.chat-header-name { font-weight: 700; font-size: 15px; color: var(--txt); }
.chat-header-status { font-size: 11px; color: var(--muted); margin-top: 2px; letter-spacing: .2px; }
.chat-header-status.online { color: var(--green); }
.chat-header-status.online::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--green); margin-right: 5px; vertical-align: middle; animation: pulse 2s infinite; }
.chat-header-status.typing { color: var(--green); font-style: italic; display: flex; align-items: center; gap: 2px; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.5} }

/* ── Messages container ─────────────────────── */
.messages-container { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 16px calc(100px + env(safe-area-inset-bottom)); background: transparent; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.messages-container::-webkit-scrollbar { width: 4px; }
.messages-container::-webkit-scrollbar-thumb { background: var(--brd); border-radius: 4px; }
.messages-list { display: flex; flex-direction: column; gap: 3px; }

/* ── Message rows ───────────────────────────── */
.messages-container { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.message-row { display: flex; align-items: flex-end; gap: 8px; margin-bottom: 2px; position: relative; }
.message-row.out { flex-direction: row-reverse; }

/* Reply swipe hint */
.reply-hint {
  position: absolute; left: 36px; top: 50%;
  transform: scale(0.5) translateY(-50%); transform-origin: left center;
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(74,222,128,.2); color: var(--green);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; z-index: 1;
}
.message-row.out .reply-hint { left: auto; right: 36px; transform-origin: right center; }
.msg-avatar { width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0; background: var(--bg2); border: 1px solid var(--brd); color: var(--green); display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 800; margin-bottom: 2px; }

.bubble { max-width: 62%; padding: 9px 13px; border-radius: 14px; font-size: 14px; line-height: 1.5; word-break: break-word; position: relative; }
.bubble.in { background: var(--bg); color: var(--txt); border: 1px solid rgba(74,222,128,.4); border-bottom-left-radius: 4px; box-shadow: 0 0 14px rgba(74,222,128,.3), 0 0 4px rgba(74,222,128,.15); }
.bubble.out { background: rgba(74,222,128,.15); border: 1px solid rgba(74,222,128,.25); color: var(--txt); border-bottom-right-radius: 4px; }

.bubble-sender { font-size: 11px; font-weight: 700; color: var(--green); margin-bottom: 3px; }
.bubble-time { font-size: 10px; color: var(--muted); margin-top: 4px; display: flex; align-items: center; justify-content: flex-end; gap: 4px; }
.bubble.out .bubble-time { color: rgba(74,222,128,.6); }
.msg-edited { display: block; font-size: 10px; color: var(--muted); text-align: right; margin-top: 2px; font-style: italic; opacity: .75; }
.bubble.bubble-emoji { background: none !important; box-shadow: none !important; padding: 2px 4px; border: none !important; }
.bubble.bubble-emoji .bubble-text { font-size: 48px; line-height: 1.1; }
.bubble.bubble-emoji .bubble-time { color: var(--muted); }

/* ── Message checkmarks ─────────────────────── */
.msg-check { display: inline-flex; align-items: center; flex-shrink: 0; }
.msg-check svg { width: 15px; height: 10px; }
.msg-check.sent   svg { color: rgba(100,116,139,.7); }
.msg-check.delivered svg { color: rgba(100,116,139,.7); }
.msg-check.read   svg { color: var(--green); }

.reply-bubble { background: rgba(255,255,255,.05); border-left: 2px solid var(--green); border-radius: 6px; padding: 4px 8px; margin-bottom: 5px; font-size: 12px; cursor: pointer; color: var(--muted2); }
.bubble.out .reply-bubble { border-left-color: var(--green2); }

.date-divider { text-align: center; margin: 14px 0; }
.date-divider span { font-size: 11px; color: var(--muted); background: rgba(51,65,85,.6); padding: 3px 12px; border-radius: 20px; letter-spacing: .3px; }

/* ── Typing ─────────────────────────────────── */
.typing-indicator { padding: 4px 16px 6px; font-size: 12px; color: var(--green); font-style: italic; min-height: 20px; }

/* ── Reply preview ──────────────────────────── */
.reply-preview {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; background: var(--bg2);
  border-top: 1px solid rgba(74,222,128,.15);
}
#reply-text {
  flex: 1; display: flex; flex-direction: column; gap: 2px;
  border-left: 3px solid var(--green); padding-left: 8px; min-width: 0;
}
.rp-name { font-size: 12px; font-weight: 700; color: var(--green); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rp-body { font-size: 12px; color: var(--muted2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reply-preview button { background: none; border: none; cursor: pointer; color: var(--muted); flex-shrink: 0; display: flex; padding: 4px; }
.reply-preview button:hover { color: var(--txt); }
.reply-preview button svg { width: 18px; height: 18px; }

/* ── Upload progress ────────────────────────── */
.upload-progress { display: none; }

/* Pending upload bubble — clip spinner to rounded corners */
.pending-upload .bubble {
  position: relative !important;
  overflow: hidden !important;
}

/* Circular progress overlay */
.upload-spinner-wrap {
  position: absolute !important;
  inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.45);
  z-index: 10;
  pointer-events: none;
  border-radius: inherit;
}
.upload-ring { width: 56px; height: 56px; }
.upload-ring-fill {
  transition: stroke-dashoffset .12s linear;
}
#upload-label { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* ── Input bar — frosted glass ──────────────── */
.message-input-bar {
  display: flex; flex-direction: column;
  background: rgba(11, 18, 32, 0.75);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid rgba(255,255,255,.06);
  padding-bottom: max(4px, env(safe-area-inset-bottom));
  position: absolute;
  bottom: 0; left: 0; right: 0;
  z-index: 320;
}
.message-input-bar::before {
  content: '';
  position: absolute;
  top: -48px; left: 0; right: 0; height: 48px;
  background: linear-gradient(to bottom, transparent, rgba(11, 18, 32, 0.75));
  pointer-events: none;
}

/* ── Floating lock bubble above mic button ── */
.voice-lock-float {
  position: absolute;
  bottom: calc(100% - 4px);
  right: 10px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: var(--bg2);
  border: 1.5px solid var(--brd);
  border-radius: 22px;
  padding: 10px 10px 6px;
  color: var(--muted2);
  z-index: 20;
  pointer-events: none;
  transform: translateY(8px);
  opacity: 0;
  transition: opacity .2s ease, transform .2s ease;
}
.voice-lock-float.visible {
  opacity: 1;
  transform: translateY(0);
}
.voice-lock-float.active {
  color: var(--green);
  border-color: var(--green);
  background: rgba(74,222,128,.1);
}
.voice-lock-float .lock-arrow { opacity: .5; }
.voice-lock-float.active .lock-arrow { opacity: 1; }

@keyframes lockSnap {
  0%   { transform: translateY(0); }
  25%  { transform: translateY(-5px); }
  55%  { transform: translateY(2px); }
  100% { transform: translateY(0); }
}
@keyframes lockPop {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.4); }
  65%  { transform: scale(0.85); }
  100% { transform: scale(1); }
}
.voice-lock-float.snapping { animation: lockPop .4s cubic-bezier(.36,.07,.19,.97); color: var(--green); border-color: var(--green); }
.voice-lock-float.snapping .lock-shackle { animation: lockSnap .4s ease; }

/* Normal input row */
.input-normal {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 8px 12px 8px;
}
#message-input {
  flex: 1;
  min-height: 40px; max-height: 120px;
  overflow-y: auto;
  background: rgba(255,255,255,.07);
  border: 1.5px solid rgba(255,255,255,.10);
  border-radius: 22px;
  padding: 10px 14px;
  color: var(--txt); font-size: 15px; line-height: 1.4;
  outline: none; word-break: break-word; font-family: inherit;
  -webkit-user-select: text; user-select: text; cursor: text;
  transition: border .2s;
}
#message-input:focus { border-color: rgba(255,255,255,.22); }
#message-input:empty::before {
  content: attr(data-placeholder);
  color: rgba(255,255,255,.35);
  pointer-events: none;
}
.send-btn { width: 42px; height: 42px; border-radius: 50%; border: none; background: var(--green); color: #0f172a; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: transform .15s, box-shadow .15s; box-shadow: 0 2px 10px rgba(74,222,128,.35); }
.send-btn:active { transform: scale(.9); }
.plus-btn { width: 36px; height: 36px; border-radius: 50%; border: 1.5px solid rgba(255,255,255,.12); background: rgba(255,255,255,.06); color: rgba(255,255,255,.55); cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: all .15s; }
.plus-btn:active { background: rgba(255,255,255,.12); transform: scale(.9); }
.voice-btn { width: 42px; height: 42px; border-radius: 50%; border: none; background: var(--green); color: #0f172a; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: opacity .15s, transform .1s; user-select: none; -webkit-user-select: none; touch-action: none; }
.voice-btn:active { transform: scale(.92); }
.voice-btn.recording { background: var(--red); color: #fff; animation: recPulse .8s ease-in-out infinite; }
@keyframes recPulse { 0%,100%{opacity:1} 50%{opacity:.6} }

/* ── Voice recording bars ───────────────────── */

/* Hold recording bar */
.voice-rec-bar {
  display: flex; align-items: center; gap: 0;
  padding: 10px 12px; height: 58px;
  background: var(--bg2);
  user-select: none; -webkit-user-select: none;
}

.voice-cancel-zone {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%;
  color: var(--muted); flex-shrink: 0;
  transition: color .2s, background .2s;
}
.voice-cancel-zone.active { color: var(--red); background: rgba(239,68,68,.15); }

.voice-rec-center {
  flex: 1; display: flex; align-items: center; gap: 8px;
  overflow: hidden; padding: 0 8px;
}

/* Red pulsing dot */
.rec-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--red); flex-shrink: 0;
  animation: recDotPulse 1s ease-in-out infinite;
}
@keyframes recDotPulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:.4;transform:scale(.7)} }

.voice-rec-timer { font-size: 14px; font-weight: 600; color: var(--txt); flex-shrink: 0; letter-spacing: .5px; }

.voice-slide-hint { font-size: 11px; color: var(--muted); flex: 1; text-align: center; white-space: nowrap; overflow: hidden; transition: color .2s; }
.voice-slide-hint.cancel-active { color: var(--red); }
.voice-slide-hint.lock-active { color: var(--green); }


/* Locked recording bar */
.voice-locked-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; height: 62px;
  background: var(--bg2);
}

.vl-trash {
  width: 40px; height: 40px; border-radius: 50%; border: none; background: transparent;
  color: var(--red); cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* Trash lid animation: opens up, file falls in, closes */
@keyframes trashLidOpen {
  0%   { transform: rotate(0deg) translate(0,0); }
  25%  { transform: rotate(-42deg) translate(4px,-3px); }
  65%  { transform: rotate(-42deg) translate(4px,-3px); }
  100% { transform: rotate(0deg) translate(0,0); }
}
.vl-trash.deleting .trash-lid { animation: trashLidOpen .55s ease forwards; transform-origin: 5px 6px; }

@keyframes trashShake {
  0%,100% { transform: translateX(0); }
  20%  { transform: translateX(-2px); }
  40%  { transform: translateX(2px); }
  60%  { transform: translateX(-1px); }
  80%  { transform: translateX(1px); }
}
.vl-trash.deleting { animation: trashShake .55s ease; }

.vl-center {
  flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; overflow: hidden;
}
.vl-center #voice-timer-locked {
  font-size: 15px; font-weight: 700; color: var(--txt); flex-shrink: 0; letter-spacing: .5px;
}

/* Waveform animation */
.voice-wave {
  display: flex; align-items: center; gap: 3px; height: 22px; flex: 1; padding: 0 4px;
}
.voice-wave span {
  width: 3px; border-radius: 2px; background: var(--green); flex: 1;
  animation: voiceWave 0.7s ease-in-out infinite;
}
.voice-wave span:nth-child(1){animation-delay:0s;height:5px}
.voice-wave span:nth-child(2){animation-delay:.12s;height:12px}
.voice-wave span:nth-child(3){animation-delay:.24s;height:20px}
.voice-wave span:nth-child(4){animation-delay:.36s;height:12px}
.voice-wave span:nth-child(5){animation-delay:.48s;height:5px}
@keyframes voiceWave { 0%,100%{transform:scaleY(0.4)} 50%{transform:scaleY(1.2)} }

/* Preview player (paused/playing state) */
.vl-play-btn {
  width: 28px; height: 28px; border-radius: 50%; border: none;
  background: var(--green); color: #0f172a; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.vl-progress-track {
  flex: 1; height: 4px; background: var(--brd); border-radius: 2px; cursor: pointer; position: relative;
}
.vl-progress-fill {
  height: 100%; background: var(--green); border-radius: 2px; width: 0%; transition: width .1s linear;
}
#vl-preview-time {
  font-size: 13px; font-weight: 600; color: var(--muted2); flex-shrink: 0; min-width: 32px;
}

/* Pause / Resume button */
.vl-pause-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 1.5px solid var(--muted);
  background: transparent; color: var(--txt); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: all .15s;
}
.vl-pause-btn.preview-mode { border-color: var(--green); color: var(--green); }

.vl-send-btn {
  width: 40px; height: 40px; border-radius: 50%; border: none;
  background: var(--green); color: #0f172a; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: opacity .15s;
}
.vl-send-btn:active { opacity: .8; }

/* ── Attach bottom sheet ────────────────────── */
/* ── Attach bottom sheet (premium) ── */
.attach-sheet {
  position: absolute; inset: 0; z-index: 400;
  pointer-events: none;
}
.attach-sheet:not(.hidden) { pointer-events: all; }
.attach-sheet-bg {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.55); backdrop-filter: blur(3px);
  opacity: 0; transition: opacity .25s;
}
.attach-sheet:not(.hidden) .attach-sheet-bg { opacity: 1; }
.attach-sheet-panel {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: #1a2639;
  border-radius: 24px 24px 0 0;
  padding: 10px 20px max(24px, env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform .32s cubic-bezier(.32,1,.4,1);
  box-shadow: 0 -4px 30px rgba(0,0,0,.4);
}
.attach-sheet:not(.hidden) .attach-sheet-panel { transform: translateY(0); }
.attach-handle {
  width: 40px; height: 4px; background: rgba(255,255,255,.14);
  border-radius: 2px; margin: 0 auto 22px;
}
.attach-sheet-grid {
  display: flex; justify-content: space-around;
  padding-bottom: 6px;
}
.attach-opt {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  background: none; border: none; cursor: pointer; padding: 4px 8px;
}
.attach-opt:active .attach-opt-icon { transform: scale(.88); }
.attach-opt-icon {
  width: 60px; height: 60px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s;
}
.attach-opt-label { font-size: 12px; color: rgba(255,255,255,.65); font-weight: 500; white-space: nowrap; }

/* ── Custom confirm dialog ── */
.confirm-modal { position: absolute; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center; }
.confirm-overlay { position: absolute; inset: 0; background: rgba(0,0,0,.55); backdrop-filter: blur(4px); }
.confirm-panel {
  position: relative; z-index: 1;
  background: #1e293b;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 22px;
  padding: 28px 24px 20px;
  width: 300px;
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
  animation: confirmPop .22s cubic-bezier(.34,1.4,.64,1);
}
@keyframes confirmPop { from{transform:scale(.85);opacity:0} to{transform:scale(1);opacity:1} }
.confirm-msg { font-size: 15px; color: var(--txt); line-height: 1.55; text-align: center; margin-bottom: 24px; }
.confirm-btns { display: flex; gap: 10px; }
.confirm-cancel {
  flex: 1; padding: 13px; border-radius: 14px;
  border: 1px solid rgba(255,255,255,.1);
  background: rgba(255,255,255,.05);
  color: rgba(255,255,255,.65); font-size: 15px; cursor: pointer;
  transition: background .15s;
}
.confirm-cancel:active { background: rgba(255,255,255,.1); }
.confirm-ok {
  flex: 1; padding: 13px; border-radius: 14px; border: none;
  background: #ef4444; color: #fff; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: opacity .15s;
}
.confirm-ok:active { opacity: .85; }
.confirm-ok.green { background: var(--green); color: #0f172a; }
.confirm-me {
  width: 100%; margin-top: 8px; padding: 13px; border-radius: 14px;
  border: 1px solid rgba(255,255,255,.1); background: rgba(255,255,255,.05);
  color: rgba(255,255,255,.7); font-size: 15px; cursor: pointer; text-align: center;
}
.confirm-me:active { background: rgba(255,255,255,.1); }

/* ── Scroll to bottom button ────────────────── */
.chat-view { position: relative; }
.scroll-btn {
  position: absolute;
  bottom: calc(72px + env(safe-area-inset-bottom));
  right: 16px;
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--bg2); border: 1px solid var(--brd);
  color: var(--txt); cursor: pointer; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 14px rgba(0,0,0,.4);
  transition: opacity .2s, transform .2s;
}
.scroll-btn:active { transform: scale(.9); }
.scroll-badge {
  position: absolute; top: -5px; right: -5px;
  min-width: 18px; height: 18px; border-radius: 9px;
  background: var(--green); color: #0f172a;
  font-size: 11px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
}


/* ── Media in bubbles ───────────────────────── */
.msg-img-wrap { width: 220px; height: 270px; border-radius: 14px; overflow: hidden; flex-shrink: 0; cursor: pointer; }
.bubble-media.has-caption .msg-img-wrap { border-radius: 14px 14px 0 0; }
.msg-image { display: block; width: 100%; height: 100%; object-fit: cover; }
.msg-image:hover { opacity: .9; }
.msg-img-err { display: flex; align-items: center; gap: 6px; padding: 10px; background: rgba(255,255,255,.04); border-radius: 8px; color: var(--muted); font-size: 12px; }
/* Video wrapper — fixed 220×165 */
.msg-video-wrap {
  position: relative;
  width: 220px; height: 270px;
  border-radius: 14px; overflow: hidden;
  background: #000; flex-shrink: 0;
}
.bubble-media.has-caption .msg-video-wrap { border-radius: 14px 14px 0 0; }
.msg-video {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
}

/* Play overlay */
.msg-video-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.28);
  cursor: pointer; transition: background .15s;
}
.msg-video-overlay:hover { background: rgba(0,0,0,.38); }
.msg-video-play-btn {
  width: 42px; height: 42px; border-radius: 50%;
  background: rgba(255,255,255,.92); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #111; box-shadow: 0 2px 8px rgba(0,0,0,.3);
  transition: transform .12s, background .12s;
}
.msg-video-play-btn:active { transform: scale(.9); background: #fff; }
.msg-video-play-btn svg { margin-left: 2px; }

/* Overlay hides while playing */
.msg-video-wrap { cursor: pointer; }
.msg-video-wrap.playing .msg-video-overlay { opacity: 0; pointer-events: none; }

/* Error overlay */
.msg-video-err {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.55); z-index: 5;
}
.msg-video-reload-btn {
  width: 48px; height: 48px; border-radius: 50%; border: 2px solid rgba(255,255,255,.7);
  background: rgba(0,0,0,.4); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* Bottom controls bar */
.mvb {
  position: absolute; bottom: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 6px;
  padding: 5px 8px 6px;
  background: linear-gradient(transparent, rgba(0,0,0,.65));
  z-index: 3;
}
.mvb-pp, .mvb-fs {
  border: none; background: transparent; color: #fff;
  cursor: pointer; flex-shrink: 0; padding: 2px;
  display: flex; align-items: center; justify-content: center;
}
.mvb-track {
  flex: 1; height: 3px; background: rgba(255,255,255,.3);
  border-radius: 2px; cursor: pointer; position: relative;
}
.mvb-fill { height: 100%; background: #fff; border-radius: 2px; width: 0%; }
.mvb-time { font-size: 10px; color: rgba(255,255,255,.85); flex-shrink: 0; min-width: 28px; }

/* Fullscreen Android: floating bar, guaranteed inside screen */
:fullscreen .msg-video-wrap,
:-webkit-full-screen .msg-video-wrap {
  overflow: hidden;
  width: 100vw !important; height: 100vh !important;
}
:fullscreen .msg-video,
:-webkit-full-screen .msg-video {
  object-fit: contain; /* show full video without crop in fullscreen */
}
:fullscreen .mvb,
:-webkit-full-screen .mvb {
  position: absolute;
  bottom: 48px; left: 16px; right: 16px; /* 48px up from bottom = above Android nav bar */
  border-radius: 14px;
  padding: 12px 16px;
  gap: 14px;
  background: rgba(0,0,0,.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 9999;
}
:fullscreen .mvb-pp,
:fullscreen .mvb-fs,
:-webkit-full-screen .mvb-pp,
:-webkit-full-screen .mvb-fs {
  width: 48px; height: 48px; border-radius: 50%;
  background: rgba(255,255,255,.15); border: 1.5px solid rgba(255,255,255,.25);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
:fullscreen .mvb-pp svg,
:fullscreen .mvb-fs svg,
:-webkit-full-screen .mvb-pp svg,
:-webkit-full-screen .mvb-fs svg { width: 22px; height: 22px; }
:fullscreen .mvb-track,
:-webkit-full-screen .mvb-track { height: 5px; }
:fullscreen .mvb-time,
:-webkit-full-screen .mvb-time { font-size: 14px; min-width: 44px; }
.msg-file { display: flex; align-items: center; justify-content: center; text-decoration: none; color: inherit; padding: 6px; }
.msg-file-icon { font-size: 32px; line-height: 1; }

/* ── Emoji reactions ────────────────────────── */
.emoji-picker-bg { position: fixed; inset: 0; z-index: 498; }
.emoji-picker {
  position: fixed; z-index: 499;
  background: #1e293b; border: 1px solid rgba(255,255,255,.1);
  border-radius: 18px; overflow: hidden;
  display: flex; flex-direction: column;
  min-width: 210px;
  box-shadow: 0 8px 32px rgba(0,0,0,.6);
  animation: epPop .18s cubic-bezier(.34,1.4,.64,1);
}
@keyframes epPop { from{transform:scale(.8);opacity:0} to{transform:scale(1);opacity:1} }
.ep-reactions { display: flex; align-items: center; gap: 2px; padding: 8px 10px; }
.ep-emoji {
  font-size: 24px; background: none; border: none; cursor: pointer;
  padding: 4px 6px; border-radius: 10px; transition: transform .12s; line-height: 1;
}
.ep-emoji:active, .ep-emoji.active { transform: scale(.85); background: rgba(74,222,128,.15); }
.ep-divider { height: 1px; background: rgba(255,255,255,.09); }
.ep-action {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 18px; background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,.85); font-size: 15px; text-align: left; width: 100%;
  transition: background .12s;
}
.ep-action:active { background: rgba(255,255,255,.09); }
.ep-action svg { color: rgba(255,255,255,.5); flex-shrink: 0; }

/* Reaction pills — Viber style: beside the bubble */
.reactions {
  display: flex; flex-direction: column; gap: 3px;
  align-self: center;
  flex-shrink: 0;
}
.reaction-pill {
  display: flex; align-items: center; justify-content: center; gap: 2px;
  background: #1e293b; border: 1.5px solid rgba(255,255,255,.15);
  border-radius: 50px; padding: 4px 8px;
  font-size: 16px; cursor: pointer; line-height: 1;
  box-shadow: 0 2px 8px rgba(0,0,0,.45);
  transition: transform .12s; white-space: nowrap; min-width: 34px;
}
.reaction-pill .rc { font-size: 12px; color: #ccc; font-weight: 700; }
.reaction-pill.mine { border-color: rgba(74,222,128,.5); background: #162212; }
.reaction-pill:active { transform: scale(.88); }

/* ── Media preview screen ───────────────────── */
.media-preview-screen {
  position: fixed; inset: 0; z-index: 900;
  background: #070d18;
  display: flex; flex-direction: column;
  animation: fadeIn .15s ease;
}
.mp-header {
  display: flex; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top,0px) + 14px) 16px 14px;
  flex-shrink: 0;
}
.mp-cancel-btn {
  width: 38px; height: 38px; border-radius: 50%; border: none;
  background: rgba(255,255,255,.08); color: var(--txt);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  flex-shrink: 0;
}
.mp-title { font-size: 17px; font-weight: 600; color: var(--txt); }
.mp-body {
  flex: 1; display: flex; align-items: center; justify-content: center;
  overflow: hidden; padding: 12px 16px; min-height: 0;
}
.mp-body img { max-width: 100%; max-height: 100%; border-radius: 12px; object-fit: contain; }
.mp-body video { max-width: 100%; max-height: 100%; border-radius: 12px; }
.mp-file-prev {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  color: var(--muted);
}
.mp-file-prev svg { color: rgba(255,255,255,.3); }
.mp-file-prev .mp-fn { font-size: 15px; color: var(--txt); text-align: center; word-break: break-all; max-width: 280px; }
.mp-file-prev .mp-fs { font-size: 13px; color: var(--muted); }
.mp-multi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px; padding: 8px;
  width: 100%; overflow-y: auto;
}
.mp-multi-cell {
  position: relative; aspect-ratio: 1;
  border-radius: 8px; overflow: hidden;
  background: rgba(255,255,255,.07);
}
.mp-multi-thumb {
  width: 100%; height: 100%; object-fit: cover;
}
.mp-multi-play {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: rgba(255,255,255,.8);
  pointer-events: none;
}
.mp-multi-file {
  width: 100%; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; padding: 6px; box-sizing: border-box;
  font-size: 11px; color: rgba(255,255,255,.7); text-align: center;
}
.mp-footer {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px calc(env(safe-area-inset-bottom,0px) + 10px);
  flex-shrink: 0;
}
.mp-caption-input {
  flex: 1; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.1);
  border-radius: 22px; padding: 11px 16px; color: var(--txt); font-size: 15px;
  outline: none; font-family: inherit;
}
.mp-send-btn {
  width: 44px; height: 44px; border-radius: 50%; border: none;
  background: var(--green); color: #0f172a;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; cursor: pointer; transition: transform .1s;
}
.mp-send-btn:active { transform: scale(.9); }
.bubble-caption {
  font-size: 14px; line-height: 1.4; color: var(--txt);
  margin-top: 6px; word-break: break-word;
}

/* ── Photo lightbox ─────────────────────────── */
.lightbox {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,.96);
  display: flex; align-items: center; justify-content: center;
  touch-action: none;
}
.lb-inner {
  position: relative; width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  transition: transform .25s cubic-bezier(.25,.46,.45,.94), opacity .25s;
}
.lightbox img {
  max-width: 100vw; max-height: 100dvh;
  object-fit: contain; display: block;
}
.lb-close {
  position: absolute; top: max(12px, env(safe-area-inset-top)) ; right: 12px;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255,255,255,.15); border: none; color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; z-index: 1;
}
.lb-close svg { width: 20px; height: 20px; }

/* ── Video lightbox ─────────────────────────── */
.video-lightbox {
  position: fixed; inset: 0; z-index: 1000;
  background: #000;
  display: flex; align-items: center; justify-content: center;
  touch-action: none;
}
.vlb-inner {
  position: relative; width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  transition: transform .25s cubic-bezier(.25,.46,.45,.94), opacity .25s;
}
#vlb-video {
  max-width: 100%; max-height: 100dvh;
  object-fit: contain; display: block;
}
.vlb-tap {
  position: absolute; inset: 0;
}
.vlb-controls {
  position: absolute; bottom: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px max(20px, env(safe-area-inset-bottom));
  background: linear-gradient(transparent, rgba(0,0,0,.75));
  transition: opacity .3s;
}
.vlb-controls.hidden-ctrl { opacity: 0; pointer-events: none; }
.vlb-btn {
  width: 44px; height: 44px; border-radius: 50%; border: none;
  background: rgba(255,255,255,.15); color: #fff; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.vlb-btn svg { width: 20px; height: 20px; }
.vlb-close-btn { margin-left: auto; }
.vlb-track {
  flex: 1; height: 4px; background: rgba(255,255,255,.3);
  border-radius: 2px; cursor: pointer; position: relative;
}
.vlb-fill { height: 100%; background: #fff; border-radius: 2px; width: 0%; }
.vlb-time { font-size: 13px; color: rgba(255,255,255,.9); flex-shrink: 0; min-width: 38px; }

/* ── Modal ──────────────────────────────────── */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: flex; align-items: center; justify-content: center; z-index: 100; backdrop-filter: blur(4px); }
.modal-content { background: var(--bg2); border: 1px solid var(--brd); border-radius: 14px; width: 380px; max-width: 95vw; padding: 20px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-header h3 { font-size: 16px; font-weight: 700; color: var(--txt); }
.modal-header button { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; transition: color .15s; }
.modal-header button:hover { color: var(--txt); }
.modal-content input { width: 100%; padding: 10px 12px; background: var(--bg); border: 1px solid var(--brd); border-radius: 8px; color: var(--txt); font-size: 14px; outline: none; margin-bottom: 12px; transition: border .2s; }
.modal-content input:focus { border-color: var(--green); }
.modal-content input::placeholder { color: var(--muted); }

.modal-tabs { display: flex; gap: 4px; margin-bottom: 14px; background: var(--bg); border-radius: 8px; padding: 3px; border: 1px solid var(--brd); }
.modal-tab { flex: 1; padding: 7px; border: none; background: transparent; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); transition: all .2s; }
.modal-tab.active { background: var(--bg2); color: var(--green); }

.phone-search-wrap { display: flex; gap: 8px; margin-bottom: 4px; }
.phone-search-wrap input { flex: 1; }
.btn-find { padding: 10px 16px; background: var(--green); color: #0f172a; border: none; border-radius: 8px; font-size: 13px; font-weight: 700; cursor: pointer; white-space: nowrap; flex-shrink: 0; }

.invite-card { padding: 16px; background: var(--bg); border: 1px solid var(--brd); border-radius: 10px; text-align: center; margin-top: 8px; }
.invite-card .inv-phone { font-size: 16px; font-weight: 700; color: var(--txt); margin-bottom: 6px; }
.invite-card .inv-sub { font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.btn-invite { width: 100%; padding: 10px; background: transparent; border: 1px solid var(--green); color: var(--green); border-radius: 8px; font-size: 13px; font-weight: 700; cursor: pointer; }

.user-search-results { max-height: 300px; overflow-y: auto; }
.user-item { display: flex; align-items: center; gap: 11px; padding: 10px 8px; border-radius: 8px; cursor: pointer; transition: background .15s; }
.user-item:hover { background: var(--green-dim); }
.user-item-avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--bg); border: 1px solid var(--brd); color: var(--green); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15px; flex-shrink: 0; }
.user-item-info .name { font-weight: 600; font-size: 14px; color: var(--txt); }
.user-item-info .username { font-size: 12px; color: var(--muted); }
.online-badge { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--green); margin-left: 5px; vertical-align: middle; }

/* ── Mobile ─────────────────────────────────── */
@media (max-width: 700px) {
  .app-layout { position: relative; }
  .sidebar { width: 100%; min-width: 100%; position: absolute; z-index: 10; top: 0; bottom: 0; left: 0; }
  .chat-area { width: 100%; position: absolute; z-index: 20; top: 0; bottom: 0; left: -100%; transition: left .25s; }
  .chat-area.mobile-open { left: 0; }
  .back-btn { display: flex !important; }
  :root { --sidebar-w: 100vw; }
  .bubble { max-width: 78%; }
  .auth-box { padding: 28px 20px; }
  .code-digit { width: 40px; height: 50px; font-size: 22px; }
  .attach-sheet-grid { gap: 8px; }
  .attach-opt { padding: 12px 6px; }
}

/* ── Custom voice player ────────────────────── */
.bubble-voice, .bubble-file, .bubble-media {
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  width: fit-content !important;
  max-width: 100%;
  box-shadow: none !important;
}
.bubble-media.has-caption {
  background: var(--bg2) !important;
  border-radius: 14px !important;
  overflow: hidden;
  padding: 0 !important;
}
.bubble-media.has-caption .bubble-caption {
  padding: 6px 10px 4px;
  margin-top: 0;
}
.bubble-media.has-caption .bubble-time {
  padding: 0 10px 6px;
}
.bubble-voice .bubble-sender,
.bubble-media .bubble-sender { display: none; }

.voice-player {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 22px;
  min-width: 190px; max-width: 240px;
  width: 220px;
}
.voice-player.out {
  background: rgba(74,222,128,.22);
  border: 1px solid rgba(74,222,128,.45);
}
.voice-player.in {
  background: var(--bg);
  border: 1px solid rgba(74,222,128,.4);
  box-shadow: 0 0 14px rgba(74,222,128,.3), 0 0 4px rgba(74,222,128,.15);
}

.vp-btn {
  width: 36px; height: 36px; border-radius: 50%;
  border: none; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: opacity .15s;
}
.vp-btn:hover { opacity: .8; }
.voice-player.out .vp-btn { background: var(--green); color: #0f172a; }
.voice-player.in  .vp-btn { background: var(--green); color: #0f172a; }

.vp-wave {
  flex: 1; display: flex; align-items: center; gap: 2px; height: 24px;
  cursor: pointer; overflow: hidden;
}
.vp-bar {
  width: 3px; border-radius: 2px; flex-shrink: 0;
}
.voice-player.out .vp-bar { background: var(--green); opacity: .5; }
.voice-player.out .vp-bar.played { background: var(--green); opacity: 1; }
.voice-player.in  .vp-bar { background: var(--green); opacity: .4; }
.voice-player.in  .vp-bar.played { background: var(--green); opacity: 1; }

.vp-time {
  font-size: 11px; font-weight: 600; flex-shrink: 0; min-width: 28px; text-align: right;
}
.voice-player.out .vp-time { color: rgba(255,255,255,.7); }
.voice-player.in  .vp-time { color: var(--muted2); }

/* Playback speed button */
.vp-speed {
  font-size: 10px; font-weight: 700; border: none; background: transparent;
  cursor: pointer; padding: 0 2px; flex-shrink: 0; min-width: 22px;
  border-radius: 4px; transition: background .15s;
}
.voice-player.out .vp-speed { color: rgba(255,255,255,.6); }
.voice-player.in  .vp-speed { color: var(--muted2); }
.voice-player.out .vp-speed:active { background: rgba(255,255,255,.1); }
.voice-player.in  .vp-speed:active { background: rgba(255,255,255,.07); }

/* ── Selection mode ── */
.select-bar {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px;
  background: var(--bg2); border-bottom: 1px solid var(--brd);
  font-size: 14px; color: var(--txt);
}
.select-bar-cancel {
  border: none; background: transparent; color: var(--muted2); cursor: pointer;
  font-size: 18px; line-height: 1; padding: 2px 6px;
}
#select-count { flex: 1; font-weight: 600; }
.select-bar-clear {
  border: none; background: transparent; color: var(--muted2); cursor: pointer;
  font-size: 13px; padding: 4px 8px; border-radius: 6px; transition: background .15s;
}
.select-bar-clear:active { background: rgba(255,255,255,.07); }
.select-bar-del {
  border: none; background: rgba(239,68,68,.15); color: var(--red); cursor: pointer;
  width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.select-bar-del:active { background: rgba(239,68,68,.3); }

/* Checkbox circle (always in DOM, hidden by default) */
.msg-checkbox {
  display: none;
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--muted);
  flex-shrink: 0; align-items: center; justify-content: center;
  cursor: pointer; transition: border-color .15s, background .15s;
  background: transparent;
}
.msg-checkbox svg { opacity: 0; transition: opacity .1s; }

/* Show checkboxes in select mode */
.messages-list.select-mode .message-row { cursor: pointer; }
.messages-list.select-mode .msg-checkbox { display: flex; }

/* Checked state */
.msg-checkbox.checked {
  background: var(--green);
  border-color: var(--green);
}
.msg-checkbox.checked svg { opacity: 1; }

/* ── Universal media button ───────────────────────────── */
.media-open-btn {
  width: 38px; height: 38px; border-radius: 50%; border: none;
  background: transparent;
  color: rgba(255,255,255,.55);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: color .15s, filter .15s;
  flex-shrink: 0;
}
.media-open-btn:active { color: rgba(255,255,255,.9); }
.media-open-btn.active {
  color: #a78bfa;
  filter: drop-shadow(0 0 6px rgba(167,139,250,.5));
}

/* ── GIF Picker panel (fixed, keyboard-height) ────────── */
.gif-picker {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: 300px;
  z-index: 300;
  display: flex; flex-direction: column;
  background: #111827;
  border-top: 1px solid rgba(255,255,255,.10);
  transform: translateY(100%);
  transition: transform .22s cubic-bezier(.4,0,.2,1), height .2s ease, top .2s ease;
}
.gif-picker.open { transform: translateY(0); }
.gif-picker.hidden { display: none; }
.gif-drag-handle {
  width: 44px; height: 5px; border-radius: 3px;
  background: rgba(255,255,255,.25);
  margin: 0 auto; flex-shrink: 0;
  padding: 12px 0; /* large touch target */
  box-sizing: content-box;
  background-clip: content-box;
  cursor: ns-resize;
}
.gif-picker-top {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px 6px; flex-shrink: 0;
}
.gif-kb-btn {
  width: 38px; height: 38px; border-radius: 10px; border: none;
  background: rgba(255,255,255,.08); color: rgba(255,255,255,.7);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
}
.gif-kb-btn:active { background: rgba(255,255,255,.15); }
.gif-search-wrap {
  flex: 1; display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.08); border-radius: 16px; padding: 6px 12px;
}
.gif-search-input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--txt); font-size: 14px;
}
.gif-tabs-bar {
  display: flex; border-bottom: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}
.gif-tab {
  flex: 1; padding: 8px 4px; border: none; border-bottom: 2px solid transparent;
  background: none; color: rgba(255,255,255,.45);
  font-size: 13px; font-weight: 600; cursor: pointer; transition: all .15s;
}
.gif-tab.active { color: var(--green); border-bottom-color: var(--green); }
.gif-grid {
  flex: 1; overflow-y: auto;
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 2px; padding: 3px;
  -webkit-overflow-scrolling: touch;
}
.gif-grid.hidden { display: none; }
.gif-thumb {
  aspect-ratio: 4/3; object-fit: cover; border-radius: 6px;
  cursor: pointer; width: 100%; background: rgba(255,255,255,.05);
  transition: opacity .15s;
}
.gif-thumb:active { opacity: 0.7; }
.gif-loading {
  grid-column: 1 / -1; text-align: center;
  padding: 32px; color: rgba(255,255,255,.3); font-size: 14px;
}
.sticker-thumb {
  aspect-ratio: 1; object-fit: contain; border-radius: 8px;
  cursor: pointer; width: 100%; background: transparent;
  transition: transform .15s;
  padding: 4px; box-sizing: border-box;
}
.sticker-thumb:active { transform: scale(.9); }

/* ── Emoji picker ─────────────────────────────────────── */
.emoji-panel {
  flex: 1; overflow: hidden;
  display: flex; flex-direction: column;
}
.emoji-panel.hidden { display: none; }
.emoji-cats {
  display: flex; gap: 2px; padding: 4px 6px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  overflow-x: auto; flex-shrink: 0;
  scrollbar-width: none;
}
.emoji-cats::-webkit-scrollbar { display: none; }
.emoji-cat-btn {
  width: 34px; height: 30px; border: none; background: none;
  border-radius: 7px; font-size: 17px; cursor: pointer;
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  transition: background .1s; opacity: .65;
}
.emoji-cat-btn.active { background: rgba(255,255,255,.12); opacity: 1; }
.emoji-items {
  display: grid; grid-template-columns: repeat(8, 1fr);
  overflow-y: auto; flex: 1; padding: 3px;
  -webkit-overflow-scrolling: touch;
}
.emoji-btn {
  aspect-ratio: 1; border: none; background: none;
  border-radius: 8px; font-size: 22px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .1s; touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.emoji-btn:active { background: rgba(255,255,255,.12); }
.emoji-empty {
  grid-column: 1/-1; text-align: center;
  padding: 28px 16px; color: rgba(255,255,255,.3); font-size: 13px;
}

/* ── GIF bubble ───────────────────────────────────────── */
.bubble-gif {
  background: none !important; box-shadow: none !important;
  padding: 0 !important; border: none !important;
}
.msg-gif { width: 220px; max-width: 100%; border-radius: 14px; display: block; }

/* ══════════════════════════════════════════════
   SIDEBAR REDESIGN — Viber/Smart-D style
   ══════════════════════════════════════════════ */

/* Override old sidebar-header */
.sidebar { position: relative; overflow: visible; }
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0; background: var(--bg2);
}
/* Hide old my-avatar/app-title/icon-btn if any remnants */
.my-avatar { display: none; }
.app-title { display: none; }

.sh-title {
  font-size: 20px; font-weight: 800; color: #fff; letter-spacing: -.3px;
}
.sh-title span {
  font-weight: 700; color: var(--green); letter-spacing: 2px;
  font-size: 18px; margin-left: 3px;
}
.sh-right { display: flex; align-items: center; gap: 10px; }
.sh-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--green), var(--green2));
  color: #0f172a; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px; cursor: pointer;
  box-shadow: 0 0 0 2px rgba(74,222,128,.25);
  transition: box-shadow .2s;
}
.sh-avatar:hover { box-shadow: 0 0 0 3px rgba(74,222,128,.45); }
.sh-dots {
  width: 34px; height: 34px; border-radius: 50%;
  background: transparent; border: none; cursor: pointer;
  color: rgba(255,255,255,.45);
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.sh-dots:hover { background: rgba(255,255,255,.07); color: rgba(255,255,255,.85); }

/* 3-dot dropdown */
.sidebar-menu {
  position: fixed; z-index: 2000;
  background: #1a2436;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 14px; overflow: hidden; min-width: 178px;
  box-shadow: 0 16px 48px rgba(0,0,0,.6), 0 0 0 1px rgba(0,0,0,.3);
}
.sm-item {
  display: flex; align-items: center; gap: 11px;
  padding: 12px 16px; width: 100%; background: none; border: none;
  cursor: pointer; color: var(--txt); font-size: 13px; font-weight: 500;
  transition: background .15s; text-align: left;
}
.sm-item:hover { background: rgba(255,255,255,.05); }
.sm-item svg { flex-shrink: 0; opacity: .6; }
.sm-item-danger { color: var(--red); }
.sm-item-danger svg { opacity: .8; }
.sm-divider { height: 1px; background: rgba(255,255,255,.07); }

/* Premium search */
.sb-search { padding: 10px 12px 6px; flex-shrink: 0; }
.sb-search-inner {
  background: rgba(255,255,255,.07);
  border-radius: 24px;
  display: flex; align-items: center; gap: 9px; padding: 9px 16px;
  transition: background .2s;
}
.sb-search-inner:focus-within { background: rgba(255,255,255,.11); }
.sb-search-inner svg { color: rgba(255,255,255,.3); flex-shrink: 0; }
.sb-search-inner input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--txt); font-size: 14px;
}
.sb-search-inner input::placeholder { color: rgba(255,255,255,.28); }

/* Tabs */
.sb-tabs { display: flex; gap: 4px; padding: 0 12px 8px; flex-shrink: 0; }
.sb-tab {
  padding: 6px 16px; border-radius: 20px;
  font-size: 13px; font-weight: 600;
  color: rgba(255,255,255,.38);
  background: none; border: none; cursor: pointer;
  transition: all .15s;
}
.sb-tab:hover { color: rgba(255,255,255,.65); }
.sb-tab.active { background: rgba(74,222,128,.14); color: var(--green); }

/* Compose FAB */
.compose-fab {
  position: absolute;
  bottom: calc(62px + env(safe-area-inset-bottom, 0px) + 14px);
  right: 16px;
  width: 54px; height: 54px; border-radius: 50%;
  background: linear-gradient(135deg, var(--green), var(--green2));
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 22px rgba(74,222,128,.45);
  z-index: 20;
  transition: transform .18s cubic-bezier(.34,1.56,.64,1), box-shadow .18s;
}
.compose-fab:hover { transform: scale(1.08); box-shadow: 0 10px 30px rgba(74,222,128,.55); }
.compose-fab.open { transform: rotate(15deg) scale(1.05); }

/* Compose menu (fixed) */
.compose-menu {
  position: fixed; z-index: 2000;
  background: #1a2436;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 14px; overflow: hidden; min-width: 196px;
  box-shadow: 0 16px 48px rgba(0,0,0,.6), 0 0 0 1px rgba(0,0,0,.3);
}
.cm-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 18px; width: 100%; background: none; border: none;
  cursor: pointer; color: var(--txt); font-size: 14px; font-weight: 500;
  transition: background .15s; text-align: left;
}
.cm-item:hover { background: rgba(255,255,255,.05); }
.cm-item svg { color: var(--green); flex-shrink: 0; }

/* Bottom nav */
.bottom-nav {
  display: flex; flex-shrink: 0;
  border-top: 1px solid rgba(255,255,255,.06);
  padding: 5px 6px calc(5px + env(safe-area-inset-bottom, 0px));
  background: var(--bg2);
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 4px; border-radius: 12px;
  background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,.28); transition: all .15s;
}
.nav-item:hover { background: rgba(255,255,255,.04); color: rgba(255,255,255,.55); }
.nav-item.active { color: var(--green); }
.nav-item span { font-size: 10px; font-weight: 600; letter-spacing: .2px; }

/* Larger chat avatars */
.conv-avatar { width: 52px; height: 52px; font-size: 18px; }

/* Toast */
.toast {
  position: fixed; bottom: 32px; left: 50%; transform: translateX(-50%);
  background: rgba(30,41,59,.95); color: var(--txt);
  padding: 10px 20px; border-radius: 24px;
  font-size: 13px; font-weight: 600; z-index: 9999;
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,.1);
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  pointer-events: none; white-space: nowrap;
  transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.hidden { opacity: 0; transform: translateX(-50%) translateY(8px); }

/* ══════════════════════════════════════════════
   MOBILE SIZE BOOST — крупнее для телефона
   ══════════════════════════════════════════════ */

/* Шапка */
.sidebar-header {
  padding: calc(18px + env(safe-area-inset-top)) 18px 16px;
}
.sh-title { font-size: 24px; }
.sh-title span { font-size: 21px; }
.sh-avatar { width: 42px; height: 42px; font-size: 16px; }
.sh-dots { width: 38px; height: 38px; }

/* Поиск */
.sb-search { padding: 12px 14px 8px; }
.sb-search-inner { padding: 11px 18px; gap: 10px; border-radius: 28px; }
.sb-search-inner input { font-size: 15px; }
.sb-search-inner svg { width: 17px; height: 17px; }

/* Вкладки */
.sb-tabs { padding: 0 14px 10px; gap: 6px; }
.sb-tab { padding: 8px 20px; font-size: 14px; border-radius: 24px; }

/* Список чатов */
.conv-item { padding: 13px 16px; gap: 14px; }
.conv-avatar { width: 58px; height: 58px; font-size: 20px; border-radius: 50%; }
.conv-avatar .online-dot { width: 13px; height: 13px; border-width: 2.5px; bottom: 0; right: 0; }
.conv-name { font-size: 16px; font-weight: 700; }
.conv-last { font-size: 13.5px; margin-top: 3px; }
.conv-status { font-size: 11.5px; }
.conv-unread { min-width: 22px; height: 22px; font-size: 12px; padding: 0 6px; }

/* FAB */
.compose-fab {
  width: 60px; height: 60px;
  bottom: calc(72px + env(safe-area-inset-bottom, 0px) + 14px);
  right: 18px;
}
.compose-fab svg { width: 25px; height: 25px; }

/* Нижняя навигация */
.bottom-nav { padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px)); }
.nav-item { padding: 9px 4px; border-radius: 14px; gap: 4px; }
.nav-item svg { width: 25px; height: 25px; }
.nav-item span { font-size: 11px; }

/* ══════════════════════════════════════════════
   СХЕМА 3 — Глубокий контраст + неон
   ══════════════════════════════════════════════ */

/* LINK в заголовке — свечение */
.sh-title span { text-shadow: 0 0 18px rgba(31,255,114,.55); }

/* Пузыри сообщений — неоновая рамка */
.bubble.in {
  border-color: rgba(31,255,114,.35);
  box-shadow: 0 0 16px rgba(31,255,114,.28), 0 0 4px rgba(31,255,114,.12);
}
.bubble.out {
  background: rgba(31,255,114,.13);
  border-color: rgba(31,255,114,.22);
}

/* Онлайн-точка — свечение */
.conv-avatar .online-dot { box-shadow: 0 0 7px rgba(31,255,114,.7); }
.chat-header-status.online::before { box-shadow: 0 0 6px rgba(31,255,114,.6); }

/* Бейдж непрочитанных — свечение */
.conv-unread { box-shadow: 0 0 10px rgba(31,255,114,.45); }

/* Активная вкладка — текст с подсветкой */
.sb-tab.active { text-shadow: 0 0 12px rgba(31,255,114,.35); }

/* Активный пункт навигации — иконка с подсветкой */
.nav-item.active svg { filter: drop-shadow(0 0 5px rgba(31,255,114,.5)); }

/* FAB — усиленное свечение */
.compose-fab {
  box-shadow: 0 6px 24px rgba(31,255,114,.5), 0 0 40px rgba(31,255,114,.12);
}
.compose-fab:hover {
  box-shadow: 0 10px 30px rgba(31,255,114,.6), 0 0 50px rgba(31,255,114,.18);
}

/* Поиск — тонкая зелёная рамка */
.sb-search-inner { border: 1px solid rgba(31,255,114,.1); }
.sb-search-inner:focus-within { border-color: rgba(31,255,114,.25); }

/* Шапка чата — чуть тёмнее фон */
.chat-header { background: #070f1e; border-bottom-color: rgba(31,255,114,.1); }

/* Sidebar header border */
.sidebar-header { border-bottom-color: rgba(31,255,114,.1); }

/* Нижняя навигация border */
.bottom-nav { border-top-color: rgba(31,255,114,.1); }

/* Активный чат в списке */
.conv-item.active {
  background: rgba(31,255,114,.08);
  border-left-color: var(--green);
}

/* Разделитель между чатами */
.conv-item { border-bottom-color: rgba(255,255,255,.04); }

/* Кнопка отправки сообщения */
.send-btn { box-shadow: 0 2px 12px rgba(31,255,114,.35); }

/* Reply bubble */
.reply-bubble { border-left-color: var(--green); }

/* Крупный бренд на экране входа */
.auth-logo .brand { text-shadow: 0 0 20px rgba(31,255,114,.4); }

/* confirm-panel под тёмную схему 3 */
.confirm-panel { background: #0c1628; border-color: rgba(31,255,114,.12); }

/* ══════════════════════════════════════════════
   THEME PICKER UI
   ══════════════════════════════════════════════ */
.sm-item-theme { justify-content: flex-start; }
.theme-picker { padding: 4px 0 4px 8px; border-top: 1px solid rgba(255,255,255,.06); border-bottom: 1px solid rgba(255,255,255,.06); margin: 2px 0; }
.tp-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px 9px 12px; width: 100%;
  background: none; border: none; cursor: pointer;
  color: var(--txt); font-size: 13px; border-radius: 8px;
  transition: background .15s; text-align: left;
}
.tp-item:hover { background: rgba(255,255,255,.05); }
.tp-swatch { width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0; }
.tp-check { margin-left: auto; opacity: 0; color: var(--green); flex-shrink: 0; }
.tp-item.active .tp-check { opacity: 1; }
.tp-item.active { font-weight: 600; }

/* ══════════════════════════════════════════════
   СВЕТЛАЯ ТЕМА 2 — Тёплый молочный
   ══════════════════════════════════════════════ */
html[data-theme="light2"] {
  --bg:        #eeece4;
  --bg2:       #f7f5ee;
  --bg3:       #e4e1d6;
  --brd:       #ddd9ca;
  --txt:       #1c2410;
  --muted:     #7a7a62;
  --muted2:    #9a9a80;
  --green:     #15803d;
  --green2:    #166534;
  --green-dim: rgba(21,128,61,.12);
}
html[data-theme="light2"] body { background: var(--bg); }
html[data-theme="light2"] .sidebar-menu,
html[data-theme="light2"] .compose-menu { background: #f0ede4; border-color: #d0ccc0; box-shadow: 0 8px 32px rgba(0,0,0,.15); }
html[data-theme="light2"] .sm-item { color: #1c2410; }
html[data-theme="light2"] .sm-item:hover { background: rgba(0,0,0,.05); }
html[data-theme="light2"] .sm-item svg { opacity: .5; }
html[data-theme="light2"] .sm-divider { background: #d8d5c8; }
html[data-theme="light2"] .tp-item { color: #1c2410; }
html[data-theme="light2"] .tp-item:hover { background: rgba(0,0,0,.05); }
html[data-theme="light2"] .theme-picker { border-color: #d8d5c8; }
html[data-theme="light2"] .confirm-panel { background: #f0ede4; border-color: #d0ccc0; }
html[data-theme="light2"] .confirm-msg { color: #1c2410; }
html[data-theme="light2"] .confirm-cancel { border-color: #d0ccc0; background: rgba(0,0,0,.04); color: #4a4a36; }
html[data-theme="light2"] .message-input-bar { background: rgba(247,245,238,.95); border-top-color: #ddd9ca; }
html[data-theme="light2"] .message-input-bar::before { background: linear-gradient(to bottom, transparent, rgba(247,245,238,.95)); }
html[data-theme="light2"] .chat-view { background: #e8e5da; }
html[data-theme="light2"] .chat-header { background: #f7f5ee; border-bottom-color: #ddd9ca; }
html[data-theme="light2"] .bubble.in { box-shadow: 0 2px 8px rgba(21,128,61,.12); border-color: rgba(21,128,61,.3); }
html[data-theme="light2"] .bubble.out { background: rgba(21,128,61,.12); border-color: rgba(21,128,61,.2); }
html[data-theme="light2"] .sh-title span { text-shadow: none; }
html[data-theme="light2"] .sb-search-inner { border-color: #d0ccc0; background: #e8e5da; }
html[data-theme="light2"] .sidebar-header { border-bottom-color: #ddd9ca; }
html[data-theme="light2"] .bottom-nav { border-top-color: #ddd9ca; }
html[data-theme="light2"] .compose-fab { box-shadow: 0 6px 20px rgba(21,128,61,.35); }
html[data-theme="light2"] .compose-fab:hover { box-shadow: 0 10px 28px rgba(21,128,61,.45); }
html[data-theme="light2"] .nav-item.active svg { filter: none; }
html[data-theme="light2"] .conv-unread { box-shadow: none; }
html[data-theme="light2"] .gif-picker { background: #f0ede4; border-color: #d0ccc0; }
html[data-theme="light2"] .gif-drag-handle { background: #d0ccc0; }
html[data-theme="light2"] #message-input[data-placeholder]:empty::before { color: #9a9a80; }
html[data-theme="light2"] .modal-content { background: #f0ede4; border-color: #d0ccc0; }
html[data-theme="light2"] .modal-header { border-bottom-color: #d0ccc0; }
html[data-theme="light2"] .toast { background: rgba(240,237,228,.95); color: #1c2410; border-color: #d0ccc0; box-shadow: 0 8px 24px rgba(0,0,0,.15); }

/* ══════════════════════════════════════════════
   СВЕТЛАЯ ТЕМА 3 — Серо-голубой
   ══════════════════════════════════════════════ */
html[data-theme="light3"] {
  --bg:        #e4eaf4;
  --bg2:       #f4f7ff;
  --bg3:       #dce3ef;
  --brd:       #d1dae8;
  --txt:       #0f1e33;
  --muted:     #6a84a0;
  --muted2:    #8ea0bb;
  --green:     #059669;
  --green2:    #047857;
  --green-dim: rgba(5,150,105,.12);
}
html[data-theme="light3"] body { background: var(--bg); }
html[data-theme="light3"] .sidebar-menu,
html[data-theme="light3"] .compose-menu { background: #eef2fb; border-color: #c8d4e8; box-shadow: 0 8px 32px rgba(0,0,0,.12); }
html[data-theme="light3"] .sm-item { color: #0f1e33; }
html[data-theme="light3"] .sm-item:hover { background: rgba(0,0,0,.04); }
html[data-theme="light3"] .sm-item svg { opacity: .5; }
html[data-theme="light3"] .sm-divider { background: #c8d4e8; }
html[data-theme="light3"] .tp-item { color: #0f1e33; }
html[data-theme="light3"] .tp-item:hover { background: rgba(0,0,0,.04); }
html[data-theme="light3"] .theme-picker { border-color: #c8d4e8; }
html[data-theme="light3"] .confirm-panel { background: #eef2fb; border-color: #c8d4e8; }
html[data-theme="light3"] .confirm-msg { color: #0f1e33; }
html[data-theme="light3"] .confirm-cancel { border-color: #c8d4e8; background: rgba(0,0,0,.04); color: #4a5a70; }
html[data-theme="light3"] .message-input-bar { background: rgba(244,247,255,.95); border-top-color: #d1dae8; }
html[data-theme="light3"] .message-input-bar::before { background: linear-gradient(to bottom, transparent, rgba(244,247,255,.95)); }
html[data-theme="light3"] .chat-view { background: #dce5f5; }
html[data-theme="light3"] .chat-header { background: #f4f7ff; border-bottom-color: #d1dae8; }
html[data-theme="light3"] .bubble.in { box-shadow: 0 2px 8px rgba(5,150,105,.1); border-color: rgba(5,150,105,.28); }
html[data-theme="light3"] .bubble.out { background: rgba(5,150,105,.11); border-color: rgba(5,150,105,.2); }
html[data-theme="light3"] .sh-title span { text-shadow: none; }
html[data-theme="light3"] .sb-search-inner { border-color: #c8d4e8; background: #dce3ef; }
html[data-theme="light3"] .sidebar-header { border-bottom-color: #d1dae8; }
html[data-theme="light3"] .bottom-nav { border-top-color: #d1dae8; }
html[data-theme="light3"] .compose-fab { box-shadow: 0 6px 20px rgba(5,150,105,.35); }
html[data-theme="light3"] .compose-fab:hover { box-shadow: 0 10px 28px rgba(5,150,105,.45); }
html[data-theme="light3"] .nav-item.active svg { filter: none; }
html[data-theme="light3"] .conv-unread { box-shadow: none; }
html[data-theme="light3"] .toast { background: rgba(238,242,251,.95); color: #0f1e33; border-color: #c8d4e8; box-shadow: 0 8px 24px rgba(0,0,0,.12); }

/* ══════════════════════════════════════════════
   СВЕТЛАЯ ТЕМА 4 — Мята
   ══════════════════════════════════════════════ */
html[data-theme="light4"] {
  --bg:        #d8f5e8;
  --bg2:       #f5fdf8;
  --bg3:       #cceedd;
  --brd:       #b8e8d0;
  --txt:       #052e16;
  --muted:     #4d8866;
  --muted2:    #6aaa80;
  --green:     #047857;
  --green2:    #065f46;
  --green-dim: rgba(4,120,87,.12);
}
html[data-theme="light4"] body { background: var(--bg); }
html[data-theme="light4"] .sidebar-menu,
html[data-theme="light4"] .compose-menu { background: #ecfdf5; border-color: #a8dcc0; box-shadow: 0 8px 32px rgba(0,0,0,.12); }
html[data-theme="light4"] .sm-item { color: #052e16; }
html[data-theme="light4"] .sm-item:hover { background: rgba(0,0,0,.04); }
html[data-theme="light4"] .sm-item svg { opacity: .5; }
html[data-theme="light4"] .sm-divider { background: #a8dcc0; }
html[data-theme="light4"] .tp-item { color: #052e16; }
html[data-theme="light4"] .tp-item:hover { background: rgba(0,0,0,.04); }
html[data-theme="light4"] .theme-picker { border-color: #a8dcc0; }
html[data-theme="light4"] .confirm-panel { background: #ecfdf5; border-color: #a8dcc0; }
html[data-theme="light4"] .confirm-msg { color: #052e16; }
html[data-theme="light4"] .confirm-cancel { border-color: #a8dcc0; background: rgba(0,0,0,.04); color: #2d6648; }
html[data-theme="light4"] .message-input-bar { background: rgba(245,253,248,.95); border-top-color: #b8e8d0; }
html[data-theme="light4"] .message-input-bar::before { background: linear-gradient(to bottom, transparent, rgba(245,253,248,.95)); }
html[data-theme="light4"] .chat-view { background: #cceedd; }
html[data-theme="light4"] .chat-header { background: #f5fdf8; border-bottom-color: #b8e8d0; }
html[data-theme="light4"] .bubble.in { box-shadow: 0 2px 8px rgba(4,120,87,.1); border-color: rgba(4,120,87,.28); }
html[data-theme="light4"] .bubble.out { background: rgba(4,120,87,.1); border-color: rgba(4,120,87,.2); }
html[data-theme="light4"] .sh-title span { text-shadow: none; }
html[data-theme="light4"] .sb-search-inner { border-color: #a8dcc0; background: #cceedd; }
html[data-theme="light4"] .sidebar-header { border-bottom-color: #b8e8d0; }
html[data-theme="light4"] .bottom-nav { border-top-color: #b8e8d0; }
html[data-theme="light4"] .compose-fab { box-shadow: 0 6px 20px rgba(4,120,87,.35); }
html[data-theme="light4"] .compose-fab:hover { box-shadow: 0 10px 28px rgba(4,120,87,.45); }
html[data-theme="light4"] .nav-item.active svg { filter: none; }
html[data-theme="light4"] .conv-unread { box-shadow: none; }
html[data-theme="light4"] .toast { background: rgba(236,253,245,.95); color: #052e16; border-color: #a8dcc0; box-shadow: 0 8px 24px rgba(0,0,0,.1); }

/* ══════════════════════════════════════════════
   ОБЩИЕ ПЕРЕОПРЕДЕЛЕНИЯ ДЛЯ ВСЕХ СВЕТЛЫХ ТЕМ
   Покрывает ВСЕ элементы которые сливаются
   ══════════════════════════════════════════════ */
html[data-theme="light2"],
html[data-theme="light3"],
html[data-theme="light4"] {
  color-scheme: light;
}

/* ── Поле ввода сообщения ── */
html[data-theme^="light"] .message-input-bar {
  background: rgba(var(--bg2-rgb, 247,245,238), .97);
  border-top-color: var(--brd);
  backdrop-filter: blur(12px);
}
html[data-theme^="light"] .message-input-bar::before {
  display: none;
}
html[data-theme^="light"] .input-normal {
  background: transparent;
}
html[data-theme^="light"] #message-input {
  color: var(--txt);
  background: rgba(0,0,0,.05);
  border-radius: 20px;
  padding: 8px 14px;
}
html[data-theme^="light"] #message-input[data-placeholder]:empty::before {
  color: var(--muted) !important;
}
html[data-theme^="light"] .plus-btn,
html[data-theme^="light"] #attach-btn {
  color: var(--muted);
  background: transparent;
}
html[data-theme^="light"] .plus-btn:hover { color: var(--green); }
html[data-theme^="light"] .media-open-btn {
  color: var(--muted) !important;
  background: transparent !important;
}
html[data-theme^="light"] .media-open-btn.active {
  color: var(--green) !important;
}
html[data-theme^="light"] .voice-btn { color: var(--muted); }
html[data-theme^="light"] .voice-btn.recording { color: var(--green); }
html[data-theme^="light"] .send-btn {
  background: var(--green);
  color: #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,.15);
}

/* ── Пузыри сообщений ── */
html[data-theme^="light"] .bubble.in {
  background: var(--bg2);
  color: var(--txt);
  border-color: var(--brd);
}
html[data-theme^="light"] .bubble.out {
  color: var(--txt);
}
html[data-theme^="light"] .bubble-time { color: var(--muted) !important; }
html[data-theme^="light"] .bubble.out .bubble-time { color: var(--muted) !important; }
html[data-theme^="light"] .bubble-sender { color: var(--green); }
html[data-theme^="light"] .date-divider span {
  background: rgba(0,0,0,.08);
  color: var(--muted);
}
html[data-theme^="light"] .reply-bubble {
  background: rgba(0,0,0,.05);
  color: var(--muted);
}

/* ── Чат шапка ── */
html[data-theme^="light"] .chat-header {
  background: var(--bg2);
  border-bottom-color: var(--brd);
}
html[data-theme^="light"] .back-btn { color: var(--muted) !important; }
html[data-theme^="light"] .back-btn:hover { background: rgba(0,0,0,.06) !important; color: var(--txt) !important; }
html[data-theme^="light"] .chat-header-avatar {
  background: var(--bg);
  border-color: var(--brd);
  color: var(--green);
}
html[data-theme^="light"] .chat-header-name { color: var(--txt); }
html[data-theme^="light"] .chat-header-status { color: var(--muted); }

/* ── Список чатов ── */
html[data-theme^="light"] .conv-item {
  border-bottom-color: var(--brd);
}
html[data-theme^="light"] .conv-item:hover { background: rgba(0,0,0,.03); }
html[data-theme^="light"] .conv-item.active {
  background: var(--green-dim);
  border-left-color: var(--green);
}
html[data-theme^="light"] .conv-avatar {
  background: var(--bg);
  border-color: var(--brd);
}
html[data-theme^="light"] .conv-avatar .online-dot {
  border-color: var(--bg2);
  box-shadow: none;
}
html[data-theme^="light"] .conv-name { color: var(--txt); }
html[data-theme^="light"] .conv-last { color: var(--muted); }
html[data-theme^="light"] .conv-status { color: var(--muted); }
html[data-theme^="light"] .conv-status.online { color: var(--green); }

/* ── Прокрутка и кнопка вниз ── */
html[data-theme^="light"] .scroll-btn {
  background: var(--bg2);
  border: 1px solid var(--brd);
  color: var(--txt);
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
html[data-theme^="light"] .messages-container::-webkit-scrollbar-thumb { background: var(--brd); }
html[data-theme^="light"] .conversations-list::-webkit-scrollbar-thumb { background: var(--brd); }

/* ── Поиск в сайдбаре ── */
html[data-theme^="light"] .sb-search-inner input { color: var(--txt); }
html[data-theme^="light"] .sh-dots { color: var(--muted); }
html[data-theme^="light"] .sh-dots:hover { background: rgba(0,0,0,.06); color: var(--txt); }

/* ── Вкладки ── */
html[data-theme^="light"] .sb-tab { color: var(--muted); }
html[data-theme^="light"] .sb-tab:hover { color: var(--txt); }

/* ── Нижняя навигация иконки ── */
html[data-theme^="light"] .nav-item { color: var(--muted); }
html[data-theme^="light"] .nav-item:hover { background: rgba(0,0,0,.04); color: var(--txt); }
html[data-theme^="light"] .nav-item.active { color: var(--green); }

/* ── Пустое состояние ── */
html[data-theme^="light"] .empty-state { color: var(--muted); }

/* ── GIF пикер ── */
html[data-theme^="light"] .gif-picker {
  background: var(--bg2);
  border-top-color: var(--brd);
  box-shadow: 0 -4px 24px rgba(0,0,0,.12);
}
html[data-theme^="light"] .gif-drag-handle { background: var(--brd); }
html[data-theme^="light"] .gif-tab { color: var(--muted); }
html[data-theme^="light"] .gif-tab.active { color: var(--green); border-bottom-color: var(--green); }
html[data-theme^="light"] .gif-search-input {
  background: rgba(0,0,0,.06);
  color: var(--txt);
  border-color: var(--brd);
}
html[data-theme^="light"] .gif-search-input::placeholder { color: var(--muted); }
html[data-theme^="light"] .gif-kb-btn { color: var(--muted); }
html[data-theme^="light"] .gif-search-wrap {
  background: rgba(0,0,0,.06);
  border-color: var(--brd);
}
html[data-theme^="light"] .gif-tabs-bar { border-bottom-color: var(--brd); }
html[data-theme^="light"] .emoji-cat-btn { color: var(--muted); }
html[data-theme^="light"] .emoji-cat-btn.active { background: rgba(0,0,0,.08); }
html[data-theme^="light"] .emoji-cats { border-bottom-color: var(--brd); }
html[data-theme^="light"] .emoji-btn:active { background: rgba(0,0,0,.1); }
html[data-theme^="light"] .sticker-thumb { background: transparent; }

/* ── Attach sheet ── */
html[data-theme^="light"] .attach-sheet-panel {
  background: var(--bg2);
  box-shadow: 0 -4px 24px rgba(0,0,0,.12);
}
html[data-theme^="light"] .attach-handle { background: var(--brd); }
html[data-theme^="light"] .attach-opt-label { color: var(--txt); }

/* ── Медиа превью ── */
html[data-theme^="light"] .media-preview-screen {
  background: var(--bg2);
}
html[data-theme^="light"] .mp-header { background: var(--bg2); border-bottom-color: var(--brd); }
html[data-theme^="light"] .mp-cancel-btn { color: var(--txt); }
html[data-theme^="light"] .mp-title { color: var(--txt); }
html[data-theme^="light"] .mp-caption-input {
  background: rgba(0,0,0,.06);
  color: var(--txt);
  border-color: var(--brd);
}
html[data-theme^="light"] .mp-caption-input::placeholder { color: var(--muted); }
html[data-theme^="light"] .mp-footer { background: var(--bg2); border-top-color: var(--brd); }

/* ── Reply/Edit preview ── */
html[data-theme^="light"] .reply-preview {
  background: var(--bg2);
  border-top-color: rgba(0,0,0,.08);
}
html[data-theme^="light"] .reply-preview button { color: var(--muted); }

/* ── Upload progress ── */
html[data-theme^="light"] #upload-label { color: var(--muted); }

/* ── Голосовое сообщение ── */
html[data-theme^="light"] .voice-rec-bar {
  background: var(--bg2);
  border-top-color: var(--brd);
}
html[data-theme^="light"] .voice-slide-hint { color: var(--muted); }
html[data-theme^="light"] .voice-cancel-zone { color: #ef4444; }
html[data-theme^="light"] .voice-locked-bar {
  background: var(--bg2);
  border-top-color: var(--brd);
}
html[data-theme^="light"] .vl-trash { color: #ef4444; }
html[data-theme^="light"] .vl-send-btn { background: var(--green); }
html[data-theme^="light"] .vl-pause-btn { color: var(--txt); border-color: var(--brd); }
html[data-theme^="light"] .vl-progress-track { background: rgba(0,0,0,.1); }
html[data-theme^="light"] .voice-lock-float { background: var(--bg2); box-shadow: 0 4px 16px rgba(0,0,0,.12); }

/* ── Select bar ── */
html[data-theme^="light"] .select-bar {
  background: var(--bg2);
  border-bottom-color: var(--brd);
  color: var(--txt);
}
html[data-theme^="light"] .select-bar-cancel,
html[data-theme^="light"] .select-bar-del { color: var(--txt); }
html[data-theme^="light"] .select-bar-clear { color: var(--green); }
html[data-theme^="light"] .msg-avatar {
  background: var(--bg);
  border-color: var(--brd);
}

/* ── Emoji reaction picker ── */
html[data-theme^="light"] .emoji-picker {
  background: var(--bg2);
  border-color: var(--brd);
  box-shadow: 0 8px 32px rgba(0,0,0,.15);
}
html[data-theme^="light"] .ep-action { color: var(--txt); }
html[data-theme^="light"] .ep-action:hover { background: rgba(0,0,0,.05); }
html[data-theme^="light"] .ep-divider { background: var(--brd); }

/* ── Модальные окна ── */
html[data-theme^="light"] .modal-content {
  background: var(--bg2);
  border-color: var(--brd);
  box-shadow: 0 16px 48px rgba(0,0,0,.15);
}
html[data-theme^="light"] .modal-header { border-bottom-color: var(--brd); color: var(--txt); }
html[data-theme^="light"] .modal-header button { color: var(--muted); }
html[data-theme^="light"] .modal-tab { color: var(--muted); }
html[data-theme^="light"] .modal-tab.active { color: var(--green); border-bottom-color: var(--green); }
html[data-theme^="light"] .modal-tabs { border-bottom-color: var(--brd); }
html[data-theme^="light"] #user-search-input,
html[data-theme^="light"] #phone-search-input {
  background: rgba(0,0,0,.05);
  border-color: var(--brd);
  color: var(--txt);
}
html[data-theme^="light"] #user-search-input::placeholder,
html[data-theme^="light"] #phone-search-input::placeholder { color: var(--muted); }
html[data-theme^="light"] .user-result {
  color: var(--txt);
  border-bottom-color: var(--brd);
}
html[data-theme^="light"] .user-result:hover { background: rgba(0,0,0,.04); }
html[data-theme^="light"] .modal-overlay { background: rgba(0,0,0,.4); }

/* ── Sidebar (фон, border) ── */
html[data-theme^="light"] .sidebar {
  background: var(--bg2);
  border-right-color: var(--brd);
}
html[data-theme^="light"] .chat-area { background: var(--bg); }
html[data-theme^="light"] .chat-placeholder { color: var(--muted); }

/* ── Нижняя навигация разделитель ── */
html[data-theme^="light"] .nav-item.active svg { filter: none; }

/* ── Typing ── */
html[data-theme^="light"] .typing-indicator { color: var(--green); }

/* ── Плюсбатон и медиапревью файла ── */
html[data-theme^="light"] .mp-multi-file { background: rgba(0,0,0,.06); color: var(--muted); }

/* ── FAB конверт (иконка) ── */
html[data-theme^="light"] .compose-fab svg { stroke: #fff; }

/* ══════════════════════════════════════════════
   ФИНАЛЬНЫЕ ФИКСЫ
   ══════════════════════════════════════════════ */

/* ── Заголовок Smart-D на светлых темах ── */
html[data-theme^="light"] .sh-title { color: var(--txt) !important; }
html[data-theme^="light"] .sh-title span { color: var(--green) !important; text-shadow: none !important; }

/* ── Фиксированная ширина меню — не "плавает" ── */
.sidebar-menu {
  min-width: 210px;
  width: 210px;
}

/* ── Новый стиль: свотчи в ряд, без текста ── */
.tp-swatches {
  display: flex;
  flex-direction: row;
  gap: 10px;
  padding: 10px 14px;
  align-items: center;
}
.tp-swatches .tp-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 0;
  width: auto;
  border-radius: 10px;
  position: relative;
}
.tp-swatches .tp-swatch {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
  transition: transform .15s, box-shadow .15s;
}
.tp-swatches .tp-item:hover .tp-swatch {
  transform: scale(1.1);
  box-shadow: 0 4px 14px rgba(0,0,0,.35);
}
.tp-swatches .tp-item.active .tp-swatch {
  transform: scale(1.12);
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
}
.tp-swatches .tp-check {
  opacity: 0;
  display: block;
  margin-left: 0;
  transition: opacity .15s;
}
.tp-swatches .tp-item.active .tp-check { opacity: 1; }

/* ══════════════════════════════════════════════
   ЯРКИЙ НЕОНОВЫЙ ЗЕЛЁНЫЙ ДЛЯ ВСЕХ СВЕТЛЫХ ТЕМ
   Тот же #00d455 с глоу — как в тёмной теме
   ══════════════════════════════════════════════ */
html[data-theme^="light"] {
  --green:     #00cc55;
  --green2:    #00aa44;
  --green-dim: rgba(0,204,85,.13);
}

/* Заголовок LINK — неон + свечение */
html[data-theme^="light"] .sh-title span {
  color: #00cc55 !important;
  text-shadow: 0 0 16px rgba(0,204,85,.65), 0 0 32px rgba(0,204,85,.3) !important;
}

/* FAB конверт — яркая кнопка с глоу */
html[data-theme^="light"] .compose-fab {
  background: linear-gradient(135deg, #00cc55, #00aa44);
  box-shadow: 0 6px 20px rgba(0,204,85,.55), 0 0 36px rgba(0,204,85,.18);
}
html[data-theme^="light"] .compose-fab:hover {
  box-shadow: 0 10px 28px rgba(0,204,85,.65), 0 0 48px rgba(0,204,85,.22);
}

/* Нижняя навигация — активный пункт светится */
html[data-theme^="light"] .nav-item.active { color: #00cc55; }
html[data-theme^="light"] .nav-item.active svg {
  filter: drop-shadow(0 0 5px rgba(0,204,85,.65));
}

/* Активная вкладка Все/Непрочитанные */
html[data-theme^="light"] .sb-tab.active {
  color: #00cc55;
  text-shadow: 0 0 10px rgba(0,204,85,.5);
  border-bottom-color: #00cc55;
}

/* Аватар моего профиля */
html[data-theme^="light"] .sh-avatar {
  background: linear-gradient(135deg, #00cc55, #00aa44);
  box-shadow: 0 0 0 2px rgba(0,204,85,.35), 0 0 12px rgba(0,204,85,.25);
}

/* Непрочитанные счётчик */
html[data-theme^="light"] .conv-unread {
  background: #00cc55;
  box-shadow: 0 0 10px rgba(0,204,85,.55);
  color: #fff;
}

/* Входящие пузыри — зелёная рамка с глоу */
html[data-theme^="light"] .bubble.in {
  border-color: rgba(0,204,85,.35);
  box-shadow: 0 0 14px rgba(0,204,85,.2), 0 2px 8px rgba(0,0,0,.08);
}

/* Онлайн-точка */
html[data-theme^="light"] .online-dot {
  background: #00cc55;
  box-shadow: 0 0 8px rgba(0,204,85,.6);
}

/* Кнопка отправки */
html[data-theme^="light"] .send-btn {
  background: linear-gradient(135deg, #00cc55, #00aa44);
  box-shadow: 0 2px 12px rgba(0,204,85,.45);
}

/* Аватар в списке чатов */
html[data-theme^="light"] .conv-avatar {
  color: #00aa44;
}
html[data-theme^="light"] .conv-avatar .online-dot {
  border-color: var(--bg2);
}

/* Active conv подсветка */
html[data-theme^="light"] .conv-item.active {
  background: rgba(0,204,85,.1);
  border-left: 3px solid #00cc55;
}

/* ══════════════════════════════════════════════
   ЭКРАН НАСТРОЕК
   ══════════════════════════════════════════════ */
.settings-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
}
.settings-screen:not(.hidden) {
  transform: translateX(0);
}
.settings-screen.hidden {
  transform: translateX(100%);
  pointer-events: none;
}

/* Шапка */
.settings-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--bg2);
  border-bottom: 1px solid var(--brd);
  position: sticky;
  top: 0;
  z-index: 10;
}
.settings-header span {
  font-size: 20px;
  font-weight: 700;
  color: var(--txt);
  letter-spacing: -.2px;
}
.settings-back {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: none; background: none;
  color: var(--muted2);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .15s, color .15s;
  flex-shrink: 0;
}
.settings-back:hover { background: rgba(255,255,255,.07); color: var(--txt); }

/* Профиль-карточка */
.settings-profile {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  background: var(--bg2);
  border-bottom: 1px solid var(--brd);
  cursor: pointer;
  transition: background .15s;
}
.settings-profile:hover { background: var(--bg3); }
.sp-avatar {
  width: 58px; height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--green), var(--green2));
  color: #0f172a;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 22px;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(31,255,114,.2), 0 0 16px rgba(31,255,114,.15);
}
.sp-info { flex: 1; min-width: 0; }
.sp-name {
  font-size: 17px; font-weight: 700;
  color: var(--txt);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sp-phone { font-size: 13px; color: var(--muted2); margin-top: 2px; }
.sp-arrow { color: var(--muted); flex-shrink: 0; }

/* Список разделов */
.settings-list {
  padding: 14px 0 32px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.settings-section {
  background: var(--bg2);
  border-radius: var(--radius);
  margin: 0 12px;
  overflow: hidden;
  border: 1px solid var(--brd);
}
.settings-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 15px 16px;
  cursor: pointer;
  transition: background .15s;
  border-bottom: 1px solid var(--brd);
}
.settings-row:last-child { border-bottom: none; }
.settings-row:hover { background: rgba(255,255,255,.04); }
.settings-row:active { background: rgba(255,255,255,.07); }
.sr-label {
  flex: 1;
  font-size: 15px;
  color: var(--txt);
  font-weight: 500;
}
.sr-arrow { color: var(--muted); flex-shrink: 0; }

/* Иконки разделов */
.sr-icon {
  width: 34px; height: 34px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sr-icon svg { stroke: #fff; }
.sr-icon-blue   { background: #3b82f6; }
.sr-icon-green  { background: #22c55e; }
.sr-icon-purple { background: #8b5cf6; }
.sr-icon-orange { background: #f97316; }
.sr-icon-teal   { background: #14b8a6; }
.sr-icon-gray   { background: #6b7280; }

/* Версия */
.settings-version {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  margin-top: 10px;
  padding: 0 20px;
}

/* Светлые темы */
html[data-theme^="light"] .settings-back:hover { background: rgba(0,0,0,.06); color: var(--txt); }
html[data-theme^="light"] .settings-row:hover   { background: rgba(0,0,0,.03); }
html[data-theme^="light"] .settings-row:active  { background: rgba(0,0,0,.06); }
html[data-theme^="light"] .sp-avatar { color: #fff; box-shadow: 0 0 0 2px rgba(0,204,85,.25); }

/* ══════════════════════════════════════════════
   ЭКРАН АККАУНТ
   ══════════════════════════════════════════════ */

/* Кнопка Сохранить в шапке */
.acc-save-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--green);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 2px;
  opacity: .4;
  pointer-events: none;
  transition: opacity .2s;
}
.acc-save-btn.dirty {
  opacity: 1;
  pointer-events: auto;
}

/* Блок аватара */
.acc-avatar-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 28px 20px 20px;
  background: var(--bg2);
  border-bottom: 1px solid var(--brd);
}
.acc-avatar-wrap {
  position: relative;
  cursor: pointer;
}
.acc-avatar {
  width: 90px; height: 90px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--green), var(--green2));
  display: flex; align-items: center; justify-content: center;
  font-size: 34px; font-weight: 800;
  color: #0f172a;
  overflow: hidden;
  box-shadow: 0 0 0 3px rgba(31,255,114,.2), 0 0 20px rgba(31,255,114,.15);
  transition: box-shadow .2s;
}
.acc-avatar-wrap:hover .acc-avatar {
  box-shadow: 0 0 0 3px rgba(31,255,114,.4), 0 0 28px rgba(31,255,114,.25);
}
.acc-avatar img { width: 100%; height: 100%; object-fit: cover; }
.acc-avatar-edit {
  position: absolute;
  bottom: 0; right: 0;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--green);
  color: #0f172a;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.acc-avatar-hint {
  font-size: 12px;
  color: var(--muted2);
}

/* Поля формы */
.acc-fields {
  padding: 14px 12px 40px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.acc-section-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .6px;
  padding: 6px 4px 4px;
}
.acc-section {
  background: var(--bg2);
  border-radius: var(--radius);
  border: 1px solid var(--brd);
  overflow: hidden;
  margin-bottom: 8px;
}
.acc-field {
  padding: 12px 16px;
}
.acc-field-sep {
  border-top: 1px solid var(--brd);
}
.acc-field-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 5px;
}
.acc-required { color: var(--green); }
.acc-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--txt);
  font-size: 16px;
  padding: 0;
  font-family: inherit;
}
.acc-input::placeholder { color: var(--muted); }
.acc-input-readonly {
  color: var(--muted2);
  cursor: default;
}
.acc-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.acc-change-btn {
  background: none;
  border: none;
  color: var(--green);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  padding: 0;
}
.acc-username-wrap {
  display: flex;
  align-items: center;
  gap: 2px;
}
.acc-at {
  color: var(--muted2);
  font-size: 16px;
  font-weight: 500;
  line-height: 1;
}
.acc-input-username { flex: 1; }
.acc-field-hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}
.acc-field-hint.error { color: var(--red); }

/* Дата рождения */
#acc-birthday {
  color-scheme: dark;
}
html[data-theme^="light"] #acc-birthday {
  color-scheme: light;
}

/* Светлые темы */
html[data-theme^="light"] .acc-save-btn { color: var(--green); }
html[data-theme^="light"] .acc-change-btn { color: var(--green); }
html[data-theme^="light"] .acc-avatar { color: #fff; }
html[data-theme^="light"] .acc-avatar-edit { background: var(--green); color: #fff; }

/* ══════════════════════════════════════════════
   ПОЛЕ ДАТЫ В АККАУНТЕ
   ══════════════════════════════════════════════ */
.acc-date-field {
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; padding: 2px 0;
}
.acc-date-display { color: var(--txt); font-size: 16px; }
.acc-date-display.placeholder { color: var(--muted); }
.acc-date-icon { color: var(--muted2); flex-shrink: 0; }

/* ══════════════════════════════════════════════
   DATEPICKER
   ══════════════════════════════════════════════ */
.dp-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,.5);
}
.dp-popup {
  position: fixed; left: 50%; bottom: 0;
  transform: translateX(-50%);
  width: min(400px, 100vw);
  z-index: 501;
  background: var(--bg2);
  border-radius: 20px 20px 0 0;
  border-top: 1px solid var(--brd);
  box-shadow: 0 -8px 40px rgba(0,0,0,.4);
  overflow: hidden;
  transition: transform .25s cubic-bezier(.4,0,.2,1);
}
.dp-popup.hidden { transform: translateX(-50%) translateY(100%); }

/* Шапка */
.dp-header {
  background: var(--bg3);
  border-bottom: 1px solid var(--brd);
  padding: 14px 12px 0;
}
.dp-nav {
  display: flex; align-items: center; gap: 4px;
  margin-bottom: 12px;
}
.dp-arr {
  width: 34px; height: 34px; border-radius: 50%;
  background: none; border: none; cursor: pointer;
  color: var(--muted2);
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
  flex-shrink: 0;
}
.dp-arr:hover { background: rgba(255,255,255,.08); color: var(--txt); }
.dp-title {
  flex: 1; display: flex; align-items: center; justify-content: center;
  gap: 6px;
}
.dp-month-lbl, .dp-year-lbl {
  background: none; border: none; cursor: pointer;
  font-size: 17px; font-weight: 700;
  color: var(--txt); padding: 4px 8px;
  border-radius: 8px; transition: background .15s;
}
.dp-month-lbl:hover, .dp-year-lbl:hover { background: rgba(255,255,255,.07); }
.dp-year-lbl { color: var(--green); }
.dp-weekdays {
  display: grid; grid-template-columns: repeat(7,1fr);
  text-align: center; padding-bottom: 6px;
}
.dp-weekdays span { font-size: 11px; color: var(--muted); font-weight: 600; }

/* Тело */
/* Тело фиксированной высоты — окно не прыгает при смене вида */
.dp-body {
  padding: 8px 10px;
  height: 258px;      /* хватает на 6 рядов дней */
  overflow: hidden;
  box-sizing: border-box;
}

/* Дни */
.dp-days {
  display: grid; grid-template-columns: repeat(7,1fr);
  gap: 2px; height: 100%;
  align-content: start;
}
.dp-day {
  height: 38px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; cursor: pointer;
  font-size: 14px; color: var(--txt);
  transition: background .1s, color .1s;
  border: none; background: none;
}
.dp-day:hover { background: rgba(255,255,255,.08); }
.dp-day.today { color: var(--green); font-weight: 700; }
.dp-day.selected {
  background: var(--green); color: #0f172a; font-weight: 700;
  box-shadow: 0 0 10px rgba(0,204,85,.4);
}
.dp-day.other-month { color: var(--muted); }
.dp-day.disabled { opacity: .3; cursor: default; pointer-events: none; }

/* Месяцы */
.dp-months {
  display: grid; grid-template-columns: repeat(3,1fr);
  gap: 6px; padding: 4px 0;
  height: 100%; align-content: center;
}
.dp-mon {
  padding: 14px 4px; text-align: center; border-radius: 10px;
  cursor: pointer; font-size: 14px; color: var(--txt);
  border: none; background: none;
  transition: background .15s;
}
.dp-mon:hover { background: rgba(255,255,255,.07); }
.dp-mon.active { background: var(--green); color: #0f172a; font-weight: 700; }

/* Годы */
.dp-years {
  display: grid; grid-template-columns: repeat(4,1fr); gap: 6px;
  padding: 4px 0; height: 100%; overflow-y: auto;
}
.dp-yr {
  padding: 10px 4px; text-align: center; border-radius: 10px;
  cursor: pointer; font-size: 14px; color: var(--txt);
  border: none; background: none;
  transition: background .15s;
}
.dp-yr:hover { background: rgba(255,255,255,.07); }
.dp-yr.active { background: var(--green); color: #0f172a; font-weight: 700; }

/* Футер */
.dp-footer {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px 24px;
  border-top: 1px solid var(--brd);
}
.dp-clear {
  background: none; border: none; cursor: pointer;
  color: var(--muted2); font-size: 15px;
}
.dp-ok {
  background: var(--green); color: #0f172a;
  border: none; border-radius: 10px; padding: 10px 28px;
  font-size: 15px; font-weight: 700; cursor: pointer;
  box-shadow: 0 2px 12px rgba(0,204,85,.4);
}

/* Светлые темы */
html[data-theme^="light"] .dp-arr:hover { background: rgba(0,0,0,.06); color: var(--txt); }
html[data-theme^="light"] .dp-month-lbl:hover,
html[data-theme^="light"] .dp-year-lbl:hover { background: rgba(0,0,0,.05); }
html[data-theme^="light"] .dp-day:hover { background: rgba(0,0,0,.06); }
html[data-theme^="light"] .dp-day.selected { color: #fff; }
html[data-theme^="light"] .dp-mon:hover { background: rgba(0,0,0,.05); }
html[data-theme^="light"] .dp-mon.active { color: #fff; }
html[data-theme^="light"] .dp-yr:hover  { background: rgba(0,0,0,.05); }
html[data-theme^="light"] .dp-yr.active { color: #fff; }
html[data-theme^="light"] .dp-ok { color: #fff; }

/* ══════════════════════════════════════════════
   ФИНАЛЬНЫЕ ФИКСЫ
   ══════════════════════════════════════════════ */

/* 1. iPhone safe-area в шапке Аккаунт/Настройки */
.settings-header {
  padding-top: calc(env(safe-area-inset-top, 0px) + 14px) !important;
}

/* 2. GIF — меньше превью, больше колонок на десктопе */
.gif-grid {
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)) !important;
}
@media (min-width: 600px) {
  .gif-picker { height: 340px; }
  .gif-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)) !important; }
  .gif-thumb { aspect-ratio: 16/10; }
}
@media (min-width: 900px) {
  .gif-picker { left: 300px; } /* не перекрывает сайдбар */
  .gif-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)) !important; }
}

/* 3. Реакции — зарезервированное место, пузырь не прыгает */
.reactions {
  min-width: 36px;     /* всегда занимает место */
  width: 36px;
  flex-shrink: 0;
}
.reactions:empty {
  min-width: 36px;
  width: 36px;
}

/* 4. Шапка чата — аватар с overflow:hidden для фото */
.chat-header-avatar {
  overflow: hidden;
}

/* ── Разделитель непрочитанных сообщений ── */
.unread-divider {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 16px; margin: 6px 0;
  opacity: 1; transition: opacity .6s ease;
}
.unread-divider::before,
.unread-divider::after {
  content: ''; flex: 1; height: 1px;
  background: rgba(31,255,114,.35);
}
.unread-divider span {
  font-size: 11px; font-weight: 600; letter-spacing: .4px;
  color: var(--green); white-space: nowrap;
  background: rgba(31,255,114,.08); border-radius: 20px;
  padding: 2px 10px;
}
.unread-divider-fade { opacity: 0; }
html[data-theme^="light"] .unread-divider::before,
html[data-theme^="light"] .unread-divider::after { background: rgba(0,170,68,.3); }
html[data-theme^="light"] .unread-divider span { background: rgba(0,170,68,.08); color: var(--green); }

/* ── Бейдж на nav-кнопке Чаты ── */
.nav-badge {
  position: absolute;
  top: 4px; right: calc(50% - 18px);
  min-width: 16px; height: 16px;
  background: #ff3b30; color: #fff;
  font-size: 10px; font-weight: 700;
  border-radius: 8px; padding: 0 4px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--bg);
  pointer-events: none;
}
.nav-badge.hidden { display: none !important; }

/* ══════════════════════════════════════════════
   CHAT INFO PANEL (Viber-style, right slide-in)
   ══════════════════════════════════════════════ */

/* Три точки в шапке чата */
.chat-dots-btn {
  margin-left: auto;
  color: var(--txt);
  flex-shrink: 0;
}

/* Overlay */
.ci-overlay {
  position: absolute; inset: 0; z-index: 399;
  background: rgba(0,0,0,.35);
  backdrop-filter: blur(1px);
}

/* Панель */
.ci-panel {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: min(340px, 88%);
  z-index: 400;
  background: var(--bg2);
  border-left: 1px solid var(--brd);
  display: flex; flex-direction: column;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  overscroll-behavior: contain;
}
.ci-panel.open { transform: translateX(0); }

/* Шапка панели */
.ci-header {
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top,0px) + 14px) 14px 14px;
  border-bottom: 1px solid var(--brd);
  flex-shrink: 0;
}
.ci-title { font-size: 16px; font-weight: 700; color: var(--txt); }

/* Профиль */
.ci-profile {
  display: flex; flex-direction: column; align-items: center;
  padding: 24px 16px 20px; gap: 6px;
  border-bottom: 1px solid var(--brd);
}
.ci-avatar {
  width: 88px; height: 88px; border-radius: 50%;
  background: var(--green); color: var(--bg);
  font-size: 32px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 0;
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px rgba(31,255,114,.3);
}
.ci-avatar img { width: 100%; height: 100%; object-fit: cover; }
.ci-name { font-size: 18px; font-weight: 700; color: var(--txt); margin-top: 6px; text-align: center; }
.ci-status { font-size: 12px; color: var(--muted); text-align: center; }

/* Быстрые кнопки звонка */
.ci-actions { display: flex; gap: 24px; margin-top: 16px; }
.ci-action-btn {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: none; border: none; cursor: pointer; color: var(--txt);
  font-size: 12px; font-weight: 500;
}
.ci-action-icon {
  width: 50px; height: 50px; border-radius: 50%;
  background: rgba(31,255,114,.12);
  display: flex; align-items: center; justify-content: center;
  color: var(--green);
  transition: background .15s;
}
.ci-action-btn:active .ci-action-icon { background: rgba(31,255,114,.25); }

/* Секции */
.ci-section {
  border-bottom: 1px solid var(--brd);
  padding: 4px 0;
}
.ci-section:last-child { border-bottom: none; flex: 1; }

/* Строки */
.ci-row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px; width: 100%;
  background: none; border: none;
  color: var(--txt); font-size: 14px; text-align: left;
  cursor: default;
}
.ci-row-info { cursor: default; }
.ci-row-action { cursor: pointer; transition: background .12s; }
.ci-row-action:active { background: rgba(255,255,255,.06); }
.ci-row-danger { cursor: pointer; color: #ff453a; transition: background .12s; }
.ci-row-danger:active { background: rgba(255,67,58,.08); }

/* Иконки в строках */
.ci-row-icon {
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.ci-row-label { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.ci-row-value { font-size: 14px; color: var(--txt); font-weight: 500; }

/* Toggle */
.ci-row-toggle {
  display: flex; align-items: center;
  justify-content: space-between; cursor: default;
}
.ci-toggle { position: relative; display: inline-block; width: 44px; height: 26px; flex-shrink: 0; }
.ci-toggle input { opacity: 0; width: 0; height: 0; }
.ci-toggle-track {
  position: absolute; inset: 0; border-radius: 13px;
  background: rgba(255,255,255,.15);
  transition: background .2s;
  cursor: pointer;
}
.ci-toggle-track::after {
  content: ''; position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; transition: transform .2s;
}
.ci-toggle input:checked + .ci-toggle-track { background: var(--green); }
.ci-toggle input:checked + .ci-toggle-track::after { transform: translateX(18px); }

/* Светлые темы */
html[data-theme^="light"] .ci-panel { background: var(--bg2); }
html[data-theme^="light"] .ci-row-action:active { background: rgba(0,0,0,.05); }
html[data-theme^="light"] .ci-toggle-track { background: rgba(0,0,0,.15); }
html[data-theme^="light"] .ci-action-icon { background: rgba(0,170,68,.12); }

/* Иконки звонка в шапке чата */
.chat-call-btn {
  color: var(--txt);
  flex-shrink: 0;
  opacity: .75;
}
.chat-call-btn:active { opacity: 1; }

/* Стрелка вправо в строке "Фон" */
.ci-row-action svg:last-child { flex-shrink: 0; }

/* Превью фото (половина экрана, сверху) */
.ci-photo-preview {
  position: absolute; top: 0; left: 0; right: 0;
  height: 55%;
  z-index: 450;
  background: #000;
  display: flex; align-items: center; justify-content: center;
  border-radius: 0 0 18px 18px;
  overflow: hidden;
  animation: ciPhotoIn .22s cubic-bezier(.4,0,.2,1);
}
@keyframes ciPhotoIn {
  from { transform: translateY(-100%); }
  to   { transform: translateY(0); }
}
.ci-photo-preview.hidden { display: none; }
.ci-photo-preview img {
  width: 100%; height: 100%;
  object-fit: contain;  /* показать полное фото без обрезки */
  border-radius: 0;     /* без круга */
}

/* Аватар в панели — курсор pointer если есть фото */
.ci-avatar.has-photo { cursor: pointer; }

/* ── Фон чата — отдельный слой, не скроллится ── */
.chat-messages-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-bg-layer {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
.messages-container {
  position: relative;
  z-index: 1;
}

/* ── Пикер фона ── */
.bg-picker-modal {
  position: absolute; inset: 0; z-index: 1500;
  background: rgba(0,0,0,.5);
  display: flex; align-items: flex-end; justify-content: center;
}
.bg-picker-modal.hidden { display: none; }
.bg-picker-sheet {
  width: 100%; max-width: 480px;
  background: var(--bg2);
  border-radius: 18px 18px 0 0;
  padding: 12px 16px calc(env(safe-area-inset-bottom,0px) + 16px);
  display: flex; flex-direction: column; gap: 4px;
}
.bg-picker-title {
  font-size: 13px; font-weight: 600; color: var(--muted);
  text-align: center; padding: 4px 0 12px; letter-spacing: .5px;
}
.bg-picker-btn {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; border-radius: 12px;
  background: none; border: none; cursor: pointer;
  color: var(--txt); font-size: 15px; font-weight: 500;
  transition: background .12s;
}
.bg-picker-btn:active { background: rgba(255,255,255,.07); }
.bg-picker-btn svg { color: var(--green); flex-shrink: 0; }
.bg-picker-reset { color: var(--muted); }
.bg-picker-cancel {
  margin-top: 6px; padding: 14px;
  border-radius: 12px; border: none;
  background: rgba(255,255,255,.06);
  color: var(--txt); font-size: 15px; font-weight: 600; cursor: pointer;
}
.bg-picker-cancel:active { background: rgba(255,255,255,.12); }

html[data-theme^="light"] .bg-picker-btn:active { background: rgba(0,0,0,.05); }
html[data-theme^="light"] .bg-picker-cancel { background: rgba(0,0,0,.05); }

/* Ссылка-телефон в панели */
a.ci-row { text-decoration: none; display: flex; }

/* ── Пузыри с кастомным фоном чата ── */
.has-custom-bg .bubble.out {
  background: rgba(74, 222, 128, .90) !important;
  border-color: rgba(74, 222, 128, .70) !important;
  color: #0d1f0d !important;
}
.has-custom-bg .bubble.out .bubble-time,
.has-custom-bg .bubble.out .msg-status {
  color: rgba(10, 30, 10, .65) !important;
}
.has-custom-bg .bubble.in {
  background: rgba(18, 24, 18, .88) !important;
  border-color: rgba(74, 222, 128, .35) !important;
  color: #e8f5e8 !important;
}
.has-custom-bg .bubble.in .bubble-time {
  color: rgba(200, 240, 200, .7) !important;
}

/* Светлые темы с кастомным фоном */
html[data-theme^="light"] .has-custom-bg .bubble.out {
  background: rgba(21, 128, 61, .85) !important;
  border-color: rgba(21, 128, 61, .60) !important;
  color: #fff !important;
}
html[data-theme^="light"] .has-custom-bg .bubble.out .bubble-time,
html[data-theme^="light"] .has-custom-bg .bubble.out .msg-status {
  color: rgba(255, 255, 255, .75) !important;
}
html[data-theme^="light"] .has-custom-bg .bubble.in {
  background: rgba(255, 255, 255, .92) !important;
  border-color: rgba(21, 128, 61, .25) !important;
  color: #1a1a1a !important;
}
html[data-theme^="light"] .has-custom-bg .bubble.in .bubble-time {
  color: rgba(0,0,0,.5) !important;
}

/* ── PIN-модал ── */
.pin-modal {
  position: absolute; inset: 0; z-index: 2000;
  background: rgba(0,0,0,.55);
  display: flex; align-items: flex-end; justify-content: center;
}
.pin-modal.hidden { display: none; }
.pin-sheet {
  background: var(--bg2);
  border-radius: 18px 18px 0 0;
  padding: 16px 16px calc(env(safe-area-inset-bottom,0px) + 12px);
  width: 100%; max-width: 380px;
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.pin-close {
  position: absolute; top: 12px; right: 12px;
  background: none; border: none; cursor: pointer;
  color: var(--muted); padding: 4px;
}
.pin-icon { margin-bottom: 0; }
.pin-icon svg { width: 24px; height: 24px; }
.pin-title { font-size: 15px; font-weight: 700; color: var(--txt); }
.pin-info {
  font-size: 11px; color: var(--muted); text-align: center;
  line-height: 1.45; margin: 0 8px;
}
.pin-step-label { font-size: 12px; color: var(--muted); margin-top: 4px; }
.pin-dots {
  display: flex; gap: 14px; margin: 4px 0 0;
}
.pin-dots span {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--brd);
  transition: background .12s, border-color .12s;
}
.pin-dots span.filled {
  background: var(--green); border-color: var(--green);
}
.pin-error {
  min-height: 16px; font-size: 11px; color: #ef4444; text-align: center;
}
.pin-pad {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 8px; width: 100%; max-width: 260px; margin-top: 2px;
}
.pin-key {
  aspect-ratio: 1; border-radius: 50%;
  background: rgba(255,255,255,.06);
  border: none; cursor: pointer;
  font-size: 18px; font-weight: 500; color: var(--txt);
  transition: background .1s;
  max-width: 72px; justify-self: center; width: 100%;
}
.pin-key:active { background: rgba(255,255,255,.18); transform: scale(.93); }
.pin-key-empty { background: none !important; cursor: default; }
.pin-key-del { font-size: 14px; }
html[data-theme^="light"] .pin-key { background: rgba(0,0,0,.06); }
html[data-theme^="light"] .pin-key:active { background: rgba(0,0,0,.13); }

/* ── Значок скрытого чата на аватарке ── */
.hidden-conv-badge {
  position: absolute; bottom: -2px; right: -2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--bg2); border: 1.5px solid var(--bg2);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
}

/* ── Экран заблокированных контактов ── */
.settings-header-action {
  background: none; border: none; cursor: pointer;
  color: var(--txt); padding: 4px; margin-left: auto;
  display: flex; align-items: center;
}
.blocked-list {
  flex: 1; overflow-y: auto; padding: 8px 0;
}
.blocked-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; border-bottom: 1px solid var(--brd2,rgba(255,255,255,.04));
}
.blocked-unblock-btn {
  background: rgba(74,222,128,.12); border: 1px solid rgba(74,222,128,.25);
  color: var(--green); border-radius: 20px;
  padding: 5px 12px; font-size: 12px; font-weight: 600; cursor: pointer;
  white-space: nowrap; flex-shrink: 0;
  transition: background .15s;
}
.blocked-unblock-btn:active { background: rgba(74,222,128,.25); }

/* ── Уведомление о блокировке (в чате) ── */
.blocked-notice {
  display: flex; align-items: center; gap: 8px;
  margin: 12px auto; padding: 10px 14px;
  background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.3);
  border-radius: 12px; max-width: 340px;
  color: #f87171; font-size: 13px; line-height: 1.4;
  animation: fadeIn .25s ease;
}
.blocked-notice svg { flex-shrink: 0; }

/* ── sr-icon цвета ── */
.sr-icon-red { background: rgba(239,68,68,.15) !important; color: #ef4444; }
.sr-icon-red svg { stroke: #ef4444; }
.sr-icon-blue { background: rgba(59,130,246,.15) !important; }
.sr-icon-blue svg { stroke: #60a5fa; }

/* ── Диалог подтверждения ── */
.confirm-modal {
  position: absolute; inset: 0; z-index: 2100;
  background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.confirm-modal.hidden { display: none; }
.confirm-sheet {
  background: var(--bg2);
  border-radius: 16px;
  padding: 22px 20px 18px;
  width: 100%; max-width: 320px;
  display: flex; flex-direction: column; gap: 10px;
}
.confirm-title {
  font-size: 16px; font-weight: 700; color: var(--txt);
}
.confirm-body {
  font-size: 13px; color: var(--muted); line-height: 1.55;
  white-space: pre-line;
}
.confirm-actions {
  display: flex; gap: 10px; margin-top: 4px;
}
.confirm-btn {
  flex: 1; padding: 12px; border-radius: 12px;
  border: none; cursor: pointer; font-size: 14px; font-weight: 600;
  transition: background .12s;
}
.confirm-cancel {
  background: rgba(255,255,255,.07); color: var(--txt);
}
.confirm-ok {
  background: rgba(74,222,128,.18); color: var(--green);
}
.confirm-danger {
  background: rgba(239,68,68,.15) !important; color: #ef4444 !important;
}
.confirm-cancel:active { background: rgba(255,255,255,.14); }
.confirm-ok:active { background: rgba(74,222,128,.32); }
html[data-theme^="light"] .confirm-cancel { background: rgba(0,0,0,.07); }
html[data-theme^="light"] .confirm-ok { background: rgba(21,128,61,.12); }
