/* НЕЙРОХАБ — дизайн-система из README.md (design-reference). Не менять цвета/
   отступы/шрифт произвольно — это утверждённый заказчиком референс. */

:root {
  --blue: #2C5BFF;
  --blue-light: #EAF0FF;
  --text: #14171F;
  --text-secondary: #5B6472;
  --text-muted: #9AA3B2;
  --bg-page: #F5F7FB;
  --bg-card: #FFFFFF;
  --border: #E3E8F0;
  --danger: #E5484D;
  --danger-light: #FDECEC;
  --success: #1D9E75;
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-xl: 20px;
}

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

body {
  font-family: 'Manrope', sans-serif;
  background: var(--bg-page);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ── Фоновая анимация сайта (Фаза 14, Шаг 4) — тот же приём, что и медленно
   вращающиеся орбитальные кольца в hero-блоке лендинга (nh-hero-rotate),
   но сдержаннее: два размытых цветных пятна плавно дрейфуют, не крутятся.
   Чистый CSS, без видео/картинок — не влияет на вес страницы. Фиксированное
   позиционирование, один <div> на все страницы через base.html. ─────────── */

.nh-bg-fx {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
.nh-bg-fx::before,
.nh-bg-fx::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.28;
  will-change: transform;
}
.nh-bg-fx::before {
  width: 560px;
  height: 560px;
  left: -8%;
  top: -12%;
  background: radial-gradient(circle, rgba(124, 111, 255, 0.55), transparent 70%);
  animation: nh-bg-drift-1 42s ease-in-out infinite;
}
.nh-bg-fx::after {
  width: 620px;
  height: 620px;
  right: -12%;
  bottom: -14%;
  background: radial-gradient(circle, rgba(79, 195, 232, 0.5), transparent 70%);
  animation: nh-bg-drift-2 50s ease-in-out infinite;
}
@keyframes nh-bg-drift-1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(50px, 35px) scale(1.08); }
}
@keyframes nh-bg-drift-2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-40px, -30px) scale(1.05); }
}
@media (prefers-reduced-motion: reduce) {
  .nh-bg-fx::before,
  .nh-bg-fx::after {
    animation: none;
  }
}

/* ── Шапка ─────────────────────────────────────────────────────────── */

.nh-header {
  background: var(--bg-card);
  border-bottom: 0.5px solid var(--border);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}
.nh-logo { display: flex; align-items: center; gap: 9px; }
/* Фаза 16, Этап 1: логотип чуть крупнее (было 20px/13px), по образцу models_v3.html */
.nh-logo-mark { width: 26px; height: 26px; border-radius: 8px; background: linear-gradient(145deg, var(--blue), #7C6FFF); }
.nh-logo-text { font-weight: 800; font-size: 15px; color: var(--text); }
.nh-header-right { display: flex; align-items: center; gap: 14px; }
.nh-nav-cta {
  background: var(--blue); color: #fff; font-size: 13px; font-weight: 700;
  padding: 9px 16px; border-radius: var(--radius-sm); text-decoration: none;
}
.nh-balance {
  display: flex; align-items: center; gap: 6px;
  background: var(--blue-light); border-radius: var(--radius-sm);
  padding: 6px 12px; font-size: 12px; font-weight: 600; color: var(--text);
}
.nh-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--blue); color: #fff; font-size: 11px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.nh-nav-link { font-size: 13px; color: var(--text-secondary); font-weight: 600; }
.nh-logout-btn { background: none; border: none; padding: 0; font-family: 'Manrope', sans-serif; cursor: pointer; }
.nh-menu-toggle { display: none; background: none; border: none; padding: 4px; font-size: 20px; line-height: 1; color: var(--text); cursor: pointer; }

/* ── Общие компоненты ──────────────────────────────────────────────── */

.nh-container { max-width: 960px; margin: 0 auto; padding: 18px 20px; }
.nh-container-wide { max-width: 1440px; margin: 0 auto; padding: 18px 20px; }

.nh-card {
  background: var(--bg-card); border: 0.5px solid var(--border);
  border-radius: var(--radius-md); padding: 16px;
}

.nh-section-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 10px; }

.nh-btn {
  display: inline-block; text-align: center; cursor: pointer;
  background: var(--blue); color: #fff; font-size: 12px; font-weight: 600;
  padding: 10px 0; border-radius: var(--radius-sm); border: none;
  font-family: 'Manrope', sans-serif; width: 100%;
}
.nh-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.nh-btn-secondary {
  background: var(--bg-page); color: var(--text); font-size: 12px; font-weight: 600;
  padding: 9px 0; border-radius: var(--radius-sm); border: 0.5px solid var(--border);
  text-align: center; cursor: pointer; font-family: 'Manrope', sans-serif; width: 100%;
}

.nh-input {
  width: 100%; height: 38px; border-radius: var(--radius-sm);
  border: 0.5px solid var(--border); background: var(--bg-card);
  padding: 0 12px; font-size: 13px; font-family: 'Manrope', sans-serif; color: var(--text);
}
.nh-input::placeholder { color: var(--text-muted); }
.nh-label { font-size: 11px; color: var(--text-secondary); margin-bottom: 6px; display: block; }

.nh-chip {
  padding: 7px 12px; border-radius: var(--radius-sm); font-size: 11px; cursor: pointer;
  background: var(--bg-card); border: 0.5px solid var(--border); color: var(--text-secondary);
}
.nh-chip.active { background: var(--blue-light); border-color: var(--blue); color: var(--text); font-weight: 600; }

.nh-toast {
  margin-top: 10px; border-radius: var(--radius-sm); padding: 9px 12px; font-size: 11px;
}
.nh-toast.info { background: var(--blue-light); color: var(--text); }
.nh-toast.error { background: var(--danger-light); color: var(--danger); }

/* Фаза 16, Этап 4, п.3: всплывающее уведомление о нехватке токенов — только
   ПОСЛЕ клика на "Запустить модель", не постоянная надпись на карточке. */
.nh-floating-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(0);
  background: var(--text); color: #fff; padding: 12px 16px; border-radius: var(--radius-md);
  font-size: 12.5px; display: flex; align-items: center; gap: 12px; z-index: 50;
  box-shadow: 0 14px 30px rgba(20, 23, 31, .28); opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease; max-width: calc(100vw - 32px);
}
.nh-floating-toast.nh-open { opacity: 1; transform: translateX(-50%) translateY(-6px); pointer-events: auto; }
.nh-floating-toast a { color: #8FB3FF; font-weight: 700; white-space: nowrap; }

.nh-error-banner {
  background: var(--danger-light); color: var(--danger); border-radius: var(--radius-sm);
  padding: 10px 14px; font-size: 12px; margin-bottom: 12px;
}

.nh-skeleton {
  background: linear-gradient(90deg, var(--border) 25%, #f0f2f6 37%, var(--border) 63%);
  background-size: 400% 100%; animation: nh-skeleton-loading 1.4s ease infinite;
  border-radius: var(--radius-sm);
}
@keyframes nh-skeleton-loading { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.nh-footer {
  text-align: center; font-size: 11px; color: var(--text-muted);
  padding: 24px 20px; border-top: 0.5px solid var(--border); margin-top: 24px;
}
.nh-footer a { color: var(--blue); font-weight: 600; }

/* ── Тарифы: центрированная сетка + раскрывающийся список моделей по
   категориям (Фаза 14, Шаг 2, design-reference/pricing_v3.html) ──────── */

.nh-grid-3 {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px;
  max-width: 1000px; margin: 0 auto;
}
.nh-pricing-toggle {
  text-align: center; font-size: 12px; color: var(--blue); font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 0 2px;
  border-top: 0.5px solid var(--border); margin-top: 8px;
}
.nh-pricing-toggle i { transition: transform .2s ease; font-size: 13px; }
.nh-pricing-toggle.nh-open i { transform: rotate(180deg); }
.nh-pricing-model-list { max-height: 0; overflow: hidden; transition: max-height .3s ease; }
.nh-pricing-model-list.nh-open { max-height: 1000px; }
.nh-pricing-cat { margin-top: 12px; }
.nh-pricing-cat-head {
  display: flex; align-items: center; gap: 6px; font-size: 10.5px; font-weight: 800;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px;
}
.nh-pricing-cat-head i { font-size: 13px; color: var(--blue); }
.nh-pricing-model-row {
  display: flex; align-items: center; gap: 10px; padding: 5px 0 5px 2px; font-size: 12px;
}
.nh-pricing-model-row .nh-pricing-mname { font-weight: 600; flex: 1; color: var(--text); }
.nh-pricing-model-row .nh-pricing-mprov { color: var(--text-muted); font-size: 10.5px; }

/* ── Прайс-лист /prices (Фаза 15, Этап 5) — таблица "модель -> токены -> ₽" ── */
.nh-pricing-model-row .nh-pricing-mtokens { color: var(--text-secondary); font-size: 11.5px; white-space: nowrap; }
.nh-pricing-model-row .nh-pricing-mrub { font-weight: 700; white-space: nowrap; min-width: 72px; text-align: right; }

/* ── Каталог моделей: заголовок/поиск/сценарии (Фаза 16, Этап 2, models_v3.html) ── */

.nh-catalog-title { font-size: 30px; font-weight: 800; letter-spacing: -.02em; margin: 4px 0 8px; color: var(--text); }
.nh-catalog-sub { font-size: 13.5px; color: var(--text-secondary); margin: 0 0 22px; max-width: 640px; }

.nh-search { position: relative; max-width: 620px; margin-bottom: 22px; }
.nh-search input {
  width: 100%; height: 48px; border-radius: var(--radius-md); border: 0.5px solid var(--border);
  background: var(--bg-card); padding: 0 16px 0 42px; font-size: 13.5px;
  font-family: 'Manrope', sans-serif; color: var(--text);
}
.nh-search input::placeholder { color: var(--text-muted); }
.nh-search i { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 16px; }

.nh-scenarios { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 24px; }
.nh-scenario {
  background: var(--bg-card); border: 0.5px solid var(--border); border-radius: var(--radius-md);
  padding: 14px; text-align: center; cursor: pointer; transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.nh-scenario:hover { border-color: var(--blue); transform: translateY(-2px); box-shadow: 0 10px 20px rgba(20, 23, 31, .06); }
.nh-scenario i { font-size: 20px; color: var(--blue); margin-bottom: 6px; display: block; }
.nh-scenario span { font-size: 12px; font-weight: 700; color: var(--text); }

@media (max-width: 720px) { .nh-scenarios { grid-template-columns: repeat(2, 1fr); } }

/* ── Модели: визуальные плитки (Фаза 14, Шаг 3, design-reference/models_v2.html) ── */

/* Фаза 16, Этап 3: панель фильтров — активный фильтр сплошным синим (не
   рамкой, как раньше), справа счётчик + сортировка. models_v3.html. */
.nh-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.nh-model-filters { display: flex; gap: 8px; flex-wrap: wrap; }
.nh-model-filters .nh-chip {
  padding: 9px 16px; border-radius: 11px; font-size: 12.5px; font-weight: 700;
  display: flex; align-items: center; gap: 6px; transition: .15s;
}
.nh-model-filters .nh-chip.active {
  background: var(--blue); color: #fff; border-color: var(--blue);
  box-shadow: 0 8px 16px rgba(44, 91, 255, .24); font-weight: 700;
}
.nh-right-tools { display: flex; align-items: center; gap: 14px; font-size: 13px; color: var(--text-secondary); white-space: nowrap; }
.nh-count { font-weight: 700; color: var(--text); }
.nh-sort {
  border: 0.5px solid var(--border); border-radius: var(--radius-sm); padding: 8px 12px;
  font-family: 'Manrope', sans-serif; font-size: 12.5px; color: var(--text); background: var(--bg-card);
}
.nh-model-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.nh-model-card { padding: 0; overflow: hidden; cursor: default; transition: transform .15s ease, box-shadow .15s ease; display: flex; flex-direction: column; }
.nh-model-card:hover { transform: translateY(-2px); box-shadow: 0 14px 28px rgba(20, 23, 31, .08); }
/* Фаза 16, Этап 4, п.1: превью уменьшено — было aspect-ratio 4/3 (~65-70%
   высоты карточки), теперь 1.5/1 (~55-58%), по models_v3.html. Больше нет
   .nh-model-locked (полупрозрачность по нехватке токенов) — карточка
   выглядит одинаково независимо от баланса, см. п.3. */
.nh-model-thumb {
  aspect-ratio: 1.5 / 1; position: relative; display: flex; align-items: center; justify-content: center;
}
.nh-model-tag {
  position: absolute; top: 8px; left: 8px; background: rgba(0, 0, 0, .35); color: #fff;
  font-size: 10px; font-weight: 600; padding: 3px 8px; border-radius: 7px; backdrop-filter: blur(4px);
}
.nh-model-badge {
  position: absolute; top: 8px; right: 8px; background: rgba(255, 255, 255, .92); color: var(--text);
  font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 7px;
}
.nh-model-body { padding: 12px 14px 14px; display: flex; flex-direction: column; flex: 1; }
.nh-model-name { font-size: 13.5px; font-weight: 700; margin-bottom: 3px; color: var(--text); }
.nh-model-desc { font-size: 11.5px; color: var(--text-secondary); line-height: 1.4; margin-bottom: 8px; min-height: 32px; }
.nh-model-tags { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 10px; }
.nh-model-tags .nh-model-mini-tag {
  font-size: 10px; font-weight: 700; color: var(--blue); background: var(--blue-light);
  padding: 3px 7px; border-radius: 6px;
}
.nh-model-foot { margin-top: auto; }
.nh-model-variants { font-size: 10.5px; color: var(--text-muted); margin-bottom: 6px; }
.nh-model-price-row { display: flex; align-items: baseline; gap: 6px; margin-bottom: 10px; font-size: 11px; }
.nh-model-price { font-weight: 700; color: var(--text); }
.nh-model-price-rub { color: var(--text-muted); }
.nh-model-actions { display: flex; gap: 8px; }
.nh-model-actions .nh-btn,
.nh-model-actions .nh-btn-secondary { width: auto; flex: 1; padding: 9px 0; font-size: 11.5px; }

@media (max-width: 1100px) { .nh-model-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 720px) { .nh-model-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .nh-model-grid { grid-template-columns: 1fr; } }

/* ── Мобильная адаптация (макеты design-reference — фиксированной десктопной
   ширины, здесь — разумное сужение под маленькие экраны, в той же
   дизайн-системе, без новых цветов/отступов) ─────────────────────────── */

@media (max-width: 720px) {
  .nh-header { padding: 12px 14px; }
  /* Бага из Фазы 17: у гостя в шапке 4 пункта (Каталог, Возможности, Войти,
     CTA) физически не помещаются в одну строку уже начиная примерно с 530px
     (не только 375-390px) — CTA "Начать создавать" обрезался/переносился.
     Этот блок для guest-шапки никогда не получал мобильной адаптации (в
     отличие от авторизованной, которая сворачивается в гамбургер выше).
     Решение: прячем второстепенные ссылки, оставляя «Войти» + CTA в одну
     строку — они гарантированно помещаются с запасом на 375/390px. */
  .nh-nav-secondary { display: none; }
  .nh-balance span { display: none; }
  .nh-header-right { gap: 8px; }
  .nh-nav-cta { padding: 9px 10px; }
  .nh-balance::after { content: attr(data-short); font-size: 11px; font-weight: 600; }
  .nh-container, .nh-container-wide { padding: 14px; }
  .nh-grid-2 { grid-template-columns: 1fr !important; }
  .nh-grid-4 { grid-template-columns: repeat(2, 1fr) !important; }
  .nh-grid-3 { grid-template-columns: 1fr !important; max-width: 420px; }
  .nh-hero { grid-template-columns: 1fr !important; padding: 32px 20px !important; }
  .nh-hero h1 { font-size: 32px !important; }
  .nh-hero .nh-hero-visual { height: 220px !important; }

  /* Авторизованная навигация (Фаза 8) на узких экранах не помещается в одну строку
     (3 пункта + баланс + аватар + «Выйти») — сворачивается в раскрывающееся меню
     по гамбургеру. Рендерится из ТОГО ЖЕ nav_items/_header.html, что и десктоп —
     просто скрыт/показан через CSS, а не отдельный шаблон (см. Шаг 4 задачи). */
  .nh-menu-toggle { display: block; }
  .nh-menu-toggle + .nh-header-right {
    display: none;
    position: absolute; top: 100%; right: 14px; left: 14px; margin-top: 8px;
    flex-direction: column; align-items: stretch; gap: 2px;
    background: var(--bg-card); border: 0.5px solid var(--border); border-radius: var(--radius-md);
    padding: 8px; box-shadow: 0 10px 30px rgba(20, 23, 31, 0.14); z-index: 20;
  }
  .nh-menu-toggle + .nh-header-right.nh-open { display: flex; }
  .nh-menu-toggle + .nh-header-right .nh-nav-link,
  .nh-menu-toggle + .nh-header-right .nh-logout-btn { width: 100%; text-align: left; padding: 10px 8px; }
  .nh-menu-toggle + .nh-header-right .nh-balance { order: -1; align-self: flex-start; margin: 0 0 4px; }
  .nh-menu-toggle + .nh-header-right .nh-balance span { display: inline; }
  .nh-menu-toggle + .nh-header-right .nh-balance::after { content: none; }
  .nh-menu-toggle + .nh-header-right .nh-avatar { display: none; }
}

/* Совсем узкие экраны (≤340px, старые iPhone SE/5) — даже «Войти» + CTA
   вдвоём чуть-чуть не помещаются в одну строку, дожимаем размер. */
@media (max-width: 340px) {
  .nh-header-right { gap: 6px; }
  .nh-nav-cta { padding: 8px 8px; font-size: 12px; }
  /* :not(#nh-header-right) — не задевает выпадающее меню авторизованной
     шапки (у него есть этот id), там свои размеры уже заданы выше. */
  .nh-header-right:not(#nh-header-right) > .nh-nav-link { font-size: 12px; }
}
