/* ======== Волна — тёмная тема в духе Telegram ======== */

:root {
  --bg: #0e1621;
  --sidebar: #17212b;
  --sidebar-2: #1c2733;
  --hover: #202b36;
  --active: #2b5278;
  --out-bubble: #2b5278;
  --in-bubble: #182533;
  --text: #e9edf1;
  --muted: #7d8b99;
  --muted-2: #5d6b7a;
  --accent: #5288c1;
  --accent-2: #64b5ef;
  --online: #4dd05a;
  --danger: #ef5b5b;
  --border: #0b1219;
  --radius: 12px;
  --shadow: 0 8px 30px rgba(0, 0, 0, .38);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body {
  overflow: hidden;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

button { font-family: inherit; color: inherit; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #2a3846; border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ======== Вход ======== */

.auth-screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 600px at 15% -10%, rgba(82, 136, 193, .20), transparent 60%),
    radial-gradient(700px 500px at 110% 110%, rgba(82, 136, 193, .14), transparent 60%),
    var(--bg);
  z-index: 50;
}

.auth-card {
  width: min(400px, 100%);
  background: var(--sidebar);
  border: 1px solid rgba(255, 255, 255, .05);
  border-radius: 20px;
  padding: 30px 28px 24px;
  box-shadow: var(--shadow);
}

.auth-logo { text-align: center; margin-bottom: 22px; }
.logo-mark {
  width: 64px; height: 64px;
  margin: 0 auto 12px;
  display: grid; place-items: center;
  background: rgba(82, 136, 193, .12);
  border-radius: 20px;
}
.auth-logo h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: .5px; }
.auth-logo p { margin: 0; font-size: 13.5px; }

.auth-tabs {
  display: flex;
  background: var(--bg);
  padding: 4px;
  border-radius: 10px;
  margin-bottom: 18px;
}
.tab {
  flex: 1;
  background: transparent;
  border: 0;
  padding: 9px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  transition: .18s;
}
.tab.active { background: var(--active); color: #fff; font-weight: 600; }

.field { display: block; margin-bottom: 14px; }
.field span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 6px 2px;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.field input {
  width: 100%;
  background: var(--bg);
  border: 1px solid #26323e;
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text);
  font-size: 16px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(82, 136, 193, .18); }

.auth-error {
  background: rgba(239, 91, 91, .12);
  border: 1px solid rgba(239, 91, 91, .3);
  color: #ff9a9a;
  padding: 9px 12px;
  border-radius: 9px;
  font-size: 13.5px;
  margin: 0 0 12px;
}

.btn-primary {
  width: 100%;
  border: 0;
  border-radius: 10px;
  padding: 13px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .05s;
}
.btn-primary:hover { background: #5f97d1; }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: .55; cursor: default; }

.auth-hint { font-size: 11.5px; text-align: center; line-height: 1.45; margin: 16px 0 0; }

/* ======== Каркас ======== */

.app {
  display: flex;
  height: 100vh;
  height: 100dvh;
}

/* ======== Боковая панель ======== */

.sidebar {
  width: 360px;
  min-width: 300px;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 2;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px 10px 16px;
}
.me-block { display: flex; align-items: center; gap: 11px; flex: 1; min-width: 0; }
.me-text { min-width: 0; }
.me-name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.avatar {
  width: 42px; height: 42px;
  flex: 0 0 auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 16px;
  color: #fff;
  user-select: none;
  background: linear-gradient(135deg, #5288c1, #7b5ea7);
  overflow: hidden;
}
.avatar.small { width: 38px; height: 38px; font-size: 15px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--muted-2);
  margin-right: 2px;
  vertical-align: 1px;
}
.status-dot.online { background: var(--online); }
.status-dot.offline { background: var(--danger); }

.icon-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  width: 38px; height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background .15s, color .15s;
  flex: 0 0 auto;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }

.search-wrap {
  position: relative;
  margin: 4px 12px 10px;
}
.search-wrap input {
  width: 100%;
  background: var(--bg);
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 10px 12px 10px 38px;
  color: var(--text);
  font-size: 16px;
  outline: none;
}
.search-wrap input:focus { border-color: var(--accent); }
.search-wrap input::-webkit-search-cancel-button { filter: invert(.6); }
.search-icon {
  position: absolute;
  left: 13px; top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.contact-list { flex: 1; overflow-y: auto; padding: 0 6px 10px; }

.contact {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: 10px;
  cursor: pointer;
  position: relative;
  transition: background .12s;
}
.contact:hover { background: var(--hover); }
.contact.active { background: var(--active); }
.contact-avatar-wrap { position: relative; flex: 0 0 auto; }
.contact .presence {
  position: absolute;
  right: 0; bottom: 1px;
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--online);
  border: 2px solid var(--sidebar);
}
.contact.active .presence { border-color: var(--active); }

.contact-body { flex: 1; min-width: 0; }
.contact-row { display: flex; align-items: baseline; gap: 8px; }
.contact-name {
  flex: 1;
  font-weight: 500;
  font-size: 14.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.contact-time { font-size: 11.5px; color: var(--muted); flex: 0 0 auto; }
.contact.active .contact-time { color: #cfe3f7; }
.contact-preview {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.contact.active .contact-preview { color: #cfe3f7; }
.contact-preview .who { color: #8fb8dd; }
.contact-preview .kind { flex: 0 0 auto; }

.badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}
.contact.active .badge { background: #fff; color: var(--active); }

.contacts-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 28px;
  text-align: center;
}
.contacts-empty-emoji { font-size: 40px; margin-bottom: 10px; }
.contacts-empty p { margin: 6px 0; line-height: 1.45; }

/* ======== Чат ======== */

.chat {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 20% 20%, rgba(82, 136, 193, .05), transparent 42%),
    radial-gradient(circle at 80% 75%, rgba(123, 94, 167, .05), transparent 46%);
}

.chat-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--muted);
  text-align: center;
  padding: 24px;
}
.placeholder-badge {
  background: var(--sidebar-2);
  color: #9db3c7;
  padding: 7px 16px;
  border-radius: 20px;
  font-size: 13px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.chat-view { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: var(--sidebar);
  border-bottom: 1px solid var(--border);
  min-height: 58px;
  z-index: 2;
}
.back-btn { display: none; margin-left: -6px; }
.peer-text { min-width: 0; }
.peer-name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.peer-status { margin-top: 1px; }
.peer-status.typing { color: var(--accent-2); }

.messages {
  flex: 1;
  overflow-y: auto;
  overflow-anchor: none;
  padding: 18px clamp(14px, 4vw, 60px) 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.history-more { text-align: center; padding: 4px 0 14px; }
.link-btn {
  background: rgba(82, 136, 193, .16);
  border: 0;
  color: #9ec9f0;
  padding: 7px 16px;
  border-radius: 16px;
  font-size: 13px;
  cursor: pointer;
}
.link-btn:hover { background: rgba(82, 136, 193, .28); }

.date-sep {
  align-self: center;
  background: rgba(20, 30, 41, .8);
  color: #93a5b5;
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 12px;
  margin: 12px 0 8px;
  position: sticky;
  top: 0;
  z-index: 1;
  backdrop-filter: blur(6px);
}

.msg-row { display: flex; justify-content: flex-start; max-width: 100%; }
.msg-row.out { justify-content: flex-end; }
.msg-row + .msg-row .bubble { margin-top: 1px; }

.bubble {
  position: relative;
  max-width: min(560px, 78%);
  background: var(--in-bubble);
  border-radius: 14px;
  border-top-left-radius: 6px;
  padding: 7px 10px 7px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, .16);
  word-wrap: break-word;
  overflow-wrap: anywhere;
  animation: pop .16s ease-out;
}
@keyframes pop { from { transform: translateY(4px); opacity: .5; } to { transform: none; opacity: 1; } }

.msg-row.out .bubble {
  background: var(--out-bubble);
  border-top-left-radius: 14px;
  border-top-right-radius: 6px;
}
.msg-row.out.solo .bubble { border-top-right-radius: 14px; }
.msg-row.in.solo .bubble { border-top-left-radius: 14px; }
.msg-row.out.last .bubble { border-bottom-right-radius: 6px; }
.msg-row.in.last .bubble { border-bottom-left-radius: 6px; }

.bubble-text { font-size: 14.5px; line-height: 1.38; white-space: pre-wrap; }
.bubble-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  font-size: 11px;
  color: rgba(255, 255, 255, .48);
  margin-top: 3px;
  min-height: 14px;
  white-space: nowrap;
  float: right;
  margin-left: 12px;
  position: relative;
  top: 3px;
}
.bubble.media-only { padding: 4px; }
.bubble.media-only .msg-media { margin: 0; }
.bubble.media-only .bubble-meta {
  position: absolute;
  right: 8px;
  bottom: 6px;
  top: auto;
  margin: 0;
  background: rgba(0, 0, 0, .45);
  padding: 2px 7px;
  border-radius: 9px;
  color: rgba(255, 255, 255, .9);
  backdrop-filter: blur(4px);
}
.bubble.has-video .bubble-meta {
  top: 8px;
  bottom: auto;
}
.bubble.has-audio .bubble-meta {
  position: static;
  float: none;
  margin: 2px 2px 0;
  min-height: 0;
  top: 0;
  background: none;
  padding: 0;
}
.tick { width: 15px; height: 15px; opacity: .85; }
.tick.read { color: var(--accent-2); opacity: 1; }

.msg-media { margin: -3px -6px 4px; border-radius: 10px; overflow: hidden; max-width: 420px; }
.msg-media img, .msg-media video {
  display: block;
  max-width: 100%;
  max-height: 420px;
  min-width: 120px;
  cursor: zoom-in;
  background: #0b1118;
}
.msg-media video { cursor: default; width: 100%; }
.msg-media .media-loading {
  width: 220px; height: 140px;
  display: grid; place-items: center;
  background: rgba(0, 0, 0, .25);
  color: var(--muted);
  font-size: 13px;
}

.file-card {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 8px 8px 4px;
  max-width: 320px;
}
.file-icon {
  width: 42px; height: 42px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .1);
  display: grid; place-items: center;
  font-size: 19px;
  flex: 0 0 auto;
}
.file-info { min-width: 0; flex: 1; }
.file-name {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-size { font-size: 12px; color: rgba(255, 255, 255, .55); margin-top: 2px; }
.download-btn {
  color: #cfe3f7;
  text-decoration: none;
  flex: 0 0 auto;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, .08);
}
.download-btn:hover { background: rgba(255, 255, 255, .16); }

/* Голосовые */

.voice {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 210px;
  padding: 4px 2px 2px;
}
.voice-play {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 0;
  flex: 0 0 auto;
  background: #fff;
  color: #2b5278;
  display: grid; place-items: center;
  cursor: pointer;
  transition: transform .1s;
}
.msg-row.in .voice-play { background: var(--accent); color: #fff; }
.voice-play:active { transform: scale(.94); }
.voice-play svg { margin-left: 1px; }
.voice-play.playing svg { margin-left: 0; }

.voice-main { flex: 1; min-width: 0; }
.voice-wave {
  display: flex;
  align-items: center;
  gap: 2.5px;
  height: 26px;
  cursor: pointer;
}
.voice-wave span {
  width: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, .32);
  transition: background .1s;
  flex: 0 0 auto;
}
.voice-wave span.played { background: #cfe3f7; }
.msg-row.in .voice-wave span.played { background: var(--accent-2); }
.voice-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: rgba(255, 255, 255, .6);
  margin-top: 3px;
  gap: 10px;
}
.voice-dur { font-variant-numeric: tabular-nums; }

/* Видео кружки */

.video-note {
  position: relative;
  width: clamp(172px, 52vw, 206px);
  height: clamp(172px, 52vw, 206px);
  border-radius: 50%;
  cursor: pointer;
  background: #0b1118;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.video-note video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  border-radius: 50%;
  background: #0b1118;
  transform: scaleX(-1);
}
.vn-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  pointer-events: none;
}
.vn-ring circle { fill: none; stroke-width: 2.5; }
.vn-ring-bg { stroke: rgba(255, 255, 255, .16); }
.vn-ring-fg { stroke: var(--accent-2); stroke-linecap: round; }
.vn-play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  background: rgba(0, 0, 0, .16);
  border-radius: 50%;
  opacity: 1;
  transition: opacity .15s;
  pointer-events: none;
}
.vn-play svg { filter: drop-shadow(0 2px 8px rgba(0, 0, 0, .55)); }
.video-note.playing .vn-play { opacity: 0; }
.vn-badge {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(0, 0, 0, .48);
  color: rgba(255, 255, 255, .92);
  font-size: 11.5px;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
  backdrop-filter: blur(4px);
  pointer-events: none;
}
.video-note.playing .vn-badge { opacity: 0; }

.bubble.has-note,
.msg-row.out .bubble.has-note,
.msg-row.in .bubble.has-note {
  background: transparent;
  box-shadow: none;
  padding: 0;
}
.bubble.has-note .bubble-meta {
  position: absolute;
  right: 4px;
  bottom: 2px;
  margin: 0;
  top: auto;
  background: rgba(0, 0, 0, .48);
  padding: 2px 7px;
  border-radius: 9px;
  color: rgba(255, 255, 255, .86);
  backdrop-filter: blur(4px);
}

/* Запись видео кружка */

.note-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: calc(24px + env(safe-area-inset-top)) 20px calc(24px + env(safe-area-inset-bottom));
  background: rgba(8, 13, 19, .96);
  backdrop-filter: blur(12px);
  animation: note-fade .16s ease-out;
}
@keyframes note-fade { from { opacity: .4; } to { opacity: 1; } }

.note-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: rgba(255, 255, 255, .72);
}
.note-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  animation: note-blink 1.1s infinite;
}
@keyframes note-blink { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }

.note-orb-wrap {
  position: relative;
  width: min(62vw, 244px);
  height: min(62vw, 244px);
  flex: 0 0 auto;
}
.note-orb {
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  overflow: hidden;
  background: #000;
  box-shadow: 0 12px 48px rgba(0, 0, 0, .5);
}
.note-orb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}
.note-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  pointer-events: none;
}
.note-ring circle { fill: none; stroke-width: 2.5; }
.note-ring-bg { stroke: rgba(255, 255, 255, .14); }
.note-ring-fg { stroke: var(--danger); stroke-linecap: round; }

.note-timer {
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
}
.note-tip { margin: 0; font-size: 13px; }

.note-actions {
  display: flex;
  align-items: center;
  gap: 56px;
  margin-top: 4px;
}
.note-action {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform .08s, background .15s;
}
.note-action:active { transform: scale(.94); }
.note-action-cancel { background: rgba(255, 255, 255, .13); color: #fff; }
.note-action-cancel:hover { background: rgba(255, 255, 255, .2); }
.note-action-send { background: var(--accent); color: #fff; }
.note-action-send:hover { background: #5f97d1; }

/* Индикатор «печатает» */

.typing-row { display: none; padding: 0 clamp(14px, 4vw, 60px) 4px; }
.typing-row.visible { display: block; }
.typing-bubble {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  background: var(--in-bubble);
  padding: 10px 14px;
  border-radius: 14px;
  border-top-left-radius: 6px;
}
.typing-bubble i {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: blink 1.2s infinite;
}
.typing-bubble i:nth-child(2) { animation-delay: .18s; }
.typing-bubble i:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%, 60%, 100% { opacity: .3; } 30% { opacity: 1; } }

/* Композер */

.composer-wrap { padding: 8px clamp(10px, 3vw, 40px) 14px; }
.composer {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  background: var(--sidebar);
  border-radius: 14px;
  padding: 6px 6px 6px 4px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .18);
}
.composer textarea {
  flex: 1;
  min-height: 40px;
  resize: none;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  line-height: 22px;
  padding: 9px 2px;
  max-height: 160px;
  outline: none;
  font-family: inherit;
}
.composer textarea::placeholder { color: var(--muted-2); }

.send-btn {
  width: 42px; height: 42px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background .15s, transform .05s;
}
.send-btn:hover { background: #5f97d1; }
.send-btn:active { transform: scale(.95); }

.mic-btn { color: var(--muted); }
.note-btn { color: var(--muted); }
.composer.has-text .mic-btn { display: none; }
.composer.has-text .note-btn { display: none; }

.attach-wrap { position: relative; flex: 0 0 auto; }

.attach-menu {
  position: absolute;
  bottom: 50px;
  left: -4px;
  width: 246px;
  background: var(--sidebar-2);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 20;
  animation: pop .13s ease-out;
}
.attach-menu button {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  background: transparent;
  border: 0;
  text-align: left;
  padding: 9px 10px;
  border-radius: 9px;
  cursor: pointer;
}
.attach-menu button:hover { background: var(--hover); }
.attach-ico { font-size: 20px; width: 26px; text-align: center; }
.attach-menu b { display: block; font-size: 14px; font-weight: 500; }
.attach-menu small { color: var(--muted); font-size: 12px; }

/* Запись голоса */

.record-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--sidebar);
  border-radius: 14px;
  padding: 8px 10px 8px 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .18);
}
.rec-cancel {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  color: var(--danger);
  display: grid; place-items: center;
  cursor: pointer;
}
.rec-cancel:hover { background: rgba(239, 91, 91, .12); }
.rec-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--danger);
  animation: pulse 1.1s infinite;
  flex: 0 0 auto;
}
@keyframes pulse { 50% { opacity: .25; } }
.rec-time { font-variant-numeric: tabular-nums; font-weight: 600; }
.rec-hint { font-size: 13px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ======== Лайтбокс, тосты, загрузка ======== */

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(5, 9, 13, .94);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 30px;
}
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 4px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
}
.lightbox-close {
  position: absolute;
  top: 14px; right: 20px;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, .1);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}
.lightbox-close:hover { background: rgba(255, 255, 255, .2); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  background: #223142;
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13.5px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: .2s;
  z-index: 200;
  max-width: 90vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.upload-toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #223142;
  padding: 11px 16px;
  border-radius: 11px;
  font-size: 13.5px;
  box-shadow: var(--shadow);
  z-index: 150;
}
.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255, 255, 255, .2);
  border-top-color: var(--accent-2);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ======== Мобильная версия ======== */

@media (max-width: 820px) {
  .sidebar { width: 100%; min-width: 0; border-right: 0; }
  .chat {
    position: fixed;
    inset: 0;
    z-index: 10;
    transform: translateX(100%);
    transition: transform .25s ease;
    visibility: hidden;
  }
  body.chat-open .chat { transform: none; visibility: visible; }
  .back-btn { display: grid; }
  .bubble { max-width: 84%; }
  .messages { padding: 12px 10px 8px; }
  .typing-row { padding: 0 10px 4px; }
  .composer-wrap { padding: 6px 8px 10px; }
  .chat-header { padding: 6px 10px; }
  .msg-media { max-width: 100%; }
}

@media (max-width: 380px) {
  .contact-time { display: none; }
}


/* Netlify на бесплатном тарифе показывает плавающий бейдж в правом нижнем углу.
   Поднимаем поле ввода, чтобы бейдж не перекрывал кнопку отправки. */
body.netlify-host .composer-wrap { padding-bottom: 80px; }
@media (max-width: 820px) {
  body.netlify-host .composer-wrap { padding-bottom: 82px; }
}

/* ======== Мобильная клавиатура и поле ввода ======== */

.chat-view { position: relative; }

@media (max-width: 820px) {
  .composer textarea,
  .field input,
  .search-wrap input {
    font-size: 16px; /* iOS не зумит страницу при фокусе */
  }
  .composer-wrap {
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }
  body.netlify-host .composer-wrap {
    padding-bottom: calc(82px + env(safe-area-inset-bottom));
  }
  .messages {
    overscroll-behavior: contain;
  }
}

/* ======== Кнопка «вниз» ======== */

.scroll-bottom {
  position: absolute;
  right: 18px;
  bottom: calc(88px + env(safe-area-inset-bottom));
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .08);
  background: var(--sidebar-2);
  color: #cfe3f7;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .35);
  z-index: 6;
  transition: opacity .15s, transform .15s;
}
.scroll-bottom:hover { background: var(--hover); }
.scroll-bottom:active { transform: scale(.95); }
.scroll-bottom[hidden] { display: none !important; }
body.netlify-host .scroll-bottom {
  bottom: calc(154px + env(safe-area-inset-bottom));
}
@media (max-width: 820px) {
  .scroll-bottom { right: 12px; bottom: calc(80px + env(safe-area-inset-bottom)); }
  body.netlify-host .scroll-bottom { bottom: calc(148px + env(safe-area-inset-bottom)); }
}

.scroll-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
  border: 2px solid var(--bg);
}
.scroll-badge[hidden] { display: none !important; }

/* ======== Загрузка файлов ======== */

.upload-toast {
  flex-direction: column;
  align-items: stretch;
  width: min(280px, calc(100vw - 36px));
  gap: 8px;
  padding: 12px 14px;
}
.upload-top {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
}
.upload-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.upload-pct { color: var(--muted); font-variant-numeric: tabular-nums; }
.upload-bar {
  height: 4px;
  background: rgba(255, 255, 255, .12);
  border-radius: 3px;
  overflow: hidden;
}
.upload-bar i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 3px;
  transition: width .15s linear;
}

/* Экран входа не должен обрезаться на маленьких экранах */
.auth-card { max-height: 92dvh; overflow-y: auto; }

.tick.failed { color: var(--danger); opacity: 1; }


/* Не даём iOS зумить по двойному тапу и при фокусе */
html { touch-action: manipulation; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
button, a, .contact, .tab, .icon-btn, .send-btn, .link-btn, input, textarea {
  touch-action: manipulation;
}
.messages { touch-action: pan-y; }

.search-empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}
