* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  margin: 0;
  padding: 0;
  background-color: #eaf2f8;
  color: #1f2937;
}

.hidden {
  display: none !important;
}

/* Верхняя панель навигации */
.topbar {
  position: sticky;
  top: 0;
  z-index: 900;
  background-color: #ffffff;
  border-bottom: 1px solid #d5e2ed;
  box-shadow: 0 2px 8px rgba(24, 65, 98, 0.06);
}

.topbar-inner {
  max-width: 1080px;
  margin: auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.brand {
  font-size: 19px;
  font-weight: 800;
  color: #2b7bba;
}

.brand span {
  font-weight: 400;
  color: #64748b;
}

.nav-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.nav-tab {
  padding: 7px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #475569;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.nav-tab:hover {
  background-color: #f1f7fc;
  color: #2b7bba;
}

.nav-tab.active {
  background-color: #2b7bba;
  color: #ffffff;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background-color: #f8fafc;
  color: #334155;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.15s;
}

.icon-btn:hover {
  border-color: #2b7bba;
  background-color: #eef6fc;
  color: #2b7bba;
}

.logout-btn {
  font-size: 13px;
  font-weight: 600;
}

.battery-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  font-weight: 600;
  color: #2e7d32;
  padding: 0 4px;
}

.current-user-link {
  font-weight: 700;
  font-size: 14px;
  color: #2b7bba;
  cursor: pointer;
}

.current-user-link:hover {
  text-decoration: underline;
}

.btn-primary {
  padding: 8px 16px;
  background-color: #2b7bba;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:hover {
  background-color: #1d5fa7;
}

.full-width {
  width: 100%;
  padding: 11px;
  font-size: 15px;
}

/* Основной контейнер и фильтры комментариев */
.main-container {
  max-width: 760px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

.comments-filter-bar {
  background-color: #ffffff;
  padding: 12px 16px;
  margin-bottom: 16px;
  border-radius: 10px;
  border-left: 5px solid #2b7bba;
  box-shadow: 0 2px 6px rgba(24, 65, 98, 0.07);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-buttons,
.filter-target-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 6px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background-color: #f8fafc;
  color: #334155;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.filter-btn:hover {
  border-color: #2b7bba;
  color: #2b7bba;
}

.filter-btn.active {
  background-color: #2b7bba;
  border-color: #2b7bba;
  color: #ffffff;
}

.filter-input {
  padding: 6px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 13px;
  width: 165px;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: #334155;
  cursor: pointer;
  user-select: none;
}

/* Карточки постов и комментариев */
.post-card {
  background-color: #ffffff;
  padding: 18px 20px;
  margin-bottom: 16px;
  border-radius: 10px;
  border-left: 5px solid #2b7bba;
  box-shadow: 0 2px 6px rgba(24, 65, 98, 0.07);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  display: flex;
  flex-direction: column;
  content-visibility: auto;
  contain-intrinsic-size: 180px;
}

.post-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(24, 65, 98, 0.13);
  border-left-color: #1d5fa7;
}

.card-main {
  display: flex;
  gap: 16px;
}

.thumb {
  width: 110px;
  height: 110px;
  object-fit: cover;
  border-radius: 10px;
  flex-shrink: 0;
  background-color: #dce7f0;
}

.card-content {
  flex: 1;
  min-width: 0;
}

.meta {
  font-size: 13px;
  color: #64748b;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.author-link {
  font-weight: 700;
  color: #2b7bba;
  cursor: pointer;
}

.author-link:hover {
  text-decoration: underline;
}

.comment-badge {
  background-color: #eef6fc;
  color: #2b7bba;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}

.title {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 8px;
  color: #0f172a;
}

.excerpt {
  font-size: 14px;
  color: #475569;
  line-height: 1.45;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid #edf2f7;
  font-size: 13px;
  color: #5c6f82;
  flex-shrink: 0; /* Запрещаем сжиматься */
  width: 100%;    /* Занимаем всю ширину */
  box-sizing: border-box;
}

.card-stats {
  display: flex;
  align-items: center;
  gap: 14px;
}

.payout-badge {
  font-weight: 700;
  color: #2e7d32;
}

.payout-badge.declined {
  color: #8898aa;
  font-weight: 400;
}

.like-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 16px;
  background-color: #ffffff;
  color: #334155;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.like-btn:hover {
  border-color: #2b7bba;
  color: #2b7bba;
  background-color: #f4f8ff;
}

.like-btn.liked {
  border-color: #2b7bba;
  background-color: #2b7bba;
  color: #ffffff;
}

#loader {
  text-align: center;
  padding: 22px;
  color: #5c6f82;
  font-weight: 600;
}

/* Плавающая кнопка «Наверх» */
.scroll-top-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background-color: #2b7bba;
  color: #ffffff;
  font-size: 18px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(24, 65, 98, 0.25);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.2s, transform 0.2s, background-color 0.15s;
  z-index: 850;
}

.scroll-top-btn.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.scroll-top-btn:hover {
  background-color: #1d5fa7;
}

/* Всплывающая подсказка Toast */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background-color: #1e293b;
  color: #ffffff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 2000;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Общий оверлей модальных окон */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.65);
  z-index: 1000;
  overflow-y: auto;
  padding: 28px 16px;
}

.modal-overlay.open {
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

/* Окно чтения поста с внешней кнопкой закрытия справа */
.reader-wrapper {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 12px;
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
}

.reader-box {
  background-color: #ffffff;
  flex: 1;
  max-width: 760px;
  padding: 28px 32px;
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
  min-width: 0;
}

.reader-outside-close {
  position: sticky;
  top: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background-color: #ffffff;
  color: #1e293b;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s, color 0.15s;
}

.reader-outside-close:hover {
  background-color: #ef4444;
  color: #ffffff;
}

@media (max-width: 640px) {
  .reader-wrapper {
    flex-direction: column-reverse;
    align-items: flex-end;
  }
  .reader-box {
    width: 100%;
    padding: 20px;
  }
}

/* Форматирование текста внутри поста */
.post-body {
  line-height: 1.65;
  font-size: 16px;
  margin-top: 18px;
  word-wrap: break-word;
}

.post-body img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 14px 0;
  display: block;
}

.post-body .pull-right {
  float: right;
  max-width: 50%;
  margin: 4px 0 12px 18px;
}

.post-body .pull-left {
  float: left;
  max-width: 50%;
  margin: 4px 18px 12px 0;
}

.post-body .text-justify {
  text-align: justify;
}

.post-body .text-center {
  text-align: center;
}

.post-body::after {
  content: "";
  display: table;
  clear: both;
}

.post-body blockquote {
  border-left: 4px solid #2b7bba;
  margin: 12px 0;
  padding: 6px 14px;
  color: #475569;
  background-color: #f8fafc;
}

.post-body a {
  color: #2b7bba;
}

.mention-in-text {
  color: #2b7bba;
  font-weight: 600;
  cursor: pointer;
}

.mention-in-text:hover {
  text-decoration: underline;
}

.tags {
  margin-top: 22px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  background-color: #eef6fc;
  color: #2b7bba;
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 13px;
}

/* Стандартные модальные окна */
.modal-card {
  background-color: #ffffff;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
  width: 100%;
  margin: auto 0;
}

.small-modal {
  max-width: 420px;
}

.medium-modal {
  max-width: 560px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 12px;
}

.modal-header h3 {
  margin: 0;
  font-size: 18px;
  color: #0f172a;
}

.modal-close-x {
  background: none;
  border: none;
  font-size: 20px;
  color: #64748b;
  cursor: pointer;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 14px;
}

.error-text {
  color: #dc2626;
  font-size: 13px;
  margin-bottom: 12px;
  min-height: 18px;
}

/* Мини-профиль автора */
.profile-head-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.profile-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  background-color: #dce7f0;
}

.profile-sub {
  font-size: 12px;
  color: #64748b;
}

.profile-posts-list {
  max-height: 60vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.profile-post-item {
  padding: 10px 12px;
  border-radius: 8px;
  background-color: #f8fafc;
  border-left: 3px solid #2b7bba;
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
  cursor: pointer;
}

.profile-post-item:hover {
  background-color: #eef6fc;
  color: #2b7bba;
}

/* Модалка лайка и доната */
.label-between {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 8px;
}

.range-slider {
  width: 100%;
  accent-color: #2b7bba;
  cursor: pointer;
}

.donate-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tip-badge {
  font-size: 13px;
  color: #475569;
  white-space: nowrap;
  background-color: #f1f5f9;
  padding: 9px 10px;
  border-radius: 8px;
}

.preset-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.preset-btn {
  flex: 1;
  padding: 6px 0;
  border: 1px solid #cbd5e1;
  background-color: #f8fafc;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
}

.preset-btn:hover,
.preset-btn.active {
  background-color: #2b7bba;
  color: #ffffff;
  border-color: #2b7bba;
}

.placeholder-note {
  color: #475569;
  font-size: 14px;
  line-height: 1.5;
  margin: 0;
}

.share-menu {
  position: fixed;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 3000;
  padding: 5px 0;
  min-width: 180px;
}

.share-option {
  padding: 8px 15px;
  cursor: pointer;
  font-size: 14px;
  color: #334155;
  transition: background 0.15s;
}

.share-option:hover {
  background: #eef6fc;
  color: #2b7bba;
}

/* Окно чтения поста всегда поверх модального окна профиля автора */

#reader-modal {
  z-index: 1050;
}

.profile-loader {
  text-align: center;
  padding: 12px;
  font-size: 13px;
  color: #64748b;
  font-weight: 600;
}

#like-modal {
  z-index: 1100;
}

#reply-modal {
  z-index: 1100;
}

#profile-modal {
  z-index: 1000;
}

#votes-modal{
  z-index: 1100;
}

/*вложенность комментариев*/

/* Комментарии */
.comments-section {
  margin-top: 30px;
  border-top: 1px solid #edf2f7;
  padding-top: 20px;
}

.comment-item {
  margin-bottom: 12px;
  padding: 10px 15px;
  background-color: #f8fafc;
  border-radius: 8px;
  border-left: 3px solid #2b7bba;
  word-wrap: break-word;
  min-width: 250px;
  box-sizing: border-box;
}

.comment-header {
  font-size: 14px;
  color: #555;
  margin-bottom: 5px;
}

.comment-header b {
  color: #2b7bba;
  cursor: pointer;
}

.comment-body {
  font-size: 15px;
  line-height: 1.5;
  margin-bottom: 10px;
}

.comment-body img {
  max-width: 100%;
  border-radius: 4px;
}

.comment-replies {
  margin-top: 10px;
  padding-left: 15px;
  border-left: 2px solid #d0e1f0;
}

/* Плоский вывод для глубоких уровней (4+) */
.comment-replies .comment-replies .comment-replies .comment-item {
  /* Больше никаких отступов */
}

/* Кнопки внутри комментариев */
.comment-item .filter-btn {
  font-size: 12px;
  padding: 4px 10px;
}

.post-card.unread {
  border-left: 5px solid #c0392b; /* Красная полоса слева */
  background-color: #fff8f8; /* Легкий розовый фон */
}

.wallet-block {
  transition: background 0.15s;
}
.wallet-block:hover {
  background: #eef6fc;
}
.wallet-block button {
  font-size: 13px;
  padding: 6px 10px;
}

.feedback-btn {
  position: fixed;
  bottom: 24px;
  left: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background-color: #2b7bba;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(24, 65, 98, 0.25);
  z-index: 850;
  transition: background-color 0.15s, transform 0.15s;
}
.feedback-btn:hover {
  background-color: #1d5fa7;
  transform: translateY(-2px);
}