:root {
  --bg: #14151a;
  --bg-card: #1d1f26;
  --accent: #7c5cff;
  --text: #e8e8ee;
  --text-dim: #9a9aa8;
  --border: #2a2c35;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', Roboto, Arial, sans-serif;
}
a { color: inherit; text-decoration: none; }

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 24px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.logo { font-weight: 700; font-size: 20px; color: var(--accent); }
.mainnav { display: flex; gap: 16px; flex: 1; }
.mainnav a { color: var(--text-dim); padding: 6px 10px; border-radius: 6px; }
.mainnav a.active, .mainnav a:hover { color: var(--text); background: #26283155; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.badge { background: var(--accent); border-radius: 10px; padding: 1px 7px; font-size: 12px; margin-left: 4px; }
.username { color: var(--text-dim); }

.btn-primary, .btn-outline, .btn-link {
  border: none; cursor: pointer; font-size: 14px; border-radius: 8px; padding: 8px 16px;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-link { background: none; color: var(--text-dim); padding: 0; }

.container { max-width: 1100px; margin: 0 auto; padding: 24px; }

.filters { display: flex; gap: 20px; margin-bottom: 20px; flex-wrap: wrap; }
.filters label { display: flex; flex-direction: column; font-size: 13px; color: var(--text-dim); gap: 4px; }
.filters select { background: var(--bg-card); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; display: block; transition: transform .15s; }
.card:hover { transform: translateY(-3px); }
.card-media { position: relative; aspect-ratio: 1/1; background: #000; display: flex; align-items: center; justify-content: center; }
.card-media img, .card-media video { width: 100%; height: 100%; object-fit: cover; }
.audio-thumb { font-size: 40px; }
.tag-nsfw { position: absolute; top: 6px; right: 6px; background: #d33; color: #fff; font-size: 11px; padding: 2px 6px; border-radius: 4px; }
.card-body { padding: 10px; }
.card-title { margin: 0 0 6px; font-size: 14px; }
.card-meta { display: flex; gap: 10px; font-size: 12px; color: var(--text-dim); margin: 0 0 4px; }
.card-author { font-size: 12px; color: var(--accent); margin: 0; }
.empty { color: var(--text-dim); grid-column: 1/-1; text-align: center; padding: 40px 0; }

.load-more { text-align: center; margin-top: 24px; }

/* ===== Просмотр поста: попап и отдельная страница ===== */

.post-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10, 10, 14, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.post-overlay[hidden] { display: none; }
.post-overlay-content {
  width: 100%; max-width: 1100px; height: 100%; max-height: 100%;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px;
  overflow: hidden;
}

.post-standalone {
  height: calc(100vh - 140px);
  max-width: 1100px; margin: 0 auto;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px;
  overflow: hidden;
}

.post-modal-inner {
  position: relative;
  display: flex; flex-direction: row;
  height: 100%; width: 100%;
}

.post-close {
  position: absolute; top: 10px; right: 10px; z-index: 5;
  width: 34px; height: 34px; border-radius: 50%;
  background: #00000080; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; line-height: 1;
}
.post-close:hover { background: var(--accent); }

.post-loading {
  height: 100%; display: flex; align-items: center; justify-content: center;
  color: var(--text-dim); font-size: 15px;
}

.post-media-area {
  flex: 1 1 60%;
  min-width: 0;
  background: #000;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.post-media-area img,
.post-media-area video {
  max-width: 100%; max-height: 100%;
  width: auto; height: auto;
  object-fit: contain;
}
.post-media-area .audio-wrap {
  display: flex; flex-direction: column; align-items: center; gap: 20px; padding: 30px;
}
.post-media-area .audio-icon { font-size: 60px; }
.post-media-area audio { width: 280px; max-width: 100%; }

.post-side {
  flex: 0 0 360px;
  max-width: 360px;
  display: flex; flex-direction: column;
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 20px;
}
.post-info h1 { margin: 0 0 4px; font-size: 18px; }
.post-author, .post-meta { color: var(--text-dim); font-size: 13px; margin: 2px 0; }
.btn-like { margin-top: 10px; background: var(--bg); border: 1px solid var(--border); color: var(--text); border-radius: 20px; padding: 8px 18px; cursor: pointer; align-self: flex-start; }
.btn-like.liked { background: var(--accent); color: #fff; border-color: var(--accent); }

.post-owner-actions { display: flex; gap: 10px; margin-top: 12px; }
.btn-danger { background: transparent; border: 1px solid #d33; color: #ff6b6b; border-radius: 8px; padding: 8px 16px; cursor: pointer; font-size: 14px; }
.btn-danger:hover { background: #d3333322; }

.delete-form { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }

.existing-files { display: flex; flex-direction: column; gap: 10px; }
.field-label { font-size: 14px; color: var(--text-dim); margin-bottom: 4px; }
.file-row { flex-direction: row !important; align-items: center; gap: 10px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; padding: 8px; }
.file-row img, .file-row video { width: 50px; height: 50px; object-fit: cover; border-radius: 6px; }
.audio-thumb-small { font-size: 24px; width: 50px; text-align: center; }

.comments { margin-top: 20px; }
.comment-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.comment-form textarea { background: var(--bg); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 10px; min-height: 60px; }
.comment { border-top: 1px solid var(--border); padding: 12px 0; }
.comment.reply { margin-left: 24px; border-top: none; padding: 8px 0; }
.comment-author { color: var(--accent); font-size: 13px; margin: 0; }
.comment-text { margin: 4px 0; }

/* Мобильная адаптация: медиа сверху, инфо и комментарии снизу со своим скроллом */
@media (max-width: 760px) {
  .post-overlay { padding: 0; }
  .post-overlay-content, .post-standalone { border-radius: 0; max-width: 100%; height: 100vh; }
  .post-modal-inner { flex-direction: column; }
  .post-media-area { flex: 1 1 50%; max-height: 55vh; }
  .post-side { flex: 1 1 50%; max-width: 100%; border-left: none; border-top: 1px solid var(--border); }
  .post-standalone { height: 100vh; }
}

.form-page { max-width: 500px; margin: 0 auto; }
.form-page.narrow { max-width: 380px; }
.form-page form { display: flex; flex-direction: column; gap: 14px; }
.form-page label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--text-dim); }
.form-page input[type=text], .form-page input[type=email], .form-page input[type=password], .form-page select, .form-page input[type=file] {
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 10px;
}
.form-page .checkbox { flex-direction: row; align-items: center; gap: 8px; }
.error { color: #ff6b6b; }

.btn-twitch {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: #9146FF; color: #fff; border-radius: 8px; padding: 10px 16px;
  font-size: 14px; font-weight: 600; text-decoration: none;
}
.btn-twitch:hover { background: #7c3ce8; }
.btn-twitch-small { padding: 6px 12px; font-size: 13px; }
.divider { display: flex; align-items: center; text-align: center; color: var(--text-dim); font-size: 12px; margin: 16px 0; }
.divider::before, .divider::after { content: ''; flex: 1; border-bottom: 1px solid var(--border); }
.divider span { padding: 0 10px; }

.notif-item { border-bottom: 1px solid var(--border); padding: 12px 0; }
.notif-item.unread { background: #26283155; }

.footer { text-align: center; color: var(--text-dim); font-size: 13px; padding: 30px 0; }
.footer .made-by {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 8px; color: var(--text-dim); text-decoration: none;
}
.footer .made-by:hover { color: var(--accent); }
