:root {
  --apex-font: Inter, "Segoe UI", Arial, sans-serif;
  --apex-bg: #f3f6fa;
  --apex-surface: #ffffff;
  --apex-text: #15171a;
  --apex-muted: #60666d;
  --apex-border: #d8dde3;
  --apex-accent: #2457e6;
  --apex-danger: #b42318;
  --apex-success: #157347;
  --apex-radius-sm: 8px;
  --apex-radius-md: 12px;
  --apex-radius-lg: 16px;
  --apex-control-height: 48px;
  --apex-container: 1200px;
  --apex-space-1: 4px;
  --apex-space-2: 8px;
  --apex-space-3: 12px;
  --apex-space-4: 16px;
  --apex-space-5: 20px;
  --apex-space-6: 24px;
  --apex-space-8: 32px;
  --apex-space-10: 40px;
  --apex-space-12: 48px;
  --apex-space-16: 64px;
  --apex-space-20: 80px;
  --apex-shadow: 0 10px 30px rgba(20, 28, 38, 0.08);
  --apex-shadow-hover: 0 16px 38px rgba(20, 28, 38, 0.12);
  --apex-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; overflow-x: clip; }
body { color: var(--apex-text); overflow-x: clip; font-family: var(--apex-font) !important; font-size: 16px; line-height: 1.6; text-rendering: optimizeLegibility; }
body { transition: opacity 180ms ease, transform 180ms var(--apex-ease); }
body.apex-ui-ready { opacity: 1 !important; }
body.apex-page-exit { opacity: 0 !important; transform: translateY(-4px); pointer-events: none; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; }

/* Shared visual system: compact headings, readable copy, and predictable controls. */
:where(h1, h2, h3, h4) { margin-top: 0; color: inherit; font-family: var(--apex-font) !important; text-wrap: balance; }
:where(h1) { line-height: 1.08 !important; letter-spacing: -.035em; }
:where(h2) { line-height: 1.2 !important; letter-spacing: -.025em; }
:where(h3, h4) { line-height: 1.3 !important; letter-spacing: -.015em; }
:where(p, li) { line-height: 1.6; }
:where(small, .product-category, .fallback-category) { line-height: 1.45; }
::selection { color: #fff; background: var(--apex-accent); }

:where(input:not([type="checkbox"]):not([type="radio"]), select, textarea) {
  min-height: var(--apex-control-height);
  padding: 11px 14px;
  color: var(--apex-text);
  background-color: var(--apex-surface);
  border: 1px solid var(--apex-border);
  border-radius: 8px !important;
  transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}
:where(input, textarea)::placeholder { color: #818891; opacity: 1; }
:where(input:not([type="checkbox"]):not([type="radio"]), select, textarea):focus {
  border-color: var(--apex-accent);
  box-shadow: 0 0 0 3px rgba(36, 87, 230, .14);
}
textarea { min-height: 132px; resize: vertical; }

:where(.hero-btn, .checkout-btn, .view-order-btn, .add-to-cart, .buy-now, .back-to-shop-btn,
  .load-more, .load-more-btn, #load-more-btn, .login-box button, .login-button, .submit-btn,
  .newsletter-input button, .fallback-add, .fallback-favorite, .demo-profile-btn) {
  min-height: var(--apex-control-height) !important;
  padding: 11px 20px !important;
  border-radius: 8px !important;
  font-family: var(--apex-font) !important;
  font-size: 15px !important;
  font-weight: 650 !important;
  line-height: 1.2 !important;
  letter-spacing: .005em;
  cursor: pointer;
  transition: transform 160ms var(--apex-ease), box-shadow 160ms var(--apex-ease), background-color 160ms ease, border-color 160ms ease, color 160ms ease !important;
}
:where(.hero-btn, .checkout-btn, .view-order-btn, .add-to-cart, .buy-now, .back-to-shop-btn,
  .load-more, .load-more-btn, #load-more-btn, .login-box button, .login-button, .submit-btn,
  .newsletter-input button, .fallback-add, .fallback-favorite, .demo-profile-btn):not(:disabled):hover {
  transform: translateY(-1px) !important;
  box-shadow: 0 8px 20px rgba(20, 28, 38, .16);
}
:where(button, input, select, textarea):disabled { cursor: not-allowed; opacity: .55; }
:where(button, [role="button"]):not(:disabled):active { transform: scale(.98) !important; }
button, [role="button"], a { -webkit-tap-highlight-color: transparent; }
button, [role="button"] { touch-action: manipulation; }

:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 3px solid color-mix(in srgb, var(--apex-accent) 70%, white);
  outline-offset: 3px;
}

:where(button, .card, .hero-btn, .checkout-btn, .view-order-btn, .login-box) {
  transition-duration: 180ms !important;
  transition-timing-function: var(--apex-ease) !important;
}

.skip-link {
  position: fixed;
  z-index: 5000;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  color: #fff;
  background: #111;
  border-radius: var(--apex-radius-sm);
  transform: translateY(-160%);
  transition: transform 160ms var(--apex-ease);
}
.skip-link:focus { transform: translateY(0); }

.apex-toast {
  position: fixed;
  z-index: 5000;
  right: 20px;
  bottom: 20px;
  max-width: min(380px, calc(100vw - 32px));
  padding: 13px 16px;
  color: #fff;
  background: #202428;
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,.24);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 180ms var(--apex-ease), transform 180ms var(--apex-ease);
}
.apex-toast.is-visible { opacity: 1; transform: translateY(0); }
.apex-toast[data-kind="error"] { background: var(--apex-danger); }
.apex-toast[data-kind="success"] { background: var(--apex-success); }

.navbar { z-index: 1000; width: 100%; max-width: 100vw; min-height: 64px; font-family: var(--apex-font) !important; }
.navbar > .logo, .navbar > .content-container, .navbar > .user-actions-container { min-width: 0; }
.navbar .nav-link { position: relative; min-height: 44px; display: inline-flex; align-items: center; font-size: 15px !important; font-weight: 600; letter-spacing: .005em; }
.navbar .nav-link::after { content: ""; position: absolute; right: 0; bottom: 5px; left: 0; height: 2px; background: currentColor; border-radius: 99px; opacity: 0; transform: scaleX(.5); transition: opacity 160ms ease, transform 160ms var(--apex-ease); }
.navbar .nav-link:hover::after, .navbar .nav-link.is-current::after { opacity: 1; transform: scaleX(1); }
.cart-icon, .search-icon, .hamburger, .user-actions-container .login { min-width: 44px; min-height: 44px; }
.cart-icon, .search-icon, .hamburger, .user-actions-container .login { display: inline-flex; align-items: center; justify-content: center; }
.search-icon, .cart-icon { background-image: none !important; background-color: transparent !important; }
.navbar .search-container { position: relative; width: min(320px, 32vw); min-width: 160px; min-height: 44px; display: flex; align-items: center; }
.navbar .search-icon { position: absolute !important; z-index: 2; top: 50% !important; left: 0 !important; width: 36px !important; min-width: 36px; height: 44px !important; min-height: 44px; color: #fff; transform: translateY(-50%) !important; }
body:has(.hero-title) .navbar .search-icon { color: #111; }
.navbar .search-bar { display: block !important; width: 100% !important; min-height: 44px !important; padding: 8px 12px 8px 38px !important; background: transparent !important; border: 0 !important; border-bottom: 1px solid currentColor !important; border-radius: 0 !important; box-shadow: none !important; }
.navbar .search-bar:focus { border-bottom-color: var(--apex-accent) !important; }
.navbar .search-container::after { content: ""; position: absolute; right: 0; bottom: 0; left: 0; height: 2px; background: var(--apex-accent); transform: scaleX(0); transform-origin: center; transition: transform 180ms var(--apex-ease); pointer-events: none; }
.navbar .search-container:focus-within::after { transform: scaleX(1); }
.navbar .cart-icon { position: relative; color: #fff; }
body:has(.hero-title) .navbar .cart-icon { color: #111; }
.search-icon::before, .cart-icon::before { content: ""; width: 21px; height: 21px; display: block; background: currentColor; }
.search-icon::before { -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='black' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-4-4'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='black' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-4-4'/%3E%3C/svg%3E") center / contain no-repeat; }
.cart-icon::before { -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='black' stroke-width='2'%3E%3Cpath d='M3 4h2l2.1 10.2a2 2 0 0 0 2 1.6h7.8a2 2 0 0 0 2-1.6L20 7H6'/%3E%3Ccircle cx='10' cy='20' r='1'/%3E%3Ccircle cx='17' cy='20' r='1'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='black' stroke-width='2'%3E%3Cpath d='M3 4h2l2.1 10.2a2 2 0 0 0 2 1.6h7.8a2 2 0 0 0 2-1.6L20 7H6'/%3E%3Ccircle cx='10' cy='20' r='1'/%3E%3Ccircle cx='17' cy='20' r='1'/%3E%3C/svg%3E") center / contain no-repeat; }
.cart-icon:hover, .search-icon:hover, .user-actions-container .login:hover { transform: none !important; opacity: .78; }
.user-actions-container .login img { width: 21px !important; height: 21px !important; object-fit: contain; }
.hamburger { width: 44px !important; flex: 0 0 44px !important; padding: 10px !important; }
.hamburger { display: none; }
.search-results-dropdown { max-width: min(700px, calc(100vw - 24px)); }
.search-results-dropdown, .dropdown-menu, .dropdown-content { border: 1px solid var(--apex-border); border-radius: var(--apex-radius-md) !important; box-shadow: var(--apex-shadow) !important; overflow: hidden; }
.search-result-item, .dropdown-item, .share-menu-item { min-height: 44px; transition: background-color 140ms ease; }
.footer a { min-height: 30px; display: inline-flex; align-items: center; }
.footer, .newsletter-footer { font-family: var(--apex-font) !important; }
.footer { line-height: 1.55; }
.footer-links { gap: 8px; }
.social-icons { display: flex; align-items: center; gap: 8px !important; }
.social-icons :where(a, .facebook, .instagram, .youtube) { width: 36px !important; height: 36px !important; min-height: 36px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background-size: 20px 20px !important; background-position: center !important; background-repeat: no-repeat !important; transition: background-color 160ms ease, transform 160ms var(--apex-ease); }
.social-icons :where(a, .facebook, .instagram, .youtube):hover { transform: translateY(-2px); background-color: rgba(255,255,255,.1); }
.newsletter-input { max-width: 100%; }
.newsletter-input { display: flex; align-items: stretch; gap: 8px; }
.newsletter-input input { min-width: 0; flex: 1; }

/* Cards and content surfaces */
:where(.card, .login-box, .shipping-option, .order-summary, .cart-item, .profile-card, .fallback-image-wrap) {
  border-radius: var(--apex-radius-md) !important;
}
:where(.card, .shipping-option, .cart-item) { transition: transform 180ms var(--apex-ease), box-shadow 180ms var(--apex-ease), border-color 180ms ease !important; }
:where(.card, .shipping-option):hover { transform: translateY(-2px); box-shadow: var(--apex-shadow-hover); }
.card .product-image { display: block; width: 100%; object-fit: contain; }
.card .product-image, .card img { transition: transform 320ms var(--apex-ease) !important; }
.card:hover .product-image, .card:hover img { transform: scale(1.025); }
.card h3 { margin-block: 12px 6px !important; line-height: 1.35 !important; }
.card p { margin-block: 0 8px; }
.no-results, .empty-checkout-notice, .empty-cart, .error-message, .prototype-notice { border-radius: 8px !important; line-height: 1.5; }

/* Home and informational pages */
.hero-title { font-size: clamp(2.75rem, 6vw, 4rem) !important; line-height: 1.02 !important; letter-spacing: -.05em !important; }
.hero-section h1, .hero h1, .header h1 { line-height: 1.08 !important; }
.about-container, .main-content, .contact-container { width: min(var(--apex-container), calc(100% - 40px)); margin-inline: auto; }
.about-description, .description, .fallback-description { color: var(--apex-muted); max-width: 68ch; }
.dropdown-section { border-color: var(--apex-border) !important; }
.dropdown-section > :first-child { min-height: 56px; }

/* Catalog */
body:has(#product-grid) { background: var(--apex-bg) !important; }
body:has(#product-grid) .hero { padding-block: clamp(40px, 6vw, 72px) !important; }
body:has(#product-grid) .hero h1 { font-size: clamp(2.25rem, 5vw, 3rem) !important; }
body:has(#product-grid) main { width: min(1280px, calc(100% - 40px)); margin-inline: auto; }
body:has(#product-grid) .filters h2 { font-size: 1.125rem !important; }
body:has(#product-grid) .filters fieldset { border: 0; border-top: 1px solid var(--apex-border); }
body:has(#product-grid) .filters label { min-height: 40px; display: flex; align-items: center; gap: 9px; }
body:has(#product-grid) .card { padding: 16px !important; overflow: hidden; border: 1px solid rgba(216,221,227,.8) !important; box-shadow: 0 4px 16px rgba(20,28,38,.05) !important; }
body:has(#product-grid) .card:hover { box-shadow: var(--apex-shadow-hover) !important; }

/* Product detail */
.product-details h1 { font-size: clamp(2rem, 4vw, 2.75rem) !important; }
.product-details .description { line-height: 1.65 !important; }
.product-details .actions { gap: 12px !important; }
.product-details .actions :where(button, a > button) { min-height: 50px !important; border-radius: 8px !important; }
.quantity-box { min-height: 46px; border-radius: 8px !important; overflow: hidden; }
.quantity-box :where(button, input) { min-width: 42px; min-height: 42px !important; }
.icon-btn, #favorite-icon, #share-icon { width: 44px !important; height: 44px !important; min-width: 44px; min-height: 44px; padding: 10px !important; border-radius: 50% !important; }
.icon-btn img, #favorite-icon img, #share-icon img { width: 22px !important; height: 22px !important; object-fit: contain; }
.shipping-info, .installment-info, .specs { line-height: 1.6; }

/* Account, forms, checkout */
.login-box { padding: clamp(24px, 5vw, 40px) !important; box-shadow: var(--apex-shadow); }
.login-box > h1 { line-height: 1.08 !important; }
.demo-profile-btn { width: 100%; margin-bottom: 20px; color: #fff; background: #111; border: 1px solid #111; }
.profile-avatar { position: relative; display: grid; place-items: center; overflow: hidden; background-color: #e3e7ec !important; background-image: none !important; }
.profile-avatar::before { content: ""; width: 52%; height: 52%; background: #727983; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='8' r='4'/%3E%3Cpath d='M4 21a8 8 0 0 1 16 0z'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='8' r='4'/%3E%3Cpath d='M4 21a8 8 0 0 1 16 0z'/%3E%3C/svg%3E") center / contain no-repeat; }
.profile-avatar[style*="background-image"]::before { display: none; }
.checkout-main { padding-bottom: clamp(48px, 8vw, 96px); }
.checkout-left h1, .profile-main-content h1 { line-height: 1.12 !important; letter-spacing: -.025em; }
.shipping-option { border: 1px solid var(--apex-border) !important; padding: 16px !important; }
.shipping-option.selected { border-color: var(--apex-accent) !important; box-shadow: 0 0 0 3px rgba(36,87,230,.1); }
.checkout-steps a { font-size: 14px !important; font-weight: 600; }

/* Motion stays subtle and never blocks interaction. */
body.apex-ui-ready main, body.apex-ui-ready .hero-section, body.apex-ui-ready .hero,
body.apex-ui-ready .checkout-main, body.apex-ui-ready .fallback-product {
  animation: apex-enter 420ms var(--apex-ease) both;
}
@keyframes apex-enter { from { opacity: .01; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.apex-reveal { opacity: 0; transform: translateY(14px); transition: opacity 420ms ease, transform 420ms var(--apex-ease) !important; }
.apex-reveal.is-visible { opacity: 1; transform: none; }

.navbar .nav-link,
.user-actions-container .login,
.dropdown-menu,
.dropdown-menu a,
.hamburger span {
  transition-property: color, background-color, border-color, opacity, transform, box-shadow !important;
  transition-duration: 180ms !important;
  transition-timing-function: var(--apex-ease) !important;
}

/* Product detail pages were built around a 5000px image rail. */
.left-collage-container { width: min(52vw, 680px) !important; flex: 0 1 680px; min-width: 0; }
.left-collage-container > div { width: 100% !important; background-size: contain !important; background-color: #fff; }
.product-details { flex: 1 1 420px; min-width: 0; }
.product-details .actions button { min-height: 46px; }

/* Checkout pages share these class names. */
.checkout-main { width: min(1320px, calc(100% - 40px)); margin-inline: auto !important; gap: clamp(28px, 5vw, 72px); }
.checkout-left, .checkout-right { min-width: 0; margin-right: 0 !important; }
.checkout-input, .checkout-select, .payment-input { min-height: 48px; border-radius: var(--apex-radius-sm) !important; }
.checkout-btn { min-height: 50px; border-radius: var(--apex-radius-sm) !important; }
.field-error { color: var(--apex-danger); font-size: .9rem; margin: 4px 0 0; }
.item-image img { width: 100%; height: 100%; object-fit: contain; }
.login-box > h1 { margin: 0 0 8px; font-size: clamp(1.8rem, 5vw, 2.4rem); }
.profile-main-content h1 { font-size: 2rem; margin-top: 0; }

@media (max-width: 900px) {
  .navbar { padding-inline: 12px !important; }
  .hamburger { display: inline-flex; flex-direction: column; margin-left: 0 !important; }
  .user-actions-container { margin-right: 0 !important; gap: 8px !important; }
  .user-actions-container .login { margin-right: 0 !important; gap: 6px !important; }
  .navbar .content-container { display: flex !important; visibility: hidden; width: 100vw !important; max-height: calc(100vh - 64px); overflow-y: auto; opacity: 0; transform: translateY(-10px); pointer-events: none; transition: opacity 180ms ease, transform 180ms var(--apex-ease), visibility 180ms ease !important; }
  .navbar .content-container.active { visibility: visible; opacity: 1; transform: none; pointer-events: auto; box-shadow: var(--apex-shadow); }
  .navbar .content-container .search-container { width: min(92%, 520px); }
  .navbar .content-container .search-bar { width: 100% !important; }
  .dropdown-menu { right: 12px !important; }

  .hero-section { padding-inline: 20px !important; }
  .hero-title { font-size: clamp(2.5rem, 12vw, 4rem) !important; line-height: 1.05; }
  .sale-banner { min-height: 300px !important; background-size: cover !important; }
  .newsletter-footer { margin-left: 0 !important; margin-top: 60px !important; padding: 32px 20px !important; }
  .footer { padding: 28px 20px !important; }

  /* Catalog: filters become a compact horizontal rail above a two-column grid. */
  body:has(#product-grid) main { padding: 28px 16px !important; }
  body:has(#product-grid) main .content { display: block !important; }
  body:has(#product-grid) .filters { width: 100% !important; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 0 0 24px !important; }
  body:has(#product-grid) .filters h2 { grid-column: 1 / -1; margin: 0; }
  body:has(#product-grid) .filters fieldset { min-width: 0; padding: 10px; }
  body:has(#product-grid) .filters label { padding: 7px 4px !important; }
  body:has(#product-grid) .products { width: 100% !important; min-width: 0; }
  body:has(#product-grid) .product-header { gap: 12px; align-items: center; flex-wrap: wrap; }
  body:has(#product-grid) .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 12px !important; }
  body:has(#product-grid) .card { min-width: 0 !important; width: 100% !important; padding: 12px !important; }
  body:has(#product-grid) .card .product-image { height: 170px !important; object-fit: contain; }
  body:has(#product-grid) .card h3 { font-size: 1rem !important; overflow-wrap: anywhere; }

  /* Existing full product pages. */
  body:has(.left-collage-container) > div[style*="max-width: 1400px"] { flex-direction: column !important; padding: 92px 16px 20px !important; gap: 24px !important; }
  .left-collage-container { width: 100% !important; flex: none; margin: 0 !important; }
  .left-collage-container > div { height: min(92vw, 520px) !important; }
  .product-details { width: 100%; margin: 0 !important; padding: 0 !important; gap: 18px !important; }
  .product-details h1 { font-size: clamp(1.8rem, 8vw, 2.5rem) !important; flex-wrap: wrap; }
  .product-details .price { flex-direction: column; align-items: flex-start; }
  .product-details .actions { width: 100%; }
  .product-details .actions > button, .product-details .actions > a { width: 100%; }
  .product-details .actions > a > button { width: 100%; }

  .checkout-main { width: calc(100% - 32px); flex-direction: column !important; padding-top: 32px !important; }
  .checkout-left, .checkout-right { width: 100% !important; }
  .checkout-form-row { flex-wrap: wrap; }
  .checkout-form-row > * { flex: 1 1 150px !important; min-width: 0; }
  .checkout-steps { overflow-x: auto; padding-bottom: 4px; }
  .checkout-steps a { white-space: nowrap; padding-inline: 6px !important; }
}

@media (max-width: 520px) {
  body:has(#product-grid) .hero { padding: 28px 20px !important; }
  body:has(#product-grid) .filters { grid-template-columns: repeat(3, minmax(168px, 1fr)); overflow-x: auto; padding-bottom: 12px; scroll-snap-type: x proximity; }
  body:has(#product-grid) .filters h2 { position: sticky; left: 0; grid-column: 1 / -1; }
  body:has(#product-grid) .filters fieldset { scroll-snap-align: start; }
  body:has(#product-grid) .product-grid { grid-template-columns: 1fr 1fr !important; }
  body:has(#product-grid) .card .product-image { height: 140px !important; }
  .apex-toast { right: 16px; bottom: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  body, body.apex-page-exit { opacity: 1 !important; transform: none !important; }
  .apex-reveal { opacity: 1 !important; transform: none !important; }
}
