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

/* Тёмная монохромная тема с холодным графитовым оттенком (в духе X) */
:root {
  --bg: #0e1113;
  --card: #16191c;
  --card-2: #1d2126;
  --text: #f0f2f4;
  --muted: #8a9199;
  --accent: #e8eaed;       /* акцент — почти белый */
  --accent-dark: #cdd1d6;
  --on-accent: #0e1113;    /* текст на акцентных кнопках */
  --danger: #f4212e;
  --like: #f91880;
  --border: #2a2f35;
  --radius: 12px;
  --bottom-nav-h: 0px;
  /* зона home-индикатора, сильно ужатая — низ почти вплотную */
  --safe-bottom: max(0px, calc(env(safe-area-inset-bottom, 0px) - 28px));
  --vvh: 100dvh; /* высота видимой области (над клавиатурой) — ставит JS из VisualViewport */
}

/* меньше «резинового» дёргания фиксированных элементов на iOS */
html { overscroll-behavior: none; }

html { color-scheme: dark; scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom));
}

a { color: #c6cbd1; text-decoration: none; }
a:hover { text-decoration: underline; color: var(--text); }

button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 16px;
  background: var(--accent);
  color: var(--on-accent);
  transition: background .15s, transform .1s, opacity .15s;
  min-height: 36px;
}
button:hover { background: var(--accent-dark); }
button:active { transform: scale(.97); }
button:disabled { opacity: 0.5; cursor: default; transform: none; }
button.secondary { background: var(--card-2); color: var(--text); border: 1px solid var(--border); }
button.secondary:hover { background: var(--border); }
button.danger-link {
  background: none; color: var(--danger); padding: 4px 8px; font-weight: 400;
}
button.danger-link:hover { background: rgba(244, 33, 46, .1); }
button.link {
  background: none; color: var(--muted); padding: 6px 10px; font-weight: 400;
  border-radius: 999px;
}
button.link:hover { background: var(--card-2); }
button.link.active { color: var(--like); }
button .spin { display: inline-block; animation: rot 1s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }

input, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px; /* 16px — iOS не зумит поле при фокусе */
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  transition: border-color .15s;
}
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { resize: none; min-height: 64px; overflow: hidden; }

/* ---------- Тосты ---------- */
.toasts {
  position: fixed; z-index: 100;
  bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 16px);
  left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px;
  width: min(92vw, 400px);
  pointer-events: none;
}
.toast {
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
  animation: toast-in .25s ease;
  pointer-events: auto;
  cursor: pointer;
}
.toast.error { border-color: var(--danger); }
.toast.out { opacity: 0; transition: opacity .3s; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Скелетоны ---------- */
.skeleton {
  background: linear-gradient(90deg, var(--card-2) 25%, #24282d 50%, var(--card-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 8px;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.sk-post .sk-line { height: 12px; margin: 8px 0; }
.sk-post .sk-head { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.sk-post .sk-avatar { width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; }

/* ---------- Модалки ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 95;
  background: rgba(0, 0, 0, .6);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  animation: fade-in .15s ease;
}
.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
  width: 100%; max-width: 400px;
  animation: toast-in .2s ease;
}
.modal-title { font-size: 19px; margin-bottom: 10px; }
.modal-body { color: var(--muted); font-size: 14px; margin-bottom: 14px; }
.modal-form { display: flex; flex-direction: column; gap: 12px; }
.modal-form select {
  width: 100%; padding: 10px 12px; border-radius: 8px;
  background: var(--bg); color: var(--text); border: 1px solid var(--border); font-size: 16px;
}
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }
.modal-choices { display: flex; flex-direction: column; gap: 10px; }
.modal-choices button { width: 100%; }
button.danger-btn { background: var(--danger); color: #fff; }
button.danger-btn:hover { background: #c4111d; }

@media (max-width: 640px) {
  /* на мобильном модалка как нижний лист */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal {
    max-width: none; border-radius: 16px 16px 0 0;
    padding-bottom: calc(22px + var(--safe-bottom));
    animation: sheet-up .22s ease;
  }
}

/* ---------- Лайтбокс ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(0,0,0,.92);
  display: flex; align-items: center; justify-content: center;
  animation: toast-in .2s ease;
  cursor: zoom-out;
}
.lightbox img { max-width: 96vw; max-height: 92vh; object-fit: contain; border-radius: 6px; }
.lightbox .close {
  position: absolute; top: 14px; right: 14px;
  background: rgba(255,255,255,.12); color: #fff;
  border-radius: 50%; width: 40px; height: 40px; font-size: 18px;
}

/* ---------- Auth ---------- */
.auth-wrap {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.auth-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 380px;
}
.auth-card h1 { font-size: 24px; margin-bottom: 4px; color: var(--accent); }
.auth-card p.sub { color: var(--muted); margin-bottom: 20px; font-size: 14px; }
.auth-card form { display: flex; flex-direction: column; gap: 12px; }
.auth-toggle { margin-top: 16px; font-size: 14px; text-align: center; }
.error-msg { color: var(--danger); font-size: 14px; min-height: 18px; }

/* ---------- Плавающая кнопка «назад» (мобильный, вложенные страницы) ---------- */
.back-fab {
  display: none;
  position: fixed; z-index: 40;
  top: calc(10px + env(safe-area-inset-top, 0px)); left: 12px;
  width: 42px; height: 42px; border-radius: 50%;
  align-items: center; justify-content: center;
  font-size: 18px; padding: 0;
  background: rgba(22, 25, 28, .75);
  color: var(--text);
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.back-fab:hover { background: var(--card-2); }

.search-form input {
  padding: 8px 14px; border-radius: 999px; font-size: 16px; background: var(--card);
}

/* ---------- Левое меню (как у Twitter) ---------- */
.shell-row {
  display: flex;
  max-width: 1260px;
  margin: 0 auto;
  align-items: flex-start;
}
.content-col { flex: 1; min-width: 0; }

.side-nav {
  position: sticky; top: 0;
  height: 100vh; height: 100dvh;
  width: 240px; flex-shrink: 0;
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px;
  border-right: 1px solid var(--border);
}
.side-nav .logo {
  display: flex; align-items: center; gap: 12px;
  font-size: 21px; font-weight: 700; color: var(--accent);
  padding: 10px 16px 18px;
}
.side-nav .logo .ico { font-size: 24px; }
.nav-item {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 16px; border-radius: 999px;
  color: var(--text); font-size: 17px; font-weight: 500;
  position: relative; white-space: nowrap;
}
.nav-item:hover { background: var(--card-2); text-decoration: none; }
.nav-item.active { font-weight: 700; color: var(--accent); }
.nav-item .ico { font-size: 21px; width: 26px; text-align: center; flex-shrink: 0; }
/* монохром: эмодзи-иконки навигации и лого обесцвечиваем */
.nav-item .ico, .bottom-nav a .ico, .side-nav .logo .ico,
.fab, .logout-btn .ico {
  filter: grayscale(1);
}
.nav-item.active .ico, .bottom-nav a.active .ico { filter: grayscale(1) brightness(1.5); }
.nav-item .badge { position: static; margin-left: auto; }
.nav-spacer { flex: 1; }
.nav-user {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 999px;
  overflow: hidden;
}
.nav-user:hover { background: var(--card-2); text-decoration: none; }
.nav-user .avatar { width: 36px; height: 36px; font-size: 14px; }
.nav-user .uname {
  color: var(--muted); font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.side-nav .logout-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  border-radius: 999px; margin-top: 4px;
}

/* Поиск в правой колонке (десктоп) */
.sidebar .side-search { margin-bottom: 16px; }

/* бейдж непрочитанных */
.badge {
  position: absolute; top: 2px; right: 2px;
  min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 999px; background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.badge:empty { display: none; }

/* ---------- FAB + bottom-sheet (мобильный композер) ---------- */
.fab {
  display: none;
  position: fixed; right: 16px;
  bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 16px);
  width: 56px; height: 56px; border-radius: 50%;
  font-size: 22px; z-index: 30;
  align-items: center; justify-content: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .55);
}
.sheet-overlay {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(0, 0, 0, .55);
  display: flex; align-items: flex-end;
  animation: fade-in .15s ease;
}
.sheet {
  width: 100%;
  background: var(--card);
  border-radius: 16px 16px 0 0;
  padding: 6px 14px calc(14px + var(--safe-bottom));
  max-height: 85dvh; overflow-y: auto;
  animation: sheet-up .22s ease;
}
@keyframes sheet-up {
  from { transform: translateY(40%); opacity: .6; }
  to { transform: none; opacity: 1; }
}
.sheet-handle {
  width: 38px; height: 4px; border-radius: 2px;
  background: var(--border); margin: 6px auto 12px;
}
.sheet .compose { border: none; margin: 0; padding: 0; background: none; }

/* ---------- Нижняя навигация (мобильная) ---------- */
.bottom-nav {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: rgba(14, 17, 19, .92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
}
.bottom-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 6px; color: var(--muted); font-size: 11px; font-weight: 500;
  position: relative; min-height: 48px; justify-content: center;
}
.bottom-nav a:hover { text-decoration: none; }
.bottom-nav a .ico { font-size: 21px; line-height: 1; }
.bottom-nav a.active { color: var(--accent); }
.bottom-nav a .badge { top: 2px; right: calc(50% - 22px); }
/* вкладка «Профиль» — аватар вместо иконки (паттерн Instagram) */
.bottom-nav .nav-profile .avatar {
  width: 24px; height: 24px; font-size: 11px;
}
.bottom-nav .nav-profile.active .avatar {
  box-shadow: 0 0 0 2px var(--accent);
}

/* ---------- Layout ---------- */
.layout {
  max-width: 1000px;
  margin: 20px auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 20px;
  padding: 0 16px;
}
.layout.single { grid-template-columns: minmax(0, 1fr); max-width: 720px; }
.layout.wide { max-width: 1160px; }

/* ---------- Фильтры ленты ---------- */
.filter-bar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 14px;
}
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 7px 14px; border-radius: 999px;
  background: var(--card-2); color: var(--muted);
  border: 1px solid var(--border);
  font-size: 13px; font-weight: 500; min-height: 32px;
}
.chip:hover { background: var(--border); color: var(--text); }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.chip.active:hover { background: var(--accent-dark); }

.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 16px;
  margin-bottom: 16px;
}

/* ---------- Compose ---------- */
.compose textarea { margin-bottom: 8px; }
.compose .row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.compose .char-count { color: var(--muted); font-size: 13px; margin-left: auto; }
.compose .char-count.over { color: var(--danger); }
.media-previews { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.media-previews .preview {
  position: relative; width: 90px; height: 90px;
  border-radius: 8px; overflow: hidden; background: var(--card-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--muted); text-align: center;
}
.media-previews .preview img { width: 100%; height: 100%; object-fit: cover; }
.media-previews .preview .x {
  position: absolute; top: 2px; right: 2px;
  background: rgba(0,0,0,.7); color: #fff;
  border-radius: 50%; width: 22px; height: 22px;
  font-size: 12px; line-height: 22px; text-align: center; cursor: pointer;
}

/* ---------- Posts ---------- */
.post { animation: fade-in .2s ease; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.post .head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px; flex-shrink: 0; overflow: hidden;
  user-select: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.post .meta { font-size: 13px; color: var(--muted); }
.post .meta a.uname { font-weight: 600; color: var(--text); font-size: 15px; }
.post .text { white-space: pre-wrap; word-wrap: break-word; margin-bottom: 10px; }
.post .media-grid { display: grid; gap: 6px; margin-bottom: 10px; }
.post .media-grid img, .post .media-grid video {
  width: 100%; max-height: 420px; object-fit: contain;
  border-radius: 8px; background: #000;
  aspect-ratio: 16 / 10; /* резервируем место — нет скачков макета */
}
.post .media-grid img { cursor: zoom-in; }
.post .media-pending {
  padding: 20px; background: var(--card-2); border-radius: 8px;
  color: var(--muted); font-size: 14px; text-align: center;
}
.post .actions { display: flex; gap: 4px; align-items: center; }
.post .actions .spacer { flex: 1; }

.infinite-sentinel { height: 1px; }
.list-loader { text-align: center; padding: 16px; color: var(--muted); }

.empty-state {
  text-align: center; padding: 40px 20px; color: var(--muted);
}
.empty-state .ico { font-size: 40px; display: block; margin-bottom: 10px; }

/* ---------- Comments ---------- */
.comments { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 10px; }
.comment { display: flex; gap: 8px; margin-bottom: 8px; font-size: 14px; }
.comment .avatar { width: 28px; height: 28px; font-size: 12px; }
.comment .bubble { background: var(--card-2); border-radius: 10px; padding: 6px 10px; }
.comment .bubble b { font-size: 13px; }
.comment-form { display: flex; gap: 8px; margin-top: 8px; }
.comment-form input { flex: 1; }

/* ---------- Profile (шапка как у Twitter) ---------- */
.profile-card { padding: 0; overflow: hidden; }
.profile-card .banner { height: 150px; }
.profile-body { padding: 0 20px 18px; }
.avatar-actions-row {
  display: flex; justify-content: space-between; align-items: flex-end;
  margin-top: -44px; /* аватар внахлёст на баннер */
}
.avatar.xl {
  width: 96px; height: 96px; font-size: 38px;
  border: 4px solid var(--card);
  box-shadow: 0 2px 10px rgba(0,0,0,.4);
}
.avatar-wrap { position: relative; display: inline-block; border-radius: 50%; }
.avatar-wrap.editable { cursor: pointer; }
.avatar-wrap .cam {
  position: absolute; inset: 4px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .45); font-size: 24px;
  opacity: 0; transition: opacity .15s;
}
.avatar-wrap.editable:hover .cam { opacity: 1; }
.profile-actions { display: flex; gap: 8px; padding-bottom: 6px; }
.p-name { font-size: 22px; font-weight: 800; margin-top: 10px; }
.p-joined { color: var(--muted); font-size: 14px; margin-top: 4px; }
.profile-body .stats {
  display: flex; gap: 18px; margin-top: 10px;
  font-size: 14px; color: var(--muted); flex-wrap: wrap;
}
.profile-body .stats b { color: var(--text); }
.stats .clickable { cursor: pointer; }
.stats .clickable:hover { color: var(--accent); text-decoration: underline; }

/* ---------- Sidebar ---------- */
.sidebar h3 { font-size: 15px; margin-bottom: 10px; color: var(--muted); }
.user-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; min-height: 48px; }
.user-row .avatar { width: 36px; height: 36px; font-size: 14px; }
.user-row .grow { flex: 1; min-width: 0; }
.user-row .grow .sub { font-size: 12px; color: var(--muted); }
.user-row button { padding: 6px 14px; font-size: 13px; }
.reco-post { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.reco-post:last-child { border-bottom: none; }
.reco-post .t { color: var(--text); display: block; margin: 2px 0; }
.reco-post .s { color: var(--muted); font-size: 12px; }

/* ---------- Search ---------- */
.search-section h3 { font-size: 16px; margin: 4px 0 10px; color: var(--muted); }
.main-search input { padding: 12px 18px; }

/* ---------- Messages ---------- */
.msg-layout {
  display: grid; grid-template-columns: 340px 1fr;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  height: calc(100dvh - 40px);
}
.conv-col { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-right: 1px solid var(--border); }
.conv-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 20px; min-height: 60px; border-bottom: 1px solid var(--border);
}
.conv-head h2 { font-size: 20px; font-weight: 700; }
.conv-list { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.conv-item {
  display: flex; gap: 12px; padding: 14px 16px; cursor: pointer;
  border-bottom: 1px solid var(--border); min-height: 72px; align-items: center;
  transition: background .15s;
}
.conv-item:hover, .conv-item.active { background: var(--card-2); }
.conv-item .grow { flex: 1; min-width: 0; }
.conv-item .last {
  font-size: 13px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-item .when { font-size: 11px; color: var(--muted); white-space: nowrap; }
.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-head {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  font-weight: 600; display: flex; align-items: center; gap: 8px;
}
.chat-head .back-btn { display: none; padding: 4px 12px; min-height: 36px; }
.chat-body {
  flex: 1; overflow-y: auto; padding: 20px 24px;
  display: flex; flex-direction: column; gap: 8px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch; /* инерционная прокрутка на iOS */
}
.bubble-msg {
  max-width: 65%; padding: 10px 14px; border-radius: 18px;
  font-size: 15px; line-height: 1.4; word-wrap: break-word;
  animation: fade-in .15s ease;
}
.bubble-msg.mine { align-self: flex-end; background: var(--accent); color: var(--on-accent); border-bottom-right-radius: 4px; }
.bubble-msg.theirs { align-self: flex-start; background: var(--card-2); border-bottom-left-radius: 4px; }
.bubble-msg .time { display: block; font-size: 10px; opacity: .7; margin-top: 2px; text-align: right; }
.bubble-msg img, .bubble-msg video {
  display: block; max-width: 100%; max-height: 320px;
  border-radius: 10px; margin-bottom: 4px; background: #000;
}
.bubble-msg img { cursor: zoom-in; }
.chat-form {
  display: flex; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border);
  align-items: center; background: var(--card);
}
.chat-form .msg-text {
  flex: 1; min-width: 0; border-radius: 999px;
  padding: 13px 18px; background: var(--card-2);
  -webkit-appearance: none; appearance: none;
}
.chat-form .msg-text::-webkit-search-cancel-button,
.chat-form .msg-text::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }
.chat-form button { border-radius: 999px; min-width: 48px; min-height: 48px; font-size: 16px; }
.chat-head { padding: 14px 20px; font-size: 16px; min-height: 72px; }
.upload-status { padding: 4px 16px; font-size: 13px; color: var(--muted); }
.upload-status:empty { display: none; } /* пустой — без отступа между диалогом и вводом */
.chat-empty {
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
}

.muted { color: var(--muted); font-size: 14px; }
.center { text-align: center; padding: 20px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}

/* ---------- Установленное приложение (PWA standalone) ---------- */
/* контент уходит под статус-бар (black-translucent) — отступаем safe-area */
@media (display-mode: standalone) {
  body { padding-top: env(safe-area-inset-top, 0px); }
  .side-nav { padding-top: calc(12px + env(safe-area-inset-top, 0px)); }
}


/* ---------- Новые фичи ---------- */
/* сетка фото 2x2 */
.media-grid.multi { grid-template-columns: 1fr 1fr; }
.media-grid.multi img, .media-grid.multi video {
  aspect-ratio: 1 / 1; object-fit: cover; max-height: 260px;
}

/* репосты */
.repost-label { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.repost-embed {
  border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 10px; cursor: pointer;
  transition: background .15s;
}
.repost-embed:hover { background: var(--card-2); }
.repost-embed .head { margin-bottom: 6px; }
.repost-embed .avatar { width: 28px; height: 28px; font-size: 12px; }
.repost-embed .text { font-size: 14px; margin-bottom: 6px; }
button.link.active-rt { color: #4caf7d; }
button.link.active-bm { color: var(--accent); }

/* уведомления */
.notif-row { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.notif-row:hover { background: var(--card-2); }
.notif-row.unread { border-left: 3px solid var(--accent); }
.notif-row .grow { flex: 1; min-width: 0; }
.notif-row .preview { font-size: 13px; margin-top: 2px; }

/* профиль: био, онлайн */
.p-bio { margin-top: 6px; font-size: 14px; white-space: pre-wrap; }
.online-dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  background: #4caf7d; margin-left: 6px; vertical-align: middle;
}

/* чаты: unread, статус */
.conv-unread {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--accent); color: var(--on-accent);
  font-size: 12px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.chat-head .grow { flex: 1; min-width: 0; }
.chat-peer { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; color: var(--text); }
.chat-peer:hover { text-decoration: none; }
.chat-peer .avatar { flex-shrink: 0; }
.chat-peer b { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.chat-status { font-size: 12px; min-height: 14px; }

/* ---------- Тренды ---------- */
.trend-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 14px; }
.trend-row .s { color: var(--muted); font-size: 12px; }

/* ---------- Треды комментариев ---------- */
.comment .grow { flex: 1; min-width: 0; }
.comment.reply { margin-left: 38px; }
.comment-meta { display: flex; gap: 10px; align-items: center; font-size: 12px; color: var(--muted); margin: 2px 0 0 4px; }
.comment-meta .link { padding: 2px 6px; font-size: 12px; min-height: 0; }

/* ---------- Чаты: галочки ---------- */
.bubble-msg .ticks { font-size: 11px; }
.bubble-msg.mine { user-select: none; }

/* ---------- Профиль: баннер-обложка ---------- */
.banner.editable { cursor: pointer; position: relative; }
.banner-cam {
  position: absolute; right: 10px; bottom: 10px;
  background: rgba(0,0,0,.5); color: #fff; font-size: 12px;
  padding: 4px 10px; border-radius: 999px; opacity: 0; transition: opacity .15s;
}
.banner.editable:hover .banner-cam { opacity: 1; }

/* ---------- Админка ---------- */
.stats-row { font-size: 14px; color: var(--muted); }
.stats-row b { color: var(--text); }
.invite-code {
  font-family: monospace; font-size: 15px; background: var(--card-2);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px; margin-top: 6px; user-select: all;
}
.report-card .report-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.report-card .report-actions button { font-size: 13px; padding: 6px 12px; }

/* ---------- Онбординг ---------- */
.onboard-list { margin-top: 12px; max-height: 50vh; overflow-y: auto; }

/* ---------- Профиль: bio, кнопки, вкладки ---------- */
.p-bio {
  margin: 8px 0 2px; font-size: 15px; line-height: 1.45;
  white-space: pre-wrap; word-wrap: break-word;
}
.icon-btn {
  width: 40px; padding: 0; display: inline-flex;
  align-items: center; justify-content: center; font-size: 16px;
}
.profile-tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}
.profile-tabs .tab {
  flex: 1; background: none; color: var(--muted);
  border-radius: 0; padding: 14px 8px; font-size: 15px;
  border-bottom: 2px solid transparent; min-height: 48px;
}
.profile-tabs .tab:hover { background: var(--card-2); color: var(--text); }
.profile-tabs .tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 700; }
/* вкладка уведомлений — компактнее, чем Посты/Закладки */
.profile-tabs .tab-sm { flex: 0 0 64px; position: relative; font-size: 17px; }
.profile-tabs .tab-sm .badge { top: 8px; right: 14px; }

/* настройки в модалке редактирования профиля */
.modal-settings { display: flex; flex-direction: column; gap: 8px; }
.modal-settings button { width: 100%; justify-content: flex-start; text-align: left; }
.push-btn.push-on { border-color: var(--accent); color: var(--accent); }

/* ---------- Адаптив ---------- */
/* < 1024px: правая колонка скрыта, левое меню — только иконки */
@media (max-width: 1023px) {
  .layout { grid-template-columns: minmax(0, 1fr); max-width: 720px; }
  .sidebar { display: none; }
  .side-nav { width: 76px; padding: 12px 8px; align-items: center; }
  .side-nav .lbl, .nav-user .uname { display: none; }
  .side-nav .logo { padding: 10px 0 16px; }
  .nav-item { padding: 12px; justify-content: center; gap: 0; }
  .nav-item .badge { position: absolute; top: 4px; right: 6px; margin: 0; }
  .nav-user { justify-content: center; padding: 8px 0; }
  .side-nav .logout-btn { width: 48px; height: 48px; padding: 0; }
}

/* < 640px: только нижняя навигация, без шапки */
@media (max-width: 640px) {
  :root { --bottom-nav-h: 54px; }

  .side-nav { display: none; }
  .back-fab { display: flex; }
  .bottom-nav { display: flex; }
  /* на мобильном пост создаётся через FAB + шторку, инлайн-композер скрыт */
  .layout .compose { display: none; }
  .fab { display: flex; }

  .layout { margin: 12px auto; padding: 0 10px; gap: 12px; }
  .card { padding: 12px; border-radius: 10px; }
  .post .media-grid img, .post .media-grid video { max-height: 320px; }
  .post .actions button.link { min-height: 44px; min-width: 44px; }
  .profile-card .banner { height: 110px; }
  .profile-body { padding: 0 14px 14px; }
  .profile-body .stats { gap: 12px; font-size: 13px; }
  .avatar.xl { width: 76px; height: 76px; font-size: 30px; }
  .avatar-actions-row { margin-top: -36px; }
  .p-name { font-size: 19px; }
  .bubble-msg { max-width: 86%; }

  /* Сообщения: на мобильном показываем либо список, либо чат.
     Прибиваем layout к области между safe-area сверху и нижней навигацией —
     так чат-форма всегда видна без скролла (надёжнее хрупкого расчёта по dvh). */
  .msg-layout {
    position: fixed;
    left: 0; right: 0;
    top: env(safe-area-inset-top, 0px);
    bottom: calc(var(--bottom-nav-h) + var(--safe-bottom));
    z-index: 5;
    display: block;          /* колонки позиционируем абсолютно — см. ниже */
    height: auto; margin: 0;
    border: none; border-radius: 0;
  }
  /* список и чат занимают всю область layout — это даёт телу сообщений
     чёткую высоту, поэтому скроллится оно, а шапка/инпут стоят на месте */
  .msg-layout .conv-col,
  .msg-layout .chat {
    position: absolute; inset: 0;
    border-right: none;
  }
  .msg-layout .chat { display: none; }
  /* в открытом чате и при клавиатуре нижняя навигация не нужна — убираем,
     чтобы на iOS она не «выезжала» над клавиатурой */
  body.in-chat .bottom-nav,
  body.kb-open .bottom-nav { display: none; }
  /* фон под открытым чатом не должен прокручиваться (иначе дёргается на Android) */
  body.in-chat { overflow: hidden; }
  /* Открытый чат точно накрывает видимую область (VisualViewport): высота = видимой,
     transform компенсирует сдвиг, который iOS делает при фокусе на инпут.
     Итог: ввод всегда у верха клавиатуры — без зазора, без «под клаву», без прокрутки инпута. */
  body.in-chat .msg-layout {
    top: 0; bottom: auto;
    height: var(--vvh, 100dvh);
    transform: translateY(var(--vvt, 0px));
  }
  /* safe-area уводим внутрь шапки и поля ввода (т.к. layout начинается от top:0) */
  body.in-chat .chat-head { padding-top: calc(14px + env(safe-area-inset-top, 0px)); }
  /* без клавиатуры — небольшой отступ над home-индикатором (ужатый --safe-bottom) */
  body.in-chat .chat-form { padding-bottom: calc(6px + var(--safe-bottom)); }
  /* с клавиатурой home-индикатора нет — без safe-area, поле прижато к клавиатуре */
  body.in-chat.kb-open .chat-form { padding-bottom: 6px; }
  .chat-body { padding: 14px 12px; }
  .chat-form { padding: 10px 12px; }
  .msg-layout.chat-open .conv-col { display: none; }
  .msg-layout.chat-open .chat { display: flex; }
  .chat-head .back-btn { display: inline-block; }
}
