/**
 * Hub sidebar — эталон handoff 2026-06-30 (Instagram-style rail):
 * 56px рейка → 196px при hover; иконки стоят в фиксированном слоте
 * (не focus-within — иначе после SPA-клика
 * подписи залипают и наезжают на /library, /it-services и т.п.).
 * Перебивает старую toggle-модель из catalog-handoff.css (!important).
 * Не затирается sync-handoff-full.mjs.
 */
:root {
  --catalog-sidebar-scale: 1;
  --catalog-sidebar-w: calc(196px * var(--catalog-sidebar-scale));
  --catalog-sidebar-w-collapsed: calc(56px * var(--catalog-sidebar-scale));
  --hub-sidebar-w-collapsed: var(--catalog-sidebar-w-collapsed);
}

body.hub-sidebar-rail .catalog-sidebar,
html.catalog-handoff-active .hub-handoff-root .catalog-sidebar {
  display: flex !important;
  flex-direction: column !important;
  height: 100dvh !important;
  width: var(--catalog-sidebar-w-collapsed) !important;
  min-width: 0 !important;
  max-width: none !important;
  padding: 16px 0 !important;
  background: transparent !important;
  border-right: none !important;
  box-shadow: none !important;
  overflow: hidden !important;
  transition: width 0.22s cubic-bezier(0.22, 1, 0.36, 1) !important;
}

/* In-stage rail: absolute overlay (not grid-track width) — expands over main */
html[data-app-stage="1"] body.hub-sidebar-rail .hub-handoff-root .catalog-sidebar {
  position: absolute !important;
  left: 0 !important;
  top: 0 !important;
  bottom: 0 !important;
  z-index: 200 !important;
  height: 100% !important;
  max-height: var(--app-stage-h) !important;
  transform: none !important;
  pointer-events: auto !important;
}

/* Expanded rail must paint above main on /library, /projects, /orders, … */
body.hub-sidebar-rail .hub-handoff-root > .catalog-app > .catalog-sidebar,
html.catalog-handoff-active .hub-handoff-root > .catalog-app > .catalog-sidebar {
  position: absolute !important;
  left: 0 !important;
  top: 0 !important;
  bottom: 0 !important;
  z-index: 200 !important;
}

body.hub-sidebar-rail .hub-handoff-root > .catalog-app > .catalog-main,
body.hub-sidebar-rail .hub-handoff-root > .catalog-app > .hub-route-pane,
html.catalog-handoff-active .hub-handoff-root > .catalog-app > .catalog-main,
html.catalog-handoff-active .hub-handoff-root > .catalog-app > .hub-route-pane {
  z-index: 1 !important;
}

body.hub-sidebar-rail .catalog-sidebar:hover,
body.hub-sidebar-rail .catalog-sidebar.is-expanded,
html.catalog-handoff-active .hub-handoff-root .catalog-sidebar:hover,
html.catalog-handoff-active .hub-handoff-root .catalog-sidebar.is-expanded {
  width: var(--catalog-sidebar-w) !important;
  padding-inline: 0 !important;
  /* Soft scrim so labels stay readable over library/projects titles */
  background: linear-gradient(
    90deg,
    rgba(3, 3, 8, 0.92) 0%,
    rgba(3, 3, 8, 0.78) 72%,
    rgba(3, 3, 8, 0) 100%
  ) !important;
  border-right: none !important;
  box-shadow: none !important;
}

/* Never expand on focus-within (SPA menu click leaves focus on the link) */
body.hub-sidebar-rail .catalog-sidebar:focus-within:not(:hover),
html.catalog-handoff-active .hub-handoff-root .catalog-sidebar:focus-within:not(:hover) {
  width: var(--catalog-sidebar-w-collapsed) !important;
}

/* Логотип — сверху-слева рейки, не зависит от раскрытия */
body.hub-sidebar-rail .catalog-sidebar__head,
html.catalog-handoff-active .hub-handoff-root .catalog-sidebar__head {
  display: flex !important;
  position: fixed;
  top: 22px;
  left: 14px;
  z-index: 81;
  flex-direction: column;
  align-items: flex-start;
  margin: 0;
  padding: 0;
  pointer-events: auto;
}

/* Inside app-stage: stay on the rail, never pin to the real viewport */
html[data-app-stage="1"] body.hub-sidebar-rail .catalog-sidebar__head,
html[data-app-stage="1"].catalog-handoff-active .hub-handoff-root .catalog-sidebar__head {
  position: absolute !important;
  top: 22px !important;
  left: 14px !important;
}

body.hub-sidebar-rail .catalog-sidebar__brand,
html.catalog-handoff-active .hub-handoff-root .catalog-sidebar__brand {
  display: flex !important;
  justify-content: flex-start;
  width: auto;
  line-height: 0;
}

body.hub-sidebar-rail .catalog-sidebar__brand:hover,
html.catalog-handoff-active .hub-handoff-root .catalog-sidebar__brand:hover {
  opacity: 0.9;
}

body.hub-sidebar-rail .catalog-sidebar__brand-logo,
html.catalog-handoff-active .hub-handoff-root .catalog-sidebar__brand-logo {
  display: block;
  width: auto;
  height: 48px;
  max-width: none;
  margin: 0;
  object-fit: contain;
  object-position: left center;
}

body.hub-sidebar-rail .catalog-logo--biz,
html.catalog-handoff-active .hub-handoff-root .catalog-logo--biz {
  display: none;
}

html.catalog-theme-biz body.hub-sidebar-rail .catalog-logo--pro,
html.catalog-theme-biz.catalog-handoff-active .hub-handoff-root .catalog-logo--pro {
  display: none;
}

html.catalog-theme-biz body.hub-sidebar-rail .catalog-logo--biz,
html.catalog-theme-biz.catalog-handoff-active .hub-handoff-root .catalog-logo--biz {
  display: block;
}

body.hub-sidebar-rail .catalog-sidebar__toggle,
body.hub-sidebar-rail .catalog-sidebar__theme,
html.catalog-handoff-active .hub-handoff-root .catalog-sidebar__toggle,
html.catalog-handoff-active .hub-handoff-root .catalog-sidebar__theme {
  display: none !important;
}

/* Навигация — по центру колонки; профиль/корзина — внизу (flex, не absolute) */
body.hub-sidebar-rail .catalog-sidebar__nav,
html.catalog-handoff-active .hub-handoff-root .catalog-sidebar__nav {
  position: relative !important;
  top: auto !important;
  left: auto !important;
  right: auto !important;
  transform: none !important;
  flex: 1 1 auto !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: center !important;
  min-height: 0;
  gap: calc(4px * var(--catalog-sidebar-scale, 1));
  padding: 0;
  overflow: visible;
}

body.hub-sidebar-rail .catalog-sidebar__bottom,
html.catalog-handoff-active .hub-handoff-root .catalog-sidebar__bottom {
  flex-shrink: 0 !important;
  margin-top: 0 !important;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

body.hub-sidebar-rail .catalog-sidebar__link,
html.catalog-handoff-active .hub-handoff-root .catalog-sidebar__link {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start !important;
  gap: 8px !important;
  min-height: calc(32px * var(--catalog-sidebar-scale, 1));
  height: auto;
  width: 100%;
  padding: 4px 0 !important;
  margin-inline: 0;
  border-radius: 0;
  overflow: hidden;
  transition: color 0.16s ease;
}

/* Активный пункт — кружок вокруг иконки (не широкая плашка, её обрезает рейка) */
body.hub-sidebar-rail .catalog-sidebar__link.is-active,
html.catalog-handoff-active .hub-handoff-root .catalog-sidebar__link.is-active {
  color: #fff;
  background: transparent !important;
}

body.hub-sidebar-rail .catalog-sidebar__link.is-active::before,
html.catalog-handoff-active .hub-handoff-root .catalog-sidebar__link.is-active::before {
  display: none !important;
  content: none !important;
}

body.hub-sidebar-rail .catalog-sidebar__link.is-active .catalog-sidebar__icon,
html.catalog-handoff-active .hub-handoff-root .catalog-sidebar__link.is-active .catalog-sidebar__icon {
  color: #7dd3fc;
  opacity: 1;
}

body.hub-sidebar-rail .catalog-sidebar__link.is-active .catalog-sidebar__icon::after,
html.catalog-handoff-active .hub-handoff-root .catalog-sidebar__link.is-active .catalog-sidebar__icon::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(28px * var(--catalog-sidebar-scale, 1));
  height: calc(28px * var(--catalog-sidebar-scale, 1));
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: rgba(56, 189, 248, 0.16);
  box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.35);
  pointer-events: none;
  z-index: 0;
}

body.hub-sidebar-rail .catalog-sidebar__link.is-active .catalog-sidebar__label,
html.catalog-handoff-active .hub-handoff-root .catalog-sidebar__link.is-active .catalog-sidebar__label {
  color: #7dd3fc;
}

/* Подсветка-пилюля — только под курсором, не шире рейки (не заезжает на фильтры) */
body.hub-sidebar-rail .catalog-sidebar__link:hover,
body.hub-sidebar-rail .catalog-sidebar__link:focus-visible,
html.catalog-handoff-active .hub-handoff-root .catalog-sidebar__link:hover,
html.catalog-handoff-active .hub-handoff-root .catalog-sidebar__link:focus-visible {
  color: #fff;
  background: transparent !important;
}

body.hub-sidebar-rail .catalog-sidebar__link:hover::before,
body.hub-sidebar-rail .catalog-sidebar__link:focus-visible::before,
html.catalog-handoff-active .hub-handoff-root .catalog-sidebar__link:hover::before,
html.catalog-handoff-active .hub-handoff-root .catalog-sidebar__link:focus-visible::before {
  content: "";
  position: absolute;
  left: 6px;
  right: 8px;
  top: 2px;
  bottom: 2px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  z-index: 0;
  pointer-events: none;
}

body.hub-sidebar-rail .catalog-sidebar__link:hover .catalog-sidebar__icon,
body.hub-sidebar-rail .catalog-sidebar__link:hover .catalog-sidebar__label,
body.hub-sidebar-rail .catalog-sidebar__link:focus-visible .catalog-sidebar__icon,
body.hub-sidebar-rail .catalog-sidebar__link:focus-visible .catalog-sidebar__label,
html.catalog-handoff-active .hub-handoff-root .catalog-sidebar__link:hover .catalog-sidebar__icon,
html.catalog-handoff-active .hub-handoff-root .catalog-sidebar__link:hover .catalog-sidebar__label,
html.catalog-handoff-active .hub-handoff-root .catalog-sidebar__link:focus-visible .catalog-sidebar__icon,
html.catalog-handoff-active .hub-handoff-root .catalog-sidebar__link:focus-visible .catalog-sidebar__label {
  position: relative;
  z-index: 1;
}

html.catalog-theme-biz body.hub-sidebar-rail .catalog-sidebar__link:hover,
html.catalog-theme-biz body.hub-sidebar-rail .catalog-sidebar__link:focus-visible,
html.catalog-theme-biz.catalog-handoff-active .hub-handoff-root .catalog-sidebar__link:hover,
html.catalog-theme-biz.catalog-handoff-active .hub-handoff-root .catalog-sidebar__link:focus-visible {
  color: rgba(15, 23, 42, 0.92);
  background: transparent !important;
}

html.catalog-theme-biz body.hub-sidebar-rail .catalog-sidebar__link:hover::before,
html.catalog-theme-biz body.hub-sidebar-rail .catalog-sidebar__link:focus-visible::before,
html.catalog-theme-biz.catalog-handoff-active .hub-handoff-root .catalog-sidebar__link:hover::before,
html.catalog-theme-biz.catalog-handoff-active .hub-handoff-root .catalog-sidebar__link:focus-visible::before {
  background: rgba(15, 23, 42, 0.06);
}

html.catalog-theme-biz body.hub-sidebar-rail .catalog-sidebar__link.is-active .catalog-sidebar__icon,
html.catalog-theme-biz.catalog-handoff-active .hub-handoff-root .catalog-sidebar__link.is-active .catalog-sidebar__icon {
  background: transparent;
  box-shadow: none;
  color: rgb(2, 132, 199);
}

html.catalog-theme-biz body.hub-sidebar-rail .catalog-sidebar__link.is-active .catalog-sidebar__icon::after,
html.catalog-theme-biz.catalog-handoff-active .hub-handoff-root .catalog-sidebar__link.is-active .catalog-sidebar__icon::after {
  background: rgba(14, 165, 233, 0.12);
  box-shadow: inset 0 0 0 1px rgba(14, 165, 233, 0.35);
}

html.catalog-theme-biz body.hub-sidebar-rail .catalog-sidebar__link.is-active .catalog-sidebar__label,
html.catalog-theme-biz.catalog-handoff-active .hub-handoff-root .catalog-sidebar__link.is-active .catalog-sidebar__label {
  color: rgb(2, 132, 199);
}

body.hub-sidebar-rail .catalog-sidebar__icon,
html.catalog-handoff-active .hub-handoff-root .catalog-sidebar__icon {
  position: relative;
  flex: 0 0 var(--catalog-sidebar-w-collapsed);
  width: var(--catalog-sidebar-w-collapsed) !important;
  height: calc(28px * var(--catalog-sidebar-scale, 1)) !important;
  margin: 0 !important;
  display: grid;
  place-items: center;
  opacity: 0.88;
}

body.hub-sidebar-rail .catalog-sidebar__link:hover .catalog-sidebar__icon,
body.hub-sidebar-rail .catalog-sidebar__link.is-active .catalog-sidebar__icon,
html.catalog-handoff-active .hub-handoff-root .catalog-sidebar__link:hover .catalog-sidebar__icon,
html.catalog-handoff-active .hub-handoff-root .catalog-sidebar__link.is-active .catalog-sidebar__icon {
  opacity: 1;
}

body.hub-sidebar-rail .catalog-sidebar__icon svg,
html.catalog-handoff-active .hub-handoff-root .catalog-sidebar__icon svg {
  position: relative;
  z-index: 1;
  width: calc(15px * var(--catalog-sidebar-scale, 1)) !important;
  height: calc(15px * var(--catalog-sidebar-scale, 1)) !important;
}

/* Подписи — инлайн, выезжают при раскрытии рейки */
body.hub-sidebar-rail .catalog-sidebar__label,
html.catalog-handoff-active .hub-handoff-root .catalog-sidebar__label {
  display: block !important;
  position: static !important;
  transform: none !important;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 0;
  padding: 0 !important;
  border: none !important;
  border-radius: 0;
  background: transparent !important;
  box-shadow: none !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  letter-spacing: 0.01em;
  text-transform: none !important;
  color: inherit !important;
  overflow: hidden;
  opacity: 0;
  visibility: visible !important;
  white-space: nowrap;
  pointer-events: none;
  transition:
    max-width 0.22s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.16s ease;
}

body.hub-sidebar-rail .catalog-sidebar:hover .catalog-sidebar__label,
body.hub-sidebar-rail .catalog-sidebar.is-expanded .catalog-sidebar__label,
html.catalog-handoff-active .hub-handoff-root .catalog-sidebar:hover .catalog-sidebar__label,
html.catalog-handoff-active .hub-handoff-root .catalog-sidebar.is-expanded .catalog-sidebar__label {
  max-width: 140px !important;
  opacity: 1 !important;
  visibility: visible !important;
}

/* Сброс после клика / SPA-перехода — подписи не торчат поверх контента */
body.hub-sidebar-rail .hub-handoff-root .catalog-sidebar:not(:hover):not(.is-expanded) .catalog-sidebar__label,
html.catalog-handoff-active .hub-handoff-root .catalog-sidebar:not(:hover):not(.is-expanded) .catalog-sidebar__label,
body.hub-sidebar-rail .catalog-sidebar:focus-within:not(:hover):not(.is-expanded) .catalog-sidebar__label,
html.catalog-handoff-active .hub-handoff-root .catalog-sidebar:focus-within:not(:hover):not(.is-expanded) .catalog-sidebar__label {
  max-width: 0 !important;
  opacity: 0 !important;
}

body.hub-sidebar-rail .hub-handoff-root .catalog-sidebar:not(:hover):not(.is-expanded),
html.catalog-handoff-active .hub-handoff-root .catalog-sidebar:not(:hover):not(.is-expanded) {
  width: var(--catalog-sidebar-w-collapsed) !important;
}

/* Корзина: overflow:hidden у .link иначе срезает бейдж (handoff ставит right:-4px). */
body.hub-sidebar-rail .catalog-sidebar__link--cart,
html.catalog-handoff-active .hub-handoff-root .catalog-sidebar__link--cart {
  overflow: visible !important;
}

body.hub-sidebar-rail .catalog-sidebar__badge,
body.hub-sidebar-rail .catalog-sidebar__link--cart .catalog-sidebar__badge,
body.hub-sidebar-rail .catalog-sidebar.is-collapsed .catalog-sidebar__badge,
html.catalog-handoff-active .hub-handoff-root .catalog-sidebar__badge,
html.catalog-handoff-active .hub-handoff-root .catalog-sidebar__link--cart .catalog-sidebar__badge,
html.catalog-handoff-active .hub-handoff-root .catalog-sidebar.is-collapsed .catalog-sidebar__badge {
  position: absolute;
  top: 2px;
  right: 2px;
  left: auto;
  margin-left: 0;
  box-sizing: border-box;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 0.7rem;
  line-height: 18px;
  z-index: 2;
}

/* catalog-handoff.css (toggle-модель) прячет подписи/лого при is-collapsed */
body.hub-sidebar-rail .catalog-sidebar.is-collapsed .catalog-sidebar__label,
html.catalog-handoff-active .hub-handoff-root .catalog-sidebar.is-collapsed .catalog-sidebar__label {
  display: block !important;
}

body.hub-sidebar-rail .catalog-sidebar.is-collapsed .catalog-sidebar__head,
html.catalog-handoff-active .hub-handoff-root .catalog-sidebar.is-collapsed .catalog-sidebar__head,
body.hub-sidebar-rail .catalog-sidebar__head,
html.catalog-handoff-active .hub-handoff-root .catalog-sidebar__head {
  display: none !important;
}

/* Узкий экран: hover не раскрывает; .is-expanded (tap) — да */
@media (max-width: 720px) {
  body.hub-sidebar-rail .catalog-sidebar:hover:not(.is-expanded),
  html.catalog-handoff-active .hub-handoff-root .catalog-sidebar:hover:not(.is-expanded) {
    width: var(--catalog-sidebar-w-collapsed) !important;
    padding-inline: 0 !important;
  }

  body.hub-sidebar-rail .catalog-sidebar,
  html.catalog-handoff-active .hub-handoff-root .catalog-sidebar {
    padding-inline: 0 !important;
  }

  body.hub-sidebar-rail .catalog-sidebar:hover:not(.is-expanded) .catalog-sidebar__label,
  html.catalog-handoff-active .hub-handoff-root .catalog-sidebar:hover:not(.is-expanded) .catalog-sidebar__label {
    max-width: 0 !important;
    opacity: 0 !important;
  }

  body.hub-sidebar-rail .catalog-sidebar__brand-logo,
  html.catalog-handoff-active .hub-handoff-root .catalog-sidebar__brand-logo {
    height: 41px;
  }
}
