html, body {
  height: auto;
  min-height: 100vh;
  overflow-y: auto;
  background: radial-gradient(circle at 50% 20%, #080013, #020008);
  color: #fff;
}


/* === КОСМИЧЕСКИЙ СТИЛЬ MERCILIUM === */
body {
  background: radial-gradient(circle at bottom, #080014 0%, #000 100%);
  color: #fff;
  font-family: 'Montserrat', sans-serif;
  margin: 0;
  overflow-x: hidden;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 5%;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  background: rgba(10,10,25,0.7);
  backdrop-filter: blur(8px);
  box-shadow: 0 0 20px rgba(128,0,255,0.2);
  gap: 16px;
}
.top-bar .left {
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.top-bar .left h2 {
  margin: 0;
}
.top-bar .subtitle {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
  letter-spacing: 0.2px;
}

.btn {
  padding: 10px 20px;
  border-radius: 10px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(128,0,255,0.6);
  color: #fff;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 600;
  margin-left: 10px;
}
.btn.btn-mini{
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
}
.btn.btn-danger{
  border-color: rgba(255,90,120,0.7);
  background: rgba(255,90,120,0.12);
}
.btn.btn-danger:hover{
  background: rgba(255,90,120,0.24);
  box-shadow: 0 0 12px rgba(255,90,120,0.5);
}
.btn:hover {
  background: rgba(128,0,255,0.3);
  box-shadow: 0 0 15px rgba(128,0,255,0.6);
}
.btn.violet {
  background: rgba(128,0,255,0.2);
  border-color: rgba(170,0,255,0.8);
}
.logout-btn {
  padding: 8px 18px;
  color: #fff;
  border: 1px solid rgba(128,0,255,0.6);
  border-radius: 10px;
  text-decoration: none;
  font-weight: 600;
  transition: 0.3s;
}
.logout-btn:hover {
  background: rgba(128,0,255,0.3);
  box-shadow: 0 0 12px rgba(128,0,255,0.7);
}

.posts-section {
  display: flex;
  justify-content: space-around;
  gap: 30px;
  padding: 30px 5%;
}

.post-block {
  flex: 1;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 18px;
  backdrop-filter: blur(6px);
}

.block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.search-bar {
  padding: 16px 5% 0;
}
.search-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(160, 90, 255, 0.45);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  outline: none;
  transition: border 0.2s, box-shadow 0.2s, background 0.2s;
}
.search-input:focus {
  border-color: rgba(210, 140, 255, 0.9);
  box-shadow: 0 0 0 3px rgba(150, 80, 255, 0.15);
  background: rgba(255, 255, 255, 0.08);
}

.post-card {
  background: rgba(255,255,255,0.05);
  border-radius: 12px;
  padding: 15px;
  margin: 10px 0;
  transition: all 0.3s ease;
}
.post-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 0 20px rgba(128,0,255,0.5);
}

.post-card h4 {
  margin: 0 0 10px;
  color: #fff;
}

.post-card .tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  background: rgba(128,0,255,0.2);
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: #fff;
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}
.actions .btn{ margin-left: 0; }

@media (max-width: 1100px) {
  .posts-section {
    flex-direction: column;
  }
}

@media (max-width: 720px) {
  .top-bar {
    flex-direction: column;
    align-items: stretch;
    padding: 16px 6%;
  }
  .top-bar .right {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-start;
  }
  .posts-section {
    padding: 20px 6%;
  }
  .block-head {
    flex-direction: column;
    align-items: stretch;
  }
  .post-card {
    padding: 14px;
  }
}

.error {
  color: #ff8888;
  text-align: center;
}

/* === ЛОАДЕР === */
.loader-screen {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at center, #0a0215 0%, #000 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  overflow: hidden;
  color: #fff;
}

.loader-orbit {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 2px solid rgba(128,0,255,0.4);
  border-top-color: rgba(255,255,255,0.9);
  animation: orbit-spin 2.8s linear infinite;
  box-shadow: 0 0 25px rgba(128,0,255,0.6);
}

.loader-title {
  margin-top: 30px;
  font-size: 32px;
  letter-spacing: 2px;
  text-shadow: 0 0 25px rgba(128,0,255,0.8);
  animation: title-pulse 3s ease-in-out infinite;
}

.loader-status {
  margin-top: 25px;
  text-align: left;
  line-height: 1.6em;
  font-size: 15px;
  opacity: 0.8;
  animation: fadeIn 1.5s ease forwards;
}

@keyframes orbit-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes title-pulse {
  0%, 100% { text-shadow: 0 0 20px rgba(128,0,255,0.8); }
  50% { text-shadow: 0 0 35px rgba(190,0,255,1); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
/* === LOGIN PAGE === */
.login-body {
  margin: 0;
  font-family: 'Montserrat', sans-serif;
  background: radial-gradient(circle at bottom, #060012 0%, #000 100%);
  color: #fff;
  overflow: hidden;
}

#stars {
  position: fixed;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
}

.login-wrapper {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%);
  z-index: 10;
  max-width: 320px;
  padding: 25px;
  background: rgba(10, 10, 25, 0.6);
  border-radius: 16px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(128, 0, 255, 0.5);
  box-shadow: 0 0 25px rgba(128,0,255,0.3);
}

.login-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 20px;
  text-shadow: 0 0 20px rgba(128,0,255,0.8);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-form label {
  font-size: 14px;
  opacity: 0.9;
}

.login-form input {
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid rgba(128,0,255,0.5);
  background: rgba(255,255,255,0.08);
  color: #fff;
  outline: none;
  transition: all 0.3s;
}

.login-form input:focus {
  border-color: rgba(180,0,255,0.9);
  box-shadow: 0 0 12px rgba(128,0,255,0.6);
}

.login-btn {
  margin-top: 15px;
  padding: 10px;
  background: rgba(128,0,255,0.3);
  border: 1px solid rgba(180,0,255,0.6);
  border-radius: 10px;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  transition: 0.3s;
}

.login-btn:hover {
  background: rgba(180,0,255,0.5);
  box-shadow: 0 0 18px rgba(180,0,255,0.7);
}

.login-error {
  background: rgba(255,0,60,0.2);
  border: 1px solid rgba(255,60,100,0.4);
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 10px;
  color: #ff9090;
  text-align: center;
}

/* === NETWORK BACKGROUND === */
#network {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle at 50% 50%, #14002a 0%, #050013 50%, #000007 100%);
  filter: brightness(0.8) contrast(1.4) saturate(1.2);
  z-index: 0;
}


/* Лёгкое “дыхание” — фон медленно пульсирует */
@keyframes bgPulse {
  0% { background: radial-gradient(circle at 50% 50%, #070014 0%, #000005 100%); }
  50% { background: radial-gradient(circle at 50% 55%, #0b0020 0%, #010008 100%); }
  100% { background: radial-gradient(circle at 50% 50%, #070014 0%, #000005 100%); }
}

/* ===============================
   MERCILIUM ADMIN — POPUP STYLES
   =============================== */

.popup {
  position: fixed;
  inset: 0;
  display: none;
  align-items: flex-start;
  justify-content: center;
  background: radial-gradient(circle at 30% 20%, rgba(90, 20, 160, 0.35), rgba(10, 0, 25, 0.9));
  backdrop-filter: blur(14px);
  z-index: 1000;
  overflow-y: auto;
  padding: 48px 0;
}
.popup.active {
  display: flex;
}

.popup-content {
  position: relative;
  background: linear-gradient(160deg, rgba(28, 6, 54, 0.98), rgba(12, 0, 32, 0.98));
  border: 1px solid rgba(180, 120, 255, 0.35);
  border-radius: 22px;
  width: 760px;
  max-width: 90%;
  padding: 28px 28px 24px;
  box-shadow: 0 20px 60px rgba(8, 0, 20, 0.65), 0 0 0 1px rgba(160, 90, 255, 0.15) inset;
  color: #fff;
  font-family: 'Montserrat', sans-serif;
  animation: fadeInUp 0.4s ease;
  overflow: visible;
  margin: 30px auto;
}
@keyframes fadeInUp {
  from {opacity:0; transform: translateY(40px);}
  to {opacity:1; transform: translateY(0);}
}

.close-btn {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 34px;
  height: 34px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(200, 120, 255, 0.35);
  border-radius: 10px;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: 0.2s ease;
}
.close-btn:hover {
  background: rgba(200, 120, 255, 0.2);
  color: #efe2ff;
}

.popup-content h2 {
  margin: 2px 0 18px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.2px;
}

/* ====== Fields ====== */
.field {
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
}
.field label {
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 700;
  color: #d8c9ff;
  letter-spacing: 0.2px;
}
.field input,
.field select {
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid rgba(160, 90, 255, 0.45);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  outline: none;
  transition: border 0.2s, box-shadow 0.2s, background 0.2s;
}
.source-picker{
  display: flex;
  align-items: center;
  gap: 10px;
}
.source-current{
  font-size: 13px;
  color: #e8dcff;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid rgba(160, 90, 255, 0.35);
  background: rgba(255, 255, 255, 0.04);
}
.source-dropdown{
  margin-top: 8px;
}
.source-select{
  display: none;
}
.field .source-select{
  appearance: none;
  padding-right: 34px;
  background-image:
    linear-gradient(45deg, transparent 50%, #d8c9ff 50%),
    linear-gradient(135deg, #d8c9ff 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 12px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}
.field input:focus,
.field select:focus {
  border-color: rgba(210, 140, 255, 0.9);
  box-shadow: 0 0 0 3px rgba(150, 80, 255, 0.15);
  background: rgba(255, 255, 255, 0.08);
}

/* ====== Quill editor ====== */
.editor {
  height: clamp(220px, 40vh, 360px);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(160, 90, 255, 0.35);
}
.editor.editor-disabled {
  opacity: 0.65;
  pointer-events: none;
  filter: saturate(0.8);
}
.ql-toolbar.ql-snow {
  border: none !important;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 12px 12px 0 0;
}
.ql-container.ql-snow {
  background: rgba(10, 0, 25, 0.85);
  color: #fff;
  border: none !important;
  border-radius: 0 0 12px 12px;
}
.ql-editor {
  min-height: 260px;
  color: #f5eaff;
  font-family: 'Roboto', sans-serif;
}

/* ====== Buttons ====== */
.btn, .btn-select-tag, .btn-create-tag {
  background: linear-gradient(120deg, #6f2bff, #c957ff);
  border: none;
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.2px;
  transition: transform 0.15s ease, filter 0.2s ease, box-shadow 0.2s ease;
  margin-top: 10px;
}
.btn:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(120, 40, 255, 0.35);
}
.btn.violet {
  background: linear-gradient(120deg, #8e45ff, #db8bff);
}
.btn-select-tag {
  width: auto;
}
.input-create-tag {
  width: 100%;
  display: block;
  margin-top: 8px;
}
.btn-create-tag {
  width: 52px;
  margin-left: 8px;
  margin-top: 8px;
}

.btn.btn-mini {
  padding: 8px 12px;
  font-size: 12px;
}

/* ====== Tags ====== */
.tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0 4px;
}
.tag {
  background: rgba(160, 60, 255, 0.2);
  border: 1px solid rgba(210, 130, 255, 0.45);
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.2s, border 0.2s;
}
.tag:hover {
  background: rgba(200, 120, 255, 0.3);
}

/* Dropdown */
.tags-dropdown {
  position: relative;
  background: rgba(24, 0, 50, 0.96);
  border: 1px solid rgba(160, 80, 255, 0.35);
  border-radius: 12px;
  margin-top: 8px;
  padding: 8px;
  max-height: 160px;
  overflow-y: auto;
  display: none;
}
.tag-option {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: #fff;
  padding: 6px 10px;
  font-size: 14px;
  border-radius: 6px;
  cursor: pointer;
}
.tag-option:hover {
  background: rgba(160, 60, 255, 0.3);
}

/* Popup actions */
.popup-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
}

/* ====== Category layout ====== */
.category-layout {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 16px;
  margin: 10px 0 16px;
}
.category-layout.simple {
  grid-template-columns: 1fr;
}
.category-layout.simple .category-tabs,
.category-layout.simple .category-header {
  display: none;
}
.category-tabs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  padding-top: 6px;
}
.category-layout.is-empty .category-current {
  opacity: 0.65;
}
.category-tab {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid rgba(190, 120, 255, 0.35);
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  transition: 0.2s ease;
}
.category-tab.active {
  background: rgba(160, 90, 255, 0.35);
  border-color: rgba(210, 140, 255, 0.8);
}
.category-tab.category-add {
  font-size: 18px;
}
.category-main {
  min-width: 0;
}
.category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.category-current {
  font-size: 14px;
  font-weight: 700;
  color: #e8dcff;
}
.category-actions {
  position: relative;
}
.btn-select-category {
  padding: 8px 12px;
}
.btn-remove-category {
  background: rgba(255, 120, 160, 0.15);
  border: 1px solid rgba(255, 120, 160, 0.4);
  color: #ffd6e3;
}
.btn-remove-category:hover {
  filter: none;
  box-shadow: 0 8px 16px rgba(255, 120, 160, 0.3);
}
.category-dropdown {
  position: absolute;
  top: 38px;
  right: 0;
  min-width: 200px;
  background: rgba(24, 0, 50, 0.96);
  border: 1px solid rgba(160, 80, 255, 0.35);
  border-radius: 12px;
  padding: 8px;
  max-height: 180px;
  overflow-y: auto;
  display: none;
  z-index: 3;
}
.category-dropdown .tag-option {
  border-radius: 8px;
  padding: 8px 10px;
}
.category-create {
  display: flex;
  align-items: center;
  gap: 8px;
}
.category-create input {
  min-width: 200px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid rgba(160, 90, 255, 0.45);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

/* ====== Tag controls ====== */
.tag-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}
.tag-create-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.tag-create-row .input-create-tag {
  flex: 1;
  margin-top: 0;
}
.tag-create-row .btn-create-tag {
  margin-top: 0;
}
