:root {
  --bg: #0d0f14; --surface: #151922; --surface-2: #1b202b;
  --border: #252b37; --text: #e8eaee; --text-muted: #98a0ad;
  --accent: #4f8cff; --accent-2: #8b5cf6;
  --radius: 16px; --radius-sm: 10px;
  --shadow: 0 10px 40px rgba(0,0,0,0.45); --maxw: 1440px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.65;
  -webkit-font-smoothing: antialiased; min-height: 100vh;
  display: flex; flex-direction: column;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
.container { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

/* Header */
.site-header { position: sticky; top: 0; z-index: 100; background: rgba(13,15,20,0.88); backdrop-filter: blur(14px); border-bottom: 1px solid var(--border); }
.header-top { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 14px 0; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 21px; letter-spacing: -0.6px; flex-shrink: 0; }
.logo-mark { width: 36px; height: 36px; border-radius: 11px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); display: grid; place-items: center; font-size: 17px; font-weight: 900; color: #fff; }
.main-nav { display: flex; gap: 6px; flex-wrap: wrap; }
.main-nav a { padding: 8px 14px; border-radius: 999px; font-size: 14px; font-weight: 600; color: var(--text-muted); transition: color .2s, background .2s; white-space: nowrap; }
.main-nav a:hover, .main-nav a.active { color: var(--text); background: var(--surface-2); }
.header-actions { display: flex; align-items: center; gap: 10px; }
.search-box { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 8px 14px; color: var(--text-muted); min-width: 220px; }
.search-box:focus-within { border-color: var(--accent); }
.search-box input { background: none; border: none; outline: none; color: var(--text); font-size: 14px; width: 100%; }
.mobile-menu-btn { display: none; background: var(--surface); border: 1px solid var(--border); color: var(--text); border-radius: 10px; padding: 8px 12px; cursor: pointer; }

/* Hero */
.hero {
  background: radial-gradient(900px 400px at 15% -10%, rgba(79,140,255,.18), transparent 60%),
              radial-gradient(700px 400px at 90% 0%, rgba(139,92,246,.15), transparent 60%),
              var(--bg);
  border-bottom: 1px solid var(--border); padding: 56px 0 48px;
}
.hero-inner { display: grid; grid-template-columns: 1.2fr .8fr; gap: 40px; align-items: center; }
.hero-badge { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--accent); background: rgba(79,140,255,.1); border: 1px solid rgba(79,140,255,.25); padding: 6px 14px; border-radius: 999px; margin-bottom: 18px; }
.hero h1 { font-size: 46px; line-height: 1.12; letter-spacing: -1.5px; font-weight: 800; margin-bottom: 18px; }
.hero h1 span { background: linear-gradient(135deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { color: var(--text-muted); font-size: 17px; max-width: 560px; margin-bottom: 26px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-weight: 700; padding: 13px 26px; border-radius: 999px; border: none; cursor: pointer; font-size: 15px; transition: transform .2s, box-shadow .2s; display: inline-block; }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(79,140,255,.35); }
.btn-ghost { background: var(--surface); border: 1px solid var(--border); color: var(--text); font-weight: 600; padding: 13px 26px; border-radius: 999px; font-size: 15px; cursor: pointer; display: inline-block; }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.hero-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.stat-card b { display: block; font-size: 28px; font-weight: 800; letter-spacing: -1px; }
.stat-card span { font-size: 13px; color: var(--text-muted); }

/* Layout */
.layout { max-width: var(--maxw); margin: 0 auto; padding: 32px 24px; display: grid; grid-template-columns: 200px 1fr 320px; gap: 28px; align-items: start; flex: 1; }
.left-rail { position: sticky; top: 92px; display: flex; flex-direction: column; gap: 20px; }
.center-col { min-width: 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.section-head h2 { font-size: 26px; font-weight: 750; letter-spacing: -0.6px; }
.section-head a { color: var(--accent); font-weight: 600; font-size: 14px; }

.feed { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.post-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; cursor: pointer; transition: transform .25s, border-color .25s, box-shadow .25s; display: flex; flex-direction: column; }
.post-card:hover { transform: translateY(-4px); border-color: var(--accent); box-shadow: var(--shadow); }
.post-card-img { width: 100%; height: 200px; object-fit: cover; background: var(--surface-2); }
.post-card-body { padding: 18px 20px 20px; display: flex; flex-direction: column; flex: 1; }
.post-meta { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .7px; margin-bottom: 10px; }
.post-meta .dot { width: 4px; height: 4px; border-radius: 50%; background: var(--accent); }
.post-card-title { font-size: 18px; font-weight: 650; line-height: 1.35; margin-bottom: 8px; }
.post-card-excerpt { color: var(--text-muted); font-size: 14px; margin-bottom: 14px; flex: 1; }
.read-link { color: var(--accent); font-weight: 600; font-size: 13px; }
.empty-state { padding: 60px 20px; text-align: center; color: var(--text-muted); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }

/* Right rail */
.right-rail { position: sticky; top: 92px; display: flex; flex-direction: column; gap: 20px; }
.ad-slot { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; text-align: center; }
.ad-slot .ad-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); margin-bottom: 10px; }
.ad-placeholder { height: 600px; border-radius: 12px; background: repeating-linear-gradient(45deg, var(--surface-2), var(--surface-2) 10px, var(--surface) 10px, var(--surface) 20px); display: grid; place-items: center; color: var(--text-muted); font-size: 13px; }
.ad-placeholder.small { height: 250px; }

/* Article */
.article-view { display: none; }
.article-view.active { display: block; animation: fadeIn .35s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.back-btn { display: inline-flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 14px; font-weight: 600; margin-bottom: 24px; padding: 8px 14px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); transition: color .2s, border-color .2s; }
.back-btn:hover { color: var(--accent); border-color: var(--accent); }
.article-title { font-size: 38px; font-weight: 780; line-height: 1.18; letter-spacing: -1px; margin-bottom: 16px; }
.article-img { width: 100%; height: 420px; object-fit: cover; border-radius: var(--radius); margin: 20px 0 30px; }

.article-body { max-width: 100%; overflow: hidden; }
.article-body p { font-size: 17px; color: #c9ced8; margin-bottom: 20px; }
.article-body h2 { font-size: 26px; font-weight: 750; margin: 36px 0 16px; letter-spacing: -0.5px; }
.article-body h3 { font-size: 20px; font-weight: 700; margin: 28px 0 12px; }
.article-body ul, .article-body ol { margin: 0 0 20px 24px; color: #c9ced8; }
.article-body li { margin-bottom: 8px; font-size: 16px; }
.article-body table { width: 100%; border-collapse: collapse; margin: 20px 0; font-size: 15px; }
.article-body th, .article-body td { border: 1px solid var(--border); padding: 10px 12px; text-align: left; }
.article-body th { background: var(--surface-2); font-weight: 700; }
.article-body code { background: var(--surface-2); padding: 2px 6px; border-radius: 4px; font-size: 14px; }
.article-body blockquote { border-left: 3px solid var(--accent); padding-left: 16px; color: var(--text-muted); margin: 20px 0; font-style: italic; }

/* Отдельная страница статьи (не-SPA) */
.article-page { padding: 40px 24px; max-width: 900px; }

/* Footer */
.site-footer { background: var(--surface); border-top: 1px solid var(--border); margin-top: 40px; }
.footer-main { max-width: var(--maxw); margin: 0 auto; padding: 56px 24px 40px; display: grid; grid-template-columns: 1.4fr 1fr 1fr 1.2fr; gap: 40px; }
.footer-brand p { color: var(--text-muted); font-size: 14px; margin: 16px 0 20px; max-width: 300px; }
.footer-col h4 { font-size: 14px; text-transform: uppercase; letter-spacing: 1px; color: var(--text); margin-bottom: 16px; }
.footer-col ul { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.footer-col ul a { color: var(--text-muted); font-size: 14px; transition: color .2s; }
.footer-col ul a:hover { color: var(--accent); }
.newsletter { display: flex; gap: 8px; margin-top: 16px; }
.newsletter input { flex: 1; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 11px 14px; color: var(--text); font-size: 14px; outline: none; }
.newsletter input:focus { border-color: var(--accent); }
.newsletter button { background: var(--accent); color: #fff; border: none; border-radius: 10px; padding: 0 18px; font-weight: 700; cursor: pointer; }
.footer-bottom { border-top: 1px solid var(--border); padding: 20px 24px; max-width: var(--maxw); margin: 0 auto; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; color: var(--text-muted); font-size: 13px; }
.footer-bottom a { color: var(--text-muted); }
.footer-bottom a:hover { color: var(--accent); }

/* --- БАННЕРЫ (вставляются через Shadow DOM, см. js/banners.js) --- */

/* Контейнеры для баннеров — размеры задаются из JS по data-bnr */
[data-bnr] {
  display: block;
  border: none;
  overflow: hidden;
  border-radius: var(--radius);
  background: transparent;
}

/* Шапка: два баннера в ряд */
.header-banners {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  padding-bottom: 16px;
  flex-wrap: nowrap;
}
.header-banners [data-bnr] {
  flex: 1 1 0;
  max-width: 468px;
  border-radius: 8px;
}

/* Левая колонка */
.banner-slot {
  width: 100%;
  max-width: 200px;
  border-radius: var(--radius);
}
.banner-slot + .banner-slot { margin-top: 20px; }

/* Внутри статьи */
.article-banner {
  margin: 40px auto;
  text-align: center;
}
.article-banner [data-bnr] {
  margin: 0 auto;
  border-radius: 8px;
}

/* Адаптив */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr 300px; }
  .left-rail { display: none; }
  .hero-inner { grid-template-columns: 1fr; }
  .hero h1 { font-size: 38px; }
  .footer-main { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 820px) {
  .main-nav, .search-box { display: none; }
  .mobile-menu-btn { display: block; }
  .layout { grid-template-columns: 1fr; padding: 16px; }
  .right-rail { display: none; }
  .feed { grid-template-columns: 1fr; }
  .article-title { font-size: 28px; }
  .article-img { height: 240px; }
  .footer-main { grid-template-columns: 1fr; gap: 32px; }
  .header-banners { display: none; }
  .article-banner { display: none; }
}