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

:root {
  --primary: #5865F2;
  --primary-hover: #4752C4;
  --secondary: #ED4245;
  --success: #57F287;
  --warning: #FEE75C;
  --danger: #ED4245;
  --info: #5865F2;
  --like-color: #FF6B9D;
  
  --bg-primary: #ffffff;
  --bg-secondary: #f2f3f5;
  --bg-tertiary: #e3e5e8;
  --bg-hover: #ebedef;
  
  --text-primary: #060607;
  --text-secondary: #4e5058;
  --text-tertiary: #80848e;
  --text-inverse: #ffffff;
  
  --border-color: #e3e5e8;
  --border-hover: #d4d7dc;
  
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.16);
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-full: 9999px;
  
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  
  --vh: 1vh;
}

body.dark-theme {
  --bg-primary: #1e1f22;
  --bg-secondary: #111214;
  --bg-tertiary: #2b2d31;
  --bg-hover: #35373c;
  
  --text-primary: #f2f3f5;
  --text-secondary: #b5bac1;
  --text-tertiary: #80848e;
  --text-inverse: #060607;
  
  --border-color: #26282c;
  --border-hover: #3f4147;
  
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.6);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.7);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.6;
  transition: var(--transition);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
}


.page {
  min-height: 100vh;
  min-height: calc(var(--vh, 1vh) * 100);
}

.hidden {
  display: none !important;
}

/* Авторизация */
#auth-page {
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: calc(var(--vh, 1vh) * 100);
  padding: 20px;
}

.logo {
  text-align: center;
  margin-bottom: 40px;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.logo h1 {
  font-size: 4em;
  font-weight: 900;
  color: var(--text-primary);
  letter-spacing: -3px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  text-shadow: none;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  pointer-events: none;
}

.auth-form {
  background: var(--bg-primary);
  padding: 40px;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 420px;
  border: 1px solid var(--border-color);
}

.auth-form h2 {
  margin-bottom: 30px;
  text-align: center;
  font-size: 1.8em;
  font-weight: 700;
  color: var(--text-primary);
}

.auth-form input {
  width: 100%;
  padding: 14px 18px;
  margin-bottom: 16px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 15px;
  transition: var(--transition);
  background: var(--bg-primary);
  color: var(--text-primary);
}

.auth-form input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.auth-form button {
  width: 100%;
  padding: 14px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.auth-form button:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.auth-form button:active {
  transform: translateY(0);
}

.auth-form p {
  text-align: center;
  margin-top: 20px;
  color: var(--text-secondary);
}

.auth-form a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.auth-form a:hover {
  text-decoration: underline;
}

.captcha-container {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  align-items: center;
}

.captcha-container img {
  flex: 1;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
}

.captcha-container button {
  width: 56px;
  height: 56px;
  padding: 0;
  background: var(--success);
  border-radius: var(--radius-md);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
}

/* Навигация */
.navbar {
  background: var(--bg-primary);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 2000;
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.nav-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.nav-logo h1 {
  font-size: 1.5em;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -1.5px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  pointer-events: none;
}

.nav-links {
  display: flex;
  gap: 4px;
  align-items: center;
}

.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 600;
  position: relative;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.nav-link:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-link.active {
  background: var(--primary);
  color: white;
}

.badge {
  background: var(--secondary);
  color: white;
  border-radius: var(--radius-full);
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 18px;
  text-align: center;
}

/* Контейнер */
.container {
  max-width: 680px;
  margin: 20px auto;
  padding: 0 16px;
  position: relative;
  z-index: 10;
}

#feed-section {
  padding-top: 8px;
  position: relative;
  z-index: 10;
}

#main-page {
  background: var(--bg-secondary);
  min-height: 100vh;
  min-height: calc(var(--vh, 1vh) * 100);
  position: relative;
}

/* Снегопад */
.snow-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.snowflake {
  position: absolute;
  top: -20px;
  color: #4e5058;
  text-shadow: 0 0 5px rgba(78, 80, 88, 0.5);
  animation: fall linear infinite;
  user-select: none;
}

body.dark-theme .snowflake {
  color: #ffffff;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.9);
}

@keyframes fall {
  0% {
    transform: translateY(-20px) rotate(0deg);
  }
  100% {
    transform: translateY(100vh) rotate(360deg);
  }
}

#search-section {
  position: relative;
  z-index: 10;
}

#notifications-section {
  position: relative;
  z-index: 10;
}

#profile-section {
  position: relative;
  z-index: 10;
}

#settings-section {
  position: relative;
  z-index: 10;
}

/* Создание поста */
.create-post {
  background: var(--bg-primary);
  padding: 16px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
  border: 1px solid var(--border-color);
  position: relative;
  z-index: 10;
}

.create-post textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 15px;
  resize: vertical;
  min-height: 80px;
  font-family: inherit;
  transition: var(--transition);
  background: var(--bg-primary);
  color: var(--text-primary);
}

.create-post textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(88, 101, 242, 0.1);
}

.create-post button {
  margin-top: 12px;
  padding: 12px 28px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 50px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-size: 15px;
}

.create-post button:hover:not(:disabled) {
  background: var(--primary-hover);
}

.create-post button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Вкладки сортировки */
.sort-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  background: var(--bg-primary);
  padding: 4px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  position: -webkit-sticky;
  position: sticky;
  top: 60px; /* Под навигацией */
  z-index: 1000;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: background, backdrop-filter, box-shadow;
}

.sort-tabs::before {
  content: '';
  position: absolute;
  top: 4px;
  left: 4px;
  width: calc(50% - 7px);
  height: calc(100% - 8px);
  background: var(--primary);
  border-radius: var(--radius-md);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 0;
  box-shadow: var(--shadow-sm);
}

/* Эффект при прокрутке - применяется через JS */
.sort-tabs.scrolled {
  background: rgba(255, 255, 255, 0.85) !important;
  backdrop-filter: blur(20px) saturate(180%) brightness(1.1);
  -webkit-backdrop-filter: blur(20px) saturate(180%) brightness(1.1);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
  border-color: rgba(227, 229, 232, 0.8);
}

body.dark-theme .sort-tabs.scrolled {
  background: rgba(17, 18, 20, 0.85) !important;
  backdrop-filter: blur(20px) saturate(180%) brightness(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(180%) brightness(1.2);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);
  border-color: rgba(38, 40, 44, 0.8);
}

.tab {
  flex: 1;
  padding: 8px;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-weight: 600;
  transition: color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  color: var(--text-secondary);
  font-size: 14px;
  position: relative;
  z-index: 1;
}

.tab:hover:not(.active) {
  color: var(--text-primary);
}

.tab.active {
  color: white;
}

.sort-tabs[data-active="popular"]::before {
  transform: translateX(calc(100% + 6px));
}

/* Посты */
.post {
  background: var(--bg-primary);
  padding: 16px;
  border-radius: 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 12px;
  border: 1px solid var(--border-color);
  transition: var(--transition);
  position: relative;
  z-index: 10;
}

.post:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
}

.pinned-post {
  border: 2px solid var(--primary);
  background: linear-gradient(135deg, var(--bg-primary) 0%, rgba(88, 101, 242, 0.05) 100%);
}

.pinned-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.pinned-indicator svg {
  flex-shrink: 0;
}

.post-menu-btn {
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-md);
  font-size: 20px;
  font-weight: bold;
  transition: var(--transition);
  margin-left: auto;
  line-height: 1;
}

.post-menu-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.post-menu {
  position: absolute;
  right: 16px;
  top: 50px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 150px;
  z-index: 1000;
  overflow: hidden;
}

.post-menu-item {
  padding: 10px 16px;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-primary);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}

.post-menu-item svg {
  flex-shrink: 0;
}

.post-menu-item:hover {
  background: var(--bg-hover);
}

.post-menu-item.danger {
  color: var(--danger);
}

.post-menu-item.danger:hover {
  background: rgba(237, 66, 69, 0.1);
}

.post-header {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
  cursor: pointer;
  gap: 10px;
}

.post-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--text-tertiary);
  font-size: 14px;
}

.post-header-info {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 4px;
}

.post-header strong {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.post-time {
  color: var(--text-tertiary);
  font-size: 12px;
  margin-left: auto;
  font-weight: 500;
}

.post-content {
  margin-bottom: 12px;
  line-height: 1.5;
  font-size: 14px;
  color: var(--text-primary);
  word-wrap: break-word;
}

.verified {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  background: #5865F2;
  border-radius: 50%;
  margin-left: 4px;
  flex-shrink: 0;
  vertical-align: middle;
  position: relative;
  top: -1px;
}

.verified::after {
  content: '';
  width: 11px;
  height: 11px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.post-image {
  width: 100%;
  max-height: 500px;
  object-fit: cover;
  border-radius: 16px;
  margin-top: 12px;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.repost-indicator {
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 6px;
}

.repost-indicator svg {
  width: 16px;
  height: 16px;
  stroke: var(--text-tertiary);
  fill: none;
  flex-shrink: 0;
}

.repost-indicator span {
  color: var(--text-tertiary);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.repost-content {
  background: var(--bg-secondary);
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--border-color);
  margin-bottom: 12px;
}

.post-actions {
  display: flex;
  gap: 8px;
  padding-top: 12px;
  align-items: center;
}

.post-actions button {
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.post-actions button:hover {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.post-actions button.liked {
  color: var(--like-color);
  animation: likeAnimation 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.post-actions button svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  transition: var(--transition);
}

.post-actions button.liked svg {
  fill: var(--like-color);
  stroke: var(--like-color);
  animation: heartBeat 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.post-actions > div svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
}

@keyframes likeAnimation {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes heartBeat {
  0% {
    transform: scale(1);
  }
  25% {
    transform: scale(1.3);
  }
  50% {
    transform: scale(1.1);
  }
  75% {
    transform: scale(1.25);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes unlikeAnimation {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(0.8);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Комментарии */
.comments-section {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid #e4e6eb;
}

.comment {
  background: #f0f2f5;
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 8px;
}

.comment-header {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 5px;
}

.comment-content {
  font-size: 14px;
}

.comment-form {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.comment-form input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 20px;
  font-size: 14px;
}

.comment-form button {
  padding: 8px 16px;
  background: #1877f2;
  color: white;
  border: none;
  border-radius: 20px;
  cursor: pointer;
}

/* Профиль */
.profile-header {
  background: white;
  padding: 30px;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
  margin-bottom: 20px;
  text-align: center;
}

.profile-header h2 {
  font-size: 2em;
  margin-bottom: 10px;
}

.profile-stats {
  display: flex;
  justify-content: center;
  gap: 30px;
  margin: 20px 0;
}

.profile-stat {
  text-align: center;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-md);
  transition: var(--transition);
}

.profile-stat:hover {
  background: var(--bg-hover);
}

.profile-stat strong {
  display: block;
  font-size: 1.5em;
  color: #1877f2;
}

.profile-bio {
  margin: 20px 0;
  color: #65676b;
}

.profile-bio textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  margin-top: 10px;
  resize: vertical;
}

.profile-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 15px;
}

.profile-actions button {
  padding: 10px 24px;
  border: none;
  border-radius: 6px;
  font-weight: bold;
  cursor: pointer;
}

.profile-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  background: var(--bg-primary);
  padding: 4px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  position: relative;
}

.profile-tabs::before {
  content: '';
  position: absolute;
  top: 4px;
  left: 4px;
  height: calc(100% - 8px);
  background: var(--primary);
  border-radius: var(--radius-md);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 0;
  box-shadow: var(--shadow-sm);
}

/* Для 3 вкладок */
.profile-tabs[data-tab-count="3"]::before {
  width: calc(33.333% - 6px);
}

.profile-tabs[data-tab-count="3"][data-active="posts"]::before {
  transform: translateX(0);
}

.profile-tabs[data-tab-count="3"][data-active="liked"]::before {
  transform: translateX(calc(100% + 6px));
}

.profile-tabs[data-tab-count="3"][data-active="reposts"]::before {
  transform: translateX(calc(200% + 12px));
}

/* Для 2 вкладок */
.profile-tabs[data-tab-count="2"]::before {
  width: calc(50% - 7px);
}

.profile-tabs[data-tab-count="2"][data-active="posts"]::before {
  transform: translateX(0);
}

.profile-tabs[data-tab-count="2"][data-active="liked"]::before {
  transform: translateX(calc(100% + 6px));
}

.profile-tab {
  flex: 1;
  padding: 8px 16px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-weight: 600;
  cursor: pointer;
  position: relative;
  z-index: 1;
  transition: color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: var(--radius-md);
  font-size: 14px;
}

.profile-tab:hover:not(.active) {
  color: var(--text-primary);
}

.profile-tab.active {
  color: white;
}

.btn-primary {
  background: #1877f2;
  color: white;
}

.btn-secondary {
  background: #e4e6eb;
  color: #1c1e21;
}

/* Уведомления */
.notification {
  background: white;
  padding: 15px;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
  margin-bottom: 10px;
  cursor: pointer;
}

.notification:hover {
  background: #f0f2f5;
}

.notification.unread {
  background: #e7f3ff;
}

.notification-text {
  margin-bottom: 5px;
}

.notification-time {
  color: #65676b;
  font-size: 13px;
}

/* Комментарии */
.comments-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.comment {
  background: var(--bg-secondary);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  border: 1px solid var(--border-color);
}

.comment-header {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 6px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.comment-header button:hover {
  background: var(--bg-hover);
  color: var(--danger);
}

.comment-header button svg {
  display: block;
}

.comment-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-tertiary);
  border: 2px solid var(--border-color);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--text-tertiary);
  font-size: 12px;
}

.comment-content {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.5;
}

.comment-form {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.comment-form input {
  flex: 1;
  padding: 10px 16px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-full);
  font-size: 14px;
  transition: var(--transition);
  background: var(--bg-primary);
  color: var(--text-primary);
}

.comment-form input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.comment-form button {
  padding: 10px 20px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-weight: 600;
  transition: var(--transition);
  font-size: 14px;
}

.comment-form button:hover {
  background: var(--primary-hover);
}

/* Профиль */
.profile-header {
  background: var(--bg-primary);
  padding: 0;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
  border: 1px solid var(--border-color);
  position: relative;
  z-index: 10;
  overflow: hidden;
}

.profile-banner {
  width: 100%;
  height: 150px;
  background: var(--primary);
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.profile-banner-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-banner-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 8px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.profile-header:hover .profile-banner-controls {
  opacity: 1;
}

.banner-control-btn {
  width: 36px;
  height: 36px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  transition: all 0.2s ease;
}

.banner-control-btn:hover {
  background: rgba(0, 0, 0, 0.8);
  transform: scale(1.1);
}

.banner-control-btn svg {
  width: 18px;
  height: 18px;
  stroke: white;
  fill: none;
}

.profile-info-section {
  padding: 32px;
  text-align: center;
  position: relative;
  margin-top: -60px;
}

.profile-avatar-container {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto 20px;
  z-index: 1;
}

.profile-avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid var(--bg-primary);
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  font-weight: 700;
  color: var(--text-tertiary);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.online-indicator {
  position: absolute;
  bottom: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  background: #57F287;
  border: 4px solid var(--bg-primary);
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  z-index: 2;
}

.last-seen-text {
  color: var(--text-tertiary);
  font-size: 13px;
  margin-top: 8px;
  font-weight: 500;
}

.avatar-upload-btn {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 36px;
  height: 36px;
  background: var(--primary);
  border: 3px solid var(--bg-primary);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  transition: var(--transition);
}

.avatar-upload-btn svg {
  width: 18px;
  height: 18px;
  stroke: white;
  fill: none;
}

.avatar-upload-btn:hover {
  background: var(--primary-hover);
  transform: scale(1.1);
}

.avatar-upload-input {
  display: none;
}

.profile-header h2 {
  font-size: 2em;
  margin-bottom: 12px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.profile-stats {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin: 24px 0;
}

.profile-stat {
  text-align: center;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-md);
  transition: var(--transition);
}

.profile-stat:hover {
  background: var(--bg-hover);
}

.profile-stat strong {
  display: block;
  font-size: 1.8em;
  font-weight: 700;
  color: var(--primary);
}

.profile-stat span {
  color: var(--text-tertiary);
  font-size: 13px;
  font-weight: 600;
}

.profile-bio {
  margin: 20px 0;
  color: var(--text-secondary);
  font-size: 15px;
}

.profile-bio textarea {
  width: 100%;
  padding: 14px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-top: 12px;
  resize: vertical;
  font-family: inherit;
  font-size: 14px;
  transition: var(--transition);
  background: var(--bg-primary);
  color: var(--text-primary);
}

.profile-bio textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.profile-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 16px;
}

.profile-actions button {
  padding: 10px 24px;
  border: none;
  border-radius: 50px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-size: 14px;
}

.btn-primary {
  background: var(--primary);
  color: white;
  border-radius: 50px;
  padding: 10px 22px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: var(--transition);
}

.btn-primary:hover {
  background: var(--primary-hover);
  opacity: 0.92;
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 50px;
  padding: 10px 22px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-secondary:hover {
  background: var(--bg-tertiary);
}

/* Уведомления */
.notification {
  background: var(--bg-primary);
  padding: 16px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 12px;
  cursor: pointer;
  border: 1px solid var(--border-color);
  transition: var(--transition);
  position: relative;
  z-index: 10;
}

.notification:hover {
  box-shadow: var(--shadow-md);
  background: #ffffff;
}

.notification:hover .notification-text {
  color: #000000;
}

.notification.unread {
  background: rgba(102, 126, 234, 0.05);
  border-color: var(--primary);
}

.notification-text {
  margin-bottom: 6px;
  font-weight: 600;
  color: var(--text-primary);
  font-size: 14px;
  transition: var(--transition);
}

.notification-time {
  color: var(--text-tertiary);
  font-size: 12px;
  font-weight: 500;
}

/* Настройки */
.settings-section {
  max-width: 600px;
  margin: 0 auto;
  position: relative;
  z-index: 10;
}

.settings-group {
  background: var(--bg-primary);
  padding: 24px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
  border: 1px solid var(--border-color);
  position: relative;
  z-index: 10;
}

.settings-group h3 {
  font-size: 1.2em;
  margin-bottom: 16px;
  color: var(--text-primary);
  font-weight: 700;
}

.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid var(--border-color);
}

.setting-item:last-child {
  border-bottom: none;
}

.setting-info h4 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.setting-info p {
  font-size: 13px;
  color: var(--text-tertiary);
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  width: 50px;
  height: 26px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition);
}

.toggle-switch.active {
  background: var(--primary);
}

.toggle-slider {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: var(--transition);
}

.toggle-switch.active .toggle-slider {
  transform: translateX(24px);
}

/* Select */
.setting-select {
  padding: 8px 16px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.setting-select:focus {
  outline: none;
  border-color: var(--primary);
}

/* Поиск */
.search-bar {
  background: var(--bg-primary);
  padding: 16px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
  border: 1px solid var(--border-color);
  position: relative;
  z-index: 10;
}

.search-bar input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 15px;
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: var(--transition);
}

.search-bar input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Модальное окно */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-content {
  background: var(--bg-primary);
  padding: 32px;
  border-radius: var(--radius-xl);
  max-width: 500px;
  width: 100%;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border-color);
  position: relative;
  z-index: 1001;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-header h3 {
  font-size: 1.5em;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-tertiary);
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  transition: var(--transition);
}

.modal-close:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

/* Список подписчиков */
.follower-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-radius: var(--radius-md);
  transition: var(--transition);
  border-bottom: 1px solid var(--border-color);
}

.follower-item:last-child {
  border-bottom: none;
}

.follower-item:hover {
  background: var(--bg-hover);
}

.follower-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.follower-info {
  flex: 1;
  min-width: 0;
}

.follower-info strong {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.follower-info p {
  font-size: 13px;
  color: var(--text-tertiary);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-follow {
  padding: 8px 20px;
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  background: var(--primary);
  color: white;
  flex-shrink: 0;
}

.btn-follow:hover {
  background: var(--primary-hover);
}

.btn-follow.following {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-follow.following:hover {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

/* Адаптивность */
@media (max-width: 768px) {
  body {
    font-size: 15px;
  }

  .container {
    padding: 0 16px;
    margin: 20px auto;
    max-width: 100%;
  }
  
  .nav-content {
    padding: 12px 16px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .nav-logo {
    margin-right: 16px;
  }
  
  .nav-logo h1 {
    font-size: 1.4em;
    white-space: nowrap;
  }
  
  .nav-link {
    padding: 10px 16px;
    min-width: auto;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    font-size: 14px;
  }
  
  .nav-links {
    gap: 4px;
    flex-wrap: nowrap;
  }
  
  .badge {
    top: 2px;
    right: 2px;
    font-size: 10px;
    padding: 2px 6px;
  }
  
  .post {
    padding: 16px;
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
  }
  
  .post-avatar {
    width: 40px;
    height: 40px;
    font-size: 16px;
  }
  
  .post-header {
    gap: 12px;
    margin-bottom: 12px;
  }
  
  .post-header strong {
    font-size: 15px;
  }
  
  .post-time {
    font-size: 12px;
  }
  
  .post-content {
    font-size: 15px;
    margin-bottom: 12px;
    line-height: 1.5;
  }
  
  .post-actions {
    gap: 8px;
    flex-wrap: nowrap;
    padding-top: 12px;
  }
  
  .post-actions button {
    padding: 10px 14px;
    font-size: 14px;
    flex: 1;
    justify-content: center;
  }
  
  .post-actions button svg {
    width: 20px;
    height: 20px;
  }
  
  .post-actions > div {
    margin-left: 0 !important;
  }
  
  .create-post {
    padding: 16px;
  }
  
  .create-post textarea {
    min-height: 100px;
    font-size: 15px;
    padding: 12px;
  }
  
  .create-post label[for="post-image"] {
    width: 48px !important;
    height: 48px !important;
    padding: 12px !important;
  }
  
  .create-post label[for="post-image"] svg {
    width: 24px !important;
    height: 24px !important;
    stroke-width: 2.5 !important;
  }
  
  .create-post button {
    padding: 12px 20px;
    font-size: 15px;
  }
  
  .create-post label {
    padding: 12px 20px !important;
    font-size: 15px;
  }
  
  .create-post label svg {
    width: 22px;
    height: 22px;
  }
  
  #image-name {
    font-size: 13px !important;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  
  .sort-tabs {
    margin-bottom: 16px;
    padding: 6px;
    top: 70px; /* Больше отступ от навигации на мобильных */
  }
  
  .tab {
    padding: 12px;
    font-size: 15px;
  }
  
  .profile-header {
    padding: 24px 16px;
  }
  
  .profile-avatar-container {
    width: 110px;
    height: 110px;
  }
  
  .profile-avatar {
    width: 110px;
    height: 110px;
    font-size: 44px;
  }
  
  .profile-header h2 {
    font-size: 1.6em;
  }
  
  .profile-stats {
    gap: 30px;
    margin: 20px 0;
  }
  
  .profile-stat strong {
    font-size: 1.5em;
  }
  
  .profile-stat span {
    font-size: 13px;
  }
  
  .profile-bio textarea {
    font-size: 15px;
  }
  
  .profile-actions {
    flex-direction: row;
    gap: 12px;
  }
  
  .profile-actions button {
    width: auto;
    flex: 1;
  }
  
  .comment {
    padding: 12px 14px;
  }
  
  .comment-avatar {
    width: 32px;
    height: 32px;
    font-size: 13px;
  }
  
  .comment-header {
    font-size: 14px;
  }
  
  .comment-content {
    font-size: 14px;
    line-height: 1.5;
  }
  
  .comment-form input {
    padding: 12px 16px;
    font-size: 15px;
  }
  
  .comment-form button {
    padding: 12px 20px;
    font-size: 15px;
  }
  
  .auth-form {
    padding: 32px 24px;
    max-width: 100%;
    margin: 0 16px;
  }
  
  .auth-form h2 {
    font-size: 1.6em;
  }
  
  .auth-form input {
    padding: 14px 18px;
    font-size: 15px;
  }
  
  .logo h1 {
    font-size: 3em;
  }
  
  .modal-content {
    margin: 20px;
    padding: 28px;
    max-width: calc(100% - 40px);
  }
  
  .modal-header h3 {
    font-size: 1.4em;
  }
  
  .follower-item {
    padding: 12px;
  }
  
  .follower-info strong {
    font-size: 14px;
  }
  
  .follower-info p {
    font-size: 13px;
  }
  
  .settings-group {
    padding: 20px;
  }
  
  .setting-item {
    padding: 16px 0;
    flex-direction: row;
    align-items: flex-start;
    gap: 10px;
  }
  
  .setting-info h4 {
    font-size: 15px;
  }
  
  .setting-info p {
    font-size: 13px;
  }
  
  .search-bar {
    padding: 16px;
  }
  
  .search-bar input {
    font-size: 15px;
    padding: 14px 18px;
  }
  
  .notification {
    padding: 16px;
  }
  
  .notification-text {
    font-size: 15px;
  }
  
  .notification-time {
    font-size: 12px;
  }
  
  .post-image {
    max-height: 400px;
    border-radius: 16px;
  }
  
  .repost-content {
    padding: 14px;
  }
  
  .repost-indicator {
    font-size: 13px;
    margin-bottom: 12px;
  }
  
  .verified {
    width: 18px;
    height: 18px;
  }
  
  .verified::after {
    width: 11px;
    height: 11px;
  }
  
  .post-menu {
    min-width: 180px;
  }
  
  .post-menu-item {
    padding: 14px 18px;
    font-size: 15px;
  }
}

/* Очень маленькие экраны */
@media (max-width: 480px) {
  .nav-logo h1 {
    font-size: 1.3em;
  }
  
  .container {
    padding: 0 12px;
  }
  
  .post {
    padding: 14px;
  }
  
  .profile-stats {
    gap: 20px;
  }
  
  .profile-stat strong {
    font-size: 1.3em;
  }
  
  .create-post textarea {
    min-height: 90px;
  }
  
  .auth-container {
    padding: 12px;
  }
  
  .captcha-container button {
    min-width: 56px;
    min-height: 56px;
  }
  
  .avatar-upload-btn {
    width: 40px;
    height: 40px;
  }
  
  .avatar-upload-btn svg {
    width: 20px;
    height: 20px;
  }
  
  .toggle-switch {
    width: 50px;
    height: 28px;
  }
  
  .toggle-slider {
    width: 22px;
    height: 22px;
  }
  
  .modal {
    padding: 16px;
  }
  
  .modal-content {
    max-height: calc(100vh - 32px);
    overflow-y: auto;
  }
  
  .follower-item {
    min-height: 60px;
  }
  
  .post-header {
    min-height: 44px;
  }
  
  .comment-header {
    min-height: 36px;
  }
}

/* Планшеты */
@media (min-width: 769px) and (max-width: 1024px) {
  .container {
    max-width: 600px;
  }
  
  .nav-content {
    padding: 10px 20px;
  }
}

/* Улучшения для сенсорных экранов */
@media (hover: none) and (pointer: coarse) {
  .nav-link,
  .post-actions button,
  .profile-actions button,
  .tab,
  .follower-item,
  .notification,
  .post-header {
    -webkit-tap-highlight-color: rgba(88, 101, 242, 0.1);
  }
  
  .nav-link:active,
  .post-actions button:active,
  .tab:active {
    transform: scale(0.95);
  }
  
  .post-actions button:active {
    background: var(--bg-hover);
  }
  
  input,
  textarea,
  select {
    font-size: 16px !important;
  }
}

/* Ландшафтная ориентация на мобильных */
@media (max-width: 768px) and (orientation: landscape) {
  .navbar {
    position: fixed;
  }
  
  .container {
    margin-top: 60px;
  }
  
  .profile-avatar-container {
    width: 80px;
    height: 80px;
  }
  
  .profile-avatar {
    width: 80px;
    height: 80px;
    font-size: 32px;
  }
  
  .profile-header {
    padding: 16px;
  }
  
  .modal-content {
    max-height: calc(100vh - 40px);
  }
}


/* Футер */
.footer {
  background: var(--bg-primary);
  border-top: 1px solid var(--border-color);
  padding: 20px;
  text-align: center;
  margin-top: 40px;
  position: relative;
  z-index: 10;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.footer-content p {
  color: var(--text-tertiary);
  font-size: 14px;
  margin: 0;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.footer-separator {
  color: var(--text-tertiary);
  font-size: 14px;
}

.footer-link {
  color: var(--primary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: var(--transition);
  white-space: nowrap;
}

.footer-link:hover {
  text-decoration: underline;
  color: var(--primary-hover);
}

@media (min-width: 768px) {
  .footer-content {
    flex-direction: row;
    justify-content: space-between;
  }
}

@media (max-width: 768px) {
  .footer {
    padding: 16px;
    margin-top: 30px;
  }
  
  .footer-content p {
    font-size: 13px;
  }
  
  .footer-links {
    gap: 8px;
  }
  
  .footer-separator {
    font-size: 12px;
  }
  
  .footer-link {
    font-size: 13px;
  }
}

/* Кнопка подтверждения в модальных окнах */
#confirm-button {
  width: 100%;
  box-shadow: none !important;
  transform: none !important;
}

#confirm-button:hover {
  box-shadow: none !important;
  transform: none !important;
}

/* ===== Skeleton загрузка ===== */
@keyframes skeleton-shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-hover) 50%, var(--bg-tertiary) 75%);
  background-size: 800px 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

.skeleton-post {
  background: var(--bg-primary);
  padding: 16px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  margin-bottom: 12px;
}

.skeleton-post .sk-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.skeleton-post .sk-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
}

.skeleton-post .sk-name {
  height: 13px;
  width: 120px;
  border-radius: 6px;
}

.skeleton-post .sk-time {
  height: 11px;
  width: 50px;
  border-radius: 6px;
  margin-left: auto;
}

.skeleton-post .sk-line {
  height: 13px;
  border-radius: 6px;
  margin-bottom: 8px;
}

.skeleton-post .sk-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.skeleton-post .sk-btn {
  height: 28px;
  width: 60px;
  border-radius: var(--radius-md);
}

/* Спиннер загрузки */
.flux-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
  gap: 16px;
}

.flux-spinner-ring {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-color);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* DM Chat */
#dm-chat-view {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 140px);
  position: relative;
  border-radius: var(--radius-lg);
}

/* Фоновый слой — за контентом, со скруглёнными углами */
.dm-bg-layer {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  z-index: 0;
  pointer-events: none;
  background-size: cover;
  background-position: center;
}

/* Когда фон активен — контент поверх слоя */
#dm-chat-view.has-bg .dm-chat-header-bar,
#dm-chat-view.has-bg .dm-messages-list,
#dm-chat-view.has-bg .dm-input-bar,
#dm-chat-view.has-bg .dm-typing-indicator {
  position: relative;
  z-index: 1;
}

/* Шапка должна быть выше всего чтобы дропдаун не перекрывался */
#dm-chat-view.has-bg .dm-chat-header-bar {
  z-index: 50;
}

#dm-chat-view.has-bg .dm-messages-list {
  background: transparent !important;
  z-index: 1;
}

#dm-chat-view.has-bg .dm-input-bar {
  background: rgba(0, 0, 0, 0.35);
  border-color: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

#dm-chat-view.has-bg .dm-chat-header-bar {
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.dm-messages-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 4px;
  scroll-behavior: smooth;
}

@media (max-width: 768px) {
  #dm-chat-view {
    height: calc(100dvh - 120px);
  }
  .dm-input-bar {
    flex-shrink: 0;
  }
}

.dm-messages-list::-webkit-scrollbar {
  width: 4px;
}

.dm-messages-list::-webkit-scrollbar-track {
  background: transparent;
}

.dm-messages-list::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.dm-input-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  padding: 6px 6px 6px 16px;
}

.dm-input-field {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  padding: 6px 0;
}

.dm-input-field::placeholder {
  color: var(--text-tertiary);
}

.dm-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
  transition: var(--transition);
}

.dm-send-btn:hover {
  background: var(--primary-hover);
  transform: scale(1.05);
}

.dm-send-btn:active {
  transform: scale(0.96);
}

/* Системные сообщения в разделе сообщений */
.sys-msg-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

.sys-msg-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.sys-msg-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sys-msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sys-msg-avatar span {
  color: white;
  font-weight: 700;
  font-size: 18px;
}

.sys-msg-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.sys-msg-name {
  font-weight: 600;
  font-size: 15px;
  color: var(--text-primary);
}

.sys-msg-time {
  color: var(--text-tertiary);
  font-size: 13px;
  font-weight: 500;
  margin-left: auto;
  white-space: nowrap;
}

.sys-msg-body {
  padding-left: 2px;
}

.sys-msg-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.sys-msg-content {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.sys-msg-expires {
  color: var(--text-tertiary);
  font-size: 12px;
  margin-top: 8px;
}

.sys-msg-card {
  transition: opacity 0.15s;
}
.sys-msg-card:hover {
  opacity: 0.8;
}
.sys-msg-preview {
  color: var(--text-tertiary);
  font-size: 13px;
  margin-top: 2px;
  padding-left: 52px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Бейдж непрочитанных сообщений в диалогах */
.dm-unread-badge {
  background: var(--danger);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  min-width: 20px;
  text-align: center;
  flex-shrink: 0;
}

/* Пузыри сообщений */
.dm-bubble {
  max-width: 75%;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
  cursor: default;
  user-select: text;
  -webkit-user-select: text;
  transition: transform 0.2s ease;
}

.dm-bubble-me {
  background: var(--primary);
  color: #fff;
  border-radius: 18px 18px 4px 18px;
}

.dm-bubble-them {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-radius: 18px 18px 18px 4px;
}

body.dark-theme .dm-bubble-them {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* Анимация появления нового сообщения */
@keyframes dm-msg-in {
  from { opacity: 0; transform: translateY(6px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Индикатор "печатает..." */
#dm-typing-indicator {
  display: none;
  padding: 4px 12px 6px;
}
.dm-typing-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-tertiary);
  font-size: 12px;
  font-weight: 500;
}
.dm-typing-dots {
  display: flex;
  align-items: center;
  gap: 3px;
}
.dm-typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-tertiary);
  animation: typing-bounce 1.2s infinite ease-in-out;
}
.dm-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.dm-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* Галочки прочтения */
.dm-ticks {
  display: inline-flex;
  align-items: center;
  margin-left: 2px;
}
.dm-ticks svg {
  width: 16px;
  height: 11px;
  fill: none;
  stroke: var(--text-tertiary);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.dm-ticks.dm-read svg {
  stroke: #4fc3f7;
}

/* Шапка чата */
.dm-chat-header-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--primary);
  border-radius: 16px;
  padding: 10px 14px;
  margin-bottom: 16px;
  position: relative;
}

.dm-back-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.85);
  cursor: pointer;
  font-size: 20px;
  padding: 0 4px;
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.15s;
}

.dm-back-btn:hover {
  color: #fff;
}

.dm-chat-avatar-sm {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: rgba(255,255,255,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 15px;
}

.dm-chat-avatar-sm img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.dm-chat-title {
  font-weight: 600;
  color: #fff;
  font-size: 15px;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Анимации чата */
@keyframes dm-slide-in {
  from { opacity: 0; transform: translateX(18px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes dm-slide-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(18px); }
}

@keyframes dm-list-in {
  from { opacity: 0; transform: translateX(-18px); }
  to   { opacity: 1; transform: translateX(0); }
}

#dm-chat-view {
  will-change: transform, opacity;
}

#dm-chat-view.dm-entering {
  animation: dm-slide-in 0.22s cubic-bezier(0.4, 0, 0.2, 1) both;
}

#dm-chat-view.dm-leaving {
  animation: dm-slide-out 0.18s cubic-bezier(0.4, 0, 0.2, 1) both;
  pointer-events: none;
}

#dm-conversations-list.dm-list-entering,
#messages-system-pinned.dm-list-entering {
  animation: dm-list-in 0.22s cubic-bezier(0.4, 0, 0.2, 1) both;
}

/* Отключаем анимации если пользователь предпочитает без них */
@media (prefers-reduced-motion: reduce) {
  #dm-chat-view.dm-entering,
  #dm-chat-view.dm-leaving,
  #dm-conversations-list.dm-list-entering,
  #messages-system-pinned.dm-list-entering {
    animation: none;
  }
}

/* ===== DM Reply (цитата) ===== */

/* Цитата внутри пузыря */
.dm-reply-quote {
  display: flex;
  align-items: stretch;
  gap: 8px;
  border-radius: 8px;
  padding: 6px 10px;
  margin-bottom: 6px;
  max-width: 100%;
  overflow: hidden;
}

.dm-reply-quote-me {
  background: rgba(255,255,255,0.18);
}

.dm-reply-quote-them {
  background: rgba(88,101,242,0.10);
}

.dm-reply-quote-line {
  width: 3px;
  border-radius: 3px;
  background: rgba(255,255,255,0.7);
  flex-shrink: 0;
}

.dm-reply-quote-them .dm-reply-quote-line {
  background: var(--primary);
}

.dm-reply-quote-name {
  font-size: 11px;
  font-weight: 700;
  opacity: 0.85;
  margin-bottom: 2px;
}

.dm-reply-quote-text {
  font-size: 12px;
  opacity: 0.75;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Панель ответа над инпутом */
#dm-reply-bar {
  padding: 6px 12px 0;
}

.dm-reply-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-secondary);
  border-radius: 10px;
  padding: 8px 10px;
  border-left: 3px solid var(--primary);
}

.dm-reply-preview-line {
  display: none;
}

.dm-reply-preview-text {
  flex: 1;
  min-width: 0;
}

.dm-reply-preview-name {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 2px;
}

.dm-reply-preview-content {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dm-reply-close {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  flex-shrink: 0;
}

.dm-reply-close:hover {
  color: var(--text-primary);
}

/* ===== Меню чата (троеточие) ===== */
.dm-menu-btn {
  background: transparent;
  border: none;
  outline: none;
  color: rgba(255,255,255,0.8);
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-left: auto;
  transition: background 0.15s, color 0.15s;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

.dm-menu-btn:hover,
.dm-menu-btn:active {
  background: rgba(255,255,255,0.15);
  color: #fff;
}

.dm-dropdown {
  position: fixed;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  min-width: 180px;
  z-index: 99999;
  overflow: hidden;
  animation: dropdown-in 0.15s cubic-bezier(0.4,0,0.2,1);
}

@keyframes dropdown-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.dm-dropdown button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  background: none;
  border: none;
  text-align: left;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.15s;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.dm-dropdown button:hover {
  background: var(--bg-hover);
}

/* position: relative теперь на .dm-chat-header-bar */

/* ===== Грид выбора фона ===== */
.chat-bg-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-top: 4px;
}

.chat-bg-item {
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 6px;
  border: 2px solid transparent;
  transition: border-color 0.15s, transform 0.15s;
  overflow: hidden;
}

.chat-bg-item:hover {
  transform: scale(1.05);
  border-color: var(--primary);
}

.chat-bg-item.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary);
}

.chat-bg-item span {
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.7);
  background: rgba(0,0,0,0.3);
  padding: 2px 6px;
  border-radius: 4px;
}

/* ===== Поиск нового чата ===== */
#new-chat-results {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.25s ease, opacity 0.2s ease;
  margin-top: 8px;
  border-radius: var(--radius-md);
}

#new-chat-results.open {
  max-height: 300px;
  overflow-y: auto;
  opacity: 1;
}

.new-chat-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s;
}

.new-chat-result-item:hover {
  background: var(--bg-hover);
}
