/* ========== БАЗОВЫЕ СТИЛИ ========== */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: Georgia, 'Times New Roman', serif;
  background: #ffffff;
  color: #000;
  transition: background .3s, color .3s;
  min-height: 100vh;
}
button, input, textarea, select { font-family: inherit; font-size: 1rem; }
a { color: inherit; }

/* ========== ФОНЫ ========== */
body.bg-dark { background: #1e1e1e; color: #e0e0e0; }
body.bg-light { background: #f5f5dc; color: #333; }
body.bg-black { background: #000; color: #ccc; }
body.bg-horror {
  background: #0a0000;
  color: #b0b0b0;
  overflow-x: hidden;
}
body.bg-horror::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(0deg, rgba(255,0,0,0.03) 0 1px, transparent 1px 3px),
    radial-gradient(circle at 50% 50%, transparent 40%, rgba(0,0,0,0.8) 100%);
  animation: horrorFlicker 4s infinite;
  z-index: 9999;
}
@keyframes horrorFlicker {
  0%,100% { opacity: .6; }
  10% { opacity: .2; }
  20% { opacity: .9; }
  30% { opacity: .3; }
  40% { opacity: .7; }
  50% { opacity: .1; }
  60% { opacity: .8; }
  70% { opacity: .2; }
  80% { opacity: .9; }
  90% { opacity: .4; }
}
body.bg-horror .app-header {
  border-bottom-color: #400;
  box-shadow: 0 0 20px rgba(255,0,0,0.2);
}
body.bg-horror .app-header::after {
  content: "";
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100'><filter id='n'><feTurbulence baseFrequency='0.9' numOctaves='2'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.08'/></svg>");
  pointer-events: none;
  animation: horrorNoise 1s steps(3) infinite;
}
@keyframes horrorNoise {
  0% { transform: translate(0,0); }
  33% { transform: translate(-2px,1px); }
  66% { transform: translate(2px,-1px); }
  100% { transform: translate(0,0); }
}

/* ========== ХЕДЕР ========== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 2px solid #000;
  position: sticky;
  top: 0;
  background: inherit;
  z-index: 100;
}
body.bg-dark .app-header,
body.bg-black .app-header,
body.bg-horror .app-header { border-bottom-color: #444; }

.brand {
  font-size: 1.6rem;
  font-weight: bold;
  letter-spacing: 2px;
  cursor: pointer;
  text-decoration: none;
}
.brand:hover { opacity: .8; }

.nav-tabs { display: flex; gap: 8px; }
.nav-tabs button {
  background: none;
  border: 1px solid currentColor;
  padding: 6px 16px;
  cursor: pointer;
  border-radius: 4px;
  transition: all .2s;
}
.nav-tabs button:hover { background: rgba(128,128,128,.2); }
.nav-tabs button.active {
  background: currentColor;
  color: #fff;
}
body.bg-dark .nav-tabs button.active,
body.bg-black .nav-tabs button.active,
body.bg-horror .nav-tabs button.active { color: #000; }
body.bg-horror .nav-tabs button.active { background: #a00; color: #fff; }

.user-info { display: flex; align-items: center; gap: 10px; font-size: .9rem; }
.logout-link {
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  color: inherit;
  font-size: .85rem;
}

/* ========== ОСНОВНОЙ КОНТЕНТ ========== */
.container {
  max-width: 820px;
  margin: 0 auto;
  padding: 24px 16px 100px;
}
.view { display: none; }
.view.active { display: block; }

/* ========== АВТОРИЗАЦИЯ ========== */
.auth-box {
  max-width: 400px;
  margin: 80px auto;
  padding: 32px;
  border: 2px solid currentColor;
  border-radius: 8px;
  text-align: center;
}
.auth-box h1 { font-size: 2rem; margin-bottom: 4px; letter-spacing: 3px; }
.auth-box .sub { opacity: .6; margin-bottom: 24px; font-size: .85rem; }
.auth-box input {
  width: 100%;
  padding: 10px 14px;
  margin-bottom: 12px;
  border: 1px solid currentColor;
  border-radius: 4px;
  background: transparent;
  color: inherit;
}
.auth-box input::placeholder { color: rgba(128,128,128,.6); }
.auth-box button[type=submit] {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 4px;
  background: #000;
  color: #fff;
  cursor: pointer;
  font-size: 1rem;
  margin-top: 8px;
}
body.bg-dark .auth-box button[type=submit],
body.bg-black .auth-box button[type=submit] { background: #e0e0e0; color: #000; }
body.bg-horror .auth-box button[type=submit] { background: #a00; }
.auth-box .switch { margin-top: 16px; font-size: .85rem; }
.auth-box .switch a { text-decoration: underline; cursor: pointer; }
.err { color: #d00; font-size: .85rem; margin-bottom: 8px; min-height: 1.2em; }

/* ========== ГЛАВНАЯ ========== */
.home-title { margin-bottom: 16px; }
.home-sub { opacity: .7; margin-bottom: 24px; }
.home-actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* ========== РЕДАКТОР ========== */
.editor-title {
  width: 100%;
  font-size: 1.8rem;
  padding: 12px 0;
  border: none;
  border-bottom: 1px solid currentColor;
  background: transparent;
  color: inherit;
  margin-bottom: 16px;
  outline: none;
  font-weight: bold;
}
.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  border: 1px solid currentColor;
  border-radius: 4px;
  margin-bottom: 16px;
  opacity: .9;
}
.editor-toolbar button, .editor-toolbar select {
  background: transparent;
  border: 1px solid currentColor;
  border-radius: 3px;
  padding: 4px 8px;
  cursor: pointer;
  color: inherit;
  min-width: 32px;
}
.editor-toolbar button:hover { background: rgba(128,128,128,.2); }
.editor-content {
  min-height: 300px;
  padding: 12px;
  border: 1px solid currentColor;
  border-radius: 4px;
  outline: none;
  font-size: 1.05rem;
  line-height: 1.6;
  overflow-y: auto;
}
.editor-content:focus { border-color: #000; }
body.bg-dark .editor-content:focus,
body.bg-black .editor-content:focus,
body.bg-horror .editor-content:focus { border-color: #888; }
.editor-content:empty::before {
  content: attr(data-placeholder);
  opacity: .4;
  pointer-events: none;
}
.editor-content img { max-width: 100%; display: block; margin: 8px 0; }
.publish-btn {
  margin-top: 16px;
  padding: 12px 32px;
  border: none;
  border-radius: 4px;
  background: #000;
  color: #fff;
  cursor: pointer;
  font-size: 1rem;
}
.publish-btn.outline {
  background: transparent;
  color: inherit;
  border: 1px solid currentColor;
}
body.bg-dark .publish-btn,
body.bg-black .publish-btn { background: #e0e0e0; color: #000; }
body.bg-horror .publish-btn { background: #a00; }
.publish-result {
  margin-top: 16px;
  padding: 12px;
  border: 1px dashed currentColor;
  border-radius: 4px;
  word-break: break-all;
  display: none;
}
.publish-result a { text-decoration: underline; }
.publish-result.show { display: block; }

/* ========== СТАТЬЯ ========== */
.article-title { font-size: 2.2rem; margin-bottom: 8px; }
.article-meta {
  opacity: .6;
  font-size: .85rem;
  margin-bottom: 24px;
  border-bottom: 1px solid currentColor;
  padding-bottom: 12px;
}
.article-body { font-size: 1.1rem; line-height: 1.7; }
.article-body img { max-width: 100%; display: block; margin: 12px 0; }
.article-body a { color: #06c; }
body.bg-dark .article-body a,
body.bg-black .article-body a,
body.bg-horror .article-body a { color: #6cf; }

/* ========== КНОПКА ЖАЛОБЫ ========== */
.report-btn {
  position: fixed;
  top: 70px;
  left: 16px;
  width: 44px;
  height: 44px;
  border: 1px solid currentColor;
  border-radius: 8px;
  background: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.report-btn:hover { transform: scale(1.05); }
.report-btn svg { width: 24px; height: 24px; }

/* ========== МОДАЛКИ ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.modal-overlay.show { display: flex; }
.modal {
  background: #fff;
  color: #000;
  border-radius: 8px;
  padding: 24px;
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}
body.bg-dark .modal, body.bg-black .modal { background: #2a2a2a; color: #eee; }
body.bg-horror .modal { background: #150000; color: #ccc; border: 1px solid #500; }
.modal h2 { margin-bottom: 16px; font-size: 1.3rem; }
.modal .close {
  position: absolute;
  top: 12px; right: 12px;
  background: none; border: none;
  font-size: 1.5rem; cursor: pointer; color: inherit;
}
.report-article-info { font-size: .85rem; opacity: .7; margin-bottom: 12px; }
.report-label { margin-bottom: 8px; font-weight: bold; }
.reason-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.reason-grid button {
  padding: 10px 8px;
  border: 1px solid currentColor;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  color: inherit;
  font-size: .9rem;
}
.reason-grid button:hover { background: rgba(128,128,128,.2); }
.reason-grid button.selected { background: #000; color: #fff; }
body.bg-dark .reason-grid button.selected,
body.bg-black .reason-grid button.selected { background: #e0e0e0; color: #000; }
body.bg-horror .reason-grid button.selected { background: #a00; }
.modal textarea {
  width: 100%;
  min-height: 80px;
  padding: 10px;
  border: 1px solid currentColor;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  resize: vertical;
  margin-bottom: 12px;
}
.modal .submit-report {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 4px;
  background: #000;
  color: #fff;
  cursor: pointer;
}
body.bg-dark .modal .submit-report,
body.bg-black .modal .submit-report { background: #e0e0e0; color: #000; }
body.bg-horror .modal .submit-report { background: #a00; }

/* ========== ЧАТ ========== */
.chat-layout { display: flex; gap: 16px; height: calc(100vh - 160px); }
.chat-sidebar {
  width: 260px;
  border: 1px solid currentColor;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-sidebar .search { padding: 8px; border-bottom: 1px solid currentColor; }
.chat-sidebar .search input {
  width: 100%; padding: 6px 10px;
  border: 1px solid currentColor; border-radius: 4px;
  background: transparent; color: inherit;
}
.chat-list { flex: 1; overflow-y: auto; }
.chat-item {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(128,128,128,.3);
  cursor: pointer;
}
.chat-item:hover, .chat-item.active { background: rgba(128,128,128,.15); }
.chat-item .name { font-weight: bold; }
.chat-item .preview {
  font-size: .8rem; opacity: .6;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-main {
  flex: 1;
  border: 1px solid currentColor;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-main .head { padding: 10px 14px; border-bottom: 1px solid currentColor; font-weight: bold; }
.chat-messages {
  flex: 1; overflow-y: auto; padding: 14px;
  display: flex; flex-direction: column; gap: 8px;
}
.msg {
  max-width: 75%;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(128,128,128,.2);
}
.msg.me { align-self: flex-end; background: #000; color: #fff; }
body.bg-dark .msg.me, body.bg-black .msg.me { background: #e0e0e0; color: #000; }
body.bg-horror .msg.me { background: #a00; color: #fff; }
.msg .time { font-size: .7rem; opacity: .6; display: block; margin-top: 2px; }
.chat-input { display: flex; border-top: 1px solid currentColor; }
.chat-input input {
  flex: 1; padding: 12px; border: none;
  background: transparent; color: inherit; outline: none;
}
.chat-input button {
  padding: 0 20px; border: none;
  background: #000; color: #fff; cursor: pointer;
}
body.bg-dark .chat-input button,
body.bg-black .chat-input button { background: #e0e0e0; color: #000; }
body.bg-horror .chat-input button { background: #a00; }
.empty-chat { margin: auto; opacity: .5; }

/* ========== ФОН ========== */
.bg-title { margin-bottom: 24px; }
.bg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 16px; }
.bg-option {
  padding: 24px;
  border: 2px solid currentColor;
  border-radius: 8px;
  cursor: pointer;
  text-align: center;
  font-weight: bold;
  transition: transform .15s;
}
.bg-option:hover { transform: scale(1.03); }
.bg-option.active { outline: 3px solid #0a0; outline-offset: 2px; }
.bg-option[data-bg="white"] { background: #fff; color: #000; }
.bg-option[data-bg="dark"] { background: #1e1e1e; color: #e0e0e0; }
.bg-option[data-bg="light"] { background: #f5f5dc; color: #333; }
.bg-option[data-bg="black"] { background: #000; color: #ccc; }
.bg-option[data-bg="horror"] { background: #0a0000; color: #b00; }

/* ========== МОДЕРАЦИЯ ========== */
.mod-panel { max-width: 1000px; margin: 0 auto; padding: 24px 16px; }
.mod-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.mod-header h1 { font-size: 1.8rem; letter-spacing: 2px; }
.mod-header-right { display: flex; gap: 12px; align-items: center; }
.mod-header-right span { opacity: .7; font-size: .9rem; }
.mod-header .logout {
  padding: 8px 16px; border: 1px solid currentColor;
  background: transparent; color: inherit;
  border-radius: 4px; cursor: pointer;
}
.reports-list { display: flex; flex-direction: column; gap: 12px; }
.report-card {
  border: 1px solid currentColor;
  border-radius: 6px;
  padding: 16px;
  background: rgba(128,128,128,.05);
}
.report-card .meta-row {
  display: flex; flex-wrap: wrap; gap: 8px 24px;
  font-size: .85rem; opacity: .75; margin-bottom: 8px;
}
.report-card .reason-tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  background: #a00;
  color: #fff;
  font-size: .8rem;
  font-weight: bold;
}
.report-card .text { margin: 8px 0; font-style: italic; }
.report-card .actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.report-card .actions button {
  padding: 6px 14px;
  border: 1px solid currentColor;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: .85rem;
}
.report-card .actions button.del { border-color: #a00; color: #a00; }
.report-card .actions button.del:hover { background: #a00; color: #fff; }
.report-card .actions button.resolve { border-color: #0a0; color: #0a0; }
.report-card .actions button.resolve:hover { background: #0a0; color: #fff; }
.report-card .actions button.ban { border-color: #c60; color: #c60; }
.report-card .actions button.ban:hover { background: #c60; color: #fff; }
.report-card .actions button:disabled { opacity: .4; cursor: not-allowed; }
.report-card.resolved { opacity: .5; }
.mod-empty { text-align: center; padding: 60px 20px; opacity: .5; }
.back-link {
  display: inline-block; margin-bottom: 16px;
  text-decoration: underline; cursor: pointer;
}
.badge-status {
  font-size: .75rem; padding: 2px 8px;
  border-radius: 10px; background: #555; color: #fff;
}
.badge-status.resolved { background: #0a0; }
.badge-status.rejected { background: #666; }

/* ========== ТОСТЫ ========== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #000;
  color: #fff;
  padding: 12px 24px;
  border-radius: 6px;
  z-index: 2000;
  transition: transform .3s;
  max-width: 90vw;
}
body.bg-dark .toast, body.bg-black .toast { background: #eee; color: #000; }
body.bg-horror .toast { background: #a00; }
.toast.show { transform: translateX(-50%) translateY(0); }

/* ========== АДАПТИВ ========== */
@media (max-width: 600px) {
  .app-header { padding: 10px 12px; flex-wrap: wrap; gap: 8px; }
  .brand { font-size: 1.2rem; }
  .nav-tabs button { padding: 5px 10px; font-size: .85rem; }
  .user-info { font-size: .8rem; }
  .reason-grid { grid-template-columns: 1fr; }
  .chat-layout { flex-direction: column; height: auto; }
  .chat-sidebar { width: 100%; max-height: 200px; }
  .chat-main { height: 400px; }
  .report-btn { top: 60px; left: 8px; width: 38px; height: 38px; }
}