/* ===== Design tokens =====
   Ink     #151B32  — тёмно-синий, сайдбар/шапки
   Paper   #F4F5F7  — фон рабочей области
   Card    #FFFFFF  — карточки и чужие сообщения
   Line    #E3E5EA  — границы, разделители
   Accent  #3D6BFF  — основной акцент (кнопки, свои сообщения)
   Warm    #FF8A3D  — тёплый акцент (непрочитанные, предупреждения)
   Success #2FB380  — статус "онлайн"
   Text    #171B29  — основной текст
   Muted   #6B7280  — вторичный текст
   Шрифты: Inter (интерфейс), IBM Plex Mono (метки времени, статусы, бренд-курсор)
*/

* { box-sizing: border-box; }

:root {
  --ink: #151B32;
  --ink-soft: #1E2542;
  --paper: #F4F5F7;
  --card: #FFFFFF;
  --line: #E3E5EA;
  --accent: #3D6BFF;
  --accent-dark: #2E52D9;
  --warm: #FF8A3D;
  --success: #2FB380;
  --danger: #E24C4C;
  --text: #171B29;
  --muted: #6B7280;
  --muted-on-ink: #9AA3C0;
  --radius: 10px;
  --font-ui: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
}

[data-theme="dark"] {
  --ink: #0B0E1C;
  --ink-soft: #141A30;
  --paper: #14172A;
  --card: #1D2136;
  --line: #2B3050;
  --accent: #5B7FFF;
  --accent-dark: #7C9AFF;
  --text: #E7E9F5;
  --muted: #8B92B5;
  --muted-on-ink: #7680A8;
}

[data-theme="dark"] .field input,
[data-theme="dark"] .sidebar__search input,
[data-theme="dark"] .modal input {
  background: var(--card);
  color: var(--text);
  border-color: var(--line);
}
[data-theme="dark"] .segmented__opt { background: var(--card); }
[data-theme="dark"] .modal__tab { background: var(--card); }
[data-theme="dark"] .day-divider { background: rgba(255,255,255,.06); }
[data-theme="dark"] .auth-card { background: var(--card); }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font-ui);
  color: var(--text);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  transition: background-color .2s ease, color .2s ease;
}

button, input {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

.is-hidden { display: none !important; }

/* ===== Brand / cursor signature ===== */

.auth-brand__cursor {
  color: var(--success);
  font-family: var(--font-mono);
  animation: blink 1.1s steps(1) infinite;
  margin-right: 2px;
}

@keyframes blink {
  0%, 45% { opacity: 1; }
  50%, 95% { opacity: 0; }
  100% { opacity: 1; }
}

.brand-logo {
  display: inline-block;
  object-fit: cover;
  border-radius: 10px;
  vertical-align: middle;
  background: rgba(255,255,255,.06);
}

.brand-logo--auth {
  width: 44px;
  height: 44px;
  box-shadow: 0 0 0 4px rgba(47,179,128,.15);
}

.brand-logo--sidebar {
  width: 24px;
  height: 24px;
  border-radius: 7px;
}

/* ===== Buttons / fields (shared) ===== */

.btn {
  border: none;
  border-radius: var(--radius);
  padding: 11px 20px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background-color .15s ease, transform .05s ease;
}
.btn:active { transform: scale(0.98); }
.btn--primary {
  background: var(--accent);
  color: #fff;
}
.btn--primary:hover { background: var(--accent-dark); }
.btn--block { width: 100%; }
.btn--secondary {
  background: rgba(61,107,255,.1);
  color: var(--accent-dark);
}
.btn--secondary:hover { background: rgba(61,107,255,.18); }
.btn--danger {
  background: rgba(226,76,76,.1);
  color: var(--danger);
}
.btn--danger:hover { background: rgba(226,76,76,.2); }

.send-icon { display: none; }

@media (max-width: 420px) {
  #send-btn { padding: 11px 14px; }
  #send-btn .send-label { display: none; }
  #send-btn .send-icon { display: inline; }
}

.text-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  padding: 4px 6px;
}
.text-btn:hover { color: var(--text); }

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: inherit;
  opacity: .85;
}
.icon-btn:hover { background: rgba(255,255,255,.08); opacity: 1; }

.field { display: block; margin-bottom: 16px; }
.field__label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.field input, .sidebar__search input, .modal input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  outline: none;
}
.field input:focus, .sidebar__search input:focus, .modal input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(61,107,255,.15);
}

.form-error {
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
  margin: 0 0 8px;
}

.form-success {
  color: var(--success);
  font-size: 13px;
  min-height: 18px;
  margin: 0 0 8px;
}

.danger-text:hover { color: var(--danger); }

/* ===== Avatar editor (profile / group settings) ===== */

.avatar-editor {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.avatar--xl { width: 64px; height: 64px; font-size: 26px; }

/* ===== Segmented control (public/private) ===== */

.segmented {
  display: flex;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.segmented__opt {
  flex: 1;
  border: none;
  background: #fff;
  padding: 10px 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-right: 1px solid var(--line);
}
.segmented__opt:last-child { border-right: none; }
.segmented__opt.is-active {
  background: rgba(61,107,255,.1);
  color: var(--accent-dark);
}
.field__hint {
  font-size: 12px;
  color: var(--muted);
  margin: 6px 0 0;
}

/* ===== Invite link row ===== */

.invite-row {
  display: flex;
  gap: 8px;
  margin: 8px 0 4px;
}
.invite-row input {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--paper);
  color: var(--muted);
}

.modal__divider {
  border: none;
  border-top: 1px solid var(--line);
  margin: 20px 0;
}
.modal__subheading {
  font-size: 14px;
  margin: 0 0 14px;
}

/* ===== Member row (chat settings) ===== */

.member-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
}
.member-row:not(:last-child) { border-bottom: 1px solid var(--line); }
.member-row__body { flex: 1; min-width: 0; }
.member-row__name { font-size: 13.5px; font-weight: 600; }
.member-row__role {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}
.member-row__remove {
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
}
.member-row__remove:hover { color: var(--danger); }
.member-row__admin-toggle { white-space: nowrap; flex-shrink: 0; }

/* ===== Avatar ===== */

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
  font-size: 15px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 5px;
}
.status-dot--online { background: var(--success); box-shadow: 0 0 0 3px rgba(47,179,128,.2); }
.status-dot--offline { background: #B7BCC7; }

/* ===== Auth screen ===== */

.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(61,107,255,.10), transparent 40%),
    radial-gradient(circle at 82% 78%, rgba(47,179,128,.08), transparent 42%),
    radial-gradient(rgba(255,255,255,.06) 1px, transparent 1px) 0 0/22px 22px,
    var(--ink);
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: 16px;
  padding: 36px 32px 32px;
  box-shadow: 0 30px 60px rgba(0,0,0,.35);
}

.auth-brand {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-tagline {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 24px;
}

.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
}
.auth-tab {
  flex: 1;
  background: none;
  border: none;
  padding: 10px 0;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.auth-tab.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ===== App shell layout ===== */

.app-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: 100vh;
}

.sidebar {
  background: var(--ink);
  color: #fff;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 14px;
}

.brand-mark {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-actions { display: flex; align-items: center; gap: 4px; }

.sidebar__header {
  border-bottom: 1px solid rgba(255,255,255,.08);
  position: relative;
}
.sidebar__header::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: linear-gradient(90deg, var(--success), var(--accent) 60%, transparent);
  opacity: .7;
}

.me-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  cursor: pointer;
  border-radius: 8px;
}
.me-card:hover { background: rgba(255,255,255,.05); }
.me-card__info { min-width: 0; flex: 1; }
.me-card__name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.me-card__status {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted-on-ink);
  display: flex;
  align-items: center;
}

.sidebar__search { padding: 12px 18px; }
.sidebar__search input {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  color: #fff;
}
.sidebar__search input::placeholder { color: var(--muted-on-ink); }
.sidebar__search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(61,107,255,.25);
}

.search-results, .chat-list {
  overflow-y: auto;
  flex: 1;
}

.search-results { border-bottom: 1px solid rgba(255,255,255,.08); }

.chat-list__empty {
  color: var(--muted-on-ink);
  font-size: 13px;
  padding: 20px 18px;
  line-height: 1.5;
}

.chat-item, .search-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  cursor: pointer;
  border-left: 3px solid transparent;
}
.chat-item:hover, .search-item:hover { background: rgba(255,255,255,.06); }
.chat-item.is-active { background: rgba(61,107,255,.18); border-left-color: var(--accent); }

.chat-item__body, .search-item__body { min-width: 0; flex: 1; }
.chat-item__top { display: flex; justify-content: space-between; gap: 6px; }
.chat-item__name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-item__time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted-on-ink);
  flex-shrink: 0;
}
.chat-item__preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 13px;
  color: var(--muted-on-ink);
}
.chat-item__preview-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.search-item__sub {
  font-size: 12px;
  color: var(--muted-on-ink);
  font-family: var(--font-mono);
}
.chat-type-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted-on-ink);
}

/* ===== Chat pane ===== */

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

.chat-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  gap: 8px;
}
.chat-placeholder__mark { font-size: 40px; }

.chat-active {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 22px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.chat-header__info { flex: 1; min-width: 0; }
.chat-header__name {
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-header__meta {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.msg-row { display: flex; gap: 10px; max-width: 70%; }
.msg-row.is-own { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar { width: 32px; height: 32px; font-size: 13px; flex-shrink: 0; }

.msg-bubble {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 14px;
  min-width: 0;
}
.is-own .msg-bubble {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.msg-sender {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 3px;
  color: var(--accent);
}
.is-own .msg-sender { color: rgba(255,255,255,.85); }
.msg-text { font-size: 14px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.msg-time {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 5px;
  text-align: right;
}
.is-own .msg-time { color: rgba(255,255,255,.7); }

.msg-media img, .msg-media video {
  max-width: 320px;
  max-height: 320px;
  border-radius: 10px;
  display: block;
  margin-bottom: 6px;
}

.day-divider {
  align-self: center;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  background: rgba(0,0,0,.04);
  padding: 3px 10px;
  border-radius: 20px;
}

/* ===== Message actions (edit/delete) ===== */

.msg-bubble-wrap { position: relative; max-width: 100%; }
.msg-actions {
  position: absolute;
  top: -14px;
  right: 6px;
  display: flex;
  gap: 2px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 2px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s ease;
}
.msg-row:hover .msg-actions,
.msg-row.actions-pinned .msg-actions {
  opacity: 1;
  pointer-events: auto;
}
.msg-actions button {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 13px;
  padding: 4px 6px;
  border-radius: 6px;
  color: var(--muted);
}
.msg-actions button:hover { background: rgba(61,107,255,.1); color: var(--accent); }

.msg-edit-box { display: flex; flex-direction: column; gap: 6px; }
.msg-edit-box textarea {
  font-family: inherit;
  font-size: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  resize: vertical;
  min-height: 44px;
}
.msg-edit-actions { display: flex; gap: 8px; justify-content: flex-end; }
.msg-edit-actions button {
  border: none;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.msg-edit-save { background: var(--accent); color: #fff; }
.msg-edit-cancel { background: rgba(0,0,0,.08); color: var(--muted); }

.msg-edited-mark {
  font-size: 10px;
  color: var(--muted);
  margin-left: 4px;
}
.is-own .msg-edited-mark { color: rgba(255,255,255,.7); }

.msg-deleted {
  font-style: italic;
  color: var(--muted);
  font-size: 13.5px;
}

/* ===== Reactions ===== */

.msg-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}
.reaction-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text);
}
.reaction-chip.is-mine {
  border-color: var(--accent);
  background: rgba(61,107,255,.12);
  color: var(--accent-dark);
}
.reaction-add-btn {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 12px;
  padding: 2px 7px;
  font-size: 12px;
  cursor: pointer;
  color: var(--muted);
}
.reaction-picker {
  position: absolute;
  bottom: 100%;
  margin-bottom: 6px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px;
  display: flex;
  gap: 4px;
  box-shadow: 0 8px 24px rgba(0,0,0,.15);
  z-index: 5;
}
.reaction-picker button {
  border: none;
  background: none;
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
}
.reaction-picker button:hover { background: rgba(61,107,255,.1); }

/* ===== Pin badge + chat item menu ===== */

.pin-badge {
  font-size: 11px;
  margin-right: 3px;
  opacity: .8;
}

.chat-item { position: relative; }
.chat-item__menu-btn {
  border: none;
  background: none;
  color: var(--muted-on-ink);
  cursor: pointer;
  font-size: 16px;
  padding: 4px 6px;
  flex-shrink: 0;
  opacity: 0;
}
.chat-item:hover .chat-item__menu-btn,
.chat-item__menu-btn.is-open { opacity: 1; }

.chat-item-menu {
  position: absolute;
  right: 10px;
  top: 44px;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(0,0,0,.25);
  z-index: 20;
  min-width: 170px;
  overflow: hidden;
}
.chat-item-menu button {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  padding: 10px 14px;
  font-size: 13.5px;
  cursor: pointer;
  color: var(--text);
}
.chat-item-menu button:hover { background: var(--paper); }
.chat-item-menu button.danger { color: var(--danger); }

.typing-indicator {
  padding: 0 22px 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}

/* ===== Ответ на сообщение (reply) ===== */

.reply-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 22px;
  background: var(--paper);
  border-top: 1px solid var(--line);
  border-left: 3px solid var(--accent);
}
.reply-banner__body { flex: 1; min-width: 0; }
.reply-banner__label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--accent);
}
.reply-banner__text {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-quote { border-left: 3px solid var(--accent);
  background: rgba(61,107,255,.06);
  border-radius: 6px;
  padding: 5px 9px;
  margin-bottom: 6px;
  cursor: pointer;
}
.msg-flash .msg-bubble { animation: msgFlash 1.2s ease; }
@keyframes msgFlash {
  0% { box-shadow: 0 0 0 3px rgba(61,107,255,.5); }
  100% { box-shadow: 0 0 0 0 rgba(61,107,255,0); }
}
.is-own .msg-quote {
  border-left-color: rgba(255,255,255,.7);
  background: rgba(255,255,255,.12);
}
.msg-quote__name {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--accent);
}
.is-own .msg-quote__name { color: rgba(255,255,255,.9); }
.msg-quote__text {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}
.is-own .msg-quote__text { color: rgba(255,255,255,.75); }

/* ===== Непрочитанные ===== */

.unread-badge {
  background: var(--accent);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  border-radius: 10px;
  padding: 1px 7px;
  flex-shrink: 0;
}
.chat-item__name.has-unread { font-weight: 700; }

.composer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 22px;
  background: #fff;
  border-top: 1px solid var(--line);
}
.composer #message-input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 11px 16px;
  outline: none;
}
.composer #message-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(61,107,255,.15);
}
.composer #message-input:disabled,
.composer .btn:disabled,
.composer .icon-btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.attach-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 22px 12px;
  font-size: 13px;
  color: var(--muted);
  font-family: var(--font-mono);
}

/* ===== Запись голосового сообщения ===== */

.recording-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 22px;
  background: #fff;
  border-top: 1px solid var(--line);
}
.recording-bar__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
  animation: recPulse 1s ease-in-out infinite;
}
@keyframes recPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .4; transform: scale(.8); }
}
.recording-bar__time { font-family: var(--font-mono); font-weight: 600; }
.recording-bar__hint { color: var(--muted); font-size: 13px; flex: 1; }

/* ===== Голосовое сообщение в чате ===== */

.msg-voice {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
}
.msg-voice audio { flex: 1; height: 36px; }
.msg-voice__icon { font-size: 18px; }

/* ===== Видео-кружок: запись ===== */

.video-note-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  background: transparent;
}
.video-note-circle {
  width: 260px;
  height: 260px;
  border-radius: 50%;
  overflow: hidden;
  background: #000;
  border: 3px solid rgba(255,255,255,.25);
}
.video-note-circle video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* зеркалим превью, как в обычной фронталке */
}
.video-note-timer {
  font-family: var(--font-mono);
  color: #fff;
  font-size: 15px;
}
.video-note-controls {
  display: flex;
  align-items: center;
  gap: 20px;
}
.record-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 4px solid #fff;
  background: var(--danger);
  cursor: pointer;
}
.record-btn.is-recording { border-radius: 12px; }

/* ===== Видео-кружок: сообщение в чате ===== */

.msg-video-note {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  overflow: hidden;
}
.msg-video-note video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ===== Лайтбокс (фото на весь экран) ===== */

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 30px;
}
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
}
.lightbox__close {
  position: absolute;
  top: 18px;
  right: 18px;
  color: #fff;
  font-size: 26px;
  width: 44px;
  height: 44px;
}
.lightbox__close:hover { background: rgba(255,255,255,.15); }
.msg-media img { cursor: zoom-in; }

/* ===== Modal ===== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(21,27,50,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}
.modal {
  background: #fff;
  border-radius: 16px;
  padding: 26px;
  width: 100%;
  max-width: 420px;
  max-height: 86vh;
  overflow-y: auto;
}
.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal__header h2 { font-size: 18px; margin: 0; }

.modal__tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 18px;
}
.modal__tab {
  flex: 1;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 8px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.modal__tab.is-active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(61,107,255,.08);
}

.modal__results {
  max-height: 160px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 12px;
}
.modal__results:empty { display: none; margin: 0; border: none; }

.modal__selected {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.selected-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(61,107,255,.1);
  color: var(--accent-dark);
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.selected-chip button {
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
  font-size: 13px;
  line-height: 1;
}

/* ===== Responsive: мобильная навигация "список чатов <-> окно чата" =====
   По умолчанию на телефоне показываем список чатов на весь экран.
   Когда выбран чат, JS добавляет класс .chat-open на .app-shell —
   тогда показываем окно чата и кнопку "назад", а список прячем.
*/

.back-btn { display: none; }

@media (max-width: 760px) {
  .app-shell {
    display: block;
    height: 100vh;
    overflow: hidden;
  }

  .sidebar {
    width: 100%;
    height: 100vh;
  }

  .chat-pane {
    display: none;
  }

  .app-shell.chat-open .sidebar { display: none; }
  .app-shell.chat-open .chat-pane {
    display: flex;
    height: 100vh;
  }

  .back-btn {
    display: inline-flex;
  }

  .msg-row { max-width: 88%; }

  /* Увеличиваем тач-зоны на маленьком экране */
  .icon-btn { width: 40px; height: 40px; font-size: 20px; }
  .chat-item, .search-item { padding: 12px 16px; }

  /* На тачскрине нет :hover — показываем управляющие элементы всегда */
  .chat-item__menu-btn { opacity: 1; width: 32px; height: 32px; font-size: 18px; }
  .msg-row .msg-actions {
    opacity: 1;
    pointer-events: auto;
    position: static;
    display: flex;
    justify-content: flex-end;
    margin-bottom: 4px;
    background: none;
    border: none;
    padding: 0;
  }
  .msg-row:not(.is-own) .msg-actions { justify-content: flex-start; }
  .composer {
    padding: 12px 14px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
  .chat-header {
    padding: 12px 14px;
    padding-top: calc(12px + env(safe-area-inset-top));
  }
  .sidebar__header {
    padding-top: calc(18px + env(safe-area-inset-top));
  }
  .messages { padding: 16px; }
}

/* ===== Accessibility: focus visibility ===== */
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .auth-brand__cursor { animation: none; }
}
