/* Главная = каталог (вариант Б). Композиция: поиск → дерево | карточки */

body.library-catalog-home .library-main {
  padding: 20px 32px 80px;
}

body.library-catalog-home .library-explorer {
  padding: 0;
}

/* —— Панель: категории слева, сортировка справа —— */
.catalog-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px 24px;
  margin-bottom: 20px;
}

body.library-catalog-home .catalog-toolbar-categories {
  display: none;
}

body.library-catalog-home .catalog-toolbar {
  justify-content: flex-end;
  margin-bottom: 12px;
}

.catalog-toolbar-categories {
  flex: 1 1 auto;
  min-width: 0;
}

.catalog-toolbar-sort-wrap {
  position: relative;
  flex: 0 0 auto;
  margin-left: auto;
}

.catalog-sort-trigger.filter-figma::after {
  content: '▾';
}

.catalog-sort-sheet {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: auto;
  min-width: 200px;
  z-index: 40;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--lib-border, #e8e8e8);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.catalog-sort-sheet[hidden] {
  display: none !important;
}

@media (max-width: 768px) {
  .catalog-toolbar-sort-wrap {
    width: 100%;
    margin-left: 0;
    display: flex;
    justify-content: flex-end;
  }
}

.catalog-sort-menu {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px;
}

.catalog-sort-option {
  display: block;
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  font-weight: 400;
  text-align: left;
  color: #444;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}

.catalog-sort-option:hover {
  background: #f5f5f5;
  color: #111;
}

.catalog-sort-option.is-active {
  background: rgba(56, 110, 68, 0.08);
  color: #111;
  font-weight: 500;
}

.catalog-toolbar-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
}

.catalog-toolbar-label {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--lib-muted, #999);
  min-width: 72px;
}

.catalog-text-tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 28px;
}

.catalog-tab {
  position: relative;
  padding: 8px 0;
  font-size: 14px;
  font-family: inherit;
  font-weight: 400;
  color: var(--lib-muted, #666);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 140ms ease, border-color 140ms ease;
  white-space: nowrap;
}

.catalog-tab:hover {
  color: #111;
}

.catalog-tab.is-active {
  color: #111;
  font-weight: 500;
  border-bottom-color: #111;
}

body.library-catalog-home .sort-select--header {
  display: none;
}

.rvt-icon {
  display: block;
  flex-shrink: 0;
  color: currentColor;
}

.lib-nav-chevron-btn .rvt-icon {
  color: var(--lib-muted, #666);
}

/* —— Зона 1: статистика (поиск в header) —— */
.catalog-top {
  margin-bottom: 12px;
}

body.library-catalog-home .catalog-header-search {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  max-width: 720px;
}

body.library-catalog-home .header-inner.header-ozon .header-row-mid {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 720px;
}

body.library-catalog-home .header-inner.header-ozon .header-search {
  border-width: 1px;
  border-color: var(--lib-border, #e8e8e8);
  border-radius: 12px;
  height: 44px;
}

body.library-catalog-home .header-inner.header-ozon .header-search:focus-within {
  border-color: #bbb;
  box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.04);
}

body.library-catalog-home .header-inner.header-ozon .header-search .search-input {
  font-size: 15px;
}

body.library-catalog-home .catalog-header-search .spotlight-dropdown,
body.library-catalog-home .catalog-header-search .library-search-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 8px);
  z-index: 120;
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.1);
}

body.library-catalog-home .site-header.library-header {
  position: sticky;
  top: 0;
  z-index: 200;
}

.catalog-stats {
  margin: 0;
  font-size: 13px;
  color: var(--lib-muted, #666);
}

.catalog-stats strong {
  color: #111;
  font-weight: 600;
}

body.library-catalog-home .library-layout {
  grid-template-columns: 248px minmax(0, 1fr);
  gap: 32px;
}

body.library-catalog-home .library-main {
  padding: 16px 28px 48px;
}

body.library-catalog-home .library-nav {
  top: 72px;
  padding-right: 4px;
  border-right: none;
}

.lib-nav-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  color: #aaa;
}

.lib-nav-row {
  padding: 9px 10px;
  font-size: 13px;
  border-radius: 8px;
}

.lib-nav-row.is-active {
  background: rgba(56, 110, 68, 0.06);
}

.lib-nav-row.is-active::before {
  width: 2px;
  background: var(--lib-green, #386e44);
}

.lib-nav-count {
  font-size: 11px;
  color: #bbb;
}

.catalog-context-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0 0 16px;
}

.catalog-highlights {
  gap: 24px;
  margin-bottom: 24px;
}

body.library-catalog-home .results-count {
  display: none;
}

@media (max-width: 960px) {
  body.library-catalog-home .library-layout {
    grid-template-columns: 1fr;
  }
}

.catalog-strip-scroll {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 4px;
  scroll-snap-type: x mandatory;
}


/* —— Крошки только при глубине —— */
.library-breadcrumbs--deep {
  margin-bottom: 12px;
  font-size: 13px;
}

.catalog-context-title {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 16px;
}

/* —— Живые полоски —— */
.catalog-highlights {
  display: flex;
  flex-direction: column;
  gap: 28px;
  margin-bottom: 24px;
}

.catalog-highlights[hidden] {
  display: none !important;
}

.catalog-strip-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}

.catalog-strip-head h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.catalog-strip-scroll {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 4px;
  scroll-snap-type: x mandatory;
}

.catalog-strip-scroll .library-card--compact {
  flex: 0 0 200px;
  scroll-snap-align: start;
}

.library-card--compact .library-card-media {
  aspect-ratio: 1 / 1;
}

.library-card--compact .library-card-body {
  padding: 10px 12px 12px;
  gap: 4px;
}

.library-card--compact .library-card-title {
  font-size: 13px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.library-card--compact .library-card-author,
.library-card--compact .library-card-specs,
.library-card--compact .library-card-stats,
.library-card--compact .library-card-date,
.library-card--compact .library-card-trust-micro,
.library-card--compact .library-card-actions {
  display: none;
}

.library-card--compact .library-card-meta {
  margin: 0;
}

.library-card--compact .library-card-price {
  font-size: 14px;
}

.library-card--compact .library-card-badges {
  top: 6px;
  left: 6px;
}

.library-card--compact .library-card-badge {
  font-size: 9px;
  padding: 2px 6px;
}

/* —— Фильтры Figma-style —— */
.catalog-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 20px;
  margin-bottom: 16px;
  position: relative;
}

.filter-figma {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 400;
  color: #444;
  background: #fff;
  border: 1px solid #e8e8e8;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 140ms ease, color 140ms ease;
}

.filter-figma::after {
  content: '▾';
  font-size: 10px;
  opacity: 0.5;
}

.filter-figma--check::after,
.filter-figma--quiet::after {
  content: none;
}

.filter-figma:hover,
.filter-figma.is-open {
  border-color: #ccc;
  color: #111;
}

.filter-figma.has-value {
  color: #111;
  font-weight: 500;
  border-color: #bbb;
}

.filter-figma--check {
  cursor: pointer;
  user-select: none;
}

.filter-figma--check input {
  margin: 0 4px 0 0;
  accent-color: var(--lib-green, #386e44);
}

.filter-figma--quiet.has-value {
  font-weight: 600;
  color: var(--lib-green, #386e44);
}

.catalog-filters .filter-sheet {
  top: calc(100% + 4px);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
}

/* —— Browse Mode: Behance / Apple Store —— */
body.library-catalog-home #product-grid.browse-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 28px;
  width: 100%;
  justify-items: stretch;
  align-content: start;
}

body.library-catalog-home #product-grid.browse-grid .browse-card {
  max-width: none;
}

.browse-grid {
  display: grid;
  gap: 28px;
  width: 100%;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.browse-card {
  display: flex;
  flex-direction: column;
  height: 360px;
  max-width: 300px;
  width: 100%;
  justify-self: stretch;
  background: #fff;
  border: 1px solid #eee;
  border-radius: 12px;
  overflow: hidden;
  transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease;
}

.browse-card:hover {
  transform: translateY(-3px) scale(1.02);
  border-color: #e0e0e0;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.07);
}

.browse-card-media {
  position: relative;
  flex: 0 0 70%;
  min-height: 0;
  background: #fff;
  overflow: hidden;
}

.browse-card-media-link {
  display: block;
  position: absolute;
  inset: 0;
  text-decoration: none;
  color: inherit;
}

.browse-card-media-link:focus-visible {
  outline: 2px solid var(--primary, #1a5f4a);
  outline-offset: -2px;
}

.browse-card-stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.browse-card-stage img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  transition: transform 200ms ease;
}

.browse-card-quick {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%) translateY(6px);
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  color: #111;
  background: #fff;
  border: 1px solid #e8e8e8;
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease, transform 150ms ease;
  white-space: nowrap;
  z-index: 2;
}

.browse-card:hover .browse-card-quick {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.browse-card-fav {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid #ebebeb;
  background: rgba(255, 255, 255, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 3;
}

.browse-card-body {
  flex: 1;
  min-height: 0;
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-decoration: none;
  color: inherit;
}

.browse-card-title {
  margin: 0 0 6px;
  flex: 0 0 auto;
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.01em;
  color: #111;
  display: block;
  overflow: hidden;
  max-height: 2.7em;
  word-break: break-word;
}

.browse-card-meta {
  margin-top: auto;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.browse-card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.browse-card-price {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.browse-card-price.is-free {
  color: var(--lib-green, #386e44);
}

.browse-card-revit {
  margin: 0;
  font-size: 11px;
  color: var(--lib-muted, #888);
}

.browse-card-author {
  margin: 0;
  font-size: 11px;
  color: var(--lib-muted, #666);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.browse-card-verified {
  font-size: 10px;
  font-weight: 600;
  color: var(--lib-green, #386e44);
  white-space: nowrap;
}

.browse-card-verified--official {
  color: #111;
}

/* Быстрый просмотр */
.quick-preview-modal[hidden] {
  display: none !important;
}

.quick-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.quick-preview-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.quick-preview-dialog {
  position: relative;
  z-index: 1;
  width: min(920px, 96vw);
  max-height: 90vh;
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.18);
}

.quick-preview-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.quick-preview-media {
  background: #f5f5f5;
  min-height: 360px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.quick-preview-stage {
  width: 88%;
  height: 88%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.quick-preview-stage img {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
}

.quick-preview-info {
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.quick-preview-info h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.quick-preview-info p {
  margin: 0;
  font-size: 14px;
  color: var(--lib-muted, #666);
}

.quick-preview-update {
  padding: 12px 14px;
  background: #f7f8fa;
  border: 1px solid #eceef2;
  border-radius: 10px;
}

.quick-preview-update-label {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #8b919a;
}

.quick-preview-update-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: #222;
  white-space: pre-wrap;
}

.btn-quick-preview-open {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: auto;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  color: #fff;
  background: #111;
  border-radius: 10px;
  transition: background 140ms ease;
}

.btn-quick-preview-open:hover {
  background: #333;
}

body.quick-preview-open {
  overflow: hidden;
}

/* Полоски подборок */
.catalog-strip-scroll .browse-card {
  flex: 0 0 220px;
  max-width: 220px;
  height: 300px;
  scroll-snap-align: start;
}

@media (max-width: 1279px) {
  body.library-catalog-home #product-grid.browse-grid,
  .browse-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 24px;
  }
}

@media (max-width: 1023px) {
  body.library-catalog-home #product-grid.browse-grid,
  .browse-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .browse-card {
    max-width: none;
  }

  .quick-preview-dialog {
    grid-template-columns: 1fr;
    max-height: 92vh;
    overflow-y: auto;
  }
}

@media (max-width: 640px) {
  .browse-grid {
    gap: 20px;
  }

  .browse-card {
    height: 360px;
  }
}

.catalog-author-mini {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 16px;
  min-width: 100px;
  text-decoration: none;
  color: inherit;
  border-radius: 10px;
  transition: background 140ms ease;
}

.catalog-author-mini:hover {
  background: #f5f5f5;
}

.catalog-author-mini img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--lib-border, #e8e8e8);
}

.catalog-author-mini span {
  font-size: 13px;
  font-weight: 500;
  text-align: center;
}

.catalog-author-mini small {
  font-size: 11px;
  color: var(--lib-muted, #666);
}

/* Inline editor в каталоге (админ) */
body.can-catalog-inline-edit .browse-card--editable {
  cursor: pointer;
}

body.can-catalog-inline-edit .browse-card--editable:hover {
  border-color: #c7d2fe;
  box-shadow: 0 8px 24px rgba(79, 70, 229, 0.08);
}

.browse-card.is-editor-open {
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.browse-card-edit-hint {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  font-weight: 600;
  color: #6366f1;
}

.catalog-inline-editor-wrap {
  grid-column: 1 / -1;
  margin: -8px 0 12px;
}

.catalog-inline-editor {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.08);
}

.catalog-inline-editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: #f8fafc;
  border-bottom: 1px solid #e5e7eb;
}

.catalog-inline-editor-title {
  font-size: 14px;
  font-weight: 700;
}

.catalog-inline-editor-close {
  width: 32px;
  height: 32px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: #6b7280;
}

.catalog-inline-editor-body {
  padding: 16px;
}

.catalog-inline-editor-body .model-product-editor-inner.is-compact .model-editor-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 900px) {
  .catalog-inline-editor-body .model-product-editor-inner.is-compact .model-editor-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .catalog-inline-editor-body .model-product-editor-inner.is-compact .model-editor-grid {
    grid-template-columns: 1fr;
  }
}
