:root {
  --surface-page: #f5f5f7;
  --surface-card: #ffffff;
  --surface-elevated: #fff;
  --radius-card: 16px;
  --radius-product: 22px;
  --radius-configurator: 24px;
  --radius-sheet: 20px;
  --radius-swatch: 50%;
  --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.08), 0 10px 24px rgba(15, 23, 42, 0.04);
  --shadow-product: 0 1px 2px rgba(15, 23, 42, 0.08), 0 16px 40px rgba(15, 23, 42, 0.04);
  --shadow-sheet: 0 18px 40px rgba(0, 0, 0, 0.22);
  --color-text-primary: #1d1d1f;
  --color-text-muted: #6e6e73;
  --color-surface-muted: #f5f5f7;
  --color-border-subtle: #e8e8ed;
  --color-accent: #0071e3;
  --preview-dark-bg: #050505;
  /* Модальные оверлеи: затемнение фона — для не-topbar сценариев; шапка использует прозрачный слой */
  --overlay-backdrop-tint: rgba(13, 18, 24, 0.4);
  --topbar-overlay-backdrop-tint: transparent;
  --glass-overlay-bg: rgba(255, 255, 255, 0.55);
  --glass-overlay-bg-opaque: rgba(252, 252, 254, 0.94);
  --glass-overlay-border: rgba(255, 255, 255, 0.36);
  --glass-overlay-blur: 20px;
  --glass-overlay-shadow: 0 28px 70px rgba(6, 10, 18, 0.28);
  --glass-row-hover: rgba(255, 255, 255, 0.42);
  --glass-row-active: rgba(255, 255, 255, 0.68);
  --glass-divider: rgba(20, 24, 32, 0.12);
  --glass-handle: rgba(20, 24, 32, 0.2);
}

.app {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  color: #1d1d1f;
  background: #f5f5f7;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  padding-top: calc(env(safe-area-inset-top, 0) + 21px);
  box-sizing: border-box;
}

:root {
  /* Motion (ШАГ 3.3): единые длительности / easing для UI + gallery */
  --ease-out-apple: cubic-bezier(0.22, 0.61, 0.36, 1);
  --motion-ease-gallery: cubic-bezier(0.22, 1, 0.36, 1);
  --motion-duration-instant: 60ms;
  --motion-duration-short: 140ms;
  --motion-duration-tap: 160ms;
  --motion-duration-medium: 180ms;
  --motion-duration-gallery: 180ms;
  --motion-list-fade-duration: 160ms;
  --motion-list-translate-y: 4px;
  --motion-menu-slide-x: 6px;
  /* Perceived-quality / overlays (app_motion_polish.md): единые dismiss + surface + reveal */
  --motion-overlay-dismiss: 175ms;
  --motion-overlay-backdrop-fade: 190ms;
  --motion-overlay-backdrop-delay: 72ms;
  --motion-surface-shift: 220ms;
  --motion-interior-reveal-primary: 225ms;
  --motion-spotlight-list-reveal: 240ms;
  --motion-product-card-enter: 200ms;
  --motion-polish-fade-y: 8px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  gap: 8px;
  background: #f5f5f7;
  border-bottom: 1px solid #e8e8ed;
  min-width: 0;
  overflow: visible;
}

.brand {
  font-weight: 600;
  white-space: nowrap;
  font-size: 17px;
  line-height: 1;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  flex: 0 0 auto;
  flex-shrink: 0;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid #d2d2d7;
  background: #fff;
  color: #1d1d1f;
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  flex: 0 0 auto;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.icon-btn:hover {
  border-color: #b9b9c0;
  background: #fafafa;
}

.icon-btn:focus-visible {
  outline: 2px solid rgba(0, 113, 227, 0.45);
  outline-offset: 1px;
}

#btnSearch {
  font-size: 24px;
}

.icon-btn--primary {
  border-color: #0071e3;
  background: #f0f7ff;
  color: #0071e3;
}

.icon-btn:active {
  transform: scale(0.96);
}

@media (max-width: 380px) {
  .topbar {
    padding: 8px 8px;
    gap: 6px;
  }

  .brand {
    font-size: 15px;
    max-width: min(38vw, 200px);
  }

  .topbar-actions {
    gap: 3px;
    margin-left: 4px;
  }

  .icon-btn {
    width: 36px;
    height: 36px;
  }
}

.app__main {
  padding: 0 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel {
  background: #fff;
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.panel h2 {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 600;
}
.panel h3 {
  margin: 4px 0 8px;
  font-size: 14px;
  color: #6e6e73;
}

.home-screen {
  display: block;
}
.home-screen.hidden {
  display: none !important;
}

.content-screen {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  background: #f5f5f7;
}
.content-screen.hidden {
  display: none !important;
}
.content-screen__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid #e8e8ed;
  flex-shrink: 0;
}
.content-screen__back {
  flex-shrink: 0;
  padding: 8px 0;
  border: none;
  background: transparent;
  color: #0071e3;
  font-size: 16px;
  cursor: pointer;
}
.content-screen__title {
  /* Типографика: app_typography.css (.app-text--shell / токены) */
  flex: 1;
  min-width: 0;
}
.content-screen__body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 16px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

/* Wide premium layout for product/configurator cards:
   keep outer safe padding via .app__main, but remove extra inner side padding. */
.content-screen__body.content-screen__body--wide {
  padding-left: 0;
  padding-right: 0;
}

#content-screen-body.items-animate {
  animation: itemsFadeIn var(--motion-list-fade-duration) var(--ease-out-apple);
}

@keyframes itemsFadeIn {
  from {
    opacity: 0;
    transform: translateY(var(--motion-list-translate-y));
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.category-btn {
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  padding: 8px;
  background: #f9fafb;
  display: inline-flex;
  align-items: center;
  width: 100%;
  font-size: 14px;
}

.search-results {
  margin-top: 10px;
  max-height: 60vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cart-close {
  border: none;
  background: none;
  cursor: pointer;
  width: 40px;
  height: 40px;
  font-size: 22px;
  line-height: 1;
  color: #1d1d1f;
}

.cart-body {
  padding: 10px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
}
.menu-sheet::before {
  content: "";
  display: block;
  width: 28px;
  height: 3px;
  border-radius: 999px;
  background: var(--glass-handle);
  margin: 6px auto 2px;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(255, 255, 255, 0.35) inset;
}

.menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 0;
  padding: 2px 14px 6px;
  border-bottom: 1px solid var(--glass-divider);
  flex-shrink: 0;
  background: transparent;
  box-sizing: border-box;
}

.menu-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 30px;
  height: 30px;
  padding: 0 12px;
  font-size: 14px;
  font-weight: 500;
  color: #0a58b3;
  background: rgba(255, 255, 255, 0.38);
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
  -webkit-tap-highlight-color: transparent;
}

.menu-back:active {
  background: rgba(255, 255, 255, 0.58);
  transform: scale(0.98);
}

.menu-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  font-size: 16px;
  line-height: 1;
  color: #111827;
  background: rgba(255, 255, 255, 0.44);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  box-shadow: none;
  -webkit-tap-highlight-color: transparent;
}

.menu-close:active {
  transform: scale(0.94);
}
.menu-list {
  list-style: none;
  margin: 0;
  padding: 6px 8px 12px;
  overflow: auto;
  flex: 1;
}
.menu-list--root {
  font-size: 18px;
  line-height: 1.35;
  font-weight: 600;
  color: #111827;
}

@keyframes menuSlideIn {
  from {
    opacity: 0;
    transform: translateX(var(--motion-menu-slide-x));
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.empty-state {
  margin-top: 8px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #f5f5f7;
  color: #6e6e73;
  font-size: 14px;
  text-align: center;
}

.items-header {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 6px 0 8px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid #f0f0f5;
}

.items-header__inner {
  display: flex;
  align-items: center;
  gap: 6px;
}

.items-header__icon {
  font-size: 18px;
  width: 22px;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .menu-sheet,
  #items,
  #content-screen-body.items-animate,
  .menu-list,
  .item-card,
  .btn,
  .icon-btn,
  .apple-configurator__image,
  .product-image,
  .apple-configurator__image-wrap,
  .product-image-wrapper {
    animation: none !important;
    transition: none !important;
    transform: none !important;
  }
}
