@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --bg: #FFFFFF;
  --bg-alt: #F6F7F8;
  --ink: #1A1D1F;
  --muted: #6B7A85;
  --accent: #2685D9;
  --accent-dark: #1E6BB3;
  --border: #E4E7EA;
  --radius: 6px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

.wrap {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- header ---------- */
.site-header {
  background: #10151A;
  border-bottom: 3px solid var(--accent);
}

.site-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.site-header-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  row-gap: 10px;
  padding-top: 16px;
  padding-bottom: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 14px;
  font-weight: 700;
  font-size: 24px;
  letter-spacing: -0.3px;
  text-decoration: none;
  color: #fff;
  flex-shrink: 0;
}

.logo-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center 20%;
  border: 2px solid var(--accent);
  flex-shrink: 0;
}

.logo span { color: var(--accent); }
.logo-text { white-space: nowrap; }
.logo-accent { color: var(--accent); }

.btn {
  display: inline-block;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 14px;
  padding: 9px 18px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

.btn-coral { background: var(--accent); color: #fff; }
.btn-coral:hover { background: var(--accent-dark); }
.btn-outline {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--border);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

.site-header .btn-outline {
  color: #fff;
  border-color: rgba(255,255,255,0.35);
}
.site-header .btn-outline:hover {
  border-color: #fff;
  color: #fff;
}

/* ---------- nav ---------- */
.nav {
  display: flex;
  gap: 18px;
  align-items: center;
  font-size: 14px;
  font-weight: 500;
  flex-wrap: wrap;
  row-gap: 8px;
}

.nav a { text-decoration: none; color: rgba(255,255,255,0.75); }
.nav a:hover { color: #fff; }
.nav .pill {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 20px;
  background: rgba(255,255,255,0.1);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
}
.nav .user-box { display: flex; align-items: center; gap: 10px; }

/* ---------- hero ---------- */
.hero {
  position: relative;
  height: 520px;
  margin-bottom: 8px;
  border-radius: var(--radius);
  overflow: hidden;
  background: #10151A;
  display: flex;
  align-items: flex-end;
}

.hero-bg-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center top;
  opacity: 0.85;
}

.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(16,21,26,0.15) 0%, rgba(16,21,26,0.75) 100%);
}

.hero-inner {
  position: relative;
  z-index: 1;
  padding: 0 24px 32px;
  width: 100%;
}

.hero-eyebrow {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12.5px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #8FC4F2;
  margin-bottom: 10px;
}

.hero h1 {
  font-weight: 700;
  font-size: 38px;
  line-height: 1.15;
  margin: 0 0 12px;
  max-width: 640px;
  color: #fff;
}

.hero p {
  max-width: 520px;
  font-size: 15.5px;
  line-height: 1.6;
  color: rgba(255,255,255,0.78);
  margin: 0 0 22px;
}

/* ---------- posts grid (бывшие открытки) ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
  padding: 8px 0 56px;
}

.postcard {
  background: var(--bg);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--ink);
  display: block;
  border: 1px solid var(--border);
  overflow: hidden;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.postcard:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 10px rgba(38,133,217,0.12);
}

.postcard-airmail { display: none; }

.postcard-cover {
  height: 160px;
  background: var(--bg-alt);
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-position: center;
  display: flex;
  align-items: flex-end;
  border-bottom: 1px solid var(--border);
}

.postcard-cover.empty {
  background: linear-gradient(135deg, #EEF2F5, #E4E9ED);
}

.postcard-stamp {
  margin: 10px 10px 0 auto;
  min-width: 30px;
  height: 26px;
  padding: 0 8px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: #fff;
  background: rgba(26,29,31,0.65);
}

.postcard-body { padding: 14px 16px 16px; }

.postcard-title {
  font-weight: 600;
  font-size: 17px;
  margin: 0 0 6px;
  color: var(--ink);
}

.postcard-desc {
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.5;
  margin: 0 0 10px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.postcard-meta {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11.5px;
  letter-spacing: 0.3px;
  color: var(--accent);
}

.empty-state {
  padding: 56px 20px;
  text-align: center;
  color: var(--muted);
}

/* ---------- forms ---------- */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  max-width: 500px;
  margin: 40px auto;
}

.card h1 {
  font-size: 22px;
  margin-top: 0;
  font-weight: 700;
}

label {
  display: block;
  font-weight: 600;
  font-size: 13px;
  margin: 16px 0 6px;
  color: var(--ink);
}

input[type=text], textarea, input[type=file] {
  width: 100%;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
}

input[type=text]:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

textarea { resize: vertical; min-height: 80px; }

.form-error {
  background: #FDECEC;
  color: #B3261E;
  border: 1px solid #F3C3C0;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13.5px;
  margin-bottom: 6px;
}

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

/* ---------- topic/post page ---------- */
.topic-header { padding: 32px 0 16px; }
.topic-header .hero-eyebrow { color: var(--accent); margin-bottom: 6px; }

.topic-header h1 {
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 8px;
}

.topic-header p {
  color: var(--muted);
  max-width: 600px;
  line-height: 1.6;
}

.upload-card {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 20px 0 36px;
}

.upload-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.upload-row > div { flex: 1; min-width: 200px; }

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 20px;
  padding-bottom: 56px;
}

.media-item {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: #EEF1F3;
  border: 1px solid var(--border);
}

.media-item img, .media-item video {
  width: 100%;
  max-height: 620px;
  height: auto;
  object-fit: contain;
  background: #0D0F11;
  display: block;
  cursor: zoom-in;
}

.media-item video { cursor: default; }

/* ---------- lightbox ---------- */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10,12,14,0.92);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 30px;
}
.lightbox.open { display: flex; }

.lightbox img {
  max-width: 100%;
  max-height: 82vh;
  object-fit: contain;
  border-radius: 4px;
}

.lightbox-bar {
  display: flex;
  gap: 12px;
  margin-top: 18px;
}

.lightbox-close {
  position: absolute;
  top: 22px;
  right: 28px;
  background: none;
  border: none;
  color: #fff;
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
}

.media-caption {
  padding: 8px 10px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--muted);
  background: var(--bg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.media-caption form { margin: 0; }
.media-caption button {
  background: none;
  border: none;
  color: #C0392B;
  cursor: pointer;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  padding: 0;
}
.media-caption button:hover { text-decoration: underline; }

/* ---------- forum banner ---------- */
.forum-banner {
  width: 100%;
  max-height: 160px;
  object-fit: cover;
  object-position: center 20%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-top: 20px;
  display: block;
}

/* ---------- forum list (habr-like rows) ---------- */
.forum-list { padding: 8px 0 56px; display: flex; flex-direction: column; gap: 12px; }

.forum-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  text-decoration: none;
  color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.forum-row:hover {
  border-color: var(--accent);
  box-shadow: 0 3px 12px rgba(0,0,0,0.08);
  transform: translateY(-1px);
}

.forum-row:hover .forum-row-title { color: var(--accent); }

.forum-row-badge {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--ink);
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  line-height: 1.1;
  flex-shrink: 0;
}
.forum-row-badge b { font-size: 15px; }
.forum-row-badge span { font-size: 9px; opacity: 0.7; text-transform: uppercase; color: var(--muted); }

.forum-row-title { font-weight: 600; font-size: 17px; margin: 0 0 4px; }
.forum-row-meta { font-family: 'IBM Plex Mono', monospace; font-size: 11.5px; color: var(--muted); }

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 32px 0 8px;
  flex-wrap: wrap;
}

.page-header h1 { font-size: 26px; font-weight: 700; margin: 0; }

/* ---------- thread ---------- */
.thread-body {
  font-size: 15px;
  line-height: 1.7;
  padding: 10px 0 20px;
  white-space: pre-wrap;
}

.comments-title {
  font-size: 19px;
  font-weight: 700;
  border-top: 1px solid var(--border);
  padding-top: 22px;
  margin-top: 18px;
}

.comment { display: flex; gap: 12px; padding: 16px 0; border-bottom: 1px solid var(--border); }

.comment-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}

.comment-head { display: flex; gap: 10px; align-items: baseline; font-size: 13px; margin-bottom: 6px; }
.comment-author { font-weight: 600; }
.comment-time { color: var(--muted); font-family: 'IBM Plex Mono', monospace; font-size: 11.5px; }
.comment-text { font-size: 14.5px; line-height: 1.6; white-space: pre-wrap; }

.comment-image {
  max-width: 320px;
  border-radius: var(--radius);
  margin-top: 10px;
  display: block;
  border: 1px solid var(--border);
}

.comment-form {
  margin-top: 12px;
  padding: 16px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.comment-form textarea { min-height: 70px; }
.comment-form .upload-row { margin-top: 10px; align-items: center; }
.comment-form input[type=file] { padding: 8px; font-size: 13px; }

.delete-link {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: #C0392B;
  background: none;
  border: none;
  cursor: pointer;
}

/* ---------- auth pages ---------- */
.auth-hint { font-size: 13.5px; color: var(--muted); margin-top: 16px; }
.auth-hint a { color: var(--accent); font-weight: 600; text-decoration: none; }

.badge-admin {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  background: var(--accent);
  color: #fff;
  padding: 2px 6px;
  border-radius: 3px;
  vertical-align: middle;
  margin-left: 6px;
}

table.users-table { width: 100%; border-collapse: collapse; margin-top: 20px; font-size: 14px; }
table.users-table th, table.users-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
table.users-table th { font-family: 'IBM Plex Mono', monospace; font-size: 11px; text-transform: uppercase; color: var(--muted); }

.tag { font-family: 'IBM Plex Mono', monospace; font-size: 11px; padding: 3px 8px; border-radius: 20px; display: inline-block; }
.tag-admin { background: var(--accent); color: #fff; }
.tag-user { background: var(--bg-alt); color: var(--ink); border: 1px solid var(--border); }
.tag-yes { background: #E4F3E1; color: #2E7D32; }
.tag-no { background: var(--bg-alt); color: var(--muted); border: 1px solid var(--border); }

.audio-item { padding: 16px; }
.audio-item audio { width: 100%; margin-top: 6px; }

footer {
  text-align: center;
  padding: 30px 0 50px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--muted);
}

@media (max-width: 560px) {
  .hero h1 { font-size: 28px; }
  .site-header .wrap { flex-direction: column; gap: 14px; align-items: flex-start; }
}

/* ---------- search & pagination ---------- */
.search-row {
  display: flex;
  gap: 10px;
  margin: 20px 0 4px;
}

.search-input {
  flex: 1;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
}
.search-input:focus { outline: none; border-color: var(--accent); }

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 8px 0 48px;
}

.pagination-info {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12.5px;
  color: var(--muted);
}

/* ---------- cover upload preview ---------- */
.cover-preview {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 12px;
  display: block;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 13.5px;
  color: var(--muted);
}
.checkbox-row input { width: auto; }

.owner-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

/* ---------- home landing ---------- */
.hero-home {
  height: 620px;
}

.hero-cta-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.btn-big {
  font-size: 16px;
  padding: 15px 30px;
}

.btn-outline-light {
  background: transparent;
  color: #fff;
  border: 1.5px solid rgba(255,255,255,0.55);
}
.btn-outline-light:hover {
  border-color: #fff;
  background: rgba(255,255,255,0.08);
}

@media (max-width: 560px) {
  .hero-home { height: 520px; }
  .logo { font-size: 19px; gap: 10px; }
  .logo-avatar { width: 38px; height: 38px; }
}

/* ---------- forum replies ---------- */
.comment-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.comment-images .comment-image {
  max-width: 220px;
  margin-top: 0;
}

.comment-actions {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-top: 8px;
}

.reply-toggle {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
}

.reply-form {
  margin-top: 10px;
  padding: 12px;
  background: var(--bg-alt);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.reply-form textarea { min-height: 50px; }

.comment-replies {
  border-left: 2px solid var(--border);
  margin-top: 10px;
  padding-left: 4px;
}

/* ================= ТЕМЫ ================= */
body { transition: background-color .15s ease, color .15s ease; }

html[data-theme="dark"] {
  --bg: #12161A;
  --bg-alt: #1B2126;
  --ink: #E7ECEF;
  --muted: #8B98A3;
  --accent: #4DA3FF;
  --accent-dark: #2C86E0;
  --border: #2A3138;
}

html[data-theme="light"] {
  --bg: #FAFBF9;
  --bg-alt: #EEF5F1;
  --ink: #1B2622;
  --muted: #5F7A70;
  --accent: #0E9F6E;
  --accent-dark: #0B7A54;
  --border: #DCEAE2;
}

html[data-theme="red"] {
  --bg: #FFFFFF;
  --bg-alt: #FBF1EF;
  --ink: #2A1512;
  --muted: #8A6A66;
  --accent: #E1483A;
  --accent-dark: #BE3A2F;
  --border: #F0DAD7;
}

.theme-switcher {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-right: 6px;
}

.theme-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.3);
  cursor: pointer;
  padding: 0;
}
.theme-dot:hover { border-color: #fff; }
.theme-dot.active { border-color: #fff; box-shadow: 0 0 0 2px var(--accent); }

.theme-dot-default { background: linear-gradient(135deg, #2685D9 50%, #fff 50%); }
.theme-dot-light { background: linear-gradient(135deg, #0E9F6E 50%, #FAFBF9 50%); }
.theme-dot-dark { background: linear-gradient(135deg, #4DA3FF 50%, #12161A 50%); }
.theme-dot-red { background: linear-gradient(135deg, #E1483A 50%, #fff 50%); }

/* ================= АВАТАРКИ, ЗВАНИЯ, ПРОФИЛЬ ================= */
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(255,255,255,0.3);
}

.profile-header {
  display: flex;
  gap: 20px;
  align-items: center;
  padding: 32px 0 8px;
  flex-wrap: wrap;
}

.profile-avatar-big {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  background: var(--bg-alt);
}

.rank-badge {
  display: inline-block;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11.5px;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--accent);
  color: #fff;
  margin-top: 6px;
}

.profile-stats {
  display: flex;
  gap: 24px;
  padding: 20px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin: 12px 0 24px;
}
.profile-stat-num { font-size: 22px; font-weight: 700; }
.profile-stat-label { font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--muted); text-transform: uppercase; }

.author-link { text-decoration: none; color: inherit; }
.author-link:hover { color: var(--accent); }

.blocked-badge {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  background: #C0392B;
  color: #fff;
  padding: 2px 6px;
  border-radius: 3px;
  margin-left: 6px;
}

/* ================= ЛС ================= */
.conversation-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--ink);
}
.conversation-row .user-avatar { width: 44px; height: 44px; border-color: var(--border); }
.conversation-name { font-weight: 600; font-size: 15px; }
.conversation-preview { font-size: 13px; color: var(--muted); max-width: 400px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-unread {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
}

.dm-bubble {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: 12px;
  margin-bottom: 10px;
  font-size: 14.5px;
  line-height: 1.5;
}
.dm-bubble.mine { background: var(--accent); color: #fff; margin-left: auto; }
.dm-bubble.theirs { background: var(--bg-alt); border: 1px solid var(--border); }
.dm-bubble img { max-width: 100%; border-radius: 8px; margin-top: 6px; display: block; }
.dm-bubble audio { width: 100%; margin-top: 6px; }
.dm-time { font-family: 'IBM Plex Mono', monospace; font-size: 10px; opacity: 0.7; margin-top: 4px; }

.nav-badge {
  background: var(--accent);
  color: #fff;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: 4px;
}

/* ================= НОВОСТИ ================= */
.news-row {
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
}
.news-row h2 { font-size: 20px; margin: 0 0 6px; }
.news-row a { text-decoration: none; color: var(--ink); }
.news-row a:hover { color: var(--accent); }
.news-body { font-size: 15px; line-height: 1.7; white-space: pre-wrap; padding: 16px 0 40px; }

/* ---------- admin subnav ---------- */
.admin-subnav {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin: 16px 0 28px;
}
.admin-subnav-tab {
  padding: 10px 16px;
  text-decoration: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.admin-subnav-tab:hover { color: var(--ink); }
.admin-subnav-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
