/* Base variables */
:root {
  --bg: #ffffff;
  --bg-sec: #e5e9ef;
  --bg-elev: #f5f7fa;
  --text: #1b1f23;
  --muted: #586069;
  --primary: #2563eb;
  --primary-contrast: #ffffff;
  --border: #d0d7de;
  --shadow: rgba(31, 41, 55, 0.08);
  --color-block-1: #f9f9f9;
  --color-block-2: #eef6ff;
  --color-block-3: #fff8e1;
  
  --alert-info-bg: #e8f4fd;
  --alert-info-text: #084c61;

  --alert-success-bg: #e6f9ed;
  --alert-success-text: #0f5132;

  --alert-warning-bg: #fff4e5;
  --alert-warning-text: #664d03;

  --alert-error-bg: #fde8e8;
  --alert-error-text: #842029;
  
  --btn-primary-bg: #2563eb;
  --btn-primary-text: #fff;

  --btn-success-bg: #238636;
  --btn-success-text: #fff;

  --btn-warning-bg: #f59e0b;
  --btn-warning-text: #fff;

  --btn-error-bg: #dc2626;
  --btn-error-text: #fff;

  --radius: 0.25rem;
  --radius-sm: 3px;
  --radius-xx: 50%;
  --space-1: 6px;
  --space-2: 10px;
  --space-3: 14px;
  --space-4: 18px;
  --space-5: 24px;
  --font-size-title: 0.8rem;
  --font-size-meta: 0.7rem;
  --font-size-sm: 0.65rem;
  --max-width: 1150px;
  --text-shadow: rgba(0, 0, 0, 0.2) 0px 2px 4px;

  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}

html[data-theme="dark"] {
  --bg: #0b0f14;
  --bg-sec: #2e394c;
  --bg-elev: #11161d;
  --text: #e6edf3;
  --muted: #9aa7b4;
  --primary: #3b82f6;
  --primary-contrast: #0b0f14;
  --border: #1f2937;
  --shadow: rgba(0, 0, 0, 0.35);
  --color-block-1: #1e1e1e;
  --color-block-2: #0d253f;
  --color-block-3: #3a2a00;
  
  --alert-info-bg: #0d253f;
  --alert-info-text: #a3d5ff;

  --alert-success-bg: #0f2f1d;
  --alert-success-text: #9be7c4;

  --alert-warning-bg: #3a2a00;
  --alert-warning-text: #ffd27f;

  --alert-error-bg: #3f0d0d;
  --alert-error-text: #ffb3b3;
  
  --btn-primary-bg: #3b82f6;
  --btn-primary-text: #111;

  --btn-success-bg: #238636;
  --btn-success-text: #111;

  --btn-warning-bg: #fbbf24;
  --btn-warning-text: #111;

  --btn-error-bg: #ef4444;
  --btn-error-text: #111;
}

*,
*::before,
*::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--font-size-body);
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
  text-shadow: var(--text-shadow);
}

a { text-decoration: none; color: var(--text); }
a::hover { color: var(--primary); }

h1 { font-size: var(--font-size-h1); }
h2 { font-size: var(--font-size-h2); }
h3 { font-size: var(--font-size-h3); }

figure {
  margin: 1rem 0;
  text-align: center; /* выравнивание содержимого */
}
figcaption {
  font-size: 0.875rem;
  color: var(--muted);
  margin-top: 0.0rem;
}

/* Utilities */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Базовые утилиты */
.hidden {
  display: none !important;
}
.visible {
  display: block !important;
}

/* Скрыть только на мобильных (≤480px) */
@media (max-width: 480px) {
  .hidden-mobile {
    display: none !important;
  }
  .visible-mobile {
    display: block !important;
  }
}

/* Скрыть на планшетах (≤768px) */
@media (max-width: 768px) {
  .hidden-sm {
    display: none !important;
  }
  .visible-sm {
    display: block !important;
  }
}

/* Показать/скрыть на средних (769–1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
  .hidden-md {
    display: none !important;
  }
  .visible-md {
    display: block !important;
  }
}

/* Скрыть/показать на десктопах (≥1025px) */
@media (min-width: 1025px) {
  .hidden-desktop {
    display: none !important;
  }
  .visible-desktop {
    display: block !important;
  }
}

/* Header */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.1rem;
}

.brand i { color: var(--primary); }

/* Nav and dropdown */
.nav .nav-list {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  list-style: none;
  padding: 0; margin: 0;
}

.nav-item > a,
.dropdown-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  color: var(--text);
  text-decoration: none;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
}

.nav-item > a:hover,
.dropdown-toggle:hover {
  background: var(--bg);
  border-color: var(--border);
}

.dropdown { position: relative; }

.dropdown .dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 220px;
  padding: var(--space-2) 0;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px var(--shadow);
  list-style: none;
  margin: 0;
  display: none;
}

.dropdown.open .dropdown-menu { display: block; }

.dropdown .dropdown-menu li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  color: var(--text);
  text-decoration: none;
}

.dropdown .dropdown-menu li a:hover {
  background: var(--bg);
}

.dropdown .dropdown-menu .divider {
  height: 1px;
  margin: 6px 0;
  background: var(--border);
}

.caret { margin-left: 4px; font-size: 0.9em; }

/* Search */
.search {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  overflow: hidden;
}
.search input {
  border: none; outline: none;
  background: transparent;
  color: var(--text);
  padding: 8px 10px;
  min-width: 220px;
}
.search button {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 8px 10px;
  cursor: pointer;
}
.search button:hover { color: var(--text); }

/* Theme toggle */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.theme-toggle:hover { box-shadow: 0 4px 14px var(--shadow); }

/* Userbox */
.userbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  position: relative;
}
.userbox .avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
}
.userbox .username { font-weight: 600; }
.userbox .user-dropdown-toggle {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 6px 8px;
}
.userbox .dropdown-menu {
  position: absolute;
  right: 0; top: calc(100% + 6px);
  min-width: 200px;
  padding: var(--space-2) 0;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px var(--shadow);
  list-style: none;
  margin: 0;
  display: none;
}
.userbox.open .dropdown-menu { display: block; }
.userbox .dropdown-menu li a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; color: var(--text); text-decoration: none;
}
.userbox .dropdown-menu li a:hover { background: var(--bg); }
.userbox .dropdown-menu .divider {
  height: 1px; margin: 6px 0; background: var(--border);
}

/* Layout */
.layout {
  display: flex;
  gap: var(--space-4);
  align-items: flex-start;
  padding: var(--space-4);
}
.sidebar {
  flex: 0 0 260px;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.content {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.wrapper {
  max-width: var(--max-width);
  margin: 0 auto;
}

/* Blocks */
.block {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 6px 20px var(--shadow);
  overflow: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Разные цвета для разных блоков */
.block.block-1 { background: var(--color-block-1); }
.block.block-2 { background: var(--color-block-2); }
.block.block-3 { background: var(--color-block-3); }

.block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4);
  border-bottom: 1px solid var(--border);
}
.block-header h2 {
  margin: 0;
  font-size: 1.1rem;
  display: inline-flex; align-items: center; gap: 10px;
}
.block-actions .btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.block-actions .btn:hover { box-shadow: 0 4px 14px var(--shadow); }

/* Forums list */
.forums-list {
  list-style: none;
  margin: 0; padding: 0;
}
.forum-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: var(--space-4);
  border-bottom: 1px solid var(--border);
}
.forum-item:last-child { border-bottom: none; }
.forum-title {
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: var(--font-size-meta);
}
.forum-title:hover { color: var(--primary); }
.forum-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 0.95rem;
  font-size: var(--font-size-meta);
}

/* Dropnav in sidebar */
.dropnav { position: relative; }
.dropnav-toggle {
  width: auto;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin: var(--space-4);
}
.dropnav-menu {
  list-style: none;
  margin: 0 var(--space-4) var(--space-4);
  padding: var(--space-2) 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev);
  box-shadow: 0 10px 30px var(--shadow);
  display: none;
}
.dropnav.open .dropnav-menu { display: block; }
.dropnav-menu li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  color: var(--text);
  text-decoration: none;
}
.dropnav-menu li a:hover { background: var(--bg); }
.dropnav-menu .divider {
  height: 1px; margin: 6px 0; background: var(--border);
}

/* Topics list */
.topics-list {
  list-style: none;
  margin: 0; padding: 0;
}
.topic-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: var(--space-4);
  border-bottom: 1px solid var(--border);
}
.topic-item:last-child { border-bottom: none; }

.topic-left .avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
}

.topic-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}
.topic-title {
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.90rem;
}
.topic-title:hover { color: var(--primary); }
.topic-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
  font-size: 0.75rem;
}
.topic-meta strong { font-weight: 700; }

.topic-right .badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.7rem;
}

/* Info block */
.info-block .info-content {
  padding: var(--space-4);
  color: var(--muted);
}

/* Footer */
.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4);
  border-top: 1px solid var(--border);
  color: var(--muted);
}
.site-footer a {
  color: var(--muted);
  text-decoration: none;
  margin-left: 12px;
}
.site-footer a:hover { color: var(--text); }

/* Responsive */
@media (max-width: 1080px) {
  .sidebar { flex-basis: 280px; }
}

@media (max-width: 860px) {
  .layout, .site-header, .content {
    flex-direction: column;
    display: block;
  }
  .sidebar { flex-basis: auto; }
}

@media (max-width: 560px) {
  .header-left { flex-wrap: wrap; }
  .search input { min-width: 140px; }
  .topic-item { align-items: flex-start; }
  .topic-right { align-self: flex-start; }
}
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: var(--space-3) var(--space-4);
  font-size: 0.95rem;
  color: var(--muted);
}
.breadcrumbs a {
  color: var(--text);
  text-decoration: none;
}
.breadcrumbs a:hover { color: var(--primary); }

.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: var(--space-4);
}
.pagination .page {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
}
.pagination .page.active {
  background: var(--primary);
  color: var(--primary-contrast);
}
.pagination .page:hover { box-shadow: 0 4px 12px var(--shadow); }
.pagination .dots { align-self: center; }

.topic-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
}
.topic-form input,
.topic-form textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
}
.topic-form .btn.primary {
  background: var(--primary);
  color: var(--primary-contrast);
  border: none;
}
.topic-form .btn.primary:hover {
  opacity: 0.9;
}

.btn {
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:8px 14px;
  border:none;
  border-radius:4px;
  cursor:pointer;
  transition:background-color 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
}

/* Варианты */
.btn-primary {
  background:var(--btn-primary-bg);
  color:var(--btn-primary-text);
}
.btn-success {
  background:var(--btn-success-bg);
  color:var(--btn-success-text);
}
.btn-warning {
  background:var(--btn-warning-bg);
  color:var(--btn-warning-text);
}
.btn-error {
  background:var(--btn-error-bg);
  color:var(--btn-error-text);
}

/* Hover/Active эффекты */
.btn:hover, .lastpost-button:hover {
  transform:translateY(-2px);
  box-shadow:0 4px 12px rgba(0,0,0,0.25);
}
.btn:active, .lastpost-button:active {
  transform:scale(0.95);
  box-shadow:0 2px 6px rgba(0,0,0,0.2);
}

/* Плавные переходы при смене темы */
body, .block, .site-header, .site-footer, .sidebar, .content,
h1, h2, h3, .btn, .pagination a, .breadcrumbs a {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* Десктопы (от 1200px) */
@media (min-width: 1200px) {
  :root {
    --font-size-body: 18px;
    --font-size-h1: 2.5rem;
    --font-size-h2: 2rem;
    --font-size-h3: 1.5rem;
  }
}

/* Планшеты (768–1199px) */
@media (min-width: 768px) and (max-width: 1199px) {
  :root {
    --font-size-body: 16px;
    --font-size-h1: 2.2rem;
    --font-size-h2: 1.7rem;
    --font-size-h3: 1.3rem;
  }
}

/* Мобильные (до 767px) */
@media (max-width: 767px) {
  :root {
    --font-size-body: 14px;
    --font-size-h1: 1.8rem;
    --font-size-h2: 1.4rem;
    --font-size-h3: 1.2rem;
  }
}

.alert {
  border-radius: 6px;
  padding: 12px 16px;
  margin-bottom: 12px;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.alert i {
  flex-shrink: 0;
}

/* Типы оповещений */
.alert-info {
  background: var(--alert-info-bg);
  color: var(--alert-info-text);
}
.alert-success {
  background: var(--alert-success-bg);
  color: var(--alert-success-text);
}
.alert-warning {
  background: var(--alert-warning-bg);
  color: var(--alert-warning-text);
}
.alert-error {
  background: var(--alert-error-bg);
  color: var(--alert-error-text);
}

/* Адаптивность */
@media (max-width: 560px) {
  .alert {
    font-size: 0.85rem;
    padding: 10px 12px;
  }
}

.thread {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  border: 1px solid var(--border);
  margin-bottom: 1rem;
  background: var(--bg-elev);
}

.likes {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 1rem;
  background: var(--bg-sec);
  font-size: var(--font-size-title);
}

.likes .amount {
  font-weight: bold;
  margin-bottom: 0.5rem;
}
.thread-figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 200px; /* ограничение ширины */
}

.thread-figure img {
  width: 100%;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.thread-figure figcaption {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.0rem;
  text-align: center;
}

.thread-content {
  flex: 1;
  display: flex;
  flex-direction: row;
  align-items: center;
  padding: 1rem;
  background: var();
}
/*.forumdisplay*/ .thread-content.newfolder::before, 
/*.forumdisplay*/ .thread-content.dot_newfolder::before, 
/*.forumdisplay*/ .thread-content.newhotclosefolder::before, 
/*.forumdisplay*/ .thread-content.newhotfolder::before {
  content: '';
  background-color: var(--primary);
  height: 12px;
  width: 12px;
  left: -22px;
  position: relative;
  border-radius: var(--radius-xx);
  box-shadow: 0px 0px 6px 0px var(--primary) #3B84DF;
}

.thread-info {
  font-size: var(--font-size-meta);
  color: var(--text);
}
 
.info {
  flex: 1;
  display: flex;
  flex-direction: row;
  align-items: center;
}

.avatar {
  margin-right: 0.75rem;
}

.details {
  flex: 1;
}

.thread-title {
  font-weight: bold;
  margin-bottom: 0.25rem;
  font-size: var(--font-size-title);
}

.lastpost {
  margin-left: 1rem;
}

.lastpost-button {
  border: none;
  background: #ddd;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: center;
}

.stats {
  margin-left: 1rem;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-size: var(--font-size-title);
  font-weight: bold;
}
.stats .stat {
  display: flex;
  align-items: center;
  margin-bottom: 0.25rem;
}
.stats .stat i {
  margin-left: 0.5rem;
  color: var(--text);
}


/* --- Адаптивность --- */
@media (max-width:860px) {
  .thread { flex-direction:row; }
  .thread-body { flex-direction:column; align-items:flex-start; }
  .thread-stats { width: 100%; justify-content: space-between; margin-left: 0; margin-top: 8px; font-size: 0.8rem; }
}
@media (max-width:560px) {
  .thread-avatar { display:none; } /* скрываем аватарку на мобильных */
  .thread-meta { font-size:.75rem; }
  .thread-title a { font-size:1rem; }
  .thread-stats { flex-direction: column; align-items: flex-start; gap: 4px; font-size: 0.75rem; }
}

.forum-code {
  margin: 1rem 0;
  background: #2d2d2d;
  border: 1px solid #444;
  border-radius: 6px;
  padding: 1rem;
  font-size: 0.75rem;
}
.forum-code figcaption {
  font-size: 0.75rem;
  color: #aaa;
  margin-top: 0.5rem;
  text-align: left;
}