/* ============================================================
   БАЗА: токены дизайна и общие компоненты для всех 9 страниц.
   Правки палитры/теней/радиусов — только здесь.
   Специфика страниц живёт в css/<страница>.css.
   ============================================================ */

:root {
  /* Палитра — основа из styles.css бэкенд-проекта напарника */
  --bg: #EEF3F0;
  --surface: #FFFFFF;
  --accent: #236B56;
  --accent-strong: #194E40;
  --accent-tint: rgba(35, 107, 86, .10);
  --mint: #D7EEE3;
  --success: #188453;
  --warning: #C66A38;
  --danger: #B94B4B;
  --text: #17201D;
  --text-muted: #53645D;
  --border: #879990;

  /* Геометрия и свет — мои, но тени под зелёную базу */
  --radius-sm: 10px;
  --radius: 12px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(24, 49, 40, .08), 0 1px 1px rgba(24, 49, 40, .06);
  --shadow-md: 0 6px 16px rgba(24, 49, 40, .10), 0 2px 4px rgba(24, 49, 40, .06);
  --shadow-lg: 0 16px 40px rgba(24, 49, 40, .14);

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  --weight-regular: 400;
  --weight-semibold: 600;
  --weight-bold: 700;
  --container: 1080px;
  --header-h: 64px;

  /* Движение: кривые и длительности по стандарту Material Design 3.
     Правки анимаций — только здесь, страницы ссылаются на токены. */
  --ease-standard: cubic-bezier(.2, 0, 0, 1);      /* ховер, цвет, обычные переходы */
  --ease-decelerate: cubic-bezier(.05, .7, .1, 1); /* появление: входит быстро, тормозит */
  --ease-accelerate: cubic-bezier(.3, 0, .8, .15); /* исчезновение: разгоняется и уходит */
  --dur-1: 100ms;  /* нажатие, мгновенный отклик */
  --dur-2: 150ms;  /* цвет, ховер, рамка */
  --dur-3: 200ms;  /* иконки, мелкие сдвиги */
  --dur-4: 300ms;  /* панели, всплывающие блоки */
  --dur-5: 400ms;  /* шкала интереса, крупные блоки */

  /* Слои состояний: одна подложка на ховер и нажатие для всех кнопок */
  --state-hover: rgba(35, 107, 86, .07);
  --state-press: rgba(35, 107, 86, .12);
  --focus-ring: 0 0 0 3px rgba(35, 107, 86, .18);
  --neutral-soft: #E4EBE7;
  --neutral-mute: #65766E;
}

/* --- Сброс и основа --- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }

body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: radial-gradient(circle at 10% 0, rgba(215, 238, 227, .72), transparent 30%), var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  animation: page-enter var(--dur-4) var(--ease-decelerate) both;
}

@keyframes page-enter {
  /* Never transform body: a transformed ancestor changes the containing
     block of position:fixed widgets and makes them scroll with the document. */
  from { opacity: .72; }
  to { opacity: 1; }
}

body.is-leaving {
  opacity: .5;
  transition: opacity 140ms var(--ease-accelerate);
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
svg { display: block; }

::selection { background: var(--mint); color: var(--text); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

.container {
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: 24px;
}

/* --- Шапка: одинаковая на всех страницах --- */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: var(--header-h);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand__logo {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-sm);
}

.brand__name {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-link{margin-left:12px;color:var(--text-muted);font-size:14px;font-weight:600;text-decoration:none}.profile-link:hover{color:var(--accent)}
.header .handbook-nav{
  margin-left:auto;
  display:flex;
  align-items:center;
  gap:6px;
  font-size:14px;
  white-space:nowrap;
}
.header .handbook-nav a{
  display:inline-flex;
  align-items:center;
  min-height:44px;
  padding:9px 12px;
  border:1px solid transparent;
  border-radius:10px;
  color:var(--text-muted);
  font-weight:600;
  text-decoration:none;
  transition:background var(--dur-2) var(--ease-standard),color var(--dur-2) var(--ease-standard),border-color var(--dur-2) var(--ease-standard);
}
.header .handbook-nav a:hover{color:var(--accent-strong);background:var(--state-hover)}
.header .handbook-nav a.is-active,
.header .handbook-nav a[aria-current="page"]{
  color:#fff;
  background:var(--accent);
  border-color:var(--accent);
  box-shadow:var(--shadow-sm);
}

/* --- Профиль и выпадающее меню --- */
.profile { position: relative; }

.profile__btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 6px 12px;
  border-radius: var(--radius);
  transition: background var(--dur-2) var(--ease-standard);
}

.profile__btn:hover { background: var(--state-hover); }

.profile__label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-sm);
}

.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 200px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  animation: menu-in var(--dur-3) var(--ease-decelerate);
}

.menu[hidden] { display: none; }

.menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  transition: background var(--dur-2) var(--ease-standard);
}

.menu__item:hover { background: var(--state-hover); }

.menu__sep {
  height: 1px;
  background: var(--border);
  margin: 6px 4px;
}

@keyframes menu-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}

/* --- Плавное появление блоков (управляется из js/app.js) --- */
.js [data-reveal] {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity var(--dur-5) var(--ease-decelerate), transform var(--dur-5) var(--ease-decelerate);
}

.js [data-reveal].is-visible {
  opacity: 1;
  transform: none;
}

/* --- Доступность и мобильные --- */
@media (prefers-reduced-motion: reduce) {
  body { animation: none; }
  body.is-leaving { opacity: 1; transform: none; transition: none; }
  .js [data-reveal] { opacity: 1; transform: none; transition: none; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  .btn:active, .icon-btn:active { transform: none; }
}

@media (max-width: 560px) {
  .profile__label { display: none; }
  .container { padding-inline: 16px; }
  /* Палец шире курсора: минимальная зона нажатия 44px. */
  .icon-btn { width: 44px; height: 44px; }
  .btn { min-height: 44px; padding-block: 11px; }
}

/* ============================================================
   ДОПОЛНЕНИЕ v2: кнопки, заголовок страницы, поиск, пилюли.
   Общие компоненты для внутренних страниц.
   ============================================================ */

/* --- Заголовок внутренней страницы: «назад» + центрированный титул --- */
.page-head {
  position: relative;
  padding: 36px 0 8px;
  text-align: center;
}

.page-head__title {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -.01em;
}

.page-head__back {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
}

/* Stable browser-back control: no scale/fade animation and no position jump. */
.nav-back {
  transition: none !important;
  animation: none !important;
}
.nav-back:active { transform: none; }
.page-head__back.nav-back:active { transform: translateY(-50%); }

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  color: var(--text-muted);
  display: grid;
  place-items: center;
  transition: color var(--dur-2) var(--ease-standard), border-color var(--dur-2) var(--ease-standard);
}

.icon-btn:hover {
  color: var(--accent);
  border-color: rgba(35, 107, 86, .45);
  background: var(--state-hover);
}

.icon-btn:active { background: var(--state-press); transform: scale(.94); transition-duration: var(--dur-1); }
.icon-btn.nav-back:active { transform: none; transition-duration: 0s; }
.page-head__back.icon-btn.nav-back:active { transform: translateY(-50%); }

/* --- Кнопки --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  transition: background var(--dur-2) var(--ease-standard), border-color var(--dur-2) var(--ease-standard), color var(--dur-2) var(--ease-standard);
}

.btn:active { transform: scale(.985); transition-duration: var(--dur-1); }
.btn--primary:active { background: var(--accent-strong); }
.btn--secondary:hover { background: var(--state-hover); }
.btn--secondary:active { background: var(--state-press); }
.btn--ghost:active { background: var(--state-press); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .68; cursor: not-allowed; transform: none; }

.btn--primary {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn--primary:hover { background: var(--accent-strong); }

.btn--secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.btn--secondary:hover {
  border-color: rgba(35, 107, 86, .45);
  color: var(--accent-strong);
}

.btn--ghost { color: var(--text-muted); }
.btn--ghost:hover { background: var(--state-hover); color: var(--text); }

/* --- Поиск --- */
.search {
  position: relative;
  display: flex;
  align-items: center;
}

.search > svg {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  pointer-events: none;
}

.search input {
  width: 100%;
  height: 42px;
  padding: 0 14px 0 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  font: inherit;
  font-size: 14px;
  color: var(--text);
  transition: border-color var(--dur-2) var(--ease-standard), box-shadow var(--dur-2) var(--ease-standard);
}

.search input::placeholder { color: var(--neutral-mute); }

.search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

/* --- Пилюли-метки (сложность, статусы и т.п.) --- */
.pill {
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.pill--easy { color: var(--success); background: rgba(39, 174, 96, .10); }
.pill--mid  { color: #C87F0A; background: rgba(243, 156, 18, .12); }
.pill--hard { color: var(--accent-strong); background: var(--accent-tint); }

/* --- Чипсы --- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 4px 10px;
  border-radius: 999px;
  background: #E9F1EC;
  font-size: 12.5px;
  font-weight: 600;
}
/* Текст интерфейса и сообщений можно выделять и копировать. */
::selection { background: #BFE3D3; color: #10251E; }
p, li, h1, h2, h3, .msg, .call__caption, .brief, .panel__body { user-select: text; -webkit-user-select: text; }

/* v18 — список моделей в подсказках (главный экран и чат) */
.model-chip__list { display: grid; gap: 5px; margin: 3px 0 0; padding: 0; list-style: none; }
.model-chip__list li { display: flex; align-items: center; gap: 7px; color: var(--text-muted); font-size: 10.5px; }
.model-chip__list li::before { content: ""; flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--neutral-mute); }
.model-chip__list li.is-up::before { background: var(--success); }
.model-chip__list li.is-down::before { background: var(--danger); }
.model-chip__list li.is-active { color: var(--text); font-weight: 600; }
.model-chip__list li span.model-chip__role { color: var(--neutral-mute); font-size: 9px; text-transform: uppercase; letter-spacing: .04em; }
.model-chip__list li b { margin-left: auto; font-size: 9.5px; font-weight: 600; color: var(--text-muted); }

/* Wrapping safeguards for long scenario titles, generated answers and IDs. */
:where(main, .container, .panel, .modal, .card) { min-width: 0; }
:where(p, h1, h2, h3, h4, li, .pill, .panel__note, .chat-bubble) { overflow-wrap: anywhere; }
:where(img, svg, video) { max-width: 100%; }
@media (max-width: 640px) {
  .container { padding-inline: 16px; }
  .header__inner { min-width: 0; }
}
@media (max-width: 640px) {
  .header__inner:has(.handbook-nav) .brand__name,
  .header__inner:has(.model-status:not([hidden])) .brand__name { display: none; }
  .page-head__title { padding-inline: 48px; overflow-wrap: anywhere; }
}

/* About and support information replaces developer diagnostics in the header. */
.about-app-button {
  flex: none;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-left: -8px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--accent);
  font-weight: 700;
  font-family: var(--font);
  font-size: 15px;
}
.header__inner .profile-link { margin-left: auto; }
.about-app-button:hover { border-color: var(--accent); background: var(--accent-tint); }
.about-modal { position: fixed; z-index: 200; inset: 0; display: grid; place-items: center; padding: 18px; }
.about-modal[hidden] { display: none; }
.about-modal__backdrop { position: absolute; inset: 0; background: rgba(15,29,24,.68); }
.about-modal__dialog {
  position: relative;
  z-index: 1;
  width: min(520px, 100%);
  max-height: min(720px, 90dvh);
  overflow: auto;
  padding: 26px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
.about-modal__dialog h2 { margin: 5px 0 10px; }
.about-modal__dialog > p:not(.page-eyebrow) { color: var(--text-muted); line-height: 1.55; }
.about-modal__close { position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border-radius: 50%; font-size: 22px; }
.about-modal__close:hover { background: var(--state-hover); }
.about-modal__team { display: grid; gap: 6px; margin-top: 20px; padding: 16px; border-radius: var(--radius); background: var(--accent-tint); }
.about-modal__team span { color: var(--text-muted); font-size: 14px; }
.about-modal__team a, .site-contact a { color: var(--accent-strong); font-weight: 600; }
.about-modal__technical { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
.about-modal__technical summary { cursor: pointer; color: var(--text-muted); font-size: 14px; }
.about-modal__technical div { margin-top: 10px; color: var(--text-muted); font-size: 14px; line-height: 1.5; }
.site-contact {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 20px;
  padding: 24px 18px 30px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
}
body.has-modal { overflow: hidden; }
.technical-summary p { margin: 0 0 10px; }
.technical-models { display:grid; gap:8px; margin:10px 0; }
.technical-model { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:3px 12px; padding:10px 12px; border:1px solid var(--border); border-left:4px solid #B8B8B2; border-radius:8px; background:var(--surface); }
.technical-model.is-up { border-left-color:var(--success); }
.technical-model.is-down { border-left-color:var(--danger, #B44949); }
.technical-model span,.technical-model small,.technical-model em { display:block; }
.technical-model small,.technical-model em { color:var(--text-muted); font-size:13px; font-style:normal; }
.technical-model strong { font-size:13px; }
.technical-model em { grid-column:1/-1; }
@media(max-width:520px){
  .technical-model { grid-template-columns:minmax(0,1fr); }
  .technical-model b { overflow-wrap:anywhere; }
  .technical-model strong { justify-self:start; }
}

@media (max-width: 760px) {
  .header__inner:has(.handbook-nav) {
    height: auto;
    min-height: var(--header-h);
    flex-wrap: wrap;
    gap: 6px 8px;
    padding-block: 8px;
  }
  .header__inner:has(.handbook-nav) .brand__name { display: inline; }
  .header .handbook-nav {
    order: 2;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    flex: 0 0 100%;
    width: 100%;
    gap: 4px;
    overflow: visible;
  }
  .header .handbook-nav a {
    justify-content: center;
    min-width: 0;
    min-height: 48px;
    padding: 6px 4px;
    font-size: 12px;
    line-height: 1.2;
    text-align: center;
    white-space: normal;
  }
}
