/* ================================================================
   RUS DEFENSE WIKI — Design System v2
   Профессиональная и читабельная, с тактическим характером
   Все цвета и стили настраиваются через CSS-переменные,
   которые динамически задаёт api.js из настроек сайта.
   ================================================================ */

@import url("https://fonts.googleapis.com/css2?family=Oswald:wght@400;500;600;700&family=Inter:wght@300;400;500;600;700&family=IBM+Plex+Sans:wght@300;400;500;600&family=Roboto:wght@300;400;500;600&family=Open+Sans:wght@300;400;500;600&family=JetBrains+Mono:wght@400;500&display=swap");

/* ── Дефолтные переменные (переопределяются через JS из настроек) ── */
:root {
  /* Акцент */
  --accent:          #FF5500;
  --accent-dark:     #CC3D00;
  --accent-light:    rgba(255,85,0,0.10);
  --accent-glow:     rgba(255,85,0,0.18);

  /* Навигация */
  --nav-bg:          #0E0E0E;

  /* Фон страницы и поверхности */
  --page-bg:         #F7F6F4;
  --surface-0:       #FFFFFF;   /* карточки, модалки, верхний слой */
  --surface-1:       #F0EDE9;   /* фон hover, чередующиеся строки */
  --surface-2:       #E6E2DD;   /* тонкий разделитель */
  --sidebar-bg:      #FFFFFF;

  /* Текст */
  --text-1:          #1A1714;   /* основной */
  --text-2:          #4A4643;   /* вторичный */
  --text-3:          #6B6866;   /* подсказки, мета */
  --text-4:          #A09D9A;   /* очень мuted */
  --text-inverse:    #FFFFFF;
  --hero-text:       #FFFFFF;

  /* Границы */
  --border:          #E2DDD8;
  --border-strong:   #C8C3BE;

  /* Скругления — настраиваются пользователем */
  --radius:          6px;
  --radius-sm:       4px;
  --radius-lg:       10px;
  --radius-xl:       16px;

  /* Тени */
  --shadow-xs:       0 1px 2px rgba(0,0,0,0.06);
  --shadow-sm:       0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.05);
  --shadow:          0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.05);
  --shadow-lg:       0 12px 32px rgba(0,0,0,0.10), 0 4px 8px rgba(0,0,0,0.06);
  --shadow-xl:       0 24px 64px rgba(0,0,0,0.12);

  /* Типографика */
  --font-display:    'Oswald', sans-serif;
  --font-body:       'Inter', system-ui, sans-serif;
  --font-mono:       'JetBrains Mono', 'Courier New', monospace;

  /* Шкала размеров текста */
  --text-xs:         11px;
  --text-sm:         13px;
  --text-base:       15.5px;
  --text-md:         17px;
  --text-lg:         20px;
  --text-xl:         24px;
  --text-2xl:        30px;
  --text-3xl:        38px;
  --text-4xl:        52px;

  /* Состояния */
  --success:         #1E7A38;
  --success-bg:      rgba(30,122,56,0.08);
  --warning:         #B86B0A;
  --warning-bg:      rgba(184,107,10,0.09);
  --danger:          #C02424;
  --danger-bg:       rgba(192,36,36,0.08);
  --info:            #1A5F9A;
  --info-bg:         rgba(26,95,154,0.08);
}

/* ════════════════════════════════════════════
   RESET И BASE
════════════════════════════════════════════ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;         /* base для rem */
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--page-bg);
  color: var(--text-1);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.65;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img, video { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ── Скроллбар ── */
::-webkit-scrollbar            { width: 7px; height: 7px; }
::-webkit-scrollbar-track      { background: transparent; }
::-webkit-scrollbar-thumb      { background: var(--border-strong); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover{ background: var(--accent); }

::selection { background: rgba(255,85,0,0.18); }

/* ════════════════════════════════════════════
   LAYOUT
════════════════════════════════════════════ */
.app-body { display: flex; min-height: calc(100vh - 62px); }
.app-main  { flex: 1; min-width: 0; }
.container { max-width: 1280px; margin: 0 auto; padding: 0 28px; }

@media (max-width: 600px) { .container { padding: 0 16px; } }

/* ════════════════════════════════════════════
   НАВИГАЦИЯ
════════════════════════════════════════════ */
.app-nav {
  position: sticky; top: 0; z-index: 200;
  background: var(--nav-bg);
  border-bottom: 1px solid rgba(255,85,0,0.25);
  box-shadow: 0 2px 16px rgba(0,0,0,0.3);
  background-image: repeating-linear-gradient(
    -45deg,
    rgba(255,85,0,0.03) 0, rgba(255,85,0,0.03) 1px,
    transparent 1px, transparent 10px
  );
}

.app-nav-inner {
  max-width: 1280px; margin: 0 auto;
  display: flex; align-items: center;
  padding: 0 28px; height: 62px; gap: 20px;
}

.app-logo { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }

.app-logo-icon {
  width: 34px; height: 34px;
  border: 2px solid var(--accent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
}
.app-logo-icon::before {
  content: '';
  width: 11px; height: 11px;
  background: var(--accent);
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}

.app-logo img { height: 34px; width: auto; object-fit: contain; }

.app-logo-name {
  font-family: var(--font-display);
  font-weight: 700; font-size: 18px;
  letter-spacing: 2.5px; text-transform: uppercase;
  color: #fff; white-space: nowrap;
}
.app-logo-name b { color: var(--accent); font-weight: 700; }

/* Поиск в навигации */
.app-nav-search { flex: 1; max-width: 380px; position: relative; margin: 0 8px; }
.app-nav-search input {
  width: 100%; height: 36px; padding: 0 14px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: #fff; font-size: var(--text-sm); outline: none;
  border-radius: var(--radius);
  transition: border-color .2s, background .2s;
}
.app-nav-search input::placeholder { color: rgba(255,255,255,0.35); }
.app-nav-search input:focus { border-color: var(--accent); background: rgba(255,255,255,0.1); }

/* Ссылки навигации */
.app-nav-links { display: flex; gap: 2px; margin-left: auto; align-items: center; }

.app-nav-link {
  font-family: var(--font-display);
  font-size: 11px; letter-spacing: 1.5px;
  text-transform: uppercase; color: rgba(255,255,255,0.55);
  padding: 7px 14px; cursor: pointer;
  transition: color .2s; white-space: nowrap;
  border-radius: var(--radius-sm);
}
.app-nav-link:hover, .app-nav-link.active { color: var(--accent); }

.app-nav-divider { width: 1px; height: 20px; background: rgba(255,255,255,0.1); margin: 0 4px; }

/* Пользовательское меню */
.app-user-menu { position: relative; }

.app-user-btn {
  display: flex; align-items: center; gap: 9px;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1);
  padding: 6px 12px 6px 6px; cursor: pointer;
  border-radius: var(--radius);
  transition: border-color .2s, background .2s;
}
.app-user-btn:hover { border-color: rgba(255,85,0,0.4); background: rgba(255,85,0,0.06); }

.app-user-avatar {
  width: 28px; height: 28px;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; font-size: 12px;
  color: #fff; flex-shrink: 0; overflow: hidden;
  border-radius: calc(var(--radius) - 1px);
}
.app-user-avatar img { width: 100%; height: 100%; object-fit: cover; }

.app-user-name  { font-size: 13px; color: #fff; white-space: nowrap; font-weight: 500; }
.app-user-role  {
  font-family: var(--font-display); font-size: 8px;
  letter-spacing: 1.5px; text-transform: uppercase; color: var(--accent);
}

.app-user-dropdown {
  position: absolute; right: 0; top: calc(100% + 8px);
  background: var(--surface-0); border: 1px solid var(--border);
  border-top: 2px solid var(--accent);
  min-width: 200px; display: none; z-index: 300;
  box-shadow: var(--shadow-lg);
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
}
.app-user-dropdown.open { display: block; }

.app-user-dropdown-item {
  padding: 11px 16px; font-size: 13.5px; color: var(--text-2);
  cursor: pointer; transition: background .15s;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--border);
}
.app-user-dropdown-item:last-child { border-bottom: none; }
.app-user-dropdown-item:hover { background: var(--surface-1); color: var(--accent); }

.app-nav-burger {
  display: none; background: none; border: none;
  width: 34px; height: 34px; color: #fff; font-size: 18px;
  align-items: center; justify-content: center;
  border-radius: var(--radius);
}

@media (max-width: 880px) {
  .app-nav-search { display: none; }
  .app-nav-links {
    display: none;
    position: fixed; top: 62px; left: 0; right: 0;
    background: var(--nav-bg); flex-direction: column;
    padding: 8px 0; border-bottom: 2px solid var(--accent);
    z-index: 250;
  }
  .app-nav-links.mobile-open { display: flex; }
  .app-nav-link { padding: 13px 24px; width: 100%; }
  .app-nav-burger { display: flex; }
  .app-user-name, .app-user-role { display: none; }
}

/* ════════════════════════════════════════════
   УТИЛИТЫ
════════════════════════════════════════════ */
.diamond {
  display: inline-block; width: 6px; height: 6px;
  background: var(--accent);
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
  flex-shrink: 0;
}

.eyebrow {
  font-family: var(--font-display); font-size: 9.5px;
  letter-spacing: 3px; text-transform: uppercase; color: var(--accent);
  display: flex; align-items: center; gap: 8px;
}
.eyebrow::before { content: '▮'; font-size: 8px; }

.tick-line {
  height: 2px; border: none;
  background: repeating-linear-gradient(
    90deg, var(--accent) 0, var(--accent) 16px, transparent 16px, transparent 24px
  );
  opacity: .45;
}

.section-title {
  font-family: var(--font-display); font-size: 10.5px;
  letter-spacing: 3px; text-transform: uppercase;
  color: var(--text-3); margin-bottom: 20px;
  display: flex; align-items: center; gap: 12px;
}
.section-title::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ════════════════════════════════════════════
   КНОПКИ
════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 40px; padding: 0 20px;
  font-family: var(--font-display); font-size: 12px;
  letter-spacing: 1.5px; text-transform: uppercase;
  font-weight: 600;
  border: none; border-radius: var(--radius); cursor: pointer;
  transition: all .18s ease;
  white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }

.btn-primary  { background: var(--accent); color: #fff; box-shadow: 0 2px 8px var(--accent-glow); }
.btn-primary:hover  { background: var(--accent-dark); box-shadow: 0 4px 16px var(--accent-glow); }

.btn-ghost  { background: transparent; color: var(--text-1); border: 1.5px solid var(--border); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

.btn-dark   { background: var(--text-1); color: #fff; }
.btn-dark:hover { background: var(--text-2); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a01d1d; }

.btn-success { background: var(--success); color: #fff; }

.btn-sm  { height: 32px; padding: 0 14px; font-size: 10.5px; letter-spacing: 1px; }
.btn-lg  { height: 48px; padding: 0 28px; font-size: 13px; letter-spacing: 2px; }
.btn-icon { width: 36px; height: 36px; padding: 0; }
.btn-icon-sm { width: 28px; height: 28px; padding: 0; font-size: 12px; }

/* ════════════════════════════════════════════
   КАРТОЧКИ
════════════════════════════════════════════ */
.card {
  background: var(--surface-0);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
}

.card-accent { border-top: 3px solid var(--accent); }
.card-dark { background: var(--text-1); color: #fff; border: none; }

/* ════════════════════════════════════════════
   ФОРМЫ
════════════════════════════════════════════ */
.field          { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }

.field-label {
  display: block;
  font-family: var(--font-display); font-size: 9.5px;
  letter-spacing: 2px; text-transform: uppercase;
  color: var(--text-3); margin-bottom: 7px;
  font-weight: 600;
}

.field-input, .field-select, .field-textarea {
  width: 100%; padding: 0 13px; height: 42px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-0);
  font-family: var(--font-body);
  font-size: 14.5px; color: var(--text-1); outline: none;
  transition: border-color .2s, box-shadow .2s;
  appearance: none;
}
.field-textarea { height: auto; padding: 11px 13px; resize: vertical; line-height: 1.6; }
.field-input:focus, .field-select:focus, .field-textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light);
}
.field-input::placeholder, .field-textarea::placeholder { color: var(--text-4); }
.field-hint  { font-size: 12px; color: var(--text-3); margin-top: 5px; line-height: 1.5; }
.field-error { font-size: 12px; color: var(--danger); margin-top: 5px; }

.field-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23FF5500'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center; background-size: 9px;
  padding-right: 36px;
}

.checkbox-row {
  display: flex; align-items: center; gap: 9px;
  font-size: 14px; color: var(--text-1); cursor: pointer;
}
.checkbox-row input { accent-color: var(--accent); width: 16px; height: 16px; cursor: pointer; }

/* ════════════════════════════════════════════
   БЕЙДЖИ
════════════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-display); font-size: 9px;
  letter-spacing: 1px; text-transform: uppercase;
  padding: 3px 10px; border-radius: var(--radius-sm);
  font-weight: 600;
}
.badge-published { background: var(--success-bg); color: var(--success); }
.badge-draft     { background: var(--warning-bg); color: var(--warning); }
.badge-admin     { background: var(--accent-light); color: var(--accent); }
.badge-editor    { background: var(--info-bg); color: var(--info); }
.badge-viewer    { background: var(--surface-1); color: var(--text-3); }
.badge-inactive  { background: var(--danger-bg); color: var(--danger); }

/* ════════════════════════════════════════════
   ТОСТЫ
════════════════════════════════════════════ */
#toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  display: flex; flex-direction: column; gap: 10px; pointer-events: none;
}
.toast {
  background: var(--surface-0); color: var(--text-1);
  border-left: 3px solid var(--accent);
  padding: 14px 18px; min-width: 280px; max-width: 380px;
  font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius);
  animation: toast-in .25s ease;
  pointer-events: auto;
}
.toast.error   { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ════════════════════════════════════════════
   МОДАЛЬНЫЕ ОКНА
════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 500; display: none; align-items: center; justify-content: center;
  padding: 24px; backdrop-filter: blur(2px);
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--surface-0); border-top: 3px solid var(--accent);
  width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-xl); border-radius: var(--radius);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface-0); z-index: 1;
}
.modal-title {
  font-family: var(--font-display); font-weight: 700; font-size: 15px;
  letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-1);
}
.modal-close { background: none; border: none; font-size: 20px; color: var(--text-3); line-height: 1; }
.modal-close:hover { color: var(--accent); }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
  background: var(--surface-0);
}

/* ════════════════════════════════════════════
   ТАБЛИЦЫ (данные в админке)
════════════════════════════════════════════ */
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table thead th {
  background: var(--text-1); color: var(--accent);
  font-family: var(--font-display); font-size: 9.5px;
  letter-spacing: 2px; text-transform: uppercase;
  padding: 12px 18px; text-align: left; white-space: nowrap;
}
.data-table thead th:first-child { border-radius: var(--radius-sm) 0 0 0; }
.data-table thead th:last-child  { border-radius: 0 var(--radius-sm) 0 0; }
.data-table tbody td {
  padding: 12px 18px; border-bottom: 1px solid var(--border);
  vertical-align: middle; color: var(--text-2);
}
.data-table tbody tr:hover td { background: var(--surface-1); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ════════════════════════════════════════════
   ЗАГРУЗКА (dropzone)
════════════════════════════════════════════ */
.dropzone {
  border: 2px dashed var(--border-strong);
  background: var(--surface-1);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 28px 20px; cursor: pointer;
  transition: border-color .2s, background .2s;
  position: relative; overflow: hidden;
  border-radius: var(--radius);
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent); background: var(--accent-light);
}
.dropzone input[type="file"] { display: none; }

.dropzone-icon {
  width: 44px; height: 44px;
  border: 2px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px; border-radius: var(--radius);
  transition: border-color .2s;
  font-size: 20px; line-height: 1;
}
.dropzone:hover .dropzone-icon { border-color: var(--accent); }

.dropzone-text { font-family: var(--font-display); font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-3); font-weight: 600; }
.dropzone-hint { font-size: 12px; color: var(--text-4); margin-top: 4px; }

.dropzone-preview { width: 100%; max-height: 180px; object-fit: cover; display: block; }
.dropzone.has-image { padding: 0; border-style: solid; }
.dropzone-overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .2s;
  font-family: var(--font-display); font-size: 11px; letter-spacing: 2px;
  text-transform: uppercase; color: #fff;
}
.dropzone.has-image:hover .dropzone-overlay { opacity: 1; }

/* ════════════════════════════════════════════
   ПАГИНАЦИЯ И ФИЛЬТРЫ
════════════════════════════════════════════ */
.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-chip {
  font-family: var(--font-display); font-size: 10.5px; letter-spacing: 1px;
  text-transform: uppercase; padding: 6px 16px;
  border: 1.5px solid var(--border);
  cursor: pointer; transition: all .15s;
  background: var(--surface-0); color: var(--text-3);
  border-radius: var(--radius);
}
.filter-chip:hover { border-color: var(--accent); color: var(--accent); }
.filter-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.pagination { display: flex; justify-content: center; gap: 6px; margin-top: 36px; }
.page-btn {
  width: 38px; height: 38px; display: flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--border); background: var(--surface-0);
  font-family: var(--font-display); font-size: 12px; cursor: pointer;
  transition: all .15s; border-radius: var(--radius); color: var(--text-2);
}
.page-btn:hover { border-color: var(--accent); color: var(--accent); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ════════════════════════════════════════════
   СПИННЕР И ПУСТЫЕ СОСТОЯНИЯ
════════════════════════════════════════════ */
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite; margin: 48px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state { text-align: center; padding: 64px 20px; color: var(--text-3); }
.empty-state-icon { font-size: 40px; margin-bottom: 16px; opacity: .3; }
.empty-state-title {
  font-family: var(--font-display); font-size: 14px; letter-spacing: 1.5px;
  text-transform: uppercase; margin-bottom: 8px; color: var(--text-1);
}
.empty-state-text { font-size: 14px; line-height: 1.6; }

/* ════════════════════════════════════════════
   ПРОГРЕСС ЗАГРУЗКИ
════════════════════════════════════════════ */
.upload-progress-wrap { margin-top: 10px; display: none; }
.upload-progress-wrap.show { display: block; }
.upload-progress-label {
  display: flex; justify-content: space-between;
  font-family: var(--font-display); font-size: 9.5px;
  letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--text-3); margin-bottom: 6px;
}
.upload-progress-bar {
  height: 5px; background: var(--surface-1); border-radius: 99px; overflow: hidden;
}
.upload-progress-fill {
  height: 100%; width: 0%; background: var(--accent);
  border-radius: 99px; transition: width .15s ease;
}

/* ════════════════════════════════════════════
   MARKDOWN-КОНТЕНТ (article viewer)
════════════════════════════════════════════ */
.md-content {
  font-size: var(--text-md);
  line-height: 1.8;
  color: var(--text-1);
}

.md-content > * + * { margin-top: 1em; }

.md-content h1, .md-content h2,
.md-content h3, .md-content h4, .md-content h5 {
  font-family: var(--font-display);
  font-weight: 700; text-transform: uppercase;
  letter-spacing: 1.5px; line-height: 1.25;
  color: var(--text-1);
}

.md-content h1 {
  font-size: 2rem; color: var(--accent);
  padding-left: 18px; border-left: 4px solid var(--accent);
  margin-top: 2.5em;
}
.md-content h1:first-child { margin-top: 0; }

.md-content h2 {
  font-size: 1.45rem; margin-top: 2em;
  padding-bottom: 10px; position: relative;
}
.md-content h2::after {
  content: '';
  position: absolute; bottom: 0; left: 0;
  width: 100%; height: 1.5px;
  background: linear-gradient(to right, var(--accent), transparent);
}

.md-content h3 {
  font-size: 1.1rem; color: var(--text-2);
  padding-left: 16px; position: relative; margin-top: 1.6em;
}
.md-content h3::before {
  content: ''; position: absolute; left: 0; top: .55em;
  width: 7px; height: 7px;
  background: var(--accent);
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}

.md-content h4 { font-size: 1rem; color: var(--text-3); }
.md-content h5 { font-size: 0.9rem; color: var(--text-4); font-weight: 600; }

.md-content p { margin-bottom: 0; }
.md-content a { color: var(--accent); font-weight: 500; border-bottom: 1px solid transparent; transition: border-color .2s; }
.md-content a:hover { border-bottom-color: var(--accent); }

.md-content ul, .md-content ol { padding-left: 1.4rem; }
.md-content ul { list-style: none; padding-left: 1.2rem; }
.md-content ul > li { position: relative; padding-left: 17px; margin-bottom: .4rem; }
.md-content ul > li::before {
  content: '';
  position: absolute; left: 0; top: .62em;
  width: 6px; height: 6px;
  background: var(--accent);
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}
.md-content ol { padding-left: 1.5rem; }
.md-content ol > li { margin-bottom: .4rem; }
.md-content ol > li::marker { color: var(--accent); font-family: var(--font-display); font-weight: 700; }

.md-content code {
  background: var(--surface-1); color: var(--text-1);
  font-family: var(--font-mono); font-size: 0.85em;
  padding: 2px 7px; border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.md-content pre {
  background: #111;
  border-top: 3px solid var(--accent);
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden; margin: 1.6em 0;
}
.md-content pre::before {
  content: '▮  DATA';
  display: block;
  background: #0A0A0A;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 9px; letter-spacing: 4px;
  padding: 8px 16px;
  border-bottom: 1px solid #2a2a2a;
}
.md-content pre code {
  display: block; padding: 18px; color: #E0DDD8;
  font-size: 14px; line-height: 1.65;
  background: none; border: none; border-radius: 0; font-size: 0.9em;
}

.md-content blockquote {
  border-left: 3px solid var(--border-strong);
  background: var(--surface-1); padding: 14px 20px; color: var(--text-2);
  font-style: italic;
  border-radius: 0 var(--radius) var(--radius) 0;
}

.md-content table {
  width: 100%; border-collapse: collapse; font-size: 0.93em;
  border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.md-content th {
  background: var(--text-1); color: var(--accent);
  font-family: var(--font-display); letter-spacing: 1.5px;
  text-transform: uppercase; font-size: .78em;
  padding: 11px 16px; text-align: left;
}
.md-content td { padding: 10px 16px; border-bottom: 1px solid var(--border); color: var(--text-2); }
.md-content tbody tr:last-child td { border-bottom: none; }
.md-content tbody tr:hover td { background: var(--surface-1); }
.md-content tbody tr:nth-child(even) td { background: var(--surface-0); }

.md-content hr {
  border: none; height: 1px; background: var(--border); margin: 2.5em 0;
}

.md-content img { border-radius: var(--radius); margin: 1em 0; }
.md-content video { border-radius: var(--radius); margin: 1em 0; }

/* ════════════════════════════════════════════
   CALLOUT-БЛОКИ
════════════════════════════════════════════ */
.md-content .callout {
  border-left: 4px solid var(--accent);
  background: var(--surface-1);
  margin: 1.6em 0; padding: 14px 18px 16px;
  font-style: normal;
  border-radius: 0 var(--radius) var(--radius) 0;
}
.md-content .callout p:last-child { margin-bottom: 0; }

.callout-header {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-display); font-weight: 700;
  font-size: 10.5px; letter-spacing: 2px; text-transform: uppercase;
  margin-bottom: 10px;
}
.callout-icon {
  width: 20px; height: 20px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; border-radius: 50%;
}

.callout-note     { border-left-color: var(--accent); }
.callout-note .callout-header     { color: var(--accent); }
.callout-note .callout-icon       { background: var(--accent-light); color: var(--accent); }

.callout-tip      { border-left-color: var(--success); background: var(--success-bg); }
.callout-tip .callout-header      { color: var(--success); }
.callout-tip .callout-icon        { background: var(--success-bg); color: var(--success); }

.callout-important{ border-left-color: #6B5CE7; background: rgba(107,92,231,.07); }
.callout-important .callout-header{ color: #6B5CE7; }
.callout-important .callout-icon  { background: rgba(107,92,231,.15); color: #6B5CE7; }

.callout-warning  { border-left-color: var(--warning); background: var(--warning-bg); }
.callout-warning .callout-header  { color: var(--warning); }
.callout-warning .callout-icon    { background: var(--warning-bg); color: var(--warning); }

.callout-caution  { border-left-color: var(--danger); background: var(--danger-bg); }
.callout-caution .callout-header  { color: var(--danger); }
.callout-caution .callout-icon    { background: var(--danger-bg); color: var(--danger); }

/* ════════════════════════════════════════════
   МЕДИА С ПОДПИСЯМИ
════════════════════════════════════════════ */
.md-content .md-figure {
  margin: 1.6em 0; border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.md-content .md-figure img,
.md-content .md-figure video {
  display: block; width: 100%; margin: 0; border-radius: 0;
}
.md-content figcaption {
  font-family: var(--font-display); font-size: 10.5px;
  letter-spacing: 1px; text-transform: uppercase;
  color: var(--text-3); background: var(--surface-1);
  padding: 9px 14px; border-top: 1px solid var(--border);
}
.md-content video {
  max-height: 520px; background: #000;
  border-radius: var(--radius); box-shadow: var(--shadow);
}

/* ════════════════════════════════════════════
   КОММЕНТАРИИ
════════════════════════════════════════════ */
.comments-section { margin-top: 56px; padding-top: 40px; border-top: 1px solid var(--border); }
.comments-section-title {
  font-family: var(--font-display); font-weight: 700;
  font-size: 13px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--text-1); margin-bottom: 28px;
  display: flex; align-items: center; gap: 10px;
}
.comments-count {
  background: var(--accent-light); color: var(--accent);
  font-size: 10px; padding: 2px 9px;
  border-radius: var(--radius-sm);
}

.comment-list { display: flex; flex-direction: column; gap: 20px; margin-bottom: 32px; }

.comment-item {
  display: flex; gap: 16px; padding: 20px;
  background: var(--surface-0);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
}
.comment-avatar {
  width: 42px; height: 42px; flex-shrink: 0;
  border-radius: calc(var(--radius) - 1px); overflow: hidden;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700;
  font-size: 15px; color: #fff;
}
.comment-avatar img { width: 100%; height: 100%; object-fit: cover; }

.comment-body { flex: 1; min-width: 0; }
.comment-header {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin-bottom: 8px; flex-wrap: wrap;
}
.comment-author { font-weight: 600; font-size: 14.5px; color: var(--text-1); }
.comment-date   { font-size: var(--text-xs); color: var(--text-4); }
.comment-text   { font-size: 14.5px; color: var(--text-2); line-height: 1.7; white-space: pre-wrap; word-break: break-word; }
.comment-actions { margin-top: 8px; display: flex; gap: 8px; }
.comment-del-btn {
  font-family: var(--font-display); font-size: 9px; letter-spacing: 1px;
  text-transform: uppercase; color: var(--text-4);
  background: none; border: none; cursor: pointer; padding: 2px 0;
  transition: color .15s;
}
.comment-del-btn:hover { color: var(--danger); }

/* Форма нового комментария */
.comment-form {
  background: var(--surface-0);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow-xs);
}
.comment-form-header { font-family: var(--font-display); font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: var(--text-3); margin-bottom: 12px; }
.comment-textarea {
  width: 100%; min-height: 90px; padding: 12px 14px;
  border: 1.5px solid var(--border); border-radius: var(--radius);
  background: var(--surface-0); font-size: 14.5px; color: var(--text-1);
  line-height: 1.6; resize: vertical; outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.comment-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.comment-form-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; gap: 12px; }
.comment-form-hint { font-size: 12px; color: var(--text-4); }

/* ════════════════════════════════════════════
   АВАТАР-ПИКЕР (профиль)
════════════════════════════════════════════ */
.avatar-picker { position: relative; display: inline-block; }
.avatar-lg {
  width: 96px; height: 96px;
  border-radius: calc(var(--radius) + 2px);
  overflow: hidden;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700;
  font-size: 32px; color: #fff; cursor: pointer;
  border: 3px solid var(--accent); box-shadow: var(--shadow);
  transition: opacity .2s;
}
.avatar-lg img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg:hover { opacity: .85; }
.avatar-edit-btn {
  position: absolute; bottom: -6px; right: -6px;
  width: 28px; height: 28px;
  background: var(--accent); color: #fff;
  border: 2px solid var(--surface-0); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; cursor: pointer; pointer-events: none;
}

/* ════════════════════════════════════════════
   РЕДАКТОР — допы
════════════════════════════════════════════ */
.ed-mddropdown { position: relative; }
.ed-mddropdown-menu {
  display: none; position: absolute; top: calc(100% + 4px); left: 0;
  background: var(--text-1); border: 1px solid #2a2a2a;
  border-top: 2px solid var(--accent);
  min-width: 200px; z-index: 50; box-shadow: var(--shadow-lg);
  border-radius: 0 0 var(--radius) var(--radius); overflow: hidden;
}
.ed-mddropdown-menu.open { display: block; }
.ed-mddropdown-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; font-size: 13px; color: rgba(255,255,255,0.8);
  cursor: pointer; transition: background .15s;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.ed-mddropdown-item:last-child { border-bottom: none; }
.ed-mddropdown-item:hover { background: rgba(255,85,0,0.12); color: var(--accent); }
.ed-mddropdown-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ════════════════════════════════════════════
   МЕДИАБИБЛИОТЕКА
════════════════════════════════════════════ */
.media-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.media-search  { display: flex; align-items: center; gap: 10px; flex: 1; max-width: 280px; }
.media-search input { flex: 1; }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }

.media-card {
  background: var(--surface-0); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; position: relative;
  box-shadow: var(--shadow-xs);
  transition: box-shadow .2s, transform .2s;
}
.media-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }

.media-thumb-wrap {
  width: 100%; height: 140px; background: var(--text-1);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.media-thumb-wrap img, .media-thumb-wrap video { width: 100%; height: 100%; object-fit: cover; }

.media-type-badge {
  position: absolute; top: 8px; left: 8px;
  font-family: var(--font-display); font-size: 8px; letter-spacing: 1.5px; text-transform: uppercase;
  padding: 3px 8px; color: #fff; background: rgba(0,0,0,0.65);
  border-radius: var(--radius-sm);
}
.media-type-badge.video { color: #FFB380; }

.media-card-body { padding: 11px 13px; }
.media-card-name {
  font-size: 12.5px; font-weight: 500; color: var(--text-1);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 4px;
}
.media-card-meta {
  display: flex; justify-content: space-between;
  font-family: var(--font-display); font-size: 9px; letter-spacing: .5px;
  color: var(--text-4);
}
.media-card-used { margin-top: 5px; font-size: 10.5px; color: var(--warning); display: flex; align-items: center; gap: 4px; }
.media-card-used::before { content: '●'; font-size: 7px; }

.media-card-actions {
  position: absolute; top: 8px; right: 8px;
  display: flex; gap: 5px; opacity: 0; transition: opacity .2s;
}
.media-card:hover .media-card-actions { opacity: 1; }
.media-card-actions button {
  width: 28px; height: 28px;
  background: rgba(0,0,0,0.7); border: none; color: #fff; font-size: 12px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .15s; border-radius: var(--radius-sm);
}
.media-card-actions button:hover { background: var(--accent); }
.media-card-actions button.danger:hover { background: var(--danger); }

.media-upload-dz { height: 140px; margin-bottom: 20px; }

/* ════════════════════════════════════════════
   ФУТЕР
════════════════════════════════════════════ */
.app-footer { background: var(--text-1); border-top: 1px solid rgba(255,255,255,0.06); padding: 28px 0; }
.app-footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.app-footer-logo { font-family: var(--font-display); font-weight: 700; font-size: 15px; letter-spacing: 3px; text-transform: uppercase; color: rgba(255,255,255,0.55); }
.app-footer-logo b { color: var(--accent); }
.app-footer-text { font-size: 12px; color: rgba(255,255,255,0.25); }

/* ════════════════════════════════════════════
   ИКОНКА-КНОПКИ
════════════════════════════════════════════ */
.icon-btn {
  background: none; border: none; color: var(--text-3);
  font-size: 14px; padding: 6px 8px; cursor: pointer;
  transition: color .15s; border-radius: var(--radius-sm);
}
.icon-btn:hover        { color: var(--accent); background: var(--accent-light); }
.icon-btn.danger:hover { color: var(--danger); background: var(--danger-bg); }

/* ════════════════════════════════════════════
   АДАПТИВ
════════════════════════════════════════════ */
@media (max-width: 600px) {
  .media-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .modal-box  { max-width: 100%; }
  .comment-item { gap: 12px; }
  .comment-avatar { width: 36px; height: 36px; font-size: 13px; }
}

/* ════════════════════════════════════════════
   BLOOM EFFECT — анимированное свечение на видео в hero
════════════════════════════════════════════ */
.hero-bloom {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  overflow: hidden;
}

.hero-bloom::before {
  content: '';
  position: absolute;
  bottom: -20%; left: 5%;
  width: 50%; height: 80%;
  background: radial-gradient(ellipse, rgba(255,85,0,0.20) 0%, transparent 65%);
  mix-blend-mode: screen;
  filter: blur(48px);
  animation: bloom-drift-a 9s ease-in-out infinite;
}

.hero-bloom::after {
  content: '';
  position: absolute;
  top: -10%; right: 10%;
  width: 40%; height: 60%;
  background: radial-gradient(ellipse, rgba(255,120,60,0.12) 0%, transparent 60%);
  mix-blend-mode: screen;
  filter: blur(36px);
  animation: bloom-drift-b 7s ease-in-out infinite;
}

@keyframes bloom-drift-a {
  0%, 100% { transform: translate(0, 0) scale(1);    opacity: 0.7; }
  40%      { transform: translate(4%, -5%) scale(1.1); opacity: 1; }
  70%      { transform: translate(-2%, 3%) scale(0.95); opacity: 0.8; }
}
@keyframes bloom-drift-b {
  0%, 100% { transform: translate(0, 0) scale(1);     opacity: 0.5; }
  35%      { transform: translate(-4%, 4%) scale(1.08); opacity: 0.8; }
  70%      { transform: translate(3%, -2%) scale(0.97); opacity: 0.6; }
}

.hero-media-wrap video,
.hero-media-wrap img.hero-gif {
  filter: brightness(0.82) saturate(1.15) contrast(1.05);
}

/* Gradient text on hero b tag */
.hero h1 b,
.hero-title-accent {
  background: linear-gradient(120deg, var(--accent), #FF9A5C);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ════════════════════════════════════════════
   READING PROGRESS BAR
════════════════════════════════════════════ */
#reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 9999;
  background: transparent;
  pointer-events: none;
}
#reading-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(to right, var(--accent), #FF9A5C);
  transition: width .1s linear;
  box-shadow: 0 0 8px var(--accent-glow);
}

/* ════════════════════════════════════════════
   SEARCH OVERLAY (Cmd+K / /)
════════════════════════════════════════════ */
#search-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: clamp(60px, 12vh, 120px);
}
#search-overlay.open { display: flex; }

.so-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.so-panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 640px;
  background: var(--surface-0);
  border: 1px solid var(--border);
  border-top: 2px solid var(--accent);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  animation: so-slide-in .18s ease;
}
@keyframes so-slide-in {
  from { opacity: 0; transform: translateY(-12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.so-input-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
  height: 58px;
  border-bottom: 1px solid var(--border);
}
.so-search-icon {
  font-size: 18px;
  color: var(--text-3);
  flex-shrink: 0;
  line-height: 1;
}
.so-input {
  flex: 1;
  border: none;
  outline: none;
  background: none;
  font-size: 17px;
  color: var(--text-1);
  font-family: var(--font-body);
}
.so-input::placeholder { color: var(--text-4); }
.so-kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 3px 8px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-3);
  flex-shrink: 0;
}

.so-results {
  max-height: 420px;
  overflow-y: auto;
}
.so-group-label {
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-4);
  padding: 12px 18px 6px;
}
.so-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  cursor: pointer;
  transition: background .12s;
  border-radius: 0;
  text-decoration: none;
  color: inherit;
}
.so-item:hover,
.so-item.active { background: var(--surface-1); }
.so-item.active .so-item-title { color: var(--accent); }

.so-item-icon {
  width: 34px;
  height: 34px;
  background: var(--surface-1);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
  color: var(--text-3);
  border: 1px solid var(--border);
}
.so-item.active .so-item-icon { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }

.so-item-body { flex: 1; min-width: 0; }
.so-item-title {
  font-size: 14.5px;
  font-weight: 500;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
  transition: color .12s;
}
.so-item-sub {
  font-size: 12px;
  color: var(--text-4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.so-item-arrow { color: var(--text-4); font-size: 14px; flex-shrink: 0; }

.so-hint-box {
  padding: 32px 20px;
  text-align: center;
  color: var(--text-3);
  font-size: 14px;
}
.so-shortcuts-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 10px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface-1);
}
.so-sc-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-4);
}

/* ════════════════════════════════════════════
   ARTICLE PREVIEW MODAL
════════════════════════════════════════════ */
#preview-modal {
  position: fixed;
  inset: 0;
  z-index: 800;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
#preview-modal.open { display: flex; }

.pm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.pm-panel {
  position: relative;
  z-index: 1;
  background: var(--surface-0);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 700px;
  max-height: 88vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: pm-in .2s ease;
}
@keyframes pm-in {
  from { opacity: 0; transform: scale(0.96) translateY(12px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.pm-cover {
  width: 100%;
  height: 200px;
  object-fit: cover;
  display: block;
  flex-shrink: 0;
}

.pm-body {
  padding: 28px 32px 24px;
  overflow-y: auto;
  flex: 1;
}

.pm-category {
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-light);
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  display: inline-block;
  margin-bottom: 14px;
}

.pm-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--text-1);
  line-height: 1.25;
  margin-bottom: 14px;
}

.pm-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.pm-author { display: flex; align-items: center; gap: 9px; }
.pm-avatar {
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; font-size: 12px; color: #fff;
  flex-shrink: 0;
}
.pm-avatar img { width: 100%; height: 100%; object-fit: cover; }
.pm-author-name { font-size: 14px; font-weight: 500; color: var(--text-1); }
.pm-date        { font-size: 12.5px; color: var(--text-3); }
.pm-read-time   { font-size: 12.5px; color: var(--text-3); }
.pm-meta-sep    { width: 3px; height: 3px; background: var(--accent); clip-path: polygon(50% 0%,100% 50%,50% 100%,0% 50%); }

.pm-excerpt {
  font-size: 15px;
  color: var(--text-2);
  line-height: 1.8;
}

.pm-footer {
  padding: 18px 32px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  background: var(--surface-0);
}

.pm-close-btn {
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 14px;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  transition: color .15s;
}
.pm-close-btn:hover { color: var(--text-1); }

/* Кнопка предпросмотра на карточке статьи */
.art-preview-trigger {
  position: absolute;
  inset: 0;
  opacity: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(2px);
  transition: opacity .18s;
  cursor: pointer;
  border-radius: var(--radius);
}
.art-card:hover .art-preview-trigger { opacity: 1; }
.art-preview-trigger span {
  background: var(--surface-0);
  color: var(--text-1);
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 8px 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-weight: 600;
}

/* ════════════════════════════════════════════
   FEATURED ARTICLES (закреплённые)
════════════════════════════════════════════ */
.featured-section {
  background: var(--surface-0);
  border-bottom: 1px solid var(--border);
  padding: 40px 0;
}
.featured-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  margin-top: 20px;
}
.featured-card {
  position: relative;
  background: var(--text-1);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: block;
  min-height: 220px;
  box-shadow: var(--shadow-lg);
  transition: transform .2s, box-shadow .2s;
}
.featured-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-xl); }

.featured-card-bg {
  position: absolute;
  inset: 0;
  object-fit: cover;
  width: 100%;
  height: 100%;
  opacity: 0.45;
  filter: saturate(0.8);
}
.featured-card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(10,10,10,0.95) 0%, rgba(10,10,10,0.3) 60%, transparent 100%);
}

.featured-card-body {
  position: relative;
  z-index: 1;
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 220px;
}
.featured-pin-badge {
  position: absolute;
  top: 16px; right: 16px;
  background: var(--accent);
  color: #fff;
  font-family: var(--font-display);
  font-size: 8.5px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
}
.featured-cat {
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}
.featured-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: .5px;
  text-transform: uppercase;
  line-height: 1.25;
  color: #fff;
  margin-bottom: 10px;
}
.featured-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.45);
}

/* ════════════════════════════════════════════
   HOMEPAGE LAYOUT — 2 колонки
════════════════════════════════════════════ */
.home-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 0;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 28px;
  align-items: start;
}
@media (max-width: 1100px) {
  .home-layout { grid-template-columns: 1fr; }
  .home-cat-panel { display: none !important; }
}

.home-feed { min-width: 0; padding: 40px 0; padding-right: 36px; }
@media (max-width: 1100px) { .home-feed { padding-right: 0; } }

/* Категориальная панель (правая) */
.home-cat-panel {
  padding: 40px 0 40px 28px;
  border-left: 1px solid var(--border);
  position: sticky;
  top: 62px;
  max-height: calc(100vh - 62px);
  overflow: hidden;               /* без общей полосы на всю панель */
  display: flex;
  flex-direction: column;
}
/* Список разделов — «карусель»: прокрутка есть (колесо/свайп/трекпад),
   но видимой полосы нет; у краёв мягкое затухание как подсказка, что можно листать.
   Классы .sc-top / .sc-bot навешивает home.js по позиции скролла. */
#cat-panel-list {
  overflow-y: auto;
  min-height: 0;
  flex: 0 1 auto;
  scrollbar-width: none;            /* Firefox */
  -ms-overflow-style: none;         /* старый Edge/IE */
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}
#cat-panel-list::-webkit-scrollbar { display: none; width: 0; height: 0; }
#cat-panel-list.sc-top:not(.sc-bot) {
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 14px);
          mask-image: linear-gradient(to bottom, transparent 0, #000 14px);
}
#cat-panel-list.sc-bot:not(.sc-top) {
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 14px), transparent 100%);
          mask-image: linear-gradient(to bottom, #000 calc(100% - 14px), transparent 100%);
}
#cat-panel-list.sc-top.sc-bot {
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 14px, #000 calc(100% - 14px), transparent 100%);
          mask-image: linear-gradient(to bottom, transparent 0, #000 14px, #000 calc(100% - 14px), transparent 100%);
}
/* Календарь прижат под списком, не сжимается */
.home-cat-panel .home-calendar { flex-shrink: 0; }

.cat-panel-title {
  font-family: var(--font-display);
  font-size: 9.5px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--text-4);
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.cat-panel-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .15s, color .15s;
  margin-bottom: 2px;
  color: var(--text-2);
}
.cat-panel-item:hover { background: var(--surface-1); color: var(--text-1); }
.cat-panel-item.active { background: var(--accent-light); color: var(--accent); }
.cat-panel-item.active .cat-panel-icon { border-color: var(--accent); color: var(--accent); }

.cat-panel-icon {
  width: 28px; height: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; flex-shrink: 0;
  transition: all .15s;
}
.cat-panel-name { font-size: 13.5px; font-weight: 500; flex: 1; }
.cat-panel-count {
  font-family: var(--font-display);
  font-size: 9px;
  color: var(--text-4);
  background: var(--surface-1);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  min-width: 28px;
  text-align: center;
}
.cat-panel-item.active .cat-panel-count { background: rgba(255,85,0,0.15); color: var(--accent); }

.cat-panel-divider { height: 1px; background: var(--border); margin: 10px 0; }

/* ════════════════════════════════════════════
   SKELETON LOADING
════════════════════════════════════════════ */
.skeleton {
  background: var(--surface-1);
  border-radius: var(--radius-sm);
  animation: skeleton-pulse 1.6s ease-in-out infinite;
}
@keyframes skeleton-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

.art-card-skeleton {
  background: var(--surface-0);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 20px;
  box-shadow: var(--shadow-xs);
}
.sk-cover  { height: 130px; margin-bottom: 14px; border-radius: var(--radius-sm); }
.sk-tag    { width: 80px; height: 18px; margin-bottom: 10px; }
.sk-title  { width: 85%; height: 18px; margin-bottom: 6px; }
.sk-title2 { width: 60%; height: 18px; margin-bottom: 10px; }
.sk-text   { width: 100%; height: 13px; margin-bottom: 5px; }
.sk-text2  { width: 75%; height: 13px; }

/* ════════════════════════════════════════════
   KEYBOARD SHORTCUTS PANEL (?-клавиша)
════════════════════════════════════════════ */
#shortcuts-panel {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
#shortcuts-panel.open { display: flex; }

.sp-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(4px);
}
.sp-box {
  position: relative;
  background: var(--surface-0);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 480px;
  padding: 28px 32px;
  animation: pm-in .18s ease;
}
.sp-title {
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--text-1);
  margin-bottom: 22px;
  font-weight: 700;
}
.sp-group { margin-bottom: 18px; }
.sp-group-label {
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-4);
  margin-bottom: 10px;
}
.sp-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.sp-row:last-child { border-bottom: none; }
.sp-action { font-size: 13.5px; color: var(--text-2); }
.sp-keys   { display: flex; gap: 4px; align-items: center; }
.sp-key {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 7px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-bottom: 2px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-2);
}

/* ════════════════════════════════════════════
   NAV SEARCH TRIGGER STYLE UPDATE
════════════════════════════════════════════ */
.app-nav-search-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  max-width: 340px;
  height: 36px;
  padding: 0 14px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .2s, background .2s;
  color: rgba(255,255,255,0.4);
  font-size: 13px;
}
.app-nav-search-trigger:hover {
  border-color: var(--accent);
  background: rgba(255,255,255,0.1);
}
.app-nav-search-trigger .trigger-kbd {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 6px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.3);
}

/* ════════════════════════════════════════════
   УБРАТЬ ЭМОДЗИ из интерфейса — override defaults
════════════════════════════════════════════ */
.dropzone-icon::before {
  font-style: normal;
  font-size: 16px;
}

/* Pin badge */
.pin-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-display);
  font-size: 8.5px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-light);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}
.pin-badge::before {
  content: '▲';
  font-size: 7px;
}

/* ════════════════════════════════════════════
   ADMIN — ARTICLES MANAGEMENT TAB
════════════════════════════════════════════ */
.admin-art-table .pin-toggle {
  background: none;
  border: 1px solid var(--border);
  padding: 3px 10px;
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: var(--radius-sm);
  color: var(--text-3);
  transition: all .15s;
}
.admin-art-table .pin-toggle:hover { border-color: var(--accent); color: var(--accent); }
.admin-art-table .pin-toggle.pinned {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

/* ════════════════════════════════════════════
   SEARCH HIGHLIGHT
════════════════════════════════════════════ */
.search-highlight {
  background: rgba(255,85,0,0.18);
  color: var(--accent);
  border-radius: 2px;
  padding: 0 2px;
}

/* ════════════════════════════════════════════
   RESPONSIVE FIXES
════════════════════════════════════════════ */
@media (max-width: 640px) {
  .pm-body  { padding: 20px; }
  .pm-footer { padding: 14px 20px; }
  .sp-box { padding: 22px 20px; }
}

/* ════════════════════════════════════════════════════════════
   PWA + MOBILE — iOS safe area, bottom nav, touch UX
   Добавляется поверх основной темы
   ════════════════════════════════════════════════════════════ */

/* ── Safe Area переменные ──────────────────────────────────── */
:root {
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --bnav-height: 0px;         /* переопределяется через pwa.js */
}

/* ── Базовый reset для touch ───────────────────────────────── */
* {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}
a, button, [role="button"], input, select, textarea, label {
  touch-action: manipulation;
}
/* Разрешаем выделение текста в контенте */
.md-content, .comment-text, p, h1, h2, h3, h4, h5,
.field-input, .field-textarea, .comment-textarea {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

/* ── СТРОГОЕ УДАЛЕНИЕ EMOJI ────────────────────────────────── */
/* Все иконки-кнопки на основе чистых Unicode/SVG */
.btn-icon-only::before { font-style: normal; }

/* ── Навигация с учётом Dynamic Island / Notch ─────────────── */
.app-nav {
  padding-top: var(--sat);  /* поднимаем выше челки */
  height: calc(62px + var(--sat));
}
.app-nav-inner {
  height: 62px; /* фиксированная высота контента навбара */
}

/* ── Bottom Navigation ──────────────────────────────────────── */
.mobile-bnav {
  display: none; /* показываем только на мобильных через медиа-запрос */
}

@media (max-width: 768px) {
  .mobile-bnav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 300;
    background: var(--nav-bg);
    border-top: 1px solid rgba(255,85,0,0.2);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.35);
    padding-bottom: var(--sab);
    height: calc(60px + var(--sab));
    align-items: stretch;
    justify-content: space-around;
  }

  /* Отступ body снизу для bottom nav */
  body {
    padding-bottom: calc(60px + var(--sab));
  }
}

.bnav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px 6px;
  color: rgba(255,255,255,0.45);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: color .15s;
  position: relative;
  min-width: 0;
}

.bnav-item.active {
  color: var(--accent);
}

.bnav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 2px;
  background: var(--accent);
  border-radius: 0 0 2px 2px;
}

.bnav-item:active { opacity: 0.7; transform: scale(0.95); }

.bnav-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.bnav-icon svg { width: 22px; height: 22px; }

.bnav-label {
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.bnav-create .bnav-icon {
  background: var(--accent);
  border-radius: var(--radius);
  width: 34px;
  height: 34px;
  color: #fff;
}
.bnav-create { color: rgba(255,255,255,0.45); }
.bnav-create.active, .bnav-create:hover { color: var(--accent); }
.bnav-create.active .bnav-icon,
.bnav-create:hover .bnav-icon { background: var(--accent-dark); }

/* ── PWA Install Banner ──────────────────────────────────────── */
.pwa-banner {
  position: fixed;
  bottom: calc(60px + var(--sab) + 12px);
  left: 12px;
  right: 12px;
  background: var(--surface-0);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  z-index: 400;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity .3s, transform .3s;
}
.pwa-banner.show { opacity: 1; transform: translateY(0); }

.pwa-banner-icon {
  width: 40px; height: 40px; flex-shrink: 0;
  background: var(--nav-bg);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700;
  font-size: 12px; letter-spacing: 1px; color: var(--accent);
  border: 2px solid var(--accent);
}
.pwa-banner-text { flex: 1; min-width: 0; }
.pwa-banner-title { font-weight: 600; font-size: 13.5px; color: var(--text-1); }
.pwa-banner-sub   { font-size: 12px; color: var(--text-3); }
.pwa-banner-btn {
  flex-shrink: 0;
  background: var(--accent); color: #fff;
  border: none; border-radius: var(--radius);
  font-family: var(--font-display); font-size: 10px;
  letter-spacing: 1.5px; text-transform: uppercase;
  padding: 8px 14px; cursor: pointer;
  font-weight: 600;
}
.pwa-banner-btn:hover { background: var(--accent-dark); }
.pwa-banner-close {
  flex-shrink: 0;
  background: none; border: none;
  color: var(--text-3); font-size: 16px;
  cursor: pointer; padding: 4px; line-height: 1;
}

/* ── Offline Bar ──────────────────────────────────────────────── */
.offline-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  background: #8a5a00;
  color: #fff;
  text-align: center;
  font-family: var(--font-display);
  font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase;
  padding: calc(var(--sat) + 6px) 16px 6px;
  z-index: 9999;
}

/* ── Mobile Container ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .container { padding: 0 16px; }

  /* Скрываем десктопную навигацию на мобильном */
  .app-nav-links  { display: none !important; }
  .app-nav-search { display: none !important; }
  .app-nav-search-trigger { display: none !important; }
  /* Бургер тоже скрываем — заменяем bottom nav */
  .app-nav-burger { display: none !important; }

  /* Логотип слева, иконки поиска и уведомлений — вместе справа */
  .app-nav-inner { justify-content: flex-start; padding: 0 16px; gap: 10px; }
  .app-logo { margin-right: auto; }
  .app-logo-name { font-size: 15px; letter-spacing: 2px; }

  /* Добавляем кнопку поиска в навбар справа на мобильном */
  .app-nav-mobile-search {
    width: 36px; height: 36px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    color: rgba(255,255,255,0.6); cursor: pointer; font-size: 16px;
    flex-shrink: 0;
  }
  .app-nav-mobile-notif {
    position: relative;
    width: 36px; height: 36px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    color: rgba(255,255,255,0.6); cursor: pointer;
    flex-shrink: 0; margin-left: 0;
  }
  .app-nav-mobile-notif .nav-notif-badge {
    position: absolute; top: -5px; right: -5px;
    min-width: 17px; height: 17px; padding: 0 4px;
    background: var(--accent); color: #fff; font-size: 10px; font-weight: 700;
    border-radius: 9px; display: flex; align-items: center; justify-content: center;
    border: 2px solid var(--nav-bg);
  }
}

/* ── Mobile Hero ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .hero { padding: 44px 0 36px; }
  .hero h1 { font-size: clamp(22px, 7vw, 34px); }
  .hero-sub { font-size: 14px; margin-bottom: 22px; }
  .hero-stats { gap: 16px; flex-wrap: wrap; }
  .hero-stat-num { font-size: 22px; }
  .hero-stat-sep { display: none; }
}

/* ── Mobile Home Layout ────────────────────────────────────────── */
@media (max-width: 1100px) {
  .home-cat-panel { display: none; }
  .home-feed { padding-right: 0; padding: 24px 0; }
}
@media (max-width: 768px) {
  .home-layout { padding: 0 16px; }
  .home-feed   { padding: 20px 0; }
  .art-grid    { grid-template-columns: 1fr; gap: 12px; }
  .featured-grid { grid-template-columns: 1fr; gap: 12px; }
  .featured-section { padding: 28px 0; }

  /* Горизонтальный скролл для категорий на мобиле */
  .cats-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
  }

  /* Toolbar stack */
  .toolbar-row { flex-direction: column; align-items: flex-start; gap: 10px; }
}

/* ── Mobile Article ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .art-layout    { flex-direction: column; }
  .art-sidebar   { display: none !important; }
  .art-content-area { padding: 24px 0 48px; }
  .art-inner     { padding: 0 16px !important; }
  .art-title     { font-size: clamp(18px, 6vw, 26px); }
  .art-title-row { flex-direction: column; gap: 12px; }
  .art-actions   { flex-wrap: wrap; }
  .art-meta-bar  { padding-left: 0; gap: 10px; }
  .art-cover     { border-radius: var(--radius); max-height: 240px; }

  /* Комментарии на мобиле */
  .comment-item  { padding: 14px; gap: 10px; }
  .comment-form  { padding: 16px; }
}

/* ── Mobile Editor ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .ed-wrap { padding: 16px 0 60px; }
  .ed-head { flex-direction: column; gap: 12px; margin-bottom: 16px; }
  .ed-layout { grid-template-columns: 1fr !important; }
  .ed-mdtoolbar { flex-wrap: wrap; gap: 1px; }
  .ed-mdbtn { width: 36px; height: 36px; font-size: 13px; }
  #ed-textarea { min-height: 320px; font-size: 15px; }
}

/* ── Mobile Admin ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .adm-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; border-bottom: 2px solid var(--border); }
  .adm-tab  { white-space: nowrap; padding: 10px 14px; font-size: 10px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .data-table { font-size: 12px; }
  .data-table thead th { padding: 10px 10px; }
  .data-table tbody td { padding: 10px 10px; }
  .settings-grid { grid-template-columns: 1fr !important; gap: 20px; }
  .settings-colors-grid { grid-template-columns: 1fr !important; }
  .media-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
}

/* ── Mobile Profile ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .prof-hero-inner { gap: 16px; padding: 0 16px; }
  .prof-avatar { width: 72px; height: 72px; font-size: 24px; }
  .prof-name   { font-size: 20px; }
  .prof-body   { padding: 24px 16px; }
  .prof-edit-grid { grid-template-columns: 1fr; }
  .prof-articles-grid { grid-template-columns: 1fr; gap: 12px; }
  .prof-tabs   { gap: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; }
  .prof-tab    { white-space: nowrap; font-size: 10px; padding: 10px 14px; flex-shrink: 0; }
}

/* ── Mobile Modal — снизу как sheet ───────────────────────────── */
@media (max-width: 768px) {
  .modal-overlay {
    align-items: flex-end !important;
    padding: 0 !important;
  }
  .modal-box {
    max-width: 100% !important;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0 !important;
    border-top: 3px solid var(--accent) !important;
    max-height: 92vh;
    padding-bottom: var(--sab);
  }
  .modal-box::before {
    content: '';
    display: block;
    width: 32px; height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 10px auto 0;
  }

  /* Search overlay на мобиле — компактный bottom sheet */
  #search-overlay { padding: 0; align-items: flex-end; }
  .so-panel {
    max-width: 100%;
    width: 100%;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    max-height: 80vh;
    padding-bottom: var(--sab);
  }
  .so-input-wrap { height: 54px; padding: 0 16px; }
  .so-input { font-size: 16px; }  /* 16px чтобы iOS не зумил */
  .so-results { max-height: calc(80vh - 130px); }

  /* Preview modal снизу */
  #preview-modal { padding: 0; align-items: flex-end; }
  .pm-panel {
    max-width: 100%;
    width: 100%;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    max-height: 90vh;
    padding-bottom: var(--sab);
  }
}

/* ── Dropzone — крестик удаления ────────────────────────────── */
.dropzone-clear {
  position: absolute;
  top: 8px; right: 8px;
  width: 26px; height: 26px;
  background: rgba(10,10,10,0.7);
  border: none; border-radius: 50%;
  color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; line-height: 1;
  z-index: 5;
  transition: background .15s;
}
.dropzone-clear:hover { background: var(--danger); }

/* ── Editor Toolbar — улучшенный дизайн ────────────────────── */
.ed-mdtoolbar-wrap {
  background: var(--nav-bg);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
}

/* Переопределяем старые стили тулбара */
.ed-mdtoolbar {
  display: flex !important;
  align-items: center;
  gap: 1px;
  flex-wrap: wrap;
  background: transparent !important;
  padding: 0 !important;
}

.ed-mdbtn {
  width: 34px !important; height: 34px !important;
  border-radius: var(--radius-sm) !important;
  color: rgba(255,255,255,0.65) !important;
  font-size: 13px !important;
  font-family: var(--font-display) !important;
  letter-spacing: 0 !important;
  transition: all .15s !important;
}
.ed-mdbtn:hover { background: rgba(255,85,0,0.2) !important; color: var(--accent) !important; }
.ed-mdbtn.active-tab { color: var(--accent) !important; background: rgba(255,85,0,0.15) !important; }

/* Группы кнопок */
.ed-mdsep {
  width: 1px !important;
  height: 22px !important;
  background: rgba(255,255,255,0.1) !important;
  margin: 0 3px !important;
}

.ed-editarea-wrap {
  border: 1px solid var(--border) !important;
  border-top: none !important;
  border-radius: 0 0 var(--radius) var(--radius) !important;
  overflow: hidden;
}

/* ── Login Page Mobile ─────────────────────────────────────── */
@media (max-width: 760px) {
  /* На мобиле — одна колонка, без левой панели */
  .lg-left { display: none; }
  .lg-right {
    width: 100%; min-height: 100vh;
    background: var(--page-bg);
    display: flex; flex-direction: column;
  }

  /* iOS safe area */
  .lg-form-wrap {
    padding: calc(var(--sat) + 40px) 24px 40px;
    flex: 1;
  }

  /* Логотип вверху страницы на мобиле */
  .lg-mobile-logo {
    display: flex !important;
    align-items: center; gap: 10px;
    justify-content: center;
    padding: calc(var(--sat) + 24px) 24px 0;
    background: var(--nav-bg);
    border-bottom: 2px solid var(--accent);
  }
  .lg-mobile-logo-icon { width: 30px; height: 30px; border: 2px solid var(--accent); display: flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); }
  .lg-mobile-logo-icon::before { content: ''; width: 9px; height: 9px; background: var(--accent); clip-path: polygon(50% 0%,100% 50%,50% 100%,0% 50%); }
  .lg-mobile-logo-name { font-family: var(--font-display); font-weight: 700; font-size: 16px; letter-spacing: 3px; text-transform: uppercase; color: #fff; }
  .lg-mobile-logo-name b { color: var(--accent); }

  .lg-title { font-size: 22px; }
  .lg-sub   { font-size: 13px; }
  .lg-footer { padding-bottom: calc(var(--sab) + 12px); }
}

/* Скрываем мобильный логотип на десктопе */
.lg-mobile-logo { display: none; }

/* ── Кнопки — минимум 44px для iOS HIG ──────────────────── */
@media (max-width: 768px) {
  .btn, .filter-chip, .page-btn, .adm-tab,
  .field-input, .field-select, .cat-panel-item,
  .so-item, .app-user-dropdown-item {
    min-height: 44px;
  }
  .btn-sm { min-height: 36px; }
  .field-input, .field-select { height: 48px !important; font-size: 16px !important; } /* 16px — предотвращает zoom на iOS */
  .field-textarea { font-size: 16px !important; }
}

/* ── Scrolling improvements ───────────────────────────────── */
.so-results,
.modal-box,
.pm-panel .pm-body,
.art-sidebar,
.home-cat-panel,
.adm-tabs,
.prof-tabs {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* ── Tap feedback (ripple alternative) ───────────────────── */
@media (hover: none) {
  .art-card:active,
  .cat-card:active,
  .featured-card:active { opacity: 0.85; transform: scale(0.98); }

  .btn:active { transform: scale(0.97); }

  .bnav-item:active { opacity: 0.6; }
}

/* ── Убираем hover-только эффекты на touch ──────────────── */
@media (hover: none) {
  .art-card:hover         { transform: none; box-shadow: var(--shadow-xs); }
  .featured-card:hover    { transform: none; }
  .media-card:hover       { transform: none; }
  .cat-card:hover         { transform: none; }
  .cat-panel-item:hover   { background: none; color: var(--text-2); }
  /* Overlay на картинках убираем на touch */
  .art-cover-overlay      { display: none; }
  .dropzone-overlay       { display: none; }
  .media-card-actions     { opacity: 1; } /* Всегда видно на touch */
}

/* ── Адаптив для очень маленьких экранов (SE, Mini) ───────── */
@media (max-width: 375px) {
  .hero h1     { font-size: 20px; }
  .hero-search button { padding: 0 14px; }
  .stats-grid  { grid-template-columns: repeat(2, 1fr); }
  .media-grid  { grid-template-columns: 1fr; }
}

/* ── Landscape phone ──────────────────────────────────────── */
@media (max-height: 500px) and (max-width: 768px) {
  .hero     { padding: 28px 0 22px; }
  .hero h1  { font-size: 22px; }
  .hero-stats { display: none; }
  .mobile-bnav { height: calc(52px + var(--sab)); }
}

/* ── Тёмная тема системная (auto dark mode поддержка) ─────── */
@media (prefers-color-scheme: dark) {
  /* Когда пользователь включил тёмную тему — мягко подстраиваемся */
  /* Не переопределяем цвета — они заданы из настроек через JS */
}

/* ── Print ────────────────────────────────────────────────── */
@media print {
  .app-nav, .mobile-bnav, .pwa-banner,
  .art-actions, .comments-section,
  .art-sidebar, .home-cat-panel { display: none !important; }
  .md-content { font-size: 12pt; }
  .art-inner  { padding: 0 !important; }
}

/* ════════════════════════════════════════════
   CODE LANGUAGE LABEL (добавляется media-render.js)
════════════════════════════════════════════ */
.code-lang-label {
  display: block;
  background: #1a1a1a;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 3px;
  text-transform: uppercase;
  padding: 6px 16px;
  border-bottom: 1px solid #2a2a2a;
  user-select: none;
}

/* ════════════════════════════════════════════
   ARTICLE MD-CONTENT — additional polish
════════════════════════════════════════════ */
/* Ensure images inside p don't overflow */
.md-content p img {
  max-width: 100%;
  height: auto;
  display: inline-block;
  vertical-align: middle;
}

/* Figure with caption — block element, no p nesting issues */
.md-content figure.md-figure {
  display: block;
  margin: 1.6em 0;
}
.md-content p:empty { display: none; } /* Hide empty p tags from auto-correction */

/* Video responsive */
.md-content .md-video,
.md-content video {
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: block;
}

/* Table horizontal scroll on mobile */
@media (max-width: 768px) {
  .md-content table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Pre/code scroll */
.md-content pre {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ════════════════════════════════════════════
   LOGIN PAGE — fix background + colors
════════════════════════════════════════════ */
.lg-left-content { flex: 1; }  /* ensure no overflow */

/* On mobile — show only form, remove left panel */
@media (max-width: 760px) {
  .lg-right::before {
    background: var(--accent);
    height: 3px;
  }
}

/* ════════════════════════════════════════════
   ADMIN PAGE — old var fallbacks
════════════════════════════════════════════ */
/* Fallback для тех мест где остались старые переменные */
:root {
  --ink:       var(--nav-bg, #0E0E0E);
  --line:      var(--border, #E2DDD8);
  --paper:     var(--page-bg, #F7F6F4);
  --paper-2:   var(--surface-0, #FFFFFF);
  --paper-3:   var(--surface-1, #F0EDE9);
  --text-dark: var(--text-1, #1A1714);
  --text-muted:var(--text-3, #6B6866);
  --text-faint:var(--text-4, #A09D9A);
}

/* ════════════════════════════════════════════
   MEDIA PREVIEWS — video/gif thumbnails
════════════════════════════════════════════ */
.media-thumb-wrap.is-video { cursor: pointer; }
.media-thumb-video {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
  background: #000;
}
.media-play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.28);
  pointer-events: none;
  transition: opacity .2s;
}
.media-play-overlay svg {
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.5));
  opacity: 0.92;
}
.media-thumb-wrap.is-video:hover .media-play-overlay { opacity: 0; }

.media-type-badge.gif {
  background: rgba(107,92,231,0.9);
  color: #fff;
}

/* Copy/delete action buttons — svg icons */
.media-card-actions button svg { display: block; }

/* Video tag in settings dropzone */
.dz-video-tag {
  position: absolute;
  bottom: 8px; left: 8px;
  background: rgba(0,0,0,0.7);
  color: #fff;
  font-family: var(--font-display);
  font-size: 8px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  pointer-events: none;
}

/* ════════════════════════════════════════════
   IMAGE STABILITY — prevent CLS (layout shift)
════════════════════════════════════════════ */
/* Фиксируем размеры контейнеров обложек — картинка не «прыгает» */
.art-card-cover,
.art-cover-thumb {
  aspect-ratio: 16 / 9;
  width: 100%;
  height: auto;
  object-fit: cover;
  background: var(--surface-1);
  display: block;
}

.featured-card-bg {
  background: var(--surface-1);
}

/* Аватары — фиксированные размеры, фон-плейсхолдер */
.art-meta-avatar,
.comment-avatar,
.app-user-avatar,
.pm-avatar,
.art-card-avatar,
.user-row-avatar {
  background: var(--accent);
}

img[loading="lazy"] {
  background: var(--surface-1);
}

/* Cover article — фикс высоты через aspect-ratio на десктопе */
.art-cover {
  aspect-ratio: 21 / 9;
  height: auto;
  max-height: 400px;
  object-fit: cover;
  background: var(--surface-1);
}
@media (max-width: 768px) {
  .art-cover { aspect-ratio: 16 / 9; max-height: 240px; }
}

/* ════════════════════════════════════════════
   ЗАПРЕТ ПЕРЕТАСКИВАНИЯ элементов интерфейса
   (кнопки, ссылки, иконки, аватары, логотипы)
════════════════════════════════════════════ */
button, a, img, svg,
.btn, .filter-chip, .page-btn, .bnav-item,
.app-logo, .app-user-avatar, .art-meta-avatar,
.comment-avatar, .media-card, .art-card,
.cat-card, .featured-card, .dropzone,
.so-item, .cat-panel-item, .adm-tab,
.prof-avatar, .avatar-lg, [role="button"] {
  -webkit-user-drag: none;
  user-select: none;
  -webkit-user-select: none;
}

/* Изображения внутри контента статьи — перетаскивание разрешено (это ок),
   но выделение текста рядом работает */
.md-content img,
.md-content video {
  -webkit-user-drag: none;
}

/* Иконки и декоративные элементы не выделяются */
.diamond, .eyebrow::before, .bnav-icon,
.dropzone-icon, .callout-icon, .media-play-overlay,
.hero-bloom, .hero-grid-overlay, .art-meta-sep {
  user-select: none;
  -webkit-user-select: none;
  pointer-events: none;
}
/* Но play-overlay в медиа не блокирует клик по карточке — вернём для is-video */
.media-thumb-wrap.is-video .media-play-overlay { pointer-events: none; }

/* Логотип-ссылка кликабельна */
.app-logo { pointer-events: auto; }

/* ════════════════════════════════════════════
   МОДАЛКИ v2 — flex-структура: футер всегда виден
   (фикс «не создать пользователя» на мобильных)
════════════════════════════════════════════ */
.modal-box {
  display: flex;
  flex-direction: column;
  max-height: 88vh;
}
.modal-header { flex-shrink: 0; }
.modal-body   { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.modal-footer {
  flex-shrink: 0;
  position: sticky; bottom: 0;
  background: var(--surface-0);
  box-shadow: 0 -4px 12px rgba(0,0,0,0.04);
}
@media (max-width: 768px) {
  .modal-box { max-height: calc(94vh - var(--sab)); }
  .modal-footer { padding-bottom: calc(14px + var(--sab)); }
}

/* ════════════════════════════════════════════
   HERO SEARCH — компактный на мобильных
════════════════════════════════════════════ */
@media (max-width: 768px) {
  .hero-search {
    height: 48px;
    max-width: 100%;
    padding: 0 6px 0 16px;
    border-radius: 999px;
  }
  .hero-search-icon { margin-right: 10px; width: 18px; height: 18px; }
  .hero-search input {
    font-size: 16px;   /* 16px — iOS не зумит при фокусе */
  }
  .hero-search button {
    height: 38px; padding: 0 18px; font-size: 10px; letter-spacing: 1px;
  }
  .hero { padding: 36px 0 30px; }
  .hero h1 { font-size: clamp(20px, 6.5vw, 30px); border-left-width: 4px; padding-left: 14px; }
  .hero-sub { font-size: 13px; margin-bottom: 18px; padding-left: 18px; }
  .hero-stats { display: none; }
}

/* ════════════════════════════════════════════
   TABLE GRID PICKER (Word-style)
════════════════════════════════════════════ */
.ed-tablepicker {
  display: none;
  position: absolute; top: calc(100% + 4px); left: 0;
  background: var(--nav-bg);
  border: 1px solid rgba(255,85,0,.25);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 12px;
  z-index: 60;
}
.ed-tablepicker.open { display: block; }
.ed-tp-label {
  font-family: var(--font-display); font-size: 10px;
  letter-spacing: 1.5px; text-transform: uppercase;
  color: rgba(255,255,255,.7); margin-bottom: 8px; text-align: center;
}
.ed-tp-grid {
  display: grid;
  grid-template-columns: repeat(8, 20px);
  grid-auto-rows: 20px;
  gap: 3px;
}
.ed-tp-cell {
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 3px;
  cursor: pointer;
  transition: background .08s, border-color .08s;
}
.ed-tp-cell.sel {
  background: rgba(255,85,0,.45);
  border-color: var(--accent);
}

/* ════════════════════════════════════════════
   КОЛОКОЛЬЧИК УВЕДОМЛЕНИЙ
════════════════════════════════════════════ */
.nav-notif-btn {
  position: relative;
  width: 36px; height: 36px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius);
  color: rgba(255,255,255,0.6);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all .2s;
  flex-shrink: 0; margin-right: 8px;
}
.nav-notif-btn:hover { border-color: var(--accent); color: var(--accent); }
.nav-notif-badge {
  position: absolute; top: -5px; right: -5px;
  min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--accent); color: #fff;
  font-family: var(--font-display); font-size: 9px; font-weight: 700;
  border-radius: 99px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--nav-bg);
}

#notif-panel {
  display: none;
  position: fixed;
  top: calc(62px + var(--sat) + 8px); right: 16px;
  width: 360px; max-width: calc(100vw - 24px);
  max-height: 70vh;
  background: var(--surface-0);
  border: 1px solid var(--border);
  border-top: 2px solid var(--accent);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  z-index: 500;
  overflow: hidden;
  flex-direction: column;
}
#notif-panel.open { display: flex; }

.notif-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.notif-head-title {
  font-family: var(--font-display); font-size: 11px;
  letter-spacing: 2px; text-transform: uppercase;
  color: var(--text-1); font-weight: 700;
}
.notif-readall {
  background: none; border: none;
  font-family: var(--font-display); font-size: 9px;
  letter-spacing: 1px; text-transform: uppercase;
  color: var(--text-3); cursor: pointer;
  transition: color .15s; padding: 4px;
}
.notif-readall:hover { color: var(--accent); }

.notif-list { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.notif-empty { padding: 36px 20px; text-align: center; font-size: 13px; color: var(--text-4); }

.notif-item {
  display: flex; gap: 12px; padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  text-decoration: none; color: inherit;
  transition: background .12s;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--surface-1); }
.notif-item.unread { background: var(--accent-light); }
.notif-item.unread:hover { background: rgba(255,85,0,0.14); }

.notif-item-icon {
  width: 30px; height: 30px; flex-shrink: 0;
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: var(--text-3);
}
.notif-item-icon.k-article { color: var(--accent); background: var(--accent-light); }
.notif-item-icon.k-comment { color: var(--info); background: var(--info-bg); }
.notif-item-icon.k-admin   { color: var(--warning); background: var(--warning-bg); }

.notif-item-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.notif-item-title { font-size: 13.5px; font-weight: 600; color: var(--text-1); line-height: 1.35; }
.notif-item-text  { font-size: 12.5px; color: var(--text-3); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.notif-item-date  { font-size: 11px; color: var(--text-4); margin-top: 2px; }

@media (max-width: 768px) {
  #notif-panel {
    top: auto; bottom: calc(60px + var(--sab) + 8px);
    right: 8px; left: 8px; width: auto;
    max-height: 60vh;
  }
}

/* ════════════════════════════════════════════
   PM-MEDIA — превью медиа в модалке предпросмотра
════════════════════════════════════════════ */
.pm-media {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 240px;
  background: #0A0A0A;
  overflow: hidden;
  flex-shrink: 0;
}
.pm-media img, .pm-media video {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
}
.pm-media video { object-fit: contain; background: #000; }
.pm-media-tag {
  position: absolute; top: 10px; left: 10px;
  background: rgba(0,0,0,0.7); color: #fff;
  font-family: var(--font-display); font-size: 8px;
  letter-spacing: 1.5px; text-transform: uppercase;
  padding: 3px 9px; border-radius: var(--radius-sm);
  pointer-events: none;
}
@media (max-width: 768px) {
  .pm-media { max-height: 190px; }
  .pm-title { font-size: 18px; }
  .pm-excerpt { font-size: 14px; }
}

/* ════════════════════════════════════════════
   POLISH v3 — ровная загрузка, фикс overflow профиля,
   премиальные медиа-превью
════════════════════════════════════════════ */

/* ── Глобальная защита от горизонтального выезда ── */
html { overflow-x: hidden; overflow-x: clip; }
body { overflow-x: hidden; overflow-x: clip; max-width: 100vw; }

/* ── Ровная загрузка: резервируем место под навбар до его рендера ── */
#app-nav-mount {
  min-height: calc(62px + var(--sat, 0px));
  background: var(--nav-bg);
}
#app-nav-mount:empty::after {
  /* тонкая полоска-скелетон вместо пустоты */
  content: '';
  display: block;
  height: calc(62px + var(--sat, 0px));
}

/* ── Профиль: фикс overflow (главная причина «выезда» в PWA) ── */
.prof-hero-inner { min-width: 0; }
.prof-hero-info  { min-width: 0; flex: 1; max-width: 100%; }
.prof-tabs       { max-width: 100%; }
.prof-meta > span { overflow-wrap: anywhere; }
.prof-name        { overflow-wrap: anywhere; }
.prof-body        { overflow-wrap: break-word; min-width: 0; }
.prof-edit-grid > * { min-width: 0; }
.prof-card        { min-width: 0; }
.prof-card .field-input,
.prof-card .field-textarea { max-width: 100%; }
.prof-articles-grid { min-width: 0; }
@media (max-width: 768px) {
  .prof-articles-grid { grid-template-columns: 1fr; }
  .prof-hero-inner { flex-wrap: wrap; }
}

/* ── Медиа в карточках: премиальный hover-zoom ── */
.art-cover-wrap {
  overflow: hidden;
  border-radius: calc(var(--radius) - 2px);
}
.art-cover-wrap .art-card-cover {
  margin-bottom: 0;
  transition: transform .35s cubic-bezier(.2,.6,.2,1);
  will-change: transform;
}
.art-card:hover .art-cover-wrap .art-card-cover { transform: scale(1.04); }
.art-cover-wrap + * { margin-top: 14px; }

.featured-card-bg { transition: transform .4s cubic-bezier(.2,.6,.2,1), opacity .3s; }
.featured-card:hover .featured-card-bg { transform: scale(1.05); opacity: .55; }

/* ── PM-media: глубокий фон + плавный переход к контенту ── */
.pm-media {
  background: linear-gradient(135deg, #101010 0%, #1c1c1c 100%);
}
.pm-media::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 44px;
  background: linear-gradient(to top, rgba(0,0,0,.35), transparent);
  pointer-events: none;
}
.pm-media img { transition: transform .4s ease; }
.pm-panel:hover .pm-media img { transform: scale(1.02); }
.pm-media video { max-height: 100%; }

/* Медиа-бейдж чуть заметнее */
.pm-media-tag {
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  background: rgba(10,10,10,0.62);
  border: 1px solid rgba(255,255,255,0.12);
}

/* ── Ровное появление динамического контента ── */
@keyframes rd-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}
.art-card, .featured-card, .cat-panel-item, .notif-item {
  animation: rd-fade-in .25s ease both;
}
@media (prefers-reduced-motion: reduce) {
  .art-card, .featured-card, .cat-panel-item, .notif-item { animation: none; }
  .art-cover-wrap .art-card-cover, .featured-card-bg, .pm-media img { transition: none; }
}

/* ════════════════════════════════════════════
   ЛОКАЛЬНЫЙ ЧАТ — FAB, шторка, мессенджер
════════════════════════════════════════════ */

/* ── Плавающая кнопка (FAB) ── */
.chat-fab {
  position: fixed;
  right: 20px;
  bottom: calc(20px + var(--sab, 0px));
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  box-shadow: 0 6px 20px rgba(255,85,0,0.4), 0 2px 8px rgba(0,0,0,0.2);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  z-index: 350;
  transition: transform .18s, box-shadow .18s, background .2s;
}
.chat-fab:hover { background: var(--accent-dark); transform: translateY(-2px); box-shadow: 0 8px 26px rgba(255,85,0,0.5); }
.chat-fab:active { transform: scale(0.94); }
/* На мобильных — над нижней навигацией */
@media (max-width: 768px) {
  .chat-fab { bottom: calc(72px + var(--sab, 0px)); right: 16px; width: 52px; height: 52px; }
}

/* ── Шторка (bottom sheet) ── */
.chat-sheet { position: fixed; inset: 0; z-index: 600; display: flex; align-items: flex-end; justify-content: center; }
.chat-sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); opacity: 0; transition: opacity .26s; }
.chat-sheet.open .chat-sheet-backdrop { opacity: 1; }

.chat-sheet-panel {
  position: relative;
  width: 100%; max-width: 520px;
  background: var(--surface-0);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  border-top: 3px solid var(--accent);
  padding: 12px 24px calc(28px + var(--sab, 0px));
  transform: translateY(100%);
  transition: transform .28s cubic-bezier(.2,.7,.2,1);
  box-shadow: 0 -8px 40px rgba(0,0,0,0.3);
}
.chat-sheet.open .chat-sheet-panel { transform: translateY(0); }

.chat-sheet-handle { width: 36px; height: 4px; background: var(--border); border-radius: 2px; margin: 0 auto 18px; }
.chat-sheet-title { font-family: var(--font-display); font-weight: 700; font-size: 17px; letter-spacing: .5px; color: var(--text-1); text-align: center; margin-bottom: 6px; }
.chat-sheet-sub { font-size: 13px; color: var(--text-3); text-align: center; margin-bottom: 22px; }

.chat-room-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.chat-room-tag {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 20px 14px;
  background: var(--surface-1);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all .16s;
}
.chat-room-tag:hover { border-color: var(--accent); background: var(--accent-light); transform: translateY(-2px); }
.chat-room-tag:active { transform: scale(0.97); }
.chat-room-icon { font-size: 24px; color: var(--accent); }
.chat-room-name { font-family: var(--font-display); font-weight: 600; font-size: 14px; letter-spacing: .5px; text-transform: uppercase; color: var(--text-1); }
.chat-room-online { font-size: 11px; color: var(--text-4); }

/* ── Мессенджер (full-screen) ── */
.chat-room {
  position: fixed; left: 0; right: 0; top: 0; z-index: 650;
  /* Высота по видимой области, а не по layout viewport: иначе на мобильных
     адресная строка/панели браузера «съедают» низ и поле ввода уезжает за экран.
     --app-vh уточняет chat.js через visualViewport (в т.ч. при открытой клавиатуре). */
  height: 100vh;
  height: 100dvh;
  height: var(--app-vh, 100dvh);
  background: var(--page-bg);
  display: flex; flex-direction: column;
  overflow: hidden;
  transform: translateY(100%);
  transition: transform .28s cubic-bezier(.2,.7,.2,1);
}
.chat-room.open { transform: translateY(0); }

.chat-room-header {
  display: flex; align-items: center; gap: 12px;
  padding: calc(12px + var(--sat, 0px)) 16px 12px;
  background: var(--nav-bg);
  border-bottom: 1px solid rgba(255,85,0,0.25);
  flex-shrink: 0;
}
.chat-back {
  width: 38px; height: 38px; flex-shrink: 0;
  background: rgba(255,255,255,0.08); border: none; border-radius: var(--radius);
  color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.chat-back:hover { background: rgba(255,85,0,0.3); }
.chat-room-titlebox { flex: 1; min-width: 0; }
.chat-room-h-name { font-family: var(--font-display); font-weight: 700; font-size: 15px; letter-spacing: .5px; color: #fff; }
.chat-room-h-status { font-size: 12px; color: rgba(255,255,255,0.5); }

.chat-messages {
  flex: 1; min-height: 0;   /* критично: иначе лента растягивает контейнер и поле ввода уезжает за экран */
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 18px 16px; display: flex; flex-direction: column; gap: 10px;
  overscroll-behavior: contain;
}
.chat-loading { margin: auto; }
.chat-empty { margin: auto; color: var(--text-4); font-size: 14px; text-align: center; }

/* Премиальный строгий вид: прямоугольные блоки, квадратные аватары.
   Входящее: слева, аватар СПРАВА от блока. Исходящее: справа, аватар СЛЕВА.
   ЕДИНЫЙ источник правды — дублирующих .chat-msg/.chat-msg-bubble нет. */
.chat-msg { display: flex; align-items: flex-end; gap: 10px; max-width: 88%; }
.chat-msg.theirs { align-self: flex-start; flex-direction: row-reverse; }
.chat-msg.mine { align-self: flex-end; }
.chat-msg-bubble {
  position: relative;
  padding: 9px 13px 7px; border-radius: 6px;
  width: fit-content; max-width: 100%;
  overflow-wrap: anywhere; word-break: normal;
}
.chat-msg.theirs .chat-msg-bubble {
  background: var(--surface-0); border: 1px solid var(--border); color: var(--text-1);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.chat-msg.mine .chat-msg-bubble {
  background: var(--accent); color: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}
.chat-msg-author {
  font-size: 10.5px; font-weight: 700; color: var(--accent);
  text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 3px;
}
.chat-msg-content { font-size: 14.5px; line-height: 1.45; white-space: pre-wrap; }
.chat-msg-time { font-size: 10px; opacity: .5; text-align: right; margin-top: 3px; letter-spacing: 0.3px; }
.chat-msg.mine .chat-msg-time { color: rgba(255,255,255,0.85); opacity: 1; }
.chat-msg.pop { animation: chat-pop .18s ease; }
@keyframes chat-pop { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.chat-msg-system {
  align-self: center; font-size: 11.5px; color: var(--text-4);
  background: var(--surface-1); padding: 4px 12px; border-radius: 99px; margin: 4px 0;
}

.chat-input-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px calc(10px + var(--sab, 0px));
  background: var(--surface-0); border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-input {
  flex: 1; height: 44px; padding: 0 16px;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 999px; font-size: 16px; color: var(--text-1); outline: none;
  transition: border-color .15s;
}
.chat-input:focus { border-color: var(--accent); }
.chat-send {
  width: 44px; height: 44px; flex-shrink: 0;
  background: var(--accent); border: none; border-radius: 8px;
  color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, transform .1s;
}
.chat-send:hover { background: var(--accent-dark); }
.chat-send:active { transform: scale(0.92); }

/* Десктоп: мессенджер как окно справа снизу, не на весь экран */
@media (min-width: 900px) {
  .chat-room {
    inset: auto; right: 24px; bottom: 24px; left: auto; top: auto;
    width: 400px; height: 600px; max-height: calc(100vh - 48px);
    border-radius: var(--radius-lg); overflow: hidden;
    box-shadow: var(--shadow-xl); border: 1px solid var(--border);
    transform: translateY(calc(100% + 48px));
  }
  .chat-room.open { transform: translateY(0); }
  .chat-sheet-panel { border-radius: var(--radius-xl); margin-bottom: 24px; }
  .chat-sheet { align-items: center; }
}

/* ════════════════════════════════════════════
   ADMIN CHAT — адаптивные строки управления
════════════════════════════════════════════ */
.chat-admin-row {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
}
.chat-admin-row .field-input { flex: 1; min-width: 140px; max-width: 200px; }

.chat-room-add {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end;
}
.chat-room-add .field { flex: 1; min-width: 120px; }
.chat-room-add .chat-room-add-icon { flex: 0 0 72px; min-width: 72px; }
.chat-room-add .btn { flex-shrink: 0; }

@media (max-width: 640px) {
  .chat-admin-row { flex-direction: column; align-items: stretch; }
  .chat-admin-row .field-input { max-width: 100%; }
  .chat-admin-row .btn { width: 100%; }

  .chat-room-add { flex-direction: column; align-items: stretch; }
  .chat-room-add .field,
  .chat-room-add .chat-room-add-icon { flex: 1 1 auto; min-width: 0; max-width: 100%; }
  .chat-room-add .btn { width: 100%; }
}

/* Гарантия: любые инпуты в chat-панели не выходят за контейнер */
#panel-chat .field-input { max-width: 100%; box-sizing: border-box; }
#panel-chat .settings-card { overflow: hidden; }

/* User modal — блок чекбоксов доступа к разделам */
.uac-cats-box {
  display: none;
  max-height: 160px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  flex-direction: column;
  gap: 8px;
}
.uac-cats-box.show { display: flex; }

/* ════════════════════════════════════════════
   ЧАТ: вложения, кнопка прикрепления, хаб «Связь»
════════════════════════════════════════════ */
.chat-attach {
  width: 40px; height: 40px; flex-shrink: 0;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 50%; color: var(--text-3); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: color .15s, border-color .15s;
}
.chat-attach:hover { color: var(--accent); border-color: var(--accent); }
.chat-attach:active { transform: scale(0.92); }

/* Пузырь-медиа (картинка/файл) — без внутренних отступов у картинки */
.chat-msg-bubble.media { padding: 4px; overflow: hidden; }
.chat-msg.mine .chat-msg-bubble.media { background: var(--accent); }
.chat-img-link { display: block; }
.chat-img {
  display: block; max-width: 240px; max-height: 280px; width: 100%;
  border-radius: 12px; object-fit: cover;
}
.chat-file {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; text-decoration: none; min-width: 180px; max-width: 260px;
}
.chat-msg.theirs .chat-file { color: var(--text-1); }
.chat-msg.mine .chat-file { color: #fff; }
.chat-file-ico { flex-shrink: 0; opacity: .9; }
.chat-file-info { display: flex; flex-direction: column; min-width: 0; }
.chat-file-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-file-size { font-size: 11px; opacity: .7; }

/* Хаб «Связь» (нижняя ✰-кнопка у обычных пользователей) */
.bnav-comms .bnav-icon svg { width: 22px; height: 22px; }
.comms-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.comms-btn {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; width: 100%;
  background: var(--surface-1); border: 1.5px solid var(--border);
  border-radius: var(--radius-lg); cursor: pointer;
  font-family: var(--font-body); font-size: 14.5px; font-weight: 500;
  color: var(--text-1); text-align: left; transition: all .15s;
}
.comms-btn:hover { border-color: var(--accent); background: var(--accent-light); }
.comms-btn:active { transform: scale(0.98); }
.comms-ico { color: var(--accent); display: flex; align-items: center; }
.comms-btn.comms-on { border-color: var(--accent); }
.comms-btn.comms-on .comms-ico { color: #1a9c4e; }

/* Превью архива/файла в медиа-гриде */
.media-thumb-file {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  background: var(--surface-1); color: var(--accent);
}
.media-type-badge.archive { background: rgba(255,85,0,.9); }

/* ════════════════════════════════════════════
   Виджет скачивания файла-вложения в статье
════════════════════════════════════════════ */
.file-download-widget {
  display: flex; align-items: center; gap: 14px;
  max-width: 420px; margin: 18px 0;
  padding: 12px 16px; text-decoration: none;
  background: var(--surface-1); border: 1px solid var(--border);
  border-left: 3px solid var(--accent); border-radius: var(--radius);
  transition: background .15s, border-color .15s, transform .1s;
}
.file-download-widget:hover { background: var(--accent-light); border-color: var(--accent); }
.file-download-widget:active { transform: scale(0.99); }
.fdw-ico {
  position: relative; flex-shrink: 0; color: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.fdw-ext {
  position: absolute; bottom: -3px; left: 50%; transform: translateX(-50%);
  font-size: 7px; font-weight: 800; letter-spacing: .3px;
  background: var(--accent); color: #fff; padding: 1px 3px; border-radius: 3px;
  font-family: var(--font-display);
}
.fdw-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.fdw-name { font-weight: 600; font-size: 14px; color: var(--text-1);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fdw-hint { font-size: 11.5px; color: var(--text-4); }
.fdw-dl { flex-shrink: 0; color: var(--text-3); }
.file-download-widget:hover .fdw-dl { color: var(--accent); }
@media (max-width: 768px) { .file-download-widget { max-width: 100%; } }

/* Кнопка скачивания агента на HERO — рядом с заголовком, «стеклянная» */
.hero-title-row {
  display: flex; align-items: center; gap: 22px; flex-wrap: wrap;
}
.hero-agent-dl {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 10px 18px;
  background: rgba(255,255,255,0.08);
  color: var(--hero-text, #fff); text-decoration: none;
  border: 1.5px solid rgba(255,255,255,0.28);
  border-radius: 999px; font-weight: 600; font-size: 13.5px;
  cursor: pointer; transition: background .18s, border-color .18s, transform .1s;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  white-space: nowrap;
}
.hero-agent-dl:hover { background: var(--accent); border-color: var(--accent); }
.hero-agent-dl:active { transform: scale(0.97); }
.hero-agent-dl svg { flex-shrink: 0; }
@media (max-width: 768px) { .hero-title-row { gap: 0; } #hero-agent-slot { display: none; } }

/* Панель уведомлений: действия и баннер включения push */
.notif-head-actions { display: flex; gap: 6px; align-items: center; }
.notif-enable {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; margin: 0; font-size: 12px; color: var(--text-3);
  background: var(--accent-light); border-bottom: 1px solid var(--border);
}
.notif-enable button {
  flex-shrink: 0; padding: 6px 12px; border: none; border-radius: var(--radius-sm);
  background: var(--accent); color: #fff; font-size: 12px; font-weight: 600;
  cursor: pointer; font-family: var(--font-body);
}
.notif-enable button:hover { background: var(--accent-dark); }

/* ════════════════════════════════════════════
   ЧАТ v2: аватары, удаление, «печатает», ЛС, превью файла
════════════════════════════════════════════ */
/* Сообщение с аватаром */
.chat-ava {
  flex-shrink: 0; border-radius: 4px; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-2); border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.chat-ava img { width: 100%; height: 100%; object-fit: cover; display: block; }
.chat-ava-init { background: var(--accent); color: #fff; font-weight: 700; font-size: 13px; font-family: var(--font-display); }

/* Кнопка удаления в пузыре */
.chat-msg-del {
  position: absolute; top: -8px;
  background: var(--surface-0); border: 1px solid var(--border); color: var(--text-3);
  width: 24px; height: 24px; border-radius: 50%; cursor: pointer;
  display: none; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm);
}
.chat-msg.mine .chat-msg-del { right: -10px; }
.chat-msg.theirs .chat-msg-del { left: -10px; }
.chat-msg:hover .chat-msg-del { display: inline-flex; }
.chat-msg-del:hover { color: #fff; background: #CC2222; border-color: #CC2222; }
.chat-msg.removing { opacity: 0; transform: scale(0.9); transition: .2s; }

/* Индикатор «печатает…» */
.chat-typing {
  height: 0; overflow: hidden; padding: 0 16px;
  font-size: 12px; color: var(--text-4); font-style: italic;
  transition: height .15s, padding .15s;
}
.chat-typing.active { height: 20px; padding: 2px 16px; }

/* Превью файла перед отправкой */
.chat-file-preview {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; margin: 0 10px 6px; border-radius: var(--radius);
  background: var(--surface-1); border: 1px solid var(--border);
}
.cfp-thumb { width: 42px; height: 42px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.cfp-fileico { width: 42px; height: 42px; border-radius: 8px; background: var(--surface-2); color: var(--accent); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.cfp-info { flex: 1; min-width: 0; }
.cfp-name { font-size: 13px; font-weight: 600; color: var(--text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cfp-size { font-size: 11px; color: var(--text-4); }
.cfp-cancel, .cfp-send { border: none; border-radius: var(--radius-sm); padding: 7px 12px; font-size: 12.5px; font-weight: 600; cursor: pointer; font-family: var(--font-body); }
.cfp-cancel { background: var(--surface-2); color: var(--text-3); }
.cfp-send { background: var(--accent); color: #fff; }
.cfp-send:disabled { opacity: .6; cursor: default; }

/* Вкладки шторки + список пользователей для ЛС */
.chat-sheet-tabs { display: flex; gap: 6px; margin-bottom: 14px; background: var(--surface-1); padding: 4px; border-radius: var(--radius); }
.chat-tab { flex: 1; border: none; background: none; padding: 9px; border-radius: var(--radius-sm); font-family: var(--font-body); font-size: 13.5px; font-weight: 600; color: var(--text-3); cursor: pointer; }
.chat-tab.active { background: var(--surface-0); color: var(--accent); box-shadow: var(--shadow-sm); }
.chat-user-list { display: flex; flex-direction: column; gap: 4px; max-height: 50vh; overflow-y: auto; }
.chat-user-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: none; background: none; border-radius: var(--radius); cursor: pointer; text-align: left; width: 100%; transition: background .12s; }
.chat-user-item:hover { background: var(--surface-1); }
.chat-user-name { font-size: 14.5px; font-weight: 500; color: var(--text-1); }

/* Хаб «Связь»: подсказка про профиль */
.comms-hint { margin-top: 12px; font-size: 12px; color: var(--text-4); text-align: center; }

/* Профиль: строка уведомлений */
.prof-notif-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.prof-notif-title { font-size: 14.5px; font-weight: 600; color: var(--text-1); }
.prof-notif-sub { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.prof-notif-hint { margin-top: 12px; font-size: 12px; color: var(--text-4); line-height: 1.5; }

/* Переключатель (toggle switch) */
.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 26px; transition: background .2s, border-color .2s;
}
.switch-slider::before {
  content: ''; position: absolute; height: 18px; width: 18px; left: 3px; bottom: 3px;
  background: #fff; border-radius: 50%; transition: transform .2s; box-shadow: var(--shadow-sm);
}
.switch input:checked + .switch-slider { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .switch-slider::before { transform: translateX(20px); }
.switch input:disabled + .switch-slider { opacity: .5; cursor: default; }

/* Крестик удаления в dropzone (обложка/аватар/медиа) */
.dz-remove {
  position: absolute; top: 6px; right: 6px; z-index: 3;
  width: 26px; height: 26px; border-radius: 50%;
  background: rgba(0,0,0,0.6); color: #fff; border: none; cursor: pointer;
  font-size: 20px; line-height: 1; display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.dz-remove:hover { background: #CC2222; }
.dropzone.has-image { position: relative; }

/* ════════════════════════════════════════════
   КАЛЕНДАРЬ на главной
════════════════════════════════════════════ */
.home-calendar {
  margin-top: 20px; padding-top: 20px;
  border-top: 1px solid var(--border);
}
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 8px; }
.cal-nav { display: flex; align-items: center; gap: 6px; }
.cal-nav-btn {
  width: 26px; height: 26px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-1);
  color: var(--text-2); cursor: pointer; font-size: 15px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.cal-nav-btn:hover { background: var(--surface-2); color: var(--accent); }
.cal-month { font-size: 12.5px; font-weight: 600; color: var(--text-2); min-width: 92px; text-align: center; }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-wd { text-align: center; font-size: 10px; color: var(--text-4); padding: 2px 0 4px; font-weight: 600; }
.cal-cell {
  aspect-ratio: 1; border-radius: var(--radius-sm); position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 12px; color: var(--text-2); cursor: pointer;
  transition: background .12s;
}
.cal-cell.empty { visibility: hidden; cursor: default; }
.cal-cell[data-day]:hover { background: var(--surface-1); }
/* Число дня — кружок, который заливается для сегодня/выбранного */
.cal-day {
  line-height: 1; width: 26px; height: 26px; display: flex;
  align-items: center; justify-content: center; border-radius: 50%;
  transition: background .12s, color .12s;
}
.cal-cell.today .cal-day { border: 1.5px solid var(--accent); color: var(--accent); font-weight: 700; }
.cal-cell.selected .cal-day { background: var(--accent); color: #fff; font-weight: 700; border-color: var(--accent); }
.cal-cell.selected { background: var(--accent-light); }
.cal-dots { display: flex; gap: 2px; margin-top: 3px; height: 5px; }
.cal-dot { width: 5px; height: 5px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.cal-dot.t-payment  { background: #22C55E; }   /* оплата — зелёный */
.cal-dot.t-meeting  { background: #3B82F6; }   /* встреча — синий */
.cal-dot.t-deadline { background: #EF4444; }   /* дедлайн — красный */
.cal-dot.t-other    { background: var(--accent); } /* прочее — акцент */

.cal-legend { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; font-size: 11px; color: var(--text-3); }
.cal-legend span { display: inline-flex; align-items: center; gap: 5px; }

.cal-upcoming { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.cal-up-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--text-4); margin-bottom: 2px; }
.cal-up-empty { font-size: 12.5px; color: var(--text-4); padding: 6px 0; }
.cal-ev { display: flex; align-items: flex-start; gap: 8px; padding: 7px 8px; border-radius: var(--radius-sm); background: var(--surface-1); }
.cal-ev .cal-dot { margin-top: 5px; }
.cal-ev-body { flex: 1; min-width: 0; }
.cal-ev-title { font-size: 13px; font-weight: 600; color: var(--text-1); }
.cal-ev-meta { font-size: 11px; color: var(--text-4); margin-top: 1px; }
.cal-ev-del { border: none; background: none; color: var(--text-4); cursor: pointer; font-size: 17px; line-height: 1; padding: 0 2px; flex-shrink: 0; }
.cal-ev-del:hover { color: #EF4444; }

.cal-add-btn {
  width: 100%; margin-top: 12px; padding: 9px; border: 1px dashed var(--border);
  background: none; color: var(--accent); border-radius: var(--radius);
  font-size: 12.5px; font-weight: 600; cursor: pointer; font-family: var(--font-body);
}
.cal-add-btn:hover { background: var(--accent-light); border-color: var(--accent); }

/* Модалка создания события */
.cal-modal { position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.cal-modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.55); backdrop-filter: blur(2px); }
.cal-modal-panel {
  position: relative; z-index: 1; width: 100%; max-width: 420px;
  background: var(--surface-0); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 22px; box-shadow: var(--shadow-lg);
  max-height: 90vh; overflow-y: auto;
}
.cal-modal-title { font-family: var(--font-display); font-size: 17px; font-weight: 700; margin-bottom: 16px; color: var(--text-1); }
.cal-field { display: block; margin-bottom: 12px; }
.cal-field span { display: block; font-size: 12px; color: var(--text-3); margin-bottom: 5px; }
.cal-field input, .cal-field select, .cal-field textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-1); color: var(--text-1); font-size: 14px; font-family: var(--font-body);
}
.cal-field textarea { resize: vertical; }
.cal-modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

@media (max-width: 768px) {
  .cal-modal-panel { max-width: 100%; }
}

/* Ссылка «развернуть календарь» */
.cal-expand-link { text-decoration: none; display: inline-flex; align-items: center; gap: 6px; color: inherit; }
.cal-expand-link:hover { color: var(--accent); }
.cal-expand-ico { font-size: 12px; opacity: .6; }
.cal-check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); margin-bottom: 12px; cursor: pointer; }
.cal-check input { accent-color: var(--accent); width: 16px; height: 16px; }

/* Карточка-ссылка на календарь — показывается ТОЛЬКО на мобильном.
   На десктопе календарь живёт в правой панели (мини-грид, см. calendar.js). */
.home-cal-mobile {
  display: none; align-items: center; gap: 14px;
  padding: 16px 18px; margin-bottom: 20px; text-decoration: none;
  background: var(--surface-0); border: 1px solid var(--border);
  border-radius: 12px; border-left: 3px solid var(--accent);
  transition: border-color .16s, box-shadow .16s, transform .16s;
}
.home-cal-mobile:hover {
  border-color: var(--accent); box-shadow: var(--shadow-sm); transform: translateY(-1px);
}
.hcm-ico { width: 44px; height: 44px; flex-shrink: 0; border-radius: 10px;
  background: var(--accent-light); color: var(--accent);
  display: flex; align-items: center; justify-content: center; }
.hcm-body { flex: 1; min-width: 0; }
.hcm-title { display: block; font-weight: 700; font-size: 15px; color: var(--text-1); }
.hcm-sub { display: block; font-size: 12.5px; color: var(--text-4); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hcm-arrow { color: var(--accent); font-size: 18px; flex-shrink: 0; transition: transform .16s; }
.home-cal-mobile:hover .hcm-arrow { transform: translateX(3px); }
@media (max-width: 900px) {
  .home-cal-mobile { display: flex; padding: 14px 16px; margin-bottom: 18px; gap: 12px; }
  .hcm-ico { width: 40px; height: 40px; border-radius: 8px; }
}


/* Карточка приглашения на событие в чате */
.chat-invite { min-width: 210px; }
.chat-inv-head { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; opacity: .8; margin-bottom: 6px; display: flex; align-items: center; gap: 5px; }
.chat-inv-title { font-size: 15px; font-weight: 700; margin-bottom: 3px; }
.chat-inv-meta { font-size: 12px; opacity: .75; }
.chat-inv-desc { font-size: 12.5px; opacity: .85; margin-top: 5px; }
.chat-inv-add {
  margin-top: 9px; width: 100%; padding: 8px; border: none; border-radius: 6px;
  background: #fff; color: var(--accent); font-weight: 700; font-size: 12.5px;
  cursor: pointer; font-family: var(--font-body); transition: opacity .15s;
}
.chat-msg.theirs .chat-inv-add { background: var(--accent); color: #fff; }
.chat-inv-add:hover { opacity: .88; }
.chat-inv-add.done { background: rgba(255,255,255,.25); color: #fff; cursor: default; }
.chat-msg.theirs .chat-inv-add.done { background: var(--surface-2); color: var(--text-3); }
.chat-inv-sent { margin-top: 8px; font-size: 11.5px; opacity: .7; font-style: italic; }

/* Кнопка музыкального сопровождения */
.music-toggle {
  position: fixed; left: 20px; bottom: calc(20px + var(--sab, 0px)); z-index: 640;
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--surface-0); border: 1px solid var(--border); color: var(--text-3);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  box-shadow: var(--shadow-md); transition: all .18s;
}
.music-toggle:hover { color: var(--accent); border-color: var(--accent); }
.music-toggle.playing { color: var(--accent); border-color: var(--accent); }
.music-toggle.playing::after {
  content: ''; position: absolute; inset: -4px; border-radius: 50%;
  border: 1.5px solid var(--accent); opacity: .4; animation: music-pulse 2s ease-out infinite;
}
@keyframes music-pulse { 0% { transform: scale(1); opacity: .5; } 100% { transform: scale(1.35); opacity: 0; } }
/* На мобильном сдвигаем выше нижней навигации */
@media (max-width: 768px) {
  .music-toggle { bottom: calc(76px + var(--sab, 0px)); left: 14px; width: 38px; height: 38px; }
}

/* Кнопка «добавить на выбранный день» в календаре */
.cal-day-add {
  width: 100%; margin-top: 8px; padding: 8px; border: 1px dashed var(--border);
  background: none; color: var(--accent); border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 600; cursor: pointer; font-family: var(--font-body);
}
.cal-day-add:hover { background: var(--accent-light); border-color: var(--accent); }
.cal-ev { cursor: pointer; }

/* ════════════════════════════════════════════
   ЧАТ: непрочитанные, подгрузка истории, опросы
════════════════════════════════════════════ */

/* Бейдж непрочитанных на плитке комнаты */
.chat-room-tag { position: relative; }
.chat-room-unread {
  position: absolute; top: 8px; right: 8px;
  min-width: 20px; height: 20px; padding: 0 6px;
  background: var(--accent); color: #fff;
  border-radius: 999px;
  font-size: 11px; font-weight: 700; line-height: 20px;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}

/* Индикатор подгрузки более ранних сообщений */
.chat-older-loading {
  align-self: center; font-size: 12px; color: var(--text-4);
  padding: 6px 12px; margin-bottom: 4px;
}

/* ── Карточка опроса в ленте ── */
.chat-poll { min-width: 240px; }
.chat-poll-head {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .6px; opacity: .75; margin-bottom: 6px;
}
.chat-poll-q { font-size: 14.5px; font-weight: 600; line-height: 1.35; margin-bottom: 10px; }
.chat-poll-opts { display: flex; flex-direction: column; gap: 6px; }

.chat-poll-opt {
  width: 100%; text-align: left;
  padding: 9px 12px; font-size: 13.5px; font-family: var(--font-body);
  background: var(--surface-1); color: var(--text-1);
  border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; transition: border-color .14s, background .14s;
}
.chat-poll-opt:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-light); }
.chat-poll-opt.sel { border-color: var(--accent); background: var(--accent-light); font-weight: 600; }
.chat-poll-opt:disabled { opacity: .55; cursor: default; }

/* Результаты: полоса заполнения + подпись */
.chat-poll-res {
  position: relative; overflow: hidden;
  padding: 8px 12px; border-radius: var(--radius);
  background: var(--surface-1); border: 1px solid var(--border);
}
.chat-poll-res.picked { border-color: var(--accent); }
.chat-poll-bar {
  position: absolute; inset: 0 auto 0 0;
  background: var(--accent-light); transition: width .35s ease;
}
.chat-poll-res-in {
  position: relative; display: flex; align-items: center;
  justify-content: space-between; gap: 10px; font-size: 13px;
}
.chat-poll-opt-txt { color: var(--text-1); overflow-wrap: anywhere; }
.chat-poll-pct { color: var(--text-3); font-weight: 700; font-size: 12px; flex-shrink: 0; }
.chat-poll-names {
  position: relative; margin-top: 4px;
  font-size: 11px; color: var(--text-4); overflow-wrap: anywhere;
}
.chat-poll-foot { margin-top: 9px; font-size: 11.5px; opacity: .7; }
.chat-poll-submit, .chat-poll-close {
  margin-top: 9px; width: 100%; padding: 8px;
  font-size: 12.5px; font-weight: 600; font-family: var(--font-body);
  border-radius: var(--radius); cursor: pointer;
}
.chat-poll-submit { background: var(--accent); color: #fff; border: none; }
.chat-poll-close { background: none; color: var(--text-4); border: 1px dashed var(--border); }
.chat-poll-close:hover { color: var(--accent); border-color: var(--accent); }
/* В своём (оранжевом) пузыре элементы опроса остаются читаемыми */
.chat-msg.mine .chat-poll-opt,
.chat-msg.mine .chat-poll-res { background: rgba(255,255,255,0.14); border-color: rgba(255,255,255,0.3); }
.chat-msg.mine .chat-poll-opt, .chat-msg.mine .chat-poll-opt-txt { color: #fff; }
.chat-msg.mine .chat-poll-bar { background: rgba(255,255,255,0.22); }
.chat-msg.mine .chat-poll-pct, .chat-msg.mine .chat-poll-names { color: rgba(255,255,255,0.9); }

/* ── Модалка создания опроса ── */
.chat-poll-modal { position: fixed; inset: 0; z-index: 700; display: flex; align-items: center; justify-content: center; }
.chat-poll-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.55); }
.chat-poll-panel {
  position: relative; width: min(440px, calc(100% - 32px));
  max-height: calc(100% - 48px); overflow-y: auto;
  background: var(--surface-0); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 22px;
  box-shadow: var(--shadow-xl);
}
.chat-poll-title { font-family: var(--font-display); font-weight: 700; font-size: 17px; color: var(--text-1); margin-bottom: 16px; }
.chat-poll-label { display: block; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-4); margin: 12px 0 6px; }
.chat-poll-input {
  width: 100%; box-sizing: border-box; margin-bottom: 7px;
  padding: 10px 12px; font-size: 16px; font-family: var(--font-body);
  background: var(--surface-1); color: var(--text-1);
  border: 1px solid var(--border); border-radius: var(--radius); outline: none;
}
.chat-poll-input:focus { border-color: var(--accent); }
.chat-poll-addopt {
  width: 100%; padding: 8px; margin-bottom: 6px;
  background: none; color: var(--accent); font-size: 12.5px; font-weight: 600;
  border: 1px dashed var(--border); border-radius: var(--radius); cursor: pointer; font-family: var(--font-body);
}
.chat-poll-addopt:hover { border-color: var(--accent); background: var(--accent-light); }
.chat-poll-check { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.chat-poll-check input { width: 16px; height: 16px; accent-color: var(--accent); flex-shrink: 0; }
.chat-poll-hint { margin-top: 12px; font-size: 11.5px; color: var(--text-4); line-height: 1.4; }
.chat-poll-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
@media (max-width: 640px) {
  .chat-poll-modal { align-items: flex-end; }
  .chat-poll-panel {
    width: 100%; border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding-bottom: calc(22px + var(--sab, 0px));
    max-height: 88vh;
  }
  .chat-poll-actions .btn { flex: 1; }
}
