/* Переключатель сервисов 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) кнопки-сетки нет: сервисы — в меню аватара. */
@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 { cursor: pointer; transition: background-color 150ms ease; }
button.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; }
