/* ============================================================
   Доктор GPT — design system
   mobile-first, CSS custom properties, BEM
   ============================================================ */

:root {
  --bg: #10131c;
  --bg-alt: #181c2a;
  --card: #1c2132;
  --card-hover: #242b45;
  --border: #2b3350;
  --text: #eef1f9;
  --text-dim: #a4aec7;
  --accent: #8b5cf6;
  --accent-strong: #6d28d9;
  --accent-soft: rgba(139, 92, 246, 0.18);
  --green: #22d3a5;
  --amber: #fbbf24;
  --pink: #f472b6;
  --sky: #38bdf8;
  --danger: #fb7185;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  --font: "Segoe UI", Roboto, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Code", Consolas, monospace;
  --maxw: 1200px;
  --header-h: 60px;
}

html[data-theme="light"] {
  --bg: #f5f7fd;
  --bg-alt: #ffffff;
  --card: #ffffff;
  --card-hover: #eef1fa;
  --border: #e0e5f1;
  --text: #1b2136;
  --text-dim: #5a647d;
  --accent: #7c3aed;
  --accent-strong: #6d28d9;
  --accent-soft: rgba(124, 58, 237, 0.12);
  --shadow: 0 8px 30px rgba(30, 41, 80, 0.12);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(139, 92, 246, 0.12), transparent 60%),
    radial-gradient(700px 450px at 0% 30%, rgba(56, 189, 248, 0.08), transparent 55%),
    radial-gradient(800px 500px at 100% 80%, rgba(244, 114, 182, 0.07), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

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

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }

/* ---------- Header ---------- */
.header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(15, 17, 23, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
html[data-theme="light"] .header { background: rgba(255, 255, 255, 0.92); }
.header.is-scrolled { box-shadow: var(--shadow); }
.header-inner {
  max-width: var(--maxw); margin: 0 auto;
  height: var(--header-h);
  display: flex; align-items: center; gap: 18px; padding: 0 16px;
}
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; color: var(--text); }
.logo svg { width: 30px; height: 30px; }
.logo:hover { color: var(--text); }
.logo .logo-accent { color: var(--accent); }

.nav-desktop { display: none; margin-left: auto; }
.nav-desktop ul { display: flex; gap: 4px; list-style: none; }
.nav-desktop a {
  display: block; padding: 8px 12px; border-radius: var(--radius-sm);
  color: var(--text-dim); font-size: 14px; font-weight: 600;
}
.nav-desktop a:hover { color: var(--text); background: var(--card); }
.nav-desktop a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }

.header-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.nav-desktop + .header-actions { margin-left: 0; }

.icon-btn {
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  transition: border-color 0.15s, background 0.15s;
}
.icon-btn:hover { border-color: var(--accent); background: var(--card-hover); }

/* Theme toggle icons */
.theme-toggle .icon-moon { display: none; }
.theme-toggle .icon-sun { display: block; }
html[data-theme="light"] .theme-toggle .icon-moon { display: block; }
html[data-theme="light"] .theme-toggle .icon-sun { display: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 700; cursor: pointer; border: 1px solid transparent;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); color: #fff; box-shadow: 0 4px 18px rgba(124, 92, 255, 0.4); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: 7px 13px; font-size: 13px; }

/* ---------- Mobile drawer ---------- */
.burger { display: inline-flex; }
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 80;
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.drawer-backdrop.is-open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; left: 0; bottom: 0; width: min(320px, 85vw);
  background: var(--bg-alt); z-index: 90; transform: translateX(-102%);
  transition: transform 0.25s; display: flex; flex-direction: column; padding: 18px;
  border-right: 1px solid var(--border);
}
.drawer.is-open { transform: translateX(0); }
.drawer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.drawer nav a {
  display: block; padding: 12px 10px; border-radius: var(--radius-sm);
  color: var(--text); font-weight: 600; border-bottom: 1px solid var(--border);
}
.drawer nav a:hover { background: var(--card); color: var(--accent); }

/* ---------- Hero ---------- */
.hero {
  padding: 48px 0 40px;
  background:
    radial-gradient(1000px 500px at 80% -10%, rgba(139, 92, 246, 0.32), transparent 62%),
    radial-gradient(700px 420px at 5% 0%, rgba(56, 189, 248, 0.22), transparent 58%),
    radial-gradient(600px 400px at 50% 120%, rgba(244, 114, 182, 0.14), transparent 60%),
    linear-gradient(180deg, #14182a, transparent);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}
html[data-theme="light"] .hero {
  background:
    radial-gradient(1000px 500px at 80% -10%, rgba(124, 58, 237, 0.18), transparent 62%),
    radial-gradient(700px 420px at 5% 0%, rgba(56, 189, 248, 0.14), transparent 58%),
    radial-gradient(600px 400px at 50% 120%, rgba(244, 114, 182, 0.10), transparent 60%),
    linear-gradient(180deg, #ffffff, transparent);
}
.hero .container { display: grid; gap: 28px; align-items: center; }
.hero-kicker {
  display: inline-block; color: var(--sky); font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; font-size: 13px;
  background: linear-gradient(90deg, var(--accent), var(--sky), var(--pink));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: var(--sky);
}
.hero h1 {
  font-size: clamp(28px, 5vw, 44px); line-height: 1.15; margin: 10px 0 14px;
  background: linear-gradient(120deg, #ffffff 30%, #c4b5fd 55%, #7dd3fc 80%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
html[data-theme="light"] .hero h1 {
  background: linear-gradient(120deg, #1b2136 30%, #7c3aed 60%, #0ea5e9 85%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.hero p { color: var(--text-dim); font-size: 17px; max-width: 60ch; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 22px; }
.hero-cover { border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }

.hero-bot {
  position: relative; width: min(230px, 62vw); aspect-ratio: 1; margin: 0 auto;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  animation: bot-bob 3.6s ease-in-out infinite;
}
.hero-bot::before {
  content: ''; position: absolute; inset: -10px; border-radius: 50%;
  background: conic-gradient(from 0deg, #8b5cf6, #38bdf8, #f472b6, #22d3a5, #fbbf24, #8b5cf6);
  filter: blur(8px); opacity: 0.85; z-index: 0;
  animation: bot-spin 7s linear infinite;
}
.hero-bot::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  background: var(--bg); z-index: 1;
}
html[data-theme="light"] .hero-bot::after { background: #f5f7fd; }
.hero-bot img {
  position: relative; z-index: 2; width: 92%; height: 92%; object-fit: cover;
  border-radius: 50%; border: 3px solid var(--card-hover);
  box-shadow: 0 0 40px rgba(139, 92, 246, 0.5), 0 0 80px rgba(56, 189, 248, 0.25);
}
@keyframes bot-spin { to { transform: rotate(360deg); } }
@keyframes bot-bob {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-10px) rotate(2deg); }
}
@media (prefers-reduced-motion: reduce) {
  .hero-bot, .hero-bot::before { animation: none; }
}

/* ---------- Sections ---------- */
.section { padding: 40px 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.section-title { font-size: clamp(20px, 3vw, 26px); font-weight: 800; }
.section-more { font-size: 14px; font-weight: 600; }

/* ---------- Stats ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.stat-card {
  background: linear-gradient(160deg, var(--card-hover), var(--card));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.stat-card:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: 0 6px 24px rgba(139, 92, 246, 0.2); }
.stat-card .stat-label { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; }
.stat-card .stat-value { font-size: 24px; font-weight: 800; margin-top: 6px; }
.stat-card .stat-note { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.stat-value--accent { color: var(--accent); }
.stat-value--sky { color: var(--sky); }
.stat-value--green { color: var(--green); }
.stat-value--pink { color: var(--pink); }

/* ---------- Cards grid ---------- */
.cards-grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; display: flex; flex-direction: column; gap: 10px;
  transition: transform 0.15s, border-color 0.15s, background 0.15s;
}
.card:hover { transform: translateY(-2px); border-color: var(--accent); background: var(--card-hover); }
.card-title { font-size: 16px; font-weight: 700; line-height: 1.35; }
.card-title a { color: var(--text); }
.card-title a:hover { color: var(--accent); }
.card-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 12.5px; color: var(--text-dim); }
.card-snippet { font-size: 14px; color: var(--text-dim); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-footer { margin-top: auto; display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--text-dim); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700;
}
.badge-verified { background: rgba(52, 211, 153, 0.15); color: var(--green); }
.badge-inspiration { background: rgba(251, 191, 36, 0.15); color: var(--amber); }
.badge-trend { background: var(--accent-soft); color: var(--accent); }
.badge-pick { background: rgba(244, 114, 182, 0.15); color: var(--pink); }
.badge-cat { background: var(--card-hover); color: var(--text-dim); }

/* ---------- Chips ---------- */
.chip {
  display: inline-flex; align-items: center; padding: 4px 11px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--border); color: var(--text-dim);
  font-size: 12.5px; transition: all 0.15s;
}
a.chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 30px; }
.pagination a, .pagination span {
  min-width: 40px; height: 40px; padding: 0 12px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--card); color: var(--text-dim); font-weight: 600;
}
.pagination a:hover { border-color: var(--accent); color: var(--accent); }
.pagination .current { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------- Breadcrumbs ---------- */
.breadcrumbs { font-size: 13px; color: var(--text-dim); padding: 16px 0 0; }
.breadcrumbs ol { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; }
.breadcrumbs li + li::before { content: "›"; margin-right: 6px; color: var(--text-dim); }
.breadcrumbs a { color: var(--text-dim); }
.breadcrumbs a:hover { color: var(--accent); }

/* ---------- Article / detail ---------- */
.page-head { padding: 30px 0 8px; }
.page-head h1 { font-size: clamp(24px, 4vw, 34px); line-height: 1.2; }
.page-head .page-meta { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 14px; color: var(--text-dim); font-size: 14px; }
.article-body { max-width: 720px; }
.article-body p { margin-bottom: 16px; }
.article-body a { text-decoration: underline; text-underline-offset: 3px; }
.article-body h2 { font-size: 22px; margin: 28px 0 12px; }
.article-body pre, .article-body code {
  font-family: var(--mono); background: var(--bg-alt); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px;
}
.article-body code { padding: 2px 6px; }
.article-body pre { padding: 14px; overflow-x: auto; margin-bottom: 16px; }
.article-body pre code { border: none; padding: 0; background: none; }

/* ---------- Copy prompt ---------- */
.prompt-box {
  background: var(--bg-alt); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin: 16px 0; position: relative; white-space: pre-wrap; font-size: 14px;
}
.copy-btn { position: absolute; top: 10px; right: 10px; }

/* ---------- FAQ ---------- */
.faq-item { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 10px; overflow: hidden; background: var(--card); }
.faq-item summary {
  padding: 14px 16px; cursor: pointer; font-weight: 600; font-size: 15px; list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; font-size: 20px; color: var(--accent); transition: transform 0.2s; }
.faq-item[open] summary::after { transform: rotate(45deg); }
.faq-item .faq-a { padding: 0 16px 14px; color: var(--text-dim); font-size: 14.5px; }

/* ---------- Forms ---------- */
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; font-weight: 600; }
.form-row input[type="email"], .form-row input[type="text"], .form-row input[type="search"] {
  width: 100%; padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-alt); color: var(--text); font-size: 15px;
}
.form-row input:focus { outline: none; border-color: var(--accent); }
.hp-field { position: absolute; left: -9999px; opacity: 0; }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--border); margin-top: 50px; background: var(--bg-alt); }
.footer-grid { display: grid; gap: 30px; padding: 44px 16px 30px; max-width: var(--maxw); margin: 0 auto; grid-template-columns: 1fr; }
.footer h4 { font-size: 14px; margin-bottom: 12px; color: var(--text); }
.footer ul { list-style: none; display: grid; gap: 8px; }
.footer a { color: var(--text-dim); font-size: 14px; }
.footer a:hover { color: var(--accent); }
.footer-metrics { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.footer-metrics h4 { margin-bottom: 8px; }
.footer-metrics .m { font-size: 13px; color: var(--text-dim); }
.footer-bottom { border-top: 1px solid var(--border); padding: 16px; text-align: center; color: var(--text-dim); font-size: 13px; }

/* ---------- Search overlay ---------- */
.search-overlay {
  position: fixed; inset: 0; background: rgba(15,17,23,0.97); z-index: 100;
  display: none; padding: 12vh 16px 20px; overflow-y: auto;
}
html[data-theme="light"] .search-overlay { background: rgba(245, 247, 253, 0.97); }
.search-overlay.is-open { display: block; }
.search-box { max-width: 680px; margin: 0 auto; }
.search-box input {
  width: 100%; padding: 16px 18px; font-size: 18px; border-radius: var(--radius);
  border: 1px solid var(--accent); background: var(--bg-alt); color: var(--text);
}
.search-results { max-width: 680px; margin: 16px auto 0; display: grid; gap: 10px; }
.search-result {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px; display: flex; gap: 12px; justify-content: space-between; align-items: center;
}
.search-result:hover { border-color: var(--accent); }
.search-result .t { font-weight: 600; }
.search-result .d { font-size: 12px; color: var(--text-dim); }
.search-empty { text-align: center; color: var(--text-dim); padding: 30px; }

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,0.9); z-index: 100;
  display: none; align-items: center; justify-content: center; padding: 24px;
}
.lightbox.is-open { display: flex; }
.lightbox-body-inner { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.lightbox img, .lightbox video { max-width: 100%; max-height: 82vh; width: auto; height: auto; border-radius: var(--radius); image-rendering: auto; }
.lightbox-tg {
  display: inline-flex; align-items: center; gap: 6px; color: #fff; font-size: 13px;
  background: rgba(255,255,255,0.12); padding: 7px 14px; border-radius: 999px; text-decoration: none;
  transition: background 0.2s;
}
.lightbox-tg:hover { background: rgba(255,255,255,0.22); }
.lightbox-close {
  position: absolute; top: 20px; right: 20px; width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--card); color: var(--text); font-size: 20px; cursor: pointer;
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 110;
  display: none; align-items: center; justify-content: center; padding: 16px;
}
.modal-backdrop.is-open { display: flex; }
.modal {
  background: var(--bg-alt); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px; max-width: 440px; width: 100%; box-shadow: var(--shadow); position: relative;
}
.modal h3 { font-size: 20px; margin-bottom: 8px; }
.modal p { color: var(--text-dim); font-size: 14px; margin-bottom: 16px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--card); border: 1px solid var(--accent); color: var(--text);
  padding: 12px 20px; border-radius: var(--radius-sm); box-shadow: var(--shadow);
  z-index: 130; opacity: 0; transition: all 0.3s; font-weight: 600; font-size: 14px;
}
.toast.is-show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- BackToTop ---------- */
.back-to-top {
  position: fixed; right: 20px; bottom: 24px; width: 44px; height: 44px; border-radius: 50%;
  background: var(--accent); color: #fff; border: none; cursor: pointer; font-size: 18px;
  opacity: 0; pointer-events: none; transition: opacity 0.3s; z-index: 60;
}
.back-to-top.is-visible { opacity: 1; pointer-events: auto; }

/* ---------- Filter bar ---------- */
.filter-bar {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 20px; display: grid; gap: 12px;
}
.filter-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filter-row .count { font-size: 13px; color: var(--text-dim); margin-left: auto; }
.filter-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.filter-chips .chip { cursor: pointer; user-select: none; }
.filter-chips .chip.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- Meme grid ---------- */
.meme-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, 1fr); }
.meme-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; cursor: zoom-in; height: 200px; display: flex; align-items: center; justify-content: center;
}
.meme-card img, .meme-card video { width: 100%; height: 100%; object-fit: contain; }
.meme-card .no-media { padding: 20px; text-align: center; color: var(--text-dim); font-size: 14px; }
.meme-card[href] { color: inherit; text-decoration: none; cursor: zoom-in; position: relative; }
.meme-badge {
  position: absolute; left: 10px; bottom: 10px; z-index: 2;
  background: rgba(0, 0, 0, 0.62); color: #fff; font-size: 12px;
  padding: 3px 9px; border-radius: 999px; backdrop-filter: blur(4px);
}

/* ---------- 404 ---------- */
.not-found { text-align: center; padding: 90px 16px; }
.not-found h1 { font-size: 80px; color: var(--accent); }
.not-found p { color: var(--text-dim); margin: 14px 0 26px; }

/* ---------- Digest list ---------- */
.digest-item {
  display: flex; gap: 16px; align-items: baseline; padding: 16px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--card);
}
.digest-item .date { font-size: 13px; color: var(--text-dim); min-width: 90px; }

/* ---------- Responsive ---------- */
@media (min-width: 768px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
  .cards-grid { grid-template-columns: repeat(2, 1fr); }
  .footer-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
  .nav-desktop { display: block; }
  .burger { display: none; }
  .hero .container { grid-template-columns: 1.2fr 0.8fr; }
  .hero .stats-grid { grid-column: 1 / -1; }
  .cards-grid { grid-template-columns: repeat(3, 1fr); }
  .footer-grid { grid-template-columns: 1.5fr 1fr 1fr 1fr 1.2fr; }
}

@media (min-width: 1280px) {
  .meme-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

@media (max-width: 640px) {
  .meme-grid { grid-template-columns: 1fr; }
}
