/* MCP Brain — общая дизайн-система (вдохновлено Apple HIG).
   Единый источник токенов: светлая + тёмная тема, тосты, базовая доступность.
   Подключается перед inline-стилями страниц; компоненты ссылаются на var(--*). */

:root { color-scheme: light dark; }
:root[data-theme="dark"] { color-scheme: dark; }
:root[data-theme="light"] { color-scheme: light; }

:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --surface-3: #f9f9fb;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: #e5e5ea;
  --line-2: #d8d8dc;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --header-bg: rgba(255, 255, 255, .85);
  --badge-bg: #f0f0f5;
  --success-bg: #edf7ed;
  --success-fg: #1a6b2a;
  --danger-bg: #fde8e8;
  --danger-fg: #b00020;
  --shadow: rgba(0, 0, 0, .10);
  --radius: 12px;
}

/* Тёмные токены. Применяются:
   1) явно — :root[data-theme="dark"] (кнопка-переключатель), и
   2) по системной теме — если пользователь не выбрал светлую вручную. */
:root[data-theme="dark"],
:root.theme-dark {
  --bg: #0c144f;
  --surface: #1c1c1e;
  --surface-2: #2c2c2e;
  --surface-3: #242426;
  --text: #f5f5f7;
  --muted: #9a9aa0;
  --line: #38383a;
  --line-2: #48484a;
  --accent: #0a84ff;
  --accent-hover: #409cff;
  --header-bg: rgba(12, 20, 79, .82);
  --badge-bg: #2c2c2e;
  --success-bg: #11331a;
  --success-fg: #5ddf7a;
  --danger-bg: #3a1113;
  --danger-fg: #ff8a8a;
  --shadow: rgba(0, 0, 0, .5);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c144f;
    --surface: #1c1c1e;
    --surface-2: #2c2c2e;
    --surface-3: #242426;
    --text: #f5f5f7;
    --muted: #9a9aa0;
    --line: #38383a;
    --line-2: #48484a;
    --accent: #0a84ff;
    --accent-hover: #409cff;
    --header-bg: rgba(12, 20, 79, .82);
    --badge-bg: #2c2c2e;
    --success-bg: #11331a;
    --success-fg: #5ddf7a;
    --danger-bg: #3a1113;
    --danger-fg: #ff8a8a;
    --shadow: rgba(0, 0, 0, .5);
  }
}

/* Доступный фокус — кольцо вместо стандартного outline */
:where(a, button, input, select, textarea, summary):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* Тосты (транзиентные уведомления) */
.toast-wrap {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: max-content;
  max-width: 92vw;
}
.toast {
  pointer-events: auto;
  min-width: 220px;
  max-width: 92vw;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 10px 34px var(--shadow);
  animation: toast-in .24s ease;
}
.toast.success { background: var(--success-bg); color: var(--success-fg); }
.toast.error   { background: var(--danger-bg);  color: var(--danger-fg); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* Общая «хромка» шапки/навигации — единый источник для всех страниц-списков. */
.logo {
  font-size: 16px; font-weight: 600; color: var(--text); letter-spacing: -.2px;
  white-space: nowrap; flex: 0 0 auto; display: inline-flex; align-items: center; gap: 8px;
}
.logo::before {
  content: ""; flex: 0 0 auto; width: 9px; height: 9px; border-radius: 3px;
  background: linear-gradient(135deg, var(--accent), #6d5cff);
}

/* Навигация — сегмент-контрол в стиле iOS: утопленный контейнер + приподнятая активная вкладка. */
.nav-center {
  display: flex; align-items: center; gap: 2px; min-width: 0;
  background: var(--badge-bg); padding: 3px; border-radius: 12px;
}
.nav-link {
  padding: 6px 13px; border-radius: 9px; font-size: 13.5px; font-weight: 500;
  color: var(--muted); white-space: nowrap;
  transition: color .15s ease, background .15s ease, box-shadow .15s ease;
}
.nav-link:hover { color: var(--text); text-decoration: none; }
.nav-link.active {
  background: var(--surface); color: var(--text); font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .14), 0 0 0 .5px rgba(0, 0, 0, .05);
}

.nav-right { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.user-pill { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.role-badge { padding: 1px 7px; background: var(--badge-bg); border-radius: 980px; font-size: 11px; color: var(--muted); }
.btn-sm { height: 32px; padding: 0 14px; border: none; border-radius: 980px; font: inherit; font-size: 14px; font-weight: 500; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; white-space: nowrap; }
.btn-sm-ghost { background: var(--badge-bg); color: var(--text); }
.btn-sm-ghost:hover { background: var(--line); text-decoration: none; }
.btn-sm-primary { background: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.btn-sm-primary:hover { background: var(--accent-hover); text-decoration: none; }

/* Переключатель темы — компактная иконка без подписи. */
.btn-theme {
  width: 32px; height: 32px; padding: 0; justify-content: center;
  border: none; border-radius: 980px; background: transparent; color: var(--muted);
  font: inherit; cursor: pointer; display: inline-flex; align-items: center; flex: 0 0 auto;
}
.btn-theme:hover { background: var(--badge-bg); color: var(--text); }
.btn-theme .theme-ico { font-size: 16px; line-height: 1; }
.btn-theme .theme-label { display: none; }

/* Заголовки страниц теперь h1: гасим UA-отступы, вид берётся из per-page .section-title. */
h1.section-title { margin: 0; }

/* «Уточнить у ИИ» — доработка результата сценария продолжением сессии Codex. */
.sc-refine { display: flex; gap: 8px; align-items: center; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.sc-refine-input { flex: 1; min-width: 0; border: 1px solid var(--line-2, var(--line)); border-radius: 8px; padding: 7px 10px; font: inherit; font-size: 14px; background: var(--surface-2); color: var(--text); }
.sc-refine-input:focus { outline: none; border-color: var(--accent); }
.sc-refine-btn { white-space: nowrap; }
.sc-refine.busy { opacity: .6; pointer-events: none; }

/* Узкие экраны: навигация скроллится по горизонтали, второстепенное прячем. */
@media (max-width: 760px) {
  .nav-center { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .nav-center::-webkit-scrollbar { display: none; }
  .user-pill { display: none; }
}
