/* ============================================================
   НХ — Дизайн-система «Дорогая академия» (бенчмарк GeoSapien AI × Nature)
   Слои: base.css — токены, reset, каркас, шапка/подвал, кнопки, формы;
   components.css — компоненты страниц.
   Палитра: чернильный сине-чёрный #0a1120 · слоновая кость #fcfbf7 ·
   приглушённое золото #c5a059 (тиснение обложек) · бирюзовый #0284c7 (tech).
   ============================================================ */

:root {
  /* Чернила и текст */
  --ink:        #0f172a;
  --ink-2:      #45526b;
  --ink-3:      #76809a;
  /* Поверхности */
  --bg:         #fcfbf7;            /* слоновая кость */
  --surface:    #ffffff;
  --surface-2:  #f6f3ea;            /* тёплая подложка */
  --line:       #e8e2d2;            /* тёплый hairline */
  --line-soft:  #f0ebde;
  /* Глубокие панели (шапка, hero) */
  --ink-deep:   #0a1120;
  --ink-panel:  #101c38;
  /* Металлы */
  --gold:       #c5a059;
  --gold-2:     #d4af37;
  --gold-deep:  #9a7b3a;
  --gold-soft:  #f6eedb;
  --gold-line:  rgba(197, 160, 89, .45);
  /* Технологичный акцент */
  --cyan:       #0284c7;
  --cyan-2:     #0ea5e9;
  --cyan-soft:  #e5f4fc;
  /* Статусы (всегда с иконкой и текстом) */
  --ok:         #1c7a4d;  --ok-soft:  #e9f5ee;
  --warn:       #8a6d1a;  --warn-soft:#faf3d9;
  --err:        #b3261e;  --err-soft: #fbecea;
  /* BBox-подсветка */
  --hl:         #f6c700;
  --hl-glow:    rgba(246, 199, 0, .45);
  /* Типографика: сериф для display, гротеск для UI, моно для метаданных.
     Внешних CDN нет — стеки деградируют на локальные шрифты. */
  --font-display: "Playfair Display", "Literaturnaya", "PT Serif", Georgia, "Times New Roman", serif;
  --font-ui:      "Inter", "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, "PT Sans", Arial, sans-serif;
  --font-mono:    "IBM Plex Mono", "Cascadia Mono", Consolas, "JetBrains Mono", monospace;
  --font-read:    "PT Serif", Georgia, "Literaturnaya", "Times New Roman", serif;
  /* Ритм */
  --r: 12px;
  --rad: 14px;
  --rad-s: 9px;
  --shadow:     0 1px 2px rgba(15, 23, 42, .05), 0 14px 34px rgba(15, 23, 42, .08);
  --shadow-lg:  0 6px 18px rgba(15, 23, 42, .12), 0 28px 60px rgba(15, 23, 42, .18);
  --gold-foil:  linear-gradient(135deg, #dfc07a 0%, #c5a059 28%, #f2ddaa 52%, #c5a059 76%, #a8863f 100%);
  --wrap: 1240px;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
/* Фактура бумаги поверх слоновой кости */
body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.6'/%3E%3C/svg%3E");
}
body > * { position: relative; z-index: 1; }

img, svg, video { max-width: 100%; height: auto; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--gold-2); outline-offset: 2px; border-radius: 4px; }

h1, h2, h3, h4 { line-height: 1.18; margin: 0 0 .5em; font-weight: 700; }
h1, h2, .display { font-family: var(--font-display); letter-spacing: -.012em; }
h1 { font-size: clamp(1.85rem, 3.6vw, 2.9rem); }
h2 { font-size: clamp(1.4rem, 2.5vw, 1.9rem); }
h3 { font-size: 1.12rem; }
p  { margin: 0 0 1em; }
ul, ol { margin: 0 0 1em; padding-left: 1.3em; }
small { color: var(--ink-3); }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--r) 0; }
code, .mono { font-family: var(--font-mono); font-size: .92em; }

/* ---------- Каркас ---------- */
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 22px; }
main { padding: 30px 0 64px; }
.section { margin: 48px 0; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px; margin-bottom: 20px; }
.section-head h2 { margin: 0; position: relative; padding-bottom: 10px; }
.section-head h2::after {
  content: ""; position: absolute; left: 1px; bottom: 0; width: 56px; height: 3px;
  background: var(--gold-foil); border-radius: 2px;
}
.section-head .hint { color: var(--ink-3); font-size: .92rem; }

.grid { display: grid; gap: var(--r); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ---------- Шапка: чернильная, одна строка 60–68px ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: linear-gradient(180deg, var(--ink-deep) 0%, #0b1528 100%);
  color: #f2ecdd;
  border-bottom: 1px solid rgba(197, 160, 89, .28);
}
.site-header .wrap {
  display: flex; align-items: center; gap: 18px;
  min-height: 62px; flex-wrap: wrap; padding-top: 3px; padding-bottom: 3px;
}
.brand { display: flex; align-items: center; gap: 12px; color: #f5efdf; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { flex: 0 0 auto; filter: drop-shadow(0 2px 6px rgba(212, 175, 55, .35)); }
.brand-name { font-weight: 800; font-size: .98rem; letter-spacing: .05em; line-height: 1.15; }
.brand-sub { font-size: .64rem; color: #b9a77c; letter-spacing: .08em; text-transform: uppercase; }

/* Меню — сразу за логотипом, в одну строку */
.main-nav { display: flex; gap: 2px; flex-wrap: wrap; }
.main-nav a {
  color: #ded5bd; padding: 8px 11px; border-radius: 9px;
  font-size: .9rem; white-space: nowrap; letter-spacing: .01em;
  display: inline-flex; align-items: center; gap: 7px;
  transition: color .15s, background .15s;
}
.main-nav a:hover { background: rgba(212, 175, 55, .12); color: #fff; text-decoration: none; }
.main-nav a[aria-current="page"] { background: rgba(212, 175, 55, .16); color: #fff; }
.nav-badge {
  font: 700 .62rem/1 var(--font-ui); letter-spacing: .06em; text-transform: uppercase;
  color: #0a1120; background: var(--gold-foil);
  padding: 3px 7px; border-radius: 999px; white-space: nowrap;
}

/* Переключатель языка — правый угол */
.header-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.lang-switch {
  display: inline-flex; align-items: center; gap: 2px;
  background: rgba(255, 255, 255, .06); border: 1px solid rgba(197, 160, 89, .3);
  border-radius: 999px; padding: 3px;
}
.lang-switch button {
  border: 0; background: none; cursor: pointer; color: #b9c3d8;
  font: 700 .74rem/1 var(--font-ui); letter-spacing: .06em;
  padding: 5px 10px; border-radius: 999px;
}
.lang-switch button.on { background: var(--gold-foil); color: #221a08; }
.lang-switch button:disabled { opacity: .45; cursor: default; }
.lang-switch .sep { width: 1px; height: 12px; background: rgba(197, 160, 89, .35); }

/* Кнопка «Кабинет исследователя» (Open WebUI) в шапке */
.btn-owui {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  padding: 7px 13px; border-radius: 999px;
  background: rgba(212, 175, 55, .14); color: #f2e4bd;
  border: 1px solid rgba(212, 175, 55, .5);
  font: 650 .82rem/1.2 var(--font-ui);
  transition: background .15s, box-shadow .15s;
}
.btn-owui:hover { background: rgba(212, 175, 55, .24); box-shadow: 0 0 16px rgba(212, 175, 55, .25); text-decoration: none; }

/* Монолитность: на главной контент начинается сразу за шапкой, без светлого зазора */
main.main-flush { padding-top: 0; }

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border-radius: 10px;
  border: 1px solid transparent; cursor: pointer;
  font-weight: 650; font-size: .95rem; line-height: 1.2; letter-spacing: .01em;
  transition: box-shadow .18s, filter .15s, transform .05s, background .15s;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
/* Чернильная primary — с золотой каймой */
.btn-primary {
  background: linear-gradient(160deg, #16244a 0%, var(--ink-deep) 100%);
  color: #f3e9d2; border-color: rgba(197, 160, 89, .55);
}
.btn-primary:hover { box-shadow: 0 6px 22px rgba(10, 17, 32, .35), 0 0 0 1px rgba(212, 175, 55, .35); }
/* Золотая фольга — главный CTA */
.btn-accent {
  background: var(--gold-foil); color: #221a08;
  border-color: rgba(154, 123, 58, .6);
  box-shadow: 0 2px 10px rgba(197, 160, 89, .35), inset 0 1px 0 rgba(255, 255, 255, .5);
}
.btn-accent:hover { filter: brightness(1.05); box-shadow: 0 6px 24px rgba(197, 160, 89, .45), inset 0 1px 0 rgba(255,255,255,.55); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--gold); }
.btn-sm { padding: 7px 13px; font-size: .85rem; }
.btn-lg { padding: 13px 28px; font-size: 1.02rem; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-icon {
  width: 44px; height: 44px; padding: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .07); border: 1px solid rgba(212, 175, 55, .35);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; color: #e9dfc4; backdrop-filter: blur(6px);
  transition: border-color .15s, box-shadow .15s;
}
.btn-icon:hover { border-color: var(--gold-2); box-shadow: 0 0 18px rgba(212, 175, 55, .3); }

/* ---------- Чипы, бейджи ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: 999px;
  background: var(--surface); color: var(--ink-2);
  font-size: .8rem; font-weight: 600; border: 1px solid var(--line);
  white-space: nowrap;
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip-brand { background: var(--gold-soft); color: var(--gold-deep); border-color: rgba(197, 160, 89, .5); }
.chip-ok    { background: var(--ok-soft); color: var(--ok); border-color: #bcdccb; }
.chip-warn  { background: var(--warn-soft); color: var(--warn); border-color: #e6d9a4; }
.chip-err   { background: var(--err-soft); color: var(--err); border-color: #ecc7c3; }
.chip-cyan  { background: var(--cyan-soft); color: var(--cyan); border-color: #bcdff5; }
.chip-demo  { background: var(--surface-2); color: var(--ink-3); border-color: var(--line); border-style: dashed; }
.chip-click { cursor: pointer; user-select: none; }
.chip-click:hover { filter: brightness(.97); }

.deg { font-size: .72rem; font-weight: 700; color: var(--gold-deep); background: var(--gold-soft); border-radius: 5px; padding: 1px 6px; }

/* ---------- Статус ИИ-контура ---------- */
.hbo-status { display: inline-flex; align-items: center; gap: 7px; font-size: .8rem; font-weight: 600; color: #cbbd97; }
.hbo-status .dot { width: 8px; height: 8px; border-radius: 50%; background: #e5b93c; box-shadow: 0 0 0 3px rgba(229, 185, 60, .22); }
.hbo-status.is-live .dot { background: #4ade80; box-shadow: 0 0 0 3px rgba(74, 222, 128, .22); }

/* ---------- Формы ---------- */
.input, .select, .textarea {
  width: 100%; padding: 11px 14px;
  border: 1px solid var(--line); border-radius: var(--rad-s);
  background: var(--surface); transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, .18);
}
.textarea { min-height: 120px; resize: vertical; }
.label { display: block; font-size: .85rem; font-weight: 650; color: var(--ink-2); margin-bottom: 6px; }

/* ---------- Подвал ---------- */
.site-footer {
  background: linear-gradient(180deg, var(--ink-deep), #0c1526);
  color: #c9c2ad; margin-top: 48px; padding: 38px 0 28px;
  font-size: .9rem; border-top: 1px solid var(--gold-line);
}
.site-footer a { color: #ecdfbd; }
.footer-cols { display: flex; flex-wrap: wrap; gap: 34px; justify-content: space-between; }
.footer-cols h4 { color: #f3e9d2; font-size: .95rem; margin-bottom: 10px; font-family: var(--font-display); }
.footer-note { border-top: 1px solid rgba(197, 160, 89, .22); margin-top: 26px; padding-top: 16px; color: #8d8871; font-size: .8rem; }

/* ---------- Утилиты ---------- */
.muted   { color: var(--ink-3); }
.small   { font-size: .85rem; }
.hidden  { display: none !important; }
.flex    { display: flex; gap: var(--r); flex-wrap: wrap; align-items: center; }
.grow    { flex: 1 1 auto; }
.mt0     { margin-top: 0; }
.mb0     { margin-bottom: 0; }
.center  { text-align: center; }
.nowrap  { white-space: nowrap; }
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: #fff; color: var(--ink); padding: 10px 16px; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }
.skip-vis {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  clip: rect(0 0 0 0); overflow: hidden; white-space: nowrap;
}

/* ---------- Адаптив ---------- */
@media (max-width: 1020px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .main-nav { order: 3; width: 100%; margin-left: -11px; font-size: .88rem; }
  .header-right { order: 2; }
  .btn-owui { font-size: .74rem; padding: 6px 10px; }
  .site-header .wrap { gap: 10px; }
}

/* Печать */
@media print {
  .site-header, .site-footer, .btn, .no-print { display: none !important; }
  body { background: #fff; }
  body::before { display: none; }
}
