:root {
  --ink: #17222e;
  --muted: #5d6b7a;
  --line: #e4e9f0;
  --bg: #f5f7fa;
  --card: #ffffff;
  --accent: #2748c9;
  --accent-dark: #1d38a3;
  --accent-soft: #eef1fc;
  --tg: #229ed9;
  --serif: Georgia, "PT Serif", "Times New Roman", serif;
  --sans: "Segoe UI", -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(23, 34, 46, .05), 0 4px 16px rgba(23, 34, 46, .06);
  --shadow-hover: 0 2px 4px rgba(23, 34, 46, .08), 0 10px 28px rgba(39, 72, 201, .12);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
}
.wrap { max-width: 1060px; margin: 0 auto; padding: 0 20px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-family: var(--serif); font-size: 1.8rem; font-weight: 700; margin: 20px 0 10px; line-height: 1.25; }
h2 { font-family: var(--serif); font-size: 1.25rem; margin: 30px 0 14px; }
h3 { font-size: 1rem; margin: 0 0 6px; }
.muted { color: var(--muted); }
.hub-text { color: var(--muted); max-width: 760px; }

/* ---------- Шапка ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; gap: 20px; padding: 10px 20px; flex-wrap: wrap; }
.logo {
  display: flex; align-items: center; gap: 9px;
  font-family: var(--serif); font-size: 1.35rem; font-weight: 700; color: var(--ink);
}
.logo:hover { text-decoration: none; }
.logo-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #5b7bef);
  color: #fff; font-size: 1.05rem;
}
.top-nav { display: flex; gap: 4px; align-items: center; }
.menu-link {
  padding: 8px 12px; border-radius: 8px; color: var(--ink);
  font-size: .95rem; font-weight: 500;
}
.menu-link:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.caret { font-size: .75em; color: var(--muted); }

/* Мега-меню категорий: слева категории, справа вылетают подкатегории */
.menu-item { position: relative; }
.dropdown {
  position: absolute; top: 100%; left: 0; z-index: 60;
  width: 340px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-hover);
  padding: 8px;
  display: none;
}
.menu-item:hover .dropdown,
.menu-item:focus-within .dropdown { display: block; }
.dd-item { position: relative; }
.dd-cat {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; border-radius: 8px;
  font-weight: 600; color: var(--ink); font-size: .94rem;
}
.dd-cat:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.dd-arrow { color: var(--muted); font-weight: 400; }
.dd-flyout {
  position: absolute; left: 100%; top: 0; z-index: 61;
  width: 380px; max-height: 70vh; overflow-y: auto;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-hover);
  padding: 12px;
  display: none;
}
.dd-item:hover .dd-flyout,
.dd-item:focus-within .dd-flyout { display: block; }
/* Первым/последним категориям флаяут может уходить за экран — прижимаем */
.dd-item:first-child .dd-flyout { top: 0; }
.dd-item:nth-last-child(-n+6) .dd-flyout { top: auto; bottom: 0; }
.dd-flyout-title {
  font-family: var(--serif); font-weight: 700; font-size: .95rem;
  padding: 2px 10px 8px; color: var(--ink);
  border-bottom: 1px solid var(--line); margin-bottom: 6px;
}
.dd-sub {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: .87rem; color: var(--muted);
  padding: 5px 10px; border-radius: 7px;
}
.dd-sub:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.dd-n { color: #a5b0bd; font-size: .8rem; }
.dd-all { font-weight: 600; color: var(--accent); margin-top: 4px; }

.search-form { display: flex; flex: 1; min-width: 200px; max-width: 360px; margin-left: auto; }
.search-form input {
  flex: 1; padding: 8px 14px; border: 1px solid var(--line);
  border-radius: 999px 0 0 999px; font-size: .92rem; outline: none;
  background: var(--bg);
}
.search-form input:focus { border-color: var(--accent); background: #fff; }
.search-form button {
  padding: 8px 16px; border: none; border-radius: 0 999px 999px 0;
  background: var(--accent); color: #fff; font-size: 1rem; cursor: pointer;
}
.search-form button:hover { background: var(--accent-dark); }
.header-tg { font-size: .88rem; padding: 7px 14px; }

/* Переключатель языка */
.lang-switch {
  display: flex; border: 1px solid var(--line); border-radius: 999px;
  overflow: hidden;
}
.lang-opt {
  padding: 5px 11px; font-size: .82rem; font-weight: 600;
  color: var(--muted);
}
.lang-opt:hover { text-decoration: none; color: var(--accent); }
.lang-opt.active { background: var(--accent); color: #fff; }

/* ---------- Главная ---------- */
.hero {
  margin: 24px 0 8px; padding: 44px 40px;
  background: linear-gradient(120deg, #101c3f 0%, #2748c9 70%, #4a6de8 100%);
  border-radius: 18px; color: #fff;
}
.hero h1 { color: #fff; margin-top: 0; font-size: 2rem; }
.hero-sub { color: rgba(255, 255, 255, .82); font-size: 1.05rem; margin: 8px 0 22px; }
.hero-stats { display: flex; gap: 44px; flex-wrap: wrap; }
.hero-stats div { display: flex; flex-direction: column; }
.hero-stats strong { font-size: 1.7rem; font-family: var(--serif); }
.hero-stats span { color: rgba(255, 255, 255, .7); font-size: .88rem; }

.cat-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.cat-card {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px; color: var(--ink);
  box-shadow: var(--shadow);
  transition: transform .15s ease, box-shadow .15s ease;
}
.cat-card:hover {
  transform: translateY(-2px); box-shadow: var(--shadow-hover);
  text-decoration: none; border-color: transparent;
}
.cat-title { font-weight: 600; font-family: var(--serif); font-size: 1.05rem; }
.cat-n { color: var(--muted); font-size: .85rem; }

/* ---------- Списки статей ---------- */
.art-list { list-style: none; margin: 0; padding: 0; }
.art-item {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 20px; margin-bottom: 12px;
  box-shadow: var(--shadow);
  transition: box-shadow .15s ease;
}
.art-item:hover { box-shadow: var(--shadow-hover); }
.art-title { font-size: 1.06rem; font-weight: 600; display: block; margin-bottom: 4px; font-family: var(--serif); }
.art-authors { color: var(--ink); font-size: .92rem; display: block; }
.art-meta { color: var(--muted); font-size: .87rem; }
.art-meta-big { color: var(--muted); font-size: .95rem; }
.art-excerpt { margin: 8px 0 0; color: var(--muted); font-size: .92rem; }

/* ---------- Хлебные крошки ---------- */
.breadcrumbs { margin-top: 20px; font-size: .88rem; color: var(--muted); }
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--accent); }
.crumb-sep { margin: 0 6px; color: #b7c1cc; }

/* ---------- Страница статьи ---------- */
.article-full {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; padding: 30px 34px; margin-top: 12px;
  box-shadow: var(--shadow);
}
.abstract p { font-size: 1rem; }
.actions { margin: 20px 0; display: flex; gap: 12px; flex-wrap: wrap; }
.btn {
  display: inline-block; padding: 9px 20px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font-size: .93rem; cursor: pointer; transition: all .15s ease;
}
.btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); color: #fff; }
.btn-cite { border-color: var(--accent); color: var(--accent); }
.btn-cite:hover { background: var(--accent-soft); }
.btn-tg { background: var(--tg); border-color: var(--tg); color: #fff; }
.btn-tg:hover { background: #1b8ac0; color: #fff; }

.tg-funnel {
  margin-top: 26px;
  background: linear-gradient(120deg, #eaf5fd, #f2f7ff);
  border: 1px solid #cfe4f5;
  border-radius: var(--radius); padding: 18px 22px;
}
.tg-funnel p { margin: 6px 0 14px; color: var(--muted); }

/* ---------- Модальное окно цитирования ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(16, 24, 40, .55);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay[hidden] { display: none; }
.modal-window {
  background: var(--card); border-radius: 16px;
  box-shadow: 0 24px 64px rgba(16, 24, 40, .35);
  width: 100%; max-width: 640px; max-height: 86vh;
  display: flex; flex-direction: column;
  animation: modal-in .18s ease;
}
@keyframes modal-in {
  from { transform: translateY(14px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 24px 10px;
}
.modal-head h3 { font-family: var(--serif); font-size: 1.15rem; margin: 0; }
.modal-close {
  border: none; background: var(--bg); color: var(--muted);
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer; font-size: .9rem;
}
.modal-close:hover { background: var(--accent-soft); color: var(--accent); }
.cite-tabs {
  display: flex; gap: 6px; padding: 0 24px;
  border-bottom: 1px solid var(--line);
}
.cite-tab {
  border: none; background: none; padding: 9px 14px; cursor: pointer;
  font-size: .93rem; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.cite-tab:hover { color: var(--accent); }
.cite-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.cite-text {
  margin: 16px 24px; padding: 14px 16px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  font-size: .9rem; white-space: pre-wrap; word-break: break-word;
  overflow-y: auto;
}
.modal-foot { padding: 0 24px 20px; display: flex; justify-content: flex-end; }

/* ---------- Журналы ---------- */
.journal-cat-title a { color: var(--ink); }
.journal-cat-title a:hover { color: var(--accent); }
.journal-sub-title { margin: 14px 0 8px; }
.journal-sub-title a { color: var(--muted); font-weight: 600; }
.journal-sub-title a:hover { color: var(--accent); }
.journals-box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 18px; margin: 14px 0; box-shadow: var(--shadow); }
.journals-box summary { cursor: pointer; font-weight: 600; }
.journal-list { columns: 2; padding-left: 18px; }
.journal-list li { margin-bottom: 4px; font-size: .92rem; }
.journals-index { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 18px; box-shadow: var(--shadow); }
.journal-row { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.journal-row:last-child { border-bottom: none; }
.journal-name { font-weight: 600; }
.journal-meta { font-size: .85rem; white-space: nowrap; }

.pager { display: flex; gap: 18px; align-items: center; margin: 22px 0; color: var(--muted); }
.pager a { font-weight: 600; }

.page-text { max-width: 760px; font-size: 1rem; }

/* ---------- Футер ---------- */
.site-footer { border-top: 1px solid var(--line); background: var(--card); margin-top: 48px; }
.footer-inner {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 18px 20px; font-size: .88rem; color: var(--muted); flex-wrap: wrap;
}
.footer-links { display: flex; gap: 16px; flex-wrap: wrap; }

/* ---------- Мобильная версия ---------- */
@media (max-width: 720px) {
  .header-inner { gap: 10px; }
  .search-form { order: 3; max-width: none; width: 100%; margin-left: 0; }
  .header-tg { display: none; }
  .dropdown { position: fixed; left: 10px; right: 10px; top: 60px; width: auto; max-height: 70vh; overflow-y: auto; }
  .dd-flyout { display: none !important; }
  .dd-arrow { display: none; }
  .hero { padding: 28px 22px; }
  .hero h1 { font-size: 1.5rem; }
  .journal-list { columns: 1; }
  .journal-row { flex-direction: column; gap: 2px; }
  .journal-meta { white-space: normal; }
  .article-full { padding: 18px; }
  .hero-stats { gap: 24px; }
}
