/* Переключатель сервисов HolyCode. Все цвета — переменные --hcs-* с
   дефолтами под токены чата (тёмная тема); data-theme="light" даёт светлые.
   Хост переопределяет переменные на .hcs без правок разметки. */

.hcs {
  --hcs-font: inherit;
  --hcs-radius: 14px;
  --hcs-bg: #141226;
  --hcs-border: #3d3566;
  --hcs-divider: #2a2450;
  --hcs-text: #ece7ff;
  --hcs-muted: #9f96cf;
  --hcs-accent: #8b5cf6;
  --hcs-accent-soft: rgba(139, 92, 246, 0.14);
  --hcs-accent-text: #b69cff;
  --hcs-tile: #17152a;
  --hcs-tile-border: #2e2748;
  --hcs-tile-icon: #221f38;
  --hcs-hover: rgba(139, 92, 246, 0.14);
  --hcs-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  --hcs-trigger-bg: rgba(139, 92, 246, 0.14);
  --hcs-trigger-border: rgba(139, 92, 246, 0.7);
  --hcs-trigger-fg: #c4b5fd;
  --hcs-trigger-hover-bg: rgba(139, 92, 246, 0.22);
  --hcs-ring: rgba(141, 105, 255, 0.6);
  position: relative;
  display: inline-block;
  min-width: 0;
  font-family: var(--hcs-font);
  color: var(--hcs-text);
}

.hcs[data-theme="light"] {
  --hcs-bg: #ffffff;
  --hcs-border: #e2e8f0;
  --hcs-divider: #f1f5f9;
  --hcs-text: #1e1b3a;
  --hcs-muted: #64748b;
  --hcs-accent: #7c3aed;
  --hcs-accent-soft: rgba(124, 58, 237, 0.1);
  --hcs-accent-text: #6d28d9;
  --hcs-tile: #f8fafc;
  --hcs-tile-border: #e2e8f0;
  --hcs-tile-icon: #ede9fe;
  --hcs-hover: #f3f4f6;
  --hcs-shadow: 0 20px 50px rgba(15, 23, 42, 0.16);
  --hcs-trigger-bg: #f5f3ff;
  --hcs-trigger-border: #c4b5fd;
  --hcs-trigger-fg: #6d28d9;
  --hcs-trigger-hover-bg: #ede9fe;
  --hcs-ring: rgba(167, 139, 250, 0.5);
}

/* На телефоне (< 768 px) кнопки-сетки нет: сервисы — в листе «Сервисы»
   нижней панели (mobile-nav.css). */
@media (max-width: 767.98px) {
  .hcs--desktop { display: none; }
}

.hcs *, .hcs *::before, .hcs *::after { box-sizing: border-box; }

.hcs-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--hcs-trigger-border);
  border-radius: 10px;
  background: var(--hcs-trigger-bg);
  color: var(--hcs-trigger-fg);
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease;
}
.hcs--compact .hcs-trigger { width: 32px; height: 32px; border-radius: 9px; }
.hcs-trigger:hover { background: var(--hcs-trigger-hover-bg); border-color: var(--hcs-accent); }
.hcs-trigger:focus { outline: none; }
.hcs-trigger:focus-visible { box-shadow: 0 0 0 2px var(--hcs-ring); }
.hcs-trigger[aria-expanded="true"] { background: var(--hcs-trigger-hover-bg); border-color: var(--hcs-accent); }

.hcs-pop {
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  z-index: 10050;
  width: 352px;
  max-width: calc(100vw - 1.5rem);
  max-height: calc(100vh - 5rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px;
  border: 1px solid var(--hcs-border);
  border-radius: var(--hcs-radius);
  background: var(--hcs-bg);
  color: var(--hcs-text);
  box-shadow: var(--hcs-shadow);
  font-size: 13px;
  line-height: 1.4;
  text-align: left;
}
.hcs-pop--right { left: auto; right: 0; }
@media (max-width: 639.98px) {
  .hcs-pop { position: fixed; left: 12px; right: 12px; top: 58px; width: auto; max-width: none; }
}

.hcs-section {
  padding: 4px 8px 6px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--hcs-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hcs-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.hcs-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-width: 0;
  min-height: 78px;
  margin: 0;
  padding: 9px 6px 8px;
  border: 1px solid var(--hcs-tile-border);
  border-radius: 11px;
  background: var(--hcs-tile);
  color: inherit;
  font: inherit;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease;
}
.hcs-tile:hover { border-color: var(--hcs-accent); background: var(--hcs-hover); }
.hcs-tile:focus { outline: none; }
.hcs-tile:focus-visible { box-shadow: 0 0 0 2px var(--hcs-ring); }
.hcs-tile--current { border-color: var(--hcs-accent); background: var(--hcs-accent-soft); cursor: default; }
.hcs-tile--current:hover { background: var(--hcs-accent-soft); }

.hcs-tile-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  margin-bottom: 5px;
  border-radius: 9px;
  background: var(--hcs-tile-icon);
  color: var(--hcs-accent-text);
  font-size: 15px;
  line-height: 1;
}
.hcs-tile--current .hcs-tile-icon { color: var(--hcs-accent-text); }
.hcs-emoji { font-size: 15px; line-height: 1; }
.hcs-letter { font-size: 13px; font-weight: 800; line-height: 1; }

.hcs-tile-name {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
}
/* Подпись — до двух строк, дальше многоточие. */
.hcs-tile-hint {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  max-width: 100%;
  overflow: hidden;
  overflow-wrap: anywhere;
  margin-top: 1px;
  font-size: 10.5px;
  line-height: 1.25;
  color: var(--hcs-muted);
}
.hcs-tile--current .hcs-tile-hint { color: var(--hcs-accent-text); }

.hcs-hr { margin: 8px 0 6px; border: 0; border-top: 1px solid var(--hcs-divider); }

.hcs-row {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 34px;
  margin: 0;
  padding: 7px 8px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: default;
}
button.hcs-row, a.hcs-row { cursor: pointer; transition: background-color 150ms ease; }
a.hcs-row { color: inherit; text-decoration: none; }
button.hcs-row:hover, a.hcs-row:hover { background: var(--hcs-hover); }
button.hcs-row:focus { outline: none; }
button.hcs-row:focus-visible { background: var(--hcs-hover); }
.hcs-row-icon { display: flex; flex: none; align-items: center; justify-content: center; width: 20px; color: var(--hcs-accent-text); }
/* Название важнее подсказки справа: тесно — укорачивается подсказка. */
.hcs-row-text { min-width: 0; flex: 1 0 auto; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hcs-row-right { flex: 0 1 auto; min-width: 0; margin-left: auto; padding-left: 8px; font-size: 11px; color: var(--hcs-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* «← Назад в HolyCode» после перехода по return_to: маленькая ссылка-пилюля
   у названия сервиса в шапке. */
.hcs-back-wrap { display: inline-flex; align-items: center; min-width: 0; }
.hcs-back {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  height: 28px;
  padding: 0 10px 0 8px;
  border: 1px solid var(--hcs-trigger-border);
  border-radius: 999px;
  background: var(--hcs-trigger-bg);
  color: var(--hcs-trigger-fg);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 150ms ease, border-color 150ms ease;
}
.hcs-back:hover { background: var(--hcs-trigger-hover-bg); border-color: var(--hcs-accent); }
.hcs-back:focus { outline: none; }
.hcs-back:focus-visible { box-shadow: 0 0 0 2px var(--hcs-ring); }
.hcs-back-text { min-width: 0; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 639.98px) {
  .hcs-back { padding: 0 8px; }
  .hcs-back-text { max-width: 96px; }
}

/* Раздел «Другие сервисы» в меню аватара нужен только там, где нет
   кнопки-сетки, — на телефоне. Хост оборачивает его в этот класс. */
.hcs-phone-only { display: block; }
@media (min-width: 768px) {
  .hcs-phone-only { display: none; }
}

/* Компактный список для меню аватара на телефоне: те же плитки в три
   колонки, но ниже и с короткими именами. */
.hcs-links { display: block; }
.hcs-links .hcs-grid { padding: 0 4px 2px; }
.hcs-links .hcs-tile { min-height: 0; flex-direction: row; justify-content: center; gap: 6px; padding: 7px 4px; }
.hcs-links .hcs-tile-icon { width: 18px; height: 18px; margin: 0; background: transparent; }
.hcs-links .hcs-tile-name { font-size: 11.5px; font-weight: 600; }

/* ---------- Общая верхняя полоса HolyCode (вариант A, 02.10.2026) ----------
   Одна во всех сервисах: 52 px во всю ширину, слева сетка · знак и имя ·
   «Назад в …», посередине — своё у сервиса (вкладки, поиск), справа —
   организация · облако HolyAgent · аватар. Логика — shell.js, отрисовка —
   TopBar.*. Хост может перекрасить фон и рамку переменными --hcs-bar-*. */
.hcs-bar {
  --hcs-bar-bg: #100e20;
  --hcs-bar-border: #2a2450;
  --hcs-bar-text: #ece7ff;
  --hcs-bar-muted: #9f96cf;
  position: relative;
  z-index: 120;
  display: flex;
  flex: 0 0 52px;
  align-items: center;
  gap: 12px;
  box-sizing: border-box;
  width: 100%;
  height: 52px;
  min-width: 0;
  padding: 0 14px;
  border-bottom: 1px solid var(--hcs-bar-border);
  background: var(--hcs-bar-bg);
  color: var(--hcs-bar-text);
  font-family: inherit;
}
.hcs-bar[data-theme="light"] {
  --hcs-bar-bg: #ffffff;
  --hcs-bar-border: #e2e8f0;
  --hcs-bar-text: #1e1b3a;
  --hcs-bar-muted: #64748b;
}
.hcs-bar *, .hcs-bar *::before, .hcs-bar *::after { box-sizing: border-box; }
.hcs-bar-left { display: flex; flex: 0 0 auto; align-items: center; gap: 10px; min-width: 0; }
.hcs-bar-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.hcs-bar-brand img { flex: none; width: 26px; height: 26px; border-radius: 7px; }
.hcs-bar-brand:focus { outline: none; }
.hcs-bar-brand:focus-visible { box-shadow: 0 0 0 2px var(--hcs-ring, rgba(141, 105, 255, 0.6)); border-radius: 8px; }
.hcs-bar-name { overflow: hidden; text-overflow: ellipsis; }
.hcs-bar-center { display: flex; flex: 1 1 auto; align-items: center; gap: 8px; min-width: 0; }
.hcs-bar-right { display: flex; flex: 0 0 auto; align-items: center; gap: 8px; margin-left: auto; }
.hcs-bar-slot { display: flex; align-items: center; gap: 8px; min-width: 0; }
.hcs-bar-agent { display: inline-flex; }
.hcs-bar-agent:empty { display: none; }
/* В полосе сетка и аватар одного размера: 34 px. */
.hcs-bar .hcs-trigger { width: 34px; height: 34px; border-radius: 9px; }
.hcs-bar .hca-trigger { width: 34px; height: 34px; }
.hcs-bar .hca-trigger .hca-avatar { width: 32px; height: 32px; font-size: 12px; }

/* Кнопка-облако HolyAgent: только внутри оболочки и только когда вышла новая
   версия (владелец 02.10.2026: «точка, при открытии полный блок, плюс
   маленькая кнопка сразу, чтобы нажать»). Клик — установка. */
.hcs-agent-btn {
  position: relative;
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1.5px solid var(--hcs-trigger-border);
  border-radius: 999px;
  background: var(--hcs-trigger-bg);
  color: var(--hcs-trigger-fg);
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease;
}
.hcs-agent-btn:hover { background: var(--hcs-trigger-hover-bg); border-color: var(--hcs-accent); }
.hcs-agent-btn:focus { outline: none; }
.hcs-agent-btn:focus-visible { box-shadow: 0 0 0 2px var(--hcs-ring); }
.hcs-agent-btn[disabled] { cursor: progress; opacity: 0.75; }
.hcs-agent-dot { position: absolute; top: -1px; right: -1px; width: 9px; height: 9px; border: 2px solid var(--hcs-bar-bg, #100e20); border-radius: 50%; background: #f59e0b; }
.hcs-agent-btn[disabled] .hcs-agent-dot { animation: hcs-agent-pulse 1.2s ease-in-out infinite; }
@keyframes hcs-agent-pulse { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .hcs-agent-btn[disabled] .hcs-agent-dot { animation: none; } }

/* Телефон: полоса — знак, имя и аватар; сервисы и разделы — нижняя панель. */
@media (max-width: 767.98px) {
  .hcs-bar {
    gap: 8px;
    height: calc(48px + env(safe-area-inset-top, 0px));
    flex-basis: auto;
    padding: env(safe-area-inset-top, 0px) 10px 0;
  }
  .hcs-bar-center, .hcs-bar-back, .hcs-bar-desktop { display: none; }
  .hcs-bar-brand { font-size: 15px; }
}

/* ---------- Пункт бокового меню — один вид во всех сервисах (02.10.2026) ----------
   Владелец: «пункт меню выделяется красивым выделением, без боковой бровки —
   как в агенте и Daenerys, единый концепт». Эталон — .sidebar-tab.active
   панелей HolyAgent и Daenerys; здесь те же числа для сервисов, где меню своё
   (админка HolyCode, HOLYBUILD). Корень меню — .hcs-nav (data-theme="light"
   для светлой темы), пункт — .hcs-nav-item, активный — aria-current="page"
   или .is-active. Префикс hcs- — палитры перекрашивают его вместе с меню. */
.hcs-nav {
  --hcs-nav-text: #ece7ff;
  --hcs-nav-muted: #b4aedb;
  --hcs-nav-hover: rgba(255, 255, 255, 0.04);
  --hcs-nav-active-text: #ffffff;
  --hcs-nav-active-border: rgba(124, 58, 237, 0.34);
  --hcs-nav-active-bg: linear-gradient(135deg, rgba(56, 189, 248, 0.14), rgba(124, 58, 237, 0.22));
  --hcs-nav-active-shadow: inset 0 0 0 1px rgba(124, 58, 237, 0.18), 0 14px 30px rgba(6, 11, 30, 0.22);
}
.hcs-nav[data-theme="light"] {
  --hcs-nav-text: #1e1b3a;
  --hcs-nav-muted: #475569;
  --hcs-nav-hover: rgba(15, 23, 42, 0.04);
  --hcs-nav-active-text: #4c1d95;
  --hcs-nav-active-border: rgba(124, 58, 237, 0.35);
  --hcs-nav-active-bg: linear-gradient(135deg, rgba(56, 189, 248, 0.12), rgba(124, 58, 237, 0.16));
  --hcs-nav-active-shadow: inset 0 0 0 1px rgba(124, 58, 237, 0.12);
}
.hcs-nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  min-width: 0;
  padding: 0.62rem 0.8rem;
  border: 1px solid transparent;
  border-radius: 0.9rem;
  background: transparent;
  color: var(--hcs-nav-muted);
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}
.hcs-nav-item:hover { color: var(--hcs-nav-text); background: var(--hcs-nav-hover); }
.hcs-nav-item:focus { outline: none; }
.hcs-nav-item:focus-visible { box-shadow: 0 0 0 2px var(--hcs-ring, rgba(141, 105, 255, 0.6)); }
.hcs-nav-item[aria-current="page"],
.hcs-nav-item.is-active {
  color: var(--hcs-nav-active-text);
  border-color: var(--hcs-nav-active-border);
  background: var(--hcs-nav-active-bg);
  box-shadow: var(--hcs-nav-active-shadow);
}
.hcs-nav-item[aria-disabled="true"], .hcs-nav-item:disabled { cursor: default; opacity: 0.5; background: transparent; }

/* Скроллбары: наши тонкие, а не системные белые (владелец, 01.10.2026).
   Один стиль на все панели — файл общий. Firefox — scrollbar-color,
   WebKit/Chromium — псевдоэлементы. */
/* В WebKit/Chromium стандартные scrollbar-width/scrollbar-color отключают
   стили ::-webkit-scrollbar и рисуют системные полосы (белые на тёмном) —
   поэтому они только для браузеров без псевдоэлементов (Firefox). */
@supports not selector(::-webkit-scrollbar) {
  * { scrollbar-width: thin; scrollbar-color: rgba(148, 163, 184, 0.35) transparent; }
}
:root { color-scheme: dark; }
:root[data-theme="light"] { color-scheme: light; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.35); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: rgba(148, 163, 184, 0.55); border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-corner { background: transparent; }
