* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  overflow-x: hidden;
}

body {
  font-family: 'Raleway', -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: #fafafa;
  color: #2c2e31;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ═══ ПРЕЛОАДЕР ═══ */
#preloader {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: #fafafa;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}
#preloader.hidden {
  opacity: 0;
  visibility: hidden;
}
.preloader-bg {
  position: absolute;
  inset: 0;
  background-image: url('assets/bg-1.webp');
  background-size: cover;
  background-position: center;
  filter: blur(20px);
  opacity: 0.4;
  z-index: 0;
  transform: scale(1.1);
}
.preloader-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}
.preloader-logo {
  height: 40px;
  width: auto;
  opacity: 0.8;
}
.preloader-bar-wrap {
  width: 200px;
  height: 4px;
  background: rgba(44, 46, 49, 0.1);
  border-radius: 2px;
  overflow: hidden;
}
.preloader-bar {
  width: 0%;
  height: 100%;
  background: #2c2e31;
  border-radius: 2px;
  transition: width 0.4s ease;
}
.preloader-text {
  font-size: 12px;
  color: #4a4d52;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
}

/* ═══ КНОПКА "НАВЕРХ" ═══ */
.scroll-top-btn {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #ffffff;
  color: #4a4d52;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(120, 125, 130, 0.15), 0 1px 4px rgba(120, 125, 130, 0.1);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all 0.3s ease;
  z-index: 9999;
}
.scroll-top-btn:hover {
  background: #f8f9fa;
  box-shadow: 0 6px 20px rgba(120, 125, 130, 0.2);
  transform: translateY(-2px);
}
.scroll-top-btn.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* ═══ LAYOUT ═══ */
.app-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 24px;
  min-height: calc(100vh - 48px);
  padding: 24px;
  align-items: stretch;
}

/* ─── САЙДБАР ─── */
.sidebar {
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-radius: 4px;
  overflow: hidden;
  height: 100%;
  box-shadow: 0 4px 24px rgba(120, 125, 130, 0.08), 0 1px 3px rgba(120, 125, 130, 0.04);
}

.sidebar-header { padding: 24px 20px 20px; flex-shrink: 0; }

.sidebar-logo-link {
  display: inline-block;
  margin-bottom: 16px;
  line-height: 0;
  border-radius: 4px;
  transition: opacity 0.15s;
}
.sidebar-logo-link:hover { opacity: 0.75; }
.sidebar-logo { display: block; height: 28px; width: auto; }

.sidebar-desc { font-size: 12px; color: #5a5d62; line-height: 1.5; margin-top: 8px; }

.sidebar-menu {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  font-size: 12px;
}
.sidebar-menu a {
  color: #4a4d52;
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.sidebar-menu a:hover {
  color: #d4a373;
  border-bottom-color: #d4a373;
}
.sidebar-menu-sep { color: #c8cbce; }

/* Скролл-зона */
.sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 20px 20px;
  min-height: 0;
}
.sidebar-body::-webkit-scrollbar { width: 6px; }
.sidebar-body::-webkit-scrollbar-thumb { background: #dfe2e5; border-radius: 3px; }
.sidebar-body::-webkit-scrollbar-track { background: transparent; }

/* Группы */
.slot-group { margin-bottom: 28px; }
.slot-group:last-child { margin-bottom: 0; }
.slot-group-title { font-size: 14px; font-weight: 600; color: #2c2e31; margin-bottom: 4px; }
.slot-group-desc { font-size: 12px; color: #8a8d91; margin-bottom: 16px; line-height: 1.4; }

/* Слоты декоров */
#slots-deck { display: flex; flex-direction: column; gap: 12px; }

/* Подсветка активного слота */
.slot { 
  position: relative; 
  transition: box-shadow 0.2s, background 0.2s; 
  padding: 6px; 
  border-radius: 8px; 
  margin: -6px; 
}

.slot.is-active { 
  background: #ffffff; 
  box-shadow: 
    0 0 0 1px rgba(44, 46, 49, 0.1), 
    0 4px 16px rgba(120, 125, 130, 0.15), 
    0 0 0 4px rgba(120, 125, 130, 0.08); 
}

.slot label { display: block; font-size: 10px; color: #9a9da1; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 6px; font-weight: 600; }

.combo {
  position: relative; display: flex; align-items: center; background: #ffffff;
  border-radius: 4px; box-shadow: 0 0 0 1px rgba(0,0,0,0.03), 0 2px 8px rgba(120, 125, 130, 0.08);
  transition: box-shadow 0.2s; cursor: text; width: 100%;
}
.combo:hover { box-shadow: 0 0 0 1px rgba(0,0,0,0.05), 0 4px 12px rgba(120, 125, 130, 0.12); }
.combo:focus-within { box-shadow: 0 0 0 2px rgba(120, 125, 130, 0.15), 0 4px 12px rgba(120, 125, 130, 0.12); }

.combo-icon {
  width: 24px; height: 24px; border-radius: 2px; background-size: cover;
  background-position: center; background-color: #e8eaec; margin-left: 8px; flex-shrink: 0;
}

.combo-input {
  width: 100%; padding: 10px 12px; font-size: 13px; background: transparent;
  border: none; outline: none; font-family: inherit; color: #2c2e31;
}
.combo-input::placeholder { color: #b4b7bb; }

.combo-list {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: #ffffff;
  border-radius: 4px; max-height: 240px; overflow-y: auto; z-index: 2000;
  box-shadow: 0 10px 40px rgba(120, 125, 130, 0.15);
}

.opt {
  display: flex; gap: 10px; align-items: center; padding: 8px 12px;
  cursor: pointer; font-size: 12px; transition: background 0.15s;
}
.opt:hover { background: #f8f9fa; }
.opt img { width: 32px; height: 32px; object-fit: cover; border-radius: 2px; flex-shrink: 0; }
.opt.empty { color: #b4b7bb; justify-content: center; padding: 18px; }

.cozy-options { display: flex; gap: 8px; flex-wrap: wrap; }
.cozy-btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px;
  background: #ffffff; border-radius: 4px; cursor: pointer; font-size: 13px; color: #4a4d52;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.03), 0 2px 8px rgba(120, 125, 130, 0.08);
  transition: all 0.2s; user-select: none;
}
.cozy-btn:hover { box-shadow: 0 0 0 1px rgba(0,0,0,0.05), 0 4px 12px rgba(120, 125, 130, 0.12); }
.cozy-btn input { display: none; }
.cozy-btn:has(input:checked) { background: #2c2e31; box-shadow: inset 0 2px 4px rgba(0,0,0,0.15); color: #ffffff; font-weight: 600; }

.sidebar-actions { flex-shrink: 0; padding: 20px; background: #ffffff; }
.btn-save {
  width: 100%; padding: 12px 16px; border: none; border-radius: 4px; font-weight: 600; cursor: pointer; font-size: 13px;
  background: #ffffff; color: #4a4d52; box-shadow: 0 0 0 1px rgba(0,0,0,0.03), 0 2px 8px rgba(120, 125, 130, 0.10);
}
.btn-save:hover { background: #f8f9fa; box-shadow: 0 0 0 1px rgba(0,0,0,0.05), 0 4px 16px rgba(120, 125, 130, 0.15); transform: translateY(-1px); }

/* ═══ СЦЕНА ═══ */
.stage-wrap { display: flex; flex-direction: column; min-width: 0; height: 100%; overflow: hidden; }
.stage-outer {
  width: 100%; height: 100%; margin: 0 auto; position: relative;
  background-color: #f4f4f4; background-image: url('assets/bg-1.webp');
  background-size: cover; background-repeat: no-repeat; background-position: center center;
  border-radius: 4px; box-shadow: 0 4px 30px rgba(120, 125, 130, 0.10);
  overflow: hidden; display: flex; align-items: center; justify-content: center;
}
#stage { position: relative; background: transparent; transform-origin: top left; }

.sample {
  position: absolute; cursor: grab; user-select: none; outline: none; z-index: 10;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.4), inset 0 -1px 0 rgba(0,0,0,0.3), inset 1px 0 0 rgba(255,255,255,0.3), inset -1px 0 0 rgba(0,0,0,0.22), 0 1px 0 rgba(0,0,0,0.3), 0 3px 4px rgba(0,0,0,0.24), 0 6px 10px rgba(0,0,0,0.16), 0 14px 24px rgba(0,0,0,0.13), 0 30px 50px rgba(0,0,0,0.08);
}
.sample-clip {
  position: absolute; inset: 0; background-size: cover; background-position: center;
  background-repeat: no-repeat; overflow: hidden; z-index: 1;
}

.decor-wrapper {
  position: absolute; z-index: 50; opacity: 0; transition: opacity 0.3s; pointer-events: none;
}
.decor-wrapper.active { opacity: 1; pointer-events: auto; }
.decor-wrapper.selected { outline: 2px dashed #1a73e8; }

.decor-layer {
  width: 100%; height: 100%; object-fit: contain; pointer-events: none; display: block;
}

.sample-caption {
  position: absolute; z-index: 9999; pointer-events: none; width: 240px;
  background: rgba(255, 255, 255, 0.1); backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px);
  border-radius: 12px; padding: 20px; box-shadow: 0 4px 20px rgba(0,0,0,0.05);
}
.sample-caption.cap-left  { text-align: right; }
.sample-caption.cap-right { text-align: left; }

.caption-pointer {
  position: absolute; z-index: 9999; background: rgba(44, 46, 49, 0.55); pointer-events: none;
}
.caption-pointer .ptr-dot {
  position: absolute; width: 8px; height: 8px; border-radius: 50%;
  background: #2c2e31; border: 2px solid rgba(255, 255, 255, 0.8); box-sizing: border-box;
}

.caption-title { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.18em; color: #2c2e31; line-height: 1.3; margin-bottom: 6px; }
.caption-line { height: 1px; background: rgba(44, 46, 49, 0.3); width: 100%; margin-bottom: 12px; }
.caption-desc { font-size: 12px; line-height: 1.5; color: #4a4d52; }

/* ═══ КАТАЛОГ ═══ */
.catalog-section { padding: 64px 24px; max-width: 1400px; margin: 0 auto; }
.catalog-header { margin-bottom: 32px; text-align: center; }
.catalog-header h2 { font-size: 28px; font-weight: 600; color: #2c2e31; }

/* Табы выбора слота */
.slot-tabs {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.slot-tab {
  padding: 10px 20px;
  background: #ffffff;
  border: none;
  border-radius: 4px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: #4a4d52;
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(120, 125, 130, 0.10);
  transition: all 0.2s;
}
.slot-tab:hover {
  box-shadow: 0 4px 16px rgba(120, 125, 130, 0.16);
  transform: translateY(-1px);
}
.slot-tab.active {
  background: #2c2e31;
  color: #ffffff;
}
.slot-tab:active {
  transform: translateY(0);
}

.catalog-filter {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 10px;
  margin: 0 auto 40px; max-width: 900px;
}
.filter-btn {
  padding: 10px 20px; background: #ffffff; border: none; border-radius: 4px;
  font-family: inherit; font-size: 13px; font-weight: 600; color: #4a4d52; cursor: pointer;
  box-shadow: 0 2px 12px rgba(120, 125, 130, 0.10);
  transition: box-shadow 0.2s, background 0.2s, transform 0.15s;
}
.filter-btn:hover { box-shadow: 0 4px 16px rgba(120, 125, 130, 0.16); transform: translateY(-1px); }
.filter-btn.active { background: #2c2e31; color: #ffffff; }
.filter-btn:active { box-shadow: 0 6px 20px rgba(120, 125, 130, 0.22); transform: translateY(0); }

.catalog-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 48px; }
.catalog-card { display: flex; flex-direction: column; background: transparent; border-radius: 4px; cursor: pointer; }
.catalog-card-img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  background-color: #f4f5f6;
  border-radius: 4px;
  box-shadow: 0 2px 12px rgba(120, 125, 130, 0.10);
  transition: box-shadow 0.2s ease;
}
.catalog-card:hover .catalog-card-img {
  box-shadow: 0 4px 16px rgba(120, 125, 130, 0.16);
}
.catalog-card:active .catalog-card-img {
  box-shadow: 0 6px 20px rgba(120, 125, 130, 0.22);
}
.catalog-card-title { padding: 12px 4px; font-size: 12px; font-weight: 500; color: #2c2e31; line-height: 1.4; text-align: center; }

.catalog-more { text-align: center; }
.btn-load-more { padding: 14px 40px; background: #ffffff; border: none; border-radius: 4px; font-weight: 600; cursor: pointer; color: #4a4d52; font-size: 14px; box-shadow: 0 2px 12px rgba(120, 125, 130, 0.10); transition: all 0.2s; }
.btn-load-more:hover { background: #f8f9fa; box-shadow: 0 4px 16px rgba(120, 125, 130, 0.16); transform: translateY(-2px); }

/* ═══ ПОДВАЛ ═══ */
.site-footer { width: 100%; padding: 40px 24px; background: #fafafa; text-align: center; font-size: 13px; color: #8a8d91; }
.footer-content { display: flex; justify-content: center; align-items: center; gap: 12px; }
.footer-content span:first-child { font-weight: 600; color: #4a4d52; }

.resize-handle {
  position: absolute; right: -6px; bottom: -6px; width: 12px; height: 12px;
  background: #1a73e8; border: 2px solid #ffffff; border-radius: 50%; cursor: nwse-resize; z-index: 100;
}

/* ═══ АДАПТИВ ═══ */
@media (min-width: 769px) {
  #stage { position: absolute; width: 1600px; height: 900px; transform: scale(var(--stage-scale, 1)); }
}
@media (max-width: 768px) {
  .app-layout { grid-template-columns: 1fr; gap: 16px; padding: 16px; min-height: auto; }
  .sidebar { height: auto; position: static; max-height: none; }
  .sidebar-header { padding: 18px 16px 14px; }
  .sidebar-logo { height: 22px; }
  .sidebar-logo-link { margin-bottom: 12px; }
  .sidebar-desc { font-size: 11px; }
  .sidebar-body { padding: 0 16px 16px; max-height: none; overflow: visible; }
  .sidebar-actions { padding: 16px; }

  .stage-wrap { padding: 0; height: auto; overflow: visible; }
  .stage-outer {
    width: 100vw; height: auto; aspect-ratio: 1600 / 900;
    margin-left: calc(50% - 50vw); margin-right: calc(50% - 50vw);
    overflow: hidden; box-shadow: none; border-radius: 0;
    display: block; position: relative;
  }
  #stage {
    position: absolute; width: 1600px; height: 900px;
    transform: scale(var(--stage-scale, 1)); transform-origin: top left;
    left: 0; top: 0;
  }

  .sample-caption, .caption-pointer { display: none !important; }

  .slot-tabs { padding: 0 16px; gap: 6px; margin-bottom: 16px; }
  .slot-tab { padding: 8px 14px; font-size: 12px; }

  .catalog-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; padding: 0 16px; }
  .catalog-filter { padding: 0 16px; gap: 8px; }
  .filter-btn { padding: 8px 14px; font-size: 12px; }

  .scroll-top-btn {
    bottom: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
  }
}