/* ============================================================
   СМИскан — Public Portal Design System
   Inspired by Brand Analytics, Медиалогия, Popsters, Крибрум
   ============================================================ */

/* ----------------------------------------------------------
   Shared tokens (geometry, motion, skeleton) — inlined from
   tokens.css so a token change bumps this file's own ?v= cache
   buster instead of relying on a separately-cached @import that
   nginx serves with a 30-day immutable Cache-Control (H1).
   ---------------------------------------------------------- */
:root {
  --radius:          10px;
  --radius-sm:       6px;
  --radius-lg:       14px;
  --radius-full:     9999px;

  --transition:      0.2s ease;
  --transition-slow: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

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

.skeleton-text {
  height: 0.9em;
  margin: 0.25em 0;
}

.skeleton-circle {
  border-radius: var(--radius-full);
}

@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ----------------------------------------------------------
   Design Tokens (Light — neutral theme default)
   ---------------------------------------------------------- */
:root {
  /* Surfaces */
  --bg:              #f4f6f9;
  --bg-card:         #ffffff;
  --bg-card-hover:   #f8faff;
  --bg-header:       #1a2332;
  --bg-footer:       #131a28;
  --bg-sidebar:      var(--bg-card);
  --bg-input:        #f8f9fb;
  --bg-hover:        #f0f3f8;
  --bg-accent-soft:  #eef4fc;

  /* Text */
  --text:            #1a2332;
  --text-secondary:  #556070;
  --text-muted:      #5f6e82; /* WCAG AA: was #8896a8 (2.78:1 on --bg — fails 4.5:1) */
  --text-light:      #c8d0dd;
  --text-inverse:    #ffffff;

  /* Borders */
  --border:          #e2e6ed;
  --border-light:    #eef1f6;
  --border-focus:    #2c6ed5;

  /* Accent / Brand */
  --accent:          #2c6ed5;
  --accent-hover:    #1a5bbf;
  --accent-light:    #e8f0fe;
  --accent-gradient: linear-gradient(135deg, #2c6ed5, #7c5bef);

  /* Semantic — values tuned so text-on-*-bg pairs (badges, alerts) clear WCAG AA 4.5:1 */
  --russia:          #d12929; /* was #d52b2b (4.50:1 on --russia-bg — right at the edge) */
  --russia-bg:       #fef0f0;
  --world:           #256ebc; /* was #2b7dd5 (3.80:1 on --world-bg — fails) */
  --world-bg:        #eef4fc;
  --like:            #d62c1a; /* was #e74c3c (3.57:1 on --like-bg — fails) */
  --like-bg:         #fff5f5;
  --success:         #1b8247; /* was #22a45a (3.04:1 on --success-bg — fails) */
  --success-bg:      #edfcf2;
  --warning:         #976811; /* was #e6a020 (2.11:1 on --warning-bg — fails) */
  --warning-bg:      #fff8eb;
  --danger:          #d12929; /* was #d52b2b (4.50:1 on --danger-bg — right at the edge) */
  --danger-bg:       #fef0f0;
  --info:            #2c6ed5;
  --info-bg:         #eef4fc;

  /* Shadows (light surface — subtler than the admin dashboard's) */
  --shadow:          0 1px 4px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-hover:    0 8px 25px rgba(0,0,0,0.08);
  --shadow-lg:       0 12px 40px rgba(0,0,0,0.1);
  --shadow-header:   0 1px 4px rgba(0,0,0,0.2);

  /* Layout */
  /* 1800px + width:95% на обёртках (header-inner/layout/footer-inner) —
     контент растягивается почти на весь экран вместо фиксированного
     центрированного блока с пустыми полями по бокам на широких мониторах. */
  --max-width:       1800px;
  --sidebar-width:   260px;
  --header-height:   60px;

  /* Z-layers */
  --z-sidebar:       95;
  --z-overlay:       90;
  --z-header:        100;
  --z-fab:           85;
  --z-skip-link:     999;
}

/* ----------------------------------------------------------
   Base / Reset
   ---------------------------------------------------------- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 16px;
  padding-top: var(--header-height);
  min-height: 100vh;
}

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

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Focus visible for keyboard users (WCAG AA) */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ----------------------------------------------------------
   Skip Link (WCAG)
   ---------------------------------------------------------- */
.skip-link {
  position: fixed;
  top: -100%;
  left: 16px;
  z-index: var(--z-skip-link);
  padding: 12px 24px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  border-radius: var(--radius-sm);
  transition: top 0.2s ease;
}
.skip-link:focus { top: 12px; }

/* ----------------------------------------------------------
   Site Header
   ---------------------------------------------------------- */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg-header);
  z-index: var(--z-header);
  box-shadow: var(--shadow-header);
  -webkit-backdrop-filter: blur(0);
  backdrop-filter: blur(0);
}

.header-inner {
  width: 95%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  text-decoration: none;
}
.site-logo:hover { color: rgba(255,255,255,0.85); }

/* B2: вордмарк — картинка. Правила .site-logo выше остаются: они оформляют
   alt-текст, если SVG не загрузился. Ховер гасим прозрачностью, а не color —
   на картинку color не действует. */
.site-logo-img {
  display: block;
  height: 30px;      /* 160x38 в исходнике -> ~126x30 в шапке высотой 60px */
  width: auto;
  flex-shrink: 0;
}
.site-logo:hover .site-logo-img { opacity: 0.85; }

.header-nav {
  display: flex;
  gap: 4px;
  align-items: center;
}

.nav-link {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-light);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}
.nav-link:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
  text-decoration: none;
}
.nav-link.active,
.nav-link[aria-current="page"] {
  background: rgba(255,255,255,0.14);
  color: #fff;
  font-weight: 700;
}

.nav-admin {
  opacity: 0.5;
  font-size: 13px;
}
.nav-admin:hover { opacity: 1; }

/* "Дайджест" — Итоги дня / Итоги недели (задача 1C) */
.nav-dropdown {
  position: relative;
}
.nav-dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
}
.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 160px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: var(--z-header);
}
.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu {
  display: block;
}
.nav-dropdown-item {
  display: block;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  white-space: nowrap;
  text-decoration: none;
}
.nav-dropdown-item:hover {
  background: var(--bg-hover);
  color: var(--accent);
  text-decoration: none;
}
.nav-dropdown-item[aria-current="page"] {
  color: var(--accent);
  font-weight: 700;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.theme-toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-light);
  transition: background var(--transition);
  line-height: 1;
}
.theme-toggle-btn:hover { background: rgba(255,255,255,0.1); }

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.mobile-menu-btn:hover { background: rgba(255,255,255,0.1); }

/* ----------------------------------------------------------
   Layout (sidebar + main)
   ---------------------------------------------------------- */
.layout {
  width: 95%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 24px 20px;
  display: flex;
  gap: 28px;
  min-height: calc(100vh - var(--header-height) - 320px);
}

/* ----------------------------------------------------------
   Sidebar Filters
   ---------------------------------------------------------- */
.sidebar-filters {
  width: var(--sidebar-width);
  flex-shrink: 0;
  position: sticky;
  top: calc(var(--header-height) + 24px);
  height: fit-content;
  max-height: calc(100vh - var(--header-height) - 40px);
  overflow-y: auto;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: all var(--transition);
}

/* Шире на больших мониторах — на ≥1400px рядом остаётся много места,
   260px там выглядит непропорционально узко. */
@media (min-width: 1400px) {
  .sidebar-filters { width: 300px; }
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.sidebar-header h3 {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}
.sidebar-close {
  display: none;
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.sidebar-close:hover { background: var(--bg-hover); color: var(--text); }

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

.filter-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.filter-select,
.filter-input {
  padding: 9px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.filter-select:focus,
.filter-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(44, 110, 213, 0.12);
}

.filter-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238896a8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

.btn-filter-apply,
.btn-filter-reset {
  display: block;
  width: 100%;
  padding: 10px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}
.btn-filter-apply {
  background: var(--accent);
  color: #fff;
  border: none;
  margin-top: 4px;
}
.btn-filter-apply:hover { background: var(--accent-hover); transform: translateY(-1px); }

.btn-filter-reset {
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  text-decoration: none;
}
.btn-filter-reset:hover { border-color: var(--text-muted); color: var(--text); background: var(--bg-hover); }

/* ----------------------------------------------------------
   Filter FAB (mobile)
   ---------------------------------------------------------- */
.filter-fab {
  display: none;
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--z-fab);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(44, 110, 213, 0.35);
  transition: all var(--transition);
  align-items: center;
  justify-content: center;
}
.filter-fab:hover {
  background: var(--accent-hover);
  transform: scale(1.05);
  box-shadow: 0 6px 24px rgba(44, 110, 213, 0.45);
}

/* ----------------------------------------------------------
   Main Area
   ---------------------------------------------------------- */
.main-area {
  flex: 1;
  min-width: 0;
}

/* Кабинет собирает .main-area без сайдбара, отдельной самостоятельной
   разметкой (без class="sidebar-filters" в .layout) — без сайдбара рядом
   несдерживаемая ширина растягивает формы и списки некрасиво, поэтому для
   этого случая возвращаем разумный потолок ширины. */
.layout:not(:has(> .sidebar-filters)) .main-area {
  max-width: 900px;
  margin: 0 auto;
}

/* ----------------------------------------------------------
   Section Headers
   ---------------------------------------------------------- */
.section { margin-bottom: 32px; }

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border);
}
.section-header h2 {
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

/* ----------------------------------------------------------
   Trending Section
   ---------------------------------------------------------- */
.trending-section {
  margin-bottom: 36px;
  background: #f8fafc;
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 20px;
}
[data-theme="black"] .trending-section { background: #1e293b; }

.trending-grid {
  display: grid;
  gap: 8px;
}

.trending-card {
  display: flex;
  gap: 14px;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  align-items: flex-start;
  transition: all var(--transition);
  cursor: pointer;
}
.trending-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
  transform: translateX(4px);
}

.trending-rank {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.trending-body { flex: 1; min-width: 0; }

.trending-source {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.trending-title {
  font-size: 15px;
  font-weight: 600;
  margin-top: 2px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

.trending-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ----------------------------------------------------------
   Card Grid
   ---------------------------------------------------------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.news-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  transition: all var(--transition-slow);
  overflow: hidden;
}
.news-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-hover);
  transform: translateY(-3px);
}

/* Card Image */
.card-image {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: var(--bg-hover);
}

/* PH1 — картинка обёрнута в <a> на первоисточник. Обёртка обязана быть
   block'ом во всю высоту контейнера: иначе height:100% у <img> считается от
   инлайнового <a> нулевой высоты и картинка схлопывается. */
.card-image-link,
.article-image-link {
  display: block;
  width: 100%;
  height: 100%;
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.news-card:hover .card-image img { transform: scale(1.06); }

.card-image-source {
  position: absolute;
  bottom: 8px;
  left: 8px;
  padding: 3px 10px;
  background: rgba(0,0,0,0.65);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

/* Card image placeholder (no image, or a broken/blocked thumbnail —
   see handleImgError in public.js) — rubric-tinted gradient instead of a
   flat pale-grey box (was reading as "empty/unfinished"). Base rule is also
   the fallback for any rubric slug without its own variant below (matches
   "other" 1:1, and covers anything unexpected the same way). */
.card-image-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
}

.card-image-placeholder-russia   { background: linear-gradient(135deg, #334155 0%, #475569 100%); }
.card-image-placeholder-world    { background: linear-gradient(135deg, #1e3a5f 0%, #2c5282 100%); }
.card-image-placeholder-it       { background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%); }
.card-image-placeholder-science  { background: linear-gradient(135deg, #312e81 0%, #4c1d95 100%); }
.card-image-placeholder-finance  { background: linear-gradient(135deg, #78350f 0%, #92400e 100%); }
.card-image-placeholder-sport    { background: linear-gradient(135deg, #14532d 0%, #166534 100%); }
.card-image-placeholder-cities   { background: linear-gradient(135deg, #164e63 0%, #155e75 100%); }
.card-image-placeholder-other    { background: linear-gradient(135deg, #1e293b 0%, #334155 100%); }
/* PH2 — плейсхолдер telegram-поста. Стоит после рубричных вариантов: у
   карточки из Telegram класс рубрики не ставится вовсе, но если он появится,
   выиграть должен градиент канала, а не рубрики. */
.card-image-placeholder-telegram { background: linear-gradient(135deg, #0f2b3d 0%, #1c5980 100%); }

/* Тёмная тема — тот же градиент чуть темнее, а не отдельный набор из 8 пар */
[data-theme="black"] .card-image-placeholder { filter: brightness(0.82); }

.card-placeholder-icon {
  font-size: 32px;
  line-height: 1;
  color: #fff;
  opacity: 0.3;
}

/* Иконка Telegram в плейсхолдере — SVG, а не шрифтовая .ti: размер задан
   атрибутами width/height, здесь только цвет и прозрачность (fill
   у самого <path> — currentColor). */
.card-placeholder-icon-svg {
  color: #fff;
  opacity: 0.3;
}

.card-placeholder-source {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  text-align: center;
  padding: 0 12px;
}

/* Card Body */
.card-body {
  padding: 16px 18px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Card Badge */
.card-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
  width: fit-content;
}
.card-badge-russia { background: var(--russia-bg); color: var(--russia); }
.card-badge-world { background: var(--world-bg); color: var(--world); }

/* Card Title */
.card-title {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 8px;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-title a { color: inherit; }
.card-title a:hover { color: var(--accent); }
.card-title a:visited { color: var(--text-muted); }

/* Card Summary — max 2 lines (TOR §5.1) */
.card-summary {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

/* Auto-generated hashtags (TOR list2 п.5) — plain-text tokens, distinct from
   rubric pills above (accent-colored, pre-defined taxonomy). */
.card-hashtags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}
.card-hashtag {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
}
.card-hashtag:hover {
  color: var(--accent);
  text-decoration: underline;
}
.article-hashtags {
  margin-top: 10px;
}

/* Card Meta Footer */
.card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
  padding: 10px 18px 14px;
  border-top: 1px solid var(--border-light);
  flex-wrap: wrap;
  gap: 8px;
}

.card-date {
  display: flex;
  align-items: center;
  gap: 4px;
}

.card-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

/* Like Button */
.card-like {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--bg-card);
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  color: var(--text-muted);
  transition: all var(--transition);
}
.card-like:hover {
  border-color: var(--like);
  color: var(--like);
  background: var(--like-bg);
}
.card-like.liked {
  border-color: var(--like);
  color: var(--like);
  background: var(--like-bg);
}

/* Bookmark Button ("Сохранить на потом", TOR list2 Блок C, п.5) */
.card-bookmark {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--bg-card);
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  color: var(--text-muted);
  transition: all var(--transition);
}
.card-bookmark:hover {
  border-color: var(--warning);
  color: var(--warning);
  background: var(--warning-bg);
}
.card-bookmark.bookmarked {
  border-color: var(--warning);
  color: var(--warning);
  background: var(--warning-bg);
}

/* Card share row (TOR list2 Блок C, п.6) — small icons, one row, card bottom */
.card-share-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px 12px;
  border-top: 1px solid var(--border-light);
}
.card-share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  font-size: 16px;
  line-height: 1;
  color: var(--text-muted);
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  transition: color var(--transition);
}
.card-share-btn:hover { color: var(--accent); }

/* Card Action Buttons */
.card-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 14px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  transition: all var(--transition);
  white-space: nowrap;
  border: none;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
}
.card-btn:hover { text-decoration: none; }

.card-btn-read {
  background: var(--accent);
  color: #fff;
}
.card-btn-read:hover { background: var(--accent-hover); color: #fff; }
.card-btn-read.active {
  background: var(--accent-light);
  color: var(--accent);
}

.card-btn-source {
  border: 1px solid var(--border);
  color: var(--text-secondary);
  background: var(--bg-card);
}
.card-btn-source:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }

/* Compact view toggle — html[data-view="compact"] set by #viewToggleBtn in
   public.js, persisted in localStorage. One row per card: no image,
   single-line source + time + title. Placed before the critical CSS cutoff
   so a saved compact preference doesn't flash the uncompacted layout before
   the full stylesheet finishes loading. */
html[data-view="compact"] .card-grid {
  grid-template-columns: 1fr;
  gap: 0;
}
html[data-view="compact"] .card-image,
html[data-view="compact"] .card-summary,
html[data-view="compact"] .card-hashtags,
html[data-view="compact"] .card-sources,
html[data-view="compact"] .cluster-badge {
  display: none;
}
html[data-view="compact"] .news-card {
  flex-direction: row;
  align-items: center;
  border-radius: 0;
  border-left: none;
  border-right: none;
  border-bottom: 1px solid var(--border-light);
  border-top: none;
}
html[data-view="compact"] .news-card:first-child { border-top: 1px solid var(--border-light); }
html[data-view="compact"] .news-card:hover {
  transform: none;
  box-shadow: none;
}
html[data-view="compact"] .card-body {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  flex: 1;
  min-width: 0;
}
html[data-view="compact"] .card-top-row {
  flex-shrink: 0;
  margin-bottom: 0;
}
html[data-view="compact"] .card-top-source {
  max-width: 140px;
}
html[data-view="compact"] .card-title {
  margin-bottom: 0;
  font-size: 14px;
  font-weight: 500;
  -webkit-line-clamp: 1;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
html[data-view="compact"] .card-meta {
  border-top: none;
  padding: 10px 14px;
  flex-shrink: 0;
  width: auto;
}

@media (max-width: 640px) {
  html[data-view="compact"] .card-body {
    flex-wrap: wrap;
  }
  html[data-view="compact"] .card-title {
    white-space: normal;
    -webkit-line-clamp: 2;
    flex-basis: 100%;
  }
}

/* Узкая одноколоночная страница — юридические документы, формы входа,
   регистрации и подтверждения email (E5). Эти страницы наследуют
   public_base.html, но не показывают сайдбар фильтров и ленту карточек,
   поэтому сетка .layout им не нужна: только колонка по центру.
   Значения перенесены один-в-один из инлайновых style= прежних шаблонов,
   чтобы наследование не меняло вёрстку. Стоит выше CUTOFF намеренно —
   это шелл страницы, он виден до загрузки public.css. */
.narrow-page {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

.legal-article {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
}

.legal-article h1 {
  font-size: 26px;
  margin-bottom: 8px;
}

/* Подзаголовок под h1: дата обновления, реквизиты оператора, преамбула. */
.legal-meta {
  color: var(--text-muted);
  margin-bottom: 24px;
}

/* Тот же подзаголовок, но когда за ним идёт ещё один абзац преамбулы
   (consent_pd, terms) — там прежний инлайн задавал отступ 8px, а не 24px. */
.legal-meta-tight {
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* Страница подтверждения email (/verify): кнопка-ссылка под сообщением.
   Значения перенесены из инлайновых style= прежнего шаблона (E5). */
.auth-actions {
  text-align: center;
  margin-top: 16px;
}

.btn-auth-inline {
  display: inline-block;
  width: auto;
  padding: 11px 32px;
  text-decoration: none;
}

/* Приглушённый вариант — для «На главную» на экране ошибки. */
.btn-auth-inline.btn-auth-muted {
  background: var(--text-muted);
}

.auth-icon-ok { color: var(--sport); }
.auth-icon-error { color: var(--russia); }

/* G1 — адрес почты, скрытый от сборщиков спама.
   В HTML он записан задом наперёд («ur.xednay@16domofnI»), а разворачивает
   его обратно вот это правило: bidi-override отменяет обычный алгоритм
   двунаправленного текста, direction:rtl задаёт порядок справа налево, и
   человек видит нормальный адрес. Бот, который грепает исходник, — нет.
   Правило лежит ВЫШЕ маркера обрезки критического CSS намеренно: адрес стоит
   в футере на каждой странице, и без инлайна он на долю секунды показался бы
   перевёрнутым. Сам маркер здесь не повторяется дословно — код ищет его
   через content.find(), то есть по ПЕРВОМУ вхождению, и упоминание в
   комментарии обрезало бы стили раньше времени.
   unicode-bidi обязателен вместе с direction: сам по себе direction:rtl
   строку из латиницы и точек не развернёт — bidi-алгоритм считает её
   слева-направо и оставит как есть. */
.protected-email {
  unicode-bidi: bidi-override;
  direction: rtl;
  /* Разрывать перевёрнутую строку переносом нельзя: части встанут в обратном
     порядке и адрес прочитается неправильно. */
  white-space: nowrap;
  color: var(--accent);
  cursor: pointer;
}

/* После обработки скриптом это уже обычная ссылка mailto, и переворачивать
   больше нечего — иначе текст развернулся бы дважды. */
a.protected-email {
  unicode-bidi: normal;
  direction: ltr;
  text-decoration: none;
}

a.protected-email:hover { text-decoration: underline; }

/* === CRITICAL CSS CUTOFF ===
   Everything above this line is inlined into <head> on every page render
   (see app/api/public.py:_load_critical_css / jinja_env.globals["critical_css"]).
   Best-effort, hand-picked without a headless browser (TOR list2 п.18) — theme
   vars + reset + skip-link + the fixed header + page shell + sidebar filters +
   the card grid shell through the first cards' action buttons, i.e. what's
   guaranteed visible before this file itself finishes loading. Keep this
   cutoff here: everything below still loads (non-blocking, see
   public_base.html), inlining more just grows every HTML response for
   content that isn't actually above the fold. */

/* Inline Card Content (Read here toggle) */
.card-content {
  padding: 0 18px 12px;
}

.card-content-text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
  padding: 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

.card-content-loading,
.card-content-empty {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: 13px;
}

/* ----------------------------------------------------------
   Latest Columns (Index page)
   ---------------------------------------------------------- */
.latest-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.latest-col-title {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
}

.latest-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.latest-item {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: background var(--transition);
}
.latest-item:hover { background: var(--bg-hover); }
.latest-item:last-child { border-bottom: none; }

.latest-source {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.latest-link {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
  text-decoration: none;
}
.latest-link:hover { color: var(--accent); }

.latest-date {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.latest-all {
  display: block;
  margin-top: 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
}
.latest-all:hover { text-decoration: underline; }

/* ----------------------------------------------------------
   Page Head / Title Bar
   ---------------------------------------------------------- */
.page-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--border);
}
.page-head h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.page-head-actions { margin-left: auto; display: flex; gap: 8px; flex-shrink: 0; }
.page-count {
  font-size: 14px;
  color: var(--text-muted);
}
/* Топ-12 subtitle (TOR list4 п.2) — same .page-head line as the rubric
   title/count, pushed to the far right via margin-left:auto (the note is
   .page-head's last flex child, so this is equivalent to
   justify-content:space-between without having to wrap h1+count in their
   own group). */
.page-head-top12-note {
  font-size: 13px;
  font-weight: 400;
  color: #6b7280;
  margin-left: auto;
}

/* SEO description under the rubric H1 (TOR list2 Блок D, п.1) — no max-width:
   fills the full content width (.main-area, itself fluid since 2026-08-05),
   wrapping naturally on narrow screens instead of forcing an early break. */
.rubric-seo-description {
  font-size: 13px;
  color: var(--text-muted);
  margin: -14px 0 20px;
}

/* ----------------------------------------------------------
   City filter (TOR §2.5.3/2.5.4) — lives in .page-head, right of the
   article count (2026-08-07: moved here from its own row below the top-12
   block). Same .page-head flex row as .page-head-top12-note, placed before
   it in the markup so that note's margin-left:auto still pushes it to the
   far right.
   ---------------------------------------------------------- */
.page-head-city-filter {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}
.page-head-city-label {
  white-space: nowrap;
}
#cityHeaderSelect {
  max-width: 200px;
  font-size: 14px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  padding: 4px 8px;
  background: var(--bg-card);
  color: var(--text);
}
.page-head-city-auto {
  white-space: nowrap;
  font-style: italic;
}

/* ----------------------------------------------------------
   Toast Notifications (ported from admin's style.css/admin.js —
   auto-refresh, city-detected, subscription-saved, etc.)
   ---------------------------------------------------------- */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: var(--z-skip-link, 999);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: calc(100vw - 32px);
}
.toast-container .toast { pointer-events: auto; }

.toast {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s ease;
  max-width: 360px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast-success { background: var(--success); color: #fff; }
.toast-error   { background: var(--danger);  color: #fff; }
.toast-info    { background: var(--info);    color: #fff; }

.toast-message { flex: 1; }
.toast-action {
  color: #fff;
  text-decoration: underline;
  white-space: nowrap;
  flex-shrink: 0;
}
.toast-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.8;
  flex-shrink: 0;
  padding: 0;
}
.toast-close:hover { opacity: 1; }

/* ----------------------------------------------------------
   Cookie banner (152-ФЗ ст. 10.1) — injected by public.js on first visit,
   non-blocking bottom bar, not a full-page overlay (site stays usable
   without dismissing it). Persisted via cookie_consent cookie, not
   localStorage, so it stays consistent with the site's other cookie-based
   preferences (city, theme fallback).
   ---------------------------------------------------------- */
.cookie-banner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-skip-link, 999);
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  padding: 14px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--text);
}
.cookie-banner p {
  flex: 1;
  min-width: 200px;
  margin: 0;
}
.cookie-banner a { color: var(--accent); }
.cookie-banner-accept {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
}
.cookie-banner-accept:hover { background: var(--accent-hover); }

@media (max-width: 540px) {
  .cookie-banner { flex-direction: column; align-items: stretch; text-align: center; }
  .cookie-banner-accept { width: 100%; }
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

@media (max-width: 480px) {
  .toast-container { left: 16px; right: 16px; }
  .toast { max-width: none; }
}

/* ----------------------------------------------------------
   Rubric Tabs (filter chips)
   ---------------------------------------------------------- */
.rubric-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.rubric-tab {
  padding: 7px 18px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: all var(--transition);
  text-decoration: none;
}
.rubric-tab:hover {
  color: var(--accent);
  border-color: var(--accent);
  text-decoration: none;
}
.rubric-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.rubric-tab-extra {
  display: none;
}
.rubric-tab-extra.is-visible {
  display: inline-flex;
  animation: rubricTagIn 0.25s ease;
}
@keyframes rubricTagIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.rubric-tab-more {
  cursor: pointer;
  background: transparent;
  border-style: dashed;
  font-weight: 600;
}
.rubric-tab-more:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ----------------------------------------------------------
   Pagination
   ---------------------------------------------------------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 28px;
  padding: 20px 0;
}

.page-link {
  padding: 9px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  transition: all var(--transition);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.page-link:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
  text-decoration: none;
}

.page-info {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ----------------------------------------------------------
   Digests (/digest/daily, /digest/weekly — задача 1)
   ---------------------------------------------------------- */
.digest-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.digest-summary-stub {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px;
  margin-bottom: 20px;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
}
[data-theme="black"] .digest-summary-stub { background: #1e293b; }

.digest-day-section { margin-bottom: 36px; }

/* Задача 3 (2026-08-06) — счётчики тональности на /digest/daily и /digest/weekly.
   Компактность (2026-08-06) — изначальный вариант складывал иконку/подпись/
   число/процент в столбик (~150px высоты); теперь всё в один горизонтальный
   ряд на карточку, ≥1024px — общая высота блока ~60px. */
.sentiment-counts-widget {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.sentiment-count-card {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
  font: inherit;
  transition: border-width 0.1s, filter 0.1s;
}

.sentiment-count-card:hover { filter: brightness(1.08); }

/* Активный фильтр — та же граница цвета, но заметно толще, и фон ярче (0.3 → 0.5). */
.sentiment-count-card.active {
  border-width: 2px;
  padding: 11px 15px;
}
.sentiment-count-card.sentiment-count-positive.active { background: rgba(16, 185, 129, 0.5); }
.sentiment-count-card.sentiment-count-neutral.active  { background: rgba(107, 114, 128, 0.5); }
.sentiment-count-card.sentiment-count-negative.active { background: rgba(239, 68, 68, 0.5); }
[data-theme="black"] .sentiment-count-card.sentiment-count-positive.active { background: rgba(16, 185, 129, 0.32); }
[data-theme="black"] .sentiment-count-card.sentiment-count-neutral.active  { background: rgba(156, 163, 175, 0.28); }
[data-theme="black"] .sentiment-count-card.sentiment-count-negative.active { background: rgba(239, 68, 68, 0.32); }

.sentiment-count-icon {
  font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
}

.sentiment-count-label {
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

.sentiment-count-number {
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
}

.sentiment-count-percent {
  font-size: 12px;
  opacity: 0.85;
  flex-shrink: 0;
}

/* Приглушённый фон — насыщенный цвет на 30% непрозрачности вместо плоской
   пастели, текст/цифры остаются полностью непрозрачными и жирными. */
.sentiment-count-positive { background: rgba(16, 185, 129, 0.3); color: #059669; border-color: #a7f3d0; }
.sentiment-count-neutral  { background: rgba(107, 114, 128, 0.3); color: #6b7280; border-color: #e5e7eb; }
.sentiment-count-negative { background: rgba(239, 68, 68, 0.3); color: #dc2626; border-color: #fecaca; }

[data-theme="black"] .sentiment-count-positive { background: rgba(16, 185, 129, 0.18); color: #34d399; border-color: #065f46; }
[data-theme="black"] .sentiment-count-neutral  { background: rgba(156, 163, 175, 0.15); color: #9ca3af; border-color: #374151; }
[data-theme="black"] .sentiment-count-negative { background: rgba(239, 68, 68, 0.18); color: #f87171; border-color: #7f1d1d; }

.sentiment-counts-period {
  font-size: 12px;
  color: var(--text-muted);
  margin: -6px 0 16px;
}

/* Планшет 768–1023px — та же однострочная раскладка, компактнее */
@media (max-width: 1023px) {
  .sentiment-count-card { padding: 8px 12px; }
  .sentiment-count-number { font-size: 18px; }
}

/* Мобильный <768px — подписи прячем (кружок + число + процент остаются),
   ряд не переносится на карточку — flex-wrap нигде не включён. */
@media (max-width: 767px) {
  .sentiment-counts-widget { gap: 4px; }
  .sentiment-count-card { padding: 6px 8px; gap: 4px; }
  .sentiment-count-label { display: none; }
  .sentiment-count-number { font-size: 16px; }
  .sentiment-count-percent { font-size: 10px; }
}

/* Очень маленький экран <400px — убираем и процент, только кружок + число */
@media (max-width: 399px) {
  .sentiment-count-percent { display: none; }
  .sentiment-count-number { font-size: 14px; }
}

/* ----------------------------------------------------------
   Trends (/trends — Google Trends «Что ищут в России»)
   ---------------------------------------------------------- */
.trends-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin: -12px 0 24px;
}

.trends-weekly-section {
  margin-bottom: 32px;
  background: #f8fafc;
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 20px;
}
[data-theme="black"] .trends-weekly-section { background: #1e293b; }

.trends-weekly-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 4px 16px;
}
.trends-weekly-list a {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
  transition: background var(--transition);
}
.trends-weekly-list a:hover {
  background: var(--bg-hover);
  text-decoration: none;
}
.trends-weekly-rank {
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
  width: 22px;
}
.trends-weekly-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.trends-weekly-traffic {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}

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

.trend-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.trend-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.trend-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.trend-traffic-badge {
  flex-shrink: 0;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
[data-theme="black"] .trend-traffic-badge { background: #1e3a5f; }

.trend-time {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.trend-related {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.trend-related h4 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 0 0 8px;
}
.trend-related-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.trend-related-title {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  line-height: 1.35;
}
.trend-related-title:hover {
  color: var(--accent);
  text-decoration: underline;
}
.trend-related-meta {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.trend-related-source-link {
  color: var(--text-muted);
}
.trend-related-source-link:hover {
  color: var(--accent);
  text-decoration: underline;
}
.trend-no-related {
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
}

/* Задача 3 — компактный виджет на главной, после топ-12 */
.trends-widget-section {
  margin-bottom: 32px;
  padding: 12px 0 16px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.trends-widget-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.trends-widget-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.trends-widget-all {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
}
.trends-widget-all:hover { color: var(--accent); }
.trends-widget-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.trends-widget-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 13px;
  text-decoration: none;
  transition: all var(--transition);
}
.trends-widget-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}
.trends-widget-chip-traffic {
  font-size: 11px;
  color: var(--text-muted);
}

/* ----------------------------------------------------------
   Empty State
   ---------------------------------------------------------- */
.empty-portal {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}
.empty-portal .empty-icon {
  font-size: 56px;
  margin-bottom: 16px;
  opacity: 0.4;
  display: flex;
  align-items: center;
  justify-content: center;
}
.empty-portal h3 {
  font-size: 20px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.empty-portal p { font-size: 14px; }

/* ----------------------------------------------------------
   Site Footer
   ---------------------------------------------------------- */
.site-footer {
  background: var(--bg-footer);
  color: var(--text-light);
  margin-top: 48px;
}

.footer-inner {
  width: 95%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.footer-rubrics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 14px;
}
.footer-rubrics a { color: var(--text-light); transition: color var(--transition); }
.footer-rubrics a:hover { color: #fff; }
.footer-sep { color: var(--text-muted); }

.footer-about {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-muted);
}
.footer-about a { color: var(--text-light); }
.footer-about a:hover { color: #fff; }

.footer-legal {
  font-size: 11px;
  color: #9ca3af;
}
.footer-legal a { color: #9ca3af; }
.footer-legal a:hover { color: #fff; }

/* ----------------------------------------------------------
   Sidebar Overlay
   ---------------------------------------------------------- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: var(--z-overlay);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.sidebar-overlay.open { display: block; }

/* ============================================================
   AUTH PAGES (login / register)
   ============================================================ */

.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--header-height) - 200px);
  padding: 32px 20px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: var(--shadow-lg);
}

.auth-card h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.auth-card > p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.auth-error,
.auth-success {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.auth-error {
  background: var(--danger-bg);
  border: 1px solid rgba(213, 43, 43, 0.2);
  color: var(--danger);
}
.auth-success {
  background: var(--success-bg);
  border: 1px solid rgba(34, 164, 90, 0.2);
  color: var(--success);
}

.field-error {
  font-size: 12px;
  color: var(--danger);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Auth form inherits from .register-form */
.register-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.register-form .form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.register-form .form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.register-form .form-group input {
  padding: 11px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.register-form .form-group input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(44, 110, 213, 0.12);
}
.register-form .form-group input::placeholder {
  color: var(--text-muted);
}

.btn-auth {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-auth:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-auth:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.auth-footer {
  margin-top: 20px;
  text-align: center;
  font-size: 14px;
  color: var(--text-secondary);
}
.auth-footer a { font-weight: 500; }

/* ============================================================
   ARTICLE DETAIL PAGE
   ============================================================ */

.article-detail {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: 800px;
  margin: 0 auto;
}

/* Breadcrumbs */
.breadcrumbs {
  margin-bottom: 20px;
  font-size: 13px;
}
.breadcrumbs ol {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.breadcrumbs li {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
}
.breadcrumbs li:not(:last-child)::after {
  content: '/';
  color: var(--text-muted);
  font-size: 12px;
}
.breadcrumbs li:last-child {
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}
.breadcrumbs a { color: var(--accent); }
.breadcrumbs a:hover { text-decoration: underline; }

/* Article Header */
.article-header { margin-bottom: 24px; }

.article-header h1 {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}

.article-detail .article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 13px;
  color: var(--text-muted);
  align-items: center;
}

.article-source {
  font-weight: 600;
  color: var(--accent);
}

.article-views,
.article-category {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Article Image */
.article-image {
  margin-bottom: 24px;
  border-radius: var(--radius);
  overflow: hidden;
  max-height: 480px;
}
.article-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Article Summary / Description */
.article-detail .article-summary {
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-secondary);
  margin-bottom: 24px;
  padding: 16px 20px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent);
}

/* LLM-резюме сюжета (ТЗ LLM3). Цвета и метрики заданы ТЗ буквально
   (#f0f9ff / 4px #3b82f6 / 15px / 1.6) — поэтому они здесь литералами, а не
   переменными темы: голубая плашка светлее общего --bg и должна отличаться от
   соседнего article-summary, где лид первоисточника. В тёмной теме эти
   значения слепят, там ниже переопределение. */
.article-detail .story-llm-summary {
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  margin-bottom: 24px;
  padding: 16px;
  background: #f0f9ff;
  border-radius: var(--radius-sm);
  border-left: 4px solid #3b82f6;
}
.article-detail .story-llm-summary .llm-summary-heading {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--text);
}
.article-detail .story-llm-summary p {
  margin: 0;
}
.article-detail .story-llm-summary .llm-summary-note {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
}

/* Article Content */
.article-detail .article-content {
  font-size: 16px;
  line-height: 1.75;
  color: var(--text);
  margin-bottom: 24px;
}
.article-detail .article-content p {
  margin-bottom: 16px;
}

/* Article Footer Actions */
.article-footer {
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.article-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.btn-source {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  background: var(--bg-card);
  transition: all var(--transition);
  text-decoration: none;
}
.btn-source:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
  text-decoration: none;
}

/* Share buttons */
.share-buttons {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.share-label {
  font-size: 14px;
  color: var(--text-secondary);
}

.btn-share {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  background: var(--bg-card);
  transition: all var(--transition);
  text-decoration: none;
  cursor: pointer;
}
.btn-share:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
  text-decoration: none;
}

/* Similar articles */
.similar-articles {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.similar-articles-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text);
}

/* ============================================================
   THEME: Black (Dark Mode — GitHub-dark inspired)
   ============================================================ */

[data-theme="black"] {
  --bg:              #0d1117;
  --bg-card:         #161b22;
  --bg-card-hover:   #1c2333;
  --bg-header:       #010409;
  --bg-footer:       #010409;
  --bg-sidebar:      var(--bg-card);
  --bg-input:        #0d1117;
  --bg-hover:        #1c2333;
  --bg-accent-soft:  #1f3a5f;

  --text:            #e6edf3;
  --text-secondary:  #8b949e;
  --text-muted:      #7d8590; /* WCAG AA: was #6e7681 (fails 4.5:1 on --bg-card) */
  --text-light:      #8b949e;
  --text-inverse:    #0d1117;

  --border:          #30363d;
  --border-light:    #21262d;
  --border-focus:    #58a6ff;

  --accent:          #58a6ff;
  --accent-hover:    #79c0ff;
  --accent-light:    #1f3a5f;

  --russia:          #f85149;
  --russia-bg:       #2d1515;
  --world:           #58a6ff;
  --world-bg:        #15223a;

  --like:            #f85149;
  --like-bg:         #2d1515;
  --success:         #3fb950;
  --success-bg:      #1b2d1f;
  --warning:         #d29922;
  --warning-bg:      #2d2415;
  --danger:          #f85149;
  --danger-bg:       #2d1515;
  --info:            #58a6ff;
  --info-bg:         #15223a;

  --shadow:          0 1px 3px rgba(0,0,0,0.4);
  --shadow-hover:    0 8px 25px rgba(0,0,0,0.5);
  --shadow-lg:       0 12px 40px rgba(0,0,0,0.6);
  --shadow-header:   0 1px 3px rgba(0,0,0,0.5);
}

[data-theme="black"] .site-header { box-shadow: 0 1px 3px rgba(0,0,0,0.5); }
[data-theme="black"] .trending-card { border-color: var(--border); }
[data-theme="black"] .trending-rank { background: var(--accent-light); }
[data-theme="black"] .article-detail .article-summary { border-left-color: var(--accent); }
/* LLM3, тёмная тема: светло-голубая плашка из ТЗ здесь читалась бы чёрным по
   белому посреди тёмной страницы. Берём готовую информационную пару темы —
   она уже проверена на контраст (см. комментарии у --info в светлой теме). */
[data-theme="black"] .article-detail .story-llm-summary {
  background: var(--info-bg);
  border-left-color: var(--info);
}
[data-theme="black"] .news-card { border-color: var(--border); }
[data-theme="black"] .sidebar-filters { border-color: var(--border); }

/* ============================================================
   THEME: Neutral (Google-inspired gray)
   ============================================================ */

[data-theme="neutral"] {
  --bg:              #f2f3f5;
  --bg-card:         #ffffff;
  --bg-card-hover:   #f0f1f3;
  --bg-header:       #3c4043;
  --bg-footer:       #202124;
  --bg-sidebar:      var(--bg-card);
  --bg-input:        #f8f9fa;
  --bg-hover:        #f0f1f3;

  --text:            #202124;
  --text-secondary:  #5f6368;
  --text-muted:      #70777f; /* WCAG AA: was #9aa0a6 (fails 4.5:1 on --bg-card) */
  --text-light:      #9aa0a6;

  --border:          #dadce0;
  --border-light:    #e8eaed;
  --border-focus:    #1a73e8;

  --accent:          #1a73e8;
  --accent-hover:    #1557b0;
  --accent-light:    #e8f0fe;

  --shadow:          0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-hover:    0 8px 25px rgba(0,0,0,0.08);
  --shadow-lg:       0 12px 40px rgba(0,0,0,0.1);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* Tablet landscape */
@media (max-width: 1024px) {
  .latest-columns { grid-template-columns: 1fr; }
}

/* Sidebar becomes a collapsible drawer below 1024px — inline 260/300px
   рядом с лентой уже не помещается. .card-grid ничего здесь не переопределяет:
   repeat(auto-fill, minmax(300px, 1fr)) сам даёт нужное число колонок под
   освободившуюся ширину .main-area. */
@media (max-width: 1023px) {
  .sidebar-filters {
    display: none;
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: 280px;
    z-index: var(--z-sidebar);
    padding: 20px;
    border: none;
    border-radius: 0;
    box-shadow: 4px 0 20px rgba(0,0,0,0.15);
    overflow-y: auto;
    max-height: none;
  }
  .sidebar-filters.open { display: block; }
  .sidebar-close { display: flex; }
  .mobile-menu-btn { display: flex; }
}

/* Tablet portrait / mobile */
@media (max-width: 768px) {
  .rubric-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px;
  }
  .rubric-tab {
    white-space: nowrap;
    flex: 0 0 auto;
  }

  /* Header nav collapse — .nav-dropdown wraps a .nav-link but isn't one
     itself, so it needs its own entry here or it's left as an empty box
     with its (hidden) toggle link inside. */
  .header-nav .nav-link:not(.nav-admin),
  .header-nav .nav-dropdown { display: none; }
  .header-nav .nav-admin { margin-left: auto; }

  /* Card grid — только уменьшенный зазор, число колонок считает auto-fill */
  .card-grid { gap: 12px; }

  /* Trending */
  .trending-card { padding: 12px 14px; }

  /* Latest */
  .latest-columns { grid-template-columns: 1fr; }

  /* Article detail */
  .article-detail { padding: 20px 16px; border-radius: 0; border-left: none; border-right: none; }
  .article-header h1 { font-size: 22px; }

  /* FAB */
  .filter-fab { display: flex; }

  /* Page head */
  .page-head h1 { font-size: 22px; }
  .page-head { flex-direction: column; align-items: flex-start; gap: 4px; }
  .page-head-city-filter { width: 100%; }
  #cityHeaderSelect { max-width: none; flex: 1; }
}

/* Small phones */
@media (max-width: 540px) {
  .trending-title { white-space: normal; }

  .auth-card { padding: 24px 20px; }

  .latest-columns { grid-template-columns: 1fr; }
  .section-header { flex-direction: column; align-items: flex-start; gap: 4px; }
}

/* ============================================================
   UTILITIES
   ============================================================ */

.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-accent { color: var(--accent); }

.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }

.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================================
   SCROLLBAR
   ============================================================ */

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Firefox scrollbar */
html { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

/* ============================================================
   ANIMATIONS
   ============================================================ */

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.news-card { animation: slideUp 0.35s ease both; }
.news-card:nth-child(1) { animation-delay: 0.02s; }
.news-card:nth-child(2) { animation-delay: 0.04s; }
.news-card:nth-child(3) { animation-delay: 0.06s; }
.news-card:nth-child(4) { animation-delay: 0.08s; }
.news-card:nth-child(5) { animation-delay: 0.10s; }
.news-card:nth-child(6) { animation-delay: 0.12s; }

/* ============================================================
   STORY CLUSTERING — badges, source line, disclosure list, modal
   ============================================================ */

.cluster-badge {
  display: inline-flex;
  align-items: center;
  font-size: 15px;
  margin-bottom: 8px;
  line-height: 1;
}

.card-sources {
  margin-top: 4px;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.sources-preview {
  color: var(--text-muted);
}

.sources-toggle {
  display: inline-flex;
  align-items: center;
  border: none;
  background: #3b82f6;
  color: #fff;
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.sources-toggle:hover { background: #2563eb; color: #fff; text-decoration: none; }

.sources-list {
  list-style: none;
  padding: 0;
  margin: 2px 0 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
}
.sources-list[hidden] { display: none; }
.sources-list li { color: var(--text-secondary); }
.sources-list a { color: var(--accent); font-weight: 500; }
.sources-list a:hover { color: var(--accent-hover); }
.sources-list time { color: var(--text-muted); margin-left: 4px; }

.story-link {
  display: inline-block;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
}
.story-link:hover { color: var(--accent-hover); text-decoration: underline; }

.article-sources {
  margin: 4px 0 20px;
}

.sources-heading {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--text-primary);
}

/* ---------- Modal ---------- */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 22, 0.55);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 640px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  position: relative;
  padding: 28px 24px 24px;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.modal-close:hover { color: var(--text); border-color: var(--text-muted); }

.modal-image {
  margin: -28px -24px 16px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  overflow: hidden;
  max-height: 280px;
}
.modal-image img { width: 100%; height: 100%; object-fit: cover; display: block; }

.modal-title {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text);
  margin-bottom: 10px;
}

.modal-meta {
  display: flex;
  gap: 12px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.modal-text {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-secondary);
  margin-bottom: 16px;
}
.modal-text p { margin-bottom: 12px; }
.modal-text p:last-child { margin-bottom: 0; }

.modal-body .sources-toggle { margin-bottom: 8px; display: inline-block; }
.modal-body .sources-list { margin-bottom: 16px; }

.modal-btn-source {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}
.modal-btn-source:hover { background: var(--accent-hover); color: #fff; }

/* ----------------------------------------------------------
   Cabinet dashboard widgets (TOR §3)
   ---------------------------------------------------------- */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.dashboard-widget {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.dashboard-widget h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.dashboard-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.dashboard-list li { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.dashboard-list a { color: var(--text); font-weight: 500; text-decoration: none; }
.dashboard-list a:hover { color: var(--accent); }
.dashboard-meta { color: var(--text-muted); font-size: 12px; }
.dashboard-loading, .dashboard-empty { color: var(--text-muted); font-size: 13px; }

.dashboard-bars { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.dashboard-bars li { display: grid; grid-template-columns: 1fr 2fr auto; align-items: center; gap: 8px; font-size: 13px; }
.dashboard-bars a { color: var(--text); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dashboard-bar-track { background: var(--bg-hover); border-radius: 6px; height: 8px; overflow: hidden; }
.dashboard-bar-fill { background: var(--accent); height: 100%; border-radius: 6px; }
.dashboard-bar-count { color: var(--text-muted); font-size: 12px; text-align: right; }

.dashboard-stats { display: flex; gap: 18px; flex-wrap: wrap; }
.dashboard-stat { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.dashboard-stat strong { font-size: 22px; color: var(--accent); }
.dashboard-stat span { font-size: 12px; color: var(--text-muted); }

/* "Мой город" widget (homepage, TOR §2.5.5) */
.my-city-section .section-header a.section-subtitle { text-decoration: none; }
.my-city-section .section-header a.section-subtitle:hover { text-decoration: underline; }

/* Sentiment filter pills (TOR §4.4) */
.sentiment-filter {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.sentiment-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  line-height: 1;
  padding: 5px 14px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border);
  text-decoration: none;
  transition: all var(--transition);
}
.sentiment-pill:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.sentiment-pill.active { color: #fff; border-color: transparent; }
.sentiment-pill.active.sentiment-positive, .sentiment-pill.sentiment-positive.active { background: var(--success); }
.sentiment-pill.active.sentiment-negative, .sentiment-pill.sentiment-negative.active { background: var(--danger); }
.sentiment-pill.active.sentiment-neutral, .sentiment-pill.sentiment-neutral.active { background: var(--text-muted); }
.sentiment-pill.active:not(.sentiment-positive):not(.sentiment-negative):not(.sentiment-neutral) { background: var(--accent); }

/* Sentiment chips relocated into sidebar (rubric pages) — wraps instead of
   scrolling so all 4 pills (Все/Позитив/Нейтрально/Негатив) stay fully
   visible within the sidebar's width. Only 3 pills now (list5 п.1 — "Все"
   removed, each pill toggles itself off on a second click instead), so a
   single non-wrapping row fits comfortably without the earlier wrap fallback. */
.sidebar-sentiment-filter {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: nowrap;
  gap: 5px;
}
.sidebar-sentiment-filter .sentiment-pill {
  flex: 1;
  text-align: center;
  padding: 3px 8px;
  font-size: 11px;
}

.sidebar-category-filter {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-category-filter noscript button {
  margin-top: 4px;
}

/* Sentiment marker on news card (TOR §4.5) */
.sentiment-marker {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.sentiment-marker.sentiment-positive { background: var(--success); }
.sentiment-marker.sentiment-negative { background: var(--danger); }
.sentiment-marker.sentiment-neutral { background: var(--text-light); }

/* Sentiment breakdown bar (cabinet dashboard widget) */
.sentiment-bar {
  display: flex;
  height: 14px;
  border-radius: 7px;
  overflow: hidden;
  background: var(--border-light);
}
.sentiment-bar-seg { height: 100%; }
.sentiment-bar-seg.sentiment-positive { background: var(--success); }
.sentiment-bar-seg.sentiment-neutral { background: var(--text-light); }
.sentiment-bar-seg.sentiment-negative { background: var(--danger); }

/* Sentiment trend — diverging stacked columns, one per day, centered on
   neutral (cabinet dashboard "Тональность по дням", TOR list2 п.13). Same
   3-color convention as .sentiment-bar above (positive=success, neutral=
   text-light, negative=danger) — kept identical on purpose, this widget
   sits right next to that one on the same dashboard.
   .sr-only itself moved to tokens.css (TOR list2 п.20) — the admin RAM-trend
   widget needs the same "table view exists" a11y pattern and previously had
   no equivalent utility at all (style.css didn't import public.css). */

.sentiment-trend-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.sentiment-trend-legend-item { display: flex; align-items: center; gap: 5px; }
.sentiment-trend-legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.sentiment-trend-legend-dot.sentiment-positive { background: var(--success); }
.sentiment-trend-legend-dot.sentiment-neutral { background: var(--text-light); }
.sentiment-trend-legend-dot.sentiment-negative { background: var(--danger); }

.sentiment-trend-chart {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 3px;
  height: 150px;
}
.sentiment-trend-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.sentiment-trend-arm-up, .sentiment-trend-arm-down {
  width: 100%;
  max-width: 18px;
  display: flex;
  flex-direction: column;
}
.sentiment-trend-arm-up { justify-content: flex-end; height: 64px; }
.sentiment-trend-arm-down { justify-content: flex-start; height: 64px; }
.sentiment-trend-seg { width: 100%; }
.sentiment-trend-seg.sentiment-positive { background: var(--success); border-radius: 4px 4px 0 0; margin-bottom: 2px; }
.sentiment-trend-seg.sentiment-negative { background: var(--danger); border-radius: 0 0 4px 4px; margin-top: 2px; }
.sentiment-trend-seg.sentiment-neutral-top { background: var(--text-light); }
.sentiment-trend-seg.sentiment-neutral-bottom { background: var(--text-light); }
.sentiment-trend-zero { width: 100%; max-width: 18px; height: 2px; background: var(--border); flex-shrink: 0; }
.sentiment-trend-label {
  margin-top: 6px;
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}
.sentiment-trend-col:hover .sentiment-trend-seg { filter: brightness(1.15); }

/* Card top row: favicon + source + relative time (TOR §5.1) */
.card-top-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
.source-favicon { border-radius: 3px; flex-shrink: 0; }
.card-top-source { font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-top-time { margin-left: auto; flex-shrink: 0; white-space: nowrap; }

.card-views {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  font-size: 12px;
}

/* Back-to-top button (TOR §5.5) */
.back-to-top {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  font-size: 18px;
  cursor: pointer;
  box-shadow: var(--shadow-hover);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: var(--z-fab);
  transition: opacity var(--transition);
}
.back-to-top.is-visible { display: flex; }
.back-to-top:hover { background: var(--accent-hover); }

/* ============================================================
   CARD GRID — число колонок больше не задаётся точками останова.
   .card-grid: grid-template-columns: repeat(auto-fill, minmax(300px, 1fr))
   сама даёт нужное число колонок под текущую ширину .main-area.
   ============================================================ */
